140 Commits

Author SHA1 Message Date
5a46f10f8b First fix REntity for 1.21
All checks were successful
SteamWarCI Build successful
2025-04-16 10:10:32 +02:00
0b14a216d9 Fix SmartPlaceListener updating block under repeater/comparator
All checks were successful
SteamWarCI Build successful
2025-04-14 10:04:57 +02:00
b2853b9dec Fix RCommand being able to send offline players
All checks were successful
SteamWarCI Build successful
2025-04-14 10:01:50 +02:00
df5c363fb7 Fix FreezeListener
All checks were successful
SteamWarCI Build successful
2025-04-14 09:57:31 +02:00
c9e4b57f12 Fix: Explicitly cast null to Integer in DownloadCommand
All checks were successful
SteamWarCI Build successful
2025-04-12 19:10:18 +02:00
fdcd248ba6 Merge branch 'main' of https://git.steamwar.de/SteamWar/SteamWar
Some checks failed
SteamWarCI Build failed
2025-04-12 19:04:11 +02:00
f573771355 Hotfix: Double Creation of //copy Schematics in //download command 2025-04-12 19:03:32 +02:00
80078cd8e2 Merge pull request 'Fix spectator handling' (#38) from spectator-improvements into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #38
Reviewed-by: Chaoscaot <max@chaoscaot.de>
2025-04-12 14:46:41 +02:00
76fc468d89 Merge pull request 'Refactors SchematicNode queries for efficiency' (#39) from improve-search-querry into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #39
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-04-12 14:40:34 +02:00
1304048509 Refactors SchematicNode queries for efficiency
All checks were successful
SteamWarCI Build successful
2025-04-11 00:07:53 +02:00
cf4ac95c2f Bugfix after testing
All checks were successful
SteamWarCI Build successful
2025-04-09 21:04:28 +02:00
f2d8c9c02b Only AntiTest
All checks were successful
SteamWarCI Build successful
2025-04-08 21:34:41 +02:00
2405c5e620 Fix spectator handling
All checks were successful
SteamWarCI Build successful
2025-04-08 21:31:47 +02:00
d9493c7474 Dont show bedrock players and send an error for getting your own skull as a bedrock player
All checks were successful
SteamWarCI Build successful
2025-04-08 20:58:23 +02:00
2ccb240ef5 Merge remote-tracking branch 'origin/main'
All checks were successful
SteamWarCI Build successful
2025-04-08 20:54:54 +02:00
d1d1679c0a Add /skull shorthand for own skull 2025-04-08 20:54:48 +02:00
62002e44d7 Merge pull request 'Add techhiderbug command.' (#36) from FightSystem/techhiderbug into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #36
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-04-07 21:22:39 +02:00
9c3f7526ff Add techhiderbug command.
All checks were successful
SteamWarCI Build successful
2025-04-07 19:37:23 +02:00
eefe17e5f7 Merge pull request 'Use combinedIds to hide in TechHider.iBlockDataHidden' (#35) from hotfix/TechHider into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #35
Reviewed-by: Chaoscaot <max@chaoscaot.de>
2025-04-05 18:12:54 +02:00
812e78d277 Make it 1.8 compatible
All checks were successful
SteamWarCI Build successful
2025-04-05 18:02:48 +02:00
fd220d7fd4 Fix maven url
All checks were successful
SteamWarCI Build successful
2025-04-04 13:57:09 +02:00
446cd5deae Fixup ChecklistChannel
All checks were successful
SteamWarCI Build successful
2025-04-04 11:23:51 +02:00
a6c46d0270 Use combinedIds to hide in TechHider.iBlockDataHidden
All checks were successful
SteamWarCI Build successful
2025-04-04 11:21:54 +02:00
2686ab285b Improve WaitTime in ChecklistChannel
All checks were successful
SteamWarCI Build successful
2025-04-04 11:16:12 +02:00
57ea1470e2 Fix for real!
All checks were successful
SteamWarCI Build successful
2025-04-04 10:54:21 +02:00
bfdc9c118a Hopefully fix it
All checks were successful
SteamWarCI Build successful
2025-04-04 10:52:37 +02:00
dafe838a8a Improve DiscordChannel on discord!
All checks were successful
SteamWarCI Build successful
2025-04-04 10:49:01 +02:00
13bd154383 Merge remote-tracking branch 'origin/main'
All checks were successful
SteamWarCI Build successful
2025-04-03 17:56:22 +02:00
9248c9fa51 Remove first second and third in master rank 2025-04-03 17:56:19 +02:00
764dec99f4 Remove display name cleansing in direct tablist handling
All checks were successful
SteamWarCI Build successful
2025-04-02 19:05:31 +02:00
c9a1528dfe Update UserElo for better distribution
All checks were successful
SteamWarCI Build successful
2025-04-02 10:21:03 +02:00
8c37466312 Revert "Add Alu-Hut"
All checks were successful
SteamWarCI Build successful
This reverts commit b37ded3a8d.
2025-04-02 08:58:42 +02:00
3b7e38aceb Revert "Fix Realtime"
This reverts commit 87f0765506.
2025-04-02 08:58:42 +02:00
e7c4c998a0 Revert "Allow edit of Lobby"
This reverts commit 1dcd2f102c.
2025-04-02 08:58:42 +02:00
5907648462 Revert "Allow edit of Lobby"
This reverts commit f62af55d39.
2025-04-02 08:58:42 +02:00
b32d6e9c69 Revert "Update difficulty"
This reverts commit 47c8cb1701.
2025-04-02 08:58:42 +02:00
f533e85007 Revert "Update difficulty"
This reverts commit 81c310c946.
2025-04-02 08:58:42 +02:00
81c310c946 Update difficulty
All checks were successful
SteamWarCI Build successful
2025-04-01 23:32:32 +02:00
47c8cb1701 Update difficulty
All checks were successful
SteamWarCI Build successful
2025-04-01 23:19:24 +02:00
f62af55d39 Allow edit of Lobby
All checks were successful
SteamWarCI Build successful
2025-04-01 20:58:10 +02:00
1dcd2f102c Allow edit of Lobby
All checks were successful
SteamWarCI Build successful
2025-04-01 20:56:33 +02:00
87f0765506 Fix Realtime
All checks were successful
SteamWarCI Build successful
2025-03-31 22:44:01 +02:00
b37ded3a8d Add Alu-Hut
All checks were successful
SteamWarCI Build successful
2025-03-31 22:37:55 +02:00
c4e9f80315 Fix leader not changeable during events
All checks were successful
SteamWarCI Build successful
2025-03-31 19:56:36 +02:00
19e14f787a Merge pull request 'feat(BauSystem): add tracer lua-lib' (#24) from BauSystem/tracer-lua-lib into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #24
Reviewed-by: Chaoscaot <max@chaoscaot.de>
Reviewed-by: Lixfel <lixfel@noreply.localhost>
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-03-30 17:33:29 +02:00
0f629a6387 Merge pull request 'Feature(BauSystem): Add example hotkey script' (#31) from BauSystem/add-example-scipt into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #31
Reviewed-by: Lixfel <lixfel@noreply.localhost>
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-03-30 17:32:42 +02:00
1a356da6e0 Trigger Rebuild
All checks were successful
SteamWarCI Build successful
2025-03-30 11:17:27 +02:00
f6a18dffcc Trigger Rebuild
All checks were successful
SteamWarCI Build successful
2025-03-30 11:14:20 +02:00
98cc09a7d3 Trigger Rebuild
All checks were successful
SteamWarCI Build successful
2025-03-30 11:11:01 +02:00
4c8a03ac9c Add 30 seconds EndCountdown for TowerRun
All checks were successful
SteamWarCI Build successful
2025-03-29 19:53:09 +01:00
16f2eaad52 fixed Script ordering
All checks were successful
SteamWarCI Build successful
2025-03-25 22:03:59 +01:00
90d2e70a6e Merge branch 'main' into BauSystem/add-example-scipt
All checks were successful
SteamWarCI Build successful
2025-03-25 21:55:04 +01:00
d22b01f5e6 Updated copyright
All checks were successful
SteamWarCI Build successful
2025-03-25 21:54:03 +01:00
0da3ebfbcc Merge pull request 'SpigotCore/RDisplay' (#23) from SpigotCore/RDisplay into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #23
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-03-23 18:30:29 +01:00
923142d0cb Merge branch 'main' into SpigotCore/RDisplay
All checks were successful
SteamWarCI Build successful
2025-03-23 18:29:09 +01:00
eca9963653 Add example hotkey script
All checks were successful
SteamWarCI Build successful
2025-03-21 18:49:49 +01:00
9467291020 Add license header to tracer lib
All checks were successful
SteamWarCI Build successful
2025-03-18 21:33:34 +01:00
e14c7321c2 Merge branch 'main' into BauSystem/tracer-lua-lib 2025-03-18 21:31:39 +01:00
50b6947312 Hotfix DiscordChatRoom
All checks were successful
SteamWarCI Build successful
2025-03-13 17:14:17 +01:00
9eca9ab990 Add DepthCommand to toggle Depth Counter
All checks were successful
SteamWarCI Build successful
2025-03-13 17:04:59 +01:00
34e4cd7060 Add click on SimulatorMaterialGui to change material
All checks were successful
SteamWarCI Build successful
2025-03-13 16:53:37 +01:00
30cb09c127 Hotfix ELO on leave
All checks were successful
SteamWarCI Build successful
2025-03-13 16:36:34 +01:00
c94d67660a Fixed doc
All checks were successful
SteamWarCI Build successful
2025-03-12 19:13:47 +01:00
522cd850a2 Add copyright and usage note!
All checks were successful
SteamWarCI Build successful
2025-03-12 08:45:01 +01:00
394591f302 First impl
All checks were successful
SteamWarCI Build successful
2025-03-11 22:58:03 +01:00
3016ad31fa Merge branch 'main' into SpigotCore/RDisplay
All checks were successful
SteamWarCI Build successful
2025-03-11 21:49:27 +01:00
1d293b446c Hotfix WhoisCommand for Developers not showing the User ID
All checks were successful
SteamWarCI Build successful
2025-03-11 18:31:31 +01:00
3b41cc4ac5 Improved tracer Lib
All checks were successful
SteamWarCI Build successful
2025-03-10 22:17:05 +01:00
a71f3f6c66 Merge pull request 'Update Bossbar of FightSystem' (#22) from FightSystem/UpdatedBossBar into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #22
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-03-09 18:27:27 +01:00
2225b811fa Update Bossbar of FightSystem
All checks were successful
SteamWarCI Build successful
2025-03-09 18:18:13 +01:00
96c25687b6 Hotfix SendCommand
All checks were successful
SteamWarCI Build successful
2025-03-08 22:16:39 +01:00
82723e4c31 Hotfix ShieldPrinting pasting AIR, it should not
All checks were successful
SteamWarCI Build successful
2025-03-08 18:34:22 +01:00
17eaefe3d0 Hotfix ShieldPrinting pasting AIR, it should not
All checks were successful
SteamWarCI Build successful
2025-03-08 17:51:41 +01:00
911a08a156 Merge remote-tracking branch 'origin/main'
All checks were successful
SteamWarCI Build successful
2025-03-08 17:44:55 +01:00
b60111e717 Hotfix ShieldPrinting pasting AIR, it should not 2025-03-08 17:44:46 +01:00
644cc9da84 Fix /arena bugs with event arenas
All checks were successful
SteamWarCI Build successful
2025-03-08 15:58:54 +01:00
29cb1cc5da Implemented first tracer lib version
All checks were successful
SteamWarCI Build successful
2025-03-08 01:11:24 +01:00
9bc1f8b328 Refactor password check and add cache clearance.
All checks were successful
SteamWarCI Build successful
2025-03-04 21:05:01 +01:00
f38b85f9cb Fix TPSSystem in 1.21 and beyond
All checks were successful
SteamWarCI Build successful
2025-03-03 11:27:46 +01:00
600c24441c Fix final things
All checks were successful
SteamWarCI Build successful
2025-03-03 10:09:54 +01:00
f3b5a45f62 Fix final things
All checks were successful
SteamWarCI Build successful
2025-03-03 10:05:08 +01:00
caee70c07e Hotfix some exceptions
All checks were successful
SteamWarCI Build successful
2025-03-03 10:01:56 +01:00
5f73395b63 Hotfix some exceptions
All checks were successful
SteamWarCI Build successful
2025-03-03 09:56:12 +01:00
b4eab65757 Hotfix xsome exceptions
All checks were successful
SteamWarCI Build successful
2025-03-03 09:42:39 +01:00
0a60654a28 Add some of the Easter Particles
All checks were successful
SteamWarCI Build successful
2025-03-03 09:35:42 +01:00
85c0db873c Final Hotfix of Send Command!
All checks were successful
SteamWarCI Build successful
2025-03-02 19:09:59 +01:00
f0beb22856 Hotfix the "to" back in
All checks were successful
SteamWarCI Build successful
2025-03-02 18:54:59 +01:00
af55c946a6 Remove player length constraint
All checks were successful
SteamWarCI Build successful
2025-03-02 18:51:01 +01:00
8b49b8a736 Add player respawn handling with custom spawn location
All checks were successful
SteamWarCI Build successful
2025-03-02 15:31:33 +01:00
6d4ae9593d Refine eventFight ID check in TNTLeagueConfig initialization.
All checks were successful
SteamWarCI Build successful
2025-03-02 15:14:10 +01:00
2fad352f62 Fix event initialization check in TNTLeagueConfig
All checks were successful
SteamWarCI Build successful
2025-03-02 15:02:11 +01:00
2d28cc6182 Fix isEvent function to correctly check eventFightId
All checks were successful
SteamWarCI Build successful
2025-03-02 14:58:26 +01:00
b0bd719627 Backend Fixes
All checks were successful
SteamWarCI Build successful
2025-03-02 09:08:49 +01:00
284c4acd4b Merge pull request 'Add event count to Team info' (#21) from VelocityCore/TeamInfoEventCount into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #21
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-03-01 21:45:06 +01:00
96a4168f37 Add event count to Team info
All checks were successful
SteamWarCI Build successful
2025-03-01 21:40:54 +01:00
c77b8f57ce Merge pull request 'Configurable techhider interaction suppression' (#19) from config-techhider-interaction-suppression into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #19
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-03-01 08:34:05 +01:00
e3c02cfb60 Revert "Update VV dependency version"
All checks were successful
SteamWarCI Build successful
This reverts commit 9f108a7cea.
2025-03-01 08:33:15 +01:00
ade9a1b5eb Allow TNT in shulker boxes
All checks were successful
SteamWarCI Build successful
2025-03-01 08:32:19 +01:00
ce907389df Refactor SQL query to remove schema qualifiers.
All checks were successful
SteamWarCI Build successful
2025-02-25 22:46:54 +01:00
d9b58d7170 Merge pull request 'Authentication v2' (#17) from Backend/new-auth into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #17
2025-02-25 22:40:09 +01:00
3db327eb84 Merge branch 'main' into Backend/new-auth
All checks were successful
SteamWarCI Build successful
2025-02-25 22:39:59 +01:00
fd82707414 Update webpassword command and clean up deprecated logic
All checks were successful
SteamWarCI Build successful
2025-02-23 17:27:29 +01:00
a2b3661605 Refactor V2 Auth
All checks were successful
SteamWarCI Build successful
2025-02-23 17:24:14 +01:00
b045f16160 Remove deprecated configureAuthRoutes function call
All checks were successful
SteamWarCI Build successful
2025-02-20 22:40:18 +01:00
dea0d33185 Refactor token generation and remove unused endpoints.
All checks were successful
SteamWarCI Build successful
2025-02-20 22:13:13 +01:00
11cf0b6c54 Merge pull request 'Add LegacyBauSystem with adaptions to current SpigotCore' (#20) from legacy-bau-system into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #20
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-02-20 06:46:06 +01:00
593ca9f0cf Merge pull request 'VelocityCore/SendCommand2.0' (#18) from VelocityCore/SendCommand2.0 into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #18
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-02-19 21:22:11 +01:00
7f5b57516e Reduce access token duration and enhance auth endpoints
All checks were successful
SteamWarCI Build successful
2025-02-17 18:28:43 +01:00
8ec12603b6 Add password reset URL generation and backend validation
All checks were successful
SteamWarCI Build successful
2025-02-17 17:48:26 +01:00
ef029eb420 Add LegacyBauSystem with adaptions to current SpigotCore
All checks were successful
SteamWarCI Build successful
2025-02-16 19:40:18 +01:00
9f108a7cea Update VV dependency version
Some checks failed
SteamWarCI Build failed
2025-02-16 17:25:18 +01:00
b516d1d569 Configurable techhider interaction suppression
All checks were successful
SteamWarCI Build successful
2025-02-16 17:14:55 +01:00
56e1abca7e Kick player on Channel injection failure
All checks were successful
SteamWarCI Build successful
2025-02-16 17:09:27 +01:00
5420c19b39 Add SCRIPT.md and sw.def.lua
All checks were successful
SteamWarCI Build successful
2025-02-14 20:34:49 +01:00
dd9467fa36 Hotfix TeamPlayer.onPlayerInteractEntity
All checks were successful
SteamWarCI Build successful
2025-02-14 16:53:26 +01:00
ccbac9f7fb Merge branch 'main' into VelocityCore/SendCommand2.0
All checks were successful
SteamWarCI Build successful
2025-02-13 20:40:16 +01:00
6aeecd444e Authentication v2
All checks were successful
SteamWarCI Build successful
2025-02-04 21:47:29 +01:00
ec43e7eba8 Trigger rebuild
All checks were successful
SteamWarCI Build successful
2025-02-02 16:29:10 +01:00
fbea45fb0f Merge pull request 'Add server shutdown if less than 2 players after 5 minutes' (#15) from TNTLeague/auto-shutdown into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #15
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-02-02 16:15:52 +01:00
abbbf7d3cb Merge branch 'main' into TNTLeague/auto-shutdown
All checks were successful
SteamWarCI Build successful
2025-02-02 16:14:25 +01:00
1dc0c0d8a8 Merge pull request 'Add ReadyCommand' (#16) from TNTLeague/add-ready-command into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #16
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-02-02 16:14:20 +01:00
25cf1ab314 Add ReadyCommand
All checks were successful
SteamWarCI Build successful
2025-02-02 16:11:02 +01:00
1715fdccdf Remove unused imports in TNTLeague classes
All checks were successful
SteamWarCI Build successful
2025-02-02 16:07:24 +01:00
e39db5978b Add server shutdown if less than 2 players after 5 minutes
All checks were successful
SteamWarCI Build successful
2025-02-02 16:06:48 +01:00
b4baef321f Trigger rebuild
All checks were successful
SteamWarCI Build successful
2025-02-02 15:28:33 +01:00
93ab1a50f3 Fix team auto-assign logic in lobby state
All checks were successful
SteamWarCI Build successful
Replaced `members.add` with `join` to correctly integrate new players into teams during the lobby phase. This ensures proper team setup and adherence to game mechanics.
2025-02-02 14:12:25 +01:00
c6a7107ec2 Merge pull request 'Make TNTLeague Event System Capable' (#13) from TNTLeague/add-event into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #13
Reviewed-by: Lixfel <lixfel@noreply.localhost>
2025-02-02 13:03:02 +01:00
8ac5fe44ef Merge pull request 'Make TowerRun Event System Capable' (#14) from TowerRun/event into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #14
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-02-02 12:55:26 +01:00
414bd20eb9 Make TowerRun Event System Capable
All checks were successful
SteamWarCI Build successful
2025-02-01 22:58:49 +01:00
482282f913 Make TNTLeague Event System Capable
All checks were successful
SteamWarCI Build successful
2025-02-01 22:00:36 +01:00
3d153d49b5 Make TNTLeague Event System Capable
All checks were successful
SteamWarCI Build successful
2025-02-01 21:50:36 +01:00
bfdf6471d2 Cleanup things and fix setting back to default
Some checks failed
SteamWarCI Build failed
2025-01-08 16:52:24 +01:00
e418109ab7 Reduce spawn packets to 0 if everything is default 2025-01-08 16:27:18 +01:00
82c73f9367 Fix packet count to at most 2 for the display entities at spawn 2025-01-08 12:24:17 +01:00
1f65121c68 Fixup postSpawn because of NPE/Not Initialized Exception 2025-01-07 18:41:50 +01:00
3c848389c9 Update structure 2025-01-07 18:41:50 +01:00
33f41869b6 Fix packets 2025-01-07 18:41:50 +01:00
3c1d46398d Add RDisplay, RBlockDisplay, RItemDisplay, RTextDisplay 2025-01-07 18:41:50 +01:00
9a8cb543e9 Update SendCommand
Some checks failed
SteamWarCI Build failed
2025-01-07 14:27:57 +01:00
55adb1a052 Improve SendCommand 2024-12-22 23:16:19 +01:00
198 changed files with 11210 additions and 440 deletions

View File

@ -406,6 +406,8 @@ BLOCK_COUNTER_MESSAGE_SECOND=§7Damage §8> §e{0} §7Blocks §e{1} §7TNT §e
BLOCK_COUNTER_ENABLE=§7BlockCounter activated
BLOCK_COUNTER_DISABLE=§7BlockCounter deactivated
# DepthCounter
DEPTH_COUNTER_DISABLE=§7Depth Counter disabled
DEPTH_COUNTER_ENABLE=§7Depth Counter enabled
DEPTH_COUNTER_MESSAGE=§7Depth §8> §7
DEPTH_COUNTER_COUNT={0}{1}§8×{2}{3}§8×{4}{5}
DEPTH_COUNTER_HOVER=§7X§8×§7Y§8×§7Z

View File

@ -369,6 +369,8 @@ BLOCK_COUNTER_MESSAGE_SECOND=§7Schaden §8> §e{0} §7Blöcke §e{1} §7TNT
BLOCK_COUNTER_ENABLE=§7BlockCounter angemacht
BLOCK_COUNTER_DISABLE=§7BlockCounter ausgemacht
# DepthCounter
DEPTH_COUNTER_DISABLE=§7Depth Counter deaktiviert
DEPTH_COUNTER_ENABLE=§7Depth Counter aktiviert
DEPTH_COUNTER_MESSAGE=§7Tiefe §8> §7
# TPSLimit
TPSLIMIT_FREEZE_HELP=§8/§etpslimit 0 §8-§7 Friere TPS ein

View File

@ -20,6 +20,7 @@
package de.steamwar.bausystem.features.cannon.depth;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
@ -65,7 +66,9 @@ public class Depth {
dimensions.setZ(Math.abs(dimensions.getZ()));
RegionUtils.message(region, player -> {
player.spigot().sendMessage(getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, tntCount));
if (Config.getInstance().get(player).getPlainValueOrDefault("depth_message", true)) {
player.spigot().sendMessage(getMessage(player, dimensions.getBlockX() + 1, dimensions.getBlockY() + 1, dimensions.getBlockZ() + 1, tntCount));
}
});
}

View File

@ -0,0 +1,45 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.cannon.depth;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.command.SWCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
@Linked
public class DepthCommand extends SWCommand {
public DepthCommand() {
super("depth");
}
@Register
public void toggle(Player player) {
if (Config.getInstance().get(player).getPlainValueOrDefault("depth_message", true)) {
Config.getInstance().get(player).put("depth_message", false);
BauSystem.MESSAGE.send("DEPTH_COUNTER_DISABLE", player);
} else {
Config.getInstance().get(player).put("depth_message", true);
BauSystem.MESSAGE.send("DEPTH_COUNTER_ENABLE", player);
}
}
}

View File

@ -113,8 +113,8 @@ public class FreezeListener implements Listener, ScoreboardElement {
if (Core.getVersion() < 19) return;
if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.DEBUG_STICK) return;
if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) {
if (e.isCancelled()) return;
e.setCancelled(true);
e.getBlock().setType(Material.BARRIER, false);
e.getBlock().setType(Material.AIR, false);
}
}

View File

@ -0,0 +1,113 @@
/*
* 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.script.lua.libs;
import de.steamwar.bausystem.features.tracer.TNTPoint;
import de.steamwar.bausystem.features.tracer.Trace;
import de.steamwar.bausystem.features.tracer.TraceManager;
import de.steamwar.linkage.Linked;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
import org.luaj.vm2.LuaTable;
import org.luaj.vm2.LuaValue;
import org.luaj.vm2.lib.ZeroArgFunction;
@Linked
public class TracerLib implements LuaLib {
@Override
public String name() {
return "tracer";
}
private static LuaTable convertTrace(Trace trace) {
LuaTable luaTrace = new LuaTable();
luaTrace.set("getRecords", new ZeroArgFunction() {
@Override
public LuaValue call() {
return LuaValue.listOf(
trace.getHistories()
.stream()
.map((history) -> LuaValue.listOf(history
.stream()
.map(TracerLib::convertTntPoint)
.toArray(LuaValue[]::new)))
.toArray(LuaValue[]::new));
}
});
luaTrace.set("getId", new ZeroArgFunction() {
@Override
public LuaValue call() {
return LuaValue.valueOf(trace.getUuid().toString());
}
});
return luaTrace;
}
private static LuaTable convertTntPoint(TNTPoint tntPoint) {
Location pointPos = tntPoint.getLocation();
LuaTable luaPos = LuaValue.tableOf(new LuaValue[]{
LuaValue.valueOf("x"), LuaValue.valueOf(pointPos.getX()),
LuaValue.valueOf("y"), LuaValue.valueOf(pointPos.getY()),
LuaValue.valueOf("z"), LuaValue.valueOf(pointPos.getZ()),
});
Vector pointVel = tntPoint.getVelocity();
LuaTable luaVel = LuaValue.tableOf(new LuaValue[]{
LuaValue.valueOf("x"), LuaValue.valueOf(pointVel.getX()),
LuaValue.valueOf("y"), LuaValue.valueOf(pointVel.getY()),
LuaValue.valueOf("z"), LuaValue.valueOf(pointVel.getZ()),
});
return LuaValue.tableOf(new LuaValue[]{
LuaValue.valueOf("pos"), luaPos,
LuaValue.valueOf("vel"), luaVel,
LuaValue.valueOf("ticksSinceStart"), LuaValue.valueOf(tntPoint.getTicksSinceStart()),
LuaValue.valueOf("fuse"), LuaValue.valueOf(tntPoint.getFuse()),
LuaValue.valueOf("isExplosion"), LuaValue.valueOf(tntPoint.isExplosion()),
LuaValue.valueOf("isInWater"), LuaValue.valueOf(tntPoint.isInWater()),
LuaValue.valueOf("hasDestroyedBuild"), LuaValue.valueOf(tntPoint.isDestroyedBuildArea()),
LuaValue.valueOf("hasDestroyedTestblock"), LuaValue.valueOf(tntPoint.isDestroyedTestBlock())
});
}
@Override
public LuaTable get(Player player) {
LuaTable rootTable = LuaValue.tableOf();
rootTable.set("getTraces", new ZeroArgFunction() {
@Override
public LuaValue call() {
return LuaValue.listOf(TraceManager.instance.getAll()
.stream()
.map(TracerLib::convertTrace)
.toArray(LuaValue[]::new));
}
}
);
return rootTable;
}
}

View File

@ -160,6 +160,11 @@ public class ShieldPrinting implements Listener {
private void paste(Map<Material, BlockDataConfiguration<?>[]> stateConfiguration) {
for (Map.Entry<Vector, BlockData> entry : shieldData.entrySet()) {
BlockData copied = entry.getValue();
if (copied.getMaterial().isAir()) {
continue;
}
Block block = entry.getKey().toLocation(WORLD).getBlock();
if (entry.getValue().getMaterial() != block.getType()) {
block.setBlockData(entry.getValue(), false);
@ -171,12 +176,11 @@ public class ShieldPrinting implements Listener {
BlockDataConfiguration[] stateConfigurations = stateConfiguration.get(entry.getValue().getMaterial());
if (stateConfigurations == null) {
block.setBlockData(entry.getValue(), false);
continue;
}
BlockData worldOriginal = block.getBlockData();
BlockData copied = entry.getValue().clone();
copied = copied.clone();
for (BlockDataConfiguration blockDataConfiguration : stateConfigurations) {
if (blockDataConfiguration == null) continue;
blockDataConfiguration.apply(copied, worldOriginal);

View File

@ -53,6 +53,16 @@ public class SimulatorMaterialGui extends SimulatorPageGui<Material> {
this.back = back;
}
@Override
public boolean shouldOpen() {
if (player.getItemOnCursor().getType().isAir()) {
return true;
}
change.accept(player.getItemOnCursor().getType());
SimulatorWatcher.update(simulator);
return false;
}
@Override
public String baseTitle() {
return "Material";

View File

@ -46,6 +46,8 @@ public abstract class SimulatorBaseGui {
}
public final void open() {
if (!shouldOpen()) return;
String newTitle = title();
String originalTitle = player.getOpenInventory().getTitle();
@ -86,6 +88,10 @@ public abstract class SimulatorBaseGui {
inventory.open();
}
public boolean shouldOpen() {
return true;
}
private void setup() {
for (int i = 0; i < 9; i++) {
inventory.setItem(i, new SWItem(Material.GRAY_STAINED_GLASS_PANE, "§8", clickType -> {

View File

@ -223,7 +223,7 @@ public class SmartPlaceListener implements Listener {
Block block = event.getBlock().getRelative(BlockFace.DOWN);
BlockState old = block.getState();
Bukkit.getScheduler().runTaskLater(BauSystem.getInstance(), () -> {
block.setType(Material.GLASS);
block.setType(Material.GLASS, false);
old.update(true, false);
}, 1);
}

View File

@ -38,6 +38,7 @@ import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWItem;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.LinkedInstance;
import de.steamwar.linkage.MaxVersion;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
@ -51,6 +52,7 @@ import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
@Linked
@MaxVersion(20) // Hotfix for 1.21 tps limit! -> Backport coming later
public class TPSSystem implements Listener {
@Getter

View File

@ -42,6 +42,15 @@ public class SkullCommand extends SWCommand {
super("skull", "head");
}
@Register
public void giveCommand(@Validator Player p) {
if (p.getName().startsWith(".")) {
BauSystem.MESSAGE.send("SKULL_INVALID", p);
return;
}
giveCommand(p, p.getName());
}
@Register(description = "SKULL_HELP")
public void giveCommand(@Validator Player p, @Mapper("player") @ErrorMessage("SKULL_INVALID") String skull) {
ItemStack is = SWItem.getPlayerSkull(skull).getItemStack();
@ -63,7 +72,7 @@ public class SkullCommand extends SWCommand {
@Override
public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) {
return Bukkit.getOnlinePlayers().stream().map(Player::getName).filter(s1 -> !s1.endsWith("")).collect(Collectors.toList());
return Bukkit.getOnlinePlayers().stream().map(Player::getName).filter(s1 -> !s1.startsWith(".")).collect(Collectors.toList());
}
};
}

419
BauSystem/SCRIPT.md Normal file
View File

@ -0,0 +1,419 @@
# SteamWar.de - Script System
---
<!-- TOC -->
* [SteamWar.de - Script System](#steamwarde---script-system)
* [Einleitung](#einleitung)
* [Nutzung mit einer IDE](#nutzung-mit-einer-ide)
* [Basis-Apis](#basis-apis)
* [SteamWar.de-Api](#steamwarde-api)
* [player](#player)
* [random](#random)
* [region](#region)
* [tnt](#tnt)
* [trace](#trace)
* [server](#server)
* [tps](#tps)
* [storage](#storage)
* [inventory](#inventory)
* [SteamWar.de-Global-Api](#steamwarde-global-api)
* [Commands](#commands)
* [Hotkeys](#hotkeys)
* [Eventtypen](#eventtypen)
* [BlockEvent](#blockevent)
* [InteractEvent](#interactevent)
* [Position](#position)
* [Instabile APIs](#instabile-apis)
* [_worldedit](#worldedit)
* [Beispiele](#beispiele)
* [Hello, World!](#hello-world)
* [Code](#code)
* [Ausgabe](#ausgabe)
* [BauGUI on DoubleSwap](#baugui-on-doubleswap)
* [Code](#code-1)
* [SL Command](#sl-command)
* [Code](#code-2)
* [Paste Hotkey](#paste-hotkey)
* [Code](#code-3)
* [Inventory](#inventory-1)
* [Code](#code-4)
<!-- TOC -->
## Einleitung
Das Script System auf SteamWar.de basiert auf [Lua](https://www.lua.org/docs.html).
Der Code wird einfach in ein Minecraft Buch geschrieben und kann mit einem Links-Klick ausgeführt werden.
## Nutzung mit einer IDE
Im Repository liegen [Lua-Definitionen](sw.def.lua) für [Luanalysis](https://plugins.jetbrains.com/plugin/14698-luanalysis).
Diese können in der IDE genutzt werden, um die APIs zu nutzen.
Einfach die `sw.def.lua` in denselben Ordner wie das Script legen und die IDE sollte die APIs erkennen.
# Basis-Apis
Es werden folgende Standard-Apis zur Verfügung gestellt:
- [`math`](https://www.lua.org/manual/5.4/manual.html#6.7)
- [`string`](https://www.lua.org/manual/5.4/manual.html#6.4)
- [`table`](https://www.lua.org/manual/5.4/manual.html#6.6)
- [`bit32`](https://www.lua.org/manual/5.2/manual.html#6.7)
# SteamWar.de-Api
APIs, die mit einem `_` beginnen sind noch nicht stabil und können sich jederzeit ändern.
Sie sollten daher nicht verwendet werden, da sie sich noch in der Entwicklung befinden.
Diese können auch undokumentierte Funktionen enthalten, die nicht in der Dokumentation aufgeführt sind.
In den Scripten gibt es dazu noch folgende globale Variablen:
- [`player`](#player)
- [`random`](#random)
- [`region`](#region)
- [`server`](#server)
- [`storage`](#storage)
- [`inventory`](#inventory)
- `_worldedit`
Ohne eine Kategorie sind folgende Funktionen verfügbar, die nicht allgemein sind:
| Name | Signature | Beschreibung |
|-----------|-----------------------------------|-------------------------------------------------------------------------------------------------------------------|
| `print` | print(String...) | @see chat(String...) |
| `input` | input(String, Function\<String>) | Fragt den User nach einer Eingabe mit der Nachricht und called die zugehörige Funktion nach dieser |
| `delayed` | delayed(Number, Function\<Void>) | Wartet die angegebene Anzahl an Ticks und führt danach die zugehörige Funktion aus |
| `pos` | pos(Number, Number, Number) | Erstellt aus drei Zahlen eine Position-Table. Die Koordinaten sind unter den Namen `x`, `y` und `z` abgespeichert |
| `exec` | exec(String...) | Führt den angegebenen Befehl als Spieler aus |
| `length` | length(Any): Int | Gibt die Länge des Objekts zurück |
| `join` | length(String, String...): String | Füge die Texte mit den ersten Parameter zusammen |
### player
Das `player`-Modul stellt Funktionen zur Verfügung, die den Spieler betreffen.
Es gibt folgende Funktionen:
| Name | Signature | Beschreibung |
|------------------|--------------------------------|---------------------------------------------------------------------------------------------------------------------------|
| `name` | name(): String | Gibt den `displayName` des Spielers zurück |
| `chat` | chat(String...) | Sendet den Text in den Chat des Spielers |
| `actionbar` | actionbar(String...) | Sendet den Text in die ActionBar des Spielers |
| `x` | x(Number), x(): Number | Setzt oder gibt die X-Koordinate des Spielers |
| `y` | y(Number), y(): Number | Setzt oder gibt die Y-Koordinate des Spielers |
| `z` | z(Number), z(): Number | Setzt oder gibt die Z-Koordinate des Spielers |
| `yaw` | yaw(Number), yaw(): Number | Setzt oder gibt die Gierung des Spielers |
| `pitch` | pitch(Number), pitch(): Number | Setzt oder gibt die Steigung des Spielers |
| `sneaking` | sneaking(): Boolean | Wahr, wenn der Spieler am Sneaken ist |
| `sprinting` | sprinting(): Boolean | Wahr, wenn der Spieler am Sprinten ist |
| `slot` | slot(Number), slot(): Number | Setzt oder gibt den Slot des gehaltenden Items des Spielers [(Wiki)](https://minecraft.fandom.com/wiki/Slot#Java_Edition) |
| `item` | item(): String | Gibt den Itemtyp der Main-Hand zurück |
| `offHandItem` | offHandItem(): String | Gibt den Itemtyp der Off-Hand zurück |
| `closeInventory` | closeInventory() | Schließe das aktuell geöffnete Inventar des Spielers |
### random
Das `random`-Modul stellt Funktionen zur Verfügung, die Zufallszahlen betreffen.
Es gibt folgende Funktionen:
| Name | Signature | Beschreibung |
|------------|------------------------------------|-------------------------------------------------------------------------------|
| nextInt | nextInt(): Int | Gibt eine Zufallszahl zurück zwischen Integer.MIN_VALUE und Integer.MAX_VALUE |
| -"- | nextInt(Int): Int | Gibt eine Zufallszahl zurück zischen 0 und dem Argument |
| -"- | nextInt(Int, Int): Int | Gibt eine Zufallszahl zurück zwischen dem ersten und zweiten Argument |
| nextDouble | nextDouble(): Double | Gibt eine Zufallszahl zurück zwischen 0 und 1 |
| -"- | nextDouble(Double): Double | Gibt eine Zufallszahl zurück zwischen 0 und dem Argument |
| -"- | nextDouble(Double, Double): Double | Gibt eine Zufallszahl zurück zwischen ersten und zweiten Argument |
| nextBool | nextBool(): Boolean | Gibt true oder false zurück |
### region
Das `region`-Modul stellt Funktion zur Verfügung, die die Region des Spielers betreffen.
Es gibt folgende Funktionen:
| Name | Signature | Beschreibung |
|-----------|---------------------|------------------------------------------------------------------------------------------------------------|
| `name` | name(): String | Gibt den Regionsnamen |
| `type` | type(): String | Gibt den Regionstyp |
| `fire` | fire(): Boolean | Gibt den Fire-Modus der Region zurück |
| `freeze` | freeze(): Boolean | Gibt den Freeze-Modus der Region zurück |
| `protect` | protect(): Boolean | Gibt den Protect-Modus der Region zurück |
| `loader` | loader(): String | Gibt den Status des Loaders des Spielers zurück, die Werte sind: `OFF`, `SETUP`, `RUNNING`, `PAUSE`, `END` |
| `get` | get(String): Region | Gibt die Region mit dem Namen zurück. Die Region ist gleich aufgebaut wie das Regions-Modul |
| `list` | list(): Region[] | Gibt alle Region zurück. Die Region ist gleich aufgebaut wie das Regions-Modul |
Es gibt folgende weitere Module:
| Name | Beschreibung |
|---------|-----------------|
| `tnt` | [tnt](#tnt) |
| `trace` | [trace](#trace) |
#### tnt
Das `tnt`-Modul stellt Funktionen zur Verfügung, die den TNT-Modus in der Region des Spielers betreffen.
Es gibt folgende Funktionen:
| Name | Signature | Beschreibung |
|-------------|----------------------|-------------------------------------------------------------------------------------|
| `mode` | mode(): String | Gibt den Aktuellen TNT-Modus zurück, die werte sind: `ALLOW`, `DENY` oder `ONLY_TB` |
| `enabled` | enabled(): Boolean | Gibt zurück, ob der TNT-Modus in der Region des Spielers aktiviert ist oder nicht |
| `onlyTb` | onlyTb(): Boolean | Gibt zurück, ob der TNT-Modus auf Only-Tb ist |
| `onlyBuild` | onlyBuild(): Boolean | Gibt zurück, ob der TNT-Modus auf Only-Build ist |
#### trace
Das `trace`-Modul stellt Funktionen zur Verfügung, die den Status des Tracers der Region betreffen.
Es gibt folgende Funktionen:
| Name | Signature | Beschreibung |
|----------|-------------------|--------------------------------------------------------------------------------|
| `active` | active(): Boolean | Gibt zurück, ob der Tracer in der Region des Spielers aktiviert ist oder nicht |
| `auto` | auto(): Boolean | Gibt zurück, ob der Tracer in der Region ein Auto-Tracer ist |
| `status` | status(): String | Gibt den Status des Tracers zurück |
| `time` | time(): String | Gibt die Zeit des Tracers zurück |
## server
Das `server`-Modul stellt Funktionen zur Verfügung, die den Server betreffen.
Es gibt folgende Funktionen:
| Name | Signature | Beschreibung |
|--------------|-------------------------|---------------------------------------------------------------------|
| `time` | time(): String | Gibt die aktuelle Zeit im Format `HH:mm:ss` zurück |
| `ticks` | ticks(): Number | Gibt die Ticks seit start des Serverstarts zurück |
| `getBlockAt` | getBlockAt(Pos): String | Gibt das Material an der Position zurück |
| `setBlockAt` | setBlockAt(Pos, String) | Setzt das Material an der angegebenen Stelle (z.B. Stein = `STONE`) |
Es gibt folgende weitere Module:
| Name | Beschreibung |
|-------|--------------|
| `tps` | [tps](#tps) |
#### tps
Das `tps`-Modul stellt Funktionen zur Verfügung, die die TPS des Servers betreffen.
Es gibt folgende Funktionen:
| Name | Signature | Beschreibung |
|--------------|----------------------|-------------------------------------------------------------------|
| `current` | current(): Number | Gibt die aktuelle TPS zurück (Das selbe wie `oneSecound()`) |
| `oneSecond` | oneSecond(): Number | Gibt die durchschnittliche TPS über die letzte Sekunde zurück |
| `tenSecond` | tenSecond(): Number | Gibt die durchschnittliche TPS über die letzte 10 Sekunden zurück |
| `oneMinute` | oneMinute(): Number | Gibt die durchschnittliche TPS über die letzte Minute zurück |
| `fiveMinute` | fiveMinute(): Number | Gibt die durchschnittliche TPS über die letzte 5 Minuten zurück |
| `tenMinute` | tenMinute(): Number | Gibt die durchschnittliche TPS über die letzte 10 Minuten zurück |
| `limit` | limit(): Number | Gibt das TPS-Limit zurück |
## storage
Das `storage`-Modul stellt Funktionen zur Verfügung, mit welchen man Werte speichern kann.
Es gibt folgende Module:
| Name | Beschreibung |
|----------|---------------------|
| `player` | Spieler abhängig |
| `region` | Region des Spielers |
| `global` | Alle Skripte |
Alle Module haben folgende Funktionen:
| Name | Signature | Beschreibung |
|------------|----------------------------|--------------------------------------------------------|
| `get` | get(String): Any | Gibt den Wert des Schlüssels zurück |
| `set` | set(String, Any) | Setzt den Wert des Schlüssels auf den angegebenen Wert |
| `has` | has(String): Boolean | Prüft ob ein Wert vorhanden ist |
| `remove` | remove(String) | Löscht den Schlüssel |
| `accessor` | accessor(String): Accessor | Gibt einen Accessor zurück |
Ein Accessor ist ein Objekt, womit du direkt auf einen Wert zugreifen kannst und es ändern kannst.
Es geht wie folgt:
```lua
keyAccessor = storage.player.accessor("key")
keyAccessor("Hello World") -- Setzt den Wert auf "Hello World"
print(keyAccessor()) -- Gibt den Wert zurück
```
## inventory
Das `inventory`-Modul stellt Funktionen zur Verfügung, um ein Inventar zu öffnen.
Es gibt folgende Funktionen:
| Name | Signature | Beschreibung |
|----------|-----------------------------------|-------------------------------------------------------------------|
| `create` | create(String, Number): Inventory | Erstellt ein Inventar mit dem Title und der Anzahl an Zeilen |
Das `Inventory`-Objekt hat folgende Funktionen:
| Name | Signature | Beschreibung |
|-------------------|--------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `item` | item(Number, String, String, Function\<String>) | Setze ein Item mit dem Typen des ersten Strings an den Slot (Startet bei 0) mit dem Namen des zweiten Strings mit einem Klick-Handler der den Klick-Typen rein gibt (z.B. `LEFT`, `SHIFT_LEFT`, `RIGHT`, `SHIFT_RIGHT`) |
| -"- | item(Number, String, String, Function\<String>, List<String>) | Füge eine Lore an das Item hinzu |
| -"- | item(Number, String, String, Function\<String>, List<String>, Boolean) | Gebe an, ob das Item enchanted sein soll |
| -"- | item(Number, String, String, Function\<String>, List<String>, Boolean, Number) | Gebe die Anzahl der Items an |
| `setCloseHandler` | setCloseHandler(Function\<Void>) | Gebe einen Handler an, der beim schließen des Inventares ausgeführt wird |
| `open` | open() | Öffne das Inventar |
Siehe auch: [Inventory Beispiel](#inventory-1)
Siehe auch: [Liste an Materials](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html)
```
⚠️⚠️⚠️
Wenn eine Barrier statt des richtigen Items angezeigt wird, dann ist das angegebene Material nicht gültig.
⚠️⚠️⚠️
```
# SteamWar.de-Global-Api
Mit `/script` kann man Script-Bücher global abspeichern. Diese haben dann zugrif auf die `global`-Api.
Die `global`-Api stellt Funktionen zur Verfügung um auf Events, Commands und Hotkeys mit einem Script zu reagieren.
Es gibt folgende Funktionen:
| Name | Signature | Beschreibung |
|-----------|-----------------------------------|-----------------------------------------------------------------------------|
| `event` | event(EventType, Function(Any)) | Registriere einen Event Listener |
| `command` | command(String, Function(Args)) | Registriere einen Befehl |
| `hotkey` | hotkey(String, Function(Boolean)) | Registriere einen Hotkey, the function gets a boolean if the key is pressed |
Es gibt folgende Variablen:
| Name | Beschreibung |
|----------|----------------------------------|
| `events` | Siehe: [Event Type](#eventtypen) |
## Commands
Der Command Handler kriegt eine Liste aller angegeben argumenten. Die Argumente sind vom Typ `String`. Mit dem Wert gespeichert unter `args.alias` oder `args["alias"]` erhältst du, welcher command eingegeben wurde. Wenn ein handler für mehrere Befehle registriert wurde kannst du es hiermit erkennen.
Du kannst `args.hasShortFlag(String)` um herauszufinden ob eine Flag angegeben wurde wie zum Beispiel `-f`. Mit `args.removeShortFlag(String)` kannst du die Flag entfernen und erhältst ob sie angegeben wurde.
## Hotkeys
Hotkeys werden im folgenden Format angegeben: `MODIFIER+KEY`. Bei den Hotkey erstellung ist die Großschreibung egal. Es gibt folgende Modifier:
- `ctrl`
- `shift`
- `alt`
- `meta`
Es können auch mehrere Modifier angegeben werden, z.B. `ctrl+shift+alt+c`. Die Reihenfolge der Modifier und des Keys ist egal.
## Eventtypen
Einige Events sind auch abbrechbar, dazu muss die Funktion `setCancelled()` aufgerufen werden.
| Name | Wenn | Parameter | Abbrechbar |
|---------------------|-----------------------------------------------------|---------------------------------|------------|
| `DoubleSwap` | Beim Doppelten Drücken der Swap-Hands taste | NIL | false |
| `PlaceBlock` | Beim Platzieren von Blöcken | [BlockEvent](#blockevent) | true |
| `BreakBlock` | Beim Zerstören von Blöcken | [BlockEvent](#blockevent) | true |
| `RightClick` | Beim Rechtsklick | [InteractEvent](#interactevent) | true |
| `LeftClick` | Beim Linksklick | [InteractEvent](#interactevent) | true |
| `TNTSpawn` | Wenn ein TNT in der aktuellen Region spawnt | NIL | false |
| `TNTExplode` | Wenn ein TNT in der aktuellen Region explodiert | [Position](#position) | true |
| `TNTExplodeInBuild` | Wenn ein TNT in der aktuellen Bau Region explodiert | [Position](#position) | true |
| `SelfJoin` | Wenn man selbst den Server betritt | NIL | false |
| `SelfLeave` | Wenn man den Server verlässt | NIL | false |
| `DropItem` | Wenn man ein Item droppt | (type: Material) | true |
| `EntityDeath` | Wenn ein Entity stirbt | (type: Entity Type) | false |
### BlockEvent
Das übergebene Objekt an den Handler hat folgende Variablen:
| Name | Beschreibung |
|--------|-----------------------------|
| `x` | Die X-Koordinate des Blocks |
| `y` | Die Y-Koordinate des Blocks |
| `z` | Die Z-Koordinate des Blocks |
| `type` | Das Material des Blocks |
### InteractEvent
Das übergebene Objekt an den Handler hat folgende Variablen:
| Name | Beschreibung |
|------------|-------------------------------------------------------------------------------------------------------------------------------|
| `action` | Die Action die ausgeführt wurde, Mögliche Werte: `RIGHT_CLICK_BLOCK`, `RIGHT_CLICK_AIR`, `LEFT_CLICK_BLOCK`, `LEFT_CLICK_AIR` |
| `hand` | Die Hand die zum ausführen genutzt wird, Mögliche Werte: `HAND`, `OFF_HAND`, `null` |
| `block` | Der Typ des Items mit dem geklickt wurde |
| `hasBlock` | Wahr, wenn auf einen Block geklickt wurde |
Wenn `hasBlock` wahr ist, gibt es folgende Variablen:
| Name | Beschreibung |
|-------------|-----------------------------------------|
| `blockX` | Die X-Koordinate des Blocks |
| `blockY` | Die Y-Koordinate des Blocks |
| `blockZ` | Die Z-Koordinate des Blocks |
| `blockFace` | Die Seite des Blocks die geklickt wurde |
### Position
Die Position ist ein Objekt mit folgenden Variablen:
| Name | Beschreibung |
|------|------------------|
| `x` | Die X-Koordinate |
| `y` | Die Y-Koordinate |
| `z` | Die Z-Koordinate |
# Instabile APIs
Hier sind einige APIs aufgelistet, die nicht stabil sind und sich jederzeit ändern können.
## _worldedit
| Name | Signatur | Beschreibung |
|-------------|-----------------------------------------------------------|-----------------------------------|
| `selection` | selection(Liste\<Pos>), selection(): {min: Pos, max: Pos} | Die aktuelle auswahl des Spielers |
# Beispiele
## Hello, World!
Ein einfaches Hello, World!-Script.
#### Code
```lua
print("Hello, World!")
```
#### Ausgabe
```
Hello, World!
```
## BauGUI on DoubleSwap
Das Standardskript für das Öffnen des BauGUIs
#### Code
```lua
function handler(event)
exec("gui")
end
event(events.DoubleSwap, handler)
```
## SL Command
Ein einfacher Command Redefiner.
#### Code
```lua
function handler(args)
exec("stoplag")
end
command("sl", handler)
```
## Paste Hotkey
Ein Hotkey zum Pasten des Clipboard-Inhalts.
#### Code
```lua
function handler(pressed)
if pressed then
exec("/paste -o")
end
end
hotkey("ctrl+v", handler)
```
## Inventory
Ein Beispiel für ein Inventar.
#### Code
```lua
inv = inventory.create("Test Inv", 3)
inv.item(13, "STONE", "Ich bin ein Stein", function(e) player.chat(e) end, {"Die Lore", "Die Zweite Zeile"}, true)
inv.open()
```

87
BauSystem/hotkeys.lua Normal file
View File

@ -0,0 +1,87 @@
-- 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/>.
---
--- This serves both as an example and a quick start to the Stewamwar Script Api
---
function hotkeys_freeze(pressed)
if pressed then
exec("/freeze")
end
end
function hotkeys_rgc(pressed)
if pressed then
exec("/rgc")
end
end
function hotkeys_rgp(pressed)
if pressed then
exec("/rgp")
end
end
trace_cycle_counter = 0;
function hotkeys_cycle_trace_view(pressed)
if not pressed then
return
end
trace_cycle = (trace_cycle + 1) % 3
trace_commands = {"trace hide", "trace show", "trace show -e -c"}
exec(trace_commands[trace_cycle + 1])
end
function hotkeys_tick_step(pressed)
if pressed then
exec("tick step")
end
end
function hotkeys_tpslimit(pressed)
if not pressed then
return
end
if tps.limit() == 20 then
exec("tpslimit 200")
else
exec("tpslimit 20")
end
end
function hotkeys_tb(pressed)
if pressed then
exec("tb -e")
end
end
function hotkeys_trace_delete(pressed)
if pressed then
exec("trace delete")
end
end
hotkey("ctrl+g", hotkeys_freeze)
hotkey("ctrl+c", hotkeys_rgc)
hotkey("ctrl+v", hotkeys_rgp)
hotkey("ctrl+x", hotkeys_tick_step)
hotkey("shift+x", hotkeys_cycle_trace_view)
hotkey("ctrl+y", hotkeys_tb)
hotkey("ctrl+alt", hotkeys_trace_delete)
hotkey("ctrl+h", hotkeys_trace_delete)

432
BauSystem/sw.def.lua Normal file
View File

@ -0,0 +1,432 @@
-- This file is a part of the SteamWar software.
--
-- Copyright (C) 2021 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/>.
---
--- This file contains the definitions for the SteamWar.de script API.
--- It is used by the IDE to provide code completion and type checking.
--- Created by Chaoscaot
---
inventory = {}
---@param title string
---@param size number
---@return Inventory
function inventory.create(title, size) return nil end
---@alias InventoryClick 'LEFT' | 'SHIFT_LEFT' | 'RIGHT' | 'SHIFT_RIGHT' | 'MIDDLE' | 'NUMBER_KEY'
---@class Inventory
local Inventory = {}
---@overload fun(slot: number, material: string, name: string, handler: fun(click: InventoryClick)): void
---@overload fun(slot: number, material: string, name: string, handler: fun(click: InventoryClick), lore: string[]): void
---@overload fun(slot: number, material: string, name: string, handler: fun(click: InventoryClick), lore: string[], enchanted: boolean): void
---@param slot number
---@param material string
---@param name string
---@param handler fun(click: InventoryClick): void
---@param lore string[]
---@param enchanted boolean
---@param amount number
---@return void
function Inventory.item(slot, material, name, handler, lore, enchanted, amount) end
---@param handler fun(): void
---@return void
function Inventory.setCloseHandler(handler) end
---@return void
function Inventory.open() end
player = {}
---@return string
---Get the name of the player.
function player.name() return "" end
---@return void
function player.chat(...) end
---@return void
---Send a message to the actionbar of the player.
function player.actionbar(...) end
---@overload fun(): number
---@param newX number
function player.x(newX) end
---@overload fun(): number
---@param newY number
function player.y(newY) end
---@overload fun(): number
---@param newZ number
function player.z(newZ) end
---@overload fun(): number
---@param newYaw number
function player.yaw(newYaw) end
---@overload fun(): number
---@param newPitch number
function player.pitch(newPitch) end
---@return boolean
function player.sneaking() return nil end
---@return boolean
function player.sprinting() return nil end
---@overload fun(): number
---@param newSlot number
function player.slot(newSlot) end
---@return string
function player.item() return nil end
---@return string
function player.offHandItem() return nil end
---@return void
function player.closeInventory() end
---@field nextBool fun(): boolean
random = {}
---@overload fun(): number
---@overload fun(bound: number): number
---@param origin number
---@param bound number
---@return number
function random.nextInt(origin, bound) return nil end
---@overload fun(): number
---@overload fun(bound: number): number
---@param origin number
---@param bound number
---@return number
function random.nextDouble(origin, bound) return nil end
---@return boolean
function random.nextBool() return nil end
---@alias RegionType 'wg' | 'mwg' | 'as' | 'ws' | 'ws_inner' | 'ws_rumpf' | 'ws_rahmen' | 'spawn'
---@class iregion
---@field tnt tnt
---@field trace trace
local iregion = {}
---@class region: iregion
region = {}
---@return string
function iregion.name() return nil end
---@return RegionType
function iregion.type() return nil end
---@return boolean
function iregion.fire() return nil end
---@return boolean
function iregion.freeze() return nil end
---@return boolean
function iregion.protect() return nil end
---@return string
function iregion.loader() return nil end
---@return Position
function iregion.copyPoint() return nil end
---@return Position
function iregion.minPointBuild() return nil end
---@return Position
function iregion.maxPointBuild() return nil end
---@return Position
function iregion.minPointBuildExtension() return nil end
---@return Position
function iregion.maxPointBuildExtension() return nil end
---@return Position
function iregion.testblockPoint() return nil end
---@return Position
function iregion.minPointTestblock() return nil end
---@return Position
function iregion.maxPointTestblock() return nil end
---@return Position
function iregion.minPointTestblockExtension() return nil end
---@return Position
function iregion.maxPointTestblockExtension() return nil end
---@alias TNTMode 'ALLOW' | 'DENY' | 'ONLY_TB'
---@class tnt
local tnt = {}
---@return TNTMode
function tnt.mode() return nil end
---@return boolean
function tnt.enabled() return nil end
---@return boolean
function tnt.onlyTb() return nil end
---@return boolean
function tnt.onlyBuild() return nil end
---@param name string
---@return iregion
function region.get(name) return nil end
---@return iregion[]
function region.list() return nil end
---@class tracerLib
tracer = {}
---@class TraceRecord
---@field pos Position
---@field vel Position
---@field ticksSinceStart number
---@field fuse number
---@field isExplosion boolean
---@field isInWater boolean
---@field hasDestroyedBuild boolean
---@field hasDestroyedTestblock boolean
---@class Tracer
---@field getId fun(): string
---@field getRecords fun(): {[number]: {[number]: TraceRecord}}
function tracer.getTraces() return nil end
---@class Position
---@field x number
---@field y number
---@field z number
---@class server
---@field tps tps
server = {}
---@return string
function server.time() return nil end
---@return number
function server.ticks() return nil end
---@param position Position
---@return string
function getBlockAt(position) return nil end
---@param position Position
---@param material string
---@return void
function setBlockAt(position, material) return nil end
---@class tps
local tps = {}
---@return number
function tps.oneSecond() return nil end
---@return number
function tps.tenSecond() return nil end
---@return number
function tps.oneMinute() return nil end
---@return number
function tps.fiveMinute() return nil end
---@return number
function tps.tenMinute() return nil end
---@return number
function tps.current() return nil end
---@return number
function tps.limit() return nil end
---@class storage
---@field global storageLib
---@field player storageLib
---@field region storageLib
storage = {}
---@class storageLib
---Any Primitive, Array or Table will be saved across restarts, everything else will be discarded
local storageLib = {}
---@param key string
---@return any
function storageLib.get(key) return nil end
---@param key string
---@param value any
---@return void
function storageLib.set(key, value) end
---@param key string
---@return boolean
function storageLib.has(key) return nil end
---@param key string
---@return void
function storageLib.remove(key) end
---@param key string
---@return Accessor
function storageLib.accessor(key) return nil end
---@class Accessor
---@overload fun(): any
---@overload fun(value: any)
---@class Selection
---@field max Position
---@field min Position
---@class _worldedit
_worldedit = {}
---@overload fun(pos: Position[]): void
---@return Selection
function _worldedit.selection() return nil end
---@param msg string
---@param callback fun(value: string): void
---@return void
function input(msg, callback) end
---@param ticks number
---@param callback fun(): void
---@return void
function delayed(ticks, callback) end
---@param x number
---@param y number
---@param z number
---@return Position
function pos(x, y, z) return nil end
---@return void
function exec(...) end
---@param obj any
---@return number
function length(obj) return 0 end
---@param separator string
---@param table any[]
---@return string
function join(separator, table) return "" end
---@class EventType
---@class events
---@field DoubleSwap EventType
---@field PlaceBlock EventType
---@field BreakBlock EventType
---@field RightClick EventType
---@field LeftClick EventType
---@field TNTSpawn EventType
---@field TNTExplode EventType
---@field TNTExplodeInBuild EventType
---@field SelfJoin EventType
---@field SelfLeave EventType
---@field DropItem EventType
---@field EntityDeath EventType
events = {}
---@param id EventType
---@param handler fun(params: any): void
---@return void
function event(id, handler) end
---@param command string
---@param handler fun(params: string[]): void
---@return void
function command(command, handler) end
---@param trigger string
---@param handler fun(pressed: boolean): void
---@return void
function hotkey(trigger, handler) end
---@class bossbar
bossbar = {}
---@alias BossBarColor 'PINK' | 'BLUE' | 'RED' | 'GREEN' | 'YELLOW' | 'PURPLE' | 'WHITE'
---@alias BossBarStyle 'SEGMENTED_6' | 'SEGMENTED_10' | 'SEGMENTED_12' | 'SEGMENTED_20' | 'SOLID'
---@alias BossBarFlag 'DARKEN_SKY' | 'PLAY_BOSS_MUSIC' | 'CREATE_FOG'
---@class BossBar
local BossBar = {}
---@param title string
---@param color BossBarColor
---@param style BossBarStyle
---@return BossBar
function bossbar.create(title, color, style) return nil end
---@return string
---@overload fun(title: string): void
function BossBar.title() end
---@return BossBarColor
---@overload fun(color: BossBarColor): void
function BossBar.color() end
---@return BossBarStyle
---@overload fun(style: BossBarStyle): void
function BossBar.style() end
---@return number
---@overload fun(progress: number): void
function BossBar.progress() end
---@return boolean
---@overload fun(visible: boolean): void
function BossBar.visible() end
---@return boolean
---@param flag BossBarFlag
function BossBar.hasFlag(flag) return nil end
---@return void
---@param flag BossBarFlag
function BossBar.addFlag(flag) end
---@return boolean
---@param flag BossBarFlag
function BossBar.removeFlag(flag) return nil end
---@return void
function BossBar.destroy() end

View File

@ -30,7 +30,6 @@ import java.util.zip.GZIPInputStream;
@AllArgsConstructor
@Getter
public class NodeData {
static {
new SqlTypeMapper<>(PipedInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("PipedInputStream is write only datatype"); }, PreparedStatement::setBinaryStream);
new SqlTypeMapper<>(ByteArrayInputStream.class, "BLOB", (rs, identifier) -> { throw new SecurityException("ByteArrayInputStream is write only datatype"); }, PreparedStatement::setBinaryStream);

View File

@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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

View File

@ -31,10 +31,13 @@ public class SchematicNode {
static {
SchematicType.Normal.name(); // Ensure SchematicType is loaded.
new SqlTypeMapper<>(SchematicNode.class, null, (rs, identifier) -> { throw new SecurityException("SchematicNode cannot be used as type (recursive select)"); }, (st, index, value) -> st.setInt(index, value.nodeId));
new SqlTypeMapper<>(SchematicNode.class, null, (rs, identifier) -> {
throw new SecurityException("SchematicNode cannot be used as type (recursive select)");
}, (st, index, value) -> st.setInt(index, value.nodeId));
}
private static final Map<Integer, Map<String, List<String>>> TAB_CACHE = new HashMap<>();
public static void clear() {
TAB_CACHE.clear();
}
@ -42,39 +45,60 @@ public class SchematicNode {
private static final String nodeSelector = "SELECT NodeId, NodeOwner, NodeOwner AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode ";
private static final Table<SchematicNode> table = new Table<>(SchematicNode.class);
private static final Statement create = table.insertFields(true, "NodeOwner", "NodeName", "ParentNode", "NodeItem", "NodeType");
private static final Statement update = table.update(Table.PRIMARY, "NodeName", "ParentNode", "NodeItem", "NodeType", "NodeRank", "ReplaceColor", "AllowReplay");
private static final Statement create = table.insertFields(true, "NodeOwner", "NodeName", "ParentNode", "NodeItem",
"NodeType");
private static final Statement update = table.update(Table.PRIMARY, "NodeName", "ParentNode", "NodeItem",
"NodeType", "NodeRank", "ReplaceColor", "AllowReplay");
private static final Statement delete = table.delete(Table.PRIMARY);
private static final SelectStatement<SchematicNode> byId = new SelectStatement<>(table, nodeSelector + "WHERE NodeId = ?");
private static final SelectStatement<SchematicNode> byOwnerNameParent = new SelectStatement<>(table, nodeSelector + "WHERE NodeOwner = ? AND NodeName = ? AND ParentNode " + Statement.NULL_SAFE_EQUALS + "?");
private static final SelectStatement<SchematicNode> byParent = new SelectStatement<>(table, nodeSelector + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
private static final SelectStatement<SchematicNode> dirsByParent = new SelectStatement<>(table, nodeSelector + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? AND NodeType is NULL ORDER BY NodeName");
private static final SelectStatement<SchematicNode> byOwnerType = new SelectStatement<>(table, nodeSelector + "WHERE NodeOwner = ? AND NodeType = ? ORDER BY NodeName");
private static final SelectStatement<SchematicNode> byType = new SelectStatement<>(table, nodeSelector + "WHERE NodeType = ? ORDER BY NodeName");
private static final SelectStatement<SchematicNode> all = new SelectStatement<>(table, "SELECT * FROM EffectiveSchematicNode WHERE EffectiveOwner = ? ORDER BY NodeName");
private static final SelectStatement<SchematicNode> list = new SelectStatement<>(table, "SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId " + Statement.NULL_SAFE_EQUALS + "? AND NM.UserId = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE (? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?) ORDER BY NodeName");
private static final SelectStatement<SchematicNode> byParentName = new SelectStatement<>(table, "SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId " + Statement.NULL_SAFE_EQUALS + "? AND NM.UserId = ? AND SchematicNode.NodeName = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE ((? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?)) AND NodeName = ?");
private static final SelectStatement<SchematicNode> schematicAccessibleForUser = new SelectStatement<>(table, "SELECT COUNT(DISTINCT NodeId) FROM EffectiveSchematicNode WHERE EffectiveOwner = ? AND NodeId = ?");
private static final SelectStatement<SchematicNode> accessibleByUserTypeInParent = new SelectStatement<>(table, "WITH RECURSIVE RSASN AS(WITH RECURSIVE RSAN AS (WITH RSANH AS (WITH RECURSIVE RSA AS (SELECT SN.NodeId, NM.ParentId FROM SchematicNode SN LEFT JOIN NodeMember NM on SN.NodeId = NM.NodeId WHERE NM.UserId = ? UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN INNER JOIN RSA ON RSA.NodeId = SN.ParentNode) SELECT * FROM RSA UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?) SELECT * FROM RSANH UNION SELECT SN.NodeId, SN.ParentNode FROM RSANH JOIN SchematicNode SN ON SN.ParentNode = RSANH.NodeId) SELECT RSAN.NodeId, RSAN.ParentId FROM RSAN JOIN SchematicNode SN ON SN.NodeId = RSAN.NodeId WHERE NodeType = ? UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN JOIN RSASN ON SN.NodeId = RSASN.ParentId) SELECT SN.*, ? as EffectiveOwner, RSASN.ParentId AS ParentNode FROM RSASN JOIN SchematicNode SN ON SN.NodeId = RSASN.NodeId WHERE RSASN.ParentId" + Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
private static final SelectStatement<SchematicNode> accessibleByUserType = new SelectStatement<>(table, "WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE NodeType = ?");
private static final SelectStatement<SchematicNode> byIdAndUser = new SelectStatement<>(table, "SELECT NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE NodeId = ?");
private static final SelectStatement<SchematicNode> allParentsOfNode = new SelectStatement<>(table, "WITH RECURSIVE R AS (SELECT NodeId, ParentNode FROM EffectiveSchematicNode WHERE NodeId = ? AND EffectiveOwner = ? UNION SELECT E.NodeId, E.ParentNode FROM R, EffectiveSchematicNode E WHERE R.ParentNode = E.NodeId AND E.EffectiveOwner = ?) SELECT SN.NodeId, SN.NodeOwner, ? AS EffectiveOwner, SN.NodeName, R.ParentNode, SN.LastUpdate, SN.NodeItem, SN.NodeType, SN.NodeRank, SN.ReplaceColor, SN.AllowReplay FROM R INNER JOIN SchematicNode SN ON SN.NodeId = R.NodeId");
private static final SelectStatement<SchematicNode> byId = new SelectStatement<>(table,
nodeSelector + "WHERE NodeId = ?");
private static final SelectStatement<SchematicNode> byOwnerNameParent = new SelectStatement<>(table,
nodeSelector + "WHERE NodeOwner = ? AND NodeName = ? AND ParentNode " + Statement.NULL_SAFE_EQUALS + "?");
private static final SelectStatement<SchematicNode> byParent = new SelectStatement<>(table,
nodeSelector + "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
private static final SelectStatement<SchematicNode> dirsByParent = new SelectStatement<>(table, nodeSelector
+ "WHERE ParentNode" + Statement.NULL_SAFE_EQUALS + "? AND NodeType is NULL ORDER BY NodeName");
private static final SelectStatement<SchematicNode> byOwnerType = new SelectStatement<>(table,
nodeSelector + "WHERE NodeOwner = ? AND NodeType = ? ORDER BY NodeName");
private static final SelectStatement<SchematicNode> byType = new SelectStatement<>(table,
nodeSelector + "WHERE NodeType = ? ORDER BY NodeName");
private static final SelectStatement<SchematicNode> all = new SelectStatement<>(table,
"WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId");
private static final SelectStatement<SchematicNode> list = new SelectStatement<>(table,
"SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId "
+ Statement.NULL_SAFE_EQUALS
+ "? AND NM.UserId = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE (? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?) ORDER BY NodeName");
private static final SelectStatement<SchematicNode> byParentName = new SelectStatement<>(table,
"SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, NM.ParentId AS ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode INNER JOIN NodeMember NM on SchematicNode.NodeId = NM.NodeId WHERE NM.ParentId "
+ Statement.NULL_SAFE_EQUALS
+ "? AND NM.UserId = ? AND SchematicNode.NodeName = ? UNION ALL SELECT SchematicNode.NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE ((? IS NULL AND ParentNode IS NULL AND NodeOwner = ?) OR (? IS NOT NULL AND ParentNode = ?)) AND NodeName = ?");
private static final SelectStatement<SchematicNode> schematicAccessibleForUser = new SelectStatement<>(table,
"WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE NodeId = ?");
private static final SelectStatement<SchematicNode> accessibleByUserTypeInParent = new SelectStatement<>(table,
"WITH RECURSIVE RSASN AS(WITH RECURSIVE RSAN AS (WITH RSANH AS (WITH RECURSIVE RSA AS (SELECT SN.NodeId, NM.ParentId FROM SchematicNode SN LEFT JOIN NodeMember NM on SN.NodeId = NM.NodeId WHERE NM.UserId = ? UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN INNER JOIN RSA ON RSA.NodeId = SN.ParentNode) SELECT * FROM RSA UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?) SELECT * FROM RSANH UNION SELECT SN.NodeId, SN.ParentNode FROM RSANH JOIN SchematicNode SN ON SN.ParentNode = RSANH.NodeId) SELECT RSAN.NodeId, RSAN.ParentId FROM RSAN JOIN SchematicNode SN ON SN.NodeId = RSAN.NodeId WHERE NodeType = ? UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN JOIN RSASN ON SN.NodeId = RSASN.ParentId) SELECT SN.*, ? as EffectiveOwner, RSASN.ParentId AS ParentNode FROM RSASN JOIN SchematicNode SN ON SN.NodeId = RSASN.NodeId WHERE RSASN.ParentId"
+ Statement.NULL_SAFE_EQUALS + "? ORDER BY NodeName");
private static final SelectStatement<SchematicNode> accessibleByUserType = new SelectStatement<>(table,
"WITH RECURSIVE Nodes AS (SELECT NodeId, ParentId as ParentNode FROM NodeMember WHERE UserId = ? UNION SELECT NodeId, ParentNode FROM SchematicNode WHERE NodeOwner = ?), RSN AS ( SELECT NodeId, ParentNode FROM Nodes UNION SELECT SN.NodeId, SN.ParentNode FROM SchematicNode SN, RSN WHERE SN.ParentNode = RSN.NodeId ) SELECT SN.*, ? AS EffectiveOwner FROM RSN INNER JOIN SchematicNode SN ON RSN.NodeId = SN.NodeId WHERE NodeType = ?");
private static final SelectStatement<SchematicNode> byIdAndUser = new SelectStatement<>(table,
"SELECT NodeId, NodeOwner, ? AS EffectiveOwner, NodeName, ParentNode, LastUpdate, NodeItem, NodeType, NodeRank, ReplaceColor, AllowReplay FROM SchematicNode WHERE NodeId = ?");
private static final SelectStatement<SchematicNode> allParentsOfNode = new SelectStatement<>(table,
"WITH RECURSIVE R AS (SELECT NodeId, ParentNode FROM EffectiveSchematicNode WHERE NodeId = ? AND EffectiveOwner = ? UNION SELECT E.NodeId, E.ParentNode FROM R, EffectiveSchematicNode E WHERE R.ParentNode = E.NodeId AND E.EffectiveOwner = ?) SELECT SN.NodeId, SN.NodeOwner, ? AS EffectiveOwner, SN.NodeName, R.ParentNode, SN.LastUpdate, SN.NodeItem, SN.NodeType, SN.NodeRank, SN.ReplaceColor, SN.AllowReplay FROM R INNER JOIN SchematicNode SN ON SN.NodeId = R.NodeId");
static {
NodeMember.init();
}
@Field(keys = {Table.PRIMARY}, autoincrement = true)
@Field(keys = { Table.PRIMARY }, autoincrement = true)
private final int nodeId;
@Field(keys = {"OwnerNameParent"})
@Field(keys = { "OwnerNameParent" })
private final int nodeOwner;
@Field(def = "0")
@Getter
private final int effectiveOwner;
@Field(keys = {"OwnerNameParent"})
@Field(keys = { "OwnerNameParent" })
private String nodeName;
@Field(keys = {"OwnerNameParent"}, nullable = true)
@Field(keys = { "OwnerNameParent" }, nullable = true)
private Integer parentNode;
@Field(def = "CURRENT_TIMESTAMP")
private Timestamp lastUpdate;
@ -102,8 +126,7 @@ public class SchematicNode {
SchematicType nodeType,
int nodeRank,
boolean replaceColor,
boolean allowReplay
) {
boolean allowReplay) {
this.nodeId = nodeId;
this.nodeOwner = nodeOwner;
this.effectiveOwner = effectiveOwner;
@ -118,7 +141,7 @@ public class SchematicNode {
}
public static List<SchematicNode> getAll(SteamwarUser user) {
return all.listSelect(user);
return all.listSelect(user, user, user);
}
public static Map<Integer, List<SchematicNode>> getAllMap(SteamwarUser user) {
@ -130,7 +153,8 @@ public class SchematicNode {
}
public static SchematicNode byParentName(SteamwarUser user, Integer schematicId, String name) {
return byParentName.select(user, schematicId, user, name, user, schematicId, user, schematicId, schematicId, name);
return byParentName.select(user, schematicId, user, name, user, schematicId, user, schematicId, schematicId,
name);
}
public static List<SchematicNode> accessibleByUserType(SteamwarUser user, SchematicType type) {
@ -142,10 +166,11 @@ public class SchematicNode {
}
public static boolean schematicAccessibleForUser(SteamwarUser user, Integer schematicId) {
return schematicAccessibleForUser.select(user, schematicId) != null;
return schematicAccessibleForUser.select(user, user, user, schematicId) != null;
}
public static List<SchematicNode> accessibleByUserTypeParent(SteamwarUser user, SchematicType type, Integer parentId) {
public static List<SchematicNode> accessibleByUserTypeParent(SteamwarUser user, SchematicType type,
Integer parentId) {
return accessibleByUserTypeInParent.listSelect(user, user, type, user, parentId);
}
@ -160,7 +185,8 @@ public class SchematicNode {
private static Map<Integer, List<SchematicNode>> map(List<SchematicNode> in) {
Map<Integer, List<SchematicNode>> map = new HashMap<>();
for (SchematicNode effectiveSchematicNode : in) {
map.computeIfAbsent(effectiveSchematicNode.getOptionalParent().orElse(0), k -> new ArrayList<>()).add(effectiveSchematicNode);
map.computeIfAbsent(effectiveSchematicNode.getOptionalParent().orElse(0), k -> new ArrayList<>())
.add(effectiveSchematicNode);
}
return map;
}
@ -218,7 +244,8 @@ public class SchematicNode {
return byId.select(id);
}
public static List<SchematicNode> getAccessibleSchematicsOfTypeInParent(int owner, String schemType, Integer parent) {
public static List<SchematicNode> getAccessibleSchematicsOfTypeInParent(int owner, String schemType,
Integer parent) {
return accessibleByUserTypeParent(SteamwarUser.get(owner), SchematicType.fromDB(schemType), parent);
}
@ -283,10 +310,12 @@ public class SchematicNode {
}
if (s.contains("/")) {
String[] layers = s.split("/");
Optional<SchematicNode> currentNode = Optional.ofNullable(SchematicNode.byParentName(user, null, layers[0]));
Optional<SchematicNode> currentNode = Optional
.ofNullable(SchematicNode.byParentName(user, null, layers[0]));
for (int i = 1; i < layers.length; i++) {
int finalI = i;
Optional<SchematicNode> node = currentNode.map(effectiveSchematicNode -> SchematicNode.byParentName(user, effectiveSchematicNode.getId(), layers[finalI]));
Optional<SchematicNode> node = currentNode.map(effectiveSchematicNode -> SchematicNode
.byParentName(user, effectiveSchematicNode.getId(), layers[finalI]));
if (!node.isPresent()) {
return null;
} else {
@ -365,7 +394,7 @@ public class SchematicNode {
@Deprecated
public void setType(String type) {
if(isDir())
if (isDir())
throw new SecurityException("Node is Directory");
this.nodeType = SchematicType.fromDB(type);
updateDB();
@ -376,13 +405,13 @@ public class SchematicNode {
}
public String getFileEnding() {
if(isDir())
if (isDir())
throw new SecurityException("Node is Directory");
return NodeData.get(this).getNodeFormat().getFileEnding();
}
public int getRank() {
if(isDir())
if (isDir())
throw new SecurityException("Node is Directory");
return nodeRank;
}
@ -393,19 +422,19 @@ public class SchematicNode {
}
public void setRank(int rank) {
if(isDir())
if (isDir())
throw new SecurityException("Node is Directory");
this.nodeRank = rank;
}
public SchematicType getSchemtype() {
if(isDir())
if (isDir())
throw new SecurityException("Is Directory");
return nodeType;
}
public void setSchemtype(SchematicType type) {
if(isDir())
if (isDir())
throw new SecurityException("Is Directory");
this.nodeType = type;
updateDB();
@ -416,7 +445,7 @@ public class SchematicNode {
}
public void setReplaceColor(boolean replaceColor) {
if(isDir())
if (isDir())
throw new SecurityException("Is Directory");
this.replaceColor = replaceColor;
updateDB();
@ -427,14 +456,15 @@ public class SchematicNode {
}
public void setAllowReplay(boolean allowReplay) {
if(isDir())
if (isDir())
throw new SecurityException("Is Directory");
this.allowReplay = allowReplay;
updateDB();
}
public SchematicNode getParentNode() {
if(parentNode == null) return null;
if (parentNode == null)
return null;
return SchematicNode.getSchematicNode(parentNode);
}
@ -486,7 +516,7 @@ public class SchematicNode {
}
public String generateBreadcrumbs() {
if(brCache == null) {
if (brCache == null) {
brCache = generateBreadcrumbs("/");
}
return brCache;
@ -495,11 +525,15 @@ public class SchematicNode {
public String generateBreadcrumbs(String split) {
StringBuilder builder = new StringBuilder(getName());
Optional<SchematicNode> currentNode = Optional.of(this);
if(currentNode.map(SchematicNode::isDir).orElse(false)) {
if (currentNode.map(SchematicNode::isDir).orElse(false)) {
builder.append(split);
}
while (currentNode.isPresent()) {
currentNode = currentNode.flatMap(schematicNode -> Optional.ofNullable(NodeMember.getNodeMember(schematicNode.getId(), effectiveOwner)).map(NodeMember::getParent).orElse(schematicNode.getOptionalParent())).map(SchematicNode::getSchematicNode);
currentNode = currentNode
.flatMap(schematicNode -> Optional
.ofNullable(NodeMember.getNodeMember(schematicNode.getId(), effectiveOwner))
.map(NodeMember::getParent).orElse(schematicNode.getOptionalParent()))
.map(SchematicNode::getSchematicNode);
currentNode.ifPresent(node -> builder.insert(0, split).insert(0, node.getName()));
}
return builder.toString();
@ -508,17 +542,22 @@ public class SchematicNode {
public List<Map.Entry<String, Integer>> generateBreadcrumbsMap(SteamwarUser user) {
List<Map.Entry<String, Integer>> map = new ArrayList<>();
Optional<SchematicNode> currentNode = Optional.of(this);
if(currentNode.map(SchematicNode::isDir).orElse(false)) {
if (currentNode.map(SchematicNode::isDir).orElse(false)) {
map.add(new AbstractMap.SimpleEntry<>(getName(), getId()));
}
while (currentNode.isPresent()) {
currentNode = currentNode.flatMap(schematicNode -> Optional.ofNullable(NodeMember.getNodeMember(schematicNode.getId(), effectiveOwner)).map(NodeMember::getParent).orElse(schematicNode.getOptionalParent())).map(SchematicNode::getSchematicNode);
currentNode = currentNode
.flatMap(schematicNode -> Optional
.ofNullable(NodeMember.getNodeMember(schematicNode.getId(), effectiveOwner))
.map(NodeMember::getParent).orElse(schematicNode.getOptionalParent()))
.map(SchematicNode::getSchematicNode);
currentNode.ifPresent(node -> map.add(0, new AbstractMap.SimpleEntry<>(node.getName(), node.getId())));
}
return map;
}
private static final List<String> FORBIDDEN_NAMES = Collections.unmodifiableList(Arrays.asList("public"));
public static boolean invalidSchemName(String[] layers) {
for (String layer : layers) {
if (layer.isEmpty()) {
@ -535,7 +574,7 @@ public class SchematicNode {
layer.contains(" ")) {
return true;
}
if(FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
if (FORBIDDEN_NAMES.contains(layer.toLowerCase())) {
return true;
}
}
@ -549,14 +588,15 @@ public class SchematicNode {
}
int index = s.lastIndexOf("/");
String cacheKey = index == -1 ? "" : s.substring(0, index);
if(TAB_CACHE.containsKey(user.getId()) && TAB_CACHE.get(user.getId()).containsKey(cacheKey)) {
if (TAB_CACHE.containsKey(user.getId()) && TAB_CACHE.get(user.getId()).containsKey(cacheKey)) {
return new ArrayList<>(TAB_CACHE.get(user.getId()).get(cacheKey));
}
List<String> list = new ArrayList<>();
if (s.contains("/")) {
String preTab = s.substring(0, s.lastIndexOf("/") + 1);
SchematicNode pa = SchematicNode.getNodeFromPath(user, preTab);
if (pa == null) return new ArrayList<>();
if (pa == null)
return new ArrayList<>();
List<SchematicNode> nodes = SchematicNode.list(user, pa.getId());
String br = pa.generateBreadcrumbs();
nodes.forEach(node -> list.add((sws ? "/" : "") + br + node.getName() + (node.isDir() ? "/" : "")));

View File

@ -335,7 +335,7 @@ public class SteamwarUser {
public boolean verifyPassword(String password) {
try {
if (this.password == null) {
if (!hasPassword()) {
return false;
}

View File

@ -75,15 +75,7 @@ public class UserElo {
public static void setElo(int userId, String gameMode, int elo) {
emblemCache.remove(userId);
int oldPlacement = getPlacement(getElo(userId, gameMode).orElse(0), gameMode);
int newPlacement = getPlacement(elo, gameMode);
gameModeUserEloCache.getOrDefault(gameMode, Collections.emptyMap()).remove(userId);
if (oldPlacement <= 3 || newPlacement <= 3) {
emblemCache.clear();
}
setElo.update(Season.getSeason(), gameMode, userId, elo);
}
@ -112,27 +104,17 @@ public class UserElo {
public static String getEmblemProgression(String gameMode, int userId) {
switch (getProgression(userId, gameMode)) {
case -1:
return "§f/ §8 ∧ ❂ III II I";
return "§8❱❱❱❱ ❂";
case 0:
return "§8/ §6 §8∧ ∧ ❂ III II I";
return "§e❱§8❱❱❱ ❂";
case 1:
return "§8/ §6∧ §8 ∧ ❂ III II I";
return "§e❱❱§8❱❱ ❂";
case 2:
return "§8/ ∧ §7 §8∧ ∧ ❂ III II I";
return "§e❱❱❱§8❱ ❂";
case 3:
return "§8/ §7∧ §8 ∧ ❂ III II I";
return "§e❱❱❱❱§8 ❂";
case 4:
return "§8/ ∧ §e §8∧ ❂ III II I";
case 5:
return "§8/ §e∧ §8❂ III II I";
case 6:
return "§8/ ∧ §5❂ §8III II I";
case 7:
return "§8/ ∧ ❂ §5III §8II I";
case 8:
return "§8/ ∧ ❂ III §5II §8I";
case 9:
return "§8/ ∧ ❂ III II §5I";
return "§8❱❱❱❱ §5❂";
default:
throw new SecurityException("Progression is not in range");
}
@ -142,19 +124,11 @@ public class UserElo {
int elo = getElo(userId, gameMode).orElse(-1);
if (elo < 0) return -1;
if (elo <= 100) return 0;
if (elo <= 200) return 1;
if (elo <= 400) return 2;
if (elo <= 600) return 3;
if (elo <= 900) return 4;
if (elo <= 1200) return 5;
int placement = getPlacement(elo, gameMode);
if (placement == 1) return 9;
if (placement == 2) return 8;
if (placement == 3) return 7;
return 6;
if (elo < 150) return 0;
if (elo < 350) return 1;
if (elo < 600) return 2;
if (elo < 900) return 3;
return 4;
}
public static String toEmblem(int progression) {
@ -162,25 +136,15 @@ public class UserElo {
case -1:
return "";
case 0:
return "§6 ";
return "§e❱ ";
case 1:
return "§6∧ ";
return "§e❱❱ ";
case 2:
return "§7 ";
return "§e❱❱❱ ";
case 3:
return "§7∧ ";
return "§e❱❱❱❱ ";
case 4:
return "§e ";
case 5:
return "§e∧ ";
case 6:
return "§5❂ ";
case 7:
return "§5III ";
case 8:
return "§5II ";
case 9:
return "§5I ";
default:
throw new SecurityException("Progression out of range");
}

View File

@ -29,4 +29,5 @@ dependencies {
compileOnly(libs.worldedit15)
compileOnly(libs.fastutil)
compileOnly(libs.authlib)
compileOnly(libs.netty)
}

View File

@ -97,6 +97,7 @@ public class FightSystem extends JavaPlugin {
new PrepareSchem();
new TestJoin();
new NormalJoin();
new Spectator();
new RunningWorldInteraction();
new PersonalKitCreator();
new ArrowStopper();
@ -156,6 +157,7 @@ public class FightSystem extends JavaPlugin {
new LockschemCommand();
new StateCommand();
new SkipCommand();
new TechhiderbugCommand();
new TPSWarpCommand();
new UnrankCommand();
new WinCommand();

View File

@ -176,15 +176,15 @@ UI_WIN={0}Victory {1}
UI_DRAW=§7Draw
BAR_PRE_LEADER=§7Waiting for team leader
BAR_PRE_SCHEM={1} §7Schematic selection {0} {2}
BAR_PREPARE={1} {3} §7Preparation {0} {4} {2}
BAR_PRE_RUNNING={1} {3} §7Start of fight in {0} {4} {2}
BAR_RUNNING0={1} {3} {0} {4} {2}
BAR_RUNNING1={1} {3} {5} {0} {6} {4} {2}
BAR_RUNNING2={1} {3} {5} {7} {0} {6} {8} {4} {2}
BAR_RUNNING3={1} {3} {5} {7} {9} {0} {6} {8} {10} {4} {2}
BAR_TIE={1} §7Draw {0} {2}
BAR_WIN={1} §7Victory {3} {0} {2}
BAR_PRE_SCHEM = {1} §7Schematic selection {0} {2}
BAR_PREPARE = {1} {3} §7Preparation {0} {4} {2}
BAR_PRE_RUNNING = {1} {3} §7Start of fight in {0} {4} {2}
BAR_RUNNING0 = {1} {3} {0} {4} {2}
BAR_RUNNING1 = {1} {3} {5} {0} {6} {4} {2}
BAR_RUNNING2 = {1} {3} {5} {7} {0} {6} {8} {4} {2}
BAR_RUNNING3 = {1} {3} {5} {7} {9} {0} {6} {8} {10} {4} {2}
BAR_TIE = {1} §7Draw {0} {2}
BAR_WIN = {1} §7Victory {3} {0} {2}
BAR_POINTS={0} §8Points
BAR_POINTS_OF={0}§8/§7{1} §8Points
BAR_PERCENT={0}§8%

View File

@ -161,11 +161,11 @@ UI_WIN={0}Sieg {1}
UI_DRAW=§7Unentschieden
BAR_PRE_LEADER=§7Warten auf Teamleader
BAR_PRE_SCHEM={1} §7Schemauswahl {0} {2}
BAR_PREPARE={1} {3} §7Vorbereitung {0} {4} {2}
BAR_PRE_RUNNING={1} {3} §7Kampfbeginn in {0} {4} {2}
BAR_TIE={1} §7Unentschieden {0} {2}
BAR_WIN={1} §7Sieg {3} {0} {2}
BAR_PRE_SCHEM = {1} §7Schemauswahl {0} {2}
BAR_PREPARE = {1} {3} §7Vorbereitung {0} {4} {2}
BAR_PRE_RUNNING = {1} {3} §7Kampfbeginn in {0} {4} {2}
BAR_TIE = {1} §7Unentschieden {0} {2}
BAR_WIN = {1} §7Sieg {3} {0} {2}
BAR_POINTS={0} §8Punkte
BAR_POINTS_OF={0}§8/§7{1} §8Punkte
BAR_PERCENT={0}§8%

View File

@ -0,0 +1,71 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.commands;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.sql.SWException;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import java.io.StringWriter;
import java.util.Arrays;
public class TechhiderbugCommand implements CommandExecutor {
public TechhiderbugCommand() {
new StateDependentCommand(ArenaMode.All, FightState.All, "techhiderbug", this);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
StringWriter writer = new StringWriter();
writer.append("ArenaMode: ").append(Config.mode.name()).append('\n');
writer.append("FightState: ").append(FightState.getFightState().name()).append('\n');
writer.append("TechHider enabled: ").append(FightState.getStateDependentFeatures().get(FightSystem.getTechHider()).toString()).append('\n');
writer.append("Arena region: ").append(Config.ArenaRegion.toString()).append('\n');
writer.append("Team regions: ");
Fight.teams().forEach(t -> writer.append(t.getName()).append(':').append(t.getExtendRegion().toString()).append(' '));
writer.append('\n');
writer.append("HullHider regions: ");
FightSystem.getHullHider().getHullMap().forEach((t, h) -> writer.append(t.getName()).append(':').append(h.getRegion().toString()).append(' '));
writer.append('\n');
writer.append("Hidden regions: ");
FightSystem.getTechHider().getHiddenRegion().forEach((p, r) -> writer.append(p.getName()).append(':').append(r.toString()).append(' '));
writer.append('\n');
writer.append('\n').append("Netty pipelines:\n");
Bukkit.getOnlinePlayers().forEach(p -> writer.append(p.getName()).append(": ").append(String.join(" ", TinyProtocol.instance.getPlayerInterceptors().get(p).getChannel().pipeline().names())).append('\n'));
SWException.log("Techhider-Bug reported by " + sender.getName() + ": " + Arrays.toString(args), writer.toString());
return false;
}
}

View File

@ -104,40 +104,6 @@ public class Fight {
return null;
}
@SuppressWarnings("deprecation")
public static void setPlayerGamemode(Player player, GameMode gameMode) {
player.setGameMode(gameMode);
if(gameMode == GameMode.SPECTATOR) {
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
currentPlayer.hidePlayer(player);
player.hidePlayer(currentPlayer);
}
}
if(Config.test() || Config.isReferee(player))
return;
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
if(!player.isOnline())
return;
pseudoSpectator(player, true);
}, 1);
}else if(gameMode == GameMode.SURVIVAL) {
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
currentPlayer.showPlayer(player);
player.showPlayer(currentPlayer);
}
}
}
}
public static void pseudoSpectator(Player player, boolean enable) {
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), enable ? GameMode.CREATIVE : GameMode.SPECTATOR));
}
public static boolean publicOnly() {
if (Config.OnlyPublicSchematics) {
return true;

View File

@ -73,7 +73,6 @@ public class FightTeam {
if(ArenaMode.VariableTeams.contains(Config.mode)){
notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).build(), GUI::chooseJoinRequests);
notReadyKit.setItem(3, "MANAGE_PLAYERS", SWItem.getPlayerSkull("AdmiralSeekrank").getItemStack(), GUI::managePlayers);
if(!AIManager.availableAIs().isEmpty())
notReadyKit.setItem(6, "ADD_AI", new ItemBuilder(Material.REDSTONE).build(), GUI::addAI);
}
@ -81,6 +80,7 @@ public class FightTeam {
if(Config.test())
notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog);
notReadyKit.setItem(3, "MANAGE_PLAYERS", SWItem.getPlayerSkull("AdmiralSeekrank").getItemStack(), GUI::managePlayers);
notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true));
}
private static final HotbarKit chooseSchemKit = new HotbarKit(notReadyKit);
@ -282,9 +282,9 @@ public class FightTeam {
FightSystem.getHullHider().updatePlayer(player);
if(FightState.Spectate.contains(FightState.getFightState())) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.setGameMode(GameMode.SPECTATOR);
} else {
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
player.setGameMode(GameMode.SURVIVAL);
(FightState.ingame() ? fightPlayer.getKit() : memberKit).loadToPlayer(player);
}
});
@ -317,7 +317,7 @@ public class FightTeam {
entity.teleport(Config.SpecSpawn);
fightPlayer.ifPlayer(player -> {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.setGameMode(GameMode.SPECTATOR);
player.getInventory().clear();
if(player.isOnline()){
@ -517,14 +517,14 @@ public class FightTeam {
@Override
public void enable() {
players.values().forEach(fightPlayer -> {
fightPlayer.ifPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SPECTATOR));
fightPlayer.ifPlayer(player -> player.setGameMode(GameMode.SPECTATOR));
fightPlayer.getEntity().teleport(FightTeam.this.spawn);
});
}
@Override
public void disable() {
players.values().forEach(fightPlayer -> fightPlayer.ifPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SURVIVAL)));
players.values().forEach(fightPlayer -> fightPlayer.ifPlayer(player -> player.setGameMode(GameMode.SURVIVAL)));
}
}
}

View File

@ -84,6 +84,6 @@ public class LeaveableArena implements Listener {
private void markInArena(Player player) {
spectatorsInArena.put(player, player.getGameMode());
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.setGameMode(GameMode.SPECTATOR);
}
}

View File

@ -74,7 +74,7 @@ public class Permanent implements Listener {
public void handlePlayerRespawn(PlayerRespawnEvent event){
Player player = event.getPlayer();
if(Fight.fighting(player)) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.setGameMode(GameMode.SPECTATOR);
FightTeam team = Fight.getPlayerTeam(player);
event.setRespawnLocation(team == null ? Config.SpecSpawn : team.getSpawn());
@ -98,11 +98,11 @@ public class Permanent implements Listener {
FightPlayer fp = Fight.getFightPlayer(player);
if (!Config.ArenaLeaveable && fp == null) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.setGameMode(GameMode.SPECTATOR);
spectatorTeam.addEntry(player.getName());
player.teleport(Config.SpecSpawn);
} else if(fp != null && !fp.isLiving()) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.setGameMode(GameMode.SPECTATOR);
player.teleport(fp.getTeam().getSpawn());
}
}

View File

@ -0,0 +1,114 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2025 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.listener;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile;
import de.steamwar.core.ProtocolWrapper;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
public class Spectator implements Listener {
private final Set<Player> pseudoSpectator = new HashSet<>();
public Spectator() {
new StateDependentListener(ArenaMode.AntiTest, FightState.All, this);
new StateDependentTask(ArenaMode.AntiTest, FightState.All, this::pseudoSpectatorCheck, 1, 1);
}
@EventHandler(priority = EventPriority.MONITOR)
public void handlePlayerJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
if(player.getGameMode() == GameMode.SPECTATOR)
gameModeChange(player, GameMode.SPECTATOR);
}
@EventHandler
public void onGameModeChange(PlayerGameModeChangeEvent e) {
gameModeChange(e.getPlayer(), e.getNewGameMode());
}
@SuppressWarnings("deprecation")
private void gameModeChange(Player player, GameMode gameMode) {
if (gameMode == GameMode.SPECTATOR) {
for(Player p : Bukkit.getServer().getOnlinePlayers()) {
if(p.getUniqueId() != player.getUniqueId())
p.hidePlayer(player);
}
} else {
for(Player p : Bukkit.getServer().getOnlinePlayers()) {
if(p.getUniqueId() != player.getUniqueId())
p.showPlayer(player);
}
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent e) {
pseudoSpectator.remove(e.getPlayer());
}
private void pseudoSpectatorCheck() {
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.getGameMode() != GameMode.SPECTATOR) {
pseudoSpectator.remove(player);
continue;
}
if (Config.isReferee(player))
continue;
FightPlayer fightPlayer = Fight.getFightPlayer(player);
if (fightPlayer == null || !fightPlayer.getTeam().getExtendRegion().playerInRegion(player.getLocation())) {
if (pseudoSpectator.add(player))
pseudoSpectator(player, true);
} else {
if (pseudoSpectator.remove(player))
pseudoSpectator(player, false);
}
}
}
private static void pseudoSpectator(Player player, boolean enable) {
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), enable ? GameMode.CREATIVE : GameMode.SPECTATOR));
}
}

View File

@ -19,9 +19,14 @@
package de.steamwar.fightsystem.listener;
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 de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.events.BoardingEvent;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.events.TeamLeaveEvent;
@ -32,23 +37,12 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import org.bukkit.Bukkit;
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 java.util.HashSet;
import java.util.Set;
public class TeamArea implements Listener {
private final FightTeam team;
private final Border spectatorBorder;
private final Border bordingBorder;
private final Set<Player> realSpectator = new HashSet<>();
public TeamArea(FightTeam team) {
this.team = team;
@ -56,7 +50,6 @@ public class TeamArea implements Listener {
this.bordingBorder = new Border(team.getExtendRegion().to2d(), true, 1, "NO_ENTERN", team.getName() + ".boardingBorder");
new StateDependentListener(ArenaMode.AntiTest, FightState.All, this);
new StateDependentTask(ArenaMode.AntiTest, FightState.TeamFix, this::realSpectatorCheck, 1, 1);
new OneShotStateDependent(ArenaMode.AntiTest, FightState.Spectate, () -> Fight.teams().forEach(t -> t.getPlayers().forEach(this::teamSpectator)));
}
@ -114,30 +107,5 @@ public class TeamArea implements Listener {
Player player = e.getPlayer();
spectatorBorder.removePlayer(player);
bordingBorder.removePlayer(player);
realSpectator.remove(player);
}
private void realSpectatorCheck() {
for(FightPlayer fightPlayer : team.getPlayers()) {
if(fightPlayer.isLiving())
continue;
fightPlayer.ifPlayer(player -> {
boolean inRegion = team.getExtendRegion().playerInRegion(player.getLocation());
if(inRegion && !realSpectator.contains(player)) {
realSpectator.add(player);
//Later to prevent race condition with Fight.setSpecatator() during respawn
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
if(!player.isOnline())
return;
Fight.pseudoSpectator(player, false);
}, 2);
}else if(!inRegion && realSpectator.contains(player)) {
Fight.pseudoSpectator(player, true);
realSpectator.remove(player);
}
});
}
}
}

View File

@ -49,6 +49,7 @@ public enum FightState {
public static final Set<FightState> AntiIngame = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PRE_RUNNING, RUNNING)));
public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
@Getter
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
@Getter
private static FightState fightState = PRE_LEADER_SETUP;

View File

@ -45,6 +45,7 @@ public class Hull {
return material.isOccluding() || Config.HiddenBlocks.contains(material);
}
@Getter
private final Region region;
private final boolean groundVisible;
private final IntVector[] directions;

View File

@ -33,6 +33,7 @@ import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.techhider.TechHider;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -56,6 +57,7 @@ import java.util.function.Function;
public class HullHider implements Listener {
@Getter
private final Map<FightTeam, Hull> hullMap = new HashMap<>();
private final Hull[] hulls;
private final Map<Class<?>, BiFunction<Player, Object, Object>> packetHiders = new HashMap<>();

View File

@ -159,4 +159,9 @@ public class Region {
public interface TriConsumer<T, V, U>{
void accept(T x, V y, U z);
}
@Override
public String toString() {
return minX + "," + minY + "," + minZ + "->" + maxX + "," + maxY + "," + maxZ;
}
}

View File

@ -32,6 +32,8 @@ import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.techhider.TechHider;
import lombok.Getter;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -50,6 +52,7 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
@Getter
private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>();
private final ConcurrentHashMap<Player, Long> patterns = new ConcurrentHashMap<>();
private final TechHider techHider;
@ -114,6 +117,11 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
});
}
@Override
public boolean suppressInteractions(Player player) {
return player.getGameMode() == GameMode.SPECTATOR;
}
@Override
public boolean skipChunk(Player player, int chunkX, int chunkZ) {
return getHiddenRegion(player).chunkOutside(chunkX, chunkZ);

View File

@ -27,4 +27,5 @@ commands:
resettb:
tpslimit:
tpswarp:
techhiderbug:
unrank:

View File

@ -0,0 +1,29 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
plugins {
steamwar.java
}
dependencies {
compileOnly(project(":SpigotCore", "default"))
compileOnly(libs.nms12)
compileOnly(libs.worldedit12)
}

View File

@ -0,0 +1,197 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem;
import de.steamwar.bausystem.commands.*;
import de.steamwar.bausystem.world.*;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.core.Core;
import de.steamwar.providers.BauServerInfo;
import de.steamwar.scoreboard.SWScoreboard;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import java.util.UUID;
import java.util.logging.Level;
public class BauSystem extends JavaPlugin implements Listener {
private static BauSystem plugin;
private static Integer owner;
public static final String PREFIX = "§eBauSystem§8» §7";
private BukkitTask autoShutdown;
@Override
public void onEnable() {
plugin = this;
Mapper.init();
new CommandTrace();
new CommandTPSLimiter();
new CommandNV();
new CommandReset();
new CommandSpeed();
new CommandTNT();
new CommandGamemode();
new CommandClear();
new CommandTime();
new CommandTeleport();
new CommandFire();
new CommandFreeze();
new CommandTestblock();
new CommandInfo();
new CommandProtect();
new CommandSkull();
new CommandLoader();
new CommandLockschem();
new CommandDebugStick();
new CommandGills();
new CommandDetonator();
new CommandScript();
new CommandScriptVars();
new CommandRedstoneTester();
new CommandGUI();
new CommandWorldSpawn();
new CommandRegion();
new CommandSelect();
new CommandKillAll();
if (Core.getVersion() > 14 && Region.buildAreaEnabled()) {
new CommandColor();
}
Bukkit.getPluginManager().registerEvents(this, this);
Bukkit.getPluginManager().registerEvents(new RegionListener(), this);
Bukkit.getPluginManager().registerEvents(new ScriptListener(), this);
Bukkit.getPluginManager().registerEvents(new BauScoreboard(), this);
Bukkit.getPluginManager().registerEvents(new ClipboardListener(), this);
Bukkit.getPluginManager().registerEvents(new CommandGUI(), this);
Bukkit.getPluginManager().registerEvents(new DetonatorListener(), this);
Bukkit.getPluginManager().registerEvents(new ItemFrameListener(), this);
new AFKStopper();
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 1200);
TPSUtils.init();
}
@Override
public void onDisable() {
Region.save();
}
public static BauSystem getPlugin() {
return plugin;
}
public static UUID getOwner() {
return SteamwarUser.get(getOwnerID()).getUUID();
}
public static int getOwnerID() {
//Lazy loading to improve startup time of the server in 1.15
if (owner == null) {
owner = BauServerInfo.getOwnerId();
}
return owner;
}
@EventHandler
public void onDeath(PlayerDeathEvent e) {
e.setDeathMessage(null);
}
@EventHandler
public void onJoin(PlayerLoginEvent e) {
if (autoShutdown != null) {
autoShutdown.cancel();
autoShutdown = null;
}
Player p = e.getPlayer();
p.setOp(true);
}
@EventHandler
public void onLeave(PlayerQuitEvent e) {
Player p = e.getPlayer();
SWScoreboard.impl.removeScoreboard(p);
if (Bukkit.getOnlinePlayers().isEmpty() || (Bukkit.getOnlinePlayers().size() == 1 && Bukkit.getOnlinePlayers().contains(p))) {
if (autoShutdown != null) {
autoShutdown.cancel();
}
CommandTPSLimiter.setTPS(20.0);
autoShutdown = Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
int count = 0;
@Override
public void run() {
if (count >= 300) {
Bukkit.shutdown();
return;
}
count++;
try {
if (RamUsage.getUsage() > 0.8) {
Bukkit.shutdown();
}
} catch (Throwable throwable) {
Bukkit.getLogger().log(Level.WARNING, throwable.getMessage(), throwable);
Bukkit.shutdown();
}
}
}, 20, 20);
}
}
@EventHandler
public void onInventoryClick(InventoryClickEvent e) {
ItemStack stack = e.getCursor();
if (stack == null || !stack.hasItemMeta())
return;
assert stack.getItemMeta() != null;
if (stack.getItemMeta().hasEnchants()) {
for (Enchantment en : Enchantment.values()) {
if (stack.getEnchantmentLevel(en) > en.getMaxLevel())
stack.removeEnchantment(en);
}
}
Material material = stack.getType();
if (material == Material.POTION || material == Material.SPLASH_POTION || material == Material.LINGERING_POTION) {
stack.setType(Material.MILK_BUCKET);
}
e.setCurrentItem(stack);
}
}

View File

@ -0,0 +1,43 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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;
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
import de.steamwar.core.VersionDependent;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
public class CraftbukkitWrapper {
private CraftbukkitWrapper() {}
public static final ICraftbukkitWrapper impl = VersionDependent.getVersionImpl(BauSystem.getPlugin());
public interface ICraftbukkitWrapper {
void initTPS();
void createTickCache(World world);
void sendTickPackets();
void openSignEditor(Player player, Location location);
AbstractTraceEntity create(World world, Vector tntPosition, boolean tnt);
}
}

View File

@ -0,0 +1,80 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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;
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.world.TPSUtils;
import net.minecraft.server.v1_12_R1.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
public class CraftbukkitWrapper12 implements CraftbukkitWrapper.ICraftbukkitWrapper {
private final List<Packet<?>> packets = new ArrayList<>();
@Override
public void initTPS() {
TPSUtils.disableWarp();
}
@Override
public void createTickCache(World world) {
packets.clear();
world.getEntities().stream().filter(entity -> !(entity instanceof Player)).forEach(entity -> {
packets.add(new PacketPlayOutEntityVelocity(entity.getEntityId(), 0, 0, 0));
packets.add(new PacketPlayOutEntityTeleport(((CraftEntity) entity).getHandle()));
if (entity instanceof TNTPrimed) {
net.minecraft.server.v1_12_R1.Entity serverEntity = ((CraftEntity) entity).getHandle();
packets.add(new PacketPlayOutEntityMetadata(serverEntity.getId(), serverEntity.getDataWatcher(), true));
}
});
}
@Override
public void sendTickPackets() {
Bukkit.getOnlinePlayers().forEach(player -> {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
for (Packet<?> p : packets) {
connection.sendPacket(p);
}
});
}
@Override
public void openSignEditor(Player player, Location location) {
PacketPlayOutOpenSignEditor packet = new PacketPlayOutOpenSignEditor(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
}
@Override
public AbstractTraceEntity create(World world, Vector tntPosition, boolean tnt) {
return new TraceEntity12(world, tntPosition, tnt);
}
}

View File

@ -0,0 +1,53 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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;
import de.steamwar.bausystem.world.Detoloader;
import de.steamwar.core.VersionDependent;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
public class FlatteningWrapper {
private FlatteningWrapper(){}
public static final IFlatteningWrapper impl = VersionDependent.getVersionImpl(BauSystem.getPlugin());
public interface IFlatteningWrapper {
boolean tntPlaceActionPerform(Location location);
boolean setRedstone(Location location, boolean active);
Detoloader onPlayerInteractLoader(PlayerInteractEvent event);
boolean getLever(Block block);
boolean isNoBook(ItemStack item);
boolean inWater(World world, Vector tntPosition);
Material getTraceShowMaterial();
Material getTraceHideMaterial();
Material getTraceXZMaterial();
void giveStick(Player player);
}
}

View File

@ -0,0 +1,148 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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;
import de.steamwar.bausystem.world.Detoloader;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
import java.util.List;
import java.util.stream.Collectors;
public class FlatteningWrapper12 implements FlatteningWrapper.IFlatteningWrapper {
@Override
public boolean tntPlaceActionPerform(Location location) {
Material m = location.getBlock().getType();
if (m != Material.AIR && m != Material.STATIONARY_WATER && m != Material.WATER)
return false;
location.getBlock().setType(Material.TNT);
return true;
}
@Override
@SuppressWarnings("deprecation")
public boolean setRedstone(Location location, boolean active) {
Block block = location.getBlock();
Material material = block.getType();
if (material == Material.LEVER || material == Material.STONE_BUTTON || material == Material.WOOD_BUTTON) {
if (active)
block.setData((byte) (block.getData() | 8));
else
block.setData((byte) (block.getData() & -9));
} else if (material == Material.STONE_PLATE || material == Material.WOOD_PLATE) {
if (active)
block.setData((byte) 1);
else
block.setData((byte) 0);
} else if (material == Material.TRIPWIRE) {
if (active) {
ArmorStand armorStand = (ArmorStand) Bukkit.getWorlds().get(0).spawnEntity(location, EntityType.ARMOR_STAND);
armorStand.setVisible(false);
armorStand.setBasePlate(false);
armorStand.addScoreboardTag("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ());
} else {
List<Entity> entityList = Bukkit.getWorlds().get(0).getEntitiesByClasses(ArmorStand.class).stream().filter(entity ->
entity.getScoreboardTags().contains("detonator-" + location.getBlockX() + location.getBlockY() + location.getBlockZ()))
.limit(1)
.collect(Collectors.toList());
if (entityList.isEmpty()) return false;
entityList.get(0).remove();
}
} else {
return false;
}
block.getState().update(true);
return true;
}
@Override
@SuppressWarnings("deprecation")
public Detoloader onPlayerInteractLoader(PlayerInteractEvent event) {
Block block = event.getClickedBlock();
Material material = block.getType();
if (material == Material.LEVER) {
if ((block.getData() & 8) == 8) {
return new Detoloader("Hebel", 0).setActive(false);
} else {
return new Detoloader("Hebel", 0).setActive(true);
}
} else if (material == Material.STONE_BUTTON) {
return new Detoloader("Knopf", Detoloader.STONE_BUTTON);
} else if (material == Material.WOOD_BUTTON) {
return new Detoloader("Knopf", Detoloader.WOODEN_BUTTON);
} else if (material == Material.NOTE_BLOCK) {
return new Detoloader("Noteblock", Detoloader.NOTE_BLOCK);
} else if (material == Material.STONE_PLATE || material == Material.WOOD_PLATE) {
return new Detoloader("Druckplatte", Detoloader.PRESSURE_PLATE);
} else if (material == Material.TRIPWIRE) {
return new Detoloader("Tripwire", Detoloader.TRIPWIRE);
}
return new Detoloader("§eUnbekannter Block betätigt (nicht aufgenommen)", -1).setAddBack(false);
}
@Override
@SuppressWarnings("deprecation")
public boolean getLever(Block block) {
return (block.getData() & 8) == 8;
}
@Override
public boolean isNoBook(ItemStack item) {
return item.getType() != Material.BOOK_AND_QUILL && item.getType() != Material.WRITTEN_BOOK;
}
@Override
public boolean inWater(World world, Vector tntPosition) {
Material material = world.getBlockAt(tntPosition.getBlockX(), tntPosition.getBlockY(), tntPosition.getBlockZ()).getType();
return material == Material.WATER || material == Material.STATIONARY_WATER;
}
@Override
public Material getTraceShowMaterial() {
return Material.CONCRETE;
}
@Override
public Material getTraceHideMaterial() {
return Material.CONCRETE;
}
@Override
public Material getTraceXZMaterial() {
return Material.STEP;
}
@Override
public void giveStick(Player player) {
player.sendMessage(BauSystem.PREFIX + "§cDen Debugstick gibt es nicht in der 1.12.");
}
}

View File

@ -0,0 +1,87 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem;
import de.steamwar.bausystem.tracer.show.ShowModeParameterType;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class Mapper {
private Mapper() {
throw new IllegalStateException("Utility Class");
}
public static void init() {
SWCommandUtils.addMapper(ShowModeParameterType.class, showModeParameterTypesTypeMapper());
SWCommandUtils.addMapper(BauweltMember.class, bauweltMemberTypeMapper());
}
private static TypeMapper<ShowModeParameterType> showModeParameterTypesTypeMapper() {
Map<String, ShowModeParameterType> showModeParameterTypesMap = new HashMap<>();
showModeParameterTypesMap.put("-water", ShowModeParameterType.WATER);
showModeParameterTypesMap.put("-interpolatey", ShowModeParameterType.INTERPOLATE_Y);
showModeParameterTypesMap.put("-interpolate-y", ShowModeParameterType.INTERPOLATE_Y);
showModeParameterTypesMap.put("-interpolate_y", ShowModeParameterType.INTERPOLATE_Y);
showModeParameterTypesMap.put("-y", ShowModeParameterType.INTERPOLATE_Y);
showModeParameterTypesMap.put("-interpolatex", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate-x", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate_x", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-x", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolatez", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate-z", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate_z", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-z", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolatexz", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate-xz", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-interpolate_xz", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-xz", ShowModeParameterType.INTERPOLATE_XZ);
showModeParameterTypesMap.put("-advanced", ShowModeParameterType.ADVANCED);
showModeParameterTypesMap.put("-a", ShowModeParameterType.ADVANCED);
showModeParameterTypesMap.put("advanced", ShowModeParameterType.ADVANCED);
showModeParameterTypesMap.put("a", ShowModeParameterType.ADVANCED);
List<String> tabCompletes = new ArrayList<>(showModeParameterTypesMap.keySet());
return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes);
}
private static TypeMapper<BauweltMember> bauweltMemberTypeMapper() {
return SWCommandUtils.createMapper(s -> BauweltMember.getMembers(BauSystem.getOwnerID())
.stream()
.filter(m -> SteamwarUser.get(m.getMemberID()).getUserName().equals(s)).findFirst().orElse(null),
s -> BauweltMember.getMembers(BauSystem.getOwnerID())
.stream()
.map(m -> SteamwarUser.get(m.getMemberID()).getUserName())
.collect(Collectors.toList()));
}
}

View File

@ -0,0 +1,26 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem;
public enum Permission {
WORLD,
WORLDEDIT,
MEMBER
}

View File

@ -0,0 +1,44 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem;
import org.bukkit.Bukkit;
import java.lang.management.ManagementFactory;
import java.util.logging.Level;
public class RamUsage {
private RamUsage() {
throw new IllegalStateException("Utility Class");
}
public static double getUsage() {
try {
long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
long freeMemory = ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getFreePhysicalMemorySize();
return (memorySize - freeMemory) / (double) memorySize;
} catch (Throwable throwable) {
Bukkit.getLogger().log(Level.WARNING, throwable.getMessage(), throwable);
return 1D;
}
}
}

View File

@ -0,0 +1,64 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
public class SWUtils {
public static void giveItemToPlayer(Player player, ItemStack itemStack) {
if (itemStack == null || itemStack.getType() == Material.AIR) {
return;
}
for (int i = 0; i < player.getInventory().getSize(); i++) {
ItemStack current = player.getInventory().getItem(i);
if (current != null && current.isSimilar(itemStack)) {
player.getInventory().setItem(i, null);
itemStack = current;
break;
}
}
ItemStack current = player.getInventory().getItemInMainHand();
player.getInventory().setItemInMainHand(itemStack);
if (current.getType() != Material.AIR) {
player.getInventory().addItem(current);
}
}
public static List<String> manageList(List<String> strings, String[] args, int index) {
strings = new ArrayList<>(strings);
for (int i = strings.size() - 1; i >= 0; i--) {
if (!strings.get(i).startsWith(args[index])) {
strings.remove(i);
}
}
return strings;
}
public static List<String> manageList(List<String> strings, String[] args) {
return manageList(strings, args, args.length - 1);
}
}

View File

@ -0,0 +1,77 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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;
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
import net.minecraft.server.v1_12_R1.*;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_12_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.util.Vector;
class TraceEntity12 extends EntityFallingBlock implements AbstractTraceEntity {
private boolean exploded;
private int references;
public TraceEntity12(World world, Vector position, boolean tnt) {
super(((CraftWorld) world).getHandle(), position.getX(), position.getY(), position.getZ(), tnt ? Blocks.TNT.getBlockData() : Blocks.STAINED_GLASS.getBlockData());
this.setNoGravity(true);
this.ticksLived = -12000;
}
@Override
public void display(Player player, boolean exploded) {
if (!this.exploded && exploded) {
this.setCustomNameVisible(true);
this.setCustomName("Bumm");
this.exploded = true;
if (references++ > 0)
sendDestroy(player);
} else if (references++ > 0)
return;
PacketPlayOutSpawnEntity packetPlayOutSpawnEntity = new PacketPlayOutSpawnEntity(this, 70, Block.getCombinedId(getBlock()));
PlayerConnection playerConnection = ((CraftPlayer) player).getHandle().playerConnection;
playerConnection.sendPacket(packetPlayOutSpawnEntity);
PacketPlayOutEntityMetadata packetPlayOutEntityMetadata = new PacketPlayOutEntityMetadata(getId(), datawatcher, true);
playerConnection.sendPacket(packetPlayOutEntityMetadata);
}
@Override
public boolean hide(Player player, boolean force) {
if (!force && --references > 0)
return false;
sendDestroy(player);
die();
return true;
}
private void sendDestroy(Player player) {
PacketPlayOutEntityDestroy packetPlayOutEntityDestroy = new PacketPlayOutEntityDestroy(getId());
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packetPlayOutEntityDestroy);
}
}

View File

@ -0,0 +1,44 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.bausystem.world.regions.PasteOptions;
import de.steamwar.bausystem.world.regions.Point;
import de.steamwar.core.VersionDependent;
import org.bukkit.entity.Player;
import java.io.File;
public class WorldeditWrapper {
private WorldeditWrapper() {}
public static final IWorldeditWrapper impl = VersionDependent.getVersionImpl(BauSystem.getPlugin());
public interface IWorldeditWrapper {
void setSelection(Player p, Point minPoint, Point maxPoint);
EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions);
EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions);
boolean isWorldEditCommand(String command);
}
}

View File

@ -0,0 +1,114 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 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;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.blocks.BlockID;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.selector.CuboidRegionSelector;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.World;
import de.steamwar.bausystem.world.regions.PasteOptions;
import de.steamwar.bausystem.world.regions.Point;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Objects;
public class WorldeditWrapper12 implements WorldeditWrapper.IWorldeditWrapper {
private final WorldEditPlugin WORLDEDIT_PLUGIN = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
private final World BUKKITWORLD = new BukkitWorld(Bukkit.getWorlds().get(0));
@Override
public void setSelection(Player p, Point minPoint, Point maxPoint) {
WORLDEDIT_PLUGIN.getSession(p).setRegionSelector(BUKKITWORLD, new CuboidRegionSelector(BUKKITWORLD, toVector(minPoint), toVector(maxPoint)));
}
@Override
public EditSession paste(File file, int x, int y, int z, PasteOptions pasteOptions) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Clipboard clipboard;
try {
clipboard = Objects.requireNonNull(ClipboardFormat.findByFile(file)).getReader(new FileInputStream(file)).read(w.getWorldData());
} catch (NullPointerException | IOException e) {
throw new SecurityException("Bausystem schematic not found", e);
}
return paste(clipboard, x, y, z, pasteOptions);
}
@Override
public EditSession paste(Clipboard clipboard, int x, int y, int z, PasteOptions pasteOptions) {
World w = new BukkitWorld(Bukkit.getWorlds().get(0));
Vector dimensions = clipboard.getDimensions();
Vector v = new Vector(x, y, z);
Vector offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin());
AffineTransform aT = new AffineTransform();
if (pasteOptions.isRotate()) {
aT = aT.rotateY(180);
v = v.add(dimensions.getX() / 2 + dimensions.getX() % 2, 0, dimensions.getZ() / 2 + dimensions.getZ() % 2).subtract(offset.multiply(-1, 1, -1)).subtract(1, 0, 1);
} else {
v = v.subtract(dimensions.getX() / 2 - dimensions.getX() % 2, 0, dimensions.getZ() / 2 - dimensions.getZ() % 2).subtract(offset);
}
EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(w, -1);
ClipboardHolder ch = new ClipboardHolder(clipboard, w.getWorldData());
ch.setTransform(aT);
if (pasteOptions.isReset()) {
try {
e.setBlocks(new CuboidRegion(toVector(pasteOptions.getMinPoint()), toVector(pasteOptions.getMaxPoint())), new BaseBlock(BlockID.AIR));
} catch (MaxChangedBlocksException ex) {
throw new SecurityException("Max blocks changed?", ex);
}
}
Operations.completeBlindly(ch.createPaste(e, w.getWorldData()).to(v).ignoreAirBlocks(pasteOptions.isIgnoreAir()).build());
return e;
}
@Override
public boolean isWorldEditCommand(String command) {
if (command.startsWith("/")) {
command = command.replaceFirst("/", "");
}
command = command.toLowerCase();
return ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit")).getWorldEdit().getPlatformManager()
.getCommandManager().getDispatcher().get(command) != null;
}
private Vector toVector(Point point) {
return Vector.toBlockPoint(point.getX(), point.getY(), point.getZ());
}
}

View File

@ -0,0 +1,71 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class CommandClear extends SWCommand {
public CommandClear() {
super("clear");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§eclear §8- §7Leere dein Inventar");
p.sendMessage("§8/§ebau clear §8[§7Player§8] §8- §7Leere ein Spieler Inventar");
}
@Register
public void genericClearCommand(Player p) {
clear(p);
p.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde geleert.");
}
@Register
public void clearPlayerCommand(Player p, Player target) {
if (!permissionCheck(p)) return;
clear(target);
target.sendMessage(BauSystem.PREFIX + "Dein Inventar wurde von " + p.getDisplayName() + " §7geleert.");
p.sendMessage(BauSystem.PREFIX + "Das Inventar von " + target.getDisplayName() + " §7wurde geleert.");
}
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.WORLD)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier keine fremden Inventare leeren.");
return false;
}
return true;
}
private void clear(Player player) {
player.getInventory().clear();
player.getInventory().setHelmet(new ItemStack(Material.AIR));
player.getInventory().setChestplate(new ItemStack(Material.AIR));
player.getInventory().setLeggings(new ItemStack(Material.AIR));
player.getInventory().setBoots(new ItemStack(Material.AIR));
}
}

View File

@ -0,0 +1,73 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.world.Color;
import de.steamwar.bausystem.world.regions.GlobalRegion;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
public class CommandColor extends SWCommand {
private static CommandColor instance = null;
public CommandColor() {
super("color");
instance = this;
}
public static CommandColor getInstance() {
return instance;
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region");
p.sendMessage("§8/§ecolor §8[§7Color§8] §8[§7Type§8] §8- §7Setze die Farbe der Region oder Global");
}
@Register
public void genericColor(Player p, Color color) {
genericColorSet(p, color, ColorizationType.LOCAL);
}
@Register
public void genericColorSet(Player p, Color color, ColorizationType colorizationType) {
if (!permissionCheck(p)) {
return;
}
if (colorizationType == ColorizationType.GLOBAL) {
Region.setGlobalColor(color);
p.sendMessage(BauSystem.PREFIX + "Alle Regions farben auf §e" + color.name().toLowerCase() + "§7 gesetzt");
return;
}
Region region = Region.getRegion(p.getLocation());
if (GlobalRegion.isGlobalRegion(region)) {
p.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
return;
}
region.setColor(color);
p.sendMessage(BauSystem.PREFIX + "Regions farben auf §e" + color.name().toLowerCase() + "§7 gesetzt");
}
@Register
public void genericColorSet(Player p, ColorizationType colorizationType, Color color) {
genericColorSet(p, color, colorizationType);
}
private boolean permissionCheck(Player p) {
if (!BauSystem.getOwner().equals(p.getUniqueId())) {
p.sendMessage(BauSystem.PREFIX + "§cDies ist nicht deine Welt!");
return false;
} else {
return true;
}
}
public enum ColorizationType {
LOCAL,
GLOBAL
}
}

View File

@ -0,0 +1,41 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.FlatteningWrapper;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
public class CommandDebugStick extends SWCommand {
public CommandDebugStick() {
super("debugstick");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§edebugstick §8- §7Erhalte einen DebugStick");
}
@Register
public void genericCommand(Player p) {
FlatteningWrapper.impl.giveStick(p);
}
}

View File

@ -0,0 +1,114 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.world.Detonator;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
public class CommandDetonator extends SWCommand {
public CommandDetonator() {
super ("detonator", "dt");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§edetonator wand §8- §7Legt den Fernzünder ins Inventar");
p.sendMessage("§8/§edetonator detonate §8- §7Benutzt den nächst besten Fernzünder");
p.sendMessage("§8/§edetonator reset §8- §7Löscht alle markierten Positionen");
p.sendMessage("§8/§edetonator remove §8- §7Entfernt den Fernzünder");
}
@Register("wand")
public void wandCommand(Player p) {
if (!permissionCheck(p)) return;
SWUtils.giveItemToPlayer(p, Detonator.WAND);
}
@Register("detonator")
public void detonatorCommand(Player p) {
if (!permissionCheck(p)) return;
SWUtils.giveItemToPlayer(p, Detonator.WAND);
}
@Register("item")
public void itemCommand(Player p) {
if (!permissionCheck(p)) return;
SWUtils.giveItemToPlayer(p, Detonator.WAND);
}
@Register("remove")
public void removeCommand(Player p) {
if (!permissionCheck(p)) return;
p.getInventory().removeItem(Detonator.WAND);
}
@Register("detonate")
public void detonateCommand(Player p) {
if (!permissionCheck(p)) return;
Detonator.execute(p);
}
@Register("click")
public void clickCommand(Player p) {
if (!permissionCheck(p)) return;
Detonator.execute(p);
}
@Register("use")
public void useCommand(Player p) {
if (!permissionCheck(p)) return;
Detonator.execute(p);
}
@Register("clear")
public void clearCommand(Player p) {
if (!permissionCheck(p)) return;
Detonator.clear(p);
}
@Register("delete")
public void deleteCommand(Player p) {
if (!permissionCheck(p)) return;
Detonator.clear(p);
}
@Register("reset")
public void resetCommand(Player p) {
if (!permissionCheck(p)) return;
Detonator.clear(p);
}
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.WORLD)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Detonator nutzen");
return false;
}
return true;
}
}

View File

@ -0,0 +1,92 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockSpreadEvent;
public class CommandFire extends SWCommand implements Listener {
public CommandFire() {
super("fire");
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§efire §8- §7Toggle Feuerschaden");
}
@Register
public void toggleCommand(Player p) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation());
if (toggle(region)) {
RegionUtils.actionBar(region, getEnableMessage());
} else {
RegionUtils.actionBar(region, getDisableMessage());
}
}
private String getNoPermMessage() {
return "§cDu darfst hier nicht Feuerschaden (de-)aktivieren";
}
private String getEnableMessage() {
return "§cRegions Feuerschaden deaktiviert";
}
private String getDisableMessage() {
return "§aRegions Feuerschaden aktiviert";
}
private boolean toggle(Region region) {
region.setFire(!region.isFire());
return region.isFire();
}
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.WORLD)) {
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
return false;
}
return true;
}
@EventHandler
public void onFireDamage(BlockBurnEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
}
@EventHandler
public void onFireSpread(BlockSpreadEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).isFire()) e.setCancelled(true);
}
}

View File

@ -0,0 +1,148 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import de.steamwar.core.Core;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.*;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
public class CommandFreeze extends SWCommand implements Listener {
public CommandFreeze() {
super("freeze", "stoplag");
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§efreeze §8- §7Toggle Freeze");
}
@Register
public void toggleCommand(Player p) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation());
if (toggle(region)) {
RegionUtils.actionBar(region, getEnableMessage());
} else {
RegionUtils.actionBar(region, getDisableMessage());
}
}
private String getNoPermMessage() {
return "§cDu darfst diese Welt nicht einfrieren";
}
private String getEnableMessage(){
return "§cRegion eingefroren";
}
private String getDisableMessage(){
return "§aRegion aufgetaut";
}
private boolean toggle(Region region) {
region.setFreeze(!region.isFreeze());
return region.isFreeze();
}
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.WORLD)) {
player.sendMessage(BauSystem.PREFIX + getNoPermMessage());
return false;
}
return true;
}
@EventHandler
public void onEntitySpawn(EntitySpawnEvent e) {
if (!Region.getRegion(e.getLocation()).isFreeze()) return;
e.setCancelled(true);
if (e.getEntityType() == EntityType.PRIMED_TNT) {
Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), () -> {
e.getLocation().getBlock().setType(Material.TNT, false);
}, 1L);
}
}
@EventHandler
public void onBlockCanBuild(BlockCanBuildEvent e) {
if (Core.getVersion() == 12) return;
if (!e.isBuildable()) return;
if (!Region.getRegion(e.getBlock().getLocation()).isFreeze()) return;
if (e.getMaterial() == Material.TNT) {
e.setBuildable(false);
e.getBlock().setType(Material.TNT, false);
}
}
@EventHandler
public void onEntityChangeBlock(EntityChangeBlockEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
}
@EventHandler
public void onPhysicsEvent(BlockPhysicsEvent e){
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
}
@EventHandler
public void onPistonExtend(BlockPistonExtendEvent e){
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
}
@EventHandler
public void onPistonRetract(BlockPistonRetractEvent e){
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
}
@EventHandler
public void onBlockGrow(BlockGrowEvent e){
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
}
@EventHandler
public void onRedstoneEvent(BlockRedstoneEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setNewCurrent(e.getOldCurrent());
}
@EventHandler
public void onBlockDispense(BlockDispenseEvent e) {
if (Region.getRegion(e.getBlock().getLocation()).isFreeze()) e.setCancelled(true);
}
@EventHandler
public void onInventoryMoveEvent(InventoryMoveItemEvent e){
if (Region.getRegion(e.getDestination().getLocation()).isFreeze()) e.setCancelled(true);
}
}

View File

@ -0,0 +1,530 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.tracer.show.TraceShowManager;
import de.steamwar.bausystem.world.*;
import de.steamwar.bausystem.world.regions.GlobalRegion;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.command.SWCommand;
import de.steamwar.core.Core;
import de.steamwar.inventory.SWAnvilInv;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffectType;
import java.util.*;
public class CommandGUI extends SWCommand implements Listener {
private static final Set<Player> OPEN_INVS = new HashSet<>();
private static final Set<Player> OPEN_TRACER_INVS = new HashSet<>();
private static final Set<Player> LAST_F_PLAYER = new HashSet<>();
private static boolean isRefreshing = false;
public CommandGUI() {
super("gui");
Bukkit.getScheduler().runTaskTimerAsynchronously(BauSystem.getPlugin(), LAST_F_PLAYER::clear, 0, 20);
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§egui §8- §7Öffne die GUI");
p.sendMessage("§8/§egui item §8- §7Gebe das GUI item");
}
@Register
public void genericCommand(Player p) {
openBauGui(p);
OPEN_INVS.add(p);
}
@Register({"item"})
public void itemCommand(Player p) {
SWUtils.giveItemToPlayer(p, new ItemStack(Material.NETHER_STAR));
}
public static void openBauGui(Player player) {
Region region = Region.getRegion(player.getLocation());
SWInventory inv = new SWInventory(player, 5 * 9, SteamwarUser.get(BauSystem.getOwner()).getUserName() + "s Bau");
inv.setCallback(-1, clickType -> {
if (!isRefreshing)
OPEN_INVS.remove(player);
});
inv.setItem(43, getMaterial("GLASS_PANE", "THIN_GLASS"), "§7Platzhalter", clickType -> {
});
inv.setItem(42, Material.NETHER_STAR, "§7Bau GUI Item", Arrays.asList("§7Du kannst dieses Item zum Öffnen der BauGUI nutzen", "§7oder Doppel F (Swap hands) drücken."), false, clickType -> {
player.closeInventory();
player.performCommand("gui item");
});
ItemStack dtWand = wand(player, Detonator.WAND, "§8/§7dt wand", Permission.WORLD, "§cDu hast keine Worldrechte");
inv.setItem(39, dtWand, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.closeInventory();
player.performCommand("dt wand");
});
ItemStack redstoneWand = wand(player, CommandRedstoneTester.WAND, "§8/§7redstonetester", null, "");
inv.setItem(37, redstoneWand, clickType -> {
player.closeInventory();
player.performCommand("redstonetester");
});
inv.setItem(40, getMaterial("WOODEN_AXE", "WOOD_AXE"), "§eWorldedit Axt", getNoPermsLore(Arrays.asList("§8//§7wand"), player, "§cDu hast keine Worldeditrechte", Permission.WORLDEDIT), false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.closeInventory();
player.performCommand("/wand");
});
inv.setItem(41, getMaterial("DEBUG_STICK", "STICK"), "§eDebugstick", getNoPermsLore(Arrays.asList("§8/§7debugstick"), player, "§cDu hast keine Worldrechte", Permission.WORLD), Core.getVersion() < 13, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.closeInventory();
player.performCommand("debugstick");
});
inv.setItem(20, Material.COMPASS, "§7TPS Limitieren", getNoPermsLore(Arrays.asList("§7Aktuell: §e" + CommandTPSLimiter.getCurrentTPSLimit(), "§8/§7tpslimit §8[§e0,5 - " + (TPSUtils.isWarpAllowed() ? 40 : 20) + "§8]"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
SWAnvilInv anvilInv = new SWAnvilInv(player, "TPS Limitieren");
anvilInv.setItem(Material.COMPASS);
anvilInv.setCallback(s -> player.performCommand("tpslimit " + s));
anvilInv.open();
});
inv.setItem(5, Material.FEATHER, "§7Geschwindigkeit", Arrays.asList("§7Aktuell: §e" + player.getFlySpeed() * 10, "§8/§7speed §8[§e1 - 10§8]"), false, clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Geschwindigkeit");
anvilInv.setItem(Material.FEATHER);
anvilInv.setCallback(s -> player.performCommand("speed " + s));
anvilInv.open();
});
if (player.getUniqueId().equals(BauSystem.getOwner())) {
SWItem skull = SWItem.getPlayerSkull(player.getName());
skull.setName("§7Bau verwalten");
List<String> skullLore = new ArrayList<>();
skullLore.add("§7TNT: §e" + region.getTntMode().getName());
skullLore.add("§7StopLag: §e" + (region.isFreeze() ? "Eingeschaltet" : "Ausgeschaltet"));
skullLore.add("§7Fire: §e" + (region.isFire() ? "Ausgeschaltet" : "Eingeschaltet"));
skullLore.add("§7Members: §e" + (BauweltMember.getMembers(BauSystem.getOwnerID()).size() - 1));
skull.setLore(skullLore);
inv.setItem(4, skull);
}
inv.setItem(6, Material.BOOK, "§7Script Bücher", Arrays.asList("§7Aktuell §e" + PredefinedBook.getBookCount() + " §7Bücher"), true, clickType -> {
player.closeInventory();
scriptBooksGUI(player);
});
inv.setItem(21, Material.OBSERVER, "§7Tracer", getNoPermsLore(Arrays.asList("§7Status: §e" + RecordStateMachine.getRecordStatus().getName()), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.closeInventory();
OPEN_TRACER_INVS.add(player);
traceGUI(player);
});
inv.setItem(22, Material.DISPENSER, "§7Auto-Loader", getNoPermsLore(Arrays.asList("§7Status: " + (AutoLoader.hasLoader(player) ? "§aan" : "§caus")), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.closeInventory();
autoLoaderGUI(player);
});
inv.setItem(17, getMaterial("PLAYER_HEAD", "SKULL_ITEM"), (byte) 3, "§7Spielerkopf geben", Arrays.asList("§8/§7skull §8[§eSpieler§8]"), false, clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Spielerköpfe");
anvilInv.setItem(Material.NAME_TAG);
anvilInv.setCallback(s -> player.performCommand("skull " + s));
anvilInv.open();
});
if (GlobalRegion.isGlobalRegion(region)) {
inv.setItem(9, Material.BARRIER, "§eKeine Region", clickType -> {
});
inv.setItem(18, Material.BARRIER, "§eKeine Region", clickType -> {
});
inv.setItem(27, Material.BARRIER, "§eKeine Region", clickType -> {
});
} else {
inv.setItem(27, getMaterial("HEAVY_WEIGHTED_PRESSURE_PLATE", "IRON_PLATE"), "§eRegion Reseten", getNoPermsLore(Arrays.asList("§8/§7reset"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
confirmationInventory(player, "Region Reseten?", () -> player.performCommand("reset"), () -> openBauGui(player));
});
if (region.hasProtection()) {
inv.setItem(18, Material.OBSIDIAN, "§eRegion Protecten", getNoPermsLore(Arrays.asList("§8/§7protect"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
confirmationInventory(player, "Region Protecten", () -> player.performCommand("protect"), () -> openBauGui(player));
});
} else {
inv.setItem(18, Material.BARRIER, "§eRegion nicht Protect bar", clickType -> {
});
}
if (region.hasTestblock()) {
inv.setItem(9, getMaterial("END_STONE", "ENDER_STONE"), "§eTestblock erneuern", getNoPermsLore(Arrays.asList("§8/§7testblock"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
confirmationInventory(player, "Testblock erneuern", () -> player.performCommand("testblock"), () -> openBauGui(player));
});
} else {
inv.setItem(9, Material.BARRIER, "§eDie Region hat keinen Testblock", clickType -> {
});
}
}
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
inv.setItem(26, Material.POTION, "§7Nightvision: §eEingeschaltet", Collections.singletonList("§8/§7nv"), false, clickType -> {
CommandNV.toggleNightvision(player);
openBauGui(player);
});
} else {
inv.setItem(26, Material.GLASS_BOTTLE, "§7Nightvision: §eAusgeschaltet", Collections.singletonList("§8/§7nv"), false, clickType -> {
CommandNV.toggleNightvision(player);
openBauGui(player);
});
}
if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
inv.setItem(35, Material.WATER_BUCKET, "§7Waterbreathing: §eEingeschaltet", Collections.singletonList("§8/§7wv"), false, clickType -> {
CommandGills.toggleGills(player);
openBauGui(player);
});
} else {
inv.setItem(35, Material.BUCKET, "§7Waterbreathing: §eAusgeschaltet", Collections.singletonList("§8/§7wv"), false, clickType -> {
CommandGills.toggleGills(player);
openBauGui(player);
});
}
boolean isBuildArea = region.hasBuildRegion();
List<String> tntLore = getNoPermsLore(Arrays.asList("§8/§7tnt §8[" + (isBuildArea ? "§eTB§7, " : "") + "§eOff §7oder §eOn§7]"), player, "§cDu hast keine Worldrechte", Permission.WORLD);
switch (region.getTntMode()) {
case OFF:
inv.setItem(23, Material.MINECART, "§7TNT: §eAusgeschaltet", tntLore, false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.performCommand("tnt " + (isBuildArea ? "tb" : "on"));
updateInventories();
});
break;
case ONLY_TB:
inv.setItem(23, getMaterial("TNT_MINECART", "EXPLOSIVE_MINECART"), "§7TNT: §enur Testblock", tntLore, false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.performCommand("tnt on");
updateInventories();
});
break;
default:
inv.setItem(23, Material.TNT, "§7TNT: §eEingeschaltet", tntLore, false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.performCommand("tnt off");
updateInventories();
});
}
if (region.isFreeze()) {
inv.setItem(24, getMaterial("GUNPOWDER", "SULPHUR"), "§7Freeze: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.performCommand("freeze");
updateInventories();
});
} else {
inv.setItem(24, Material.REDSTONE, "§7Freeze: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7freeze"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.performCommand("freeze");
updateInventories();
});
}
if (region.isFire()) {
inv.setItem(3, getMaterial("FIREWORK_STAR", "FIREWORK_CHARGE"), "§7Fire: §eAusgeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.performCommand("fire");
updateInventories();
});
} else {
inv.setItem(3, getMaterial("FIRE_CHARGE", "FIREBALL"), "§7Fire: §eEingeschaltet", getNoPermsLore(Arrays.asList("§8/§7fire"), player, "§cDu hast keine Worldrechte", Permission.WORLD), false, clickType -> {
if (Welt.noPermission(player, Permission.WORLD))
return;
player.performCommand("fire");
updateInventories();
});
}
inv.setItem(2, Material.ENDER_PEARL, "§7Teleporter", getNoPermsLore(Arrays.asList("§8/§7tp §8[§eSpieler§8]"), player, "", null), false, clickType -> {
List<SWListInv.SWListEntry<String>> playerSWListEntry = new ArrayList<>();
Bukkit.getOnlinePlayers().forEach(player1 -> {
if (player1.equals(player))
return;
playerSWListEntry.add(new SWListInv.SWListEntry<>(SWItem.getPlayerSkull(player1.getName()), player1.getName()));
});
SWListInv<String> playerSWListInv = new SWListInv<>(player, "Teleporter", playerSWListEntry, (clickType1, player1) -> {
player.closeInventory();
player.performCommand("tp " + player1);
});
playerSWListInv.open();
});
inv.open();
}
private static void traceGUI(Player player) {
SWInventory inv = new SWInventory(player, 9, "Tracer");
inv.setCallback(-1, clickType -> {
if (!isRefreshing)
OPEN_TRACER_INVS.remove(player);
});
List<String> stateLore = Arrays.asList("§7Aktuell: §e" + RecordStateMachine.getRecordStatus().getName(), "§8/§7trace §8[§estart§8, stop §8oder §eauto§8]");
switch (RecordStateMachine.getRecordStatus()) {
case IDLE:
inv.setItem(0, getMaterial("SNOWBALL", "SNOW_BALL"), "§7Tracerstatus", stateLore, false, clickType -> {
RecordStateMachine.commandAuto();
updateInventories();
});
break;
case IDLE_AUTO:
inv.setItem(0, Material.ENDER_PEARL, "§7Tracerstatus", stateLore, false, clickType -> {
RecordStateMachine.commandStart();
updateInventories();
});
break;
case RECORD:
case RECORD_AUTO:
inv.setItem(0, getMaterial("ENDER_EYE", "EYE_OF_ENDER"), "§7Tracerstatus", stateLore, false, clickType -> {
RecordStateMachine.commandStop();
updateInventories();
});
}
if (TraceShowManager.hasActiveShow(player)) {
inv.setItem(2, Material.TNT, "§7Showstatus", Arrays.asList("§7Aktuell: §eGezeigt", "§8/§7trace §8[§eshow§8/§ehide§8]"), false, clickType -> {
player.performCommand("trace hide");
traceGUI(player);
});
} else {
inv.setItem(2, Material.GLASS, "§7Showstatus", Arrays.asList("§7Aktuell: §eVersteckt", "§8/§7trace §8[§eshow§8/§ehide§8]"), false, clickType -> {
player.performCommand("trace show");
traceGUI(player);
});
}
inv.setItem(4, getMaterial("TNT_MINECART", "EXPLOSIVE_MINECART"), "§7Trace GUI", Collections.singletonList("§8/§7trace show gui"), false, clickType -> {
player.closeInventory();
player.performCommand("trace show gui");
});
inv.setItem(6, Material.BARRIER, "§7Trace löschen", Arrays.asList("§8/§7trace delete"), false, clickType -> confirmationInventory(player, "Trace löschen", () -> player.performCommand("trace delete"), () -> {
}));
inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> {
player.closeInventory();
openBauGui(player);
OPEN_INVS.add(player);
});
inv.open();
}
private static void scriptBooksGUI(Player player) {
List<SWListInv.SWListEntry<PredefinedBook>> entries = new ArrayList<>();
List<PredefinedBook> books = PredefinedBook.getBooks();
books.forEach(predefinedBook -> entries.add(new SWListInv.SWListEntry<>(new SWItem(predefinedBook.getBookMat(), predefinedBook.getName(), predefinedBook.getLore(), false, clickType -> {
}), predefinedBook)));
SWListInv<PredefinedBook> inv = new SWListInv<>(player, "Script Bücher", entries, (clickType, predefinedBook) -> {
player.closeInventory();
player.getInventory().addItem(predefinedBook.toItemStack());
});
inv.open();
}
private static void autoLoaderGUI(Player player) {
SWInventory inv = new SWInventory(player, 9, "Autoloader");
boolean hasLoader = AutoLoader.hasLoader(player);
if (hasLoader) {
AutoLoader loader = AutoLoader.getLoader(player);
if (loader.isSetup()) {
inv.setItem(0, Material.DROPPER, "§7Loader Starten", Collections.singletonList("§8/§7loader start"), false, clickType -> {
loader.start();
autoLoaderGUI(player);
});
inv.setItem(2, Material.ARROW, "§7Letzte Aktion entfernen", Collections.singletonList("§8/§7loader undo"), false, clickType -> {
});
} else {
inv.setItem(0, Material.BLAZE_ROD, "§7Loader Bearbeiten", Collections.singletonList("§8/§7loader setup"), false, clickType -> {
loader.setup();
autoLoaderGUI(player);
});
}
inv.setItem(4, Material.COMPASS, "§7Schuss Delay", Arrays.asList("§7Aktuell: §e" + loader.getTicksBetweenShots(), "§8/§7loader wait §8[§eTicks§8]"), false, clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Schuss Delay", loader.getTicksBetweenShots() + "");
anvilInv.setItem(Material.STONE);
anvilInv.setCallback(s -> {
player.performCommand("loader wait " + s);
autoLoaderGUI(player);
});
anvilInv.open();
});
inv.setItem(6, getMaterial("CLOCK", "WATCH"), "§7Block platzier Geschwindigkeit", Arrays.asList("§7Aktuell: §e" + loader.getTicksBetweenBlocks(), "§8/§7loader speed §8[§eTicks§8]"), false, clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, "Platzier Geschwindigkeit", loader.getTicksBetweenBlocks() + "");
anvilInv.setItem(Material.STONE);
anvilInv.setCallback(s -> {
player.performCommand("loader speed " + s);
autoLoaderGUI(player);
});
anvilInv.open();
});
inv.setItem(8, Material.BARRIER, "§7Loader löschen", Collections.singletonList("§8/§7loader stop"), false, clickType -> confirmationInventory(player, "Loader löschen?", () -> {
loader.stop();
autoLoaderGUI(player);
}, () -> autoLoaderGUI(player)));
} else {
inv.setItem(4, Material.GOLD_NUGGET, "§eNeuer Autoloader", clickType -> {
AutoLoader.getLoader(player);
player.closeInventory();
});
inv.setItem(8, Material.ARROW, "§7Zurück", clickType -> {
player.closeInventory();
openBauGui(player);
OPEN_INVS.add(player);
});
}
inv.open();
}
private static void confirmChatMessage(Player player, String command) {
player.sendMessage(BauSystem.PREFIX + "§7Klicke auf die Nachricht zum bestätigen");
TextComponent t = new TextComponent();
t.setText("[Hier]");
t.setColor(ChatColor.YELLOW);
t.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
t.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§7" + command)));
player.spigot().sendMessage(t);
}
private static List<String> getNoPermsLore(List<String> lore, Player player, String noPerms, Permission perm) {
if (perm != null && Welt.noPermission(player, perm)) {
lore = new ArrayList<>(lore);
lore.add(noPerms);
}
return lore;
}
private static void updateInventories() {
isRefreshing = true;
OPEN_INVS.forEach(CommandGUI::openBauGui);
OPEN_TRACER_INVS.forEach(CommandGUI::traceGUI);
isRefreshing = false;
}
private static void confirmationInventory(Player player, String title, Runnable confirm, Runnable decline) {
SWInventory inv = new SWInventory(player, 9, title);
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§cAbbrechen", clickType -> {
player.closeInventory();
decline.run();
});
inv.setItem(8, SWItem.getDye(10), (byte) 10, "§aBestätigen", clickType -> {
player.closeInventory();
confirm.run();
});
inv.open();
}
private static Material getMaterial(String... names) {
for (String name : names) {
try {
return Material.valueOf(name);
} catch (IllegalArgumentException ignored) {
//Ignored /\
}
}
return null;
}
private static ItemStack wand(Player player, ItemStack base, String command, Permission permission, String noPermissionMessage) {
base = base.clone();
ItemMeta meta = base.getItemMeta();
List<String> lore = meta.getLore();
lore.add(command);
if (permission != null && Welt.noPermission(player, permission))
lore.add(noPermissionMessage);
meta.setLore(lore);
base.setItemMeta(meta);
return base;
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK)
return;
if (event.getItem() == null || event.getItem().getType() != Material.NETHER_STAR)
return;
openBauGui(event.getPlayer());
OPEN_INVS.add(event.getPlayer());
}
@EventHandler
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
if (LAST_F_PLAYER.contains(event.getPlayer())) {
openBauGui(event.getPlayer());
OPEN_INVS.add(event.getPlayer());
} else {
LAST_F_PLAYER.add(event.getPlayer());
}
}
}

View File

@ -0,0 +1,50 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.command.SWCommand;
import org.bukkit.GameMode;
import org.bukkit.entity.Player;
public class CommandGamemode extends SWCommand {
public CommandGamemode() {
super("gamemode", "gm", "g");
}
@Register(help = true)
public void gamemodeHelp(Player p, String... args) {
p.sendMessage("§cUnbekannter Spielmodus");
}
@Register
public void genericCommand(Player p) {
if (p.getGameMode() == GameMode.CREATIVE) {
p.setGameMode(GameMode.SPECTATOR);
} else {
p.setGameMode(GameMode.CREATIVE);
}
}
@Register
public void gamemodeCommand(Player p, GameMode gameMode) {
p.setGameMode(gameMode);
}
}

View File

@ -0,0 +1,53 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class CommandGills extends SWCommand {
public CommandGills() {
super("watervision", "wv");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§ewatervision §8- §7Toggle WaterBreathing");
}
@Register
public void genericCommand(Player p) {
toggleGills(p);
}
public static void toggleGills(Player player) {
if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) {
player.sendMessage(BauSystem.PREFIX + "Wassersicht deaktiviert");
player.removePotionEffect(PotionEffectType.WATER_BREATHING);
return;
}
player.addPotionEffect(new PotionEffect(PotionEffectType.WATER_BREATHING, 1000000, 255, false, false));
player.sendMessage(BauSystem.PREFIX + "Wassersicht aktiviert");
}
}

View File

@ -0,0 +1,80 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.world.TPSUtils;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.command.SWCommand;
import de.steamwar.core.TPSWatcher;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.entity.Player;
import java.util.List;
import static de.steamwar.bausystem.world.TPSUtils.getTps;
public class CommandInfo extends SWCommand {
public CommandInfo() {
super("bauinfo");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§ebauinfo §8- §7Gibt Informationen über den Bau");
}
@Register
public void genericCommand(Player p) {
CommandInfo.sendBauInfo(p);
}
public static void sendBauInfo(Player p) {
p.sendMessage(BauSystem.PREFIX + "Besitzer: §e" + SteamwarUser.get(BauSystem.getOwnerID()).getUserName());
Region region = Region.getRegion(p.getLocation());
p.sendMessage(BauSystem.PREFIX + "§eTNT§8: " + region.getTntMode().getName() + " §eFire§8: " + (region.isFire() ? "§aAUS" : "§cAN") + " §eFreeze§8: " + (region.isFreeze() ? "§aAN" : "§cAUS"));
if (region.hasProtection()) {
p.sendMessage(BauSystem.PREFIX + "§eProtect§8: " + (region.isProtect() ? "§aAN" : "§cAUS"));
}
List<BauweltMember> members = BauweltMember.getMembers(BauSystem.getOwnerID());
StringBuilder membermessage = new StringBuilder().append(BauSystem.PREFIX).append("Mitglieder: ");
for (BauweltMember member : members) {
membermessage.append("§e").append(SteamwarUser.get(member.getMemberID()).getUserName()).append("§8[");
membermessage.append(member.isWorldEdit() ? "§a" : "§c").append("WE").append("§8,");
membermessage.append(member.isWorld() ? "§a" : "§c").append("W").append("§8]").append(" ");
}
p.sendMessage(membermessage.toString());
StringBuilder tpsMessage = new StringBuilder();
tpsMessage.append(BauSystem.PREFIX).append("TPS:§e");
tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.ONE_SECOND));
tpsMessage.append(" ").append(getTps(TPSWatcher.TPSType.TEN_SECONDS));
if (!TPSUtils.isWarping()) {
tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.ONE_MINUTE));
tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.FIVE_MINUTES));
tpsMessage.append(" ").append(TPSWatcher.getTPS(TPSWatcher.TPSType.TEN_MINUTES));
}
p.sendMessage(tpsMessage.toString());
}
}

View File

@ -0,0 +1,74 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.world.regions.*;
import de.steamwar.command.SWCommand;
import java.util.concurrent.atomic.AtomicLong;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
public class CommandKillAll extends SWCommand {
private static final World WORLD = Bukkit.getWorlds().get(0);
public CommandKillAll() {
super("killall", "removeall");
}
@Register(help = true)
public void genericHelp(Player player, String... args) {
player.sendMessage("§8/§ekillall §8- §7Entferne alle Entities aus deiner Region");
player.sendMessage("§8/§ekillall §8[§7Global§8/Local§7] §8- §7Entferne alle Entities aus deiner Region oder global");
}
@Register
public void genericCommand(Player player) {
genericCommand(player, RegionSelectionType.LOCAL);
}
@Register
public void genericCommand(Player player, RegionSelectionType regionSelectionType) {
Region region = Region.getRegion(player.getLocation());
AtomicLong removedEntities = new AtomicLong();
if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.isGlobalRegion(region)) {
WORLD.getEntities()
.stream()
.filter(e -> !(e instanceof Player))
.forEach(entity -> {
entity.remove();
removedEntities.getAndIncrement();
});
RegionUtils.actionBar(GlobalRegion.getInstance(), "§a" + removedEntities.get() + " Entities aus der Welt entfernt");
} else {
WORLD.getEntities()
.stream()
.filter(e -> !(e instanceof Player))
.filter(e -> region.inRegion(e.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
.forEach(entity -> {
entity.remove();
removedEntities.getAndIncrement();
});
RegionUtils.actionBar(region, "§a" + removedEntities.get() + " Entities aus der Region entfernt");
}
}
}

View File

@ -0,0 +1,134 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.AutoLoader;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
public class CommandLoader extends SWCommand {
public CommandLoader() {
super("loader");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§eloader setup §8- §7Startet die Aufnahme der Aktionen");
p.sendMessage("§8/§7loader undo §8- §7Entfernt die zuletzt aufgenommene Aktion");
p.sendMessage("§8/§eloader start §8- §7Spielt die zuvor aufgenommenen Aktionen ab");
p.sendMessage("§8/§7loader wait §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Schüssen");
p.sendMessage("§8/§7loader speed §8[§7Ticks§8] - §7Setzt die Wartezeit zwischen Aktionen");
p.sendMessage("§8/§eloader stop §8- §7Stoppt die Aufnahme bzw. das Abspielen");
p.sendMessage("§7Der AutoLader arbeitet mit §eIngame§8-§eTicks §8(20 Ticks pro Sekunde)");
}
@Register({"setup"})
public void setupCommand(Player p) {
setup(p);
}
@Register({"undo"})
public void undoCommand(Player p) {
undo(p);
}
@Register({"start"})
public void startCommand(Player p) {
start(p);
}
@Register({"stop"})
public void stopCommand(Player p) {
stop(p);
}
@Register({"wait"})
public void waitCommand(Player p, int time) {
wait(p, time);
}
@Register({"speed"})
public void speedCommand(Player p, int time) {
speed(p, time);
}
private void setup(Player player) {
AutoLoader.getLoader(player).setup();
}
private void undo(Player player) {
AutoLoader loader = loader(player);
if (loader == null)
return;
if (!loader.isSetup()) {
player.sendMessage("§cDer AutoLader wird in den Setup-Zustand versetzt");
setup(player);
}
loader.undo();
}
private void start(Player player) {
AutoLoader loader = loader(player);
if (loader == null)
return;
loader.start();
}
private void stop(Player player) {
if (!AutoLoader.hasLoader(player)) {
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader");
return;
}
AutoLoader.getLoader(player).stop();
}
private void wait(Player player, int time) {
AutoLoader loader = loader(player);
if (loader == null) {
loader = AutoLoader.getLoader(player);
}
loader.wait(time);
}
private void speed(Player player, int time) {
AutoLoader loader = loader(player);
if (loader == null) {
loader = AutoLoader.getLoader(player);
}
loader.blockWait(time);
}
private AutoLoader loader(Player player) {
if (AutoLoader.hasLoader(player)) {
return AutoLoader.getLoader(player);
}
player.sendMessage(BauSystem.PREFIX + "§cDu hast keinen aktiven AutoLader");
player.sendMessage(BauSystem.PREFIX + "§7Es wird ein neuer AutoLader gestartet");
setup(player);
return null;
}
}

View File

@ -0,0 +1,67 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.*;
import org.bukkit.entity.Player;
public class CommandLockschem extends SWCommand {
public CommandLockschem() {
super("lockschem");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
if (!SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.CHECK)) {
return;
}
sendHelp(p);
}
@Register
public void genericCommand(Player p, String owner, String schematicName) {
if (!SteamwarUser.get(p.getUniqueId()).hasPerm(UserPerm.CHECK)) {
return;
}
SteamwarUser schemOwner = SteamwarUser.get(owner);
if (schemOwner == null) {
p.sendMessage(BauSystem.PREFIX + "Dieser Spieler existiert nicht!");
return;
}
SchematicNode node = SchematicNode.getNodeFromPath(schemOwner, schematicName);
if (node == null) {
p.sendMessage(BauSystem.PREFIX + "Dieser Spieler besitzt keine Schematic mit diesem Namen!");
return;
}
p.sendMessage(BauSystem.PREFIX + "Schematic " + node .getName() + " von " +
SteamwarUser.get(node.getOwner()).getUserName() + " von " + node.getSchemtype().toString() +
" auf NORMAL zurückgesetzt!");
node.setSchemtype(SchematicType.Normal);
}
private void sendHelp(Player player) {
player.sendMessage("§8/§eschemlock §8[§7Owner§8] §8[§7Schematic§8] §8- §7 Sperre eine Schematic");
}
}

View File

@ -0,0 +1,54 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class CommandNV extends SWCommand {
public CommandNV() {
super("nightvision", "nv");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§enightvision §8- §7Toggle NightVision");
}
@Register
public void genericCommand(Player p) {
toggleNightvision(p);
}
public static void toggleNightvision(Player player) {
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
player.sendMessage(BauSystem.PREFIX + "Nachtsicht deaktiviert");
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
return;
}
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000000, 255, false, false));
player.sendMessage(BauSystem.PREFIX + "Nachtsicht aktiviert");
}
}

View File

@ -0,0 +1,127 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import java.io.IOException;
import java.util.logging.Level;
public class CommandProtect extends SWCommand implements Listener {
public CommandProtect() {
super("protect");
if (Region.buildAreaEnabled()) {
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
}
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§eprotect §8- §7Schütze die Region");
p.sendMessage("§8/§eprotect §8[§7Schematic§8] §8- §7Schütze die Region mit einer Schematic");
}
@Register
public void genericProtectCommand(Player p) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p);
if (region == null) return;
if (Region.buildAreaEnabled()) {
region.setProtect(!region.isProtect());
if (region.isProtect()) {
RegionUtils.actionBar(region, "§aBoden geschützt");
} else {
RegionUtils.actionBar(region, "§cBoden Schutz aufgehoben");
}
return;
}
try {
region.protect(null);
p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed protect", e);
}
}
@Register
public void schematicProtectCommand(Player p, String s) {
if (!permissionCheck(p)) return;
if (Region.buildAreaEnabled()) {
genericHelp(p);
return;
}
Region region = regionCheck(p);
if (region == null) return;
SteamwarUser owner = SteamwarUser.get(p.getUniqueId());
SchematicNode schem = SchematicNode.getNodeFromPath(owner, s);
if (schem == null) {
p.sendMessage(BauSystem.PREFIX + "§cSchematic nicht gefunden");
return;
}
try {
region.protect(schem);
p.sendMessage(BauSystem.PREFIX + "§7Boden geschützt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Schützen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed protect", e);
}
}
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.WORLDEDIT)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Boden schützen");
return false;
}
return true;
}
private Region regionCheck(Player player) {
Region region = Region.getRegion(player.getLocation());
if (!region.hasProtection()) {
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner (M)WG-Region");
return null;
}
return region;
}
@EventHandler
public void onExplode(EntityExplodeEvent event) {
Region region = Region.getRegion(event.getLocation());
if (!region.isProtect() || !region.hasProtection()) {
return;
}
event.blockList().removeIf(block -> {
return block.getY() < region.getProtectYLevel();
});
}
}

View File

@ -0,0 +1,52 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.command.SWCommand;
import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
public class CommandRedstoneTester extends SWCommand {
public static final ItemStack WAND = new SWItem(Material.BLAZE_ROD, "§eRedstonetester", Arrays.asList("§eLinksklick Block §8- §7Setzt die 1. Position", "§eRechtsklick Block §8- §7Setzt die 2. Position", "§eShift-Rechtsklick Luft §8- §7Zurücksetzten"), false, null).getItemStack();
public CommandRedstoneTester() {
super("redstonetester", "rt");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§eredstonetester §8- §7Gibt den RedstoneTester");
}
@Register
public void genericCommand(Player p) {
p.sendMessage(BauSystem.PREFIX + "Messe die Zeit zwischen der Aktivierung zweier Redstone Komponenten");
SWUtils.giveItemToPlayer(p, WAND);
}
}

View File

@ -0,0 +1,132 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Color;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.bausystem.world.regions.GlobalRegion;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.bausystem.world.regions.RegionExtensionType;
import de.steamwar.bausystem.world.regions.RegionType;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.io.IOException;
import java.util.logging.Level;
public class CommandRegion extends SWCommand {
public CommandRegion() {
super("region", "rg");
}
@Register
public void genericCommand(Player player) {
genericHelp(player);
}
@Register(help = true)
public void genericHelp(Player player, String... args) {
player.sendMessage("§8/§eregion undo §8- §7Mache die letzten 20 /testblock oder /reset rückgängig");
player.sendMessage("§8/§eregion redo §8- §7Wiederhole die letzten 20 §8/§7rg undo");
player.sendMessage("§8/§eregion restore §8- §7Setzte die Region zurück, ohne das Gebaute zu löschen");
player.sendMessage("§8/§eregion §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus");
player.sendMessage("§8/§eregion §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension");
player.sendMessage("§8/§eregion color §8[§7Color§8] §8- §7Ändere die Regions Farbe");
}
@Register("undo")
public void undoCommand(Player p) {
if(!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation());
if(checkGlobalRegion(region, p)) return;
if (region.undo()) {
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion rückgangig gemacht");
} else {
p.sendMessage(BauSystem.PREFIX + "§cNichts zum rückgängig machen");
}
}
@Register("redo")
public void redoCommand(Player p) {
if (!permissionCheck(p)) {
return;
}
Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) {
return;
}
if (region.redo()) {
p.sendMessage(BauSystem.PREFIX + "Letzte Aktion wiederhohlt");
} else {
p.sendMessage(BauSystem.PREFIX + "§cNichts zum wiederhohlen");
}
}
@Register
public void baurahmenCommand(Player p, RegionType regionType) {
CommandSelect.getInstance().baurahmenCommand(p, regionType, RegionExtensionType.NORMAL);
}
@Register
public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) {
CommandSelect.getInstance().baurahmenCommand(p, regionType, regionExtensionType);
}
@Register("restore")
public void genericRestoreCommand(Player p) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation());
if(checkGlobalRegion(region, p)) return;
if (region == null) return;
try {
region.reset(null, true);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
}
}
@Register("restore")
public void schematicRestoreCommand(Player p, SchematicNode schem) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation());
if(checkGlobalRegion(region, p)) return;
if (region == null) return;
try {
region.reset(schem, true);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);
}
}
@Register("color")
public void colorCommand(Player p, Color color) {
CommandColor.getInstance().genericColor(p, color);
}
static boolean checkGlobalRegion(Region region, Player p) {
if (GlobalRegion.isGlobalRegion(region)) {
p.sendMessage(BauSystem.PREFIX + "§cDu bist in keiner Region");
return true;
}
return false;
}
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.WORLDEDIT)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region verändern");
return false;
}
return true;
}
}

View File

@ -0,0 +1,91 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.bausystem.world.regions.GlobalRegion;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.command.SWCommand;
import de.steamwar.sql.SchematicNode;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.io.IOException;
import java.util.logging.Level;
public class CommandReset extends SWCommand {
public CommandReset() {
super("reset");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§ereset §8- §7Setzte die Region zurück");
p.sendMessage("§8/§ereset §8[§7Schematic§8] §8- §7Setzte die Region mit einer Schematic zurück");
}
@Register
public void genericResetCommand(Player p) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p);
if (region == null) return;
try {
region.reset(null, false);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
}
}
@Register
public void schematicResetCommand(Player p, SchematicNode schem) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p);
if (region == null) return;
try {
region.reset(schem, false);
p.sendMessage(BauSystem.PREFIX + "§7Region zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen der Region");
Bukkit.getLogger().log(Level.WARNING, "Failed reset", e);
}
}
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.WORLD)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Region zurücksetzen");
return false;
}
return true;
}
private Region regionCheck(Player player) {
Region region = Region.getRegion(player.getLocation());
if (region == GlobalRegion.getInstance()) {
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
return null;
}
return region;
}
}

View File

@ -0,0 +1,94 @@
/*
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* /
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.command.SWCommand;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import java.util.ArrayList;
import java.util.List;
public class CommandScript extends SWCommand {
public CommandScript() {
super("script");
}
public static final ItemStack BOOK = new ItemStack(Material.WRITTEN_BOOK, 1);
static {
List<String> pages = new ArrayList<>();
pages.add("§6Script System§8\n\n- Commands\n- Kommentare\n- Scriptausführung\n- Sleep\n- Variablen\n- Konstanten\n- Abfragen\n- Schleifen\n- \"echo\"\n- \"input\"\n- Arithmetik\n- Logik");
pages.add("§6Commands§8\n\nEin minecraft Befehl wird im Scriptbuch so hingeschrieben. Dabei kann man ein '/' weglassen. Um Befehle zu trennen kommen diese in neue Zeilen.\n\nStatt\n/tnt -> tnt\n//pos1 -> /pos1");
pages.add("§6Kommentare§8\n\nFür ein Kommentar fängt die Zeile mit einem '#' an. Diese Zeilen werden bei dem Ausführen dann ignoriert.\n\nBeispiel:\n§9# TNT an/aus\ntnt");
pages.add("§6Scriptausführung§8\n\nWenn du mit dem Buch in der Hand links klickst wird dieses ausgeführt.");
pages.add("§6Sleep§8\n\nUm Sachen langsamer zu machen kann man ein 'sleep' in sein Script schreiben. Danach kommt eine Zahl mit der Anzahl der GameTicks die zu schlafen sind.\n\nBeispiel:\n§9# 1 Sekunde schlafen\nsleep 20");
pages.add("§6Variablen§8\n\nMit Variablen kann man sich Zahlen speichern. Man definiert diese mit 'var <NAME> <VALUE>'.\n\nBeispiel:\n§9# Setze i zu 0\nvar i 0§8\n\nEs gibt einige spezial values. Dazu zählen");
pages.add("§8'true', 'yes', 'false' und 'no', welche für 1, 1, 0 und 0 stehen.\n\nMan kann eine Variable auch um einen erhöhen oder verkleinern. Hierfür schreibt man statt einer Zahl '++', 'inc' oder '--', 'dec'.\n\nBeispiel:\n§9var i ++");
pages.add("§8Variablen kann man referenzieren\ndurch '<' vor dem Variablennamen und '>' nach diesem. Diese kann man in jedem Befehl verwenden.\n\nBeispiel:\n§9# Stacked um 10\nvar stacks 10\n/stack <stacks>");
pages.add("§8Man kann auch explizit eine globale, locale, oder konstante variable referenzieren, indem 'global.', 'local.' oder 'const.' vor den Namen in die Klammern zu schreiben.");
pages.add("§8Um Variablen über das Script ausführen zu speichern gibt es 'global' und 'unglobal' als Befehle. Der erste speichert eine locale Variable global und das zweite löscht eine globale wieder.");
pages.add("§8Des weiteren kann man Lokale Variablen mit 'unvar' löschen. Nach dem verlassen einer Welt werden alle Globalen Variablen gelöscht. Globale Variablen kann man mit '/scriptvars' einsehen.");
pages.add("§6Konstanten§8\n\nNeben den variablen gibt es noch 5 Konstante Werte, welche nicht mit dem 'var' Befehl verändert werden können.\n\nDiese sind:\n- trace/autotrace\n- tnt\n- freeze\n- fire");
pages.add("§8Des weiteren gibt es 3 weitere Variablen, welche explizit Spieler gebunden sind\n\nDiese sind:\n- x\n- y\n- z");
pages.add("§6Abfragen§8\n\nMit Abfragen kann man nur Gleichheit von 2 Werten überprüft werden. Hierfür verwendet man\n'if <VAL> <VAL>'.\nNach den zwei Werten kann man ein oder 2 Jump-Points schreiben\n'if [...] <JP> (JP)'.");
pages.add("§8Des weiteren kann man überprüfen, ob eine Variable existiert mit 'if <VAL> exists' wonach dann wieder 1 oder 2 Jump-Points sein müssen.");
pages.add("§8Ein Jump-Point ist eine Zeile Script, wohin man springen kann. Dieser wird mit einem '.' am Anfang der Zeile beschrieben und direkt danach der Jump-Point Namen ohne Leerzeichen.\n\nBeispiel:\n§9# Jump-Point X\n.X§8");
pages.add("§8Um zu einem Jump-Point ohne Abfrage zu springen kann man den\n'jump <JP>' Befehl verwenden.");
pages.add("§6Schleifen§8\n\nSchleifen werden mit Jump-Points, if Abfragen und Jumps gebaut.\n\nBeispiel:\n§9var i 0\n.JUMP\nvar i ++\nif i 10 END JUMP\n.END§8");
pages.add("§6\"echo\"§8\n\nDer echo Befehl ist da um Ausgaben zu tätigen. Hier drin kann man sowohl Variablen ausgeben, als auch Farbcodes verwenden. Es wird alles nach dem Befehl ausgegeben.\n\nBeispiel:\n§9echo &eSteam&8war &7war hier!");
pages.add("§6\"input\"§8\n\nDer input Befehl ist eine Aufforderung einer Eingabe des Users. Die Argumente sind eine Variable und ein Text als Nachricht.\n\nBeispiel:\n§9input age &eDein Alter?");
pages.add("§6Arithmetik§8\n\nEs gibt 4 Arithmetische Befehle:\n- add\n- sub\n- mul\n- div\n\nDer erste Parameter ist die Variable welche den ausgerechneten Wert halten soll. Hiernach muss ein");
pages.add("§8Wert oder Variable kommen welcher verrechnet wird. Hierbei wird das erste Argument als ersten Operand genommen.\n\nBeispiel:\n§9var i 2\nvar j 3\nadd i j\necho $i");
pages.add("§8Man kann auch 3 Argumente angeben. Dann wird die arithmetische Operation zwischen den letzten beiden Argumenten berechnet und als Variable des ersten Arguments abgespeichert. \n\nBeispiel auf der nächsten Seite -->");
pages.add("§8Beispiel:\n§9var i 2\nvar j 2\nadd k i j\necho $k");
pages.add("§6Logik§8\n\nEs gibt 3 Vergleichs Befehle:\n- equal\n- less\n- greater\n\nUnd 3 Logik Befehle:\n- and\n- or\n- not");
pages.add("§8Der erste Parameter ist die Variable welche den ausgerechneten Wert halten soll. Hiernach muss ein Wert oder Variable kommen welcher verrechnet wird. Hierbei wird das erste Argument als ersten Operand genommen. Dies gilt nicht für den 'not' Befehl, welcher");
pages.add("§8nur 2 Parameter nimmt. Der erste die Variable und der zweite eine optionale Variable oder ein Wert. Equal vergleicht 2 Werte, less gibt zurück ob der erste kleiner als der zweite Wert ist, greater gibt zurück ob der erste größer als der zweite Wert ist.");
pages.add("§8And vergleicht ob 2 Werte true (1) sind. Or vergleicht ob 1 Wert oder 2 Werte true (1) ist/sind. Not invertiert den Wert von true (1) auf false und anders rum.");
pages.add("§8Beispiel:\n§9var i 1\nvar j 1\n#Ist i und j gleich\nequal k i j\nvar j 0\n#Ist i kleiner j\nless k i j\n#Ist i größer j\ngreater k i j\n#Ist i und j true\nand k i j\n#Beispiel weiter auf nächster Seite");
pages.add("§9#Ist i oder j true\nor k i j\n#Invertiere i\nnot k i");
BookMeta bookMeta = (BookMeta) BOOK.getItemMeta();
bookMeta.setGeneration(BookMeta.Generation.ORIGINAL);
bookMeta.setAuthor("§eSteam§8war");
bookMeta.setTitle("§7Script Buch");
bookMeta.setDisplayName("§7Script Buch");
bookMeta.setPages(pages);
BOOK.setItemMeta(bookMeta);
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§escript §8- §7Gibt das Script Buch");
}
@Register
public void giveCommand(Player p) {
SWUtils.giveItemToPlayer(p, BOOK);
}
}

View File

@ -0,0 +1,120 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.world.ScriptListener;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import org.bukkit.entity.Player;
import java.util.*;
public class CommandScriptVars extends SWCommand {
public CommandScriptVars() {
super("scripvars");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§escriptvars §8- §7Zähle alle globalen Variablen auf");
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8- §7Gebe den Wert der Variable zurück");
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8[§7Value§8] §8- §7Setzte eine Variable auf einen Wert");
p.sendMessage("§8/§escriptvars §8[§7Variable§8] §8<§7remove§8|§7delete§8|§7clear§8> §8- §7Lösche eine Variable");
}
@Register
public void genericCommand(Player p) {
Map<String, Integer> globalVariables = ScriptListener.GLOBAL_VARIABLES.get(p);
if (globalVariables == null) {
p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert");
return;
}
int i = 0;
p.sendMessage(BauSystem.PREFIX + globalVariables.size() + " Variable(n)");
for (Map.Entry<String, Integer> var : globalVariables.entrySet()) {
if (i++ >= 40) break;
p.sendMessage("- " + var.getKey() + "=" + var.getValue());
}
}
@Register
public void removeCommand(Player p, String varName) {
Map<String, Integer> globalVariables = ScriptListener.GLOBAL_VARIABLES.get(p);
if (globalVariables == null) {
p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert");
return;
}
if (!globalVariables.containsKey(varName)) {
p.sendMessage(BauSystem.PREFIX + "§cUnbekannte Variable");
return;
}
p.sendMessage(BauSystem.PREFIX + varName + "=" + globalVariables.get(varName));
}
@Register
public void booleanValueCommand(Player p, String varName, int value) {
ScriptListener.GLOBAL_VARIABLES.computeIfAbsent(p, player -> new HashMap<>()).put(varName, value);
p.sendMessage(BauSystem.PREFIX + varName + " auf " + value + " gesetzt");
}
@Register
public void removeCommand(Player p, String varName, @Mapper(value = "Delete") String remove) {
if (!ScriptListener.GLOBAL_VARIABLES.containsKey(p)) {
p.sendMessage(BauSystem.PREFIX + "§cKeine globalen Variablen definiert");
return;
}
ScriptListener.GLOBAL_VARIABLES.get(p).remove(varName);
p.sendMessage(BauSystem.PREFIX + "Variable " + varName + " gelöscht");
}
@ClassMapper(value = String.class, local = true)
public TypeMapper<String> stringTypeMapper() {
return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> {
if (commandSender instanceof Player) {
Player player = (Player) commandSender;
return new ArrayList<>(ScriptListener.GLOBAL_VARIABLES.getOrDefault(player, new HashMap<>()).keySet());
}
return null;
});
}
@Mapper(value = "Delete", local = true)
public TypeMapper<String> clearStringTypeMapper() {
List<String> tabCompletes = Arrays.asList("delete", "clear", "remove");
return SWCommandUtils.createMapper(s -> {
if (s.equalsIgnoreCase("delete") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("remove")) {
return s;
}
return null;
}, s -> tabCompletes);
}
@ClassMapper(value = int.class, local = true)
public TypeMapper<Integer> integerTypeMapper() {
List<String> tabCompletes = Arrays.asList("true", "false", "yes", "no");
return SWCommandUtils.createMapper(s -> {
if (s.equalsIgnoreCase("remove") || s.equalsIgnoreCase("clear") || s.equalsIgnoreCase("delete")) return null;
return ScriptListener.parseValue(s);
}, s -> tabCompletes);
}
}

View File

@ -0,0 +1,124 @@
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.WorldeditWrapper;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.bausystem.world.regions.*;
import de.steamwar.command.SWCommand;
import lombok.Getter;
import org.bukkit.entity.Player;
public class CommandSelect extends SWCommand {
@Getter
private static CommandSelect instance = null;
public CommandSelect() {
super("select");
}
{
instance = this;
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§eselect §8[§7RegionsTyp§8] §8- §7Wähle einen RegionsTyp aus");
p.sendMessage("§8/§eselect §8[§7RegionsTyp§8] §8[§7Extension§8] §8- §7Wähle einen RegionsTyp aus mit oder ohne Extension");
}
@Register
public void baurahmenCommand(Player p, RegionType regionType) {
if (!permissionCheck(p)) {
return;
}
Region region = Region.getRegion(p.getLocation());
if (GlobalRegion.isGlobalRegion(region)) {
p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen");
return;
}
if (regionType == RegionType.TESTBLOCK) {
if (!region.hasTestblock()) {
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen Testblock");
return;
}
setSelection(regionType, RegionExtensionType.NORMAL, region, p);
return;
}
if (regionType == RegionType.BUILD) {
if (!region.hasBuildRegion()) {
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen BuildArea");
return;
}
setSelection(regionType, RegionExtensionType.NORMAL, region, p);
return;
}
setSelection(regionType, RegionExtensionType.NORMAL, region, p);
}
@Register
public void baurahmenCommand(Player p, RegionType regionType, RegionExtensionType regionExtensionType) {
if (!permissionCheck(p)) {
return;
}
Region region = Region.getRegion(p.getLocation());
if (GlobalRegion.isGlobalRegion(region)) {
p.sendMessage(BauSystem.PREFIX + "§cDie globale Region kannst du nicht auswählen");
return;
}
if (regionType == RegionType.TESTBLOCK) {
if (!region.hasTestblock()) {
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen Testblock");
return;
}
if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionArea(regionType)) {
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keine Ausfahrmaße");
return;
}
setSelection(regionType, regionExtensionType, region, p);
return;
}
if (regionType == RegionType.BUILD) {
if (!region.hasBuildRegion()) {
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keinen BuildArea");
return;
}
if (regionExtensionType == RegionExtensionType.EXTENSION && !region.hasExtensionArea(regionType)) {
p.sendMessage(BauSystem.PREFIX + "§cDiese Region hat keine Ausfahrmaße");
return;
}
setSelection(regionType, regionExtensionType, region, p);
return;
}
setSelection(regionType, regionExtensionType, region, p);
}
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.WORLDEDIT)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Select verwenden");
return false;
}
return true;
}
private void setSelection(RegionType regionType, RegionExtensionType regionExtensionType, Region region, Player p) {
Point minPoint = region.getMinPoint(regionType, regionExtensionType);
Point maxPoint = region.getMaxPoint(regionType, regionExtensionType);
WorldeditWrapper.impl.setSelection(p, minPoint, maxPoint);
p.sendMessage(BauSystem.PREFIX + "WorldEdit auswahl auf " + minPoint.getX() + ", " + minPoint.getY() + ", " + minPoint.getZ() + " und " + maxPoint.getX() + ", " + maxPoint.getY() + ", " + maxPoint.getZ() + " gesetzt");
}
}

View File

@ -0,0 +1,49 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.command.SWCommand;
import de.steamwar.inventory.SWItem;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
public class CommandSkull extends SWCommand {
public CommandSkull() {
super("skull");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§eskull §8[§eSpieler§8] §8- §7Gibt einen SpielerKopf");
}
@Register
public void giveCommand(Player p, String skull) {
ItemStack is = SWItem.getPlayerSkull(skull).getItemStack();
SkullMeta sm = (SkullMeta) is.getItemMeta();
assert sm != null;
sm.setDisplayName("§e" + skull + "§8s Kopf");
is.setItemMeta(sm);
SWUtils.giveItemToPlayer(p, is);
}
}

View File

@ -0,0 +1,70 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List;
public class CommandSpeed extends SWCommand {
public CommandSpeed() {
super("speed");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§espeed §8[§7Geschwindigkeit§8] §8- §7Setzte deine Flug- und Gehgeschwindigkeit");
}
@Register({"default"})
public void defaultCommand(Player p) {
speedCommand(p, 1);
}
@Register
public void speedCommand(Player p, float speed) {
if (speed < 0 || speed > 10) {
p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 10 an");
return;
}
p.sendMessage("§aGeschwindigkeit wurde auf §6" + speed + " §agesetzt");
p.setFlySpeed(speed / 10);
p.setWalkSpeed((speed >= 9 ? speed : speed + 1) / 10);
}
@ClassMapper(value = float.class, local = true)
public TypeMapper<Float> doubleTypeMapper() {
List<String> tabCompletes = Arrays.asList("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
return SWCommandUtils.createMapper(s -> {
try {
return Float.parseFloat(s.replace(',', '.'));
} catch (NumberFormatException e) {
return null;
}
}, s -> tabCompletes);
}
}

View File

@ -0,0 +1,173 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.bausystem.world.regions.RegionExtensionType;
import de.steamwar.bausystem.world.regions.RegionType;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class CommandTNT extends SWCommand implements Listener {
public enum TNTMode {
ON("§aan"),
ONLY_TB("§7Kein §eBaurahmen"),
OFF("§caus");
private String name;
TNTMode(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
public CommandTNT() {
super("tnt");
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§etnt §8- §7Ändere das TNT verhalten");
p.sendMessage("§8/§etnt §8[§7Mode§8] §8- §7Setzte das TNT verhalten auf einen Modus");
}
@Register
public void toggleCommand(Player p) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation());
tntToggle(region, null, null);
}
@Register
public void setCommand(Player p, TNTMode tntMode) {
if (!permissionCheck(p)) return;
Region region = Region.getRegion(p.getLocation());
String requestedMessage = null;
switch (tntMode) {
case ON:
requestedMessage = getEnableMessage();
break;
case OFF:
requestedMessage = getDisableMessage();
break;
case ONLY_TB:
requestedMessage = getTestblockEnableMessage();
break;
}
tntToggle(region, tntMode, requestedMessage);
}
private boolean permissionCheck(Player p) {
if (Welt.noPermission(p, Permission.WORLD)) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht TNT-Schaden (de-)aktivieren");
return false;
}
return true;
}
@ClassMapper(value = TNTMode.class, local = true)
public TypeMapper<TNTMode> tntModeTypeMapper() {
Map<String, TNTMode> tntModeMap = new HashMap<>();
tntModeMap.put("an", TNTMode.ON);
tntModeMap.put("on", TNTMode.ON);
tntModeMap.put("aus", TNTMode.OFF);
tntModeMap.put("off", TNTMode.OFF);
if (Region.buildAreaEnabled()) {
tntModeMap.put("testblock", TNTMode.ONLY_TB);
tntModeMap.put("tb", TNTMode.ONLY_TB);
}
List<String> tabCompletes = new ArrayList<>(tntModeMap.keySet());
return SWCommandUtils.createMapper(s -> tntModeMap.getOrDefault(s, null), s -> tabCompletes);
}
private String getEnableMessage() {
return "§aTNT-Schaden aktiviert";
}
private String getDisableMessage() {
return "§cTNT-Schaden deaktiviert";
}
private String getTestblockEnableMessage() {
return "§aTNT-Schaden außerhalb Baurahmen aktiviert";
}
private void tntToggle(Region region, TNTMode requestedMode, String requestedMessage) {
if (requestedMode != null && region.hasTestblock()) {
region.setTntMode(requestedMode);
RegionUtils.actionBar(region, requestedMessage);
return;
}
switch (region.getTntMode()) {
case ON:
case ONLY_TB:
region.setTntMode(TNTMode.OFF);
RegionUtils.actionBar(region, getDisableMessage());
break;
case OFF:
if (Region.buildAreaEnabled() && region.hasTestblock()) {
region.setTntMode(TNTMode.ONLY_TB);
RegionUtils.actionBar(region, getTestblockEnableMessage());
} else {
region.setTntMode(TNTMode.ON);
RegionUtils.actionBar(region, getEnableMessage());
}
break;
}
}
@EventHandler
public void onExplode(EntityExplodeEvent event) {
event.blockList().removeIf(block -> {
Region region = Region.getRegion(block.getLocation());
if (region.getTntMode() == TNTMode.ON) return false;
if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.NORMAL)) {
RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Baubereich zerstört");
return true;
}
if (region.hasBuildRegion() && region.inRegion(block.getLocation(), RegionType.BUILD, RegionExtensionType.EXTENSION)) {
RegionUtils.actionBar(region, "§cEine Explosion hätte Blöcke im Ausfahrbereich zerstört");
return true;
}
return region.getTntMode() == TNTMode.OFF;
});
}
}

View File

@ -0,0 +1,176 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.CraftbukkitWrapper;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.TPSUtils;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class CommandTPSLimiter extends SWCommand {
private static CommandTPSLimiter instance = null;
{
instance = this;
}
private static final World WORLD = Bukkit.getWorlds().get(0);
private static double currentTPSLimit = 20;
private long lastTime = System.nanoTime();
private long currentTime = System.nanoTime();
private double delay = 0;
private int loops = 0;
private long sleepDelay = 0;
private BukkitTask tpsLimiter = null;
private List<String> tabCompletions = new ArrayList<>(Arrays.asList("0,5", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20"));
public CommandTPSLimiter() {
super("tpslimit");
if (TPSUtils.isWarpAllowed()) {
for (int i = 20; i <= 60; i += 5) {
tabCompletions.add(i + "");
}
}
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage(BauSystem.PREFIX + "Jetziges TPS limit: " + currentTPSLimit);
p.sendMessage("§8/§etpslimit §8[§7TPS§8|§edefault§8] §8- §7Setzte die TPS auf dem Bau");
}
@Register({"default"})
public void defaultCommand(Player p) {
if (!permissionCheck(p)) return;
currentTPSLimit = 20;
sendNewTPSLimitMessage();
tpsLimiter();
}
@Register
public void valueCommand(Player p, double tpsLimitDouble) {
if (!permissionCheck(p)) return;
if (tpsLimitDouble < 0.5 || tpsLimitDouble > (TPSUtils.isWarpAllowed() ? 60 : 20)) {
sendInvalidArgumentMessage(p);
return;
}
currentTPSLimit = tpsLimitDouble;
sendNewTPSLimitMessage();
tpsLimiter();
}
@ClassMapper(value = double.class, local = true)
public TypeMapper<Double> doubleTypeMapper() {
return SWCommandUtils.createMapper(s -> {
try {
return Double.parseDouble(s.replace(',', '.'));
} catch (NumberFormatException e) {
return 0D;
}
}, s -> tabCompletions);
}
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.WORLD)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TPS-Limiter nutzen");
return false;
}
return true;
}
private void sendNewTPSLimitMessage() {
Bukkit.getOnlinePlayers().forEach(p -> p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText("§eTPS limit auf " + currentTPSLimit + " gesetzt.")));
}
private void sendInvalidArgumentMessage(Player player) {
player.sendMessage(BauSystem.PREFIX + "§cNur Zahlen zwischen 0,5 und " + (TPSUtils.isWarpAllowed() ? 60 : 20) + ", und 'default' erlaubt.");
}
private void tpsLimiter() {
delay = 20 / currentTPSLimit;
loops = (int) Math.ceil(delay);
sleepDelay = (long) (50 * delay) / loops;
TPSUtils.setTPS(currentTPSLimit);
if (currentTPSLimit >= 20) {
if (tpsLimiter == null) return;
tpsLimiter.cancel();
tpsLimiter = null;
} else {
if (tpsLimiter != null) return;
tpsLimiter = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
CraftbukkitWrapper.impl.createTickCache(WORLD);
for (int i = 0; i < loops; i++) {
sleepUntilNextTick(sleepDelay);
CraftbukkitWrapper.impl.sendTickPackets();
}
}, 0, 1);
}
}
private void sleepUntilNextTick(long neededDelta) {
lastTime = currentTime;
currentTime = System.nanoTime();
long timeDelta = (currentTime - lastTime) / 1000000;
if (neededDelta - timeDelta < 0) return;
try {
Thread.sleep(neededDelta - timeDelta);
currentTime = System.nanoTime();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
public static double getCurrentTPSLimit() {
return (double) Math.round(currentTPSLimit * 10.0D) / 10.0D;
}
public static void setTPS(double d) {
if (d < 0.5) d = 0.5;
if (d > (TPSUtils.isWarpAllowed() ? 60 : 20)) d = (TPSUtils.isWarpAllowed() ? 60 : 20);
if (instance != null) {
currentTPSLimit = d;
instance.tpsLimiter();
}
}
}

View File

@ -0,0 +1,46 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
public class CommandTeleport extends SWCommand {
public CommandTeleport() {
super("teleport", "tp");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§etp §8[§7Player§8] §8- §7Teleportiere dich zu einem Spieler");
}
@Register
public void genericCommand(Player p, Player target) {
if (p.getUniqueId().equals(target.getUniqueId())) {
p.sendMessage(BauSystem.PREFIX + "§cSei eins mit dir selbst!");
return;
}
p.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
}
}

View File

@ -0,0 +1,128 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.tracer.show.ShowModeParameterType;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.bausystem.world.regions.RegionExtensionType;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
public class CommandTestblock extends SWCommand {
public CommandTestblock() {
super("testblock", "tb");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§etestblock §8- §7Setzte den Testblock zurück");
p.sendMessage("§8/§etestblock §8[§7Schematic§8] §8- §7Setzte den Testblock mit einer Schematic zurück");
}
@Register
public void genericTestblockCommand(Player p) {
genericTestblockCommand(p, RegionExtensionType.NORMAL);
}
@Register
public void genericTestblockCommand(Player p, RegionExtensionType regionExtensionType) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p);
if (region == null) return;
try {
region.resetTestblock(null, regionExtensionType == RegionExtensionType.EXTENSION);
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
}
}
@Register
public void schematicTestblockCommand(Player p, SchematicNode schem) {
schematicTestblockCommand(p, schem, RegionExtensionType.NORMAL);
}
@Register
public void schematicTestblockCommand(Player p, RegionExtensionType regionExtensionType, SchematicNode schem) {
schematicTestblockCommand(p, schem, regionExtensionType);
}
@Register
public void schematicTestblockCommand(Player p, SchematicNode schem, RegionExtensionType regionExtensionType) {
if (!permissionCheck(p)) return;
Region region = regionCheck(p);
if (region == null) return;
try {
region.resetTestblock(schem, regionExtensionType == RegionExtensionType.EXTENSION);
p.sendMessage(BauSystem.PREFIX + "§7Testblock zurückgesetzt");
} catch (IOException e) {
p.sendMessage(BauSystem.PREFIX + "§cFehler beim Zurücksetzen des Testblocks");
Bukkit.getLogger().log(Level.WARNING, "Failed testblock", e);
}
}
@ClassMapper(value = RegionExtensionType.class, local = true)
private TypeMapper<RegionExtensionType> regionExtensionTypeTypeMapper() {
Map<String, RegionExtensionType> showModeParameterTypesMap = new HashMap<>();
showModeParameterTypesMap.put("-normal", RegionExtensionType.NORMAL);
showModeParameterTypesMap.put("-n", RegionExtensionType.NORMAL);
showModeParameterTypesMap.put("-extension", RegionExtensionType.EXTENSION);
showModeParameterTypesMap.put("-e", RegionExtensionType.EXTENSION);
List<String> tabCompletes = new ArrayList<>(showModeParameterTypesMap.keySet());
return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes);
}
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.WORLDEDIT)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den Testblock zurücksetzen");
return false;
}
return true;
}
private Region regionCheck(Player player) {
Region region = Region.getRegion(player.getLocation());
if (!region.hasTestblock()) {
player.sendMessage(BauSystem.PREFIX + "§cDu befindest dich derzeit in keiner Region");
return null;
}
return region;
}
}

View File

@ -0,0 +1,99 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
import de.steamwar.command.TypeMapper;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class CommandTime extends SWCommand {
private static List<String> tabCompletions = Arrays.asList("0", "6000", "12000", "18000");
public CommandTime() {
super("time");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§etime §8<§7Zeit 0=Morgen§8, §76000=Mittag§8, §718000=Mitternacht§8> §8- §7Setzt die Zeit auf dem Bau");
}
@Register
public void genericCommand(Player p, int time) {
if (Welt.noPermission(p, Permission.WORLD)) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
return;
}
if (time < 0 || time > 24000) {
p.sendMessage(BauSystem.PREFIX + "§cBitte gib eine Zahl zwischen 0 und 24000 an");
return;
}
Bukkit.getWorlds().get(0).setTime(time);
}
@Register
public void genericCommand(Player p, Time time) {
if (Welt.noPermission(p, Permission.WORLD)) {
p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht die Zeit ändern");
return;
}
Bukkit.getWorlds().get(0).setTime(time.getValue());
}
@ClassMapper(value = int.class, local = true)
public TypeMapper<Integer> doubleTypeMapper() {
return SWCommandUtils.createMapper(s -> {
try {
return Integer.parseInt(s);
} catch (NumberFormatException e) {
return 0;
}
}, s -> tabCompletions);
}
public enum Time {
NIGHT(18000),
DAY(6000),
DAWN(0),
SUNSET(12000),
NACHT(18000),
TAG(6000),
MORGEN(0),
ABEND(12000);
private int value;
private Time(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
}

View File

@ -0,0 +1,132 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.gui.GuiTraceShow;
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.tracer.show.ShowModeParameterType;
import de.steamwar.bausystem.tracer.show.StoredRecords;
import de.steamwar.bausystem.tracer.show.TraceShowManager;
import de.steamwar.bausystem.tracer.show.mode.EntityShowMode;
import de.steamwar.bausystem.world.Welt;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
public class CommandTrace extends SWCommand {
public CommandTrace() {
super("trace");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§etrace start §8- §7Startet die Aufnahme aller TNT-Positionen");
p.sendMessage("§8/§etrace stop §8- §7Stoppt den TNT-Tracer");
p.sendMessage("§8/§etrace toggleauto §8- §7Automatischer Aufnahmenstart");
p.sendMessage("§8/§etrace show gui §8- §7Zeigt die Trace show gui");
p.sendMessage("§8/§etrace show §8<§e-water§8|§e-interpolate-xz§8|§e-interpolate-y§8> §8- §7Zeigt alle TNT-Positionen");
p.sendMessage("§8/§etrace hide §8- §7Versteckt alle TNT-Positionen");
p.sendMessage("§8/§etrace delete §8- §7Löscht alle TNT-Positionen");
// p.sendMessage("§8/§etrace list §8<§7FRAME-ID§8> §8- §7Listet alle TNT auf");
// p.sendMessage("§8/§etrace gui §8- §7Zeigt die Trace Oberfläche an");
// p.sendMessage("§7Optionale Parameter mit §8<>§7, Benötigte Parameter mit §8[]");
}
@Register({"start"})
public void startCommand(Player p) {
if (!permissionCheck(p)) return;
RecordStateMachine.commandStart();
p.sendMessage(BauSystem.PREFIX + "§aTNT-Tracer gestartet");
}
@Register({"stop"})
public void stopCommand(Player p) {
if (!permissionCheck(p)) return;
RecordStateMachine.commandStop();
p.sendMessage(BauSystem.PREFIX + "§cTNT-Tracer gestoppt");
}
@Register({"toggleauto"})
public void toggleAutoCommand(Player p) {
autoCommand(p);
}
@Register({"auto"})
public void autoCommand(Player p) {
if (!permissionCheck(p)) return;
RecordStateMachine.commandAuto();
p.sendMessage(BauSystem.PREFIX + RecordStateMachine.getRecordStatus().getAutoMessage());
}
@Register({"clear"})
public void clearCommand(Player p) {
deleteCommand(p);
}
@Register({"delete"})
public void deleteCommand(Player p) {
if (!permissionCheck(p)) return;
StoredRecords.clear();
p.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen gelöscht");
}
@Register({"show"})
public void showCommand(Player p) {
if (!permissionCheck(p)) return;
TraceShowManager.show(p, new EntityShowMode(p, new ShowModeParameter()));
p.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
}
@Register({"show"})
public void showCommand(Player p, ShowModeParameterType... showModeParameterTypes) {
if (!permissionCheck(p)) return;
ShowModeParameter showModeParameter = new ShowModeParameter();
for (ShowModeParameterType showModeParameterType : showModeParameterTypes) {
showModeParameterType.getShowModeParameterConsumer().accept(showModeParameter);
}
TraceShowManager.show(p, new EntityShowMode(p, showModeParameter));
p.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
}
@Register({"show", "gui"})
public void showGuiCommand(Player p) {
if (!permissionCheck(p)) return;
GuiTraceShow.openGui(p);
}
@Register({"hide"})
public void hideCommand(Player p) {
if (!permissionCheck(p)) return;
TraceShowManager.hide(p);
p.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet");
}
private boolean permissionCheck(Player player) {
if (Welt.noPermission(player, Permission.WORLD)) {
player.sendMessage(BauSystem.PREFIX + "§cDu darfst hier nicht den TNT-Tracer nutzen");
return false;
}
return true;
}
}

View File

@ -0,0 +1,45 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.command.SWCommand;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
public class CommandWorldSpawn extends SWCommand {
private World world = Bukkit.getWorlds().get(0);
public CommandWorldSpawn() {
super("worldspawn");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
p.sendMessage("§8/§eworldspawn §8- §7Teleportiere dich zum Spawn");
}
@Register
public void genericCommand(Player p) {
p.teleport(world.getSpawnLocation(), PlayerTeleportEvent.TeleportCause.COMMAND);
}
}

View File

@ -0,0 +1,42 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.commands;
import de.steamwar.bausystem.world.regions.GlobalRegion;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.bausystem.world.regions.RegionExtensionType;
import de.steamwar.bausystem.world.regions.RegionType;
import lombok.experimental.UtilityClass;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
@UtilityClass
public class RegionUtils {
public static void actionBar(Region region, String s) {
if (GlobalRegion.isGlobalRegion(region)) {
Bukkit.getOnlinePlayers().forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
} else {
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
}
}
}

View File

@ -0,0 +1,133 @@
/*
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* /
*/
package de.steamwar.bausystem.gui;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.FlatteningWrapper;
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
import de.steamwar.bausystem.tracer.show.TraceShowManager;
import de.steamwar.bausystem.tracer.show.mode.EntityShowMode;
import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class GuiTraceShow {
private static final Map<Player, ShowModeParameter> ShowModeParameterMap = new HashMap<>();
private GuiTraceShow() {
}
public static void openGui(Player player) {
ShowModeParameter playerShowMode = new ShowModeParameter();
playerShowMode.setInterpolate_Y(false);
playerShowMode.setInterpolate_XZ(false);
ShowModeParameterMap.put(player, playerShowMode);
SWInventory swInventory = new SWInventory(player, 9, "Trace Show GUI");
swInventory.addCloseCallback(clickType -> ShowModeParameterMap.remove(player));
setActiveShow(player, swInventory);
SWItem water = new SWItem(Material.TNT, "§eWasser §7Positionen", Arrays.asList("§7Zeigt alles TNT, welches", "§7im Wasser explodiert ist."), false, clickType -> {
});
swInventory.setItem(5, water);
swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, water));
SWItem interpolateY = new SWItem(Material.QUARTZ_STAIRS, "§eInterpolation §7Y-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der Y-Achse."), false, clickType -> {
});
swInventory.setItem(6, interpolateY);
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, interpolateY));
Material xzMaterial = FlatteningWrapper.impl.getTraceXZMaterial();
SWItem interpolateXZ = new SWItem(xzMaterial, (byte) 7, "§eInterpolation §7XZ-Achse", Arrays.asList("§7Zeigt die Interpolation", "§7auf der XZ-Achse."), false, clickType -> {
});
swInventory.setItem(7, interpolateXZ);
swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, interpolateXZ));
// Water Bucket (-water)
// TNT (-water-exploded)
// Quartz_Stair (-interpolate-y)
// Quartz_Slab (-interpolate-xz)
swInventory.open();
}
private static void setActiveShow(Player player, SWInventory swInventory) {
if (TraceShowManager.hasActiveShow(player)) {
Material showMaterial = FlatteningWrapper.impl.getTraceShowMaterial();
SWItem shown = new SWItem(showMaterial, (byte) 5, "§aTraces angezeigt", new ArrayList<>(), false, clickType -> {
TraceShowManager.hide(player);
player.sendMessage(BauSystem.PREFIX + "§cAlle TNT-Positionen ausgeblendet");
setActiveShow(player, swInventory);
});
swInventory.setItem(1, shown);
} else {
Material hideMaterial = FlatteningWrapper.impl.getTraceHideMaterial();
SWItem hidden = new SWItem(hideMaterial, (byte) 14, "§cTraces ausgeblendet", new ArrayList<>(), false, clickType -> {
show(player);
player.sendMessage(BauSystem.PREFIX + "§aAlle TNT-Positionen angezeigt");
setActiveShow(player, swInventory);
});
swInventory.setItem(1, hidden);
}
}
private static void toggleHideTNTinWaterExploded(Player player, SWInventory swInventory, SWItem swItem) {
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
showModeParameter.setWater(!showModeParameter.isWater());
show(player);
swItem.setEnchanted(showModeParameter.isWater());
swInventory.setItem(5, swItem);
swInventory.setCallback(5, clickType -> toggleHideTNTinWaterExploded(player, swInventory, swItem));
}
private static void toggleInterpolateYPosition(Player player, SWInventory swInventory, SWItem swItem) {
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
showModeParameter.setInterpolate_Y(!showModeParameter.isInterpolate_Y());
show(player);
swItem.setEnchanted(showModeParameter.isInterpolate_Y());
swInventory.setItem(6, swItem);
swInventory.setCallback(6, clickType -> toggleInterpolateYPosition(player, swInventory, swItem));
}
private static void toggleInterpolateXZPosition(Player player, SWInventory swInventory, SWItem swItem) {
ShowModeParameter showModeParameter = ShowModeParameterMap.get(player);
showModeParameter.setInterpolate_XZ(!showModeParameter.isInterpolate_XZ());
show(player);
swItem.setEnchanted(showModeParameter.isInterpolate_XZ());
swInventory.setItem(7, swItem);
swInventory.setCallback(7, clickType -> toggleInterpolateXZPosition(player, swInventory, swItem));
}
private static void show(Player player) {
TraceShowManager.show(player, new EntityShowMode(player, ShowModeParameterMap.get(player)));
}
}

View File

@ -0,0 +1,34 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.tracer;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public interface AbstractTraceEntity {
void display(Player player, boolean exploded);
boolean hide(Player player, boolean always);
int getId();
Entity getBukkitEntity();
}

View File

@ -0,0 +1,65 @@
/*
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* /
*/
package de.steamwar.bausystem.tracer;
import org.bukkit.util.Vector;
import java.util.Objects;
public class RoundedTNTPosition {
private static final int factor = 10;
private int x;
private int y;
private int z;
public RoundedTNTPosition(TNTPosition tntPosition) {
this(tntPosition.getLocation().getX(), tntPosition.getLocation().getY(), tntPosition.getLocation().getZ());
}
public RoundedTNTPosition(Vector vector) {
this(vector.getX(), vector.getY(), vector.getZ());
}
public RoundedTNTPosition(double x, double y, double z) {
this.x = (int) (x * factor);
this.y = (int) (y * factor);
this.z = (int) (z * factor);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof RoundedTNTPosition)) return false;
RoundedTNTPosition that = (RoundedTNTPosition) o;
return x == that.x &&
y == that.y &&
z == that.z;
}
@Override
public int hashCode() {
return Objects.hash(x, y, z);
}
}

View File

@ -0,0 +1,63 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.tracer;
import de.steamwar.bausystem.tracer.show.Record;
import org.bukkit.entity.Entity;
import org.bukkit.util.Vector;
public class TNTPosition {
private final Record.TNTRecord record;
private final Vector location;
private final Vector previousLocation;
private final boolean exploded;
public TNTPosition(Record.TNTRecord record, Entity entity, Vector previousLocation, boolean exploded) {
this.location = entity.getLocation().toVector();
this.record = record;
this.previousLocation = previousLocation;
this.exploded = exploded;
}
public Vector getLocation() {
return location;
}
public Vector getPreviousLocation() {
return previousLocation;
}
public boolean isExploded() {
return exploded;
}
public Record.TNTRecord getRecord() {
return record;
}
@Override
public String toString() {
return "Position{" +
"location=" + location +
'}';
}
}

View File

@ -0,0 +1,94 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.tracer.record;
public class RecordStateMachine {
private RecordStateMachine() {
}
private static final TraceAutoHandler autoHandler = new TraceAutoHandler();
private static RecordStatus recordStatus = RecordStatus.IDLE;
private static Recorder recorder = null;
public static void commandStart() {
autoHandler.disable();
recordStart();
recordStatus = RecordStatus.RECORD;
}
public static void commandStop() {
autoHandler.disable();
recordStop();
recordStatus = RecordStatus.IDLE;
}
public static void commandAuto() {
if (recordStatus.isTracing())
return;
if (recordStatus == RecordStatus.IDLE_AUTO) {
recordStatus = RecordStatus.IDLE;
autoHandler.disable();
} else {
recordStatus = RecordStatus.IDLE_AUTO;
autoHandler.enable();
}
}
static void autoRecord() {
recordStart();
recordStatus = RecordStatus.RECORD_AUTO;
}
static void autoIdle() {
recordStop();
recordStatus = RecordStatus.IDLE_AUTO;
}
private static void recordStart() {
if (recordStatus.isTracing()) return;
recorder = new Recorder();
}
private static void recordStop() {
if (!recordStatus.isTracing()) return;
recorder.stopRecording();
}
public static RecordStatus getRecordStatus() {
return recordStatus;
}
public static int size() {
if (recorder == null) return 0;
return recorder.size();
}
public static long getStartTime() {
if (recorder == null) return 0;
return recorder.getStartTime();
}
public static void postClear() {
if (recorder == null) return;
recorder.postClear();
}
}

View File

@ -0,0 +1,55 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.tracer.record;
public enum RecordStatus {
RECORD("§aan", true, "§cTNT-Tracer muss gestoppt werden"),
RECORD_AUTO("§aan", true, "§cTNT-Tracer darf nicht aufnehmen"),
IDLE("§caus", false, "§cAuto-Tracer gestoppt"),
IDLE_AUTO("§eauto", false, "§aAuto-Tracer gestartet");
String name;
boolean tracing;
String autoMessage;
RecordStatus(String value, boolean tracing, String autoMessage) {
this.name = value;
this.tracing = tracing;
this.autoMessage = autoMessage;
}
public String getName() {
return name;
}
public boolean isTracing() {
return tracing;
}
public boolean isAutoTrace() {
return this == RECORD_AUTO || this == IDLE_AUTO;
}
public String getAutoMessage() {
return autoMessage;
}
}

View File

@ -0,0 +1,96 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.tracer.record;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.tracer.show.Record;
import de.steamwar.bausystem.tracer.show.StoredRecords;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.scheduler.BukkitTask;
import java.util.HashMap;
import java.util.Map;
public class Recorder implements Listener {
private static final World world = Bukkit.getWorlds().get(0);
private final Map<TNTPrimed, Record.TNTRecord> recordMap = new HashMap<>();
private final BukkitTask task;
private final Record record;
Recorder() {
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this::run, 1, 1);
record = new Record();
// To trace TNT initial positions with AutoTracer
run();
}
void stopRecording() {
HandlerList.unregisterAll(this);
task.cancel();
}
int size() {
return record.size();
}
long getStartTime() {
return record.getStartTime();
}
void postClear() {
record.clear();
recordMap.clear();
StoredRecords.add(record);
}
private void run() {
world.getEntitiesByClass(TNTPrimed.class).forEach(tntPrimed -> get(tntPrimed).add(tntPrimed));
}
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof TNTPrimed))
return;
TNTPrimed tntPrimed = (TNTPrimed) event.getEntity();
get(tntPrimed).explode(tntPrimed);
recordMap.remove(tntPrimed);
}
private Record.TNTRecord get(TNTPrimed tntPrimed) {
Record.TNTRecord tntRecord = recordMap.get(tntPrimed);
if (tntRecord != null)
return tntRecord;
tntRecord = this.record.spawn();
recordMap.put(tntPrimed, tntRecord);
return tntRecord;
}
}

View File

@ -0,0 +1,70 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.tracer.record;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.Bukkit;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.scheduler.BukkitTask;
public class TraceAutoHandler implements Listener {
/* This listener handles the en- and disabling of the Tracer in AUTO mode */
private BukkitTask task;
private int lastExplosion = 0; // Time since the last explosion in ticks
public void enable() {
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
}
public void disable() {
HandlerList.unregisterAll(this);
if (task != null) {
task.cancel();
task = null;
}
}
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (!(event.getEntity() instanceof TNTPrimed))
return;
lastExplosion = 0;
if (task == null) {
RecordStateMachine.autoRecord();
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this::run, 1, 1);
}
}
private void run() {
lastExplosion++;
if (lastExplosion > 80) {
RecordStateMachine.autoIdle();
task.cancel();
task = null;
}
}
}

View File

@ -0,0 +1,94 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.tracer.show;
import de.steamwar.bausystem.tracer.TNTPosition;
import org.bukkit.entity.TNTPrimed;
import java.util.ArrayList;
import java.util.List;
public class Record {
private final long startTime;
private final List<TNTRecord> tnt = new ArrayList<>();
public int size() {
return tnt.size();
}
public long getStartTime() {
return startTime;
}
public void showAll(ShowMode mode) {
for (TNTRecord record : tnt)
record.showAll(mode);
}
/* The following methods should only be called by a recorder */
public Record() {
startTime = System.currentTimeMillis();
StoredRecords.add(this);
}
public TNTRecord spawn() {
TNTRecord record = new TNTRecord();
tnt.add(record);
return record;
}
public void clear() {
tnt.clear();
}
public static class TNTRecord {
private final List<TNTPosition> positions = new ArrayList<>(41);
public void showAll(ShowMode mode) {
for (TNTPosition position : positions)
mode.show(position);
}
/* The following methods should only be called by a recorder */
public void add(TNTPrimed tntPrimed) {
add(tntPrimed, false);
}
private void add(TNTPrimed tntPrimed, boolean exploded) {
TNTPosition position;
if (positions.isEmpty()) {
position = new TNTPosition(this, tntPrimed, null, exploded);
} else {
position = new TNTPosition(this, tntPrimed, positions.get(positions.size() - 1).getLocation(), exploded);
}
positions.add(position);
TraceShowManager.show(position);
}
public void explode(TNTPrimed tntPrimed) {
add(tntPrimed, true);
}
public List<TNTPosition> getPositions() {
return positions;
}
}
}

View File

@ -0,0 +1,28 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.tracer.show;
import de.steamwar.bausystem.tracer.TNTPosition;
public interface ShowMode {
void show(TNTPosition position);
void hide();
}

View File

@ -0,0 +1,57 @@
/*
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* /
*/
package de.steamwar.bausystem.tracer.show;
public class ShowModeParameter {
private boolean water = false;
private boolean interpolate_Y = false;
private boolean interpolate_XZ = false;
public ShowModeParameter() {
}
public boolean isWater() {
return water;
}
public boolean isInterpolate_Y() {
return interpolate_Y;
}
public boolean isInterpolate_XZ() {
return interpolate_XZ;
}
public void setWater(boolean water) {
this.water = water;
}
public void setInterpolate_Y(boolean interpolate_Y) {
this.interpolate_Y = interpolate_Y;
}
public void setInterpolate_XZ(boolean interpolate_XZ) {
this.interpolate_XZ = interpolate_XZ;
}
}

View File

@ -0,0 +1,44 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.tracer.show;
import java.util.function.Consumer;
public enum ShowModeParameterType {
WATER(showModeParameter -> showModeParameter.setWater(true)),
INTERPOLATE_Y(showModeParameter -> showModeParameter.setInterpolate_Y(true)),
INTERPOLATE_XZ(showModeParameter -> showModeParameter.setInterpolate_XZ(true)),
ADVANCED(showModeParameter -> {
showModeParameter.setInterpolate_Y(true);
showModeParameter.setInterpolate_XZ(true);
});
private final Consumer<ShowModeParameter> showModeParameterConsumer;
public Consumer<ShowModeParameter> getShowModeParameterConsumer() {
return showModeParameterConsumer;
}
ShowModeParameterType(Consumer<ShowModeParameter> showModeParameterConsumer) {
this.showModeParameterConsumer = showModeParameterConsumer;
}
}

View File

@ -0,0 +1,45 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.tracer.show;
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
import java.util.ArrayList;
import java.util.List;
public class StoredRecords {
private static final List<Record> records = new ArrayList<>();
public static void add(Record record) {
records.add(record);
}
public static void showAll(ShowMode mode) {
for (Record record : records) record.showAll(mode);
}
public static void clear() {
records.clear();
TraceShowManager.clear();
RecordStateMachine.postClear();
}
}

View File

@ -0,0 +1,59 @@
package de.steamwar.bausystem.tracer.show;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.tracer.TNTPosition;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashMap;
import java.util.Map;
public class TraceShowManager implements Listener {
private TraceShowManager() {
}
private static final Map<Player, ShowMode> showModes = new HashMap<>();
public static void show(Player player, ShowMode showMode) {
hide(player);
showModes.put(player, showMode);
StoredRecords.showAll(showMode);
}
public static void hide(Player player) {
ShowMode showMode = showModes.remove(player);
if (showMode == null)
return;
showMode.hide();
}
/* Only to be called by record */
static void show(TNTPosition tnt) {
for (ShowMode mode : showModes.values())
mode.show(tnt);
}
/* Only to be called by StoredRecords */
static void clear() {
for (ShowMode mode : showModes.values())
mode.hide();
}
/* Internal if player leaves*/
static {
Bukkit.getPluginManager().registerEvents(new TraceShowManager(), BauSystem.getPlugin());
}
@EventHandler
public void onLeave(PlayerQuitEvent event) {
showModes.remove(event.getPlayer());
}
public static boolean hasActiveShow(Player player) {
return showModes.containsKey(player);
}
}

View File

@ -0,0 +1,120 @@
/*
*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* /
*/
package de.steamwar.bausystem.tracer.show.mode;
import de.steamwar.bausystem.CraftbukkitWrapper;
import de.steamwar.bausystem.FlatteningWrapper;
import de.steamwar.bausystem.tracer.AbstractTraceEntity;
import de.steamwar.bausystem.tracer.RoundedTNTPosition;
import de.steamwar.bausystem.tracer.TNTPosition;
import de.steamwar.bausystem.tracer.show.ShowMode;
import de.steamwar.bausystem.tracer.show.ShowModeParameter;
import org.bukkit.entity.Player;
import org.bukkit.util.Consumer;
import org.bukkit.util.Vector;
import java.util.HashMap;
import java.util.Map;
public class EntityShowMode implements ShowMode {
protected final Player player;
protected final ShowModeParameter showModeParameter;
private final Map<RoundedTNTPosition, AbstractTraceEntity> tntEntityMap = new HashMap<>();
private final Map<RoundedTNTPosition, AbstractTraceEntity> updateEntityMap = new HashMap<>();
public EntityShowMode(Player player, ShowModeParameter showModeParameter) {
this.player = player;
this.showModeParameter = showModeParameter;
}
@Override
public void show(TNTPosition position) {
if (!showModeParameter.isWater() && position.isExploded() && checkWater(position.getLocation())) {
// Basic
for (TNTPosition pos : position.getRecord().getPositions()) {
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(pos);
tntEntityMap.computeIfPresent(roundedTNTPosition, (p, tnt) -> {
return tnt.hide(player, false) ? null : tnt;
});
}
// Advanced
for (TNTPosition pos : position.getRecord().getPositions()) {
applyOnPosition(pos, updatePointPosition -> {
updateEntityMap.computeIfPresent(new RoundedTNTPosition(updatePointPosition), (p, point) -> {
return point.hide(player, false) ? null : point;
});
});
}
return;
}
RoundedTNTPosition roundedTNTPosition = new RoundedTNTPosition(position);
AbstractTraceEntity entity = tntEntityMap.computeIfAbsent(roundedTNTPosition, pos -> createEntity(player, position.getLocation(), true));
entity.display(player, position.isExploded());
applyOnPosition(position, updatePointPosition -> {
updateEntityMap.computeIfAbsent(new RoundedTNTPosition(updatePointPosition), pos -> {
return createEntity(player, updatePointPosition, false);
}).display(player, position.isExploded());
});
}
private boolean checkWater(Vector position) {
return FlatteningWrapper.impl.inWater(player.getWorld(), position);
}
public static AbstractTraceEntity createEntity(Player player, Vector position, boolean tnt) {
return CraftbukkitWrapper.impl.create(player.getWorld(), position, tnt);
}
private void applyOnPosition(TNTPosition position, Consumer<Vector> function) {
if (position.getPreviousLocation() == null) return;
if (showModeParameter.isInterpolate_Y()) {
Vector updatePointY = position.getPreviousLocation().clone().setY(position.getLocation().getY());
if (!position.getLocation().equals(updatePointY)) {
function.accept(updatePointY);
}
}
if (showModeParameter.isInterpolate_XZ()) {
Vector movement = position.getLocation().clone().subtract(position.getPreviousLocation());
Vector updatePointXZ = Math.abs(movement.getX()) > Math.abs(movement.getZ())
? position.getLocation().clone().setZ(position.getPreviousLocation().getZ())
: position.getLocation().clone().setX(position.getPreviousLocation().getX());
if (!position.getLocation().equals(updatePointXZ)) {
function.accept(updatePointXZ);
}
}
}
@Override
public void hide() {
tntEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
tntEntityMap.clear();
updateEntityMap.forEach((roundedTNTPosition, abstractTraceEntity) -> abstractTraceEntity.hide(player, true));
updateEntityMap.clear();
}
}

View File

@ -0,0 +1,56 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
public class AFKStopper implements Listener {
private static final String afkWarning = BauSystem.PREFIX + "§cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt";
private int minutesAfk;
public AFKStopper() {
minutesAfk = 0;
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), () -> {
switch (minutesAfk) {
case 5:
for (Player p : Bukkit.getOnlinePlayers())
p.kickPlayer("§cAuf diesem Server ist seit 5 Minuten nichts passiert.");
break;
case 4:
Bukkit.broadcastMessage(afkWarning);
default:
minutesAfk++;
}
}, 1200, 1200); //every minute
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
minutesAfk = 0;
}
}

View File

@ -0,0 +1,122 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.world;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.LinkedList;
abstract class AbstractAutoLoader {
abstract Player getPlayer();
abstract boolean setRedstone(Location location, boolean active);
abstract LinkedList<LoaderAction> getActions();
abstract void resetLastActivation();
abstract int getLastActivation();
void print(String message, boolean withSize){
if(withSize)
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message + " §8" + getActions().size()));
else
getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
}
abstract static class LoaderAction {
final Location location;
final AbstractAutoLoader loader;
LoaderAction(AbstractAutoLoader loader, Location location){
this.location = location;
this.loader = loader;
loader.getActions().add(this);
loader.resetLastActivation();
}
abstract boolean perform();
abstract int ticks();
}
static class RedstoneActivation extends LoaderAction{
final boolean active;
final int length;
int status;
RedstoneActivation(AbstractAutoLoader loader, Location location, int ticks, boolean active){
super(loader, location);
this.length = ticks;
this.active = active;
status = 0;
}
@Override
public boolean perform() {
status++;
if(status < length)
return false;
if(!loader.setRedstone(location, active))
return false;
status = 0;
return true;
}
@Override
int ticks() {
return 1;
}
}
static class TemporaryActivation extends LoaderAction{
final int length;
int status;
TemporaryActivation(AbstractAutoLoader loader, Location location, int ticks){
super(loader, location);
this.length = ticks;
status = 0;
}
@Override
public boolean perform() {
if(status == 0){
if(!loader.setRedstone(location, true))
return false;
}else if(status == length){
if(!loader.setRedstone(location, false))
return false;
status = 0;
return true;
}
status++;
return false;
}
@Override
int ticks() {
return 1;
}
}
}

View File

@ -0,0 +1,266 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.FlatteningWrapper;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitTask;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Map;
public class AutoLoader extends AbstractAutoLoader implements Listener {
private static final Map<Player, AutoLoader> players = new HashMap<>();
public static AutoLoader getLoader(Player player){
if(!players.containsKey(player))
return new AutoLoader(player);
return players.get(player);
}
public static boolean hasLoader(Player player){
return players.containsKey(player);
}
private final Player player;
private final BukkitTask task;
private final LinkedList<LoaderAction> actions = new LinkedList<>();
private int ticksBetweenShots = 80;
private int ticksBetweenBlocks = 1;
private int lastActivation;
private int waitTicks;
private ListIterator<LoaderAction> lastAction;
private boolean setup;
private Location lastLocation;
private AutoLoader(Player player){
this.player = player;
Bukkit.getPluginManager().registerEvents(this, BauSystem.getPlugin());
task = Bukkit.getScheduler().runTaskTimer(BauSystem.getPlugin(), this::run, 1, 1);
players.put(player, this);
player.sendMessage(BauSystem.PREFIX + "§7Schieße bitte einmal die Kanone ab");
player.sendMessage(BauSystem.PREFIX + "§7Und starte anschließend den AutoLader mit §8/§eloader start");
setup();
}
public void setup(){
print("§aAutoLader im Setup-Modus", false);
setup = true;
waitTicks = 0;
lastActivation = 0;
}
public void start(){
if(actions.isEmpty()){
print("§cKeine Aktion vorhanden", false);
return;
}
if(!setup){
print("§cAutoLader läuft bereits", false);
return;
}
setup = false;
waitTicks = 0;
lastActivation = 0;
lastAction = actions.listIterator();
print("§aAutoLader gestartet", false);
}
public void stop(){
print("§cAutoLader gestoppt", false);
players.remove(player);
HandlerList.unregisterAll(this);
if(task != null)
task.cancel();
}
public void undo(){
if(actions.isEmpty()){
print("§cKeine Aktion vorhanden", false);
return;
}
actions.removeLast();
print("§aUndo erfolgreich", true);
}
public void wait(int time){
if(time < 1){
print("§cDie Wartezeit ist zu klein", false);
return;
}
print("§aSchusswartezeit §e" + time + " §aTicks§8, zuvor " + ticksBetweenShots, false);
ticksBetweenShots = time;
}
public void blockWait(int time){
if(time < 1){
print("§cDie Wartezeit ist zu klein", false);
return;
}
print("§aSetzwartezeit §e" + time + " §aTicks§8, zuvor " + ticksBetweenBlocks, false);
ticksBetweenBlocks = time;
}
public int getTicksBetweenShots() {
return ticksBetweenShots;
}
public int getTicksBetweenBlocks() {
return ticksBetweenBlocks;
}
public boolean isSetup() {
return setup;
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event){
if(!setup || !event.getPlayer().equals(player))
return;
if(event.getBlock().getType() != Material.TNT)
return;
new TNTPlaceAction(this, event.getBlock().getLocation());
print("§eTNT platziert", true);
}
//BlockRedstoneEvent?
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event){
if (event.getAction() != Action.RIGHT_CLICK_BLOCK && event.getAction() != Action.PHYSICAL)
return;
if (event.getClickedBlock().getType() == Material.OBSERVER)
return;
if (event.getPlayer().isSneaking())
return;
if (!setup || !event.getPlayer().equals(player))
return;
Detoloader detoloader = FlatteningWrapper.impl.onPlayerInteractLoader(event);
if (detoloader == null || detoloader.getActivation() < 0) return;
if (lastLocation != null && lastLocation.distance(event.getClickedBlock().getLocation()) <= 1) return;
if (detoloader.useActive) {
new AbstractAutoLoader.RedstoneActivation(this, event.getClickedBlock().getLocation()
, detoloader.getActivation() == 0 ? getLastActivation() : detoloader.getActivation()
, detoloader.isActive());
} else {
new AbstractAutoLoader.TemporaryActivation(this, event.getClickedBlock().getLocation()
, detoloader.getActivation());
}
print(detoloader.addBack ? "§e" + detoloader.getBlock() + " betätigt" :
detoloader.getBlock(), detoloader.addBack);
lastLocation = event.getClickedBlock().getLocation();
}
@EventHandler
public void onLeave(PlayerQuitEvent event){
if(!event.getPlayer().equals(player))
return;
stop();
}
private void run(){
lastActivation++;
if(setup)
return;
while(lastActivation >= waitTicks){
lastActivation = 0;
LoaderAction action = lastAction.next();
if(action.perform()){
waitTicks = action.ticks();
}else{
waitTicks = 1;
lastAction.previous();
}
if(!lastAction.hasNext()){
lastAction = actions.listIterator();
waitTicks = ticksBetweenShots;
}
}
}
@Override
Player getPlayer() {
return player;
}
@Override
boolean setRedstone(Location location, boolean active){
return FlatteningWrapper.impl.setRedstone(location, active);
}
@Override
LinkedList<LoaderAction> getActions() {
return actions;
}
@Override
void resetLastActivation() {
lastActivation = 0;
}
@Override
int getLastActivation() {
return lastActivation;
}
class TNTPlaceAction extends AbstractAutoLoader.LoaderAction {
TNTPlaceAction(AbstractAutoLoader loader, Location location){
super(loader, location);
}
@Override
public boolean perform() {
return FlatteningWrapper.impl.tntPlaceActionPerform(location);
}
@Override
int ticks(){
return ticksBetweenBlocks;
}
}
}

View File

@ -0,0 +1,111 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.world;
import de.steamwar.bausystem.commands.CommandTPSLimiter;
import de.steamwar.bausystem.tracer.record.RecordStateMachine;
import de.steamwar.bausystem.world.regions.Region;
import de.steamwar.core.TPSWatcher;
import de.steamwar.scoreboard.SWScoreboard;
import de.steamwar.scoreboard.ScoreboardCallback;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
public class BauScoreboard implements Listener {
@EventHandler
public void handlePlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
SWScoreboard.impl.createScoreboard(player, new ScoreboardCallback() {
@Override
public HashMap<String, Integer> getData() {
return sidebar(player);
}
@Override
public String getTitle() {
return "§eSteam§8War";
}
});
}
private HashMap<String, Integer> sidebar(Player p) {
List<String> strings = new ArrayList<>();
strings.add("§1");
strings.add("§eUhrzeit§8: §7" + new SimpleDateFormat("HH:mm:ss").format(Calendar.getInstance().getTime()));
strings.add("§2");
Region region = Region.getRegion(p.getLocation());
strings.add("§eTNT§8: " + region.getTntMode().getName());
strings.add("§eFreeze§8: " + (region.isFreeze() ? "§aan" : "§caus"));
strings.add("§eFire§8: " + (region.isFire() ? "§aaus" : "§can"));
strings.add("§eTrace§8: " + RecordStateMachine.getRecordStatus().getName());
strings.add("§eLoader§8: " + (AutoLoader.hasLoader(p) ? "§aan" : "§caus"));
if (region.hasProtection()) {
strings.add("§eProtect§8: " + (region.isProtect() ? "§aan" : "§caus"));
}
if (RecordStateMachine.getRecordStatus().isTracing()) {
strings.add("§3");
strings.add("§eTicks§8: §7" + traceTicks());
strings.add("§eAnzahl TNT§8: §7" + RecordStateMachine.size());
}
strings.add("§4");
strings.add("§eTPS§8: " + tpsColor() + TPSUtils.getTps(TPSWatcher.TPSType.ONE_SECOND) + tpsLimit());
int i = strings.size();
HashMap<String, Integer> result = new HashMap<>();
for (String s : strings)
result.put(s, i--);
return result;
}
private long traceTicks() {
return (System.currentTimeMillis() - RecordStateMachine.getStartTime()) / 50;
}
private String tpsColor() {
double tps = TPSUtils.getTps(TPSWatcher.TPSType.ONE_SECOND);
if (tps > CommandTPSLimiter.getCurrentTPSLimit() * 0.9) {
return "§a";
}
if (tps > CommandTPSLimiter.getCurrentTPSLimit() * 0.5) {
return "§e";
}
return "§c";
}
private String tpsLimit() {
if (CommandTPSLimiter.getCurrentTPSLimit() == 20) {
return "";
}
return "§8/§7" + CommandTPSLimiter.getCurrentTPSLimit();
}
}

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