Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
83fc1a5904 | ||
|
|
ecc34b0816 | ||
|
|
980defa641 | ||
|
|
ddbc20a599 | ||
|
|
b79439d225 | ||
|
|
e3a69aca1b | ||
|
|
9ca6a7b364 | ||
|
|
b99e2ee4db | ||
|
|
1ebedf3741 | ||
|
|
19cc22aca6 | ||
|
|
98dee905f4 | ||
|
|
0d10f65a45 | ||
|
|
76e3002246 | ||
|
|
b34a7c177f | ||
|
|
02fbca16ed | ||
|
|
9e4545e923 | ||
|
|
60b43e1def | ||
|
|
59c7313a78 | ||
|
|
175d1391f4 | ||
|
|
014c7a8ba2 | ||
|
|
e0992658f6 | ||
|
|
287ca3701c | ||
|
|
e8ae19af90 | ||
|
|
86999c0e2a | ||
|
|
099f469df4 | ||
|
|
5711dfaf44 | ||
|
|
6c8cb2604a | ||
|
|
636cfacd4f | ||
|
|
c0a667b50a | ||
|
|
f2fcdcfe6f | ||
|
|
b5d768300f | ||
|
|
2480f749a1 | ||
|
|
0367a0a47a | ||
|
|
dc0f2b2dc8 | ||
|
|
94b6ff76f6 | ||
|
|
dd58e1a6d9 | ||
|
|
4d6ffe3e51 | ||
|
|
f9bcf3c40f | ||
|
|
35b3954611 | ||
|
|
a18edc2e6c | ||
|
|
563d558279 | ||
|
|
add74a6406 | ||
|
|
9b92b75937 | ||
|
|
f5ed87a9d2 | ||
|
|
4251a3b620 | ||
|
|
cac21e38b4 | ||
|
|
9d877e4cf1 | ||
|
|
de32e96ccc | ||
|
|
02257d82fc | ||
|
|
eee9d6d243 | ||
|
|
e4282b6e5a | ||
|
|
e1b3096e68 | ||
|
|
3ba4c6e826 | ||
|
|
3da9c7de28 | ||
|
|
3c01d696b5 | ||
|
|
8934363931 | ||
|
|
38bcf87c97 | ||
|
|
770772ce77 | ||
|
|
cb53f59af7 | ||
|
|
4d0673acd6 | ||
|
|
bffeacc7ad | ||
|
|
62d19c4a80 | ||
|
|
3b82c54d11 | ||
|
|
446f2cd58b | ||
|
|
fd6a162b22 | ||
|
|
c8e4b9a55f | ||
|
|
d5dba852d0 | ||
|
|
7fd7e81d51 | ||
|
|
34f7e8fa5e | ||
|
|
e7ef99f034 | ||
|
|
8c34dd6f00 | ||
|
|
5f93749a14 | ||
|
|
e25712678f | ||
|
|
764ba1208b | ||
|
|
fabdb348f1 | ||
|
|
9bb872d280 | ||
|
|
0c3855be55 | ||
|
|
29436a34b0 | ||
|
|
5cad070ace | ||
|
|
e05856d225 | ||
|
|
09d698a634 | ||
|
|
f9087e1b3c | ||
|
|
55611ef5d0 | ||
|
|
0652138f30 | ||
|
|
e3f558cefd | ||
|
|
f21aaec4f3 | ||
|
|
a507fcfebe | ||
|
|
8a2cc43945 | ||
|
|
0e461298fe | ||
|
|
77370fa524 | ||
|
|
347e858c3e | ||
|
|
9749c3568e | ||
|
|
7759b45278 | ||
|
|
db4f2b08d0 | ||
|
|
efd0d3e541 | ||
|
|
00dbe11c02 | ||
|
|
8b6186c509 | ||
|
|
35c6f0a7a4 | ||
|
|
09af443311 | ||
|
|
15777bf035 | ||
|
|
7e4359b3b9 | ||
|
|
015b296822 | ||
|
|
bbb19e761b | ||
|
|
0bb8cabf03 | ||
|
|
d5fafe0433 | ||
|
|
fe9e92d5c9 | ||
|
|
5b945dde87 | ||
|
|
cee8ce1b4d | ||
|
|
7f4e22f60d | ||
|
|
98ec0e7ac7 | ||
|
|
d9c9801d71 | ||
|
|
3544afd337 | ||
|
|
a9335aef33 | ||
|
|
7bba49e59e | ||
|
|
13b545ae1d | ||
|
|
fb6d20a5c9 | ||
|
|
8177c5fd23 | ||
|
|
c7efff3771 | ||
|
|
4bf9d51c0e | ||
|
|
850add20ec | ||
|
|
beed101d57 | ||
|
|
72243203cb | ||
|
|
a7b42f4fbd | ||
|
|
141d5dfc59 | ||
|
|
7fdb9cdadd | ||
|
|
3b869179a1 | ||
|
|
72f54694a5 | ||
|
|
98fa4fc87f | ||
|
|
7d5fed68fc | ||
|
|
ff8df2225f | ||
|
|
1b54874421 | ||
|
|
dce6552783 | ||
|
|
69068779ea | ||
|
|
f357b85162 | ||
|
|
f115a355d9 | ||
|
|
d5b0923a95 | ||
|
|
d981df9b37 | ||
|
|
ce9a1a4806 | ||
|
|
de71f904c9 | ||
|
|
f150a0808c | ||
|
|
8e11c3423a | ||
|
|
7fe6c5ba39 | ||
|
|
dc81cb6702 | ||
|
|
ffece8e69d | ||
|
|
3737a8f77b | ||
|
|
e44c2caf29 | ||
|
|
99947579ba | ||
|
|
dea9cc876e | ||
|
|
dff17c85ad | ||
|
|
729e0fd925 | ||
|
|
075489628e | ||
|
|
1145c3e1f3 | ||
|
|
6f15842f89 | ||
|
|
b40be6d908 | ||
|
|
d9598aba9b | ||
|
|
b61d989b28 | ||
|
|
7ddfff7886 | ||
|
|
09a7e8b954 | ||
|
|
64ae0540b1 | ||
|
|
18fd40a294 | ||
|
|
624e0d4bab | ||
|
|
69af87153c | ||
|
|
524cc7ff51 | ||
|
|
2b52314b89 | ||
|
|
a3bc95ec7b | ||
|
|
66f4e65187 | ||
|
|
ec55d4db84 | ||
|
|
860fda414e | ||
|
|
5ba4431d8a | ||
|
|
cb5e5e431f | ||
|
|
2f07f5f3f0 | ||
|
|
eba7912e39 | ||
|
|
9d712b2530 | ||
|
|
38555bc401 | ||
|
|
d771564fff | ||
|
|
0b6ddb6192 | ||
|
|
509822388d | ||
|
|
8b007371dc | ||
|
|
03fcb889ff | ||
|
|
4903ed6333 | ||
|
|
bf4438547a | ||
|
|
bc3085316f | ||
|
|
9361a3287e | ||
|
|
e483c899ad | ||
|
|
86411bcc9c | ||
|
|
dd5cdaae57 | ||
|
|
3ac2212733 | ||
|
|
518c9dfb1b | ||
|
|
614536db2b | ||
|
|
08ed6311fd | ||
|
|
54620667ef | ||
|
|
9789b28848 | ||
|
|
a1433b0280 | ||
|
|
6970fda3db | ||
|
|
8ca266ff3f | ||
|
|
9fd54946eb | ||
|
|
04bcb9baad | ||
|
|
a61fc81ead | ||
|
|
d9ba20713b | ||
|
|
8d9b92c6e4 | ||
|
|
c822d2af76 | ||
|
|
e8ebf3066c | ||
|
|
e71e5a16c1 | ||
|
|
8df96c6443 | ||
|
|
29a894367c | ||
|
|
416b289d44 | ||
|
|
86d5df7d34 | ||
|
|
6c6abd4ec5 | ||
|
|
d11da3c04a | ||
|
|
71623ac112 | ||
|
|
bd8455d6d2 | ||
|
|
edb4add549 | ||
|
|
8d5d58150d | ||
|
|
5222e1e965 | ||
|
|
9e7d894dad | ||
|
|
23eb26c5cb | ||
|
|
09390edc18 | ||
|
|
7ffd8d2711 | ||
|
|
e02df078b8 | ||
|
|
1e8eb3d37a | ||
|
|
ba3fed6d55 | ||
|
|
bb6540ab9a | ||
|
|
a4ad4c00e0 | ||
|
|
58c8d2fc05 | ||
|
|
4853f091c0 | ||
|
|
955db04be4 | ||
|
|
90cbf1fd57 | ||
|
|
030e831c76 | ||
|
|
4affe97022 | ||
|
|
14a145114e | ||
|
|
3092428cae | ||
|
|
71db108f91 | ||
|
|
ab2a6c73bd | ||
|
|
313d209664 | ||
|
|
2c87f0abfb | ||
|
|
b1ed5db4dc | ||
|
|
0caf5e7b7e | ||
|
|
0fedca7e6b | ||
|
|
ce0a3b44a4 | ||
|
|
f315bb1537 | ||
|
|
8846037f02 | ||
|
|
7cf30d4022 | ||
|
|
2485c94152 | ||
|
|
05a869402d | ||
|
|
46f9503e2f | ||
|
|
042a3cccc5 | ||
|
|
a4aa04e2e6 | ||
|
|
89499b8aad | ||
|
|
d5744bd32d | ||
|
|
cb4128653b | ||
|
|
eae005d17e | ||
|
|
2d7167924e | ||
|
|
98b6cb497d | ||
|
|
e966ebdb93 | ||
|
|
cb6ca3f724 | ||
|
|
f8b8c9eba8 | ||
|
|
f22db8c7ec | ||
|
|
d0ca53dd6f | ||
|
|
72022f62b5 | ||
|
|
0d3247c5df | ||
|
|
db8cbc2447 | ||
|
|
ca03db8219 | ||
|
|
9d068cb15a | ||
|
|
ffa79cd283 | ||
|
|
0a66bb97db | ||
|
|
61a62d8e88 | ||
|
|
f8ede59186 | ||
|
|
60a0b21547 | ||
|
|
438b1ae260 | ||
|
|
f1a82ccf5a | ||
|
|
cee0a8ce30 | ||
|
|
4ae3d387b9 | ||
|
|
ae545f9fdd | ||
|
|
237d350de7 | ||
|
|
46ec63299c | ||
|
|
ff5455e9da | ||
|
|
6ccaeef26d | ||
|
|
6436d5934d | ||
|
|
86804e5760 | ||
|
|
baf0570f0d | ||
|
|
154b0e4f08 | ||
|
|
34d15f8074 | ||
|
|
ebba46eb74 | ||
|
|
e3f024ea43 | ||
|
|
a1b5e615e7 | ||
|
|
67ab992852 | ||
|
|
e7ef2309bb | ||
|
|
541b9a04e7 | ||
|
|
c3bedae55b | ||
|
|
c23d11d3b3 | ||
|
|
d332a0c070 | ||
|
|
d537c0b8cd | ||
|
|
20859da95d | ||
|
|
4b8dd3a848 | ||
|
|
373e6c05d7 | ||
|
|
c5451d3594 | ||
|
|
cf1c96c3f7 |
No files matched your search
@@ -3,7 +3,7 @@
|
||||
<!--
|
||||
~
|
||||
~ BuildBattle - Ultimate building competition minigame
|
||||
~ Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
~ Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
@@ -20,21 +20,6 @@
|
||||
~
|
||||
-->
|
||||
|
||||
<!--
|
||||
~ Murder Mystery is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU General Public License as published by
|
||||
~ the Free Software Foundation; either version 3 of the License, or
|
||||
~ (at your option) any later version.
|
||||
~
|
||||
~ Murder Mystery 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 General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with Murder Mystery. If not, see <http://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
|
||||
+275
-146
@@ -4,17 +4,68 @@ Changelog is followed by special scheme which is required in order to allow auto
|
||||
deploy webhooks to print changelog successfully
|
||||
|
||||
## Log scheme
|
||||
|
||||
`### <current version from pom.xml> <anything else here>`
|
||||
`<update log line>`
|
||||
|
||||
That's all, matcher will stop when detects next line started with `###` match
|
||||
|
||||
### 5.0.6 Release (24.04.2024)
|
||||
* Updated to minigamesbox 1.3.8
|
||||
|
||||
### 5.0.5 Release (15.01.2024)
|
||||
* Updated to minigamesbox 1.3.7
|
||||
|
||||
### 5.0.4 Release (13.01.2024)
|
||||
* Updated to minigamesbox 1.3.6
|
||||
|
||||
### 5.0.3 Release (03.01.2024)
|
||||
* Added new command /bba locale <locale> to set your locale
|
||||
* Fixed GameProfile API 1.20 change
|
||||
* Fixed none kits related plugins issues
|
||||
|
||||
### 5.0.2 Release (31.12.2023)
|
||||
* Fixed gtb round reset on player leave
|
||||
* Fixed gtb "could not pass event AsyncPlayerChatEvent" if spectators ingame
|
||||
* Fixed bouncing and mouse pointer reset on themevoting
|
||||
* Added 1.20.3 & 1.20.4 support
|
||||
* Updated to minigamesbox 1.3.4
|
||||
|
||||
### 5.0.1 Release (21.08.2023)
|
||||
* Fixed rewards enabling
|
||||
* Fixed bossbar disabling
|
||||
* Fixed locale registration if service unavailable
|
||||
|
||||
### 5.0.0 Release (09.08.2023)
|
||||
* Added up to 1.20 compatibility
|
||||
* Changed arena solo and team to classic, with different team sizes
|
||||
* Changed supported languages [https://translate.plugily.xyz]
|
||||
* Changed plugin base is based on MinigamesCore [https://github.com/Plugily-Projects/MiniGamesBox]
|
||||
* Changed native java building to java17, java 8 downloadable on our discord [https://discord.plugily.xyz]
|
||||
* Fixed gtb mode issues
|
||||
* Fixed all known bugs
|
||||
|
||||
### 4.5.3 Release (04.08.2021 - xx.xx.2021)
|
||||
|
||||
* Fixed when players didn't got rewards after plot reset
|
||||
* Now you can configure the notification of the remaining build time
|
||||
* Fixed issue when player's inventories did not get cleared before teleport
|
||||
* An attempt to fix executing console reward commands multiple times
|
||||
* Fixed mysql create table statement
|
||||
* Added %ARENATYPE% as placeholder for messages
|
||||
* Fixed NPE when player's plot was invalid after NPC click
|
||||
* Added option for the third first guessers to receive more points
|
||||
* Fixed IndexOutOfBoundsException when retrieving currentBuilder at next round
|
||||
|
||||
### 4.5.2 Release (02.08.2021 - 03.08.2021)
|
||||
|
||||
* Fixed issues with spectators get added multiple times to the players list
|
||||
* Fixed Cannot invoke because "userPlot" is null
|
||||
|
||||
### 4.5.1 Release (15.04.2021 - 02.08.2021)
|
||||
|
||||
* Added 1.17 support
|
||||
* Added adjustable team mode plot size
|
||||
* Added adjustable team mode plot size
|
||||
* Added placeholder total_points_earned and highest_points
|
||||
* Added plot selector for team mode
|
||||
* Added greek as language (Thanks to poeditor contributors)
|
||||
@@ -22,12 +73,14 @@ That's all, matcher will stop when detects next line started with `###` match
|
||||
* Reuse XMaterial for specialitems
|
||||
* Fixed teamarena does not stop when only two players are left from the same team
|
||||
* Fixed spectatormode does not display summary and players
|
||||
>>> b1
|
||||
|
||||
> > > b1
|
||||
|
||||
* Added forcestart item
|
||||
* Added new message In-Game.Floor-Item-Blacklisted
|
||||
* Added /bb guess <word> argument (useful for servers with bungee handled chat)
|
||||
* Added placeholder arena_players_online
|
||||
* Added /bb join maxplayers type which tries to get the arena with the highest amount of players
|
||||
* Added /bb join maxplayers type which tries to get the baseArena with the highest amount of players
|
||||
* Added special_items.yml
|
||||
* Added changeable options menu item
|
||||
* Changed randomjoin mechanics -> Searches for starting -> random join -> Searches for waiting -> random join
|
||||
@@ -37,7 +90,7 @@ That's all, matcher will stop when detects next line started with `###` match
|
||||
* Changed empty message is no longer sent
|
||||
* Fixed gtb guessers got options menu on there inventory
|
||||
* Fixed on gtb the time and weather is not synced with all players
|
||||
* Fixed minecarts can go outside of plot
|
||||
* Fixed minecarts can go outside of plot
|
||||
* Fixed item frames can be rotated outside plot
|
||||
* Fixed some bugs on particle menu
|
||||
* Fixed when plugins scoreboards not re-appeared after game end
|
||||
@@ -48,66 +101,75 @@ That's all, matcher will stop when detects next line started with `###` match
|
||||
* Removed temp added scoreboard rewards
|
||||
|
||||
### 4.5.0 Release (21.03.2021 - 13.04.2021)
|
||||
|
||||
* Automatically disable bossbar support on 1.8 to prevent issue if bossbar is enabled on config.yml
|
||||
* Fix when arena selector GUI does not opened
|
||||
* Fix when baseArena selector GUI does not opened
|
||||
* Fixed HolidayManager that crashes themes on Teams and GTB mode
|
||||
* Fixed NPE on ArrowEvents and other version improvements
|
||||
|
||||
### 4.4.9 Release (19.03.2021)
|
||||
* Added configurable arena selector items (per state)
|
||||
|
||||
* Added configurable baseArena selector items (per state)
|
||||
* Fixed particle issues on some versions
|
||||
|
||||
### 4.4.8 Release (08.02.2021 - 17.03.2021)
|
||||
|
||||
* Added option to perform command after specific amount of reports
|
||||
* Added list of restricted entities that can't be spawned in game
|
||||
* Added legacy support
|
||||
* Added super_votes papi placeholder
|
||||
* Added TeleportArgument (/bba tp)
|
||||
* Added new RewardType scoreboard_remove
|
||||
* Added modifiable arena state names to language
|
||||
* Added modifiable baseArena state names to language
|
||||
* Fix when sign instances section is null in some cases
|
||||
* Fix when some inventory can't be opened in game
|
||||
* Moved statistic save method inside onDisable
|
||||
* Changed prevent interaction with enderchest
|
||||
|
||||
### 4.4.7 Release (24.01.2021 - 28.01.2021)
|
||||
* Fixed Join SubTitle not being sent
|
||||
|
||||
* Fixed Join SubTitle not being sent
|
||||
* Fixed stack trace array length is 0 when trying to send exception to service
|
||||
* Fix NPE related to citizens NPCRegistry method return value
|
||||
* Fixed spectators can not see each other after joining game while being ingame
|
||||
* Added 2 new Plot times - Noon, MidNight
|
||||
|
||||
### 4.4.6 Release (18.01.2021 - 22.01.2021)
|
||||
* Fixed bb items are not removed if inventory manager is enabled and the server is stopping
|
||||
|
||||
* Fixed bb items are not removed if inventory manager is enabled and the server is stopping
|
||||
* Fixed particle refresh scheduler not worked on game start
|
||||
|
||||
### 4.4.5 Release (31.12.2020 - 18.01.2021)
|
||||
|
||||
* ArgumentsRegistry now accessible from outside
|
||||
* Fixed some reported NPEs about setup inventory
|
||||
* Added start game reward action
|
||||
* Added join title and subtitle
|
||||
* Added customizable item name in arena selector gui (by ajgeiss0702)
|
||||
* Added customizable item name in baseArena selector gui (by ajgeiss0702)
|
||||
* Fixed asynchronous issue when performing commands from async chat
|
||||
* Optimized plot particle refresh scheduler, now it only runs when a game is running
|
||||
* Only add points to plot that do not have points already
|
||||
|
||||
### 4.4.4 Release (18.12.2020 - 29.12.2020)
|
||||
|
||||
* Rewritten scoreboardlib (fixed flickering and color matching) -> 122 chars for 1.14 up and 48 for lower versions
|
||||
* Fix async catch exception in old versions when teleporting players to their plots
|
||||
* Fixed setup menu on "normal" spigot servers
|
||||
|
||||
### 4.4.3 Release (30.11.2020 - 13.12.2020)
|
||||
|
||||
* Fixed joining through a sign while hotbar slot for leave-item is active
|
||||
* Fixed cast exception when banner meta is not item
|
||||
* Fixed NoSuchMethodError when CommandSender#spigot does not exists on 1.11
|
||||
* Fixed BiomeChange specially on 1.15 (PacketPlayOutMapChunk)
|
||||
* Fixed Command-Instead-Of-Head-Menu is not executed on the first menu
|
||||
* Fixed Command-Instead-Of-Head-Menu is not executed on the first menu
|
||||
* Fixed lore is not updating on setup inventory
|
||||
* Fixed ANNOUNCE_PLOTOWNER_LATER did not show both owners on team mode
|
||||
|
||||
### 4.4.2 Release (02.10.2020 - 12.11.2020)
|
||||
|
||||
* Fixed spectators are able to damage entities
|
||||
* Fixed NPE related to arenas config not loaded correctly
|
||||
* Fixed NPE related to baseArenas config not loaded correctly
|
||||
* Fixed for 1.11 player heads
|
||||
* Fixed particles can't activate again after they got removed
|
||||
* Fixed spectators can't fly after changing world
|
||||
@@ -121,10 +183,11 @@ That's all, matcher will stop when detects next line started with `###` match
|
||||
* Fixed NPE related to vote menu updating
|
||||
|
||||
### 4.4.1 Release (15.08.2020 - 20.09.2020)
|
||||
|
||||
* (Developer Alert - Class rename)
|
||||
* Added spectator mode
|
||||
* Added GTB to the SetUp inventory
|
||||
* Added arena selector
|
||||
* Added baseArena selector
|
||||
* Added support for 1.16 hex colors
|
||||
* Fixed NPE when teleporting players to plots
|
||||
* Fixed IllegalArgumentException when some particles have "custom class data"
|
||||
@@ -141,17 +204,18 @@ That's all, matcher will stop when detects next line started with `###` match
|
||||
* Fixed async catch from bukkit when performing commands
|
||||
* Fixed IllegalPluginAccessException on plugin disable
|
||||
* Fixed NPE on Plotreset (GTB)
|
||||
* Fixed player being kicked when trying to join an in-game arena
|
||||
* Fixed NPE when trying to teleport players to lobby location
|
||||
* Fixed player being kicked when trying to join an in-game baseArena
|
||||
* Fixed NPE when trying to teleport players to lobby location
|
||||
* Fixed PlaceholderAPI placeholders not works on scoreboard in guessTheBuild mode
|
||||
* Fixed problems with materials
|
||||
* Fixed problems with materials
|
||||
* Reworked version checker
|
||||
* Improved the tab complete handling
|
||||
* Updated PlaceholderAPI dependency
|
||||
* Updated locales to latest version
|
||||
* Added the possibility to change messages of locales on language.yml
|
||||
* Added the possibility to change messages of locales on language.yml
|
||||
|
||||
### 4.4.0 Release (01.07.2020 - 29.07.2020)
|
||||
|
||||
* GuessTheBuild release
|
||||
* Reworked whole Rewards
|
||||
* New file rewards.yml
|
||||
@@ -159,13 +223,13 @@ That's all, matcher will stop when detects next line started with `###` match
|
||||
* Added option to disable separate chat
|
||||
* Added possibility to change table name of mysql database
|
||||
* Added possibility to run command for report item
|
||||
* Added the new particles from 1.13 and up
|
||||
* Added the new particles from 1.13 and up
|
||||
* Added an option to disable party features
|
||||
* Added missing 1.14 & 1.15 & 1.16 Materials/Biomes
|
||||
* Added 1.16.x compatibility
|
||||
* Added 1.16.x compatibility
|
||||
* Added adjustable floor blacklist
|
||||
* Added bungeemode Arena shuffler
|
||||
* Added players will get kicked on bungeemode when arena is full and has no rights
|
||||
* Added players will get kicked on bungeemode when baseArena is full and has no rights
|
||||
* Added an event to cancel fire spread on the plot
|
||||
* Added option to announce plot owner after voting
|
||||
* Fixed force start command when setting forced theme didn't set build time properly
|
||||
@@ -178,38 +242,41 @@ That's all, matcher will stop when detects next line started with `###` match
|
||||
* Fixed team member leave plot reset
|
||||
* Fixed water/lava flow and piston outside of plot in worst cases
|
||||
* Fixed nether star (options menu) duplication
|
||||
* Tried to fix Server crash on 1.15
|
||||
* Tried to fix Server crash on 1.15
|
||||
* Migrator for new config file as there are some more changes
|
||||
* Update setup tips Feedback page link
|
||||
* Randomjoin command will now longer send proper message when no arena is available
|
||||
* Randomjoin command will now longer send proper message when no baseArena is available
|
||||
* Changed mysql updates to do only one instead of more than 10 (should improve performance)
|
||||
* Updated particles.yml (Thanks Fabian Adrian #6234)
|
||||
* Changed increased npc finder to radius of 5 to the plot
|
||||
* Optimized floor change to get all materials
|
||||
|
||||
### 4.3.2 Release
|
||||
|
||||
* Added per particle disabler
|
||||
* Fixed Already-Playing message on randomjoin command
|
||||
* Fixed Type-Arena-Name language
|
||||
|
||||
### 4.3.1 Release (31.03.2020)
|
||||
|
||||
* Fixed Heads in lower version than 1.15.X
|
||||
* Fixed bungee value Shutdown-When-Game-Ends
|
||||
* Fixed automatic bungee arena restart (Now scoreboard and Bossbar applies)
|
||||
* Tried to fix parties compatibility
|
||||
* Fixed automatic bungee baseArena restart (Now scoreboard and Bossbar applies)
|
||||
* Tried to fix parties compatibility
|
||||
* Fixed broken language migrator
|
||||
|
||||
### 4.3.0 Release (17.03.2020)
|
||||
|
||||
* PlaceholderAPI placeholders are no longer case sensitive
|
||||
* Added arena state placeholders for PlaceholderAPI:
|
||||
* %buildbattle_{arena id}:{data}% where data types are:
|
||||
* players - amount of players in arena
|
||||
* max_players - max players in arena
|
||||
* state - current state raw enum name eg. STARTING
|
||||
* state_pretty - prettified name of enum eg. Waiting (instead WAITING_FOR_PLAYERS)
|
||||
* mapname - name of arena map
|
||||
* arenatype - raw enum name of arena (SOLO, TEAM etc)
|
||||
* arenatype_pretty - prettified name of enum eg. Classic (instead SOLO)
|
||||
* Added baseArena state placeholders for PlaceholderAPI:
|
||||
* %buildbattle_{baseArena id}:{data}% where data types are:
|
||||
* players - amount of players in baseArena
|
||||
* max_players - max players in baseArena
|
||||
* state - current state raw enum name eg. STARTING
|
||||
* state_pretty - prettified name of enum eg. Waiting (instead WAITING_FOR_PLAYERS)
|
||||
* mapname - name of baseArena map
|
||||
* arenatype - raw enum name of baseArena (SOLO, TEAM etc)
|
||||
* arenatype_pretty - prettified name of enum eg. Classic (instead SOLO)
|
||||
* Fixed VoteMenu NullPointerException
|
||||
* Added Parties support for PAF and Parties
|
||||
* Now if user don´t vote the plot will get 3 points of this player to prevent unfair game behaviors
|
||||
@@ -218,26 +285,27 @@ That's all, matcher will stop when detects next line started with `###` match
|
||||
* Added End-Location-Hub boolean to bungee.yml
|
||||
* Fixed mysql database - Create a new one and your stats should be saved correctly
|
||||
|
||||
|
||||
### 4.2.0 Release (16.11.2019 - 13.12.2019) (by Tigerpanzer)
|
||||
* Fixed arena deletion
|
||||
|
||||
* Fixed baseArena deletion
|
||||
* Added a item to go to main options page
|
||||
* Fixed Holiday themes
|
||||
* Added a new MOTD Manager in the bungee.yml (Now you can define the message on your self)
|
||||
* Added a new MOTD Manager in the bungee.yml (Now you can define the message on your self)
|
||||
* Now the values in bungee.yml will work
|
||||
* Now the biomes permissions will work
|
||||
* Added new check for setup validation (now registered plots amount will be checked)
|
||||
* Added 1.15 compatibility
|
||||
|
||||
### 4.1.0 Release (13.07.2019 - 18.10.2019) (by Tigerpanzer and Plajer)
|
||||
|
||||
* Added new permission to join full games "buildbattle.fullgames"
|
||||
* Added the option to join when a game is full (you will kick a player without perm)
|
||||
* Fixed issue that you could join full games before they started now proper full game
|
||||
permission check will occur and do the thing to allow or disallow you to join
|
||||
permission check will occur and do the thing to allow or disallow you to join
|
||||
* Fixed file creating for bungee.yml
|
||||
* /bb randomjoin will now really join random arena not first one it find good to join
|
||||
* /bb randomjoin will now really join random baseArena not first one it find good to join
|
||||
* Added a new option to block commands ingame
|
||||
* Fixed the NoSuchMethodException on arena sign load when the sign isn´t a wallsign
|
||||
* Fixed the NoSuchMethodException on baseArena sign load when the sign isn´t a wallsign
|
||||
* Added Chinese (Traditional) locale (zh_tw prefix)
|
||||
* Changed Chinese (Simplified) locale prefix from zh to cn
|
||||
* Added 1.14 support
|
||||
@@ -247,33 +315,39 @@ permission check will occur and do the thing to allow or disallow you to join
|
||||
* Players hiding feature is now fully removed, it was buggy
|
||||
|
||||
### 4.0.2 Release (15.06.2019 - 13.07.2019)
|
||||
|
||||
* Join permission message outputs required permission node now
|
||||
* Biome menu won't throw errors when using it now
|
||||
* Fixed firework spawn after the game if they were disabled in config
|
||||
* Fixed odd game behaviour when game couldn't start because there were some lacking plots
|
||||
when player left game before he was removed from the plot
|
||||
when player left game before he was removed from the plot
|
||||
* Locales with special characters like Russian or Korean will now work properly and won't be seen as `?` characters
|
||||
* Fixed locales might not work in fresh install of plugin
|
||||
* Added 6 new locales: Portuguese (BR), Slovenian, Dutch, Lithuanian, Japanese and Italian (thanks a lot to our POEditor contributors!)
|
||||
* Added 6 new locales: Portuguese (BR), Slovenian, Dutch, Lithuanian, Japanese and Italian (thanks a lot to our POEditor
|
||||
contributors!)
|
||||
* Fixed Russian locale didn't work
|
||||
|
||||
### 4.0.1 Release (11.06.2019)
|
||||
|
||||
* Fixed game wouldn't start if there were 2 players or more, sorry
|
||||
* Fixed error occurred when you didn't look at sign while adding sign via setup GUI
|
||||
|
||||
### 4.0.0 Release (10.06.2019)
|
||||
|
||||
* Fixed typo in message accessor for guess the build game mode message
|
||||
* Now players aren't saved async in onDisable method which led to exceptions in disable stage
|
||||
* Fixed bad logic of assigning players to teams in teams game mode
|
||||
* Teams game mode require now to have at least 3 minimum players to play, it will set it to 3 if
|
||||
it's set lower
|
||||
it's set lower
|
||||
* Improved faster and more efficient scoreboard library (thanks to TigerHix)
|
||||
* Reload and arena delete commands now require confirmation to execute, you must type the command twice to confirm the action
|
||||
* Reload and baseArena delete commands now require confirmation to execute, you must type the command twice to confirm
|
||||
the action
|
||||
* Implemented faster Hikari database connection pool library instead of BoneCP, jar is now 3 times smaller
|
||||
* First time database creation is now made async not in main server thread
|
||||
* Apache Commons-io library is shaded into the jar now, 1.14 removed it
|
||||
* You cannot set non occluding blocks as a floor block
|
||||
* **CRITICAL** Players received packets that would break their chunks nearby them due to wrong arena plot reset check, now it's fixed
|
||||
* **CRITICAL** Players received packets that would break their chunks nearby them due to wrong baseArena plot reset
|
||||
check, now it's fixed
|
||||
* Debug in config is no longer visible by default, no one need it
|
||||
* Removed hiding/showing players in-game and outside game thing, it was bugged and better to avoid problems with it
|
||||
* Fixed game ending message was never showed when using any of the locales (accessor was broken)
|
||||
@@ -282,97 +356,134 @@ it's set lower
|
||||
* Added not playing message node to language.yml, locales already had it somehow
|
||||
|
||||
### 4.0.0 Beta Pre Releases 3-15 (03.10.2018 - 06.06.2019)
|
||||
> RC 2
|
||||
* Fixed plugin couldn't start if Cloudflare was blocked in your country (or services were offline)
|
||||
* Removed locale suggester, it will no longer spam console when English (default) locale is used
|
||||
* Fixed issue with plot adding via setup menu
|
||||
> RC 1
|
||||
* Fixed animals couldn't spawn and breed outside arenas
|
||||
* Fixed spawning animals on arena even if option for disable-spawning was false
|
||||
* Fixed /bba addnpc didn't work
|
||||
* Fixed setup GUI didn't work properly
|
||||
* Fixed [#612 exception when registering arenas](https://www.plajer.xyz/errorservice/viewer.php?id=612) when arenas.yml file was empty
|
||||
* Fixed [#610 exception when special item didn't have material-name section set](https://www.plajer.xyz/errorservice/viewer.php?id=610) now by default
|
||||
it will have BEDROCK value if absent
|
||||
* Added pro tips about user voice and /bba votes executable from console too
|
||||
> Pre 15
|
||||
* Fixed [#595 /bb randomjoin command exception](https://www.plajer.xyz/errorservice/viewer.php?id=595) when no arena type
|
||||
args were specified
|
||||
* Fixed [#592 /bba addplot command exception](https://www.plajer.xyz/errorservice/viewer.php?id=592) when no arena name
|
||||
was typed
|
||||
* Fixed [#589 options menu click exceptions](https://plajer.xyz/errorservice/viewer.php?id=589) when click was on
|
||||
air or outside inventoryView slots
|
||||
* Fixed Signs weren't updating if Signs-Block-States-Enabled option was false
|
||||
* Abandoned the direct try-catch exception handling in most of methods and event listeners in favour of
|
||||
logger listening, code looks better now
|
||||
* Implemented Holiday Events for April Fools, Christmas and Halloween, special themes
|
||||
for solo and teams will be applied if enabled
|
||||
> Pre 14
|
||||
* Fixed time couldn't be set for plots because we were checking raw slot click instead of normal slot
|
||||
* Made particles.yml particle items more user friendly (lores and names looks now better)
|
||||
* Fixed bba addplot command didn't work properly
|
||||
* Added fully configurable biomes in biomes.yml
|
||||
* Fixed biomes are now properly reset in plot reset option and after arena reset
|
||||
* Added "Go Back" button in particles remove menu
|
||||
> Pre 13
|
||||
* Added GuessTheBuild game mode (alpha)
|
||||
* When using super vote you won't see two game prefixes now
|
||||
* Merged /bba addvotes and /bba setvotes into /bba votes add/set command
|
||||
* Added message sent to player when receives super votes
|
||||
> Pre 12
|
||||
* Added BBPlayersPlotReceiveEvent to API
|
||||
* Fixed /bba forcestart wasn't working properly
|
||||
* Added BBPlotResetEvent to API
|
||||
* Particles speed is now 1, they may behave better for builders now
|
||||
* Now you can properly execute all /bb and /bba commands in-game while being non op player
|
||||
* Somehow plugin was lacking lobby events and you could lose food and health in lobby
|
||||
* Added chat events so in-game chat is no separated from server chat (I thought it's obvious)
|
||||
* Now after selection of head in heads inventoryView won't be closed, user will close it when he wants
|
||||
* Now language manager will use cached language.yml file so plugin will perform bit better
|
||||
* Theme vote GUI is now properly listening for click events, you don't need to click few times to make it vote
|
||||
* Added useSSL=false argument in mysql.yml address to avoid mysql warnings in console (not harmful)
|
||||
* Whole plugin runs now definitely faster and code execution time and plugin load decreases in timings
|
||||
* Setup GUI option for setting min/max players amount now runs smoothly
|
||||
> Pre 11
|
||||
* Added biomes in Options menu
|
||||
* Added time in Options menu
|
||||
* Code improvements and changes
|
||||
* Fixed arena signs were incorrectly saved via setup menu (4.0.0 pre issue)
|
||||
> Pre 10
|
||||
* Added setup tutorial link to setup menu
|
||||
* Added tip about downloadable maps when no arenas are set up while typing /bba list
|
||||
* Fixed exp not saving properly with InventoryManager
|
||||
> Pre 9
|
||||
* Fixed NPE when player was null (https://plajer.xyz/errorservice/viewer.php?id=347)
|
||||
* Code must be changed to avoid those NPE's in the future
|
||||
> Pre 8
|
||||
* Fixed NPE because of wrong string access in code
|
||||
* Locales will be now automatically disabled in this version - ppl don't read warnings about locales so I force them
|
||||
to disable
|
||||
* Now /bba reload /bba addvotes/setvotes and /bba list can be now properly executed from console
|
||||
> Pre 7
|
||||
* Updates are now checked async without freezing the main thread which caused TPS to drop a bit
|
||||
> Pre 6
|
||||
* Particles in menu are now incrementing automatically
|
||||
* Particle redstone requires DustOptions and causes errors so it was removed from menu
|
||||
* Fixed possible NPEs in block spread event (https://plajer.xyz/errorservice/viewer.php?id=282)
|
||||
* Fixed NPE when teleporting to plot, now players will be teleported 1 x and z block away from center if
|
||||
height reach Y plot limit (https://plajer.xyz/errorservice/viewer.php?id=283)
|
||||
> Pre 5
|
||||
* You cannot join game now infinitely through command (lol????)
|
||||
* Now players that will leave game will be visible by other players outside game
|
||||
> Pre 4
|
||||
* API change - now you can access BuildBattle API via pl.plajer.buildbattle.api
|
||||
* Maybe a fix for https://plajer.xyz/errorservice/viewer.php?id=244
|
||||
> Pre 3
|
||||
* Removed annoying "Please enable bStats" message
|
||||
* Code improvements
|
||||
* Added PR0 TIPS when editing arena
|
||||
|
||||
> RC 2
|
||||
|
||||
* Fixed plugin couldn't start if Cloudflare was blocked in your country (or services were offline)
|
||||
* Removed locale suggester, it will no longer spam console when English (default) locale is used
|
||||
* Fixed issue with plot adding via setup menu
|
||||
|
||||
> RC 1
|
||||
|
||||
* Fixed animals couldn't spawn and breed outside baseArenas
|
||||
* Fixed spawning animals on baseArena even if option for disable-spawning was false
|
||||
* Fixed /bba addnpc didn't work
|
||||
* Fixed setup GUI didn't work properly
|
||||
* Fixed [#612 exception when registering baseArenas](https://www.plajer.xyz/errorservice/viewer.php?id=612) when
|
||||
baseArenas.yml file was empty
|
||||
*
|
||||
Fixed [#610 exception when special item didn't have material-name section set](https://www.plajer.xyz/errorservice/viewer.php?id=610)
|
||||
now by default
|
||||
it will have BEDROCK value if absent
|
||||
* Added pro tips about user voice and /bba votes executable from console too
|
||||
|
||||
> Pre 15
|
||||
|
||||
* Fixed [#595 /bb randomjoin command exception](https://www.plajer.xyz/errorservice/viewer.php?id=595) when no baseArena
|
||||
type
|
||||
args were specified
|
||||
* Fixed [#592 /bba addplot command exception](https://www.plajer.xyz/errorservice/viewer.php?id=592) when no baseArena
|
||||
name
|
||||
was typed
|
||||
* Fixed [#589 options menu click exceptions](https://plajer.xyz/errorservice/viewer.php?id=589) when click was on
|
||||
air or outside inventoryView slots
|
||||
* Fixed Signs weren't updating if Signs-Block-States-Enabled option was false
|
||||
* Abandoned the direct try-catch exception handling in most of methods and event listeners in favour of
|
||||
logger listening, code looks better now
|
||||
* Implemented Holiday Events for April Fools, Christmas and Halloween, special themes
|
||||
for solo and teams will be applied if enabled
|
||||
|
||||
> Pre 14
|
||||
|
||||
* Fixed time couldn't be set for plots because we were checking raw slot click instead of normal slot
|
||||
* Made particles.yml particle items more user friendly (lores and names looks now better)
|
||||
* Fixed bba addplot command didn't work properly
|
||||
* Added fully configurable biomes in biomes.yml
|
||||
* Fixed biomes are now properly reset in plot reset option and after baseArena reset
|
||||
* Added "Go Back" button in particles remove menu
|
||||
|
||||
> Pre 13
|
||||
|
||||
* Added GuessTheBuild game mode (alpha)
|
||||
* When using super vote you won't see two game prefixes now
|
||||
* Merged /bba addvotes and /bba setvotes into /bba votes add/set command
|
||||
* Added message sent to player when receives super votes
|
||||
|
||||
> Pre 12
|
||||
|
||||
* Added BBPlayersPlotReceiveEvent to API
|
||||
* Fixed /bba forcestart wasn't working properly
|
||||
* Added BBPlotResetEvent to API
|
||||
* Particles speed is now 1, they may behave better for builders now
|
||||
* Now you can properly execute all /bb and /bba commands in-game while being non op player
|
||||
* Somehow plugin was lacking lobby events and you could lose food and health in lobby
|
||||
* Added chat events so in-game chat is no separated from server chat (I thought it's obvious)
|
||||
* Now after selection of head in heads inventoryView won't be closed, user will close it when he wants
|
||||
* Now language manager will use cached language.yml file so plugin will perform bit better
|
||||
* Theme vote GUI is now properly listening for click events, you don't need to click few times to make it vote
|
||||
* Added useSSL=false argument in mysql.yml address to avoid mysql warnings in console (not harmful)
|
||||
* Whole plugin runs now definitely faster and code execution time and plugin load decreases in timings
|
||||
* Setup GUI option for setting min/max players amount now runs smoothly
|
||||
|
||||
> Pre 11
|
||||
|
||||
* Added biomes in Options menu
|
||||
* Added time in Options menu
|
||||
* Code improvements and changes
|
||||
* Fixed baseArena signs were incorrectly saved via setup menu (4.0.0 pre issue)
|
||||
|
||||
> Pre 10
|
||||
|
||||
* Added setup tutorial link to setup menu
|
||||
* Added tip about downloadable maps when no baseArenas are set up while typing /bba list
|
||||
* Fixed exp not saving properly with InventoryManager
|
||||
|
||||
> Pre 9
|
||||
|
||||
* Fixed NPE when player was null (https://plajer.xyz/errorservice/viewer.php?id=347)
|
||||
* Code must be changed to avoid those NPE's in the future
|
||||
|
||||
> Pre 8
|
||||
|
||||
* Fixed NPE because of wrong string access in code
|
||||
* Locales will be now automatically disabled in this version - ppl don't read warnings about locales so I force them
|
||||
to disable
|
||||
* Now /bba reload /bba addvotes/setvotes and /bba list can be now properly executed from console
|
||||
|
||||
> Pre 7
|
||||
|
||||
* Updates are now checked async without freezing the main thread which caused TPS to drop a bit
|
||||
|
||||
> Pre 6
|
||||
|
||||
* Particles in menu are now incrementing automatically
|
||||
* Particle redstone requires DustOptions and causes errors so it was removed from menu
|
||||
* Fixed possible NPEs in block spread event (https://plajer.xyz/errorservice/viewer.php?id=282)
|
||||
* Fixed NPE when teleporting to plot, now players will be teleported 1 x and z block away from center if
|
||||
height reach Y plot limit (https://plajer.xyz/errorservice/viewer.php?id=283)
|
||||
|
||||
> Pre 5
|
||||
|
||||
* You cannot join game now infinitely through command (lol????)
|
||||
* Now players that will leave game will be visible by other players outside game
|
||||
|
||||
> Pre 4
|
||||
|
||||
* API change - now you can access BuildBattle API via pl.plajer.buildbattle.api
|
||||
* Maybe a fix for https://plajer.xyz/errorservice/viewer.php?id=244
|
||||
|
||||
> Pre 3
|
||||
|
||||
* Removed annoying "Please enable bStats" message
|
||||
* Code improvements
|
||||
* Added PR0 TIPS when editing baseArena
|
||||
|
||||
### 4.0.0 Release (20.08.2018 - 28.09.2018)
|
||||
|
||||
* Fixed NullPointerException for users who where no longer online
|
||||
* Now using default values when they not exist in config to avoid NullPointerException from ConfigPreferences
|
||||
* Fixed IllegalArgumentException when you add invalid item name to the in-game items blacklist - now it will notify you in console
|
||||
* Fixed IllegalArgumentException when you add invalid item name to the in-game items blacklist - now it will notify you
|
||||
in console
|
||||
* Fixed %player% placeholder wasn't parsed in /bb stats <player>
|
||||
* Added PlaceholderAPI placeholders in scoreboard
|
||||
* Added Russian, Czech, Romanian and Estonian locales (thanks to POEditor contributors!)
|
||||
@@ -392,13 +503,16 @@ it's set lower
|
||||
* Head blocks textures are now loading instantly and do not cause server to freeze at the start now
|
||||
* Fixed /bb top was reversed while MySQL was enabled
|
||||
* Disabled game end rewards by default because they were confusing for users
|
||||
* Fixed server was stopped using Shutdown-When-Game-Ends option but player just left not started arena
|
||||
* Fixed server was stopped using Shutdown-When-Game-Ends option but player just left not started baseArena
|
||||
* Player will be given now survival gamemode on server stop
|
||||
* Removed unused code for entities
|
||||
|
||||
### 3.5.1 Release (17.08.2018)
|
||||
* Fixed NumberFormatException for language.yml migrator - this error is very rare to occur in normal environment but it was reported so I fixed it
|
||||
* Fixed NullPointerException for plot adding via selector wand due to lack of code stop when message with not full selection was sent
|
||||
|
||||
* Fixed NumberFormatException for language.yml migrator - this error is very rare to occur in normal environment but it
|
||||
was reported so I fixed it
|
||||
* Fixed NullPointerException for plot adding via selector wand due to lack of code stop when message with not full
|
||||
selection was sent
|
||||
* Fixed Can't fly outside plot message but you were in plot
|
||||
* Fixed scoreboard contents were always in Waiting state
|
||||
* Fixed IndexOutOfBoundsException in join event while bungee is enabled
|
||||
@@ -406,20 +520,23 @@ it's set lower
|
||||
* Fixed NoDefClassFoundException in 1.13 while using sign game states
|
||||
|
||||
### 3.5.0 Release (08/16.08.2018)
|
||||
|
||||
* Built against PLCore API
|
||||
* Hooked code with Error reporter service
|
||||
* Fixed MySQL error
|
||||
* Removed WorldEdit from arena usages
|
||||
* Added ability to edit floor in game (requires arenas.yml edit or new setup!)
|
||||
* Removed WorldEdit from baseArena usages
|
||||
* Added ability to edit floor in game (requires baseArenas.yml edit or new setup!)
|
||||
* Added joints when users have same points in voting time
|
||||
* Fixed small problem when game was started and voting for theme started, timer was set for build time instead of voting time and it
|
||||
could be seen in scoreboard for a second
|
||||
* Fixed small problem when game was started and voting for theme started, timer was set for build time instead of voting
|
||||
time and it
|
||||
could be seen in scoreboard for a second
|
||||
* Plot reset now include weather reset
|
||||
* Added Turkish and Indonesian locales (thanks to POEditor contributors)
|
||||
* Added /bba removeplot command
|
||||
* Added new command /bba plotwand
|
||||
|
||||
### 3.4.1 Release (30.07/03.08.2018)
|
||||
|
||||
* Added public access to MySQL executeUpdate method
|
||||
* Added BBPlayerStatisticChangeEvent event
|
||||
* Updated Spanish and Korean locales
|
||||
@@ -427,6 +544,7 @@ could be seen in scoreboard for a second
|
||||
* Removed scoreboard saving in InventoryManager due to errors
|
||||
|
||||
### 3.4.0 Release (25/29.07.2018)
|
||||
|
||||
* Added super votes
|
||||
* Added /bb top command
|
||||
* Fixed locales and updated them
|
||||
@@ -434,6 +552,7 @@ could be seen in scoreboard for a second
|
||||
* Added /bba forcestart <theme> to start with predefined theme (suggested by ColaIan)
|
||||
|
||||
### 3.3.0 Release (24.07.2018)
|
||||
|
||||
* Now while teleporting to the plot you won't fall down
|
||||
* Fixed xp was given wrong using inventoryView manager
|
||||
* Removed unnecessary listeners from spectator code
|
||||
@@ -441,24 +560,29 @@ could be seen in scoreboard for a second
|
||||
* Removed Particle-Offset option, was useless, default offset should stay same for every server
|
||||
* Removed Disable-Scoreboard-Ingame option as scoreboard is integral part of the game
|
||||
* Removed Hook-Into-Vault option as plugin automatically hooks with Vault if found
|
||||
(this hook really doesn't add anything except an extra placeholder on the scoreboard which is anyway medium useful in this game)
|
||||
(this hook really doesn't add anything except an extra placeholder on the scoreboard which is anyway medium useful in
|
||||
this game)
|
||||
* Using item flags instead of empty custom enchant which didn't work in 1.13
|
||||
* **Added 1.13 support**
|
||||
(still lots of code uses deprecated code which shouldn't be used in 1.13 but because 1.13 has got backwards compatibility
|
||||
we will keep that for a while as an temporary workaround)
|
||||
**Keep in mind that 1.13 forces me to do changes with ID's in BuildBattle and those changes will be done soon**
|
||||
(still lots of code uses deprecated code which shouldn't be used in 1.13 but because 1.13 has got backwards
|
||||
compatibility
|
||||
we will keep that for a while as an temporary workaround)
|
||||
**Keep in mind that 1.13 forces me to do changes with ID's in BuildBattle and those changes will be done soon**
|
||||
|
||||
### 3.2.2 Release (20.07.2018)
|
||||
|
||||
* Fixed NoSuchMethod error in 1.9.4 for title
|
||||
* Added support for Vietnamese, Hungarian and Chinese simplified locales
|
||||
* Added ability to change weather in plot
|
||||
|
||||
### 3.2.1 Release (14.07.2018)
|
||||
|
||||
* Fixed NPE when clicking not named Villager
|
||||
* Fixed migration error
|
||||
|
||||
### 3.2.0 Release (06/12.07.2018)
|
||||
* Added video tutorial link while creating new arena
|
||||
|
||||
* Added video tutorial link while creating new baseArena
|
||||
* Added new game mode: TEAM
|
||||
* Fixed error on disabling caused by disabled boss bar feature
|
||||
* Item rewards at the end of the game now will be properly given after clearing in-game inventoryView of players
|
||||
@@ -472,20 +596,23 @@ we will keep that for a while as an temporary workaround)
|
||||
* Separate game timer for team mode
|
||||
|
||||
### 3.1.2 Release (05.07.2018)
|
||||
|
||||
* Fixed error when 1st winner UUID was null (somehow)
|
||||
* Added subtitle "x seconds left" in game
|
||||
|
||||
### 3.1.0 Release (08.06.2018)
|
||||
|
||||
* New good looking summary message at the end of the game
|
||||
* Added game sign block states
|
||||
* /bb command is now translatable via language.yml
|
||||
* Admin commands (/bba) are now better with hover and click event (JSON messages)
|
||||
* Default map name when creating new arena is arena ID not "0" now
|
||||
* Default map name when creating new baseArena is baseArena ID not "0" now
|
||||
* Now warning message "can't save language.yml because already exists!" won't occur anymore
|
||||
* Fixed error in console when player left the arena and his plot was cleared even if he didn't have it
|
||||
* Fixed error in console when player left the baseArena and his plot was cleared even if he didn't have it
|
||||
* Now you can't change your floor by NPC during the voting time
|
||||
|
||||
### 3.0.4 Release (04.06.2018)
|
||||
|
||||
* Rewards will be given now only once after the game
|
||||
* Now you can leave started game without spamming infinitely errors in console
|
||||
* Fixed broken heads lores in heads menu and changed some strings there
|
||||
@@ -493,12 +620,14 @@ we will keep that for a while as an temporary workaround)
|
||||
* Now sending "You've became xth" message for 4th winners and lower
|
||||
* Voting for player plot title is now displayed longer
|
||||
* Added missing plugin prefix in voting messages
|
||||
* Immediately voting after game timer ends now
|
||||
* Immediately voting after game timer ends now
|
||||
|
||||
### 3.0.2 Release (03.06.2018)
|
||||
|
||||
* Fixed /bb create command not working
|
||||
* Added /bba settheme command
|
||||
* Fixed game boss bar not removing after plugin force disable
|
||||
|
||||
### 3.0.0 Release (14.05.2018 - 01.06.2018)
|
||||
|
||||
* Add everything here
|
||||
@@ -5,6 +5,7 @@
|
||||
**I'm sincerely glad to everyone who supported our project every time!**
|
||||
|
||||
**Contributors are listed in alphabetical order, every contributor is equally important!**
|
||||
|
||||
* Adrian Garay - Spanish translator
|
||||
* [Dianox](https://www.spigotmc.org/members/dianox.74931/) - French translator
|
||||
* Fatih Resul Göker - Turkish translator
|
||||
@@ -18,14 +19,17 @@
|
||||
* [MattUGV](https://www.spigotmc.org/members/mattugv.139086/) - code snippets
|
||||
* [montlikadani](https://www.spigotmc.org/members/toldi.251100/) - Hungarian translator and code contributor
|
||||
* Pheonix Harryson - Korean translator
|
||||
* [Tigerkatze](https://www.spigotmc.org/members/tigerkatze.414545/) - Main tester, German translator and staff member of Plajer's Lair discord
|
||||
* [Tigerkatze](https://www.spigotmc.org/members/tigerkatze.414545/) - Main tester, German translator and staff member of
|
||||
Plajer's Lair discord
|
||||
* [TomTheDeveloper](https://www.spigotmc.org/members/tomthedeveloper.4729/) - former author of Build Battle 1 and 2
|
||||
* [Tristiisch74](https://www.spigotmc.org/members/tristiisch74.149406/) - code snippets
|
||||
|
||||
**Thanks to these companies for providing free licenses for Build Battle open source work:**
|
||||
|
||||
* Code Whale Inc. - POEditor open source project license
|
||||
|
||||
**Also thanks to every bug reporters for reporting us those nasty bugs, and code contributors for making Build Battle better!**
|
||||
**Also thanks to every bug reporters for reporting us those nasty bugs, and code contributors for making Build Battle
|
||||
better!**
|
||||
|
||||
`Please note that translators are put here only if their contribution to the language is higher than 15% of total strings`
|
||||
|
||||
+160
-160
@@ -1,190 +1,190 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
@@ -192,9 +192,9 @@ modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
@@ -202,12 +202,12 @@ non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
@@ -232,19 +232,19 @@ terms of section 4, provided that you also meet all of these conditions:
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
@@ -290,75 +290,75 @@ in one of these ways:
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
@@ -385,74 +385,74 @@ that material) supplement the terms of this License with terms:
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
@@ -460,43 +460,43 @@ give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
@@ -510,7 +510,7 @@ covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
@@ -518,10 +518,10 @@ or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
@@ -533,73 +533,73 @@ for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
@@ -609,9 +609,9 @@ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
@@ -622,11 +622,11 @@ copy of the Program in return for a fee.
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
@@ -649,7 +649,7 @@ the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
@@ -658,17 +658,17 @@ notice like this when it starts in an interactive mode:
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
+20
-9
@@ -1,29 +1,40 @@
|
||||

|
||||
|
||||
# Build Battle [](https://jd.plugily.xyz/apidocs/minecraft/buildbattle) [](https://wiki.plugily.xyz/minecraft/buildbattle/index.php) [](https://sonarcloud.io/dashboard?id=Plugily-Projects_BuildBattle) [](https://discord.gg/UXzUdTP)
|
||||
BuildBattle is a Minecraft minigame designed for small and big servers. This minigame is unique and very configurable, 100% free and open source!
|
||||
# Build Battle [](https://maven.plugily.xyz/#/releases/plugily/projects/buildbattle) [](https://maven.plugily.xyz/javadoc/releases/plugily/projects/buildbattle/latest) [](https://sonarcloud.io/summary/overall?id=Plugily-Projects_BuildBattle) [](https://discord.plugily.xyz) [](https://patreon.com/plugily)
|
||||
|
||||
BuildBattle is a Minecraft minigame designed for small and big servers. This minigame is unique and very configurable,
|
||||
100% free and open source!
|
||||
|
||||
The goal is to build the best you can! You must compete with other players in this building game. Who will be the best?
|
||||
Have fun using it! Leave a good rating if you really like it.
|
||||
|
||||
## Want to contribute in this project?
|
||||
[**💣 Issues Reporting (Discord)**](https://discordapp.com/invite/UXzUdTP) [**❤ Make Donation**](https://www.paypal.me/plugilyprojects)
|
||||
|
||||
[**💣 Issues Reporting (Discord)**](https://discordapp.com/invite/UXzUdTP)
|
||||
[**❤ Make Donation**](https://www.paypal.me/plugilyprojects)
|
||||
|
||||
# Credits
|
||||
|
||||
## Open Source Libraries
|
||||
| Library | Author | License |
|
||||
|-------------------------------------------------------------|-------------------------------------------------|----------------------------------------------------------------------------|
|
||||
| [InventoryFramework](https://github.com/stefvanschie/IF/) | [stefvanschie](https://github.com/stefvanschie) | [Unlicense](https://github.com/stefvanschie/IF/blob/master/LICENSE) |
|
||||
| [ScoreboardLib](https://github.com/TigerHix/ScoreboardLib/) | [TigerHix](https://github.com/TigerHix) | [LGPLv3](https://github.com/TigerHix/ScoreboardLib/blob/master/LICENSE) |
|
||||
|
||||
| Library | Author | License |
|
||||
|-------------------------------------------------------------|-------------------------------------------------------|------------------------------------------------------------------------------------|
|
||||
| [InventoryFramework](https://github.com/stefvanschie/IF/) | [stefvanschie](https://github.com/stefvanschie) | [Unlicense](https://github.com/stefvanschie/IF/blob/master/LICENSE) |
|
||||
| [ScoreboardLib](https://github.com/TigerHix/ScoreboardLib/) | [TigerHix](https://github.com/TigerHix) | [LGPLv3](https://github.com/TigerHix/ScoreboardLib/blob/master/LICENSE) |
|
||||
| [HikariCP](https://github.com/brettwooldridge/HikariCP) | [brettwooldridge](https://github.com/brettwooldridge) | [Apache License 2.0](https://github.com/brettwooldridge/HikariCP/blob/dev/LICENSE) |
|
||||
| [bStats](https://github.com/Bastian/bStats-Metrics) | [Bastian](https://github.com/Bastian) | [LGPLv3](https://github.com/Bastian/bStats-Metrics/blob/master/LICENSE) |
|
||||
| [Commons Box](https://github.com/Plajer/Commons-Box) | [Plajer](https://github.com/Plajer) | [GPLv3](https://github.com/Plajer/Commons-Box/blob/master/LICENSE.md) |
|
||||
| [bStats](https://github.com/Bastian/bStats-Metrics) | [Bastian](https://github.com/Bastian) | [LGPLv3](https://github.com/Bastian/bStats-Metrics/blob/master/LICENSE) |
|
||||
| [Commons Box](https://github.com/Plajer/Commons-Box) | [Plajer](https://github.com/Plajer) | [GPLv3](https://github.com/Plajer/Commons-Box/blob/master/LICENSE.md) |
|
||||
|
||||
## Open Source Licenses
|
||||
|
||||
#### Code Whale
|
||||
|
||||
<img src="https://poeditor.com/public/images/logo/logo_head_500_transparent.png" alt="jetbrains logo" width="150"/>
|
||||
|
||||
Thanks to Code Whale for Open Source license for POEditor project.
|
||||
|
||||
## Contributors
|
||||
|
||||
<a href="https://github.com/Plugily-Projects/BuildBattle/graphs/contributors">
|
||||
<img src="https://contrib.rocks/image?repo=Plugily-Projects/BuildBattle" />
|
||||
</a>
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~
|
||||
~ BuildBattle - Ultimate building competition minigame
|
||||
~ Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU 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 General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>plugily.projects</groupId>
|
||||
<artifactId>buildbattle</artifactId>
|
||||
<version>5.0.0</version>
|
||||
<name>BuildBattle</name>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>plugilyprojects</id>
|
||||
<url>https://maven.plugily.xyz/releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>plugilyprojects-snapshots</id>
|
||||
<url>https://maven.plugily.xyz/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>citizens-repo</id>
|
||||
<url>http://repo.citizensnpcs.co/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.19.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>23.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plugily.projects</groupId>
|
||||
<artifactId>MiniGamesBox-Classic</artifactId>
|
||||
<version>1.2.0-SNAPSHOT51</version>
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.citizensnpcs</groupId>
|
||||
<artifactId>citizensapi</artifactId>
|
||||
<version>2.0.26-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ch.ethz.globis.phtree</groupId>
|
||||
<artifactId>phtree</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.12.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.10.1</version>
|
||||
<goals>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.4.0</version>
|
||||
<configuration>
|
||||
<destDir>minecraft/buildbattle</destDir>
|
||||
<isOffline>false</isOffline>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>plugily.projects.buildbattle.database.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>plugily.projects.minigamesbox</pattern>
|
||||
<shadedPattern>plugily.projects.buildbattle.minigamesbox</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>plugily.projects.commonsbox</pattern>
|
||||
<shadedPattern>plugily.projects.buildbattle.commonsbox</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- External beta versions discord deployer plugin -->
|
||||
<plugin>
|
||||
<groupId>plugily.projects</groupId>
|
||||
<artifactId>betty-maven-plugin</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<configuration>
|
||||
<changelogFile>${project.basedir}/CHANGELOG.md</changelogFile>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- External beta versions discord deployer plugin -->
|
||||
</plugins>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh</artifactId>
|
||||
<version>3.5.2</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>plugily-projects</id>
|
||||
<url>https://maven.plugily.xyz/releases</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
</project>
|
||||
@@ -0,0 +1,43 @@
|
||||
name: Bump and Publish Development Branch
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ development ]
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
bump:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Latest Commit
|
||||
uses: actions/checkout@v4.1.3
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Bump Version
|
||||
id: bump
|
||||
uses: Plugily-Projects/version-bump-action@v8
|
||||
with:
|
||||
github-token: ${{ secrets.github_token }}
|
||||
auto-version-bump: true
|
||||
- name: Print Version
|
||||
run: "echo 'New Version: ${{steps.bump.outputs.version}}'"
|
||||
publish:
|
||||
needs: bump
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Latest Commit
|
||||
uses: actions/checkout@v4.1.3
|
||||
with:
|
||||
ref: 'development'
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4.2.1
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
java-package: jdk
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Publish with Gradle
|
||||
run: ./gradlew publishMavenPublicationToSnapshotsRepository
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ secrets.SNAPSHOTSUSERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.SNAPSHOTSPASSWORD }}
|
||||
@@ -0,0 +1,46 @@
|
||||
name: Bump and Publish Master Branch
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
workflow_dispatch:
|
||||
jobs:
|
||||
bump:
|
||||
if: github.event.pull_request.merged
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Latest Commit
|
||||
uses: actions/checkout@v4.1.3
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Bump Version
|
||||
id: bump
|
||||
uses: Plugily-Projects/version-bump-action@v8
|
||||
with:
|
||||
github-token: ${{ secrets.github_token }}
|
||||
auto-version-bump: false
|
||||
auto-version-bump-release: true
|
||||
- name: Print Version
|
||||
run: "echo 'New Version: ${{steps.bump.outputs.version}}'"
|
||||
publish:
|
||||
needs: bump
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Latest Commit
|
||||
uses: actions/checkout@v4.1.3
|
||||
with:
|
||||
ref: 'master'
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v4.2.1
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
java-package: jdk
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
- name: Publish with Gradle
|
||||
run: ./gradlew publishMavenPublicationToReleasesRepository
|
||||
env:
|
||||
MAVEN_USERNAME: ${{ secrets.RELEASESUSERNAME }}
|
||||
MAVEN_PASSWORD: ${{ secrets.RELEASESPASSWORD }}
|
||||
@@ -1,65 +0,0 @@
|
||||
# This is a basic workflow to help you get started with Actions
|
||||
|
||||
name: deploy
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
# Triggers the workflow on push or pull request events but only for the main branch
|
||||
push:
|
||||
branches: [ development ]
|
||||
# pull_request:
|
||||
# branches: [ main ]
|
||||
|
||||
# Allows you to run this workflow manually from the Actions tab
|
||||
workflow_dispatch:
|
||||
|
||||
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
|
||||
jobs:
|
||||
# This workflow contains a single job called "build"
|
||||
deploy:
|
||||
# The type of runner that the job will run on
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
# Steps represent a sequence of tasks that will be executed as part of the job
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Bump Version
|
||||
id: bump
|
||||
uses: Plugily-Projects/maven-version-bump-action@dev
|
||||
with:
|
||||
github-token: ${{ secrets.github_token }}
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.m2/repository
|
||||
key: maven-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: maven-
|
||||
|
||||
- name: Set up Maven
|
||||
uses: stCarolas/setup-maven@v4
|
||||
with:
|
||||
maven-version: 3.6.3
|
||||
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 16
|
||||
|
||||
- name: maven-settings-action
|
||||
uses: s4u/maven-settings-action@v2.4.0
|
||||
with:
|
||||
servers: |
|
||||
[{
|
||||
"id": "${{ secrets.PLUGILY_MAVEN }}",
|
||||
"username": "${{ secrets.PLUGILY_MAVEN_USERNAME }}",
|
||||
"password": "${{ secrets.PLUGILY_MAVEN_PASSWORD }}"
|
||||
},
|
||||
{
|
||||
"id": "${{ secrets.PLUGILY_JD }}",
|
||||
"username": "${{ secrets.PLUGILY_JD_USERNAME }}",
|
||||
"password": "${{ secrets.PLUGILY_JD_PASSWORD }}"
|
||||
}]
|
||||
|
||||
- run: mvn clean verify compile package site:site site:deploy deploy -f pom.xml
|
||||
@@ -1,48 +0,0 @@
|
||||
name: sonarcloud
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- development
|
||||
- dev
|
||||
- main
|
||||
- master
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened]
|
||||
jobs:
|
||||
sonarcloud:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||
|
||||
- name: Set up JDK 16
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 16
|
||||
|
||||
- name: Set up Maven
|
||||
uses: stCarolas/setup-maven@v4
|
||||
with:
|
||||
maven-version: 3.6.3
|
||||
|
||||
- name: Cache SonarCloud packages
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.sonar/cache
|
||||
key: ${{ runner.os }}-sonar
|
||||
restore-keys: ${{ runner.os }}-sonar
|
||||
|
||||
- name: Cache Maven packages
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.m2
|
||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||
restore-keys: ${{ runner.os }}-m2
|
||||
|
||||
- name: Build and analyze
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
|
||||
@@ -4,4 +4,3 @@
|
||||
/target/
|
||||
/minecraft/
|
||||
/docs/
|
||||
.*
|
||||
@@ -0,0 +1,107 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("signing")
|
||||
`maven-publish`
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
java
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||
maven("https://oss.sonatype.org/content/repositories/snapshots")
|
||||
maven("https://oss.sonatype.org/content/repositories/central")
|
||||
maven(uri("https://papermc.io/repo/repository/maven-public/"))
|
||||
maven(uri("https://maven.plugily.xyz/releases"))
|
||||
maven(uri("https://maven.plugily.xyz/snapshots"))
|
||||
maven(uri("https://repo.citizensnpcs.co/"))
|
||||
maven(uri("https://repo.maven.apache.org/maven2/"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("plugily.projects:MiniGamesBox-Classic:1.3.9") { isTransitive = false }
|
||||
compileOnly("org.spigotmc:spigot-api:1.20.4-R0.1-SNAPSHOT")
|
||||
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
|
||||
compileOnly("net.citizensnpcs:citizensapi:2.0.31-SNAPSHOT")
|
||||
compileOnly("org.jetbrains:annotations:24.0.1")
|
||||
}
|
||||
|
||||
group = "plugily.projects"
|
||||
version = "5.0.7"
|
||||
description = "BuildBattle"
|
||||
|
||||
java {
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
tasks {
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveClassifier.set("")
|
||||
relocate("plugily.projects.minigamesbox", "plugily.projects.buildbattle.minigamesbox")
|
||||
relocate("com.zaxxer.hikari", "plugily.projects.buildbattle.database.hikari")
|
||||
minimize()
|
||||
}
|
||||
|
||||
processResources {
|
||||
filesMatching("**/plugin.yml") {
|
||||
expand(project.properties)
|
||||
}
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "Releases"
|
||||
url = uri("https://maven.plugily.xyz/releases")
|
||||
credentials {
|
||||
username = System.getenv("MAVEN_USERNAME")
|
||||
password = System.getenv("MAVEN_PASSWORD")
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "Snapshots"
|
||||
url = uri("https://maven.plugily.xyz/snapshots")
|
||||
credentials {
|
||||
username = System.getenv("MAVEN_USERNAME")
|
||||
password = System.getenv("MAVEN_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
BIN
Binary file not shown.
+26
@@ -0,0 +1,26 @@
|
||||
#
|
||||
#
|
||||
# BuildBattle - Ultimate building competition minigame
|
||||
# Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,249 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
#
|
||||
# BuildBattle - Ultimate building competition minigame
|
||||
# Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+92
@@ -0,0 +1,92 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
Binary file not shown.
@@ -1,5 +0,0 @@
|
||||
_This lib folder contains external libs that are not provided by their author with Maven._
|
||||
|
||||
**(All external libraries located in this folder have been approved by their author!)**
|
||||
|
||||
PAFSpigot (Simonsator#5834 | https://www.spigotmc.org/resources/authors/simonsator.67188/ )
|
||||
@@ -1,390 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~
|
||||
~ BuildBattle - Ultimate building competition minigame
|
||||
~ Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
~
|
||||
~ This program is free software: you can redistribute it and/or modify
|
||||
~ it under the terms of the GNU 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 General Public License for more details.
|
||||
~
|
||||
~ You should have received a copy of the GNU General Public License
|
||||
~ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
~
|
||||
-->
|
||||
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>plugily.projects</groupId>
|
||||
<artifactId>buildbattle</artifactId>
|
||||
<version>4.5.2</version>
|
||||
<name>BuildBattle</name>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<sonar.projectKey>Plugily-Projects_BuildBattle</sonar.projectKey>
|
||||
<sonar.organization>plugily-projects</sonar.organization>
|
||||
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>citizens-repo</id>
|
||||
<url>http://repo.citizensnpcs.co/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>papi-repo</id>
|
||||
<url>http://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>plugily-repo</id>
|
||||
<url>https://maven.plugily.xyz/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>mojang-repo</id>
|
||||
<url>https://libraries.minecraft.net/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>bstats-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>simonsators-repo</id>
|
||||
<url>http://simonsator.de/repo/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>placeholderapi</id>
|
||||
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>alessiodp-repo</id>
|
||||
<url>https://repo.alessiodp.com/releases/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<!-- Paper API-->
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.checkerframework</groupId>
|
||||
<artifactId>checker-qual</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.tigerhix.lib</groupId>
|
||||
<artifactId>scoreboard</artifactId>
|
||||
<version>1.0.9</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plugily.projects</groupId>
|
||||
<artifactId>commons-box-database</artifactId>
|
||||
<version>1.3.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plugily.projects</groupId>
|
||||
<artifactId>commons-box-minecraft</artifactId>
|
||||
<version>1.3.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plugily.projects</groupId>
|
||||
<artifactId>commons-box-classic</artifactId>
|
||||
<version>1.3.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>plugily.projects.inventoryframework</groupId>
|
||||
<artifactId>IF</artifactId>
|
||||
<version>0.10.0</version>
|
||||
<scope>compile</scope>
|
||||
<classifier>legacy-jar-with-dependencies</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.citizensnpcs</groupId>
|
||||
<artifactId>citizensapi</artifactId>
|
||||
<version>2.0.26-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>ch.ethz.globis.phtree</groupId>
|
||||
<artifactId>phtree</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.clip</groupId>
|
||||
<artifactId>placeholderapi</artifactId>
|
||||
<version>2.10.10</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<groupId>commons-io</groupId>
|
||||
<scope>compile</scope>
|
||||
<version>2.10.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mojang</groupId>
|
||||
<artifactId>authlib</artifactId>
|
||||
<version>1.5.21</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.google.code.findbugs</groupId>
|
||||
<artifactId>jsr305</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.alessiodp.parties</groupId>
|
||||
<artifactId>parties-api</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.checkerframework</groupId>
|
||||
<artifactId>checker-qual</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.google.errorprone</groupId>
|
||||
<artifactId>javac</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.simonsator</groupId>
|
||||
<artifactId>Party-and-Friends-MySQL-Edition-Spigot-API</artifactId>
|
||||
<version>1.3.2</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>be.maximvdw</groupId>
|
||||
<artifactId>MVdWPlaceholderAPI</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.simonsator</groupId>
|
||||
<artifactId>Spigot-Party-API-For-RedisBungee</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>redis.clients</groupId>
|
||||
<artifactId>jedis</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.simonsator</groupId>
|
||||
<artifactId>partyandfriends</artifactId>
|
||||
<version>1.0.52</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/PAFSpigot.jar</systemPath>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.jetbrains/annotations -->
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>21.0.1</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-site-plugin</artifactId>
|
||||
<version>3.9.1</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<windowtitle>Build Battle API docs for v${project.version}</windowtitle>
|
||||
<description>Minecraft building minigame.
|
||||
Build the best you can to win the game, play solo or in teams! API documentation for hooking Build Battle with your plugin.
|
||||
</description>
|
||||
<destDir>minecraft/buildbattle</destDir>
|
||||
<isOffline>false</isOffline>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadoc</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
<goal>javadoc</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>me.tigerhix.lib.scoreboard</pattern>
|
||||
<shadedPattern>plugily.projects.buildbattle.utils.scoreboard</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.apache.commons.io</pattern>
|
||||
<shadedPattern>plugily.projects.buildbattle.utils.commons.io</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>com.zaxxer.hikari</pattern>
|
||||
<shadedPattern>plugily.projects.buildbattle.database.hikari</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>plugily.projects.commonsbox</pattern>
|
||||
<shadedPattern>plugily.projects.buildbattle.commonsbox</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>plugily.projects.buildbattle.utils.bstats</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>plugily.projects.inventoryframework</pattern>
|
||||
<shadedPattern>plugily.projects.buildbattle.inventoryframework</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.0.0-M5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.jacoco</groupId>
|
||||
<artifactId>jacoco-maven-plugin</artifactId>
|
||||
<version>0.8.7</version>
|
||||
<configuration>
|
||||
<append>true</append>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>prepare-agent</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>post-unit-test</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>report</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<!-- External beta versions discord deployer plugin -->
|
||||
<plugin>
|
||||
<groupId>plugily.projects</groupId>
|
||||
<artifactId>betty-maven-plugin</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<configuration>
|
||||
<changelogFile>${project.basedir}/CHANGELOG.md</changelogFile>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- External beta versions discord deployer plugin -->
|
||||
</plugins>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ftp</artifactId>
|
||||
<version>3.4.3</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>plugily-projects-repo</id>
|
||||
<url>ftp://81.19.211.8</url>
|
||||
</repository>
|
||||
<site>
|
||||
<id>plugily-projects-java-docs</id>
|
||||
<name>thebridge</name>
|
||||
<url>ftp://81.19.211.8</url>
|
||||
</site>
|
||||
</distributionManagement>
|
||||
|
||||
</project>
|
||||
+2
-6
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,8 +18,4 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* All in-game player related events.
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.api.event.player;
|
||||
rootProject.name = "buildbattle"
|
||||
@@ -1,219 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import plugily.projects.commonsbox.minecraft.compat.xseries.XMaterial;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Created by Tom on 17/08/2015.
|
||||
*/
|
||||
public class ConfigPreferences {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
private final Map<String, List<String>> gameThemes = new HashMap<>();
|
||||
private final List<String> endGameCommands = new ArrayList<>(), whitelistedCommands = new ArrayList<>();
|
||||
private final List<Material> itemBlacklist = new ArrayList<>(), floorBlacklist = new ArrayList<>();
|
||||
private final Map<Option, Boolean> options = new EnumMap<>(Option.class);
|
||||
|
||||
public ConfigPreferences(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
loadOptions();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all options and loads them again
|
||||
*/
|
||||
public void loadOptions() {
|
||||
options.clear();
|
||||
gameThemes.clear();
|
||||
endGameCommands.clear();
|
||||
whitelistedCommands.clear();
|
||||
|
||||
for(Option option : Option.values()) {
|
||||
options.put(option, plugin.getConfig().getBoolean(option.getPath(), option.getDefault()));
|
||||
}
|
||||
endGameCommands.addAll(plugin.getConfig().getStringList("End-Game-Commands"));
|
||||
whitelistedCommands.addAll(plugin.getConfig().getStringList("Whitelisted-Commands"));
|
||||
loadThemes();
|
||||
loadBlackList();
|
||||
}
|
||||
|
||||
private void loadThemes() {
|
||||
gameThemes.put(BaseArena.ArenaType.SOLO.getPrefix(), plugin.getConfig().getStringList("Themes.Classic"));
|
||||
gameThemes.put(BaseArena.ArenaType.TEAM.getPrefix(), plugin.getConfig().getStringList("Themes.Teams"));
|
||||
gameThemes.put(BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix() + "_EASY", plugin.getConfig().getStringList("Themes.Guess-The-Build.Easy"));
|
||||
gameThemes.put(BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix() + "_MEDIUM", plugin.getConfig().getStringList("Themes.Guess-The-Build.Medium"));
|
||||
gameThemes.put(BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix() + "_HARD", plugin.getConfig().getStringList("Themes.Guess-The-Build.Hard"));
|
||||
Debugger.debug("Themes loaded: " + gameThemes);
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getGameThemes() {
|
||||
return gameThemes;
|
||||
}
|
||||
|
||||
public List<String> getThemes(String accessor) {
|
||||
return Collections.unmodifiableList(gameThemes.getOrDefault(accessor, new ArrayList<>()));
|
||||
}
|
||||
|
||||
public boolean isThemeBlacklisted(String theme) {
|
||||
for(String s : plugin.getConfig().getStringList("Blacklisted-Themes")) {
|
||||
if(s.equalsIgnoreCase(theme)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public List<String> getWinCommands(Position pos) {
|
||||
return plugin.getConfig().getStringList("Win-Commands." + pos.getName());
|
||||
}
|
||||
|
||||
public List<String> getEndGameCommands() {
|
||||
return Collections.unmodifiableList(endGameCommands);
|
||||
}
|
||||
|
||||
public List<Material> getItemBlacklist() {
|
||||
return Collections.unmodifiableList(itemBlacklist);
|
||||
}
|
||||
|
||||
public List<Material> getFloorBlacklist() {
|
||||
return Collections.unmodifiableList(floorBlacklist);
|
||||
}
|
||||
|
||||
private void loadBlackList() {
|
||||
for(String item : plugin.getConfig().getStringList("Blacklisted-Item-Names")) {
|
||||
Optional<XMaterial> opt = XMaterial.matchXMaterial(item.toUpperCase());
|
||||
if(!opt.isPresent()) {
|
||||
Debugger.sendConsoleMsg("&c[Build Battle] Invalid black listed item! " + item + " doesn't exist, are you sure it's properly named?");
|
||||
continue;
|
||||
}
|
||||
|
||||
itemBlacklist.add(opt.get().parseMaterial());
|
||||
}
|
||||
|
||||
for(String item : plugin.getConfig().getStringList("Blacklisted-Floor-Materials")) {
|
||||
Optional<XMaterial> opt = XMaterial.matchXMaterial(item.toUpperCase());
|
||||
if(!opt.isPresent()) {
|
||||
Debugger.sendConsoleMsg("&c[Build Battle] Invalid black listed item! " + item + " doesn't exist, are you sure it's properly named?");
|
||||
continue;
|
||||
}
|
||||
|
||||
floorBlacklist.add(opt.get().parseMaterial());
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getWhitelistedCommands() {
|
||||
return Collections.unmodifiableList(whitelistedCommands);
|
||||
}
|
||||
|
||||
public int getTimer(TimerType type, BaseArena arena) {
|
||||
String prefix = "Time-Manager." + arena.getArenaType().getPrefix() + ".";
|
||||
switch(type) {
|
||||
case BUILD:
|
||||
return plugin.getConfig().getInt(prefix + "Build-Time", 200);
|
||||
case LOBBY:
|
||||
return plugin.getConfig().getInt(prefix + "Lobby-Starting-Time", 60);
|
||||
case PLOT_VOTE:
|
||||
return plugin.getConfig().getInt(prefix + "Voting-Time-In-Seconds", 20);
|
||||
case THEME_VOTE:
|
||||
return plugin.getConfig().getInt(prefix + "Theme-Voting-Time-In-Seconds", 25);
|
||||
case DELAYED_TASK:
|
||||
return plugin.getConfig().getInt(prefix + "Delay-Between-Rounds-In-Seconds", 5);
|
||||
case TIME_SHORTENER:
|
||||
return plugin.getConfig().getInt(prefix + "Time-Shortener-In-Seconds", 10);
|
||||
case THEME_SELECTION:
|
||||
return plugin.getConfig().getInt(prefix + "Theme-Selection-Time-In-Seconds", 15);
|
||||
case ALL_GUESSED:
|
||||
return plugin.getConfig().getInt(prefix + "All-Guessed-In-Seconds", 5);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether option value is true or false
|
||||
*
|
||||
* @param option option to get value from
|
||||
* @return true or false based on user plugin.getConfig()uration
|
||||
*/
|
||||
public boolean getOption(Option option) {
|
||||
return options.get(option);
|
||||
}
|
||||
|
||||
public enum TimerType {
|
||||
BUILD, LOBBY, PLOT_VOTE, THEME_VOTE, DELAYED_TASK, TIME_SHORTENER, THEME_SELECTION, ALL_GUESSED
|
||||
}
|
||||
|
||||
public enum Option {
|
||||
BOSSBAR_ENABLED("Boss-Bar-Enabled", true), BUNGEE_ENABLED("BungeeActivated", false), DATABASE_ENABLED("DatabaseActivated", false),
|
||||
INVENTORY_MANAGER_ENABLED("InventoryManager", true), BLOCK_COMMANDS_IN_GAME("Block-Commands-In-Game", true), REWARDS("Rewards-Enabled", false),
|
||||
HEADS_COMMAND("Command-Instead-Of-Head-Menu.Enabled", false), ENABLE_SHORT_COMMANDS("Enable-Short-Commands", false),
|
||||
DISABLE_SEPARATE_CHAT("Disable-Separate-Chat", false), DISABLE_PARTIES("Disable-Parties", true), ANNOUNCE_PLOTOWNER_LATER("Announce-PlotOwner-Later", false),
|
||||
RUN_COMMAND_ON_REPORT("Run-Command-On-Report.Enabled", false), DISABLE_SPECTATORS("Disable-Spectators", false);
|
||||
|
||||
private final String path;
|
||||
private final boolean def;
|
||||
|
||||
Option(String path, boolean def) {
|
||||
this.path = path;
|
||||
this.def = def;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return default value of option if absent in plugin.getConfig()
|
||||
*/
|
||||
public boolean getDefault() {
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Position {
|
||||
FIRST("First"), SECOND("Second"), THIRD("Third");
|
||||
|
||||
private final String name;
|
||||
|
||||
Position(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,314 +20,131 @@
|
||||
|
||||
package plugily.projects.buildbattle;
|
||||
|
||||
import me.tigerhix.lib.scoreboard.ScoreboardLib;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import plugily.projects.buildbattle.api.StatsStorage;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import plugily.projects.buildbattle.arena.ArenaEvents;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.PlotMenuHandler;
|
||||
import plugily.projects.buildbattle.arena.vote.VoteEvents;
|
||||
import plugily.projects.buildbattle.arena.vote.VoteItems;
|
||||
import plugily.projects.buildbattle.boot.AdditionalValueInitializer;
|
||||
import plugily.projects.buildbattle.boot.MessageInitializer;
|
||||
import plugily.projects.buildbattle.boot.PlaceholderInitializer;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.events.ChatEvents;
|
||||
import plugily.projects.buildbattle.events.GameEvents;
|
||||
import plugily.projects.buildbattle.events.JoinEvents;
|
||||
import plugily.projects.buildbattle.events.LobbyEvents;
|
||||
import plugily.projects.buildbattle.events.QuitEvents;
|
||||
import plugily.projects.buildbattle.events.spectator.SpectatorEvents;
|
||||
import plugily.projects.buildbattle.events.spectator.SpectatorItemEvents;
|
||||
import plugily.projects.buildbattle.handlers.BungeeManager;
|
||||
import plugily.projects.buildbattle.handlers.ChatManager;
|
||||
import plugily.projects.buildbattle.handlers.HolidayManager;
|
||||
import plugily.projects.buildbattle.handlers.PermissionManager;
|
||||
import plugily.projects.buildbattle.handlers.PlaceholderManager;
|
||||
import plugily.projects.buildbattle.handlers.items.SpecialItemsManager;
|
||||
import plugily.projects.buildbattle.handlers.language.LanguageManager;
|
||||
import plugily.projects.buildbattle.handlers.party.PartyHandler;
|
||||
import plugily.projects.buildbattle.handlers.party.PartySupportInitializer;
|
||||
import plugily.projects.buildbattle.handlers.reward.RewardsFactory;
|
||||
import plugily.projects.buildbattle.handlers.setup.SetupInventoryEvents;
|
||||
import plugily.projects.buildbattle.handlers.sign.SignManager;
|
||||
import plugily.projects.buildbattle.menus.options.OptionsMenuHandler;
|
||||
import plugily.projects.buildbattle.menus.options.OptionsRegistry;
|
||||
import plugily.projects.buildbattle.menus.options.registry.banner.BannerMenu;
|
||||
import plugily.projects.buildbattle.menus.themevoter.VoteMenuListener;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
import plugily.projects.buildbattle.user.UserManager;
|
||||
import plugily.projects.buildbattle.user.data.MysqlManager;
|
||||
import plugily.projects.buildbattle.utils.CuboidSelector;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
import plugily.projects.buildbattle.utils.ExceptionLogHandler;
|
||||
import plugily.projects.buildbattle.utils.LegacyDataFixer;
|
||||
import plugily.projects.buildbattle.utils.MessageUtils;
|
||||
import plugily.projects.buildbattle.utils.UpdateChecker;
|
||||
import plugily.projects.buildbattle.utils.services.ServiceRegistry;
|
||||
import plugily.projects.commonsbox.database.MysqlDatabase;
|
||||
import plugily.projects.commonsbox.minecraft.compat.ServerVersion;
|
||||
import plugily.projects.commonsbox.minecraft.compat.events.EventsInitializer;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.commonsbox.minecraft.misc.MiscUtils;
|
||||
import plugily.projects.commonsbox.minecraft.serialization.InventorySerializer;
|
||||
|
||||
import java.util.Arrays;
|
||||
import plugily.projects.buildbattle.handlers.menu.OptionsRegistry;
|
||||
import plugily.projects.buildbattle.handlers.misc.BlacklistManager;
|
||||
import plugily.projects.buildbattle.handlers.setup.SetupCategoryManager;
|
||||
import plugily.projects.buildbattle.handlers.themes.ThemeManager;
|
||||
import plugily.projects.minigamesbox.classic.PluginMain;
|
||||
import plugily.projects.minigamesbox.classic.handlers.setup.SetupInventory;
|
||||
import plugily.projects.minigamesbox.classic.handlers.setup.categories.PluginSetupCategoryManager;
|
||||
import plugily.projects.minigamesbox.classic.utils.services.metrics.Metrics;
|
||||
|
||||
/**
|
||||
* Created by Tom on 17/08/2015.
|
||||
* Updated by Tigerpanzer_02 on 03.12.2021
|
||||
*/
|
||||
//todo setup handler recode
|
||||
//todo arenas handler recode
|
||||
//todo inventoryframework
|
||||
public class Main extends JavaPlugin {
|
||||
public class Main extends PluginMain {
|
||||
|
||||
private ArgumentsRegistry registry;
|
||||
private ExceptionLogHandler exceptionLogHandler;
|
||||
private ChatManager chatManager;
|
||||
private ConfigPreferences configPreferences;
|
||||
private MysqlDatabase database;
|
||||
private UserManager userManager;
|
||||
private BungeeManager bungeeManager;
|
||||
private SignManager signManager;
|
||||
private CuboidSelector cuboidSelector;
|
||||
private VoteItems voteItems;
|
||||
private ThemeManager themeManager;
|
||||
private BlacklistManager blacklistManager;
|
||||
private OptionsRegistry optionsRegistry;
|
||||
private SpecialItemsManager specialItemsManager;
|
||||
private boolean forceDisable = false;
|
||||
private PartyHandler partyHandler;
|
||||
private RewardsFactory rewardsHandler;
|
||||
private ArenaRegistry arenaRegistry;
|
||||
private ArenaManager arenaManager;
|
||||
private ArgumentsRegistry argumentsRegistry;
|
||||
private PlotMenuHandler plotMenuHandler;
|
||||
|
||||
public CuboidSelector getCuboidSelector() {
|
||||
return cuboidSelector;
|
||||
|
||||
@TestOnly
|
||||
public Main() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
long start = System.currentTimeMillis();
|
||||
MessageInitializer messageInitializer = new MessageInitializer(this);
|
||||
super.onEnable();
|
||||
getDebugger().debug("[System] [Plugin] Initialization start");
|
||||
arenaRegistry = new ArenaRegistry(this);
|
||||
new PlaceholderInitializer(this);
|
||||
messageInitializer.registerMessages();
|
||||
new AdditionalValueInitializer(this);
|
||||
initializePluginClasses();
|
||||
getDebugger().debug("Full {0} plugin enabled", getName());
|
||||
getDebugger().debug("[System] [Plugin] Initialization finished took {0}ms", System.currentTimeMillis() - start);
|
||||
}
|
||||
|
||||
public void initializePluginClasses() {
|
||||
addFileName("themes");
|
||||
addFileName("vote_items");
|
||||
blacklistManager = new BlacklistManager(this);
|
||||
themeManager = new ThemeManager(this);
|
||||
BaseArena.init(this);
|
||||
new ArenaEvents(this);
|
||||
arenaManager = new ArenaManager(this);
|
||||
arenaRegistry.registerArenas();
|
||||
getSignManager().loadSigns();
|
||||
getSignManager().updateSigns();
|
||||
argumentsRegistry = new ArgumentsRegistry(this);
|
||||
voteItems = new VoteItems(this);
|
||||
new VoteEvents(this);
|
||||
plotMenuHandler = new PlotMenuHandler(this);
|
||||
optionsRegistry = new OptionsRegistry(this);
|
||||
optionsRegistry.registerOptions();
|
||||
addPluginMetrics();
|
||||
}
|
||||
|
||||
private void addPluginMetrics() {
|
||||
getMetrics().addCustomChart(new Metrics.SimplePie("hooked_addons", () -> {
|
||||
if(getServer().getPluginManager().getPlugin("BuildBattle-Extras") != null) {
|
||||
return "Extras";
|
||||
}
|
||||
return "None";
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
public VoteItems getVoteItems() {
|
||||
return voteItems;
|
||||
}
|
||||
|
||||
public ThemeManager getThemeManager() {
|
||||
return themeManager;
|
||||
}
|
||||
|
||||
public BlacklistManager getBlacklistManager() {
|
||||
return blacklistManager;
|
||||
}
|
||||
|
||||
public OptionsRegistry getOptionsRegistry() {
|
||||
return optionsRegistry;
|
||||
}
|
||||
|
||||
public BungeeManager getBungeeManager() {
|
||||
return bungeeManager;
|
||||
}
|
||||
|
||||
public SignManager getSignManager() {
|
||||
return signManager;
|
||||
}
|
||||
|
||||
public ConfigPreferences getConfigPreferences() {
|
||||
return configPreferences;
|
||||
}
|
||||
|
||||
public SpecialItemsManager getSpecialItemsManager() {
|
||||
return specialItemsManager;
|
||||
}
|
||||
|
||||
public ArgumentsRegistry getArgumentsRegistry() {
|
||||
return registry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if(!validateIfPluginShouldStart()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ServiceRegistry.registerService(this);
|
||||
exceptionLogHandler = new ExceptionLogHandler(this);
|
||||
Debugger.setEnabled(getDescription().getVersion().contains("debug") || getConfig().getBoolean("Debug"));
|
||||
Debugger.debug("Main setup started");
|
||||
saveDefaultConfig();
|
||||
for(String s : Arrays.asList("arenas", "particles", "special_items", "stats", "voteItems", "mysql", "biomes", "bungee", "rewards")) {
|
||||
ConfigUtils.getConfig(this, s);
|
||||
}
|
||||
LanguageManager.init(this);
|
||||
chatManager = new ChatManager(this);
|
||||
configPreferences = new ConfigPreferences(this);
|
||||
new LegacyDataFixer(this);
|
||||
initializeClasses();
|
||||
}
|
||||
|
||||
private void checkUpdate() {
|
||||
if(!getConfig().getBoolean("Update-Notifier.Enabled", true)) {
|
||||
return;
|
||||
}
|
||||
UpdateChecker.init(this, 44703).requestUpdateCheck().whenComplete((result, exception) -> {
|
||||
if(!result.requiresUpdate()) {
|
||||
return;
|
||||
}
|
||||
if(result.getNewestVersion().contains("b")) {
|
||||
if(getConfig().getBoolean("Update-Notifier.Notify-Beta-Versions", true)) {
|
||||
Debugger.sendConsoleMsg("&c[Build Battle] Your software is ready for update! However it's a BETA VERSION. Proceed with caution.");
|
||||
Debugger.sendConsoleMsg("&c[Build Battle] Current version %old%, latest version %new%".replace("%old%", getDescription().getVersion()).replace("%new%",
|
||||
result.getNewestVersion()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
MessageUtils.updateIsHere();
|
||||
Debugger.sendConsoleMsg("&aYour Build Battle plugin is outdated! Download it to keep with latest changes and fixes.");
|
||||
Debugger.sendConsoleMsg("&aDisable this option in config.yml if you wish.");
|
||||
Debugger.sendConsoleMsg("&eCurrent version: &c" + getDescription().getVersion() + " &eLatest version: &a" + result.getNewestVersion());
|
||||
});
|
||||
}
|
||||
|
||||
private boolean validateIfPluginShouldStart() {
|
||||
try {
|
||||
Class.forName("org.spigotmc.SpigotConfig");
|
||||
} catch(Exception e) {
|
||||
MessageUtils.thisVersionIsNotSupported();
|
||||
Debugger.sendConsoleMsg("&cYour server software is not supported by Build Battle!");
|
||||
Debugger.sendConsoleMsg("&cWe support only Spigot and Spigot forks only! Shutting off...");
|
||||
forceDisable = true;
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return false;
|
||||
}
|
||||
if(ServerVersion.Version.isCurrentLower(ServerVersion.Version.v1_8_R1)) {
|
||||
MessageUtils.thisVersionIsNotSupported();
|
||||
Debugger.sendConsoleMsg("&cYour server version is not supported by Build Battle!");
|
||||
Debugger.sendConsoleMsg("&cSadly, we must shut off. Maybe you consider updating your server version?");
|
||||
forceDisable = true;
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//order matters
|
||||
private void initializeClasses() {
|
||||
ScoreboardLib.setPluginInstance(this);
|
||||
if(getConfig().getBoolean("BungeeActivated")) {
|
||||
bungeeManager = new BungeeManager(this);
|
||||
}
|
||||
if(configPreferences.getOption(ConfigPreferences.Option.DATABASE_ENABLED)) {
|
||||
FileConfiguration config = ConfigUtils.getConfig(this, "mysql");
|
||||
database = new MysqlDatabase(config.getString("user"), config.getString("password"), config.getString("address"), config.getLong("maxLifeTime", 1800000));
|
||||
}
|
||||
registry = new ArgumentsRegistry(this);
|
||||
userManager = new UserManager(this);
|
||||
PermissionManager.init();
|
||||
new SetupInventoryEvents(this);
|
||||
signManager = new SignManager(this);
|
||||
ArenaRegistry.registerArenas();
|
||||
signManager.loadSigns();
|
||||
signManager.updateSigns();
|
||||
specialItemsManager = new SpecialItemsManager(this);
|
||||
voteItems = new VoteItems();
|
||||
new VoteEvents(this);
|
||||
new LobbyEvents(this);
|
||||
new ChatEvents(this);
|
||||
optionsRegistry = new OptionsRegistry(this);
|
||||
new OptionsMenuHandler(this);
|
||||
Metrics metrics = new Metrics(this, 2491);
|
||||
metrics.addCustomChart(new org.bstats.charts.SimplePie("bungeecord_hooked", () -> String.valueOf(configPreferences.getOption(ConfigPreferences.Option.BUNGEE_ENABLED))));
|
||||
metrics.addCustomChart(new org.bstats.charts.SimplePie("locale_used", LanguageManager.getPluginLocale()::getPrefix));
|
||||
metrics.addCustomChart(new org.bstats.charts.SimplePie("update_notifier", () -> {
|
||||
if(getConfig().getBoolean("Update-Notifier.Enabled", true)) {
|
||||
return getConfig().getBoolean("Update-Notifier.Notify-Beta-Versions", true) ? "Enabled with beta notifier" : "Enabled";
|
||||
}
|
||||
return getConfig().getBoolean("Update-Notifier.Notify-Beta-Versions", true) ? "Beta notifier only" : "Disabled";
|
||||
}));
|
||||
new JoinEvents(this);
|
||||
new QuitEvents(this);
|
||||
if(getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
new PlaceholderManager().register();
|
||||
}
|
||||
cuboidSelector = new CuboidSelector(this);
|
||||
UpdateChecker.init(this, 44703);
|
||||
checkUpdate();
|
||||
new GameEvents(this);
|
||||
new VoteMenuListener(this);
|
||||
new HolidayManager(this);
|
||||
new SpectatorEvents(this);
|
||||
new SpectatorItemEvents(this);
|
||||
BannerMenu.init(this);
|
||||
partyHandler = new PartySupportInitializer().initialize(this);
|
||||
rewardsHandler = new RewardsFactory(this);
|
||||
plotMenuHandler = new PlotMenuHandler(this);
|
||||
new EventsInitializer().initialize(this);
|
||||
MiscUtils.sendStartUpMessage(this, "BuildBattle", getDescription(), true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if(forceDisable) return;
|
||||
|
||||
Debugger.debug("System disabling...");
|
||||
Bukkit.getLogger().removeHandler(exceptionLogHandler);
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
for(Player player : arena.getPlayers()) {
|
||||
arena.getScoreboardManager().stopAllScoreboards();
|
||||
arena.doBarAction(BaseArena.BarAction.REMOVE, player);
|
||||
arena.teleportToEndLocation(player);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.getActivePotionEffects().forEach(pe -> player.removePotionEffect(pe.getType()));
|
||||
if(configPreferences.getOption(ConfigPreferences.Option.INVENTORY_MANAGER_ENABLED)) {
|
||||
InventorySerializer.loadInventory(this, player);
|
||||
}
|
||||
}
|
||||
arena.getPlotManager().getPlots().forEach(Plot::fullyResetPlot);
|
||||
}
|
||||
for(Player player : getServer().getOnlinePlayers()) {
|
||||
User user = userManager.getUser(player);
|
||||
if(userManager.getDatabase() instanceof MysqlManager) {
|
||||
StringBuilder update = new StringBuilder(" SET ");
|
||||
for(StatsStorage.StatisticType stat : StatsStorage.StatisticType.values()) {
|
||||
if(!stat.isPersistent()) continue;
|
||||
|
||||
int userStat = user.getStat(stat);
|
||||
|
||||
if(update.toString().equalsIgnoreCase(" SET ")) {
|
||||
update.append(stat.getName()).append('=').append(userStat);
|
||||
}
|
||||
|
||||
update.append(", ").append(stat.getName()).append('=').append(userStat);
|
||||
}
|
||||
|
||||
MysqlManager db = (MysqlManager) userManager.getDatabase();
|
||||
//copy of userManager#saveStatistic but without async database call that's not allowed in onDisable method.
|
||||
db.getDatabase().executeUpdate("UPDATE " + db.getTableName()
|
||||
+ update.toString() + " WHERE UUID='" + user.getUniqueId().toString() + "';");
|
||||
continue;
|
||||
}
|
||||
for(StatsStorage.StatisticType stat : StatsStorage.StatisticType.values()) {
|
||||
userManager.getDatabase().saveStatistic(user, stat);
|
||||
}
|
||||
}
|
||||
if(configPreferences.getOption(ConfigPreferences.Option.DATABASE_ENABLED)) {
|
||||
getMysqlDatabase().shutdownConnPool();
|
||||
}
|
||||
}
|
||||
|
||||
public ChatManager getChatManager() {
|
||||
return chatManager;
|
||||
}
|
||||
|
||||
public MysqlDatabase getMysqlDatabase() {
|
||||
return database;
|
||||
}
|
||||
|
||||
public UserManager getUserManager() {
|
||||
return userManager;
|
||||
}
|
||||
|
||||
public PartyHandler getPartyHandler() {
|
||||
return partyHandler;
|
||||
}
|
||||
|
||||
public RewardsFactory getRewardsHandler() {
|
||||
return rewardsHandler;
|
||||
}
|
||||
|
||||
public PlotMenuHandler getPlotMenuHandler() {
|
||||
return plotMenuHandler;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ArenaRegistry getArenaRegistry() {
|
||||
return arenaRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArenaManager getArenaManager() {
|
||||
return arenaManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArgumentsRegistry getArgumentsRegistry() {
|
||||
return argumentsRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PluginSetupCategoryManager getSetupCategoryManager(SetupInventory setupInventory) {
|
||||
return new SetupCategoryManager(setupInventory);
|
||||
}
|
||||
}
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.api;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.commonsbox.sorter.SortUtils;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.user.data.MysqlManager;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
import plugily.projects.buildbattle.utils.MessageUtils;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Plajer, TomTheDeveloper
|
||||
* @since 2.0.0
|
||||
* <p>
|
||||
* Class for accessing users statistics.
|
||||
*/
|
||||
public class StatsStorage {
|
||||
|
||||
private static final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
/**
|
||||
* Get all UUID's sorted ascending by Statistic Type
|
||||
*
|
||||
* @param stat Statistic type to get (kills, deaths etc.)
|
||||
* @return Map of UUID keys and Integer values sorted in ascending order of requested statistic type
|
||||
*/
|
||||
public static Map<UUID, Integer> getStats(StatisticType stat) {
|
||||
if(plugin.getConfigPreferences().getOption(ConfigPreferences.Option.DATABASE_ENABLED)) {
|
||||
try(Connection connection = plugin.getMysqlDatabase().getConnection();
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet set = statement.executeQuery("SELECT UUID, " + stat.getName() + " FROM " + ((MysqlManager) plugin.getUserManager().getDatabase()).getTableName() + " ORDER BY " + stat.getName())) {
|
||||
Map<UUID, Integer> column = new LinkedHashMap<>();
|
||||
while(set.next()) {
|
||||
column.put(UUID.fromString(set.getString("UUID")), set.getInt(stat.getName()));
|
||||
}
|
||||
return column;
|
||||
} catch(SQLException e) {
|
||||
e.printStackTrace();
|
||||
MessageUtils.errorOccurred();
|
||||
Debugger.sendConsoleMsg("Cannot get contents from MySQL database!");
|
||||
Debugger.sendConsoleMsg("Check configuration of mysql.yml file or disable mysql option in config.yml");
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
FileConfiguration config = ConfigUtils.getConfig(plugin, "stats");
|
||||
Map<UUID, Integer> stats = new TreeMap<>();
|
||||
for(String string : config.getKeys(false)) {
|
||||
if("data-version".equals(string)) {
|
||||
continue;
|
||||
}
|
||||
stats.put(UUID.fromString(string), config.getInt(string + "." + stat.getName()));
|
||||
}
|
||||
return SortUtils.sortByValue(stats);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user statistic based on StatisticType
|
||||
*
|
||||
* @param player Online player to get data from
|
||||
* @param statisticType Statistic type to get (blocks placed, wins etc.)
|
||||
* @return int of statistic
|
||||
* @see StatisticType
|
||||
*/
|
||||
public static int getUserStats(Player player, StatisticType statisticType) {
|
||||
return plugin.getUserManager().getUser(player).getStat(statisticType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Available statistics to get.
|
||||
*/
|
||||
//todo separate stats for different arena modes!
|
||||
public enum StatisticType {
|
||||
BLOCKS_PLACED("blocksplaced", true), BLOCKS_BROKEN("blocksbroken", true), GAMES_PLAYED("gamesplayed", true), WINS("wins", true),
|
||||
LOSES("loses", true), HIGHEST_WIN("highestwin", true), HIGHEST_POINTS("higestpoints", true), TOTAL_POINTS_EARNED("totalpointsearned", true), PARTICLES_USED("particles", true), SUPER_VOTES("supervotes", true),
|
||||
LOCAL_POINTS("points", false), LOCAL_GUESS_THE_BUILD_POINTS("gtb_points", false), REPORTS("reports", false);
|
||||
|
||||
private final String name;
|
||||
private final boolean persistent;
|
||||
|
||||
StatisticType(String name, boolean persistent) {
|
||||
this.name = name;
|
||||
this.persistent = persistent;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public boolean isPersistent() {
|
||||
return persistent;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.api.event;
|
||||
|
||||
import org.bukkit.event.Event;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
|
||||
/**
|
||||
* Represents BuildBattle game related events.
|
||||
*/
|
||||
public abstract class BBEvent extends Event {
|
||||
|
||||
protected BaseArena arena;
|
||||
|
||||
public BBEvent(BaseArena eventArena) {
|
||||
arena = eventArena;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns event arena
|
||||
* Returns null when called from BBPlayerStatisticChangeEvent when super votes are added via command
|
||||
* To get more information about arena you can check instanceof SoloArena, TeamArena and GuessTheBuildArena
|
||||
* and then cast it.
|
||||
*
|
||||
* @return event arena
|
||||
*/
|
||||
public BaseArena getArena() {
|
||||
return arena;
|
||||
}
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.api.event.game;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import plugily.projects.buildbattle.api.event.BBEvent;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
|
||||
/**
|
||||
* Called when arena states changes
|
||||
*/
|
||||
public class BBGameChangeStateEvent extends BBEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final ArenaState gameState;
|
||||
private final ArenaState previous;
|
||||
|
||||
public BBGameChangeStateEvent(ArenaState gameState, BaseArena arena, ArenaState previous) {
|
||||
super(arena);
|
||||
this.gameState = gameState;
|
||||
this.previous = previous;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public ArenaState getState() {
|
||||
return gameState;
|
||||
}
|
||||
|
||||
public ArenaState getPreviousState() {
|
||||
return previous;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.api.event.game;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import plugily.projects.buildbattle.api.event.BBEvent;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
|
||||
/**
|
||||
* Called when game is ended
|
||||
*/
|
||||
public class BBGameEndEvent extends BBEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public BBGameEndEvent(BaseArena arena) {
|
||||
super(arena);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.api.event.game;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import plugily.projects.buildbattle.api.event.BBEvent;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
|
||||
/**
|
||||
* Called when player joins arena
|
||||
*/
|
||||
public class BBGameJoinEvent extends BBEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final Player player;
|
||||
|
||||
public BBGameJoinEvent(Player player, BaseArena arena) {
|
||||
super(arena);
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get player associated with this event
|
||||
*
|
||||
* @return player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.api.event.game;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import plugily.projects.buildbattle.api.event.BBEvent;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
|
||||
/**
|
||||
* Called when game is started
|
||||
*/
|
||||
public class BBGameStartEvent extends BBEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public BBGameStartEvent(BaseArena arena) {
|
||||
super(arena);
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
+20
-21
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,41 +18,40 @@
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.api.event.game;
|
||||
package plugily.projects.buildbattle.api.event.guess;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import plugily.projects.buildbattle.api.event.BBEvent;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.GuessArena;
|
||||
import plugily.projects.buildbattle.handlers.themes.BBTheme;
|
||||
import plugily.projects.minigamesbox.api.events.PlugilyEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Called when player leaves arena
|
||||
* @author Tigerpanzer_02
|
||||
* @since 5.0.0
|
||||
* <p>
|
||||
* Called when player guess the theme right
|
||||
*/
|
||||
public class BBGameLeaveEvent extends BBEvent {
|
||||
public class PlayerThemeGuessEvent extends PlugilyEvent {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Player player;
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final BBTheme theme;
|
||||
|
||||
public BBGameLeaveEvent(Player player, BaseArena arena) {
|
||||
super(arena);
|
||||
this.player = player;
|
||||
public PlayerThemeGuessEvent(GuessArena eventArena, BBTheme theme) {
|
||||
super(eventArena);
|
||||
this.theme = theme;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get player associated with this event
|
||||
*
|
||||
* @return player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
public BBTheme getTheme() {
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
-72
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.api.event.player;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import plugily.projects.buildbattle.api.StatsStorage;
|
||||
import plugily.projects.buildbattle.api.event.BBEvent;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* @see StatsStorage.StatisticType
|
||||
* @since 3.4.1
|
||||
* <p>
|
||||
* Called when player receive new statistic.
|
||||
*/
|
||||
public class BBPlayerStatisticChangeEvent extends BBEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Player player;
|
||||
private final StatsStorage.StatisticType statisticType;
|
||||
private final int number;
|
||||
|
||||
public BBPlayerStatisticChangeEvent(@Nullable BaseArena eventArena, Player player, StatsStorage.StatisticType statisticType, int number) {
|
||||
super(eventArena);
|
||||
this.player = player;
|
||||
this.statisticType = statisticType;
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return HANDLERS;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public StatsStorage.StatisticType getStatisticType() {
|
||||
return statisticType;
|
||||
}
|
||||
|
||||
public int getNumber() {
|
||||
return number;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,19 +23,19 @@ package plugily.projects.buildbattle.api.event.plot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import plugily.projects.buildbattle.api.event.BBEvent;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.minigamesbox.api.events.PlugilyEvent;
|
||||
|
||||
public class BBPlayerChoosePlotEvent extends BBEvent implements Cancellable {
|
||||
public class PlotPlayerChooseEvent extends PlugilyEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final Player player;
|
||||
private final Plot plot;
|
||||
private boolean isCancelled;
|
||||
|
||||
public BBPlayerChoosePlotEvent(Player player, Plot plot, BaseArena arena) {
|
||||
super(arena);
|
||||
public PlotPlayerChooseEvent(Player player, Plot plot, BaseArena baseArena) {
|
||||
super(baseArena);
|
||||
this.player = player;
|
||||
this.plot = plot;
|
||||
this.isCancelled = false;
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,9 +21,9 @@
|
||||
package plugily.projects.buildbattle.api.event.plot;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import plugily.projects.buildbattle.api.event.BBEvent;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.minigamesbox.api.events.PlugilyEvent;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
@@ -31,12 +31,12 @@ import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
* <p>
|
||||
* Called when player receive plot in game after the game starts
|
||||
*/
|
||||
public class BBPlayerPlotReceiveEvent extends BBEvent {
|
||||
public class PlotPlayerReceiveEvent extends PlugilyEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Plot plot;
|
||||
|
||||
public BBPlayerPlotReceiveEvent(BaseArena eventArena, Plot plot) {
|
||||
public PlotPlayerReceiveEvent(BaseArena eventArena, Plot plot) {
|
||||
super(eventArena);
|
||||
this.plot = plot;
|
||||
}
|
||||
+4
-5
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -18,8 +18,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* All arena in-game related events.
|
||||
*/
|
||||
package plugily.projects.buildbattle.api.event.plot;
|
||||
|
||||
package plugily.projects.buildbattle.api.event.game;
|
||||
public class PlotReportEvent {
|
||||
}
|
||||
+5
-5
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,9 +21,9 @@
|
||||
package plugily.projects.buildbattle.api.event.plot;
|
||||
|
||||
import org.bukkit.event.HandlerList;
|
||||
import plugily.projects.buildbattle.api.event.BBEvent;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.minigamesbox.api.events.PlugilyEvent;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
@@ -31,12 +31,12 @@ import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
* <p>
|
||||
* Called when plot is being reset
|
||||
*/
|
||||
public class BBPlotResetEvent extends BBEvent {
|
||||
public class PlotResetEvent extends PlugilyEvent {
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
private final Plot plot;
|
||||
|
||||
public BBPlotResetEvent(BaseArena eventArena, Plot plot) {
|
||||
public PlotResetEvent(BaseArena eventArena, Plot plot) {
|
||||
super(eventArena);
|
||||
this.plot = plot;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -0,0 +1,604 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.vehicle.VehicleMoveEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.minigamesbox.api.arena.IArenaState;
|
||||
import plugily.projects.minigamesbox.api.arena.IPluginArena;
|
||||
import plugily.projects.minigamesbox.classic.arena.PluginArenaEvents;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.ServerVersion;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.VersionUtils;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.events.api.PlugilyPlayerInteractEntityEvent;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.events.api.PlugilyPlayerInteractEvent;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.events.api.PlugilyPlayerPickupArrow;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.xseries.XMaterial;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>Created at 13.03.2018
|
||||
*/
|
||||
public class ArenaEvents extends PluginArenaEvents {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public ArenaEvents(Main plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBreak(BlockBreakEvent event) {
|
||||
BaseArena arena = plugin.getArenaRegistry().getArena(event.getPlayer());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
if(arena.getArenaState() != IArenaState.IN_GAME || (arena instanceof BuildArena && arena.getArenaInGameState() == BaseArena.ArenaInGameState.PLOT_VOTING)
|
||||
|| plugin.getBlacklistManager().getItemList().contains(event.getBlock().getType())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Plot buildPlot = arena.getPlotManager().getPlot(event.getPlayer());
|
||||
|
||||
if(buildPlot != null && buildPlot.getCuboid() != null && buildPlot.getCuboid().isIn(event.getBlock().getLocation())) {
|
||||
plugin.getUserManager().getUser(event.getPlayer()).adjustStatistic("BLOCKS_BROKEN", 1);
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlace(BlockPlaceEvent event) {
|
||||
BaseArena arena = plugin.getArenaRegistry().getArena(event.getPlayer());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
if(arena.getArenaState() != IArenaState.IN_GAME || plugin.getBlacklistManager().getItemList().contains(event.getBlock().getType())
|
||||
|| (arena instanceof BuildArena && arena.getArenaInGameState() == BaseArena.ArenaInGameState.PLOT_VOTING)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(arena instanceof GuessArena && !((GuessArena) arena).getCurrentBuilders().contains(event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
Plot buildPlot = arena.getPlotManager().getPlot(event.getPlayer());
|
||||
|
||||
if(buildPlot != null && buildPlot.getCuboid() != null && buildPlot.getCuboid().isIn(event.getBlock().getLocation())) {
|
||||
plugin.getUserManager().getUser(event.getPlayer()).adjustStatistic("BLOCKS_PLACED", 1);
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemFrameRotate(PlayerInteractEntityEvent event) {
|
||||
if(event.getRightClicked().getType() == EntityType.ITEM_FRAME && ((ItemFrame) event.getRightClicked()).getItem().getType() != Material.AIR) {
|
||||
Location entityLocation = event.getRightClicked().getLocation();
|
||||
|
||||
for(IPluginArena arena : plugin.getArenaRegistry().getArenas()) {
|
||||
if(!(arena instanceof BaseArena)) {
|
||||
continue;
|
||||
}
|
||||
for(Plot buildPlot : ((BaseArena) arena).getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && !buildPlot.getCuboid().isInWithMarge(entityLocation, -1) && buildPlot.getCuboid().isIn(entityLocation)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onNPCClick(PlugilyPlayerInteractEntityEvent event) {
|
||||
if(VersionUtils.checkOffHand(event.getHand()) || event.getRightClicked().getType() != EntityType.VILLAGER) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack hand = VersionUtils.getItemInHand(event.getPlayer());
|
||||
|
||||
if(hand.getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
BaseArena arena = plugin.getArenaRegistry().getArena(event.getPlayer());
|
||||
|
||||
if(arena == null || arena.getArenaState() != IArenaState.IN_GAME) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(arena instanceof BuildArena && arena.getArenaInGameState() == BaseArena.ArenaInGameState.PLOT_VOTING) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(plugin.getUserManager().getUser(event.getPlayer()).isSpectator()) {
|
||||
return;
|
||||
}
|
||||
|
||||
String customName = event.getRightClicked().getCustomName();
|
||||
|
||||
if(customName == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Citizens includes 1 more color before name so we removes all
|
||||
customName = ChatColor.stripColor(customName);
|
||||
|
||||
if(!customName.equalsIgnoreCase(ChatColor.stripColor(new MessageBuilder("IN_GAME_MESSAGES_PLOT_NPC_NAME").asKey().build()))) {
|
||||
return;
|
||||
}
|
||||
|
||||
Material material = hand.getType();
|
||||
|
||||
if(material != XMaterial.WATER_BUCKET.parseMaterial() && material != XMaterial.LAVA_BUCKET.parseMaterial()
|
||||
&& !(material.isBlock() && material.isSolid() && material.isOccluding())) {
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_PERMISSION_FLOOR_ITEM").asKey().player(event.getPlayer()).sendPlayer();
|
||||
return;
|
||||
}
|
||||
|
||||
if(plugin.getBlacklistManager().getFloorList().contains(material)) {
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_PERMISSION_FLOOR_ITEM").asKey().player(event.getPlayer()).sendPlayer();
|
||||
return;
|
||||
}
|
||||
|
||||
Plot playerPlot = arena.getPlotManager().getPlot(event.getPlayer());
|
||||
|
||||
if(playerPlot != null) {
|
||||
|
||||
// Prevent "Legacy material support initialisation"
|
||||
playerPlot.changeFloor(material, ServerVersion.Version.isCurrentEqualOrLower(ServerVersion.Version.v1_12_R1) ? hand.getData().getData() : 0);
|
||||
new MessageBuilder("MENU_OPTION_CONTENT_FLOOR_CHANGED").asKey().player(event.getPlayer()).sendPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEnderchestClick(PlugilyPlayerInteractEvent event) {
|
||||
if(event.getClickedBlock() == null)
|
||||
return;
|
||||
|
||||
BaseArena arena = plugin.getArenaRegistry().getArena(event.getPlayer());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(arena.getArenaState() != IArenaState.IN_GAME || event.getClickedBlock().getType() == XMaterial.ENDER_CHEST.parseMaterial()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMinecartMove(VehicleMoveEvent event) {
|
||||
Vehicle vehicle = event.getVehicle();
|
||||
if(vehicle.getType() != EntityType.MINECART) {
|
||||
return;
|
||||
}
|
||||
for(IPluginArena arena : plugin.getArenaRegistry().getArenas()) {
|
||||
if(!(arena instanceof BaseArena)) {
|
||||
continue;
|
||||
}
|
||||
for(Plot buildPlot : ((BaseArena) arena).getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && !buildPlot.getCuboid().isInWithMarge(event.getTo(), -1) && buildPlot.getCuboid().isIn(event.getTo())) {
|
||||
((Minecart) vehicle).setMaxSpeed(0);
|
||||
vehicle.setVelocity(vehicle.getVelocity().zero());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onIgniteEvent(BlockIgniteEvent event) {
|
||||
Location blockLocation = event.getBlock().getLocation();
|
||||
|
||||
for(IPluginArena arena : plugin.getArenaRegistry().getArenas()) {
|
||||
if(!(arena instanceof BaseArena)) {
|
||||
continue;
|
||||
}
|
||||
for(Plot buildPlot : ((BaseArena) arena).getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && buildPlot.getCuboid().isInWithMarge(blockLocation, 5)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonRetractEvent(BlockPistonRetractEvent event) {
|
||||
Location blockLocation = event.getBlock().getLocation();
|
||||
|
||||
for(IPluginArena arena : plugin.getArenaRegistry().getArenas()) {
|
||||
if(!(arena instanceof BaseArena)) {
|
||||
continue;
|
||||
}
|
||||
for(Plot buildPlot : ((BaseArena) arena).getPlotManager().getPlots()) {
|
||||
for(Block block : event.getBlocks()) {
|
||||
if(buildPlot.getCuboid() != null && !buildPlot.getCuboid().isInWithMarge(block.getLocation(), -1) && buildPlot.getCuboid().isIn(blockLocation)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeavesDecay(LeavesDecayEvent event) {
|
||||
Location blockLocation = event.getBlock().getLocation();
|
||||
|
||||
for(IPluginArena arena : plugin.getArenaRegistry().getArenas()) {
|
||||
if(!(arena instanceof BaseArena)) {
|
||||
continue;
|
||||
}
|
||||
for(Plot buildPlot : ((BaseArena) arena).getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && buildPlot.getCuboid().isInWithMarge(blockLocation, 5)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||
BaseArena arena = plugin.getArenaRegistry().getArena(event.getPlayer());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Plot buildPlot = arena.getPlotManager().getPlot(event.getPlayer());
|
||||
|
||||
if(buildPlot != null && buildPlot.getCuboid() != null && !buildPlot.getCuboid().isIn(event.getBlockClicked().getRelative(event.getBlockFace()).getLocation())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
if(event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
|
||||
return;
|
||||
}
|
||||
|
||||
int maxMobPerPlot = plugin.getConfig().getInt("Mob.Max-Amount", 20);
|
||||
Location entityLoc = event.getEntity().getLocation();
|
||||
|
||||
for(IPluginArena arena : plugin.getArenaRegistry().getArenas()) {
|
||||
if(!(arena instanceof BaseArena)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BaseArena baseArena = (BaseArena) arena;
|
||||
|
||||
if(baseArena.getPlotManager().getPlots().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Plot first = baseArena.getPlotManager().getPlots().get(0);
|
||||
if(first == null || (first.getCuboid() != null && !entityLoc.getWorld().equals(first.getCuboid().getCenter().getWorld()))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(event.getEntity().getType() == EntityType.WITHER || !plugin.getConfigPreferences().getOption("MOB_SPAWN")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
for(Plot plot : baseArena.getPlotManager().getPlots()) {
|
||||
if(plot.getCuboid() != null && plot.getCuboid().isInWithMarge(entityLoc, 1)) {
|
||||
if(plot.getEntities() >= maxMobPerPlot) {
|
||||
plot.getMembers().forEach(player -> new MessageBuilder("IN_GAME_MESSAGES_PLOT_LIMIT_ENTITIES").asKey().arena(arena).player(player).sendPlayer());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
for(String entityNames : plugin.getConfig().getStringList("Mob.Restricted")) {
|
||||
if(event.getEntity().getType().name().equalsIgnoreCase(entityNames)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
plot.addEntity();
|
||||
event.setCancelled(false);
|
||||
|
||||
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1)) {
|
||||
event.getEntity().setAI(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockSpread(BlockSpreadEvent event) {
|
||||
if(event.getSource().getType() != Material.FIRE)
|
||||
return;
|
||||
|
||||
for(IPluginArena arena : plugin.getArenaRegistry().getArenas()) {
|
||||
if(!(arena instanceof BaseArena)) {
|
||||
continue;
|
||||
}
|
||||
BaseArena base = (BaseArena) arena;
|
||||
if(!base.getPlotManager().getPlots().isEmpty()) {
|
||||
Plot plot = base.getPlotManager().getPlots().get(0);
|
||||
|
||||
if(plot != null && plot.getCuboid() != null
|
||||
&& event.getBlock().getWorld().equals(plot.getCuboid().getCenter().getWorld())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDispense(BlockDispenseEvent event) {
|
||||
Location blockLoc = event.getBlock().getLocation();
|
||||
|
||||
for(IPluginArena arena : plugin.getArenaRegistry().getArenas()) {
|
||||
if(!(arena instanceof BaseArena)) {
|
||||
continue;
|
||||
}
|
||||
for(Plot buildPlot : ((BaseArena) arena).getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && !buildPlot.getCuboid().isInWithMarge(blockLoc, -1) && buildPlot.getCuboid().isInWithMarge(blockLoc, 5)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTreeGrow(StructureGrowEvent event) {
|
||||
BaseArena arena = plugin.getArenaRegistry().getArena(event.getPlayer());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
Plot buildPlot = arena.getPlotManager().getPlot(event.getPlayer());
|
||||
if(buildPlot == null || buildPlot.getCuboid() == null) {
|
||||
return;
|
||||
}
|
||||
for(BlockState blockState : event.getBlocks()) {
|
||||
if(!buildPlot.getCuboid().isIn(blockState.getLocation())) {
|
||||
blockState.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamageEntity(EntityDamageByEntityEvent event) {
|
||||
if(event.getEntity().getType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = plugin.getArenaRegistry().getArena((Player) event.getEntity());
|
||||
if(arena == null || arena.getArenaState() != IArenaState.IN_GAME) {
|
||||
return;
|
||||
}
|
||||
if(event.getEntity().getType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDamage(EntityDamageEvent event) {
|
||||
if(event.getEntity().getType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = plugin.getArenaRegistry().getArena((Player) event.getEntity());
|
||||
if(arena == null || arena.getArenaState() != IArenaState.IN_GAME) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
Player player = (Player) event.getEntity();
|
||||
if(player.getLocation().getY() < 1) {
|
||||
Plot plot = arena.getPlotManager().getPlot(player);
|
||||
if(plot != null) {
|
||||
VersionUtils.teleport(player, plot.getTeleportLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTNTInteract(PlugilyPlayerInteractEvent event) {
|
||||
if(event.getClickedBlock() == null || VersionUtils.checkOffHand(event.getHand())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!plugin.getArenaRegistry().isInArena(event.getPlayer()) || VersionUtils.getItemInHand(event.getPlayer()).getType() != Material.FLINT_AND_STEEL) {
|
||||
return;
|
||||
}
|
||||
if(event.getClickedBlock().getType() == Material.TNT) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTNTExplode(EntityExplodeEvent event) {
|
||||
Location entityLocation = event.getEntity().getLocation();
|
||||
|
||||
for(IPluginArena arena : plugin.getArenaRegistry().getArenas()) {
|
||||
if(!(arena instanceof BaseArena)) {
|
||||
continue;
|
||||
}
|
||||
for(Plot buildPlot : ((BaseArena) arena).getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && buildPlot.getCuboid().isInWithMarge(entityLocation, 5)) {
|
||||
event.blockList().clear();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWaterFlowEvent(BlockFromToEvent event) {
|
||||
Location toBlock = event.getToBlock().getLocation();
|
||||
Location blockLoc = event.getBlock().getLocation();
|
||||
|
||||
for(IPluginArena arena : plugin.getArenaRegistry().getArenas()) {
|
||||
if(!(arena instanceof BaseArena)) {
|
||||
continue;
|
||||
}
|
||||
for(Plot buildPlot : ((BaseArena) arena).getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null) {
|
||||
if(!buildPlot.getCuboid().isIn(toBlock) && buildPlot.getCuboid().isIn(blockLoc)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if(!buildPlot.getCuboid().isInWithMarge(toBlock, -1) && buildPlot.getCuboid().isIn(toBlock)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFoodChange(FoodLevelChangeEvent event) {
|
||||
if(event.getEntity().getType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getEntity();
|
||||
if(!plugin.getArenaRegistry().isInArena(player)) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
player.setFoodLevel(20);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPistonExtendEvent(BlockPistonExtendEvent event) {
|
||||
Location blockLoc = event.getBlock().getLocation();
|
||||
for(IPluginArena arena : plugin.getArenaRegistry().getArenas()) {
|
||||
if(!(arena instanceof BaseArena)) {
|
||||
continue;
|
||||
}
|
||||
for(Plot buildPlot : ((BaseArena) arena).getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && buildPlot.getCuboid().isIn(blockLoc)) {
|
||||
for(Block block : event.getBlocks()) {
|
||||
if(!buildPlot.getCuboid().isInWithMarge(block.getLocation(), -1)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onArrowPickup(PlugilyPlayerPickupArrow event) {
|
||||
if(plugin.getArenaRegistry().isInArena(event.getPlayer())) {
|
||||
event.getItem().remove();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
Player player = (Player) event.getPlayer();
|
||||
BaseArena baseArena = plugin.getArenaRegistry().getArena(player);
|
||||
if(baseArena != null && baseArena.getArenaInGameState() == BaseArena.ArenaInGameState.BUILD_TIME) {
|
||||
baseArena.addMenuItem(player);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemMove(InventoryClickEvent event) {
|
||||
HumanEntity humanEntity = event.getWhoClicked();
|
||||
|
||||
if(humanEntity instanceof Player) {
|
||||
BaseArena baseArena = plugin.getArenaRegistry().getArena((Player) humanEntity);
|
||||
|
||||
if(baseArena != null && baseArena.getArenaState() != IArenaState.IN_GAME) {
|
||||
if(event.getClickedInventory() == humanEntity.getInventory()) {
|
||||
if(event.getView().getType() == InventoryType.CRAFTING
|
||||
|| event.getView().getType() == InventoryType.PLAYER) {
|
||||
event.setResult(Event.Result.DENY);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onGTBGuessChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
BaseArena arena = plugin.getArenaRegistry().getArena(player);
|
||||
if(!(arena instanceof GuessArena)) {
|
||||
return;
|
||||
}
|
||||
if(arena.getArenaState() != IArenaState.IN_GAME) {
|
||||
return;
|
||||
}
|
||||
if(arena.getSpectators().contains(player)) {
|
||||
return;
|
||||
}
|
||||
GuessArena gameArena = (GuessArena) arena;
|
||||
if(gameArena.getWhoGuessed().contains(player)) {
|
||||
event.setCancelled(true);
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_CANT_TALK").asKey().arena(gameArena).player(player).sendPlayer();
|
||||
return;
|
||||
}
|
||||
if(gameArena.getCurrentBuilders().contains(player)) {
|
||||
event.setCancelled(true);
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_BUILDER").asKey().arena(gameArena).player(player).sendPlayer();
|
||||
return;
|
||||
}
|
||||
if(gameArena.getCurrentBBTheme() == null || !gameArena.getCurrentBBTheme().getTheme().equalsIgnoreCase(event.getMessage())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
gameArena.broadcastPlayerGuessed(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
if(!plugin.getArenaRegistry().isInArena(event.getPlayer())) {
|
||||
return;
|
||||
}
|
||||
ItemStack drop = event.getItemDrop().getItemStack();
|
||||
if(plugin.getVoteItems().getPoints(drop) != 0) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,388 +20,87 @@
|
||||
|
||||
package plugily.projects.buildbattle.arena;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.api.StatsStorage;
|
||||
import plugily.projects.buildbattle.api.event.game.BBGameEndEvent;
|
||||
import plugily.projects.buildbattle.api.event.game.BBGameJoinEvent;
|
||||
import plugily.projects.buildbattle.api.event.game.BBGameLeaveEvent;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.impl.GuessTheBuildArena;
|
||||
import plugily.projects.buildbattle.arena.impl.SoloArena;
|
||||
import plugily.projects.buildbattle.arena.impl.TeamArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.handlers.ChatManager;
|
||||
import plugily.projects.buildbattle.handlers.PermissionManager;
|
||||
import plugily.projects.buildbattle.handlers.items.SpecialItem;
|
||||
import plugily.projects.buildbattle.handlers.party.GameParty;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
import plugily.projects.commonsbox.minecraft.compat.VersionUtils;
|
||||
import plugily.projects.commonsbox.minecraft.misc.MiscUtils;
|
||||
import plugily.projects.commonsbox.minecraft.misc.stuff.ComplementAccessor;
|
||||
import plugily.projects.commonsbox.minecraft.serialization.InventorySerializer;
|
||||
import plugily.projects.minigamesbox.api.arena.IArenaState;
|
||||
import plugily.projects.minigamesbox.api.arena.IPluginArena;
|
||||
import plugily.projects.minigamesbox.api.user.IUser;
|
||||
import plugily.projects.minigamesbox.classic.arena.PluginArena;
|
||||
import plugily.projects.minigamesbox.classic.arena.PluginArenaManager;
|
||||
import plugily.projects.minigamesbox.classic.user.User;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 25.05.2018
|
||||
* <p>Created at 13.05.2018
|
||||
*/
|
||||
public class ArenaManager {
|
||||
public class ArenaManager extends PluginArenaManager {
|
||||
|
||||
private static final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
private final Main plugin;
|
||||
|
||||
private ArenaManager() {
|
||||
public ArenaManager(Main plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts player to join arena.
|
||||
* Calls BBGameJoinEvent.
|
||||
* Can be cancelled only via above-mentioned event
|
||||
*
|
||||
* @param player player to join
|
||||
* @param arena arena to join
|
||||
* @see BBGameJoinEvent
|
||||
*/
|
||||
public static void joinAttempt(Player player, BaseArena arena) {
|
||||
Debugger.debug("Initial join attempt, " + player.getName());
|
||||
BBGameJoinEvent bbGameJoinEvent = new BBGameJoinEvent(player, arena);
|
||||
Bukkit.getPluginManager().callEvent(bbGameJoinEvent);
|
||||
|
||||
ChatManager chatManager = plugin.getChatManager();
|
||||
|
||||
if(!arena.isReady()) {
|
||||
player.sendMessage(chatManager.getPrefix() + chatManager.colorMessage("In-Game.Arena-Not-Configured"));
|
||||
return;
|
||||
}
|
||||
if(bbGameJoinEvent.isCancelled()) {
|
||||
player.sendMessage(chatManager.getPrefix() + chatManager.colorMessage("In-Game.Join-Cancelled-Via-API"));
|
||||
return;
|
||||
}
|
||||
if(ArenaRegistry.getArena(player) != null) {
|
||||
player.sendMessage(chatManager.getPrefix() + chatManager.colorMessage("In-Game.Messages.Already-Playing"));
|
||||
return;
|
||||
}
|
||||
Plot partyPlot = null;
|
||||
//check if player is in party and send party members to the game
|
||||
if(plugin.getPartyHandler().isPlayerInParty(player)) {
|
||||
Debugger.debug("[Party] Initialized party check " + player.getName());
|
||||
GameParty party = plugin.getPartyHandler().getParty(player);
|
||||
if(party.getLeader() == player) {
|
||||
if(arena.getMaximumPlayers() - arena.getPlayers().size() >= party.getPlayers().size()) {
|
||||
partyPlot = arena.getPlotManager().getPlots().get(ThreadLocalRandom.current().nextInt(arena.getPlotManager().getPlots().size()));
|
||||
for(Player partyPlayer : party.getPlayers()) {
|
||||
if(partyPlayer == player) {
|
||||
continue;
|
||||
}
|
||||
BaseArena partyPlayerArena = ArenaRegistry.getArena(partyPlayer);
|
||||
if(partyPlayerArena != null) {
|
||||
if(partyPlayerArena.getArenaState() == ArenaState.IN_GAME) {
|
||||
continue;
|
||||
}
|
||||
Debugger.debug("[Party] Remove party member " + partyPlayer.getName() + " from other not ingame arena " + player.getName());
|
||||
leaveAttempt(partyPlayer, partyPlayerArena);
|
||||
}
|
||||
partyPlayer.sendMessage(chatManager.getPrefix() + chatManager.formatMessage(arena, chatManager.colorMessage("In-Game.Join-As-Party-Member"), partyPlayer));
|
||||
joinAttempt(partyPlayer, arena);
|
||||
Debugger.debug("[Party] Added party member " + partyPlayer.getName() + " to arena of " + player.getName());
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(chatManager.getPrefix() + chatManager.formatMessage(arena, chatManager.colorMessage("In-Game.Messages.Lobby-Messages.Not-Enough-Space-For-Party"), player));
|
||||
Debugger.debug("[Party] Not enough space for party of " + player.getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
Player partyLeader = party.getLeader();
|
||||
if(arena.getPlayers().contains(partyLeader)) {
|
||||
Plot partyLeaderPlot = arena.getPlotManager().getPlot(partyLeader);
|
||||
if(partyLeaderPlot != null) {
|
||||
partyPlot = partyLeaderPlot;
|
||||
}
|
||||
}
|
||||
Debugger.debug("[Party] Party check done for " + player.getName());
|
||||
}
|
||||
//Arena join permission when bungee false
|
||||
if(!plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED) &&
|
||||
(!(player.hasPermission(PermissionManager.getJoinPerm().replace("<arena>", "*"))
|
||||
|| player.hasPermission(PermissionManager.getJoinPerm().replace("<arena>", arena.getID()))))) {
|
||||
player.sendMessage(chatManager.getPrefix() + chatManager.colorMessage("In-Game.Join-No-Permission")
|
||||
.replace("%permission%", PermissionManager.getJoinPerm().replace("<arena>", arena.getID())));
|
||||
@Override
|
||||
public void additionalPartyJoin(Player player, IPluginArena arena, Player partyLeader) {
|
||||
BaseArena pluginArena = plugin.getArenaRegistry().getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if((arena.getArenaState() == ArenaState.IN_GAME || arena.getArenaState() == ArenaState.ENDING)
|
||||
&& plugin.getConfigPreferences().getOption(ConfigPreferences.Option.DISABLE_SPECTATORS)) {
|
||||
return;
|
||||
}
|
||||
List<Plot> plots = pluginArena.getPlotManager().getPlots();
|
||||
Plot partyPlot = plots.get(plots.size() == 1 ? 0 : plugin.getRandom().nextInt(plots.size()));
|
||||
|
||||
if(arena.getArenaState() == ArenaState.RESTARTING) {
|
||||
if(plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
ComplementAccessor.getComplement().kickPlayer(player, chatManager.getPrefix() + chatManager.colorMessage("Commands.Arena-Restarting"));
|
||||
} else {
|
||||
player.sendMessage(chatManager.getPrefix() + chatManager.colorMessage("Commands.Arena-Restarting"));
|
||||
if(arena.getPlayers().contains(partyLeader)) {
|
||||
Plot partyLeaderPlot = pluginArena.getPlotManager().getPlot(partyLeader);
|
||||
if(partyLeaderPlot != null) {
|
||||
partyPlot = partyLeaderPlot;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(arena.getArenaState() == ArenaState.STARTING && arena.getPlayers().size() >= arena.getMaximumPlayers()) {
|
||||
if(!player.hasPermission(PermissionManager.getJoinFullGames())) {
|
||||
player.sendMessage(chatManager.getPrefix() + chatManager.colorMessage("In-Game.Full-Game-No-Permission"));
|
||||
return;
|
||||
}
|
||||
boolean foundSlot = false;
|
||||
for(Player loopPlayer : arena.getPlayers()) {
|
||||
if(loopPlayer.hasPermission(PermissionManager.getJoinFullGames())) {
|
||||
continue;
|
||||
}
|
||||
leaveAttempt(loopPlayer, arena);
|
||||
loopPlayer.sendMessage(chatManager.getPrefix() + chatManager.colorMessage("In-Game.Messages.Lobby-Messages.You-Were-Kicked-For-Premium-Slot"));
|
||||
chatManager.broadcast(arena, chatManager.formatMessage(arena, chatManager.colorMessage("In-Game.Messages.Lobby-Messages.Kicked-For-Premium-Slot"), loopPlayer));
|
||||
foundSlot = true;
|
||||
break;
|
||||
}
|
||||
if(!foundSlot) {
|
||||
player.sendMessage(chatManager.getPrefix() + chatManager.colorMessage("In-Game.No-Slots-For-Premium"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Debugger.debug("Final join attempt, " + player.getName());
|
||||
User user = plugin.getUserManager().getUser(player);
|
||||
user.lastBoard = player.getScoreboard();
|
||||
//reset scoreboard
|
||||
player.setScoreboard(Bukkit.getScoreboardManager().getNewScoreboard());
|
||||
|
||||
arena.getScoreboardManager().createScoreboard(user);
|
||||
if(plugin.getConfigPreferences().getOption(ConfigPreferences.Option.INVENTORY_MANAGER_ENABLED)) {
|
||||
InventorySerializer.saveInventoryToFile(plugin, player);
|
||||
}
|
||||
|
||||
player.setExp(1);
|
||||
player.setFoodLevel(20);
|
||||
player.setHealth(VersionUtils.getMaxHealth(player));
|
||||
player.setLevel(0);
|
||||
player.setWalkSpeed(0.2f);
|
||||
player.setFlySpeed(0.1f);
|
||||
|
||||
arena.doBarAction(BaseArena.BarAction.ADD, player);
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(new ItemStack[]{new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR)});
|
||||
|
||||
//Set player as spectator as the game is already started
|
||||
if(arena.getArenaState() == ArenaState.IN_GAME || arena.getArenaState() == ArenaState.ENDING) {
|
||||
arena.addSpectator(player);
|
||||
|
||||
player.teleport(arena.getPlotManager().getPlots().get(0).getTeleportLocation());
|
||||
player.sendMessage(chatManager.colorMessage("In-Game.Spectator.You-Are-Spectator"));
|
||||
player.getInventory().clear();
|
||||
|
||||
for(SpecialItem item : plugin.getSpecialItemsManager().getSpecialItems()) {
|
||||
if(item.getDisplayStage() != SpecialItem.DisplayStage.SPECTATOR) {
|
||||
continue;
|
||||
}
|
||||
player.getInventory().setItem(item.getSlot(), item.getItemStack());
|
||||
}
|
||||
|
||||
player.getActivePotionEffects().forEach(potionEffect -> player.removePotionEffect(potionEffect.getType()));
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0));
|
||||
|
||||
//Hide player from other players
|
||||
arena.getPlayers().forEach(onlinePlayer -> VersionUtils.hidePlayer(plugin, onlinePlayer, player));
|
||||
|
||||
user.setSpectator(true);
|
||||
|
||||
VersionUtils.setCollidable(player, false);
|
||||
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
|
||||
for(Player spectator : arena.getPlayers()) {
|
||||
if(plugin.getUserManager().getUser(spectator).isSpectator()) {
|
||||
VersionUtils.showPlayer(plugin, player, spectator);
|
||||
} else {
|
||||
VersionUtils.hidePlayer(plugin, spectator, player);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(partyPlot != null) {
|
||||
partyPlot.addMember(player, arena, false);
|
||||
partyPlot.addMember(player, pluginArena, false);
|
||||
}
|
||||
arena.addPlayer(player);
|
||||
|
||||
arena.teleportToLobby(player);
|
||||
if(arena.getArenaState() == ArenaState.STARTING || arena.getArenaState() == ArenaState.WAITING_FOR_PLAYERS) {
|
||||
for(SpecialItem item : plugin.getSpecialItemsManager().getSpecialItems()) {
|
||||
if(arena.getArenaType() == BaseArena.ArenaType.TEAM && item.getDisplayStage() == SpecialItem.DisplayStage.TEAM) {
|
||||
player.getInventory().setItem(item.getSlot(), item.getItemStack());
|
||||
continue;
|
||||
}
|
||||
if(item.getDisplayStage() != SpecialItem.DisplayStage.LOBBY) {
|
||||
continue;
|
||||
}
|
||||
player.getInventory().setItem(item.getSlot(), item.getItemStack());
|
||||
}
|
||||
}
|
||||
player.updateInventory();
|
||||
|
||||
chatManager.broadcastAction(arena, player, ChatManager.ActionType.JOIN);
|
||||
VersionUtils.sendTitles(player, chatManager.colorMessage("In-Game.Messages.Join-Title").replace("%ARENANAME%", arena.getMapName()),
|
||||
chatManager.colorMessage("In-Game.Messages.Join-SubTitle").replace("%ARENANAME%", arena.getMapName()), 5, 40, 5);
|
||||
plugin.getSignManager().updateSigns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts player to leave arena.
|
||||
* Calls BBGameLeaveEvent event.
|
||||
*
|
||||
* @param player player to leave
|
||||
* @param arena arena to leave
|
||||
* @see BBGameLeaveEvent
|
||||
*/
|
||||
public static void leaveAttempt(Player player, BaseArena arena) {
|
||||
Debugger.debug("Initial leave attempt, " + player.getName());
|
||||
Bukkit.getPluginManager().callEvent(new BBGameLeaveEvent(player, arena));
|
||||
|
||||
arena.teleportToEndLocation(player);
|
||||
|
||||
arena.doBarAction(BaseArena.BarAction.REMOVE, player);
|
||||
player.getActivePotionEffects().forEach(effect -> player.removePotionEffect(effect.getType()));
|
||||
VersionUtils.setMaxHealth(player, 20);
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.resetPlayerTime();
|
||||
player.resetPlayerWeather();
|
||||
player.setAllowFlight(false);
|
||||
player.setExp(0);
|
||||
player.setFireTicks(0);
|
||||
player.setFlying(false);
|
||||
player.setFoodLevel(20);
|
||||
player.setLevel(0);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setWalkSpeed(0.2f);
|
||||
|
||||
User user = plugin.getUserManager().getUser(player);
|
||||
user.removeScoreboard(arena);
|
||||
|
||||
if(plugin.getConfigPreferences().getOption(ConfigPreferences.Option.INVENTORY_MANAGER_ENABLED)) {
|
||||
InventorySerializer.loadInventory(plugin, player);
|
||||
}
|
||||
|
||||
for(Player onlinePlayer : plugin.getServer().getOnlinePlayers()) {
|
||||
if(ArenaRegistry.getArena(onlinePlayer) == null) {
|
||||
VersionUtils.showPlayer(plugin, onlinePlayer, player);
|
||||
}
|
||||
VersionUtils.showPlayer(plugin, player, onlinePlayer);
|
||||
}
|
||||
|
||||
// Spectator
|
||||
if(user.isSpectator() || arena.getSpectators().contains(player)) {
|
||||
arena.removeSpectator(player);
|
||||
user.setSpectator(false);
|
||||
@Override
|
||||
public void leaveAttempt(@NotNull Player player, @NotNull IPluginArena arena) {
|
||||
BaseArena pluginArena = plugin.getArenaRegistry().getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = arena.getPlotManager().getPlot(player);
|
||||
if(plot != null) {
|
||||
if(arena instanceof SoloArena) {
|
||||
if(plot.getMembers().size() <= 1) {
|
||||
((SoloArena) arena).getQueue().remove(plot);
|
||||
}
|
||||
super.leaveAttempt(player, arena);
|
||||
IUser user = plugin.getUserManager().getUser(player);
|
||||
user.setStatistic("LOCAL_POINTS", 0);
|
||||
user.setStatistic("LOCAL_POINTS_GTB", 0);
|
||||
Plot plot = pluginArena.getPlotManager().getPlot(player);
|
||||
if(plot == null) {
|
||||
return;
|
||||
}
|
||||
plot.getMembers().remove(player);
|
||||
if(arena instanceof BuildArena) {
|
||||
if(plot.getMembers().isEmpty()) {
|
||||
((BuildArena) arena).getQueue().remove(plot);
|
||||
}
|
||||
}
|
||||
|
||||
arena.removePlayer(player);
|
||||
plugin.getChatManager().broadcastAction(arena, player, ChatManager.ActionType.LEAVE);
|
||||
|
||||
// Games played +1
|
||||
if(arena.getArenaState() == ArenaState.IN_GAME || arena.getArenaState() == ArenaState.ENDING) {
|
||||
user.addStat(StatsStorage.StatisticType.GAMES_PLAYED, 1);
|
||||
}
|
||||
|
||||
user.setStat(StatsStorage.StatisticType.LOCAL_GUESS_THE_BUILD_POINTS, 0);
|
||||
|
||||
if(plot != null) {
|
||||
if(arena instanceof TeamArena) {
|
||||
plot.getMembers().remove(player);
|
||||
if(plot.getMembers().size() < 1) {
|
||||
plot.fullyResetPlot();
|
||||
}
|
||||
} else
|
||||
plot.fullyResetPlot();
|
||||
}
|
||||
if(arena instanceof GuessTheBuildArena) {
|
||||
((GuessTheBuildArena) arena).getWhoGuessed().remove(player);
|
||||
}
|
||||
|
||||
if(arena.getArenaState() != ArenaState.WAITING_FOR_PLAYERS && arena.getPlayers().isEmpty()) {
|
||||
arena.setArenaState(ArenaState.RESTARTING);
|
||||
arena.setTimer(0);
|
||||
}
|
||||
|
||||
plugin.getSignManager().updateSigns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Stops current arena. Calls BBGameEndEvent event
|
||||
*
|
||||
* @param quickStop should arena be stopped immediately? (use only in important cases)
|
||||
* @param arena arena to stop
|
||||
* @see BBGameEndEvent
|
||||
*/
|
||||
public static void stopGame(boolean quickStop, BaseArena arena) {
|
||||
Debugger.debug("Game stop event initiate, arena " + arena.getID());
|
||||
Bukkit.getPluginManager().callEvent(new BBGameEndEvent(arena));
|
||||
if(!quickStop) {
|
||||
for(Player player : arena.getPlayers()) {
|
||||
spawnFireworks(arena, player);
|
||||
for(SpecialItem item : plugin.getSpecialItemsManager().getSpecialItems()) {
|
||||
if(item.getDisplayStage() != SpecialItem.DisplayStage.SPECTATOR) {
|
||||
continue;
|
||||
if(arena instanceof GuessArena) {
|
||||
GuessArena guessArena = (GuessArena) pluginArena;
|
||||
((GuessArena) arena).getWhoGuessed().remove(player);
|
||||
if(guessArena.getCurrentBuilders().contains(player)) {
|
||||
if(plot.getMembers().isEmpty()) {
|
||||
if(arena.getArenaState() == IArenaState.IN_GAME) {
|
||||
//ToDo message force skipped
|
||||
pluginArena.setTimer(plugin.getConfig().getInt("Time-Manager." + pluginArena.getArenaType().getPrefix() + ".Round-Delay"), true);
|
||||
pluginArena.setArenaInGameState(BaseArena.ArenaInGameState.PLOT_VOTING);
|
||||
}
|
||||
player.getInventory().setItem(item.getSlot(), item.getItemStack());
|
||||
}
|
||||
User user = plugin.getUserManager().getUser(player);
|
||||
user.removeScoreboard(arena);
|
||||
}
|
||||
}
|
||||
arena.getScoreboardManager().stopAllScoreboards();
|
||||
arena.setArenaState(ArenaState.ENDING);
|
||||
arena.setTimer(10);
|
||||
if(arena instanceof SoloArena) {
|
||||
((SoloArena) arena).setVoting(false);
|
||||
}
|
||||
Debugger.debug("Game stop event finish, arena " + arena.getID());
|
||||
}
|
||||
|
||||
private static void spawnFireworks(BaseArena arena, Player player) {
|
||||
if(!plugin.getConfig().getBoolean("Firework-When-Game-Ends", true)) {
|
||||
return;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
int i = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(i == 4 || !arena.getPlayers().contains(player)) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
MiscUtils.spawnRandomFirework(player.getLocation());
|
||||
i++;
|
||||
}
|
||||
}.runTaskTimer(plugin, 30, 30);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,223 +21,165 @@
|
||||
package plugily.projects.buildbattle.arena;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.impl.GuessTheBuildArena;
|
||||
import plugily.projects.buildbattle.arena.impl.SoloArena;
|
||||
import plugily.projects.buildbattle.arena.impl.TeamArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
import plugily.projects.commonsbox.minecraft.compat.ServerVersion.Version;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.commonsbox.minecraft.dimensional.Cuboid;
|
||||
import plugily.projects.commonsbox.minecraft.serialization.LocationSerializer;
|
||||
import plugily.projects.minigamesbox.api.arena.IPluginArena;
|
||||
import plugily.projects.minigamesbox.classic.arena.PluginArena;
|
||||
import plugily.projects.minigamesbox.classic.arena.PluginArenaRegistry;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.configuration.ConfigUtils;
|
||||
import plugily.projects.minigamesbox.classic.utils.dimensional.Cuboid;
|
||||
import plugily.projects.minigamesbox.classic.utils.serialization.LocationSerializer;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.ServerVersion;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Created by Tom on 27/07/2014.
|
||||
*/
|
||||
public class ArenaRegistry {
|
||||
public class ArenaRegistry extends PluginArenaRegistry {
|
||||
|
||||
private static final List<BaseArena> ARENAS = new ArrayList<>();
|
||||
private static final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
private final Main plugin;
|
||||
|
||||
private static int bungeeArena = -999;
|
||||
|
||||
public static List<BaseArena> getArenas() {
|
||||
return ARENAS;
|
||||
public ArenaRegistry(Main plugin) {
|
||||
super(plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns arena where the player is
|
||||
*
|
||||
* @param p target player
|
||||
* @return Arena or null if not playing
|
||||
*/
|
||||
@Nullable
|
||||
public static BaseArena getArena(Player p) {
|
||||
if(p == null) {
|
||||
return null;
|
||||
|
||||
@Override
|
||||
public PluginArena getNewArena(String id) {
|
||||
switch(ConfigUtils.getConfig(plugin, "arenas").getString("instances." + id + ".gametype", "classic").toLowerCase(Locale.ENGLISH)) {
|
||||
case "gtb":
|
||||
case "guessthebuild":
|
||||
case "guess_the_build":
|
||||
return new GuessArena(id);
|
||||
case "classic":
|
||||
case "solo":
|
||||
case "team":
|
||||
default:
|
||||
return new BuildArena(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean additionalValidatorChecks(ConfigurationSection section, PluginArena arena, String id) {
|
||||
if(!super.additionalValidatorChecks(section, arena, id)) return false;
|
||||
|
||||
boolean isBuildArena = arena instanceof BuildArena;
|
||||
boolean isGuessArena = arena instanceof GuessArena;
|
||||
|
||||
if(isBuildArena) {
|
||||
int plotMemberSize = section.getInt(id + ".plotmembersize", 0);
|
||||
|
||||
// Member size can not be less than 1
|
||||
if(plotMemberSize < 1) {
|
||||
plugin.getDebugger().sendConsoleMsg(new MessageBuilder("VALIDATOR_INVALID_ARENA_CONFIGURATION").asKey().value("INVALID PLOT MEMBER SIZE!").arena(arena).build());
|
||||
return false;
|
||||
}
|
||||
|
||||
arena.setArenaOption("PLOT_MEMBER_SIZE", plotMemberSize);
|
||||
int minPlayers = arena.getArenaOption("MINIMUM_PLAYERS");
|
||||
if(minPlayers <= plotMemberSize) {
|
||||
arena.setArenaOption("MINIMUM_PLAYERS", plotMemberSize + 1);
|
||||
plugin.getDebugger().sendConsoleMsg(new MessageBuilder("VALIDATOR_INVALID_ARENA_CONFIGURATION").asKey().value("MIN PLAYERS NEEDS TO BE 1 MORE THAN PLOT_MEMBER_SIZE, AUTOMATICALLY ADJUSTED. CONFIRM BY CHECKING ARENA SETUP!").arena(arena).build());
|
||||
}
|
||||
|
||||
((BuildArena) arena).setTypeByPlotMembers();
|
||||
} else {
|
||||
//todo gtb team mode, because why not!
|
||||
arena.setArenaOption("PLOT_MEMBER_SIZE", 1);
|
||||
}
|
||||
|
||||
java.util.UUID playerId = p.getUniqueId();
|
||||
|
||||
for(BaseArena arena : ARENAS) {
|
||||
for(Player player : arena.getPlayers()) {
|
||||
if(playerId.equals(player.getUniqueId())) return arena;
|
||||
}
|
||||
for(Player player : arena.getSpectators()) {
|
||||
if(playerId.equals(player.getUniqueId())) return arena;
|
||||
}
|
||||
ConfigurationSection plotSection = section.getConfigurationSection(id + ".plots");
|
||||
if(plotSection == null) {
|
||||
plugin.getDebugger().sendConsoleMsg(new MessageBuilder("VALIDATOR_INVALID_ARENA_CONFIGURATION").asKey().value("PLOTS SETUP MISSING!").arena(arena).build());
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void registerArena(BaseArena arena) {
|
||||
Debugger.debug("Registering new game instance, " + arena.getID());
|
||||
ARENAS.add(arena);
|
||||
}
|
||||
BaseArena baseArena = (BaseArena) arena;
|
||||
|
||||
public static void unregisterArena(BaseArena arena) {
|
||||
Debugger.debug("Unegistering game instance, " + arena.getID());
|
||||
ARENAS.remove(arena);
|
||||
}
|
||||
for(String plotName : plotSection.getKeys(false)) {
|
||||
String minPointString = plotSection.getString(plotName + ".1", null);
|
||||
String maxPointString = plotSection.getString(plotName + ".2", null);
|
||||
|
||||
/**
|
||||
* Returns arena based by ID
|
||||
*
|
||||
* @param id name of arena
|
||||
* @return Arena or null if not found
|
||||
*/
|
||||
public static BaseArena getArena(String id) {
|
||||
for(BaseArena arena : ARENAS) {
|
||||
if(arena.getID().equalsIgnoreCase(id)) {
|
||||
return arena;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
if(minPointString != null && maxPointString != null) {
|
||||
Location minPoint = LocationSerializer.getLocation(minPointString);
|
||||
Location maxPoint = LocationSerializer.getLocation(maxPointString);
|
||||
|
||||
public static int getArenaPlayersOnline() {
|
||||
int players = 0;
|
||||
for(BaseArena arena : ARENAS) {
|
||||
players += arena.getPlayers().size();
|
||||
}
|
||||
return players;
|
||||
}
|
||||
if(minPoint != null && maxPoint != null) {
|
||||
World minWorld = minPoint.getWorld();
|
||||
|
||||
public static void registerArenas() {
|
||||
Debugger.debug("Initial arenas registration");
|
||||
ArenaRegistry.getArenas().clear();
|
||||
if(minWorld != null) {
|
||||
Biome biome = ServerVersion.Version.isCurrentHigher(ServerVersion.Version.v1_15_R1) ?
|
||||
minWorld.getBiome(minPoint.getBlockX(), minPoint.getBlockY(), minPoint.getBlockZ())
|
||||
: minWorld.getBiome(minPoint.getBlockX(), minPoint.getBlockZ());
|
||||
|
||||
ConfigurationSection section = ConfigUtils.getConfig(plugin, "arenas").getConfigurationSection("instances");
|
||||
if(section == null) {
|
||||
Debugger.debug(Debugger.Level.WARN, "No instances configuration section in arenas.yml, skipping registration process! Was it manually edited?");
|
||||
return;
|
||||
}
|
||||
for(String id : section.getKeys(false)) {
|
||||
if(id.equalsIgnoreCase("default")) {
|
||||
continue;
|
||||
}
|
||||
Plot buildPlot = new Plot(baseArena, biome);
|
||||
|
||||
BaseArena.ArenaType arenaType;
|
||||
try {
|
||||
arenaType = BaseArena.ArenaType.valueOf(section.getString(id + ".gametype", "solo").toUpperCase());
|
||||
} catch(IllegalArgumentException e) {
|
||||
arenaType = BaseArena.ArenaType.SOLO;
|
||||
}
|
||||
buildPlot.setCuboid(new Cuboid(minPoint, maxPoint));
|
||||
buildPlot.fullyResetPlot();
|
||||
|
||||
BaseArena arena;
|
||||
switch(arenaType) {
|
||||
case TEAM:
|
||||
arena = new TeamArena(id, plugin);
|
||||
break;
|
||||
case GUESS_THE_BUILD:
|
||||
arena = new GuessTheBuildArena(id, plugin);
|
||||
break;
|
||||
case SOLO:
|
||||
default:
|
||||
arena = new SoloArena(id, plugin);
|
||||
break;
|
||||
}
|
||||
|
||||
if(section.contains(id + ".minimumplayers")) {
|
||||
arena.setMinimumPlayers(section.getInt(id + ".minimumplayers"));
|
||||
} else {
|
||||
arena.setMinimumPlayers(section.getInt("instances.default.minimumplayers"));
|
||||
}
|
||||
if(section.contains(id + ".maximumplayers")) {
|
||||
arena.setMaximumPlayers(section.getInt(id + ".maximumplayers"));
|
||||
} else {
|
||||
arena.setMaximumPlayers(section.getInt("instances.default.maximumplayers"));
|
||||
}
|
||||
if(section.contains(id + ".mapname")) {
|
||||
arena.setMapName(section.getString(id + ".mapname"));
|
||||
} else {
|
||||
arena.setMapName(section.getString("instances.default.mapname"));
|
||||
}
|
||||
|
||||
Location lobbyLoc = LocationSerializer.getLocation(section.getString(id + ".lobbylocation"));
|
||||
if(lobbyLoc == null || lobbyLoc.getWorld() == null) {
|
||||
arena.setReady(false);
|
||||
continue;
|
||||
}
|
||||
|
||||
arena.setLobbyLocation(lobbyLoc);
|
||||
if(section.contains(id + ".Endlocation")) {
|
||||
arena.setEndLocation(LocationSerializer.getLocation(section.getString(id + ".Endlocation")));
|
||||
} else if(!plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
System.out.print(id + " doesn't contains an end location!");
|
||||
arena.setReady(false);
|
||||
ArenaRegistry.registerArena(arena);
|
||||
continue;
|
||||
}
|
||||
|
||||
arena.setArenaType(arenaType);
|
||||
arena.setPlotSize(section.getInt(id + ".plotSize", 2));
|
||||
|
||||
ConfigurationSection plotSection = section.getConfigurationSection(id + ".plots");
|
||||
|
||||
if(plotSection != null) {
|
||||
for(String plotName : plotSection.getKeys(false)) {
|
||||
String minPointString = plotSection.getString(plotName + ".minpoint");
|
||||
String maxPointString = plotSection.getString(plotName + ".maxpoint");
|
||||
|
||||
if(minPointString != null && maxPointString != null) {
|
||||
Location minPoint = LocationSerializer.getLocation(minPointString);
|
||||
|
||||
if(minPoint != null) {
|
||||
org.bukkit.World minWorld = minPoint.getWorld();
|
||||
|
||||
if(minWorld != null) {
|
||||
Biome biome = Version.isCurrentHigher(Version.v1_15_R1) ?
|
||||
minWorld.getBiome(minPoint.getBlockX(), minPoint.getBlockY(), minPoint.getBlockZ())
|
||||
: minWorld.getBiome(minPoint.getBlockX(), minPoint.getBlockZ());
|
||||
|
||||
Plot buildPlot = new Plot(arena, biome);
|
||||
|
||||
buildPlot.setCuboid(new Cuboid(minPoint, LocationSerializer.getLocation(maxPointString)));
|
||||
buildPlot.fullyResetPlot();
|
||||
|
||||
arena.getPlotManager().addBuildPlot(buildPlot);
|
||||
if(isGuessArena) {
|
||||
int plotMemberSize = arena.getArenaOption("PLOT_MEMBER_SIZE");
|
||||
int maxPlayers = arena.getMaximumPlayers();
|
||||
int plotAmount = maxPlayers / plotMemberSize;
|
||||
for(int i = 0; i < plotAmount; i++) {
|
||||
Plot copyBuildPlot = new Plot(baseArena, biome);
|
||||
copyBuildPlot.setCuboid(new Cuboid(minPoint, maxPoint));
|
||||
copyBuildPlot.fullyResetPlot();
|
||||
baseArena.getPlotManager().addBuildPlot(copyBuildPlot);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
baseArena.getPlotManager().addBuildPlot(buildPlot);
|
||||
}
|
||||
} else {
|
||||
System.out.println("Non configured plot instances found for arena " + id);
|
||||
arena.setReady(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("Non configured plots in arena " + id);
|
||||
arena.setReady(false);
|
||||
plugin.getDebugger().sendConsoleMsg(new MessageBuilder("VALIDATOR_INVALID_ARENA_CONFIGURATION").asKey().value("PLOT NOT CONFIGURED!").arena(arena).build());
|
||||
return false;
|
||||
}
|
||||
arena.setReady(section.getBoolean(id + ".isdone"));
|
||||
if(arena instanceof SoloArena) {
|
||||
((SoloArena) arena).initPoll();
|
||||
}
|
||||
ArenaRegistry.registerArena(arena);
|
||||
arena.start();
|
||||
}
|
||||
Debugger.debug("Arenas registration completed");
|
||||
if(isBuildArena) {
|
||||
((BuildArena) arena).initPoll();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void shuffleBungeeArena() {
|
||||
bungeeArena = new Random().nextInt(ARENAS.size());
|
||||
@Override
|
||||
public @Nullable BaseArena getArena(Player player) {
|
||||
IPluginArena pluginArena = super.getArena(player);
|
||||
if(pluginArena instanceof BaseArena) {
|
||||
return (BaseArena) pluginArena;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static int getBungeeArena() {
|
||||
if(bungeeArena == -999) {
|
||||
bungeeArena = new Random().nextInt(ARENAS.size());
|
||||
@Override
|
||||
public @Nullable BaseArena getArena(String id) {
|
||||
IPluginArena pluginArena = super.getArena(id);
|
||||
if(pluginArena instanceof BaseArena) {
|
||||
return (BaseArena) pluginArena;
|
||||
}
|
||||
return bungeeArena;
|
||||
return null;
|
||||
}
|
||||
|
||||
public @NotNull List<BaseArena> getPluginArenas() {
|
||||
List<BaseArena> baseArenas = new ArrayList<>(super.getArenas().size());
|
||||
for(IPluginArena pluginArena : super.getArenas()) {
|
||||
if(pluginArena instanceof BaseArena) {
|
||||
baseArenas.add((BaseArena) pluginArena);
|
||||
}
|
||||
}
|
||||
return baseArenas;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import plugily.projects.buildbattle.Main;
|
||||
|
||||
/**
|
||||
* @author TomTheDeveloper
|
||||
* <p>
|
||||
* Contains all GameStates.
|
||||
*/
|
||||
public enum ArenaState {
|
||||
WAITING_FOR_PLAYERS("Waiting"), STARTING("Starting"), IN_GAME("In-Game"), ENDING("Ending"), RESTARTING("Restarting");
|
||||
|
||||
private final String formattedName;
|
||||
private final String placeholder;
|
||||
|
||||
ArenaState(String formattedName) {
|
||||
this.formattedName = formattedName;
|
||||
this.placeholder = JavaPlugin.getPlugin(Main.class).getChatManager().colorMessage("Placeholders.Game-States." + formattedName);
|
||||
}
|
||||
|
||||
public String getFormattedName() {
|
||||
return formattedName;
|
||||
}
|
||||
|
||||
public String getPlaceholder() {
|
||||
return placeholder;
|
||||
}
|
||||
}
|
||||
@@ -1,68 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.impl.SoloArena;
|
||||
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
* <p>
|
||||
* Created at 18.06.2021
|
||||
*/
|
||||
public class ArenaUtils {
|
||||
|
||||
private static final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
public static void arenaForceStart(Player player, String theme) {
|
||||
if(!plugin.getArgumentsRegistry().hasPermission(player, "buildbattle.admin.forcestart")) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena(player);
|
||||
if(arena == null) {
|
||||
player.sendMessage(plugin.getChatManager().getPrefix() + plugin.getChatManager().colorMessage("Commands.No-Playing"));
|
||||
return;
|
||||
}
|
||||
|
||||
int minPlayers = arena.getMinimumPlayers();
|
||||
if(arena.getPlayers().size() < minPlayers) {
|
||||
plugin.getChatManager().broadcast(arena, plugin.getChatManager().colorMessage("In-Game.Messages.Lobby-Messages.Waiting-For-Players").replace("%MINPLAYERS%", Integer.toString(minPlayers)));
|
||||
return;
|
||||
}
|
||||
if(arena.getArenaState() == ArenaState.WAITING_FOR_PLAYERS || arena.getArenaState() == ArenaState.STARTING) {
|
||||
arena.setArenaState(ArenaState.STARTING);
|
||||
arena.setForceStart(true);
|
||||
arena.setTimer(0);
|
||||
if(!theme.isEmpty() && arena instanceof SoloArena) {
|
||||
((SoloArena) arena).setThemeVoteTime(false);
|
||||
arena.setTimer(plugin.getConfigPreferences().getTimer(ConfigPreferences.TimerType.BUILD, arena));
|
||||
arena.setTheme(theme);
|
||||
}
|
||||
plugin.getChatManager().broadcast(arena, plugin.getChatManager().colorMessage("In-Game.Messages.Admin-Messages.Set-Starting-In-To-0"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.managers.MapRestorerManager;
|
||||
import plugily.projects.buildbattle.arena.managers.ScoreboardManager;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.PlotManager;
|
||||
import plugily.projects.buildbattle.handlers.menu.registry.particles.ParticleRefreshScheduler;
|
||||
import plugily.projects.minigamesbox.classic.arena.PluginArena;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.TitleBuilder;
|
||||
import plugily.projects.minigamesbox.classic.handlers.reward.RewardType;
|
||||
import plugily.projects.minigamesbox.classic.handlers.reward.RewardsFactory;
|
||||
import plugily.projects.minigamesbox.classic.utils.items.HandlerItem;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.VersionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
* <p>
|
||||
* Created at 17.12.2021
|
||||
*/
|
||||
public class BaseArena extends PluginArena {
|
||||
|
||||
private static Main plugin;
|
||||
private final List<Player> spectators = new ArrayList<>();
|
||||
private MapRestorerManager mapRestorerManager;
|
||||
private final PlotManager plotManager;
|
||||
private String theme = "Theme";
|
||||
protected ParticleRefreshScheduler particleRefreshScheduler;
|
||||
private ArenaType arenaType;
|
||||
|
||||
private ArenaInGameState arenaInGameState;
|
||||
|
||||
private Map<Player, Plot> plotList = new HashMap<>();
|
||||
|
||||
private Plot winnerPlot;
|
||||
|
||||
public BaseArena(String id) {
|
||||
super(id);
|
||||
setPluginValues();
|
||||
setScoreboardManager(new ScoreboardManager(this));
|
||||
mapRestorerManager = new MapRestorerManager(this);
|
||||
plotManager = new PlotManager(this);
|
||||
setMapRestorerManager(mapRestorerManager);
|
||||
}
|
||||
|
||||
public static void init(Main plugin) {
|
||||
BaseArena.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Main getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MapRestorerManager getMapRestorerManager() {
|
||||
return mapRestorerManager;
|
||||
}
|
||||
|
||||
|
||||
private void setPluginValues() {
|
||||
}
|
||||
|
||||
|
||||
public void addSpectatorPlayer(Player player) {
|
||||
spectators.add(player);
|
||||
}
|
||||
|
||||
public void removeSpectatorPlayer(Player player) {
|
||||
spectators.remove(player);
|
||||
}
|
||||
|
||||
public boolean isSpectatorPlayer(Player player) {
|
||||
return spectators.contains(player);
|
||||
}
|
||||
|
||||
public void cleanUpArena() {
|
||||
spectators.clear();
|
||||
plotList.clear();
|
||||
setTheme(null);
|
||||
winnerPlot = null;
|
||||
}
|
||||
|
||||
public List<Player> getSpectators() {
|
||||
return spectators;
|
||||
}
|
||||
|
||||
public enum ArenaType {
|
||||
SOLO("Classic"), TEAM("Teams"), GUESS_THE_BUILD("Guess-The-Build");
|
||||
|
||||
private final String prefix;
|
||||
|
||||
ArenaType(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
|
||||
public enum ArenaInGameState {
|
||||
THEME_VOTING("Theme-Voting"), BUILD_TIME("Build-Time"), PLOT_VOTING("Plot-Voting"), NONE("NONE");
|
||||
|
||||
private final String prefix;
|
||||
|
||||
ArenaInGameState(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current arena theme
|
||||
*
|
||||
* @return arena theme String or "Theme" as default
|
||||
*/
|
||||
@NotNull
|
||||
public String getTheme() {
|
||||
return theme;
|
||||
}
|
||||
|
||||
public void setTheme(String theme) {
|
||||
this.theme = theme == null ? "Theme" : theme;
|
||||
}
|
||||
|
||||
public void sendBuildLeftTimeMessage() {
|
||||
new TitleBuilder("IN_GAME_MESSAGES_PLOT_TIME_LEFT_TITLE").asKey().arena(this).sendArena();
|
||||
String message = new MessageBuilder("IN_GAME_MESSAGES_PLOT_TIME_LEFT_CHAT").asKey().arena(this).build();
|
||||
for(Player p : getPlayers()) {
|
||||
VersionUtils.sendActionBar(p, message);
|
||||
p.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
public final void checkPlayerOutSidePlot() {
|
||||
if(plugin.getConfigPreferences().getOption("PLOT_MOVE_OUTSIDE")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(getArenaOption("IN_PLOT_CHECKER") >= 3) {
|
||||
setArenaOption("IN_PLOT_CHECKER", 0);
|
||||
|
||||
for(Player player : getPlayersLeft()) {
|
||||
Plot buildPlot = null;
|
||||
|
||||
if(this instanceof BuildArena) {
|
||||
buildPlot = getPlotFromPlayer(player);
|
||||
} else if(this instanceof GuessArena && (buildPlot = getPlotFromPlayer(player)) != null) {
|
||||
player.setPlayerWeather(buildPlot.getWeatherType());
|
||||
player.setPlayerTime(Plot.Time.format(buildPlot.getTime(), player.getWorld().getTime()), false);
|
||||
}
|
||||
|
||||
if(buildPlot != null && buildPlot.getCuboid() != null && !buildPlot.getCuboid().isInWithMarge(player.getLocation(), 5)) {
|
||||
VersionUtils.teleport(player, buildPlot.getTeleportLocation());
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_PERMISSION_OUTSIDE").asKey().arena(this).player(player).sendPlayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeArenaOptionBy("IN_PLOT_CHECKER", 1);
|
||||
}
|
||||
|
||||
public void calculateWinnerPlot() {
|
||||
winnerPlot = plotManager.getTopPlotsOrder().get(0);
|
||||
}
|
||||
|
||||
public void executeEndRewards() {
|
||||
RewardsFactory rewards = plugin.getRewardsHandler();
|
||||
RewardType placeRewardType = rewards.getRewardType("PLACE");
|
||||
|
||||
List<Plot> plotsRanking = plotManager.getTopPlotsOrder();
|
||||
|
||||
plotsRanking.forEach(plot -> plot.getMembers().forEach(player -> rewards.performReward(player, this, placeRewardType, plotsRanking.indexOf(plot) + 1)));
|
||||
plugin.getRewardsHandler().performReward(this, plugin.getRewardsHandler().getRewardType("END_GAME"));
|
||||
}
|
||||
|
||||
public void teleportToWinnerPlot() {
|
||||
Location winnerLocation = winnerPlot.getTeleportLocation();
|
||||
String formattedMembers = winnerPlot.getFormattedMembers();
|
||||
for(Player player : getPlayers()) {
|
||||
VersionUtils.teleport(player, winnerLocation);
|
||||
new TitleBuilder("IN_GAME_MESSAGES_PLOT_VOTING_WINNER").asKey().player(player).value(formattedMembers).sendPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
HandlerItem optionsMenuItem;
|
||||
|
||||
private HandlerItem getMenuItem() {
|
||||
if(optionsMenuItem == null) {
|
||||
HandlerItem optionsMenu = new HandlerItem(getPlugin().getOptionsRegistry().getMenuItem());
|
||||
optionsMenu.setLeftClick(true);
|
||||
optionsMenu.setRightClick(true);
|
||||
optionsMenu.addInteractHandler(event -> {
|
||||
event.setCancelled(true);
|
||||
getPlugin().getOptionsRegistry().getOptionsGui().open(event.getPlayer());
|
||||
});
|
||||
optionsMenu.addInventoryClickHandler(event -> {
|
||||
getPlugin().getOptionsRegistry().getOptionsGui().open(event.getWhoClicked());
|
||||
});
|
||||
optionsMenuItem = optionsMenu.build();
|
||||
}
|
||||
return optionsMenuItem;
|
||||
}
|
||||
|
||||
public void addMenuItem(Player player) {
|
||||
if(player.getInventory().contains(getMenuItem().getItemStack())) {
|
||||
return;
|
||||
}
|
||||
player.getInventory().setItem(8, getMenuItem().getItemStack());
|
||||
}
|
||||
|
||||
|
||||
public PlotManager getPlotManager() {
|
||||
return plotManager;
|
||||
}
|
||||
|
||||
public ArenaType getArenaType() {
|
||||
return arenaType;
|
||||
}
|
||||
|
||||
public void setArenaType(ArenaType arenaType) {
|
||||
this.arenaType = arenaType;
|
||||
}
|
||||
|
||||
public ArenaInGameState getArenaInGameState() {
|
||||
return arenaInGameState;
|
||||
}
|
||||
|
||||
public void setArenaInGameState(ArenaInGameState arenaInGameState) {
|
||||
this.arenaInGameState = arenaInGameState;
|
||||
}
|
||||
|
||||
public ParticleRefreshScheduler getParticleRefreshScheduler() {
|
||||
return particleRefreshScheduler;
|
||||
}
|
||||
|
||||
public void setParticleRefreshScheduler(ParticleRefreshScheduler particleRefreshScheduler) {
|
||||
this.particleRefreshScheduler = particleRefreshScheduler;
|
||||
}
|
||||
|
||||
public boolean enoughPlayersToContinue() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void distributePlots() {
|
||||
}
|
||||
|
||||
public Map<Player, Plot> getPlotList() {
|
||||
return plotList;
|
||||
}
|
||||
|
||||
public Plot getPlotFromPlayer(Player player) {
|
||||
return plotList.get(player);
|
||||
}
|
||||
|
||||
public Plot getWinnerPlot() {
|
||||
return winnerPlot;
|
||||
}
|
||||
|
||||
public void setWinnerPlot(Plot winnerPlot) {
|
||||
this.winnerPlot = winnerPlot;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.arena.states.build.InGameState;
|
||||
import plugily.projects.buildbattle.arena.states.build.StartingState;
|
||||
import plugily.projects.buildbattle.handlers.themes.vote.VoteMenu;
|
||||
import plugily.projects.buildbattle.handlers.themes.vote.VotePoll;
|
||||
import plugily.projects.minigamesbox.api.arena.IArenaState;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
* <p>
|
||||
* Created at 22.04.2022
|
||||
*/
|
||||
public class BuildArena extends BaseArena {
|
||||
private final Queue<Plot> queue = new LinkedList<>();
|
||||
private Plot votingPlot;
|
||||
private VoteMenu voteMenu;
|
||||
|
||||
public BuildArena(String id) {
|
||||
super(id);
|
||||
setArenaType(ArenaType.SOLO);
|
||||
addGameStateHandler(IArenaState.IN_GAME, new InGameState());
|
||||
addGameStateHandler(IArenaState.STARTING, new StartingState());
|
||||
getPlugin().getDebugger().debug("Init Arena {0} with ArenaType {1}", getId(), getArenaType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates voting poll
|
||||
*/
|
||||
public void initPoll() {
|
||||
voteMenu = new VoteMenu(this);
|
||||
voteMenu.resetPoll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanUpArena() {
|
||||
votingPlot = null;
|
||||
if(voteMenu != null) {
|
||||
voteMenu.resetPoll();
|
||||
}
|
||||
super.cleanUpArena();
|
||||
}
|
||||
|
||||
public VotePoll getVotePoll() {
|
||||
return voteMenu.getVotePoll();
|
||||
}
|
||||
|
||||
public VoteMenu getVoteMenu() {
|
||||
return voteMenu;
|
||||
}
|
||||
|
||||
public void setVotingPlot(Plot votingPlot) {
|
||||
this.votingPlot = votingPlot;
|
||||
}
|
||||
|
||||
public Plot getVotingPlot() {
|
||||
return votingPlot;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Queue<Plot> getQueue() {
|
||||
return queue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distributePlots() {
|
||||
int neededPlots = getPlayers().size() / getArenaOption("PLOT_MEMBER_SIZE");
|
||||
if(getPlotManager().getPlots().size() < neededPlots) {
|
||||
getPlugin().getMessageUtils().errorOccurred();
|
||||
getPlugin().getDebugger().sendConsoleMsg("&c[Build Battle] [PLOT WARNING] Not enough plots in arena " + getId() + "! Lacks " + (neededPlots - getPlotManager().getPlots().size()) + " plots");
|
||||
getPlugin().getDebugger().sendConsoleMsg("&c[PLOT WARNING] Required " + neededPlots + " but have " + getPlotManager().getPlots().size());
|
||||
getPlugin().getDebugger().sendConsoleMsg("&c[PLOT WARNING] Instance was stopped!");
|
||||
getPlugin().getArenaManager().stopGame(true, this);
|
||||
}
|
||||
switch(getArenaType()) {
|
||||
case SOLO:
|
||||
List<Player> players = new ArrayList<>(getPlayersLeft());
|
||||
for(Plot plot : getPlotManager().getPlots()) {
|
||||
if(players.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(!getPlugin().getUserManager().getUser(players.get(0)).isSpectator()) {
|
||||
plot.addMember(players.remove(0), this, true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TEAM:
|
||||
for(Player player : getPlayers()) {
|
||||
// get base with min players
|
||||
Plot minPlayers = getPlotManager().getPlots().stream().min(Comparator.comparing(Plot::getMembersSize)).get();
|
||||
// add player to min base if he got no base
|
||||
Plot playerPlot = getPlotManager().getPlot(player);
|
||||
if(playerPlot == null) {
|
||||
minPlayers.addMember(player, this, true);
|
||||
}
|
||||
// fallback
|
||||
if(playerPlot == null) {
|
||||
getPlotManager().getPlots().get(0).addMember(player, this, true);
|
||||
}
|
||||
}
|
||||
//check if not only one plot got players
|
||||
Plot maxPlayers = getPlotManager().getPlots().stream().max(Comparator.comparing(Plot::getMembersSize)).get();
|
||||
Plot minPlayers = getPlotManager().getPlots().stream().min(Comparator.comparing(Plot::getMembersSize)).get();
|
||||
if(maxPlayers.getMembersSize() == getPlayers().size()) {
|
||||
for(int i = 0; i < maxPlayers.getMembersSize() / 2; i++) {
|
||||
Player move = maxPlayers.getMembers().get(i);
|
||||
minPlayers.addMember(move, this, true);
|
||||
maxPlayers.removeMember(move);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(Plot plot : getPlotManager().getPlots()) {
|
||||
if(plot.getMembers().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
for(Player member : plot.getMembers()) {
|
||||
getPlotList().put(member, plot);
|
||||
}
|
||||
}
|
||||
getPlotManager().teleportToPlots();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean enoughPlayersToContinue() {
|
||||
int size = getPlayers().size();
|
||||
int memberSize = getArenaOption("PLOT_MEMBER_SIZE");
|
||||
|
||||
if(size > memberSize) {
|
||||
return true;
|
||||
}
|
||||
if(size == memberSize) {
|
||||
return !new HashSet<>(getPlotManager().getPlot(getPlayersLeft().get(0)).getMembers()).containsAll(getPlayers());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMinimumPlayers(int amount) {
|
||||
if(getArenaType() == ArenaType.TEAM && amount <= getArenaOption("PLOT_MEMBER_SIZE")) {
|
||||
getPlugin().getDebugger().debug("Minimum players amount for TEAM game mode arena cannot be less than 3! Setting amount to 3!");
|
||||
super.setMinimumPlayers(3);
|
||||
return;
|
||||
}
|
||||
super.setMinimumPlayers(amount);
|
||||
}
|
||||
|
||||
protected void setTypeByPlotMembers() {
|
||||
setArenaType(getArenaOption("PLOT_MEMBER_SIZE") <= 1 ? ArenaType.SOLO : ArenaType.TEAM);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.api.event.guess.PlayerThemeGuessEvent;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.arena.states.guess.InGameState;
|
||||
import plugily.projects.buildbattle.arena.states.guess.StartingState;
|
||||
import plugily.projects.buildbattle.handlers.themes.BBTheme;
|
||||
import plugily.projects.minigamesbox.api.arena.IArenaState;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.VersionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
* <p>
|
||||
* Created at 29.05.2022
|
||||
*/
|
||||
public class GuessArena extends BaseArena {
|
||||
|
||||
private final List<Player> whoGuessed = new ArrayList<>();
|
||||
private int round = 1;
|
||||
private BBTheme currentTheme = null;
|
||||
|
||||
private Plot buildPlot = null;
|
||||
private List<Integer> removedCharsAt = new ArrayList<>();
|
||||
|
||||
private final int plotMemberSize = getArenaOption("PLOT_MEMBER_SIZE");
|
||||
|
||||
private List<Plot> playedPlots = new ArrayList<>();
|
||||
|
||||
private List<String> playedThemes = new ArrayList<>();
|
||||
|
||||
public GuessArena(String id) {
|
||||
super(id);
|
||||
setArenaType(ArenaType.GUESS_THE_BUILD);
|
||||
addGameStateHandler(IArenaState.IN_GAME, new InGameState());
|
||||
addGameStateHandler(IArenaState.STARTING, new StartingState());
|
||||
getPlugin().getDebugger().debug("Init Arena {0} with ArenaType {1}", getId(), getArenaType());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanUpArena() {
|
||||
currentTheme = null;
|
||||
round = 1;
|
||||
whoGuessed.clear();
|
||||
removedCharsAt.clear();
|
||||
playedPlots.clear();
|
||||
playedThemes.clear();
|
||||
super.cleanUpArena();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distributePlots() {
|
||||
int neededPlots = getPlayers().size() / plotMemberSize;
|
||||
if(getPlotManager().getPlots().size() < neededPlots) {
|
||||
getPlugin().getMessageUtils().errorOccurred();
|
||||
getPlugin().getDebugger().sendConsoleMsg("&c[Build Battle] [PLOT WARNING] Not enough plots in arena " + getId() + "! Lacks " + (neededPlots - getPlotManager().getPlots().size()) + " plots");
|
||||
getPlugin().getDebugger().sendConsoleMsg("&c[PLOT WARNING] Required " + neededPlots + " but have " + getPlotManager().getPlots().size());
|
||||
getPlugin().getDebugger().sendConsoleMsg("&c[PLOT WARNING] Instance was stopped!");
|
||||
getPlugin().getArenaManager().stopGame(true, this);
|
||||
}
|
||||
List<Player> players = new ArrayList<>(getPlayersLeft());
|
||||
for(Plot plot : getPlotManager().getPlots()) {
|
||||
if(players.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
if(!getPlugin().getUserManager().getUser(players.get(0)).isSpectator()) {
|
||||
plot.addMember(players.remove(0), this, true);
|
||||
}
|
||||
}
|
||||
for(Plot plot : getPlotManager().getPlots()) {
|
||||
if(plot.getMembers().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
for(Player member : plot.getMembers()) {
|
||||
getPlotList().put(member, plot);
|
||||
}
|
||||
}
|
||||
getPlotManager().teleportToPlots();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean enoughPlayersToContinue() {
|
||||
int size = getPlayers().size();
|
||||
|
||||
if(size > plotMemberSize) {
|
||||
return true;
|
||||
}
|
||||
if(size == plotMemberSize) {
|
||||
return !new HashSet<>(getPlotManager().getPlot(getPlayersLeft().get(0)).getMembers()).containsAll(getPlayers());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setNextPlot() {
|
||||
List<Plot> plots = new ArrayList<>(getPlotList().values());
|
||||
plots.removeAll(playedPlots);
|
||||
if(plots.isEmpty()) {
|
||||
plots = new ArrayList<>(getPlotList().values());
|
||||
playedPlots.clear();
|
||||
}
|
||||
Plot nextPlot = plots.get(getPlugin().getRandom().nextInt(plots.size()));
|
||||
playedPlots.add(nextPlot);
|
||||
buildPlot = nextPlot;
|
||||
getPlugin().getDebugger().debug("Arena {0} Next BuilderTeam is {1}", getId(), nextPlot.getFormattedMembers());
|
||||
teleportPlayersToPlot(nextPlot);
|
||||
}
|
||||
|
||||
public void resetBuildPlot() {
|
||||
if(buildPlot != null) {
|
||||
buildPlot.resetPlot();
|
||||
}
|
||||
getRemovedCharsAt().clear();
|
||||
setBuildPlot(null);
|
||||
setCurrentTheme(null);
|
||||
getWhoGuessed().clear();
|
||||
round += 1;
|
||||
getPlayers().forEach(player -> getPlugin().getActionBarManager().clearActionBarsFromPlayer(player));
|
||||
}
|
||||
|
||||
public void teleportPlayersToPlot(Plot plot) {
|
||||
Location plotLoc = plot.getTeleportLocation();
|
||||
for(Player player : getPlayers()) {
|
||||
VersionUtils.teleport(player, plotLoc);
|
||||
player.setPlayerWeather(plot.getWeatherType());
|
||||
player.setPlayerTime(Plot.Time.format(plot.getTime(), player.getWorld().getTime()), false);
|
||||
VersionUtils.setCollidable(player, false);
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
player.getInventory().clear();
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMinimumPlayers(int amount) {
|
||||
if(amount <= plotMemberSize) {
|
||||
getPlugin().getDebugger().debug("Minimum players amount for TEAM game mode arena cannot be less than 3! Setting amount to 3!");
|
||||
setArenaOption("MINIMUM_PLAYERS", 3);
|
||||
return;
|
||||
}
|
||||
super.setMinimumPlayers(amount);
|
||||
}
|
||||
|
||||
public void addWhoGuessed(Player player) {
|
||||
whoGuessed.add(player);
|
||||
getPlugin().getRewardsHandler().performReward(player, this, getPlugin().getRewardsHandler().getRewardType("GUESS"), -1);
|
||||
|
||||
int timer = getTimer();
|
||||
|
||||
//decrease game time by guessed theme
|
||||
if(timer >= 15) {
|
||||
setTimer(timer - getPlugin().getConfig().getInt("Time-Manager." + getArenaType().getPrefix() + ".Guess"));
|
||||
}
|
||||
|
||||
//-1 because builder can´t guess
|
||||
if(whoGuessed.size() >= getPlayers().size() - 1) {
|
||||
setTimer(getPlugin().getConfig().getInt("Time-Manager." + getArenaType().getPrefix() + ".Round-Delay"));
|
||||
setArenaInGameState(ArenaInGameState.PLOT_VOTING);
|
||||
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESSED").asKey().arena(this).sendArena();
|
||||
|
||||
getPlugin().getRewardsHandler().performReward(this, getPlugin().getRewardsHandler().getRewardType("GUESS_ALL"));
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastPlayerGuessed(Player player) {
|
||||
int bonusAmount = getPlugin().getConfig().getInt("Guessing-Points." + (whoGuessed.size() + 1), 0);
|
||||
int points = currentTheme.getDifficulty().getPointsReward() + bonusAmount;
|
||||
getPlotManager().getPlot(player).addPoints(points);
|
||||
buildPlot.addPoints(getPlugin().getConfig().getInt("Guessing-Points.Builder", 1));
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_GUESSED").asKey().arena(this).player(player).sendArena();
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_POINTS").asKey().integer(points).arena(this).player(player).sendPlayer();
|
||||
|
||||
addWhoGuessed(player);
|
||||
Bukkit.getScheduler().runTask(getPlugin(), () -> Bukkit.getPluginManager().callEvent(new PlayerThemeGuessEvent(this, currentTheme)));
|
||||
}
|
||||
|
||||
public BBTheme getCurrentBBTheme() {
|
||||
return currentTheme;
|
||||
}
|
||||
|
||||
public boolean isCurrentThemeSet() {
|
||||
return currentTheme != null;
|
||||
}
|
||||
|
||||
public List<Player> getCurrentBuilders() {
|
||||
if(buildPlot == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return buildPlot.getMembers();
|
||||
}
|
||||
|
||||
public Plot getBuildPlot() {
|
||||
return buildPlot;
|
||||
}
|
||||
|
||||
public void setBuildPlot(Plot buildPlot) {
|
||||
this.buildPlot = buildPlot;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getPlayedThemes() {
|
||||
return playedThemes;
|
||||
}
|
||||
|
||||
public int getRound() {
|
||||
return round;
|
||||
}
|
||||
|
||||
public void setCurrentTheme(BBTheme currentTheme) {
|
||||
if(currentTheme == null) {
|
||||
getPlugin().getDebugger().debug("Arena {0} set Theme null", getId());
|
||||
} else {
|
||||
getPlugin().getDebugger().debug("Arena {0} set Theme to {1} ({2})", getId(), currentTheme.getTheme(), currentTheme.getDifficulty());
|
||||
}
|
||||
this.currentTheme = currentTheme;
|
||||
}
|
||||
|
||||
public List<Player> getWhoGuessed() {
|
||||
return whoGuessed;
|
||||
}
|
||||
|
||||
public List<Integer> getRemovedCharsAt() {
|
||||
return removedCharsAt;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,460 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena.impl;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.api.event.game.BBGameChangeStateEvent;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.managers.ScoreboardManager;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.PlotManager;
|
||||
import plugily.projects.buildbattle.arena.options.ArenaOption;
|
||||
import plugily.projects.buildbattle.menus.options.registry.particles.ParticleRefreshScheduler;
|
||||
import plugily.projects.commonsbox.minecraft.compat.ServerVersion;
|
||||
import plugily.projects.commonsbox.minecraft.compat.VersionUtils;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.commonsbox.string.StringFormatUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 18.01.2019
|
||||
*/
|
||||
public class BaseArena extends BukkitRunnable {
|
||||
|
||||
private final List<Player> players = new ArrayList<>();
|
||||
private final List<Player> spectators = new ArrayList<>();
|
||||
|
||||
//instead of 2 (lobby, end) location fields we use map with GameLocation enum
|
||||
private final Map<GameLocation, Location> gameLocations = new EnumMap<>(GameLocation.class);
|
||||
//all arena values that are integers, contains constant and floating values
|
||||
private final Map<ArenaOption, Integer> arenaOptions = new EnumMap<>(ArenaOption.class);
|
||||
|
||||
private final Main plugin;
|
||||
private final String id;
|
||||
private final PlotManager plotManager;
|
||||
private final ScoreboardManager scoreboardManager;
|
||||
private String mapName = "";
|
||||
//todo move?
|
||||
private String theme = "Theme";
|
||||
private ArenaState arenaState;
|
||||
private BossBar gameBar;
|
||||
private ArenaType arenaType;
|
||||
private int plotSize = 2;
|
||||
private boolean forceStart = false;
|
||||
private boolean ready = true;
|
||||
|
||||
protected ParticleRefreshScheduler particleRefreshSched;
|
||||
|
||||
public BaseArena(String id, Main plugin) {
|
||||
arenaState = ArenaState.WAITING_FOR_PLAYERS;
|
||||
this.plugin = plugin;
|
||||
this.id = id == null ? "" : id;
|
||||
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1) && plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BOSSBAR_ENABLED)) {
|
||||
gameBar = Bukkit.createBossBar(plugin.getChatManager().colorMessage("Bossbar.Waiting-For-Players"), BarColor.BLUE, BarStyle.SOLID);
|
||||
}
|
||||
plotManager = new PlotManager(this);
|
||||
scoreboardManager = new ScoreboardManager(this);
|
||||
for(ArenaOption option : ArenaOption.values()) {
|
||||
arenaOptions.put(option, option.getDefaultValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if arena is validated and ready to play
|
||||
*
|
||||
* @return true = ready, false = not ready either you must validate it or it's wrongly created
|
||||
*/
|
||||
public boolean isReady() {
|
||||
return ready;
|
||||
}
|
||||
|
||||
public void setReady(boolean ready) {
|
||||
this.ready = ready;
|
||||
}
|
||||
|
||||
public PlotManager getPlotManager() {
|
||||
return plotManager;
|
||||
}
|
||||
|
||||
public ArenaType getArenaType() {
|
||||
return arenaType;
|
||||
}
|
||||
|
||||
public void setArenaType(ArenaType arenaType) {
|
||||
this.arenaType = arenaType;
|
||||
}
|
||||
|
||||
public void setPlotSize(int plotSize) {
|
||||
this.plotSize = plotSize;
|
||||
}
|
||||
|
||||
public int getPlotSize() {
|
||||
return plotSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
runTaskTimer(plugin, 20L, 20L);
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes boss bar action for arena
|
||||
*
|
||||
* @param action add or remove a player from boss bar
|
||||
* @param p player
|
||||
*/
|
||||
public void doBarAction(@NotNull BarAction action, Player p) {
|
||||
if(p == null || gameBar == null || !ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_9_R1) || !plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BOSSBAR_ENABLED)) {
|
||||
return;
|
||||
}
|
||||
if(action == BarAction.ADD) {
|
||||
gameBar.addPlayer(p);
|
||||
} else if(action == BarAction.REMOVE) {
|
||||
gameBar.removePlayer(p);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateBossBar() {
|
||||
|
||||
}
|
||||
|
||||
public void distributePlots() {
|
||||
}
|
||||
|
||||
public void sendBuildLeftTimeMessage() {
|
||||
int timer = getTimer();
|
||||
String message = plugin.getChatManager().colorMessage("In-Game.Messages.Time-Left-To-Build").replace("%FORMATTEDTIME%", StringFormatUtils.formatIntoMMSS(timer));
|
||||
String subtitle = plugin.getChatManager().colorMessage("In-Game.Messages.Time-Left-Subtitle").replace("%FORMATTEDTIME%", Integer.toString(timer));
|
||||
for(Player p : players) {
|
||||
VersionUtils.sendActionBar(p, message);
|
||||
p.sendMessage(plugin.getChatManager().getPrefix() + message);
|
||||
VersionUtils.sendSubTitle(p, subtitle, 5, 30, 5);
|
||||
}
|
||||
}
|
||||
|
||||
public ScoreboardManager getScoreboardManager() {
|
||||
return scoreboardManager;
|
||||
}
|
||||
|
||||
public boolean isForceStart() {
|
||||
return forceStart;
|
||||
}
|
||||
|
||||
public void setForceStart(boolean forceStart) {
|
||||
this.forceStart = forceStart;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get arena ID, ID != map name
|
||||
* ID is used to get and manage arenas
|
||||
*
|
||||
* @return arena ID
|
||||
*/
|
||||
@NotNull
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lobby location of arena
|
||||
*
|
||||
* @return lobby loc of arena
|
||||
*/
|
||||
@Nullable
|
||||
public Location getLobbyLocation() {
|
||||
return gameLocations.get(BaseArena.GameLocation.LOBBY);
|
||||
}
|
||||
|
||||
public void setLobbyLocation(Location loc) {
|
||||
gameLocations.put(BaseArena.GameLocation.LOBBY, loc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Min players that are required to start arena
|
||||
*
|
||||
* @return min players size
|
||||
*/
|
||||
public int getMinimumPlayers() {
|
||||
return getOption(ArenaOption.MINIMUM_PLAYERS);
|
||||
}
|
||||
|
||||
public void setMinimumPlayers(int amount) {
|
||||
setOptionValue(ArenaOption.MINIMUM_PLAYERS, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get map name, map name != ID
|
||||
* Map name is used in signs
|
||||
*
|
||||
* @return map name String
|
||||
*/
|
||||
@NotNull
|
||||
public String getMapName() {
|
||||
return mapName;
|
||||
}
|
||||
|
||||
public void setMapName(String mapname) {
|
||||
if(mapname != null)
|
||||
this.mapName = mapname;
|
||||
}
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
players.add(player);
|
||||
}
|
||||
|
||||
public void removePlayer(Player player) {
|
||||
players.remove(player);
|
||||
}
|
||||
|
||||
public void clearPlayers() {
|
||||
players.clear();
|
||||
}
|
||||
|
||||
public void addSpectator(Player player) {
|
||||
spectators.add(player);
|
||||
}
|
||||
|
||||
public void removeSpectator(Player player) {
|
||||
spectators.remove(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Global timer of arena
|
||||
*
|
||||
* @return timer of arena
|
||||
*/
|
||||
public int getTimer() {
|
||||
return getOption(ArenaOption.TIMER);
|
||||
}
|
||||
|
||||
public void setTimer(int timer) {
|
||||
setOptionValue(ArenaOption.TIMER, timer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Max players size arena can hold
|
||||
*
|
||||
* @return max players size
|
||||
*/
|
||||
public int getMaximumPlayers() {
|
||||
return getOption(ArenaOption.MAXIMUM_PLAYERS);
|
||||
}
|
||||
|
||||
public void setMaximumPlayers(int amount) {
|
||||
setOptionValue(ArenaOption.MAXIMUM_PLAYERS, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Arena state of arena
|
||||
*
|
||||
* @return arena state
|
||||
* @see ArenaState
|
||||
*/
|
||||
@NotNull
|
||||
public ArenaState getArenaState() {
|
||||
return arenaState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes arena state of arena
|
||||
* Calls BBGameChangeStateEvent
|
||||
*
|
||||
* @param arenaState arena state to change
|
||||
* @see BBGameChangeStateEvent
|
||||
*/
|
||||
public void setArenaState(@NotNull ArenaState arenaState) {
|
||||
if(this.arenaState != null) {
|
||||
plugin.getServer().getPluginManager().callEvent(new BBGameChangeStateEvent(arenaState, this, this.arenaState));
|
||||
}
|
||||
|
||||
this.arenaState = arenaState;
|
||||
plugin.getSignManager().updateSigns();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get players in game
|
||||
*
|
||||
* @return List with players
|
||||
*/
|
||||
@NotNull
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get players of the game and spectators
|
||||
*
|
||||
* @return List with players
|
||||
*/
|
||||
@NotNull
|
||||
public List<Player> getAllArenaPlayers() {
|
||||
List<Player> allPlayers = new ArrayList<>(players);
|
||||
allPlayers.addAll(spectators);
|
||||
return allPlayers;
|
||||
}
|
||||
|
||||
public List<Player> getSpectators() {
|
||||
return spectators;
|
||||
}
|
||||
|
||||
public Main getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public void teleportAllToEndLocation() {
|
||||
if(plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED) && ConfigUtils.getConfig(plugin, "bungee").getBoolean("End-Location-Hub", true)) {
|
||||
players.forEach(plugin.getBungeeManager()::connectToHub);
|
||||
spectators.forEach(plugin.getBungeeManager()::connectToHub);
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = getEndLocation();
|
||||
if(location == null) {
|
||||
location = getLobbyLocation();
|
||||
System.out.print("EndLocation for arena " + getID() + " isn't intialized!");
|
||||
}
|
||||
|
||||
if(location != null) {
|
||||
for(Player player : players) {
|
||||
player.teleport(location);
|
||||
}
|
||||
for(Player player : spectators) {
|
||||
player.teleport(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void teleportToLobby(Player player) {
|
||||
Location location = getLobbyLocation();
|
||||
if(location == null) {
|
||||
System.out.print("LobbyLocation isn't intialized for arena " + getID());
|
||||
return;
|
||||
}
|
||||
|
||||
player.teleport(location);
|
||||
}
|
||||
|
||||
public void teleportToEndLocation(Player player) {
|
||||
if(plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED) && ConfigUtils.getConfig(plugin, "bungee").getBoolean("End-Location-Hub", true)) {
|
||||
plugin.getBungeeManager().connectToHub(player);
|
||||
return;
|
||||
}
|
||||
|
||||
Location location = getEndLocation();
|
||||
if(location == null) {
|
||||
location = getLobbyLocation();
|
||||
System.out.print("EndLocation for arena " + getID() + " isn't intialized!");
|
||||
}
|
||||
|
||||
if(location != null) {
|
||||
player.teleport(location);
|
||||
}
|
||||
}
|
||||
|
||||
public void giveRewards() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current arena theme
|
||||
*
|
||||
* @return arena theme String or "Theme" as default
|
||||
*/
|
||||
@NotNull
|
||||
public String getTheme() {
|
||||
//make sure to have no NPE
|
||||
return theme == null ? "Theme" : theme;
|
||||
}
|
||||
|
||||
public void setTheme(String theme) {
|
||||
this.theme = theme == null ? "Theme" : theme;
|
||||
}
|
||||
|
||||
/**
|
||||
* End location of arena
|
||||
*
|
||||
* @return end loc of arena
|
||||
*/
|
||||
@Nullable
|
||||
public Location getEndLocation() {
|
||||
return gameLocations.get(GameLocation.END);
|
||||
}
|
||||
|
||||
public void setEndLocation(Location endLoc) {
|
||||
gameLocations.put(GameLocation.END, endLoc);
|
||||
}
|
||||
|
||||
protected BossBar getGameBar() {
|
||||
return gameBar;
|
||||
}
|
||||
|
||||
public int getOption(ArenaOption option) {
|
||||
return arenaOptions.getOrDefault(option, 0);
|
||||
}
|
||||
|
||||
public void setOptionValue(ArenaOption option, int value) {
|
||||
arenaOptions.put(option, value);
|
||||
}
|
||||
|
||||
public void addOptionValue(ArenaOption option, int value) {
|
||||
arenaOptions.put(option, getOption(option) + value);
|
||||
}
|
||||
|
||||
public enum ArenaType {
|
||||
SOLO("Classic"), TEAM("Teams"), GUESS_THE_BUILD("Guess-The-Build");
|
||||
|
||||
private final String prefix;
|
||||
|
||||
ArenaType(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
}
|
||||
|
||||
public enum GameLocation {
|
||||
LOBBY, END
|
||||
}
|
||||
|
||||
public enum BarAction {
|
||||
ADD, REMOVE
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,604 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena.impl;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.api.StatsStorage;
|
||||
import plugily.projects.buildbattle.api.event.game.BBGameEndEvent;
|
||||
import plugily.projects.buildbattle.api.event.game.BBGameStartEvent;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.managers.GuessTheBuildScoreboardManager;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.arena.options.ArenaOption;
|
||||
import plugily.projects.buildbattle.handlers.reward.Reward;
|
||||
import plugily.projects.buildbattle.menus.options.registry.particles.ParticleRefreshScheduler;
|
||||
import plugily.projects.buildbattle.menus.themevoter.BBTheme;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
import plugily.projects.buildbattle.utils.MessageUtils;
|
||||
import plugily.projects.commonsbox.minecraft.compat.VersionUtils;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.commonsbox.minecraft.item.ItemBuilder;
|
||||
import plugily.projects.commonsbox.minecraft.misc.MiscUtils;
|
||||
import plugily.projects.commonsbox.minecraft.misc.stuff.ComplementAccessor;
|
||||
import plugily.projects.commonsbox.minecraft.serialization.InventorySerializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class GuessTheBuildArena extends BaseArena {
|
||||
|
||||
private final List<Player> whoGuessed = new ArrayList<>();
|
||||
private final GuessTheBuildScoreboardManager scoreboardManager;
|
||||
private int round = 1;
|
||||
private BBTheme currentTheme;
|
||||
private boolean themeSet;
|
||||
private boolean nextRoundCooldown = false;
|
||||
private Player currentBuilder;
|
||||
private Map<Player, Integer> playersPoints = new HashMap<>();
|
||||
private List<Integer> removedCharsAt = new ArrayList<>();
|
||||
|
||||
public GuessTheBuildArena(String id, Main plugin) {
|
||||
super(id, plugin);
|
||||
scoreboardManager = new GuessTheBuildScoreboardManager(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//idle task
|
||||
if(getArenaState() == ArenaState.WAITING_FOR_PLAYERS && getPlayers().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateBossBar();
|
||||
|
||||
switch(getArenaState()) {
|
||||
case WAITING_FOR_PLAYERS:
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
getPlugin().getServer().setWhitelist(false);
|
||||
}
|
||||
|
||||
getPlotManager().resetPlotsGradually();
|
||||
|
||||
int minPlayers = getMinimumPlayers();
|
||||
|
||||
if(getPlayers().size() < minPlayers) {
|
||||
if(getTimer() <= 0) {
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.LOBBY, this));
|
||||
getPlugin().getChatManager().broadcast(this, getPlugin().getChatManager().colorMessage("In-Game.Messages.Lobby-Messages.Waiting-For-Players").replace("%MINPLAYERS%", Integer.toString(minPlayers)));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
getPlugin().getChatManager().broadcast(this, getPlugin().getChatManager().colorMessage("In-Game.Messages.Lobby-Messages.Enough-Players-To-Start"));
|
||||
setArenaState(ArenaState.STARTING);
|
||||
Bukkit.getPluginManager().callEvent(new BBGameStartEvent(this));
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.LOBBY, this));
|
||||
}
|
||||
setTimer(getTimer() - 1);
|
||||
break;
|
||||
case STARTING:
|
||||
int timer = getTimer();
|
||||
int lobbyTimer = getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.LOBBY, this);
|
||||
float exp = (float) (timer / (double) lobbyTimer);
|
||||
|
||||
if(exp > 1f || exp < 0f) {
|
||||
exp = 1f;
|
||||
}
|
||||
|
||||
for(Player player : getPlayers()) {
|
||||
player.setExp(exp);
|
||||
player.setLevel(timer);
|
||||
}
|
||||
|
||||
int minPls = getMinimumPlayers();
|
||||
|
||||
if(getPlayers().size() < minPls) {
|
||||
getPlugin().getChatManager().broadcast(this, getPlugin().getChatManager().colorMessage("In-Game.Messages.Lobby-Messages.Waiting-For-Players").replace("%MINPLAYERS%", Integer.toString(minPls)));
|
||||
setArenaState(ArenaState.WAITING_FOR_PLAYERS);
|
||||
Bukkit.getPluginManager().callEvent(new BBGameStartEvent(this));
|
||||
setTimer(lobbyTimer);
|
||||
for(Player player : getPlayers()) {
|
||||
player.setExp(1);
|
||||
player.setLevel(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(getTimer() == 0) {
|
||||
particleRefreshSched = new ParticleRefreshScheduler(getPlugin());
|
||||
if(!getPlotManager().isPlotsCleared()) {
|
||||
getPlotManager().resetQueuedPlots();
|
||||
}
|
||||
setArenaState(ArenaState.IN_GAME);
|
||||
for(Player player : getPlayers()) {
|
||||
playersPoints.put(player, 0);
|
||||
}
|
||||
distributePlots();
|
||||
getPlotManager().teleportToPlots();
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.DELAYED_TASK, this));
|
||||
for(Player player : getPlayers()) {
|
||||
player.getInventory().clear();
|
||||
//to prevent world switch bug
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> {
|
||||
player.setGameMode(GameMode.ADVENTURE);
|
||||
VersionUtils.setCollidable(player, false);
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
}, 20);
|
||||
}
|
||||
Plot plot = getPlotManager().getPlot(getPlayers().get(round - 1));
|
||||
org.bukkit.Location plotLoc = plot == null ? null : plot.getTeleportLocation();
|
||||
if(plotLoc != null) {
|
||||
for(Player p : getPlayers()) {
|
||||
p.teleport(plotLoc);
|
||||
getPlugin().getRewardsHandler().performReward(p, Reward.RewardType.START_GAME, -1);
|
||||
}
|
||||
}
|
||||
nextRoundCooldown = true;
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> nextRoundCooldown = false, 20L * getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.DELAYED_TASK, this));
|
||||
if(plot != null) {
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> plot.getMembers().forEach(player -> player.setGameMode(GameMode.CREATIVE)), 20);
|
||||
}
|
||||
break;
|
||||
}
|
||||
setTimer(getTimer() - 1);
|
||||
break;
|
||||
case IN_GAME:
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
getPlugin().getServer().setWhitelist(getMaximumPlayers() <= getPlayers().size());
|
||||
}
|
||||
if(currentBuilder == null && !nextRoundCooldown) {
|
||||
currentBuilder = getPlayers().get(round - 1);
|
||||
openThemeSelectionInventoryToCurrentBuilder();
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.THEME_SELECTION, this));
|
||||
break;
|
||||
}
|
||||
if(!themeSet && getTimer() <= 0 && currentBuilder != null) {
|
||||
Random r = new Random();
|
||||
String type = "EASY";
|
||||
switch(r.nextInt(2 + 1)) {
|
||||
case 1:
|
||||
type = "MEDIUM";
|
||||
break;
|
||||
case 2:
|
||||
type = "HARD";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
List<String> themes = getPlugin().getConfigPreferences().getThemes(BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix() + "_" + type);
|
||||
if(!themes.isEmpty()) {
|
||||
BBTheme theme = new BBTheme(themes.get(themes.size() == 1 ? 0 : r.nextInt(themes.size())), BBTheme.Difficulty.valueOf(type));
|
||||
setCurrentTheme(theme);
|
||||
setThemeSet(true);
|
||||
VersionUtils.sendActionBar(currentBuilder, getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Theme-Is-Name")
|
||||
.replace("%THEME%", theme.getTheme()));
|
||||
}
|
||||
currentBuilder.closeInventory();
|
||||
|
||||
String roundMessage = getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Current-Round")
|
||||
.replace("%ROUND%", Integer.toString(round))
|
||||
.replace("%MAXPLAYERS%", Integer.toString(getPlayers().size()));
|
||||
for(Player p : getPlayers()) {
|
||||
VersionUtils.sendTitle(p, getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Start-Guessing-Title"), 5, 25, 5);
|
||||
p.sendMessage(roundMessage);
|
||||
}
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.BUILD, this));
|
||||
break;
|
||||
}
|
||||
if(getTimer() <= 90 && currentTheme != null) {
|
||||
if(getTimer() == 90) {
|
||||
getPlugin().getChatManager().broadcast(this, getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Theme-Is-Long")
|
||||
.replace("%NUM%", Integer.toString(currentTheme.getTheme().length())));
|
||||
}
|
||||
for(Player player : getPlayers()) {
|
||||
if(currentBuilder == player) {
|
||||
continue;
|
||||
}
|
||||
if(whoGuessed.contains(player)) {
|
||||
VersionUtils.sendActionBar(player, currentTheme.getTheme());
|
||||
}
|
||||
StringBuilder actionbar = new StringBuilder();
|
||||
List<Integer> charsAt = new ArrayList<>();
|
||||
|
||||
for(int i = 0; i < currentTheme.getTheme().length(); i++) {
|
||||
if(!removedCharsAt.contains(i)) {
|
||||
charsAt.add(i);
|
||||
}
|
||||
}
|
||||
if(currentTheme.getTheme().length() - removedCharsAt.size() > 2) {
|
||||
int t = getTimer();
|
||||
|
||||
if(t % 10 == 0 && t <= 70) {
|
||||
int removeCharAt = charsAt.get(charsAt.size() == 1 ? 0 : new Random().nextInt(charsAt.size()));
|
||||
removedCharsAt.add(removeCharAt);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for(int i = 0; i < currentTheme.getTheme().length(); i++) {
|
||||
if(Character.isWhitespace(currentTheme.getTheme().charAt(i))) {
|
||||
actionbar.append(" ");
|
||||
continue;
|
||||
}
|
||||
if(removedCharsAt.contains(i)) {
|
||||
actionbar.append(currentTheme.getTheme().charAt(i)).append(' ');
|
||||
continue;
|
||||
}
|
||||
actionbar.append("_ ");
|
||||
}
|
||||
VersionUtils.sendActionBar(player, actionbar.toString());
|
||||
}
|
||||
}
|
||||
if(getTimer() <= 0 && themeSet) {
|
||||
getPlugin().getChatManager().broadcast(this, getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Theme-Was-Name").replace("%THEME%", currentTheme.getTheme()));
|
||||
|
||||
String themeTitle = getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Theme-Was-Title");
|
||||
String themeSubtitle = getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Theme-Was-Subtitle")
|
||||
.replace("%THEME%", currentTheme.getTheme());
|
||||
|
||||
for(Player p : getPlayers()) {
|
||||
VersionUtils.sendTitles(p, themeTitle, themeSubtitle, 5, 25, 5);
|
||||
}
|
||||
removedCharsAt.clear();
|
||||
currentBuilder = null;
|
||||
setThemeSet(false);
|
||||
setCurrentTheme(null);
|
||||
whoGuessed.clear();
|
||||
round++;
|
||||
if(round > getPlayers().size()) {
|
||||
setTimer(15);
|
||||
setArenaState(ArenaState.ENDING);
|
||||
Bukkit.getPluginManager().callEvent(new BBGameEndEvent(this));
|
||||
break;
|
||||
}
|
||||
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.DELAYED_TASK, this));
|
||||
nextRoundCooldown = true;
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> {
|
||||
nextRoundCooldown = false;
|
||||
currentBuilder = getPlayers().get(round - 1);
|
||||
|
||||
Plot plot = getPlotManager().getPlot(currentBuilder);
|
||||
org.bukkit.Location plotLoc = plot == null ? null : plot.getTeleportLocation();
|
||||
|
||||
for(Player p : getPlayers()) {
|
||||
if(plot != null) {
|
||||
if(plotLoc != null) {
|
||||
p.teleport(plotLoc);
|
||||
}
|
||||
p.setPlayerWeather(plot.getWeatherType());
|
||||
p.setPlayerTime(Plot.Time.format(plot.getTime(), p.getWorld().getTime()), false);
|
||||
}
|
||||
VersionUtils.setCollidable(p, false);
|
||||
p.setGameMode(GameMode.ADVENTURE);
|
||||
p.setAllowFlight(true);
|
||||
p.setFlying(true);
|
||||
p.getInventory().clear(8);
|
||||
p.updateInventory();
|
||||
}
|
||||
openThemeSelectionInventoryToCurrentBuilder();
|
||||
if(plot != null) {
|
||||
plot.getMembers().forEach(player -> player.setGameMode(GameMode.CREATIVE));
|
||||
}
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.THEME_SELECTION, this));
|
||||
if(getArenaState() != ArenaState.IN_GAME || themeSet) {
|
||||
return;
|
||||
}
|
||||
for(Player player : getPlayers()) {
|
||||
if(currentBuilder != player) {
|
||||
VersionUtils.sendSubTitle(player, getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Theme-Being-Selected"), 5, 25, 5);
|
||||
}
|
||||
}
|
||||
}, 20L * getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.DELAYED_TASK, this));
|
||||
//todo next round info and game state?
|
||||
break;
|
||||
}
|
||||
if(getPlayers().size() < 2) {
|
||||
getPlugin().getChatManager().broadcast(this, getPlugin().getChatManager().colorMessage("In-Game.Messages.Game-End-Messages.Only-You-Playing"));
|
||||
setArenaState(ArenaState.ENDING);
|
||||
Bukkit.getPluginManager().callEvent(new BBGameEndEvent(this));
|
||||
setTimer(15);
|
||||
}
|
||||
if(themeSet && (getTimer() == (4 * 60) || getTimer() == (3 * 60) || getTimer() == 5 * 60 || getTimer() == 30 || getTimer() == 2 * 60 || getTimer() == 60 || getTimer() == 15)) {
|
||||
sendBuildLeftTimeMessage();
|
||||
}
|
||||
//if player leaves during round force next round
|
||||
if(currentBuilder != null && !currentBuilder.isOnline()) {
|
||||
setTimer(1);
|
||||
}
|
||||
if(getTimer() != 0 && currentBuilder != null) {
|
||||
if(getOption(ArenaOption.IN_PLOT_CHECKER) == 1) {
|
||||
setOptionValue(ArenaOption.IN_PLOT_CHECKER, 0);
|
||||
|
||||
Plot buildPlot = getPlugin().getUserManager().getUser(currentBuilder).getCurrentPlot();
|
||||
|
||||
if(buildPlot != null) {
|
||||
org.bukkit.Location plotLoc = buildPlot.getTeleportLocation();
|
||||
|
||||
for(Player player : getPlayers()) {
|
||||
player.setPlayerWeather(buildPlot.getWeatherType());
|
||||
player.setPlayerTime(Plot.Time.format(buildPlot.getTime(), player.getWorld().getTime()), false);
|
||||
if(plotLoc != null && !buildPlot.getCuboid().isInWithMarge(player.getLocation(), 5)) {
|
||||
player.teleport(plotLoc);
|
||||
player.sendMessage(getPlugin().getChatManager().getPrefix() + getPlugin().getChatManager().colorMessage("In-Game.Messages.Cant-Fly-Outside-Plot"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
addOptionValue(ArenaOption.IN_PLOT_CHECKER, 1);
|
||||
}
|
||||
setTimer(getTimer() - 1);
|
||||
break;
|
||||
case ENDING:
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
getPlugin().getServer().setWhitelist(false);
|
||||
}
|
||||
if(getPlugin().getConfig().getBoolean("Firework-When-Game-Ends", true)) {
|
||||
for(Player player : getPlayers()) {
|
||||
MiscUtils.spawnRandomFirework(player.getLocation());
|
||||
}
|
||||
}
|
||||
if(getTimer() <= 0) {
|
||||
scoreboardManager.stopAllScoreboards();
|
||||
|
||||
for(Player player : getAllArenaPlayers()) {
|
||||
teleportToEndLocation(player);
|
||||
if(getGameBar() != null) {
|
||||
getGameBar().removePlayer(player);
|
||||
}
|
||||
User user = getPlugin().getUserManager().getUser(player);
|
||||
user.removeScoreboard(this);
|
||||
user.setSpectator(false);
|
||||
player.getInventory().clear();
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setFlying(false);
|
||||
player.setAllowFlight(false);
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.sendMessage(getPlugin().getChatManager().getPrefix() + getPlugin().getChatManager().colorMessage("Commands.Teleported-To-The-Lobby"));
|
||||
user.addStat(StatsStorage.StatisticType.GAMES_PLAYED, 1);
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.INVENTORY_MANAGER_ENABLED)) {
|
||||
InventorySerializer.loadInventory(getPlugin(), player);
|
||||
}
|
||||
//fast solution
|
||||
Plot plot = getPlotManager().getPlot(player);
|
||||
if(plot != null)
|
||||
plot.fullyResetPlot();
|
||||
}
|
||||
|
||||
// do it in the main thread to prevent async catch from bukkit
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), this::giveRewards);
|
||||
|
||||
clearPlayers();
|
||||
if(particleRefreshSched != null) {
|
||||
particleRefreshSched.task.cancel();
|
||||
}
|
||||
setArenaState(ArenaState.RESTARTING);
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
getPlugin().getServer().getOnlinePlayers().forEach(this::addPlayer);
|
||||
}
|
||||
}
|
||||
setTimer(getTimer() - 1);
|
||||
break;
|
||||
case RESTARTING:
|
||||
setOptionValue(ArenaOption.IN_PLOT_CHECKER, 0);
|
||||
whoGuessed.clear();
|
||||
playersPoints.clear();
|
||||
round = 1;
|
||||
clearPlayers();
|
||||
nextRoundCooldown = false;
|
||||
setTimer(14);
|
||||
setArenaState(ArenaState.WAITING_FOR_PLAYERS);
|
||||
currentBuilder = null;
|
||||
setThemeSet(false);
|
||||
setCurrentTheme(null);
|
||||
for(Player spectator : new ArrayList<>(getSpectators())) {
|
||||
ArenaManager.leaveAttempt(spectator, this);
|
||||
}
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
if(ConfigUtils.getConfig(getPlugin(), "bungee").getBoolean("Shutdown-When-Game-Ends")) {
|
||||
getPlugin().getServer().shutdown();
|
||||
}
|
||||
ArenaRegistry.shuffleBungeeArena();
|
||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||
ArenaManager.joinAttempt(player, ArenaRegistry.getArenas().get(ArenaRegistry.getBungeeArena()));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void openThemeSelectionInventoryToCurrentBuilder() {
|
||||
if(currentBuilder == null)
|
||||
return;
|
||||
|
||||
Random r = new Random();
|
||||
|
||||
List<String> themes = getPlugin().getConfigPreferences().getThemes(BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix() + "_EASY");
|
||||
String itemLore = getPlugin().getChatManager().colorMessage("Menus.Guess-The-Build-Theme-Selector.Theme-Item-Lore");
|
||||
String themeItemName = getPlugin().getChatManager().colorMessage("Menus.Guess-The-Build-Theme-Selector.Theme-Item-Name");
|
||||
|
||||
Inventory inv = ComplementAccessor.getComplement().createInventory(null, 27, getPlugin().getChatManager().colorMessage("Menus.Guess-The-Build-Theme-Selector.Inventory-Name"));
|
||||
inv.setItem(11, new ItemBuilder(Material.PAPER).name(themeItemName
|
||||
.replace("%theme%", !themes.isEmpty() ? themes.get(themes.size() == 1 ? 0 : r.nextInt(themes.size())) : ""))
|
||||
.lore(itemLore
|
||||
.replace("%difficulty%", getPlugin().getChatManager().colorMessage("Menus.Guess-The-Build-Theme-Selector.Difficulties.Easy"))
|
||||
.replace("%points%", "1").split(";")).build());
|
||||
|
||||
themes = getPlugin().getConfigPreferences().getThemes(BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix() + "_MEDIUM");
|
||||
|
||||
inv.setItem(13, new ItemBuilder(Material.PAPER).name(themeItemName
|
||||
.replace("%theme%", !themes.isEmpty() ? themes.get(themes.size() == 1 ? 0 : r.nextInt(themes.size())) : ""))
|
||||
.lore(itemLore
|
||||
.replace("%difficulty%", getPlugin().getChatManager().colorMessage("Menus.Guess-The-Build-Theme-Selector.Difficulties.Medium"))
|
||||
.replace("%points%", "2").split(";")).build());
|
||||
|
||||
themes = getPlugin().getConfigPreferences().getThemes(BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix() + "_HARD");
|
||||
|
||||
inv.setItem(15, new ItemBuilder(Material.PAPER).name(themeItemName
|
||||
.replace("%theme%", !themes.isEmpty() ? themes.get(themes.size() == 1 ? 0 : r.nextInt(themes.size())) : ""))
|
||||
.lore(itemLore
|
||||
.replace("%difficulty%", getPlugin().getChatManager().colorMessage("Menus.Guess-The-Build-Theme-Selector.Difficulties.Hard"))
|
||||
.replace("%points%", "3").split(";")).build());
|
||||
currentBuilder.openInventory(inv);
|
||||
currentBuilder.getInventory().setItem(8, getPlugin().getOptionsRegistry().getMenuItem());
|
||||
currentBuilder.updateInventory();
|
||||
}
|
||||
|
||||
public void recalculateLeaderboard() {
|
||||
playersPoints = playersPoints.entrySet()
|
||||
.stream()
|
||||
.sorted((Map.Entry.<Player, Integer>comparingByValue().reversed()))
|
||||
.collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveRewards() {
|
||||
List<Player> list = new ArrayList<>(playersPoints.keySet());
|
||||
int size = list.size();
|
||||
for(int i = 0; i <= size; i++) {
|
||||
if(size - 1 < i) {
|
||||
continue;
|
||||
}
|
||||
getPlugin().getRewardsHandler().performReward(list.get(i), Reward.RewardType.PLACE, i + 1);
|
||||
}
|
||||
getPlugin().getRewardsHandler().performReward(this, Reward.RewardType.END_GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBossBar() {
|
||||
if(getGameBar() == null) {
|
||||
return;
|
||||
}
|
||||
switch(getArenaState()) {
|
||||
case WAITING_FOR_PLAYERS:
|
||||
getGameBar().setTitle(getPlugin().getChatManager().colorMessage("Bossbar.Waiting-For-Players"));
|
||||
break;
|
||||
case STARTING:
|
||||
getGameBar().setTitle(getPlugin().getChatManager().colorMessage("Bossbar.Starting-In").replace("%time%", Integer.toString(getTimer())));
|
||||
break;
|
||||
case IN_GAME:
|
||||
getGameBar().setTitle(getPlugin().getChatManager().colorMessage("Bossbar.Time-Left").replace("%time%", Integer.toString(getTimer())));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distributePlots() {
|
||||
//clear plots before distribution to avoid problems
|
||||
for(Plot plot : getPlotManager().getPlots()) {
|
||||
plot.getMembers().clear();
|
||||
}
|
||||
List<Player> players = new ArrayList<>(getPlayers());
|
||||
for(Plot plot : getPlotManager().getPlots()) {
|
||||
if(players.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
Player first = players.get(0);
|
||||
plot.addMember(first, this, true);
|
||||
getPlugin().getUserManager().getUser(first).setCurrentPlot(plot);
|
||||
players.remove(0);
|
||||
}
|
||||
if(!players.isEmpty()) {
|
||||
MessageUtils.errorOccurred();
|
||||
Debugger.sendConsoleMsg("&c[Build Battle] [PLOT WARNING] Not enough plots in arena " + getID() + "!");
|
||||
Debugger.sendConsoleMsg("&c[PLOT WARNING] Required " + getPlayers().size() + " but have " + getPlotManager().getPlots().size());
|
||||
Debugger.sendConsoleMsg("&c[PLOT WARNING] Instance was stopped!");
|
||||
ArenaManager.stopGame(false, this);
|
||||
}
|
||||
}
|
||||
|
||||
public int getRound() {
|
||||
return round;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Player getCurrentBuilder() {
|
||||
return currentBuilder;
|
||||
}
|
||||
|
||||
public BBTheme getCurrentTheme() {
|
||||
return currentTheme;
|
||||
}
|
||||
|
||||
public void setCurrentTheme(BBTheme currentTheme) {
|
||||
this.currentTheme = currentTheme;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<Player> getWhoGuessed() {
|
||||
return whoGuessed;
|
||||
}
|
||||
|
||||
public void addWhoGuessed(Player player) {
|
||||
whoGuessed.add(player);
|
||||
getPlugin().getRewardsHandler().performReward(player, Reward.RewardType.GTB_GUESS, -1);
|
||||
//decrease game time by guessed theme
|
||||
if(getTimer() >= 15) {
|
||||
setTimer(getTimer() - getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.TIME_SHORTENER, this));
|
||||
}
|
||||
//-1 because builder can´t guess
|
||||
if(whoGuessed.size() >= getPlayers().size() - 1) {
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.ALL_GUESSED, this));
|
||||
for(Player players : getPlayers()) {
|
||||
players.sendMessage(getPlugin().getChatManager().getPrefix() + getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Theme-Guessed"));
|
||||
getPlugin().getRewardsHandler().performReward(players, Reward.RewardType.GTB_ALL_GUESSED, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuessTheBuildScoreboardManager getScoreboardManager() {
|
||||
return scoreboardManager;
|
||||
}
|
||||
|
||||
public boolean isThemeSet() {
|
||||
return themeSet;
|
||||
}
|
||||
|
||||
public void setThemeSet(boolean themeSet) {
|
||||
this.themeSet = themeSet;
|
||||
}
|
||||
|
||||
public Map<Player, Integer> getPlayersPoints() {
|
||||
return playersPoints;
|
||||
}
|
||||
}
|
||||
@@ -1,703 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena.impl;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.api.StatsStorage;
|
||||
import plugily.projects.buildbattle.api.event.game.BBGameEndEvent;
|
||||
import plugily.projects.buildbattle.api.event.game.BBGameStartEvent;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.arena.options.ArenaOption;
|
||||
import plugily.projects.buildbattle.handlers.HolidayManager;
|
||||
import plugily.projects.buildbattle.handlers.language.LanguageManager;
|
||||
import plugily.projects.buildbattle.handlers.reward.Reward;
|
||||
import plugily.projects.buildbattle.menus.options.registry.particles.ParticleRefreshScheduler;
|
||||
import plugily.projects.buildbattle.menus.themevoter.VoteMenu;
|
||||
import plugily.projects.buildbattle.menus.themevoter.VotePoll;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
import plugily.projects.buildbattle.utils.MessageUtils;
|
||||
import plugily.projects.commonsbox.minecraft.compat.VersionUtils;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.commonsbox.minecraft.misc.MiscUtils;
|
||||
import plugily.projects.commonsbox.minecraft.serialization.InventorySerializer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class SoloArena extends BaseArena {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
private final Map<Integer, List<Player>> topList = new HashMap<>();
|
||||
private final Queue<Plot> queue = new LinkedList<>();
|
||||
private boolean receivedVoteItems;
|
||||
private Plot votingPlot;
|
||||
private boolean voteTime;
|
||||
private boolean themeVoteTime = true;
|
||||
private boolean themeTimerSet = false;
|
||||
private VoteMenu voteMenu;
|
||||
|
||||
public SoloArena(String id, Main plugin) {
|
||||
super(id, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiates voting poll
|
||||
*/
|
||||
public void initPoll() {
|
||||
voteMenu = new VoteMenu(this);
|
||||
voteMenu.resetPoll();
|
||||
}
|
||||
|
||||
public VotePoll getVotePoll() {
|
||||
return voteMenu.getVotePoll();
|
||||
}
|
||||
|
||||
public VoteMenu getVoteMenu() {
|
||||
return voteMenu;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is voting time in game?
|
||||
*
|
||||
* @return true = voting time, false = no
|
||||
*/
|
||||
public boolean isVoting() {
|
||||
return voteTime;
|
||||
}
|
||||
|
||||
public void setVoting(boolean voting) {
|
||||
voteTime = voting;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Queue<Plot> getQueue() {
|
||||
return queue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//idle task
|
||||
if(getArenaState() == ArenaState.WAITING_FOR_PLAYERS && getPlayers().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
updateBossBar();
|
||||
|
||||
switch(getArenaState()) {
|
||||
case WAITING_FOR_PLAYERS:
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
getPlugin().getServer().setWhitelist(false);
|
||||
}
|
||||
getPlotManager().resetPlotsGradually();
|
||||
|
||||
int minmPlayers = getMinimumPlayers();
|
||||
|
||||
if(getPlayers().size() < minmPlayers) {
|
||||
if(getTimer() <= 0) {
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.LOBBY, this));
|
||||
getPlugin().getChatManager().broadcast(this, getPlugin().getChatManager().colorMessage("In-Game.Messages.Lobby-Messages.Waiting-For-Players").replace("%MINPLAYERS%", Integer.toString(minmPlayers)));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
getPlugin().getChatManager().broadcast(this, getPlugin().getChatManager().colorMessage("In-Game.Messages.Lobby-Messages.Enough-Players-To-Start"));
|
||||
setArenaState(ArenaState.STARTING);
|
||||
if(HolidayManager.getCurrentHoliday() != HolidayManager.HolidayType.NONE) {
|
||||
initPoll();
|
||||
}
|
||||
Bukkit.getPluginManager().callEvent(new BBGameStartEvent(this));
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.LOBBY, this));
|
||||
}
|
||||
setTimer(getTimer() - 1);
|
||||
break;
|
||||
case STARTING:
|
||||
int lobbyTimer = getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.LOBBY, this);
|
||||
int timer = getTimer();
|
||||
float exp = (float) (timer / (double) lobbyTimer);
|
||||
|
||||
if(exp > 1f || exp < 0f) {
|
||||
exp = 1f;
|
||||
}
|
||||
|
||||
for(Player player : getPlayers()) {
|
||||
player.setExp(exp);
|
||||
player.setLevel(timer);
|
||||
}
|
||||
|
||||
int minPlayers = getMinimumPlayers();
|
||||
|
||||
if(getPlayers().size() < minPlayers && !isForceStart()) {
|
||||
getPlugin().getChatManager().broadcast(this, getPlugin().getChatManager().colorMessage("In-Game.Messages.Lobby-Messages.Waiting-For-Players").replace("%MINPLAYERS%", Integer.toString(minPlayers)));
|
||||
setArenaState(ArenaState.WAITING_FOR_PLAYERS);
|
||||
Bukkit.getPluginManager().callEvent(new BBGameStartEvent(this));
|
||||
setTimer(lobbyTimer);
|
||||
for(Player player : getPlayers()) {
|
||||
player.setExp(1);
|
||||
player.setLevel(0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(getTimer() == 0 || isForceStart()) {
|
||||
particleRefreshSched = new ParticleRefreshScheduler(getPlugin());
|
||||
if(!getPlotManager().isPlotsCleared()) {
|
||||
getPlotManager().resetQueuedPlots();
|
||||
}
|
||||
setArenaState(ArenaState.IN_GAME);
|
||||
distributePlots();
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.THEME_VOTE, this));
|
||||
for(Player player : getPlayers()) {
|
||||
player.getInventory().clear();
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
player.getInventory().setItem(8, getPlugin().getOptionsRegistry().getMenuItem());
|
||||
//to prevent Multiverse changing gamemode bug
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> player.setGameMode(GameMode.CREATIVE), 40);
|
||||
getPlugin().getRewardsHandler().performReward(player, Reward.RewardType.START_GAME, -1);
|
||||
}
|
||||
}
|
||||
if(isForceStart()) {
|
||||
setForceStart(false);
|
||||
}
|
||||
setTimer(getTimer() - 1);
|
||||
break;
|
||||
case IN_GAME:
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
getPlugin().getServer().setWhitelist(getMaximumPlayers() <= getPlayers().size());
|
||||
}
|
||||
if(themeVoteTime) {
|
||||
if(!themeTimerSet) {
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.THEME_VOTE, this));
|
||||
setThemeTimerSet(true);
|
||||
for(Player p : getPlayers()) {
|
||||
p.openInventory(voteMenu.getInventory());
|
||||
}
|
||||
}
|
||||
|
||||
getPlayers().forEach(voteMenu::updateInventory);
|
||||
|
||||
if(getTimer() == 0) {
|
||||
setThemeVoteTime(false);
|
||||
if(getVotePoll() != null) {
|
||||
setTheme(getVotePoll().getVotedTheme());
|
||||
}
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.BUILD, this));
|
||||
String message = getPlugin().getChatManager().colorMessage("In-Game.Messages.Lobby-Messages.Game-Started");
|
||||
for(Player p : getPlayers()) {
|
||||
p.closeInventory();
|
||||
Plot plot = getPlotManager().getPlot(p);
|
||||
if(plot != null) {
|
||||
p.teleport(plot.getTeleportLocation());
|
||||
}
|
||||
|
||||
p.sendMessage(getPlugin().getChatManager().getPrefix() + message);
|
||||
}
|
||||
} else {
|
||||
setTimer(getTimer() - 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(!enoughPlayersToContinue()) {
|
||||
getPlugin().getChatManager().broadcast(this, getPlugin().getChatManager().colorMessage("In-Game.Messages.Game-End-Messages.Only-You-Playing"));
|
||||
setArenaState(ArenaState.ENDING);
|
||||
Bukkit.getPluginManager().callEvent(new BBGameEndEvent(this));
|
||||
setTimer(10);
|
||||
}
|
||||
|
||||
int timerco = getTimer();
|
||||
|
||||
if((timerco == (4 * 60) || timerco == (3 * 60) || timerco == (5 * 60) || timerco == 30 || timerco == (2 * 60) || timerco == 60 || timerco == 15) && !voteTime) {
|
||||
sendBuildLeftTimeMessage();
|
||||
}
|
||||
|
||||
if(timerco != 0 && !receivedVoteItems) {
|
||||
if(getOption(ArenaOption.IN_PLOT_CHECKER) == 1) {
|
||||
setOptionValue(ArenaOption.IN_PLOT_CHECKER, 0);
|
||||
for(Player player : getPlayers()) {
|
||||
User user = getPlugin().getUserManager().getUser(player);
|
||||
Plot buildPlot = user.getCurrentPlot();
|
||||
if(buildPlot != null && buildPlot.getCuboid() != null && !buildPlot.getCuboid().isInWithMarge(player.getLocation(), 5)) {
|
||||
player.teleport(buildPlot.getTeleportLocation());
|
||||
player.sendMessage(getPlugin().getChatManager().getPrefix() + getPlugin().getChatManager().colorMessage("In-Game.Messages.Cant-Fly-Outside-Plot"));
|
||||
}
|
||||
}
|
||||
}
|
||||
addOptionValue(ArenaOption.IN_PLOT_CHECKER, 1);
|
||||
} else if(timerco == 0 && !receivedVoteItems) {
|
||||
for(Player player : getPlayers()) {
|
||||
User user = getPlugin().getUserManager().getUser(player);
|
||||
|
||||
if(user.isSpectator()) continue;
|
||||
if(!queue.contains(user.getCurrentPlot())) {
|
||||
queue.add(user.getCurrentPlot());
|
||||
}
|
||||
player.getInventory().clear();
|
||||
getPlugin().getVoteItems().giveVoteItems(player);
|
||||
user.setStat(StatsStorage.StatisticType.LOCAL_POINTS, 3);
|
||||
}
|
||||
receivedVoteItems = true;
|
||||
}
|
||||
if(getTimer() == 0 && receivedVoteItems) {
|
||||
setVoting(true);
|
||||
if(!queue.isEmpty()) {
|
||||
voteForNextPlot();
|
||||
} else {
|
||||
if(votingPlot != null) {
|
||||
if(votingPlot.getPoints() == 0) {
|
||||
String message = getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Voted-For-Player-Plot").replace("%PLAYER%", votingPlot.getFormattedMembers());
|
||||
for(Player player : getPlayers()) {
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.ANNOUNCE_PLOTOWNER_LATER)) {
|
||||
for(Player p : getPlayers()) {
|
||||
String owner = getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Plot-Owner-Title");
|
||||
owner = formatWinners(votingPlot, owner);
|
||||
VersionUtils.sendTitle(p, owner, 5, 40, 5);
|
||||
p.sendMessage(getPlugin().getChatManager().getPrefix() + message);
|
||||
}
|
||||
}
|
||||
User user = getPlugin().getUserManager().getUser(player);
|
||||
int points = user.getStat(StatsStorage.StatisticType.LOCAL_POINTS);
|
||||
//no vote made, in this case make it a good vote
|
||||
if(points == 0) {
|
||||
points = 3;
|
||||
}
|
||||
if(!votingPlot.getMembers().contains(player))
|
||||
votingPlot.setPoints(votingPlot.getPoints() + points);
|
||||
user.setStat(StatsStorage.StatisticType.LOCAL_POINTS, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
calculateResults();
|
||||
Plot winnerPlot = null;
|
||||
for(List<Player> potentialWinners : topList.values()) {
|
||||
if(!potentialWinners.isEmpty()) {
|
||||
winnerPlot = getPlotManager().getPlot(potentialWinners.get(0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(winnerPlot == null) {
|
||||
getPlugin().getLogger().log(Level.SEVERE, "Fatal error in getting winner plot in game! No plot contain any online player!");
|
||||
setArenaState(ArenaState.ENDING);
|
||||
Bukkit.getPluginManager().callEvent(new BBGameEndEvent(this));
|
||||
setTimer(10);
|
||||
break;
|
||||
}
|
||||
announceResults();
|
||||
|
||||
Location winnerLocation = winnerPlot.getTeleportLocation();
|
||||
|
||||
for(Player player : getAllArenaPlayers()) {
|
||||
player.teleport(winnerLocation);
|
||||
String winner = getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Winner-Title");
|
||||
winner = formatWinners(winnerPlot, winner);
|
||||
VersionUtils.sendTitle(player, winner, 5, 35, 5);
|
||||
}
|
||||
setArenaState(ArenaState.ENDING);
|
||||
Bukkit.getPluginManager().callEvent(new BBGameEndEvent(this));
|
||||
setTimer(10);
|
||||
}
|
||||
}
|
||||
setTimer(getTimer() - 1);
|
||||
break;
|
||||
case ENDING:
|
||||
getScoreboardManager().stopAllScoreboards();
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
getPlugin().getServer().setWhitelist(false);
|
||||
}
|
||||
setVoting(false);
|
||||
setThemeTimerSet(false);
|
||||
if(getPlugin().getConfig().getBoolean("Firework-When-Game-Ends", true)) {
|
||||
for(Player player : getAllArenaPlayers()) {
|
||||
MiscUtils.spawnRandomFirework(player.getLocation());
|
||||
}
|
||||
}
|
||||
if(getTimer() <= 0) {
|
||||
for(Player player : getAllArenaPlayers()) {
|
||||
User user = plugin.getUserManager().getUser(player);
|
||||
user.removeScoreboard(this);
|
||||
user.setSpectator(false);
|
||||
teleportToEndLocation(player);
|
||||
doBarAction(BarAction.REMOVE, player);
|
||||
player.getInventory().clear();
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setFlying(false);
|
||||
player.setAllowFlight(false);
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.sendMessage(getPlugin().getChatManager().getPrefix() + getPlugin().getChatManager().colorMessage("Commands.Teleported-To-The-Lobby"));
|
||||
user.addStat(StatsStorage.StatisticType.GAMES_PLAYED, 1);
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.INVENTORY_MANAGER_ENABLED)) {
|
||||
InventorySerializer.loadInventory(getPlugin(), player);
|
||||
}
|
||||
//plot might be already deleted by team mate in TEAM game mode
|
||||
Plot plot = getPlotManager().getPlot(player);
|
||||
if(plot != null) {
|
||||
plot.fullyResetPlot();
|
||||
}
|
||||
}
|
||||
giveRewards();
|
||||
clearPlayers();
|
||||
if(particleRefreshSched != null) {
|
||||
particleRefreshSched.task.cancel();
|
||||
}
|
||||
setArenaState(ArenaState.RESTARTING);
|
||||
}
|
||||
setTimer(getTimer() - 1);
|
||||
break;
|
||||
case RESTARTING:
|
||||
setTimer(14);
|
||||
setVoting(false);
|
||||
receivedVoteItems = false;
|
||||
setOptionValue(ArenaOption.IN_PLOT_CHECKER, 0);
|
||||
setArenaState(ArenaState.WAITING_FOR_PLAYERS);
|
||||
topList.clear();
|
||||
//clear plot members
|
||||
for(Plot plot : getPlotManager().getPlots()) {
|
||||
plot.getMembers().clear();
|
||||
}
|
||||
setThemeTimerSet(false);
|
||||
setThemeVoteTime(true);
|
||||
voteMenu.resetPoll();
|
||||
for(Player spectator : new ArrayList<>(getSpectators())) {
|
||||
ArenaManager.leaveAttempt(spectator, this);
|
||||
}
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
if(ConfigUtils.getConfig(getPlugin(), "bungee").getBoolean("Shutdown-When-Game-Ends")) {
|
||||
getPlugin().getServer().shutdown();
|
||||
}
|
||||
ArenaRegistry.shuffleBungeeArena();
|
||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||
ArenaManager.joinAttempt(player, ArenaRegistry.getArenas().get(ArenaRegistry.getBungeeArena()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBossBar() {
|
||||
if(getGameBar() == null) {
|
||||
return;
|
||||
}
|
||||
switch(getArenaState()) {
|
||||
case WAITING_FOR_PLAYERS:
|
||||
getGameBar().setTitle(getPlugin().getChatManager().colorMessage("Bossbar.Waiting-For-Players"));
|
||||
break;
|
||||
case STARTING:
|
||||
getGameBar().setTitle(getPlugin().getChatManager().colorMessage("Bossbar.Starting-In").replace("%time%", Integer.toString(getTimer())));
|
||||
break;
|
||||
case IN_GAME:
|
||||
getGameBar().setTitle(getPlugin().getChatManager().colorMessage(voteTime ? "Bossbar.Vote-Time-Left" : "Bossbar.Time-Left")
|
||||
.replace("%time%", Integer.toString(getTimer())));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distributePlots() {
|
||||
//clear plots before distribution to avoid problems
|
||||
for(Plot plot : getPlotManager().getPlots()) {
|
||||
plot.getMembers().clear();
|
||||
}
|
||||
List<Player> players = new ArrayList<>(getPlayers());
|
||||
for(Plot plot : getPlotManager().getPlots()) {
|
||||
if(players.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
Player first = players.get(0);
|
||||
User user = plugin.getUserManager().getUser(first);
|
||||
if(user.isSpectator()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
plot.addMember(first, this, true);
|
||||
user.setCurrentPlot(plot);
|
||||
|
||||
players.remove(0);
|
||||
}
|
||||
if(!players.isEmpty()) {
|
||||
MessageUtils.errorOccurred();
|
||||
Debugger.sendConsoleMsg("&c[Build Battle] [PLOT WARNING] Not enough plots in arena " + getID() + "! Lacks " + players.size() + " plots");
|
||||
Debugger.sendConsoleMsg("&c[PLOT WARNING] Required " + getPlayers().size() + " but have " + getPlotManager().getPlots().size());
|
||||
Debugger.sendConsoleMsg("&c[PLOT WARNING] Instance was stopped!");
|
||||
ArenaManager.stopGame(false, this);
|
||||
}
|
||||
getPlotManager().teleportToPlots();
|
||||
}
|
||||
|
||||
public void voteRoutine() {
|
||||
if(!queue.isEmpty()) {
|
||||
setTimer(getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.PLOT_VOTE, this));
|
||||
Plot plot = queue.poll();
|
||||
while(plot == null && !queue.isEmpty()) {
|
||||
// should not happen anymore... to be removed
|
||||
System.out.print("A PLAYER HAS NO PLOT!");
|
||||
plot = queue.poll();
|
||||
}
|
||||
if(queue.isEmpty() && plot == null) {
|
||||
votingPlot = null;
|
||||
return;
|
||||
}
|
||||
|
||||
// getPlotManager().teleportAllToPlot(plotManager.getPlot(player.getUniqueId()));
|
||||
votingPlot = plot;
|
||||
String message = getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Voting-For-Player-Plot").replace("%PLAYER%", plot.getFormattedMembers());
|
||||
|
||||
Location teleportLoc = votingPlot.getTeleportLocation();
|
||||
|
||||
for(Player p : getPlayers()) {
|
||||
p.teleport(teleportLoc);
|
||||
p.setPlayerWeather(votingPlot.getWeatherType());
|
||||
p.setPlayerTime(Plot.Time.format(votingPlot.getTime(), p.getWorld().getTime()), false);
|
||||
if(getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.ANNOUNCE_PLOTOWNER_LATER)) {
|
||||
p.sendMessage(getPlugin().getChatManager().getPrefix() + getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Vote-For-Next-Plot"));
|
||||
} else {
|
||||
String owner = getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Plot-Owner-Title");
|
||||
owner = formatWinners(votingPlot, owner);
|
||||
VersionUtils.sendTitle(p, owner, 5, 40, 5);
|
||||
p.sendMessage(getPlugin().getChatManager().getPrefix() + message);
|
||||
}
|
||||
}
|
||||
|
||||
for(Player spectator : getSpectators()) {
|
||||
spectator.teleport(teleportLoc);
|
||||
spectator.setPlayerWeather(votingPlot.getWeatherType());
|
||||
spectator.setPlayerTime(Plot.Time.format(votingPlot.getTime(), spectator.getWorld().getTime()), false);
|
||||
String owner = getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Plot-Owner-Title");
|
||||
owner = formatWinners(votingPlot, owner);
|
||||
VersionUtils.sendTitle(spectator, owner, 5, 40, 5);
|
||||
spectator.sendMessage(getPlugin().getChatManager().getPrefix() + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String formatWinners(Plot plot, String string) {
|
||||
return string.replace("%player%", plot.getFormattedMembers());
|
||||
}
|
||||
|
||||
public void voteForNextPlot() {
|
||||
if(votingPlot != null) {
|
||||
if(votingPlot.getPoints() == 0) {
|
||||
for(Player player : getPlayers()) {
|
||||
User user = getPlugin().getUserManager().getUser(player);
|
||||
if(!votingPlot.getMembers().contains(player))
|
||||
votingPlot.setPoints(votingPlot.getPoints() + user.getStat(StatsStorage.StatisticType.LOCAL_POINTS));
|
||||
user.setStat(StatsStorage.StatisticType.LOCAL_POINTS, 3);
|
||||
if(!player.getInventory().contains(plugin.getVoteItems().getReportItem())) {
|
||||
player.getInventory().setItem(plugin.getVoteItems().getReportVoteItem().getSlot(), plugin.getVoteItems().getReportVoteItem().getItemStack());
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!votingPlot.getMembers().isEmpty() && getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.ANNOUNCE_PLOTOWNER_LATER)) {
|
||||
String message = getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Voted-For-Player-Plot").replace("%PLAYER%", votingPlot.getFormattedMembers());
|
||||
for(Player p : getPlayers()) {
|
||||
String owner = getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Plot-Owner-Title");
|
||||
owner = formatWinners(votingPlot, owner);
|
||||
VersionUtils.sendTitle(p, owner, 5, 40, 5);
|
||||
p.sendMessage(getPlugin().getChatManager().getPrefix() + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
voteRoutine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plot where players are voting currently
|
||||
*
|
||||
* @return Plot object where players are voting
|
||||
*/
|
||||
public Plot getVotingPlot() {
|
||||
return votingPlot;
|
||||
}
|
||||
|
||||
private void announceResults() {
|
||||
List<String> messages = LanguageManager.getLanguageList("In-Game.Messages.Voting-Messages.Summary");
|
||||
List<String> formattedSummary = new ArrayList<>();
|
||||
for(String summary : messages) {
|
||||
String message = getPlugin().getChatManager().colorRawMessage(summary);
|
||||
for(int i = 1; i < 4; i++) {
|
||||
String access = "One";
|
||||
switch(i) {
|
||||
case 2:
|
||||
access = "Two";
|
||||
break;
|
||||
case 3:
|
||||
access = "Three";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
String accessLower = access.toLowerCase();
|
||||
|
||||
if(message.contains("%place_" + accessLower + "%")) {
|
||||
List<Player> list = topList.get(i);
|
||||
|
||||
if(list != null && !list.isEmpty()) {
|
||||
Plot plot = getPlotManager().getPlot(list.get(0));
|
||||
message = StringUtils.replace(message, "%place_" + accessLower + "%", getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Place-" + access)
|
||||
.replace("%player%", formatWinners(list))
|
||||
.replace("%number%", plot == null ? "" : Integer.toString(plot.getPoints())));
|
||||
} else {
|
||||
message = StringUtils.replace(message, "%place_" + accessLower + "%", getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Place-" + access)
|
||||
.replace("%player%", "None")
|
||||
.replace("%number%", "none"));
|
||||
}
|
||||
}
|
||||
}
|
||||
formattedSummary.add(message);
|
||||
}
|
||||
getAllArenaPlayers().forEach(player -> formattedSummary.forEach(msg -> MiscUtils.sendCenteredMessage(player, msg)));
|
||||
for(Map.Entry<Integer, List<Player>> map : topList.entrySet()) {
|
||||
for(Player p : map.getValue()) {
|
||||
if(map.getKey() > 3) {
|
||||
p.sendMessage(getPlugin().getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Summary-Other-Place").replace("%number%", Integer.toString(map.getKey())));
|
||||
}
|
||||
User user = getPlugin().getUserManager().getUser(p);
|
||||
Plot plot = getPlotManager().getPlot(p);
|
||||
if(plot != null) {
|
||||
if(plot.getPoints() > user.getStat(StatsStorage.StatisticType.HIGHEST_POINTS)) {
|
||||
user.setStat(StatsStorage.StatisticType.HIGHEST_POINTS, plot.getPoints());
|
||||
}
|
||||
user.addStat(StatsStorage.StatisticType.TOTAL_POINTS_EARNED, plot.getPoints());
|
||||
}
|
||||
if(map.getKey() != 1) {
|
||||
user.addStat(StatsStorage.StatisticType.LOSES, 1);
|
||||
continue;
|
||||
}
|
||||
user.addStat(StatsStorage.StatisticType.WINS, 1);
|
||||
if(plot != null && plot.getPoints() > user.getStat(StatsStorage.StatisticType.HIGHEST_WIN)) {
|
||||
user.setStat(StatsStorage.StatisticType.HIGHEST_WIN, plot.getPoints());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String formatWinners(final List<Player> winners) {
|
||||
List<Player> players = new ArrayList<>(winners);
|
||||
StringBuilder builder = new StringBuilder(players.get(0).getName());
|
||||
if(players.size() == 1) {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
players.remove(0);
|
||||
|
||||
for(Player p : players) {
|
||||
builder.append(" & ").append(p.getName());
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private void calculateResults() {
|
||||
for(int b = 1; b <= getPlayers().size(); b++) {
|
||||
topList.put(b, new ArrayList<>());
|
||||
}
|
||||
for(Plot buildPlot : getPlotManager().getPlots()) {
|
||||
long i = buildPlot.getPoints();
|
||||
|
||||
for(Map.Entry<Integer, List<Player>> map : new HashMap<>(topList).entrySet()) {
|
||||
Player first = map.getValue().isEmpty() ? null : map.getValue().get(0);
|
||||
|
||||
Plot plot = getPlotManager().getPlot(first);
|
||||
if(plot == null) {
|
||||
topList.put(map.getKey(), buildPlot.getMembers());
|
||||
break;
|
||||
}
|
||||
if(i > plot.getPoints()) {
|
||||
moveScore(map.getKey(), buildPlot.getMembers());
|
||||
break;
|
||||
}
|
||||
if(i == plot.getPoints()) {
|
||||
List<Player> winners = topList.getOrDefault(map.getKey(), new ArrayList<>());
|
||||
winners.addAll(buildPlot.getMembers());
|
||||
topList.put(map.getKey(), winners);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void moveScore(int pos, List<Player> owners) {
|
||||
List<Player> after = topList.getOrDefault(pos, new ArrayList<>());
|
||||
topList.put(pos, owners);
|
||||
if(pos <= getPlayers().size() && !after.isEmpty()) {
|
||||
moveScore(pos + 1, after);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean enoughPlayersToContinue() {
|
||||
return getPlayers().size() >= 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveRewards() {
|
||||
for(int i = 1; i <= topList.size(); i++) {
|
||||
List<Player> list = topList.get(i);
|
||||
if(list != null) {
|
||||
for(Player player : list) {
|
||||
getPlugin().getRewardsHandler().performReward(player, Reward.RewardType.PLACE, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
getPlugin().getRewardsHandler().performReward(this, Reward.RewardType.END_GAME);
|
||||
}
|
||||
|
||||
public boolean isThemeVoteTime() {
|
||||
return themeVoteTime;
|
||||
}
|
||||
|
||||
public void setThemeVoteTime(boolean themeVoteTime) {
|
||||
this.themeVoteTime = themeVoteTime;
|
||||
}
|
||||
|
||||
public boolean isThemeTimerSet() {
|
||||
return themeTimerSet;
|
||||
}
|
||||
|
||||
public void setThemeTimerSet(boolean themeTimerSet) {
|
||||
this.themeTimerSet = themeTimerSet;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena.impl;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.arena.options.ArenaOption;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class TeamArena extends SoloArena {
|
||||
|
||||
public TeamArena(String id, Main plugin) {
|
||||
super(id, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMinimumPlayers(int amount) {
|
||||
if(amount <= getPlotSize()) {
|
||||
Debugger.debug(Debugger.Level.WARN, "Minimum players amount for TEAM game mode arena cannot be less than 3! Setting amount to 3!");
|
||||
setOptionValue(ArenaOption.MINIMUM_PLAYERS, 3);
|
||||
return;
|
||||
}
|
||||
super.setMinimumPlayers(amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void distributePlots() {
|
||||
for(Player player : getPlayers()) {
|
||||
// get base with min players
|
||||
Plot minPlayers = getPlotManager().getPlots().stream().min(Comparator.comparing(Plot::getMembersSize)).get();
|
||||
// add player to min base if he got no base
|
||||
Plot playerPlot = getPlotManager().getPlot(player);
|
||||
if(playerPlot == null) {
|
||||
minPlayers.addMember(player, this, true);
|
||||
}
|
||||
// fallback
|
||||
if(playerPlot == null) {
|
||||
Plot firstPlot = getPlotManager().getPlots().get(0);
|
||||
firstPlot.addMember(player, this, true);
|
||||
}
|
||||
}
|
||||
//check if not only one plot got players
|
||||
Plot maxPlayers = getPlotManager().getPlots().stream().max(Comparator.comparing(Plot::getMembersSize)).get();
|
||||
Plot minPlayers = getPlotManager().getPlots().stream().min(Comparator.comparing(Plot::getMembersSize)).get();
|
||||
if(maxPlayers.getMembersSize() == getPlayers().size()) {
|
||||
for(int i = 0; i < maxPlayers.getMembersSize() / 2; i++) {
|
||||
Player move = maxPlayers.getMembers().get(i);
|
||||
minPlayers.addMember(move, this, true);
|
||||
maxPlayers.removeMember(move);
|
||||
}
|
||||
}
|
||||
getPlotManager().teleportToPlots();
|
||||
/*if (!players.isEmpty()) {
|
||||
MessageUtils.errorOccurred();
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Build Battle] [PLOT WARNING] Not enough plots in arena " + getID() + "!");
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[PLOT WARNING] Required " + Math.ceil((double) getPlayers().size() / 2) + " but have " + getPlotManager().getPlots().size());
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[PLOT WARNING] Instance was stopped!");
|
||||
ArenaManager.stopGame(false, this);
|
||||
}*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enoughPlayersToContinue() {
|
||||
int size = getPlayers().size();
|
||||
|
||||
if(size > getPlotSize()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(size == getPlotSize()) {
|
||||
return !getPlotManager().getPlot(getPlayers().get(0)).getMembers().containsAll(getPlayers());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
-130
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena.managers;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.tigerhix.lib.scoreboard.common.EntryBuilder;
|
||||
import me.tigerhix.lib.scoreboard.type.Entry;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.impl.GuessTheBuildArena;
|
||||
import plugily.projects.buildbattle.handlers.language.LanguageManager;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class GuessTheBuildScoreboardManager extends ScoreboardManager {
|
||||
|
||||
private final Map<String, List<String>> scoreboardContents = new HashMap<>();
|
||||
private final GuessTheBuildArena arena;
|
||||
|
||||
public GuessTheBuildScoreboardManager(BaseArena arena) {
|
||||
super(arena);
|
||||
this.arena = (GuessTheBuildArena) arena;
|
||||
for(ArenaState state : ArenaState.values()) {
|
||||
//not registering RESTARTING state and registering IN_GAME and ENDING later
|
||||
if(state == ArenaState.RESTARTING || state == ArenaState.IN_GAME || state == ArenaState.ENDING) {
|
||||
continue;
|
||||
}
|
||||
//todo migrator
|
||||
List<String> lines = LanguageManager.getLanguageList("Scoreboard.Content." + state.getFormattedName());
|
||||
scoreboardContents.put(state.getFormattedName(), lines);
|
||||
}
|
||||
List<String> playing = LanguageManager.getLanguageList("Scoreboard.Content.Playing-States." + BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix());
|
||||
List<String> ending = LanguageManager.getLanguageList("Scoreboard.Content.Ending-States." + BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix());
|
||||
//todo locale
|
||||
scoreboardContents.put(ArenaState.IN_GAME.getFormattedName() + "_" + BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix(), playing);
|
||||
scoreboardContents.put(ArenaState.ENDING.getFormattedName() + "_" + BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix(), ending);
|
||||
}
|
||||
|
||||
//todo maybe not needed and private
|
||||
@Override
|
||||
public List<Entry> formatScoreboard(User user) {
|
||||
EntryBuilder builder = new EntryBuilder();
|
||||
List<String> lines = scoreboardContents.get(arena.getArenaState().getFormattedName());
|
||||
if(arena.getArenaState() == ArenaState.IN_GAME || arena.getArenaState() == ArenaState.ENDING) {
|
||||
lines = scoreboardContents.get(arena.getArenaState().getFormattedName() + "_" + BaseArena.ArenaType.GUESS_THE_BUILD.getPrefix());
|
||||
}
|
||||
if (lines == null) {
|
||||
return builder.build();
|
||||
}
|
||||
for(String line : lines) {
|
||||
builder.next(formatScoreboardLine(line, user));
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatScoreboardLine(String string, User user) {
|
||||
Player player = user.getPlayer();
|
||||
String returnString = string;
|
||||
returnString = StringUtils.replace(returnString, "%PLAYERS%", Integer.toString(arena.getPlayers().size()));
|
||||
returnString = StringUtils.replace(returnString, "%PLAYER%", player.getName());
|
||||
if(arena.isThemeSet()) {
|
||||
returnString = StringUtils.replace(returnString, "%CURRENT_TIMER%", getPlugin().getChatManager().colorMessage("Scoreboard.GTB-Current-Timer.Build-Time"));
|
||||
} else {
|
||||
returnString = StringUtils.replace(returnString, "%CURRENT_TIMER%", getPlugin().getChatManager().colorMessage("Scoreboard.GTB-Current-Timer.Starts-In"));
|
||||
}
|
||||
if(arena.getCurrentBuilder() != null) {
|
||||
if((arena.getCurrentBuilder().equals(player) && arena.getCurrentTheme() != null) || arena.getWhoGuessed().contains(player)) {
|
||||
returnString = StringUtils.replace(returnString, "%THEME%", arena.getCurrentTheme().getTheme());
|
||||
} else {
|
||||
returnString = StringUtils.replace(returnString, "%THEME%", getPlugin().getChatManager().colorMessage("Scoreboard.Theme-Unknown"));
|
||||
}
|
||||
returnString = StringUtils.replace(returnString, "%BUILDER%", arena.getCurrentBuilder().getName());
|
||||
} else {
|
||||
returnString = StringUtils.replace(returnString, "%THEME%", getPlugin().getChatManager().colorMessage("Scoreboard.Theme-Unknown"));
|
||||
returnString = StringUtils.replace(returnString, "%BUILDER%", getPlugin().getChatManager().colorMessage("Scoreboard.Theme-Unknown"));
|
||||
}
|
||||
if(arena.getArenaState() == ArenaState.IN_GAME || arena.getArenaState() == ArenaState.ENDING) {
|
||||
int max = arena.getArenaState() == ArenaState.IN_GAME ? 3 : 10;
|
||||
List<Map.Entry<Player, Integer>> list = new ArrayList<>(arena.getPlayersPoints().entrySet());
|
||||
int size = list.size();
|
||||
for(int i = 0; i <= max; i++) {
|
||||
if(size - 1 < i) {
|
||||
returnString = StringUtils.replace(returnString, "%" + (i + 1) + "%", "None");
|
||||
returnString = StringUtils.replace(returnString, "%" + (i + 1) + "_PTS%", "0");
|
||||
continue;
|
||||
}
|
||||
Map.Entry<Player, Integer> entry = list.get(i);
|
||||
returnString = StringUtils.replace(returnString, "%" + (i + 1) + "%", entry.getKey().getName());
|
||||
returnString = StringUtils.replace(returnString, "%" + (i + 1) + "_PTS%", String.valueOf(entry.getValue()));
|
||||
}
|
||||
}
|
||||
returnString = replaceValues(returnString);
|
||||
if(getPlugin().getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
returnString = PlaceholderAPI.setPlaceholders(player, returnString);
|
||||
}
|
||||
returnString = getPlugin().getChatManager().colorRawMessage(returnString);
|
||||
return returnString;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena.managers;
|
||||
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.minigamesbox.classic.arena.managers.PluginMapRestorerManager;
|
||||
|
||||
public class MapRestorerManager extends PluginMapRestorerManager {
|
||||
|
||||
public final BaseArena arena;
|
||||
|
||||
public MapRestorerManager(BaseArena arena) {
|
||||
super(arena);
|
||||
this.arena = arena;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fullyRestoreArena() {
|
||||
arena.cleanUpArena();
|
||||
clearPlots();
|
||||
cancelParticleRefresh();
|
||||
arena.setArenaOption("IN_PLOT_CHECKER", 0);
|
||||
arena.setArenaInGameState(BaseArena.ArenaInGameState.NONE);
|
||||
super.fullyRestoreArena();
|
||||
}
|
||||
|
||||
private void clearPlots() {
|
||||
for(Plot plot : arena.getPlotManager().getPlots()) {
|
||||
plot.fullyResetPlot();
|
||||
plot.getMembers().clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void cancelParticleRefresh() {
|
||||
if(arena.getParticleRefreshScheduler() != null) {
|
||||
arena.getParticleRefreshScheduler().cancelTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,174 +20,74 @@
|
||||
|
||||
package plugily.projects.buildbattle.arena.managers;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.tigerhix.lib.scoreboard.ScoreboardLib;
|
||||
import me.tigerhix.lib.scoreboard.common.EntryBuilder;
|
||||
import me.tigerhix.lib.scoreboard.type.Entry;
|
||||
import me.tigerhix.lib.scoreboard.type.Scoreboard;
|
||||
import me.tigerhix.lib.scoreboard.type.ScoreboardHandler;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.impl.SoloArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.handlers.language.LanguageManager;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
import plugily.projects.commonsbox.string.StringFormatUtils;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.GuessArena;
|
||||
import plugily.projects.minigamesbox.api.arena.IPluginArena;
|
||||
import plugily.projects.minigamesbox.api.user.IUser;
|
||||
import plugily.projects.minigamesbox.classic.arena.PluginArena;
|
||||
import plugily.projects.minigamesbox.classic.arena.managers.PluginScoreboardManager;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.scoreboard.common.EntryBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.scoreboard.type.Entry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
* @author Tigerpanzer_02
|
||||
* <p>Created at 19.12.2021
|
||||
*/
|
||||
public class ScoreboardManager {
|
||||
public class ScoreboardManager extends PluginScoreboardManager {
|
||||
|
||||
private static final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
private final Map<String, List<String>> scoreboardContents = new HashMap<>();
|
||||
private final List<Scoreboard> scoreboards = new ArrayList<>();
|
||||
private final String boardTitle = plugin.getChatManager().colorMessage("Scoreboard.Title");
|
||||
private final BaseArena arena;
|
||||
private final PluginArena arena;
|
||||
|
||||
public ScoreboardManager(BaseArena arena) {
|
||||
public ScoreboardManager(PluginArena arena) {
|
||||
super(arena);
|
||||
this.arena = arena;
|
||||
for(ArenaState state : ArenaState.values()) {
|
||||
//not registering RESTARTING state and registering IN_GAME and ENDING later
|
||||
if(state == ArenaState.RESTARTING || state == ArenaState.IN_GAME || state == ArenaState.ENDING) {
|
||||
continue;
|
||||
}
|
||||
//todo migrator
|
||||
List<String> lines = LanguageManager.getLanguageList("Scoreboard.Content." + state.getFormattedName());
|
||||
scoreboardContents.put(state.getFormattedName(), lines);
|
||||
}
|
||||
for(BaseArena.ArenaType type : BaseArena.ArenaType.values()) {
|
||||
List<String> playing = LanguageManager.getLanguageList("Scoreboard.Content.Playing-States." + type.getPrefix());
|
||||
List<String> ending = LanguageManager.getLanguageList("Scoreboard.Content.Ending-States." + type.getPrefix());
|
||||
//todo locale
|
||||
scoreboardContents.put(ArenaState.IN_GAME.getFormattedName() + "_" + type.getPrefix(), playing);
|
||||
scoreboardContents.put(ArenaState.ENDING.getFormattedName() + "_" + type.getPrefix(), ending);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates arena scoreboard for target user
|
||||
*
|
||||
* @param user user that represents game player
|
||||
* @see User
|
||||
*/
|
||||
public void createScoreboard(User user) {
|
||||
Scoreboard scoreboard = ScoreboardLib.createScoreboard(user.getPlayer()).setHandler(new ScoreboardHandler() {
|
||||
@Override
|
||||
public String getTitle(Player player) {
|
||||
return boardTitle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Entry> getEntries(Player player) {
|
||||
return formatScoreboard(user);
|
||||
}
|
||||
});
|
||||
scoreboard.activate();
|
||||
scoreboards.add(scoreboard);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes scoreboard of user
|
||||
*
|
||||
* @param user user that represents game player
|
||||
* @see User
|
||||
*/
|
||||
public void removeScoreboard(User user) {
|
||||
for(Scoreboard board : scoreboards) {
|
||||
if(board.getHolder().equals(user.getPlayer())) {
|
||||
scoreboards.remove(board);
|
||||
board.deactivate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces all scoreboards to deactivate.
|
||||
*/
|
||||
public void stopAllScoreboards() {
|
||||
scoreboards.forEach(Scoreboard::deactivate);
|
||||
scoreboards.clear();
|
||||
}
|
||||
|
||||
public List<Entry> formatScoreboard(User user) {
|
||||
@Override
|
||||
public List<Entry> formatScoreboard(IUser user) {
|
||||
EntryBuilder builder = new EntryBuilder();
|
||||
List<String> lines = scoreboardContents.get(arena.getArenaState().getFormattedName());
|
||||
if(arena.getArenaState() == ArenaState.IN_GAME || arena.getArenaState() == ArenaState.ENDING) {
|
||||
lines = scoreboardContents.get(arena.getArenaState().getFormattedName() + "_" + arena.getArenaType().getPrefix());
|
||||
}
|
||||
if(lines != null) {
|
||||
for(String line : lines) {
|
||||
builder.next(formatScoreboardLine(line, user));
|
||||
List<String> lines;
|
||||
IPluginArena userArena = user.getArena();
|
||||
|
||||
switch (userArena.getArenaState()) {
|
||||
case FULL_GAME: {
|
||||
lines = userArena.getPlugin().getLanguageManager().getLanguageList("Scoreboard.Content.Starting");
|
||||
break;
|
||||
}
|
||||
case IN_GAME: {
|
||||
if(userArena instanceof GuessArena) {
|
||||
lines = userArena.getPlugin().getLanguageManager().getLanguageList("Scoreboard.Content." + userArena.getArenaState().getFormattedName() + ".Guess-The-Build" + (((GuessArena) userArena).getArenaInGameState() == BaseArena.ArenaInGameState.PLOT_VOTING ? "-Waiting" : ""));
|
||||
} else {
|
||||
if(userArena.getArenaOption("PLOT_MEMBER_SIZE") <= 1) {
|
||||
lines = userArena.getPlugin().getLanguageManager().getLanguageList("Scoreboard.Content." + userArena.getArenaState().getFormattedName() + ".Classic");
|
||||
} else {
|
||||
lines = userArena.getPlugin().getLanguageManager().getLanguageList("Scoreboard.Content." + userArena.getArenaState().getFormattedName() + ".Teams");
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ENDING: {
|
||||
if(userArena instanceof GuessArena) {
|
||||
lines = userArena.getPlugin().getLanguageManager().getLanguageList("Scoreboard.Content." + userArena.getArenaState().getFormattedName() + ".Guess-The-Build");
|
||||
} else {
|
||||
lines = userArena.getPlugin().getLanguageManager().getLanguageList("Scoreboard.Content." + userArena.getArenaState().getFormattedName() + ".Classic");
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
lines = userArena.getPlugin().getLanguageManager().getLanguageList("Scoreboard.Content." + userArena.getArenaState().getFormattedName());
|
||||
}
|
||||
}
|
||||
|
||||
Player player = user.getPlayer();
|
||||
|
||||
for(String line : lines) {
|
||||
builder.next(new MessageBuilder(line).player(player).arena(arena).build());
|
||||
}
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
public String formatScoreboardLine(String string, User user) {
|
||||
Player player = user.getPlayer();
|
||||
String returnString = string;
|
||||
returnString = StringUtils.replace(returnString, "%PLAYERS%", Integer.toString(arena.getPlayers().size()));
|
||||
returnString = StringUtils.replace(returnString, "%PLAYER%", player.getName());
|
||||
returnString = replaceValues(returnString);
|
||||
if(((SoloArena) arena).isThemeVoteTime()) {
|
||||
returnString = StringUtils.replace(returnString, "%THEME%", plugin.getChatManager().colorMessage("In-Game.No-Theme-Yet"));
|
||||
returnString = StringUtils.replace(returnString, "%TEAMMATE%", plugin.getChatManager().colorMessage("In-Game.Nobody"));
|
||||
} else {
|
||||
returnString = StringUtils.replace(returnString, "%THEME%", arena.getTheme());
|
||||
|
||||
Plot plot = arena.getPlotManager().getPlot(player);
|
||||
if(arena.getArenaType() == BaseArena.ArenaType.TEAM && plot != null) {
|
||||
if(plot.getMembers().size() > 1) {
|
||||
StringBuilder members = new StringBuilder();
|
||||
plot.getMembers().forEach(p -> members.append(p.getName()).append(" & "));
|
||||
members.deleteCharAt(members.length() - 2);
|
||||
returnString = StringUtils.replace(returnString, "%TEAMMATE%", members.toString());
|
||||
} else {
|
||||
returnString = StringUtils.replace(returnString, "%TEAMMATE%", plugin.getChatManager().colorMessage("In-Game.Nobody"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if(plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
returnString = PlaceholderAPI.setPlaceholders(player, returnString);
|
||||
}
|
||||
returnString = plugin.getChatManager().colorRawMessage(returnString);
|
||||
return returnString;
|
||||
}
|
||||
|
||||
public String replaceValues(String string) {
|
||||
String returnString = string;
|
||||
returnString = StringUtils.replace(returnString, "%MIN_PLAYERS%", Integer.toString(arena.getMinimumPlayers()));
|
||||
returnString = StringUtils.replace(returnString, "%MAX_PLAYERS%", Integer.toString(arena.getMaximumPlayers()));
|
||||
|
||||
int timer = arena.getTimer();
|
||||
|
||||
returnString = StringUtils.replace(returnString, "%TIMER%", Integer.toString(timer));
|
||||
returnString = StringUtils.replace(returnString, "%TIME_LEFT%", Long.toString(timer));
|
||||
returnString = StringUtils.replace(returnString, "%FORMATTED_TIME_LEFT%", StringFormatUtils.formatIntoMMSS(timer));
|
||||
returnString = StringUtils.replace(returnString, "%ARENA_ID%", arena.getID());
|
||||
returnString = StringUtils.replace(returnString, "%MAPNAME%", arena.getMapName());
|
||||
return returnString;
|
||||
}
|
||||
|
||||
public String getBoardTitle() {
|
||||
return boardTitle;
|
||||
}
|
||||
|
||||
public Main getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -31,15 +31,14 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.api.event.plot.BBPlotResetEvent;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.utils.Utils;
|
||||
import plugily.projects.commonsbox.minecraft.compat.ServerVersion;
|
||||
import plugily.projects.commonsbox.minecraft.compat.xseries.XMaterial;
|
||||
import plugily.projects.commonsbox.minecraft.dimensional.Cuboid;
|
||||
import plugily.projects.buildbattle.api.event.plot.PlotResetEvent;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.handlers.misc.ChunkManager;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.dimensional.Cuboid;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.ServerVersion;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.xseries.XMaterial;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -51,8 +50,6 @@ import java.util.Map;
|
||||
*/
|
||||
public class Plot {
|
||||
|
||||
private static final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
private final Map<Location, String> particles = new HashMap<>();
|
||||
private final XMaterial defaultFloor;
|
||||
|
||||
@@ -68,8 +65,8 @@ public class Plot {
|
||||
public Plot(BaseArena arena, Biome biome) {
|
||||
this.arena = arena;
|
||||
plotDefaultBiome = biome;
|
||||
defaultFloor = XMaterial.matchXMaterial(plugin.getConfig().getString("Default-Floor-Material-Name", "LOG")
|
||||
.toUpperCase()).orElse(XMaterial.OAK_LOG);
|
||||
defaultFloor = XMaterial.matchXMaterial(arena.getPlugin().getConfig().getString("Floor.Material", "LOG")
|
||||
.toUpperCase(java.util.Locale.ENGLISH)).orElse(XMaterial.OAK_LOG);
|
||||
}
|
||||
|
||||
public int getEntities() {
|
||||
@@ -99,7 +96,9 @@ public class Plot {
|
||||
}
|
||||
|
||||
public void setWeatherType(WeatherType weatherType) {
|
||||
this.weatherType = weatherType;
|
||||
if(weatherType != null) {
|
||||
this.weatherType = weatherType;
|
||||
}
|
||||
}
|
||||
|
||||
public Time getTime() {
|
||||
@@ -125,13 +124,13 @@ public class Plot {
|
||||
|
||||
@NotNull
|
||||
public String getFormattedMembers() {
|
||||
if(members.size() >= 1) {
|
||||
if(!members.isEmpty()) {
|
||||
StringBuilder member = new StringBuilder();
|
||||
members.forEach(player -> member.append(player.getName()).append(" & "));
|
||||
return member.substring(0, member.length() - 3);
|
||||
} else {
|
||||
return "PLAYER_NOT_FOUND";
|
||||
}
|
||||
|
||||
return "PLAYER_NOT_FOUND";
|
||||
}
|
||||
|
||||
public int getMembersSize() {
|
||||
@@ -144,12 +143,14 @@ public class Plot {
|
||||
}
|
||||
|
||||
if(members.contains(player)) {
|
||||
if(!silent) player.sendMessage(plugin.getChatManager().colorMessage("Plots.Team.Member"));
|
||||
if(!silent)
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_SELECTOR_MEMBER").asKey().arena(arena).player(player).sendPlayer();
|
||||
return false;
|
||||
}
|
||||
|
||||
if(members.size() >= playerArena.getPlotSize()) {
|
||||
if(!silent) player.sendMessage(plugin.getChatManager().colorMessage("Plots.Team.Full"));
|
||||
if(members.size() >= arena.getArenaOption("PLOT_MEMBER_SIZE")) {
|
||||
if(!silent)
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_SELECTOR_FULL").asKey().prefix().arena(arena).player(player).sendPlayer();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -158,7 +159,6 @@ public class Plot {
|
||||
plot.removeMember(player);
|
||||
}
|
||||
members.add(player);
|
||||
plugin.getUserManager().getUser(player).setCurrentPlot(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -168,12 +168,7 @@ public class Plot {
|
||||
|
||||
public void fullyResetPlot() {
|
||||
resetPlot();
|
||||
|
||||
for(Player p : members) {
|
||||
plugin.getUserManager().getUser(p).setCurrentPlot(null);
|
||||
}
|
||||
|
||||
setPoints(0);
|
||||
points = 0;
|
||||
members.clear();
|
||||
particles.clear();
|
||||
}
|
||||
@@ -200,11 +195,12 @@ public class Plot {
|
||||
World centerWorld = cuboid.getCenter().getWorld();
|
||||
|
||||
if(centerWorld != null) {
|
||||
boolean isCitizensEnabled = arena.getPlugin().getServer().getPluginManager().isPluginEnabled("Citizens");
|
||||
|
||||
for(Entity entity : centerWorld.getEntities()) {
|
||||
if(cuboid.isInWithMarge(entity.getLocation(), 5)) {
|
||||
//deprecated seems not to work with latest builds of citizens
|
||||
if(plugin.getServer().getPluginManager().isPluginEnabled("Citizens") && CitizensAPI.getNPCRegistry() != null
|
||||
&& CitizensAPI.getNPCRegistry().isNPC(entity)) {
|
||||
if(isCitizensEnabled && CitizensAPI.getNPCRegistry() != null && CitizensAPI.getNPCRegistry().isNPC(entity)) {
|
||||
continue;
|
||||
}
|
||||
//citizens also uses metadata, see https://wiki.citizensnpcs.co/API
|
||||
@@ -224,9 +220,14 @@ public class Plot {
|
||||
}
|
||||
|
||||
for(Chunk chunk : cuboid.chunkList()) {
|
||||
for(Player p : plugin.getServer().getOnlinePlayers()) {
|
||||
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_15_R1)) {
|
||||
chunk.getWorld().refreshChunk(chunk.getX(), chunk.getZ());
|
||||
continue;
|
||||
}
|
||||
|
||||
for(Player p : arena.getPlugin().getServer().getOnlinePlayers()) {
|
||||
if(p.getWorld().equals(chunk.getWorld())) {
|
||||
Utils.sendMapChunk(p, chunk);
|
||||
ChunkManager.sendMapChunk(p, chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -238,15 +239,13 @@ public class Plot {
|
||||
Location min = cuboid.getMinPoint();
|
||||
Location max = cuboid.getMaxPoint();
|
||||
|
||||
int y = Math.min(min.getBlockY(), max.getBlockY());
|
||||
|
||||
centerWorld.setBiome(min.getBlockX(), y, max.getBlockZ(), plotDefaultBiome);
|
||||
centerWorld.setBiome(min.getBlockX(), Math.min(min.getBlockY(), max.getBlockY()), max.getBlockZ(), plotDefaultBiome);
|
||||
} else {
|
||||
centerWorld.setBiome(cuboid.getMinPoint().getBlockX(), cuboid.getMaxPoint().getBlockZ(), plotDefaultBiome);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.getServer().getPluginManager().callEvent(new BBPlotResetEvent(arena, this));
|
||||
arena.getPlugin().getServer().getPluginManager().callEvent(new PlotResetEvent(arena, this));
|
||||
}
|
||||
|
||||
public int getPoints() {
|
||||
@@ -257,6 +256,10 @@ public class Plot {
|
||||
this.points = points;
|
||||
}
|
||||
|
||||
public void addPoints(int points) {
|
||||
this.points += points;
|
||||
}
|
||||
|
||||
private void changeFloor(Material material) {
|
||||
Location min = cuboid.getMinPoint();
|
||||
Location max = cuboid.getMaxPoint();
|
||||
@@ -324,7 +327,9 @@ public class Plot {
|
||||
int counter = 0;
|
||||
Location location = tploc.clone();
|
||||
while(counter != 10) {
|
||||
if(!(location.getBlock().getType() == Material.BARRIER || location.getBlock().getType() == Material.AIR)) {
|
||||
Material type = location.getBlock().getType();
|
||||
|
||||
if(!(type == Material.BARRIER || type == Material.AIR)) {
|
||||
enclosed = true;
|
||||
tploc = location;
|
||||
counter = 9;
|
||||
@@ -353,7 +358,7 @@ public class Plot {
|
||||
}
|
||||
|
||||
public static long format(Time time, long currTime) {
|
||||
return time == Time.WORLD_TIME ? currTime : time.getTicks();
|
||||
return time == Time.WORLD_TIME ? currTime : time.ticks;
|
||||
}
|
||||
|
||||
public long getTicks() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,19 +21,20 @@
|
||||
package plugily.projects.buildbattle.arena.managers.plots;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.api.event.plot.BBPlayerPlotReceiveEvent;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.commonsbox.minecraft.compat.ServerVersion.Version;
|
||||
import plugily.projects.commonsbox.minecraft.dimensional.Cuboid;
|
||||
import plugily.projects.buildbattle.api.event.plot.PlotPlayerReceiveEvent;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.minigamesbox.classic.utils.dimensional.Cuboid;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.VersionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Created by Tom on 17/08/2015.
|
||||
@@ -52,6 +53,10 @@ public class PlotManager {
|
||||
plots.add(buildPlot);
|
||||
}
|
||||
|
||||
public void removeBuildPlot(Plot buildPlot) {
|
||||
plots.remove(buildPlot);
|
||||
}
|
||||
|
||||
public Plot getPlot(Player player) {
|
||||
if(player != null) {
|
||||
for(Plot buildPlot : plots) {
|
||||
@@ -93,60 +98,41 @@ public class PlotManager {
|
||||
continue;
|
||||
}
|
||||
|
||||
if(Version.isCurrentEqualOrLower(Version.v1_13_R2)) { // Async catch in old versions
|
||||
// Should do this in async thread to do not cause dead for the main thread
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
Location loc = tploc;
|
||||
int m = 0;
|
||||
while(loc.getBlock().getType() != Material.AIR) {
|
||||
if(m >= 500) {
|
||||
break;// Thread never ends on flat map?
|
||||
if(arena.getArenaInGameState() != BaseArena.ArenaInGameState.THEME_VOTING) {
|
||||
break; // Thread never ends on flat map?
|
||||
}
|
||||
|
||||
if(arena.getArenaState() == ArenaState.IN_GAME && arena.getTimer() > 30) {
|
||||
break;
|
||||
}
|
||||
|
||||
loc = loc.add(0, 1, 0);
|
||||
//teleporting 1 x and z block away from center cause Y is above plot limit
|
||||
if(loc.getY() >= cuboid.getMaxPoint().getY()) {
|
||||
loc = cuboid.getCenter().clone().add(1, 0, 1);
|
||||
}
|
||||
|
||||
m++; // Preventing server froze on flat map
|
||||
}
|
||||
|
||||
for(Player p : buildPlot.getMembers()) {
|
||||
p.teleport(cuboid.getCenter());
|
||||
return loc;
|
||||
}).thenAccept(loc -> {
|
||||
for(Player player : buildPlot.getMembers()) {
|
||||
VersionUtils.teleport(player, loc);
|
||||
//Fix respawning bug while theme voting
|
||||
Bukkit.getScheduler().runTaskLater(arena.getPlugin(), () -> {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
}, 40);
|
||||
}
|
||||
} else {
|
||||
// Should do this in async thread to do not cause dead for the main thread
|
||||
CompletableFuture.supplyAsync(() -> {
|
||||
Location loc = tploc;
|
||||
while(loc.getBlock().getType() != Material.AIR) {
|
||||
if(arena.getArenaState() == ArenaState.IN_GAME && arena.getTimer() > 30) {
|
||||
break; // Thread never ends on flat map?
|
||||
}
|
||||
|
||||
loc = loc.add(0, 1, 0);
|
||||
//teleporting 1 x and z block away from center cause Y is above plot limit
|
||||
if(loc.getY() >= cuboid.getMaxPoint().getY()) {
|
||||
loc = cuboid.getCenter().clone().add(1, 0, 1);
|
||||
}
|
||||
}
|
||||
|
||||
return loc;
|
||||
}).thenAccept(loc -> {
|
||||
for(Player p : buildPlot.getMembers()) {
|
||||
p.teleport(cuboid.getCenter());
|
||||
//apply creative again to prevent multiverse default gamemode on world switch
|
||||
p.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
Bukkit.getPluginManager().callEvent(new BBPlayerPlotReceiveEvent(arena, buildPlot));
|
||||
Bukkit.getPluginManager().callEvent(new PlotPlayerReceiveEvent(arena, buildPlot));
|
||||
}
|
||||
}
|
||||
|
||||
public List<Plot> getTopPlotsOrder() {
|
||||
List<Plot> plotRanking = plots.stream().filter(plot -> !plot.getMembers().isEmpty()).sorted(Comparator.comparingInt(Plot::getPoints)).collect(Collectors.toList());
|
||||
Collections.reverse(plotRanking);
|
||||
return plotRanking;
|
||||
}
|
||||
|
||||
public List<Plot> getPlots() {
|
||||
return plots;
|
||||
}
|
||||
|
||||
+79
-92
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,24 +22,19 @@ package plugily.projects.buildbattle.arena.managers.plots;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.api.event.plot.BBPlayerChoosePlotEvent;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.handlers.items.SpecialItem;
|
||||
import plugily.projects.buildbattle.handlers.items.SpecialItemsManager;
|
||||
import plugily.projects.buildbattle.utils.Utils;
|
||||
import plugily.projects.commonsbox.minecraft.compat.VersionUtils;
|
||||
import plugily.projects.commonsbox.minecraft.compat.xseries.XMaterial;
|
||||
import plugily.projects.commonsbox.minecraft.item.ItemBuilder;
|
||||
import plugily.projects.inventoryframework.gui.GuiItem;
|
||||
import plugily.projects.inventoryframework.gui.type.ChestGui;
|
||||
import plugily.projects.inventoryframework.pane.StaticPane;
|
||||
import plugily.projects.buildbattle.api.event.plot.PlotPlayerChooseEvent;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.minigamesbox.classic.handlers.items.SpecialItem;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.helper.ItemBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.items.HandlerItem;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.VersionUtils;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.xseries.XMaterial;
|
||||
import plugily.projects.minigamesbox.inventory.common.item.SimpleClickableItem;
|
||||
import plugily.projects.minigamesbox.inventory.normal.NormalFastInv;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -48,38 +43,27 @@ import java.util.List;
|
||||
* Created by Tigerpanzer_02 on 26/Jul/2021.
|
||||
*/
|
||||
|
||||
public class PlotMenuHandler implements Listener {
|
||||
public final class PlotMenuHandler {
|
||||
|
||||
private final Main plugin;
|
||||
private final ItemStack empty;
|
||||
private final ItemStack waiting;
|
||||
private final ItemStack full;
|
||||
private final ItemStack inside;
|
||||
private final String fullTeam;
|
||||
private final String emptyTeam;
|
||||
private final String insideTeam;
|
||||
private final String teamName;
|
||||
private final SpecialItem baseItem;
|
||||
|
||||
public PlotMenuHandler(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
this.baseItem = plugin.getSpecialItemsManager().getSpecialItem(SpecialItemsManager.SpecialItems.PLOT_SELECTOR.getName());
|
||||
this.baseItem = plugin.getSpecialItemManager().getSpecialItem("PLOT_SELECTOR");
|
||||
|
||||
empty = XMaterial.GREEN_WOOL.parseItem();
|
||||
waiting = XMaterial.YELLOW_WOOL.parseItem();
|
||||
full = XMaterial.RED_WOOL.parseItem();
|
||||
inside = XMaterial.PINK_WOOL.parseItem();
|
||||
fullTeam = plugin.getChatManager().colorMessage("Plots.Team.Full");
|
||||
emptyTeam = plugin.getChatManager().colorMessage("Plots.Team.Empty");
|
||||
insideTeam = plugin.getChatManager().colorMessage("Plots.Team.Inside");
|
||||
teamName = plugin.getChatManager().colorMessage("Plots.Team.Name");
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
private ItemStack getItemStack(Plot plot, int maxPlotMembers, Player player) {
|
||||
int plotMembers = plot.getMembers().size();
|
||||
|
||||
if(plotMembers == 0) {
|
||||
if(plot.getMembers().isEmpty()) {
|
||||
return empty.clone();
|
||||
}
|
||||
|
||||
@@ -87,7 +71,7 @@ public class PlotMenuHandler implements Listener {
|
||||
return inside.clone();
|
||||
}
|
||||
|
||||
if(plotMembers == maxPlotMembers) {
|
||||
if(plot.getMembersSize() == maxPlotMembers) {
|
||||
return full.clone();
|
||||
}
|
||||
|
||||
@@ -95,73 +79,76 @@ public class PlotMenuHandler implements Listener {
|
||||
}
|
||||
|
||||
public void createMenu(Player player, BaseArena arena) {
|
||||
ChestGui gui = new ChestGui(Utils.serializeInt(arena.getPlotManager().getPlots().size()) / 9, plugin.getChatManager().colorMessage("Plots.Team.Menu-Name"));
|
||||
StaticPane pane = new StaticPane(9, gui.getRows());
|
||||
gui.addPane(pane);
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
NormalFastInv gui = new NormalFastInv(plugin.getBukkitHelper().serializeInt(arena.getPlotManager().getPlots().size()), new MessageBuilder("IN_GAME_MESSAGES_PLOT_SELECTOR_MENU_NAME").asKey().build());
|
||||
int plots = 0;
|
||||
int arenaPlotMemberSize = arena.getArenaOption("PLOT_MEMBER_SIZE");
|
||||
|
||||
for(Plot plot : arena.getPlotManager().getPlots()) {
|
||||
ItemStack itemStack = getItemStack(plot, arena.getPlotSize(), player);
|
||||
itemStack.setAmount(plot.getMembers().size() == 0 ? 1 : plot.getMembers().size());
|
||||
if(plot.getMembers().size() >= arena.getPlotSize()) {
|
||||
itemStack = new ItemBuilder(itemStack).lore(fullTeam).build();
|
||||
} else {
|
||||
itemStack = new ItemBuilder(itemStack).lore(emptyTeam).build();
|
||||
}
|
||||
if(plot.getMembers().size() > 0) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for(Player inside : plot.getMembers()) {
|
||||
players.add("- " + inside.getName());
|
||||
ItemStack itemStack = getItemStack(plot, arenaPlotMemberSize, player);
|
||||
int plotMemberSize = plot.getMembersSize();
|
||||
|
||||
itemStack.setAmount(plotMemberSize == 0 ? 1 : plotMemberSize);
|
||||
|
||||
itemStack = new ItemBuilder(itemStack).lore(new MessageBuilder(plotMemberSize >= arenaPlotMemberSize ? "IN_GAME_MESSAGES_PLOT_SELECTOR_FULL"
|
||||
: "IN_GAME_MESSAGES_PLOT_SELECTOR_EMPTY").asKey().build()).build();
|
||||
|
||||
if(plotMemberSize != 0) {
|
||||
List<String> players = new ArrayList<>(plotMemberSize);
|
||||
|
||||
for(Player plotMember : plot.getMembers()) {
|
||||
players.add("- " + plotMember.getName());
|
||||
}
|
||||
|
||||
itemStack = new ItemBuilder(itemStack).lore(players).build();
|
||||
}
|
||||
if(plot.getMembers().contains(player)) {
|
||||
itemStack = new ItemBuilder(itemStack).lore(insideTeam).build();
|
||||
}
|
||||
itemStack = new ItemBuilder(itemStack).name(teamName.replace("%plot%", Integer.toString(plots))).build();
|
||||
int finalPlots = plots;
|
||||
pane.addItem(new GuiItem(itemStack, e -> {
|
||||
e.setCancelled(true);
|
||||
if(!(e.getWhoClicked() instanceof Player) || !(e.isLeftClick() || e.isRightClick())) {
|
||||
return;
|
||||
}
|
||||
BBPlayerChoosePlotEvent event = new BBPlayerChoosePlotEvent(player, plot, arena);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if(!plot.addMember(player, arena, false)) {
|
||||
return;
|
||||
}
|
||||
player.sendMessage(plugin.getChatManager().colorMessage("Plots.Team.Plot-Choose").replace("%plot%", Integer.toString(finalPlots)));
|
||||
e.getWhoClicked().closeInventory();
|
||||
}), x, y);
|
||||
plots++;
|
||||
x++;
|
||||
if(x == 9) {
|
||||
x = 0;
|
||||
y++;
|
||||
}
|
||||
}
|
||||
gui.show(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlotMenuItemClick(PlayerInteractEvent e) {
|
||||
if(!(e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK)) {
|
||||
return;
|
||||
if(plot.getMembers().contains(player)) {
|
||||
itemStack = new ItemBuilder(itemStack).lore(new MessageBuilder("IN_GAME_MESSAGES_PLOT_SELECTOR_INSIDE").asKey().build()).build();
|
||||
}
|
||||
|
||||
itemStack = new ItemBuilder(itemStack).name(new MessageBuilder("IN_GAME_MESSAGES_PLOT_SELECTOR_NAME").asKey().integer(plots).build()).build();
|
||||
|
||||
new HandlerItem(itemStack).addInteractHandler(event -> {
|
||||
if(!(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!VersionUtils.getItemInHand(event.getPlayer()).equals(baseItem.getItemStack())) {
|
||||
return;
|
||||
}
|
||||
|
||||
BaseArena baseArena = plugin.getArenaRegistry().getArena(event.getPlayer());
|
||||
if(baseArena == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
createMenu(event.getPlayer(), baseArena);
|
||||
});
|
||||
|
||||
int finalPlots = plots;
|
||||
gui.addItem(new SimpleClickableItem(itemStack, event -> {
|
||||
event.setCancelled(true);
|
||||
|
||||
if(!(event.isLeftClick() || event.isRightClick())) {
|
||||
return;
|
||||
}
|
||||
|
||||
PlotPlayerChooseEvent plotChooseEvent = new PlotPlayerChooseEvent(player, plot, arena);
|
||||
Bukkit.getPluginManager().callEvent(plotChooseEvent);
|
||||
|
||||
if(plotChooseEvent.isCancelled() || !plot.addMember(player, arena, false)) {
|
||||
return;
|
||||
}
|
||||
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_SELECTOR_PLOT_CHOOSE").asKey().player(player).integer(finalPlots).sendPlayer();
|
||||
event.getWhoClicked().closeInventory();
|
||||
}));
|
||||
|
||||
plots++;
|
||||
}
|
||||
ItemStack stack = VersionUtils.getItemInHand(e.getPlayer());
|
||||
if(!stack.equals(baseItem.getItemStack())) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena(e.getPlayer());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
createMenu(e.getPlayer(), arena);
|
||||
|
||||
gui.open(player);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena.options;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public enum ArenaOption {
|
||||
/**
|
||||
* Current arena timer, ex. 30 seconds before game starts.
|
||||
*/
|
||||
TIMER(0),
|
||||
/**
|
||||
* Minimum players in arena needed to start.
|
||||
*/
|
||||
MINIMUM_PLAYERS(2),
|
||||
/**
|
||||
* Maximum players arena can hold, users with full games permission can bypass this!
|
||||
*/
|
||||
MAXIMUM_PLAYERS(10),
|
||||
/**
|
||||
* Value for checking whether player is in plot or not, otherwise teleport him back.
|
||||
* <p>
|
||||
* Each time values reach 1 check will be run.
|
||||
*/
|
||||
IN_PLOT_CHECKER(0);
|
||||
|
||||
private final int defaultValue;
|
||||
|
||||
ArenaOption(int defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
}
|
||||
|
||||
public int getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena.states.build;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.BuildArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.arena.vote.VoteItems;
|
||||
import plugily.projects.minigamesbox.api.user.IUser;
|
||||
import plugily.projects.minigamesbox.classic.arena.PluginArena;
|
||||
import plugily.projects.minigamesbox.classic.arena.states.PluginInGameState;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.TitleBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.VersionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
* <p>Created at 28.05.2022
|
||||
*/
|
||||
public class InGameState extends PluginInGameState {
|
||||
|
||||
@Override
|
||||
public void handleCall(PluginArena arena) {
|
||||
super.handleCall(arena);
|
||||
BuildArena pluginArena = (BuildArena) getPlugin().getArenaRegistry().getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return;
|
||||
}
|
||||
switch(pluginArena.getArenaInGameState()) {
|
||||
case THEME_VOTING:
|
||||
if(arena.getTimer() <= 0) {
|
||||
// may consider start to build message...
|
||||
pluginArena.setArenaInGameState(BaseArena.ArenaInGameState.BUILD_TIME);
|
||||
|
||||
setArenaTimer(getPlugin().getConfig().getInt("Time-Manager." + pluginArena.getArenaType().getPrefix() + ".In-Game"));
|
||||
|
||||
if(pluginArena.getVotePoll() != null && pluginArena.getTheme().equals("Theme")) {
|
||||
pluginArena.setTheme(pluginArena.getVotePoll().getVotedTheme());
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_NAME").asKey().arena(pluginArena).sendArena();
|
||||
}
|
||||
|
||||
for(Player player : pluginArena.getPlayers()) {
|
||||
player.closeInventory();
|
||||
pluginArena.addMenuItem(player);
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
} else {
|
||||
handleThemeVoting(pluginArena);
|
||||
}
|
||||
|
||||
break;
|
||||
case BUILD_TIME:
|
||||
handleBuildTime(pluginArena);
|
||||
if(arena.getTimer() <= 0) {
|
||||
for(Player player : pluginArena.getPlayersLeft()) {
|
||||
IUser user = getPlugin().getUserManager().getUser(player);
|
||||
|
||||
if(user.isSpectator()) continue;
|
||||
|
||||
Plot playerPlot = pluginArena.getPlotFromPlayer(player);
|
||||
if(!pluginArena.getQueue().contains(playerPlot)) {
|
||||
pluginArena.getQueue().add(playerPlot);
|
||||
}
|
||||
player.getInventory().clear();
|
||||
pluginArena.getPlugin().getVoteItems().giveVoteItems(player);
|
||||
user.setStatistic("LOCAL_POINTS", 3);
|
||||
}
|
||||
|
||||
pluginArena.setArenaInGameState(BaseArena.ArenaInGameState.PLOT_VOTING);
|
||||
voteForNextPlot(pluginArena);
|
||||
}
|
||||
break;
|
||||
case PLOT_VOTING:
|
||||
handlePlotVoting(pluginArena);
|
||||
if(arena.getTimer() <= 0) {
|
||||
calculatePlotResults(pluginArena);
|
||||
if(pluginArena.getQueue().isEmpty()) {
|
||||
pluginArena.calculateWinnerPlot();
|
||||
adjustStatistics(pluginArena);
|
||||
|
||||
pluginArena.teleportToWinnerPlot();
|
||||
pluginArena.executeEndRewards();
|
||||
getPlugin().getArenaManager().stopGame(false, arena);
|
||||
} else {
|
||||
voteForNextPlot(pluginArena);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// no players - stop game
|
||||
if(!pluginArena.enoughPlayersToContinue()) {
|
||||
getPlugin().getArenaManager().stopGame(true, pluginArena);
|
||||
}
|
||||
}
|
||||
|
||||
private void calculatePlotResults(BuildArena pluginArena) {
|
||||
Plot votingPlot = pluginArena.getVotingPlot();
|
||||
|
||||
if(votingPlot == null || votingPlot.getPoints() != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean hidePlotOwner = getPlugin().getConfigPreferences().getOption("PLOT_HIDE_OWNER");
|
||||
String formattedMembers = "";
|
||||
|
||||
if(hidePlotOwner) {
|
||||
formattedMembers = votingPlot.getFormattedMembers();
|
||||
}
|
||||
List<Plot> plotsVoted = new ArrayList<>();
|
||||
for(Player player : pluginArena.getPlayersLeft()) {
|
||||
if(hidePlotOwner) {
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_WAS").asKey().arena(pluginArena).player(player).value(formattedMembers).sendArena();
|
||||
new TitleBuilder("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_TITLE").asKey().arena(pluginArena).player(player).value(formattedMembers).sendArena();
|
||||
}
|
||||
|
||||
IUser user = getPlugin().getUserManager().getUser(player);
|
||||
int points = user.getStatistic("LOCAL_POINTS");
|
||||
|
||||
//no vote made, in this case make it a good vote
|
||||
if(points == 0) {
|
||||
points = 3;
|
||||
}
|
||||
Plot plot = pluginArena.getPlotFromPlayer(player);
|
||||
if(!votingPlot.getMembers().contains(player)) {
|
||||
if(!plotsVoted.contains(plot)) {
|
||||
votingPlot.addPoints(points);
|
||||
plotsVoted.add(plot);
|
||||
}
|
||||
}
|
||||
|
||||
user.setStatistic("LOCAL_POINTS", 3);
|
||||
}
|
||||
}
|
||||
|
||||
private void adjustStatistics(BuildArena pluginArena) {
|
||||
for(Plot plot : pluginArena.getPlotManager().getTopPlotsOrder()) {
|
||||
plot.getMembers().forEach(player -> {
|
||||
IUser user = getPlugin().getUserManager().getUser(player);
|
||||
if(plot.getPoints() > user.getStatistic("POINTS_HIGHEST")) {
|
||||
user.setStatistic("POINTS_HIGHEST", plot.getPoints());
|
||||
}
|
||||
user.adjustStatistic("POINTS_TOTAL", plot.getPoints());
|
||||
if(plot == pluginArena.getWinnerPlot()) {
|
||||
user.adjustStatistic("WINS", 1);
|
||||
} else {
|
||||
user.adjustStatistic("LOSES", 1);
|
||||
}
|
||||
getPlugin().getUserManager().addExperience(player, 5);
|
||||
if(plot.getPoints() > user.getStatistic("POINTS_HIGHEST_WIN")) {
|
||||
user.setStatistic("POINTS_HIGHEST_WIN", plot.getPoints());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleThemeVoting(BuildArena pluginArena) {
|
||||
for(Player player : pluginArena.getPlayers()) {
|
||||
pluginArena.getVoteMenu().updateInventory(player);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleBuildTime(BuildArena pluginArena) {
|
||||
int timer = pluginArena.getTimer();
|
||||
for(int timers : getPlugin().getConfig().getIntegerList("Time-Manager.Time-Left-Intervals")) {
|
||||
if(timers == timer) {
|
||||
pluginArena.sendBuildLeftTimeMessage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
pluginArena.checkPlayerOutSidePlot();
|
||||
}
|
||||
|
||||
private void handlePlotVoting(BuildArena pluginArena) {
|
||||
|
||||
}
|
||||
|
||||
public void voteForNextPlot(BuildArena pluginArena) {
|
||||
Plot votingPlot = pluginArena.getVotingPlot();
|
||||
|
||||
if(votingPlot != null) {
|
||||
if(votingPlot.getPoints() == 0) {
|
||||
List<Plot> plotsVoted = new ArrayList<>();
|
||||
for(Player player : pluginArena.getPlayersLeft()) {
|
||||
IUser user = getPlugin().getUserManager().getUser(player);
|
||||
Plot plot = pluginArena.getPlotFromPlayer(player);
|
||||
if(!votingPlot.getMembers().contains(player)) {
|
||||
if(!plotsVoted.contains(plot)) {
|
||||
votingPlot.addPoints(user.getStatistic("LOCAL_POINTS"));
|
||||
plotsVoted.add(plot);
|
||||
}
|
||||
}
|
||||
|
||||
user.setStatistic("LOCAL_POINTS", 3);
|
||||
|
||||
VoteItems voteItems = pluginArena.getPlugin().getVoteItems();
|
||||
|
||||
if(!player.getInventory().contains(voteItems.getReportItem())) {
|
||||
player.getInventory().setItem(voteItems.getReportVoteItem().getSlot(), voteItems.getReportVoteItem().getItemStack());
|
||||
player.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!votingPlot.getMembers().isEmpty() && getPlugin().getConfigPreferences().getOption("PLOT_HIDE_OWNER")) {
|
||||
String formattedMembers = votingPlot.getFormattedMembers();
|
||||
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_WAS").asKey().arena(pluginArena).value(formattedMembers).sendArena();
|
||||
new TitleBuilder("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_TITLE").asKey().arena(pluginArena).value(formattedMembers).sendArena();
|
||||
}
|
||||
}
|
||||
|
||||
voteRoutine(pluginArena);
|
||||
}
|
||||
|
||||
public void voteRoutine(BuildArena pluginArena) {
|
||||
if(pluginArena.getQueue().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
setArenaTimer(getPlugin().getConfig().getInt("Time-Manager." + pluginArena.getArenaType().getPrefix() + ".Voting.Plot"));
|
||||
|
||||
Plot plot = pluginArena.getQueue().poll();
|
||||
|
||||
while(plot == null && !pluginArena.getQueue().isEmpty()) {
|
||||
// should not happen anymore... to be removed
|
||||
System.out.print("A PLAYER HAS NO PLOT!");
|
||||
plot = pluginArena.getQueue().poll();
|
||||
}
|
||||
|
||||
if(pluginArena.getQueue().isEmpty() && plot == null) {
|
||||
pluginArena.setVotingPlot(null);
|
||||
return;
|
||||
}
|
||||
|
||||
pluginArena.setVotingPlot(plot);
|
||||
|
||||
if(plot == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location teleportLoc = plot.getTeleportLocation();
|
||||
String formattedMembers = plot.getFormattedMembers();
|
||||
boolean hidePlotOwner = getPlugin().getConfigPreferences().getOption("PLOT_HIDE_OWNER");
|
||||
|
||||
for(Player player : pluginArena.getPlayers()) {
|
||||
VersionUtils.teleport(player, teleportLoc);
|
||||
player.setPlayerWeather(plot.getWeatherType());
|
||||
player.setPlayerTime(Plot.Time.format(plot.getTime(), player.getWorld().getTime()), false);
|
||||
|
||||
if(hidePlotOwner) {
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_NEXT").asKey().arena(pluginArena).value("???").player(player).sendPlayer();
|
||||
} else {
|
||||
new TitleBuilder("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_TITLE").asKey().arena(pluginArena).value(formattedMembers).player(player).sendPlayer();
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_NEXT").asKey().arena(pluginArena).value(formattedMembers).player(player).sendPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
for(Player spectator : pluginArena.getSpectators()) {
|
||||
VersionUtils.teleport(spectator, teleportLoc);
|
||||
spectator.setPlayerWeather(plot.getWeatherType());
|
||||
spectator.setPlayerTime(Plot.Time.format(plot.getTime(), spectator.getWorld().getTime()), false);
|
||||
|
||||
new TitleBuilder("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_TITLE").asKey().arena(pluginArena).value(formattedMembers).player(spectator).sendPlayer();
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_NEXT").asKey().arena(pluginArena).value(formattedMembers).player(spectator).sendPlayer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena.states.build;
|
||||
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.BuildArena;
|
||||
import plugily.projects.buildbattle.handlers.menu.registry.particles.ParticleRefreshScheduler;
|
||||
import plugily.projects.minigamesbox.classic.arena.PluginArena;
|
||||
import plugily.projects.minigamesbox.classic.arena.states.PluginStartingState;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>Created at 03.06.2019
|
||||
*/
|
||||
public class StartingState extends PluginStartingState {
|
||||
|
||||
@Override
|
||||
public void handleCall(PluginArena arena) {
|
||||
super.handleCall(arena);
|
||||
BuildArena pluginArena = (BuildArena) getPlugin().getArenaRegistry().getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return;
|
||||
}
|
||||
if(arena.getTimer() == 0 || arena.isForceStart()) {
|
||||
|
||||
pluginArena.setParticleRefreshScheduler(new ParticleRefreshScheduler(getPlugin()));
|
||||
|
||||
if(!pluginArena.getPlotManager().isPlotsCleared()) {
|
||||
pluginArena.getPlotManager().resetQueuedPlots();
|
||||
}
|
||||
|
||||
pluginArena.distributePlots();
|
||||
setArenaTimer(getPlugin().getConfig().getInt("Time-Manager." + pluginArena.getArenaType().getPrefix() + ".Voting.Theme"));
|
||||
|
||||
pluginArena.setArenaInGameState(BaseArena.ArenaInGameState.THEME_VOTING);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,302 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena.states.guess;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.GuessArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.handlers.themes.BBTheme;
|
||||
import plugily.projects.buildbattle.handlers.themes.ThemeManager;
|
||||
import plugily.projects.minigamesbox.api.user.IUser;
|
||||
import plugily.projects.minigamesbox.classic.arena.PluginArena;
|
||||
import plugily.projects.minigamesbox.classic.arena.states.PluginInGameState;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.TitleBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.actionbar.ActionBar;
|
||||
import plugily.projects.minigamesbox.classic.utils.helper.ItemBuilder;
|
||||
import plugily.projects.minigamesbox.inventory.common.item.SimpleClickableItem;
|
||||
import plugily.projects.minigamesbox.inventory.normal.NormalFastInv;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
* <p>Created at 28.05.2022
|
||||
*/
|
||||
public class InGameState extends PluginInGameState {
|
||||
|
||||
@Override
|
||||
public void handleCall(PluginArena arena) {
|
||||
super.handleCall(arena);
|
||||
GuessArena pluginArena = (GuessArena) getPlugin().getArenaRegistry().getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return;
|
||||
}
|
||||
switch(pluginArena.getArenaInGameState()) {
|
||||
case THEME_VOTING:
|
||||
if(pluginArena.getBuildPlot() == null) {
|
||||
pluginArena.setNextPlot();
|
||||
new TitleBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_BEING_SELECTED").asKey().arena(pluginArena).sendArena();
|
||||
openThemeSelectionInventoryToCurrentBuilder(pluginArena);
|
||||
break;
|
||||
}
|
||||
|
||||
if(arena.getTimer() <= 0 || pluginArena.isCurrentThemeSet()) {
|
||||
forceSetTheme(pluginArena);
|
||||
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_ROUND").asKey().integer(pluginArena.getRound()).arena(pluginArena).sendArena();
|
||||
new TitleBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_TITLE").asKey().arena(pluginArena).sendArena();
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> pluginArena.getCurrentBuilders().forEach(player -> player.setGameMode(GameMode.CREATIVE)), 40);
|
||||
pluginArena.getCurrentBuilders().forEach(pluginArena::addMenuItem);
|
||||
|
||||
setArenaTimer(getPlugin().getConfig().getInt("Time-Manager." + pluginArena.getArenaType().getPrefix() + ".In-Game"));
|
||||
pluginArena.setArenaInGameState(BaseArena.ArenaInGameState.BUILD_TIME);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case BUILD_TIME:
|
||||
// check not needed anymore
|
||||
// if(pluginArena.isCurrentThemeSet()) {
|
||||
int timer = arena.getTimer();
|
||||
|
||||
if(timer <= 90) {
|
||||
if(timer == 90) {
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_CHARS").asKey().arena(pluginArena).integer(pluginArena.getCurrentBBTheme().getTheme().length()).sendArena();
|
||||
}
|
||||
sendThemeHints(arena, pluginArena);
|
||||
}
|
||||
if(timer <= 0) {
|
||||
//not all guessed
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_WAS").asKey().value(pluginArena.getCurrentBBTheme().getTheme()).arena(pluginArena).sendArena();
|
||||
new TitleBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_TITLE").asKey().value(pluginArena.getCurrentBBTheme().getTheme()).arena(pluginArena).sendArena();
|
||||
|
||||
setArenaTimer(getPlugin().getConfig().getInt("Time-Manager." + pluginArena.getArenaType().getPrefix() + ".Round-Delay"));
|
||||
pluginArena.setArenaInGameState(BaseArena.ArenaInGameState.PLOT_VOTING);
|
||||
}
|
||||
//}
|
||||
handleBuildTime(pluginArena);
|
||||
break;
|
||||
case PLOT_VOTING:
|
||||
if(pluginArena.getRound() + 1 > pluginArena.getPlotList().size() * pluginArena.getArenaOption("GTB_ROUNDS_PER_PLOT")) {
|
||||
pluginArena.calculateWinnerPlot();
|
||||
adjustStatistics(pluginArena);
|
||||
|
||||
pluginArena.teleportToWinnerPlot(); //todo save built plot from winner
|
||||
pluginArena.executeEndRewards();
|
||||
getPlugin().getArenaManager().stopGame(false, arena);
|
||||
}
|
||||
//round delay
|
||||
if(arena.getTimer() <= 0) {
|
||||
pluginArena.resetBuildPlot();
|
||||
setArenaTimer(getPlugin().getConfig().getInt("Time-Manager." + pluginArena.getArenaType().getPrefix() + ".Voting.Theme"));
|
||||
pluginArena.setArenaInGameState(BaseArena.ArenaInGameState.THEME_VOTING);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// no players - stop game
|
||||
if(!pluginArena.enoughPlayersToContinue()) {
|
||||
getPlugin().getArenaManager().stopGame(true, pluginArena);
|
||||
}
|
||||
}
|
||||
|
||||
private void sendThemeHints(PluginArena arena, GuessArena pluginArena) {
|
||||
for(Player player : arena.getPlayers()) {
|
||||
if(pluginArena.getCurrentBuilders().contains(player)) {
|
||||
continue;
|
||||
}
|
||||
if(pluginArena.getWhoGuessed().contains(player)) {
|
||||
getPlugin().getActionBarManager().addActionBar(player, new ActionBar(new MessageBuilder(pluginArena.getCurrentBBTheme().getTheme()), ActionBar.ActionBarType.DISPLAY));
|
||||
continue;
|
||||
}
|
||||
int themeLength = pluginArena.getCurrentBBTheme().getTheme().length();
|
||||
List<Integer> charsAt = new ArrayList<>(themeLength);
|
||||
|
||||
for(int i = 0; i < themeLength; i++) {
|
||||
if(!pluginArena.getRemovedCharsAt().contains(i)) {
|
||||
charsAt.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(themeLength - pluginArena.getRemovedCharsAt().size() > 2) {
|
||||
int timer = arena.getTimer();
|
||||
|
||||
if(timer % 10 == 0 && timer <= 70) {
|
||||
pluginArena.getRemovedCharsAt().add(charsAt.get(charsAt.size() == 1 ? 0 : pluginArena.getPlugin().getRandom().nextInt(charsAt.size())));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder actionbar = new StringBuilder();
|
||||
for(int i = 0; i < themeLength; i++) {
|
||||
char charAt = pluginArena.getCurrentBBTheme().getTheme().charAt(i);
|
||||
|
||||
if(Character.isWhitespace(charAt)) {
|
||||
actionbar.append(" ");
|
||||
continue;
|
||||
}
|
||||
if(pluginArena.getRemovedCharsAt().contains(i)) {
|
||||
actionbar.append(charAt).append(' ');
|
||||
continue;
|
||||
}
|
||||
actionbar.append("_ ");
|
||||
}
|
||||
getPlugin().getActionBarManager().addActionBar(player, new ActionBar(new MessageBuilder(actionbar.toString()), ActionBar.ActionBarType.DISPLAY));
|
||||
}
|
||||
}
|
||||
|
||||
private void forceSetTheme(GuessArena pluginArena) {
|
||||
if(pluginArena.isCurrentThemeSet()) {
|
||||
return;
|
||||
}
|
||||
BBTheme.Difficulty difficulty = BBTheme.Difficulty.EASY;
|
||||
switch(pluginArena.getPlugin().getRandom().nextInt(2 + 1)) {
|
||||
case 1:
|
||||
difficulty = BBTheme.Difficulty.MEDIUM;
|
||||
break;
|
||||
case 2:
|
||||
difficulty = BBTheme.Difficulty.HARD;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
setChosenTheme(pluginArena, getThemeByDifficulty(pluginArena, difficulty));
|
||||
}
|
||||
|
||||
private void setChosenTheme(GuessArena pluginArena, BBTheme bbTheme) {
|
||||
setTheme(pluginArena, bbTheme);
|
||||
pluginArena.getCurrentBuilders().forEach(HumanEntity::closeInventory);
|
||||
pluginArena.getCurrentBuilders().forEach(player ->
|
||||
getPlugin().getActionBarManager().addActionBar(player, new ActionBar(new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_NAME").asKey().player(player).arena(pluginArena),
|
||||
ActionBar.ActionBarType.DISPLAY)));
|
||||
}
|
||||
|
||||
|
||||
private void openThemeSelectionInventoryToCurrentBuilder(GuessArena pluginArena) {
|
||||
if(pluginArena.getCurrentBuilders().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
pluginArena.getCurrentBuilders().forEach(HumanEntity::closeInventory);
|
||||
|
||||
NormalFastInv gui = new NormalFastInv(9 * 3, new MessageBuilder("MENU_THEME_GTB_INVENTORY").asKey().build());
|
||||
gui.addClickHandler(inventoryClickEvent -> inventoryClickEvent.setCancelled(true));
|
||||
gui.addCloseHandler(event -> {
|
||||
if(!pluginArena.isCurrentThemeSet()) {
|
||||
Bukkit.getScheduler().runTask(getPlugin(), () -> event.getPlayer().openInventory(event.getInventory()));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
BBTheme easy = getThemeByDifficulty(pluginArena, BBTheme.Difficulty.EASY);
|
||||
gui.setItem(11, new SimpleClickableItem(new ItemBuilder(Material.PAPER).name(getThemeItemName(pluginArena).value(easy.getTheme()).build())
|
||||
.lore(getThemeItemLore(pluginArena).value(new MessageBuilder("MENU_THEME_GTB_DIFFICULTIES_EASY").asKey().build()).integer(easy.getDifficulty().getPointsReward()).build().split(";")).build(), event -> {
|
||||
setChosenTheme(pluginArena, easy);
|
||||
}));
|
||||
|
||||
BBTheme medium = getThemeByDifficulty(pluginArena, BBTheme.Difficulty.MEDIUM);
|
||||
gui.setItem(13, new SimpleClickableItem(new ItemBuilder(Material.PAPER).name(getThemeItemName(pluginArena).value(medium.getTheme()).build())
|
||||
.lore(getThemeItemLore(pluginArena).value(new MessageBuilder("MENU_THEME_GTB_DIFFICULTIES_MEDIUM").asKey().build()).integer(medium.getDifficulty().getPointsReward()).build().split(";")).build(), event -> {
|
||||
setChosenTheme(pluginArena, medium);
|
||||
}));
|
||||
|
||||
BBTheme hard = getThemeByDifficulty(pluginArena, BBTheme.Difficulty.HARD);
|
||||
gui.setItem(15, new SimpleClickableItem(new ItemBuilder(Material.PAPER).name(getThemeItemName(pluginArena).value(hard.getTheme()).build())
|
||||
.lore(getThemeItemLore(pluginArena).value(new MessageBuilder("MENU_THEME_GTB_DIFFICULTIES_HARD").asKey().build()).integer(hard.getDifficulty().getPointsReward()).build().split(";")).build(), event -> {
|
||||
setChosenTheme(pluginArena, hard);
|
||||
}));
|
||||
|
||||
getPlugin().getDebugger().debug("Opened Theme Selector for {0}", pluginArena.getCurrentBuilders().toString());
|
||||
pluginArena.getCurrentBuilders().forEach(gui::open);
|
||||
}
|
||||
|
||||
public MessageBuilder getThemeItemName(GuessArena pluginArena) {
|
||||
return new MessageBuilder("MENU_THEME_GTB_ITEM_NAME").asKey().arena(pluginArena);
|
||||
}
|
||||
|
||||
public MessageBuilder getThemeItemLore(GuessArena pluginArena) {
|
||||
return new MessageBuilder("MENU_THEME_GTB_ITEM_LORE").asKey().arena(pluginArena);
|
||||
}
|
||||
|
||||
|
||||
private BBTheme getThemeByDifficulty(GuessArena pluginArena, BBTheme.Difficulty difficulty) {
|
||||
List<String> themes = pluginArena.getPlugin().getThemeManager().getThemes(ThemeManager.GameThemes.getByDifficulty(difficulty));
|
||||
List<String> themesFilter = new ArrayList<>(themes);
|
||||
themesFilter.removeAll(pluginArena.getPlayedThemes());
|
||||
if(themesFilter.isEmpty()) {
|
||||
themesFilter = themes;
|
||||
}
|
||||
String themeName = themesFilter.get(getPlugin().getRandom().nextInt(themesFilter.size()));
|
||||
BBTheme theme = new BBTheme(themeName, difficulty);
|
||||
pluginArena.getPlayedThemes().add(themeName);
|
||||
return theme;
|
||||
}
|
||||
|
||||
private void setTheme(GuessArena pluginArena, BBTheme theme) {
|
||||
pluginArena.setCurrentTheme(theme);
|
||||
}
|
||||
|
||||
private void adjustStatistics(GuessArena pluginArena) {
|
||||
for(Plot plot : pluginArena.getPlotManager().getTopPlotsOrder()) {
|
||||
plot.getMembers().forEach(player -> {
|
||||
IUser user = getPlugin().getUserManager().getUser(player);
|
||||
/*
|
||||
//ToDo GTB stats
|
||||
if(plot.getPoints() > user.getStatistic("POINTS_HIGHEST")) {
|
||||
user.setStatistic("POINTS_HIGHEST", plot.getPoints());
|
||||
}
|
||||
*/
|
||||
user.adjustStatistic("POINTS_TOTAL", plot.getPoints());
|
||||
if(plot == pluginArena.getWinnerPlot()) {
|
||||
user.adjustStatistic("WINS", 1);
|
||||
} else {
|
||||
user.adjustStatistic("LOSES", 1);
|
||||
}
|
||||
getPlugin().getUserManager().addExperience(player, 5);
|
||||
/*
|
||||
if(plot.getPoints() > user.getStatistic("POINTS_HIGHEST_WIN")) {
|
||||
user.setStatistic("POINTS_HIGHEST_WIN", plot.getPoints());
|
||||
}
|
||||
*/
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void handleBuildTime(GuessArena pluginArena) {
|
||||
int timer = pluginArena.getTimer();
|
||||
|
||||
for(int timers : getPlugin().getConfig().getIntegerList("Time-Manager.Time-Left-Intervals")) {
|
||||
if(timers == timer) {
|
||||
pluginArena.sendBuildLeftTimeMessage();
|
||||
break;
|
||||
}
|
||||
}
|
||||
pluginArena.checkPlayerOutSidePlot();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.arena.states.guess;
|
||||
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.GuessArena;
|
||||
import plugily.projects.buildbattle.handlers.menu.registry.particles.ParticleRefreshScheduler;
|
||||
import plugily.projects.minigamesbox.classic.arena.PluginArena;
|
||||
import plugily.projects.minigamesbox.classic.arena.states.PluginStartingState;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>Created at 03.06.2019
|
||||
*/
|
||||
public class StartingState extends PluginStartingState {
|
||||
|
||||
@Override
|
||||
public void handleCall(PluginArena arena) {
|
||||
super.handleCall(arena);
|
||||
GuessArena pluginArena = (GuessArena) getPlugin().getArenaRegistry().getArena(arena.getId());
|
||||
if (pluginArena == null) {
|
||||
return;
|
||||
}
|
||||
if (arena.getTimer() == 0 || arena.isForceStart()) {
|
||||
pluginArena.setParticleRefreshScheduler(new ParticleRefreshScheduler(getPlugin()));
|
||||
if(!pluginArena.getPlotManager().isPlotsCleared()) {
|
||||
pluginArena.getPlotManager().resetQueuedPlots();
|
||||
}
|
||||
|
||||
pluginArena.distributePlots();
|
||||
|
||||
setArenaTimer(getPlugin().getConfig().getInt("Time-Manager." + pluginArena.getArenaType().getPrefix() + ".Voting.Theme"));
|
||||
pluginArena.setArenaInGameState(BaseArena.ArenaInGameState.THEME_VOTING);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -23,20 +23,17 @@ package plugily.projects.buildbattle.arena.vote;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import plugily.projects.commonsbox.minecraft.compat.VersionUtils;
|
||||
import plugily.projects.commonsbox.minecraft.compat.events.api.CBPlayerInteractEvent;
|
||||
import plugily.projects.commonsbox.minecraft.item.ItemUtils;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.api.StatsStorage;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.impl.GuessTheBuildArena;
|
||||
import plugily.projects.buildbattle.arena.impl.SoloArena;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.BuildArena;
|
||||
import plugily.projects.buildbattle.arena.GuessArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.handlers.reward.Reward;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
import plugily.projects.minigamesbox.api.arena.IArenaState;
|
||||
import plugily.projects.minigamesbox.api.user.IUser;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.misc.complement.ComplementAccessor;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.VersionUtils;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.events.api.PlugilyPlayerInteractEvent;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
@@ -53,56 +50,75 @@ public class VoteEvents implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onVote(CBPlayerInteractEvent e) {
|
||||
if(VersionUtils.checkOffHand(e.getHand()) || e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.PHYSICAL) {
|
||||
public void onVote(PlugilyPlayerInteractEvent event) {
|
||||
if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!ItemUtils.isItemStackNamed(e.getItem())) {
|
||||
if(VersionUtils.checkOffHand(event.getHand())) {
|
||||
return;
|
||||
}
|
||||
|
||||
BaseArena arena = ArenaRegistry.getArena(e.getPlayer());
|
||||
if(arena == null || arena instanceof GuessTheBuildArena || arena.getArenaState() != ArenaState.IN_GAME) {
|
||||
BaseArena arena = plugin.getArenaRegistry().getArena(event.getPlayer());
|
||||
if(arena == null || arena.getArenaState() != IArenaState.IN_GAME || arena instanceof GuessArena) {
|
||||
return;
|
||||
}
|
||||
|
||||
SoloArena solo = (SoloArena) arena;
|
||||
if (!solo.isVoting())
|
||||
BuildArena solo = (BuildArena) arena;
|
||||
if(solo.getArenaInGameState() != BaseArena.ArenaInGameState.PLOT_VOTING) {
|
||||
return;
|
||||
}
|
||||
|
||||
User user = plugin.getUserManager().getUser(e.getPlayer());
|
||||
Plot plot = solo.getVotingPlot();
|
||||
|
||||
if(plugin.getVoteItems().getReportItem().equals(e.getItem())) {
|
||||
user.setStat(StatsStorage.StatisticType.REPORTS, user.getStat(StatsStorage.StatisticType.REPORTS) + 1);
|
||||
if(plugin.getVoteItems().getReportItem().equals(event.getItem())) {
|
||||
IUser user = plugin.getUserManager().getUser(event.getPlayer());
|
||||
|
||||
int reportsAmountNeeded = plugin.getConfig().getInt("Run-Command-On-Report.Reports-Amount-To-Run", -1);
|
||||
user.adjustStatistic("REPORTS_TRIGGERED", 1);
|
||||
|
||||
if(plot != null && plugin.getConfigPreferences().getOption(ConfigPreferences.Option.RUN_COMMAND_ON_REPORT)
|
||||
&& (reportsAmountNeeded == -1 || user.getStat(StatsStorage.StatisticType.REPORTS) >= reportsAmountNeeded)) {
|
||||
plot.getMembers().forEach(player -> plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(),
|
||||
plugin.getConfig().getString("Run-Command-On-Report.Command", "kick %reported%")
|
||||
.replace("%reported%", player.getName()).replace("%reporter%", e.getPlayer().getName())));
|
||||
e.getPlayer().getInventory().remove(e.getItem());
|
||||
e.getPlayer().updateInventory();
|
||||
plugin.getRewardsHandler().performReward(e.getPlayer(), Reward.RewardType.REPORT, -1);
|
||||
if(plot != null && plugin.getConfigPreferences().getOption("REPORT_COMMANDS")) {
|
||||
int reportsAmountNeeded = plugin.getConfig().getInt("Report.Amount", -1);
|
||||
|
||||
if(reportsAmountNeeded == -1 || user.getStatistic("REPORTS_TRIGGERED") >= reportsAmountNeeded) {
|
||||
String reportCommand = plugin.getConfig().getString("Report.Execute", "kick %reported%");
|
||||
reportCommand = reportCommand.replace("%reporter%", event.getPlayer().getName());
|
||||
|
||||
for(org.bukkit.entity.Player player : plot.getMembers()) {
|
||||
plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(),
|
||||
reportCommand.replace("%reported%", player.getName()));
|
||||
}
|
||||
|
||||
event.getPlayer().getInventory().remove(event.getItem());
|
||||
event.getPlayer().updateInventory();
|
||||
|
||||
plugin.getRewardsHandler().performReward(event.getPlayer(), arena, plugin.getRewardsHandler().getRewardType("REPORT"));
|
||||
}
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if(plot != null && plot.getMembers().contains(e.getPlayer())) {
|
||||
e.getPlayer().sendMessage(plugin.getChatManager().getPrefix() + plugin.getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Cant-Vote-Own-Plot"));
|
||||
e.setCancelled(true);
|
||||
if(plot != null && plot.getMembers().contains(event.getPlayer())) {
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_OWN").asKey().arena(arena).player(event.getPlayer()).sendPlayer();
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
user.setStat(StatsStorage.StatisticType.LOCAL_POINTS, plugin.getVoteItems().getPoints(e.getItem()));
|
||||
plugin.getVoteItems().playVoteSound(e.getPlayer(), e.getItem());
|
||||
e.getPlayer().sendMessage(plugin.getChatManager().getPrefix() + plugin.getChatManager().colorMessage("In-Game.Messages.Voting-Messages.Vote-Successful"));
|
||||
e.setCancelled(true);
|
||||
VoteItems.VoteItem voteItem = plugin.getVoteItems().getVoteItem(event.getItem());
|
||||
if(voteItem != null) {
|
||||
plugin.getUserManager().getUser(event.getPlayer()).setStatistic("LOCAL_POINTS", plugin.getVoteItems().getPointsAndPlayVoteSound(event.getPlayer(), voteItem));
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_VOTING_SUCCESS").asKey().value(ComplementAccessor.getComplement().getDisplayName(voteItem.getItemStack().getItemMeta())).arena(arena).player(event.getPlayer()).sendPlayer();
|
||||
if(arena.getArenaType() == BaseArena.ArenaType.TEAM) {
|
||||
plot.getMembers().forEach(player -> {
|
||||
plugin.getUserManager().getUser(player).setStatistic("LOCAL_POINTS", plugin.getVoteItems().getPointsAndPlayVoteSound(player, voteItem));
|
||||
if(player != event.getPlayer()) {
|
||||
//todo add by who
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_VOTING_SUCCESS").asKey().value(ComplementAccessor.getComplement().getDisplayName(voteItem.getItemStack().getItemMeta())).arena(arena).player(event.getPlayer()).send(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -25,15 +25,13 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import plugily.projects.commonsbox.minecraft.compat.xseries.XMaterial;
|
||||
import plugily.projects.commonsbox.minecraft.compat.xseries.XSound;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.commonsbox.minecraft.item.ItemBuilder;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.configuration.ConfigUtils;
|
||||
import plugily.projects.minigamesbox.classic.utils.helper.ItemBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.xseries.XMaterial;
|
||||
import plugily.projects.minigamesbox.classic.utils.version.xseries.XSound;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@@ -45,13 +43,14 @@ public class VoteItems {
|
||||
|
||||
private final Set<VoteItem> voteItems = new HashSet<>();
|
||||
private final FileConfiguration config;
|
||||
private final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
private final Main plugin;
|
||||
|
||||
private ItemStack reportItem = new ItemStack(Material.BEDROCK, 32);
|
||||
private VoteItem reportVoteItem = new VoteItem(new ItemStack(Material.BEDROCK, 32), 8, 8 + 1, XSound.ENTITY_ARROW_HIT.parseSound());
|
||||
|
||||
public VoteItems() {
|
||||
config = ConfigUtils.getConfig(plugin, "voteItems");
|
||||
public VoteItems(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
config = ConfigUtils.getConfig(plugin, "vote_items");
|
||||
|
||||
updateVoteItemsConfig();
|
||||
loadVoteItems();
|
||||
@@ -59,26 +58,33 @@ public class VoteItems {
|
||||
|
||||
private void loadVoteItems() {
|
||||
for(String key : config.getKeys(false)) {
|
||||
if(!config.isSet(key + ".displayname")) {
|
||||
String displayName = config.getString(key + ".displayname", null);
|
||||
|
||||
if(displayName == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ItemStack stack = new ItemBuilder(XMaterial.matchXMaterial(config.getString(key + ".material-name", "BEDROCK")
|
||||
.toUpperCase()).orElse(XMaterial.BEDROCK).parseItem())
|
||||
.name(plugin.getChatManager().colorRawMessage(config.getString(key + ".displayname")))
|
||||
.toUpperCase(java.util.Locale.ENGLISH)).orElse(XMaterial.BEDROCK).parseItem())
|
||||
.name(new MessageBuilder(displayName).build())
|
||||
.build();
|
||||
|
||||
if(config.getBoolean(key + ".report-item-function")) {
|
||||
reportItem = stack;
|
||||
}
|
||||
Sound sound = null;
|
||||
Sound sound = XSound.matchXSound(config.getString(key + ".sound", "")).orElse(XSound.BLOCK_ANVIL_HIT).parseSound();
|
||||
|
||||
int slot;
|
||||
try {
|
||||
sound = Sound.valueOf(config.getString(key + ".sound", ""));
|
||||
} catch(IllegalArgumentException ignored) {
|
||||
slot = Integer.parseInt(key);
|
||||
} catch(NumberFormatException e) {
|
||||
continue;
|
||||
}
|
||||
int s = Integer.parseInt(key);
|
||||
VoteItem voteItem = new VoteItem(stack, s, s + 1, sound);
|
||||
reportVoteItem = voteItem;
|
||||
|
||||
VoteItem voteItem = new VoteItem(stack, slot, slot + 1, sound);
|
||||
|
||||
if(config.getBoolean(key + ".report-item-function", false)) {
|
||||
reportItem = stack;
|
||||
reportVoteItem = voteItem;
|
||||
}
|
||||
|
||||
voteItems.add(voteItem);
|
||||
}
|
||||
}
|
||||
@@ -89,25 +95,25 @@ public class VoteItems {
|
||||
continue;
|
||||
}
|
||||
config.set(key + ".material-name", XMaterial.GREEN_TERRACOTTA.name());
|
||||
Debugger.debug(Debugger.Level.WARN, "Found outdated item in votingItems.yml! We've converted it to the newest version!");
|
||||
plugin.getDebugger().debug("Found outdated item in vote_items.yml! We've converted it to the newest version!");
|
||||
}
|
||||
ConfigUtils.saveConfig(plugin, config, "voteItems");
|
||||
ConfigUtils.saveConfig(plugin, config, "vote_items");
|
||||
}
|
||||
|
||||
public void giveVoteItems(Player player) {
|
||||
for(VoteItem voteItem : voteItems) {
|
||||
player.getInventory().setItem(voteItem.getSlot(), voteItem.getItemStack());
|
||||
player.getInventory().setItem(voteItem.slot, voteItem.itemStack);
|
||||
}
|
||||
player.updateInventory();
|
||||
}
|
||||
|
||||
public void playVoteSound(Player player, ItemStack itemStack) {
|
||||
for(VoteItem item : voteItems) {
|
||||
if(item.getItemStack().isSimilar(itemStack)) {
|
||||
if(item.getSound() == null) {
|
||||
if(item.itemStack.isSimilar(itemStack)) {
|
||||
if(item.sound == null) {
|
||||
return;
|
||||
}
|
||||
player.playSound(player.getLocation(), item.getSound(), 1, 1);
|
||||
player.playSound(player.getLocation(), item.sound, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,13 +126,30 @@ public class VoteItems {
|
||||
*/
|
||||
public int getPoints(ItemStack itemStack) {
|
||||
for(VoteItem item : voteItems) {
|
||||
if(item.getItemStack().isSimilar(itemStack)) {
|
||||
return item.getPoints();
|
||||
if(item.itemStack.isSimilar(itemStack)) {
|
||||
return item.points;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int getPointsAndPlayVoteSound(Player player, VoteItem voteItem) {
|
||||
if(voteItem.sound == null) {
|
||||
return voteItem.points;
|
||||
}
|
||||
player.playSound(player.getLocation(), voteItem.sound, 1, 1);
|
||||
return voteItem.points;
|
||||
}
|
||||
|
||||
public VoteItem getVoteItem(ItemStack itemStack) {
|
||||
for(VoteItem item : voteItems) {
|
||||
if(item.itemStack.isSimilar(itemStack)) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return itemStack that represents report building function
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.boot;
|
||||
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.minigamesbox.api.preferences.IConfigPreferences;
|
||||
import plugily.projects.minigamesbox.classic.api.StatisticType;
|
||||
import plugily.projects.minigamesbox.classic.api.StatsStorage;
|
||||
import plugily.projects.minigamesbox.classic.arena.options.ArenaOption;
|
||||
import plugily.projects.minigamesbox.classic.arena.options.ArenaOptionManager;
|
||||
import plugily.projects.minigamesbox.classic.handlers.items.SpecialItemManager;
|
||||
import plugily.projects.minigamesbox.classic.handlers.permissions.PermissionCategory;
|
||||
import plugily.projects.minigamesbox.classic.handlers.permissions.PermissionsManager;
|
||||
import plugily.projects.minigamesbox.classic.handlers.reward.RewardType;
|
||||
import plugily.projects.minigamesbox.classic.handlers.reward.RewardsFactory;
|
||||
import plugily.projects.minigamesbox.classic.preferences.ConfigOption;
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
* <p>
|
||||
* Created at 15.10.2022
|
||||
*/
|
||||
public class AdditionalValueInitializer {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public AdditionalValueInitializer(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
registerConfigOptions();
|
||||
registerStatistics();
|
||||
registerPermission();
|
||||
registerRewards();
|
||||
registerSpecialItems();
|
||||
registerArenaOptions();
|
||||
}
|
||||
|
||||
private void registerConfigOptions() {
|
||||
IConfigPreferences configPreferences = plugin.getConfigPreferences();
|
||||
|
||||
configPreferences.registerOption("MOB_SPAWN", new ConfigOption("Mob.Spawn", false));
|
||||
configPreferences.registerOption("HEAD_MENU_CUSTOM", new ConfigOption("Head-Menu.Custom", false));
|
||||
configPreferences.registerOption("REPORT_COMMANDS", new ConfigOption("Report.Commands", false));
|
||||
configPreferences.registerOption("PLOT_HIDE_OWNER", new ConfigOption("Plot.Hide-Owner", false));
|
||||
configPreferences.registerOption("PLOT_MOVE_OUTSIDE", new ConfigOption("Plot.Move-Outside", false));
|
||||
configPreferences.registerOption("SUPER_VOTES", new ConfigOption("Super-Votes", true));
|
||||
}
|
||||
|
||||
private void registerStatistics() {
|
||||
StatsStorage statsStorage = plugin.getStatsStorage();
|
||||
|
||||
statsStorage.registerStatistic("BLOCKS_PLACED", new StatisticType("blocks_placed", true, "int(11) NOT NULL DEFAULT '0'"));
|
||||
statsStorage.registerStatistic("BLOCKS_BROKEN", new StatisticType("blocks_broken", true, "int(11) NOT NULL DEFAULT '0'"));
|
||||
statsStorage.registerStatistic("POINTS_HIGHEST", new StatisticType("points_highest", true, "int(11) NOT NULL DEFAULT '0'"));
|
||||
statsStorage.registerStatistic("POINTS_HIGHEST_WIN", new StatisticType("points_highest_win", true, "int(11) NOT NULL DEFAULT '0'"));
|
||||
statsStorage.registerStatistic("POINTS_TOTAL", new StatisticType("points_total", true, "int(11) NOT NULL DEFAULT '0'"));
|
||||
statsStorage.registerStatistic("PARTICLES_USED", new StatisticType("particles_used", true, "int(11) NOT NULL DEFAULT '0'"));
|
||||
statsStorage.registerStatistic("SUPER_VOTES", new StatisticType("super_votes", true, "int(11) NOT NULL DEFAULT '0'"));
|
||||
statsStorage.registerStatistic("LOCAL_POINTS", new StatisticType("local_points", false, "int(11) NOT NULL DEFAULT '0'"));
|
||||
statsStorage.registerStatistic("LOCAL_POINTS_GTB", new StatisticType("local_points_gtb", false, "int(11) NOT NULL DEFAULT '0'"));
|
||||
statsStorage.registerStatistic("REPORTS_TRIGGERED", new StatisticType("reports_triggered", false, "int(11) NOT NULL DEFAULT '0'"));
|
||||
}
|
||||
|
||||
private void registerPermission() {
|
||||
PermissionsManager permissionsManager = plugin.getPermissionsManager();
|
||||
|
||||
permissionsManager.registerPermissionCategory("POINTS_BOOSTER", new PermissionCategory("Points-Boost", null));
|
||||
permissionsManager.registerPermissionCategory("VOTING_BOOSTER", new PermissionCategory("Voting-Boost", null));
|
||||
}
|
||||
|
||||
private void registerRewards() {
|
||||
RewardsFactory rewardsFactory = plugin.getRewardsHandler();
|
||||
|
||||
rewardsFactory.registerRewardType("GUESS", new RewardType("guessed"));
|
||||
rewardsFactory.registerRewardType("GUESS_ALL", new RewardType("guessed-all"));
|
||||
rewardsFactory.registerRewardType("VOTE", new RewardType("voted"));
|
||||
rewardsFactory.registerRewardType("VOTE_ALL", new RewardType("voted-all"));
|
||||
rewardsFactory.registerRewardType("REPORT", new RewardType("report"));
|
||||
rewardsFactory.registerRewardType("PLACE", new RewardType("place"));
|
||||
}
|
||||
|
||||
private void registerSpecialItems() {
|
||||
SpecialItemManager specialItemManager = plugin.getSpecialItemManager();
|
||||
|
||||
specialItemManager.registerSpecialItem("OPTIONS_MENU", "Options-Menu");
|
||||
specialItemManager.registerSpecialItem("PLOT_SELECTOR", "Plot-Selector");
|
||||
}
|
||||
|
||||
private void registerArenaOptions() {
|
||||
ArenaOptionManager arenaOptionManager = plugin.getArenaOptionManager();
|
||||
|
||||
arenaOptionManager.registerArenaOption("IN_PLOT_CHECKER", new ArenaOption("null", 0, true));
|
||||
arenaOptionManager.registerArenaOption("PLOT_MEMBER_SIZE", new ArenaOption("plotmembersize", 1, true));
|
||||
arenaOptionManager.registerArenaOption("GTB_ROUNDS_PER_PLOT", new ArenaOption("roundsperplot", 2, true));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.boot;
|
||||
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.Message;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageManager;
|
||||
import plugily.projects.minigamesbox.classic.utils.services.locale.Locale;
|
||||
import plugily.projects.minigamesbox.classic.utils.services.locale.LocaleRegistry;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
* <p>
|
||||
* Created at 15.10.2022
|
||||
*/
|
||||
public class MessageInitializer {
|
||||
private final Main plugin;
|
||||
|
||||
public MessageInitializer(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void registerMessages() {
|
||||
MessageManager messageManager = plugin.getMessageManager();
|
||||
|
||||
messageManager.registerMessage("COMMANDS_THEME_BLACKLISTED", new Message("Commands.Theme-Blacklisted", ""));
|
||||
messageManager.registerMessage("COMMANDS_ADMIN_ADDED_PLOT", new Message("Commands.Admin.Added-Plot", ""));
|
||||
messageManager.registerMessage("SCOREBOARD_THEME_UNKNOWN", new Message("Scoreboard.Theme-Unknown", ""));
|
||||
// scoreboard ingame classic/teams/guess-the-build/guess-the-build-waiting | ending classic/guess-the-build
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_GAME_END_PLACEHOLDERS_WINNER", new Message("In-Game.Messages.Game-End.Placeholders.Winner", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_GAME_END_PLACEHOLDERS_PLACE", new Message("In-Game.Messages.Game-End.Placeholders.Place", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_GAME_END_PLACEHOLDERS_OWN", new Message("In-Game.Messages.Game-End.Placeholders.Own", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_ADMIN_CHANGED_THEME", new Message("In-Game.Messages.Admin.Changed-Theme", ""));
|
||||
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_", new Message("In-Game.Messages.Plot.", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_NOBODY", new Message("In-Game.Messages.Plot.Nobody", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_TIME_LEFT_TITLE", new Message("In-Game.Messages.Plot.Time-Left.Title", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_TIME_LEFT_CHAT", new Message("In-Game.Messages.Plot.Time-Left.Chat", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_LIMIT_ENTITIES", new Message("In-Game.Messages.Plot.Limit.Entities", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_LIMIT_PARTICLES", new Message("In-Game.Messages.Plot.Limit.Particles", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_PERMISSION_HEAD", new Message("In-Game.Messages.Plot.Permission.Head", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_PERMISSION_PARTICLE", new Message("In-Game.Messages.Plot.Permission.Particle", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_PERMISSION_BIOME", new Message("In-Game.Messages.Plot.Permission.Biome", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_PERMISSION_OUTSIDE", new Message("In-Game.Messages.Plot.Permission.Outside", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_PERMISSION_FLOOR_ITEM", new Message("In-Game.Messages.Plot.Permission.Floor-Item", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_SELECTOR_FULL", new Message("In-Game.Messages.Plot.Selector.Full", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_SELECTOR_EMPTY", new Message("In-Game.Messages.Plot.Selector.Empty", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_SELECTOR_INSIDE", new Message("In-Game.Messages.Plot.Selector.Inside", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_SELECTOR_NAME", new Message("In-Game.Messages.Plot.Selector.Name", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_SELECTOR_MENU_NAME", new Message("In-Game.Messages.Plot.Selector.Menu-Name", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_SELECTOR_PLOT_CHOOSE", new Message("In-Game.Messages.Plot.Selector.Plot-Choose", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_SELECTOR_MEMBER", new Message("In-Game.Messages.Plot.Selector.Member", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_VOTING_NAME", new Message("In-Game.Messages.Plot.Voting.Name", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_CHAT", new Message("In-Game.Messages.Plot.Voting.Plot-Owner.Chat", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_TITLE", new Message("In-Game.Messages.Plot.Voting.Plot-Owner.Title", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_NEXT", new Message("In-Game.Messages.Plot.Voting.Plot-Owner.Next", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_WAS", new Message("In-Game.Messages.Plot.Voting.Plot-Owner.Was", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_VOTING_PLOT_OWNER_OWN", new Message("In-Game.Messages.Plot.Voting.Plot-Owner.Own", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_VOTING_SUCCESS", new Message("In-Game.Messages.Plot.Voting.Success", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_VOTING_WINNER", new Message("In-Game.Messages.Plot.Voting.Winner", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_BUILDER", new Message("In-Game.Messages.Plot.Guess-The-Build.Builder", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_ROUND", new Message("In-Game.Messages.Plot.Guess-The-Build.Round", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_THEME_CHARS", new Message("In-Game.Messages.Plot.Guess-The-Build.Theme.Chars", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_THEME_NAME", new Message("In-Game.Messages.Plot.Guess-The-Build.Theme.Name", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_THEME_WAS", new Message("In-Game.Messages.Plot.Guess-The-Build.Theme.Was", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_THEME_TITLE", new Message("In-Game.Messages.Plot.Guess-The-Build.Theme.Title", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESSED", new Message("In-Game.Messages.Plot.Guess-The-Build.Theme.Guessed", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_THEME_BEING_SELECTED", new Message("In-Game.Messages.Plot.Guess-The-Build.Theme.Being-Selected", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_TITLE", new Message("In-Game.Messages.Plot.Guess-The-Build.Theme.Guess.Title", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_POINTS", new Message("In-Game.Messages.Plot.Guess-The-Build.Theme.Guess.Points", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_GUESSED", new Message("In-Game.Messages.Plot.Guess-The-Build.Theme.Guess.Guessed", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_CANT_TALK", new Message("In-Game.Messages.Plot.Guess-The-Build.Theme.Guess.Cant-Talk", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_BUILDER", new Message("In-Game.Messages.Plot.Guess-The-Build.Theme.Guess.Builder", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_NPC_NAME", new Message("In-Game.Messages.Plot.NPC.Name", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_NPC_CREATED", new Message("In-Game.Messages.Plot.NPC.Created", ""));
|
||||
messageManager.registerMessage("IN_GAME_MESSAGES_PLOT_NPC_CITIZENS", new Message("In-Game.Messages.Plot.NPC.Install-Citizens", ""));
|
||||
|
||||
|
||||
messageManager.registerMessage("MENU_PERMISSION", new Message("Menu.Permission", ""));
|
||||
messageManager.registerMessage("MENU_BUTTONS_BACK_ITEM_NAME", new Message("Menu.Buttons.Back.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_BUTTONS_BACK_ITEM_LORE", new Message("Menu.Buttons.Back.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_LOCATION", new Message("Menu.Location", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_INVENTORY", new Message("Menu.Option.Inventory", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_PARTICLE_INVENTORY", new Message("Menu.Option.Content.Particle.Inventory", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_PARTICLE_ITEM_NAME", new Message("Menu.Option.Content.Particle.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_PARTICLE_ITEM_LORE", new Message("Menu.Option.Content.Particle.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_PARTICLE_ITEM_REMOVE_NAME", new Message("Menu.Option.Content.Particle.Item.Remove.Name", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_PARTICLE_ITEM_REMOVE_LORE", new Message("Menu.Option.Content.Particle.Item.Remove.Lore", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_PARTICLE_ADDED", new Message("Menu.Option.Content.Particle.Added", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_PARTICLE_REMOVED", new Message("Menu.Option.Content.Particle.Removed", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_HEADS_INVENTORY", new Message("Menu.Option.Content.Heads.Inventory", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_HEADS_ITEM_NAME", new Message("Menu.Option.Content.Heads.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_HEADS_ITEM_LORE", new Message("Menu.Option.Content.Heads.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_FLOOR_ITEM_NAME", new Message("Menu.Option.Content.Floor.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_FLOOR_ITEM_LORE", new Message("Menu.Option.Content.Floor.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_FLOOR_CHANGED", new Message("Menu.Option.Content.Floor.Changed", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_TIME_INVENTORY", new Message("Menu.Option.Content.Time.Inventory", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_TIME_ITEM_NAME", new Message("Menu.Option.Content.Time.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_TIME_ITEM_LORE", new Message("Menu.Option.Content.Time.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_TIME_TYPE_WORLD", new Message("Menu.Option.Content.Time.Type.World", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_TIME_TYPE_DAY", new Message("Menu.Option.Content.Time.Type.Day", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_TIME_TYPE_NOON", new Message("Menu.Option.Content.Time.Type.Noon", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_TIME_TYPE_SUNSET", new Message("Menu.Option.Content.Time.Type.Sunset", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_TIME_TYPE_NIGHT", new Message("Menu.Option.Content.Time.Type.Night", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_TIME_TYPE_MIDNIGHT", new Message("Menu.Option.Content.Time.Type.MidNight", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_TIME_TYPE_SUNRISE", new Message("Menu.Option.Content.Time.Type.Sunrise", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_TIME_CHANGED", new Message("Menu.Option.Content.Time.Changed", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BIOME_INVENTORY", new Message("Menu.Option.Content.Biome.Inventory", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BIOME_ITEM_NAME", new Message("Menu.Option.Content.Biome.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BIOME_ITEM_LORE", new Message("Menu.Option.Content.Biome.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BIOME_CHANGED", new Message("Menu.Option.Content.Biome.Changed", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_WEATHER_INVENTORY", new Message("Menu.Option.Content.Weather.Inventory", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_WEATHER_ITEM_NAME", new Message("Menu.Option.Content.Weather.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_WEATHER_ITEM_LORE", new Message("Menu.Option.Content.Weather.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_WEATHER_TYPE_DOWNFALL", new Message("Menu.Option.Content.Weather.Type.Downfall", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_WEATHER_TYPE_CLEAR", new Message("Menu.Option.Content.Weather.Type.Clear", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_WEATHER_CHANGED", new Message("Menu.Option.Content.Weather.Changed", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BANNER_INVENTORY_COLOR", new Message("Menu.Option.Content.Banner.Inventory.Color", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BANNER_INVENTORY_LAYER", new Message("Menu.Option.Content.Banner.Inventory.Layer", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BANNER_INVENTORY_LAYER_COLOR", new Message("Menu.Option.Content.Banner.Inventory.Layer-Color", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BANNER_ITEM_NAME", new Message("Menu.Option.Content.Banner.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BANNER_ITEM_LORE", new Message("Menu.Option.Content.Banner.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BANNER_ITEM_CREATE_NAME", new Message("Menu.Option.Content.Banner.Item.Create.Name", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BANNER_ITEM_CREATE_LORE", new Message("Menu.Option.Content.Banner.Item.Create.Lore", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_BANNER_CHANGED", new Message("Menu.Option.Content.Banner.Changed", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_RESET_ITEM_NAME", new Message("Menu.Option.Content.Reset.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_RESET_ITEM_LORE", new Message("Menu.Option.Content.Reset.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_OPTION_CONTENT_RESET_CHAT", new Message("Menu.Option.Content.Reset.Chat", ""));
|
||||
messageManager.registerMessage("MENU_THEME_INVENTORY", new Message("Menu.Theme.Inventory", ""));
|
||||
messageManager.registerMessage("MENU_THEME_ITEM_NAME", new Message("Menu.Theme.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_THEME_ITEM_LORE", new Message("Menu.Theme.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_THEME_VOTE_SUCCESS", new Message("Menu.Theme.Vote.Success", ""));
|
||||
messageManager.registerMessage("MENU_THEME_VOTE_ALREADY", new Message("Menu.Theme.Vote.Already", ""));
|
||||
messageManager.registerMessage("MENU_THEME_VOTE_SUPER_ITEM_NAME", new Message("Menu.Theme.Vote.Super.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_THEME_VOTE_SUPER_ITEM_LORE", new Message("Menu.Theme.Vote.Super.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_THEME_VOTE_SUPER_USED", new Message("Menu.Theme.Vote.Super.Used", ""));
|
||||
messageManager.registerMessage("MENU_THEME_GTB_INVENTORY", new Message("Menu.Theme.Guess-The-Build.Inventory", ""));
|
||||
messageManager.registerMessage("MENU_THEME_GTB_ITEM_NAME", new Message("Menu.Theme.Guess-The-Build.Item.Name", ""));
|
||||
messageManager.registerMessage("MENU_THEME_GTB_ITEM_LORE", new Message("Menu.Theme.Guess-The-Build.Item.Lore", ""));
|
||||
messageManager.registerMessage("MENU_THEME_GTB_DIFFICULTIES_EASY", new Message("Menu.Theme.Guess-The-Build.Difficulties.Easy", ""));
|
||||
messageManager.registerMessage("MENU_THEME_GTB_DIFFICULTIES_MEDIUM", new Message("Menu.Theme.Guess-The-Build.Difficulties.Medium", ""));
|
||||
messageManager.registerMessage("MENU_THEME_GTB_DIFFICULTIES_HARD", new Message("Menu.Theme.Guess-The-Build.Difficulties.Hard", ""));
|
||||
|
||||
messageManager.registerMessage("LEADERBOARD_STATISTICS_POINTS_HIGHEST_WIN", new Message("Leaderboard.Statistics.Highest-Win", ""));
|
||||
messageManager.registerMessage("LEADERBOARD_STATISTICS_POINTS_HIGHEST", new Message("Leaderboard.Statistics.Highest-Points", ""));
|
||||
messageManager.registerMessage("LEADERBOARD_STATISTICS_POINTS_TOTAL", new Message("Leaderboard.Statistics.Total-Points-Earned", ""));
|
||||
messageManager.registerMessage("LEADERBOARD_STATISTICS_BLOCKS_PLACED", new Message("Leaderboard.Statistics.Blocks-Placed", ""));
|
||||
messageManager.registerMessage("LEADERBOARD_STATISTICS_BLOCKS_BROKEN", new Message("Leaderboard.Statistics.Blocks-Broken", ""));
|
||||
messageManager.registerMessage("LEADERBOARD_STATISTICS_PARTICLES_USED", new Message("Leaderboard.Statistics.Particles-Placed", ""));
|
||||
messageManager.registerMessage("LEADERBOARD_STATISTICS_SUPER_VOTES", new Message("Leaderboard.Statistics.Super-Votes", ""));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,483 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.boot;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.BuildArena;
|
||||
import plugily.projects.buildbattle.arena.GuessArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.handlers.themes.BBTheme;
|
||||
import plugily.projects.minigamesbox.api.arena.IArenaState;
|
||||
import plugily.projects.minigamesbox.api.arena.IPluginArena;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.handlers.placeholder.Placeholder;
|
||||
import plugily.projects.minigamesbox.classic.handlers.placeholder.PlaceholderManager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
* <p>
|
||||
* Created at 15.10.2022
|
||||
*/
|
||||
public class PlaceholderInitializer {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public PlaceholderInitializer(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
registerPlaceholders();
|
||||
}
|
||||
|
||||
private void registerPlaceholders() {
|
||||
PlaceholderManager placeholderManager = plugin.getPlaceholderManager();
|
||||
ArenaRegistry arenaRegistry = plugin.getArenaRegistry();
|
||||
|
||||
placeholderManager.registerPlaceholder(new Placeholder("theme", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getTheme(player, arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getTheme(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getTheme(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
String theme = pluginArena.getTheme();
|
||||
if(theme.equalsIgnoreCase("theme")) {
|
||||
theme = new MessageBuilder("SCOREBOARD_THEME_UNKNOWN").asKey().build();
|
||||
}
|
||||
return theme;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getTheme(Player player, IPluginArena arena) {
|
||||
String theme = getTheme(arena);
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
if(!(pluginArena instanceof GuessArena)) {
|
||||
return theme;
|
||||
}
|
||||
if(theme.equalsIgnoreCase(new MessageBuilder("SCOREBOARD_THEME_UNKNOWN").asKey().build())) {
|
||||
if(((GuessArena) pluginArena).getCurrentBuilders().contains(player) || ((GuessArena) pluginArena).getWhoGuessed().contains(player)) {
|
||||
BBTheme guessTheme = ((GuessArena) pluginArena).getCurrentBBTheme();
|
||||
theme = guessTheme == null ? new MessageBuilder("SCOREBOARD_THEME_UNKNOWN").asKey().build() : guessTheme.getTheme();
|
||||
}
|
||||
}
|
||||
return theme;
|
||||
}
|
||||
});
|
||||
|
||||
placeholderManager.registerPlaceholder(new Placeholder("difficulty", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getTheme(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getTheme(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getTheme(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena instanceof GuessArena) {
|
||||
BBTheme theme = ((GuessArena) pluginArena).getCurrentBBTheme();
|
||||
if(theme == null) {
|
||||
return null;
|
||||
}
|
||||
return theme.getDifficulty().name();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
placeholderManager.registerPlaceholder(new Placeholder("difficulty_points_reward", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getTheme(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getTheme(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getTheme(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena instanceof GuessArena) {
|
||||
BBTheme theme = ((GuessArena) pluginArena).getCurrentBBTheme();
|
||||
if(theme == null) {
|
||||
return "0";
|
||||
}
|
||||
return Integer.toString(theme.getDifficulty().getPointsReward());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
placeholderManager.registerPlaceholder(new Placeholder("builder", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getBuilder(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getBuilder(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getBuilder(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(!(pluginArena instanceof GuessArena)) {
|
||||
return null;
|
||||
}
|
||||
if(((GuessArena) pluginArena).getBuildPlot() == null || ((GuessArena) pluginArena).getBuildPlot().getMembers().isEmpty()) {
|
||||
return "???";
|
||||
}
|
||||
return ((GuessArena) pluginArena).getBuildPlot().getFormattedMembers();
|
||||
}
|
||||
});
|
||||
|
||||
placeholderManager.registerPlaceholder(new Placeholder("type", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getType(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getType(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getType(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
return pluginArena.getArenaType().toString();
|
||||
}
|
||||
});
|
||||
placeholderManager.registerPlaceholder(new Placeholder("type_pretty", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getType(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getType(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getType(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
return pluginArena.getArenaType().getPrefix();
|
||||
}
|
||||
});
|
||||
for(int i = 1; i <= 32; i++) {
|
||||
final int number = i;
|
||||
placeholderManager.registerPlaceholder(new Placeholder("place_member_" + number, Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getPlace(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getPlace(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getPlace(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
if(pluginArena.getArenaInGameState() != BaseArena.ArenaInGameState.PLOT_VOTING && pluginArena.getArenaState() != IArenaState.ENDING) {
|
||||
return "???";
|
||||
}
|
||||
List<Plot> plotRanking = pluginArena.getPlotManager().getTopPlotsOrder();
|
||||
if(plotRanking.size() < number) {
|
||||
return "???";
|
||||
}
|
||||
StringBuilder members = new StringBuilder();
|
||||
plotRanking.get(number - 1).getMembers().forEach(player -> members.append(player.getName()).append(" & "));
|
||||
members.delete(members.length() - 3, members.length());
|
||||
return new MessageBuilder(members.toString()).build();
|
||||
}
|
||||
});
|
||||
|
||||
placeholderManager.registerPlaceholder(new Placeholder("place_points_" + number, Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getPlace(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getPlace(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getPlace(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
if(pluginArena.getArenaInGameState() != BaseArena.ArenaInGameState.PLOT_VOTING && pluginArena.getArenaState() != IArenaState.ENDING) {
|
||||
return "???";
|
||||
}
|
||||
List<Plot> plotRanking = pluginArena.getPlotManager().getTopPlotsOrder();
|
||||
if(plotRanking.size() < number) {
|
||||
return "???";
|
||||
}
|
||||
return String.valueOf(plotRanking.get(number - 1).getPoints());
|
||||
}
|
||||
});
|
||||
}
|
||||
placeholderManager.registerPlaceholder(new Placeholder("ingame_state", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getState(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getState(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getState(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
if(pluginArena.getArenaInGameState() == null) {
|
||||
return null;
|
||||
}
|
||||
return pluginArena.getArenaInGameState().toString();
|
||||
}
|
||||
});
|
||||
|
||||
placeholderManager.registerPlaceholder(new Placeholder("ingame_state_pretty", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getState(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getState(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getState(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
if(pluginArena.getArenaInGameState() == null) {
|
||||
return null;
|
||||
}
|
||||
return pluginArena.getArenaInGameState().getPrefix();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
placeholderManager.registerPlaceholder(new Placeholder("teammates", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getMembers(player, arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getMembers(Player player, IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
if(!(pluginArena instanceof BuildArena)) {
|
||||
return new MessageBuilder("IN_GAME_MESSAGES_PLOT_NOBODY").asKey().build();
|
||||
}
|
||||
Plot plot = pluginArena.getPlotManager().getPlot(player);
|
||||
|
||||
if(plot != null) {
|
||||
if(plot.getMembers().size() > 1) {
|
||||
StringBuilder members = new StringBuilder();
|
||||
plot.getMembers().forEach(p -> members.append(p.getName()).append(" & "));
|
||||
members.delete(members.length() - 3, members.length());
|
||||
return new MessageBuilder(members.toString()).build();
|
||||
}
|
||||
}
|
||||
return new MessageBuilder("IN_GAME_MESSAGES_PLOT_NOBODY").asKey().build();
|
||||
}
|
||||
});
|
||||
|
||||
placeholderManager.registerPlaceholder(new Placeholder("summary_player", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getSummary(arena, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getSummary(IPluginArena arena, Player player) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
Plot plot = pluginArena.getWinnerPlot();
|
||||
if(plot != null && !plot.getMembers().isEmpty() && plot.getMembers().contains(player)) {
|
||||
return new MessageBuilder("IN_GAME_MESSAGES_GAME_END_PLACEHOLDERS_WIN").asKey().arena(pluginArena).build();
|
||||
}
|
||||
return new MessageBuilder("IN_GAME_MESSAGES_GAME_END_PLACEHOLDERS_LOSE").asKey().arena(pluginArena).build();
|
||||
}
|
||||
});
|
||||
|
||||
placeholderManager.registerPlaceholder(new Placeholder("summary_place_own", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getSummary(arena, player);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getSummary(IPluginArena arena, Player player) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
if(pluginArena.getArenaInGameState() != BaseArena.ArenaInGameState.PLOT_VOTING && pluginArena.getArenaState() != IArenaState.ENDING) {
|
||||
return null;
|
||||
}
|
||||
List<Plot> plotRanking = pluginArena.getPlotManager().getTopPlotsOrder();
|
||||
List<Plot> potentialPlot = plotRanking.stream().filter(plot -> plot.getMembers().contains(player)).collect(Collectors.toList());
|
||||
if(potentialPlot.isEmpty()) {
|
||||
return new MessageBuilder("IN_GAME_MESSAGES_GAME_END_PLACEHOLDERS_OWN").asKey().integer(0).arena(pluginArena).build();
|
||||
}
|
||||
int plotIndex = plotRanking.indexOf(potentialPlot.get(0));
|
||||
if(plotIndex == -1) {
|
||||
return new MessageBuilder("IN_GAME_MESSAGES_GAME_END_PLACEHOLDERS_OWN").asKey().integer(0).arena(pluginArena).build();
|
||||
}
|
||||
return new MessageBuilder("IN_GAME_MESSAGES_GAME_END_PLACEHOLDERS_OWN").asKey().integer(plotIndex + 1).arena(pluginArena).build();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
placeholderManager.registerPlaceholder(new Placeholder("summary", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getSummary(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getSummary(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getSummary(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
Plot plot = pluginArena.getWinnerPlot();
|
||||
if(plot != null && !plot.getMembers().isEmpty()) {
|
||||
return new MessageBuilder("IN_GAME_MESSAGES_GAME_END_PLACEHOLDERS_WINNER").asKey().arena(pluginArena).build();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
placeholderManager.registerPlaceholder(new Placeholder("summary_place_list", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getSummary(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getSummary(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getSummary(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
if(pluginArena.getArenaInGameState() != BaseArena.ArenaInGameState.PLOT_VOTING && pluginArena.getArenaState() != IArenaState.ENDING) {
|
||||
return null;
|
||||
}
|
||||
int places = pluginArena.getPlotManager().getTopPlotsOrder().size();
|
||||
if(places > 16) {
|
||||
places = 16;
|
||||
}
|
||||
StringBuilder placeSummary = new StringBuilder();
|
||||
for(int i = 1; i <= places; i++) {
|
||||
//number = place, value = members + points
|
||||
placeSummary.append("\n").append(new MessageBuilder("IN_GAME_MESSAGES_GAME_END_PLACEHOLDERS_PLACE").asKey().integer(i).value("%arena_place_member_" + i + "% (%arena_place_points_" + i + "%)").arena(pluginArena).build());
|
||||
}
|
||||
return placeSummary.toString();
|
||||
}
|
||||
});
|
||||
placeholderManager.registerPlaceholder(new Placeholder("gtb_rounds", Placeholder.PlaceholderType.ARENA, Placeholder.PlaceholderExecutor.ALL) {
|
||||
@Override
|
||||
public String getValue(Player player, IPluginArena arena) {
|
||||
return getSummary(arena);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue(IPluginArena arena) {
|
||||
return getSummary(arena);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String getSummary(IPluginArena arena) {
|
||||
BaseArena pluginArena = arenaRegistry.getArena(arena.getId());
|
||||
if(pluginArena == null) {
|
||||
return null;
|
||||
}
|
||||
return String.valueOf(pluginArena.getPlotList().size() * pluginArena.getArenaOption("GTB_ROUNDS_PER_PLOT"));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 27.05.2018
|
||||
*/
|
||||
public class TabCompletion implements TabCompleter {
|
||||
|
||||
private final ArgumentsRegistry registry;
|
||||
|
||||
public TabCompletion(ArgumentsRegistry registry) {
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender sender, Command cmd, @NotNull String label, String[] args) {
|
||||
List<String> cmds = new ArrayList<>();
|
||||
|
||||
if(cmd.getName().equalsIgnoreCase("buildbattleadmin")) {
|
||||
if(args.length == 1) {
|
||||
cmds.addAll(registry.getMappedArguments().get("buildbattleadmin").stream().map(CommandArgument::getArgumentName)
|
||||
.collect(Collectors.toList()));
|
||||
} else if(args.length == 2) {
|
||||
if(args[0].equalsIgnoreCase("delete") || args[0].equalsIgnoreCase("removeplot")
|
||||
|| args[0].equalsIgnoreCase("addnpc") || args[0].equalsIgnoreCase("addplot")) {
|
||||
cmds.addAll(ArenaRegistry.getArenas().stream().map(BaseArena::getID).collect(Collectors.toList()));
|
||||
} else if(args[0].equalsIgnoreCase("settheme")) {
|
||||
for(List<String> l : registry.getPlugin().getConfigPreferences().getGameThemes().values()) {
|
||||
cmds.addAll(l);
|
||||
}
|
||||
} else if(args[0].equalsIgnoreCase("votes")) {
|
||||
cmds.addAll(Arrays.asList("add", "set"));
|
||||
}
|
||||
} else if(args.length == 3 && args[0].equalsIgnoreCase("removeplot")) {
|
||||
BaseArena arena = ArenaRegistry.getArena(args[1]);
|
||||
if (arena != null) {
|
||||
FileConfiguration config = ConfigUtils.getConfig(registry.getPlugin(), "arenas");
|
||||
org.bukkit.configuration.ConfigurationSection section =
|
||||
config.getConfigurationSection("instances." + arena.getID() + ".plots");
|
||||
if (section != null) {
|
||||
cmds.addAll(section.getKeys(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cmds.isEmpty() ? null : cmds; // Completes the player names
|
||||
}
|
||||
|
||||
if(cmd.getName().equalsIgnoreCase("buildbattle")) {
|
||||
if(args.length == 2 && (args[0].equalsIgnoreCase("join") || args[0].equalsIgnoreCase("randomjoin"))) {
|
||||
if(args[0].equalsIgnoreCase("randomjoin")) {
|
||||
cmds.addAll(Arrays.asList("solo", "team", "gtb", "guess_the_build"));
|
||||
} else {
|
||||
cmds.addAll(ArenaRegistry.getArenas().stream().map(BaseArena::getID).collect(Collectors.toList()));
|
||||
}
|
||||
} else if(args.length == 1) {
|
||||
cmds.addAll(registry.getMappedArguments().get("buildbattle").stream().map(CommandArgument::getArgumentName)
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
|
||||
return cmds.isEmpty() ? null : cmds; // Completes the player names
|
||||
}
|
||||
}
|
||||
+23
-216
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -20,247 +20,54 @@
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments;
|
||||
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.chat.hover.content.Text;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.TabCompletion;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.ListArenasArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.ReloadArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.TeleportArgument;
|
||||
import plugily.projects.buildbattle.arena.BuildArena;
|
||||
import plugily.projects.buildbattle.arena.GuessArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.ThemeArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.arena.AddNpcArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.arena.DeleteArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.arena.ForceStartArguments;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.arena.SetThemeArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.arena.StopArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.plot.AddPlotArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.plot.PlotWandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.plot.RemovePlotArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.plot.SelectPlotArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.admin.votes.VotesArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.game.ArenaSelectorArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.game.CreateArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.game.GuessArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.game.JoinArguments;
|
||||
import plugily.projects.buildbattle.commands.arguments.game.LeaderboardArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.game.LeaveArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.game.StatsArgument;
|
||||
import plugily.projects.buildbattle.handlers.setup.SetupInventory;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
import plugily.projects.commonsbox.minecraft.compat.ServerVersion;
|
||||
import plugily.projects.commonsbox.string.StringMatcher;
|
||||
import plugily.projects.minigamesbox.api.arena.IPluginArena;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.PluginArgumentsRegistry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 03.12.2018
|
||||
* <p>Created at 24.11.2018
|
||||
*/
|
||||
public class ArgumentsRegistry implements CommandExecutor {
|
||||
|
||||
private final Map<String, List<CommandArgument>> mappedArguments = new HashMap<>();
|
||||
private final Main plugin;
|
||||
public class ArgumentsRegistry extends PluginArgumentsRegistry {
|
||||
|
||||
public ArgumentsRegistry(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
TabCompletion completion = new TabCompletion(this);
|
||||
Optional.ofNullable(plugin.getCommand("buildbattle")).ifPresent(bb -> {
|
||||
bb.setExecutor(this);
|
||||
bb.setTabCompleter(completion);
|
||||
});
|
||||
Optional.ofNullable(plugin.getCommand("buildbattleadmin")).ifPresent(bba -> {
|
||||
bba.setExecutor(this);
|
||||
bba.setTabCompleter(completion);
|
||||
});
|
||||
|
||||
//register Build Battle basic arguments
|
||||
new CreateArgument(this);
|
||||
new JoinArguments(this);
|
||||
new LeaderboardArgument(this);
|
||||
new LeaveArgument(this);
|
||||
new GuessArgument(this);
|
||||
new StatsArgument(this);
|
||||
new ArenaSelectorArgument(this);
|
||||
|
||||
//register Build Battle admin arguments
|
||||
//arena related arguments
|
||||
super(plugin);
|
||||
new AddNpcArgument(this);
|
||||
new DeleteArgument(this);
|
||||
new ForceStartArguments(this);
|
||||
new ReloadArgument(this);
|
||||
new SetThemeArgument(this);
|
||||
new StopArgument(this);
|
||||
new VotesArgument(this);
|
||||
|
||||
//plot related arguments
|
||||
new AddPlotArgument(this);
|
||||
new PlotWandArgument(this);
|
||||
new RemovePlotArgument(this);
|
||||
new SelectPlotArgument(this);
|
||||
|
||||
//other admin related arguments
|
||||
new ListArenasArgument(this);
|
||||
new TeleportArgument(this);
|
||||
new GuessArgument(this);
|
||||
new ThemeArgument(this);
|
||||
}
|
||||
|
||||
//todo complex
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||
for(String mainCommand : mappedArguments.keySet()) {
|
||||
if(cmd.getName().equalsIgnoreCase(mainCommand)) {
|
||||
if(cmd.getName().equalsIgnoreCase("buildbattle")) {
|
||||
if(args.length == 0 || args[0].equalsIgnoreCase("help")) {
|
||||
sender.sendMessage(plugin.getChatManager().colorMessage("Commands.Main-Command.Header"));
|
||||
sender.sendMessage(plugin.getChatManager().colorMessage("Commands.Main-Command.Description"));
|
||||
if(sender.hasPermission("buildbattle.admin")) {
|
||||
sender.sendMessage(plugin.getChatManager().colorMessage("Commands.Main-Command.Admin-Bonus-Description"));
|
||||
}
|
||||
sender.sendMessage(plugin.getChatManager().colorMessage("Commands.Main-Command.Footer"));
|
||||
return true;
|
||||
}
|
||||
if(args.length > 1 && args[1].equalsIgnoreCase("edit")) {
|
||||
if(args[1].equalsIgnoreCase("edit") || args[0].equalsIgnoreCase("create")) {
|
||||
if(!checkSenderIsExecutorType(sender, CommandArgument.ExecutorType.PLAYER) || !hasPermission(sender, "buildbattle.admin.create")) {
|
||||
return true;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena(args[0]);
|
||||
if(arena == null) {
|
||||
sender.sendMessage(plugin.getChatManager().getPrefix() + plugin.getChatManager().colorMessage("Commands.No-Arena-Like-That"));
|
||||
return true;
|
||||
}
|
||||
|
||||
SetupInventory.sendProTip((Player) sender);
|
||||
new SetupInventory(arena).openInventory((Player) sender);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(cmd.getName().equalsIgnoreCase("buildbattleadmin") && (args.length == 0 || args[0].equalsIgnoreCase("help"))) {
|
||||
if(!sender.hasPermission("buildbattle.admin")) {
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(ChatColor.GREEN + " " + ChatColor.BOLD + "Build Battle " + ChatColor.GRAY + plugin.getDescription().getVersion());
|
||||
sender.sendMessage(ChatColor.RED + " []" + ChatColor.GRAY + " = optional " + ChatColor.GOLD + "<>" + ChatColor.GRAY + " = required");
|
||||
if(sender instanceof Player) {
|
||||
sender.sendMessage(ChatColor.GRAY + "Hover command to see more, click command to suggest it.");
|
||||
}
|
||||
List<LabelData> data = mappedArguments.get("buildbattleadmin").stream().filter(arg -> arg instanceof LabeledCommandArgument)
|
||||
.map(arg -> ((LabeledCommandArgument) arg).getLabelData()).collect(Collectors.toList());
|
||||
data.add(new LabelData("/bb &6<arena>&f edit", "/bb <arena> edit",
|
||||
"&7Edit existing arena\n&6Permission: &7buildbattle.admin.edit"));
|
||||
data.addAll(mappedArguments.get("buildbattle").stream().filter(arg -> arg instanceof LabeledCommandArgument)
|
||||
.map(arg -> ((LabeledCommandArgument) arg).getLabelData()).collect(Collectors.toList()));
|
||||
for(LabelData labelData : data) {
|
||||
if(sender instanceof Player) {
|
||||
TextComponent component = new TextComponent(labelData.getText());
|
||||
component.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, labelData.getCommand()));
|
||||
|
||||
// Backwards compatibility
|
||||
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16_R1)) {
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(labelData.getDescription())));
|
||||
} else {
|
||||
component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(labelData.getDescription())));
|
||||
}
|
||||
|
||||
((Player) sender).spigot().sendMessage(component);
|
||||
} else {
|
||||
//more descriptive for console - split at \n to show only basic description
|
||||
Debugger.sendConsoleMsg(labelData.getText() + " - " + labelData.getDescription().split("\n")[0]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
for(CommandArgument argument : mappedArguments.get(mainCommand)) {
|
||||
if(argument.getArgumentName().equalsIgnoreCase(args[0])) {
|
||||
for(String perm : argument.getPermissions()) {
|
||||
if(perm.isEmpty() || hasPermission(sender, perm)) {
|
||||
break;
|
||||
}
|
||||
|
||||
//user has no permission to execute command
|
||||
return true;
|
||||
}
|
||||
if(checkSenderIsExecutorType(sender, argument.getValidExecutors())) {
|
||||
argument.execute(sender, args);
|
||||
}
|
||||
//return true even if sender is not good executor or hasn't got permission
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//sending did you mean help
|
||||
List<StringMatcher.Match> matches = StringMatcher.match(args[0], mappedArguments.get(cmd.getName().toLowerCase()).stream().map(CommandArgument::getArgumentName).collect(Collectors.toList()));
|
||||
if(!matches.isEmpty()) {
|
||||
sender.sendMessage(plugin.getChatManager().colorMessage("Commands.Did-You-Mean").replace("%command%", label + " " + matches.get(0).getMatch()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean checkSenderIsExecutorType(CommandSender sender, CommandArgument.ExecutorType type) {
|
||||
switch(type) {
|
||||
case BOTH:
|
||||
return sender instanceof ConsoleCommandSender || sender instanceof Player;
|
||||
case CONSOLE:
|
||||
return sender instanceof ConsoleCommandSender;
|
||||
case PLAYER:
|
||||
if(sender instanceof Player) {
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(plugin.getChatManager().colorMessage("Commands.Only-By-Player"));
|
||||
return false;
|
||||
public List<IPluginArena> getSpecificFilteredArenas(List<IPluginArena> arenas, String filter) {
|
||||
switch(filter.toLowerCase(Locale.ENGLISH)) {
|
||||
case "gtb":
|
||||
case "guessthebuild":
|
||||
case "guess_the_build":
|
||||
return arenas.stream().filter(GuessArena.class::isInstance).collect(Collectors.toList());
|
||||
case "classic":
|
||||
case "solo":
|
||||
case "team":
|
||||
default:
|
||||
return false;
|
||||
return arenas.stream().filter(BuildArena.class::isInstance).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps new argument to the main command
|
||||
*
|
||||
* @param mainCommand mother command ex. /mm
|
||||
* @param argument argument to map ex. leave (for /mm leave)
|
||||
*/
|
||||
public void mapArgument(String mainCommand, CommandArgument argument) {
|
||||
List<CommandArgument> args = mappedArguments.getOrDefault(mainCommand, new ArrayList<>());
|
||||
args.add(argument);
|
||||
mappedArguments.put(mainCommand, args);
|
||||
}
|
||||
|
||||
public boolean hasPermission(CommandSender sender, String perm) {
|
||||
if(sender.hasPermission(perm)) {
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(plugin.getChatManager().getPrefix() + plugin.getChatManager().colorMessage("Commands.No-Permission"));
|
||||
return false;
|
||||
}
|
||||
|
||||
public Map<String, List<CommandArgument>> getMappedArguments() {
|
||||
return mappedArguments;
|
||||
}
|
||||
|
||||
public Main getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.admin;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class ListArenasArgument {
|
||||
|
||||
public ListArenasArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattleadmin", new LabeledCommandArgument("list", "buildbattle.admin.list", CommandArgument.ExecutorType.BOTH,
|
||||
new LabelData("/bba list", "/bba list",
|
||||
"&7Shows list with all loaded arenas\n&6Permission: &7buildbattle.admin.list")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.Admin-Commands.List-Command.Header"));
|
||||
if(ArenaRegistry.getArenas().size() == 0) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.Admin-Commands.List-Command.No-Arenas"));
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorRawMessage("&e&lTIP: &7You can get free maps with configs at our wiki! Just head to https://wiki.plugily.xyz/buildbattle/setup/maps"));
|
||||
return;
|
||||
}
|
||||
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.Admin-Commands.List-Command.Format").replace("%arena%", arena.getID())
|
||||
.replace("%status%", arena.getArenaState().getPlaceholder()).replace("%players%", Integer.toString(arena.getPlayers().size()))
|
||||
.replace("%maxplayers%", Integer.toString(arena.getMaximumPlayers())));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
-88
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.admin;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.commonsbox.minecraft.serialization.InventorySerializer;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.buildbattle.handlers.language.LanguageManager;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class ReloadArgument {
|
||||
|
||||
private final Set<CommandSender> confirmations = new HashSet<>();
|
||||
|
||||
public ReloadArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattleadmin", new LabeledCommandArgument("reload", "buildbattle.admin.reload", CommandArgument.ExecutorType.BOTH,
|
||||
new LabelData("/bba reload", "/bba reload", "&7Reload all game arenas and configuration files\n&7&lThey will be stopped!\n&6Permission: &7buildbattle.admin.reload")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!confirmations.contains(sender)) {
|
||||
confirmations.add(sender);
|
||||
Bukkit.getScheduler().runTaskLater(registry.getPlugin(), () -> confirmations.remove(sender), 20 * 10);
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix()
|
||||
+ registry.getPlugin().getChatManager().colorRawMessage("&cAre you sure you want to do this action? Type the command again &6within 10 seconds &cto confirm!"));
|
||||
return;
|
||||
}
|
||||
confirmations.remove(sender);
|
||||
|
||||
registry.getPlugin().reloadConfig();
|
||||
LanguageManager.reloadConfig();
|
||||
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
for(Player player : arena.getPlayers()) {
|
||||
arena.doBarAction(BaseArena.BarAction.REMOVE, player);
|
||||
arena.teleportToEndLocation(player);
|
||||
if(registry.getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.INVENTORY_MANAGER_ENABLED)) {
|
||||
InventorySerializer.loadInventory(registry.getPlugin(), player);
|
||||
} else {
|
||||
player.getInventory().clear();
|
||||
player.getInventory().setArmorContents(null);
|
||||
player.getActivePotionEffects().forEach(pe -> player.removePotionEffect(pe.getType()));
|
||||
}
|
||||
}
|
||||
ArenaManager.stopGame(true, arena);
|
||||
}
|
||||
registry.getPlugin().getConfigPreferences().loadOptions();
|
||||
ArenaRegistry.registerArenas();
|
||||
sender.sendMessage(ChatColor.GREEN + "Plugin reloaded!");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.admin;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
* <p>
|
||||
* Created at 14.03.2021
|
||||
*/
|
||||
public class TeleportArgument {
|
||||
|
||||
public TeleportArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattleadmin", new LabeledCommandArgument("tp", "buildbattle.admin.teleport", CommandArgument.ExecutorType.PLAYER,
|
||||
new LabelData("/bba tp &6<arena> <location type>", "/bba tp <arena> <location>",
|
||||
"&7Teleport you to provided arena location\n&7Valid locations:\n&7• LOBBY - lobby location\n&7• START - starting location\n"
|
||||
+ "&7• END - ending location\n&6Permission: &7buildbattle.admin.teleport")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length == 1) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Type-Arena-Name"));
|
||||
return;
|
||||
}
|
||||
if(args.length == 2) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + ChatColor.RED + "Please type location type: " + Arrays.toString(LocationType.values()).replace("[", "").replace("]", ""));
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
LocationType type;
|
||||
try {
|
||||
type = LocationType.valueOf(args[2].toUpperCase());
|
||||
} catch(IllegalArgumentException e) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + ChatColor.RED + "Please type location type: " + Arrays.toString(LocationType.values()).replace("[", "").replace("]", ""));
|
||||
return;
|
||||
}
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
if(arena.getID().equalsIgnoreCase(args[1])) {
|
||||
teleport(player, arena, type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void teleport(Player player, BaseArena arena, LocationType locationType) {
|
||||
switch(locationType) {
|
||||
case LOBBY:
|
||||
org.bukkit.Location lobby = arena.getLobbyLocation();
|
||||
if(lobby == null) {
|
||||
player.sendMessage(ChatColor.RED + "Lobby location isn't set for this arena!");
|
||||
return;
|
||||
}
|
||||
player.teleport(lobby);
|
||||
player.sendMessage(ChatColor.GRAY + "Teleported to LOBBY location from arena " + arena.getID());
|
||||
break;
|
||||
case START:
|
||||
if(arena.getPlotManager().getPlots().isEmpty()) {
|
||||
player.sendMessage(ChatColor.RED + "Start location isn't set for this arena!");
|
||||
return;
|
||||
}
|
||||
player.teleport(arena.getPlotManager().getPlots().get(0).getTeleportLocation());
|
||||
player.sendMessage(ChatColor.GRAY + "Teleported to START location from arena " + arena.getID());
|
||||
break;
|
||||
case END:
|
||||
if(arena.getEndLocation() == null) {
|
||||
player.sendMessage(ChatColor.RED + "End location isn't set for this arena!");
|
||||
return;
|
||||
}
|
||||
arena.teleportToEndLocation(player);
|
||||
player.sendMessage(ChatColor.GRAY + "Teleported to END location from arena " + arena.getID());
|
||||
break;
|
||||
default:
|
||||
break; //o.o
|
||||
}
|
||||
}
|
||||
|
||||
public enum LocationType {
|
||||
LOBBY, END, START //todo PLOT
|
||||
}
|
||||
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.admin;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.handlers.themes.ThemeManager;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.LabelData;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
|
||||
public final class ThemeArgument {
|
||||
|
||||
private String printGameTypes() {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
int length = ThemeManager.GameThemes.VALUES.length;
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
stringBuilder.append(ThemeManager.GameThemes.VALUES[i].strip.toLowerCase(Locale.ENGLISH) + (i + 1 < length ? ", " : ""));
|
||||
}
|
||||
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
public ThemeArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattleadmin", new LabeledCommandArgument("theme", "buildbattle.admin.theme", CommandArgument.ExecutorType.PLAYER,
|
||||
new LabelData("/bba theme &c[add/remove] [gameType] [theme]", "/bba theme",
|
||||
"&7Theme commands to add or remove themes for the specified game type\n&6Permission: &7buildbattle.admin.theme")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length < 4) {
|
||||
new MessageBuilder("COMMANDS_WRONG_USAGE").asKey().value("/" + registry.getPlugin().getCommandAdminPrefix() + " &c[add/remove] [gameType] [theme]").send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
String gameType = args[2];
|
||||
ThemeManager.GameThemes theme = null;
|
||||
|
||||
for(ThemeManager.GameThemes gameTheme : ThemeManager.GameThemes.VALUES) {
|
||||
if(gameTheme.strip.equalsIgnoreCase(gameType)) {
|
||||
theme = gameTheme;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(theme == null) {
|
||||
new MessageBuilder("&cThere is no game type with this name. Possible types: " + printGameTypes()).prefix().send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
String themeName = ChatColor.stripColor(args[3]);
|
||||
ThemeManager themeManager = ((Main) registry.getPlugin()).getThemeManager();
|
||||
|
||||
switch(args[1].toLowerCase(Locale.ENGLISH)) {
|
||||
case "add":
|
||||
if(themeManager.isThemeBlacklisted(themeName)) {
|
||||
new MessageBuilder("COMMANDS_THEME_BLACKLISTED").asKey().prefix().send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
if(themeManager.getThemes(theme).contains(themeName)) {
|
||||
new MessageBuilder("&cThe given theme already exists.").prefix().send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(theme) {
|
||||
case SOLO:
|
||||
case CLASSIC:
|
||||
themeManager.classicThemes.add(themeName);
|
||||
break;
|
||||
case TEAM:
|
||||
case TEAMS:
|
||||
themeManager.teamsThemes.add(themeName);
|
||||
break;
|
||||
case GUESS_THE_BUILD_EASY:
|
||||
themeManager.GTBThemesEasy.add(themeName);
|
||||
break;
|
||||
case GUESS_THE_BUILD_MEDIUM:
|
||||
themeManager.GTBThemesMedium.add(themeName);
|
||||
break;
|
||||
case GUESS_THE_BUILD_HARD:
|
||||
themeManager.GTBThemesHard.add(themeName);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
themeManager.loadThemes(true);
|
||||
themeManager.saveThemesToConfig();
|
||||
break;
|
||||
case "remove":
|
||||
boolean contained = false;
|
||||
|
||||
switch(theme) {
|
||||
case SOLO:
|
||||
case CLASSIC:
|
||||
contained = themeManager.classicThemes.remove(themeName);
|
||||
break;
|
||||
case TEAM:
|
||||
case TEAMS:
|
||||
contained = themeManager.teamsThemes.remove(themeName);
|
||||
break;
|
||||
case GUESS_THE_BUILD_EASY:
|
||||
contained = themeManager.GTBThemesEasy.remove(themeName);
|
||||
break;
|
||||
case GUESS_THE_BUILD_MEDIUM:
|
||||
contained = themeManager.GTBThemesMedium.remove(themeName);
|
||||
break;
|
||||
case GUESS_THE_BUILD_HARD:
|
||||
contained = themeManager.GTBThemesHard.remove(themeName);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if(!contained) {
|
||||
new MessageBuilder("&cThe given theme doesn't exists.").prefix().send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
themeManager.loadThemes(true);
|
||||
themeManager.saveThemesToConfig();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+10
-9
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -26,9 +26,10 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.LabelData;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
@@ -39,18 +40,18 @@ public class AddNpcArgument {
|
||||
|
||||
public AddNpcArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattleadmin", new LabeledCommandArgument("addnpc", "buildbattle.admin.addnpc", CommandArgument.ExecutorType.PLAYER,
|
||||
new LabelData("/bba addnpc &6<arena>", "/bba addnpc <arena>",
|
||||
new LabelData("/bba addnpc", "/bba addnpc",
|
||||
"&7Deletes specified arena\n&6Permission: &7buildbattle.admin.addnpc")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(registry.getPlugin().getServer().getPluginManager().isPluginEnabled("Citizens")) {
|
||||
NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.VILLAGER, registry.getPlugin().getChatManager().colorMessage("In-Game.NPC.Floor-Change-NPC-Name"));
|
||||
NPC npc = CitizensAPI.getNPCRegistry().createNPC(EntityType.VILLAGER, new MessageBuilder("IN_GAME_MESSAGES_PLOT_NPC_NAME").asKey().build());
|
||||
npc.spawn(((Player) sender).getLocation());
|
||||
npc.setProtected(true);
|
||||
npc.setName(registry.getPlugin().getChatManager().colorMessage("In-Game.NPC.Floor-Change-NPC-Name"));
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("In-Game.NPC.NPC-Created"));
|
||||
npc.setName(new MessageBuilder("IN_GAME_MESSAGES_PLOT_NPC_NAME").asKey().build());
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_NPC_CREATED").asKey().send(sender);
|
||||
} else {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("In-Game.NPC.Install-Citizens"));
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_NPC_CITIZENS").asKey().send(sender);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
-80
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.admin.arena;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class DeleteArgument {
|
||||
|
||||
private final Set<CommandSender> confirmations = new HashSet<>();
|
||||
|
||||
public DeleteArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattleadmin", new LabeledCommandArgument("delete", "buildbattle.admin.delete", CommandArgument.ExecutorType.PLAYER,
|
||||
new LabelData("/bba delete &6<arena>", "/bba delete <arena>",
|
||||
"&7Deletes specified arena\n&6Permission: &7buildbattle.admin.delete")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length == 1) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Type-Arena-Name"));
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena(args[1]);
|
||||
if(arena == null) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.No-Arena-Like-That"));
|
||||
return;
|
||||
}
|
||||
if(!confirmations.contains(sender)) {
|
||||
confirmations.add(sender);
|
||||
Bukkit.getScheduler().runTaskLater(registry.getPlugin(), () -> confirmations.remove(sender), 20 * 10);
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix()
|
||||
+ registry.getPlugin().getChatManager().colorRawMessage("&cAre you sure you want to do this action? Type the command again &6within 10 seconds &cto confirm!"));
|
||||
return;
|
||||
}
|
||||
confirmations.remove(sender);
|
||||
ArenaManager.stopGame(false, arena);
|
||||
FileConfiguration config = ConfigUtils.getConfig(registry.getPlugin(), "arenas");
|
||||
config.set("instances." + args[1], null);
|
||||
ConfigUtils.saveConfig(registry.getPlugin(), config, "arenas");
|
||||
ArenaRegistry.unregisterArena(arena);
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Removed-Game-Instance"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
-53
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.admin.arena;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.arena.ArenaUtils;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class ForceStartArguments {
|
||||
|
||||
public ForceStartArguments(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattleadmin", new LabeledCommandArgument("forcestart", "buildbattle.admin.forcestart", CommandArgument.ExecutorType.PLAYER,
|
||||
new LabelData("/bba forcestart &c[theme]", "/bba forcestart",
|
||||
"&7Force starts arena you're in\n&6Permission: &7buildbattle.admin.forcestart")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length == 2 && !sender.hasPermission("buildbattle.admin.forcestart.theme")) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.No-Permission"));
|
||||
return;
|
||||
}
|
||||
ArenaUtils.arenaForceStart((Player) sender, args.length == 2 ? args[1] : "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+20
-24
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,15 +22,13 @@ package plugily.projects.buildbattle.commands.arguments.admin.arena;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.impl.SoloArena;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.BuildArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.LabelData;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
@@ -45,34 +43,32 @@ public class SetThemeArgument {
|
||||
"&7Set new arena theme\n&6Permission: &7buildbattle.admin.settheme\n&6You can set arena theme only when it started\n&6and only for 20 seconds after start!")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
BaseArena arena = ArenaRegistry.getArena((Player) sender);
|
||||
BaseArena arena = (BaseArena) registry.getPlugin().getArenaRegistry().getArena((Player) sender);
|
||||
if(arena == null) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.No-Playing"));
|
||||
new MessageBuilder("COMMANDS_NOT_PLAYING").asKey().send(sender);
|
||||
return;
|
||||
}
|
||||
if(!(arena instanceof SoloArena)) {
|
||||
if(!(arena instanceof BuildArena)) {
|
||||
//todo translatable
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorRawMessage("&cCan't set theme on this arena type!"));
|
||||
new MessageBuilder("&cCan't set theme on this arena type!").prefix().send(sender);
|
||||
return;
|
||||
}
|
||||
if(args.length == 1) {
|
||||
//todo translatable
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorRawMessage("&cPlease type arena theme!"));
|
||||
new MessageBuilder("&cPlease type arena theme!").prefix().send(sender);
|
||||
return;
|
||||
}
|
||||
if(arena.getArenaState() == ArenaState.IN_GAME && registry.getPlugin().getConfigPreferences().getTimer(ConfigPreferences.TimerType.BUILD, arena) - arena.getTimer() <= 20) {
|
||||
if(registry.getPlugin().getConfigPreferences().isThemeBlacklisted(args[1].toLowerCase())) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Admin-Commands.Theme-Blacklisted"));
|
||||
if(arena.getArenaInGameState() == BaseArena.ArenaInGameState.THEME_VOTING) {
|
||||
String themeName = args[1];
|
||||
|
||||
if(arena.getPlugin().getThemeManager().isThemeBlacklisted(themeName)) {
|
||||
new MessageBuilder("COMMANDS_THEME_BLACKLISTED").asKey().prefix().send(sender);
|
||||
return;
|
||||
}
|
||||
arena.setTheme(args[1]);
|
||||
registry.getPlugin().getChatManager().broadcast(arena, registry.getPlugin().getChatManager().colorMessage("In-Game.Messages.Admin-Messages.Changed-Theme").replace("%THEME%", args[1]));
|
||||
arena.setTheme(themeName);
|
||||
new MessageBuilder("IN_GAME_MESSAGES_ADMIN_CHANGED_THEME").asKey().prefix().value(themeName).arena(arena).sendArena();
|
||||
} else {
|
||||
if(arena.getArenaState() == ArenaState.STARTING) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Wait-For-Start"));
|
||||
} else {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Arena-Started"));
|
||||
}
|
||||
new MessageBuilder("&cWrong state to force theme!").prefix().send(sender);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
-60
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.admin.arena;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class StopArgument {
|
||||
|
||||
public StopArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattleadmin", new LabeledCommandArgument("stop", "buildbattle.admin.stop", CommandArgument.ExecutorType.PLAYER,
|
||||
new LabelData("/bba stop", "/bba stop",
|
||||
"&7Stops the arena you're in\n&7&lYou must be in target arena!\n&6Permission: &7buildbattle.admin.stop")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
BaseArena arena = ArenaRegistry.getArena((Player) sender);
|
||||
if(arena == null) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.No-Playing"));
|
||||
return;
|
||||
}
|
||||
if(arena.getArenaState() != ArenaState.ENDING) {
|
||||
ArenaManager.stopGame(false, arena);
|
||||
}
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Arguments.Success"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+21
-20
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -21,17 +21,18 @@
|
||||
package plugily.projects.buildbattle.commands.arguments.admin.plot;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.commonsbox.minecraft.serialization.LocationSerializer;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.buildbattle.utils.CuboidSelector;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.LabelData;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.configuration.ConfigUtils;
|
||||
import plugily.projects.minigamesbox.classic.utils.dimensional.CuboidSelector;
|
||||
import plugily.projects.minigamesbox.classic.utils.serialization.LocationSerializer;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
@@ -46,30 +47,30 @@ public class AddPlotArgument {
|
||||
"&7Add new game plot to the arena\n&6Permission: &7buildbattle.admin.addplot")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
if(args.length == 1) {
|
||||
//todo translatable
|
||||
player.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorRawMessage("&cPlease type arena name!"));
|
||||
new MessageBuilder("COMMANDS_TYPE_ARENA_NAME").asKey().send(sender);
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena(args[1]);
|
||||
BaseArena arena = (BaseArena) registry.getPlugin().getArenaRegistry().getArena(args[1]);
|
||||
if(arena == null) {
|
||||
player.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.No-Arena-Like-That"));
|
||||
new MessageBuilder("COMMANDS_NO_ARENA_LIKE_THAT").asKey().send(sender);
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
CuboidSelector.Selection selection = registry.getPlugin().getCuboidSelector().getSelection(player);
|
||||
if(selection == null || selection.getFirstPos() == null || selection.getSecondPos() == null) {
|
||||
player.sendMessage(registry.getPlugin().getChatManager().colorRawMessage(registry.getPlugin().getChatManager().getPrefix() + "&cPlease select both corners before adding a plot!"));
|
||||
new MessageBuilder("&cPlease select both corners before adding a plot!").send(sender);
|
||||
return;
|
||||
}
|
||||
FileConfiguration config = ConfigUtils.getConfig(registry.getPlugin(), "arenas");
|
||||
int id = 0;
|
||||
if(config.isConfigurationSection("instances." + arena.getID() + ".plots")) {
|
||||
id = config.getConfigurationSection("instances." + arena.getID() + ".plots").getKeys(false).size() + 1;
|
||||
ConfigurationSection section = config.getConfigurationSection("instances." + arena.getId() + ".plots");
|
||||
if(section != null) {
|
||||
id = section.getKeys(false).size() + 1;
|
||||
}
|
||||
LocationSerializer.saveLoc(registry.getPlugin(), config, "arenas", "instances." + arena.getID() + ".plots." + id + ".minpoint", selection.getFirstPos());
|
||||
LocationSerializer.saveLoc(registry.getPlugin(), config, "arenas", "instances." + arena.getID() + ".plots." + id + ".maxpoint", selection.getSecondPos());
|
||||
player.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorRawMessage("&aPlot with ID &e" + id + "&a added to arena instance &e" + arena.getID()));
|
||||
LocationSerializer.saveLoc(registry.getPlugin(), config, "arenas", "instances." + arena.getId() + ".plots." + id + ".1", selection.getFirstPos());
|
||||
LocationSerializer.saveLoc(registry.getPlugin(), config, "arenas", "instances." + arena.getId() + ".plots." + id + ".2", selection.getSecondPos());
|
||||
new MessageBuilder("&aPlot with ID &e" + id + "&a added to arena instance &e" + arena.getId()).send(sender);
|
||||
registry.getPlugin().getCuboidSelector().removeSelection(player);
|
||||
}
|
||||
});
|
||||
|
||||
-48
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.admin.plot;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class PlotWandArgument {
|
||||
|
||||
public PlotWandArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattleadmin", new LabeledCommandArgument("plotwand", "buildbattle.admin.plotwand", CommandArgument.ExecutorType.PLAYER,
|
||||
new LabelData("/bba plotwand", "/bba plotwand",
|
||||
"&7Get plot wand to create plots\n&6Permission: &7buildbattle.admin.plotwand")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
registry.getPlugin().getCuboidSelector().giveSelectorWand((Player) sender);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+19
-19
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,22 +22,19 @@ package plugily.projects.buildbattle.commands.arguments.admin.plot;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.LabelData;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
import plugily.projects.minigamesbox.classic.utils.configuration.ConfigUtils;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
* @deprecated should remove arena directly from game arena too
|
||||
*/
|
||||
@Deprecated
|
||||
public class RemovePlotArgument {
|
||||
|
||||
public RemovePlotArgument(ArgumentsRegistry registry) {
|
||||
@@ -46,24 +43,27 @@ public class RemovePlotArgument {
|
||||
"&7Removes game plot of the arena (only in arenas.yml!)\n&6Permission: &7buildbattle.admin.removeplot")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
if(args.length < 3) {
|
||||
//todo translatable
|
||||
player.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorRawMessage("&cPlease type arena name and plot ID!"));
|
||||
new MessageBuilder("COMMANDS_TYPE_ARENA_NAME").asKey().send(sender);
|
||||
new MessageBuilder("COMMANDS_WRONG_USAGE").asKey().value("/bba removeplot <arena> <plot ID>").send(sender);
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena(args[1]);
|
||||
|
||||
BaseArena arena = (BaseArena) registry.getPlugin().getArenaRegistry().getArena(args[1]);
|
||||
if(arena == null) {
|
||||
player.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.No-Arena-Like-That"));
|
||||
new MessageBuilder("COMMANDS_NO_ARENA_LIKE_THAT").asKey().send(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
String plot = args[2];
|
||||
FileConfiguration config = ConfigUtils.getConfig(registry.getPlugin(), "arenas");
|
||||
if(config.contains("instances." + arena.getID() + ".plots." + args[2])) {
|
||||
config.set("instances." + arena.getID() + ".plots." + args[2], null);
|
||||
|
||||
if(config.contains("instances." + arena.getId() + ".plots." + plot)) {
|
||||
config.set("instances." + arena.getId() + ".plots." + plot, null);
|
||||
ConfigUtils.saveConfig(registry.getPlugin(), config, "arenas");
|
||||
player.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorRawMessage("&aPlot with ID &e" + args[2] + "&a removed from arena &e" + arena.getID()));
|
||||
new MessageBuilder("&aPlot with ID &e" + plot + "&a removed from arena &e" + arena.getId()).send(sender);
|
||||
} else {
|
||||
player.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorRawMessage("&cPlot with that ID doesn't exist!"));
|
||||
new MessageBuilder("&cPlot with that ID doesn't exist!").send(sender);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+9
-11
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,11 +22,10 @@ package plugily.projects.buildbattle.commands.arguments.admin.plot;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.minigamesbox.api.arena.IArenaState;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.CommandArgument;
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
@@ -39,12 +38,11 @@ public class SelectPlotArgument {
|
||||
registry.mapArgument("buildbattle", new CommandArgument("selectplot", "buildbattle.command.selectplot", CommandArgument.ExecutorType.PLAYER) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
BaseArena arena = ArenaRegistry.getArena((Player) sender);
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
if(arena.getArenaState() == ArenaState.WAITING_FOR_PLAYERS || arena.getArenaState() == ArenaState.STARTING)
|
||||
registry.getPlugin().getPlotMenuHandler().createMenu((Player) sender, arena);
|
||||
Player player = (Player) sender;
|
||||
BaseArena arena = (BaseArena) registry.getPlugin().getArenaRegistry().getArena(player);
|
||||
|
||||
if(arena != null && (arena.getArenaState() == IArenaState.WAITING_FOR_PLAYERS || arena.getArenaState() == IArenaState.STARTING))
|
||||
arena.getPlugin().getPlotMenuHandler().createMenu(player, arena);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
-98
@@ -1,98 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.admin.votes;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.commonsbox.number.NumberUtils;
|
||||
import plugily.projects.buildbattle.api.StatsStorage;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 23.01.2019
|
||||
*/
|
||||
public class VotesArgument {
|
||||
|
||||
public VotesArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattleadmin", new LabeledCommandArgument("votes", "buildbattle.admin.supervotes.manage",
|
||||
CommandArgument.ExecutorType.BOTH, new LabelData("/bba votes &6<add/set> <amount> &c[player]", "/bba votes <action> <amount>",
|
||||
"&7Set or add super votes to yourself or target player\n&7Can be used from console too\n&6Permission: &7buildbattle.admin.supervotes.manage")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length == 1) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Invalid-Args"));
|
||||
return;
|
||||
}
|
||||
if(args.length == 2) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + ChatColor.RED + "Please type amount of super votes to add or set!");
|
||||
return;
|
||||
}
|
||||
if(!args[1].equalsIgnoreCase("add") && !args[1].equalsIgnoreCase("set")) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + ChatColor.RED + "Wrong command usage, please use /bba votes <add|set> <amount> [player]!");
|
||||
return;
|
||||
}
|
||||
Player target;
|
||||
if(args.length == 3) {
|
||||
if(!(sender instanceof Player)) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + ChatColor.RED + "Console can't recieve supervotes.");
|
||||
return;
|
||||
}
|
||||
target = (Player) sender;
|
||||
} else {
|
||||
target = Bukkit.getPlayerExact(args[3]);
|
||||
}
|
||||
if(target == null) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.Player-Not-Found"));
|
||||
return;
|
||||
}
|
||||
if(NumberUtils.isInteger(args[2])) {
|
||||
User user = registry.getPlugin().getUserManager().getUser(target);
|
||||
String successMessage;
|
||||
if(args[1].equalsIgnoreCase("add")) {
|
||||
user.addStat(StatsStorage.StatisticType.SUPER_VOTES, Integer.parseInt(args[2]));
|
||||
successMessage = registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Arguments.Super-Votes-Added");
|
||||
successMessage = StringUtils.replace(successMessage, "%amount%", args[2]);
|
||||
} else {
|
||||
user.setStat(StatsStorage.StatisticType.SUPER_VOTES, Integer.parseInt(args[2]));
|
||||
successMessage = registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Arguments.Super-Votes-Set");
|
||||
successMessage = StringUtils.replace(successMessage, "%amount%", args[2]);
|
||||
}
|
||||
//todo translatable?
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorRawMessage("&aSuper votes amount modified!"));
|
||||
target.sendMessage(successMessage);
|
||||
} else {
|
||||
//todo translatable?
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorRawMessage("&cArgument isn't a number!"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
-71
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.data;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 03.12.2018
|
||||
*/
|
||||
public class CommandArgument {
|
||||
|
||||
private final String argumentName;
|
||||
private final List<String> permissions;
|
||||
private final ExecutorType validExecutors;
|
||||
|
||||
public CommandArgument(String argumentName, String permissions, ExecutorType validExecutors) {
|
||||
this.argumentName = argumentName;
|
||||
this.permissions = Collections.singletonList(permissions);
|
||||
this.validExecutors = validExecutors;
|
||||
}
|
||||
|
||||
public CommandArgument(String argumentName, List<String> permissions, ExecutorType validExecutors) {
|
||||
this.argumentName = argumentName;
|
||||
this.permissions = permissions;
|
||||
this.validExecutors = validExecutors;
|
||||
}
|
||||
|
||||
public String getArgumentName() {
|
||||
return argumentName;
|
||||
}
|
||||
|
||||
public List<String> getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public ExecutorType getValidExecutors() {
|
||||
return validExecutors;
|
||||
}
|
||||
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
throw new UnsupportedOperationException("Method must be overridden to be used");
|
||||
}
|
||||
|
||||
public enum ExecutorType {
|
||||
BOTH, CONSOLE, PLAYER
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.data;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class LabelData {
|
||||
|
||||
private final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
private final String text;
|
||||
private String command;
|
||||
private String description;
|
||||
|
||||
public LabelData(String text, String command, String description) {
|
||||
this.text = plugin.getChatManager().colorRawMessage(text);
|
||||
this.command = command;
|
||||
this.description = plugin.getChatManager().colorRawMessage(description);
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public void setCommand(String command) {
|
||||
this.command = command;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
}
|
||||
-51
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class LabeledCommandArgument extends CommandArgument {
|
||||
|
||||
private final LabelData labelData;
|
||||
|
||||
public LabeledCommandArgument(String argumentName, List<String> permissions, CommandArgument.ExecutorType validExecutors, LabelData labelData) {
|
||||
super(argumentName, permissions, validExecutors);
|
||||
this.labelData = labelData;
|
||||
}
|
||||
|
||||
public LabeledCommandArgument(String argumentName, String permissions, CommandArgument.ExecutorType validExecutors, LabelData labelData) {
|
||||
super(argumentName, permissions, validExecutors);
|
||||
this.labelData = labelData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return label data of command (description and usages of command)
|
||||
*/
|
||||
public LabelData getLabelData() {
|
||||
return labelData;
|
||||
}
|
||||
|
||||
}
|
||||
-148
@@ -1,148 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.game;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import plugily.projects.commonsbox.minecraft.compat.xseries.XMaterial;
|
||||
import plugily.projects.commonsbox.minecraft.misc.stuff.ComplementAccessor;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.buildbattle.handlers.language.LanguageManager;
|
||||
import plugily.projects.buildbattle.utils.Utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @author 2Wild4You
|
||||
* <p>
|
||||
* Created at 09.08.2020
|
||||
*/
|
||||
public class ArenaSelectorArgument implements Listener {
|
||||
|
||||
private final Map<Integer, BaseArena> arenas = new HashMap<>();
|
||||
|
||||
public ArenaSelectorArgument(ArgumentsRegistry registry) {
|
||||
registry.getPlugin().getServer().getPluginManager().registerEvents(this, registry.getPlugin());
|
||||
registry.mapArgument("buildbattle", new LabeledCommandArgument("arenas", "buildbattle.arenas", CommandArgument.ExecutorType.PLAYER,
|
||||
new LabelData("/bb arenas", "/bb arenas", "&7Select an arena\n&6Permission: &7buildbattle.arenas")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
int arenaSize = ArenaRegistry.getArenas().size();
|
||||
if(arenaSize == 0) {
|
||||
player.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.No-Arena-Like-That"));
|
||||
return;
|
||||
}
|
||||
|
||||
Inventory inventory = ComplementAccessor.getComplement().createInventory(player, Utils.serializeInt(arenaSize), registry.getPlugin().getChatManager().colorMessage("Arena-Selector.Inv-Title"));
|
||||
|
||||
int slot = 0;
|
||||
arenas.clear();
|
||||
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
arenas.put(slot, arena);
|
||||
ItemStack itemStack = XMaterial.matchXMaterial(registry.getPlugin().getConfig().getString("Arena-Selector.State-Item." + arena.getArenaState().getFormattedName(), "YELLOW_WOOL").toUpperCase()).orElse(XMaterial.YELLOW_WOOL).parseItem();
|
||||
if(itemStack == null)
|
||||
continue;
|
||||
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if(itemMeta != null) {
|
||||
ComplementAccessor.getComplement().setDisplayName(itemMeta, formatItem(LanguageManager.getLanguageMessage("Arena-Selector.Item.Name"), arena, registry.getPlugin()));
|
||||
|
||||
List<String> lore = LanguageManager.getLanguageList("Arena-Selector.Item.Lore");
|
||||
for(int b = 0; b < lore.size(); b++) {
|
||||
lore.set(b, formatItem(lore.get(b), arena, registry.getPlugin()));
|
||||
}
|
||||
|
||||
ComplementAccessor.getComplement().setLore(itemMeta, lore);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
inventory.addItem(itemStack);
|
||||
slot++;
|
||||
}
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private String formatItem(String string, BaseArena arena, Main plugin) {
|
||||
String formatted = string;
|
||||
formatted = StringUtils.replace(formatted, "%mapname%", arena.getMapName());
|
||||
|
||||
int maxPlayers = arena.getMaximumPlayers();
|
||||
int players = arena.getPlayers().size();
|
||||
|
||||
if(players >= maxPlayers) {
|
||||
formatted = StringUtils.replace(formatted, "%state%", plugin.getChatManager().colorMessage("Signs.Game-States.Full-Game"));
|
||||
} else {
|
||||
formatted = StringUtils.replace(formatted, "%state%", arena.getArenaState().getPlaceholder());
|
||||
}
|
||||
|
||||
formatted = StringUtils.replace(formatted, "%type%", arena.getArenaType().getPrefix());
|
||||
formatted = StringUtils.replace(formatted, "%playersize%", Integer.toString(players));
|
||||
formatted = StringUtils.replace(formatted, "%maxplayers%", Integer.toString(maxPlayers));
|
||||
formatted = plugin.getChatManager().colorRawMessage(formatted);
|
||||
return formatted;
|
||||
}
|
||||
|
||||
private static final Main plugin = JavaPlugin.getPlugin(Main.class);
|
||||
|
||||
@EventHandler
|
||||
public void onArenaSelectorMenuClick(InventoryClickEvent e) {
|
||||
if(!ComplementAccessor.getComplement().getTitle(e.getView()).equals(plugin.getChatManager().colorMessage("Arena-Selector.Inv-Title"))) {
|
||||
return;
|
||||
}
|
||||
if(e.getCurrentItem() == null || !e.getCurrentItem().hasItemMeta()) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
player.closeInventory();
|
||||
|
||||
BaseArena arena = arenas.get(e.getRawSlot());
|
||||
if(arena != null) {
|
||||
ArenaManager.joinAttempt(player, arena);
|
||||
} else {
|
||||
player.sendMessage(plugin.getChatManager().getPrefix() + plugin.getChatManager().colorMessage("Commands.No-Arena-Like-That"));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-116
@@ -1,116 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.game;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.commonsbox.minecraft.serialization.LocationSerializer;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.impl.SoloArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabelData;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.LabeledCommandArgument;
|
||||
import plugily.projects.buildbattle.handlers.setup.SetupInventory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class CreateArgument {
|
||||
|
||||
private final ArgumentsRegistry registry;
|
||||
|
||||
public CreateArgument(ArgumentsRegistry registry) {
|
||||
this.registry = registry;
|
||||
registry.mapArgument("buildbattle", new LabeledCommandArgument("create", "buildbattle.admin.create", CommandArgument.ExecutorType.PLAYER,
|
||||
new LabelData("/bb create &6<arena>", "/bb create <arena>",
|
||||
"&7Create new arena\n&6Permission: &7buildbattle.admin.create")) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length == 1) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.Type-Arena-Name"));
|
||||
return;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
if(arena.getID().equalsIgnoreCase(args[1])) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "Arena with that ID already exists!");
|
||||
player.sendMessage(ChatColor.DARK_RED + "Usage: /bb create <ID>");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(ConfigUtils.getConfig(registry.getPlugin(), "arenas").contains("instances." + args[1])) {
|
||||
player.sendMessage(ChatColor.DARK_RED + "Instance/Arena already exists! Use another ID or delete it first!");
|
||||
} else {
|
||||
createInstanceInConfig(args[1]);
|
||||
player.sendMessage(ChatColor.BOLD + "------------------------------------------");
|
||||
player.sendMessage(ChatColor.YELLOW + " Instance " + args[1] + " created!");
|
||||
player.sendMessage("");
|
||||
player.sendMessage(ChatColor.GREEN + "Edit this arena via " + ChatColor.GOLD + "/bb " + args[1] + " edit" + ChatColor.GREEN + "!");
|
||||
player.sendMessage(ChatColor.GOLD + "Don't know where to start? Check out tutorial video:");
|
||||
player.sendMessage(ChatColor.GOLD + SetupInventory.VIDEO_LINK);
|
||||
player.sendMessage(ChatColor.BOLD + "------------------------------------------- ");
|
||||
SetupInventory.sendProTip(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createInstanceInConfig(String id) {
|
||||
String path = "instances." + id + ".";
|
||||
FileConfiguration config = ConfigUtils.getConfig(registry.getPlugin(), "arenas");
|
||||
org.bukkit.Location worldSpawn = Bukkit.getServer().getWorlds().get(0).getSpawnLocation();
|
||||
LocationSerializer.saveLoc(registry.getPlugin(), config, "arenas", path + "lobbylocation", worldSpawn);
|
||||
LocationSerializer.saveLoc(registry.getPlugin(), config, "arenas", path + "Endlocation", worldSpawn);
|
||||
config.set(path + "minimumplayers", 2);
|
||||
config.set(path + "maximumplayers", 4);
|
||||
config.set(path + "mapname", id);
|
||||
config.set(path + "signs", new ArrayList<>());
|
||||
config.createSection(path + "plots");
|
||||
config.set(path + "gametype", "SOLO");
|
||||
config.set(path + "isdone", false);
|
||||
ConfigUtils.saveConfig(registry.getPlugin(), config, "arenas");
|
||||
|
||||
SoloArena arena = new SoloArena(id, registry.getPlugin());
|
||||
|
||||
arena.setMinimumPlayers(config.getInt(path + "minimumplayers"));
|
||||
arena.setMaximumPlayers(config.getInt(path + "maximumplayers"));
|
||||
arena.setMapName(config.getString(path + "mapname"));
|
||||
arena.setLobbyLocation(LocationSerializer.getLocation(config.getString(path + "lobbylocation")));
|
||||
arena.setEndLocation(LocationSerializer.getLocation(config.getString(path + "Endlocation")));
|
||||
arena.setArenaType(BaseArena.ArenaType.SOLO);
|
||||
arena.setReady(false);
|
||||
arena.initPoll();
|
||||
ArenaRegistry.registerArena(arena);
|
||||
|
||||
ArenaRegistry.registerArenas();
|
||||
}
|
||||
|
||||
}
|
||||
+31
-37
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
* Copyright (C) 2022 Plugily Projects - maintained by Tigerpanzer_02 and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -22,12 +22,12 @@ package plugily.projects.buildbattle.commands.arguments.game;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.impl.GuessTheBuildArena;
|
||||
import plugily.projects.buildbattle.arena.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.GuessArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.minigamesbox.api.arena.IArenaState;
|
||||
import plugily.projects.minigamesbox.classic.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.minigamesbox.classic.handlers.language.MessageBuilder;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -42,42 +42,36 @@ public class GuessArgument {
|
||||
registry.mapArgument("buildbattle", new CommandArgument("guess", "", CommandArgument.ExecutorType.PLAYER) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
Player player = (Player) sender;
|
||||
BaseArena arena = ArenaRegistry.getArena(player);
|
||||
if(args.length < 2) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.Invalid-Args"));
|
||||
new MessageBuilder("COMMANDS_WRONG_USAGE").asKey().value("/bb guess <word>").send(sender);
|
||||
return;
|
||||
}
|
||||
if(arena == null || arena.getArenaType() != BaseArena.ArenaType.GUESS_THE_BUILD || arena.getArenaState() != ArenaState.IN_GAME) {
|
||||
player.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.No-Playing"));
|
||||
return;
|
||||
}
|
||||
GuessTheBuildArena gameArena = (GuessTheBuildArena) arena;
|
||||
if(gameArena.getWhoGuessed().contains(player)) {
|
||||
player.sendMessage(registry.getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Chat.Cant-Talk-When-Guessed"));
|
||||
return;
|
||||
}
|
||||
if(player == gameArena.getCurrentBuilder()) {
|
||||
player.sendMessage(registry.getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Chat.Cant-Talk-When-Building"));
|
||||
return;
|
||||
}
|
||||
if(gameArena.getCurrentTheme() == null || !gameArena.getCurrentTheme().getTheme().equalsIgnoreCase(Arrays.toString(args).split(" ", 2)[1].replace(",", "").replace("]", ""))) {
|
||||
return;
|
||||
}
|
||||
registry.getPlugin().getChatManager().broadcast(arena, registry.getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Chat.Guessed-The-Theme").replace("%player%", player.getName()));
|
||||
|
||||
player.sendMessage(registry.getPlugin().getChatManager().colorMessage("In-Game.Guess-The-Build.Plus-Points")
|
||||
.replace("%pts%", Integer.toString(gameArena.getCurrentTheme().getDifficulty().getPointsReward())));
|
||||
gameArena.getPlayersPoints().put(player, gameArena.getPlayersPoints().getOrDefault(player, 0)
|
||||
+ gameArena.getCurrentTheme().getDifficulty().getPointsReward());
|
||||
if(gameArena.getWhoGuessed().isEmpty()) {
|
||||
gameArena.getPlayersPoints().put(gameArena.getCurrentBuilder(), gameArena.getPlayersPoints().getOrDefault(player, 0)
|
||||
+ gameArena.getCurrentTheme().getDifficulty().getPointsReward());
|
||||
Player player = (Player) sender;
|
||||
BaseArena arena = (BaseArena) registry.getPlugin().getArenaRegistry().getArena(player);
|
||||
|
||||
if(!(arena instanceof GuessArena) || arena.getArenaState() != IArenaState.IN_GAME) {
|
||||
new MessageBuilder("COMMANDS_NOT_PLAYING").asKey().player(player).sendPlayer();
|
||||
return;
|
||||
}
|
||||
org.bukkit.Bukkit.getScheduler().runTaskLater(registry.getPlugin(), () -> {
|
||||
gameArena.addWhoGuessed(player);
|
||||
gameArena.recalculateLeaderboard();
|
||||
}, 1L);
|
||||
|
||||
GuessArena gameArena = (GuessArena) arena;
|
||||
|
||||
if(gameArena.getWhoGuessed().contains(player)) {
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_CANT_TALK").asKey().arena(gameArena).player(player).sendPlayer();
|
||||
return;
|
||||
}
|
||||
|
||||
if(gameArena.getCurrentBuilders().contains(player)) {
|
||||
new MessageBuilder("IN_GAME_MESSAGES_PLOT_GTB_THEME_GUESS_BUILDER").asKey().arena(gameArena).player(player).sendPlayer();
|
||||
return;
|
||||
}
|
||||
|
||||
if(gameArena.getCurrentBBTheme() == null || !gameArena.getCurrentBBTheme().getTheme().equalsIgnoreCase(Arrays.toString(args).split(" ", 2)[1].replace(",", "").replace("]", ""))) {
|
||||
return;
|
||||
}
|
||||
|
||||
gameArena.broadcastPlayerGuessed(player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
-177
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.game;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 03.12.2018
|
||||
*/
|
||||
public class JoinArguments {
|
||||
|
||||
public JoinArguments(ArgumentsRegistry registry) {
|
||||
//join argument
|
||||
registry.mapArgument("buildbattle", new CommandArgument("join", "", CommandArgument.ExecutorType.PLAYER) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length == 1) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.Type-Arena-Name"));
|
||||
return;
|
||||
}
|
||||
if(ArenaRegistry.getArena(((Player) sender)) != null) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("In-Game.Messages.Already-Playing"));
|
||||
return;
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("maxplayers") && ArenaRegistry.getArena("maxplayers") == null) {
|
||||
if(args.length == 2) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.Invalid-Args"));
|
||||
return;
|
||||
}
|
||||
switch(args[2].toLowerCase()) {
|
||||
case "solo":
|
||||
case "team":
|
||||
case "gtb":
|
||||
case "guess_the_build":
|
||||
default:
|
||||
if(args[2].equalsIgnoreCase("gtb") || args[2].equalsIgnoreCase("guess_the_build")) {
|
||||
args[2] = "GUESS_THE_BUILD";
|
||||
}
|
||||
|
||||
BaseArena.ArenaType type = BaseArena.ArenaType.SOLO;
|
||||
try {
|
||||
type = BaseArena.ArenaType.valueOf(args[2].toUpperCase());
|
||||
} catch(IllegalArgumentException ignored) {
|
||||
}
|
||||
|
||||
List<BaseArena> baseArenas = new ArrayList<>();
|
||||
Map<BaseArena, Integer> arenas = new HashMap<>();
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
if(arena.getArenaType() == type) {
|
||||
arenas.put(arena, arena.getPlayers().size());
|
||||
baseArenas.add(arena);
|
||||
}
|
||||
}
|
||||
if(arenas.isEmpty()) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.No-Free-Arenas"));
|
||||
return;
|
||||
}
|
||||
if(ArenaRegistry.getArenaPlayersOnline() == 0) {
|
||||
BaseArena arena = baseArenas.get(ThreadLocalRandom.current().nextInt(baseArenas.size()));
|
||||
ArenaManager.joinAttempt((Player) sender, arena);
|
||||
return;
|
||||
}
|
||||
|
||||
LinkedHashMap<BaseArena, Integer> orderedArenas = new LinkedHashMap<>();
|
||||
arenas.entrySet()
|
||||
.stream()
|
||||
.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder()))
|
||||
.forEachOrdered(x -> orderedArenas.put(x.getKey(), x.getValue()));
|
||||
|
||||
if(!orderedArenas.isEmpty()) {
|
||||
BaseArena arena = orderedArenas.keySet().stream().findFirst().get();
|
||||
ArenaManager.joinAttempt((Player) sender, arena);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
if(args[1].equalsIgnoreCase(arena.getID())) {
|
||||
ArenaManager.joinAttempt((Player) sender, arena);
|
||||
return;
|
||||
}
|
||||
}
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.No-Arena-Like-That"));
|
||||
}
|
||||
});
|
||||
|
||||
//random join argument, register only for multi arena
|
||||
if(!registry.getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
registry.mapArgument("buildbattle", new CommandArgument("randomjoin", "", CommandArgument.ExecutorType.PLAYER) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(ArenaRegistry.getArena(((Player) sender)) != null) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("In-Game.Messages.Already-Playing"));
|
||||
return;
|
||||
}
|
||||
if(args.length == 1) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.Invalid-Args"));
|
||||
return;
|
||||
}
|
||||
switch(args[1].toLowerCase()) {
|
||||
case "solo":
|
||||
case "team":
|
||||
case "gtb":
|
||||
case "guess_the_build":
|
||||
if(args[1].equalsIgnoreCase("gtb") || args[1].equalsIgnoreCase("guess_the_build")) {
|
||||
args[1] = "GUESS_THE_BUILD";
|
||||
}
|
||||
BaseArena.ArenaType t = BaseArena.ArenaType.SOLO;
|
||||
try {
|
||||
t = BaseArena.ArenaType.valueOf(args[1].toUpperCase());
|
||||
} catch(IllegalArgumentException ex) {
|
||||
}
|
||||
|
||||
BaseArena.ArenaType type = t;
|
||||
//check starting arenas -> random
|
||||
List<BaseArena> arenas = ArenaRegistry.getArenas().stream().filter(baseArena -> baseArena.getArenaType() == type).filter(arena -> arena.getArenaState() == ArenaState.STARTING && arena.getPlayers().size() < arena.getMaximumPlayers()).collect(Collectors.toList());
|
||||
if(!arenas.isEmpty()) {
|
||||
BaseArena arena = arenas.get(ThreadLocalRandom.current().nextInt(arenas.size()));
|
||||
ArenaManager.joinAttempt((Player) sender, arena);
|
||||
return;
|
||||
}
|
||||
//check waiting arenas -> random
|
||||
arenas = ArenaRegistry.getArenas().stream().filter(baseArena -> baseArena.getArenaType() == type).filter(arena -> (arena.getArenaState() == ArenaState.WAITING_FOR_PLAYERS || arena.getArenaState() == ArenaState.STARTING)
|
||||
&& arena.getPlayers().size() < arena.getMaximumPlayers()).collect(Collectors.toList());
|
||||
if(!arenas.isEmpty()) {
|
||||
BaseArena arena = arenas.get(ThreadLocalRandom.current().nextInt(arenas.size()));
|
||||
ArenaManager.joinAttempt((Player) sender, arena);
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.No-Free-Arenas"));
|
||||
return;
|
||||
default:
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Invalid-Args"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
-117
@@ -1,117 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.game;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.api.StatsStorage;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.user.data.MysqlManager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class LeaderboardArgument {
|
||||
|
||||
public LeaderboardArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattle", new CommandArgument("top", "", CommandArgument.ExecutorType.PLAYER) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
try {
|
||||
if(args.length == 1) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Statistics.Type-Name"));
|
||||
return;
|
||||
}
|
||||
StatsStorage.StatisticType statisticType = StatsStorage.StatisticType.BLOCKS_BROKEN;
|
||||
try {
|
||||
statisticType = StatsStorage.StatisticType.valueOf(args[1].toUpperCase());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
}
|
||||
|
||||
if(!statisticType.isPersistent()) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Statistics.Invalid-Name"));
|
||||
return;
|
||||
}
|
||||
java.util.Map<UUID, Integer> stats = StatsStorage.getStats(statisticType);
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.Statistics.Header"));
|
||||
String statistic = StringUtils.capitalize(statisticType.toString().toLowerCase().replace('_', ' '));
|
||||
Object[] array = stats.keySet().toArray();
|
||||
UUID current = (UUID) array[array.length - 1];
|
||||
for(int i = 0; i < 10; i++) {
|
||||
try {
|
||||
String message = registry.getPlugin().getChatManager().colorMessage("Commands.Statistics.Format");
|
||||
message = StringUtils.replace(message, "%position%", Integer.toString(i + 1));
|
||||
message = StringUtils.replace(message, "%name%", Bukkit.getOfflinePlayer(current).getName());
|
||||
message = StringUtils.replace(message, "%value%", String.valueOf(stats.remove(current)));
|
||||
message = StringUtils.replace(message, "%statistic%", statistic); //Games_played > Games played etc
|
||||
sender.sendMessage(message);
|
||||
} catch(IndexOutOfBoundsException ex) {
|
||||
String message = registry.getPlugin().getChatManager().colorMessage("Commands.Statistics.Format");
|
||||
message = StringUtils.replace(message, "%position%", Integer.toString(i + 1));
|
||||
message = StringUtils.replace(message, "%name%", "Empty");
|
||||
message = StringUtils.replace(message, "%value%", "0");
|
||||
message = StringUtils.replace(message, "%statistic%", statistic); //Games_played > Games played etc
|
||||
sender.sendMessage(message);
|
||||
} catch(NullPointerException ex) {
|
||||
if(registry.getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.DATABASE_ENABLED)) {
|
||||
try(Connection connection = registry.getPlugin().getMysqlDatabase().getConnection();
|
||||
Statement statement = connection.createStatement();
|
||||
ResultSet set = statement.executeQuery("SELECT name FROM " + ((MysqlManager) registry.getPlugin().getUserManager().getDatabase()).getTableName() + " WHERE UUID='" + current.toString() + "'")) {
|
||||
if(set.next()) {
|
||||
String message = registry.getPlugin().getChatManager().colorMessage("Commands.Statistics.Format");
|
||||
message = StringUtils.replace(message, "%position%", Integer.toString(i + 1));
|
||||
message = StringUtils.replace(message, "%name%", set.getString(1));
|
||||
message = StringUtils.replace(message, "%value%", String.valueOf(stats.get(current)));
|
||||
message = StringUtils.replace(message, "%statistic%", statistic); //Games_played > Games played etc
|
||||
sender.sendMessage(message);
|
||||
continue;
|
||||
}
|
||||
} catch(SQLException ignored) {
|
||||
//fail silently
|
||||
}
|
||||
}
|
||||
String message = registry.getPlugin().getChatManager().colorMessage("Commands.Statistics.Format");
|
||||
message = StringUtils.replace(message, "%position%", Integer.toString(i + 1));
|
||||
message = StringUtils.replace(message, "%name%", "Unknown Player");
|
||||
message = StringUtils.replace(message, "%value%", String.valueOf(stats.get(current)));
|
||||
message = StringUtils.replace(message, "%statistic%", statistic); //Games_played > Games played etc
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
}
|
||||
} catch(IllegalArgumentException e) {
|
||||
sender.sendMessage(registry.getPlugin().getChatManager().colorMessage("Commands.Statistics.Invalid-Name"));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.game;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class LeaveArgument {
|
||||
|
||||
public LeaveArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattle", new CommandArgument("leave", "", CommandArgument.ExecutorType.PLAYER) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(!registry.getPlugin().getConfig().getBoolean("Disable-Leave-Command")) {
|
||||
Player p = (Player) sender;
|
||||
BaseArena arena = ArenaRegistry.getArena(p);
|
||||
if(arena == null) {
|
||||
p.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.No-Playing"));
|
||||
return;
|
||||
}
|
||||
p.sendMessage(registry.getPlugin().getChatManager().getPrefix() + registry.getPlugin().getChatManager().colorMessage("Commands.Teleported-To-The-Lobby"));
|
||||
if(registry.getPlugin().getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
registry.getPlugin().getBungeeManager().connectToHub(p);
|
||||
Debugger.debug(p.getName() + " was teleported to the Hub server");
|
||||
} else {
|
||||
arena.teleportToEndLocation(p);
|
||||
ArenaManager.leaveAttempt(p, arena);
|
||||
Debugger.debug(p.getName() + " has left the arena! He is teleported to the end location.");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.commands.arguments.game;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.buildbattle.api.StatsStorage;
|
||||
import plugily.projects.buildbattle.commands.arguments.ArgumentsRegistry;
|
||||
import plugily.projects.buildbattle.commands.arguments.data.CommandArgument;
|
||||
import plugily.projects.buildbattle.handlers.ChatManager;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 11.01.2019
|
||||
*/
|
||||
public class StatsArgument {
|
||||
|
||||
public StatsArgument(ArgumentsRegistry registry) {
|
||||
registry.mapArgument("buildbattle", new CommandArgument("stats", "", CommandArgument.ExecutorType.PLAYER) {
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
Player player = args.length == 2 ? Bukkit.getPlayerExact(args[1]) : (Player) sender;
|
||||
ChatManager cm = registry.getPlugin().getChatManager();
|
||||
if(player == null) {
|
||||
sender.sendMessage(cm.getPrefix() + cm.colorMessage("Commands.Player-Not-Found"));
|
||||
return;
|
||||
}
|
||||
User user = registry.getPlugin().getUserManager().getUser(player);
|
||||
if (user == null) {
|
||||
sender.sendMessage(cm.getPrefix() + cm.colorMessage("Commands.Player-Not-Found"));
|
||||
return;
|
||||
}
|
||||
if(player.equals(sender)) {
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Header"));
|
||||
} else {
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Header-Other").replace("%player%", player.getName()));
|
||||
}
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Wins") + user.getStat(StatsStorage.StatisticType.WINS));
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Loses") + user.getStat(StatsStorage.StatisticType.LOSES));
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Games-Played") + user.getStat(StatsStorage.StatisticType.GAMES_PLAYED));
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Highest-Win") + user.getStat(StatsStorage.StatisticType.HIGHEST_WIN));
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Highest-Points") + user.getStat(StatsStorage.StatisticType.HIGHEST_POINTS));
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Total-Points-Earned") + user.getStat(StatsStorage.StatisticType.TOTAL_POINTS_EARNED));
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Blocks-Placed") + user.getStat(StatsStorage.StatisticType.BLOCKS_PLACED));
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Blocks-Broken") + user.getStat(StatsStorage.StatisticType.BLOCKS_BROKEN));
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Particles-Placed") + user.getStat(StatsStorage.StatisticType.PARTICLES_USED));
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Super-Votes") + user.getStat(StatsStorage.StatisticType.SUPER_VOTES));
|
||||
sender.sendMessage(cm.colorMessage("Commands.Stats-Command.Footer"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.api.StatsStorage;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.impl.GuessTheBuildArena;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 31.12.2018
|
||||
*/
|
||||
public class ChatEvents implements Listener {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public ChatEvents(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChatIngame(AsyncPlayerChatEvent event) {
|
||||
BaseArena arena = ArenaRegistry.getArena(event.getPlayer());
|
||||
if(!plugin.getConfigPreferences().getOption(ConfigPreferences.Option.DISABLE_SEPARATE_CHAT)) {
|
||||
if(arena == null) {
|
||||
for(BaseArena loopArena : ArenaRegistry.getArenas()) {
|
||||
for(Player player : loopArena.getPlayers()) {
|
||||
event.getRecipients().remove(player);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
event.getRecipients().clear();
|
||||
event.getRecipients().addAll(new ArrayList<>(arena.getPlayers()));
|
||||
}
|
||||
if(!(arena instanceof GuessTheBuildArena)) {
|
||||
return;
|
||||
}
|
||||
GuessTheBuildArena gameArena = (GuessTheBuildArena) arena;
|
||||
if(gameArena.getWhoGuessed().contains(event.getPlayer())) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(plugin.getChatManager().colorMessage("In-Game.Guess-The-Build.Chat.Cant-Talk-When-Guessed"));
|
||||
return;
|
||||
}
|
||||
if(event.getPlayer() == gameArena.getCurrentBuilder()) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(plugin.getChatManager().colorMessage("In-Game.Guess-The-Build.Chat.Cant-Talk-When-Building"));
|
||||
return;
|
||||
}
|
||||
if(gameArena.getCurrentTheme() == null || !gameArena.getCurrentTheme().getTheme().equalsIgnoreCase(event.getMessage())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
plugin.getChatManager().broadcast(arena, plugin.getChatManager().colorMessage("In-Game.Guess-The-Build.Chat.Guessed-The-Theme").replace("%player%", event.getPlayer().getName()));
|
||||
//todo how this works
|
||||
event.getPlayer().sendMessage(plugin.getChatManager().colorMessage("In-Game.Guess-The-Build.Plus-Points")
|
||||
.replace("%pts%", Integer.toString(gameArena.getCurrentTheme().getDifficulty().getPointsReward())));
|
||||
gameArena.getPlayersPoints().put(event.getPlayer(), gameArena.getPlayersPoints().getOrDefault(event.getPlayer(), 0)
|
||||
+ gameArena.getCurrentTheme().getDifficulty().getPointsReward());
|
||||
if(gameArena.getWhoGuessed().isEmpty()) {
|
||||
gameArena.getPlayersPoints().put(gameArena.getCurrentBuilder(), gameArena.getPlayersPoints().getOrDefault(event.getPlayer(), 0)
|
||||
+ gameArena.getCurrentTheme().getDifficulty().getPointsReward());
|
||||
}
|
||||
org.bukkit.Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
gameArena.addWhoGuessed(event.getPlayer());
|
||||
gameArena.recalculateLeaderboard();
|
||||
}, 1L);
|
||||
|
||||
//todo add api event for successful guess
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,622 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.events;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.LeavesDecayEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryInteractEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.vehicle.VehicleMoveEvent;
|
||||
import org.bukkit.event.world.StructureGrowEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import plugily.projects.commonsbox.minecraft.compat.VersionUtils;
|
||||
import plugily.projects.commonsbox.minecraft.compat.events.api.CBPlayerInteractEntityEvent;
|
||||
import plugily.projects.commonsbox.minecraft.compat.events.api.CBPlayerInteractEvent;
|
||||
import plugily.projects.commonsbox.minecraft.compat.xseries.XMaterial;
|
||||
import plugily.projects.commonsbox.minecraft.item.ItemUtils;
|
||||
import plugily.projects.commonsbox.minecraft.misc.stuff.ComplementAccessor;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.api.StatsStorage;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.ArenaUtils;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.arena.impl.GuessTheBuildArena;
|
||||
import plugily.projects.buildbattle.arena.impl.SoloArena;
|
||||
import plugily.projects.buildbattle.arena.managers.plots.Plot;
|
||||
import plugily.projects.buildbattle.handlers.items.SpecialItemsManager;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
|
||||
/**
|
||||
* Created by Tom on 17/08/2015.
|
||||
*/
|
||||
public class GameEvents implements Listener {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public GameEvents(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpecialItem(CBPlayerInteractEvent event) {
|
||||
if(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena(event.getPlayer());
|
||||
ItemStack itemStack = VersionUtils.getItemInHand(event.getPlayer());
|
||||
if(arena == null || !ItemUtils.isItemStackNamed(itemStack)) {
|
||||
return;
|
||||
}
|
||||
String key = plugin.getSpecialItemsManager().getRelatedSpecialItem(itemStack).getName();
|
||||
if(key == null) {
|
||||
return;
|
||||
}
|
||||
if(key.equalsIgnoreCase(SpecialItemsManager.SpecialItems.FORCESTART.getName())) {
|
||||
event.setCancelled(true);
|
||||
ArenaUtils.arenaForceStart(event.getPlayer(), "");
|
||||
return;
|
||||
}
|
||||
if(key.equals(SpecialItemsManager.SpecialItems.LOBBY_LEAVE_ITEM.getName()) || key.equals(SpecialItemsManager.SpecialItems.SPECTATOR_LEAVE_ITEM.getName())) {
|
||||
event.setCancelled(true);
|
||||
if(plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
plugin.getBungeeManager().connectToHub(event.getPlayer());
|
||||
} else {
|
||||
ArenaManager.leaveAttempt(event.getPlayer(), arena);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onOpenOptionMenu(CBPlayerInteractEvent event) {
|
||||
if(VersionUtils.checkOffHand(event.getHand()) || event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK || event.getAction() == Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
if(!ItemUtils.isItemStackNamed(event.getItem())) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena(event.getPlayer());
|
||||
if(arena == null || arena.getArenaState() != ArenaState.IN_GAME || arena instanceof SoloArena && ((SoloArena) arena).isVoting()) {
|
||||
return;
|
||||
}
|
||||
if(!ComplementAccessor.getComplement().getDisplayName(plugin.getOptionsRegistry().getMenuItem().getItemMeta())
|
||||
.equalsIgnoreCase(ComplementAccessor.getComplement().getDisplayName(event.getItem().getItemMeta()))) {
|
||||
return;
|
||||
}
|
||||
event.getPlayer().openInventory(plugin.getOptionsRegistry().formatInventory());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonExtendEvent(BlockPistonExtendEvent event) {
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
for(Plot buildPlot : arena.getPlotManager().getPlots()) {
|
||||
for(Block block : event.getBlocks()) {
|
||||
if(!buildPlot.getCuboid().isInWithMarge(block.getLocation(), -1) && buildPlot.getCuboid().isIn(event.getBlock().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFoodChange(FoodLevelChangeEvent event) {
|
||||
if(!(event.getEntity().getType() == EntityType.PLAYER)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getEntity();
|
||||
if(ArenaRegistry.getArena(player) == null) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
player.setFoodLevel(20);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWaterFlowEvent(BlockFromToEvent event) {
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
for(Plot buildPlot : arena.getPlotManager().getPlots()) {
|
||||
if(!buildPlot.getCuboid().isIn(event.getToBlock().getLocation()) && buildPlot.getCuboid().isIn(event.getBlock().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if(!buildPlot.getCuboid().isInWithMarge(event.getToBlock().getLocation(), -1) && buildPlot.getCuboid().isIn(event.getToBlock().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTNTExplode(EntityExplodeEvent event) {
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
for(Plot buildPlot : arena.getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() == null)
|
||||
continue;
|
||||
if(buildPlot.getCuboid().isInWithMarge(event.getEntity().getLocation(), 5)) {
|
||||
event.blockList().clear();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTNTInteract(CBPlayerInteractEvent event) {
|
||||
if(event.getClickedBlock() == null || VersionUtils.checkOffHand(event.getHand())) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena(event.getPlayer());
|
||||
if(arena == null || VersionUtils.getItemInHand(event.getPlayer()).getType() != Material.FLINT_AND_STEEL) {
|
||||
return;
|
||||
}
|
||||
if(event.getClickedBlock().getType() == Material.TNT) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamageEntity(EntityDamageByEntityEvent event) {
|
||||
if(event.getEntity().getType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena((Player) event.getEntity());
|
||||
if(arena != null) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDamage(EntityDamageEvent event) {
|
||||
if(event.getEntity().getType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena((Player) event.getEntity());
|
||||
if(arena == null || arena.getArenaState() != ArenaState.IN_GAME) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
Player player = (Player) event.getEntity();
|
||||
if(player.getLocation().getY() < 1) {
|
||||
Plot plot = arena.getPlotManager().getPlot(player);
|
||||
if(plot != null) {
|
||||
player.teleport(plot.getTeleportLocation());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTreeGrow(StructureGrowEvent event) {
|
||||
BaseArena arena = ArenaRegistry.getArena(event.getPlayer());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
Plot buildPlot = arena.getPlotManager().getPlot(event.getPlayer());
|
||||
if(buildPlot == null) {
|
||||
return;
|
||||
}
|
||||
for(BlockState blockState : event.getBlocks()) {
|
||||
if(!buildPlot.getCuboid().isIn(blockState.getLocation())) {
|
||||
blockState.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onDispense(BlockDispenseEvent event) {
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
for(Plot buildPlot : arena.getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && !buildPlot.getCuboid().isInWithMarge(event.getBlock().getLocation(), -1) && buildPlot.getCuboid().isInWithMarge(event.getBlock().getLocation(), 5)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
//only a temporary code
|
||||
@EventHandler
|
||||
public void onPlayerHeadsClick(InventoryClickEvent event) {
|
||||
if(!ItemUtils.isItemStackNamed(event.getCurrentItem()) || !(event.getWhoClicked() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena((Player) event.getWhoClicked());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
if(plugin.getOptionsRegistry().getPlayerHeadsRegistry().isHeadsMenu(event.getInventory())) {
|
||||
if(event.getCurrentItem().getType() != ItemUtils.PLAYER_HEAD_ITEM.getType()) {
|
||||
return;
|
||||
}
|
||||
event.getWhoClicked().getInventory().addItem(event.getCurrentItem().clone());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@EventHandler
|
||||
public void onOptionItemClick(InventoryClickEvent event) {
|
||||
if(!(event.getWhoClicked() instanceof Player) || !ItemUtils.isItemStackNamed(event.getCurrentItem())) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena((Player) event.getWhoClicked());
|
||||
String key = plugin.getSpecialItemsManager().getRelatedSpecialItem(event.getCurrentItem()).getName();
|
||||
if(key == null || arena == null) {
|
||||
return;
|
||||
}
|
||||
if(!key.equals(SpecialItemsManager.SpecialItems.OPTIONS_MENU.getName())) {
|
||||
return;
|
||||
}
|
||||
event.setResult(Event.Result.DENY);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onOptionItemClick(InventoryInteractEvent event) {
|
||||
if(!(event.getWhoClicked() instanceof Player) || !ItemUtils.isItemStackNamed(event.getWhoClicked().getItemOnCursor())) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena((Player) event.getWhoClicked());
|
||||
String key = plugin.getSpecialItemsManager().getRelatedSpecialItem(event.getWhoClicked().getItemOnCursor()).getName();
|
||||
if(key == null || arena == null) {
|
||||
return;
|
||||
}
|
||||
if(!key.equals(SpecialItemsManager.SpecialItems.OPTIONS_MENU.getName())) {
|
||||
return;
|
||||
}
|
||||
event.setResult(Event.Result.DENY);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPreCommand(PlayerCommandPreprocessEvent event) {
|
||||
if(ArenaRegistry.getArena(event.getPlayer()) == null) {
|
||||
return;
|
||||
}
|
||||
if(!plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BLOCK_COMMANDS_IN_GAME)) {
|
||||
return;
|
||||
}
|
||||
String command = event.getMessage().substring(1);
|
||||
int indexOf = command.indexOf(' ');
|
||||
command = (indexOf >= 0 ? command.substring(0, indexOf) : command);
|
||||
for(String string : plugin.getConfigPreferences().getWhitelistedCommands()) {
|
||||
if(command.equalsIgnoreCase(string)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(event.getPlayer().isOp() || event.getPlayer().hasPermission("buildbattle.admin") || event.getPlayer().hasPermission("buildbattle.command.bypass")) {
|
||||
return;
|
||||
}
|
||||
if(command.equalsIgnoreCase("bb") || command.equalsIgnoreCase("buildbattle") || command.equalsIgnoreCase("bba") ||
|
||||
command.equalsIgnoreCase("buildbattleadmin")) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(plugin.getChatManager().getPrefix() + plugin.getChatManager().colorMessage("In-Game.Only-Command-Ingame-Is-Leave"));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerCommandExecution(PlayerCommandPreprocessEvent event) {
|
||||
if(plugin.getConfigPreferences().getOption(ConfigPreferences.Option.ENABLE_SHORT_COMMANDS)) {
|
||||
Player player = event.getPlayer();
|
||||
if(event.getMessage().equalsIgnoreCase("/start")) {
|
||||
player.performCommand("bba forcestart");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(event.getMessage().equalsIgnoreCase("/leave")) {
|
||||
player.performCommand("bb leave");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||
BaseArena arena = ArenaRegistry.getArena(event.getPlayer());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
Plot buildPlot = arena.getPlotManager().getPlot(event.getPlayer());
|
||||
if(buildPlot != null && buildPlot.getCuboid() != null && !buildPlot.getCuboid().isIn(event.getBlockClicked().getRelative(event.getBlockFace()).getLocation())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockSpread(BlockSpreadEvent event) {
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
if(!arena.getPlotManager().getPlots().isEmpty()) {
|
||||
Plot plot = arena.getPlotManager().getPlots().get(0);
|
||||
if(plot != null && plot.getCuboid() != null
|
||||
&& event.getBlock().getWorld().equals(plot.getCuboid().getCenter().getWorld()) && event.getSource().getType() == Material.FIRE) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
if(arena.getPlotManager().getPlots().isEmpty() || arena.getPlotManager().getPlots().get(0) == null
|
||||
|| !event.getEntity().getWorld().equals(arena.getPlotManager().getPlots().get(0).getCuboid().getCenter().getWorld())) {
|
||||
continue;
|
||||
}
|
||||
if(event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) {
|
||||
return;
|
||||
}
|
||||
if(event.getEntity().getType() == EntityType.WITHER || plugin.getConfig().getBoolean("Disable-Mob-Spawning-Completely", true)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
for(Plot plot : arena.getPlotManager().getPlots()) {
|
||||
if(plot.getCuboid().isInWithMarge(event.getEntity().getLocation(), 1)) {
|
||||
if(plot.getEntities() >= plugin.getConfig().getInt("Mobs-Max-Amount-Per-Plot", 20)) {
|
||||
//todo maybe only for spawner player?
|
||||
for(Player p : plot.getMembers()) {
|
||||
p.sendMessage(plugin.getChatManager().colorMessage("In-Game.Max-Entities-Limit-Reached"));
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
for(String entityNames : plugin.getConfig().getStringList("Restricted-Entities-Spawn")) {
|
||||
if(event.getEntity().getType().name().equalsIgnoreCase(entityNames)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
plot.addEntity();
|
||||
event.setCancelled(false);
|
||||
event.getEntity().setAI(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeavesDecay(LeavesDecayEvent event) {
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
for(Plot buildPlot : arena.getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && buildPlot.getCuboid().isInWithMarge(event.getBlock().getLocation(), 5)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onIgniteEvent(BlockIgniteEvent event) {
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
for(Plot buildPlot : arena.getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && buildPlot.getCuboid().isInWithMarge(event.getBlock().getLocation(), 5)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPistonRetractEvent(BlockPistonRetractEvent event) {
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
for(Plot buildPlot : arena.getPlotManager().getPlots()) {
|
||||
for(Block block : event.getBlocks()) {
|
||||
if(buildPlot.getCuboid() != null && !buildPlot.getCuboid().isInWithMarge(block.getLocation(), -1) && buildPlot.getCuboid().isIn(event.getBlock().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
if(ArenaRegistry.getArena(event.getPlayer()) == null) {
|
||||
return;
|
||||
}
|
||||
ItemStack drop = event.getItemDrop().getItemStack();
|
||||
if(!ItemUtils.isItemStackNamed(drop)) {
|
||||
return;
|
||||
}
|
||||
if(ComplementAccessor.getComplement().getDisplayName(drop.getItemMeta()).equals(plugin.getChatManager().colorMessage("Menus.Option-Menu.Inventory-Name")) || plugin.getVoteItems().getPoints(drop) != 0) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBreak(BlockBreakEvent event) {
|
||||
BaseArena arena = ArenaRegistry.getArena(event.getPlayer());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
if(arena.getArenaState() != ArenaState.IN_GAME || (arena instanceof SoloArena && ((SoloArena) arena).isVoting())
|
||||
|| plugin.getConfigPreferences().getItemBlacklist().contains(event.getBlock().getType())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
User user = plugin.getUserManager().getUser(event.getPlayer());
|
||||
Plot buildPlot = user.getCurrentPlot();
|
||||
|
||||
if(buildPlot != null && buildPlot.getCuboid() != null && buildPlot.getCuboid().isIn(event.getBlock().getLocation())) {
|
||||
user.addStat(StatsStorage.StatisticType.BLOCKS_BROKEN, 1);
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlace(BlockPlaceEvent event) {
|
||||
BaseArena arena = ArenaRegistry.getArena(event.getPlayer());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
if(arena.getArenaState() != ArenaState.IN_GAME || plugin.getConfigPreferences().getItemBlacklist().contains(event.getBlock().getType())
|
||||
|| (arena instanceof SoloArena && ((SoloArena) arena).isVoting())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(arena instanceof GuessTheBuildArena && !event.getPlayer().equals(((GuessTheBuildArena) arena).getCurrentBuilder())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
User user = plugin.getUserManager().getUser(event.getPlayer());
|
||||
Plot buildPlot = user.getCurrentPlot();
|
||||
|
||||
if(buildPlot != null && buildPlot.getCuboid() != null && buildPlot.getCuboid().isIn(event.getBlock().getLocation())) {
|
||||
user.addStat(StatsStorage.StatisticType.BLOCKS_PLACED, 1);
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
BaseArena arena = ArenaRegistry.getArena((Player) event.getWhoClicked());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
if(arena.getArenaState() != ArenaState.IN_GAME) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(arena instanceof SoloArena && !((SoloArena) arena).isVoting()) {
|
||||
return;
|
||||
}
|
||||
if(arena instanceof GuessTheBuildArena && event.getWhoClicked().equals(((GuessTheBuildArena) arena).getCurrentBuilder())) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onNPCClick(CBPlayerInteractEntityEvent event) {
|
||||
if(VersionUtils.checkOffHand(event.getHand()) || VersionUtils.getItemInHand(event.getPlayer()).getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(plugin.getUserManager().getUser(event.getPlayer()).isSpectator()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(event.getRightClicked() instanceof Villager && event.getRightClicked().getCustomName() != null && event.getRightClicked().getCustomName().equalsIgnoreCase(plugin.getChatManager().colorMessage("In-Game.NPC.Floor-Change-NPC-Name"))) {
|
||||
BaseArena arena = ArenaRegistry.getArena(event.getPlayer());
|
||||
if(arena == null || arena.getArenaState() != ArenaState.IN_GAME) {
|
||||
return;
|
||||
}
|
||||
if(arena instanceof SoloArena && ((SoloArena) arena).isVoting()) {
|
||||
return;
|
||||
}
|
||||
Material material = VersionUtils.getItemInHand(event.getPlayer()).getType();
|
||||
if(material != XMaterial.WATER_BUCKET.parseMaterial() && material != XMaterial.LAVA_BUCKET.parseMaterial()
|
||||
&& !(material.isBlock() && material.isSolid() && material.isOccluding())) {
|
||||
event.getPlayer().sendMessage(plugin.getChatManager().colorMessage("In-Game.Floor-Item-Blacklisted"));
|
||||
return;
|
||||
}
|
||||
if(plugin.getConfigPreferences().getFloorBlacklist().contains(material)) {
|
||||
event.getPlayer().sendMessage(plugin.getChatManager().colorMessage("In-Game.Floor-Item-Blacklisted"));
|
||||
return;
|
||||
}
|
||||
arena.getPlotManager().getPlot(event.getPlayer()).changeFloor(material, VersionUtils.getItemInHand(event.getPlayer()).getData().getData());
|
||||
event.getPlayer().sendMessage(plugin.getChatManager().getPrefix() + plugin.getChatManager().colorMessage("Menus.Option-Menu.Items.Floor.Floor-Changed"));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEnderchestClick(CBPlayerInteractEvent event) {
|
||||
BaseArena arena = ArenaRegistry.getArena(event.getPlayer());
|
||||
if(arena == null) {
|
||||
return;
|
||||
}
|
||||
if(arena.getArenaState() != ArenaState.IN_GAME) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Block block = event.getClickedBlock();
|
||||
if(block != null && block.getType() == XMaterial.ENDER_CHEST.parseMaterial()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMinecartMove(VehicleMoveEvent event) {
|
||||
Vehicle vehicle = event.getVehicle();
|
||||
if(!(vehicle instanceof Minecart)) {
|
||||
return;
|
||||
}
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
for(Plot buildPlot : arena.getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && !buildPlot.getCuboid().isInWithMarge(event.getTo(), -1) && buildPlot.getCuboid().isIn(event.getTo())) {
|
||||
((Minecart) vehicle).setMaxSpeed(0);
|
||||
vehicle.setVelocity(vehicle.getVelocity().zero());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemFrameRotate(PlayerInteractEntityEvent event) {
|
||||
if(event.getRightClicked() instanceof ItemFrame && !((ItemFrame) event.getRightClicked()).getItem().getType().equals(Material.AIR)) {
|
||||
for(BaseArena arena : ArenaRegistry.getArenas()) {
|
||||
for(Plot buildPlot : arena.getPlotManager().getPlots()) {
|
||||
if(buildPlot.getCuboid() != null && !buildPlot.getCuboid().isInWithMarge(event.getRightClicked().getLocation(), -1) && buildPlot.getCuboid().isIn(event.getRightClicked().getLocation())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.events;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.handlers.PermissionManager;
|
||||
import plugily.projects.buildbattle.utils.UpdateChecker;
|
||||
|
||||
/**
|
||||
* Created by Tom on 10/07/2015.
|
||||
*/
|
||||
|
||||
public class JoinEvents implements Listener {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public JoinEvents(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLogin(PlayerLoginEvent e) {
|
||||
if(!plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED) && !plugin.getServer().hasWhitelist()
|
||||
|| e.getResult() != PlayerLoginEvent.Result.KICK_WHITELIST) {
|
||||
return;
|
||||
}
|
||||
if(e.getPlayer().hasPermission(PermissionManager.getJoinFullGames())) {
|
||||
e.setResult(PlayerLoginEvent.Result.ALLOWED);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoinCheckVersion(PlayerJoinEvent e) {
|
||||
//we want to be the first :)
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
if(!e.getPlayer().hasPermission("buildbattle.updatenotify") || !plugin.getConfig().getBoolean("Update-Notifier.Enabled", true)) {
|
||||
return;
|
||||
}
|
||||
UpdateChecker.init(plugin, 44703).requestUpdateCheck().whenComplete((result, exception) -> {
|
||||
if(!result.requiresUpdate()) {
|
||||
return;
|
||||
}
|
||||
if(result.getNewestVersion().contains("b")) {
|
||||
if(plugin.getConfig().getBoolean("Update-Notifier.Notify-Beta-Versions", true)) {
|
||||
e.getPlayer().sendMessage("");
|
||||
e.getPlayer().sendMessage(ChatColor.BOLD + "BUILD BATTLE UPDATE NOTIFY");
|
||||
e.getPlayer().sendMessage(ChatColor.RED + "BETA version of software is ready for update! Proceed with caution.");
|
||||
e.getPlayer().sendMessage(ChatColor.YELLOW + "Current version: " + ChatColor.RED + plugin.getDescription().getVersion() + ChatColor.YELLOW + " Latest version: " + ChatColor.GREEN + result.getNewestVersion());
|
||||
}
|
||||
return;
|
||||
}
|
||||
e.getPlayer().sendMessage("");
|
||||
e.getPlayer().sendMessage(ChatColor.BOLD + "BUILD BATTLE UPDATE NOTIFY");
|
||||
e.getPlayer().sendMessage(ChatColor.GREEN + "Software is ready for update! Download it to keep with latest changes and fixes.");
|
||||
e.getPlayer().sendMessage(ChatColor.YELLOW + "Current version: " + ChatColor.RED + plugin.getDescription().getVersion() + ChatColor.YELLOW + " Latest version: " + ChatColor.GREEN + result.getNewestVersion());
|
||||
});
|
||||
}, 25);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoinLoadStats(PlayerJoinEvent e) {
|
||||
if(plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED) && !ArenaRegistry.getArenas().isEmpty()) {
|
||||
ArenaRegistry.getArenas().get(ArenaRegistry.getBungeeArena()).teleportToLobby(e.getPlayer());
|
||||
}
|
||||
plugin.getUserManager().loadStatistics(plugin.getUserManager().getUser(e.getPlayer()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.events;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import plugily.projects.commonsbox.minecraft.compat.VersionUtils;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 31.12.2018
|
||||
*/
|
||||
public class LobbyEvents implements Listener {
|
||||
|
||||
public LobbyEvents(Main plugin) {
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onFoodLose(FoodLevelChangeEvent event) {
|
||||
if(event.getEntity().getType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena((Player) event.getEntity());
|
||||
if(arena != null && (arena.getArenaState() == ArenaState.STARTING || arena.getArenaState() == ArenaState.WAITING_FOR_PLAYERS)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLobbyDamage(EntityDamageEvent event) {
|
||||
if(event.getEntity().getType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getEntity();
|
||||
BaseArena arena = ArenaRegistry.getArena(player);
|
||||
if(arena == null || arena.getArenaState() == ArenaState.IN_GAME) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
player.setHealth(VersionUtils.getMaxHealth(player));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemFrameRotate(PlayerInteractEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
BaseArena arena = ArenaRegistry.getArena(player);
|
||||
if(arena == null || arena.getArenaState() == ArenaState.IN_GAME) {
|
||||
return;
|
||||
}
|
||||
if(event.getRightClicked() instanceof ItemFrame && !((ItemFrame) event.getRightClicked()).getItem().getType().equals(Material.AIR)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHangingBreak(HangingBreakByEntityEvent event) {
|
||||
if(event.getEntity().getType() != EntityType.PLAYER) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getEntity();
|
||||
BaseArena arena = ArenaRegistry.getArena(player);
|
||||
if(arena == null || arena.getArenaState() == ArenaState.IN_GAME) {
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import plugily.projects.buildbattle.ConfigPreferences;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 29.04.2018
|
||||
*/
|
||||
public class QuitEvents implements Listener {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public QuitEvents(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent e) {
|
||||
onQuit(e.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onKick(PlayerKickEvent e) {
|
||||
onQuit(e.getPlayer());
|
||||
}
|
||||
|
||||
private void onQuit(Player player) {
|
||||
BaseArena arena = ArenaRegistry.getArena(player);
|
||||
if(arena != null && !plugin.getConfigPreferences().getOption(ConfigPreferences.Option.BUNGEE_ENABLED)) {
|
||||
ArenaManager.leaveAttempt(player, arena);
|
||||
}
|
||||
|
||||
User user = plugin.getUserManager().getUser(player);
|
||||
plugin.getUserManager().saveAllStatistic(user);
|
||||
plugin.getUserManager().removeUser(user);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,194 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.events.spectator;
|
||||
|
||||
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.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.player.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
import plugily.projects.commonsbox.minecraft.compat.events.api.CBEntityPickupItemEvent;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.user.User;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 05.08.2018
|
||||
*/
|
||||
public class SpectatorEvents implements Listener {
|
||||
|
||||
private final Main plugin;
|
||||
|
||||
public SpectatorEvents(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onSpectatorTarget(EntityTargetEvent e) {
|
||||
if(!(e.getTarget() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if(plugin.getUserManager().getUser((Player) e.getTarget()).isSpectator()) {
|
||||
e.setCancelled(true);
|
||||
e.setTarget(null);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onSpectatorTarget(EntityTargetLivingEntityEvent e) {
|
||||
if(!(e.getTarget() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
if(plugin.getUserManager().getUser((Player) e.getTarget()).isSpectator()) {
|
||||
e.setCancelled(true);
|
||||
e.setTarget(null);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if(plugin.getUserManager().getUser(event.getPlayer()).isSpectator()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if(plugin.getUserManager().getUser(event.getPlayer()).isSpectator()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDropItem(PlayerDropItemEvent event) {
|
||||
if(plugin.getUserManager().getUser(event.getPlayer()).isSpectator()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||
if(plugin.getUserManager().getUser(event.getPlayer()).isSpectator()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onInteract(PlayerInteractEntityEvent event) {
|
||||
if(plugin.getUserManager().getUser(event.getPlayer()).isSpectator()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onShear(PlayerShearEntityEvent event) {
|
||||
if(plugin.getUserManager().getUser(event.getPlayer()).isSpectator()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onConsume(PlayerItemConsumeEvent event) {
|
||||
if(plugin.getUserManager().getUser(event.getPlayer()).isSpectator()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if(!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getEntity();
|
||||
if(plugin.getUserManager().getUser(player).isSpectator()) {
|
||||
event.setFoodLevel(20);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDamage(EntityDamageEvent event) {
|
||||
if(!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getEntity();
|
||||
User user = plugin.getUserManager().getUser(player);
|
||||
if(!user.isSpectator()) {
|
||||
return;
|
||||
}
|
||||
if(user.getArena() == null) {
|
||||
return;
|
||||
}
|
||||
if(player.getLocation().getY() < 1) {
|
||||
BaseArena arena = ArenaRegistry.getArena(player);
|
||||
if(arena != null) {
|
||||
player.teleport(arena.getPlotManager().getPlots().get(0).getTeleportLocation());
|
||||
}
|
||||
event.setDamage(0);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDamageByBlock(EntityDamageByBlockEvent event) {
|
||||
if(!(event.getEntity() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getEntity();
|
||||
if(plugin.getUserManager().getUser(player).isSpectator()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
if(!(event.getDamager() instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
Player player = (Player) event.getDamager();
|
||||
if(plugin.getUserManager().getUser(player).isSpectator()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPickup(CBEntityPickupItemEvent event) {
|
||||
if(event.getEntity() instanceof Player && plugin.getUserManager().getUser((Player) event.getEntity()).isSpectator()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.events.spectator;
|
||||
|
||||
import plugily.projects.inventoryframework.gui.GuiItem;
|
||||
import plugily.projects.inventoryframework.gui.type.ChestGui;
|
||||
import plugily.projects.inventoryframework.pane.OutlinePane;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import plugily.projects.commonsbox.minecraft.compat.VersionUtils;
|
||||
import plugily.projects.commonsbox.minecraft.compat.events.api.CBPlayerInteractEvent;
|
||||
import plugily.projects.commonsbox.minecraft.compat.xseries.XMaterial;
|
||||
import plugily.projects.commonsbox.minecraft.item.ItemUtils;
|
||||
import plugily.projects.commonsbox.minecraft.misc.stuff.ComplementAccessor;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.handlers.ChatManager;
|
||||
import plugily.projects.buildbattle.handlers.items.SpecialItemsManager;
|
||||
import plugily.projects.buildbattle.utils.Utils;
|
||||
|
||||
/**
|
||||
* @author Tigerpanzer_02
|
||||
* <p>
|
||||
* Created at 30.05.2021
|
||||
*/
|
||||
public class SpectatorItemEvents implements Listener {
|
||||
|
||||
private final Main plugin;
|
||||
private final ChatManager chatManager;
|
||||
private final SpectatorSettingsMenu spectatorSettingsMenu;
|
||||
|
||||
public SpectatorItemEvents(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
chatManager = plugin.getChatManager();
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
spectatorSettingsMenu = new SpectatorSettingsMenu(plugin, chatManager.colorMessage("In-Game.Spectator.Settings-Menu.Inventory-Name"),
|
||||
chatManager.colorMessage("In-Game.Spectator.Settings-Menu.Speed-Name"));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpectatorItemClick(CBPlayerInteractEvent e) {
|
||||
if(e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK || e.getAction() == Action.PHYSICAL) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArena(e.getPlayer());
|
||||
ItemStack stack = VersionUtils.getItemInHand(e.getPlayer());
|
||||
if(arena == null || !ItemUtils.isItemStackNamed(stack)) {
|
||||
return;
|
||||
}
|
||||
if(plugin.getSpecialItemsManager().getRelatedSpecialItem(stack).getName().equals(SpecialItemsManager.SpecialItems.PLAYERS_LIST.getName())) {
|
||||
e.setCancelled(true);
|
||||
openSpectatorMenu(arena, e.getPlayer());
|
||||
} else if(plugin.getSpecialItemsManager().getRelatedSpecialItem(stack).getName().equals(SpecialItemsManager.SpecialItems.SPECTATOR_OPTIONS.getName())) {
|
||||
e.setCancelled(true);
|
||||
spectatorSettingsMenu.openSpectatorSettingsMenu(e.getPlayer());
|
||||
} else if(plugin.getSpecialItemsManager().getRelatedSpecialItem(stack).getName().equals(SpecialItemsManager.SpecialItems.SPECTATOR_LEAVE_ITEM.getName())) {
|
||||
e.setCancelled(true);
|
||||
ArenaManager.leaveAttempt(e.getPlayer(), arena);
|
||||
}
|
||||
}
|
||||
|
||||
private void openSpectatorMenu(BaseArena arena, Player player) {
|
||||
int rows = Utils.serializeInt(arena.getPlayers().size()) / 9;
|
||||
if(rows > 6 || rows < 1) {
|
||||
rows = 6;
|
||||
}
|
||||
|
||||
ChestGui gui = new ChestGui(rows, plugin.getChatManager().colorMessage("In-Game.Spectator.Spectator-Menu-Name"));
|
||||
OutlinePane pane = new OutlinePane(9, rows);
|
||||
ItemStack skull = XMaterial.PLAYER_HEAD.parseItem();
|
||||
gui.setOnGlobalClick(event -> event.setCancelled(true));
|
||||
for(Player arenaPlayer : arena.getPlayers()) {
|
||||
if(plugin.getUserManager().getUser(arenaPlayer).isSpectator()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack cloneSkull = skull.clone();
|
||||
SkullMeta meta = VersionUtils.setPlayerHead(arenaPlayer, (SkullMeta) cloneSkull.getItemMeta());
|
||||
ComplementAccessor.getComplement().setDisplayName(meta, arenaPlayer.getName());
|
||||
cloneSkull.setItemMeta(meta);
|
||||
pane.addItem(new GuiItem(cloneSkull, e -> {
|
||||
e.setCancelled(true);
|
||||
e.getWhoClicked().sendMessage(plugin.getChatManager().formatMessage(arena, plugin.getChatManager().colorMessage("Commands.Admin-Commands.Teleported-To-Player"), arenaPlayer));
|
||||
e.getWhoClicked().closeInventory();
|
||||
e.getWhoClicked().teleport(arenaPlayer);
|
||||
}));
|
||||
}
|
||||
gui.addPane(pane);
|
||||
gui.show(player);
|
||||
}
|
||||
|
||||
}
|
||||
-115
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.events.spectator;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import plugily.projects.commonsbox.minecraft.compat.xseries.XMaterial;
|
||||
import plugily.projects.commonsbox.minecraft.item.ItemBuilder;
|
||||
import plugily.projects.commonsbox.minecraft.misc.stuff.ComplementAccessor;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.handlers.ChatManager;
|
||||
|
||||
public class SpectatorSettingsMenu implements Listener {
|
||||
|
||||
private final Main plugin;
|
||||
private final String inventoryName;
|
||||
private final String speedOptionName;
|
||||
private final Inventory inv;
|
||||
|
||||
public SpectatorSettingsMenu(Main plugin, String inventoryName, String speedOptionName) {
|
||||
this.plugin = plugin;
|
||||
this.inventoryName = inventoryName;
|
||||
this.speedOptionName = speedOptionName;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
inv = initInventory();
|
||||
}
|
||||
|
||||
public void openSpectatorSettingsMenu(Player player) {
|
||||
player.openInventory(inv);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSpectatorMenuClick(InventoryClickEvent e) {
|
||||
if(!ComplementAccessor.getComplement().getTitle(e.getView()).equals(plugin.getChatManager().colorRawMessage(inventoryName))) {
|
||||
return;
|
||||
}
|
||||
org.bukkit.inventory.ItemStack currentItem = e.getCurrentItem();
|
||||
if(currentItem == null || !currentItem.hasItemMeta()) {
|
||||
return;
|
||||
}
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
p.closeInventory();
|
||||
|
||||
switch(currentItem.getType()) {
|
||||
case LEATHER_BOOTS:
|
||||
p.removePotionEffect(PotionEffectType.SPEED);
|
||||
p.setFlySpeed(0.15f);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 0, false, false));
|
||||
break;
|
||||
case CHAINMAIL_BOOTS:
|
||||
p.removePotionEffect(PotionEffectType.SPEED);
|
||||
p.setFlySpeed(0.2f);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1, false, false));
|
||||
break;
|
||||
case IRON_BOOTS:
|
||||
p.removePotionEffect(PotionEffectType.SPEED);
|
||||
p.setFlySpeed(0.25f);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2, false, false));
|
||||
break;
|
||||
case GOLDEN_BOOTS:
|
||||
p.removePotionEffect(PotionEffectType.SPEED);
|
||||
p.setFlySpeed(0.3f);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 3, false, false));
|
||||
break;
|
||||
case DIAMOND_BOOTS:
|
||||
p.removePotionEffect(PotionEffectType.SPEED);
|
||||
p.setFlySpeed(0.35f);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 4, false, false));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private Inventory initInventory() {
|
||||
Inventory inv = ComplementAccessor.getComplement().createInventory(null, 9 * 3, inventoryName);
|
||||
ChatManager chatManager = plugin.getChatManager();
|
||||
inv.setItem(11, new ItemBuilder(Material.LEATHER_BOOTS)
|
||||
.name(chatManager.colorRawMessage(speedOptionName + " I")).build());
|
||||
inv.setItem(12, new ItemBuilder(Material.CHAINMAIL_BOOTS)
|
||||
.name(chatManager.colorRawMessage(speedOptionName + " II")).build());
|
||||
inv.setItem(13, new ItemBuilder(Material.IRON_BOOTS)
|
||||
.name(chatManager.colorRawMessage(speedOptionName + " III")).build());
|
||||
inv.setItem(14, new ItemBuilder(XMaterial.GOLDEN_BOOTS.parseItem())
|
||||
.name(chatManager.colorRawMessage(speedOptionName + " IV")).build());
|
||||
inv.setItem(15, new ItemBuilder(Material.DIAMOND_BOOTS)
|
||||
.name(chatManager.colorRawMessage(speedOptionName + " V")).build());
|
||||
return inv;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,105 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.handlers;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
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.server.ServerListPingEvent;
|
||||
import plugily.projects.commonsbox.minecraft.configuration.ConfigUtils;
|
||||
import plugily.projects.commonsbox.minecraft.misc.stuff.ComplementAccessor;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.ArenaManager;
|
||||
import plugily.projects.buildbattle.arena.ArenaRegistry;
|
||||
import plugily.projects.buildbattle.arena.ArenaState;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Tom on 31/08/2014.
|
||||
*/
|
||||
public class BungeeManager implements Listener {
|
||||
|
||||
private final Main plugin;
|
||||
private final Map<ArenaState, String> gameStateToString = new EnumMap<>(ArenaState.class);
|
||||
private final String motd;
|
||||
private final FileConfiguration conf;
|
||||
|
||||
public BungeeManager(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
this.conf = ConfigUtils.getConfig(plugin, "bungee");
|
||||
gameStateToString.put(ArenaState.WAITING_FOR_PLAYERS, plugin.getChatManager().colorRawMessage(conf.getString("MOTD.Game-States.Inactive", "Inactive")));
|
||||
gameStateToString.put(ArenaState.STARTING, plugin.getChatManager().colorRawMessage(conf.getString("MOTD.Game-States.Starting", "Starting")));
|
||||
gameStateToString.put(ArenaState.IN_GAME, plugin.getChatManager().colorRawMessage(conf.getString("MOTD.Game-States.In-Game", "In-Game")));
|
||||
gameStateToString.put(ArenaState.ENDING, plugin.getChatManager().colorRawMessage(conf.getString("MOTD.Game-States.Ending", "Ending")));
|
||||
gameStateToString.put(ArenaState.RESTARTING, plugin.getChatManager().colorRawMessage(conf.getString("MOTD.Game-States.Restarting", "Restarting")));
|
||||
motd = plugin.getChatManager().colorRawMessage(conf.getString("MOTD.Message", "The actual game state of bb is %state%"));
|
||||
plugin.getServer().getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
public void connectToHub(Player player) {
|
||||
if(!plugin.isEnabled() || !conf.getBoolean("Connect-To-Hub", true)) {
|
||||
return;
|
||||
}
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(conf.getString("Hub"));
|
||||
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onServerListPing(ServerListPingEvent event) {
|
||||
if(ArenaRegistry.getArenas().isEmpty() || !conf.getBoolean("MOTD.Manager")) {
|
||||
return;
|
||||
}
|
||||
BaseArena arena = ArenaRegistry.getArenas().get(ArenaRegistry.getBungeeArena());
|
||||
event.setMaxPlayers(arena.getMaximumPlayers());
|
||||
ComplementAccessor.getComplement().setMotd(event, motd.replace("%state%", gameStateToString.get(arena.getArenaState())));
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onJoin(final PlayerJoinEvent event) {
|
||||
ComplementAccessor.getComplement().setJoinMessage(event, "");
|
||||
if(!ArenaRegistry.getArenas().isEmpty())
|
||||
plugin.getServer().getScheduler().runTaskLater(plugin, () -> ArenaManager.joinAttempt(event.getPlayer(), ArenaRegistry.getArenas().get(ArenaRegistry.getBungeeArena())), 1L);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
ComplementAccessor.getComplement().setQuitMessage(event, "");
|
||||
if(!ArenaRegistry.getArenas().isEmpty() && ArenaRegistry.getArena(event.getPlayer()) != null) {
|
||||
ArenaManager.leaveAttempt(event.getPlayer(), ArenaRegistry.getArenas().get(ArenaRegistry.getBungeeArena()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,125 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.handlers;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import plugily.projects.commonsbox.minecraft.compat.ServerVersion;
|
||||
import plugily.projects.commonsbox.minecraft.misc.MiscUtils;
|
||||
import plugily.projects.commonsbox.string.StringFormatUtils;
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.arena.impl.BaseArena;
|
||||
import plugily.projects.buildbattle.handlers.language.LanguageManager;
|
||||
|
||||
/**
|
||||
* Created by Tom on 27/07/2014.
|
||||
*/
|
||||
public class ChatManager {
|
||||
|
||||
private final String pluginPrefix;
|
||||
private final Main plugin;
|
||||
|
||||
public ChatManager(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
this.pluginPrefix = colorMessage("In-Game.Plugin-Prefix");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return game prefix
|
||||
*/
|
||||
public String getPrefix() {
|
||||
return pluginPrefix;
|
||||
}
|
||||
|
||||
public String colorMessage(String path) {
|
||||
return path == null ? "" : colorRawMessage(LanguageManager.getLanguageMessage(path));
|
||||
}
|
||||
|
||||
public String colorRawMessage(String msg) {
|
||||
if(msg == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if(ServerVersion.Version.isCurrentEqualOrHigher(ServerVersion.Version.v1_16_R1) && msg.contains("#")) {
|
||||
msg = MiscUtils.matchColorRegex(msg);
|
||||
}
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', msg);
|
||||
}
|
||||
|
||||
public void broadcast(BaseArena arena, String message) {
|
||||
if(message != null && !message.isEmpty()) {
|
||||
for(Player p : arena.getPlayers()) {
|
||||
p.sendMessage(pluginPrefix + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String formatMessage(BaseArena arena, String message, Player player) {
|
||||
String returnString = message;
|
||||
|
||||
returnString = StringUtils.replace(returnString, "%PLAYER%", player.getName());
|
||||
|
||||
returnString = formatPlaceholders(returnString, arena);
|
||||
|
||||
if(plugin.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||
returnString = PlaceholderAPI.setPlaceholders(player, returnString);
|
||||
}
|
||||
|
||||
return colorRawMessage(formatPlaceholders(returnString, arena));
|
||||
}
|
||||
|
||||
private static String formatPlaceholders(String message, BaseArena arena) {
|
||||
String returnString = message;
|
||||
returnString = StringUtils.replace(returnString, "%ARENANAME%", arena.getMapName());
|
||||
|
||||
int timer = arena.getTimer();
|
||||
|
||||
returnString = StringUtils.replace(returnString, "%TIME%", Integer.toString(timer));
|
||||
returnString = StringUtils.replace(returnString, "%FORMATTEDTIME%", StringFormatUtils.formatIntoMMSS(timer));
|
||||
returnString = StringUtils.replace(returnString, "%PLAYERSIZE%", Integer.toString(arena.getPlayers().size()));
|
||||
returnString = StringUtils.replace(returnString, "%MAXPLAYERS%", Integer.toString(arena.getMaximumPlayers()));
|
||||
returnString = StringUtils.replace(returnString, "%MINPLAYERS%", Integer.toString(arena.getMinimumPlayers()));
|
||||
return returnString;
|
||||
}
|
||||
|
||||
public void broadcastAction(BaseArena arena, Player player, ActionType action) {
|
||||
String path;
|
||||
switch(action) {
|
||||
case JOIN:
|
||||
path = "In-Game.Messages.Join";
|
||||
break;
|
||||
case LEAVE:
|
||||
path = "In-Game.Messages.Leave";
|
||||
break;
|
||||
default:
|
||||
return; //likely won't ever happen
|
||||
}
|
||||
broadcast(arena, formatMessage(arena, colorMessage(path), player));
|
||||
}
|
||||
|
||||
public enum ActionType {
|
||||
JOIN, LEAVE
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* BuildBattle - Ultimate building competition minigame
|
||||
* Copyright (C) 2021 Plugily Projects - maintained by Tigerpanzer_02, 2Wild4You and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package plugily.projects.buildbattle.handlers;
|
||||
|
||||
import plugily.projects.buildbattle.Main;
|
||||
import plugily.projects.buildbattle.utils.Debugger;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author Plajer
|
||||
* <p>
|
||||
* Created at 24.03.2019
|
||||
*/
|
||||
public class HolidayManager {
|
||||
|
||||
private static HolidayType currentHoliday = HolidayType.NONE;
|
||||
|
||||
public HolidayManager(Main plugin) {
|
||||
if(!plugin.getConfig().getBoolean("Holidays-Enabled", true)) {
|
||||
return;
|
||||
}
|
||||
LocalDateTime time = LocalDateTime.now();
|
||||
|
||||
Debugger.debug("[HolidayManager] Time of server " + time);
|
||||
|
||||
int day = time.getDayOfMonth();
|
||||
int month = time.getMonthValue();
|
||||
|
||||
switch(month) {
|
||||
case 2:
|
||||
if(day >= 10 && day <= 18) {
|
||||
currentHoliday = HolidayType.VALENTINES_DAY;
|
||||
//replace themes
|
||||
plugin.getConfigPreferences().getGameThemes().clear();
|
||||
plugin.getConfigPreferences().getGameThemes().put("Classic", plugin.getConfig().getStringList("Holiday-Themes.Valentines-Day"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Teams", plugin.getConfig().getStringList("Holiday-Themes.Valentines-Day"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Guess-The-Build", plugin.getConfig().getStringList("Holiday-Themes.Valentines-Day"));
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
//4 days before april fools
|
||||
if(day >= 28) {
|
||||
currentHoliday = HolidayType.APRIL_FOOLS;
|
||||
plugin.getConfigPreferences().getGameThemes().clear();
|
||||
plugin.getConfigPreferences().getGameThemes().put("Classic", plugin.getConfig().getStringList("Holiday-Themes.April-Fools"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Teams", plugin.getConfig().getStringList("Holiday-Themes.April-Fools"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Guess-The-Build", plugin.getConfig().getStringList("Holiday-Themes.April-Fools"));
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
//4 days after april fools
|
||||
if(day <= 5) {
|
||||
currentHoliday = HolidayType.APRIL_FOOLS;
|
||||
plugin.getConfigPreferences().getGameThemes().clear();
|
||||
plugin.getConfigPreferences().getGameThemes().put("Classic", plugin.getConfig().getStringList("Holiday-Themes.April-Fools"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Teams", plugin.getConfig().getStringList("Holiday-Themes.April-Fools"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Guess-The-Build", plugin.getConfig().getStringList("Holiday-Themes.April-Fools"));
|
||||
}
|
||||
break;
|
||||
case 10:
|
||||
//4 days before halloween
|
||||
if(day >= 27) {
|
||||
currentHoliday = HolidayType.HALLOWEEN;
|
||||
plugin.getConfigPreferences().getGameThemes().clear();
|
||||
plugin.getConfigPreferences().getGameThemes().put("Classic", plugin.getConfig().getStringList("Holiday-Themes.Halloween"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Teams", plugin.getConfig().getStringList("Holiday-Themes.Halloween"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Guess-The-Build", plugin.getConfig().getStringList("Holiday-Themes.Halloween"));
|
||||
}
|
||||
break;
|
||||
case 11:
|
||||
//4 days after halloween
|
||||
if(day <= 4) {
|
||||
currentHoliday = HolidayType.HALLOWEEN;
|
||||
plugin.getConfigPreferences().getGameThemes().clear();
|
||||
plugin.getConfigPreferences().getGameThemes().put("Classic", plugin.getConfig().getStringList("Holiday-Themes.Halloween"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Teams", plugin.getConfig().getStringList("Holiday-Themes.Halloween"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Guess-The-Build", plugin.getConfig().getStringList("Holiday-Themes.Halloween"));
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
if(day >= 21 && day <= 29) {
|
||||
currentHoliday = HolidayType.CHRISTMAS;
|
||||
plugin.getConfigPreferences().getGameThemes().clear();
|
||||
plugin.getConfigPreferences().getGameThemes().put("Classic", plugin.getConfig().getStringList("Holiday-Themes.Christmas"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Teams", plugin.getConfig().getStringList("Holiday-Themes.Christmas"));
|
||||
plugin.getConfigPreferences().getGameThemes().put("Guess-The-Build", plugin.getConfig().getStringList("Holiday-Themes.Christmas"));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Debugger.debug("[HolidayManager] CurrentHoliday: " + getCurrentHoliday().name());
|
||||
Debugger.debug("[HolidayManager] New Themes: " + plugin.getConfigPreferences().getGameThemes());
|
||||
}
|
||||
|
||||
public static HolidayType getCurrentHoliday() {
|
||||
return currentHoliday;
|
||||
}
|
||||
|
||||
public enum HolidayType {
|
||||
HALLOWEEN, APRIL_FOOLS, CHRISTMAS, NONE, VALENTINES_DAY
|
||||
}
|
||||
|
||||
}
|
||||
Loaded 100 of 199 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user