215 Commits

Author SHA1 Message Date
22ed7e23da Add DB Indexes for future local Development deployments
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-25 20:51:57 +01:00
a87cc94700 Pot fix for WinconditionBasePercent
All checks were successful
SteamWarCI Build successful
2025-12-23 12:27:48 +01:00
31dac93698 Remove UnrankCommand
All checks were successful
SteamWarCI Build successful
2025-12-23 10:40:53 +01:00
1f568f3d8b Remove UnrankCommand
Some checks failed
SteamWarCI Build failed
2025-12-22 21:25:40 +01:00
b8b8dd1ba0 Update UserPerm.kt
All checks were successful
SteamWarCI Build successful
2025-12-21 13:25:30 +01:00
99f864d889 Hotfix SteamwarUser and ServerStarter
All checks were successful
SteamWarCI Build successful
2025-12-21 12:27:55 +01:00
711a21b634 Merge pull request 'Remove SchemElo and UserElo' (#256) from RemoveElo into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #256
2025-12-21 12:04:27 +01:00
9a85e8b442 Merge branch 'main' into RemoveElo
All checks were successful
SteamWarCI Build successful
2025-12-21 12:03:33 +01:00
8358203cd4 Fix kits frfrfrfrfrfr
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-20 22:15:30 +01:00
6a619c2fd1 Fix kits frfrfrfrfr?
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-20 22:12:48 +01:00
d348e4a480 Fix kits frfrfrfr?
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-20 22:10:25 +01:00
1269e4d971 Fix kits frfrfr
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-20 22:03:09 +01:00
feac17d732 Fix kits frfr
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-20 21:58:44 +01:00
975b2bb8e6 Fix Kits and Maybe? Locale
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-20 21:35:34 +01:00
a1add4f997 Remove SchemElo and UserElo
All checks were successful
SteamWarCI Build successful
2025-12-20 21:28:00 +01:00
b517fe3ad0 Remove SchemElo and UserElo
All checks were successful
SteamWarCI Build successful
2025-12-20 21:26:42 +01:00
ac5dda58a1 Remove SchemElo and UserElo
All checks were successful
SteamWarCI Build successful
2025-12-20 21:19:20 +01:00
9efe625603 Pot fix for too many open files
All checks were successful
SteamWarCI Build successful
2025-12-20 13:14:35 +01:00
146ed598c8 Improve message on non ManualCheck submitted schematics
All checks were successful
SteamWarCI Build successful
2025-12-20 12:20:36 +01:00
50e86fbf89 Add 1.19 impl for SteamwarGameProfileRepository
All checks were successful
SteamWarCI Build successful
2025-12-20 11:53:28 +01:00
7216806a1c Fix SWPlayer on 1.15
All checks were successful
SteamWarCI Build successful
2025-12-20 11:45:36 +01:00
6cda79f7e1 Fix AbstractLinker
All checks were successful
SteamWarCI Build successful
2025-12-20 11:41:36 +01:00
87cc43a348 Fix FAWE stuff in 1.15
All checks were successful
SteamWarCI Build successful
2025-12-20 11:35:08 +01:00
f9509c19d1 Trigger rebuild
All checks were successful
SteamWarCI Build successful
2025-12-19 21:20:32 +01:00
e7bd5a9e74 Fix translation
All checks were successful
SteamWarCI Build successful
2025-12-19 13:37:29 +01:00
aa74e0b887 Fix SQLWrapperImpl
All checks were successful
SteamWarCI Build successful
2025-12-18 18:18:56 +01:00
fe8d37c966 Maybe? Fix kits
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-17 23:29:00 +01:00
ccb79737db Fix Core.setServerName
All checks were successful
SteamWarCI Build successful
2025-12-17 21:33:19 +01:00
1eea792e23 Synchronize team cache access to ensure thread safety
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-17 21:29:14 +01:00
19c6ad0965 Merge pull request 'Add WorldIdentifier' (#249) from SpigotCore/WorldIdentifier into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #249
Reviewed-by: D4rkr34lm <dark@steamwar.de>
2025-12-17 21:28:41 +01:00
2c5306bfd1 Merge pull request 'Add WaterDestroy feature with command and listener' (#248) from waterblocker into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #248
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-12-17 21:13:45 +01:00
1982b5e42c Update WaterDestroyCommand
All checks were successful
SteamWarCI Build successful
2025-12-17 21:13:31 +01:00
3ad4081add Merge pull request 'Add AuditLog to Backend' (#244) from Backend/auditlog into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #244
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-12-17 21:03:04 +01:00
33a7961979 Add WaterDestroy feature with command and listener
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-17 20:49:23 +01:00
4e994813eb Add WorldIdentifier
All checks were successful
SteamWarCI Build successful
2025-12-17 20:31:21 +01:00
367a72141a Undo Improve TNTDistributor
All checks were successful
SteamWarCI Build successful
2025-12-17 11:32:11 +01:00
c29788f1eb Improve TNTDistributor
All checks were successful
SteamWarCI Build successful
2025-12-17 11:15:47 +01:00
9d32a331ca Improve TNTDistributor
All checks were successful
SteamWarCI Build successful
2025-12-16 14:50:56 +01:00
c55494aeba Revert WinconditionPercent for QuickGear
All checks were successful
SteamWarCI Build successful
2025-12-16 14:15:04 +01:00
61dcee6f8e Improve WinconditionPercent for QuickGear
All checks were successful
SteamWarCI Build successful
2025-12-16 13:20:55 +01:00
8b2b7e011a Add WaterDestroy feature with command and listener
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-11 00:34:29 +01:00
8640d43d4b Merge pull request 'BauSystem/ImproveRegionData' (#234) from BauSystem/ImproveRegionData into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #234
Reviewed-by: D4rkr34lm <dark@steamwar.de>
2025-12-03 13:26:10 +01:00
fbdb0cfaf1 Merge pull request 'Fix replay in 1.21 -> RPlayer needs fixing before' (#199) from FightSystem/ReplayFix21 into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #199
2025-12-03 10:05:03 +01:00
9305ab5f91 Merge pull request 'Refactor Authlib integration and adjust entity handling for 1.21 compatibility' (#106) from 1.21.1/rplayer-fix into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #106
2025-12-03 10:04:50 +01:00
34ade1de19 Merge branch 'main' into 1.21.1/rplayer-fix
All checks were successful
SteamWarCI Build successful
2025-12-03 09:59:33 +01:00
87d0df8067 Merge pull request 'Remove Poll-System' (#245) from Refactor/remove-poll-system into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #245
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-12-03 09:56:28 +01:00
09d2ed5384 Include permissions in /me route response
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-02 22:24:24 +01:00
b576c36c2d Reapply "Improve Performance"
This reverts commit 0a7a753c48.

Signed-off-by: Chaoscaot <max@maxsp.de>

# Conflicts:
#	WebsiteBackend/src/de/steamwar/routes/AuditLog.kt
2025-12-02 21:59:34 +01:00
2f8491c3f6 Fix Team Creation
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-02 21:35:14 +01:00
a089d42d9a Improve Performance
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-02 21:34:35 +01:00
0a7a753c48 Revert "Improve Performance"
All checks were successful
SteamWarCI Build successful
This reverts commit 86bfde90b8.
2025-12-02 21:14:00 +01:00
86bfde90b8 Improve Performance
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-02 21:13:43 +01:00
4df92f7e5f Remove Poll-System
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-02 20:43:37 +01:00
9a78b99a75 Remove Poll-System
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-02 16:39:16 +01:00
1de1bf6571 Fix Leaderboard ID handling
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-02 00:47:54 +01:00
7c5a927d0f Add AuditLog to Backend
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-01 18:36:36 +01:00
dfb71594b9 Fix Leaderboard
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-01 14:49:23 +01:00
f535e056c7 Merge remote-tracking branch 'origin/main'
All checks were successful
SteamWarCI Build successful
# Conflicts:
#	LobbySystem/src/de/steamwar/lobby/special/advent/Present.java
2025-12-01 12:23:34 +01:00
e67e340707 Fix Advent Calendar Present parent ID handling
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-01 12:23:04 +01:00
a594a163f7 Fix NodeMember for Present since the setter for parent apparently does not work
All checks were successful
SteamWarCI Build successful
2025-12-01 09:14:09 +01:00
1c0146a02d Fix SchematicNode.parentNode get
All checks were successful
SteamWarCI Build successful
2025-12-01 09:01:00 +01:00
d3fecf763c Fix Lobby
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-12-01 00:21:12 +01:00
3944c011b0 Fix Lobby
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-30 21:22:21 +01:00
1f4a77e8b4 Fix Lobby
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-30 20:59:03 +01:00
4d40e52ea6 Merge pull request 'Refactor leaderboard management' (#166) from Lobby/refactor-leaderboard into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #166
2025-11-30 20:56:10 +01:00
698e411944 Fix SQLWrapperImpl.getMaterialWithGreaterBlastResistance for 1.12 or lower
All checks were successful
SteamWarCI Build successful
2025-11-30 20:18:58 +01:00
0fd7aab86c Fix FightStatistics
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-30 17:27:27 +01:00
624fe98c47 Add some Clear tasks
All checks were successful
SteamWarCI Build successful
2025-11-30 16:12:52 +01:00
ede7df82f3 Fix FightStatistics
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-30 16:09:40 +01:00
3970f21999 Yeet Lunar
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-30 15:04:56 +01:00
6f248b78b8 Maybe fix Techhider
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-30 14:36:44 +01:00
6f4ec64ef7 Fix EventRelations
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-29 18:51:18 +01:00
bfc835b0dc Hotfix steamwar.java.gradle
Some checks failed
SteamWarCI Build failed
2025-11-29 18:27:08 +01:00
2dfad9e55c Hotfix FightStatistics
All checks were successful
SteamWarCI Build successful
2025-11-29 17:57:25 +01:00
00f5481630 Fix tnt only listeners detecting WindCharges
All checks were successful
SteamWarCI Build successful
2025-11-28 12:15:34 +01:00
2424bd430d Fix TNTListener action bar message showing for WindCharge
All checks were successful
SteamWarCI Build successful
Remove OtherTNTListener and merge into TNTListener
2025-11-28 12:13:06 +01:00
eafb469eca Remove FlagStorage and merge into RegionData
All checks were successful
SteamWarCI Build successful
2025-11-28 12:04:36 +01:00
14bd38f471 Improve FlagStorage 2025-11-28 11:59:14 +01:00
c107b741c0 Merge pull request 'Add UserPerm.PUNISHMENTS' (#233) from CommonCore/UserPerm-Punishments into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #233
Reviewed-by: D4rkr34lm <dark@steamwar.de>
2025-11-28 10:10:13 +01:00
febf2c283d Fix REntity.bowDrawnWatcher
All checks were successful
SteamWarCI Build successful
2025-11-28 09:56:18 +01:00
5f53ebf5b3 Fix REntity.getEquipmentPacket
All checks were successful
SteamWarCI Build successful
Fix FightSchematic.pasteTeamName
2025-11-28 09:27:04 +01:00
f6f7b0dced Add UserPerm.PUNISHMENTS
All checks were successful
SteamWarCI Build successful
Improve PunishmentType needed permissions
2025-11-28 08:02:28 +01:00
5bdbf5dff4 Fix schematic commands for SteamWarLuaPlugin
All checks were successful
SteamWarCI Build successful
Closes: #228
2025-11-25 22:10:14 +01:00
1ae445319a Improve Present.click
All checks were successful
SteamWarCI Build successful
2025-11-25 22:04:44 +01:00
a426a563db Fix SpectatorListener running the techhider all the time
All checks were successful
SteamWarCI Build successful
2025-11-25 21:40:23 +01:00
1098c5617f Redirect to Issue tracker
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-25 21:11:47 +01:00
c2bca83735 Fix Tab Complete
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-25 18:37:58 +01:00
cfa1b5d0cd Hotfix XrayCommand bugging players back
All checks were successful
SteamWarCI Build successful
2025-11-25 18:26:48 +01:00
500f8978e5 Fix Schematic List
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-25 18:12:30 +01:00
395e4a2167 Hotfix windcharges destroying blocks
All checks were successful
SteamWarCI Build successful
2025-11-25 17:37:23 +01:00
1d65f2349e Merge pull request 'Add SWPlayer for per player storage and without Memory Leaks' (#188) from SpigotCore/SWPlayer into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #188
Reviewed-by: D4rkr34lm <dark@steamwar.de>
2025-11-25 17:00:24 +01:00
c0a4413b7a Merge branch 'main' into SpigotCore/SWPlayer
All checks were successful
SteamWarCI Build successful
2025-11-25 16:59:28 +01:00
6b71ac28fe Merge pull request 'bausystem/TLS' (#184) from bausystem/TLS into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #184
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-11-25 16:58:21 +01:00
880c6f5066 Remove TypeGenerator
All checks were successful
SteamWarCI Build successful
2025-11-25 16:37:19 +01:00
e284f8f08c Fix PR
All checks were successful
SteamWarCI Build successful
2025-11-25 12:57:28 +00:00
8a5c5794c0 Replace - with : in translation
All checks were successful
SteamWarCI Build successful
2025-11-25 12:54:10 +00:00
a9e278ccd9 Fix spelling (s.a. PR)
All checks were successful
SteamWarCI Build successful
2025-11-25 12:43:38 +00:00
c9bfcc5c0c Fix not ignoring deleted teams
All checks were successful
SteamWarCI Build successful
Closes: #226
2025-11-24 20:55:58 +01:00
e343d044ff Refactor Discord authentication endpoint for improved error handling and structure
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-14 23:56:04 +01:00
f923a007a7 Revert "Add EventCache for efficient retrieval of event groups and teams"
All checks were successful
SteamWarCI Build successful
This reverts commit 8b4f864f99.

Revert "Refactor EventFights and Fight classes to improve player initialization and retrieval"

This reverts commit 8d705e7a84.

Revert "Refactor EventFights and Fight classes to improve player initialization and retrieval"

This reverts commit 78352a3e67.
2025-11-14 23:25:05 +01:00
78352a3e67 Refactor EventFights and Fight classes to improve player initialization and retrieval
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-14 23:18:38 +01:00
8d705e7a84 Refactor EventFights and Fight classes to improve player initialization and retrieval
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-14 23:14:13 +01:00
8b4f864f99 Add EventCache for efficient retrieval of event groups and teams
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-14 22:47:27 +01:00
f9cb712b07 Merge pull request 'Simplify Tokens and add Discord OAuth' (#220) from authv3 into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #220
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-11-14 22:43:04 +01:00
b3b13d2950 Move Chatter.disconnect call to ensure proper execution after IP ban check.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-13 23:01:37 +01:00
08ad5edf76 Simplify Tokens and add Discord OAuth
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-13 14:31:05 +01:00
afcf3a1906 Fix Schematic Move
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-12 22:52:51 +01:00
33efd26d48 Fix build.gradle.kts
All checks were successful
SteamWarCI Build successful
2025-11-12 07:43:36 +01:00
2a96b3c26a Hotfix AutoCheckerItems for 1.19
Some checks failed
SteamWarCI Build failed
2025-11-11 22:06:44 +01:00
3de4b3871d Hotfix ModifyPart
All checks were successful
SteamWarCI Build successful
2025-11-11 21:42:38 +01:00
67223be80e Trigger rebuild
All checks were successful
SteamWarCI Build successful
2025-11-11 21:28:13 +01:00
81715736ae Refactor TeamTable to introduce default values for color and deleted, and make address column nullable.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-11 18:44:46 +01:00
36691c6fea Refactor TeamTable to introduce default values for color and deleted, and make address column nullable.
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-11 18:44:25 +01:00
d0c1413ea6 Refactor Leaderboard to Kotlin, leveraging Exposed library for database operations, and update LeaderboardManager for compatibility.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-11 17:39:39 +01:00
58618a3991 Fix FightTeam.removeLeader
All checks were successful
SteamWarCI Build successful
Fix FightTeam.setLeader
2025-11-11 17:36:19 +01:00
5f7c5f0a18 Merge remote-tracking branch 'origin/Lobby/refactor-leaderboard' into Lobby/refactor-leaderboard
# Conflicts:
#	LobbySystem/src/de/steamwar/lobby/util/LeaderboardManager.java
2025-11-11 17:28:03 +01:00
9e9f405e30 Refactor leaderboard management: replace UserConfig-based implementation with new Leaderboard SQL class, update related classes to use LeaderboardManager, and fix query/logic for best time retrieval. 2025-11-11 17:27:24 +01:00
e6848b27a0 Refactor FightTable to use WinningTeam enum for win column and adjust related logic.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-11 17:25:38 +01:00
93d0011b46 Update openMaterialSelector to exclude non-item materials in UtilGui.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-11 17:20:33 +01:00
fd4d15ac5a Fix replay in 1.21 -> RPlayer needs fixing before
All checks were successful
SteamWarCI Build successful
2025-11-11 17:13:35 +01:00
f56fedefe4 Fix Obsidian and Bedrock
All checks were successful
SteamWarCI Build successful
2025-11-11 17:07:56 +01:00
167bb4e266 Fix YMLWrapper
All checks were successful
SteamWarCI Build successful
2025-11-11 17:05:46 +01:00
f6a9ce184b Closes: #214
All checks were successful
SteamWarCI Build successful
Closes: #215
2025-11-11 16:40:26 +01:00
d5708c110c Refactor NodeDataTable to use default current timestamp for createdAt and ensure schemData reads blob as bytes.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-11 00:18:16 +01:00
f23c1215b7 Refactor NodeDataTable to use insert instead of insertIgnore and add blobParam import.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-11 00:15:19 +01:00
cfcaf1569c Add GameModeConfig.Schematic.MaxBlastResistance
All checks were successful
SteamWarCI Build successful
2025-11-10 21:39:35 +01:00
dc56b67ff6 Sort fights by start time in descending order and refactor saveFromStream method to use useDb block.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 14:18:13 +01:00
13c4a3ff8b Sort fights by start time in descending order and refactor saveFromStream method to use useDb block.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 12:27:02 +01:00
7e5a13989b Sort fights by start time in descending order and refactor saveFromStream method to use useDb block.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 12:24:51 +01:00
990a03ca6c Add Exposed library dependencies to WebsiteBackend build script.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 11:57:12 +01:00
4a608fe5b5 Fix SchematicType.fromDB
All checks were successful
SteamWarCI Build successful
2025-11-10 11:55:17 +01:00
5ca15aa117 Refactor PersonalKitTable to use explicit ID column initialization and update create method to utilize insert operation.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 11:50:39 +01:00
9b459bd12c Refactor PersonalKitTable to use explicit ID column initialization and update create method to utilize insert operation.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 11:40:34 +01:00
b20d37e252 Refactor PersonalKitTable to use explicit ID column initialization and update create method to utilize insert operation.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 11:40:20 +01:00
a8c98594a9 Fix GameModeConfig.Schematic.SubTypes
All checks were successful
SteamWarCI Build successful
2025-11-10 11:32:03 +01:00
1c076b5bbf Fix incorrect field references in BauweltMember methods.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 11:19:56 +01:00
133ddb39cc Add ID column initialization for BauweltMember
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 11:09:57 +01:00
ebb375d8d6 Improve messages
All checks were successful
SteamWarCI Build successful
2025-11-10 11:04:29 +01:00
8ada9a6335 Fix UserElo.getEloFromDb
All checks were successful
SteamWarCI Build successful
2025-11-10 11:01:31 +01:00
0760a5a08a Update build scripts: migrate to Spigot API, adjust JVM toolchains and Java version.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 09:42:24 +01:00
852ff95757 Update build scripts: migrate to Spigot API, adjust JVM toolchains and Java version.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 09:40:36 +01:00
5c7d388876 Remove unused SLF4J exclusion from shadowJar task.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 09:34:44 +01:00
4f92f8132d Remove unused SLF4J exclusion from shadowJar task.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 09:27:58 +01:00
56fb63f781 Add MySQL dependency to KotlinCore build script.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 09:17:37 +01:00
273efff87d Remove unused api-version field from plugin.yml.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 09:16:14 +01:00
0cac6f36c1 Remove unused api-version field from plugin.yml.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 09:09:44 +01:00
8680b9e6cf Change api dependencies to compileOnlyApi in build.gradle.kts and rename KitName column to Name in PersonalKitTable.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 09:02:23 +01:00
6c94efaf90 Improve TeamCommand.info
All checks were successful
SteamWarCI Build successful
2025-11-10 09:00:18 +01:00
f6261ad989 Improve output for DevCommand reloadmodes 2025-11-10 09:00:18 +01:00
614e989892 Rename IgnoreTable to IgnoredPlayers in IgnoreSystemTable for improved clarity.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-10 08:47:32 +01:00
84e1f605bd Merge pull request 'Exposed!' (#179) from exposed into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #179
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-11-10 08:42:59 +01:00
0ea5a62dbe Merge branch 'main' into exposed
All checks were successful
SteamWarCI Build successful
2025-11-10 08:40:42 +01:00
0eb6047139 Merge remote-tracking branch 'origin/exposed' into exposed
All checks were successful
SteamWarCI Build successful
2025-11-09 17:48:12 +01:00
fcebecf745 Add placement column to TeamTeilnahme table and corresponding property.
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-09 17:48:02 +01:00
dd14e9f518 Cleanup Session
All checks were successful
SteamWarCI Build successful
2025-11-09 17:30:21 +01:00
6c5239c8fc Optimize imports across SQL module: replace explicit class imports with wildcard imports, remove unused imports for cleaner structure.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-09 17:28:40 +01:00
fc71f47add Remove needsAdmin property from PunishmentType enum and refactor related declarations for cleaner structure.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-09 17:25:19 +01:00
5d36393643 Refactor EventRelation, EventGroup, and EventFight classes: ensure database operations are enclosed in useDb, add default values for group points, and override delete methods. Update Gradle build script to include lombok dependencies.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-08 22:44:22 +01:00
fa4d006dd3 Refactor Authlib integration and adjust entity handling for 1.21 compatibility
All checks were successful
SteamWarCI Build successful
2025-11-08 20:09:02 +01:00
ebc6f50261 Refactor Gradle build scripts: update source set exclusions, add java-library plugin, and remove redundant configurations in SQL module.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-08 13:52:27 +01:00
69cf219e39 Fix FlatteningWrapper21
All checks were successful
SteamWarCI Build successful
2025-11-07 22:47:05 +01:00
fb4e53165f Hotfix FixedFlagStorage.clear and FixedGlobalFlagStorage.clear
All checks were successful
SteamWarCI Build successful
2025-11-07 22:42:48 +01:00
415d783365 Hotfix SEND_COMMAND_FEEDBACK in 1.20+
All checks were successful
SteamWarCI Build successful
2025-11-07 22:17:30 +01:00
ee99708340 Hotfix (FA)WE Selection 1.20+
All checks were successful
SteamWarCI Build successful
2025-11-07 22:13:31 +01:00
c9d74fb656 Remove redundant SQL logger in useDb and extra newlines in SQLConfig.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-07 18:59:01 +01:00
e50e52950b Refactor Token and SteamwarUser classes: enhance owner property with memoized transformation, increase hash generation key size, and ensure database usage in useDb block.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-07 18:57:34 +01:00
aaccd4b095 Merge branch 'main' into SpigotCore/SWPlayer
All checks were successful
SteamWarCI Build successful
2025-11-07 15:41:56 +01:00
cac0ae3e13 Hotfix MaterialLazyInit for 1.21
All checks were successful
SteamWarCI Build successful
2025-11-07 15:41:48 +01:00
14045a3366 Update method name in Countingwand
All checks were successful
SteamWarCI Build successful
2025-11-07 15:30:18 +01:00
f9b3dd34cf Trigger rebuild
All checks were successful
SteamWarCI Build successful
2025-11-07 15:25:20 +01:00
e5a61226ca Add newline at end of build.gradle.kts file for consistency.
All checks were successful
SteamWarCI Build successful
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-07 15:06:37 +01:00
cc3b93a8f6 Improve SelectAdjacent
All checks were successful
SteamWarCI Build successful
2025-11-07 14:54:57 +01:00
0c35ace5e2 Remove redundant Java installation paths in Gradle configuration.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-07 14:54:30 +01:00
23bcf14ca5 Update Gradle configuration to specify multiple Java installation paths for compatibility.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-07 14:53:07 +01:00
58460416c3 Improve WarpListener
All checks were successful
SteamWarCI Build successful
2025-11-07 14:49:10 +01:00
40ac7b2139 Improve NoClipCommand
All checks were successful
SteamWarCI Build successful
Improve SelectBauGuiItem
2025-11-07 14:43:52 +01:00
63a5fcff97 Add Kotlin plugin and configure build scripts for Kotlin compatibility, integrate exposed library dependencies, and enhance JVM settings.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-07 14:40:10 +01:00
b69adcd362 Improve MaterialCommand
All checks were successful
SteamWarCI Build successful
2025-11-07 14:34:30 +01:00
ceb8d2c6d4 Improve LaufbauUtils
All checks were successful
SteamWarCI Build successful
2025-11-07 14:21:05 +01:00
39b3cdb897 Introduce GDPRQuery command for GDPR data generation, refactor SQL statements, and improve null safety across modules.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-07 12:42:15 +01:00
26b4d8578a Improve ScriptRunner
All checks were successful
SteamWarCI Build successful
2025-11-07 09:43:11 +01:00
51411ceabe Improve ScriptRunner
All checks were successful
SteamWarCI Build successful
2025-11-07 09:34:28 +01:00
1ccc2c4b55 Improve Loader
All checks were successful
SteamWarCI Build successful
Improve ObserverTracer
2025-11-07 09:25:40 +01:00
941a1916b7 Improve Detonator
All checks were successful
SteamWarCI Build successful
2025-11-07 09:12:17 +01:00
3ccfe92afb Remove DC prefix for discord send messages to cleanup the chat
All checks were successful
SteamWarCI Build successful
2025-11-07 08:46:26 +01:00
c17b76851d Improve chat from discord
All checks were successful
SteamWarCI Build successful
2025-11-07 08:44:07 +01:00
f0e18bfc72 Improve CouncilChannel and StaticMessageChannel
All checks were successful
SteamWarCI Build successful
2025-11-07 08:39:42 +01:00
160f982955 Improve ChatListener for STC Chat
All checks were successful
SteamWarCI Build successful
Add debug output for DiscordChannel
Fix CouncilChannel
2025-11-07 08:34:19 +01:00
6b8f791497 Add SWPlayer for per player storage and without Memory Leaks
All checks were successful
SteamWarCI Build successful
2025-11-06 21:38:24 +01:00
6ac0143459 Remove outdated SQL-related Java classes (GDPRQuery, Field, SelectStatement, SqlTypeMapper, Statement) and update references across modules.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-06 11:30:01 +01:00
98ca9e852c Merge pull request 'Add version dependant impl of tps warp to fight system' (#187) from FightSystem/Add-version-dependent-impl-of-tps-warp into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #187
Reviewed-by: Chaoscaot <max@chaoscaot.de>
2025-11-06 09:50:24 +01:00
D4rkr34lm
17910ec8a4 Add version dependant impl
All checks were successful
SteamWarCI Build successful
2025-11-06 02:07:20 +01:00
56bc75763b Migrate Token class to Kotlin, remove outdated Java implementation, and refactor references across modules. Update timestamp fields to use CurrentTimestamp where applicable.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-05 21:44:52 +01:00
8272c73b48 Migrate SQL-related classes (Referee, SchemElo, Script, Session, SWException, TeamTeilnahme) to Kotlin and remove outdated Java implementations. Update references across modules.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-05 17:47:30 +01:00
9acfb32ae0 Refactor SQL classes: update GameModeConfig functions, improve null safety in SchematicNode and SchematicType, and adjust NodeMemberTable structure.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-05 17:04:01 +01:00
b2a4b05545 Merge branch 'main' into exposed
# Conflicts:
#	CommonCore/SQL/src/de/steamwar/sql/GameModeConfig.java
#	CommonCore/SQL/src/de/steamwar/sql/Punishment.java
2025-11-05 16:18:30 +01:00
acf9325179 Add Help messages and small refactor
All checks were successful
SteamWarCI Build successful
2025-11-04 21:02:57 +00:00
89e2df0eb2 Migrate Punishment and PollAnswer classes to Kotlin and remove outdated Java implementations. Update references across modules.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-04 21:17:53 +01:00
ca3a7a82be Add /tb default subcommand
All checks were successful
SteamWarCI Build successful
2025-11-04 15:52:41 +00:00
0e5a03e139 Added tls toggle 2025-11-04 15:18:29 +00:00
73da9179bf Migrate SQL-related classes (IgnoreSystem, Mod, NodeDownload, NodeMember) to Kotlin and remove old Java implementations. Update references across modules.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-02 19:28:14 +01:00
0fbbcdacea Migrate Fight, FightPlayer, and SchematicType classes to Kotlin and remove old Java implementations. Update references across modules.
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-11-01 13:52:26 +01:00
4e6933f2fd Remove Event-related SQL classes and update relevant references across modules
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-10-30 23:14:25 +01:00
eea1073892 Migrate Event class to Kotlin and update references across modules
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-10-29 23:17:17 +01:00
702aa1cfa6 Refactor CheckedSchematic and migrate to Kotlin
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-10-29 17:42:29 +01:00
6ea73f4890 Refactor NodeData
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-10-28 22:25:31 +01:00
14e82f36a5 Rename .java to .kt
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-10-28 22:25:31 +01:00
a8eaf3daa7 Fixes
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-10-28 21:31:57 +01:00
b51ea484e4 Refactor UserConfig
Some checks failed
SteamWarCI Build failed
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-10-28 20:38:02 +01:00
8bef19ed8b Rename .java to .kt
Signed-off-by: Chaoscaot <max@maxsp.de>
2025-10-28 20:38:02 +01:00
1aff7b30a6 Refactor SchematicNode
Some checks failed
SteamWarCI Build failed
2025-10-28 19:03:30 +01:00
c8ac984ad3 Rename .java to .kt 2025-10-28 19:03:30 +01:00
a462231bab Starting...
Some checks failed
SteamWarCI Build failed
2025-10-27 18:34:31 +01:00
e6bbb76a0b Rename .java to .kt 2025-10-27 18:34:30 +01:00
eb63381b83 Refactor leaderboard management: replace UserConfig-based implementation with new Leaderboard SQL class, update related classes to use LeaderboardManager, and fix query/logic for best time retrieval.
All checks were successful
SteamWarCI Build successful
2025-10-20 16:39:35 +02:00
356 changed files with 8265 additions and 8740 deletions

3
.gitignore vendored
View File

@@ -20,4 +20,5 @@ lib
/WebsiteBackend/data
/WebsiteBackend/logs
/WebsiteBackend/skins
/WebsiteBackend/config.json
/WebsiteBackend/config.json
/WebsiteBackend/sessions

View File

@@ -0,0 +1,46 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.utils;
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
import net.minecraft.server.level.ServerPlayer;
import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class PlayerMovementWrapper21 implements PlayerMovementWrapper {
@Override
public void setPosition(Player player, Object object) {
ServerboundMovePlayerPacket packetPlayInFlying = ((ServerboundMovePlayerPacket) object);
ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
if (packetPlayInFlying.hasPos) {
serverPlayer.setPosRaw(packetPlayInFlying.x, packetPlayInFlying.y, packetPlayInFlying.z);
}
if (packetPlayInFlying.hasRot) {
serverPlayer.setXRot(packetPlayInFlying.xRot);
serverPlayer.setYRot(packetPlayInFlying.yRot);
}
}
@Override
public Object convertToOut(Player player, Object object) {
return object;
}
}

View File

@@ -52,6 +52,9 @@ FLAG_ITEMS=Items
FLAG_NO_GRAVITY = No Gravity
FLAG_TESTBLOCK=Testblock
FLAG_CHANGED=Changed
FLAG_WATER_DESTROY=Water Destroy
FLAG_WATER_DESTROY_ALLOW=§coff
FLAG_WATER_DESTROY_DENY=§aon
FLAG_FIRE_ALLOW=§con
FLAG_FIRE_DENY=§aoff
FLAG_FREEZE_ACTIVE=§aon
@@ -140,6 +143,7 @@ BAU_INFO_ITEM_LORE_ITEMS=§7Items§8: §e{0}
BAU_INFO_ITEM_LORE_NO_GRAVITY = §7NoGravity§8: §e{0}
BAU_INFO_ITEM_LORE_TESTBLOCK=§7Testblock§8: §e{0}
BAU_INFO_ITEM_LORE_CHANGED=§7Changed§8: §e{0}
BAU_INFO_ITEM_LORE_WATER_DESTROY=§7Water Destroy§8: §e{0}
BAU_INFO_COMMAND_HELP=§8/§ebauinfo §8- §7Information regarding this build server
BAU_INFO_COMMAND_OWNER=§7Owner§8: §e{0}
BAU_INFO_COMMAND_MEMBER=§7{0} §8[§7{1}§8]§8: §e{2}
@@ -756,6 +760,9 @@ REGION_FIRE_DISABLED=§aFire damage activated in this region
REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze
REGION_FREEZE_ENABLED=§cRegion frozen
REGION_FREEZE_DISABLED=§aRegion thawed
REGION_WATER_HELP=§8/§ewaterdestroy §8- §7Toggle water damage
REGION_WATER_ENABLED=§aWater damage deactivated in this region
REGION_WATER_DISABLED=§cWater damage activated in this region
REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items
REGION_ITEMS_ENABLED=§aItems enabled in this region
REGION_ITEMS_DISABLED=§cItems disabled in this region
@@ -1030,6 +1037,7 @@ SCHEMATIC_GUI_ITEM=§eSchematics
# TNTListener
TLS_MESSAGE_79=§7TLS§8> §7Tick §e{0} §8- §7TNT §e{1}
TLS_MESSAGE_80=§7TLS§8> §7Tick §e{0} §8- §7TNT §e{1} §8(§e{2} §7with Fuse 80§8)
TLS_START_HELP=§8/§etls start §8: §7Start the TNT Listener
TLS_STOP_HELP=§8/§etls stop §8: §7Stop the TNT Listener
TLS_SCOREBOARD_ELEMENT=§eTLS§8: §aon
TLS_START_HELP=§8/§etls start §8- §7Start the TNT Listener
TLS_STOP_HELP=§8/§etls stop §8- §7Stop the TNT Listener
TLS_SCOREBOARD_ELEMENT=§eTLS§8: §aon
TLS_TOGGLE_HELP=§8/§etls§8: §7Toggle the TNT Listener

View File

@@ -54,6 +54,9 @@ FLAG_FREEZE_ACTIVE=§aan
FLAG_FREEZE_INACTIVE=§caus
FLAG_PROTECT_ACTIVE=§aan
FLAG_PROTECT_INACTIVE=§caus
FLAG_WATER_DESTROY=Wasserschaden
FLAG_WATER_DESTROY_ALLOW=§cerlaubt
FLAG_WATER_DESTROY_DENY=§aaus
FLAG_TNT_ALLOW=§aan
FLAG_TNT_DENY=§caus
FLAG_TNT_ONLY_TB=§7Kein §eBaurahmen
@@ -122,6 +125,7 @@ BAU_INFO_ITEM_NAME=§eBau-Management
BAU_INFO_ITEM_LORE_FIRE=§7Feuer§8: §e{0}
BAU_INFO_ITEM_LORE_COLOR=§7Farbe§8: §e{0}
BAU_INFO_ITEM_LORE_CHANGED=§7Verändert§8: §e{0}
BAU_INFO_ITEM_LORE_WATER_DESTROY=§7Wasserschaden§8: §e{0}
BAU_INFO_COMMAND_HELP=§8/§ebauinfo §8- §7Gibt Informationen über den Bau
BAU_INFO_COMMAND_OWNER=§7Besitzer§8: §e{0}
BAU_INFO_COMMAND_MEMBER=§7{0} §8[§7{1}§8]§8: §e{2}
@@ -704,6 +708,9 @@ REGION_PROTECT_FALSE_REGION=§cDu befindest dich derzeit in keiner (M)WG-Region
REGION_NO_GRAVITY_HELP = §8/§enogravity §8- §7Toggle NoGravity
REGION_NO_GRAVITY_ENABLED = §aNoGravity aktiviert in dieser Region
REGION_NO_GRAVITY_DISABLED = §cNoGravity deaktiviert in dieser Region
REGION_WATER_HELP=§8/§ewaterblock §8- §7Wasserschaden umschalten
REGION_WATER_ENABLED=§aWasserschaden deaktiviert
REGION_WATER_DISABLED=§cWasserschaden aktiviert
REGION_REGION_HELP_UNDO=§8/§eregion undo §8- §7Mache die letzten 20 /testblock oder /reset rückgängig
REGION_REGION_HELP_REDO=§8/§eregion redo §8- §7Wiederhole die letzten 20 §8/§7rg undo
REGION_REGION_HELP_RESTORE=§8/§eregion restore §8- §7Setzte die Region zurück, ohne das Gebaute zu löschen
@@ -961,6 +968,7 @@ TYPEREPLACE_HELP=§8//§etyreplace §8[§7type§8] §8[§7type§8] §8- §7Erset
# Schematics
SCHEMATIC_GUI_ITEM=§eSchematics
TLS_MESSAGE_80=§7TLS§8> §7Tick §e{0} §8- §7TNT §e{1} §8(§e{2} §7mit Fuse 80§8)
TLS_START_HELP=§8/§etls start §8: §7Starte den TNT Listener
TLS_STOP_HELP=§8/§etls stop §8: §7Stope den TNT Listener
TLS_SCOREBOARD_ELEMENT=§eTLS§8: §aan
TLS_START_HELP=§8/§etls start §8- §7Starte den TNT Listener
TLS_STOP_HELP=§8/§etls stop §8- §7Stope den TNT Listener
TLS_SCOREBOARD_ELEMENT=§eTLS§8: §aan
TLS_TOGGLE_HELP=§8/§etls §8: §7Toggle den TNT Listener

View File

@@ -1,18 +1,20 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem;
@@ -38,12 +40,16 @@ import de.steamwar.bausystem.worlddata.WorldData;
import de.steamwar.command.AbstractValidator;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.core.CRIUSleepEvent;
import de.steamwar.core.Core;
import de.steamwar.core.WorldEditRendererCUIEditor;
import de.steamwar.core.WorldIdentifier;
import de.steamwar.linkage.AbstractLinker;
import de.steamwar.linkage.SpigotLinker;
import de.steamwar.message.Message;
import de.steamwar.providers.BauServerInfo;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.GameRule;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -69,7 +75,6 @@ public class BauSystem extends JavaPlugin implements Listener {
@Getter
private static BauSystem instance;
@Getter
private SpigotLinker linker;
@Override
@@ -119,6 +124,7 @@ public class BauSystem extends JavaPlugin implements Listener {
} catch (AbstractLinker.LinkException e) {
getLogger().log(Level.SEVERE, "Could not link a class.", e);
Bukkit.shutdown();
return;
}
TickListener.impl.init();
@@ -127,6 +133,11 @@ public class BauSystem extends JavaPlugin implements Listener {
TraceRecorder.instance.init();
new WorldEditRendererCUIEditor();
Bukkit.getWorlds().get(0).setGameRule(GameRule.SEND_COMMAND_FEEDBACK, false);
String identifier = BauServerInfo.getOwnerUser().getUUID().toString().replace("-", "");
WorldIdentifier.set("bau/" + Core.getVersion() + "/" + identifier);
}
@EventHandler
@@ -182,8 +193,7 @@ public class BauSystem extends JavaPlugin implements Listener {
@Override
public void run() {
if (TickManager.impl.isFrozen())
return;
if (TickManager.impl.isFrozen()) return;
if (counter >= delay) {
runnable.run();
cancel();
@@ -201,8 +211,7 @@ public class BauSystem extends JavaPlugin implements Listener {
@Override
public void run() {
if (TickManager.impl.isFrozen())
return;
if (TickManager.impl.isFrozen()) return;
if (counter >= (first ? delay : period)) {
first = false;
runnable.run();
@@ -218,4 +227,4 @@ public class BauSystem extends JavaPlugin implements Listener {
AtomicReference<BukkitTask> task = new AtomicReference<>();
task.set(runTaskTimer(plugin, () -> consumer.accept(task.get()), delay, period));
}
}
}

View File

@@ -27,8 +27,6 @@ import de.steamwar.sql.SteamwarUser;
import lombok.AllArgsConstructor;
import org.bukkit.entity.Player;
import java.util.HashSet;
import java.util.Set;
import java.util.function.Predicate;
@AllArgsConstructor
@@ -39,13 +37,12 @@ public enum Permission {
return bauweltMember.isSupervisor();
}),
BUILD(bauweltMember -> {
if (isTempOnlySpectator(bauweltMember)) return false;
return bauweltMember.isBuild() || SUPERVISOR.permissionPredicate.test(bauweltMember);
}),
/**
* Only used for {@link BauMemberUpdate}
*/
REAL_SPECTATOR(bauweltMember -> {
SPECTATOR(bauweltMember -> {
return !bauweltMember.isBuild() && !bauweltMember.isSupervisor();
}),
/**
@@ -55,28 +52,6 @@ public enum Permission {
return true;
});
private static final Set<Integer> TEMP_ONLY_SPECTATOR = new HashSet<>();
private static boolean isTempOnlySpectator(BauweltMember bauweltMember) {
return TEMP_ONLY_SPECTATOR.contains(bauweltMember.getMemberID());
}
public static boolean isTempOnlySpectator(Player player) {
return TEMP_ONLY_SPECTATOR.contains(SteamwarUser.get(player.getUniqueId()).getId());
}
public static void forceOnlySpectator(Player player) {
TEMP_ONLY_SPECTATOR.add(SteamwarUser.get(player.getUniqueId()).getId());
BauMemberUpdate.baumemberUpdate();
}
/**
* Only used by {@link BauMemberUpdate}
*/
public static void removeForceOnlySpectator(Player player) {
TEMP_ONLY_SPECTATOR.remove(SteamwarUser.get(player.getUniqueId()).getId());
}
private final Predicate<BauweltMember> permissionPredicate;
public boolean hasPermission(BauweltMember bauweltMember) {
@@ -86,10 +61,10 @@ public enum Permission {
public boolean hasPermission(Player member) {
if (SteamwarUser.get(member.getUniqueId()).getId() == BauServer.getInstance().getOwnerID()) {
return this != REAL_SPECTATOR;
return this != SPECTATOR;
}
BauweltMember bauweltMember = BauweltMember.getBauMember(BauServer.getInstance().getOwner(), member.getUniqueId());
if (bauweltMember == null) return this == REAL_SPECTATOR;
if (bauweltMember == null) return this == SPECTATOR;
return permissionPredicate.test(bauweltMember);
}
}

View File

@@ -36,7 +36,7 @@ public class BauServer {
private Integer owner;
public UUID getOwner() {
return SteamwarUser.get(getOwnerID()).getUUID();
return SteamwarUser.byId(getOwnerID()).getUUID();
}
public int getOwnerID() {

View File

@@ -32,6 +32,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.type.Chest;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
@@ -120,6 +121,7 @@ public class AutostartListener implements Listener {
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof TNTPrimed)) return;
if (regionStartTime.isEmpty()) {
return;
}

View File

@@ -59,7 +59,7 @@ public class BackupCommand extends SWCommand {
if (checkGlobalRegion(region, p)) {
return;
}
if (region.getFlags().get(Flag.CHANGED).isWithDefault(ChangedMode.NO_CHANGE)) {
if (region.getRegionData().get(Flag.CHANGED).isWithDefault(ChangedMode.NO_CHANGE)) {
BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p);
return;
}

View File

@@ -56,8 +56,8 @@ public class BauInfoBauGuiItem extends BauGuiItem {
Region region = Region.getRegion(player.getLocation());
List<String> stringList = new ArrayList<>();
for (Flag flag : Flag.getFlags()) {
if (!region.getFlags().has(flag).isApplicable()) continue;
FlagOptional<?> value = region.getFlags().get(flag);
if (!region.getRegionData().has(flag).isApplicable()) continue;
FlagOptional<?> value = region.getRegionData().get(flag);
if (value.isPresent()) {
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), player)));
}

View File

@@ -1,71 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.bau;
import de.steamwar.bausystem.Permission;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Collection;
import java.util.stream.Collectors;
@Linked
public class ForceSpectatorCommand extends SWCommand {
public ForceSpectatorCommand() {
super("forcespectator");
}
@Register
public void forceSpectator(@Validator("supervisor") Player player, @Mapper("builder") Player other) {
Permission.forceOnlySpectator(other);
}
@Mapper("builder")
public TypeMapper<Player> spectatorMapper() {
return new TypeMapper<>() {
@Override
public Player map(CommandSender commandSender, String[] previousArguments, String s) {
Player player = Bukkit.getPlayer(s);
if (player == null) {
return null;
}
if (Permission.BUILD.hasPermission(player) && !Permission.SUPERVISOR.hasPermission(player)) {
return player;
}
return null;
}
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
return Bukkit.getOnlinePlayers().stream()
.filter(Permission.BUILD::hasPermission)
.filter(player -> !Permission.SUPERVISOR.hasPermission(player))
.map(Player::getName)
.collect(Collectors.toList());
}
};
}
}

View File

@@ -47,11 +47,11 @@ public class InfoCommand extends SWCommand {
@Register(description = "BAU_INFO_COMMAND_HELP")
public void genericCommand(Player p) {
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_OWNER", p, SteamwarUser.get(bauServer.getOwnerID()).getUserName());
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_OWNER", p, SteamwarUser.byId(bauServer.getOwnerID()).getUserName());
Region region = Region.getRegion(p.getLocation());
for (Flag flag : Flag.getFlags()) {
if (!region.getFlags().has(flag).isApplicable()) continue;
FlagOptional<?> value = region.getFlags().get(flag);
if (!region.getRegionData().has(flag).isApplicable()) continue;
FlagOptional<?> value = region.getRegionData().get(flag);
if (value.isPresent()) {
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), p));
}
@@ -97,7 +97,7 @@ public class InfoCommand extends SWCommand {
st.append("§8, ");
}
st.append("§7");
st.append(SteamwarUser.get(bauweltMembers.get(i).getMemberID()).getUserName());
st.append(SteamwarUser.byId(bauweltMembers.get(i).getMemberID()).getUserName());
}
return st.toString();
}

View File

@@ -21,9 +21,10 @@ package de.steamwar.bausystem.features.countingwand;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.shared.Pair;
import de.steamwar.bausystem.utils.ItemUtils;
import de.steamwar.core.SWPlayer;
import de.steamwar.inventory.SWItem;
import lombok.Data;
import lombok.experimental.UtilityClass;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@@ -31,13 +32,32 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
@UtilityClass
public class Countingwand {
@Data
public class CountingWandComponent implements SWPlayer.Component {
private Point pos1;
private Point pos2;
public boolean setPosition(boolean pos1, Point point) {
if (this.pos1 == null || this.pos2 == null) {
this.pos1 = point;
this.pos2 = point;
return true;
}
Point current = pos1 ? this.pos1 : this.pos2;
if (current.equals(point)) return false;
if (pos1) {
this.pos1 = point;
} else {
this.pos2 = point;
}
return true;
}
}
public static ItemStack getWandItem(Player player) {
ItemStack itemStack = new SWItem(Material.STICK, BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_NAME", player), Arrays.asList(BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_LORE1", player), BauSystem.MESSAGE.parse("COUNTINGWAND_ITEM_LORE2", player)), false, null).getItemStack();
ItemUtils.setItem(itemStack, "countingwand");
@@ -47,61 +67,20 @@ public class Countingwand {
return itemStack;
}
private final Map<String, Pair<Point, Point>> selections = new HashMap<>();
public boolean isCountingwand(ItemStack itemStack) {
return ItemUtils.isItem(itemStack, "countingwand");
}
public boolean isCountingwand(ItemStack itemStack) {
return ItemUtils.isItem(itemStack, "countingwand");
}
public void checkSelection(final Point point, final boolean pos1, final Player p) {
Pair<Point, Point> selection = selections.get(p.getUniqueId().toString());
final boolean newPos;
if (selection != null) {
if (pos1) {
newPos = !point.equals(selection.setKey(point));
} else {
newPos = !point.equals(selection.setValue(point));
}
} else {
if (pos1) {
selection = new Pair<>(point, null);
} else {
selection = new Pair<>(null, point);
}
selections.put(p.getUniqueId().toString(), selection);
newPos = true;
}
if (newPos) {
String dimension = getDimensions(p, selection.getKey(), selection.getValue());
String volume = getVolume(p, selection.getKey(), selection.getValue());
if (pos1) {
BauSystem.MESSAGE.send("COUNTINGWAND_MESSAGE_RCLICK", p, point.getX(), point.getY(), point.getZ(), dimension, volume);
} else {
BauSystem.MESSAGE.send("COUNTINGWAND_MESSAGE_LCLICK", p, point.getX(), point.getY(), point.getZ(), dimension, volume);
}
}
}
public void removePlayer(Player p) {
selections.remove(p.getUniqueId().toString());
}
public String getVolume(Player player, final Point point1, final Point point2) {
if (point1 == null || point2 == null) {
return BauSystem.MESSAGE.parse("COUNTINGWAND_MESSAGE_VOLUME", player, 0);
}
return BauSystem.MESSAGE.parse("COUNTINGWAND_MESSAGE_VOLUME", player, getAmount(point1, point2));
}
public String getDimensions(Player player, final Point point1, final Point point2) {
if (point1 == null || point2 == null) {
return BauSystem.MESSAGE.parse("COUNTINGWAND_MESSAGE_DIMENSION", player, 0, 0, 0);
}
return BauSystem.MESSAGE.parse("COUNTINGWAND_MESSAGE_DIMENSION", player, Math.abs(point1.getX() - point2.getX()) + 1, Math.abs(point1.getY() - point2.getY()) + 1, Math.abs(point1.getZ() - point2.getZ()) + 1);
}
public int getAmount(final Point point1, final Point point2) {
return (Math.abs(point1.getX() - point2.getX()) + 1) * (Math.abs(point1.getY() - point2.getY()) + 1) * (Math.abs(point1.getZ() - point2.getZ()) + 1);
}
public void checkSelection(final Point point, final boolean pos1, final Player p) {
SWPlayer player = SWPlayer.of(p);
CountingWandComponent countingWandComponent = player.getComponentOrDefault(CountingWandComponent.class, CountingWandComponent::new);
if (countingWandComponent.setPosition(pos1, point)) {
Point point1 = countingWandComponent.pos1;
Point point2 = countingWandComponent.pos2;
int amount = (Math.abs(point1.getX() - point2.getX()) + 1) * (Math.abs(point1.getY() - point2.getY()) + 1) * (Math.abs(point1.getZ() - point2.getZ()) + 1);
String dimension = player.using(BauSystem.MESSAGE).parse("COUNTINGWAND_MESSAGE_VOLUME", amount);
String volume = player.parse("COUNTINGWAND_MESSAGE_DIMENSION", Math.abs(point1.getX() - point2.getX()) + 1, Math.abs(point1.getY() - point2.getY()) + 1, Math.abs(point1.getZ() - point2.getZ()) + 1);
player.sendMessage(pos1 ? "COUNTINGWAND_MESSAGE_RCLICK" : "COUNTINGWAND_MESSAGE_LCLICK", point.getX(), point.getY(), point.getZ(), dimension, volume);
}
}
}

View File

@@ -27,7 +27,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.util.RayTraceResult;
import java.util.Objects;
@@ -67,9 +66,4 @@ public class CountingwandListener implements Listener {
event.setCancelled(true);
Countingwand.checkSelection(Point.fromLocation(Objects.requireNonNull(event.getClickedBlock()).getLocation()), false, event.getPlayer());
}
@EventHandler
public void onLeave(PlayerQuitEvent event) {
Countingwand.removePlayer(event.getPlayer());
}
}

View File

@@ -25,8 +25,11 @@ import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.features.autostart.AutostartListener;
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
import de.steamwar.core.SWPlayer;
import de.steamwar.entity.REntityServer;
import de.steamwar.entity.RFallingBlockEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -45,7 +48,28 @@ import java.util.*;
@UtilityClass
public class Detonator {
private static final Map<Player, REntityServer> ENTITIES_MAP = new HashMap<>();
public class DetonatorComponent implements SWPlayer.Component {
private final REntityServer entities = new REntityServer();
@Getter
@Setter
private boolean hasUpdated = false;
@Override
public void onMount(SWPlayer player) {
entities.addPlayer(player.getPlayer());
entities.setCallback((player1, entity, action) -> {
Vector vector = new Vector(entity.getX(), entity.getY(), entity.getZ());
DetonatorListener.addLocationToDetonator(vector.toLocation(player.getWorld()).getBlock().getLocation(), player1);
});
}
@Override
public void onUnmount(SWPlayer player) {
entities.close();
}
}
private static final Vector HALF = new Vector(0.5, 0, 0.5);
public static boolean isDetonator(ItemStack itemStack) {
@@ -53,28 +77,19 @@ public class Detonator {
}
public static void showDetonator(Player p, List<Location> locs) {
if (ENTITIES_MAP.containsKey(p)) return;
REntityServer entities = new REntityServer();
entities.setCallback((player, rEntity, entityAction) -> {
Vector vector = new Vector(rEntity.getX(), rEntity.getY(), rEntity.getZ());
DetonatorListener.addLocationToDetonator(vector.toLocation(player.getWorld()).getBlock().getLocation(), player);
DetonatorListener.HAS_UPDATED.add(player);
});
entities.addPlayer(p);
ENTITIES_MAP.put(p, entities);
DetonatorComponent detonatorComponent = SWPlayer.of(p).getComponentOrDefault(DetonatorComponent.class, DetonatorComponent::new);
locs.forEach(location -> {
RFallingBlockEntity entity = new RFallingBlockEntity(entities, location.clone().add(HALF), Material.RED_STAINED_GLASS);
RFallingBlockEntity entity = new RFallingBlockEntity(detonatorComponent.entities, location.clone().add(HALF), Material.RED_STAINED_GLASS);
entity.setNoGravity(true);
});
}
public static void hideDetonator(Player p) {
ENTITIES_MAP.remove(p).close();
SWPlayer.of(p).removeComponent(DetonatorComponent.class);
}
public static boolean hasActiveDetonatorShow(Player p) {
return ENTITIES_MAP.containsKey(p);
return SWPlayer.of(p).hasComponent(DetonatorComponent.class);
}
public static void activateDetonator(DetonatorStorage detonator) {

View File

@@ -24,6 +24,7 @@ import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.detonator.storage.DetonatorStorage;
import de.steamwar.bausystem.features.detonator.storage.ItemStorage;
import de.steamwar.core.SWPlayer;
import de.steamwar.linkage.Linked;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -36,15 +37,11 @@ import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import java.util.HashSet;
import java.util.Set;
@Linked
public class DetonatorListener implements Listener {
static final Set<Player> HAS_UPDATED = new HashSet<>();
static void addLocationToDetonator(Location location, Player p) {
SWPlayer.of(p).getComponent(Detonator.DetonatorComponent.class).ifPresent(detonatorComponent -> detonatorComponent.setHasUpdated(true));
Detoblock detoblock = Detonator.getBlock(location.getBlock());
if (detoblock == Detoblock.INVALID) {
SWUtils.sendToActionbar(p, BauSystem.MESSAGE.parse("DETONATOR_INVALID_BLOCK", p));
@@ -66,64 +63,59 @@ public class DetonatorListener implements Listener {
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
Player p = event.getPlayer();
if (Detonator.isDetonator(p.getInventory().getItemInMainHand())) {
event.setCancelled(true);
addLocationToDetonator(event.getBlock().getLocation(), p);
HAS_UPDATED.add(event.getPlayer());
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Detonator.isDetonator(event.getItem())) {
return;
}
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Detonator.isDetonator(event.getItem())) return;
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
event.setCancelled(true);
DetonatorStorage detonator = new ItemStorage(event.getPlayer());
Detonator.activateDetonator(detonator);
HAS_UPDATED.add(event.getPlayer());
SWPlayer.of(event.getPlayer()).getComponent(Detonator.DetonatorComponent.class).ifPresent(detonatorComponent -> detonatorComponent.setHasUpdated(true));
}
}
@EventHandler(ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent event) {
if (!Permission.BUILD.hasPermission(event.getPlayer()) ||!Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) {
if (!Permission.BUILD.hasPermission(event.getPlayer()) || !Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) {
if (Detonator.hasActiveDetonatorShow(event.getPlayer())) {
Detonator.hideDetonator(event.getPlayer());
}
} else {
if (!Detonator.hasActiveDetonatorShow(event.getPlayer())) {
Detonator.showDetonator(event.getPlayer(), new ItemStorage(event.getPlayer()).getLocations());
}
return;
}
if (HAS_UPDATED.contains(event.getPlayer())) {
HAS_UPDATED.remove(event.getPlayer());
if (Detonator.hasActiveDetonatorShow(event.getPlayer())) {
Detonator.hideDetonator(event.getPlayer());
Detonator.showDetonator(event.getPlayer(), new ItemStorage(event.getPlayer()).getLocations());
}
if (!Detonator.hasActiveDetonatorShow(event.getPlayer())) {
Detonator.showDetonator(event.getPlayer(), new ItemStorage(event.getPlayer()).getLocations());
return;
}
Detonator.DetonatorComponent component = SWPlayer.of(event.getPlayer())
.getComponentAndFilter(Detonator.DetonatorComponent.class, Detonator.DetonatorComponent::isHasUpdated)
.orElse(null);
if (component == null) return;
component.setHasUpdated(false);
Detonator.hideDetonator(event.getPlayer());
Detonator.showDetonator(event.getPlayer(), new ItemStorage(event.getPlayer()).getLocations());
}
@EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) {
HAS_UPDATED.add(event.getPlayer());
}
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Detonator.isDetonator(event.getPlayer().getInventory().getItemInMainHand())) return;
SWPlayer.of(event.getPlayer()).getComponent(Detonator.DetonatorComponent.class).ifPresent(detonatorComponent -> detonatorComponent.setHasUpdated(true));
}
@EventHandler
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (Detonator.isDetonator(event.getMainHandItem()) || Detonator.isDetonator(event.getOffHandItem())) {
HAS_UPDATED.add(event.getPlayer());
}
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!(Detonator.isDetonator(event.getMainHandItem()) || Detonator.isDetonator(event.getOffHandItem()))) return;
SWPlayer.of(event.getPlayer()).getComponent(Detonator.DetonatorComponent.class).ifPresent(detonatorComponent -> detonatorComponent.setHasUpdated(true));
}
}

View File

@@ -26,6 +26,7 @@ import de.steamwar.bausystem.features.loader.elements.LoaderInteractionElement;
import de.steamwar.bausystem.features.loader.elements.impl.LoaderTNT;
import de.steamwar.bausystem.features.loader.elements.impl.LoaderWait;
import de.steamwar.bausystem.shared.EnumDisplay;
import de.steamwar.core.SWPlayer;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
@@ -40,21 +41,17 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
public class Loader implements Listener {
private static final Map<Player, Loader> LOADER_MAP = new HashMap<>();
public class Loader implements Listener, SWPlayer.Component {
public static Loader getLoader(Player player) {
return LOADER_MAP.get(player);
return SWPlayer.of(player).getComponent(Loader.class).orElse(null);
}
public static void newLoader(Player player) {
LOADER_MAP.put(player, new Loader(player));
SWPlayer.of(player).setComponent(new Loader(player));
}
private final Player p;
@@ -145,7 +142,7 @@ public class Loader implements Listener {
recorder = null;
}
elements.clear();
LOADER_MAP.remove(p);
SWPlayer.of(p).removeComponent(Loader.class);
}
public boolean setTicksBetweenShots(int delay) {

View File

@@ -29,6 +29,7 @@ import org.bukkit.boss.BarColor;
import org.bukkit.boss.BarStyle;
import org.bukkit.boss.BossBar;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
@@ -156,6 +157,7 @@ public class Loadtimer implements Listener {
}
public void onTntExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof TNTPrimed)) return;
if (region.getBuildArea().inRegion(event.getLocation(), true) && stage == Stage.IGNITION) {
stage = Stage.END;
explode = TPSUtils.currentRealTick.get();

View File

@@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.observer;
import de.steamwar.Reflection;
import de.steamwar.bausystem.region.Point;
import de.steamwar.core.SWPlayer;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
@@ -34,7 +35,7 @@ import org.bukkit.entity.Player;
import java.util.*;
public class ObserverTracer {
public class ObserverTracer implements SWPlayer.Component {
private static final Set<BlockFace> ALLOWED = EnumSet.of(BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST, BlockFace.UP, BlockFace.DOWN);

View File

@@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.observer;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand;
import de.steamwar.core.SWPlayer;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
@@ -41,23 +42,23 @@ public class ObserverTracerCommand extends SWCommand {
@Register(value = "disable", description = "OBSERVER_HELP_DISABLE")
public void disable(Player p) {
ObserverTracerListener.enabled.remove(p);
ObserverTracerListener.observerTracerMap.remove(p);
SWPlayer.of(p).removeComponent(ObserverTracer.class);
BauSystem.MESSAGE.send("OBSERVER_DISABLE", p);
}
@Register(value = "delete", description = "OBSERVER_HELP_DELETE")
public void delete(@Validator Player p) {
ObserverTracerListener.observerTracerMap.remove(p);
SWPlayer.of(p).removeComponent(ObserverTracer.class);
BauSystem.MESSAGE.send("OBSERVER_DELETE", p);
}
@Register(value = "retrace", description = "OBSERVER_HELP_RETRACE")
public void retrace(@Validator Player p) {
if (ObserverTracerListener.observerTracerMap.containsKey(p)) {
if (SWPlayer.of(p).hasComponent(ObserverTracer.class)) {
BauSystem.MESSAGE.send("OBSERVER_RETRACE_NO_TRACE", p);
return;
}
ObserverTracerListener.observerTracerMap.get(p).trace();
SWPlayer.of(p).getComponent(ObserverTracer.class).ifPresent(ObserverTracer::trace);
BauSystem.MESSAGE.send("OBSERVER_RETRACE_DONE", p);
}
}

View File

@@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.observer;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
import de.steamwar.core.SWPlayer;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
@@ -34,23 +35,19 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@Linked
public class ObserverTracerListener implements Listener {
static Set<Player> enabled = new HashSet<>();
static Map<Player, ObserverTracer> observerTracerMap = new HashMap<>();
public ObserverTracerListener() {
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
observerTracerMap.forEach((player, observerTracer) -> {
if (player.getGameMode() == GameMode.SPECTATOR) {
observerTracer.show();
}
SWPlayer.allWithSingleComponent(ObserverTracer.class).forEach(pair -> {
if (pair.getPlayer().getGameMode() != GameMode.SPECTATOR) return;
pair.getComponent().show();
});
}, 15L, 15L);
}
@@ -58,20 +55,16 @@ public class ObserverTracerListener implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!enabled.contains(event.getPlayer())) {
return;
}
if (event.getClickedBlock() == null) {
return;
}
if (observerTracerMap.containsKey(event.getPlayer())) {
ObserverTracer observerTracer = observerTracerMap.get(event.getPlayer());
if (!enabled.contains(event.getPlayer())) return;
if (event.getClickedBlock() == null) return;
ObserverTracer observerTracer = SWPlayer.of(event.getPlayer()).getComponent(ObserverTracer.class).orElse(null);
if (observerTracer != null) {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
if (!observerTracer.trace()) {
createNew(event);
}
observerTracerMap.forEach((player, o) -> {
o.trace();
SWPlayer.allWithSingleComponent(ObserverTracer.class).forEach(pair -> {
pair.getComponent().trace();
});
}, 1L);
} else {
@@ -86,13 +79,13 @@ public class ObserverTracerListener implements Listener {
if (event.getClickedBlock().getType() == Material.OBSERVER) {
ObserverTracer observerTracer = new ObserverTracer(event.getPlayer(), event.getClickedBlock());
observerTracer.trace();
observerTracerMap.put(event.getPlayer(), observerTracer);
SWPlayer.of(event.getPlayer()).setComponent(observerTracer);
}
}
@EventHandler
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
event.getNewSpectator().forEach(observerTracerMap::remove);
event.getNewBuilder().forEach(player -> SWPlayer.of(player).removeComponent(ObserverTracer.class));
}
@EventHandler
@@ -103,6 +96,5 @@ public class ObserverTracerListener implements Listener {
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
enabled.remove(event.getPlayer());
observerTracerMap.remove(event.getPlayer());
}
}

View File

@@ -51,17 +51,17 @@ public class ColorCommand extends SWCommand {
public void genericColorSet(@Validator Player p, ColorMode color, ColorizationType colorizationType) {
if (colorizationType == ColorizationType.GLOBAL) {
Region.getRegions().forEach(region -> {
region.getFlags().set(Flag.COLOR, color);
region.getRegionData().set(Flag.COLOR, color);
});
BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p));
return;
}
Region region = Region.getRegion(p.getLocation());
if (!region.getFlags().has(Flag.COLOR).isWritable()) {
if (!region.getRegionData().has(Flag.COLOR).isWritable()) {
BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p);
return;
}
region.getFlags().set(Flag.COLOR, color);
region.getRegionData().set(Flag.COLOR, color);
try {
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
.ignoreAir(true)

View File

@@ -53,11 +53,11 @@ public class FireCommand extends SWCommand {
}
private boolean toggle(Region region) {
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
region.getFlags().set(Flag.FIRE, FireMode.DENY);
if (region.getRegionData().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
region.getRegionData().set(Flag.FIRE, FireMode.DENY);
return true;
} else {
region.getFlags().set(Flag.FIRE, FireMode.ALLOW);
region.getRegionData().set(Flag.FIRE, FireMode.ALLOW);
return false;
}
}

View File

@@ -36,12 +36,12 @@ public class FireListener implements Listener, ScoreboardElement {
@EventHandler
public void onFireDamage(BlockBurnEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
}
@EventHandler
public void onFireSpread(BlockSpreadEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FIRE).isWithDefault(FireMode.DENY)) e.setCancelled(true);
}
@Override
@@ -56,7 +56,7 @@ public class FireListener implements Listener, ScoreboardElement {
@Override
public String get(Region region, Player p) {
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.DENY)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FIRE).getWithDefault().getChatValue(), p);
if (region.getRegionData().get(Flag.FIRE).isWithDefault(FireMode.DENY)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.FIRE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.FIRE).getWithDefault().getChatValue(), p);
}
}

View File

@@ -53,11 +53,11 @@ public class FreezeCommand extends SWCommand {
}
private boolean toggle(Region region) {
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
region.getFlags().set(Flag.FREEZE, FreezeMode.INACTIVE);
if (region.getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
region.getRegionData().set(Flag.FREEZE, FreezeMode.INACTIVE);
return false;
} else {
region.getFlags().set(Flag.FREEZE, FreezeMode.ACTIVE);
region.getRegionData().set(Flag.FREEZE, FreezeMode.ACTIVE);
return true;
}
}

View File

@@ -48,7 +48,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onEntitySpawn(EntitySpawnEvent e) {
if (Region.getRegion(e.getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
if (Region.getRegion(e.getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
e.setCancelled(true);
if (e.getEntityType() == TrickyTrialsWrapper.impl.getTntEntityType()) {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
@@ -60,7 +60,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onBlockCanBuild(BlockCanBuildEvent e) {
if (!e.isBuildable()) return;
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return;
if (e.getMaterial() == Material.TNT) {
e.setBuildable(false);
e.getBlock().setType(Material.TNT, false);
@@ -69,14 +69,14 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@EventHandler
public void onPhysicsEvent(BlockPhysicsEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (e.getSourceBlock().getType() == Material.NOTE_BLOCK) {
BlockState state = e.getSourceBlock().getState();
NoteBlock noteBlock = (NoteBlock) state.getBlockData();
@@ -101,44 +101,44 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onPistonExtend(BlockPistonExtendEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@EventHandler
public void onBlockGrow(BlockGrowEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@EventHandler
public void onRedstoneEvent(BlockRedstoneEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setNewCurrent(e.getOldCurrent());
}
}
@EventHandler
public void onBlockDispense(BlockDispenseEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@EventHandler
public void onInventoryMoveEvent(InventoryMoveItemEvent e) {
if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (e.getDestination().getLocation() != null && Region.getRegion(e.getDestination().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
} else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
} else if (e.getSource().getLocation() != null && Region.getRegion(e.getSource().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@@ -147,7 +147,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
public void onBlockBreak(BlockBreakEvent e) {
if (Core.getVersion() < 19) return;
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
e.getBlock().setType(Material.BARRIER, false);
e.getBlock().setType(Material.AIR, false);
@@ -170,35 +170,35 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onFluidLevelChange(FluidLevelChangeEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@EventHandler
public void onBlockSpread(BlockSpreadEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@EventHandler
public void onBlockFromTo(BlockFromToEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@EventHandler
public void onSpongeAbsorb(SpongeAbsorbEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@EventHandler
public void onBlockForm(BlockFormEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@@ -206,7 +206,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
if (e.getAction() != Action.RIGHT_CLICK_BLOCK) return;
if (Region.getRegion(e.getClickedBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getClickedBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
Block block = e.getClickedBlock();
if (block.getType() == Material.LEVER) {
Switch data = ((Switch) block.getBlockData());
@@ -218,7 +218,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
@EventHandler
public void onBlockFade(BlockFadeEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (Region.getRegion(e.getBlock().getLocation()).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
e.setCancelled(true);
}
}
@@ -235,7 +235,7 @@ public class FreezeListener implements Listener, ScoreboardElement {
@Override
public String get(Region region, Player p) {
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.FREEZE).getWithDefault().getChatValue(), p);
if (region.getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.INACTIVE)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.FREEZE.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.FREEZE).getWithDefault().getChatValue(), p);
}
}

View File

@@ -55,11 +55,11 @@ public class ItemsCommand extends SWCommand {
}
private boolean toggle(Region region) {
if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.ACTIVE)) {
region.getFlags().set(Flag.ITEMS, ItemMode.INACTIVE);
if (region.getRegionData().get(Flag.ITEMS).isWithDefault(ItemMode.ACTIVE)) {
region.getRegionData().set(Flag.ITEMS, ItemMode.INACTIVE);
return false;
} else {
region.getFlags().set(Flag.ITEMS, ItemMode.ACTIVE);
region.getRegionData().set(Flag.ITEMS, ItemMode.ACTIVE);
return true;
}
}

View File

@@ -37,7 +37,7 @@ public class ItemsListener implements Listener, ScoreboardElement {
@EventHandler
public void onItemSpawn(ItemSpawnEvent event) {
if (Region.getRegion(event.getLocation()).getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) {
if (Region.getRegion(event.getLocation()).getRegionData().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) {
event.setCancelled(true);
}
}
@@ -54,7 +54,7 @@ public class ItemsListener implements Listener, ScoreboardElement {
@Override
public String get(Region region, Player p) {
if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.ITEMS).getWithDefault().getChatValue(), p);
if (region.getRegionData().get(Flag.ITEMS).isWithDefault(ItemMode.INACTIVE)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.ITEMS.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.ITEMS).getWithDefault().getChatValue(), p);
}
}

View File

@@ -53,11 +53,11 @@ public class NoGravityCommand extends SWCommand {
}
private boolean toggle(Region region) {
if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE);
if (region.getRegionData().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
region.getRegionData().set(Flag.NO_GRAVITY, NoGravityMode.INACTIVE);
return false;
} else {
region.getFlags().set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE);
region.getRegionData().set(Flag.NO_GRAVITY, NoGravityMode.ACTIVE);
return true;
}
}

View File

@@ -37,7 +37,7 @@ public class NoGravityListener implements Listener, ScoreboardElement {
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
if (event.getEntityType() == EntityType.PLAYER) return;
if (Region.getRegion(event.getLocation()).getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
if (Region.getRegion(event.getLocation()).getRegionData().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.ACTIVE)) {
event.getEntity().setGravity(false);
}
}
@@ -54,7 +54,7 @@ public class NoGravityListener implements Listener, ScoreboardElement {
@Override
public String get(Region region, Player p) {
if (region.getFlags().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.INACTIVE)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.NO_GRAVITY).getWithDefault().getChatValue(), p);
if (region.getRegionData().get(Flag.NO_GRAVITY).isWithDefault(NoGravityMode.INACTIVE)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.NO_GRAVITY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.NO_GRAVITY).getWithDefault().getChatValue(), p);
}
}

View File

@@ -39,18 +39,18 @@ public class ProtectCommand extends SWCommand {
public void genericProtectCommand(@Validator Player p) {
Region region = regionCheck(p);
if (region == null) return;
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
region.getFlags().set(Flag.PROTECT, ProtectMode.INACTIVE);
if (region.getRegionData().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
region.getRegionData().set(Flag.PROTECT, ProtectMode.INACTIVE);
RegionUtils.actionBar(region, "REGION_PROTECT_DISABLE");
} else {
region.getFlags().set(Flag.PROTECT, ProtectMode.ACTIVE);
region.getRegionData().set(Flag.PROTECT, ProtectMode.ACTIVE);
RegionUtils.actionBar(region, "REGION_PROTECT_ENABLE");
}
}
private Region regionCheck(Player player) {
Region region = Region.getRegion(player.getLocation());
if (!region.getFlags().has(Flag.PROTECT).isApplicable()) {
if (!region.getRegionData().has(Flag.PROTECT).isApplicable()) {
BauSystem.MESSAGE.send("REGION_PROTECT_FALSE_REGION", player);
return null;
}

View File

@@ -41,7 +41,7 @@ public class ProtectListener implements Listener, ScoreboardElement {
private void explode(List<Block> blockList, Location location) {
Region region = Region.getRegion(location);
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return;
if (region.getRegionData().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return;
Point p1 = region.getBuildArea().getMinPoint(true);
Point p2 = region.getTestblockArea().getMinPoint(true);
int floorLevel = Math.min(p1.getY(), p2.getY());
@@ -70,7 +70,7 @@ public class ProtectListener implements Listener, ScoreboardElement {
@Override
public String get(Region region, Player p) {
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.PROTECT).getWithDefault().getChatValue(), p);
if (region.getRegionData().get(Flag.PROTECT).isWithDefault(ProtectMode.INACTIVE)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.PROTECT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.PROTECT).getWithDefault().getChatValue(), p);
}
}

View File

@@ -102,7 +102,7 @@ public class RegionCommand extends SWCommand {
try {
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
.ignoreAir(true)
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
region.getArea().reset(pasteBuilder, false);
RegionUtils.message(region, "REGION_REGION_RESTORED");
} catch (SecurityException e) {
@@ -124,7 +124,7 @@ public class RegionCommand extends SWCommand {
try {
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
.ignoreAir(true)
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
region.getArea().reset(pasteBuilder, false);
RegionUtils.message(region, "REGION_REGION_RESTORED");
} catch (SecurityException e) {

View File

@@ -182,6 +182,6 @@ public class RegionListener implements Listener {
}
private static void tagChangedRegion(final Location location) {
Region.getRegion(location).getFlags().set(Flag.CHANGED, ChangedMode.HAS_CHANGE);
Region.getRegion(location).getRegionData().set(Flag.CHANGED, ChangedMode.HAS_CHANGE);
}
}

View File

@@ -53,9 +53,8 @@ public class ResetCommand extends SWCommand {
if (region == null) return;
try {
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getArea().getResetFile()))
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
region.getArea().reset(pasteBuilder, false);
region.getFlags().clear();
region.getRegionData().clear();
RegionUtils.message(region, "REGION_RESET_RESETED");
} catch (SecurityException e) {
@@ -84,7 +83,7 @@ public class ResetCommand extends SWCommand {
}
try {
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
region.getArea().reset(pasteBuilder, true);
RegionUtils.message(region, "REGION_RESET_RESETED");
} catch (SecurityException e) {

View File

@@ -92,7 +92,7 @@ public class TNTCommand extends SWCommand {
@Override
public List<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
Region region = Region.getRegion(((Player) sender).getLocation());
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
if (region.getRegionData().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
return new ArrayList<>(tntModeMap.keySet());
} else {
return new ArrayList<>(tntModeMapReduced.keySet());
@@ -102,7 +102,7 @@ public class TNTCommand extends SWCommand {
@Override
public TNTMode map(CommandSender sender, PreviousArguments previousArguments, String s) {
Region region = Region.getRegion(((Player) sender).getLocation());
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
if (region.getRegionData().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
return tntModeMap.getOrDefault(s, null);
} else {
return tntModeMapReduced.getOrDefault(s, null);
@@ -124,23 +124,23 @@ public class TNTCommand extends SWCommand {
}
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
if (requestedMode != null && region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
region.getFlags().set(Flag.TNT, requestedMode);
if (requestedMode != null && region.getRegionData().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
region.getRegionData().set(Flag.TNT, requestedMode);
RegionUtils.actionBar(region, requestedMessage);
return;
}
switch (region.getFlags().get(Flag.TNT).getWithDefault()) {
switch (region.getRegionData().get(Flag.TNT).getWithDefault()) {
case ALLOW:
case ONLY_TB:
region.getFlags().set(Flag.TNT, TNTMode.DENY);
region.getRegionData().set(Flag.TNT, TNTMode.DENY);
RegionUtils.actionBar(region, getDisableMessage());
break;
case DENY:
if (region.getFlags().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
region.getFlags().set(Flag.TNT, TNTMode.ONLY_TB);
if (region.getRegionData().get(Flag.TESTBLOCK).isNotWithDefault(TestblockMode.NO_VALUE)) {
region.getRegionData().set(Flag.TNT, TNTMode.ONLY_TB);
RegionUtils.actionBar(region, getTestblockEnableMessage());
} else {
region.getFlags().set(Flag.TNT, TNTMode.ALLOW);
region.getRegionData().set(Flag.TNT, TNTMode.ALLOW);
RegionUtils.actionBar(region, getEnableMessage());
}
break;

View File

@@ -26,8 +26,10 @@ import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.TNTMode;
import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@@ -39,11 +41,14 @@ import java.util.List;
@Linked
public class TNTListener implements Listener, ScoreboardElement {
private void explode(List<Block> blockList) {
private void explode(List<Block> blockList, boolean destroy) {
blockList.removeIf(block -> {
Region region = Region.getRegion(block.getLocation());
TNTMode value = region.getFlags().get(Flag.TNT).getWithDefault();
TNTMode value = region.getRegionData().get(Flag.TNT).getWithDefault();
if (value == TNTMode.ALLOW) {
if (destroy && block.getType() != Material.TNT) {
block.setType(Material.AIR);
}
return false;
} else if (value == TNTMode.ONLY_TB) {
if (region.getBuildArea().inRegion(block.getLocation(), true)) {
@@ -57,12 +62,16 @@ public class TNTListener implements Listener, ScoreboardElement {
@EventHandler
public void onBlockExplode(BlockExplodeEvent event) {
explode(event.blockList());
explode(event.blockList(), false);
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onExplode(EntityExplodeEvent event) {
explode(event.blockList());
if (!(event.getEntity() instanceof TNTPrimed)) {
event.blockList().clear();
return;
}
explode(event.blockList(), true);
}
@Override
@@ -77,7 +86,7 @@ public class TNTListener implements Listener, ScoreboardElement {
@Override
public String get(Region region, Player p) {
if (region.getFlags().get(Flag.TNT).isWithDefault(TNTMode.ALLOW)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getFlags().get(Flag.TNT).getWithDefault().getChatValue(), p);
if (region.getRegionData().get(Flag.TNT).isWithDefault(TNTMode.ALLOW)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.TNT.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.TNT).getWithDefault().getChatValue(), p);
}
}

View File

@@ -31,7 +31,6 @@ import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.LinkedInstance;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.Punishment;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
@@ -73,6 +72,14 @@ public class TestblockCommand extends SWCommand {
resetRegion(p, node, isExtension ? RegionExtensionType.EXTENSION : RegionExtensionType.NORMAL, isIgnoreAir, isOnlyColor, replaceTNT, replaceWater);
}
@Register(value="default")
public void setTestblockDefault(Player p) {
Region region = regionCheck(p);
if (region == null) return;
region.getRegionData().setTestblockSchematic(null);
resetRegion(p, null, RegionExtensionType.EXTENSION, false, false, false, false);
}
private void resetRegion(Player p, SchematicNode node, RegionExtensionType regionExtensionType, boolean ignoreAir, boolean onlyColors, boolean removeTNT, boolean removeWater) {
Region region = regionCheck(p);
if (region == null) return;
@@ -93,29 +100,10 @@ public class TestblockCommand extends SWCommand {
}
}
// Beta Tester enabled
switch (BauServer.getInstance().getOwnerID()) {
case 245:
case 403:
case 1898:
case 3320:
case 4603:
case 5262:
case 5399:
case 6032:
case 7862:
case 11077:
case 11888:
case 12258:
case 16009:
if (node == null) {
node = region.getRegionData().getTestblockSchematic();
} else {
region.getRegionData().setTestblockSchematic(node);
}
break;
default:
break;
if (node == null) {
node = region.getRegionData().getTestblockSchematic();
} else {
region.getRegionData().setTestblockSchematic(node);
}
PasteBuilder.ClipboardProvider clipboardProvider;
@@ -131,7 +119,7 @@ public class TestblockCommand extends SWCommand {
.onlyColors(onlyColors)
.removeTNT(removeTNT)
.removeWater(removeWater)
.color(region.getFlags().get(Flag.COLOR).getWithDefault());
.color(region.getRegionData().get(Flag.COLOR).getWithDefault());
region.getTestblockArea().reset(pasteBuilder, regionExtensionType == RegionExtensionType.EXTENSION);
RegionUtils.message(region, "REGION_TB_DONE");
} catch (SecurityException e) {
@@ -198,7 +186,7 @@ public class TestblockCommand extends SWCommand {
@Override
public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) {
List<String> stringList = new ArrayList<>(SchematicNode.getNodeTabcomplete(SteamwarUser.get(((Player) commandSender).getUniqueId()), s));
stringList.addAll(SchematicNode.getNodeTabcomplete(SteamwarUser.get(0), s));
stringList.addAll(SchematicNode.getNodeTabcomplete(SteamwarUser.byId(0), s));
return stringList;
}
@@ -206,7 +194,7 @@ public class TestblockCommand extends SWCommand {
public SchematicNode map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
SchematicNode node = SchematicNode.getNodeFromPath(SteamwarUser.get(((Player) commandSender).getUniqueId()), s);
if (node == null) {
node = SchematicNode.getNodeFromPath(SteamwarUser.get(0), s);
node = SchematicNode.getNodeFromPath(SteamwarUser.byId(0), s);
}
return node;
}

View File

@@ -0,0 +1,64 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.region;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.WaterDestroyMode;
import de.steamwar.command.SWCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
@Linked
public class WaterDestroyCommand extends SWCommand {
public WaterDestroyCommand() {
super("waterdestroy");
}
private String getEnableMessage(){
return "REGION_WATER_ENABLED";
}
private String getDisableMessage(){
return "REGION_WATER_DISABLED";
}
@Register(description = "REGION_WATER_HELP")
public void toggleCommand(@Validator Player p) {
Region region = Region.getRegion(p.getLocation());
if (toggle(region)) {
RegionUtils.actionBar(region, getEnableMessage());
} else {
RegionUtils.actionBar(region, getDisableMessage());
}
}
private boolean toggle(Region region) {
if (region.getRegionData().get(Flag.WATER_DESTROY).isWithDefault(WaterDestroyMode.DENY)) {
region.getRegionData().set(Flag.WATER_DESTROY, WaterDestroyMode.ALLOW);
return false;
} else {
region.getRegionData().set(Flag.WATER_DESTROY, WaterDestroyMode.DENY);
return true;
}
}
}

View File

@@ -0,0 +1,57 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.region;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.WaterDestroyMode;
import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockFromToEvent;
@Linked
public class WaterDestroyListener implements Listener, ScoreboardElement {
@EventHandler
public void onBlockFromTo(BlockFromToEvent event) {
if (event.getBlock().getType() == Material.WATER && event.getToBlock().getType() != Material.AIR && Region.getRegion(event.getBlock().getLocation()).getRegionData().get(Flag.WATER_DESTROY).isWithDefault(WaterDestroyMode.DENY)) event.setCancelled(true);
}
@Override
public ScoreboardGroup getGroup() {
return ScoreboardGroup.REGION;
}
@Override
public int order() {
return 5;
}
@Override
public String get(Region region, Player p) {
if (region.getRegionData().get(Flag.WATER_DESTROY).isWithDefault(WaterDestroyMode.ALLOW)) return null;
return "§e" + BauSystem.MESSAGE.parse(Flag.WATER_DESTROY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.WATER_DESTROY).getWithDefault().getChatValue(), p);
}
}

View File

@@ -84,14 +84,14 @@ public class ColorBauGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
Region region = Region.getRegion(player.getLocation());
ColorMode mode = region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
ColorMode mode = region.getRegionData().get(Flag.COLOR).orElse(ColorMode.PINK);
return new SWItem(mapColor(mode), BauSystem.MESSAGE.parse("REGION_ITEM_COLOR", player, BauSystem.MESSAGE.parse(mode.getChatValue(), player))).getItemStack();
}
@Override
public boolean click(ClickType click, Player p) {
p.closeInventory();
ColorMode current = Region.getRegion(p.getLocation()).getFlags().get(Flag.COLOR).orElse(ColorMode.PINK);
ColorMode current = Region.getRegion(p.getLocation()).getRegionData().get(Flag.COLOR).orElse(ColorMode.PINK);
List<SWListInv.SWListEntry<ColorMode>> items = new ArrayList<>();
for (ColorMode value : ColorMode.values()) {
items.add(new SWListInv.SWListEntry<>(new SWItem(mapColor(value), (byte) 0, "§f" + BauSystem.MESSAGE.parse(value.getChatValue(), p), Collections.emptyList(), value == current, clickType -> {

View File

@@ -42,10 +42,10 @@ public class FireBauGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
Region region = Region.getRegion(player.getLocation());
if (!region.getFlags().has(Flag.FIRE).isApplicable()) {
if (!region.getRegionData().has(Flag.FIRE).isApplicable()) {
return new SWItem(Material.BARRIER, "").getItemStack();
}
if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
if (region.getRegionData().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
return new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_ALLOW", player)).getItemStack();
} else {
return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_DISALLOW", player)).getItemStack();

View File

@@ -42,10 +42,10 @@ public class FreezeBauGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
Region region = Region.getRegion(player.getLocation());
if (!region.getFlags().has(Flag.FREEZE).isApplicable()) {
if (!region.getRegionData().has(Flag.FREEZE).isApplicable()) {
return new SWItem(Material.BARRIER, "").getItemStack();
}
if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
if (region.getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
return new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_ALLOW", player)).getItemStack();
} else {
return new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_DISALLOW", player)).getItemStack();

View File

@@ -43,10 +43,10 @@ public class ProtectBauGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
Region region = Region.getRegion(player.getLocation());
if (!region.getFlags().has(Flag.PROTECT).isApplicable()) {
if (!region.getRegionData().has(Flag.PROTECT).isApplicable()) {
return new SWItem(Material.BARRIER, "").getItemStack();
}
if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
if (region.getRegionData().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack();
} else {
return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack();

View File

@@ -42,7 +42,7 @@ public class TntBauGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
switch (Region.getRegion(player.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
switch (Region.getRegion(player.getLocation()).getRegionData().get(Flag.TNT).getWithDefault()) {
case DENY:
return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack();
case ONLY_TB:
@@ -55,7 +55,7 @@ public class TntBauGuiItem extends BauGuiItem {
@Override
public boolean click(ClickType click, Player p) {
if (click == ClickType.LEFT) {
switch (Region.getRegion(p.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
switch (Region.getRegion(p.getLocation()).getRegionData().get(Flag.TNT).getWithDefault()) {
case DENY:
updateTntMode(TNTMode.ALLOW, p);
break;

View File

@@ -38,7 +38,7 @@ public class ScriptHelper {
BookMeta meta = (BookMeta) itemStack.getItemMeta();
if(!writeable) {
meta.setTitle(script.getName());
meta.setAuthor(SteamwarUser.get(script.getUserId()).getUserName());
meta.setAuthor(SteamwarUser.byId(script.getUserId()).getUserName());
}
meta.setPages(getScriptPages(script));
itemStack.setItemMeta(meta);

View File

@@ -67,7 +67,7 @@ public class ScriptListener implements Listener {
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
ScriptRunner.remove(event.getPlayer());
playerSet.remove(event.getPlayer());
}
@EventHandler

View File

@@ -23,8 +23,11 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.script.lua.CommandRegister;
import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin;
import de.steamwar.bausystem.features.script.lua.SteamWarPlatform;
import de.steamwar.core.SWPlayer;
import de.steamwar.sql.Script;
import de.steamwar.sql.SteamwarUser;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.UtilityClass;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@@ -44,12 +47,25 @@ public class ScriptRunner {
// Key -> bau-script-<BUCH NAME>
// Value -> <LUA Script>
private static final Map<Player, Map<SteamWarGlobalLuaPlugin.EventType, List<LuaFunction>>> EVENT_MAP = new HashMap<>();
private static final Map<Player, Map<Hotkey, List<LuaFunction>>> HOTKEY_MAP = new HashMap<>();
private static final Map<Player, Map<String, CommandRegister>> COMMAND_MAP = new HashMap<>();
public class ScriptData implements SWPlayer.Component {
private Map<SteamWarGlobalLuaPlugin.EventType, List<LuaFunction>> events = new EnumMap<>(SteamWarGlobalLuaPlugin.EventType.class);
private Map<Hotkey, List<LuaFunction>> hotkeys = new HashMap<>();
private Map<String, CommandRegister> commands = new HashMap<>();
@Getter
private Set<String> calledCommands = new HashSet<>();
@Getter
@Setter
private Long lastF = Long.MAX_VALUE;
@Getter
@Setter
private boolean ignore;
}
public Set<String> getCommandsOfPlayer(Player player) {
return COMMAND_MAP.getOrDefault(player, new HashMap<>()).keySet();
return SWPlayer.of(player).getComponentOrDefault(ScriptData.class, ScriptData::new).commands.keySet();
}
public static void runScript(String script, Player player) {
@@ -64,10 +80,12 @@ public class ScriptRunner {
public static void createGlobalScript(List<String> scripts, Player player) {
remove(player);
SWPlayer swPlayer = SWPlayer.of(player);
ScriptData scriptData = swPlayer.getComponentOrDefault(ScriptData.class, ScriptData::new);
Globals globals = SteamWarPlatform.createGlobalGlobals(player,
(s, luaFunction) -> EVENT_MAP.computeIfAbsent(player, player1 -> new EnumMap<>(SteamWarGlobalLuaPlugin.EventType.class)).computeIfAbsent(s, s1 -> new ArrayList<>()).add(luaFunction),
(s, luaFunction) -> HOTKEY_MAP.computeIfAbsent(player, player1 -> new HashMap<>()).computeIfAbsent(Hotkey.fromString(s), s1 -> new ArrayList<>()).add(luaFunction),
commandRegister -> COMMAND_MAP.computeIfAbsent(player, player1 -> new HashMap<>()).put(commandRegister.getName(), commandRegister));
(s, luaFunction) -> scriptData.events.computeIfAbsent(s, s1 -> new ArrayList<>()).add(luaFunction),
(s, luaFunction) -> scriptData.hotkeys.computeIfAbsent(Hotkey.fromString(s), s1 -> new ArrayList<>()).add(luaFunction),
commandRegister -> scriptData.commands.put(commandRegister.getName(), commandRegister));
for (String script : scripts) {
catchScript("SCRIPT_ERROR_GLOBAL", player, () -> globals.load(script).call());
@@ -75,13 +93,14 @@ public class ScriptRunner {
}
public static void remove(Player player) {
EVENT_MAP.remove(player);
COMMAND_MAP.remove(player);
HOTKEY_MAP.remove(player);
SWPlayer.of(player).removeComponent(ScriptData.class);
}
public static void callEvent(Player player, SteamWarGlobalLuaPlugin.EventType event, LuaValue eventValue, Event wrappedEvent) {
List<LuaFunction> luaFunctions = EVENT_MAP.getOrDefault(player, Collections.emptyMap()).getOrDefault(event, Collections.emptyList());
List<LuaFunction> luaFunctions = SWPlayer.of(player).getComponent(ScriptData.class)
.map(scriptData -> scriptData.events)
.orElse(Collections.emptyMap())
.getOrDefault(event, Collections.emptyList());
if (luaFunctions.isEmpty()) {
if(event == SteamWarGlobalLuaPlugin.EventType.DoubleSwap) {
player.performCommand("gui");
@@ -124,7 +143,10 @@ public class ScriptRunner {
}
public static boolean callCommand(Player player, String command, String[] argsArray) {
CommandRegister commandRegister = COMMAND_MAP.getOrDefault(player, Collections.emptyMap()).get(command);
CommandRegister commandRegister = SWPlayer.of(player).getComponent(ScriptData.class)
.map(scriptData -> scriptData.commands)
.orElse(Collections.emptyMap())
.get(command);
if (commandRegister == null) {
return false;
}
@@ -188,7 +210,11 @@ public class ScriptRunner {
public static void callHotkey(int mods, int key, Player player, boolean pressed) {
Hotkey hotkey = Hotkey.fromChar(key, mods);
catchScript("SCRIPT_ERROR_GLOBAL", player, () -> HOTKEY_MAP.getOrDefault(player, Collections.emptyMap()).getOrDefault(hotkey, Collections.emptyList()).forEach(luaFunction -> luaFunction.call(LuaValue.valueOf(pressed))));
List<LuaFunction> hotkeys = SWPlayer.of(player).getComponent(ScriptData.class)
.map(scriptData -> scriptData.hotkeys)
.orElse(Collections.emptyMap())
.getOrDefault(hotkey, Collections.emptyList());
catchScript("SCRIPT_ERROR_GLOBAL", player, () -> hotkeys.forEach(luaFunction -> luaFunction.call(LuaValue.valueOf(pressed))));
}
public static void catchScript(String errorMsg, Player player, Runnable run) {

View File

@@ -21,44 +21,24 @@ package de.steamwar.bausystem.features.script.event;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.features.script.ScriptRunner;
import de.steamwar.core.SWPlayer;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@Linked
public class CommandListener implements Listener {
private Map<Player, Set<String>> calledCommands = new HashMap<>();
@EventHandler
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
String[] split = event.getMessage().split(" ");
if (calledCommands.getOrDefault(event.getPlayer(), new HashSet<>()).contains(split[0])) {
return;
}
ScriptRunner.ScriptData scriptData = SWPlayer.of(event.getPlayer()).getComponentOrDefault(ScriptRunner.ScriptData.class, ScriptRunner.ScriptData::new);
if (scriptData.getCalledCommands().contains(split[0])) return;
calledCommands.getOrDefault(event.getPlayer(), new HashSet<>()).add(split[0]);
scriptData.getCalledCommands().add(split[0]);
event.setCancelled(ScriptRunner.callCommand(event.getPlayer(), split[0].substring(1), split));
calledCommands.getOrDefault(event.getPlayer(), new HashSet<>()).remove(split[0]);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
calledCommands.put(event.getPlayer(), new HashSet<>());
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
calledCommands.remove(event.getPlayer());
scriptData.getCalledCommands().remove(split[0]);
}
}

View File

@@ -25,6 +25,7 @@ import de.steamwar.bausystem.features.script.ScriptRunner;
import de.steamwar.bausystem.features.script.lua.SteamWarGlobalLuaPlugin;
import de.steamwar.bausystem.features.script.lua.libs.StorageLib;
import de.steamwar.bausystem.region.Region;
import de.steamwar.core.SWPlayer;
import de.steamwar.core.TrickyTrialsWrapper;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
@@ -43,32 +44,27 @@ import org.bukkit.event.player.*;
import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaValue;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@Linked
public class EventListener implements Listener {
private static final Map<Player, Long> LAST_FS = new HashMap<>();
static {
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
long millis = System.currentTimeMillis();
LAST_FS.entrySet().removeIf(entry -> millis - entry.getValue() > 200);
SWPlayer.allWithSingleComponent(ScriptRunner.ScriptData.class)
.filter(pair -> millis - pair.getComponent().getLastF() > 200)
.forEach(pair -> pair.getComponent().setLastF(Long.MAX_VALUE));
}, 1, 1);
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfJoin, LuaValue.NIL, event);
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerQuit(PlayerQuitEvent event) {
if(Permission.BUILD.hasPermission(event.getPlayer())) {
if (Permission.BUILD.hasPermission(event.getPlayer())) {
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.SelfLeave, LuaValue.NIL, event);
}
StorageLib.removePlayer(event.getPlayer());
@@ -76,19 +72,20 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (LAST_FS.containsKey(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
ScriptRunner.ScriptData scriptData = SWPlayer.of(event.getPlayer()).getComponentOrDefault(ScriptRunner.ScriptData.class, ScriptRunner.ScriptData::new);
if (scriptData.getLastF() != Long.MAX_VALUE) {
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.DoubleSwap, LuaValue.NIL, event);
}, 1);
} else {
LAST_FS.put(event.getPlayer(), System.currentTimeMillis());
scriptData.setLastF(System.currentTimeMillis());
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onBlockPlace(BlockPlaceEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
LuaTable table = new LuaTable();
table.set("x", event.getBlock().getX());
table.set("y", event.getBlock().getY());
@@ -99,7 +96,7 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
LuaTable table = new LuaTable();
table.set("x", event.getBlock().getX());
table.set("y", event.getBlock().getY());
@@ -108,12 +105,12 @@ public class EventListener implements Listener {
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.BreakBlock, table, event);
}
private final Set<Player> ignore = new HashSet<>();
@EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(PlayerInteractEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (ignore.remove(event.getPlayer())) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
ScriptRunner.ScriptData scriptData = SWPlayer.of(event.getPlayer()).getComponentOrDefault(ScriptRunner.ScriptData.class, ScriptRunner.ScriptData::new);
if (scriptData.isIgnore()) {
scriptData.setIgnore(false);
return;
}
LuaTable table = new LuaTable();
@@ -124,7 +121,7 @@ public class EventListener implements Listener {
table.set("hand", event.getHand().name());
}
table.set("block", event.getItem() == null ? Material.AIR.name() : event.getItem().getType().name());
if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) {
if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_BLOCK) {
table.set("hasBlock", LuaValue.valueOf(true));
table.set("blockX", event.getClickedBlock().getX());
table.set("blockY", event.getClickedBlock().getY());
@@ -150,7 +147,7 @@ public class EventListener implements Listener {
Region tntRegion = Region.getRegion(event.getLocation());
for (Player player : Bukkit.getOnlinePlayers()) {
if(!Permission.BUILD.hasPermission(player)) continue;
if (!Permission.BUILD.hasPermission(player)) continue;
if (tntRegion.getArea().inRegion(player.getLocation(), false)) {
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event);
}
@@ -172,7 +169,7 @@ public class EventListener implements Listener {
boolean inBuild = event.blockList().stream().anyMatch(block -> tntRegion.getBuildArea().inRegion(block.getLocation(), true));
for (Player player : Bukkit.getOnlinePlayers()) {
if(!Permission.BUILD.hasPermission(player)) continue;
if (!Permission.BUILD.hasPermission(player)) continue;
if (tntRegion.getArea().inRegion(player.getLocation(), false)) {
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event);
if (inBuild) {
@@ -184,8 +181,9 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerDropItem(PlayerDropItemEvent event) {
if(!Permission.BUILD.hasPermission(event.getPlayer())) return;
ignore.add(event.getPlayer());
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
ScriptRunner.ScriptData scriptData = SWPlayer.of(event.getPlayer()).getComponentOrDefault(ScriptRunner.ScriptData.class, ScriptRunner.ScriptData::new);
scriptData.setIgnore(true);
LuaTable table = new LuaTable();
table.set("type", event.getItemDrop().getItemStack().getType().name());
ScriptRunner.callEvent(event.getPlayer(), SteamWarGlobalLuaPlugin.EventType.DropItem, table, event);
@@ -194,7 +192,7 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onEntityDeath(EntityDeathEvent event) {
for (Player player : Bukkit.getOnlinePlayers()) {
if(!Permission.BUILD.hasPermission(player)) continue;
if (!Permission.BUILD.hasPermission(player)) continue;
LuaTable table = new LuaTable();
table.set("type", event.getEntityType().name());
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.EntityDeath, table, event);

View File

@@ -48,6 +48,7 @@ import java.util.logging.Level;
public class SteamWarLuaPlugin extends TwoArgFunction {
private static final boolean hasFAWE = Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit") != null;
private static final Set<String> ignoreCommandFromWorldEdit = Set.of("select", "schem", "/schem", "schematic", "/schematic");
protected static final Map<Class<?>, List<LuaLib>> LUA_LIBS = new HashMap<>();
@@ -116,7 +117,7 @@ public class SteamWarLuaPlugin extends TwoArgFunction {
command = preprocessEvent.getMessage().substring(1);
Bukkit.getLogger().log(Level.INFO, player.getName() + " dispatched command: " + command);
String[] commandSplit = command.split(" ");
if (!commandSplit[0].equals("select") && hasFAWE && WorldEditListener.isWorldEditCommand("/" + commandSplit[0])) {
if (!ignoreCommandFromWorldEdit.contains(commandSplit[0]) && hasFAWE && WorldEditListener.isWorldEditCommand("/" + commandSplit[0])) {
EditSession editSession = WorldEditUtils.getEditSession(player);
Actor actor = BukkitAdapter.adapt(player);
WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().handleCommandOnCurrentThread(new CommandEvent(actor, command, editSession));

View File

@@ -59,14 +59,14 @@ public class RegionLib implements LuaLib {
}));
LuaValue tntLib = LuaValue.tableOf();
tntLib.set("mode", getter(() -> region.get().getFlags().get(Flag.TNT).nameWithDefault()));
tntLib.set("enabled", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) != TNTMode.DENY));
tntLib.set("onlyTb", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) == TNTMode.ONLY_TB));
tntLib.set("mode", getter(() -> region.get().getRegionData().get(Flag.TNT).nameWithDefault()));
tntLib.set("enabled", getter(() -> region.get().getRegionData().get(Flag.TNT).orElse(null) != TNTMode.DENY));
tntLib.set("onlyTb", getter(() -> region.get().getRegionData().get(Flag.TNT).orElse(null) == TNTMode.ONLY_TB));
table.set("tnt", tntLib);
table.set("fire", getter(() -> region.get().getFlags().get(Flag.FIRE).orElse(null) == FireMode.ALLOW));
table.set("freeze", getter(() -> region.get().getFlags().get(Flag.FREEZE).orElse(null) == FreezeMode.ACTIVE));
table.set("protect", getter(() -> region.get().getFlags().get(Flag.PROTECT).orElse(null) == ProtectMode.ACTIVE));
table.set("fire", getter(() -> region.get().getRegionData().get(Flag.FIRE).orElse(null) == FireMode.ALLOW));
table.set("freeze", getter(() -> region.get().getRegionData().get(Flag.FREEZE).orElse(null) == FreezeMode.ACTIVE));
table.set("protect", getter(() -> region.get().getRegionData().get(Flag.PROTECT).orElse(null) == ProtectMode.ACTIVE));
//LuaValue traceLib = LuaValue.tableOf();
//traceLib.set("active", getter(() -> !region.get().isGlobal() && Recorder.INSTANCE.get(region.get()) instanceof ActiveTracer));

View File

@@ -89,7 +89,7 @@ public class StorageLib implements LuaLib, Enable, Disable {
jsonObject.keySet().forEach(key -> {
map.put(key, fromJson(jsonObject.get(key)));
});
SteamwarUser steamwarUser = SteamwarUser.get(Integer.parseInt(playerStorage.getName().substring(0, playerStorage.getName().length() - ".json".length())));
SteamwarUser steamwarUser = SteamwarUser.byId(Integer.parseInt(playerStorage.getName().substring(0, playerStorage.getName().length() - ".json".length())));
PLAYER_STORAGE.put(steamwarUser.getUUID(), map);
} catch (Exception e) {}
}

View File

@@ -1,18 +1,20 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator;
@@ -20,9 +22,7 @@ package de.steamwar.bausystem.features.simulator;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.display.SimulatorCursor;
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
import de.steamwar.bausystem.features.simulator.SimulatorCursorManager;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
@@ -40,7 +40,7 @@ import java.util.Collection;
public class SimulatorCommand extends SWCommand {
@LinkedInstance
public SimulatorCursorManager cursorManager;
public SimulatorCursor simulatorCursor;
public SimulatorCommand() {
super("sim", "simulator");
@@ -49,12 +49,12 @@ public class SimulatorCommand extends SWCommand {
@Register(description = "SIMULATOR_HELP")
public void genericCommand(@Validator Player p) {
SWUtils.giveItemToPlayer(p, SimulatorStorage.getWand(p));
cursorManager.showCursor(p, null);
simulatorCursor.calcCursor(p);
}
@Register(value = "change", description = "SIMULATOR_CHANGE_HELP")
public void change(@Validator Player p) {
if (!SimulatorUtils.isSimulatorItem(p.getInventory().getItemInMainHand()) && !SimulatorUtils.isSimulatorItem(p.getInventory().getItemInOffHand())) {
if (!SimulatorCursor.isSimulatorItem(p.getInventory().getItemInMainHand()) && !SimulatorCursor.isSimulatorItem(p.getInventory().getItemInOffHand())) {
BauSystem.MESSAGE.send("SIMULATOR_NO_SIM_IN_HAND", p);
return;
}

View File

@@ -0,0 +1,472 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.Reflection;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
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.SimulatorExecutor;
import de.steamwar.bausystem.features.simulator.gui.SimulatorGroupGui;
import de.steamwar.bausystem.features.simulator.gui.SimulatorGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
import de.steamwar.bausystem.utils.ItemUtils;
import de.steamwar.bausystem.utils.RayTraceUtils;
import de.steamwar.entity.REntity;
import de.steamwar.entity.REntityServer;
import de.steamwar.entity.RFallingBlockEntity;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.MinVersion;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.stream.Collectors;
@Linked
@MinVersion(19)
public class SimulatorCursor implements Listener {
private static final World WORLD = Bukkit.getWorlds().get(0);
private Class<?> position = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Pos");
private Class<?> look = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$Rot");
private Class<?> positionLook = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundMovePlayerPacket$PosRot");
private static Map<Player, CursorType> cursorType = Collections.synchronizedMap(new HashMap<>());
private static Map<Player, REntityServer> cursors = Collections.synchronizedMap(new HashMap<>());
private static final Set<Player> calculating = new HashSet<>();
public static boolean isSimulatorItem(ItemStack itemStack) {
return ItemUtils.isItem(itemStack, "simulator");
}
public SimulatorCursor() {
BiFunction<Player, Object, Object> function = (player, object) -> {
calcCursor(player);
return object;
};
TinyProtocol.instance.addFilter(position, function);
TinyProtocol.instance.addFilter(look, function);
TinyProtocol.instance.addFilter(positionLook, function);
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
calcCursor(event.getPlayer());
}, 0);
}
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
calcCursor(event.getPlayer());
}
@EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent event) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
calcCursor(event.getPlayer());
}, 1);
}
@EventHandler
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
event.getChanged().forEach(SimulatorCursor::calcCursor);
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
cursorType.remove(event.getPlayer());
cursors.remove(event.getPlayer());
synchronized (calculating) {
calculating.remove(event.getPlayer());
}
}
private static final Map<Player, Long> LAST_SNEAKS = new HashMap<>();
static {
Bukkit.getScheduler().runTaskTimer(BauSystem.getInstance(), () -> {
long millis = System.currentTimeMillis();
LAST_SNEAKS.entrySet().removeIf(entry -> millis - entry.getValue() > 200);
}, 1, 1);
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
if (!event.isSneaking()) return;
Player player = event.getPlayer();
if (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand())) {
return;
}
if (LAST_SNEAKS.containsKey(player)) {
CursorType currentType = cursorType.getOrDefault(player, CursorType.TNT);
if (currentType == CursorType.TNT) {
cursorType.put(player, CursorType.REDSTONE_BLOCK);
} else {
cursorType.put(player, CursorType.TNT);
}
calcCursor(player);
} else {
LAST_SNEAKS.put(player, System.currentTimeMillis());
}
}
public static CursorType getCursorType(Player player) {
return cursorType.getOrDefault(player, CursorType.TNT);
}
public static void setCursorType(Player player, CursorType cursorType) {
SimulatorCursor.cursorType.put(player, cursorType);
calcCursor(player);
}
public static void calcCursor(Player player) {
synchronized (calculating) {
if (calculating.contains(player)) return;
calculating.add(player);
}
if (!Permission.BUILD.hasPermission(player) || (!isSimulatorItem(player.getInventory().getItemInMainHand()) && !isSimulatorItem(player.getInventory().getItemInOffHand()))) {
if (removeCursor(player) || SimulatorWatcher.show(null, player)) {
SWUtils.sendToActionbar(player, "");
}
synchronized (calculating) {
calculating.remove(player);
}
return;
}
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) {
removeCursor(player);
if (simulator == null) {
SWUtils.sendToActionbar(player, "§eSelect Simulator");
} else {
SWUtils.sendToActionbar(player, "§eOpen Simulator");
}
synchronized (calculating) {
calculating.remove(player);
}
return;
}
showCursor(player, rayTraceResult, simulator != null);
synchronized (calculating) {
calculating.remove(player);
}
}
private static synchronized boolean removeCursor(Player player) {
REntityServer entityServer = cursors.get(player);
boolean hadCursor = entityServer != null && !entityServer.getEntities().isEmpty();
if (entityServer != null) {
entityServer.getEntities().forEach(REntity::die);
}
return hadCursor;
}
private static synchronized void showCursor(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, boolean hasSimulatorSelected) {
REntityServer entityServer = cursors.computeIfAbsent(player, __ -> {
REntityServer rEntityServer = new REntityServer();
rEntityServer.addPlayer(player);
return rEntityServer;
});
CursorType type = cursorType.getOrDefault(player, CursorType.TNT);
REntity hitEntity = rayTraceResult.getHitEntity();
Location location = hitEntity != null ? new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ()).toLocation(WORLD) :
type.position.apply(player, rayTraceResult).toLocation(WORLD);
Material material = hitEntity != null ? Material.GLASS : type.getMaterial();
List<RFallingBlockEntity> entities = entityServer.getEntitiesByType(RFallingBlockEntity.class);
entities.removeIf(rFallingBlockEntity -> {
if (rFallingBlockEntity.getMaterial() != material) {
rFallingBlockEntity.die();
return true;
}
rFallingBlockEntity.move(location);
return false;
});
if (entities.isEmpty()) {
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(entityServer, location, material);
rFallingBlockEntity.setNoGravity(true);
if (material == Material.GLASS) {
rFallingBlockEntity.setGlowing(true);
}
}
if (hasSimulatorSelected) {
if (hitEntity != null) {
SWUtils.sendToActionbar(player, "§eEdit Position");
} else {
SWUtils.sendToActionbar(player, "§eAdd new " + type.name);
}
} else {
SWUtils.sendToActionbar(player, "§eCreate new Simulator");
}
}
public static Vector getPosFree(Player player, RayTraceUtils.RRayTraceResult result) {
Vector pos = result.getHitPosition();
BlockFace face = result.getHitBlockFace();
if (face != null) {
switch (face) {
case DOWN:
pos.setY(pos.getY() - 0.98);
break;
case EAST:
pos.setX(pos.getX() + 0.49);
break;
case WEST:
pos.setX(pos.getX() - 0.49);
break;
case NORTH:
pos.setZ(pos.getZ() - 0.49);
break;
case SOUTH:
pos.setZ(pos.getZ() + 0.49);
break;
default:
break;
}
if (face.getModY() == 0 && player.isSneaking()) {
pos.setY(pos.getY() - 0.49);
}
}
if (!player.isSneaking()) {
pos.setX(pos.getBlockX() + 0.5);
if (face == null || face.getModY() == 0)
pos.setY(pos.getBlockY() + 0.0);
pos.setZ(pos.getBlockZ() + 0.5);
}
return pos;
}
private static Vector getPosBlockAligned(Player player, RayTraceUtils.RRayTraceResult result) {
Vector pos = result.getHitPosition();
BlockFace face = result.getHitBlockFace();
if (face != null) {
switch (face) {
case DOWN:
pos.setY(pos.getY() - 0.98);
break;
case EAST:
pos.setX(pos.getX() + 0.49);
break;
case WEST:
pos.setX(pos.getX() - 0.49);
break;
case NORTH:
pos.setZ(pos.getZ() - 0.49);
break;
case SOUTH:
pos.setZ(pos.getZ() + 0.49);
break;
default:
break;
}
}
pos.setX(pos.getBlockX() + 0.5);
if (pos.getY() - pos.getBlockY() != 0 && face == BlockFace.UP) {
pos.setY(pos.getBlockY() + 1.0);
} else {
pos.setY(pos.getBlockY());
}
pos.setZ(pos.getBlockZ() + 0.5);
return pos;
}
@Getter
@AllArgsConstructor
public enum CursorType {
TNT(Material.TNT, Material.GUNPOWDER, SimulatorCursor::getPosFree, "TNT", vector -> new TNTElement(vector).add(new TNTPhase())),
REDSTONE_BLOCK(Material.REDSTONE_BLOCK, Material.REDSTONE, SimulatorCursor::getPosBlockAligned, "Redstone Block", vector -> new RedstoneElement(vector).add(new RedstonePhase())),
OBSERVER(Material.OBSERVER, Material.QUARTZ, SimulatorCursor::getPosBlockAligned, "Observer", vector -> new ObserverElement(vector).add(new ObserverPhase())),
;
public final Material material;
public final Material nonSelectedMaterial;
public final BiFunction<Player, RayTraceUtils.RRayTraceResult, Vector> position;
public final String name;
public final Function<Vector, SimulatorElement<?>> elementFunction;
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (!Permission.BUILD.hasPermission(event.getPlayer())) return;
if (!ItemUtils.isItem(event.getItem(), "simulator")) {
return;
}
event.setCancelled(true);
Player player = event.getPlayer();
Simulator simulator = SimulatorStorage.getSimulator(player);
if (event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.LEFT_CLICK_AIR) {
if (simulator == null) {
return;
}
SimulatorExecutor.run(event.getPlayer(), simulator, null);
return;
}
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.RIGHT_CLICK_AIR) {
return;
}
RayTraceUtils.RRayTraceResult rayTraceResult = RayTraceUtils.traceREntity(player, player.getLocation(), SimulatorWatcher.getEntitiesOfSimulator(simulator));
if (simulator == null) {
if (rayTraceResult == null) {
SimulatorStorage.openSimulatorSelector(player);
} else {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Name");
anvilInv.setCallback(s -> {
Simulator sim = SimulatorStorage.getSimulator(s);
if (sim != null) {
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", player);
return;
}
if (!s.matches("[a-zA-Z_0-9-]+")) {
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", player);
return;
}
sim = new Simulator(s);
SimulatorStorage.addSimulator(s, sim);
createElement(player, rayTraceResult, sim);
SimulatorStorage.setSimulator(player, sim);
});
anvilInv.open();
}
return;
}
if (rayTraceResult == null) {
new SimulatorGui(player, simulator).open();
return;
}
if (rayTraceResult.getHitEntity() != null) {
REntity hitEntity = rayTraceResult.getHitEntity();
Vector vector = new Vector(hitEntity.getX(), hitEntity.getY(), hitEntity.getZ());
List<SimulatorElement<?>> elements = simulator.getGroups().stream().map(SimulatorGroup::getElements).flatMap(List::stream).filter(element -> {
return element.getWorldPos().distanceSquared(vector) < (1 / 16.0) * (1 / 16.0);
}).collect(Collectors.toList());
switch (elements.size()) {
case 0:
return;
case 1:
// Open single element present in Simulator
SimulatorElement<?> element = elements.get(0);
SimulatorGroup group1 = element.getGroup(simulator);
SimulatorBaseGui back = new SimulatorGui(player, simulator);
if (group1.getElements().size() > 1) {
back = new SimulatorGroupGui(player, simulator, group1, back);
}
element.open(player, simulator, group1, back);
break;
default:
List<SimulatorGroup> parents = elements.stream().map(e -> e.getGroup(simulator)).distinct().collect(Collectors.toList());
if (parents.size() == 1) {
// Open multi element present in Simulator in existing group
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
new SimulatorGroupGui(player, simulator, parents.get(0), simulatorGui).open();
} else {
// Open multi element present in Simulator in implicit group
SimulatorGroup group2 = new SimulatorGroup();
group2.setMaterial(null);
group2.getElements().addAll(elements);
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
new SimulatorGroupGui(player, simulator, group2, simulatorGui).open();
}
break;
}
return;
}
// Add new Element to current simulator
createElement(player, rayTraceResult, simulator);
}
private void createElement(Player player, RayTraceUtils.RRayTraceResult rayTraceResult, Simulator simulator) {
CursorType type = cursorType.getOrDefault(player, CursorType.TNT);
Vector vector = type.position.apply(player, rayTraceResult);
if (type == CursorType.REDSTONE_BLOCK) {
vector.subtract(new Vector(0.5, 0, 0.5));
}
SimulatorElement<?> element = type.elementFunction.apply(vector);
SimulatorGroup group = new SimulatorGroup().add(element);
simulator.getGroups().add(group);
SimulatorGui simulatorGui = new SimulatorGui(player, simulator);
element.open(player, simulator, group, simulatorGui);
SimulatorWatcher.update(simulator);
calcCursor(player);
}
}

View File

@@ -1,103 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.display.ASimulatorCursor;
import de.steamwar.bausystem.features.simulator.display.EmptySimulatorCursor;
import de.steamwar.bausystem.features.simulator.display.SimulatorCursor;
import de.steamwar.bausystem.features.simulator.display.SimulatorCursorMode;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.MinVersion;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.*;
import org.bukkit.inventory.ItemStack;
import java.util.*;
// TODO fix memory leak when players leave the server
// TODO fix cursor not being hidden when player deequips simulator item
@Linked
@MinVersion(19)
public class SimulatorCursorManager implements Listener {
public static final SimulatorCursorManager INSTANCE = new SimulatorCursorManager();
private final Map<Player, Map<Simulator, ASimulatorCursor>> openCursorsByPlayerBySimulator = new HashMap<>();
private final Map<Player, ASimulatorCursor> activeCursorByPlayer = new HashMap<>();
@EventHandler
public void onPlayerItemEquip(PlayerItemHeldEvent event) {
ItemStack newItem = event.getPlayer().getInventory().getItem(event.getNewSlot());
if (SimulatorUtils.isSimulatorItem(newItem)) {
Simulator simulator = SimulatorStorage.getSimulator(newItem);
showCursor(event.getPlayer(), simulator);
}
}
/**
* Shows the cursor for the given simulator to the given player. Shows an empty cursor if the
* simulator is null.
*/
public void showCursor(Player player, Simulator simulator) {
var currentActiveCursor = activeCursorByPlayer.get(player);
if (currentActiveCursor != null) {
currentActiveCursor.hide();
}
var cursorMode = currentActiveCursor != null ? currentActiveCursor.getCursorMode() : SimulatorCursorMode.TNT;
var cursorsBySimulator = openCursorsByPlayerBySimulator.computeIfAbsent(player, __ -> new HashMap<>());
var cursor = cursorsBySimulator.get(simulator);
if (cursor == null) {
if (simulator == null) {
ASimulatorCursor emptyCursor = new EmptySimulatorCursor(player, cursorMode);
cursorsBySimulator.put(simulator, emptyCursor);
cursor = emptyCursor;
} else {
ASimulatorCursor newCursor = new SimulatorCursor(simulator, player, cursorMode);
cursorsBySimulator.put(simulator, newCursor);
cursor = newCursor;
}
}
cursor.show();
}
public Optional<SimulatorCursorMode> getActiveCursorMode(Player player) {
var currentActiveCursor = activeCursorByPlayer.get(player);
if (currentActiveCursor != null) {
return Optional.of(currentActiveCursor.getCursorMode());
} else {
return Optional.empty();
}
}
public void setActiveCursorMode(Player player, SimulatorCursorMode mode) {
var currentActiveCursor = activeCursorByPlayer.get(player);
if (currentActiveCursor != null) {
currentActiveCursor.setCursorMode(mode);
}
}
}

View File

@@ -1,18 +1,20 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator;
@@ -54,13 +56,12 @@ public class SimulatorStorage implements Enable {
public static Simulator getSimulator(Player player) {
Simulator simulator = getSimulator(player.getInventory().getItemInMainHand());
if (simulator != null)
return simulator;
if (simulator != null) return simulator;
return getSimulator(player.getInventory().getItemInOffHand());
}
public static Simulator getSimulator(ItemStack itemStack) {
if (!SimulatorUtils.isSimulatorItem(itemStack)) {
if (!SimulatorCursor.isSimulatorItem(itemStack)) {
return null;
}
String selection = ItemUtils.getTag(itemStack, simulatorSelection);
@@ -85,11 +86,11 @@ public class SimulatorStorage implements Enable {
YAPIONFormatSimulatorLoader yapionFormatSimulatorLoader = new YAPIONFormatSimulatorLoader();
File[] files = simulatorsDir.listFiles();
if (files == null)
return;
if (files == null) return;
for (File file : files) {
try {
List<Simulator> simulators = simFormatSimulatorLoader.load(file).orElse(null);
List<Simulator> simulators = simFormatSimulatorLoader.load(file)
.orElse(null);
if (simulators != null) {
simulators.forEach(simulator -> {
simulatorMap.put(simulator.getName(), simulator);
@@ -101,7 +102,8 @@ public class SimulatorStorage implements Enable {
}
try {
List<Simulator> simulators = simulatorFormatSimulatorLoader.load(file).orElse(null);
List<Simulator> simulators = simulatorFormatSimulatorLoader.load(file)
.orElse(null);
if (simulators != null) {
simulators.forEach(simulator -> {
simulatorMap.put(simulator.getName(), simulator);
@@ -114,7 +116,8 @@ public class SimulatorStorage implements Enable {
}
try {
List<Simulator> simulators = yapionFormatSimulatorLoader.load(file).orElse(null);
List<Simulator> simulators = yapionFormatSimulatorLoader.load(file)
.orElse(null);
if (simulators != null) {
simulators.forEach(simulator -> {
simulatorMap.put(simulator.getName(), simulator);
@@ -128,8 +131,7 @@ public class SimulatorStorage implements Enable {
}
public static void openSimulatorSelector(Player player) {
SimulatorPageGui<Simulator> simulatorPageGui = new SimulatorPageGui<Simulator>(player, null, 6 * 9,
simulatorMap.values().stream().sorted(Comparator.comparing(Simulator::getName)).collect(Collectors.toList())) {
SimulatorPageGui<Simulator> simulatorPageGui = new SimulatorPageGui<Simulator>(player, null, 6 * 9, simulatorMap.values().stream().sorted(Comparator.comparing(Simulator::getName)).collect(Collectors.toList())) {
@Override
public String baseTitle() {
return "Simulators";
@@ -169,11 +171,7 @@ public class SimulatorStorage implements Enable {
}
public static ItemStack getWand(Player p) {
ItemStack itemStack = new SWItem(Material.BLAZE_ROD, BauSystem.MESSAGE.parse("SIMULATOR_WAND_NAME", p),
Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_1", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_2", p),
BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_3", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_4", p),
BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_5", p)),
false, null).getItemStack();
ItemStack itemStack = new SWItem(Material.BLAZE_ROD, BauSystem.MESSAGE.parse("SIMULATOR_WAND_NAME", p), Arrays.asList(BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_1", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_2", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_3", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_4", p), BauSystem.MESSAGE.parse("SIMULATOR_WAND_LORE_5", p)), false, null).getItemStack();
ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setCustomModelData(1);
itemStack.setItemMeta(itemMeta);
@@ -185,9 +183,9 @@ public class SimulatorStorage implements Enable {
ItemStack mainHand = player.getInventory().getItemInMainHand();
ItemStack offHand = player.getInventory().getItemInOffHand();
ItemStack itemStack;
if (SimulatorUtils.isSimulatorItem(mainHand)) {
if (SimulatorCursor.isSimulatorItem(mainHand)) {
itemStack = mainHand;
} else if (SimulatorUtils.isSimulatorItem(offHand)) {
} else if (SimulatorCursor.isSimulatorItem(offHand)) {
itemStack = offHand;
} else {
itemStack = null;

View File

@@ -1,12 +0,0 @@
package de.steamwar.bausystem.features.simulator;
import org.bukkit.inventory.ItemStack;
import de.steamwar.bausystem.utils.ItemUtils;
import lombok.experimental.UtilityClass;
@UtilityClass
public class SimulatorUtils {
public static boolean isSimulatorItem(ItemStack itemStack) {
return ItemUtils.isItem(itemStack, "simulator");
}
}

View File

@@ -0,0 +1,129 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.storage.SimulatorSaver;
import de.steamwar.bausystem.shared.Pair;
import de.steamwar.entity.REntity;
import de.steamwar.entity.REntityServer;
import de.steamwar.entity.RFallingBlockEntity;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.MinVersion;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
@UtilityClass
public class SimulatorWatcher {
private final World WORLD = Bukkit.getWorlds().get(0);
private Map<Simulator, REntityServer> entityServers = new HashMap<>();
private Map<Player, Pair<Simulator, Runnable>> watchers = new HashMap<>();
public void watch(Player player, Simulator simulator, Runnable watcher) {
if (simulator == null || watcher == null) {
watchers.remove(player);
} else {
watchers.put(player, new Pair<>(simulator, watcher));
}
}
public synchronized void update(Simulator simulator) {
REntityServer rEntityServer = entityServers.get(simulator);
if (rEntityServer != null) {
rEntityServer.getEntities().forEach(REntity::die);
createSim(rEntityServer, simulator);
}
new ArrayList<>(watchers.values()).forEach(simulatorRunnablePair -> {
if (simulatorRunnablePair.getKey() == simulator) {
simulatorRunnablePair.getValue().run();
}
});
SimulatorSaver.saveSimulator(SimulatorStorage.simulatorsDir, simulator);
}
@Linked
@MinVersion(19)
public static class QuitListener implements Listener {
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
watchers.remove(event.getPlayer());
show(null, event.getPlayer());
}
}
private REntityServer createSim(REntityServer server, Simulator simulator) {
if (simulator == null) {
return null;
}
Map<Vector, Set<Class<?>>> positionCache = new HashMap<>();
simulator.getGroups().stream().map(group -> group.getElements().stream().map(element -> new Pair<>(group, element)).collect(Collectors.toList())).flatMap(List::stream).forEach(pair -> {
SimulatorGroup group = pair.getKey();
SimulatorElement<?> element = pair.getValue();
boolean wasNotPresent = positionCache.computeIfAbsent(element.getPosition(), __ -> new HashSet<>())
.add(element.getClass());
if (!wasNotPresent) return;
Material material = group.isDisabled() || element.isDisabled() ? element.getWorldDisabledMaterial() : element.getWorldMaterial();
Location location = element.getWorldPos().toLocation(WORLD);
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(server, location, material);
rFallingBlockEntity.setNoGravity(true);
});
return server;
}
public synchronized boolean show(Simulator sim, Player player) {
AtomicBoolean removed = new AtomicBoolean();
entityServers.forEach((simulator, rEntityServer) -> {
if (rEntityServer == null) return;
if (rEntityServer.getPlayers().contains(player) && sim != simulator) {
rEntityServer.removePlayer(player);
removed.set(true);
}
});
if (sim == null) return removed.get();
entityServers.computeIfAbsent(sim, __ -> createSim(new REntityServer(), sim)).addPlayer(player);
return removed.get();
}
synchronized List<REntity> getEntitiesOfSimulator(Simulator simulator) {
REntityServer entityServer = entityServers.get(simulator);
if (entityServer == null) {
return Collections.emptyList();
}
return entityServer.getEntities();
}
}

View File

@@ -65,7 +65,7 @@ public final class TNTPhase extends SimulatorPhase {
@Override
public void accept(World world) {
Location location = position.toLocation(world);
if (Region.getRegion(location).getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) return;
if (Region.getRegion(location).getRegionData().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) return;
TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));

View File

@@ -1,54 +0,0 @@
package de.steamwar.bausystem.features.simulator.display;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import de.steamwar.bausystem.utils.cursor.Cursor;
import de.steamwar.entity.REntityServer;
import lombok.Getter;
public abstract class ASimulatorCursor extends Cursor implements Listener {
protected final Player owner;
@Getter
protected SimulatorCursorMode cursorMode;
protected ASimulatorCursor(Player owner, REntityServer targetServer, SimulatorCursorMode cursorMode) {
super(targetServer, owner, Material.GLASS, Material.TNT, List.of(Cursor.CursorMode.FREE, Cursor.CursorMode.BLOCK_ALIGNED));
this.cursorMode = cursorMode;
this.owner = owner;
}
public void swapCursorMode() {
cursorMode = cursorMode.switchType();
setCursorMaterial(cursorMode.getMaterial());
setAllowedCursorModes(cursorMode.getAllowedCursorModes());
}
public void setCursorMode(SimulatorCursorMode mode) {
this.cursorMode = mode;
setCursorMaterial(cursorMode.getMaterial());
setAllowedCursorModes(cursorMode.getAllowedCursorModes());
}
public void hide() {
super.hide();
super.getTargetServer().removePlayer(owner);
}
public void show() {
super.show();
super.getTargetServer().addPlayer(owner);
}
@EventHandler
public void onPlayerShift(PlayerToggleSneakEvent event) {
if (event.getPlayer() != owner) {
return;
}
swapCursorMode();
}
}

View File

@@ -1,47 +0,0 @@
package de.steamwar.bausystem.features.simulator.display;
import java.util.Optional;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.entity.REntityServer;
import de.steamwar.inventory.SWAnvilInv;
public class EmptySimulatorCursor extends ASimulatorCursor {
public EmptySimulatorCursor(Player owner, SimulatorCursorMode cursorMode) {
super(owner, new REntityServer(), cursorMode);
}
@Override
public void onClick(Optional<Location> clickedLocation, boolean clickedOnEntity, Action clickAction) {
if (clickAction == Action.RIGHT_CLICK_AIR) {
SimulatorStorage.openSimulatorSelector(owner);
} else if (clickAction == Action.RIGHT_CLICK_BLOCK) {
SWAnvilInv anvilInv = new SWAnvilInv(owner, "Name");
anvilInv.setCallback(name -> {
Simulator sim = SimulatorStorage.getSimulator(name);
if (sim != null) {
BauSystem.MESSAGE.send("SIMULATOR_NAME_ALREADY_EXISTS", owner);
return;
}
if (!name.matches("[a-zA-Z_0-9-]+")) {
BauSystem.MESSAGE.send("SIMULATOR_NAME_INVALID", owner);
return;
}
sim = new Simulator(name);
SimulatorStorage.addSimulator(name, sim);
SimulatorElement<?> element = cursorMode.getElementFunction().apply(clickedLocation.get().toVector());
SimulatorGroup group = new SimulatorGroup();
group.add(element);
sim.add(group);
SimulatorStorage.setSimulator(owner, sim);
});
anvilInv.open();
}
}
}

View File

@@ -1,69 +0,0 @@
package de.steamwar.bausystem.features.simulator.display;
import java.util.List;
import java.util.Optional;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.util.Vector;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.execute.SimulatorExecutor;
import de.steamwar.bausystem.features.simulator.gui.SimulatorGroupGui;
import de.steamwar.bausystem.features.simulator.gui.SimulatorGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
public class SimulatorCursor extends ASimulatorCursor {
private final Simulator simulator;
public SimulatorCursor(Simulator simulator, Player owner, SimulatorCursorMode cursorMode) {
super(owner, SimulatorRenderer.renderSimulator(simulator), cursorMode);
this.simulator = simulator;
}
@Override
public void onClick(Optional<Location> clickedLocation, boolean clickedOnEntity, Action clickAction) {
if (clickAction == Action.LEFT_CLICK_AIR || clickAction == Action.LEFT_CLICK_BLOCK) {
SimulatorExecutor.run(owner, simulator, null);
} else if (!clickedOnEntity || clickedLocation.isEmpty()) {
new SimulatorGui(owner, simulator);
} else {
Vector vector = clickedLocation.get().toVector();
List<SimulatorElement<?>> elements = simulator.getGroups().stream().map(SimulatorGroup::getElements).flatMap(List::stream)
.filter(element -> element.getWorldPos().distanceSquared(vector) < (1 / 16.0) * (1 / 16.0)).toList();
switch (elements.size()) {
case 0:
return;
case 1:
// Open single element present in Simulator
SimulatorElement<?> element = elements.get(0);
SimulatorGroup group1 = element.getGroup(simulator);
SimulatorBaseGui back = new SimulatorGui(owner, simulator);
if (group1.getElements().size() > 1) {
back = new SimulatorGroupGui(owner, simulator, group1, back);
}
element.open(owner, simulator, group1, back);
break;
default:
List<SimulatorGroup> parents = elements.stream().map(e -> e.getGroup(simulator)).distinct().toList();
if (parents.size() == 1) {
// Open multi element present in Simulator in existing group
SimulatorGui simulatorGui = new SimulatorGui(owner, simulator);
new SimulatorGroupGui(owner, simulator, parents.get(0), simulatorGui).open();
} else {
// Open multi element present in Simulator in implicit group
SimulatorGroup group2 = new SimulatorGroup();
group2.setMaterial(null);
group2.getElements().addAll(elements);
SimulatorGui simulatorGui = new SimulatorGui(owner, simulator);
new SimulatorGroupGui(owner, simulator, group2, simulatorGui).open();
}
break;
}
}
}
}

View File

@@ -1,41 +0,0 @@
package de.steamwar.bausystem.features.simulator.display;
import java.util.List;
import java.util.function.Function;
import org.bukkit.Material;
import org.bukkit.util.Vector;
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
import de.steamwar.bausystem.utils.cursor.Cursor.CursorMode;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum SimulatorCursorMode {
TNT(Material.TNT, Material.GUNPOWDER, "TNT", vector -> new TNTElement(vector).add(new TNTPhase()),
List.of(CursorMode.FREE, CursorMode.BLOCK_ALIGNED)), REDSTONE_BLOCK(Material.REDSTONE_BLOCK, Material.REDSTONE_WIRE, "Redstone Block",
vector -> new RedstoneElement(vector).add(new RedstonePhase()), List.of(CursorMode.BLOCK_ALIGNED)), OBSERVER(Material.OBSERVER, Material.QUARTZ,
"Observer", vector -> new ObserverElement(vector).add(new ObserverPhase()), List.of(CursorMode.BLOCK_ALIGNED)),;
public final Material material;
public final Material nonSelectedMaterial;
public final String name;
public final Function<Vector, SimulatorElement<?>> elementFunction;
public final List<CursorMode> allowedCursorModes;
public SimulatorCursorMode switchType() {
if (this == TNT) {
return REDSTONE_BLOCK;
}
if (this == REDSTONE_BLOCK) {
return OBSERVER;
}
return TNT;
}
}

View File

@@ -1,78 +0,0 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.display;
import de.steamwar.bausystem.features.simulator.SimulatorStorage;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.storage.SimulatorSaver;
import de.steamwar.bausystem.shared.Pair;
import de.steamwar.entity.REntity;
import de.steamwar.entity.REntityServer;
import de.steamwar.entity.RFallingBlockEntity;
import lombok.experimental.UtilityClass;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.event.Listener;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.stream.Collectors;
@UtilityClass
public class SimulatorRenderer implements Listener {
private final World WORLD = Bukkit.getWorlds().get(0);
private Map<Simulator, REntityServer> entityServers = new HashMap<>();
public synchronized void update(Simulator simulator) {
renderSimulator(simulator);
SimulatorSaver.saveSimulator(SimulatorStorage.simulatorsDir, simulator);
}
public REntityServer renderSimulator(Simulator simulator) {
if (simulator == null) {
return null;
}
REntityServer server = entityServers.computeIfAbsent(simulator, __ -> new REntityServer());
server.getEntities().forEach(REntity::die);
Map<Vector, Set<Class<?>>> positionCache = new HashMap<>();
simulator.getGroups().stream().map(group -> group.getElements().stream().map(element -> new Pair<>(group, element)).toList()).flatMap(List::stream)
.forEach(pair -> {
SimulatorGroup group = pair.getKey();
SimulatorElement<?> element = pair.getValue();
boolean wasNotPresent = positionCache.computeIfAbsent(element.getPosition(), __ -> new HashSet<>()).add(element.getClass());
if (!wasNotPresent)
return;
Material material = group.isDisabled() || element.isDisabled() ? element.getWorldDisabledMaterial() : element.getWorldMaterial();
Location location = element.getWorldPos().toLocation(WORLD);
RFallingBlockEntity rFallingBlockEntity = new RFallingBlockEntity(server, location, material);
rFallingBlockEntity.setNoGravity(true);
});
return server;
}
}

View File

@@ -35,8 +35,8 @@ public class StabFinalizer extends StabStep {
try {
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
if (data.region.getRegionData().has(Flag.COLOR).isReadable()) {
pasteBuilder.color(data.region.getRegionData().get(Flag.COLOR).getWithDefault());
}
data.region.getTestblockArea().reset(pasteBuilder, true);
} catch (SecurityException e) {

View File

@@ -26,6 +26,7 @@ import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
@@ -51,6 +52,7 @@ public class StabGenerator extends StabStep implements Listener {
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof TNTPrimed)) return;
if (Region.getRegion(event.getEntity().getLocation()) == data.region) {
event.blockList().forEach(block -> {
if (!data.region.getTestblockArea().inRegion(block.getLocation(), true))
@@ -71,8 +73,8 @@ public class StabGenerator extends StabStep implements Listener {
try {
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
if (data.region.getRegionData().has(Flag.COLOR).isReadable()) {
pasteBuilder.color(data.region.getRegionData().get(Flag.COLOR).getWithDefault());
}
data.region.getTestblockArea().reset(pasteBuilder, true);
} catch (SecurityException e) {

View File

@@ -20,7 +20,7 @@
package de.steamwar.bausystem.features.simulator.execute;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
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;
@@ -72,7 +72,7 @@ public abstract class StabStep {
protected final void stop() {
data.simulator.setStabGenerator(null);
SimulatorRenderer.update(data.simulator);
SimulatorWatcher.update(data.simulator);
for (Player player : Bukkit.getOnlinePlayers()) {
BauSystemBossbar bossbar = BossBarService.instance.get(player, data.region, "simulator_stab_generator");

View File

@@ -1,35 +1,35 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.simulator.SimulatorCursorManager;
import de.steamwar.bausystem.features.simulator.SimulatorCursor;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.display.SimulatorCursorMode;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.data.CMDs;
import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.Collections;
public class SimulatorCursorSwitcherGui extends SimulatorBaseGui {
private final SimulatorCursorManager cursorManager = BauSystem.getInstance().getLinker().get(SimulatorCursorManager.class).orElseThrow();
private SimulatorBaseGui back;
@@ -50,12 +50,14 @@ public class SimulatorCursorSwitcherGui extends SimulatorBaseGui {
}).setCustomModelData(CMDs.BACK));
int slot = 2;
SimulatorCursorMode currentType = cursorManager.getActiveCursorMode(player).orElse(SimulatorCursorMode.TNT);
for (SimulatorCursorMode type : SimulatorCursorMode.values()) {
SimulatorCursor.CursorType currentType = SimulatorCursor.getCursorType(player);
for (SimulatorCursor.CursorType type : SimulatorCursor.CursorType.values()) {
boolean selected = type == currentType;
SWItem swItem = new SWItem(selected ? type.material : type.nonSelectedMaterial, "§e" + type.name)
.setCustomModelData(selected ? 0 : CMDs.Simulator.NEW_PHASE).setLore(Collections.singletonList("§eClick to select")).setCallback(click -> {
cursorManager.setActiveCursorMode(player, type);
.setCustomModelData(selected ? 0 : CMDs.Simulator.NEW_PHASE)
.setLore(Collections.singletonList("§eClick to select"))
.setCallback(click -> {
SimulatorCursor.setCursorType(player, type);
player.closeInventory();
});
inventory.setItem(slot, swItem);

View File

@@ -1,26 +1,28 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
import de.steamwar.inventory.InvCallback;
@@ -36,11 +38,8 @@ public class SimulatorGroupChooserGui extends SimulatorPageGui<SimulatorGroup> {
private final SimulatorGroup parent;
private final SimulatorBaseGui back;
public SimulatorGroupChooserGui(Player player, Simulator simulator, SimulatorElement<?> subject,
SimulatorGroup parent, SimulatorBaseGui back) {
super(player, simulator, 6 * 9,
simulator.getGroups().stream().filter(e -> e != parent).filter(e -> subject.canBeInGroup(e))
.collect(Collectors.toList()));
public SimulatorGroupChooserGui(Player player, Simulator simulator, SimulatorElement<?> subject, SimulatorGroup parent, SimulatorBaseGui back) {
super(player, simulator, 6 * 9, simulator.getGroups().stream().filter(e -> e != parent).filter(e -> subject.canBeInGroup(e)).collect(Collectors.toList()));
this.subject = subject;
this.parent = parent;
this.back = back;
@@ -57,7 +56,7 @@ public class SimulatorGroupChooserGui extends SimulatorPageGui<SimulatorGroup> {
simulator.getGroups().add(newParent);
parent.getElements().remove(subject);
back.open();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
if (parent.getElements().size() == 1) {
parent.setDisabled(false);
parent.setMaterial(Material.BARREL);
@@ -84,7 +83,7 @@ public class SimulatorGroupChooserGui extends SimulatorPageGui<SimulatorGroup> {
parent.setMaterial(Material.BARREL);
}
back.open();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
};
return simulatorGroup.toItem(player, invCallback, invCallback);
}

View File

@@ -1,26 +1,28 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
import de.steamwar.data.CMDs;
@@ -58,7 +60,7 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
}
if (simulatorGroup.getElements().removeIf(element -> element.getPhases().isEmpty())) {
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}
if (simulatorGroup.getElements().size() < 2) {
back.open();
@@ -73,12 +75,11 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
simulatorGroup.getElements().clear();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DELETE));
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
if (simulatorGroup.getMaterial() == null)
return;
if (simulatorGroup.getMaterial() == null) return;
new SimulatorMaterialGui(player, simulator, simulatorGroup::getMaterial, simulatorGroup::setMaterial, this).open();
}, clickType -> {
}));
@@ -86,19 +87,17 @@ public class SimulatorGroupGui extends SimulatorPageGui<SimulatorElement<?>> {
inventory.setItem(48, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
new SimulatorGroupSettingsGui(player, simulator, simulatorGroup, this).open();
}).setCustomModelData(CMDs.Simulator.SETTINGS));
boolean disabled = simulatorGroup.getMaterial() == null ? simulatorGroup.getElements().stream().allMatch(SimulatorElement::isDisabled)
: simulatorGroup.isDisabled();
inventory.setItem(50,
new SWItem(disabled ? Material.ENDER_PEARL : Material.ENDER_EYE, simulatorGroup.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
if (simulatorGroup.getMaterial() == null) {
simulatorGroup.getElements().forEach(simulatorElement -> {
simulatorElement.setDisabled(!disabled);
});
} else {
simulatorGroup.setDisabled(!disabled);
}
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
boolean disabled = simulatorGroup.getMaterial() == null ? simulatorGroup.getElements().stream().allMatch(SimulatorElement::isDisabled) : simulatorGroup.isDisabled();
inventory.setItem(50, new SWItem(disabled ? Material.ENDER_PEARL : Material.ENDER_EYE, simulatorGroup.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
if (simulatorGroup.getMaterial() == null) {
simulatorGroup.getElements().forEach(simulatorElement -> {
simulatorElement.setDisabled(!disabled);
});
} else {
simulatorGroup.setDisabled(!disabled);
}
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
}
@Override

View File

@@ -1,26 +1,28 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
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.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.data.CMDs;
@@ -35,8 +37,7 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
private final SimulatorGroup simulatorGroup;
private final SimulatorBaseGui back;
public SimulatorGroupSettingsGui(Player player, Simulator simulator, SimulatorGroup simulatorGroup,
SimulatorBaseGui back) {
public SimulatorGroupSettingsGui(Player player, Simulator simulator, SimulatorGroup simulatorGroup, SimulatorBaseGui back) {
super(player, simulator, 5 * 9);
this.simulatorGroup = simulatorGroup;
this.back = back;
@@ -61,169 +62,164 @@ public class SimulatorGroupSettingsGui extends SimulatorBaseGui {
// Material Chooser
inventory.setItem(4, simulatorGroup.toItem(player, clickType -> {
if (simulatorGroup.getMaterial() == null)
return;
new SimulatorMaterialGui(player, simulator, simulatorGroup::getMaterial, simulatorGroup::setMaterial, this)
.open();
if (simulatorGroup.getMaterial() == null) return;
new SimulatorMaterialGui(player, simulator, simulatorGroup::getMaterial, simulatorGroup::setMaterial, this).open();
}, clickType -> {
}));
// Base Tick
int baseTicks = simulatorGroup.getBaseTick();
inventory.setItem(9,
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
if (integer < 0)
return false;
if (integer < 0) return false;
simulatorGroup.changeBaseTicks(integer - baseTicks);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
});
baseTick.getItemStack().setAmount(Math.max(1, Math.min(baseTicks, 64)));
inventory.setItem(18, baseTick);
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"),
false, clickType -> {
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
simulatorGroup.changeBaseTicks(-baseTicks);
} else {
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
}
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
inventory.setItem(27, new SWItem(SWItem.getDye(baseTicks > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
if (baseTicks - (clickType.isShiftClick() ? 5 : 1) < 0) {
simulatorGroup.changeBaseTicks(-baseTicks);
} else {
simulatorGroup.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
}
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
boolean allTNT = simulatorGroup.getElements().stream().allMatch(TNTElement.class::isInstance);
if (allTNT) {
// Subpixel Alignment
inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tntElement -> {
tntElement.alignX(0);
tntElement.alignZ(0);
});
SimulatorRenderer.update(simulator);
simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.forEach(tntElement -> {
tntElement.alignX(0);
tntElement.alignZ(0);
});
SimulatorWatcher.update(simulator);
}));
// Z
SWItem negativZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tntElement -> {
if (tntElement.getAlignment().getZ() != -1)
tntElement.alignZ(-1);
});
SimulatorRenderer.update(simulator);
simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.forEach(tntElement -> {
if (tntElement.getAlignment().getZ() != -1) tntElement.alignZ(-1);
});
SimulatorWatcher.update(simulator);
});
negativZItem.setEnchanted(
simulatorGroup.getElements().stream().map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getZ() == -1));
negativZItem.setEnchanted(simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getZ() == -1));
inventory.setItem(20, negativZItem);
SWItem positivZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> {
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tntElement -> {
if (tntElement.getAlignment().getZ() != 1)
tntElement.alignZ(1);
});
SimulatorRenderer.update(simulator);
simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.forEach(tntElement -> {
if (tntElement.getAlignment().getZ() != 1) tntElement.alignZ(1);
});
SimulatorWatcher.update(simulator);
});
positivZItem.setEnchanted(
simulatorGroup.getElements().stream().map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getZ() == 1));
positivZItem.setEnchanted(simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getZ() == 1));
inventory.setItem(22, positivZItem);
// X
SWItem negativXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tntElement -> {
if (tntElement.getAlignment().getX() != -1)
tntElement.alignX(-1);
});
simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.forEach(tntElement -> {
if (tntElement.getAlignment().getX() != -1) tntElement.alignX(-1);
});
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
});
negativXItem.setEnchanted(
simulatorGroup.getElements().stream().map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getX() == -1));
negativXItem.setEnchanted(simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getX() == -1));
inventory.setItem(12, negativXItem);
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
simulatorGroup.getElements().stream().map(TNTElement.class::cast).forEach(tntElement -> {
if (tntElement.getAlignment().getX() != 1)
tntElement.alignX(1);
});
SimulatorRenderer.update(simulator);
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.forEach(tntElement -> {
if (tntElement.getAlignment().getX() != 1) tntElement.alignX(1);
});
SimulatorWatcher.update(simulator);
});
positivXItem.setEnchanted(
simulatorGroup.getElements().stream().map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getX() == -1));
positivXItem.setEnchanted(simulatorGroup.getElements().stream()
.map(TNTElement.class::cast)
.allMatch(tntElement -> tntElement.getAlignment().getX() == -1));
inventory.setItem(30, positivXItem);
}
// Pos X
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1",
Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0, 0);
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
//Pos X
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0, 0);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
new SimulatorAnvilGui<>(player, "Relative X", "", Double::parseDouble, number -> {
if (!allTNT) {
if(!allTNT){
number = (double) Math.round(number);
}
simulatorGroup.move(number, 0, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.PAPER).open();
}));
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1",
Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0);
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
simulatorGroup.move(clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0, 0);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Pos Y
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1",
Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0);
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
//Pos Y
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1, 0);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
new SimulatorAnvilGui<>(player, "Relative Y", "", Double::parseDouble, number -> {
if (!allTNT) {
if(!allTNT){
number = (double) Math.round(number);
}
simulatorGroup.move(0, number, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.PAPER).open();
}));
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1",
Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0);
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
simulatorGroup.move(0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1, 0);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
// Pos Z
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1",
Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1);
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
//Pos Z
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList(allTNT ? "§7Shift§8: §e+0.0625" : "§7Shift§8: §e+5"), false, clickType -> {
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? 0.0625 : 5) : 1);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
new SimulatorAnvilGui<>(player, "Relative Z", "", Double::parseDouble, number -> {
if (!allTNT) {
if(!allTNT){
number = (double) Math.round(number);
}
simulatorGroup.move(0, 0, number);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.PAPER).open();
}));
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1",
Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1);
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList(allTNT ? "§7Shift§8: §e-0.0625" : "§7Shift§8: §e-5"), false, clickType -> {
simulatorGroup.move(0, 0, clickType.isShiftClick() ? (allTNT ? -0.0625 : -5) : -1);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
}
}

View File

@@ -1,30 +1,29 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.simulator.SimulatorCursorManager;
import de.steamwar.bausystem.features.simulator.SimulatorCursor;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorElement;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.display.SimulatorCursor;
import de.steamwar.bausystem.features.simulator.display.SimulatorCursorMode;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
import de.steamwar.data.CMDs;
import de.steamwar.inventory.SWItem;
@@ -33,8 +32,6 @@ import org.bukkit.entity.Player;
public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
private final SimulatorCursorManager cursorManager = BauSystem.getInstance().getLinker().get(SimulatorCursorManager.class).orElseThrow();
public SimulatorGui(Player player, Simulator simulator) {
super(player, simulator, 6 * 9, simulator.getGroups());
}
@@ -46,15 +43,14 @@ public class SimulatorGui extends SimulatorPageGui<SimulatorGroup> {
@Override
public void headerAndFooter() {
if (simulator.getGroups().removeIf(element -> element.getElements().isEmpty()
|| element.getElements().stream().allMatch(simulatorElement -> simulatorElement.getPhases().isEmpty()))) {
SimulatorRenderer.update(simulator);
if (simulator.getGroups().removeIf(element -> element.getElements().isEmpty() || element.getElements().stream().allMatch(simulatorElement -> simulatorElement.getPhases().isEmpty()))) {
SimulatorWatcher.update(simulator);
}
inventory.setItem(4, simulator.toItem(player, clickType -> {
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();
}));
SimulatorCursorMode cursorType = cursorManager.getActiveCursorMode(player).orElse(SimulatorCursorMode.TNT);
SimulatorCursor.CursorType cursorType = SimulatorCursor.getCursorType(player);
inventory.setItem(48, new SWItem(cursorType.material, "§7Placing §8-§e " + cursorType.name, clickType -> {
new SimulatorCursorSwitcherGui(player, simulator, this).open();
}));

View File

@@ -1,24 +1,26 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorPageGui;
import de.steamwar.data.CMDs;
@@ -34,8 +36,11 @@ import java.util.stream.Collectors;
public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
private static final List<Material> MATERIALS = Arrays.stream(Material.values()).filter(material -> !material.isAir())
.filter(material -> !material.isLegacy()).filter(Material::isItem).collect(Collectors.toList());
private static final List<Material> MATERIALS = Arrays.stream(Material.values())
.filter(material -> !material.isAir())
.filter(material -> !material.isLegacy())
.filter(Material::isItem)
.collect(Collectors.toList());
private final Supplier<Material> currentMaterial;
private Material material;
@@ -55,7 +60,7 @@ public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
return true;
}
change.accept(player.getItemOnCursor().getType());
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return false;
}
@@ -76,10 +81,9 @@ public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
@Override
public SWItem convert(Material material) {
return new SWItem(material, "§eNew Material", Arrays.asList(material == this.material ? "§eSelected" : "§eClick to select"), material == this.material,
clickType -> {
change.accept(material);
SimulatorRenderer.update(simulator);
});
return new SWItem(material, "§eNew Material", Arrays.asList(material == this.material ? "§eSelected" : "§eClick to select"), material == this.material, clickType -> {
change.accept(material);
SimulatorWatcher.update(simulator);
});
}
}

View File

@@ -1,27 +1,29 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
import de.steamwar.data.CMDs;
@@ -58,7 +60,7 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
public void headerAndFooter() {
if (observer.getPhases().isEmpty()) {
back.open();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return;
}
@@ -85,7 +87,7 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
observer.getPhases().clear();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DELETE));
// Material Chooser
@@ -99,11 +101,10 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
}).setCustomModelData(CMDs.Simulator.SETTINGS));
// Enable/Disable
inventory.setItem(48,
new SWItem(observer.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, observer.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
observer.setDisabled(!observer.isDisabled());
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
inventory.setItem(48, new SWItem(observer.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, observer.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
observer.setDisabled(!observer.isDisabled());
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
// Group chooser
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
@@ -138,7 +139,7 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
SWItem observer = new SWItem(Material.OBSERVER, "§eObserver", lore, false, clickType -> {
if (clickType == ClickType.MIDDLE) {
this.observer.getPhases().remove(observerPhase);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
} else {
new SimulatorObserverPhaseSettingsGui(player, simulator, this.observer, observerPhase, this).open();
}
@@ -147,35 +148,42 @@ public class SimulatorObserverGui extends SimulatorScrollGui<ObserverPhase> {
Supplier<Integer> getter = observerPhase::getTickOffset;
Consumer<Integer> setter = observerPhase::setTickOffset;
return new SWItem[] {new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), observer,
return new SWItem[] {
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
observer,
new SWItem(SWItem.getDye(getter.get() > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED), new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
new SimulatorObserverPhaseSettingsGui(player, simulator, this.observer, observerPhase, this).open();
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),};
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),
};
}
@Override
public SWItem[] lastColumn() {
return new SWItem[] {new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
addNewPhase(clickType.isShiftClick());
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), new SWItem(Material.QUARTZ, "§eObserver§8:§a New Phase", clickType -> {
addNewPhase(false);
}).setCustomModelData(CMDs.Simulator.NEW_PHASE), new SWItem(SWItem.getDye(8), "§7", clickType -> {
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),};
return new SWItem[]{
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
addNewPhase(clickType.isShiftClick());
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
new SWItem(Material.QUARTZ, "§eObserver§8:§a New Phase", clickType -> {
addNewPhase(false);
}).setCustomModelData(CMDs.Simulator.NEW_PHASE),
new SWItem(SWItem.getDye(8), "§7", clickType -> {
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
};
}
private void addNewPhase(boolean shift) {
ObserverPhase lastElement = observer.getPhases().get(observer.getPhases().size() - 1);
ObserverPhase newPhase = new ObserverPhase(lastElement.getTickOffset() + 4);
if (shift)
newPhase.setTickOffset(newPhase.getTickOffset() + 5);
if (shift) newPhase.setTickOffset(newPhase.getTickOffset() + 5);
scroll += 2;
observer.add(newPhase);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}
}

View File

@@ -1,27 +1,29 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
import de.steamwar.bausystem.features.simulator.data.observer.ObserverPhase;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.core.Core;
@@ -39,8 +41,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
private final ObserverPhase observer;
private final SimulatorBaseGui back;
public SimulatorObserverPhaseSettingsGui(Player player, Simulator simulator, ObserverElement observerElement, ObserverPhase observer,
SimulatorBaseGui back) {
public SimulatorObserverPhaseSettingsGui(Player player, Simulator simulator, ObserverElement observerElement, ObserverPhase observer, SimulatorBaseGui back) {
super(player, simulator, 5 * 9);
this.observerElement = observerElement;
this.observer = observer;
@@ -73,7 +74,7 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
observerElement.getPhases().remove(observer);
back.open();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DELETE));
int index = observerElement.getPhases().indexOf(observer);
@@ -93,19 +94,18 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
max = Integer.MAX_VALUE - 4;
}
// Tick Offset
//Tick Offset
int offset = observer.getTickOffset();
inventory.setItem(10, new SWItem(SWItem.getDye(offset < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
observer.setTickOffset(Math.min(max, offset + (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
if (integer < 0)
return false;
if (integer < 0) return false;
observer.setTickOffset(Math.min(Math.max(integer, min), max));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
});
@@ -114,66 +114,60 @@ public class SimulatorObserverPhaseSettingsGui extends SimulatorBaseGui {
inventory.setItem(28, new SWItem(SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
observer.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Order
//Order
int order = observer.getOrder();
inventory.setItem(13,
new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
observer.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(13, new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
observer.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> {
if (integer < -SimulatorPhase.ORDER_LIMIT)
return false;
if (integer > SimulatorPhase.ORDER_LIMIT)
return false;
if (integer < -SimulatorPhase.ORDER_LIMIT) return false;
if (integer > SimulatorPhase.ORDER_LIMIT) return false;
observer.setOrder(integer);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open();
});
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
inventory.setItem(22, orderItem);
inventory.setItem(31,
new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
observer.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
inventory.setItem(31, new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
observer.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Update orientation
inventory.setItem(25, new SWItem(Material.SUNFLOWER, "§7", clickType -> {
}));
inventory.setItem(15, new SWItem(observer.getOrientation() == BlockFace.UP ? Material.LIME_CONCRETE : Material.GRAY_CONCRETE, "§eUp", clickType -> {
observer.setOrientation(BlockFace.UP);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}));
inventory.setItem(33, new SWItem(observer.getOrientation() == BlockFace.DOWN ? Material.RED_CONCRETE : Material.GRAY_CONCRETE, "§eDown", clickType -> {
observer.setOrientation(BlockFace.DOWN);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}));
inventory.setItem(16, new SWItem(observer.getOrientation() == BlockFace.NORTH ? Material.LIME_WOOL : Material.GRAY_WOOL, "§eNorth", clickType -> {
observer.setOrientation(BlockFace.NORTH);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}));
inventory.setItem(34, new SWItem(observer.getOrientation() == BlockFace.SOUTH ? Material.RED_WOOL : Material.GRAY_WOOL, "§eSouth", clickType -> {
observer.setOrientation(BlockFace.SOUTH);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}));
inventory.setItem(24, new SWItem(observer.getOrientation() == BlockFace.EAST ? Material.LIME_STAINED_GLASS : Material.GRAY_STAINED_GLASS, "§eEast", clickType -> {
observer.setOrientation(BlockFace.EAST);
SimulatorWatcher.update(simulator);
}));
inventory.setItem(26, new SWItem(observer.getOrientation() == BlockFace.WEST ? Material.RED_STAINED_GLASS : Material.GRAY_STAINED_GLASS, "§eWest", clickType -> {
observer.setOrientation(BlockFace.WEST);
SimulatorWatcher.update(simulator);
}));
inventory.setItem(24,
new SWItem(observer.getOrientation() == BlockFace.EAST ? Material.LIME_STAINED_GLASS : Material.GRAY_STAINED_GLASS, "§eEast", clickType -> {
observer.setOrientation(BlockFace.EAST);
SimulatorRenderer.update(simulator);
}));
inventory.setItem(26,
new SWItem(observer.getOrientation() == BlockFace.WEST ? Material.RED_STAINED_GLASS : Material.GRAY_STAINED_GLASS, "§eWest", clickType -> {
observer.setOrientation(BlockFace.WEST);
SimulatorRenderer.update(simulator);
}));
}
}

View File

@@ -1,25 +1,27 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.observer.ObserverElement;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.data.CMDs;
@@ -66,14 +68,13 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
int baseTicks = observer.getBaseTick();
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
observer.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
if (integer < 0)
return false;
if (integer < 0) return false;
observer.changeBaseTicks(integer - baseTicks);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
});
@@ -85,58 +86,58 @@ public class SimulatorObserverSettingsGui extends SimulatorBaseGui {
} else {
observer.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
}
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Pos X
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
//Pos X
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
observer.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + observer.getPosition().getBlockX(), clickType -> {
new SimulatorAnvilGui<>(player, "X", observer.getPosition().getBlockX() + "", Integer::parseInt, i -> {
observer.getPosition().setX(i);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
}));
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
observer.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Pos Y
//Pos Y
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
observer.move(0, clickType.isShiftClick() ? 5 : 1, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + observer.getPosition().getBlockY(), clickType -> {
new SimulatorAnvilGui<>(player, "Y", observer.getPosition().getBlockY() + "", Integer::parseInt, i -> {
observer.getPosition().setY(i);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
}));
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
observer.move(0, clickType.isShiftClick() ? -5 : -1, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Pos Z
//Pos Z
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
observer.move(0, 0, clickType.isShiftClick() ? 5 : 1);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + observer.getPosition().getBlockZ(), clickType -> {
new SimulatorAnvilGui<>(player, "Z", observer.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
observer.getPosition().setZ(i);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
}));
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
observer.move(0, 0, clickType.isShiftClick() ? -5 : -1);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
}
}

View File

@@ -1,27 +1,29 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorGroup;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorScrollGui;
import de.steamwar.data.CMDs;
@@ -59,7 +61,7 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
public void headerAndFooter() {
if (redstone.getPhases().isEmpty()) {
back.open();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return;
}
@@ -91,7 +93,7 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
redstone.getPhases().clear();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DELETE));
// Material Chooser
@@ -105,11 +107,10 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
}).setCustomModelData(CMDs.Simulator.SETTINGS));
// Enable/Disable
inventory.setItem(48,
new SWItem(redstone.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstone.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
redstone.setDisabled(!redstone.isDisabled());
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
inventory.setItem(48, new SWItem(redstone.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, redstone.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
redstone.setDisabled(!redstone.isDisabled());
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
// Group chooser
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
@@ -150,49 +151,55 @@ public class SimulatorRedstoneGui extends SimulatorScrollGui<SimulatorRedstoneGu
lore.add("");
lore.add("§7Click§8:§e Edit");
lore.add("§7Middle-Click§8:§e Remove");
SWItem redstone = new SWItem(redstoneSubPhase.place ? Material.REDSTONE_BLOCK : Material.STONE, redstoneSubPhase.place ? "§eActivate" : "§eDeactivate",
lore, false, clickType -> {
if (clickType == ClickType.MIDDLE) {
this.redstone.getPhases().remove(redstoneSubPhase.phase);
SimulatorRenderer.update(simulator);
} else {
new SimulatorRedstonePhaseSettingsGui(player, simulator, this.redstone, redstoneSubPhase.phase, this).open();
}
});
SWItem redstone = new SWItem(redstoneSubPhase.place ? Material.REDSTONE_BLOCK : Material.STONE, redstoneSubPhase.place ? "§eActivate" : "§eDeactivate", lore, false, clickType -> {
if (clickType == ClickType.MIDDLE) {
this.redstone.getPhases().remove(redstoneSubPhase.phase);
SimulatorWatcher.update(simulator);
} else {
new SimulatorRedstonePhaseSettingsGui(player, simulator, this.redstone, redstoneSubPhase.phase, this).open();
}
});
redstone.getItemStack().setAmount(Math.max(1, Math.min(time, 64)));
Supplier<Integer> getter = redstoneSubPhase.place ? redstoneSubPhase.phase::getTickOffset : redstoneSubPhase.phase::getLifetime;
Consumer<Integer> setter = redstoneSubPhase.place ? redstoneSubPhase.phase::setTickOffset : redstoneSubPhase.phase::setLifetime;
return new SWItem[] {new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), redstone,
return new SWItem[] {
new SWItem(SWItem.getDye(getter.get() < max ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
setter.accept(Math.min(max, getter.get() + (clickType.isShiftClick() ? 5 : 1)));
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
redstone,
new SWItem(SWItem.getDye(getter.get() > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
setter.accept(Math.max(min, getter.get() - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED), new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
new SWItem(Material.ANVIL, "§eEdit Activation", clickType -> {
new SimulatorRedstonePhaseSettingsGui(player, simulator, this.redstone, redstoneSubPhase.phase, this).open();
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),};
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),
};
}
@Override
public SWItem[] lastColumn() {
return new SWItem[] {new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
addNewPhase(clickType.isShiftClick());
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), new SWItem(Material.REDSTONE, "§eRedstone§8:§a New Phase", clickType -> {
addNewPhase(false);
}).setCustomModelData(CMDs.Simulator.NEW_PHASE), new SWItem(SWItem.getDye(8), "§7", clickType -> {
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),};
return new SWItem[]{
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
addNewPhase(clickType.isShiftClick());
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
new SWItem(Material.REDSTONE, "§eRedstone§8:§a New Phase", clickType -> {
addNewPhase(false);
}).setCustomModelData(CMDs.Simulator.NEW_PHASE),
new SWItem(SWItem.getDye(8), "§7", clickType -> {
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
};
}
private void addNewPhase(boolean shift) {
RedstonePhase lastElement = redstone.getPhases().get(redstone.getPhases().size() - 1);
RedstonePhase newPhase = new RedstonePhase(lastElement.getTickOffset() + lastElement.getLifetime() + 1);
if (shift)
newPhase.setTickOffset(newPhase.getTickOffset() + 5);
if (shift) newPhase.setTickOffset(newPhase.getTickOffset() + 5);
scroll += 2;
redstone.add(newPhase);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}
@AllArgsConstructor

View File

@@ -1,27 +1,29 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstonePhase;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.core.Core;
@@ -37,8 +39,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
private final RedstonePhase redstone;
private final SimulatorBaseGui back;
public SimulatorRedstonePhaseSettingsGui(Player player, Simulator simulator, RedstoneElement redstoneElement, RedstonePhase redstone,
SimulatorBaseGui back) {
public SimulatorRedstonePhaseSettingsGui(Player player, Simulator simulator, RedstoneElement redstoneElement, RedstonePhase redstone, SimulatorBaseGui back) {
super(player, simulator, 5 * 9);
this.redstoneElement = redstoneElement;
this.redstone = redstone;
@@ -71,7 +72,7 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
redstoneElement.getPhases().remove(redstone);
back.open();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DELETE));
int index = redstoneElement.getPhases().indexOf(redstone);
@@ -94,19 +95,18 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
maxOffset = Integer.MAX_VALUE - 5;
}
// Tick Offset
//Tick Offset
int offset = redstone.getTickOffset();
inventory.setItem(10, new SWItem(SWItem.getDye(offset < maxOffset ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
redstone.setTickOffset(Math.min(maxOffset, offset + (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
if (integer < 0)
return false;
if (integer < 0) return false;
redstone.setTickOffset(Math.min(Math.max(integer, min), maxOffset));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
});
@@ -115,22 +115,21 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
inventory.setItem(28, new SWItem(SWItem.getDye(offset > min ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
redstone.setTickOffset(Math.max(min, offset - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Lifetime
//Lifetime
int lifetime = redstone.getLifetime();
inventory.setItem(11, new SWItem(SWItem.getDye(lifetime < maxLifetime ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
redstone.setLifetime(Math.min(maxLifetime, lifetime + (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eActivation Time§8:§7 " + lifetime, clickType -> {
new SimulatorAnvilGui<>(player, "Activation Time", lifetime + "", Integer::parseInt, integer -> {
if (integer < 0)
return false;
if (integer < 0) return false;
redstone.setLifetime(Math.min(integer, maxLifetime));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.CLOCK).open();
});
@@ -139,36 +138,32 @@ public class SimulatorRedstonePhaseSettingsGui extends SimulatorBaseGui {
inventory.setItem(29, new SWItem(SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
redstone.setLifetime(Math.max(0, lifetime - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Order
//Order
int order = redstone.getOrder();
inventory.setItem(13,
new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
redstone.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(13, new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
redstone.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eActivation Order§8:§7 " + order, clickType -> {
new SimulatorAnvilGui<>(player, "Activation Order", order + "", Integer::parseInt, integer -> {
if (integer < -SimulatorPhase.ORDER_LIMIT)
return false;
if (integer > SimulatorPhase.ORDER_LIMIT)
return false;
if (integer < -SimulatorPhase.ORDER_LIMIT) return false;
if (integer > SimulatorPhase.ORDER_LIMIT) return false;
redstone.setOrder(integer);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open();
});
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
inventory.setItem(22, orderItem);
inventory.setItem(31,
new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
redstone.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
inventory.setItem(31, new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
redstone.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
}
}

View File

@@ -1,25 +1,27 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.redstone.RedstoneElement;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.data.CMDs;
@@ -65,14 +67,13 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
int baseTicks = redstone.getBaseTick();
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
redstone.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
if (integer < 0)
return false;
if (integer < 0) return false;
redstone.changeBaseTicks(integer - baseTicks);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
});
@@ -84,58 +85,58 @@ public class SimulatorRedstoneSettingsGui extends SimulatorBaseGui {
} else {
redstone.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
}
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Pos X
//Pos X
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
redstone.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + redstone.getPosition().getBlockX(), clickType -> {
new SimulatorAnvilGui<>(player, "X", redstone.getPosition().getBlockX() + "", Integer::parseInt, i -> {
redstone.getPosition().setX(i);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
}));
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
redstone.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Pos Y
//Pos Y
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
redstone.move(0, clickType.isShiftClick() ? 5 : 1, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + redstone.getPosition().getBlockY(), clickType -> {
new SimulatorAnvilGui<>(player, "Y", redstone.getPosition().getBlockY() + "", Integer::parseInt, i -> {
redstone.getPosition().setY(i);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
}));
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
redstone.move(0, clickType.isShiftClick() ? -5 : -1, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Pos Z
//Pos Z
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
redstone.move(0, 0, clickType.isShiftClick() ? 5 : 1);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + redstone.getPosition().getBlockZ(), clickType -> {
new SimulatorAnvilGui<>(player, "Z", redstone.getPosition().getBlockZ() + "", Integer::parseInt, i -> {
redstone.getPosition().setZ(i);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
}));
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
redstone.move(0, 0, clickType.isShiftClick() ? -5 : -1);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
}
}

View File

@@ -1,24 +1,26 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.data.CMDs;
import de.steamwar.inventory.SWItem;
@@ -53,52 +55,50 @@ public class SimulatorSettingsGui extends SimulatorBaseGui {
new SimulatorMaterialGui(player, simulator, simulator::getMaterial, simulator::setMaterial, this).open();
}));
// AutoTrace
inventory.setItem(19, new SWItem(simulator.isAutoTrace() ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK,
"§eAutoTrace§8: " + (simulator.isAutoTrace() ? "§aOn" : "§cOff"), clickType -> {
simulator.setAutoTrace(!simulator.isAutoTrace());
SimulatorRenderer.update(simulator);
}));
inventory.setItem(20, new SWItem(simulator.isAutoTestblock() ? Material.END_STONE : Material.BARRIER,
"§eTestblock§8: " + (simulator.isAutoTestblock() ? "§aOn" : "§cOff"), clickType -> {
simulator.setAutoTestblock(!simulator.isAutoTestblock());
SimulatorRenderer.update(simulator);
}));
//AutoTrace
inventory.setItem(19, new SWItem(simulator.isAutoTrace() ? Material.CHAIN_COMMAND_BLOCK : Material.COMMAND_BLOCK, "§eAutoTrace§8: " + (simulator.isAutoTrace() ? "§aOn" : "§cOff"), clickType -> {
simulator.setAutoTrace(!simulator.isAutoTrace());
SimulatorWatcher.update(simulator);
}));
inventory.setItem(20, new SWItem(simulator.isAutoTestblock() ? Material.END_STONE : Material.BARRIER, "§eTestblock§8: " + (simulator.isAutoTestblock() ? "§aOn" : "§cOff"), clickType -> {
simulator.setAutoTestblock(!simulator.isAutoTestblock());
SimulatorWatcher.update(simulator);
}));
// Pos X
//Pos X
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
simulator.move(clickType.isShiftClick() ? 5 : 1, 0, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(24, new SWItem(Material.PAPER, "§eX", clickType -> {
}));
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
simulator.move(clickType.isShiftClick() ? -5 : -1, 0, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Pos Y
//Pos Y
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
simulator.move(0, clickType.isShiftClick() ? 5 : 1, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(25, new SWItem(Material.PAPER, "§eY", clickType -> {
}));
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
simulator.move(0, clickType.isShiftClick() ? -5 : -1, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Pos Z
//Pos Z
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
simulator.move(0, 0, clickType.isShiftClick() ? 5 : 1);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ", clickType -> {
}));
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
simulator.move(0, 0, clickType.isShiftClick() ? -5 : -1);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
}
}

View File

@@ -1,27 +1,29 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
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.display.SimulatorRenderer;
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;
@@ -58,7 +60,7 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
public void headerAndFooter() {
if (tnt.getPhases().isEmpty()) {
back.open();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return;
}
@@ -85,7 +87,7 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
tnt.getPhases().clear();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DELETE));
// Material Chooser
@@ -96,18 +98,16 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
inventory.setItem(47, new SWItem(Material.REPEATER, "§eSettings", clickType -> {
new SimulatorTNTSettingsGui(player, simulator, tnt, this).open();
}).setCustomModelData(CMDs.Simulator.SETTINGS));
inventory.setItem(48,
new SWItem(tnt.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, tnt.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
tnt.setDisabled(!tnt.isDisabled());
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
inventory.setItem(48, new SWItem(tnt.isDisabled() ? Material.ENDER_PEARL : Material.ENDER_EYE, tnt.isDisabled() ? "§cDisabled" : "§aEnabled", clickType -> {
tnt.setDisabled(!tnt.isDisabled());
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.ENABLED_OR_DISABLED));
if (Core.getVersion() > 19) {
inventory.setItem(49, new SWItem(Material.CALIBRATED_SCULK_SENSOR, "§eCreate Stab", click -> {
new SimulatorAnvilGui<>(player, "Depth Limit", "", Integer::parseInt, depthLimit -> {
if (depthLimit <= 0)
return false;
if (depthLimit <= 0) return false;
simulator.setStabGenerator(new SimulatorStabGenerator(Region.getRegion(player.getLocation()), simulator, tnt, depthLimit));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, null).open();
}).setCustomModelData(CMDs.Simulator.CREATE_STAB));
@@ -117,7 +117,7 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
tntElement.add(new TNTPhase());
parent.add(tntElement);
new SimulatorGroupGui(player, simulator, parent, new SimulatorGui(player, simulator)).open();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.MAKE_GROUP));
inventory.setItem(51, new SWItem(Material.LEAD, "§eJoin Group", clickType -> {
new SimulatorGroupChooserGui(player, simulator, tnt, tnt.getGroup(simulator), this).open();
@@ -126,50 +126,52 @@ public class SimulatorTNTGui extends SimulatorScrollGui<TNTPhase> {
@Override
public SWItem[] column(TNTPhase tntSetting, int index) {
SWItem tnt = new SWItem(Material.TNT, "§eTNT§8:§7 " + tntSetting.getCount(),
Arrays.asList("§7Tick§8: §e" + tntSetting.getTickOffset(), "§7Fuse§8:§e " + tntSetting.getLifetime(), "",
"§7Order§8:§e " + tntSetting.getOrder(), "", "§7X-Jump§8: " + (tntSetting.isXJump() ? "§aOn" : "§cOff"),
"§7Y-Jump§8: " + (tntSetting.isYJump() ? "§aOn" : "§cOff"), "§7Z-Jump§8: " + (tntSetting.isZJump() ? "§aOn" : "§cOff"), "",
"§7Click§8:§e Edit", "§7Middle-Click§8:§e Remove"),
false, clickType -> {
if (clickType == ClickType.MIDDLE) {
this.tnt.getPhases().remove(tntSetting);
SimulatorRenderer.update(simulator);
} else {
new SimulatorTNTPhaseSettingsGui(player, simulator, this.tnt, tntSetting, this).open();
}
});
SWItem tnt = new SWItem(Material.TNT, "§eTNT§8:§7 " + tntSetting.getCount(), Arrays.asList("§7Tick§8: §e" + tntSetting.getTickOffset(), "§7Fuse§8:§e " + tntSetting.getLifetime(), "", "§7Order§8:§e " + tntSetting.getOrder(), "", "§7X-Jump§8: " + (tntSetting.isXJump() ? "§aOn" : "§cOff"), "§7Y-Jump§8: " + (tntSetting.isYJump() ? "§aOn" : "§cOff"), "§7Z-Jump§8: " + (tntSetting.isZJump() ? "§aOn" : "§cOff"), "", "§7Click§8:§e Edit", "§7Middle-Click§8:§e Remove"), false, clickType -> {
if (clickType == ClickType.MIDDLE) {
this.tnt.getPhases().remove(tntSetting);
SimulatorWatcher.update(simulator);
} else {
new SimulatorTNTPhaseSettingsGui(player, simulator, this.tnt, tntSetting, this).open();
}
});
tnt.getItemStack().setAmount(Math.min(tntSetting.getCount(), 64));
return new SWItem[] {new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
tntSetting.setCount(tntSetting.getCount() + (clickType.isShiftClick() ? 5 : 1));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), tnt,
return new SWItem[]{
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
tntSetting.setCount(tntSetting.getCount() + (clickType.isShiftClick() ? 5 : 1));
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
tnt,
new SWItem(SWItem.getDye(tntSetting.getCount() > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8:§e -5"), false, clickType -> {
tntSetting.setCount(Math.max(1, tntSetting.getCount() - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED), new SWItem(Material.ANVIL, "§eEdit Phase", clickType -> {
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
new SWItem(Material.ANVIL, "§eEdit Phase", clickType -> {
new SimulatorTNTPhaseSettingsGui(player, simulator, this.tnt, tntSetting, this).open();
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),};
}).setCustomModelData(CMDs.Simulator.EDIT_ACTIVATION),
};
}
@Override
public SWItem[] lastColumn() {
return new SWItem[] {new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
addNewPhase(clickType.isShiftClick());
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED), new SWItem(Material.GUNPOWDER, "§eTNT§8:§a New Phase", clickType -> {
addNewPhase(false);
}).setCustomModelData(CMDs.Simulator.NEW_PHASE), new SWItem(SWItem.getDye(8), "§7", clickType -> {
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),};
return new SWItem[]{
new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8:§e +5"), false, clickType -> {
addNewPhase(clickType.isShiftClick());
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED),
new SWItem(Material.GUNPOWDER, "§eTNT§8:§a New Phase", clickType -> {
addNewPhase(false);
}).setCustomModelData(CMDs.Simulator.NEW_PHASE),
new SWItem(SWItem.getDye(8), "§7", clickType -> {
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED),
};
}
private void addNewPhase(boolean shift) {
TNTPhase lastElement = tnt.getPhases().get(tnt.getPhases().size() - 1);
TNTPhase newPhase = new TNTPhase(lastElement.getTickOffset() + 1);
if (shift)
newPhase.setCount(newPhase.getCount() + 5);
if (shift) newPhase.setCount(newPhase.getCount() + 5);
scroll++;
tnt.add(newPhase);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}
}

View File

@@ -1,27 +1,29 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.core.Core;
@@ -66,26 +68,25 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
new SimulatorMaterialGui(player, simulator, tntElement::getMaterial, tntElement::setMaterial, this).open();
}));
// Delete
//Delete
inventory.setItem(8, new SWItem(Material.BARRIER, "§eDelete", clickType -> {
tntElement.getPhases().remove(tnt);
back.open();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DELETE));
// Count
//Count
int count = tnt.getCount();
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
tnt.setCount(count + (clickType.isShiftClick() ? 5 : 1));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
SWItem countItem = new SWItem(Material.TNT, "§eCount§8:§7 " + count, clickType -> {
new SimulatorAnvilGui<>(player, "Count", count + "", Integer::parseInt, integer -> {
if (integer < 1)
return false;
if (integer < 1) return false;
tnt.setCount(integer);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.TNT).open();
});
@@ -94,22 +95,21 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
inventory.setItem(27, new SWItem(SWItem.getDye(count > 1 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
tnt.setCount(Math.max(1, count - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Tick Offset
//Tick Offset
int offset = tnt.getTickOffset();
inventory.setItem(10, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
tnt.setTickOffset(offset + (clickType.isShiftClick() ? 5 : 1));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
SWItem offsetItem = new SWItem(Material.REPEATER, "§eStart at§8:§7 " + offset, clickType -> {
new SimulatorAnvilGui<>(player, "Start at", offset + "", Integer::parseInt, integer -> {
if (integer < 0)
return false;
if (integer < 0) return false;
tnt.setTickOffset(integer);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
});
@@ -118,22 +118,21 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
inventory.setItem(28, new SWItem(SWItem.getDye(offset > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
tnt.setTickOffset(Math.max(0, offset - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Lifetime
//Lifetime
int lifetime = tnt.getLifetime();
inventory.setItem(11, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
tnt.setLifetime(lifetime + (clickType.isShiftClick() ? 5 : 1));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
SWItem lifetimeItem = new SWItem(Material.CLOCK, "§eLifetime§8:§7 " + lifetime, clickType -> {
new SimulatorAnvilGui<>(player, "Lifetime", lifetime + "", Integer::parseInt, integer -> {
if (integer < 1)
return false;
if (integer < 1) return false;
tnt.setLifetime(integer);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.CLOCK).open();
});
@@ -142,63 +141,56 @@ public class SimulatorTNTPhaseSettingsGui extends SimulatorBaseGui {
inventory.setItem(29, new SWItem(SWItem.getDye(lifetime > 0 ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
tnt.setLifetime(Math.max(1, lifetime - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Order
//Order
int order = tnt.getOrder();
inventory.setItem(13,
new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
tnt.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(13, new SWItem(SWItem.getDye(order < SimulatorPhase.ORDER_LIMIT ? 10 : 8), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
tnt.setOrder(Math.min(SimulatorPhase.ORDER_LIMIT, order + (clickType.isShiftClick() ? 5 : 1)));
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
Material negativeNumbers = Material.getMaterial(Core.getVersion() >= 19 ? "RECOVERY_COMPASS" : "FIREWORK_STAR");
SWItem orderItem = new SWItem(order >= 0 ? Material.COMPASS : negativeNumbers, "§eCalculation Order§8:§7 " + order, clickType -> {
new SimulatorAnvilGui<>(player, "Calculation Order", order + "", Integer::parseInt, integer -> {
if (integer < -SimulatorPhase.ORDER_LIMIT)
return false;
if (integer > SimulatorPhase.ORDER_LIMIT)
return false;
if (integer < -SimulatorPhase.ORDER_LIMIT) return false;
if (integer > SimulatorPhase.ORDER_LIMIT) return false;
tnt.setOrder(integer);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(order >= 0 ? Material.COMPASS : negativeNumbers).open();
});
orderItem.getItemStack().setAmount(Math.max(1, Math.min(Math.abs(order), 30)));
inventory.setItem(22, orderItem);
inventory.setItem(31,
new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
tnt.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
SimulatorRenderer.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
inventory.setItem(31, new SWItem(SWItem.getDye(order > -SimulatorPhase.ORDER_LIMIT ? 1 : 8), "§e-1", Arrays.asList("§7Shift§8: §e-5"), false, clickType -> {
tnt.setOrder(Math.max(-SimulatorPhase.ORDER_LIMIT, order - (clickType.isShiftClick() ? 5 : 1)));
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Jump
SWItem jumpX =
new SWItem(tnt.isXJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump X§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
tnt.setXJump(!tnt.isXJump());
SimulatorRenderer.update(simulator);
});
//Jump
SWItem jumpX = new SWItem(tnt.isXJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump X§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
tnt.setXJump(!tnt.isXJump());
SimulatorWatcher.update(simulator);
});
inventory.setItem(33, jumpX);
SWItem jumpY =
new SWItem(tnt.isYJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump Y§8: " + (tnt.isYJump() ? "§aon" : "§coff"), clickType -> {
tnt.setYJump(!tnt.isYJump());
SimulatorRenderer.update(simulator);
});
SWItem jumpY = new SWItem(tnt.isYJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump Y§8: " + (tnt.isYJump() ? "§aon" : "§coff"), clickType -> {
tnt.setYJump(!tnt.isYJump());
SimulatorWatcher.update(simulator);
});
inventory.setItem(16, jumpY);
SWItem jumpZ =
new SWItem(tnt.isZJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump Z§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
tnt.setZJump(!tnt.isZJump());
SimulatorRenderer.update(simulator);
});
SWItem jumpZ = new SWItem(tnt.isZJump() ? Material.LIME_WOOL : Material.RED_WOOL, "§7TNT §eJump Z§8: " + (tnt.isZJump() ? "§aon" : "§coff"), clickType -> {
tnt.setZJump(!tnt.isZJump());
SimulatorWatcher.update(simulator);
});
inventory.setItem(35, jumpZ);
SWItem jumpAll = new SWItem(Material.TNT, "§7TNT §eJump §8: " + (tnt.hasJump() ? "§aon" : "§coff"), clickType -> {
tnt.setJump(!tnt.hasJump());
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
});
inventory.setItem(25, jumpAll);
}

View File

@@ -1,25 +1,27 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTElement;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorAnvilGui;
import de.steamwar.bausystem.features.simulator.gui.base.SimulatorBaseGui;
import de.steamwar.data.CMDs;
@@ -74,14 +76,13 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
int baseTicks = tnt.getBaseTick();
inventory.setItem(9, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+5"), false, clickType -> {
tnt.changeBaseTicks(clickType.isShiftClick() ? 5 : 1);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
SWItem baseTick = new SWItem(Material.REPEATER, "§eTicks§8:§7 " + baseTicks, clickType -> {
new SimulatorAnvilGui<>(player, "Ticks", baseTicks + "", Integer::parseInt, integer -> {
if (integer < 0)
return false;
if (integer < 0) return false;
tnt.changeBaseTicks(integer - baseTicks);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).setItem(Material.REPEATER).open();
});
@@ -93,46 +94,42 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
} else {
tnt.changeBaseTicks(clickType.isShiftClick() ? -5 : -1);
}
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Subpixel Alignment
inventory.setItem(21, new SWItem(Material.SUNFLOWER, "§7Align§8: §eCenter", clickType -> {
tnt.alignX(0);
tnt.alignZ(0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}));
// Z
SWItem negativZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §eNegativ Z", clickType -> {
if (tnt.getAlignment().getZ() != -1)
tnt.alignZ(-1);
SimulatorRenderer.update(simulator);
if (tnt.getAlignment().getZ() != -1) tnt.alignZ(-1);
SimulatorWatcher.update(simulator);
});
negativZItem.setEnchanted(tnt.getAlignment().getZ() == -1);
inventory.setItem(20, negativZItem);
SWItem positivZItem = new SWItem(Material.OAK_BUTTON, "§7Align§8: §ePositiv Z", clickType -> {
if (tnt.getAlignment().getZ() != 1)
tnt.alignZ(1);
SimulatorRenderer.update(simulator);
if (tnt.getAlignment().getZ() != 1) tnt.alignZ(1);
SimulatorWatcher.update(simulator);
});
positivZItem.setEnchanted(tnt.getAlignment().getZ() == 1);
inventory.setItem(22, positivZItem);
// X
SWItem negativXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §eNegativ X", clickType -> {
if (tnt.getAlignment().getX() != -1)
tnt.alignX(-1);
SimulatorRenderer.update(simulator);
if (tnt.getAlignment().getX() != -1) tnt.alignX(-1);
SimulatorWatcher.update(simulator);
});
negativXItem.setEnchanted(tnt.getAlignment().getX() == -1);
inventory.setItem(12, negativXItem);
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
if (tnt.getAlignment().getX() != 1)
tnt.alignX(1);
SimulatorRenderer.update(simulator);
SWItem positivXItem = new SWItem(Material.STONE_BUTTON, "§7Align§8: §ePositiv X", clickType -> {
if(tnt.getAlignment().getX() != 1) tnt.alignX(1);
SimulatorWatcher.update(simulator);
});
positivXItem.setEnchanted(tnt.getAlignment().getX() == 1);
inventory.setItem(30, positivXItem);
@@ -140,52 +137,52 @@ public class SimulatorTNTSettingsGui extends SimulatorBaseGui {
// Pos X
inventory.setItem(15, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
tnt.move(clickType.isShiftClick() ? 0.0625 : 1, 0, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(24, new SWItem(Material.PAPER, "§eX§8:§7 " + tnt.getPosition().getX(), clickType -> {
new SimulatorAnvilGui<>(player, "X", tnt.getPosition().getX() + "", Double::parseDouble, d -> {
tnt.getPosition().setX(d);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
}));
inventory.setItem(33, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
tnt.move(clickType.isShiftClick() ? -0.0625 : -1, 0, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Pos Y
inventory.setItem(16, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
tnt.move(0, clickType.isShiftClick() ? 0.0625 : 1, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(25, new SWItem(Material.PAPER, "§eY§8:§7 " + tnt.getPosition().getY(), clickType -> {
new SimulatorAnvilGui<>(player, "Y", tnt.getPosition().getY() + "", Double::parseDouble, d -> {
tnt.getPosition().setY(d);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
}));
inventory.setItem(34, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
tnt.move(0, clickType.isShiftClick() ? -0.0625 : -1, 0);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
// Pos Z
inventory.setItem(17, new SWItem(SWItem.getDye(10), "§e+1", Arrays.asList("§7Shift§8: §e+0.0625"), false, clickType -> {
tnt.move(0, 0, clickType.isShiftClick() ? 0.0625 : 1);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.INCREMENT_OR_DISABLED));
inventory.setItem(26, new SWItem(Material.PAPER, "§eZ§8:§7 " + tnt.getPosition().getZ(), clickType -> {
new SimulatorAnvilGui<>(player, "Z", tnt.getPosition().getZ() + "", Double::parseDouble, d -> {
tnt.getPosition().setZ(d);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
return true;
}, this).open();
}));
inventory.setItem(35, new SWItem(SWItem.getDye(1), "§e-1", Arrays.asList("§7Shift§8: §e-0.0625"), false, clickType -> {
tnt.move(0, 0, clickType.isShiftClick() ? -0.0625 : -1);
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}).setCustomModelData(CMDs.Simulator.DECREMENT_OR_DISABLED));
}
}

View File

@@ -1,24 +1,26 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU Affero General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with this program.
* If not, see <https://www.gnu.org/licenses/>.
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.simulator.gui.base;
import de.steamwar.bausystem.features.simulator.SimulatorWatcher;
import de.steamwar.bausystem.features.simulator.data.Simulator;
import de.steamwar.bausystem.features.simulator.display.SimulatorRenderer;
import de.steamwar.core.Core;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
@@ -43,8 +45,7 @@ public abstract class SimulatorBaseGui {
}
public final void open() {
if (!shouldOpen())
return;
if (!shouldOpen()) return;
String newTitle = title();
String originalTitle = player.getOpenInventory().getTitle();
@@ -57,6 +58,7 @@ public abstract class SimulatorBaseGui {
setup();
if (player.getOpenInventory().getTopInventory() != inv) {
inventory.open();
SimulatorWatcher.watch(player, simulator, this::open);
}
if (Core.getVersion() > 19) {
player.getOpenInventory().setTitle(title());
@@ -68,6 +70,7 @@ public abstract class SimulatorBaseGui {
}
if (player.getOpenInventory().getTopInventory() == inv) {
inventory.open();
SimulatorWatcher.watch(player, simulator, this::open);
}
return;
}
@@ -79,7 +82,11 @@ public abstract class SimulatorBaseGui {
return inv;
});
setup();
inventory.addCloseCallback(clickType -> {
SimulatorWatcher.watch(player, null, null);
});
SimulatorWatcher.watch(player, simulator, this::open);
if (simulator != null && simulator.getStabGenerator() != null) {
populateStabGenerator();
} else {
@@ -91,7 +98,7 @@ public abstract class SimulatorBaseGui {
private void populateStabGenerator() {
inventory.setItem(22, new SWItem(Material.BARRIER, "§cCancel Stab Generator", click -> {
simulator.getStabGenerator().cancel();
SimulatorRenderer.update(simulator);
SimulatorWatcher.update(simulator);
}));
}

View File

@@ -54,7 +54,7 @@ public class YAPIONFormatSimulatorLoader implements SimulatorLoader {
}
String name = file.getName().substring(0, file.getName().length() - 7);
SteamwarUser steamwarUser = SteamwarUser.get(Integer.parseInt(name));
SteamwarUser steamwarUser = SteamwarUser.byId(Integer.parseInt(name));
List<Simulator> simulators = new ArrayList<>();
for (String s : yapionObject.getKeys()) {

View File

@@ -20,17 +20,14 @@
package de.steamwar.bausystem.features.slaves.laufbau;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.core.SWPlayer;
import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked;
import de.steamwar.sql.UserConfig;
import lombok.Cleanup;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.meta.ItemMeta;
import yapion.hierarchy.output.StreamOutput;
import yapion.hierarchy.types.YAPIONObject;
@@ -39,44 +36,45 @@ import yapion.parser.options.StreamOptions;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Base64;
import java.util.List;
import java.util.stream.Collectors;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
@Linked
public class LaufbauUtils implements Listener {
@UtilityClass
public class LaufbauUtils {
private static Map<Player, YAPIONObject> yapionObjectMap = new HashMap<>();
public static class LaufbauComponent implements SWPlayer.Component {
@EventHandler
@SneakyThrows
public void onPlayerJoin(PlayerJoinEvent event) {
String config = UserConfig.getConfig(event.getPlayer().getUniqueId(), "bausystem-laufbau");
if (config == null) {
return;
}
byte[] bytes = Base64.getDecoder().decode(config);
@Cleanup GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(bytes));
YAPIONObject yapionObject = new YAPIONParser(gzipInputStream, new StreamOptions().stopOnStreamEnd(true)).parse().result();
yapionObjectMap.put(event.getPlayer(), yapionObject);
}
private YAPIONObject yapionObject = new YAPIONObject();
@EventHandler
@SneakyThrows
public void onPlayerQuit(PlayerQuitEvent event) {
YAPIONObject yapionObject = yapionObjectMap.get(event.getPlayer());
if (yapionObject == null) {
return;
@Override
@SneakyThrows
public void onMount(SWPlayer player) {
String config = UserConfig.getConfig(player.getPlayer().getUniqueId(), "bausystem-laufbau");
if (config == null) {
return;
}
byte[] bytes = Base64.getDecoder().decode(config);
@Cleanup GZIPInputStream gzipInputStream = new GZIPInputStream(new ByteArrayInputStream(bytes));
yapionObject = new YAPIONParser(gzipInputStream, new StreamOptions().stopOnStreamEnd(true)).parse().result();
}
if (yapionObject.isEmpty()) {
UserConfig.removePlayerConfig(event.getPlayer().getUniqueId(), "bausystem-laufbau");
return;
@Override
@SneakyThrows
public void onUnmount(SWPlayer player) {
if (yapionObject.isEmpty()) {
UserConfig.removePlayerConfig(player.getPlayer().getUniqueId(), "bausystem-laufbau");
return;
}
@Cleanup ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
@Cleanup GZIPOutputStream gzipOutputStream = new GZIPOutputStream(byteArrayOutputStream);
yapionObject.toYAPION(new StreamOutput(gzipOutputStream)).close();
UserConfig.updatePlayerConfig(player.getPlayer().getUniqueId(), "bausystem-laufbau", Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray()));
}
@Cleanup ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
@Cleanup GZIPOutputStream gzipOutputStream = new GZIPOutputStream(byteArrayOutputStream);
yapionObject.toYAPION(new StreamOutput(gzipOutputStream)).close();
UserConfig.updatePlayerConfig(event.getPlayer().getUniqueId(), "bausystem-laufbau", Base64.getEncoder().encodeToString(byteArrayOutputStream.toByteArray()));
}
public static Cuboid pixelCuboid(double pixelX, double pixelY, double pixelZ, double pixelDX, double pixelDY, double pixelDZ) {
@@ -125,11 +123,7 @@ public class LaufbauUtils implements Listener {
return false;
}
String identifier = identifier(bb);
YAPIONObject yapionObject = yapionObjectMap.get(p);
if (yapionObject == null) {
return false;
}
return yapionObject.containsKey(identifier);
return SWPlayer.of(p).getComponentOrDefault(LaufbauComponent.class, LaufbauComponent::new).yapionObject.containsKey(identifier);
}
@SneakyThrows
@@ -138,11 +132,7 @@ public class LaufbauUtils implements Listener {
return;
}
String identifier = identifier(bb);
YAPIONObject yapionObject = yapionObjectMap.get(p);
if (yapionObject == null) {
yapionObject = new YAPIONObject();
yapionObjectMap.put(p, yapionObject);
}
YAPIONObject yapionObject = SWPlayer.of(p).getComponentOrDefault(LaufbauComponent.class, LaufbauComponent::new).yapionObject;
if (yapionObject.containsKey(identifier)) {
yapionObject.remove(identifier);
} else {

View File

@@ -107,7 +107,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
@Override
public Player map(CommandSender commandSender, String[] previousArguments, String s) {
Player player = Bukkit.getPlayer(s);
if (player != null && Permission.REAL_SPECTATOR.hasPermission(player)) {
if (player != null && Permission.SPECTATOR.hasPermission(player)) {
return player;
}
return null;
@@ -116,7 +116,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
return Bukkit.getOnlinePlayers().stream()
.filter(Permission.REAL_SPECTATOR::hasPermission)
.filter(Permission.SPECTATOR::hasPermission)
.map(Player::getName)
.collect(Collectors.toList());
}

View File

@@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.testblock.blockcounter;
import de.steamwar.bausystem.region.Region;
import de.steamwar.linkage.Linked;
import org.bukkit.block.Block;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
@@ -34,6 +35,7 @@ public class BlockCounterListener implements Listener {
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof TNTPrimed)) return;
Region region = Region.getRegion(event.getLocation());
if (region.getType().isGlobal()) {
return;

View File

@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.tntlistener;
package de.steamwar.bausystem.features.tls;
import de.steamwar.command.SWCommand;
import de.steamwar.linkage.Linked;
@@ -43,4 +43,13 @@ public class TLSCommand extends SWCommand {
public void stop(@Validator Player player) {
listener.stopListening(player);
}
@Register(description = "TLS_TOGGLE_HELP")
public void toggle(@Validator Player player) {
if (listener.isActiveFor(player)) {
listener.stopListening(player);
} else {
listener.startListening(player);
}
}
}

View File

@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.tntlistener;
package de.steamwar.bausystem.features.tls;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;

View File

@@ -17,7 +17,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.tntlistener;
package de.steamwar.bausystem.features.tls;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;

View File

@@ -45,8 +45,6 @@ public class TraceManager implements Listener {
instance = this;
}
public void init() {
if (!tracesFolder.exists())
tracesFolder.mkdir();

View File

@@ -20,6 +20,7 @@ package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand;
import de.steamwar.core.SWPlayer;
import de.steamwar.linkage.Linked;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
@@ -39,10 +40,11 @@ public class GamemodeCommand extends SWCommand {
@Register
public void genericCommand(final Player p) {
if (NoClipCommand.getNOCLIPS().contains(p)) {
p.performCommand("noclip");
return;
}
SWPlayer swPlayer = SWPlayer.of(p);
if (swPlayer.hasComponent(NoClipCommand.NoClipData.class)) {
swPlayer.removeComponent(NoClipCommand.NoClipData.class);
return;
}
if (p.getGameMode() == GameMode.CREATIVE) {
p.setGameMode(GameMode.SPECTATOR);
} else {
@@ -52,9 +54,7 @@ public class GamemodeCommand extends SWCommand {
@Register
public void gamemodeCommand(final Player p, final GameMode gameMode) {
if (NoClipCommand.getNOCLIPS().contains(p)) {
p.performCommand("noclip");
}
SWPlayer.of(p).removeComponent(NoClipCommand.NoClipData.class);
p.setGameMode(gameMode);
}
}

View File

@@ -26,6 +26,7 @@ import de.steamwar.bausystem.shared.EnumDisplay;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.core.SWPlayer;
import de.steamwar.data.CMDs;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory;
@@ -56,11 +57,9 @@ public class MaterialCommand extends SWCommand implements Listener {
WorldEditListener.addCommandExclusion("material");
}
private Map<Player, Search> searchMap = new HashMap<>();
@Getter
@Setter
static class Search {
public class SearchParameter implements SWPlayer.Component {
SearchType transparent = SearchType.IGNORE;
SearchType solid = SearchType.IGNORE;
SearchType gravity = SearchType.IGNORE;
@@ -104,10 +103,10 @@ public class MaterialCommand extends SWCommand implements Listener {
@Register
public void materialGUI(Player p) {
materialGUI(p, searchMap.get(p));
materialGUI(p, SWPlayer.of(p).getComponentOrDefault(SearchParameter.class, SearchParameter::new));
}
private static final Map<String, BiConsumer<Search, SearchType>> elements = new HashMap<>();
private static final Map<String, BiConsumer<SearchParameter, SearchType>> elements = new HashMap<>();
static {
elements.put("-transparent", (search, searchType) -> search.transparent = searchType);
elements.put("-solid", (search, searchType) -> search.solid = searchType);
@@ -122,15 +121,15 @@ public class MaterialCommand extends SWCommand implements Listener {
@Register
public void search(Player p, @Mapper("search") String... searches) {
Search search = new Search();
SearchParameter searchParameter = SWPlayer.of(p).getComponentOrDefault(SearchParameter.class, SearchParameter::new);
for (String s : searches) {
boolean has = false;
for (Map.Entry<String, BiConsumer<Search, SearchType>> element: elements.entrySet()) {
for (Map.Entry<String, BiConsumer<SearchParameter, SearchType>> element: elements.entrySet()) {
if (s.startsWith(element.getKey() + ":")) {
element.getValue().accept(search, SearchType.valueOf(s.substring(element.getKey().length() + 1).toUpperCase()));
element.getValue().accept(searchParameter, SearchType.valueOf(s.substring(element.getKey().length() + 1).toUpperCase()));
has = true;
} else if (s.startsWith(element.getKey().substring(0, 2) + ":")) {
element.getValue().accept(search, SearchType.valueOf(s.substring(element.getKey().substring(0, 2).length() + 1).toUpperCase()));
element.getValue().accept(searchParameter, SearchType.valueOf(s.substring(element.getKey().substring(0, 2).length() + 1).toUpperCase()));
has = true;
}
if (has) break;
@@ -141,15 +140,15 @@ public class MaterialCommand extends SWCommand implements Listener {
case "-blastresistance:":
s = s.substring(s.indexOf(':') + 1).replace('_', ' ');
if (s.isEmpty() || s.matches("((([><]=?)|!|=)\\d+(\\.|,\\d+)?)( ((([><]=?)|!|=)\\d+(\\.|,\\d+)?))*")) {
search.blastResistance = s;
searchParameter.blastResistance = s;
}
break;
default:
search.name = s;
searchParameter.name = s;
break;
}
}
materialGUI(p, search);
materialGUI(p, searchParameter);
}
@Mapper(value = "search", local = true)
@@ -182,7 +181,7 @@ public class MaterialCommand extends SWCommand implements Listener {
};
}
public void materialGUI(Player p, Search search) {
public void materialGUI(Player p, SearchParameter search) {
List<SWListInv.SWListEntry<Material>> swListEntries = new ArrayList<>();
MaterialLazyInit.materialData.forEach(data -> {
if (data.is(search)) {
@@ -202,59 +201,59 @@ public class MaterialCommand extends SWCommand implements Listener {
private void searchGUI(Player p) {
SWInventory swInventory = new SWInventory(p, 54, BauSystem.MESSAGE.parse("MATERIAL_SEARCH", p));
Search search = searchMap.get(p);
SearchParameter searchParameter = SWPlayer.of(p).getComponentOrDefault(SearchParameter.class, SearchParameter::new);
swInventory.setItem(0, new SWItem(Material.ARROW, BauSystem.MESSAGE.parse("MATERIAL_BACK", p), clickType -> {
materialGUI(p);
}).setCustomModelData(CMDs.BACK));
swInventory.setItem(10, new SWItem(Material.NAME_TAG, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.name), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p), search.name);
swInventory.setItem(10, new SWItem(Material.NAME_TAG, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, searchParameter.name), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_NAME", p), searchParameter.name);
swAnvilInv.setCallback(s -> {
search.name = s;
searchParameter.name = s;
searchGUI(p);
});
swAnvilInv.open();
}));
swInventory.setItem(19, new SWItem(Material.GLASS, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_TRANSPARENT", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(search.transparent.getChatValue(), p)), clickType -> {
search.transparent = search.transparent.next();
swInventory.setItem(19, new SWItem(Material.GLASS, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_TRANSPARENT", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(searchParameter.transparent.getChatValue(), p)), clickType -> {
searchParameter.transparent = searchParameter.transparent.next();
searchGUI(p);
}));
swInventory.setItem(20, new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_SOLID", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(search.solid.getChatValue(), p)), clickType -> {
search.solid = search.solid.next();
swInventory.setItem(20, new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_SOLID", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(searchParameter.solid.getChatValue(), p)), clickType -> {
searchParameter.solid = searchParameter.solid.next();
searchGUI(p);
}));
swInventory.setItem(21, new SWItem(Material.BLACK_CONCRETE_POWDER, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_GRAVITY", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(search.gravity.getChatValue(), p)), clickType -> {
search.gravity = search.gravity.next();
swInventory.setItem(21, new SWItem(Material.BLACK_CONCRETE_POWDER, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_GRAVITY", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(searchParameter.gravity.getChatValue(), p)), clickType -> {
searchParameter.gravity = searchParameter.gravity.next();
searchGUI(p);
}));
swInventory.setItem(22, new SWItem(Material.BIRCH_LOG, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_OCCLUDING", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(search.occluding.getChatValue(), p)), clickType -> {
search.occluding = search.occluding.next();
swInventory.setItem(22, new SWItem(Material.BIRCH_LOG, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_OCCLUDING", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(searchParameter.occluding.getChatValue(), p)), clickType -> {
searchParameter.occluding = searchParameter.occluding.next();
searchGUI(p);
}));
swInventory.setItem(23, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_INTERACTEABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(search.interacteable.getChatValue(), p)), clickType -> {
search.interacteable = search.interacteable.next();
swInventory.setItem(23, new SWItem(Material.OAK_BUTTON, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_INTERACTEABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(searchParameter.interacteable.getChatValue(), p)), clickType -> {
searchParameter.interacteable = searchParameter.interacteable.next();
searchGUI(p);
}));
swInventory.setItem(24, new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_FLAMMABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(search.flammable.getChatValue(), p)), clickType -> {
search.flammable = search.flammable.next();
swInventory.setItem(24, new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_FLAMMABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(searchParameter.flammable.getChatValue(), p)), clickType -> {
searchParameter.flammable = searchParameter.flammable.next();
searchGUI(p);
}));
swInventory.setItem(25, new SWItem(Material.LAVA_BUCKET, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BURNABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(search.burnable.getChatValue(), p)), clickType -> {
search.burnable = search.burnable.next();
swInventory.setItem(25, new SWItem(Material.LAVA_BUCKET, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BURNABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(searchParameter.burnable.getChatValue(), p)), clickType -> {
searchParameter.burnable = searchParameter.burnable.next();
searchGUI(p);
}));
swInventory.setItem(28, new SWItem(Material.WATER_BUCKET, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_WATERLOGGABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(search.waterloggable.getChatValue(), p)), clickType -> {
search.waterloggable = search.waterloggable.next();
swInventory.setItem(28, new SWItem(Material.WATER_BUCKET, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_WATERLOGGABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(searchParameter.waterloggable.getChatValue(), p)), clickType -> {
searchParameter.waterloggable = searchParameter.waterloggable.next();
searchGUI(p);
}));
swInventory.setItem(29, new SWItem(Material.PISTON, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_UNMOVEABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(search.unmoveable.getChatValue(), p)), clickType -> {
search.unmoveable = search.unmoveable.next();
swInventory.setItem(29, new SWItem(Material.PISTON, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_UNMOVEABLE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, BauSystem.MESSAGE.parse(searchParameter.unmoveable.getChatValue(), p)), clickType -> {
searchParameter.unmoveable = searchParameter.unmoveable.next();
searchGUI(p);
}));
swInventory.setItem(34, new SWItem(Material.NETHER_BRICK, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, search.blastResistance), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p), search.blastResistance);
swInventory.setItem(34, new SWItem(Material.NETHER_BRICK, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p) + BauSystem.MESSAGE.parse("MATERIAL_SEARCH_VALUE", p, searchParameter.blastResistance), clickType -> {
SWAnvilInv swAnvilInv = new SWAnvilInv(p, BauSystem.MESSAGE.parse("MATERIAL_SEARCH_BLASTRESISTANCE", p), searchParameter.blastResistance);
swAnvilInv.setCallback(s -> {
if (s.isEmpty() || s.matches("((([><]=?)|!|=)\\d+(\\.|,\\d+)?)( ((([><]=?)|!|=)\\d+(\\.|,\\d+)?))*")) {
search.blastResistance = s;
searchParameter.blastResistance = s;
}
searchGUI(p);
});
@@ -262,14 +261,4 @@ public class MaterialCommand extends SWCommand implements Listener {
}));
swInventory.open();
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
searchMap.put(event.getPlayer(), new Search());
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
searchMap.remove(event.getPlayer());
}
}

View File

@@ -87,6 +87,7 @@ public class MaterialLazyInit {
Block block = Bukkit.getWorlds().get(0).getBlockAt(0, 0, 0);
block.setType(material);
unmoveable = block.getPistonMoveReaction() == PistonMoveReaction.BLOCK || block.getPistonMoveReaction() == PistonMoveReaction.IGNORE || block.getState() instanceof TileState;
block.setType(Material.AIR);
}
if (material.isItem() && material != Material.AIR) {
@@ -132,7 +133,7 @@ public class MaterialLazyInit {
}), originalMaterial);
}
public boolean is(MaterialCommand.Search search) {
public boolean is(MaterialCommand.SearchParameter search) {
boolean result = true;
result &= search.transparent.test(transparent);
result &= search.solid.test(solid);

View File

@@ -19,17 +19,17 @@
package de.steamwar.bausystem.features.util;
import de.steamwar.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile;
import de.steamwar.Reflection;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.tpslimit.TPSUtils;
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
import de.steamwar.bausystem.utils.NMSWrapper;
import de.steamwar.command.SWCommand;
import de.steamwar.core.ProtocolWrapper;
import de.steamwar.core.SWPlayer;
import de.steamwar.linkage.Linked;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
@@ -40,10 +40,6 @@ import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.BiFunction;
@Linked
@@ -59,29 +55,34 @@ public class NoClipCommand extends SWCommand implements Listener {
private static final Class<?> windowClick = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundContainerClickPacket");
private static final Class<?> setSlotStack = Reflection.getClass("net.minecraft.network.protocol.game.ServerboundSetCreativeModeSlotPacket");
@Getter
private static final List<Player> NOCLIPS = new ArrayList<>();
private static final Map<Player, Long> LAST_TICKS = new HashMap<>();
public static class NoClipData implements SWPlayer.Component {
private long lastTick = -1;
@Override
public void onUnmount(SWPlayer player) {
player.setGameMode(GameMode.CREATIVE);
}
}
public NoClipCommand() {
super("noclip", "nc");
BiFunction<Player, Object, Object> first = (player, o) -> {
if (NOCLIPS.contains(player)) {
if (LAST_TICKS.getOrDefault(player, -1L).equals(TPSUtils.currentTick.get())) return o;
NMSWrapper.impl.setInternalGameMode(player, GameMode.SPECTATOR);
LAST_TICKS.put(player, TPSUtils.currentTick.get());
}
NoClipData noClipData = SWPlayer.of(player).getComponent(NoClipData.class).orElse(null);
if (noClipData == null) return o;
if (noClipData.lastTick == TPSUtils.currentTick.get()) return o;
NMSWrapper.impl.setInternalGameMode(player, GameMode.SPECTATOR);
noClipData.lastTick = TPSUtils.currentTick.get();
return o;
};
TinyProtocol.instance.addFilter(position, first);
TinyProtocol.instance.addFilter(positionLook, first);
BiFunction<Player, Object, Object> second = (player, o) -> {
if (NOCLIPS.contains(player)) {
NMSWrapper.impl.setInternalGameMode(player, GameMode.CREATIVE);
LAST_TICKS.put(player, TPSUtils.currentTick.get());
}
NoClipData noClipData = SWPlayer.of(player).getComponent(NoClipData.class).orElse(null);
if (noClipData == null) return o;
NMSWrapper.impl.setInternalGameMode(player, GameMode.CREATIVE);
noClipData.lastTick = TPSUtils.currentTick.get();
return o;
};
TinyProtocol.instance.addFilter(useItem, second);
@@ -89,7 +90,7 @@ public class NoClipCommand extends SWCommand implements Listener {
TinyProtocol.instance.addFilter(windowClick, second);
BiFunction<Player, Object, Object> third = (player, o) -> {
if (NOCLIPS.contains(player)) {
if (SWPlayer.of(player).hasComponent(NoClipData.class)) {
NMSWrapper.impl.setSlotToItemStack(player, o);
}
return o;
@@ -99,9 +100,9 @@ public class NoClipCommand extends SWCommand implements Listener {
@Register(help = true)
public void genericCommand(@Validator Player player) {
if (NOCLIPS.contains(player)) {
NOCLIPS.remove(player);
player.setGameMode(GameMode.CREATIVE);
SWPlayer swPlayer = SWPlayer.of(player);
if (swPlayer.hasComponent(NoClipData.class)) {
swPlayer.removeComponent(NoClipData.class);
} else {
player.setGameMode(GameMode.SPECTATOR);
NMSWrapper.impl.setPlayerBuildAbilities(player);
@@ -109,8 +110,8 @@ public class NoClipCommand extends SWCommand implements Listener {
Object gameStateChangeObject = Reflection.newInstance(gameStateChange);
NMSWrapper.impl.setGameStateChangeReason(gameStateChangeObject);
floatFieldAccessor.set(gameStateChangeObject, 1F);
NOCLIPS.add(player);
swPlayer.setComponent(new NoClipData());
BauSystem.MESSAGE.send("OTHER_NOCLIP_SLOT_INFO", player);
TinyProtocol.instance.sendPacket(player, gameStateChangeObject);
pseudoGameMode(player, GameMode.SPECTATOR);
@@ -120,30 +121,27 @@ public class NoClipCommand extends SWCommand implements Listener {
@EventHandler
public void onBauMemberUpdate(BauMemberUpdateEvent event) {
event.getNewSpectator().forEach(player -> {
if (NOCLIPS.contains(player)) {
NOCLIPS.remove(player);
player.setGameMode(GameMode.CREATIVE);
}
SWPlayer.of(player).removeComponent(NoClipData.class);
});
}
@EventHandler(ignoreCancelled = true)
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
if (NOCLIPS.contains(event.getPlayer())) {
if (SWPlayer.of(event.getPlayer()).hasComponent(NoClipData.class)) {
event.setCancelled(true);
}
}
@EventHandler(ignoreCancelled = true)
public void onBlock(BlockCanBuildEvent event) {
if (NOCLIPS.contains(event.getPlayer())) {
if (SWPlayer.of(event.getPlayer()).hasComponent(NoClipData.class)) {
event.setBuildable(true);
}
}
@EventHandler(ignoreCancelled = true)
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
if (NOCLIPS.contains(event.getPlayer())) {
if (SWPlayer.of(event.getPlayer()).hasComponent(NoClipData.class)) {
event.setCancelled(true);
event.getPlayer().setFlying(true);
}
@@ -154,7 +152,7 @@ public class NoClipCommand extends SWCommand implements Listener {
if (event.getCause() != PlayerTeleportEvent.TeleportCause.SPECTATE) {
return;
}
if (NOCLIPS.contains(event.getPlayer())) {
if (SWPlayer.of(event.getPlayer()).hasComponent(NoClipData.class)) {
event.setCancelled(true);
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
event.getPlayer().setSpectatorTarget(null);

View File

@@ -24,6 +24,7 @@ import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.BauGuiItem;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.core.SWPlayer;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked;
@@ -35,15 +36,11 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@Linked
public class SelectBauGuiItem extends BauGuiItem {
private static final Map<Player, LastSelect> LAST_SELECT_MAP = new HashMap<>();
public SelectBauGuiItem() {
super(13);
}
@@ -58,13 +55,13 @@ public class SelectBauGuiItem extends BauGuiItem {
private static void selectFinish(Player p, RegionType type, RegionExtensionType extensionType) {
p.closeInventory();
LAST_SELECT_MAP.put(p, new LastSelect(type, extensionType));
SWPlayer.of(p).setComponent(new LastSelect(type, extensionType));
p.performCommand("select " + type.name() + " " + extensionType.toString());
}
@Override
public ItemStack getItem(Player player) {
LastSelect last = LAST_SELECT_MAP.getOrDefault(player, new LastSelect(RegionType.BUILD, RegionExtensionType.NORMAL));
LastSelect last = SWPlayer.of(player).getComponentOrDefault(LastSelect.class, () -> new LastSelect(RegionType.BUILD, RegionExtensionType.NORMAL));
return new SWItem(Material.SCAFFOLDING, BauSystem.MESSAGE.parse("SELECT_ITEM_SELECT", player), Arrays.asList(BauSystem.MESSAGE.parse("SELECT_ITEM_AUSWAHL", player, BauSystem.MESSAGE.parse(last.type.getChatValue(), player), last.extensionType.name()), BauSystem.MESSAGE.parse("SELECT_ITEM_RIGHT_CLICK", player)), false, clickType -> {
}).getItemStack();
}
@@ -80,7 +77,7 @@ public class SelectBauGuiItem extends BauGuiItem {
inv.open();
} else {
p.closeInventory();
LastSelect last = LAST_SELECT_MAP.getOrDefault(p, new LastSelect(RegionType.BUILD, RegionExtensionType.NORMAL));
LastSelect last = SWPlayer.of(p).getComponentOrDefault(LastSelect.class, () -> new LastSelect(RegionType.BUILD, RegionExtensionType.NORMAL));
p.performCommand("select " + last.getType().name() + " " + last.getExtensionType().toString());
}
return false;
@@ -92,7 +89,7 @@ public class SelectBauGuiItem extends BauGuiItem {
}
@AllArgsConstructor
private static class LastSelect {
private static class LastSelect implements SWPlayer.Component {
@Getter
private final RegionType type;
@Getter

View File

@@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.warp;
import de.steamwar.bausystem.region.Region;
import de.steamwar.core.Core;
import de.steamwar.core.SWPlayer;
import de.steamwar.entity.RArmorStand;
import de.steamwar.entity.REntityServer;
import de.steamwar.linkage.Linked;
@@ -30,7 +31,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
@@ -42,8 +46,21 @@ import java.util.Map;
@Linked
public class WarpListener implements Listener {
private Map<Player, REntityServer> warpEntityServer = new HashMap<>();
private Map<Player, List<Location>> selected = new HashMap<>();
public static class WarpComponent implements SWPlayer.Component {
private REntityServer server;
private List<Location> selected = new ArrayList<>();
@Override
public void onMount(SWPlayer player) {
server = new REntityServer();
server.addPlayer(player.getPlayer());
}
@Override
public void onUnmount(SWPlayer player) {
server.close();
}
}
@EventHandler
public void onPlayerItemHeld(PlayerItemHeldEvent e) {
@@ -65,20 +82,11 @@ public class WarpListener implements Listener {
}
private void reshow(Player p, Material material, boolean sneaking) {
REntityServer entityServer = warpEntityServer.get(p);
if (entityServer != null) {
entityServer.close();
}
if (material != Material.COMPASS) {
warpEntityServer.remove(p);
return;
}
selected.remove(p);
entityServer = new REntityServer();
entityServer.addPlayer(p);
warpEntityServer.put(p, entityServer);
SWPlayer swPlayer = SWPlayer.of(p);
swPlayer.removeComponent(WarpComponent.class);
if (material != Material.COMPASS) return;
WarpComponent warpComponent = swPlayer.getComponentOrDefault(WarpComponent.class, WarpComponent::new);
Vector current = p.getLocation().clone().add(p.getLocation().getDirection().multiply(5)).toVector();
Map<String, Location> locations = new HashMap<>();
@@ -99,12 +107,9 @@ public class WarpListener implements Listener {
}
}
REntityServer finalEntityServer = entityServer;
locations.forEach((name, location) -> {
Vector vector = location.toVector().subtract(p.getLocation().toVector());
if (vector.getX() * vector.getX() + vector.getZ() * vector.getZ() < 25) {
return;
}
if (vector.getX() * vector.getX() + vector.getZ() * vector.getZ() < 25) return;
vector.setY(0);
Vector position = p.getLocation().toVector().clone().add(vector.normalize().multiply(5));
@@ -112,9 +117,9 @@ public class WarpListener implements Listener {
if ((position.getX() - current.getX()) * (position.getX() - current.getX()) + (position.getZ() - current.getZ()) * (position.getZ() - current.getZ()) < 0.1) {
name = "§a§l" + name;
selected.computeIfAbsent(p, player -> new ArrayList<>()).add(location);
warpComponent.selected.add(location);
}
RArmorStand armorStand = new RArmorStand(finalEntityServer, position.toLocation(p.getWorld()), RArmorStand.Size.MARKER);
RArmorStand armorStand = new RArmorStand(warpComponent.server, position.toLocation(p.getWorld()), RArmorStand.Size.MARKER);
armorStand.setDisplayName(name);
armorStand.setNoGravity(true);
armorStand.setInvisible(true);
@@ -123,28 +128,13 @@ public class WarpListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getPlayer().getInventory().getItemInMainHand().getType() != Material.COMPASS) {
return;
}
if (event.getAction() != Action.RIGHT_CLICK_AIR) {
return;
}
List<Location> locations = selected.getOrDefault(event.getPlayer(), new ArrayList<>());
if (locations.size() != 1) {
return;
}
Location location = locations.get(0);
if (event.getPlayer().getInventory().getItemInMainHand().getType() != Material.COMPASS) return;
if (event.getAction() != Action.RIGHT_CLICK_AIR) return;
WarpComponent warpComponent = SWPlayer.of(event.getPlayer()).getComponent(WarpComponent.class).orElse(null);
if (warpComponent == null || warpComponent.selected.size() != 1) return;
Location location = warpComponent.selected.get(0);
event.getPlayer().teleport(location);
event.getPlayer().playSound(location, Sound.ENTITY_ENDERMAN_TELEPORT, SoundCategory.PLAYERS, 1, 1);
event.setCancelled(true);
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
warpEntityServer.computeIfPresent(event.getPlayer(), (player, rEntityServer) -> {
rEntityServer.close();
return null;
});
selected.remove(event.getPlayer());
}
}

View File

@@ -41,7 +41,7 @@ public class AntiBauAddMemberFix implements Listener {
}
if (BauweltMember.getBauMember(BauServer.getInstance().getOwner(), event.getPlayer().getUniqueId()) == null) {
event.getPlayer().kickPlayer("");
throw new SecurityException("The player " + event.getPlayer().getName() + " joined on the server of " + SteamwarUser.get(BauServer.getInstance().getOwnerID()).getUserName() + " without being added!");
throw new SecurityException("The player " + event.getPlayer().getName() + " joined on the server of " + SteamwarUser.byId(BauServer.getInstance().getOwnerID()).getUserName() + " without being added!");
}
}

Some files were not shown because too many files have changed in this diff Show More