SteamWar/FightSystem
Archiviert
13
1

Commits vergleichen

...
Dieses Repository wurde am 2024-08-05 archiviert. Du kannst Dateien ansehen und es klonen, aber nicht pushen oder Issues/Pull-Requests öffnen.

134 Commits

Autor SHA1 Nachricht Datum
db23ae9cb6 Fix <1.12 schematic checking
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-25 21:31:29 +01:00
b9f0039025 Fix HullHider
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-22 20:36:27 +01:00
f5a150c203 Merge pull request '1.8 - 1.15 HullHider, fix Tab Hiding, fix appearing NameTags, improve Performance' (#419) from fixTagAndTab into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #419
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2024-03-22 15:31:29 +01:00
bffbd2cc06 1.8 - 1.15 HullHider, fix Tab Hiding, fix appearing NameTags, improve Performance
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
untested

Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-17 16:58:34 +01:00
abb7df4e5c Fix Entity HullHider for Referee
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-16 20:38:11 +01:00
df2ced027b Fix world reset race condition with TechHider
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-14 22:32:03 +01:00
5394adfd14 Merge pull request 'Configurable spectate port' (#418) from configurableSpectatePort into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #418
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2024-03-13 17:18:49 +01:00
52e3fd754e Merge pull request 'Block HullHider' (#416) from blockHullHider into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #416
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2024-03-13 17:13:37 +01:00
ac4babd44a Configurable spectate port
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-13 13:20:11 +01:00
447c8767f1 Merge pull request 'Allow multiple Referees per Event' (#417) from referee into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #417
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2024-03-13 13:08:59 +01:00
3bd54fcdbd Bugfixes, Block precise performance improvement
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-13 13:08:17 +01:00
0c947f0b5b Fix debug code
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-11 22:49:22 +01:00
c3bb34ed6b Performance and information hiding improvements (no unchanged hullhider blocks)
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-11 21:33:46 +01:00
e0659c1bb2 Bugfixes, Performance improvements
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-10 19:35:31 +01:00
f964f58d93 Allow multiple Referees per Event
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-09 19:19:42 +01:00
e3535c379a Block HullHider
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Untested

Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-07 12:54:13 +01:00
79413434f7 Fix WaterRemover TNT
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-03-05 16:17:55 +01:00
c17dc43678 Merge pull request 'Replace TNT on red side in check arenas' (#415) from noRedTntOnCheck into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #415
Reviewed-by: Chaoscaot <chaoscaot@zohomail.eu>
2024-02-13 10:50:34 +01:00
7d7b6226a0 Potential Border rejoin fix
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-02-11 19:13:47 +01:00
e0b6c1b931 Potential Border rejoin fix
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-02-11 18:55:32 +01:00
39bff371a4 Fix y border size for players
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-02-08 13:19:15 +01:00
470f8613cd Add logging to debug team area bugs
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-02-06 22:50:42 +01:00
46e3c383bd Replace TNT on red side in check arenas
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-02-06 22:11:01 +01:00
ace26a7750 Fix falling off AirShip during PRE_RUNNING
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-02-05 16:19:08 +01:00
33a84d6a66 Fix team leave
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-26 09:06:54 +01:00
75af1f00ba Fix respawn own Schematic collision
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-25 11:24:22 +01:00
2469f1bced Merge pull request 'Code cleanup, Utilize Lombok' (#414) from lombok into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #414
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2024-01-24 12:11:04 +01:00
5dfdb8e722 Code cleanup, Utilize Lombok
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-24 12:07:38 +01:00
0db80a56a6 Merge pull request 'Team Event API, Fancy Borders' (#413) from fancyBorder into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #413
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2024-01-24 12:05:03 +01:00
c8b9263b70 Fix behaviour during spectator phase
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-20 21:16:48 +01:00
ba475457db Fix Z and NormalJoin bug
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-20 19:18:09 +01:00
9d3516152d (Untested) Team Event API, Fancy Borders
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-20 18:42:22 +01:00
053152f392 Merge pull request '(Untested) Explosion, Particle and Sound Hider' (#410) from hullHider into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #410
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2024-01-20 17:52:07 +01:00
edc77ca2d4 Fix Name if leader null
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-20 17:51:44 +01:00
f5419a1a77 Fix Sound and Particle HullHider
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-20 16:45:03 +01:00
169649204a Merge pull request 'Better sound location' (#411) from betterSound into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #411
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2024-01-19 16:16:39 +01:00
e12a7ac7b4 Merge pull request 'Join request with leader names instead of team names' (#412) from leaderNameJoinRequest into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #412
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2024-01-19 16:16:32 +01:00
918f309625 Join request with leader names instead of team names
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-18 23:48:46 +01:00
965bba1ea5 Better sound location
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-18 23:45:28 +01:00
6d641856fe (Untested) Explosion, Particle and Sound Hider
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-18 01:16:56 +01:00
faebc3cace Fix WaterRemover: Iterate downwards
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-05 17:32:28 +01:00
5d9aa147b7 Fix WaterRemover: Remove empty blocklist check.
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-05 17:21:23 +01:00
ed1ab06ce1 Merge pull request 'Fix WaterRemover for Water based armor' (#409) from waterremover into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #409
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2024-01-05 16:42:52 +01:00
869b883b2f Fix WaterRemover for Water based armor
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-05 16:36:24 +01:00
0edbe4be94 Fix replay IllegalStateException
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-04 23:55:31 +01:00
90d8492d9a Merge pull request 'HullHider v2' (#408) from hullhiderv2 into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #408
Reviewed-by: YoyoNow <jwsteam@nidido.de>
Reviewed-by: Chaoscaot <chaoscaot@zohomail.eu>
2024-01-03 16:26:03 +01:00
7f9cfe73f7 Fix unchecked schematics at events
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-01 16:46:25 +01:00
7fab960315 Fix unchecked schematics at events
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2024-01-01 16:45:32 +01:00
c18de054a8 Merge branch 'master' into hullhiderv2
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-12-30 12:26:43 +01:00
6f4e0f0293 Replay REntity HullHider
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-30 12:26:11 +01:00
65028799b0 Correct HullHider behaviour for boarding
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-19 22:18:16 +01:00
9b78103592 Replay HullHider, Fix HullHider for players already online
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-19 16:40:12 +01:00
ce3384c7e9 Bugfixes, remove debug info
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-17 18:23:54 +01:00
8de15e0af5 Fix rotation of teamname display in gamemodes without schematic rotation
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-17 16:29:04 +01:00
5fab7e5404 Untested entity 1.18+ hullhiding
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-17 16:18:20 +01:00
4d5f4e9be6 Fast recursive 45° approx hullhider implementation
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-16 21:59:56 +01:00
29927985b1 Initial directional quadrant 45° hullhider implementation
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-16 18:21:33 +01:00
a17bd4c401 Fix imports
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-16 14:08:14 +01:00
5851d5019b Fix percent display
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-12 17:24:07 +01:00
5e8241605e Merge pull request 'Simplify percent system by adding entern percent and whitelist config toggles' (#406) from percentChange into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #406
Reviewed-by: D4rkr34lm <d4rkr34lm@steamwar.de>
2023-12-12 17:13:37 +01:00
0fb7a7b8ce Change percent damage display to damage health
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-12 12:48:56 +01:00
0a45b161a2 Simplify percent system by adding entern percent and whitelist config toggles
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-12 00:10:05 +01:00
yoyosource
4f65023491 Hotfix FightSchematic public choosing with no publics abailable in schematictype
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-12-05 15:36:40 +01:00
ad7a42a685 Merge pull request 'MultiSchemTypes' (#403) from MultiSchemTypes into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #403
Reviewed-by: Lixfel <lixfel@steamwar.de>
2023-12-05 15:21:22 +01:00
6396264194 Fix schem deleted bug
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-03 20:55:36 +01:00
75152abc0b Merge pull request 'Fix entern after reset' (#405) from entern-fix into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #405
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2023-12-03 20:28:03 +01:00
d140db2401 Fix entern after reset
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-12-03 20:26:04 +01:00
e8b263d841 Merge pull request 'Add pasting of non prepared schem on red side' (#404) from NonPreparedSchemOnRedSide into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #404
Reviewed-by: Lixfel <lixfel@steamwar.de>
2023-12-02 20:43:34 +01:00
yoyosource
2e8ad5301e Add pasting of non prepared schem on red side
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-12-02 20:03:48 +01:00
yoyosource
c08cec7cf2 Add pasting of non prepared schem on red side
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-12-02 16:02:30 +01:00
yoyosource
3ee7411591 Revert lowercase
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Fix SchematicType not used for checking available schematics
Fix leader not present to enable public only schem selection
2023-12-01 18:15:28 +01:00
yoyosource
c0665b1868 Fix non lower case SchematicType fromDB lookup
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Fix RankedEvent not being considered für ignore publics only
Fix using index 0 instead of i for creating of gui
Fix config.yml missing comment
2023-12-01 18:03:09 +01:00
yoyosource
8d77f4dcf4 Fix Fight.publicOnly method
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-12-01 16:19:55 +01:00
yoyosource
b3ad960973 Add MultiSchemType selection for GUI.preSchemDialog
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-12-01 16:14:37 +01:00
ad5a2d4a08 Document manualcheck option
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-11-29 16:40:10 +01:00
ef8cdef05c Distribute first TNT after 300s
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-11-29 15:47:48 +01:00
86de472fe0 Revert "Make Armor Mandatory in yaml kits."
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
This reverts commit a8112eccc8.
2023-11-29 15:35:33 +01:00
a8112eccc8 Make Armor Mandatory in yaml kits.
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-11-29 15:34:07 +01:00
70c86f40c6 Fix override
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-10-29 17:35:42 +01:00
61eb28f78e Fix double item drops
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-10-27 23:38:31 +02:00
7ad5a1dc22 Fix TNT Distribution
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-10-12 18:57:03 +02:00
256239c557 Merge pull request 'TPS Warp' (#402) from tpswarp into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #402
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2023-10-11 13:34:26 +02:00
c87bac641e TPS Warp
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-10-11 10:56:05 +02:00
3f78a595c2 Merge pull request 'Persistent Damage & TNT Distribution' (#401) from persistentDamage into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #401
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2023-10-10 17:57:19 +02:00
0c762e5624 TNT Distribution
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-10-08 18:21:19 +02:00
4b82ea9426 Persistent Damage Event
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-10-08 18:08:13 +02:00
7dd2cee635 Merge pull request 'Unchecked schematics' (#400) from unchecked into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #400
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2023-09-20 15:30:47 +02:00
2cb9c12e46 Fix item and item location
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-09-16 11:09:41 +02:00
230169e163 Unchecked schematics
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-09-15 20:50:39 +02:00
cbd5fe407f Fix Lockschem in Replays
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-09-09 18:45:41 +02:00
84be0b3244 Fix TestJoin
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-09-02 20:24:07 +02:00
5614f000ad Merge pull request 'Pathplanning' (#399) from lixfel-pathplanning into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #399
2023-09-02 20:22:52 +02:00
97113b1ae2 Implement planToAnywhere
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-09-02 20:21:51 +02:00
26f2fb2afd AI and Pathplanning fixes
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-09-02 20:11:47 +02:00
15e0fbde06 AI and Pathplanning fixes
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-09-02 19:58:47 +02:00
e7bb1e6669 Pathplanning
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-09-02 18:23:30 +02:00
4655dbe21b Merge pull request 'Add Repeater, Comparator and Lectern to interact method' (#398) from psirobot-ai into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #398
Reviewed-by: Lixfel <lixfel@steamwar.de>
2023-09-02 17:31:39 +02:00
PsiRobot
2ed5f5000d Fixed previous commmit
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-09-02 15:28:34 +00:00
PsiRobot
071b76a4ce Add Repeater, Comparator and Lectern to interact method
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-09-02 15:20:33 +00:00
891a26cc12 Fix 1.8 and 1.9
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-30 14:49:21 +02:00
f81a1e13b1 Merge pull request 'UserPerm' (#397) from userPerm into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #397
Reviewed-by: Chaoscaot <chaoscaot@zohomail.eu>
2023-08-30 12:08:28 +02:00
11a8d0a612 UserPerm
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-29 22:01:54 +02:00
58d1f69e1c Merge pull request 'AI API' (#396) from villager-ai into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #396
Reviewed-by: Chaoscaot <chaoscaot@zohomail.eu>
2023-08-29 21:51:45 +02:00
1cc247f6dd AI API
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-29 13:45:46 +02:00
d7b63841a1 AI API prototype
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-29 00:36:28 +02:00
a9453aa859 Rename for better clarity
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-28 23:35:02 +02:00
783474c958 WIP villager AI
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-28 23:31:00 +02:00
a24585e497 Potential posToChunk fix
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-27 15:20:16 +02:00
c7eba24ae6 Fight info command rename to fightinfo
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-25 21:59:46 +02:00
adeb4e1d32 Merge pull request 'Fight info command' (#395) from infoCommand into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #395
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2023-08-25 21:46:16 +02:00
09bc0d8fbb Fight info command
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-25 21:43:27 +02:00
1a8255e94c Do not replace Obsidian and Bedrock in prepare arenas
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-25 15:52:48 +02:00
19d12df834 Merge pull request 'Move Spawnoffset to GameMode config' (#394) from spawnoffset into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #394
Reviewed-by: Chaoscaot <chaoscaot@zohomail.eu>
2023-08-19 11:26:41 +02:00
13e1610f61 Move Spawnoffset to GameMode config
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-08-19 11:12:22 +02:00
0cad5fa3ae Fix /leader
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-07-01 22:06:21 +02:00
9da8e33360 Fix checking
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-25 21:40:06 +02:00
fd5db46700 Fix reset
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-25 21:06:35 +02:00
722a8748d5 Merge pull request 'join anytime' (#359) from joinAnytime into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #359
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2023-06-25 20:11:51 +02:00
89682fe044 Merge pull request '1.20 support' (#393) from 1.20 into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #393
2023-06-25 20:09:39 +02:00
5e4190ea75 Limit JoinAnytime to variable teams
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-25 20:07:41 +02:00
e9e1667de4 1.20 support
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-23 16:24:44 +02:00
cbb0dcf8eb Some of the requested changes
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-13 22:00:43 +02:00
43e63b4201 Bugfixes: Offline players, rejoining
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-06 18:44:17 +02:00
1a13446548 Merge pull request 'Fix item pickup and exploding chests' (#392) from itemFixes into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #392
Reviewed-by: Chaoscaot <chaoscaot@zohomail.eu>
2023-06-06 18:10:08 +02:00
72ef2bc486 Fix item pickup and exploding chests
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-06 18:08:18 +02:00
6081c5f565 Prevent players from switching teams
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-06 17:55:55 +02:00
1a2eabaea4 Bugfixes: No multiple player instances, spectator kit after death, confirmation message, allow request command while in team
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-06 11:47:37 +02:00
98a376a62b Bugfixes, Simplify UX to requests-Command
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-05 17:00:45 +02:00
0020b2b152 Fix build
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-05 16:10:41 +02:00
c91f22658b Merge branch 'master' into joinAnytime
# Conflicts:
#	FightSystem_Core/src/de/steamwar/fightsystem/FightSystem.properties
#	FightSystem_Core/src/de/steamwar/fightsystem/FightSystem_de.properties
#	FightSystem_Core/src/de/steamwar/fightsystem/countdown/EnternCountdown.java
#	FightSystem_Core/src/de/steamwar/fightsystem/fight/FightTeam.java
#	FightSystem_Core/src/de/steamwar/fightsystem/fight/HotbarKit.java
2023-06-05 16:08:57 +02:00
0fc36cea4e Lavaremover
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Signed-off-by: Lixfel <agga-games@gmx.de>
2023-06-03 14:19:10 +02:00
a708a12b99 Merge pull request 'Add Gradle Plugin' (#391) from gradle_plugin into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #391
Reviewed-by: YoyoNow <jwsteam@nidido.de>
2023-05-22 09:27:20 +02:00
Chaoscaot
f6bf5398a9 Add Gradle Plugin
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-05-21 20:53:50 +02:00
d82fa59ed4 WIP join anytime
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed
Signed-off-by: Lixfel <agga-games@gmx.de>
2022-08-04 17:33:53 +02:00
101 geänderte Dateien mit 3258 neuen und 1356 gelöschten Zeilen

Datei anzeigen

@ -39,7 +39,7 @@ public class CraftbukkitWrapper10 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) {
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();

Datei anzeigen

@ -39,7 +39,7 @@ public class CraftbukkitWrapper12 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) {
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();

Datei anzeigen

@ -46,6 +46,8 @@ dependencies {
implementation project(":FightSystem_9")
implementation project(":FightSystem_8")
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
compileOnly swdep("Spigot-1.14")
compileOnly swdep("WorldEdit-1.15")
compileOnly swdep("SpigotCore")

Datei anzeigen

@ -21,17 +21,31 @@ package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.core.Core;
import de.steamwar.fightsystem.Config;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.util.Map;
public class BlockIdWrapper14 implements BlockIdWrapper {
private static final Class<?> worldServer = Reflection.getClass("{nms.server.level}.WorldServer");
private static final Class<?> chunkProviderServer = Reflection.getClass("{nms.server.level}.ChunkProviderServer");
private static final Reflection.MethodInvoker getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
private static final Class<?> playerChunkMap = Reflection.getClass("{nms.server.level}.PlayerChunkMap");
private static final Reflection.FieldAccessor<?> getPlayerChunkMap = Reflection.getField(chunkProviderServer, playerChunkMap, 0);
private static final Reflection.FieldAccessor<? extends Map> entityTrackers = Core.getVersion() > 15 ? Reflection.getField(playerChunkMap, Int2ObjectMap.class, 0) : Reflection.getField(playerChunkMap, org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap.class, 0);
private static final Class<?> block = Reflection.getClass("{nms.world.level.block}.Block");
private static final Class<?> iBlockData = Reflection.getClass("{nms.world.level.block.state}.IBlockData");
private static final Class<?> blockPosition = Reflection.getClass("{nms.core}.BlockPosition");
private final Map trackers;
public BlockIdWrapper14() {
trackers = entityTrackers.get(getPlayerChunkMap.get(getChunkProvider.invoke(getWorldHandle.invoke(Config.world))));
}
private static final Reflection.MethodInvoker getCombinedId = Reflection.getTypedMethod(block, null, int.class, iBlockData);
private static final Reflection.MethodInvoker getNMS = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.CraftBlock"), "getNMS", iBlockData);
@Override
@ -40,11 +54,9 @@ public class BlockIdWrapper14 implements BlockIdWrapper {
}
private static final Reflection.MethodInvoker getByCombinedId = Reflection.getTypedMethod(block, null, iBlockData, int.class);
private static final Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle", worldServer);
private static final Reflection.ConstructorInvoker newBlockPosition = Reflection.getConstructor(blockPosition, int.class, int.class, int.class);
private static final Reflection.MethodInvoker getTypeAndData = Reflection.getMethod(worldServer, null, blockPosition, iBlockData, int.class);
private static final Reflection.MethodInvoker removeTileEntity = Reflection.getMethod(worldServer, Core.getVersion() > 15 ? "m" : "removeTileEntity", blockPosition);
private static final Reflection.MethodInvoker getChunkProvider = Reflection.getTypedMethod(worldServer, null, chunkProviderServer);
private static final Reflection.MethodInvoker flagDirty = Reflection.getMethod(chunkProviderServer, null, blockPosition);
@Override
public void setBlock(World world, int x, int y, int z, int blockState) {
@ -56,4 +68,28 @@ public class BlockIdWrapper14 implements BlockIdWrapper {
getTypeAndData.invoke(nworld, pos, blockData, 1042);
flagDirty.invoke(getChunkProvider.invoke(nworld), pos);
}
private static final Class<?> entityTracker = Reflection.getClass("{nms.server.level}.PlayerChunkMap$EntityTracker");
private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "b" : "updatePlayer", entityPlayer);
@Override
public void trackEntity(Player player, int entity) {
Object tracker = trackers.get(entity);
if(tracker != null)
updatePlayer.invoke(tracker, getPlayer.invoke(player));
}
private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTracker, Core.getVersion() > 15 ? "a" : "clear", entityPlayer);
@Override
public void untrackEntity(Player player, int entity) {
Object tracker = trackers.get(entity);
if(tracker != null)
clearPlayer.invoke(tracker, getPlayer.invoke(player));
}
private static final Reflection.MethodInvoker getMaterialByBlock = Reflection.getTypedMethod(Reflection.getClass("{obc}.util.CraftMagicNumbers"), "getMaterial", Material.class, block);
private static final Reflection.MethodInvoker getBlockByBlockData = Reflection.getTypedMethod(iBlockData, null, block);
@Override
public Material idToMaterial(int blockState) {
return (Material)getMaterialByBlock.invoke(null, getBlockByBlockData.invoke(getByCombinedId.invoke(null, blockState)));
}
}

Datei anzeigen

@ -38,7 +38,7 @@ public class CraftbukkitWrapper14 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) {
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();

Datei anzeigen

@ -55,7 +55,8 @@ public class FlatteningWrapper14 implements FlatteningWrapper {
@Override
public boolean removeWater(Block block) {
if(block.getType() == Material.WATER){
Material type = block.getType();
if(type == Material.WATER || type == Material.LAVA){
block.setType(Material.AIR);
return true;
}
@ -107,4 +108,9 @@ public class FlatteningWrapper14 implements FlatteningWrapper {
public boolean isCrouching(Player player) {
return player.getPose() == Pose.SWIMMING;
}
@Override
public void sendBlockChange(Player player, Block block, Material type) {
player.sendBlockChange(block.getLocation(), type.createBlockData());
}
}

Datei anzeigen

@ -38,7 +38,7 @@ public class CraftbukkitWrapper15 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) {
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();

Datei anzeigen

@ -48,6 +48,7 @@ dependencies {
compileOnly 'com.mojang:datafixerupper:4.0.26'
compileOnly 'io.netty:netty-all:4.1.68.Final'
compileOnly 'com.mojang:authlib:1.5.25'
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
compileOnly swdep("Spigot-1.18")
compileOnly swdep("WorldEdit-1.15")

Datei anzeigen

@ -0,0 +1,82 @@
/*
* 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/>.
*/
package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.Config;
import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.SectionPosition;
import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange;
import net.minecraft.world.level.block.state.IBlockData;
import org.bukkit.block.data.BlockData;
import java.util.ArrayList;
import java.util.List;
public class HullHiderWrapper18 implements HullHiderWrapper {
private static final Reflection.MethodInvoker getState = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.data.CraftBlockData"), "getState", IBlockData.class);
@Override
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
List<Object> blockdata = new ArrayList<>(changes.size());
changes.removeIf(change -> {
BlockData data = Config.world.getBlockData(change.getX(), change.getY(), change.getZ());
boolean unchanged = data.getMaterial() == Config.ObfuscateWith || Config.HiddenBlocks.contains(data.getMaterial());
if(!unchanged)
blockdata.add(getState.invoke(data));
return unchanged;
});
if(changes.isEmpty())
return null;
return generateBlockChangePacket(changes, blockdata.toArray());
}
private Object generateBlockChangePacket(List<Hull.IntVector> changes, Object[] blockdata) {
if(changes.size() > 1) {
Hull.IntVector section = changes.get(0);
section = new Hull.IntVector(section.getX() >> 4, section.getY() >> 4, section.getZ() >> 4);
int xOffset = 16*section.getX();
int yOffset = 16*section.getY();
int zOffset = 16*section.getZ();
short[] pos = new short[changes.size()];
for(int i = 0; i < changes.size(); i++) {
Hull.IntVector change = changes.get(i);
pos[i] = (short) (((change.getX()-xOffset) << 8) + ((change.getZ()-zOffset) << 4) + (change.getY()-yOffset));
}
return constructMultiBlockChange(section, pos, blockdata);
} else {
Hull.IntVector pos = changes.get(0);
return new PacketPlayOutBlockChange(new BlockPosition(pos.getX(), pos.getY(), pos.getZ()), (IBlockData) blockdata[0]);
}
}
protected Object constructMultiBlockChange(Hull.IntVector section, short[] pos, Object[] blockdata) {
return new PacketPlayOutMultiBlockChange(SectionPosition.a(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length), false);
}
}

52
FightSystem_20/build.gradle Normale Datei
Datei anzeigen

@ -0,0 +1,52 @@
/*
* 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/>.
*/
plugins {
id 'java'
}
group 'steamwar'
version '1.0'
compileJava.options.encoding = 'UTF-8'
sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceSets {
main {
java {
srcDirs = ['src/']
}
resources {
srcDirs = ['src/']
exclude '**/*.java', '**/*.kt'
}
}
}
dependencies {
implementation project(":FightSystem_Core")
implementation project(":FightSystem_18")
compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT'
compileOnly 'it.unimi.dsi:fastutil:8.5.6'
compileOnly swdep("Spigot-1.20")
}

Datei anzeigen

@ -1,7 +1,7 @@
/*
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
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
@ -15,13 +15,16 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
*/
package de.steamwar.fightsystem.winconditions;
package de.steamwar.fightsystem.utils;
public class WinconditionBlacklistPercent extends PercentWincondition {
import org.bukkit.entity.Entity;
public WinconditionBlacklistPercent(){
super("RelativePercent", Winconditions.RELATIVE_PERCENT);
public class CraftbukkitWrapper20 extends CraftbukkitWrapper18 {
@Override
public float headRotation(Entity e) {
return getEntity(e).cm();
}
}

Datei anzeigen

@ -0,0 +1,32 @@
/*
* 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/>.
*/
package de.steamwar.fightsystem.utils;
import it.unimi.dsi.fastutil.shorts.Short2ObjectArrayMap;
import net.minecraft.core.SectionPosition;
import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange;
public class HullHiderWrapper20 extends HullHiderWrapper18 {
@Override
protected Object constructMultiBlockChange(Hull.IntVector section, short[] pos, Object[] blockdata) {
return new PacketPlayOutMultiBlockChange(SectionPosition.a(section.getX(), section.getY(), section.getZ()), new Short2ObjectArrayMap<>(pos, blockdata, blockdata.length));
}
}

Datei anzeigen

@ -19,10 +19,25 @@
package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.Config;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public class BlockIdWrapper8 implements BlockIdWrapper {
private static final Class<?> entityTracker = Reflection.getClass("{nms}.EntityTracker");
private static final Reflection.FieldAccessor<?> getEntityTracker = Reflection.getField(worldServer, entityTracker, 0);
private static final Class<?> intHashMap = Reflection.getClass("{nms}.IntHashMap");
private static final Reflection.FieldAccessor<?> getTrackedEntities = Reflection.getField(entityTracker, intHashMap, 0);
private final Object trackers;
public BlockIdWrapper8() {
trackers = getTrackedEntities.get(getEntityTracker.get(getWorldHandle.invoke(Config.world)));
}
@Override
@SuppressWarnings("deprecation")
public int blockToId(Block block) {
@ -37,4 +52,31 @@ public class BlockIdWrapper8 implements BlockIdWrapper {
world.getBlockAt(x, y, z).setTypeIdAndData(blockState >> 4, (byte)(blockState & 0b1111), false);
}
private static final Class<?> entityTrackerEntry = Reflection.getClass("{nms}.EntityTrackerEntry");
private static final Reflection.MethodInvoker get = Reflection.getTypedMethod(intHashMap, "get", Object.class, int.class);
private static final Reflection.MethodInvoker updatePlayer = Reflection.getMethod(entityTrackerEntry, "updatePlayer", entityPlayer);
@Override
public void trackEntity(Player player, int entity) {
Object tracker = get.invoke(trackers, entity);
if(tracker != null)
updatePlayer.invoke(tracker, getPlayer.invoke(player));
}
private static final Reflection.MethodInvoker clearPlayer = Reflection.getMethod(entityTrackerEntry, "a", entityPlayer);
@Override
public void untrackEntity(Player player, int entity) {
Object tracker = get.invoke(trackers, entity);
if(tracker != null)
clearPlayer.invoke(tracker, getPlayer.invoke(player));
}
@Override
@SuppressWarnings("deprecation")
public Material idToMaterial(int blockState) {
if((blockState >> 4) > 256) // Illegal blockstate / corrupted replay
blockState = 0;
return Material.getMaterial(blockState >> 4);
}
}

Datei anzeigen

@ -37,7 +37,7 @@ public class FlatteningWrapper8 implements FlatteningWrapper {
@Override
public boolean isWater(Block block) {
Material type = block.getType();
return type == Material.WATER || type == Material.STATIONARY_WATER;
return type == Material.WATER || type == Material.STATIONARY_WATER || type == Material.LAVA || type == Material.STATIONARY_LAVA;
}
@Override
@ -83,4 +83,10 @@ public class FlatteningWrapper8 implements FlatteningWrapper {
public boolean isCrouching(Player player) {
return false;
}
@Override
@SuppressWarnings("deprecation")
public void sendBlockChange(Player player, Block block, Material type) {
player.sendBlockChange(block.getLocation(), type, (byte)0);
}
}

Datei anzeigen

@ -0,0 +1,55 @@
/*
* 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/>.
*/
package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.Config;
import org.bukkit.Material;
import java.util.List;
public class HullHiderWrapper8 implements HullHiderWrapper {
private static final Reflection.ConstructorInvoker newMultiBlockChange = Reflection.getConstructor("{nms}.PacketPlayOutMultiBlockChange", int.class, short[].class, Reflection.getClass("{nms}.Chunk"));
private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.CraftChunk", "getHandle");
@Override
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
changes.removeIf(change -> {
Material material = Config.world.getBlockAt(change.getX(), change.getY(), change.getZ()).getType();
return material == Config.ObfuscateWith || Config.HiddenBlocks.contains(material);
});
if(changes.isEmpty())
return null;
Hull.IntVector chunk = changes.get(0);
chunk = new Hull.IntVector(chunk.getX() >> 4, chunk.getY() >> 4, chunk.getZ() >> 4);
int xOffset = 16*chunk.getX();
int zOffset = 16*chunk.getZ();
short[] pos = new short[changes.size()];
for(int i = 0; i < changes.size(); i++) {
Hull.IntVector change = changes.get(i);
pos[i] = (short) (((change.getX()-xOffset) << 12) + ((change.getZ()-zOffset) << 8) + change.getY());
}
return newMultiBlockChange.invoke(pos.length, pos, getHandle.invoke(Config.world.getChunkAt(chunk.getX(), chunk.getZ())));
}
}

Datei anzeigen

@ -39,7 +39,7 @@ public class CraftbukkitWrapper9 implements CraftbukkitWrapper {
System.arraycopy(backupChunk.getSections(), 0, chunk.getSections(), 0, chunk.getSections().length);
System.arraycopy(backupChunk.heightMap, 0, chunk.heightMap, 0, chunk.heightMap.length);
w.tileEntityListTick.removeAll(chunk.tileEntities.values());
if (!FightWorld.isPaper()) {
if (!FightWorld.isPAPER()) {
w.tileEntityList.removeAll(chunk.tileEntities.values());
}
chunk.tileEntities.clear();

Datei anzeigen

@ -47,6 +47,9 @@ dependencies {
compileOnly 'io.netty:netty-all:4.1.68.Final'
compileOnly 'com.mojang:authlib:1.5.25'
compileOnly 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.30'
compileOnly swdep("WorldEdit-1.15")
compileOnly swdep("SpigotCore")
}

Datei anzeigen

@ -37,6 +37,11 @@ Arena:
Schem2Border:
x: 24 # defaults to 24 if missing
z: 24 # defaults to 24 if missing
# The offset the teams spawn relative to the center of their area
SpawnOffset:
x: 0 # defaults to 0 if missing
y: 0 # defaults to Schematic.Size.y if missing
z: 0 # defaults to 0 if missing
# The size of the team areas are expanded around the schematics
BorderFromSchematic: 12 # defaults to 12 if missing
# If ground walkable, teams can walk below the lower arena border during setup
@ -56,10 +61,14 @@ Schematic:
z: 0
# The schematic type that can be chosen in this arena
Type: Normal # defaults to Normal if missing
# The schematic types that are also allowed to be chosen in this arena
SubTypes: [] # defaults to empty List
# Shortcut of the schematic type
Shortcut: "" # defaults to "" if missing
# Spigot (1.8) material for GUIs
Material: STONE_BUTTON # defaults to STONE_BUTTON if missing
# Manual check of schematic necessary
ManualCheck: true # defaults to true if missing
# If the schematics should be rotated during pasting
Rotate: true # defaults to true if missing
# If the schematics should be pasted aligned to the borders instead of centered
@ -105,8 +114,6 @@ WinConditions: # defaults to none if missing
# - CAPTAIN_DEAD
# - PERCENT_SYSTEM
# - WHITELIST_PERCENT
# - RELATIVE_PERCENT
# - POINTS
# - POINTS_AIRSHIP
@ -116,12 +123,18 @@ WinConditions: # defaults to none if missing
# - HELLS_BELLS
# - METEOR
# - PERSISTENT_DAMAGE
# - TNT_DISTRIBUTION
WinConditionParams:
# The time of any of the timeout win conditions in seconds
TimeoutTime: 1200 # defaults to 1200 if missing
# The percentage when any of the percent win conditions limits or triggers a win
PercentWin: 7.0 # defaults to 7.0 if missing
# Does the percentage still change after the start of the enter phase
PercentEntern: true # defaults to true if missing
# Is Blocks a whitelist (true) or blacklist (false)
BlocksWhitelist: false # defaults to false if missing
# Special Blocks (Valid spigot material values) used by the percent win conditions
Blocks: [] # defaults to none if missing
@ -165,8 +178,3 @@ Techhider:
# x: 0 # defaults to 0 if missing
# y: 0 # defaults to 0 if missing
# z: 0 # defaults to Schematic.Size.z + 50 if missing
# # The offset the teams spawn relative to the center of their area
# SpawnOffset:
# x: 0 # defaults to 0 if missing
# y: 0 # defaults to Schematic.Size.y if missing
# z: 0 # defaults to 0 if missing

Datei anzeigen

@ -45,7 +45,8 @@ public enum ArenaMode {
public static final Set<ArenaMode> AntiEvent = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT)));
public static final Set<ArenaMode> AntiTestCheckPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE)));
public static final Set<ArenaMode> AntiPrepare = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(PREPARE)));
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY)));
public static final Set<ArenaMode> VariableTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY, CHECK)));
public static final Set<ArenaMode> ManualTeams = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(EVENT, REPLAY)));
public static final Set<ArenaMode> RankedEvent = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));
public static final Set<ArenaMode> Restartable = Collections.unmodifiableSet(EnumSet.of(NORMAL, TEST));
public static final Set<ArenaMode> NotRestartable = Collections.unmodifiableSet(EnumSet.of(EVENT, REPLAY));

Datei anzeigen

@ -21,10 +21,7 @@ package de.steamwar.fightsystem;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.winconditions.Winconditions;
import de.steamwar.sql.Event;
import de.steamwar.sql.EventFight;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.Team;
import de.steamwar.sql.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -83,6 +80,7 @@ public class Config {
public static final boolean OnlyPublicSchematics;
public static final boolean IgnorePublicOnly;
public static final de.steamwar.sql.SchematicType SchematicType;
public static final List<de.steamwar.sql.SchematicType> SubTypes;
public static final boolean RedRotate;
public static final boolean BlueRotate;
public static final boolean PasteAligned;
@ -106,6 +104,8 @@ public class Config {
//win condition parameters
public static final int TimeoutTime;
public static final double PercentWin;
public static final boolean PercentEntern;
public static final boolean PercentBlocksWhitelist;
public static final Set<Material> PercentBlocks;
//default kits
@ -117,13 +117,13 @@ public class Config {
//tech hider parameter
public static final boolean TechhiderActive;
public static final Set<String> HiddenBlocks;
public static final Set<Material> HiddenBlocks;
public static final Set<String> HiddenBlockEntities;
public static final String ObfuscateWith;
public static final Material ObfuscateWith;
//event parameter
private static final int EventKampfID;
public static final EventFight EventKampf;
private static final Set<Integer> Referees;
public static final int EventTeamBlueID;
public static final int EventTeamRedID;
public static final boolean BothTeamsPublic;
@ -138,10 +138,14 @@ public class Config {
//replay system parameter
public static final String spectateIP = "127.0.0.1";
public static final int spectatePort = 2222;
public static final int SpectatePort;
public static final int ReplayID;
static{
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
String configFile = System.getProperty("config", "config.yml");
if(!new File(FightSystem.getPlugin().getDataFolder(), configFile).exists()) {
FightSystem.getPlugin().saveDefaultConfig();
@ -181,6 +185,7 @@ public class Config {
int schemsizeZ = config.getInt("Schematic.Size.z");
RanksEnabled = !config.getStringList("Ranks").isEmpty();
SchematicType = de.steamwar.sql.SchematicType.fromDB(Objects.requireNonNull(config.getString("Schematic.Type", "normal")));
SubTypes = config.getStringList("Schematic.SubTypes").stream().map(de.steamwar.sql.SchematicType::fromDB).collect(Collectors.toList());
IgnorePublicOnly = config.getBoolean("Schematic.IgnorePublicOnly", false);
boolean rotate = config.getBoolean("Schematic.Rotate", true);
PasteAligned = config.getBoolean("Schematic.PasteAligned", false);
@ -195,6 +200,8 @@ public class Config {
TimeoutTime = config.getInt("WinConditionParams.TimeoutTime", 1200);
PercentWin = config.getDouble("WinConditionParams.PercentWin", 7.0);
PercentEntern = config.getBoolean("WinConditionParams.PercentEntern", true);
PercentBlocksWhitelist = config.getBoolean("WinConditionParams.BlocksWhitelist", false);
PercentBlocks = Collections.unmodifiableSet(config.getStringList("WinConditionParams.Blocks").stream().map(Material::valueOf).collect(Collectors.toSet()));
EnterStages = Collections.unmodifiableList(config.getIntegerList("EnterStages"));
@ -207,8 +214,8 @@ public class Config {
ForbiddenItems = Collections.unmodifiableSet(config.getStringList("Kits.ForbiddenItems").stream().map(Material::valueOf).collect(Collectors.toSet()));
TechhiderActive = config.getBoolean("Techhider.Active", false);
ObfuscateWith = config.getString("Techhider.ObfuscateWith", "end_stone").toUpperCase();
HiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks")));
ObfuscateWith = Material.getMaterial(config.getString("Techhider.ObfuscateWith", "end_stone").toUpperCase());
HiddenBlocks = config.getStringList("Techhider.HiddenBlocks").stream().map(String::toUpperCase).map(Material::getMaterial).collect(Collectors.toSet());
HiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
if(schemsizeX < 0){
@ -227,9 +234,9 @@ public class Config {
BlueToRedX = worldconfig.getInt("BlueToRed.x", 0);
BlueToRedY = worldconfig.getInt("BlueToRed.y", 0);
BlueToRedZ = worldconfig.getInt("BlueToRed.z", schemsizeZ + 50);
double teamBlueSpawnOffsetX = worldconfig.getDouble("SpawnOffset.x", 0);
double teamBlueSpawnOffsetY = worldconfig.getDouble("SpawnOffset.y", schemsizeY);
double teamBlueSpawnOffsetZ = worldconfig.getDouble("SpawnOffset.z", 0);
double teamBlueSpawnOffsetX = config.getDouble("Arena.SpawnOffset.x", 0);
double teamBlueSpawnOffsetY = config.getDouble("Arena.SpawnOffset.y", schemsizeY);
double teamBlueSpawnOffsetZ = config.getDouble("Arena.SpawnOffset.z", 0);
int teamRedCornerX = BlueToRedX + blueCornerX;
int teamRedCornerY = BlueToRedY + blueCornerY;
@ -303,25 +310,25 @@ public class Config {
RedRotate = teamRedRotate;
BlueRotate = teamBlueRotate;
RedPasteRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
BluePasteRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
RedPasteRegion = Region.fromSize(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ);
BluePasteRegion = Region.fromSize(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ);
RedExtendRegion = new Region(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
BlueExtendRegion = new Region(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
ArenaRegion = new Region(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX - arenaMinX, world.getMaxHeight() - underBorder, arenaMaxZ - arenaMinZ);
RedExtendRegion = Region.withExtension(teamRedCornerX, teamRedCornerY, teamRedCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
BlueExtendRegion = Region.withExtension(blueCornerX, blueCornerY, blueCornerZ, schemsizeX, schemsizeY, schemsizeZ, PreperationArea, PreperationArea, PreperationArea);
ArenaRegion = Region.withExtension(arenaMinX, blueCornerY, arenaMinZ, arenaMaxX - arenaMinX, schemsizeY, arenaMaxZ - arenaMinZ, 0, PreperationArea, 0);
PlayerRegion = new Region(arenaMinX, underBorder, arenaMinZ, arenaMaxX, world.getMaxHeight(), arenaMaxZ);
EventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
if(EventKampfID >= 1){
EventFight eventFight = EventFight.get(EventKampfID);
if(eventFight == null){
int eventKampfID = Integer.parseInt(System.getProperty("fightID", "0"));
if(eventKampfID >= 1){
EventKampf = EventFight.get(eventKampfID);
if(EventKampf == null){
Bukkit.getLogger().log(Level.SEVERE, "Failed to load EventFight");
Bukkit.shutdown();
}
assert eventFight != null;
Team team1 = Team.get(eventFight.getTeamBlue());
Team team2 = Team.get(eventFight.getTeamRed());
assert EventKampf != null;
Team team1 = Team.get(EventKampf.getTeamBlue());
Team team2 = Team.get(EventKampf.getTeamRed());
if(team1 == null || team2 == null){
Bukkit.getLogger().log(Level.SEVERE, "Failed to load Team");
@ -337,9 +344,11 @@ public class Config {
EventTeamBlueID = team1.getTeamId();
EventTeamRedID = team2.getTeamId();
BothTeamsPublic = EventTeamRedID == 0 && EventTeamBlueID == 0;
EventKampf = eventFight;
SpectatePort = EventKampf.getSpectatePort();
LiveReplay = SpectatePort != 0;
Referees = Referee.get(Config.EventKampf.getEventID());
Event event = Event.get(eventFight.getEventID());
Event event = Event.get(EventKampf.getEventID());
if(BothTeamsPublic) {
OnlyPublicSchematics = true;
MaximumTeamMembers = Integer.MAX_VALUE;
@ -347,7 +356,6 @@ public class Config {
OnlyPublicSchematics = event.publicSchemsOnly();
MaximumTeamMembers = event.getMaximumTeamMembers();
}
LiveReplay = event.spectateSystem();
}else{
//No event
TeamRedColor = config.getString("Red.Prefix", "§c");
@ -359,8 +367,10 @@ public class Config {
EventTeamRedID = 0;
EventKampf = null;
BothTeamsPublic = true;
Referees = Collections.emptySet();
MaximumTeamMembers = Integer.MAX_VALUE;
LiveReplay = false;
SpectatePort = -ReplayID;
}
String blueLeader = System.getProperty("blueLeader", null);
@ -374,17 +384,13 @@ public class Config {
else
RedLeader = null;
CheckSchemID = Integer.parseInt(System.getProperty("checkSchemID", "0"));
PrepareSchemID = Integer.parseInt(System.getProperty("prepareSchemID", "0"));
ReplayID = Integer.parseInt(System.getProperty("replay", "0"));
if(CheckSchemID != 0){
mode = ArenaMode.CHECK;
}else if(PrepareSchemID != 0){
mode = ArenaMode.PREPARE;
}else if(EventKampfID >= 1){
}else if(eventKampfID >= 1){
mode = ArenaMode.EVENT;
}else if(EventKampfID == -1){
}else if(eventKampfID == -1){
mode = ArenaMode.TEST;
}else if(ReplayID != 0){
mode = ArenaMode.REPLAY;
@ -397,15 +403,13 @@ public class Config {
return ArenaMode.Test.contains(mode);
}
public static boolean replayserver(){
return ReplayID == -1;
return ReplayID < 0;
}
public static boolean blueNegZ(){
return BlueToRedZ > 0;
}
public static boolean isReferee(Player player) {
if(EventKampf == null)
return false;
return SteamwarUser.get(player.getUniqueId()).getId() == EventKampf.getKampfleiter();
return Referees.contains(SteamwarUser.get(player.getUniqueId()).getId());
}
}

Datei anzeigen

@ -25,30 +25,39 @@ import de.steamwar.fightsystem.commands.*;
import de.steamwar.fightsystem.countdown.*;
import de.steamwar.fightsystem.event.HellsBells;
import de.steamwar.fightsystem.event.Meteor;
import de.steamwar.fightsystem.event.PersistentDamage;
import de.steamwar.fightsystem.event.TNTDistributor;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.FightWorld;
import de.steamwar.fightsystem.fight.HotbarKit;
import de.steamwar.fightsystem.listener.Shutdown;
import de.steamwar.fightsystem.listener.*;
import de.steamwar.fightsystem.record.*;
import de.steamwar.fightsystem.record.FileRecorder;
import de.steamwar.fightsystem.record.FileSource;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.record.LiveRecorder;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.winconditions.*;
import de.steamwar.message.Message;
import de.steamwar.sql.SchematicNode;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
public class FightSystem extends JavaPlugin {
@Getter
private static FightSystem plugin;
private Message message;
private FightTeam lastWinner;
private String lastWinreason;
private TechHiderWrapper techHider;
private HullHider hullHider;
@Override
public void onLoad() {
@ -75,7 +84,6 @@ public class FightSystem extends JavaPlugin {
});
new Chat();
new ArenaBorder();
new TeamArea();
new IngameDeath();
new InFightDamage();
new InFightInventory();
@ -92,16 +100,18 @@ public class FightSystem extends JavaPlugin {
new RunningWorldInteraction();
new PersonalKitCreator();
new ArrowStopper();
new ArrowPickup();
new StateDependentListener(ArenaMode.All, FightState.All, BountifulWrapper.impl.newDenyArrowPickupListener());
new BlockFadeListener();
new LeaveableArena();
new ClickAnalyzer();
new BlockPlaceCollision();
new HotbarKit.HotbarKitListener();
new JoinRequestListener();
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
new EnterHandler();
techHider = new TechHiderWrapper();
hullHider = new HullHider();
new FightWorld();
new FightUI();
new FightStatistics();
@ -111,9 +121,7 @@ public class FightSystem extends JavaPlugin {
new WinconditionCaptainDead();
new WinconditionBlocks(Winconditions.WATER_TECH_KO, "WaterTechKO", "BAR_WATER", FlatteningWrapper.impl::isWater);
new WinconditionBlocks(Winconditions.PUMPKIN_TECH_KO, "PumpkinTechKO", "BAR_CANNONS", block -> block.getType() == WinconditionBlocks.PUMPKIN_LANTERN);
new WinconditionPercentSystem();
new WinconditionBlacklistPercent();
new WinconditionWhitelistPercent();
new WinconditionPercent(Winconditions.PERCENT_SYSTEM, "Percent");
new WinconditionPoints();
new WinconditionPointsAirShip();
new WinconditionTimeout();
@ -124,6 +132,8 @@ public class FightSystem extends JavaPlugin {
new HellsBells();
new Meteor();
new PersistentDamage();
new TNTDistributor();
new WinconditionAmongUs();
new NoPlayersOnlineCountdown();
@ -136,18 +146,18 @@ public class FightSystem extends JavaPlugin {
new LeaveCommand();
new KitCommand();
new RemoveCommand();
new AcceptCommand();
new RequestsCommand();
new InfoCommand();
new WGCommand();
new TBCommand();
new DeclineCommand();
new GamemodeCommand();
new InviteCommand();
new ReadyCommand();
new AkCommand();
new LeaderCommand();
new LockschemCommand();
new StateCommand();
new SkipCommand();
new TPSWarpCommand();
new UnrankCommand();
new WinCommand();
@ -159,7 +169,15 @@ public class FightSystem extends JavaPlugin {
if(Config.mode == ArenaMode.EVENT) {
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
}else if(Config.mode == ArenaMode.CHECK){
Fight.getBlueTeam().setSchem(SchematicNode.getSchematicNode(Config.CheckSchemID));
SchematicNode checkSchematicNode = SchematicNode.getSchematicNode(Config.CheckSchemID);
Fight.getBlueTeam().setSchem(checkSchematicNode);
if (checkSchematicNode.getName().endsWith("-prepared")) {
SchematicNode unpreparedSchematicNode = SchematicNode.getSchematicNode(checkSchematicNode.getOwner(), checkSchematicNode.getName().substring(0, checkSchematicNode.getName().length() - 9), checkSchematicNode.getParent());
if (unpreparedSchematicNode != null) {
Fight.getRedTeam().setSchem(unpreparedSchematicNode);
}
}
}else if(Config.mode == ArenaMode.PREPARE) {
Fight.getUnrotated().setSchem(SchematicNode.getSchematicNode(Config.PrepareSchemID));
}
@ -179,15 +197,6 @@ public class FightSystem extends JavaPlugin {
FightState.setFightState(FightState.SPECTATE);
}
public static FightSystem getPlugin() {
return plugin;
}
public static void broadcast(String msg, Object... params) {
getMessage().broadcast(msg, params);
GlobalRecorder.getInstance().system(msg, params);
}
public static Message getMessage() {
return plugin.message;
}
@ -204,6 +213,10 @@ public class FightSystem extends JavaPlugin {
return plugin.techHider;
}
public static HullHider getHullHider() {
return plugin.hullHider;
}
public static void shutdown() {
//Staggered kick to prevent lobby overloading
if(Bukkit.getOnlinePlayers().isEmpty()){

Datei anzeigen

@ -25,13 +25,6 @@ FIGHT_ALREADY_STARTED=§cThe fight already started
NOT_LEADER=§cYou aren't a leader
PLAYER_UNAVAILABLE=§cThe player is not in an arena
NO_INVITATION=§cYou weren't invited by any team
INVITATION_DECLINED=§cInvitation declined
INVITATION_DECLINED_TEAM=§e{0} §chas declined the invitation
PLAYER_IN_TEAM=§e{0} §cis already in a team
ALREADY_INVITED=§e{0} §cwas invited
INVITATION_SENT=§e{0} §7invited
NOT_IN_TEAM=§e{0} §cis not in your team
KIT_UNAVAILABLE=§cThis kit does not exist
@ -41,8 +34,6 @@ GAMEMODE_NOT_ALLOWED=§cChanging gamemode is not permitted
GAMEMODE_UNKNOWN=§cUnknown gamemode {0}
GAMEMODE_HELP=§8/§7gm §8[§egamemode§8]
INVITE_HELP=§8/§einvite §8[§eplayer§8]
LEADER_FULL=§cAll teams already have a leader
ALREADY_IN_TEAM=§cYou are already in a team
@ -56,14 +47,15 @@ REMOVE_HELP=§8/§eremove §8[§eplayer§8]
NOT_FIGHTLEADER=§cYou are not the fight leader
WIN_HELP=§8/§7win §8[§eteam §8or §etie§8]
INFO_RANKED=§7Ranked§8: §e{0}
INFO_LEADER=§7Leader {0}§8: {1}
INFO_SCHEMATIC=§7Schematic {0}§8: §e{1} §7from {2}, Rank: {3}
TPSWARP_HELP=§8/§7tpswarp §8[§eticks per second§8]
TPSWARP_SET=§7TPS set to §e{0}
# GUI
INVITATION_TITLE=Invitation from {0}
INVITATION_ACCEPT=§aAccept
INVITATION_DECLINE=§cDecline
INVITATION_CHAT_ACCEPT=§8/§aaccept§8, §7to §aaccept§7 the invitation
INVITATION_CHAT_DECLINE=§8/§cdecline§8, §7to §cdecline§7 the invitation
STATE_TITLE=Fight state
STATE_PRE_LEADER_SETUP=§7Team leader waiting phase
STATE_PRE_SCHEM_SETUP=§7Schematic selection phase
@ -73,8 +65,6 @@ STATE_RUNNING=§eFighting phase
STATE_SPECTATE_WIN=§7Victory {0}
STATE_SPECTATE_TIE=§7Draw
INVITE_TITLE=Invite player
REMOVE_TITLE=Kick player
KIT_SELECTION_TITLE=Kit selection
@ -88,6 +78,7 @@ KITSEARCH_TITLE=Search for kit
SCHEM_NO_ENEMY=§cNo schematic selection without an opponent
SCHEM_TITLE={0} selection
SCHEM_PUBLIC=§ePublic {0}
SCHEM_UNCHECKED=§eUnchecked {0}
SCHEM_PRIVATE=§ePrivate {0}
SCHEM_NO_PRIVATE=§7No private {0} present
SCHEM_PRIVATE_FORBIDDEN=§7No private {0} allowed
@ -112,6 +103,7 @@ SPECTATE_COUNTDOWN=until the arena is reset
# Fight
SCHEMATIC_UNLOADABLE=§cUnable to load schematic
SCHEMATIC_CHOSEN=§7{0} §e{1} §7chosen
SCHEMATIC_UNCHECKED=§7Team {0} §7has chosen an §eunchecked §7schematic§8!
TEAM_READY=§aTeam ready
TEAM_NOT_READY=§c§mTeam ready
SKIP_READY=§aSkipping to next event
@ -119,7 +111,6 @@ SKIP_NOT_READY=§c§mSkipping to next event
TEAM_CHAT={0}{1}§8» {0}{2}
CHOOSE_KIT=§eChoose kit
RESPAWN=§eRespawn
INVITE_PLAYERS=§eInvite player
REMOVE_PLAYERS=§cKick player
CHOOSE_SCHEMATIC=§eChoose {0}
SCHEMATIC_REQUIRED=§cChoose a schematic first
@ -244,3 +235,22 @@ WIN_CREWMATE_DEAD={0} §7killed all team mates
AMONG_US_IMPOSTER_MESSAGE = §4You are the Imposter§8! §7Kill all your team mates to win the game!
AMONG_US_IMPOSTER_AMONG_MESSAGE = §4There is an Imposter among us§8! §7Kill him to win the game!
# Invites
JOIN_REQUEST=§7Request join
JOIN_REQUEST_TITLE=Request join
JOIN_REQUEST_ALREADY=§cYou have already sent a join request
JOIN_REQUEST_TEAM=§7Join {0}
JOIN_REQUEST_CONFIRMATION=§7Join request submitted
JOIN_REQUEST_NOTIFICATION=§e{0} §7requests joining team {1}§8. §7Accept or decline using §8/§erequests
REQUESTS=§7Open join requests
REQUESTS_TITLE=Open join requests
REQUEST_DECLINED=§cJoin of {0} declined
REQUEST_YOUR_DECLINED=§cYour join request was declined
REQUESTS_LEFT_CLICK=§eLeft click §7to §eaccept§8!
REQUESTS_RIGHT_CLICK=§eRight click §7to §edecline§8!
NO_JOIN_REQUEST=§cThe player did not request joining
NO_CONFIRMATION=§cNo confirmation necessary

Datei anzeigen

@ -23,13 +23,6 @@ FIGHT_ALREADY_STARTED=§cDer Kampf hat bereits begonnen
NOT_LEADER=§cDu bist kein Leader
PLAYER_UNAVAILABLE=§cDer Spieler ist nicht in der Arena
NO_INVITATION=§cDu wurdest von keinem Team eingeladen
INVITATION_DECLINED=§cEinladung abgelehnt
INVITATION_DECLINED_TEAM=§e{0} §chat die Einladung abgelehnt
PLAYER_IN_TEAM=§e{0} §cist bereits in einem Team
ALREADY_INVITED=§e{0} §cwurde bereits eingeladen
INVITATION_SENT=§e{0} §7eingeladen
NOT_IN_TEAM=§e{0} §cist nicht in deinem Team
KIT_UNAVAILABLE=§cDieses Kit gibt es nicht
@ -39,8 +32,6 @@ GAMEMODE_NOT_ALLOWED=§cSpielmodusänderung verboten
GAMEMODE_UNKNOWN=§cUnbekannter Spielmodus {0}
GAMEMODE_HELP=§8/§7gm §8[§eSpielmodus§8]
INVITE_HELP=§8/§einvite §8[§eSpieler§8]
LEADER_FULL=§cAlle Teams haben bereits einen Leader
ALREADY_IN_TEAM=§cDu bist bereits in einem Team
@ -54,14 +45,11 @@ REMOVE_HELP=§8/§eremove §8[§eSpieler§8]
NOT_FIGHTLEADER=§cDu bist nicht Kampfleiter
WIN_HELP=§8/§7win §8[§eTeam §8oder §etie§8]
TPSWARP_HELP=§8/§7tpswarp §8[§eTicks pro Sekunde§8]
TPSWARP_SET=§7TPS auf §e{0} §7gesetzt
# GUI
INVITATION_TITLE=Einladung von {0}
INVITATION_ACCEPT=§aAnnehmen
INVITATION_DECLINE=§cAblehnen
INVITATION_CHAT_ACCEPT=§8/§aaccept§8, §7um die Einladung §aanzunehmen
INVITATION_CHAT_DECLINE=§8/§cdecline§8, §7um die Einladung §cabzulehnen
STATE_TITLE=Kampfstatus
STATE_PRE_LEADER_SETUP=§7Teamleaderwartephase
STATE_PRE_SCHEM_SETUP=§7Schemauswahlphase
@ -71,8 +59,6 @@ STATE_RUNNING=§eKampfphase
STATE_SPECTATE_WIN=§7Sieg {0}
STATE_SPECTATE_TIE=§7Unentschieden
INVITE_TITLE=Spieler einladen
REMOVE_TITLE=Spieler rauswerfen
KIT_SELECTION_TITLE=Kitauswahl
@ -86,6 +72,7 @@ KITSEARCH_TITLE=Nach Kit suchen
SCHEM_NO_ENEMY=§cKeine Schematicwahl ohne Gegner
SCHEM_TITLE={0}-Auswahl
SCHEM_PUBLIC=§eÖffentliches {0}
SCHEM_UNCHECKED=§eUngeprüftes {0}
SCHEM_PRIVATE=§ePrivates {0}
SCHEM_NO_PRIVATE=§7Kein privates {0} vorhanden
SCHEM_PRIVATE_FORBIDDEN=§7Kein privates {0} erlaubt
@ -110,13 +97,13 @@ SPECTATE_COUNTDOWN=bis die Arena zurückgesetzt wird
# Fight
SCHEMATIC_UNLOADABLE=§cSchematic konnte nicht geladen werden
SCHEMATIC_CHOSEN=§7{0} §e{1} §7gewählt
SCHEMATIC_UNCHECKED=§7Team {0} §7hat eine §eungeprüfte §7Schematic gewählt§8!
TEAM_READY=§aTeam bereit
TEAM_NOT_READY=§c§mTeam bereit
SKIP_READY=§aBeschleunigung zum nächsten Event
SKIP_NOT_READY=§c§mBeschleunigung zum nächsten Event
CHOOSE_KIT=§eKit wählen
RESPAWN=§eRespawn
INVITE_PLAYERS=§eSpieler einladen
REMOVE_PLAYERS=§cSpieler rauswerfen
CHOOSE_SCHEMATIC=§e{0} wählen
SCHEMATIC_REQUIRED=§cZuerst muss eine Schematic gewählt sein
@ -228,4 +215,22 @@ WIN_IMPOSTER_DEAD={0} §7 hat den Imposter getötet
WIN_CREWMATE_DEAD={0} §7 hat alle Kameraden getötet
AMONG_US_IMPOSTER_MESSAGE = §4Du bist ein Imposter§8! §7Du musst alle Kameraden töten, um zu gewinnen.
AMONG_US_IMPOSTER_AMONG_MESSAGE = §4Es ist ein Imposter unter uns§8! §7Tötet ihn, um das Spiel zu gewinnen!
AMONG_US_IMPOSTER_AMONG_MESSAGE = §4Es ist ein Imposter unter uns§8! §7Tötet ihn, um das Spiel zu gewinnen!
# Invites
JOIN_REQUEST=§7Teambeitritt anfragen
JOIN_REQUEST_TITLE=Teambeitritt anfragen
JOIN_REQUEST_ALREADY=§cDu hast bereits ein Team um Beitritt angefragt
JOIN_REQUEST_TEAM={0} §7beitreten
JOIN_REQUEST_CONFIRMATION=§7Teambeitritt angefragt
JOIN_REQUEST_NOTIFICATION=§e{0} §7möchte Team {1} §7beitreten§8. §7Akzeptiere oder lehne ab mit §8/§erequests
REQUESTS=§7Offene Beitrittsanfragen
REQUESTS_TITLE=Offene Beitrittsanfragen
REQUEST_DECLINED=§cBeitritt von {0} abgelehnt
REQUEST_YOUR_DECLINED=§cDeine Betrittsanfrage wurde abgelehnt
REQUESTS_LEFT_CLICK=§eLinksklick §7um §eanzunehmen§8!
REQUESTS_RIGHT_CLICK=§eRechtsklick §7um §eabzulehnen§8!
NO_JOIN_REQUEST=§cDer Spieler hat noch keinen Beitritt angefragt
NO_CONFIRMATION=§cKeine Zustimmung nötig

Datei anzeigen

@ -0,0 +1,294 @@
/*
* 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.fightsystem.ai;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.listener.Chat;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Note;
import org.bukkit.block.Block;
import org.bukkit.block.Lectern;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Openable;
import org.bukkit.block.data.Powerable;
import org.bukkit.block.data.type.Comparator;
import org.bukkit.block.data.type.NoteBlock;
import org.bukkit.block.data.type.Repeater;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.Villager;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
import java.util.*;
import java.util.logging.Level;
public abstract class AI {
private static final Map<UUID, AI> ais = new HashMap<>();
static {
new OneShotStateDependent(ArenaMode.All, FightState.Spectate, () -> {
ais.values().forEach(AI::stop);
ais.clear();
});
}
public static AI getAI(UUID uuid) {
return ais.get(uuid);
}
private final FightTeam team;
private final LivingEntity entity;
private final BukkitTask task;
private final Queue<Action> queue = new ArrayDeque<>();
protected AI(FightTeam team, SteamwarUser user) {
this.team = team;
entity = (LivingEntity) Config.world.spawnEntity(Config.SpecSpawn, EntityType.VILLAGER);
entity.setCustomName(user.getUserName());
((Villager)entity).setAware(false);
task = Bukkit.getScheduler().runTaskTimer(FightSystem.getPlugin(), this::run, 1, 1);
ais.put(entity.getUniqueId(), this);
team.addMember(entity, user);
}
public abstract SchematicNode chooseSchematic();
public boolean acceptJoinRequest(Player player, FightTeam team) {
return true;
}
protected abstract void plan();
public void stop() {
if(!entity.isDead())
entity.remove();
if(!task.isCancelled())
task.cancel();
}
public LivingEntity getEntity() {
return entity;
}
protected void setReady() {
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
return;
if(team.getLeader().getEntity() != entity)
return;
team.setReady(true);
}
protected void chat(String message) {
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + "» " + message);
Chat.broadcastChat("PARTICIPANT_CHAT", team.getColoredName(), entity.getName(), message);
}
protected Vector getPosition() {
Location location = entity.getLocation();
Region extend = team.getExtendRegion();
if(Fight.getUnrotated() == team)
return new Vector(
location.getX() - extend.getMinX(),
location.getY() - team.getSchemRegion().getMinY(),
location.getZ() - extend.getMinZ()
);
else
return new Vector(
extend.getMaxX() - location.getX(),
location.getY() - team.getSchemRegion().getMinY(),
extend.getMaxZ() - location.getZ()
);
}
protected Material getBlock(Vector pos) {
queue.add(new Action(1));
return translate(pos, true).getBlock().getType();
}
protected boolean isPowered(Vector pos) {
queue.add(new Action(1));
return translate(pos, true).getBlock().isBlockPowered();
}
protected void setTNT(Vector pos) {
queue.add(new Action(1) {
@Override
public void run() {
if(FightState.getFightState() != FightState.RUNNING)
return;
Location location = translate(pos, true);
if(interactionDistanceViolation(location))
return;
Block block = location.getBlock();
if(block.getType() == Material.AIR)
block.setType(Material.TNT);
}
});
}
protected void interact(Vector pos) {
queue.add(new Action(1) {
@Override
public void run() {
Location location = translate(pos, true);
if(interactionDistanceViolation(location))
return;
interact(location.getBlock());
}
});
}
protected void interact(Vector pos, int n) {
queue.add(new Action(1) {
@Override
public void run() {
Location location = translate(pos, true);
if (interactionDistanceViolation(location))
return;
Block block = location.getBlock();
BlockData data = block.getBlockData();
if (data instanceof Repeater) {
Repeater repeater = (Repeater) data;
repeater.setDelay(n);
} else if (data instanceof Lectern) {
Lectern lectern = (Lectern) data;
lectern.setPage(n);
}
block.setBlockData(data);
}
});
}
protected void move(Vector pos) {
queue.add(new Action(2) {
@Override
public void run() {
Location location = entity.getLocation();
Location target = translate(pos, false);
if(Math.abs(location.getX() - target.getX()) > 1 || Math.abs(location.getY() - target.getY()) > 1.2 || Math.abs(location.getZ() - target.getZ()) > 1) {
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> entity.getName() + ": Overdistance movement " + location.toVector() + " " + target.toVector());
return;
}
if(!team.getFightPlayer(entity).canEntern() && !team.getExtendRegion().inRegion(target))
return;
entity.teleport(target, PlayerTeleportEvent.TeleportCause.COMMAND);
}
});
}
private boolean interactionDistanceViolation(Location location) {
return location.distance(entity.getEyeLocation()) > 5;
}
private void interact(Block block) {
BlockData data = block.getBlockData(); //TODO only 1.14+ compatible at the moment
if (data instanceof NoteBlock) {
NoteBlock noteBlock = (NoteBlock) data;
Note note = noteBlock.getNote();
noteBlock.setNote(note.isSharped() ? note.flattened() : note.sharped());
} else if (data instanceof Openable) {
Openable openable = (Openable) data;
openable.setOpen(!openable.isOpen());
} else if (data instanceof Comparator) {
Comparator comparator = (Comparator) data;
comparator.setMode(Comparator.Mode.values()[1 - comparator.getMode().ordinal()]);
} else if (data instanceof Powerable) {
Material type = block.getType();
Powerable powerable = (Powerable) data;
boolean isPowered = powerable.isPowered();
if(type.name().endsWith("BUTTON")) {
if(isPowered)
return;
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
if(!block.getType().name().endsWith("BUTTON"))
return;
powerable.setPowered(false);
block.setBlockData(powerable);
}, type.name().endsWith("STONE_BUTTON") ? 20 : 30);
}
powerable.setPowered(!isPowered);
}
block.setBlockData(data);
}
private void run() {
if(queue.isEmpty())
plan();
if(!queue.isEmpty() && --queue.peek().delay == 0)
queue.poll().run();
}
private Location translate(Vector pos, boolean blockPos) {
Region extend = team.getExtendRegion();
if(Fight.getUnrotated() == team)
return new Location(
Config.world,
pos.getX() + extend.getMinX(),
pos.getY() + team.getSchemRegion().getMinY(),
pos.getZ() + extend.getMinZ()
);
else
return new Location(
Config.world,
extend.getMaxX() - pos.getX() - (blockPos ? 1 : 0),
pos.getY() + team.getSchemRegion().getMinY(),
extend.getMaxZ() - pos.getZ() - (blockPos ? 1 : 0)
);
}
private static class Action {
private int delay;
public Action(int delay) {
this.delay = delay;
}
public void run() {}
}
}

Datei anzeigen

@ -0,0 +1,60 @@
/*
* 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.fightsystem.ai;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.util.Vector;
import java.util.List;
import java.util.Random;
public class LixfelAI extends AI {
private final Random random = new Random();
private LixfelPathplanner pathplanner;
public LixfelAI(FightTeam team, String user) {
super(team, SteamwarUser.get(user));
}
@Override
public SchematicNode chooseSchematic() {
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
SchematicNode schem = publics.get(new Random().nextInt(publics.size()));
pathplanner = new LixfelPathplanner(schem);
return schem;
}
@Override
protected void plan() {
setReady();
Vector destination = pathplanner.getWalkable().get(random.nextInt(pathplanner.getWalkable().size()));
List<Vector> path = pathplanner.plan(getPosition(), destination);
if(!path.isEmpty())
chat("Path size: " + path.size());
for(Vector p : path) {
move(p);
}
}
}

Datei anzeigen

@ -0,0 +1,141 @@
/*
* 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.fightsystem.ai;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BlockType;
import de.steamwar.fightsystem.Config;
import de.steamwar.sql.SchematicData;
import de.steamwar.sql.SchematicNode;
import org.bukkit.util.Vector;
import java.io.IOException;
import java.util.*;
public class LixfelPathplanner {
private static BlockType getBlockType(Clipboard clipboard, BlockVector3 vector) {
return clipboard.getBlock(vector).getBlockType();
}
private static boolean nonsolid(Clipboard clipboard, BlockVector3 vector) {
return !getBlockType(clipboard, vector).getMaterial().isSolid();
}
private static Vector toBukkit(BlockVector3 vector) {
return new Vector(vector.getX() + 0.5, vector.getY(), vector.getZ() + 0.5);
}
private final List<Vector> walkable = new ArrayList<>();
private final Map<Vector, Vector[]> neighbours = new HashMap<>();
public LixfelPathplanner(SchematicNode schem) {
try {
fillWalkable(new SchematicData(schem).load());
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
public List<Vector> getWalkable() {
return walkable;
}
private void fillWalkable(Clipboard clipboard) {
BlockVector3 min = clipboard.getRegion().getMinimumPoint().subtract(Config.PreperationArea, 0, Config.PreperationArea); //TODO assumes nonextended Schematic with maximal size
Region region = clipboard.getRegion();
clipboard.getRegion().forEach(vector -> {
BlockVector3 below = vector.subtract(0, 1, 0);
if(!region.contains(below))
return;
BlockType belowMaterial = getBlockType(clipboard, below);
BlockVector3 above = vector.add(0, 1, 0);
if(nonsolid(clipboard, vector)) {
if(
(belowMaterial.getMaterial().isSolid() || belowMaterial.getId().equals("minecraft:ladder")) &&
(!region.contains(above) || nonsolid(clipboard, above))
)
walkable.add(toBukkit(vector.subtract(min)));
} else {
if(!region.contains(above))
walkable.add(toBukkit(above.subtract(min)));
}
});
for(Vector vector : walkable) {
neighbours.put(vector, walkable.stream().filter(neighbour -> neighbouring(neighbour, vector)).filter(neighbour -> neighbour != vector).toArray(Vector[]::new));
}
}
public List<Vector> planToAnywhere(Vector start, Vector destination) {
Vector intermediate = walkable.stream().filter(vector -> neighbouring(vector, destination)).findAny().orElse(null);
if(intermediate == null)
return Collections.emptyList();
List<Vector> plan = plan(start, intermediate);
plan.add(destination);
return plan;
}
public List<Vector> plan(Vector start, Vector destination) {
if(neighbouring(start, destination))
return Collections.singletonList(destination);
Map<Vector, Vector> approach = new HashMap<>();
Set<Vector> checking = Collections.singleton(destination);
while(!checking.isEmpty()) {
Set<Vector> toCheck = new HashSet<>();
for(Vector current : checking) {
Vector firstStep = Arrays.stream(neighbours.get(current))
.filter(vector -> !approach.containsKey(vector))
.filter(next -> {
approach.put(next, current);
toCheck.add(next);
return neighbouring(next, start);
})
.findAny().orElse(null);
if(firstStep != null) {
List<Vector> path = new ArrayList<>();
path.add(firstStep);
while(path.get(path.size()-1) != destination) {
path.add(approach.get(path.get(path.size()-1)));
}
return path;
}
}
checking = toCheck;
}
return Collections.emptyList();
}
private boolean neighbouring(Vector a, Vector b) {
return Math.abs(a.getX() - b.getX()) <= 1 && Math.abs(a.getY() - b.getY()) <= 1 && Math.abs(a.getZ() - b.getZ()) <= 1;
}
}

Datei anzeigen

@ -1,46 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class AcceptCommand implements CommandExecutor {
public AcceptCommand() {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "accept", this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
Commands.acceptInvitation(player);
return false;
}
}

Datei anzeigen

@ -26,7 +26,7 @@ import de.steamwar.fightsystem.fight.Kit;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import de.steamwar.sql.UserPerm;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -47,7 +47,7 @@ public class AkCommand implements CommandExecutor {
if(!player.isOp())
return false;
if(SteamwarUser.get(player.getUniqueId()).getUserGroup() != UserGroup.Developer && Core.getInstance() != FightSystem.getPlugin()){
if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.ADMINISTRATION) && Core.getInstance() != FightSystem.getPlugin()){
return false;
}

Datei anzeigen

@ -1,42 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import java.lang.reflect.Field;
public class CommandInjector {
private CommandInjector(){}
private static final String PACKAGE_NAME = Bukkit.getServer().getClass().getPackage().getName();
private static final String VERSION = PACKAGE_NAME.substring(PACKAGE_NAME.lastIndexOf('.') + 1);
public static void injectCommand(Command cmd) throws Exception {
Class serverClass = Class.forName("org.bukkit.craftbukkit." + VERSION + ".CraftServer");
Field f1 = serverClass.getDeclaredField("commandMap");
f1.setAccessible(true);
SimpleCommandMap commandMap = (SimpleCommandMap) f1.get(Bukkit.getServer());
commandMap.register("BauSystem", cmd);
}
}

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.fightsystem.commands;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@ -28,12 +29,20 @@ import de.steamwar.fightsystem.fight.Kit;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser;
import lombok.experimental.UtilityClass;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.entity.Player;
@UtilityClass
public class Commands {
private Commands(){}
private static final Reflection.FieldAccessor<SimpleCommandMap> commandMap = Reflection.getField("{obc}.CraftServer", "commandMap", SimpleCommandMap.class);
public static void injectCommand(Command cmd) {
commandMap.get(Bukkit.getServer()).register("FightSystem", cmd);
}
private static void errNoTeam(Player p){
FightSystem.getMessage().sendPrefixless("NO_TEAM", p, ChatMessageType.ACTION_BAR);
@ -47,14 +56,6 @@ public class Commands {
return false;
}
private static FightTeam checkGetInvitedTeam(Player p){
FightTeam fightTeam = Fight.getInvitedTeam(p);
if(fightTeam == null){
FightSystem.getMessage().sendPrefixless("NO_INVITATION", p, ChatMessageType.ACTION_BAR);
}
return fightTeam;
}
private static FightPlayer checkGetPlayer(Player p){
FightPlayer fightPlayer = Fight.getFightPlayer(p);
if(fightPlayer == null){
@ -104,30 +105,6 @@ public class Commands {
fightTeam.skip();
}
static void acceptInvitation(Player p){
if(checkSetup(p))
return;
FightTeam team = checkGetInvitedTeam(p);
if(team == null)
return;
team.addMember(p);
}
static void declineInvitation(Player p){
if(checkSetup(p))
return;
FightTeam team = checkGetInvitedTeam(p);
if(team == null)
return;
FightSystem.getMessage().sendPrefixless("INVITATION_DECLINED", p, ChatMessageType.ACTION_BAR);
team.broadcast("INVITATION_DECLINED_TEAM", p.getName());
team.getInvited().remove(p);
}
static void leaveTeam(Player p){
if(checkSetup(p))
return;
@ -139,37 +116,6 @@ public class Commands {
fightTeam.removePlayer(p);
}
static void invite(Player p, String invited){
if(checkSetup(p))
return;
FightTeam fightTeam = checkGetTeam(p);
if(fightTeam == null)
return;
FightPlayer fightPlayer = checkGetLeader(p);
if(fightPlayer == null)
return;
Player target = checkGetPlayer(p, invited);
if(target == null)
return;
if(Fight.getPlayerTeam(target) != null) {
FightSystem.getMessage().sendPrefixless("PLAYER_IN_TEAM", p, ChatMessageType.ACTION_BAR, target.getName());
return;
}
if(Fight.getOpposite(fightTeam).getInvited().contains(target) || fightTeam.getInvited().contains(target)) {
FightSystem.getMessage().sendPrefixless("ALREADY_INVITED", p, ChatMessageType.ACTION_BAR, target.getName());
return;
}
FightSystem.getMessage().sendPrefixless("INVITATION_SENT", p, ChatMessageType.ACTION_BAR, target.getName());
fightTeam.getInvited().add(target);
GUI.invitation(p, target);
}
static void kick(Player p, String kicked){
if(checkSetup(p))
return;

Datei anzeigen

@ -1,46 +0,0 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class DeclineCommand implements CommandExecutor {
public DeclineCommand() {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "decline", this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
return false;
}
Player player = (Player) sender;
Commands.declineInvitation(player);
return false;
}
}

Datei anzeigen

@ -19,18 +19,18 @@
package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.Kit;
import de.steamwar.fightsystem.fight.*;
import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.utils.ColorConverter;
import de.steamwar.inventory.*;
import de.steamwar.message.Message;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
@ -47,23 +47,28 @@ public class GUI {
private static final Message msg = FightSystem.getMessage();
static void invitation(Player p, Player target){
SWInventory inv = new SWInventory(target, 9, msg.parse("INVITATION_TITLE", target, p.getName()));
inv.setItem(0, SWItem.getDye(10), (byte)10, msg.parse("INVITATION_ACCEPT", target), (ClickType click) ->{
Commands.acceptInvitation(target);
target.closeInventory();
@SuppressWarnings("deprecation")
private static void addTeamRequest(Player p, SWInventory inv, int pos, FightTeam team) {
byte colorCode = ColorConverter.chat2dye(team.getColor()).getDyeData();
String name = team.getLeader() != null ? team.getLeader().getEntity().getName() : team.getName();
inv.setItem(pos, SWItem.getDye(colorCode), colorCode, msg.parse("JOIN_REQUEST_TEAM", p, team.getColor() + name), click -> {
p.closeInventory();
new JoinRequest(p, team);
});
inv.setItem(8, SWItem.getDye(1), (byte)1, msg.parse("INVITATION_DECLINE", target), (ClickType click) ->{
Commands.declineInvitation(target);
target.closeInventory();
});
inv.addCloseCallback((ClickType click) ->{
if(Fight.getInvitedTeam(target) != null){
msg.sendPrefixless("INVITATION_CHAT_ACCEPT", target);
msg.sendPrefixless("INVITATION_CHAT_DECLINE", target);
}
});
inv.setCallback(-999, (ClickType click) -> target.closeInventory());
}
public static void joinRequest(Player p) {
if(JoinRequest.get(p) != null) {
msg.sendPrefixless("JOIN_REQUEST_ALREADY", p, ChatMessageType.ACTION_BAR);
return;
}
SWInventory inv = new SWInventory(p, 9, msg.parse("JOIN_REQUEST_TITLE", p));
FightTeam team = Fight.getPlayerTeam(p);
if(team != Fight.getRedTeam())
addTeamRequest(p, inv, team == null ? 0 : 4, Fight.getBlueTeam());
if(team != Fight.getBlueTeam())
addTeamRequest(p, inv, team == null ? 8 : 4, Fight.getRedTeam());
inv.open();
}
@ -84,12 +89,11 @@ public class GUI {
inv.open();
}
public static void chooseInvitation(Player p){
List<SWListInv.SWListEntry<UUID>> players = SWListInv.createPlayerList(p.getUniqueId());
players.removeIf(swItemUUIDPair -> Fight.getFightPlayer(Bukkit.getPlayer(swItemUUIDPair.getObject())) != null);
SWListInv<UUID> inv = new SWListInv<>(p, msg.parse("INVITE_TITLE", p), players, (ClickType click, UUID player) -> {
Commands.invite(p, SteamwarUser.get(player).getUserName());
public static void chooseJoinRequests(Player p){
List<SWListInv.SWListEntry<Player>> players = JoinRequest.openRequests(p, Fight.getPlayerTeam(p));
SWListInv<Player> inv = new SWListInv<>(p, msg.parse("REQUESTS_TITLE", p), players, (ClickType click, Player player) -> {
p.closeInventory();
RequestsCommand.onJoinRequest(p, player, click.isLeftClick() ? JoinRequest::accept : JoinRequest::decline);
});
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open();
@ -166,27 +170,47 @@ public class GUI {
return;
}
SWInventory inv = new SWInventory(p, 9, msg.parse("SCHEM_TITLE", p, Config.GameName));
inv.setItem(8, Material.REDSTONE, msg.parse("SCHEM_PUBLIC", p, Config.GameName), (ClickType click) -> {
p.closeInventory();
schemDialog(p, true);
});
if(Fight.getMaxRank() == 0){
inv.setItem(0, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_PRIVATE_FORBIDDEN", p, Config.GameName), (ClickType click)->{});
}else if(SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), Config.SchematicType.toDB()).isEmpty() && !Config.test()){
inv.setItem(0, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_NO_PRIVATE", p, Config.GameName), (ClickType click)->{});
}else{
inv.setItem(0, SWItem.getMaterial("CAULDRON_ITEM"), msg.parse("SCHEM_PRIVATE", p, Config.GameName), (ClickType click) -> {
p.closeInventory();
schemDialog(p, false);
});
int invSize = (Config.SubTypes.size() + 1) * 9;
SWInventory inv = new SWInventory(p, invSize, msg.parse("SCHEM_TITLE", p, Config.GameName));
setupSchemTypeRow(p, inv, Config.SchematicType, 0);
for (int i = 0; i < Config.SubTypes.size(); i++) {
setupSchemTypeRow(p, inv, Config.SubTypes.get(i), i + 1);
}
inv.setCallback(-999, (ClickType click) -> p.closeInventory());
inv.open();
}
private static void schemDialog(Player p, boolean publicSchems){
SchematicSelector selector = new SchematicSelector(p, Config.test()?SchematicSelector.selectSchematic():SchematicSelector.selectSchematicTypeWithRank(Config.SchematicType, Fight.getMaxRank()), node -> {
private static void setupSchemTypeRow(Player p, SWInventory inv, SchematicType type, int row) {
inv.setItem(row * 9 + 8, Material.REDSTONE, msg.parse("SCHEM_PUBLIC", p, type.name()), (ClickType click) -> {
p.closeInventory();
schemDialog(p, type, true, false);
});
if (Fight.publicOnly()) {
inv.setItem(row * 9, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_PRIVATE_FORBIDDEN", p, type.name()), (ClickType click)->{});
return;
}
if (type.checkType() != null && type.checkType() != type && ArenaMode.AntiEvent.contains(Config.mode) && !SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.checkType().toDB()).isEmpty()) {
inv.setItem(row * 9 + 4, Material.ANVIL, msg.parse("SCHEM_UNCHECKED", p, type.name()), (ClickType click) -> {
p.closeInventory();
schemDialog(p, type, false, true);
});
}
if (SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(p.getUniqueId()).getId(), type.toDB()).isEmpty() && !Config.test()) {
inv.setItem(row * 9, SWItem.getDye(8), (byte)8, msg.parse("SCHEM_NO_PRIVATE", p, type.name()), (ClickType click)->{});
return;
}
inv.setItem(row * 9, SWItem.getMaterial("CAULDRON_ITEM"), msg.parse("SCHEM_PRIVATE", p, type.name()), (ClickType click) -> {
p.closeInventory();
schemDialog(p, type, false, false);
});
}
private static void schemDialog(Player p, SchematicType type, boolean publicSchems, boolean unchecked){
SchematicSelector selector = new SchematicSelector(p, Config.test() ? SchematicSelector.selectSchematic() : SchematicSelector.selectSchematicType(unchecked ? type.checkType() : type), node -> {
FightTeam fightTeam = Fight.getPlayerTeam(p);
if(fightTeam == null)
return;

Datei anzeigen

@ -47,10 +47,10 @@ public class GamemodeCommand extends BukkitCommand {
try {
CommandRemover.removeAll("gamemode");
CommandInjector.injectCommand(this);
} catch (Exception e) {
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Failed to replace commands", e);
}
Commands.injectCommand(this);
}
@Override

Datei anzeigen

@ -0,0 +1,64 @@
/*
* 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.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.fightsystem.utils.FightStatistics;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class InfoCommand implements CommandExecutor {
public InfoCommand() {
new StateDependentCommand(ArenaMode.All, FightState.All, "fightinfo", this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player))
return false;
Player player = (Player) sender;
if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK))
return false;
FightSystem.getMessage().send("INFO_RANKED", player, !FightStatistics.isUnranked());
for(FightTeam team : Fight.teams()) {
if(!team.isLeaderless())
FightSystem.getMessage().send("INFO_LEADER", player, team.getColoredName(), team.getLeader().getEntity().getName());
if(team.getSchematic() != 0) {
SchematicNode schematic = SchematicNode.getSchematicNode(team.getSchematic());
FightSystem.getMessage().send("INFO_SCHEMATIC", player, team.getColoredName(), schematic.getName(), SteamwarUser.get(schematic.getOwner()).getUserName(), schematic.getRank());
}
}
return false;
}
}

Datei anzeigen

@ -34,7 +34,7 @@ import org.bukkit.entity.Player;
public class LeaderCommand implements CommandExecutor {
public LeaderCommand() {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "leader", this);
new StateDependentCommand(ArenaMode.ManualTeams, FightState.Setup, "leader", this);
}
@Override

Datei anzeigen

@ -25,10 +25,7 @@ import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import de.steamwar.sql.*;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -38,7 +35,7 @@ import org.bukkit.entity.Player;
public class LockschemCommand implements CommandExecutor {
public LockschemCommand() {
new StateDependentCommand(ArenaMode.AntiReplay, FightState.All, "lockschem", this);
new StateDependentCommand(ArenaMode.All, FightState.Schem, "lockschem", this);
}
@Override
@ -47,13 +44,9 @@ public class LockschemCommand implements CommandExecutor {
return false;
Player player = (Player) sender;
SteamwarUser steamwarUser = SteamwarUser.get(player.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
if(!userGroup.isCheckSchematics())
if(!SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.CHECK))
return false;
if(args.length != 1) {
FightSystem.getMessage().sendPrefixless("LOCKSCHEM_HELP", player);
return false;

Datei anzeigen

@ -21,6 +21,10 @@ package de.steamwar.fightsystem.commands;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.JoinRequest;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import org.bukkit.command.Command;
@ -28,25 +32,46 @@ import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class InviteCommand implements CommandExecutor {
import java.util.function.BiConsumer;
public InviteCommand() {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.Setup, "invite", this);
public class RequestsCommand implements CommandExecutor {
public RequestsCommand() {
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "request", this);
new StateDependentCommand(ArenaMode.VariableTeams, FightState.AntiSpectate, "requests", this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if(!(sender instanceof Player)) {
if(!(sender instanceof Player))
return false;
}
Player player = (Player) sender;
if(args.length != 1){
FightSystem.getMessage().sendPrefixless("INVITE_HELP", player);
FightPlayer fp = Fight.getFightPlayer(player);
if(fp == null || !(fp.isLeader() || fp.isLiving())) {
GUI.joinRequest(player);
return false;
}
Commands.invite(player, args[0]);
if(Commands.checkGetLeader(player) == null)
return false;
GUI.chooseJoinRequests(player);
return false;
}
public static void onJoinRequest(Player player, Player target, BiConsumer<JoinRequest, FightTeam> handleJoinRequest) {
JoinRequest request = JoinRequest.get(target);
if(request == null) {
FightSystem.getMessage().send("NO_JOIN_REQUEST", player);
return;
}
FightTeam team = Fight.getPlayerTeam(player);
if(!request.required(team)) {
FightSystem.getMessage().send("NO_CONFIRMATION", player);
return;
}
handleJoinRequest.accept(request, team);
}
}

Datei anzeigen

@ -0,0 +1,52 @@
/*
* 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.fightsystem.commands;
import de.steamwar.core.TPSWarpUtils;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentCommand;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
public class TPSWarpCommand implements CommandExecutor {
public TPSWarpCommand() {
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpswarp", this);
new StateDependentCommand(ArenaMode.Prepare, FightState.PostSchemSetup, "tpslimit", this);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
double tps;
try {
tps = Double.parseDouble(args[0]);
} catch (NumberFormatException | ArrayIndexOutOfBoundsException e) {
FightSystem.getMessage().send("TPSWARP_HELP", sender);
return false;
}
TPSWarpUtils.warp(tps);
FightSystem.getMessage().broadcastActionbar("TPSWARP_SET", tps);
return false;
}
}

Datei anzeigen

@ -83,8 +83,6 @@ public abstract class Countdown {
}
for(Countdown countdown : new ArrayList<>(currentCountdowns)) {
if(countdown.time - smallestTime <= 1)
countdown.prepareFinish();
countdown.time -= smallestTime;
countdown.show();
}
@ -104,8 +102,6 @@ public abstract class Countdown {
Bukkit.getOnlinePlayers().forEach(p -> sendCountdownMessage(p, message, time / divisor, appendix));
}
protected void prepareFinish() {}
public int getTimeLeft(){
return time;
}
@ -124,7 +120,6 @@ public abstract class Countdown {
broadcast("COUNTDOWN_SECONDS", 1);
break;
case 1:
prepareFinish();
broadcast("COUNTDOWN_SECOND", 1);
break;
case 0:

Datei anzeigen

@ -21,39 +21,57 @@ package de.steamwar.fightsystem.countdown;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.events.BoardingEvent;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.utils.Message;
import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.utils.SWSound;
import de.steamwar.techhider.ProtocolUtils;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import java.util.List;
public class EnternCountdown extends Countdown {
private static int calcTime(FightPlayer fp, Countdown countdown) {
int time = Config.EnterStages.get(fp.getKit().getEnterStage());
if(countdown != null) {
time -= Config.TimeoutTime - countdown.getTimeLeft();
if(time < 0)
time = 0;
}
return time;
}
private final FightPlayer fightPlayer;
private List<ProtocolUtils.ChunkPos> chunkPos;
public EnternCountdown(FightPlayer fp) {
super(Config.EnterStages.get(fp.getKit().getEnterStage()), new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
public EnternCountdown(FightPlayer fp, Countdown countdown) {
super(calcTime(fp, countdown), new Message("ENTERN_COUNTDOWN"), SWSound.BLOCK_NOTE_PLING, false);
fightPlayer = fp;
enable();
}
@Override
public void countdownFinished() {
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getPlayer(), ChatMessageType.ACTION_BAR);
FightSystem.getTechHider().reloadChunks(fightPlayer.getPlayer(), chunkPos, false);
}
@Override
protected void prepareFinish() {
chunkPos = FightSystem.getTechHider().prepareChunkReload(fightPlayer.getPlayer(), false);
Bukkit.getPluginManager().callEvent(new BoardingEvent(fightPlayer));
FightSystem.getMessage().sendPrefixless("ENTERN_ALLOWED", fightPlayer.getEntity(), ChatMessageType.ACTION_BAR);
fightPlayer.ifPlayer(player -> {
FightSystem.getHullHider().updatePlayer(player);
FightSystem.getTechHider().reloadChunks(player, Fight.getOpposite(fightPlayer.getTeam()).getExtendRegion(), Region.EMPTY);
});
}
@Override
protected void broadcast(String message, int divisor) {
fightPlayer.getPlayer().playSound(fightPlayer.getPlayer().getLocation(), sound, 100.0f, 1.0f);
sendCountdownMessage(fightPlayer.getPlayer(), message, time / divisor, appendix);
fightPlayer.ifPlayer(player -> {
player.playSound(player.getLocation(), sound, 100.0f, 1.0f);
sendCountdownMessage(player, message, time / divisor, appendix);
});
}
}

Datei anzeigen

@ -0,0 +1,49 @@
/*
* 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.fightsystem.event;
import com.sk89q.worldedit.WorldEditException;
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.OneShotStateDependent;
import de.steamwar.fightsystem.utils.WorldeditWrapper;
import de.steamwar.fightsystem.winconditions.Winconditions;
import de.steamwar.sql.SchematicNode;
import java.util.logging.Level;
public class PersistentDamage {
public PersistentDamage() {
if(!ArenaMode.SeriousFight.contains(Config.mode))
return;
new OneShotStateDependent(Winconditions.PERSISTENT_DAMAGE, FightState.Spectate, () -> Fight.teams().forEach(team -> {
try{
WorldeditWrapper.impl.saveSchem(SchematicNode.getSchematicNode(team.getSchematic()), team.getExtendRegion(), team.getSchemRegion().getMinY());
}catch(WorldEditException e){
FightSystem.getPlugin().getLogger().log(Level.SEVERE, "Could not persist schematic state", e);
}
}));
}
}

Datei anzeigen

@ -0,0 +1,39 @@
/*
* 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.fightsystem.event;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.winconditions.Winconditions;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class TNTDistributor {
public TNTDistributor() {
new StateDependentTask(Winconditions.TNT_DISTRIBUTION, FightState.Running, () -> Fight.teams().forEach(team -> team.getPlayers().forEach(fp -> {
if(!fp.isLiving())
return;
fp.ifPlayer(player -> player.getInventory().addItem(new ItemStack(Material.TNT, 20)));
})), 300, 300);
}
}

Datei anzeigen

@ -0,0 +1,40 @@
/*
* 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/>.
*/
package de.steamwar.fightsystem.events;
import de.steamwar.fightsystem.fight.FightPlayer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@AllArgsConstructor
public class BoardingEvent extends Event {
@Getter
private static final HandlerList handlerList = new HandlerList();
private final FightPlayer fightPlayer;
@Override
public HandlerList getHandlers() {
return handlerList;
}
}

Datei anzeigen

@ -0,0 +1,40 @@
/*
* 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/>.
*/
package de.steamwar.fightsystem.events;
import de.steamwar.fightsystem.fight.FightPlayer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@AllArgsConstructor
public class TeamDeathEvent extends Event {
@Getter
private static final HandlerList handlerList = new HandlerList();
private final FightPlayer fightPlayer;
@Override
public HandlerList getHandlers() {
return handlerList;
}
}

Datei anzeigen

@ -0,0 +1,40 @@
/*
* 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/>.
*/
package de.steamwar.fightsystem.events;
import de.steamwar.fightsystem.fight.FightPlayer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@AllArgsConstructor
public class TeamLeaveEvent extends Event {
@Getter
private static final HandlerList handlerList = new HandlerList();
private final FightPlayer fightPlayer;
@Override
public HandlerList getHandlers() {
return handlerList;
}
}

Datei anzeigen

@ -0,0 +1,40 @@
/*
* 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/>.
*/
package de.steamwar.fightsystem.events;
import de.steamwar.fightsystem.fight.FightPlayer;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
@AllArgsConstructor
public class TeamSpawnEvent extends Event {
@Getter
private static final HandlerList handlerList = new HandlerList();
private final FightPlayer fightPlayer;
@Override
public HandlerList getHandlers() {
return handlerList;
}
}

Datei anzeigen

@ -21,14 +21,17 @@ package de.steamwar.fightsystem.fight;
import com.comphenix.tinyprotocol.TinyProtocol;
import com.mojang.authlib.GameProfile;
import de.steamwar.core.Core;
import de.steamwar.core.ProtocolWrapper;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.record.GlobalRecorder;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import java.util.Collection;
@ -37,7 +40,9 @@ import java.util.HashSet;
public class Fight {
private Fight(){}
@Getter
private static final FightTeam redTeam = new FightTeam(Config.TeamRedName, Config.TeamRedColor, Config.TeamRedSpawn, Config.RedPasteRegion, Config.RedExtendRegion, Config.RedRotate, false, Config.RedLeader);
@Getter
private static final FightTeam blueTeam = new FightTeam(Config.TeamBlueName, Config.TeamBlueColor, Config.TeamBlueSpawn, Config.BluePasteRegion, Config.BlueExtendRegion, Config.BlueRotate, true, Config.BlueLeader);
private static final Collection<FightTeam> teams = new HashSet<>();
static {
@ -45,7 +50,7 @@ public class Fight {
teams.add(blueTeam);
}
public static FightTeam getPlayerTeam(Player player) {
public static FightTeam getPlayerTeam(LivingEntity player) {
if(redTeam.isPlayerInTeam(player))
return redTeam;
if(blueTeam.isPlayerInTeam(player))
@ -62,15 +67,7 @@ public class Fight {
throw new IllegalArgumentException();
}
public static FightTeam getInvitedTeam(Player player){
if(redTeam.getInvited().contains(player))
return redTeam;
else if(blueTeam.getInvited().contains(player))
return blueTeam;
return null;
}
public static FightPlayer getFightPlayer(Player player) {
public static FightPlayer getFightPlayer(LivingEntity player) {
if(redTeam.isPlayerInTeam(player))
return redTeam.getFightPlayer(player);
if(blueTeam.isPlayerInTeam(player))
@ -78,30 +75,25 @@ public class Fight {
return null;
}
public static boolean fighting(Player player) {
public static boolean fighting(LivingEntity player) {
return getPlayerTeam(player) != null;
}
public static FightTeam getRedTeam() {
return redTeam;
}
public static FightTeam getBlueTeam() {
return blueTeam;
}
public static Collection<FightTeam> teams() {
return teams;
}
public static FightTeam getUnrotated() {
return Config.BlueRotate ? Fight.getRedTeam() : Fight.getBlueTeam();
return Config.blueNegZ() ? Fight.getBlueTeam() : Fight.getRedTeam();
}
public static void playSound(Sound sound, float volume, float pitch) {
GlobalRecorder.getInstance().soundAtPlayer(sound.name(), volume, pitch);
//volume: max. 100, pitch: max. 2
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
if(Core.getVersion() >= 18)
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player, sound, volume, pitch));
else
Bukkit.getServer().getOnlinePlayers().forEach(player -> player.playSound(player.getLocation(), sound, volume, pitch));
}
public static FightTeam getTeamByName(String name) {
@ -131,7 +123,7 @@ public class Fight {
if(!player.isOnline())
return;
pseudoSpectator(player, true);
}, 2);
}, 1);
}else if(gameMode == GameMode.SURVIVAL) {
for(Player currentPlayer : Bukkit.getServer().getOnlinePlayers()) {
if(currentPlayer.getUniqueId() != player.getUniqueId() && currentPlayer.getGameMode() == GameMode.SPECTATOR) {
@ -146,21 +138,16 @@ public class Fight {
TinyProtocol.instance.sendPacket(player, ProtocolWrapper.impl.playerInfoPacketConstructor(ProtocolWrapper.PlayerInfoAction.GAMEMODE, new GameProfile(player.getUniqueId(), player.getName()), enable ? GameMode.CREATIVE : GameMode.SPECTATOR));
}
public static int getMaxRank(){
/* MaxRank of 0 is Pubonly*/
if(Config.OnlyPublicSchematics){
return 0;
public static boolean publicOnly() {
if (Config.OnlyPublicSchematics) {
return true;
}
if(Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)){
return 1000;
if (Config.IgnorePublicOnly || ArenaMode.RankedEvent.contains(Config.mode)) {
return false;
}
if(redTeam.getLeader() == null || blueTeam.getLeader() == null){
return 1000;
if (redTeam.getLeader() == null || blueTeam.getLeader() == null) {
return false;
}
return Math.min(redTeam.getSchemRank(), blueTeam.getSchemRank());
return redTeam.isPublicsOnly() || blueTeam.isPublicsOnly();
}
}

Datei anzeigen

@ -20,27 +20,42 @@
package de.steamwar.fightsystem.fight;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.ai.AI;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.countdown.EnternCountdown;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import java.util.function.Consumer;
public class FightPlayer {
private final Player player;
private final int id;
private LivingEntity entity;
@Getter
private final FightTeam team;
private boolean isOut;
@Setter
@Getter
private Kit kit;
@Getter
private int kills;
private EnternCountdown enternCountdown = null;
FightPlayer(Player player, FightTeam team) {
this.player = player;
FightPlayer(LivingEntity entity, SteamwarUser user, FightTeam team) {
this.id = user.getId();
this.entity = entity;
this.team = team;
this.isOut = false;
kit = Kit.getKitByName(Config.MemberDefault);
if(Config.PersonalKits){
PersonalKit personalKit = PersonalKit.getKitInUse(SteamwarUser.get(player.getUniqueId()).getId(), Config.SchematicType.toDB());
PersonalKit personalKit = PersonalKit.getKitInUse(user.getId(), Config.SchematicType.toDB());
if(personalKit != null){
kit = new Kit(personalKit);
}
@ -48,13 +63,20 @@ public class FightPlayer {
kills = 0;
}
public void setOut() {
isOut = true;
stopEnternCountdown();
public void revive() {
isOut = false;
}
public void setEnternCountdown(EnternCountdown countdown){
enternCountdown = countdown;
public void setOut() {
isOut = true;
Bukkit.getPluginManager().callEvent(new TeamDeathEvent(this));
stopEnternCountdown();
ifAI(AI::stop);
}
public void startEnternCountdown(Countdown countdown) {
if(Config.EnterStages.size() > kit.getEnterStage() && kit.getEnterStage() >= 0)
enternCountdown = new EnternCountdown(this, countdown);
}
public void stopEnternCountdown(){
@ -64,8 +86,28 @@ public class FightPlayer {
enternCountdown = null;
}
public Player getPlayer() {
return this.player;
public LivingEntity getEntity() {
LivingEntity bukkit = Bukkit.getPlayer(entity.getUniqueId());
if(bukkit != null)
entity = bukkit;
return entity;
}
public SteamwarUser getUser() {
return SteamwarUser.get(id);
}
public void ifAI(Consumer<AI> function) {
if(entity instanceof Player)
return;
AI ai = AI.getAI(entity.getUniqueId());
if(ai != null)
function.accept(ai);
}
public void ifPlayer(Consumer<Player> function) {
if(entity instanceof Player)
function.accept((Player) entity);
}
public boolean isLiving() {
@ -74,23 +116,7 @@ public class FightPlayer {
public boolean isLeader() {
FightPlayer leader = team.getLeader();
return leader != null && leader.getPlayer() == player;
}
public Kit getKit() {
return kit;
}
public void setKit(Kit kit) {
this.kit = kit;
}
public FightTeam getTeam(){
return team;
}
public int getKills(){
return kills;
return leader != null && leader.getEntity() == entity;
}
public void addKill(){

Datei anzeigen

@ -33,6 +33,7 @@ import de.steamwar.fightsystem.utils.Region;
import de.steamwar.fightsystem.utils.WorldeditWrapper;
import de.steamwar.sql.SchematicData;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SchematicType;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Location;
@ -100,8 +101,17 @@ public class FightSchematic extends StateDependent {
if(clipboard == null){
List<SchematicNode> publics = SchematicNode.getAllSchematicsOfType(0, Config.SchematicType.toDB());
if(publics.isEmpty())
return;
if(publics.isEmpty()) {
for (SchematicType type : Config.SubTypes) {
publics = SchematicNode.getAllSchematicsOfType(0, type.toDB());
if (!publics.isEmpty()) {
break;
}
}
if (publics.isEmpty()) {
return;
}
}
setSchematic(publics.get(new Random().nextInt(publics.size())));
}
@ -138,6 +148,9 @@ public class FightSchematic extends StateDependent {
).add(new Vector(rotate ? 1 : 0, 0, rotate ? 1 : 0)),
new AffineTransform().rotateY(rotate ? 180 : 0)
);
FightSystem.getHullHider().initialize(team);
if(ArenaMode.Check.contains(Config.mode) && !team.isBlue())
replaceSync(Material.TNT, Material.OBSIDIAN);
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), freezer::disable, 3);
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), team::teleportToSpawn, 40);
@ -145,7 +158,7 @@ public class FightSchematic extends StateDependent {
@Override
public void disable() {
if(!Config.ReplaceObsidianBedrock)
if(!Config.ReplaceObsidianBedrock || Config.mode == ArenaMode.PREPARE)
return;
FreezeWorld freezer = null;
@ -187,7 +200,7 @@ public class FightSchematic extends StateDependent {
}
length -= 1;
AffineTransform aT = new AffineTransform().rotateY(rotate ? 180 : 0);
AffineTransform aT = new AffineTransform().rotateY(((team == Fight.getRedTeam()) == (Config.BlueToRedZ > 0)) ? 180 : 0);
Location base = new Location(Config.world, region.centerX(), team.getExtendRegion().getMaxY(), region.centerZ());
for(int i = 0; i < characters.length; i++){
WorldeditWrapper.impl.pasteClipboard(characters[i], base, new Vector(offsets[i] - length/2, 0, -region.getSizeZ()/2), aT);

Datei anzeigen

@ -25,34 +25,38 @@ import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.commands.GUI;
import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.events.TeamLeaveEvent;
import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.listener.FightScoreboard;
import de.steamwar.fightsystem.listener.Permanent;
import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.record.GlobalRecorder;
import de.steamwar.fightsystem.listener.TeamArea;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.winconditions.Wincondition;
import de.steamwar.fightsystem.winconditions.Winconditions;
import de.steamwar.inventory.SWItem;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.techhider.ProtocolUtils;
import lombok.Getter;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.*;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.NameTagVisibility;
import org.bukkit.scoreboard.Team;
import java.util.*;
import java.util.function.Consumer;
public class FightTeam {
private static void setKitButton(HotbarKit kit, boolean leader) {
if (Kit.getAvailableKits(leader).size() > 1 || Config.PersonalKits)
kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), player -> GUI.kitSelection(player, ""));
kit.setItem(1, "CHOOSE_KIT", new ItemBuilder(Material.LEATHER_CHESTPLATE).enchant().build(), player -> GUI.kitSelection(player, ""));
else
kit.setItem(1, null, null, null);
}
@ -60,51 +64,61 @@ public class FightTeam {
private static final HotbarKit memberKit = new HotbarKit();
static {
setKitButton(memberKit, false);
memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).removeAllAttributes().build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn()));
memberKit.setItem(7, "RESPAWN", new ItemBuilder(Material.BEACON).build(), player -> player.teleport(Objects.requireNonNull(Fight.getPlayerTeam(player)).getSpawn()));
}
private static final HotbarKit notReadyKit = new HotbarKit(memberKit);
static {
setKitButton(notReadyKit, true);
if(!ArenaMode.RankedEvent.contains(Config.mode)){
notReadyKit.setItem(2, "INVITE_PLAYERS", new ItemBuilder(Material.PAPER).removeAllAttributes().build(), GUI::chooseInvitation);
notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).removeAllAttributes().build(), GUI::chooseRemove);
notReadyKit.setItem(2, "REQUESTS", new ItemBuilder(Material.PAPER).build(), GUI::chooseJoinRequests);
notReadyKit.setItem(3, "REMOVE_PLAYERS", new ItemBuilder(SWItem.getMaterial("FIREWORK_CHARGE")).build(), GUI::chooseRemove);
}
if(Config.test())
notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), GUI::preSchemDialog);
notReadyKit.setItem(5, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog);
notReadyKit.setItem(4, "TEAM_NOT_READY", new ItemBuilder(SWItem.getDye(10), (short) 10).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(true));
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);
static {
chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).removeAllAttributes().addEnchantment(Enchantment.DURABILITY, 1).build(), GUI::preSchemDialog);
chooseSchemKit.setItem(4, "CHOOSE_SCHEMATIC", new ItemBuilder(SWItem.getMaterial("CAULDRON_ITEM")).enchant().build(), GUI::preSchemDialog);
}
private static final HotbarKit readyKit = new HotbarKit(memberKit);
static {
readyKit.setItem(1, null, null, null);
readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).removeAllAttributes().addEnchantment(Enchantment.DURABILITY,1 ).build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false));
readyKit.setItem(4, "TEAM_READY", new ItemBuilder(SWItem.getDye(8), (short) 8).enchant().build(), player -> Objects.requireNonNull(Fight.getPlayerTeam(player)).setReady(false));
}
@Getter
private UUID designatedLeader;
@Getter
private FightPlayer leader;
private int schemRank;
@Getter
private boolean publicsOnly;
private final Map<Player, FightPlayer> players = new HashMap<>();
private final Set<Player> invited = new HashSet<>();
private final Map<UUID, FightPlayer> players = new HashMap<>();
@Getter
private String name;
@Getter
private String prefix;
@Getter
private ChatColor color;
private final FightSchematic schematic;
private final Team team;
@Getter
private final boolean blue;
@Getter
private boolean ready;
private boolean skip;
@Getter
private final Location spawn;
@Getter
private final Region schemRegion;
@Getter
private final Region extendRegion;
@SuppressWarnings("deprecation")
@ -112,7 +126,7 @@ public class FightTeam {
this.spawn = spawn;
this.schemRegion = schemRegion;
this.extendRegion = extendRegion;
this.schemRank = 0;
this.publicsOnly = false;
this.ready = false;
this.skip = false;
this.blue = blue;
@ -121,6 +135,7 @@ public class FightTeam {
this.schematic = new FightSchematic(this, rotate);
new KitLoader();
new SpectateHandler();
new TeamArea(this);
team = FightScoreboard.getBukkitTeam(name);
WorldOfColorWrapper.impl.setTeamColor(team, color);
@ -134,7 +149,7 @@ public class FightTeam {
new OneShotStateDependent(Config.replayserver(), FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), this::reset));
new OneShotStateDependent(ArenaMode.All, FightState.PostSchemSetup, () -> {
if(leader != null)
notReadyKit.loadToPlayer(leader.getPlayer());
leader.ifPlayer(notReadyKit::loadToPlayer);
});
}
@ -144,32 +159,16 @@ public class FightTeam {
this.color = ChatColor.getByChar(ChatColor.getLastColors(prefix).replace("§", ""));
}
public UUID getDesignatedLeader(){
return designatedLeader;
}
public Region getSchemRegion() {
return schemRegion;
}
public Region getExtendRegion() {
return extendRegion;
}
public boolean canbeLeader(Player p){
return isLeaderless() && (designatedLeader == null || designatedLeader.equals(p.getUniqueId()));
}
public int getSchemRank() {
return schemRank;
}
public void teleportToSpawn(){
players.forEach((player, fp) -> player.teleport(spawn));
players.forEach((player, fp) -> fp.getEntity().teleport(spawn));
}
public FightPlayer getFightPlayer(Player player) {
return players.get(player);
public FightPlayer getFightPlayer(LivingEntity player) {
return players.get(player.getUniqueId());
}
public boolean allPlayersOut() {
@ -180,17 +179,17 @@ public class FightTeam {
return true;
}
public boolean isPlayerInTeam(Player player) {
return players.containsKey(player);
public boolean isPlayerInTeam(LivingEntity player) {
return players.containsKey(player.getUniqueId());
}
public boolean canPlayerEntern(Player player) {
public boolean canPlayerEntern(LivingEntity player) {
return getFightPlayer(player).canEntern();
}
public boolean isPlayerLeader(Player player) {
public boolean isPlayerLeader(LivingEntity player) {
if(leader != null)
return leader.getPlayer().equals(player);
return leader.getEntity().equals(player);
else
return false;
}
@ -199,24 +198,27 @@ public class FightTeam {
skip = false;
ready = false;
schematic.reset();
invited.clear();
Set<Player> playerSet = new HashSet<>(players.keySet());
for(Player player : playerSet){
if(!Bukkit.getOnlinePlayers().contains(player))
removePlayer(player);
}
Set<UUID> playerSet = new HashSet<>(players.keySet());
playerSet.removeIf(uuid -> {
Player player = Bukkit.getPlayer(uuid);
if(player == null) {
removePlayer(players.get(uuid).getEntity());
return true;
}
return false;
});
FightPlayer leaderBackup = leader;
playerSet.removeIf(player -> !Bukkit.getOnlinePlayers().contains(player));
players.clear();
leader = null;
if(leaderBackup != null){
playerSet.remove(leaderBackup.getPlayer());
addMember(leaderBackup.getPlayer(), true);
playerSet.remove(leaderBackup.getEntity().getUniqueId());
addMember(leaderBackup.getEntity(), leaderBackup.getUser(), true);
}
playerSet.forEach(p -> addMember(p, true));
playerSet.forEach(uuid -> addMember(Bukkit.getPlayer(uuid), SteamwarUser.get(uuid), true));
if(ArenaMode.VariableTeams.contains(Config.mode) && isLeaderless()){
List<Player> onlinePlayers = new ArrayList<>(Bukkit.getOnlinePlayers());
@ -231,81 +233,104 @@ public class FightTeam {
}
public void broadcast(String message, Object... params) {
players.forEach((player, fp) -> FightSystem.getMessage().sendPrefixless(message, player, ChatMessageType.ACTION_BAR, params));
broadcast(player -> FightSystem.getMessage().sendPrefixless(message, player, ChatMessageType.ACTION_BAR, params));
}
public void broadcastSystem(String message, Object... params) {
players.forEach((player, fp) -> FightSystem.getMessage().send(message, player, params));
broadcast(player -> FightSystem.getMessage().send(message, player, params));
}
public void broadcastChat(Player sender, String message) {
players.forEach((player, fp) -> FightSystem.getMessage().sendPrefixless("TEAM_CHAT", player, ChatMessageType.CHAT, prefix, sender.getName(), message));
broadcast(player -> FightSystem.getMessage().sendPrefixless("TEAM_CHAT", player, ChatMessageType.CHAT, prefix, sender.getName(), message));
}
private void broadcast(Consumer<Player> f) {
players.forEach((uuid, fightPlayer) -> {
Player player = Bukkit.getPlayer(uuid);
if(player != null)
f.accept(player);
});
}
public void addMember(Player player) {
addMember(player, false);
addMember(player, SteamwarUser.get(player.getUniqueId()), false);
}
public void addMember(Player player, boolean silent) {
final List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, false);
FightPlayer fightPlayer = new FightPlayer(player, this);
players.put(player, fightPlayer);
invited.remove(player);
Permanent.getSpectatorTeam().removeEntry(player.getName());
team.addEntry(player.getName());
public void addMember(LivingEntity entity, SteamwarUser user) {
addMember(entity, user, false);
}
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
player.setHealth(20);
player.setFoodLevel(20);
player.getInventory().clear();
BountifulWrapper.impl.setAttackSpeed(player);
player.teleport(spawn);
memberKit.loadToPlayer(player);
GlobalRecorder.getInstance().playerJoins(player);
FightSystem.getTechHider().reloadChunks(player, chunksToReload, false);
public void addMember(LivingEntity entity, SteamwarUser user, boolean silent) {
FightPlayer fightPlayer = getFightPlayer(entity) != null ? getFightPlayer(entity) : new FightPlayer(entity, user, this);
fightPlayer.revive();
players.put(entity.getUniqueId(), fightPlayer);
Bukkit.getPluginManager().callEvent(new TeamSpawnEvent(fightPlayer));
Permanent.getSpectatorTeam().removeEntry(entity.getName());
team.addEntry(entity.getName());
entity.setHealth(20);
entity.teleport(spawn);
fightPlayer.ifPlayer(player -> {
BountifulWrapper.impl.setAttackSpeed(player);
player.setFoodLevel(20);
player.getInventory().clear();
FightSystem.getHullHider().updatePlayer(player);
if(FightState.Spectate.contains(FightState.getFightState())) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
} else {
Fight.setPlayerGamemode(player, GameMode.SURVIVAL);
(FightState.ingame() ? fightPlayer.getKit() : memberKit).loadToPlayer(player);
}
});
if(FightState.Running.contains(FightState.getFightState()))
fightPlayer.startEnternCountdown(Wincondition.getTimeOverCountdown());
fightPlayer.ifPlayer(player -> FightSystem.getTechHider().reloadChunks(player, Config.ArenaRegion, fightPlayer.canEntern() ? Region.EMPTY : Fight.getOpposite(this).getExtendRegion()));
if(isLeaderless())
setLeader(fightPlayer, silent);
else if(!silent)
FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, player.getName());
FightUI.addSubtitle("UI_PLAYER_JOINS", prefix, entity.getName());
}
public void removePlayer(Player player) {
FightPlayer fightPlayer = getFightPlayer(player);
public void removePlayer(LivingEntity entity) {
FightPlayer fightPlayer = getFightPlayer(entity);
Bukkit.getPluginManager().callEvent(new TeamLeaveEvent(fightPlayer));
PersonalKitCreator.closeIfInKitCreator(player);
List<ProtocolUtils.ChunkPos> chunksToReload = FightSystem.getTechHider().prepareChunkReload(player, true);
players.remove(player);
team.removeEntry(player.getName());
Permanent.getSpectatorTeam().addEntry(player.getName());
fightPlayer.ifPlayer(PersonalKitCreator::closeIfInKitCreator);
players.remove(entity.getUniqueId());
team.removeEntry(entity.getName());
Permanent.getSpectatorTeam().addEntry(entity.getName());
FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, player.getName());
FightUI.addSubtitle("UI_PLAYER_LEAVES", prefix, entity.getName());
if(fightPlayer.equals(leader))
removeLeader();
GlobalRecorder.getInstance().entityDespawns(player);
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.teleport(Config.SpecSpawn);
player.getInventory().clear();
entity.teleport(Config.SpecSpawn);
if(player.isOnline()){
FightSystem.getTechHider().reloadChunks(player, chunksToReload, true);
}
fightPlayer.ifPlayer(player -> {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.getInventory().clear();
if(player.isOnline()){
FightSystem.getHullHider().updatePlayer(player);
FightSystem.getTechHider().reloadChunks(player, Config.ArenaRegion, Fight.getOpposite(this).getExtendRegion());
if(ArenaMode.VariableTeams.contains(Config.mode))
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
}
});
}
public boolean isLeaderless() {
return leader == null;
}
public boolean isBlue(){
return blue;
}
public FightPlayer getLeader() {
return leader;
}
private void removeLeader() {
this.leader = null;
if(!players.isEmpty()) {
@ -316,7 +341,7 @@ public class FightTeam {
}
private void setLeader(FightPlayer leader, boolean silent) {
PersonalKitCreator.closeIfInKitCreator(leader.getPlayer());
leader.ifPlayer(PersonalKitCreator::closeIfInKitCreator);
this.leader = leader;
designatedLeader = null;
@ -324,41 +349,41 @@ public class FightTeam {
setReady(false);
if(!silent)
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getPlayer().getName());
FightUI.addSubtitle("UI_LEADER_JOINS", prefix, leader.getEntity().getName());
Optional<Integer> maxRank = SchematicNode.getAllAccessibleSchematicsOfType(SteamwarUser.get(leader.getPlayer().getUniqueId()).getId(), Config.SchematicType.toDB()).stream().map(SchematicNode::getRank).max(Integer::compare);
if(Config.RanksEnabled)
schemRank = maxRank.orElse(1);
else
schemRank = maxRank.isPresent() ? 1 : 0;
publicsOnly = SchematicNode.getAllAccessibleSchematicsOfType(leader.getUser().getId(), Config.SchematicType.toDB()).isEmpty();
if(!Config.PersonalKits)
leader.setKit(Kit.getKitByName(Config.LeaderDefault));
Player player = leader.getPlayer();
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
chooseSchemKit.loadToPlayer(player);
else
notReadyKit.loadToPlayer(player);
leader.ifPlayer(player -> {
if(FightState.getFightState() != FightState.POST_SCHEM_SETUP)
chooseSchemKit.loadToPlayer(player);
else
notReadyKit.loadToPlayer(player);
});
if(FightState.getFightState() == FightState.PRE_LEADER_SETUP && !Fight.getOpposite(this).isLeaderless()){
FightState.setFightState(FightState.PRE_SCHEM_SETUP);
}
leader.ifAI(ai -> pasteSchem(ai.chooseSchematic()));
}
public Collection<FightPlayer> getPlayers() {
return players.values();
}
public boolean isReady() {
return ready;
}
public void pasteSchem() {
testPasteAction();
}
public void pasteSchem(SchematicNode schematic){
if(schematic.getSchemtype().check()) {
FightStatistics.unrank();
FightSystem.getMessage().broadcast("SCHEMATIC_UNCHECKED", getColoredName());
}
setSchem(schematic);
testPasteAction();
}
@ -386,7 +411,7 @@ public class FightTeam {
}
public void setReady(boolean ready) {
Player l = leader.getPlayer();
LivingEntity l = leader.getEntity();
if(!schematic.hasSchematic()){
FightSystem.getMessage().sendPrefixless("SCHEMATIC_REQUIRED", l, ChatMessageType.ACTION_BAR);
@ -396,12 +421,12 @@ public class FightTeam {
this.ready = ready;
if(ready) {
broadcast("TEAM_READY");
readyKit.loadToPlayer(l);
leader.ifPlayer(readyKit::loadToPlayer);
if(Fight.getOpposite(this).isReady() || ArenaMode.SoloLeader.contains(Config.mode))
FightState.setFightState(FightState.PRE_RUNNING);
} else {
broadcast("TEAM_NOT_READY");
notReadyKit.loadToPlayer(l);
leader.ifPlayer(notReadyKit::loadToPlayer);
}
}
@ -419,32 +444,16 @@ public class FightTeam {
}
}
public Set<Player> getInvited() {
return invited;
}
public String getName() {
return name;
}
public String getColoredName() {
return prefix + name;
}
public String getPrefix() {
return prefix;
}
public int getSchematic() {
return schematic.getId();
}
public Location getSpawn() {
return spawn;
}
public double getCurrentHearts() {
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getPlayer().getHealth()).sum();
return players.values().stream().filter(FightPlayer::isLiving).mapToDouble(fp -> fp.getEntity().getHealth()).sum();
}
public double getHeartRatio(){
@ -460,10 +469,6 @@ public class FightTeam {
return (int) players.values().stream().filter(FightPlayer::isLiving).count();
}
public ChatColor getColor() {
return color;
}
@Override
public String toString() {
return name;
@ -478,17 +483,18 @@ public class FightTeam {
@Override
public void enable() {
for(FightPlayer fightPlayer : players.values()) {
Player player = fightPlayer.getPlayer();
PersonalKitCreator.closeIfInKitCreator(player);
fightPlayer.ifPlayer(player -> {
PersonalKitCreator.closeIfInKitCreator(player);
player.closeInventory();
fightPlayer.getKit().loadToPlayer(player);
player.closeInventory();
fightPlayer.getKit().loadToPlayer(player);
});
}
}
@Override
public void disable() {
players.values().forEach(fightPlayer -> fightPlayer.getPlayer().getInventory().clear());
players.values().forEach(fightPlayer -> fightPlayer.ifPlayer(p -> p.getInventory().clear()));
}
}
@ -501,14 +507,14 @@ public class FightTeam {
@Override
public void enable() {
players.values().forEach(fightPlayer -> {
Fight.setPlayerGamemode(fightPlayer.getPlayer(), GameMode.SPECTATOR);
fightPlayer.getPlayer().teleport(FightTeam.this.spawn);
fightPlayer.ifPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SPECTATOR));
fightPlayer.getEntity().teleport(FightTeam.this.spawn);
});
}
@Override
public void disable() {
players.values().forEach(fightPlayer -> Fight.setPlayerGamemode(fightPlayer.getPlayer(), GameMode.SURVIVAL));
players.values().forEach(fightPlayer -> fightPlayer.ifPlayer(player -> Fight.setPlayerGamemode(player, GameMode.SURVIVAL)));
}
}
}

Datei anzeigen

@ -21,11 +21,13 @@ package de.steamwar.fightsystem.fight;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
@ -39,11 +41,8 @@ import java.util.Objects;
public class FightWorld extends StateDependent {
private static final boolean paper = Bukkit.getVersion().contains("git-Paper");
public static boolean isPaper(){
return paper;
}
@Getter
private static final boolean PAPER = Bukkit.getVersion().contains("git-Paper");
public FightWorld() {
super(ArenaMode.Restartable.contains(Config.mode) || Config.replayserver(), FightState.Schem);
@ -57,7 +56,7 @@ public class FightWorld extends StateDependent {
@Override
public void disable() {
resetWorld();
Bukkit.getScheduler().runTask(FightSystem.getPlugin(), FightWorld::resetWorld); //Delay to prevent raceconditions with techhider and hullhider
}
public static void forceLoad(){

Datei anzeigen

@ -23,10 +23,13 @@ import de.steamwar.core.Core;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.commands.GUI;
import de.steamwar.fightsystem.listener.PersonalKitCreator;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.utils.ItemBuilder;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -45,6 +48,12 @@ import java.util.function.Consumer;
public class HotbarKit extends Kit {
public static final HotbarKit SPECTATOR_KIT = new HotbarKit();
static {
for(int i = 0; i < 9; i++)
SPECTATOR_KIT.setItem(i, "JOIN_REQUEST", new ItemBuilder(Material.PAPER).build(), GUI::joinRequest);
}
private static final int HOTBAR_SIZE = 9;
private final String[] nameTags;
@ -87,8 +96,8 @@ public class HotbarKit extends Kit {
private static final Set<Player> clicked = new HashSet<>();
public HotbarKitListener() {
new StateDependentListener(ArenaMode.AntiReplay, FightState.Setup, this);
new StateDependentTask(ArenaMode.AntiReplay, FightState.Setup, clicked::clear, 10, 10);
new StateDependentListener(ArenaMode.AntiReplay, FightState.All, this);
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, clicked::clear, 10, 10);
}
@EventHandler

Datei anzeigen

@ -0,0 +1,110 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2022 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.fight;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.inventory.SWItem;
import de.steamwar.inventory.SWListInv;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.ClickEvent;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.stream.Collectors;
public class JoinRequest {
private static final Map<Player, JoinRequest> activeRequests = new HashMap<>();
public static List<SWListInv.SWListEntry<Player>> openRequests(Player p, FightTeam team) {
return activeRequests.values().stream().filter(
request -> request.waitOnApproval.contains(team)
).map(request -> {
SWItem item = SWItem.getPlayerSkull(request.player);
item.setLore(Arrays.asList(
FightSystem.getMessage().parse("REQUESTS_LEFT_CLICK", p),
FightSystem.getMessage().parse("REQUESTS_RIGHT_CLICK", p)
));
return new SWListInv.SWListEntry<>(item, request.player);
}).collect(Collectors.toList());
}
public static void clearRequests() {
activeRequests.clear();
}
public static JoinRequest get(Player player) {
return activeRequests.get(player);
}
private final Player player;
private final FightTeam team;
private final Set<FightTeam> waitOnApproval;
public JoinRequest(Player player, FightTeam team) {
this.player = player;
this.team = team;
this.waitOnApproval = new HashSet<>(FightState.ingame() ? Fight.teams() : Collections.singleton(team));
Set<FightTeam> alreadyAccepted = new HashSet<>();
activeRequests.put(player, this);
for(FightTeam t : waitOnApproval) {
FightPlayer leader = t.getLeader();
if(leader == null)
continue;
if(leader.getEntity() == null)
continue;
leader.ifPlayer(leaderPlayer -> FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_NOTIFICATION", leaderPlayer, "REQUESTS", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/requests"), player.getName(), team.getColoredName()));
leader.ifAI(ai -> {
if(ai.acceptJoinRequest(player, team))
alreadyAccepted.add(t);
});
}
FightSystem.getMessage().sendPrefixless("JOIN_REQUEST_CONFIRMATION", player, ChatMessageType.ACTION_BAR);
alreadyAccepted.forEach(this::accept);
}
public boolean required(FightTeam decider) {
return waitOnApproval.contains(decider);
}
public void accept(FightTeam acceptor) {
waitOnApproval.remove(acceptor);
if(waitOnApproval.isEmpty()) {
team.addMember(player);
activeRequests.remove(player);
}
}
public void decline(FightTeam declinor) {
FightSystem.getMessage().sendPrefixless("REQUEST_YOUR_DECLINED", player, ChatMessageType.ACTION_BAR);
waitOnApproval.forEach(t -> t.broadcast("REQUEST_DECLINED", player.getName()));
silentDecline();
}
public void silentDecline() {
activeRequests.remove(player);
}
}

Datei anzeigen

@ -30,6 +30,7 @@ import de.steamwar.inventory.SWInventory;
import de.steamwar.inventory.SWItem;
import de.steamwar.sql.PersonalKit;
import de.steamwar.sql.SteamwarUser;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@ -69,11 +70,19 @@ public class Kit {
}
}
@Getter
private final String name;
@Getter
private final ItemStack[] inventory;
@Getter
private final ItemStack[] armor;
@Getter
private final Collection<PotionEffect> effects;
/* In which stage is entern allowed? */
@Getter
private final int enterStage;
/* Is this kit allowed to set/handle tnt? */
@Getter
private final boolean tnt;
private final boolean leaderAllowed;
private final boolean memberAllowed;
@ -140,10 +149,6 @@ public class Kit {
return kits;
}
public String getName() {
return name;
}
public boolean canUseKit(boolean leader){
if (leader) {
return leaderAllowed;
@ -156,10 +161,6 @@ public class Kit {
return !memberAllowed;
}
public ItemStack[] getInventory() {
return inventory;
}
public boolean contains(ItemStack stack) {
for(ItemStack i : inventory) {
if(similar(i, stack))
@ -172,24 +173,6 @@ public class Kit {
return false;
}
public ItemStack[] getArmor() {
return armor;
}
public Collection<PotionEffect> getEffects() {
return effects;
}
/* Is this kit allowed to set/handle tnt? */
public boolean isTnt(){
return tnt;
}
/* In which stage is entern allowed? */
public int getEnterStage() {
return enterStage;
}
public void toPersonalKit(PersonalKit kit) {
kit.setContainer(inventory, armor);
}

Datei anzeigen

@ -21,58 +21,88 @@ package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.events.TeamLeaveEvent;
import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
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.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class ArenaBorder implements Listener {
private final Border spectatorBorder = new Border(Config.PlayerRegion, true, 5, "NO_ARENA_LEAVING", "ArenaBorder.spectatorBorder");
private final Border playerBorder = new Border(Config.PlayerRegion.to2d(), true, 5, "NO_ARENA_LEAVING", "ArenaBorder.playerBorder");
public ArenaBorder() {
new StateDependentListener(ArenaMode.All, FightState.All, this);
new StateDependentTask(ArenaMode.All, FightState.Running, this::damage, 2, 2);
new StateDependentListener(!Config.GroundWalkable, FightState.AntiRunning, new Listener() {
@EventHandler
public void onMove(PlayerMoveEvent e) {
Player player = e.getPlayer();
if(e.getTo().getY() <= Config.PlayerRegion.getMinY() && playerBorder.contains(player))
player.teleport(Fight.getPlayerTeam(player).getSpawn());
}
});
}
@EventHandler
public void arenaBorder(PlayerMoveEvent event){
Player player = event.getPlayer();
FightTeam team = Fight.getPlayerTeam(player);
public void onPlayerJoin(PlayerJoinEvent e) {
addToSpectator(e.getPlayer());
}
if(Config.ArenaLeaveable && team == null)
return;
@EventHandler
public void onTeamJoin(TeamSpawnEvent e) {
e.getFightPlayer().ifPlayer(player -> {
spectatorBorder.removePlayer(player);
playerBorder.addPlayer(player);
});
}
Location to = event.getTo();
assert to != null;
@EventHandler
public void onTeamDeath(TeamDeathEvent e) {
e.getFightPlayer().ifPlayer(player -> {
playerBorder.removePlayer(player);
addToSpectator(player);
});
}
if(Config.PlayerRegion.inRegion(to))
return;
@EventHandler
public void onTeamLeave(TeamLeaveEvent e) {
e.getFightPlayer().ifPlayer(player -> {
playerBorder.removePlayer(player);
addToSpectator(player);
});
}
if(to.getY() <= Config.PlayerRegion.getMinY() && player.getGameMode() != GameMode.SPECTATOR && team != null) {
if(!Config.GroundWalkable && !FightState.infight())
player.teleport(team.getSpawn());
return;
}
player.teleport(event.getFrom());
FightSystem.getMessage().sendPrefixless("NO_ARENA_LEAVING", player, ChatMessageType.ACTION_BAR);
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e) {
spectatorBorder.removePlayer(e.getPlayer());
}
private void damage() {
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
FightTeam team = Fight.getPlayerTeam(player);
if(team != null && player.getLocation().getY() <= Config.PlayerRegion.getMinY())
player.damage(1);
}
Fight.teams().forEach(team -> {
for(FightPlayer fp : team.getPlayers()) {
LivingEntity entity = fp.getEntity();
if(fp.isLiving() && entity.getLocation().getY() <= Config.PlayerRegion.getMinY())
entity.damage(1);
}
});
}
private void addToSpectator(Player player) {
if(Config.ArenaLeaveable || !player.isOnline() || playerBorder.contains(player))
return;
spectatorBorder.addPlayer(player);
}
}

Datei anzeigen

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

Datei anzeigen

@ -85,7 +85,7 @@ public class ArrowStopper {
}
private boolean checkBlock(Block block) {
return Config.HiddenBlocks.contains(block.getType().name().toLowerCase());
return Config.HiddenBlocks.contains(block.getType());
}
private boolean invalidEntity(Projectile entity) {

Datei anzeigen

@ -0,0 +1,148 @@
/*
* 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/>.
*/
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.fightsystem.utils.Region;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.logging.Level;
public class Border {
private final Map<UUID, Set<Block>> ghostBarriers = new HashMap<>();
private final Map<UUID, Location> lastLocation = new HashMap<>();
private final boolean contain;
private final String resetMessage;
private final String name;
private final Region region;
private final int ghostRange;
private final int ghostSize;
public Border(Region region, boolean contain, int ghostRange, String resetMessage, String name) {
this.contain = contain;
this.resetMessage = resetMessage;
this.name = name;
this.region = region;
this.ghostRange = ghostRange;
this.ghostSize = 2*ghostRange + 1;
new StateDependentTask(ArenaMode.All, FightState.All, this::run, 1, 1);
}
public void addPlayer(Player player) {
if(ghostBarriers.containsKey(player.getUniqueId()))
return;
ghostBarriers.put(player.getUniqueId(), new HashSet<>());
lastLocation.put(player.getUniqueId(), player.getLocation());
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was added to border " + name);
}
public boolean contains(Player player) {
return ghostBarriers.containsKey(player.getUniqueId());
}
public void removePlayer(Player player) {
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> player.getName() + " was removed from border " + name);
lastLocation.remove(player.getUniqueId());
Set<Block> blocks = ghostBarriers.remove(player.getUniqueId());
if(blocks == null || !player.isOnline())
return;
for(Block block : blocks)
sendChange(player, block, Material.AIR);
}
private void run() {
List<UUID> offline = new ArrayList<>();
for(Map.Entry<UUID, Set<Block>> entry : ghostBarriers.entrySet()) {
UUID uuid = entry.getKey();
Player player = Bukkit.getPlayer(uuid);
if(player == null) {
offline.add(uuid);
continue;
}
Location location = player.getLocation();
if(region.playerInRegion(location) != contain) {
player.teleport(lastLocation.get(uuid));
FightSystem.getMessage().sendPrefixless(resetMessage, player, ChatMessageType.ACTION_BAR);
return;
}
Set<Block> ghostBlocks = entry.getValue();
Region ghostRegion = Region.fromSize(location.getBlockX() - ghostRange, location.getBlockY() - ghostRange, location.getBlockZ() - ghostRange, ghostSize, ghostSize, ghostSize);
ghostBlocks.removeIf(block -> {
if(!ghostRegion.inRegion(block)) {
sendChange(player, block, Material.AIR);
return true;
}
return false;
});
if(contain) {
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX()-1, region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY()-1, region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ()-1, region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMaxX(), region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMaxY(), region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMaxZ(), region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
} else {
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMinZ(), region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMaxX()-1, region.getMinY(), region.getMinZ(), 1, region.getSizeY(), region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMaxY()-1, region.getMinZ(), region.getSizeX(), 1, region.getSizeZ()).intersection(ghostRegion));
borderIteration(player, ghostBlocks, Region.fromSize(region.getMinX(), region.getMinY(), region.getMaxZ()-1, region.getSizeX(), region.getSizeY(), 1).intersection(ghostRegion));
}
lastLocation.put(entry.getKey(), location);
}
offline.forEach(uuid -> FightSystem.getPlugin().getLogger().log(Level.INFO, () -> uuid + " was removed from border " + name));
offline.forEach(ghostBarriers::remove);
offline.forEach(lastLocation::remove);
}
private void borderIteration(Player player, Set<Block> ghostBlocks, Region border) {
border.forEach((x, y, z) -> {
Block block = Config.world.getBlockAt(x, y, z);
if(ghostBlocks.add(block))
sendChange(player, block, Material.BARRIER);
});
}
private void sendChange(Player player, Block block, Material type) {
if(block.getType() == Material.AIR)
FlatteningWrapper.impl.sendBlockChange(player, block, type);
}
}

Datei anzeigen

@ -63,7 +63,7 @@ public class Chat implements Listener {
event.setCancelled(true);
}
private void broadcastChat(String message, Object... params) {
public static void broadcastChat(String message, Object... params) {
GlobalRecorder.getInstance().chat(message, params);
FightSystem.getMessage().chat(message, params);
}

Datei anzeigen

@ -26,7 +26,7 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import de.steamwar.sql.UserPerm;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -47,7 +47,7 @@ public class Check implements Listener {
Player player = e.getPlayer();
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(allowedToCheck(user))
if(user.hasPerm(UserPerm.CHECK))
return;
SchematicNode schem = SchematicNode.getSchematicNode(Config.CheckSchemID);
@ -68,11 +68,4 @@ public class Check implements Listener {
FightSystem.getMessage().send("CHECK_COMMAND_LOCKED", player);
Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!");
}
private boolean allowedToCheck(SteamwarUser user) {
return user.getUserGroup() == UserGroup.Supporter ||
user.getUserGroup() == UserGroup.Developer ||
user.getUserGroup() == UserGroup.Moderator ||
user.getUserGroup() == UserGroup.Admin;
}
}

Datei anzeigen

@ -27,6 +27,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
public class DenyInventoryMovement implements Listener {
@ -48,4 +49,9 @@ public class DenyInventoryMovement implements Listener {
if(!PersonalKitCreator.inKitCreator(event.getWhoClicked()))
event.setCancelled(true);
}
@EventHandler
public void onItemPickup(PlayerPickupItemEvent event) {
event.setCancelled(true);
}
}

Datei anzeigen

@ -19,7 +19,6 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
@ -28,7 +27,7 @@ import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.winconditions.Winconditions;
import net.md_5.bungee.api.ChatMessageType;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
@ -43,25 +42,25 @@ public class InFightDamage implements Listener {
@EventHandler
public void handleEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(!(event.getEntity() instanceof Player))
if(!(event.getEntity() instanceof LivingEntity))
//Target is not a player
return;
Player player = ((Player) event.getEntity());
LivingEntity player = ((LivingEntity) event.getEntity());
if(!Fight.fighting(player))
return;
Player damager;
LivingEntity damager;
if(event.getDamager() instanceof Player) {
damager = ((Player) event.getDamager()).getPlayer();
if(event.getDamager() instanceof LivingEntity) {
damager = (LivingEntity) event.getDamager();
}else if(event.getDamager() instanceof Arrow) {
Arrow damagerArrow = (Arrow) event.getDamager();
if(!(damagerArrow.getShooter() instanceof Player))
if(!(damagerArrow.getShooter() instanceof LivingEntity))
//Shooter is not a player
return;
damager = (Player) damagerArrow.getShooter();
damager = (LivingEntity) damagerArrow.getShooter();
}else{
//Damager is not a player
return;

Datei anzeigen

@ -26,11 +26,12 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.FightUI;
import de.steamwar.fightsystem.utils.SWSound;
import org.bukkit.entity.Player;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.function.Consumer;
@ -42,20 +43,20 @@ public class IngameDeath implements Listener {
}
@EventHandler
public void broadcastDeath(PlayerDeathEvent event) {
public void broadcastDeath(EntityDeathEvent event) {
onPlayerEnd(event.getEntity(), fightPlayer -> {
FightUI.addSubtitle("UI_PLAYER_DEATH", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName());
FightUI.addSubtitle("UI_PLAYER_DEATH", fightPlayer.getTeam().getPrefix(), fightPlayer.getEntity().getName());
Fight.playSound(SWSound.ENTITY_WITHER_DEATH.getSound(), 100.0F, 1.0F);
});
}
@EventHandler
public void broadcastQuit(PlayerQuitEvent event) {
onPlayerEnd(event.getPlayer(), fightPlayer -> FightUI.addSubtitle("UI_PLAYER_LEAVE", fightPlayer.getTeam().getPrefix(), fightPlayer.getPlayer().getName()));
onPlayerEnd(event.getPlayer(), fightPlayer -> FightUI.addSubtitle("UI_PLAYER_LEAVE", fightPlayer.getTeam().getPrefix(), fightPlayer.getEntity().getName()));
}
@EventHandler(priority = EventPriority.MONITOR)
public void handlePlayerDeath(PlayerDeathEvent event) {
public void handlePlayerDeath(EntityDeathEvent event) {
onPlayerEnd(event.getEntity(), FightPlayer::setOut);
}
@ -64,8 +65,11 @@ public class IngameDeath implements Listener {
onPlayerEnd(event.getPlayer(), FightPlayer::setOut);
}
private void onPlayerEnd(Player player, Consumer<FightPlayer> withLivingPlayer) {
FightPlayer fightPlayer = Fight.getFightPlayer(player);
private void onPlayerEnd(Entity player, Consumer<FightPlayer> withLivingPlayer) {
if(!(player instanceof LivingEntity))
return;
FightPlayer fightPlayer = Fight.getFightPlayer((LivingEntity) player);
if(fightPlayer == null || !fightPlayer.isLiving())
return;

Datei anzeigen

@ -0,0 +1,74 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2022 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 de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.HotbarKit;
import de.steamwar.fightsystem.fight.JoinRequest;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import org.bukkit.Bukkit;
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.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
public class JoinRequestListener implements Listener {
public JoinRequestListener() {
new OneShotStateDependent(ArenaMode.VariableTeams, FightState.PreLeaderSetup, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), JoinRequest::clearRequests));
new OneShotStateDependent(ArenaMode.VariableTeams, FightState.PreRunning, () -> Bukkit.getScheduler().runTask(FightSystem.getPlugin(), JoinRequest::clearRequests));
new StateDependentListener(ArenaMode.VariableTeams, FightState.All, this);
}
@EventHandler(priority = EventPriority.HIGH)
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
FightPlayer fp = Fight.getFightPlayer(player);
if (!Config.ArenaLeaveable && (fp == null || !fp.isLiving())) {
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
}
}
@EventHandler
public void handlePlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if(Fight.fighting(player)) {
HotbarKit.SPECTATOR_KIT.loadToPlayer(player);
}
}
@EventHandler
public void onLeave(PlayerQuitEvent event) {
JoinRequest request = JoinRequest.get(event.getPlayer());
if(request != null)
request.silentDecline();
}
}

Datei anzeigen

@ -40,6 +40,8 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.SpawnerSpawnEvent;
@ -93,11 +95,15 @@ public class Permanent implements Listener {
event.setJoinMessage(null);
Player player = event.getPlayer();
FightPlayer fp = Fight.getFightPlayer(player);
if (!Config.ArenaLeaveable && !Fight.fighting(player)) {
if (!Config.ArenaLeaveable && fp == null) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
spectatorTeam.addEntry(player.getName());
player.teleport(Config.SpecSpawn);
} else if(fp != null && !fp.isLiving()) {
Fight.setPlayerGamemode(player, GameMode.SPECTATOR);
player.teleport(fp.getTeam().getSpawn());
}
}
@ -148,14 +154,6 @@ public class Permanent implements Listener {
e.setCancelled(true);
}
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
Block block = e.getBlock();
for(ItemStack stack : block.getDrops(e.getPlayer().getItemInHand()))
Config.world.dropItemNaturally(block.getLocation(), stack);
}
@EventHandler
public void onDropPickup(PlayerPickupItemEvent e) {
if(!(Config.ArenaRegion.inRegion(e.getItem().getLocation())))
@ -178,6 +176,18 @@ public class Permanent implements Listener {
}
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onExplosion(EntityExplodeEvent e) {
e.blockList().removeIf(block -> {
if(block.getType() == Material.TNT) {
return false;
} else {
block.setType(Material.AIR);
return true;
}
});
}
@EventHandler
public void onWorldLoad(WorldLoadEvent e) {
if(!Config.ArenaLeaveable)
@ -209,4 +219,25 @@ public class Permanent implements Listener {
if(e.getItem().getType() == Material.TNT || FlatteningWrapper.impl.isFacingWater(block))
e.setCancelled(true);
}
@EventHandler
public void blockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
if(Fight.teams().stream().anyMatch(team -> team.getExtendRegion().inRegion(block)))
return;
event.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR);
}
@EventHandler
public void blockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if(Config.BlueExtendRegion.getMinY() <= block.getY())
return;
event.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", event.getPlayer(), ChatMessageType.ACTION_BAR);
}
}

Datei anzeigen

@ -23,6 +23,9 @@ import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.fightsystem.ArenaMode;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.events.TeamLeaveEvent;
import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
@ -31,7 +34,10 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.utils.*;
import de.steamwar.fightsystem.utils.BountifulWrapper;
import de.steamwar.fightsystem.utils.CraftbukkitWrapper;
import de.steamwar.fightsystem.utils.FlatteningWrapper;
import de.steamwar.fightsystem.utils.SWSound;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -139,6 +145,11 @@ public class Recording implements Listener {
return packet;
}
@EventHandler
public void onPlayerSpawn(TeamSpawnEvent e) {
GlobalRecorder.getInstance().playerJoins(e.getFightPlayer().getEntity(), e.getFightPlayer().getUser());
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerMove(PlayerMoveEvent e){
if(isNotSent(e.getPlayer()))
@ -148,19 +159,13 @@ public class Recording implements Listener {
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
if(isNotSent(e.getEntity()))
return;
GlobalRecorder.getInstance().entityDespawns(e.getEntity());
public void onPlayerDeath(TeamDeathEvent e) {
GlobalRecorder.getInstance().entityDespawns(e.getFightPlayer().getEntity());
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent e){
if(isNotSent(e.getPlayer()))
return;
GlobalRecorder.getInstance().entityDespawns(e.getPlayer());
public void onPlayerLeave(TeamLeaveEvent e) {
GlobalRecorder.getInstance().entityDespawns(e.getFightPlayer().getEntity());
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
@ -281,19 +286,20 @@ public class Recording implements Listener {
if(!fp.isLiving())
continue;
Player player = fp.getPlayer();
BountifulWrapper.impl.recordHandItems(player);
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getChestplate()), "CHEST");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getBoots()), "FEET");
fp.ifPlayer(player -> {
BountifulWrapper.impl.recordHandItems(player);
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getHelmet()), "HEAD");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getChestplate()), "CHEST");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getLeggings()), "LEGS");
GlobalRecorder.getInstance().item(player, disarmNull(player.getInventory().getBoots()), "FEET");
});
}
}
private void despawnTeam(FightTeam team){
for(FightPlayer player : team.getPlayers()){
if(player.isLiving())
GlobalRecorder.getInstance().entityDespawns(player.getPlayer());
GlobalRecorder.getInstance().entityDespawns(player.getEntity());
}
}

Datei anzeigen

@ -22,109 +22,122 @@ package de.steamwar.fightsystem.listener;
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;
import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
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.utils.Region;
import net.md_5.bungee.api.ChatMessageType;
import de.steamwar.fightsystem.states.StateDependentTask;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
public class TeamArea implements Listener {
private static final Set<Player> realSpectator = new HashSet<>();
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;
this.spectatorBorder = new Border(team.getExtendRegion(), false, 5, "NO_TEAMAREA", team.getName() + ".spectatorBorder");
this.bordingBorder = new Border(team.getExtendRegion().to2d(), true, 1, "NO_ENTERN", team.getName() + ".boardingBorder");
public TeamArea() {
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)));
}
@EventHandler
public void teamAreas(PlayerMoveEvent event) {
Player player = event.getPlayer();
if(Config.isReferee(player))
return;
public void playerJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
if(Fight.getPlayerTeam(player) != team && !Config.isReferee(player))
spectatorBorder.addPlayer(player);
}
FightTeam team = Fight.getPlayerTeam(player);
Fight.teams().forEach(t -> checkInTeamRegion(event, t, player, team));
@EventHandler
public void teamJoin(TeamSpawnEvent e) {
FightPlayer fightPlayer = e.getFightPlayer();
if(fightPlayer.getTeam() == team) {
fightPlayer.ifPlayer(player -> {
spectatorBorder.removePlayer(player);
bordingBorder.addPlayer(player);
});
}
}
@EventHandler
public void teamLeave(TeamLeaveEvent e) {
FightPlayer fightPlayer = e.getFightPlayer();
fightPlayer.ifPlayer(spectatorBorder::addPlayer);
if(fightPlayer.getTeam() == team)
fightPlayer.ifPlayer(bordingBorder::removePlayer);
}
@EventHandler
public void boarding(BoardingEvent e) {
FightPlayer fightPlayer = e.getFightPlayer();
if(fightPlayer.getTeam() == team) {
fightPlayer.ifPlayer(bordingBorder::removePlayer);
} else {
fightPlayer.ifPlayer(spectatorBorder::removePlayer);
}
}
@EventHandler
public void teamDeath(TeamDeathEvent e) {
teamSpectator(e.getFightPlayer());
}
private void teamSpectator(FightPlayer fightPlayer) {
if(fightPlayer.getTeam() == team) {
fightPlayer.ifPlayer(bordingBorder::removePlayer);
} else {
fightPlayer.ifPlayer(spectatorBorder::addPlayer);
}
}
@EventHandler
public void playerQuit(PlayerQuitEvent e) {
realSpectator.remove(e.getPlayer());
Player player = e.getPlayer();
spectatorBorder.removePlayer(player);
bordingBorder.removePlayer(player);
realSpectator.remove(player);
}
@EventHandler
public void blockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
Block block = event.getBlock();
if(Config.BlueExtendRegion.inRegion(block) || Config.RedExtendRegion.inRegion(block))
return;
private void realSpectatorCheck() {
for(FightPlayer fightPlayer : team.getPlayers()) {
if(fightPlayer.isLiving())
continue;
event.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_BLOCK_PLACE", player, ChatMessageType.ACTION_BAR);
}
fightPlayer.ifPlayer(player -> {
boolean inRegion = team.getExtendRegion().playerInRegion(player.getLocation());
if(inRegion && !realSpectator.contains(player)) {
realSpectator.add(player);
@EventHandler
public void blockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if(Config.BlueExtendRegion.getMinY() <= block.getY())
return;
event.setCancelled(true);
FightSystem.getMessage().sendPrefixless("NO_BLOCK_BREAK", event.getPlayer(), ChatMessageType.ACTION_BAR);
}
private void checkInTeamRegion(PlayerMoveEvent event, FightTeam team, Player player, FightTeam playerTeam) {
boolean spectator = player.getGameMode() == GameMode.SPECTATOR;
if(!spectator && playerTeam != null && playerTeam.canPlayerEntern(player))
return; // Player can entern
Region region = team.getExtendRegion();
boolean inRegion = region.in2dRegion(event.getTo());
if(team == playerTeam) {
if(spectator) {
realSpectator(inRegion, player);
} else if (!playerTeam.canPlayerEntern(player) && !inRegion) {
reset(event, "NO_ENTERN"); // Leaving prior to entern
}
return; // Always allowed in own region
//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);
}
});
}
if(region.playerInRegion(event.getTo())) {
reset(event, "NO_TEAMAREA"); // Not allowed in region
if(team.getSchemRegion().playerInRegion(event.getTo()) && Config.PreperationArea >= 5){ // Preventing false positives due to small extension
player.kickPlayer(null);
Bukkit.getLogger().log(Level.INFO, player.getName() + " has entered a team area");
}
}
}
private void realSpectator(boolean inRegion, Player player) {
if(inRegion && !realSpectator.contains(player)) {
Fight.pseudoSpectator(player, false);
realSpectator.add(player);
}else if(!inRegion && realSpectator.contains(player)) {
Fight.pseudoSpectator(player, true);
realSpectator.remove(player);
}
}
private void reset(PlayerMoveEvent event, String message){
Player player = event.getPlayer();
player.teleport(event.getFrom());
FightSystem.getMessage().sendPrefixless(message, player, ChatMessageType.ACTION_BAR);
}
}

Datei anzeigen

@ -27,6 +27,7 @@ import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserPerm;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -43,7 +44,7 @@ public class TestJoin implements Listener {
Player player = event.getPlayer();
FightTeam fightTeam = Fight.getPlayerTeam(player);
if(Config.ReplayID != 0 && !SteamwarUser.get(player.getUniqueId()).getUserGroup().isAdminGroup()) {
if(Config.ReplayID != 0 && !SteamwarUser.get(player.getUniqueId()).hasPerm(UserPerm.MODERATION)) {
FightSystem.getMessage().send("CHECK_JOIN_DENIED", player);
player.kickPlayer("");
return;

Datei anzeigen

@ -71,19 +71,27 @@ public class WaterRemover implements Listener {
event.setYield(0); //No drops (additionally to world config)
FightTeam spawn = tnt.remove(event.getEntity().getEntityId());
if(spawn != null && event.blockList().isEmpty() && Fight.getOpposite(spawn).getExtendRegion().inRegion(event.getLocation())) {
checkBlock(event.getLocation().getBlock());
if(spawn != null && !spawn.getExtendRegion().inRegion(event.getLocation())) {
Block b = event.getLocation().getBlock();
for(int y = -1; y <= 1; y++) {
for(int z = -1; z <= 1; z++) {
for(int x = -1; x <= 1; x++) {
checkBlock(b.getRelative(x, y, z));
}
}
}
}
for(Block b : event.blockList()){
//b cannot be water or air due to current explosion
event.blockList().forEach(this::checkNeighbours);
}
checkBlock(b.getRelative(BlockFace.UP));
checkBlock(b.getRelative(BlockFace.EAST));
checkBlock(b.getRelative(BlockFace.WEST));
checkBlock(b.getRelative(BlockFace.NORTH));
checkBlock(b.getRelative(BlockFace.SOUTH));
}
private void checkNeighbours(Block b) {
checkBlock(b.getRelative(BlockFace.UP));
checkBlock(b.getRelative(BlockFace.EAST));
checkBlock(b.getRelative(BlockFace.WEST));
checkBlock(b.getRelative(BlockFace.NORTH));
checkBlock(b.getRelative(BlockFace.SOUTH));
checkBlock(b.getRelative(BlockFace.DOWN));
}
private void checkBlock(Block b) {
@ -98,10 +106,6 @@ public class WaterRemover implements Listener {
if(b.getY() < MIN_Y)
return;
checkBlock(b.getRelative(BlockFace.UP));
checkBlock(b.getRelative(BlockFace.EAST));
checkBlock(b.getRelative(BlockFace.WEST));
checkBlock(b.getRelative(BlockFace.NORTH));
checkBlock(b.getRelative(BlockFace.SOUTH));
checkNeighbours(b);
}
}

Datei anzeigen

@ -22,19 +22,17 @@ package de.steamwar.fightsystem.record;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import lombok.Getter;
import java.io.*;
import java.util.zip.GZIPOutputStream;
public class FileRecorder extends StateDependent implements Recorder {
@Getter
private static final File file = new File(Config.world.getWorldFolder(), "recording.recording");
private DataOutputStream outputStream;
public static File getFile() {
return file;
}
public FileRecorder(){
super(Config.ReplayID == 0, FightState.Recording);
register();

Datei anzeigen

@ -41,7 +41,7 @@ public class LiveRecorder extends StateDependent implements Recorder {
@Override
public void enable() {
try {
socket = new Socket(Config.spectateIP, Config.spectatePort);
socket = new Socket(Config.spectateIP, Config.SpectatePort);
socket.setSoTimeout(1); // Wait a maximum of 1ms on a blocking operation (flush)
socket.setSoLinger(true, 1); // Wait a maximum of 1ms on disable
socket.setTcpNoDelay(true); // Don't wait on ack

Datei anzeigen

@ -33,7 +33,7 @@ public class LiveServer {
private final ServerSocket socket;
public LiveServer() throws IOException {
socket = new ServerSocket(Config.spectatePort);
socket = new ServerSocket(Config.SpectatePort);
Bukkit.getScheduler().runTaskAsynchronously(FightSystem.getPlugin(), this::acceptConnections);
}

Datei anzeigen

@ -88,8 +88,8 @@ public class PacketProcessor implements Listener {
private final PacketSource source;
private final BukkitTask task;
private final LinkedList<Runnable> syncList = new LinkedList<>();
private final Set<Integer> hiddenBlockIds = Config.HiddenBlocks.stream().map(String::toUpperCase).map(Material::getMaterial).flatMap(m -> BlockIds.impl.materialToAllIds(m).stream()).collect(Collectors.toSet());
private final int obfuscateWith = BlockIds.impl.materialToId(Material.getMaterial(Config.ObfuscateWith.toUpperCase()));
private final Set<Integer> hiddenBlockIds = Config.HiddenBlocks.stream().flatMap(m -> BlockIds.impl.materialToAllIds(m).stream()).collect(Collectors.toSet());
private final int obfuscateWith = BlockIds.impl.materialToId(Config.ObfuscateWith);
private final FreezeWorld freezer = new FreezeWorld();
private final REntityServer entityServer = new REntityServer();
private final Map<Integer, REntity> entities = new HashMap<>();
@ -165,6 +165,11 @@ public class PacketProcessor implements Listener {
entityServer.addPlayer(player);
}
private void addREntity(int entityId, REntity entity) {
entities.put(entityId, entity);
FightSystem.getHullHider().updateREntity(entity);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent e) {
entityServer.addPlayer(e.getPlayer());
@ -235,7 +240,7 @@ public class PacketProcessor implements Listener {
execSync(() -> {
SteamwarUser user = SteamwarUser.get(userId);
entities.put(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn));
addREntity(entityId, new RPlayer(entityServer, user.getUUID(), user.getUserName(), Config.SpecSpawn));
team.addEntry(user.getUserName());
});
}
@ -257,8 +262,10 @@ public class PacketProcessor implements Listener {
execSync(() -> {
REntity entity = entities.get(entityId);
if(entity != null)
if(entity != null) {
entity.move(locX, locY, locZ, pitch, yaw, headYaw);
FightSystem.getHullHider().updateREntity(entity);
}
});
}
@ -267,8 +274,10 @@ public class PacketProcessor implements Listener {
execSync(() -> {
REntity entity = entities.remove(entityId);
if(entity != null)
if(entity != null) {
FightSystem.getHullHider().despawnREntity(entity);
entity.die();
}
});
}
@ -289,7 +298,7 @@ public class PacketProcessor implements Listener {
private void tntSpawn() throws IOException {
int entityId = source.readInt();
execSync(() -> entities.put(entityId, new REntity(entityServer, EntityType.PRIMED_TNT, Config.SpecSpawn)));
execSync(() -> addREntity(entityId, new REntity(entityServer, EntityType.PRIMED_TNT, Config.SpecSpawn)));
}
private void entityVelocity() throws IOException {
@ -344,13 +353,13 @@ public class PacketProcessor implements Listener {
private void arrowSpawn() throws IOException {
int entityId = source.readInt();
execSync(() -> entities.put(entityId, new REntity(entityServer, EntityType.ARROW, Config.SpecSpawn)));
execSync(() -> addREntity(entityId, new REntity(entityServer, EntityType.ARROW, Config.SpecSpawn)));
}
private void fireballSpawn() throws IOException {
int entityId = source.readInt();
execSync(() -> entities.put(entityId, new REntity(entityServer, EntityType.FIREBALL, Config.SpecSpawn)));
execSync(() -> addREntity(entityId, new REntity(entityServer, EntityType.FIREBALL, Config.SpecSpawn)));
}
private void send(ChatMessageType type) throws IOException {
@ -437,7 +446,10 @@ public class PacketProcessor implements Listener {
if(!Config.ArenaRegion.in2dRegion(x, z))
return; //Outside of the arena
execSync(() -> BlockIdWrapper.impl.setBlock(Config.world, x, y, z, TechHiderWrapper.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState));
execSync(() -> {
BlockIdWrapper.impl.setBlock(Config.world, x, y, z, TechHiderWrapper.ENABLED && hiddenBlockIds.contains(blockState) ? obfuscateWith : blockState);
FightSystem.getHullHider().blockUpdate(Config.world.getBlockAt(x, y, z), BlockIdWrapper.impl.idToMaterial(blockState));
});
}
private void particle() throws IOException {
@ -578,6 +590,7 @@ public class PacketProcessor implements Listener {
private void endReplay() {
HandlerList.unregisterAll(this);
entityServer.close();
entities.values().forEach(FightSystem.getHullHider()::despawnREntity);
entities.clear();
freezer.disable();

Datei anzeigen

@ -36,6 +36,7 @@ import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector;
@ -68,7 +69,7 @@ public interface Recorder {
if(FightState.AntiSpectate.contains(FightState.getFightState())){
for(FightPlayer player : team.getPlayers()){
if(player.isLiving()){
playerJoins(player.getPlayer());
playerJoins(player.getEntity(), player.getUser());
}
}
}
@ -148,9 +149,7 @@ public interface Recorder {
* 0x08: Message following
* */
default void playerJoins(Player p){
SteamwarUser user = SteamwarUser.get(p.getUniqueId());
default void playerJoins(LivingEntity p, SteamwarUser user){
write(0x00, p.getEntityId(), user.getId());
entityMoves(p);
}

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.fightsystem.states;
import lombok.Getter;
import java.util.*;
public enum FightState {
@ -48,12 +50,9 @@ public enum FightState {
public static final Set<FightState> AntiSpectate = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(SPECTATE)));
private static final Map<IStateDependent, Boolean> stateDependentFeatures = new HashMap<>();
@Getter
private static FightState fightState = PRE_LEADER_SETUP;
public static FightState getFightState() {
return fightState;
}
public static void registerStateDependent(IStateDependent stateDependent){
if(stateDependent.enabled().isEmpty())
return;

Datei anzeigen

@ -19,14 +19,28 @@
package de.steamwar.fightsystem.utils;
import com.comphenix.tinyprotocol.Reflection;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public interface BlockIdWrapper {
Class<?> worldServer = Reflection.getClass("{nms.server.level}.WorldServer");
Reflection.MethodInvoker getWorldHandle = Reflection.getTypedMethod(Reflection.getClass("{obc}.CraftWorld"), "getHandle", worldServer);
Class<?> craftPlayer = Reflection.getClass("{obc}.entity.CraftPlayer");
Class<?> entityPlayer = Reflection.getClass("{nms.server.level}.EntityPlayer");
Reflection.MethodInvoker getPlayer = Reflection.getTypedMethod(craftPlayer, "getHandle", entityPlayer);
BlockIdWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
Material idToMaterial(int blockState);
int blockToId(Block block);
void setBlock(World world, int x, int y, int z, int blockState);
void trackEntity(Player player, int entity);
void untrackEntity(Player player, int entity);
}

Datei anzeigen

@ -52,12 +52,12 @@ public class BungeeFightInfo {
Fight.getRedTeam().getColoredName(),
FightState.getFightState().name(),
StateDependentCountdown.getMainCountdown() != null ? StateDependentCountdown.getMainCountdown().getTimeLeft() : 0,
Fight.getBlueTeam().getLeader() != null ? SteamwarUser.get(Fight.getBlueTeam().getLeader().getPlayer().getUniqueId()).getId() : 0,
Fight.getRedTeam().getLeader() != null ? SteamwarUser.get(Fight.getRedTeam().getLeader().getPlayer().getUniqueId()).getId() : 0,
Fight.getBlueTeam().getLeader() != null ? Fight.getBlueTeam().getLeader().getUser().getId() : 0,
Fight.getRedTeam().getLeader() != null ? Fight.getRedTeam().getLeader().getUser().getId() : 0,
Fight.getBlueTeam().getSchematic(),
Fight.getRedTeam().getSchematic(),
Fight.getBlueTeam().getPlayers().stream().map(p -> SteamwarUser.get(p.getPlayer().getUniqueId()).getId()).collect(Collectors.toList()),
Fight.getRedTeam().getPlayers().stream().map(p -> SteamwarUser.get(p.getPlayer().getUniqueId()).getId()).collect(Collectors.toList()),
Fight.getBlueTeam().getPlayers().stream().map(p -> p.getUser().getId()).collect(Collectors.toList()),
Fight.getRedTeam().getPlayers().stream().map(p -> p.getUser().getId()).collect(Collectors.toList()),
Bukkit.getOnlinePlayers().stream().filter(p -> Fight.getPlayerTeam(p) == null).map(p -> SteamwarUser.get(p.getUniqueId()).getId()).collect(Collectors.toList())
));
}

Datei anzeigen

@ -19,8 +19,6 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.countdown.EnternCountdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
@ -53,8 +51,7 @@ public class EnterHandler implements IStateDependent {
private void registerTeam(FightTeam team){
for(FightPlayer fp : team.getPlayers()){
if(Config.EnterStages.size() > fp.getKit().getEnterStage() && fp.getKit().getEnterStage() >= 0)
fp.setEnternCountdown(new EnternCountdown(fp));
fp.startEnternCountdown(null);
}
}

Datei anzeigen

@ -35,6 +35,7 @@ import de.steamwar.network.packets.common.FightEndsPacket;
import de.steamwar.sql.Replay;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import lombok.Getter;
import org.bukkit.Bukkit;
import java.sql.Timestamp;
@ -46,6 +47,7 @@ import static de.steamwar.sql.Fight.create;
public class FightStatistics {
@Getter
private static boolean unranked = false;
public static void unrank() {
@ -94,12 +96,12 @@ public class FightStatistics {
Integer redSchem;
try {
blueSchem = SchematicNode.getSchematicNode(Fight.getBlueTeam().getSchematic()).getId();
} catch (SecurityException e) {
} catch (NullPointerException e) {
blueSchem = null;
}
try {
redSchem = SchematicNode.getSchematicNode(Fight.getRedTeam().getSchematic()).getId();
} catch (SecurityException e) {
} catch (NullPointerException e) {
redSchem = null;
}
@ -132,7 +134,7 @@ public class FightStatistics {
}
if (!Bukkit.getOnlinePlayers().isEmpty() && !unranked) {
NetworkSender.send(new FightEndsPacket((byte) win, blueSchem == null ? 0 : blueSchem, redSchem == null ? 0 : redSchem, Fight.getBlueTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(p -> SteamwarUser.get(p.getUniqueId())).map(SteamwarUser::getId).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(FightPlayer::getPlayer).map(p -> SteamwarUser.get(p.getUniqueId())).map(SteamwarUser::getId).collect(Collectors.toList()), gameMode, (int)(endTime.getEpochSecond() - starttime.toInstant().getEpochSecond())));
NetworkSender.send(new FightEndsPacket((byte) win, blueSchem == null ? 0 : blueSchem, redSchem == null ? 0 : redSchem, Fight.getBlueTeam().getPlayers().stream().map(FightPlayer::getUser).map(SteamwarUser::getId).collect(Collectors.toList()), Fight.getRedTeam().getPlayers().stream().map(FightPlayer::getUser).map(SteamwarUser::getId).collect(Collectors.toList()), gameMode, (int)(endTime.getEpochSecond() - starttime.toInstant().getEpochSecond())));
}
unranked = false;
@ -140,14 +142,13 @@ public class FightStatistics {
private int getLeader(FightTeam team) {
if (team.getLeader() != null)
return SteamwarUser.get(team.getLeader().getPlayer().getUniqueId()).getId();
return team.getLeader().getUser().getId();
else if (team.getDesignatedLeader() != null)
return SteamwarUser.get(team.getDesignatedLeader()).getId();
return 0;
}
private void savePlayerStats(FightPlayer fp, int fightId) {
SteamwarUser user = SteamwarUser.get(fp.getPlayer().getUniqueId());
de.steamwar.sql.FightPlayer.create(fightId, user.getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
de.steamwar.sql.FightPlayer.create(fightId, fp.getUser().getId(), fp.getTeam().isBlue(), fp.getKit().getName(), fp.getKills(), !fp.isLiving());
}
}

Datei anzeigen

@ -31,6 +31,7 @@ import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.fightsystem.winconditions.Wincondition;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -43,10 +44,8 @@ import java.util.stream.Collectors;
public class FightUI {
@Getter
private static FightUI instance;
public static FightUI getInstance() {
return instance;
}
public FightUI() {
new StateDependentTask(ArenaMode.AntiReplay, FightState.All, this::update, 20, 20);

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -49,4 +50,5 @@ public interface FlatteningWrapper {
boolean isFacingWater(Block dispenser);
boolean isCrouching(Player player);
void sendBlockChange(Player player, Block block, Material type);
}

Datei anzeigen

@ -0,0 +1,379 @@
/*
* 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.fightsystem.utils;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.entity.REntity;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.FightTeam;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.*;
import java.util.function.BiConsumer;
import java.util.logging.Level;
public class Hull {
private static boolean isOccluding(Material material) {
return material.isOccluding() || Config.HiddenBlocks.contains(material);
}
private final Region region;
private final boolean groundVisible;
private final BitSet occluding;
private final BitSet visibility;
private final Map<IntVector, Map<IntVector, BitSet>> blockVisibility = new HashMap<>();
private final Set<IntVector> uncoveredSurface = new HashSet<>();
private final HashSet<Player> players = new HashSet<>();
private final Set<Entity> entities = new HashSet<>();
private final Set<REntity> rentities = new HashSet<>();
public Hull(FightTeam team) {
this.region = team.getSchemRegion();
this.groundVisible = region.getMinY() != Config.PlayerRegion.getMinY();
this.occluding = new BitSet(region.volume());
this.visibility = new BitSet(region.volume());
IntVector[] directions;
if (groundVisible) {
directions = new IntVector[]{
new IntVector(1, 0, 0),
new IntVector(-1, 0, 0),
new IntVector(0, 1, 0),
new IntVector(0, -1, 0),
new IntVector(0, 0, 1),
new IntVector(0, 0, -1)
};
} else {
directions = new IntVector[]{
new IntVector(1, 0, 0),
new IntVector(-1, 0, 0),
new IntVector(0, -1, 0),
new IntVector(0, 0, 1),
new IntVector(0, 0, -1)
};
}
// Generate quadrants for each direction
for (IntVector direction : directions) {
Map<IntVector, BitSet> map = new HashMap<>();
for (int z = (direction.z == 0 ? -1 : 0); z <= 1; z += 2) {
for (int y = (direction.y == 0 ? -1 : 0); y <= 1; y += 2) {
for (int x = (direction.x == 0 ? -1 : 0); x <= 1; x += 2) {
map.put(new IntVector(x, y, z), new BitSet(region.volume()));
}
}
}
blockVisibility.put(direction, map);
}
}
public boolean blockPrecise(Player player, int chunkX, int chunkY, int chunkZ) {
return players.contains(player) && !region.chunkSectionOutside(chunkX, chunkY, chunkZ);
}
public boolean isBlockHidden(Player player, int x, int y, int z) {
return region.inRegion(x, y, z) && players.contains(player) && !visibility.get(((y - region.getMinY()) * region.getSizeZ() + (z - region.getMinZ())) * region.getSizeX() + (x - region.getMinX()));
}
public boolean isLocationHidden(Player player, Location location) {
return players.contains(player) && region.inRegion(location) && !visibility.get(new IntVector(location).toId(region));
}
public void addPlayer(Player player) {
if(players.add(player)) {
for(Entity entity : entities)
BlockIdWrapper.impl.untrackEntity(player, entity.getEntityId());
}
}
public void removePlayer(Player player, boolean activeRemoval) {
if(players.remove(player) && activeRemoval) {
for(Entity entity : entities)
BlockIdWrapper.impl.trackEntity(player, entity.getEntityId());
// techhider triggers block change sending
}
}
public void checkEntity(Entity entity) {
Location location = entity.getLocation();
if(region.inRegion(location) && !visibility.get(new IntVector(location).toId(region))) { //TODO more precise
if(entities.add(entity)) {
for(Player player : players)
BlockIdWrapper.impl.untrackEntity(player, entity.getEntityId());
}
} else {
if(entities.remove(entity)) {
for(Player player : players)
BlockIdWrapper.impl.trackEntity(player, entity.getEntityId());
}
}
}
public void removeEntity(Entity entity) {
entities.remove(entity);
}
public void checkREntity(REntity entity) {
Location location = new Location(Config.world, entity.getX(), entity.getY(), entity.getZ());
if(region.inRegion(location) && !visibility.get(new IntVector(location).toId(region))) { //TODO more precise
if(rentities.add(entity))
entity.hide(true);
} else {
if(rentities.remove(entity))
entity.hide(false);
}
}
public void removeREntity(REntity entity) {
rentities.remove(entity);
}
public void initialize() {
visibility.clear();
occluding.clear();
uncoveredSurface.clear();
for (Map<IntVector, BitSet> direction : blockVisibility.values()) {
for (BitSet set : direction.values())
set.clear();
}
long start = System.currentTimeMillis();
region.forEach((x, y, z) -> {
IntVector block = new IntVector(x, y, z);
if (isOccluding(Config.world.getBlockAt(x, y, z).getType()))
occluding.set(block.toId(region));
});
forEachBorder((root, direction) -> {
for (Map.Entry<IntVector, BitSet> quadrant : blockVisibility.get(direction).entrySet()) {
checkBlock(new NullList<>(), root, direction, quadrant.getKey(), quadrant.getValue());
}
});
FightSystem.getPlugin().getLogger().log(Level.INFO, () -> "[HullHider] initialisation finished: " + (System.currentTimeMillis() - start) + " ms, visible blocks: " + visibility.cardinality());
}
public void updateBlockVisibility(Block b, Material changedType) {
IntVector root = new IntVector(b.getX(), b.getY(), b.getZ());
if (root.notInRegion(region))
return;
int id = root.toId(region);
if (!occluding.get(id) || isOccluding(changedType))
return;
List<IntVector> uncovered = new ArrayList<>();
occluding.clear(id);
for (Map.Entry<IntVector, Map<IntVector, BitSet>> direction : blockVisibility.entrySet()) {
for (Map.Entry<IntVector, BitSet> quadrant : direction.getValue().entrySet()) {
if (quadrant.getValue().get(id)) {
quadrant.getValue().clear(id);
checkBlock(uncovered, root, direction.getKey(), quadrant.getKey(), quadrant.getValue());
}
}
}
if(uncovered.isEmpty())
return;
Set<IntVector> uncoveredSet = new HashSet<>(uncovered);
Iterator<Entity> it = entities.iterator();
while(it.hasNext()) {
Entity entity = it.next();
if(uncoveredSet.contains(new IntVector(entity.getLocation()))) { //TODO more precise
it.remove();
for(Player player : players)
BlockIdWrapper.impl.trackEntity(player, entity.getEntityId());
}
}
Iterator<REntity> rit = rentities.iterator();
while(rit.hasNext()) {
REntity entity = rit.next();
if(uncoveredSet.contains(new IntVector(new Location(Config.world, entity.getX(), entity.getY(), entity.getZ())))) { //TODO more precise
rit.remove();
entity.hide(false);
}
}
uncoveredSurface.addAll(uncoveredSet);
uncoveredSurface.remove(root);
}
public void sendUncoveredBlocks() {
Map<IntVector, List<IntVector>> sectionWise = new HashMap<>();
for(IntVector uncovered : uncoveredSurface) {
sectionWise.computeIfAbsent(new IntVector(uncovered.x >> 4, uncovered.y >> 4, uncovered.z >> 4), section -> new ArrayList<>()).add(uncovered);
}
uncoveredSurface.clear();
for (Map.Entry<IntVector, List<IntVector>> entry : sectionWise.entrySet()) {
Object packet = HullHiderWrapper.impl.generateBlockChangePacket(entry.getValue());
if(packet == null)
continue;
players.forEach(player -> TinyProtocol.instance.sendPacket(player, packet));
}
}
private void forEachBorder(BiConsumer<IntVector, IntVector> f) {
for (int x = region.getMinX(); x < region.getMaxX(); x++) {
for (int z = region.getMinZ(); z < region.getMaxZ(); z++) {
if (groundVisible)
f.accept(new IntVector(x, region.getMinY(), z), new IntVector(0, 1, 0));
f.accept(new IntVector(x, region.getMaxY() - 1, z), new IntVector(0, -1, 0));
}
}
for (int x = region.getMinX(); x < region.getMaxX(); x++) {
for (int y = region.getMinY(); y < region.getMaxY(); y++) {
f.accept(new IntVector(x, y, region.getMinZ()), new IntVector(0, 0, 1));
f.accept(new IntVector(x, y, region.getMaxZ() - 1), new IntVector(0, 0, -1));
}
}
for (int z = region.getMinZ(); z < region.getMaxZ(); z++) {
for (int y = region.getMinY(); y < region.getMaxY(); y++) {
f.accept(new IntVector(region.getMinX(), y, z), new IntVector(1, 0, 0));
f.accept(new IntVector(region.getMaxX() - 1, y, z), new IntVector(-1, 0, 0));
}
}
}
private void checkBlock(List<IntVector> uncovered, IntVector block, IntVector direction, IntVector quadrant, BitSet quadVisibility) {
if (block.notInRegion(region))
return;
int id = block.toId(region);
if (quadVisibility.get(id))
return;
quadVisibility.set(id);
if (!visibility.get(id)) {
visibility.set(id);
uncovered.add(block);
}
if (occluding.get(id))
return;
IntVector neighbour = block.add(direction);
checkBlock(uncovered, neighbour, direction, quadrant, quadVisibility);
boolean neigbourTransparent = boundedNonOccluding(neighbour);
boolean diagonalReachable = false;
if (direction.x == 0 && (neigbourTransparent || boundedNonOccluding(block.add(quadrant.x, 0, 0)))) {
checkBlock(uncovered, neighbour.add(quadrant.x, 0, 0), direction, quadrant, quadVisibility);
diagonalReachable = boundedNonOccluding(neighbour.add(quadrant.x, 0, 0));
}
if (direction.y == 0 && (neigbourTransparent || boundedNonOccluding(block.add(0, quadrant.y, 0)))) {
checkBlock(uncovered, neighbour.add(0, quadrant.y, 0), direction, quadrant, quadVisibility);
diagonalReachable = diagonalReachable || boundedNonOccluding(neighbour.add(0, quadrant.y, 0));
}
if (direction.z == 0 && (neigbourTransparent || boundedNonOccluding(block.add(0, 0, quadrant.z)))) {
checkBlock(uncovered, neighbour.add(0, 0, quadrant.z), direction, quadrant, quadVisibility);
diagonalReachable = diagonalReachable || boundedNonOccluding(neighbour.add(0, 0, quadrant.z));
}
if (diagonalReachable)
checkBlock(uncovered, neighbour.add(quadrant), direction, quadrant, quadVisibility);
}
private boolean boundedNonOccluding(IntVector block) {
return !(block.notInRegion(region) || occluding.get(block.toId(region)));
}
@Getter
@AllArgsConstructor
public static class IntVector {
private final int x;
private final int y;
private final int z;
public IntVector(Location location) {
this.x = location.getBlockX();
this.y = location.getBlockY();
this.z = location.getBlockZ();
}
public boolean notInRegion(Region region) {
return !region.inRegion(x, y, z);
}
public int toId(Region region) {
return ((y - region.getMinY()) * region.getSizeZ() + (z - region.getMinZ())) * region.getSizeX() + (x - region.getMinX());
}
public IntVector add(int x, int y, int z) {
return new IntVector(this.x + x, this.y + y, this.z + z);
}
public IntVector add(IntVector v) {
return add(v.x, v.y, v.z);
}
@Override
public int hashCode() {
return y << 24 ^ x << 12 ^ z;
}
@Override
public boolean equals(Object o) {
if(o == null || this.getClass() != o.getClass())
return false;
IntVector v = (IntVector) o;
return x == v.x && y == v.y && z == v.z;
}
@Override
public String toString() {
return x + "," + y + "," + z;
}
}
private static class NullList<E> extends AbstractList<E> {
@Override
public void add(int index, E element) {
// Straight to /dev/null!
}
@Override
public E get(int index) {
return null;
}
@Override
public int size() {
return 0;
}
}
}

Datei anzeigen

@ -0,0 +1,241 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2022 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.utils;
import com.comphenix.tinyprotocol.Reflection;
import com.comphenix.tinyprotocol.TinyProtocol;
import de.steamwar.core.Core;
import de.steamwar.entity.REntity;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.listener.Recording;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.techhider.TechHider;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.function.BiFunction;
import java.util.function.Function;
public class HullHider implements Listener {
private final Map<FightTeam, Hull> hullMap = new HashMap<>();
private final Hull[] hulls;
private final Map<Class<?>, BiFunction<Player, Object, Object>> packetHiders = new HashMap<>();
public HullHider() {
if(!TechHiderWrapper.ENABLED) {
hulls = new Hull[0];
return;
}
Fight.teams().forEach(team -> hullMap.put(team, new Hull(team)));
hulls = hullMap.values().toArray(new Hull[0]);
packetHiders.put(packetPlayOutWorldEvent, this::worldEventHider);
packetHiders.put(packetPlayOutExplosion, this::explosionHider);
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutWorldParticles", Core.getVersion() >= 18 ? double.class : float.class, 1.0);
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutNamedSoundEffect", int.class, 8.0);
if(Core.getVersion() >= 9 && Core.getVersion() < 18)
posHiderGenerator("{nms.network.protocol.game}.PacketPlayOutCustomSoundEffect", int.class, 8.0);
new StateDependentListener(TechHiderWrapper.ENABLED, FightState.Schem, this);
new StateDependent(TechHiderWrapper.ENABLED, FightState.Schem) {
@Override
public void enable() {
packetHiders.forEach(TinyProtocol.instance::addFilter);
Bukkit.getOnlinePlayers().forEach(HullHider.this::updatePlayer);
}
@Override
public void disable() {
Bukkit.getOnlinePlayers().forEach(player -> removePlayer(player, true));
packetHiders.forEach(TinyProtocol.instance::removeFilter);
}
}.register();
new StateDependentTask(TechHiderWrapper.ENABLED, FightState.Schem, this::onTick, 0, 1);
}
public void initialize(FightTeam team) {
if(!TechHiderWrapper.ENABLED)
return;
hullMap.get(team).initialize();
}
@EventHandler(priority = EventPriority.HIGH)
public void onJoin(PlayerJoinEvent e) {
updatePlayer(e.getPlayer());
}
@EventHandler
public void onLeave(PlayerQuitEvent e) {
removePlayer(e.getPlayer(), false);
}
public void updatePlayer(Player player) {
if(!TechHiderWrapper.ENABLED)
return;
FightTeam team = Fight.getPlayerTeam(player);
FightPlayer fp = Fight.getFightPlayer(player);
for(Map.Entry<FightTeam, Hull> hull : hullMap.entrySet()) {
if(Config.isReferee(player) || hull.getKey() == team || (fp != null && fp.canEntern())) {
hull.getValue().removePlayer(player, true);
} else {
hull.getValue().addPlayer(player);
}
}
}
private void removePlayer(Player player, boolean activeRemoval) {
for (Hull hull : hulls)
hull.removePlayer(player, activeRemoval);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPhysic(BlockPhysicsEvent e) {
if(FlatteningWrapper.impl.doRecord(e))
blockUpdate(e.getBlock(), e.getChangedType());
}
public void blockUpdate(Block block, Material changedType) {
for (Hull hull : hulls)
hull.updateBlockVisibility(block, changedType);
}
public boolean isBlockHidden(Player player, int x, int y, int z) {
if(!TechHiderWrapper.ENABLED)
return false;
for (Hull hull : hulls)
if(hull.isBlockHidden(player, x, y, z))
return true;
return false;
}
public boolean blockPrecise(Player player, int chunkX, int chunkY, int chunkZ) {
if(!TechHiderWrapper.ENABLED)
return false;
for (Hull hull : hulls)
if(hull.blockPrecise(player, chunkX, chunkY, chunkZ))
return true;
return false;
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSpawn(EntitySpawnEvent e) {
for (Hull hull : hulls)
hull.checkEntity(e.getEntity());
}
private void onTick() {
Recording.iterateOverEntities(Objects::nonNull, entity -> {
for (Hull hull : hulls)
hull.checkEntity(entity);
});
for (Hull hull : hulls)
hull.sendUncoveredBlocks();
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDeath(EntityDeathEvent e) {
for(Hull hull : hulls)
hull.removeEntity(e.getEntity());
}
public void updateREntity(REntity e) {
for(Hull hull : hulls)
hull.checkREntity(e);
}
public void despawnREntity(REntity e) {
for(Hull hull : hulls)
hull.removeREntity(e);
}
private static final Class<?> packetPlayOutWorldEvent = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutWorldEvent");
private static final Reflection.FieldAccessor<?> worldEventPosition = Reflection.getField(packetPlayOutWorldEvent, TechHider.blockPosition, 0);
public static final Reflection.FieldAccessor<Integer> blockPositionY = Reflection.getField("{nms.core}.BaseBlockPosition", int.class, 1);
private Object worldEventHider(Player player, Object packet) {
Object baseBlock = worldEventPosition.get(packet);
return packetHider(player, packet, new Location(Config.world, TechHider.blockPositionX.get(baseBlock), blockPositionY.get(baseBlock), TechHider.blockPositionZ.get(baseBlock)));
}
private static final Class<?> packetPlayOutExplosion = Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion");
private static final Reflection.FieldAccessor<List> explosionBlocks = Reflection.getField(packetPlayOutExplosion, List.class, 0);
private static final Function<Object, Location> explosionLocation = posPacketToLocation(packetPlayOutExplosion, double.class, 1.0);
private Object explosionHider(Player player, Object packet) {
if(explosionBlocks.get(packet).isEmpty())
return packetHider(player, packet, explosionLocation.apply(packet));
return packet;
}
private void posHiderGenerator(String typeName, Class<? extends Number> posType, double factor) {
Class<?> type = Reflection.getClass(typeName);
Function<Object, Location> location = posPacketToLocation(type, posType, factor);
packetHiders.put(type, (player, packet) -> packetHider(player, packet, location.apply(packet)));
}
private static Function<Object, Location> posPacketToLocation(Class<?> type, Class<? extends Number> posType, double factor) {
Reflection.FieldAccessor<? extends Number> x = Reflection.getField(type, posType, 0);
Reflection.FieldAccessor<? extends Number> y = Reflection.getField(type, posType, 1);
Reflection.FieldAccessor<? extends Number> z = Reflection.getField(type, posType, 2);
return packet -> new Location(Config.world, x.get(packet).doubleValue()/factor, y.get(packet).doubleValue()/factor, z.get(packet).doubleValue()/factor);
}
private Object packetHider(Player player, Object packet, Location location) {
for(Hull hull : hulls) {
if(hull.isLocationHidden(player, location))
return null;
}
return packet;
}
}

Datei anzeigen

@ -0,0 +1,31 @@
/*
* 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/>.
*/
package de.steamwar.fightsystem.utils;
import de.steamwar.core.VersionDependent;
import de.steamwar.fightsystem.FightSystem;
import java.util.List;
public interface HullHiderWrapper {
HullHiderWrapper impl = VersionDependent.getVersionImpl(FightSystem.getPlugin());
Object generateBlockChangePacket(List<Hull.IntVector> changes);
}

Datei anzeigen

@ -25,51 +25,26 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.List;
public class ItemBuilder {
private final ItemStack item;
private final ItemMeta meta;
public ItemBuilder(Material matrial) {
item = new ItemStack(matrial);
meta = item.getItemMeta();
}
public ItemBuilder(Material matrial, int amount) {
item = new ItemStack(matrial, amount);
public ItemBuilder(Material material) {
item = new ItemStack(material);
meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.values());
}
@SuppressWarnings("deprecation")
public ItemBuilder(Material matrial, short subid) {
item = new ItemStack(matrial, 1, subid);
public ItemBuilder(Material material, short subid) {
item = new ItemStack(material, 1, subid);
meta = item.getItemMeta();
meta.addItemFlags(ItemFlag.values());
}
public ItemBuilder removeAllAttributes() {
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.addItemFlags(ItemFlag.HIDE_DESTROYS);
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
meta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
return this;
}
public ItemBuilder setDisplayName(String name) {
meta.setDisplayName(name);
return this;
}
public ItemBuilder addLore(List<String> lore) {
meta.setLore(lore);
return this;
}
public ItemBuilder addEnchantment(Enchantment enchantment, int level) {
meta.addEnchant(enchantment, level, true);
public ItemBuilder enchant() {
meta.addEnchant(Enchantment.DURABILITY, 1, true);
return this;
}
@ -77,5 +52,4 @@ public class ItemBuilder {
item.setItemMeta(meta);
return item;
}
}

Datei anzeigen

@ -19,7 +19,11 @@
package de.steamwar.fightsystem.utils;
import lombok.Getter;
@Getter
public class Message {
private final String msg;
private final Object[] params;
@ -27,12 +31,4 @@ public class Message {
this.msg = msg;
this.params = params;
}
public String getMsg() {
return msg;
}
public Object[] getParams() {
return params;
}
}

Datei anzeigen

@ -19,13 +19,29 @@
package de.steamwar.fightsystem.utils;
import de.steamwar.techhider.ProtocolUtils;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.Location;
import org.bukkit.block.Block;
import java.util.function.ObjIntConsumer;
@Getter
@AllArgsConstructor
public class Region {
public static final Region EMPTY = Region.fromSize(-10000, -10000, -10000, 0, 0, 0);
public static Region withExtension(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendY, int extendZ) {
return Region.fromSize(minX - extendX, minY - extendY, minZ - extendZ,
sizeX + extendX * 2, sizeY + extendY * 2, sizeZ + extendZ * 2);
}
public static Region fromSize(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
return new Region(minX, minY, minZ, minX+sizeX, minY+sizeY, minZ+sizeZ);
}
private final int minX;
private final int minY;
private final int minZ;
@ -33,70 +49,32 @@ public class Region {
private final int maxY;
private final int maxZ;
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ, int extendX, int extendY, int extendZ) {
this(minX - extendX, minY - extendY, minZ - extendZ,
sizeX + extendX * 2, sizeY + extendY * 2, sizeZ + extendZ * 2);
}
public Region(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
this.minX = minX;
this.minY = minY;
this.minZ = minZ;
this.maxX = minX + sizeX;
this.maxY = minY + sizeY;
this.maxZ = minZ + sizeZ;
}
public int getMinX() {
return minX;
}
public int getMinY() {
return minY;
}
public int getMinZ() {
return minZ;
}
public int getMaxX() {
return maxX;
}
public int getMaxY() {
return maxY;
}
public int getMaxZ() {
return maxZ;
}
public int getSizeX() {
return maxX - minX;
}
public int getSizeY() {
return maxY - minY;
}
public int getSizeZ() {
return maxZ - minZ;
}
public double posToChunk(int pos){
return pos / 16.0;
}
private int getMinChunkX(){
return (int) Math.floor(posToChunk(minX));
return ProtocolUtils.posToChunk(minX);
}
private int getMaxChunkX(){
return (int) Math.ceil(posToChunk(maxX));
return ProtocolUtils.posToChunk(maxX);
}
private int getMinChunkZ(){
return (int) Math.floor(posToChunk(minZ));
return ProtocolUtils.posToChunk(minZ);
}
private int getMaxChunkZ(){
return (int) Math.ceil(posToChunk(maxZ));
return ProtocolUtils.posToChunk(maxZ);
}
public boolean chunkOutside(int cX, int cZ) {
@ -104,6 +82,12 @@ public class Region {
getMinChunkZ() > cZ || cZ > getMaxChunkZ();
}
public boolean chunkSectionOutside(int cX, int cY, int cZ) {
return getMinChunkX() > cX || cX > getMaxChunkX() ||
ProtocolUtils.posToChunk(minY) > cY || cY > ProtocolUtils.posToChunk(maxY) ||
getMinChunkZ() > cZ || cZ > getMaxChunkZ();
}
public void forEachChunk(ObjIntConsumer<Integer> executor) {
for(int x = getMinChunkX(); x <= getMaxChunkX(); x++)
for(int z = getMinChunkZ(); z <= getMaxChunkZ(); z++)
@ -113,7 +97,7 @@ public class Region {
public void forEach(TriConsumer<Integer, Integer, Integer> executor) {
for(int x = minX; x < maxX; x++) {
for(int y = minY; y < maxY; y++) {
for (int z = minZ; z <= maxZ; z++) {
for (int z = minZ; z < maxZ; z++) {
executor.accept(x, y, z);
}
}
@ -141,7 +125,7 @@ public class Region {
}
public boolean playerInRegion(Location location){
return in2dRegion(location) && minY <= location.getY() && location.getY() + 1.8 < maxY;
return in2dRegion(location) && minY <= location.getY() && location.getY() < maxY;
}
public boolean in2dRegion(Block block){
@ -149,13 +133,29 @@ public class Region {
}
public boolean in2dRegion(int x, int z) {
return minX <= x && x < maxX && minZ <= z && z <= maxZ;
return minX <= x && x < maxX && minZ <= z && z < maxZ;
}
public boolean inRegion(Block block){
return in2dRegion(block) && minY <= block.getY() && block.getY() < maxY;
}
public boolean inRegion(int x, int y, int z) {
return in2dRegion(x, z) && minY <= y && y < maxY;
}
public Region intersection(Region other) {
int x = Math.max(minX, other.minX);
int y = Math.max(minY, other.minY);
int z = Math.max(minZ, other.minZ);
return new Region(x, y, z, Math.min(maxX, other.maxX), Math.min(maxY, other.maxY), Math.min(maxZ, other.maxZ));
}
public Region to2d() {
return new Region(minX, Integer.MIN_VALUE/2, minZ, maxX, Integer.MAX_VALUE/2, maxZ);
}
public interface TriConsumer<T, V, U>{
void accept(T x, V y, U z);
}

Datei anzeigen

@ -22,29 +22,34 @@ package de.steamwar.fightsystem.utils;
import de.steamwar.core.CraftbukkitWrapper;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.events.BoardingEvent;
import de.steamwar.fightsystem.events.TeamLeaveEvent;
import de.steamwar.fightsystem.events.TeamSpawnEvent;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependent;
import de.steamwar.techhider.ProtocolUtils;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.techhider.TechHider;
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.player.PlayerQuitEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
import java.util.concurrent.ConcurrentHashMap;
public class TechHiderWrapper extends StateDependent {
public class TechHiderWrapper extends StateDependent implements TechHider.LocationEvaluator, Listener {
public static final boolean ENABLED = !Config.OnlyPublicSchematics && !Config.test() && Config.TechhiderActive;
private final ConcurrentHashMap<Player, Region> hiddenRegion = new ConcurrentHashMap<>();
private final TechHider techHider;
public TechHiderWrapper() {
super(ENABLED, FightState.Schem);
techHider = new TechHider(this::bypass, Material.getMaterial(Config.ObfuscateWith), Config.HiddenBlocks.stream().map(String::toUpperCase).map(Material::getMaterial).collect(Collectors.toSet()), Config.HiddenBlockEntities);
techHider = new TechHider(this, Config.ObfuscateWith, Config.HiddenBlocks, Config.HiddenBlockEntities);
new StateDependentListener(ENABLED, FightState.Schem, this);
register();
}
@ -56,43 +61,82 @@ public class TechHiderWrapper extends StateDependent {
@Override
public void disable() {
techHider.disable();
hiddenRegion.clear();
}
public List<ProtocolUtils.ChunkPos> prepareChunkReload(Player p, boolean hide) {
if(!ENABLED)
return Collections.emptyList();
@EventHandler
public void teamJoin(TeamSpawnEvent e) {
e.getFightPlayer().ifPlayer(player -> hiddenRegion.put(player, getHiddenRegion(player)));
}
List<ProtocolUtils.ChunkPos> chunksToReload = new ArrayList<>();
Config.ArenaRegion.forEachChunk((x, z) -> {
if(bypass(p, x, z) == hide)
chunksToReload.add(new ProtocolUtils.ChunkPos(x, z));
@EventHandler
public void boarding(BoardingEvent e) {
e.getFightPlayer().ifPlayer(player -> hiddenRegion.put(player, getHiddenRegion(player)));
}
@EventHandler
public void teamLeave(TeamLeaveEvent e) {
e.getFightPlayer().ifPlayer(player -> {
if(player.isOnline())
hiddenRegion.put(player, getHiddenRegion(player));
});
return chunksToReload;
}
public void reloadChunks(Player p, List<ProtocolUtils.ChunkPos> chunksToReload, boolean hide) {
if(!ENABLED || !FightState.Schem.contains(FightState.getFightState()))
@EventHandler
public void playerQuit(PlayerQuitEvent e) {
Player player = e.getPlayer();
hiddenRegion.remove(player);
}
public void reloadChunks(Player player, Region region, Region exclusion) {
if(!ENABLED || !FightState.Schem.contains(FightState.getFightState()) || !player.isOnline())
return;
Bukkit.getScheduler().runTaskLater(FightSystem.getPlugin(), () -> {
for(ProtocolUtils.ChunkPos chunk : chunksToReload){
if(bypass(p, chunk.x(), chunk.z()) != hide)
CraftbukkitWrapper.impl.sendChunk(p, chunk.x(), chunk.z());
}
}, 40);
region.forEachChunk((chunkX, chunkZ) -> {
if(exclusion.chunkOutside(chunkX, chunkZ))
CraftbukkitWrapper.impl.sendChunk(player, chunkX, chunkZ);
});
}
private boolean bypass(Player p, int chunkX, int chunkZ){
if(Config.isReferee(p))
return true;
@Override
public boolean skipChunk(Player player, int chunkX, int chunkZ) {
return getHiddenRegion(player).chunkOutside(chunkX, chunkZ);
}
FightTeam ft = Fight.getPlayerTeam(p);
if(ft == null){
return Config.ArenaRegion.chunkOutside(chunkX, chunkZ);
}else if(ft.isBlue()){
return ft.canPlayerEntern(p) || Config.RedExtendRegion.chunkOutside(chunkX, chunkZ);
}else{
return ft.canPlayerEntern(p) || Config.BlueExtendRegion.chunkOutside(chunkX, chunkZ);
@Override
public boolean skipChunkSection(Player player, int chunkX, int chunkY, int chunkZ) {
return getHiddenRegion(player).chunkSectionOutside(chunkX, chunkY, chunkZ);
}
@Override
public TechHider.State check(Player player, int x, int y, int z) {
if(hiddenRegion.computeIfAbsent(player, this::getHiddenRegion).inRegion(x, y, z)) {
if(FightSystem.getHullHider().isBlockHidden(player, x, y, z)) {
return TechHider.State.HIDE;
} else {
return TechHider.State.CHECK;
}
} else {
return TechHider.State.SKIP;
}
}
@Override
public boolean blockPrecise(Player player, int chunkX, int chunkY, int chunkZ) {
return FightSystem.getHullHider().blockPrecise(player, chunkX, chunkY, chunkZ);
}
private Region getHiddenRegion(Player player) {
if(Config.isReferee(player))
return Region.EMPTY;
FightTeam team = Fight.getPlayerTeam(player);
if(team == null)
return Config.ArenaRegion;
if(team.canPlayerEntern(player))
return Region.EMPTY;
return Fight.getOpposite(team).getExtendRegion();
}
}

Datei anzeigen

@ -24,7 +24,9 @@ import de.steamwar.fightsystem.countdown.Countdown;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.StateDependentCountdown;
import org.bukkit.entity.Player;
import lombok.Getter;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import java.util.ArrayList;
import java.util.List;
@ -33,8 +35,10 @@ import java.util.stream.Collectors;
public abstract class Wincondition {
protected static PercentWincondition percentWincondition = null;
@Getter
protected static WinconditionPercent percentWincondition = null;
protected static StateDependentCountdown timeOverCountdown = null;
@Getter
protected static final List<PrintableWincondition> printableWinconditions = new ArrayList<>();
private final String windescription;
@ -53,16 +57,11 @@ public abstract class Wincondition {
FightSystem.setSpectateState(team, windescription, subtitle, params);
}
protected FightTeam isTarget(Player player){
return Fight.getPlayerTeam(player);
}
protected FightTeam isTarget(Entity player){
if(!(player instanceof LivingEntity))
return null;
public static List<PrintableWincondition> getPrintableWinconditions(){
return printableWinconditions;
}
public static PercentWincondition getPercentWincondition() {
return percentWincondition;
return Fight.getPlayerTeam((LivingEntity) player);
}
protected void comparisonWin(ToDoubleFunction<FightTeam> evaluate, String winMessage, String tieMessage) {

Datei anzeigen

@ -19,16 +19,13 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
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.player.PlayerQuitEvent;
public class WinconditionAllDead extends Wincondition implements Listener {
@ -38,25 +35,12 @@ public class WinconditionAllDead extends Wincondition implements Listener {
}
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
handleDeath(event.getEntity().getPlayer());
}
public void handlePlayerDeath(TeamDeathEvent event) {
FightTeam team = event.getFightPlayer().getTeam();
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
handleDeath(event.getPlayer());
}
private void handleDeath(Player player){
FightTeam team = isTarget(player);
if(team == null)
if(team.getAlivePlayers() > 0)
return;
for(FightPlayer fp : team.getPlayers()) {
if(fp.isLiving() && fp.getPlayer() != player)
return;
}
win(Fight.getOpposite(team), "WIN_ALL_DEAD", team.getPrefix());
}
}

Datei anzeigen

@ -54,9 +54,9 @@ public class WinconditionAmongUs extends Wincondition implements Listener {
FightPlayer imposter = fightPlayerList.get(random.nextInt(fightPlayerList.size()));
for (FightPlayer fightPlayer : fightPlayerList) {
if (fightPlayer == imposter) {
FightSystem.getMessage().send("AMONG_US_IMPOSTER_MESSAGE", fightPlayer.getPlayer());
FightSystem.getMessage().send("AMONG_US_IMPOSTER_MESSAGE", fightPlayer.getEntity());
} else {
FightSystem.getMessage().send("AMONG_US_IMPOSTER_AMONG_MESSAGE", fightPlayer.getPlayer());
FightSystem.getMessage().send("AMONG_US_IMPOSTER_AMONG_MESSAGE", fightPlayer.getEntity());
}
}
return imposter;

Datei anzeigen

@ -19,15 +19,14 @@
package de.steamwar.fightsystem.winconditions;
import de.steamwar.fightsystem.events.TeamDeathEvent;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightPlayer;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.StateDependentListener;
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.player.PlayerQuitEvent;
public class WinconditionCaptainDead extends Wincondition implements Listener {
@ -37,22 +36,12 @@ public class WinconditionCaptainDead extends Wincondition implements Listener {
}
@EventHandler
public void handlePlayerDeath(PlayerDeathEvent event) {
handleDeath(event.getEntity().getPlayer());
}
@EventHandler
public void handlePlayerQuit(PlayerQuitEvent event) {
handleDeath(event.getPlayer());
}
private void handleDeath(Player player){
FightTeam team = isTarget(player);
if(team == null)
public void handlePlayerDeath(TeamDeathEvent event) {
FightPlayer leader = event.getFightPlayer();
if(!leader.isLeader())
return;
if(team.isPlayerLeader(player)) {
win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + team.getLeader().getPlayer().getName());
}
FightTeam team = leader.getTeam();
win(Fight.getOpposite(team), "WIN_LEADER_DEAD", team.getPrefix() + leader.getEntity().getName());
}
}

Datei anzeigen

@ -26,7 +26,6 @@ import de.steamwar.fightsystem.states.FightState;
import de.steamwar.fightsystem.states.OneShotStateDependent;
import de.steamwar.fightsystem.states.StateDependentListener;
import de.steamwar.fightsystem.utils.Message;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -34,27 +33,12 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BooleanSupplier;
import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.function.ToIntFunction;
public class PercentWincondition extends Wincondition implements PrintableWincondition {
public class WinconditionPercent extends Wincondition implements PrintableWincondition {
private final Map<FightTeam, TeamPercent> teamMap = new HashMap<>();
protected BooleanSupplier explosionFilter = () -> !Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft();
protected Predicate<Material> testBlock = type -> !Config.PercentBlocks.contains(type);
protected ToIntFunction<FightTeam> totalBlockCalc = team -> {
AtomicInteger blocks = new AtomicInteger();
team.getSchemRegion().forEach((x, y, z) -> {
if (testBlock.test(Config.world.getBlockAt(x, y, z).getType())) {
blocks.getAndIncrement();
}
});
return blocks.get();
};
protected Consumer<FightTeam> checkWin = team -> {
if (getPercent(team) >= Config.PercentWin) {
win(Fight.getOpposite(team), "WIN_PERCENT", team.getColoredName());
@ -62,7 +46,7 @@ public class PercentWincondition extends Wincondition implements PrintableWincon
};
protected Consumer<FightTeam> postEnable = team -> {};
public PercentWincondition(String windescription, Winconditions wincondition) {
public WinconditionPercent(Winconditions wincondition, String windescription) {
super(windescription);
if (Config.ActiveWinconditions.contains(wincondition)) {
@ -74,7 +58,7 @@ public class PercentWincondition extends Wincondition implements PrintableWincon
}
public Message getDisplay(FightTeam team) {
return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(100.0 * getPercent(team)) / 100.0));
return new Message("BAR_PERCENT", team.getPrefix() + (Math.round(10000.0 * (1.0 - getPercent(team) / Config.PercentWin)) / 100.0));
}
public double getPercent(FightTeam team) {
@ -105,12 +89,16 @@ public class PercentWincondition extends Wincondition implements PrintableWincon
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (event.getEntityType() == EntityType.FIREBALL || explosionFilter.getAsBoolean() || !team.getExtendRegion().inRegion(event.getEntity().getLocation())) {
if (
event.getEntityType() == EntityType.FIREBALL ||
!team.getExtendRegion().inRegion(event.getEntity().getLocation()) ||
(!Config.PercentEntern && !Config.EnterStages.isEmpty() && Config.EnterStages.get(0) >= Wincondition.getTimeOverCountdown().getTimeLeft())
) {
return;
}
event.blockList().forEach(block -> {
if (testBlock.test(block.getType())) {
if (Config.PercentBlocks.contains(block.getType()) == Config.PercentBlocksWhitelist) {
currentBlocks--;
}
});
@ -119,7 +107,11 @@ public class PercentWincondition extends Wincondition implements PrintableWincon
}
private void enable() {
totalBlocks = totalBlockCalc.applyAsInt(team);
totalBlocks = 0;
team.getSchemRegion().forEach((x, y, z) -> {
if (Config.PercentBlocks.contains(Config.world.getBlockAt(x, y, z).getType()) == Config.PercentBlocksWhitelist)
totalBlocks++;
});
currentBlocks = totalBlocks;
postEnable.accept(team);
}

Datei anzeigen

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

Datei anzeigen

@ -36,12 +36,12 @@ import org.bukkit.event.player.PlayerQuitEvent;
import java.util.HashMap;
import java.util.Map;
public class WinconditionPoints extends PercentWincondition implements Listener {
public class WinconditionPoints extends WinconditionPercent implements Listener {
private final Map<FightTeam, TeamPoints> teamMap = new HashMap<>();
public WinconditionPoints(){
super("Points", Winconditions.POINTS);
super(Winconditions.POINTS, "Points");
checkWin = team -> {};
postEnable = this::pointInit;

Datei anzeigen

@ -35,7 +35,7 @@ import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
public class WinconditionPointsAirShip extends PercentWincondition implements Listener {
public class WinconditionPointsAirShip extends WinconditionPercent implements Listener {
private double[] as = new double[] {
0.5,
@ -56,7 +56,7 @@ public class WinconditionPointsAirShip extends PercentWincondition implements Li
private final Map<FightTeam, TeamPoints> teamMap = new HashMap<>();
public WinconditionPointsAirShip(){
super("Points", Winconditions.POINTS_AIRSHIP);
super(Winconditions.POINTS_AIRSHIP, "Points");
checkWin = team -> {
if (teamMap.get(team).getPoints() > TeamPoints.WIN_POINTS) {

Datei anzeigen

@ -1,31 +0,0 @@
/*
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.fightsystem.winconditions;
import de.steamwar.fightsystem.Config;
public class WinconditionWhitelistPercent extends PercentWincondition {
public WinconditionWhitelistPercent() {
super("WhitelistPercent", Winconditions.WHITELIST_PERCENT);
testBlock = Config.PercentBlocks::contains;
}
}

Datei anzeigen

@ -28,8 +28,6 @@ public enum Winconditions {
CAPTAIN_DEAD,
PERCENT_SYSTEM,
WHITELIST_PERCENT,
RELATIVE_PERCENT,
POINTS,
POINTS_AIRSHIP,
@ -39,5 +37,7 @@ public enum Winconditions {
HELLS_BELLS,
METEOR,
AMONG_US
AMONG_US,
PERSISTENT_DAMAGE,
TNT_DISTRIBUTION
}

Datei anzeigen

@ -12,10 +12,10 @@ api-version: "1.13"
commands:
ak:
accept:
decline:
request:
requests:
fightinfo:
leave:
invite:
ready:
kit:
remove:
@ -26,4 +26,6 @@ commands:
win:
resetwg:
resettb:
tpslimit:
tpswarp:
unrank:

Datei anzeigen

@ -17,10 +17,6 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import org.apache.tools.ant.taskdefs.condition.Os
plugins {
// Adding the base plugin fixes the following gradle warnings in IntelliJ:
//
@ -33,43 +29,12 @@ plugins {
id 'application'
id 'com.github.johnrengelman.shadow' version '5.0.0'
}
ext.swdep = { s ->
if (file("${rootDir}/lib/${s}.jar").exists()) {
return files("${rootDir}/lib/${s}.jar")
} else {
if (s.contains("-")) {
return "de.steamwar:${s.toLowerCase().replace('-', ':')}"
} else {
return "de.steamwar:${s.toLowerCase()}:RELEASE"
}
}
id 'de.steamwar.gradle' version 'RELEASE'
}
group 'de.steamwar'
version ''
Properties steamwarProperties = new Properties()
if (file("steamwar.properties").exists()) {
steamwarProperties.load(file("steamwar.properties").newDataInputStream())
}
ext {
buildName = 'FightSystem'
artifactName = 'fightsystem'
uberJarName = "${buildName}-all.jar"
jarName = "${artifactName}.jar"
libs = "${buildDir}/libs"
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
operatingSystem = "windows"
} else {
operatingSystem = "unix"
}
}
compileJava.options.encoding = 'UTF-8'
compileJava.options.compilerArgs << '-parameter'
@ -81,11 +46,6 @@ mainClassName = ''
allprojects {
repositories {
mavenCentral()
jcenter()
maven {
url = uri("https://repo.codemc.io/repository/maven-snapshots/")
}
maven {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
@ -94,14 +54,6 @@ allprojects {
maven {
url = uri('https://libraries.minecraft.net')
}
maven {
url = uri('https://steamwar.de/maven')
credentials {
username = steamwarProperties.getProperty("maven.username")
password = steamwarProperties.getProperty("maven.password")
}
}
}
}
@ -115,151 +67,3 @@ dependencies {
}
}
}
task buildProject {
description 'Build this project'
group "Steamwar"
dependsOn build, tasks.getByPath(':FightSystem_Standalone:shadowJar')
}
task finalizeProject {
description 'Finalize this project'
group "Steamwar"
doLast {
if ("${buildDir}" == null) {
return
}
delete fileTree("${libs}").matching {
exclude("${uberJarName}")
}
file(libs + "/" + uberJarName).renameTo(file(libs + "/" + jarName))
}
}
build.finalizedBy(finalizeProject)
if (steamwarProperties.containsKey("hostname")) {
String hostname = steamwarProperties.get("hostname")
String uploadPath = steamwarProperties.getOrDefault("uploadPath", "~")
String server = steamwarProperties.getOrDefault("server", "Dev1.15")
String serverStartFlags = steamwarProperties.getOrDefault("serverStartFlags", "")
task uploadProject {
description 'Upload this project'
group "Steamwar"
doLast {
await(shell("scp ${libs}/${jarName} ${hostname}:${uploadPath}/${server}/plugins"))
if (steamwarProperties.getOrDefault("directStart", "false") == "false" && !answer("Start ${server} server?")) {
return
}
serverStart(server, serverStartFlags, hostname)
}
}
uploadProject.dependsOn(buildProject)
task startDevServer {
description 'Start the DevServer'
group "Steamwar"
doLast {
serverStart(server, serverStartFlags, hostname)
}
}
}
private def await(Process proc) {
def out = new StringBuilder()
def err = new StringBuilder()
proc.waitForProcessOutput(out, err)
return [out, err, proc.exitValue()]
}
private def shell(String command) {
if (operatingSystem == "unix") {
return ['bash', '-c', command].execute()
} else {
return ["cmd", "/c", command].execute()
}
}
private def serverStart(String serverName, String serverFlags, String hostname) {
def proc = shell("ssh -t ${hostname} \"./mc ${serverFlags} ${serverName}\"")
Set<String> strings = new HashSet<>()
File file = new File("${projectDir}/ignoredlog");
if (file.exists()) {
new BufferedReader(new InputStreamReader(new FileInputStream(file))).readLines().forEach({ s ->
strings.add(s)
})
}
Thread outputThread = new Thread({
Reader reader = proc.getInputStream().newReader();
Writer writer = System.out.newWriter();
try {
while (proc.alive) {
String s = reader.readLine()
if (s == null) {
return
}
if (strings.stream().anyMatch({check -> s.contains(check)})) {
continue
}
writer.write(s + "\n")
writer.flush()
}
} catch (IOException e) {
// Ignored
}
})
outputThread.setName("${serverName} - OutputThread")
outputThread.start()
Writer writer
Thread inputThread = new Thread({
Reader reader = System.in.newReader()
writer = proc.getOutputStream().newWriter()
try {
while (proc.alive) {
String s = reader.readLine()
writer.write(s + "\n")
writer.flush()
}
} catch (IOException e) {
// Ignored
}
})
inputThread.setName("${serverName} - InputThread")
inputThread.start()
gradle.buildFinished { buildResult ->
if (!proc.alive) {
return
}
writer = proc.getOutputStream().newWriter()
writer.write("stop\n")
writer.flush()
awaitClose(proc, outputThread, inputThread)
}
awaitClose(proc, outputThread, inputThread)
};
private static def awaitClose(Process proc, Thread outputThread, Thread inputThread) {
while (proc.alive) {
Thread.sleep(10)
}
proc.closeStreams()
outputThread.interrupt()
inputThread.interrupt()
}
private def answer(String question) {
while (System.in.available() > 0) System.in.read()
println(question)
boolean valid = "Yy".contains(((char) System.in.read()).toString())
while (System.in.available() > 0) System.in.read()
return valid
}

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen