Updates .jar to 1.18, fixes formatting and fixes some warnings
This commit is contained in:
parent
d5296c4314
commit
544286bd5e
92
README.md
92
README.md
@ -1,81 +1,109 @@
|
|||||||
[Jail 3.0](http://ci.graywolf336.com/job/Jail/) - [JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc) - [Wiki](https://github.com/graywolf336/Jail/wiki) - [Translate](https://translate.lingohub.com/craftyn/jail-plugin/dashboard)
|
[Jail 3.0](http://ci.graywolf336.com/job/Jail/) - [JavaDoc](http://ci.graywolf336.com/job/Jail/javadoc) - [Wiki](https://github.com/graywolf336/Jail/wiki) - [Translate](https://translate.lingohub.com/craftyn/jail-plugin/dashboard)
|
||||||
====
|
====
|
||||||
This plugins adds Jail to your Minecraft server. Admins can define several jails and then jail/unjail people, can be on a time basis. This plugin also offers wide variety of protections, this way players won't escape out of jail.
|
This plugins adds Jail to your Minecraft server. Admins can define several jails and then jail/unjail people, can be on
|
||||||
|
a time basis. This plugin also offers wide variety of protections, this way players won't escape out of jail.
|
||||||
|
|
||||||
[![Build Status](https://ci.craftyn.com/job/Jail/badge/icon)](https://ci.graywolf336.com/job/Jail/) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7934cceb4d27488f99ccba52f30681d1)](https://www.codacy.com/app/graywolf336/Jail?utm_source=github.com&utm_medium=referral&utm_content=graywolf336/Jail&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/7934cceb4d27488f99ccba52f30681d1)](https://www.codacy.com/app/graywolf336/Jail?utm_source=github.com&utm_medium=referral&utm_content=graywolf336/Jail&utm_campaign=Badge_Coverage)
|
[![Build Status](https://ci.craftyn.com/job/Jail/badge/icon)](https://ci.graywolf336.com/job/Jail/) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/7934cceb4d27488f99ccba52f30681d1)](https://www.codacy.com/app/graywolf336/Jail?utm_source=github.com&utm_medium=referral&utm_content=graywolf336/Jail&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/7934cceb4d27488f99ccba52f30681d1)](https://www.codacy.com/app/graywolf336/Jail?utm_source=github.com&utm_medium=referral&utm_content=graywolf336/Jail&utm_campaign=Badge_Coverage)
|
||||||
|
|
||||||
Translating
|
Translating
|
||||||
===
|
===
|
||||||
If you would like to help translate this project, please shoot me an email `graywolf336`@`craftyn.com` and let me know which language(s) you would like to contribute to and I will add you.
|
If you would like to help translate this project, please shoot me an email `graywolf336`@`craftyn.com` and let me know
|
||||||
|
which language(s) you would like to contribute to and I will add you.
|
||||||
|
|
||||||
Developing/Building
|
Developing/Building
|
||||||
===
|
===
|
||||||
If you want to make some changes, build, and run the unit tests you will notice we require CraftBukkit 1.8 with maven and it isn't hosted anywhere publicly for legal reasons. You will need to build CraftBukkit 1.8 yourself and then put it locally for maven with the following command:
|
If you want to make some changes, build, and run the unit tests you will notice we require CraftBukkit 1.8 with maven
|
||||||
|
and it isn't hosted anywhere publicly for legal reasons. You will need to build CraftBukkit 1.8 yourself and then put it
|
||||||
|
locally for maven with the following command:
|
||||||
|
|
||||||
`mvn install:install-file -Dfile=craftbukkit-1.9-R0.1.jar -DgroupId=org.bukkit -DartifactId=craftbukkit -Dversion=1.9-R0.1-SNAPSHOT -Dpackaging=jar`
|
`mvn install:install-file -Dfile=craftbukkit-1.9-R0.1.jar -DgroupId=org.bukkit -DartifactId=craftbukkit -Dversion=1.9-R0.1-SNAPSHOT -Dpackaging=jar`
|
||||||
|
|
||||||
Beta 6 Changes
|
Beta 6 Changes
|
||||||
===
|
===
|
||||||
*Changes since Beta 5*
|
*Changes since Beta 5*
|
||||||
|
|
||||||
* Plugin now requires Java 1.8
|
* Plugin now requires Java 1.8
|
||||||
* Fixed an issue with sqlite and 1.10 [#128](https://github.com/graywolf336/Jail/issues/128)
|
* Fixed an issue with sqlite and 1.10 [#128](https://github.com/graywolf336/Jail/issues/128)
|
||||||
|
|
||||||
[Beta 5](https://github.com/graywolf336/Jail/releases/tag/v3.0.0-beta.5) Changes
|
[Beta 5](https://github.com/graywolf336/Jail/releases/tag/v3.0.0-beta.5) Changes
|
||||||
===
|
===
|
||||||
*Changes since Beta 4*
|
*Changes since Beta 4*
|
||||||
* Added a command to update, verify, refresh, and clean signs on cells. [#79](https://github.com/graywolf336/Jail/issues/79)
|
|
||||||
|
* Added a command to update, verify, refresh, and clean signs on
|
||||||
|
cells. [#79](https://github.com/graywolf336/Jail/issues/79)
|
||||||
* Added an api to get the build number, this way we can reference it in the future.
|
* Added an api to get the build number, this way we can reference it in the future.
|
||||||
* Added a password requirement on the broadcast of jailing, defaults to everyone. [#54](https://github.com/graywolf336/Jail/issues/54)
|
* Added a password requirement on the broadcast of jailing, defaults to
|
||||||
* Added the ability to show `reason`, `jail`, and `cell` to the broadcast messages. [#53](https://github.com/graywolf336/Jail/issues/53)
|
everyone. [#54](https://github.com/graywolf336/Jail/issues/54)
|
||||||
|
* Added the ability to show `reason`, `jail`, and `cell` to the broadcast
|
||||||
|
messages. [#53](https://github.com/graywolf336/Jail/issues/53)
|
||||||
* Added tab complete to all the commands. [#77](https://github.com/graywolf336/Jail/issues/77)
|
* Added tab complete to all the commands. [#77](https://github.com/graywolf336/Jail/issues/77)
|
||||||
* Added reloading the move protection listener, so the reload actually loads/disables it. [#88](https://github.com/graywolf336/Jail/issues/88)
|
* Added reloading the move protection listener, so the reload actually loads/disables
|
||||||
|
it. [#88](https://github.com/graywolf336/Jail/issues/88)
|
||||||
* Changed cell names to be semi-sorted alphabetically. [#80](https://github.com/graywolf336/Jail/issues/80)
|
* Changed cell names to be semi-sorted alphabetically. [#80](https://github.com/graywolf336/Jail/issues/80)
|
||||||
* Changed how we handle inventory when storing is set to false. Don't remove their inventory when they are unjailed and we don't store it. [#57](https://github.com/graywolf336/Jail/issues/57)
|
* Changed how we handle inventory when storing is set to false. Don't remove their inventory when they are unjailed and
|
||||||
* Changed offline players jailing, don't allow jailing players unless they've played before (can be overwrote with -f). [#82](https://github.com/graywolf336/Jail/issues/82)
|
we don't store it. [#57](https://github.com/graywolf336/Jail/issues/57)
|
||||||
* Changed the jail api, see [#72's comment](https://github.com/graywolf336/Jail/issues/72#issuecomment-104757472) for some details.
|
* Changed offline players jailing, don't allow jailing players unless they've played before (can be overwrote with -f)
|
||||||
* Changed jailing items, we run all jailing sync so that any api usage async won't cause problems. [#73](https://github.com/graywolf336/Jail/issues/73)
|
. [#82](https://github.com/graywolf336/Jail/issues/82)
|
||||||
|
* Changed the jail api, see [#72's comment](https://github.com/graywolf336/Jail/issues/72#issuecomment-104757472) for
|
||||||
|
some details.
|
||||||
|
* Changed jailing items, we run all jailing sync so that any api usage async won't cause
|
||||||
|
problems. [#73](https://github.com/graywolf336/Jail/issues/73)
|
||||||
* Changed the format of the jail check command, thanks to stevoh6. [#65](https://github.com/graywolf336/Jail/pull/65)
|
* Changed the format of the jail check command, thanks to stevoh6. [#65](https://github.com/graywolf336/Jail/pull/65)
|
||||||
* Changed the explanation of why the gamemode setting was problematic and give the available options. [#73](https://github.com/graywolf336/Jail/issues/73)
|
* Changed the explanation of why the gamemode setting was problematic and give the available
|
||||||
|
options. [#73](https://github.com/graywolf336/Jail/issues/73)
|
||||||
* Changed pretty time to be the default of the signs.
|
* Changed pretty time to be the default of the signs.
|
||||||
* Fixed a sqlite issue which was preventing plugin from launching. [#78](https://github.com/graywolf336/Jail/issues/78)
|
* Fixed a sqlite issue which was preventing plugin from launching. [#78](https://github.com/graywolf336/Jail/issues/78)
|
||||||
* Fixed a sqlite error when deleting a cell. [#89](https://github.com/graywolf336/Jail/issues/89)
|
* Fixed a sqlite error when deleting a cell. [#89](https://github.com/graywolf336/Jail/issues/89)
|
||||||
* Fixed an issue where cell data was being duplicated (or more) in the database. [#74](https://github.com/graywolf336/Jail/issues/74)
|
* Fixed an issue where cell data was being duplicated (or more) in the
|
||||||
* Fixed an on load issue when the config didn't have four lines for the signs. [#61](https://github.com/graywolf336/Jail/issues/61)
|
database. [#74](https://github.com/graywolf336/Jail/issues/74)
|
||||||
|
* Fixed an on load issue when the config didn't have four lines for the
|
||||||
|
signs. [#61](https://github.com/graywolf336/Jail/issues/61)
|
||||||
* Fixed cell signs not updating when an offline player is jailed. [#68](https://github.com/graywolf336/Jail/issues/68)
|
* Fixed cell signs not updating when an offline player is jailed. [#68](https://github.com/graywolf336/Jail/issues/68)
|
||||||
* Fixed chests being selectable if trapped and regular were next to each other.
|
* Fixed chests being selectable if trapped and regular were next to each other.
|
||||||
* Fixed inventory not being stored in chests, trapped chests and chests work just fine now.
|
* Fixed inventory not being stored in chests, trapped chests and chests work just fine now.
|
||||||
* Fixed jail names being case sensitive. [#76](https://github.com/graywolf336/Jail/issues/76)
|
* Fixed jail names being case sensitive. [#76](https://github.com/graywolf336/Jail/issues/76)
|
||||||
* Fixed jail sticks not putting players into cells. [#68](https://github.com/graywolf336/Jail/issues/68)
|
* Fixed jail sticks not putting players into cells. [#68](https://github.com/graywolf336/Jail/issues/68)
|
||||||
* Fixed pretty time not working with jailed forever time.
|
* Fixed pretty time not working with jailed forever time.
|
||||||
* Fixed respawning after dying not placing players back into their cells when another plugin sets their respawn point. [#55](https://github.com/graywolf336/Jail/issues/55)
|
* Fixed respawning after dying not placing players back into their cells when another plugin sets their respawn
|
||||||
* Fixed time being added/subtracted from a player's time when they were jailed forever, resulting in them being able to get out. [#69](https://github.com/graywolf336/Jail/issues/69)
|
point. [#55](https://github.com/graywolf336/Jail/issues/55)
|
||||||
* Fixed transferring players who've never been on before not working. [#83](https://github.com/graywolf336/Jail/issues/83)
|
* Fixed time being added/subtracted from a player's time when they were jailed forever, resulting in them being able to
|
||||||
|
get out. [#69](https://github.com/graywolf336/Jail/issues/69)
|
||||||
|
* Fixed transferring players who've never been on before not
|
||||||
|
working. [#83](https://github.com/graywolf336/Jail/issues/83)
|
||||||
* Fixed signs disappearing after reloading the plugin. [#67](https://github.com/graywolf336/Jail/issues/67)
|
* Fixed signs disappearing after reloading the plugin. [#67](https://github.com/graywolf336/Jail/issues/67)
|
||||||
* Fixed signs not updating after transferring someone.
|
* Fixed signs not updating after transferring someone.
|
||||||
* Fixed storage not changing when reloading the plugin, allows converting from one type to another. [#75](https://github.com/graywolf336/Jail/issues/75)
|
* Fixed storage not changing when reloading the plugin, allows converting from one type to
|
||||||
|
another. [#75](https://github.com/graywolf336/Jail/issues/75)
|
||||||
* Fixed subcommands of `/jail` being case sensitive.
|
* Fixed subcommands of `/jail` being case sensitive.
|
||||||
|
|
||||||
[Beta 4](https://github.com/graywolf336/Jail/releases/tag/v3.0.0-beta.4) Changes
|
[Beta 4](https://github.com/graywolf336/Jail/releases/tag/v3.0.0-beta.4) Changes
|
||||||
===
|
===
|
||||||
*Changes since Beta 3*
|
*Changes since Beta 3*
|
||||||
* Added `/jail vote`. [Jail Vote Wiki Page](https://github.com/graywolf336/Jail/wiki/Jail-Vote). [#8](https://github.com/graywolf336/Jail/issues/8)
|
|
||||||
* Added support for `%prettytime%` on signs, formats the time with `1h4m20s`. [#35](https://github.com/graywolf336/Jail/issues/35)
|
* Added `/jail vote`. [Jail Vote Wiki Page](https://github.com/graywolf336/Jail/wiki/Jail-Vote)
|
||||||
|
. [#8](https://github.com/graywolf336/Jail/issues/8)
|
||||||
|
* Added support for `%prettytime%` on signs, formats the time with `1h4m20s`
|
||||||
|
. [#35](https://github.com/graywolf336/Jail/issues/35)
|
||||||
* Added temporary help command, see the wiki for *wip* information: https://github.com/graywolf336/Jail/wiki/
|
* Added temporary help command, see the wiki for *wip* information: https://github.com/graywolf336/Jail/wiki/
|
||||||
* Added the ability to set a prisoner's time with `/jail time set [player] [amount]`
|
* Added the ability to set a prisoner's time with `/jail time set [player] [amount]`
|
||||||
* Fixed updating signs throwing an error on Spigot. [#36](https://github.com/graywolf336/Jail/issues/36)
|
* Fixed updating signs throwing an error on Spigot. [#36](https://github.com/graywolf336/Jail/issues/36)
|
||||||
* Fixed incorrect permissions for `/jail listcells`. [#39](https://github.com/graywolf336/Jail/issues/39)
|
* Fixed incorrect permissions for `/jail listcells`. [#39](https://github.com/graywolf336/Jail/issues/39)
|
||||||
* Fixed some permissions not being included in `jail.command.*`. [#38](https://github.com/graywolf336/Jail/issues/38)
|
* Fixed some permissions not being included in `jail.command.*`. [#38](https://github.com/graywolf336/Jail/issues/38)
|
||||||
* Fixed teleport free not sending the prisoner to the correct world.
|
* Fixed teleport free not sending the prisoner to the correct world.
|
||||||
* Fixed jailed players not being able to destory and place whitelisted blocks. [#34](https://github.com/graywolf336/Jail/issues/34)
|
* Fixed jailed players not being able to destory and place whitelisted
|
||||||
* Fixed the plugin being loaded before the worlds, if using Multiverse-Core. [#41](https://github.com/graywolf336/Jail/issues/41)
|
blocks. [#34](https://github.com/graywolf336/Jail/issues/34)
|
||||||
|
* Fixed the plugin being loaded before the worlds, if using
|
||||||
|
Multiverse-Core. [#41](https://github.com/graywolf336/Jail/issues/41)
|
||||||
* Fixed automatically jailing to open cells missing. [#42](https://github.com/graywolf336/Jail/issues/42)
|
* Fixed automatically jailing to open cells missing. [#42](https://github.com/graywolf336/Jail/issues/42)
|
||||||
* Fixed capital letters being ignore when creating cells. [#47](https://github.com/graywolf336/Jail/issues/47)
|
* Fixed capital letters being ignore when creating cells. [#47](https://github.com/graywolf336/Jail/issues/47)
|
||||||
* Fixed some cells not being created when a chest wasn't defined. [#46](https://github.com/graywolf336/Jail/issues/46)
|
* Fixed some cells not being created when a chest wasn't defined. [#46](https://github.com/graywolf336/Jail/issues/46)
|
||||||
* Fixed not being able to jail someone for an infinite amount of time. [#49](https://github.com/graywolf336/Jail/issues/49)
|
* Fixed not being able to jail someone for an infinite amount of
|
||||||
|
time. [#49](https://github.com/graywolf336/Jail/issues/49)
|
||||||
|
|
||||||
[Beta 3](https://github.com/graywolf336/Jail/releases/tag/v3.0.0-beta.3) Changes
|
[Beta 3](https://github.com/graywolf336/Jail/releases/tag/v3.0.0-beta.3) Changes
|
||||||
===
|
===
|
||||||
*Changes since Beta 2*
|
*Changes since Beta 2*
|
||||||
|
|
||||||
* Added support for sqlite storage
|
* Added support for sqlite storage
|
||||||
* Add advanced update notifications, even for beta builds
|
* Add advanced update notifications, even for beta builds
|
||||||
* Move cellcreate command to createcell
|
* Move cellcreate command to createcell
|
||||||
@ -90,6 +118,7 @@ Beta 6 Changes
|
|||||||
[Beta 2](https://github.com/graywolf336/Jail/releases/tag/v3.0.0-beta.2) Changes
|
[Beta 2](https://github.com/graywolf336/Jail/releases/tag/v3.0.0-beta.2) Changes
|
||||||
===
|
===
|
||||||
*Changes since Beta 1*
|
*Changes since Beta 1*
|
||||||
|
|
||||||
* Using UUID as the only means of knowing if someone is jailed or not, last known username is stored for commands
|
* Using UUID as the only means of knowing if someone is jailed or not, last known username is stored for commands
|
||||||
* Jailings via jail sticks are now recorded, [#20](https://github.com/graywolf336/Jail/issues/20)
|
* Jailings via jail sticks are now recorded, [#20](https://github.com/graywolf336/Jail/issues/20)
|
||||||
* Fix the default Jail Stick not being loaded correctly, [#21](https://github.com/graywolf336/Jail/issues/21)
|
* Fix the default Jail Stick not being loaded correctly, [#21](https://github.com/graywolf336/Jail/issues/21)
|
||||||
@ -97,24 +126,31 @@ Beta 6 Changes
|
|||||||
* Implemented Jail Pay [#11](https://github.com/graywolf336/Jail/issues/11)
|
* Implemented Jail Pay [#11](https://github.com/graywolf336/Jail/issues/11)
|
||||||
* Convert old data and config values, only some are done and if you don't want the old data delete your `global.yml`
|
* Convert old data and config values, only some are done and if you don't want the old data delete your `global.yml`
|
||||||
* Add config option to disallow the usage of Jail Sticks
|
* Add config option to disallow the usage of Jail Sticks
|
||||||
* Added `/jail time` for easy access to adding/subtracting time - [Bukkit Dev Ticket #432](http://dev.bukkit.org/bukkit-plugins/jail/tickets/432/)
|
* Added `/jail time` for easy access to adding/subtracting time
|
||||||
* Added `/togglejaildebug` for easily toggling the debugging state, enable if you have a problem and want to send me information
|
- [Bukkit Dev Ticket #432](http://dev.bukkit.org/bukkit-plugins/jail/tickets/432/)
|
||||||
* Added some caching of online prisoners and where they're located at, this improves performance on servers with 500+ prisoners jailed
|
* Added `/togglejaildebug` for easily toggling the debugging state, enable if you have a problem and want to send me
|
||||||
|
information
|
||||||
|
* Added some caching of online prisoners and where they're located at, this improves performance on servers with 500+
|
||||||
|
prisoners jailed
|
||||||
* Only updating prisoners in the database if they were changed, this should help improve saving speed
|
* Only updating prisoners in the database if they were changed, this should help improve saving speed
|
||||||
|
|
||||||
[Beta 1](https://github.com/graywolf336/Jail/releases/tag/v3.0.0-beta.1) Changes
|
[Beta 1](https://github.com/graywolf336/Jail/releases/tag/v3.0.0-beta.1) Changes
|
||||||
===
|
===
|
||||||
*Changes since alpha*
|
*Changes since alpha*
|
||||||
|
|
||||||
* MySQL storage is now a valid option for storage ([#18](https://github.com/graywolf336/Jail/issues/18))
|
* MySQL storage is now a valid option for storage ([#18](https://github.com/graywolf336/Jail/issues/18))
|
||||||
* MySQL data validation, basically if a cell or prisoner reference a jail which no longer exists they are removed
|
* MySQL data validation, basically if a cell or prisoner reference a jail which no longer exists they are removed
|
||||||
* Fix a bug with not being able to unjail someone forcefully if they were in a cell ([#17](https://github.com/graywolf336/Jail/issues/17))
|
* Fix a bug with not being able to unjail someone forcefully if they were in a
|
||||||
|
cell ([#17](https://github.com/graywolf336/Jail/issues/17))
|
||||||
* Add the record keeping system ([#12](https://github.com/graywolf336/Jail/issues/12))
|
* Add the record keeping system ([#12](https://github.com/graywolf336/Jail/issues/12))
|
||||||
* Added Jail Sticks, format of them has slightly changed ([#16](https://github.com/graywolf336/Jail/issues/16))
|
* Added Jail Sticks, format of them has slightly changed ([#16](https://github.com/graywolf336/Jail/issues/16))
|
||||||
|
|
||||||
To Do
|
To Do
|
||||||
===
|
===
|
||||||
|
|
||||||
* Jail set
|
* Jail set
|
||||||
* Jailing for swearing
|
* Jailing for swearing
|
||||||
* Guards (PlayerMoveProtectionAction - when they try to move do we teleport them back, let the guards get them, or nothing)
|
* Guards (PlayerMoveProtectionAction - when they try to move do we teleport them back, let the guards get them, or
|
||||||
|
nothing)
|
||||||
* Storing permissions
|
* Storing permissions
|
||||||
* Pages on jail list
|
* Pages on jail list
|
||||||
|
14
pom.xml
14
pom.xml
@ -41,7 +41,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -82,9 +82,15 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
<version>1.18.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains</groupId>
|
||||||
|
<artifactId>annotations</artifactId>
|
||||||
|
<version>RELEASE</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<!-- End of Test Dependencies -->
|
<!-- End of Test Dependencies -->
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
@ -140,8 +146,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.8.1</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>16</source>
|
<source>17</source>
|
||||||
<target>16</target>
|
<target>17</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
@ -33,53 +33,55 @@ import java.util.UUID;
|
|||||||
* @since 2.x.x
|
* @since 2.x.x
|
||||||
*/
|
*/
|
||||||
public class JailIO {
|
public class JailIO {
|
||||||
private final JailMain pl;
|
|
||||||
|
private final JailMain jailMain;
|
||||||
private FileConfiguration flat, records;
|
private FileConfiguration flat, records;
|
||||||
private Connection con;
|
private Connection connection;
|
||||||
private int storage = -1; //0 = flatfile, 1 = sqlite, 2 = mysql
|
private int storage = -1; //0 = flatfile, 1 = sqlite, 2 = mysql
|
||||||
private String prefix;
|
private String prefix;
|
||||||
private boolean changed = false;
|
private boolean changed = false;
|
||||||
|
|
||||||
protected JailIO(JailMain plugin) {
|
protected JailIO(JailMain plugin) {
|
||||||
this.pl = plugin;
|
this.jailMain = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the language file from disk, if there is none then we save the default one.
|
* Loads the language file from disk, if there is none then we save the default one.
|
||||||
*/
|
*/
|
||||||
protected void loadLanguage() {
|
protected void loadLanguage() {
|
||||||
String language = pl.getConfig().getString(Settings.LANGUAGE.getPath());
|
String language = jailMain.getConfig().getString(Settings.LANGUAGE.getPath());
|
||||||
boolean save = false;
|
boolean save = false;
|
||||||
File langFile = new File(pl.getDataFolder() + File.separator + "locales", language + ".yml");
|
File langFile = new File(jailMain.getDataFolder() + File.separator + "locales", language + ".yml");
|
||||||
|
|
||||||
//File or folder already exists, let's check
|
//File or folder already exists, let's check
|
||||||
if (langFile.exists()) {
|
if (langFile.exists()) {
|
||||||
if (langFile.isFile()) {
|
if (langFile.isFile()) {
|
||||||
Lang.setFile(YamlConfiguration.loadConfiguration(langFile));
|
Lang.setFile(YamlConfiguration.loadConfiguration(langFile));
|
||||||
pl.getLogger().info("Loaded the language: " + language);
|
jailMain.getLogger().info("Loaded the language: " + language);
|
||||||
} else {
|
} else {
|
||||||
pl.getLogger().severe("The language file can not be a folder.");
|
jailMain.getLogger().severe("The language file can not be a folder.");
|
||||||
pl.getLogger().severe("As a result, we are reverting back to English as the language.");
|
jailMain.getLogger().severe("As a result, we are reverting back to English as the language.");
|
||||||
Lang.setFile(YamlConfiguration.loadConfiguration(new InputStreamReader(pl.getResource("locales/en.yml"))));
|
Lang.setFile(YamlConfiguration.loadConfiguration(new InputStreamReader(jailMain.getResource("locales/en.yml"))));
|
||||||
save = true;
|
save = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pl.getLogger().warning("Loading the default language of: en");
|
jailMain.getLogger().warning("Loading the default language of: en");
|
||||||
pl.getLogger().warning("If you wish to change this, please rename 'en.yml' to whatever you wish and set the config value to the name of the file.");
|
jailMain.getLogger().warning("If you wish to change this, please rename 'en.yml' to whatever you wish and set the config value to the name of the file.");
|
||||||
Lang.setFile(YamlConfiguration.loadConfiguration(new InputStreamReader(pl.getResource("locales/en.yml"))));
|
Lang.setFile(YamlConfiguration.loadConfiguration(new InputStreamReader(jailMain.getResource("locales/en.yml"))));
|
||||||
save = true;
|
save = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Make sure we have all the new language settings loaded
|
//Make sure we have all the new language settings loaded
|
||||||
if (!save)
|
if (!save) {
|
||||||
save = Lang.writeNewLanguage(YamlConfiguration.loadConfiguration(new InputStreamReader(pl.getResource("locales/en.yml"))));
|
save = Lang.writeNewLanguage(YamlConfiguration.loadConfiguration(new InputStreamReader(jailMain.getResource("locales/en.yml"))));
|
||||||
|
}
|
||||||
|
|
||||||
//If we have flagged to save the language file, let's save it as en.yml as this flag usually means they didn't have it loaded.
|
//If we have flagged to save the language file, let's save it as en.yml as this flag usually means they didn't have it loaded.
|
||||||
if (save) {
|
if (save) {
|
||||||
try {
|
try {
|
||||||
Lang.getFile().save(new File(pl.getDataFolder() + File.separator + "locales", "en.yml"));
|
Lang.getFile().save(new File(jailMain.getDataFolder() + File.separator + "locales", "en.yml"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
pl.getLogger().severe("Unable to save the language file: " + e.getMessage() + " (" + e.getClass().getSimpleName() + ")");
|
jailMain.getLogger().severe("Unable to save the language file: " + e.getMessage() + " (" + e.getClass().getSimpleName() + ")");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -93,13 +95,13 @@ public class JailIO {
|
|||||||
protected boolean prepareStorage(boolean doInitialCreations) {
|
protected boolean prepareStorage(boolean doInitialCreations) {
|
||||||
int inital = storage == -1 ? -1 : storage;
|
int inital = storage == -1 ? -1 : storage;
|
||||||
|
|
||||||
String st = pl.getConfig().getString("storage.type", "flatfile");
|
String st = jailMain.getConfig().getString("storage.type", "flatfile");
|
||||||
if (st.equalsIgnoreCase("sqlite")) {
|
if (st.equalsIgnoreCase("sqlite")) {
|
||||||
storage = 1;
|
storage = 1;
|
||||||
prefix = pl.getConfig().getString("storage.mysql.prefix");
|
prefix = jailMain.getConfig().getString("storage.mysql.prefix");
|
||||||
} else if (st.equalsIgnoreCase("mysql")) {
|
} else if (st.equalsIgnoreCase("mysql")) {
|
||||||
storage = 2;
|
storage = 2;
|
||||||
prefix = pl.getConfig().getString("storage.mysql.prefix");
|
prefix = jailMain.getConfig().getString("storage.mysql.prefix");
|
||||||
} else {
|
} else {
|
||||||
storage = 0;
|
storage = 0;
|
||||||
}
|
}
|
||||||
@ -108,33 +110,37 @@ public class JailIO {
|
|||||||
//this way we can know whether to save EVERYTHING
|
//this way we can know whether to save EVERYTHING
|
||||||
//or not afterwards
|
//or not afterwards
|
||||||
if (inital != -1 && inital != storage) {
|
if (inital != -1 && inital != storage) {
|
||||||
pl.debug("We changed storage types! We used to be " + inital + " and changed to " + storage + ".");
|
jailMain.debug("We changed storage types! We used to be " + inital + " and changed to " + storage + ".");
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
pl.debug("The storage type " + st + " with the type being " + storage + ".");
|
jailMain.debug("The storage type " + st + " with the type being " + storage + ".");
|
||||||
if (!pl.inDebug()) pl.getLogger().info("Storage type selected: " + st);
|
if (!jailMain.inDebug()) {
|
||||||
|
jailMain.getLogger().info("Storage type selected: " + st);
|
||||||
|
}
|
||||||
|
|
||||||
switch (storage) {
|
switch (storage) {
|
||||||
case 1:
|
case 1:
|
||||||
try {
|
try {
|
||||||
Class.forName("org.sqlite.JDBC");
|
Class.forName("org.sqlite.JDBC");
|
||||||
pl.getLogger().info("Connecting to the sqlite database.");
|
jailMain.getLogger().info("Connecting to the sqlite database.");
|
||||||
Connection sqliteConnection = DriverManager.getConnection("jdbc:sqlite:" + new File(pl.getDataFolder().getPath(), "jail3.sqlite").getPath());
|
Connection sqliteConnection = DriverManager.getConnection("jdbc:sqlite:" + new File(jailMain.getDataFolder().getPath(), "jail3.sqlite").getPath());
|
||||||
sqliteConnection.setAutoCommit(true);
|
sqliteConnection.setAutoCommit(true);
|
||||||
this.con = sqliteConnection;
|
this.connection = sqliteConnection;
|
||||||
pl.debug("Connection created for sqlite.");
|
jailMain.debug("Connection created for sqlite.");
|
||||||
|
|
||||||
if (doInitialCreations) createTables();
|
if (doInitialCreations) {
|
||||||
|
createTables();
|
||||||
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Sqlite driver not found, disabling the plugin.");
|
jailMain.getLogger().severe("Sqlite driver not found, disabling the plugin.");
|
||||||
return false;
|
return false;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Unable to connect to the sqlite database, please update your config accordingly.");
|
jailMain.getLogger().severe("Unable to connect to the sqlite database, please update your config accordingly.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,31 +148,33 @@ public class JailIO {
|
|||||||
case 2:
|
case 2:
|
||||||
try {
|
try {
|
||||||
Class.forName("com.mysql.jdbc.Driver");
|
Class.forName("com.mysql.jdbc.Driver");
|
||||||
pl.getLogger().info("Connecting to the MySQL database.");
|
jailMain.getLogger().info("Connecting to the MySQL database.");
|
||||||
Connection mysqlConnection = DriverManager.getConnection("jdbc:mysql://" + pl.getConfig().getString("storage.mysql.host") + ":"
|
Connection mysqlConnection = DriverManager.getConnection("jdbc:mysql://" + jailMain.getConfig().getString("storage.mysql.host") + ":"
|
||||||
+ pl.getConfig().getString("storage.mysql.port") + "/"
|
+ jailMain.getConfig().getString("storage.mysql.port") + "/"
|
||||||
+ pl.getConfig().getString("storage.mysql.database"), pl.getConfig().getString("storage.mysql.username"), pl.getConfig().getString("storage.mysql.password"));
|
+ jailMain.getConfig().getString("storage.mysql.database"), jailMain.getConfig().getString("storage.mysql.username"), jailMain.getConfig().getString("storage.mysql.password"));
|
||||||
mysqlConnection.setAutoCommit(true);
|
mysqlConnection.setAutoCommit(true);
|
||||||
this.con = mysqlConnection;
|
this.connection = mysqlConnection;
|
||||||
pl.debug("Connection created for MySQL.");
|
jailMain.debug("Connection created for MySQL.");
|
||||||
|
|
||||||
if (doInitialCreations) createTables();
|
if (doInitialCreations) {
|
||||||
|
createTables();
|
||||||
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("MySQL driver not found, disabling the plugin.");
|
jailMain.getLogger().severe("MySQL driver not found, disabling the plugin.");
|
||||||
return false;
|
return false;
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Unable to connect to the MySQL database, please update your config accordingly.");
|
jailMain.getLogger().severe("Unable to connect to the MySQL database, please update your config accordingly.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
flat = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "data.yml"));
|
flat = YamlConfiguration.loadConfiguration(new File(jailMain.getDataFolder(), "data.yml"));
|
||||||
records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
|
records = YamlConfiguration.loadConfiguration(new File(jailMain.getDataFolder(), "records.yml"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,27 +194,35 @@ public class JailIO {
|
|||||||
private Connection getConnection() {
|
private Connection getConnection() {
|
||||||
switch (storage) {
|
switch (storage) {
|
||||||
case 1:
|
case 1:
|
||||||
if (con == null) this.prepareStorage(false);
|
if (connection == null) {
|
||||||
|
this.prepareStorage(false);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (con.isClosed()) this.prepareStorage(false);
|
if (connection.isClosed()) {
|
||||||
|
this.prepareStorage(false);
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Unable to get a SQLite connection, please see the error above and fix the problem.");
|
jailMain.getLogger().severe("Unable to get a SQLite connection, please see the error above and fix the problem.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return con;
|
return connection;
|
||||||
case 2:
|
case 2:
|
||||||
if (con == null) this.prepareStorage(false);
|
if (connection == null) {
|
||||||
|
this.prepareStorage(false);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (con.isClosed() || !con.isValid(10)) this.prepareStorage(false);
|
if (connection.isClosed() || !connection.isValid(10)) {
|
||||||
|
this.prepareStorage(false);
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Unable to get a MySql connection, please see the error above and fix the problem.");
|
jailMain.getLogger().severe("Unable to get a MySql connection, please see the error above and fix the problem.");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return con;
|
return connection;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -220,16 +236,16 @@ public class JailIO {
|
|||||||
case 1:
|
case 1:
|
||||||
case 2:
|
case 2:
|
||||||
try {
|
try {
|
||||||
if (con != null) {
|
if (connection != null) {
|
||||||
con.close();
|
connection.close();
|
||||||
con = null;
|
connection = null;
|
||||||
|
|
||||||
pl.debug("Closed the SQL connection.");
|
jailMain.debug("Closed the SQL connection.");
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Unable to close the SQL connection.");
|
jailMain.getLogger().severe("Unable to close the SQL connection.");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -240,7 +256,7 @@ public class JailIO {
|
|||||||
|
|
||||||
private void createTables() {
|
private void createTables() {
|
||||||
if (getConnection() == null) {
|
if (getConnection() == null) {
|
||||||
pl.debug("The connection was null when we tried to create a table.");
|
jailMain.debug("The connection was null when we tried to create a table.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,8 +428,8 @@ public class JailIO {
|
|||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while creating the tables, please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while creating the tables, please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,27 +448,27 @@ public class JailIO {
|
|||||||
ResultSet set = ps.executeQuery();
|
ResultSet set = ps.executeQuery();
|
||||||
|
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
Jail j = new Jail(pl, set.getString("name"));
|
Jail j = new Jail(jailMain, set.getString("name"));
|
||||||
|
|
||||||
j.setWorld(set.getString("world"));
|
j.setWorld(set.getString("world"));
|
||||||
j.setMaxPoint(new int[]{set.getInt("top.x"), set.getInt("top.y"), set.getInt("top.z")});
|
j.setMaxPoint(new int[]{set.getInt("top.x"), set.getInt("top.y"), set.getInt("top.z")});
|
||||||
j.setMinPoint(new int[]{set.getInt("bottom.x"), set.getInt("bottom.y"), set.getInt("bottom.z")});
|
j.setMinPoint(new int[]{set.getInt("bottom.x"), set.getInt("bottom.y"), set.getInt("bottom.z")});
|
||||||
j.setTeleportIn(new Location(pl.getServer().getWorld(j.getWorldName()), set.getDouble("tps.in.x"),
|
j.setTeleportIn(new Location(jailMain.getServer().getWorld(j.getWorldName()), set.getDouble("tps.in.x"),
|
||||||
set.getDouble("tps.in.y"), set.getDouble("tps.in.z"),
|
set.getDouble("tps.in.y"), set.getDouble("tps.in.z"),
|
||||||
set.getFloat("tps.in.yaw"), set.getFloat("tps.in.pitch")));
|
set.getFloat("tps.in.yaw"), set.getFloat("tps.in.pitch")));
|
||||||
j.setTeleportFree(new Location(pl.getServer().getWorld(j.getWorldName()), set.getDouble("tps.free.x"),
|
j.setTeleportFree(new Location(jailMain.getServer().getWorld(j.getWorldName()), set.getDouble("tps.free.x"),
|
||||||
set.getDouble("tps.free.y"), set.getDouble("tps.free.z"),
|
set.getDouble("tps.free.y"), set.getDouble("tps.free.z"),
|
||||||
set.getFloat("tps.free.yaw"), set.getFloat("tps.free.pitch")));
|
set.getFloat("tps.free.yaw"), set.getFloat("tps.free.pitch")));
|
||||||
j.setEnabled(j.getWorld() != null);
|
j.setEnabled(j.getWorld() != null);
|
||||||
pl.getJailManager().addJail(j, false);
|
jailMain.getJailManager().addJail(j, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
set.close();
|
set.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while loading the jails, please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while loading the jails, please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//This list contains an integer which refers to the cellid column in sql
|
//This list contains an integer which refers to the cellid column in sql
|
||||||
@ -465,7 +481,7 @@ public class JailIO {
|
|||||||
ResultSet set = ps.executeQuery();
|
ResultSet set = ps.executeQuery();
|
||||||
|
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
Jail j = pl.getJailManager().getJail(set.getString("jail"));
|
Jail j = jailMain.getJailManager().getJail(set.getString("jail"));
|
||||||
|
|
||||||
if (j != null) {
|
if (j != null) {
|
||||||
if (j.getWorld() != null) {
|
if (j.getWorld() != null) {
|
||||||
@ -494,46 +510,49 @@ public class JailIO {
|
|||||||
if (!j.addCell(c, false)) {
|
if (!j.addCell(c, false)) {
|
||||||
int id = set.getInt("cellid");
|
int id = set.getInt("cellid");
|
||||||
cellsToRemove.add(id);
|
cellsToRemove.add(id);
|
||||||
pl.debug("The cell, " + c.getName() + " (" + id + "), is already in jail " + j.getName() + " so we're removing it.");
|
jailMain.debug("The cell, " + c.getName() + " (" + id + "), is already in jail " + j.getName() + " so we're removing it.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pl.getLogger().warning("The cell, " + set.getString("name") + ", in " + j.getName() + " is located in a world that is not loaded.");
|
jailMain.getLogger().warning("The cell, " + set.getString("name") + ", in " + j.getName() + " is located in a world that is not loaded.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cellsToRemove.add(set.getInt("cellid"));
|
cellsToRemove.add(set.getInt("cellid"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pl.debug("There are " + cellsToRemove.size() + " cells we need to remove due to being invalid.");
|
jailMain.debug("There are " + cellsToRemove.size() + " cells we need to remove due to being invalid.");
|
||||||
|
|
||||||
set.close();
|
set.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while loading all of the cells, please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while loading all of the cells, please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove the invalid prisoners
|
//Remove the invalid prisoners
|
||||||
if (!cellsToRemove.isEmpty()) {
|
if (!cellsToRemove.isEmpty()) {
|
||||||
StringBuilder ids = new StringBuilder();
|
StringBuilder ids = new StringBuilder();
|
||||||
for (int c : cellsToRemove) {
|
for (int c : cellsToRemove) {
|
||||||
if (ids.length() == 0) ids.append("'").append(c).append("'");
|
if (ids.length() == 0) {
|
||||||
else ids.append("," + "'").append(c).append("'");
|
ids.append("'").append(c).append("'");
|
||||||
|
} else {
|
||||||
|
ids.append("," + "'").append(c).append("'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement cds = getConnection().prepareStatement("delete from " + prefix + "cells where cellid in (" + ids + ");");
|
PreparedStatement cds = getConnection().prepareStatement("delete from " + prefix + "cells where cellid in (" + ids + ");");
|
||||||
|
|
||||||
pl.debug("Deleting old cells: `delete from " + prefix + "cells where cellid in (" + ids + ");`");
|
jailMain.debug("Deleting old cells: `delete from " + prefix + "cells where cellid in (" + ids + ");`");
|
||||||
|
|
||||||
int count = cds.executeUpdate();
|
int count = cds.executeUpdate();
|
||||||
pl.getLogger().info("Deleted " + count + " cells which were invalid, they either referenced a jail which are no longer valid or were duplicates.");
|
jailMain.getLogger().info("Deleted " + count + " cells which were invalid, they either referenced a jail which are no longer valid or were duplicates.");
|
||||||
cds.close();
|
cds.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while deleting the old cells which were invalid (they either referenced a jail which are no longer valid or were duplicates), please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while deleting the old cells which were invalid (they either referenced a jail which are no longer valid or were duplicates), please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -547,7 +566,7 @@ public class JailIO {
|
|||||||
ResultSet set = ps.executeQuery();
|
ResultSet set = ps.executeQuery();
|
||||||
|
|
||||||
while (set.next()) {
|
while (set.next()) {
|
||||||
Jail j = pl.getJailManager().getJail(set.getString("jail"));
|
Jail j = jailMain.getJailManager().getJail(set.getString("jail"));
|
||||||
|
|
||||||
if (j != null) {
|
if (j != null) {
|
||||||
String cellname = set.getString("cell");
|
String cellname = set.getString("cell");
|
||||||
@ -580,37 +599,40 @@ public class JailIO {
|
|||||||
set.close();
|
set.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|
||||||
pl.debug("There are " + prisonersToRemove.size() + " prisoners we need to remove due to being invalid.");
|
jailMain.debug("There are " + prisonersToRemove.size() + " prisoners we need to remove due to being invalid.");
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while loading all of the prisoners, please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while loading all of the prisoners, please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove the invalid prisoners
|
//Remove the invalid prisoners
|
||||||
if (!prisonersToRemove.isEmpty()) {
|
if (!prisonersToRemove.isEmpty()) {
|
||||||
StringBuilder names = new StringBuilder();
|
StringBuilder names = new StringBuilder();
|
||||||
for (String s : prisonersToRemove) {
|
for (String s : prisonersToRemove) {
|
||||||
if (names.length() == 0) names = new StringBuilder("'" + s + "'");
|
if (names.length() == 0) {
|
||||||
else names.append("," + "'").append(s).append("'");
|
names = new StringBuilder("'" + s + "'");
|
||||||
|
} else {
|
||||||
|
names.append("," + "'").append(s).append("'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement pds = getConnection().prepareStatement("delete from " + prefix + "prisoners where name in (" + names + ");");
|
PreparedStatement pds = getConnection().prepareStatement("delete from " + prefix + "prisoners where name in (" + names + ");");
|
||||||
|
|
||||||
pl.debug("Deleting old prisoners: 'delete from " + prefix + "prisoners where name in (" + names + ");'");
|
jailMain.debug("Deleting old prisoners: 'delete from " + prefix + "prisoners where name in (" + names + ");'");
|
||||||
|
|
||||||
int count = pds.executeUpdate();
|
int count = pds.executeUpdate();
|
||||||
pl.getLogger().info("Deleted " + count + " old prisoners which referenced a jail no longer valid: " + names);
|
jailMain.getLogger().info("Deleted " + count + " old prisoners which referenced a jail no longer valid: " + names);
|
||||||
pds.close();
|
pds.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while deleting the old prisoners which don't have a valid jail, please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while deleting the old prisoners which don't have a valid jail, please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pl.debug("Took " + (System.currentTimeMillis() - st) + " millis to load the jails and all the data.");
|
jailMain.debug("Took " + (System.currentTimeMillis() - st) + " millis to load the jails and all the data.");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//load the jails from flatfile
|
//load the jails from flatfile
|
||||||
@ -625,24 +647,24 @@ public class JailIO {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
int js = pl.getJailManager().getJails().size();
|
int js = jailMain.getJailManager().getJails().size();
|
||||||
pl.getLogger().info("Loaded " + js + (js == 1 ? " jail." : " jails."));
|
jailMain.getLogger().info("Loaded " + js + (js == 1 ? " jail." : " jails."));
|
||||||
|
|
||||||
int cs = pl.getJailManager().getAllCells().size();
|
int cs = jailMain.getJailManager().getAllCells().size();
|
||||||
pl.getLogger().info("Loaded " + cs + (cs == 1 ? " cell." : " cells."));
|
jailMain.getLogger().info("Loaded " + cs + (cs == 1 ? " cell." : " cells."));
|
||||||
|
|
||||||
int ps = pl.getJailManager().getAllPrisoners().size();
|
int ps = jailMain.getJailManager().getAllPrisoners().size();
|
||||||
pl.getLogger().info("Loaded " + ps + (ps == 1 ? " prisoner." : " prisoners."));
|
jailMain.getLogger().info("Loaded " + ps + (ps == 1 ? " prisoner." : " prisoners."));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadJailFromFlatFile(String name) {
|
private void loadJailFromFlatFile(String name) {
|
||||||
String node = "jails." + name + ".";
|
String node = "jails." + name + ".";
|
||||||
String cNode = node + "cells.";
|
String cNode = node + "cells.";
|
||||||
pl.debug("Loading the jail " + name + "; " + node + "; " + cNode);
|
jailMain.debug("Loading the jail " + name + "; " + node + "; " + cNode);
|
||||||
Jail j = new Jail(pl, name);
|
Jail j = new Jail(jailMain, name);
|
||||||
|
|
||||||
if (flat.getString(node + "world") == null || flat.getString(node + "world").isEmpty()) {
|
if (flat.getString(node + "world") == null || flat.getString(node + "world").isEmpty()) {
|
||||||
pl.getLogger().severe("Failed to load the jail, " + name + ", because the world is not set.");
|
jailMain.getLogger().severe("Failed to load the jail, " + name + ", because the world is not set.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -651,14 +673,14 @@ public class JailIO {
|
|||||||
j.setMinPoint(new int[]{flat.getInt(node + "bottom.x"), flat.getInt(node + "bottom.y"), flat.getInt(node + "bottom.z")});
|
j.setMinPoint(new int[]{flat.getInt(node + "bottom.x"), flat.getInt(node + "bottom.y"), flat.getInt(node + "bottom.z")});
|
||||||
|
|
||||||
j.setTeleportIn(new Location(
|
j.setTeleportIn(new Location(
|
||||||
pl.getServer().getWorld(j.getWorldName()),
|
jailMain.getServer().getWorld(j.getWorldName()),
|
||||||
flat.getDouble(node + "tps.in.x"),
|
flat.getDouble(node + "tps.in.x"),
|
||||||
flat.getDouble(node + "tps.in.y"),
|
flat.getDouble(node + "tps.in.y"),
|
||||||
flat.getDouble(node + "tps.in.z"),
|
flat.getDouble(node + "tps.in.z"),
|
||||||
(float) flat.getDouble(node + "tps.in.yaw"),
|
(float) flat.getDouble(node + "tps.in.yaw"),
|
||||||
(float) flat.getDouble(node + "tps.in.pitch")));
|
(float) flat.getDouble(node + "tps.in.pitch")));
|
||||||
j.setTeleportFree(new Location(
|
j.setTeleportFree(new Location(
|
||||||
pl.getServer().getWorld(flat.getString(node + "tps.free.world")),
|
jailMain.getServer().getWorld(flat.getString(node + "tps.free.world")),
|
||||||
flat.getDouble(node + "tps.free.x"),
|
flat.getDouble(node + "tps.free.x"),
|
||||||
flat.getDouble(node + "tps.free.y"),
|
flat.getDouble(node + "tps.free.y"),
|
||||||
flat.getDouble(node + "tps.free.z"),
|
flat.getDouble(node + "tps.free.z"),
|
||||||
@ -740,8 +762,8 @@ public class JailIO {
|
|||||||
}
|
}
|
||||||
|
|
||||||
j.setEnabled(j.getWorld() != null);
|
j.setEnabled(j.getWorld() != null);
|
||||||
pl.getJailManager().addJail(j, false);
|
jailMain.getJailManager().addJail(j, false);
|
||||||
pl.getLogger().info("Loaded jail " + j.getName() + " with " + j.getAllPrisoners().size() + " prisoners and " + j.getCellCount() + " cells" + (j.isEnabled() ? "." : " but the jail is disabled as the world doesn't exist or isn't loaded."));
|
jailMain.getLogger().info("Loaded jail " + j.getName() + " with " + j.getAllPrisoners().size() + " prisoners and " + j.getCellCount() + " cells" + (j.isEnabled() ? "." : " but the jail is disabled as the world doesn't exist or isn't loaded."));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -750,7 +772,7 @@ public class JailIO {
|
|||||||
protected void saveEverything() {
|
protected void saveEverything() {
|
||||||
long st = System.currentTimeMillis();
|
long st = System.currentTimeMillis();
|
||||||
|
|
||||||
for (Jail j : pl.getJailManager().getJails()) {
|
for (Jail j : jailMain.getJailManager().getJails()) {
|
||||||
saveJail(j);
|
saveJail(j);
|
||||||
|
|
||||||
//Only save the cells individually
|
//Only save the cells individually
|
||||||
@ -762,7 +784,7 @@ public class JailIO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pl.debug("Saving everything took " + (System.currentTimeMillis() - st) + " millis.");
|
jailMain.debug("Saving everything took " + (System.currentTimeMillis() - st) + " millis.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -808,14 +830,15 @@ public class JailIO {
|
|||||||
ps.close();
|
ps.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while saving the Jail '" + j.getName() + "' (not updating the prisoners), please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while saving the Jail '" + j.getName() + "' (not updating the prisoners), please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (Cell c : j.getCells()) {
|
for (Cell c : j.getCells()) {
|
||||||
if (c.getDatabaseID() != -1)
|
if (c.getDatabaseID() != -1) {
|
||||||
saveCell(j, c, false);
|
saveCell(j, c, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (c.hasPrisoner() && c.getPrisoner().wasChanged()) {
|
if (c.hasPrisoner() && c.getPrisoner().wasChanged()) {
|
||||||
Prisoner p = c.getPrisoner();
|
Prisoner p = c.getPrisoner();
|
||||||
@ -845,8 +868,8 @@ public class JailIO {
|
|||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while saving the cells of the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while saving the cells of the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -876,11 +899,11 @@ public class JailIO {
|
|||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while saving the prisoners of the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while saving the prisoners of the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
|
|
||||||
pl.debug("Took " + (System.currentTimeMillis() - st) + " millis to save the jail " + j.getName() + ".");
|
jailMain.debug("Took " + (System.currentTimeMillis() - st) + " millis to save the jail " + j.getName() + ".");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (flat != null) {
|
if (flat != null) {
|
||||||
@ -950,11 +973,13 @@ public class JailIO {
|
|||||||
flat.set(cNode + "prisoner.reason", p.getReason());
|
flat.set(cNode + "prisoner.reason", p.getReason());
|
||||||
flat.set(cNode + "prisoner.inventory", p.getInventory());
|
flat.set(cNode + "prisoner.inventory", p.getInventory());
|
||||||
flat.set(cNode + "prisoner.armor", p.getArmor());
|
flat.set(cNode + "prisoner.armor", p.getArmor());
|
||||||
if (p.getPreviousLocationString() != null)
|
if (p.getPreviousLocationString() != null) {
|
||||||
flat.set(cNode + "prisoner.previousLocation", p.getPreviousLocationString());
|
flat.set(cNode + "prisoner.previousLocation", p.getPreviousLocationString());
|
||||||
if (p.getPreviousGameMode() != null)
|
}
|
||||||
|
if (p.getPreviousGameMode() != null) {
|
||||||
flat.set(cNode + "prisoner.previousGameMode", p.getPreviousGameMode().toString());
|
flat.set(cNode + "prisoner.previousGameMode", p.getPreviousGameMode().toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c.setChanged(false);
|
c.setChanged(false);
|
||||||
}
|
}
|
||||||
@ -972,19 +997,21 @@ public class JailIO {
|
|||||||
flat.set(pNode + "reason", p.getReason());
|
flat.set(pNode + "reason", p.getReason());
|
||||||
flat.set(pNode + "inventory", p.getInventory());
|
flat.set(pNode + "inventory", p.getInventory());
|
||||||
flat.set(pNode + "armor", p.getArmor());
|
flat.set(pNode + "armor", p.getArmor());
|
||||||
if (p.getPreviousLocationString() != null)
|
if (p.getPreviousLocationString() != null) {
|
||||||
flat.set(pNode + "previousLocation", p.getPreviousLocationString());
|
flat.set(pNode + "previousLocation", p.getPreviousLocationString());
|
||||||
if (p.getPreviousGameMode() != null)
|
}
|
||||||
|
if (p.getPreviousGameMode() != null) {
|
||||||
flat.set(pNode + "previousGameMode", p.getPreviousGameMode().toString());
|
flat.set(pNode + "previousGameMode", p.getPreviousGameMode().toString());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
flat.save(new File(pl.getDataFolder(), "data.yml"));
|
flat.save(new File(jailMain.getDataFolder(), "data.yml"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
pl.getLogger().severe("Unable to save the Jail data: " + e.getMessage());
|
jailMain.getLogger().severe("Unable to save the Jail data: " + e.getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pl.getLogger().severe("Storage not enabled, could not save the jail " + j.getName());
|
jailMain.getLogger().severe("Storage not enabled, could not save the jail " + j.getName());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -994,7 +1021,9 @@ public class JailIO {
|
|||||||
public void saveCell(Jail j, Cell c, boolean force) {
|
public void saveCell(Jail j, Cell c, boolean force) {
|
||||||
//if the cell hasn't changed, no need to save it again
|
//if the cell hasn't changed, no need to save it again
|
||||||
//unless they're forcing the save
|
//unless they're forcing the save
|
||||||
if (!c.hasChanged() && !force) return;
|
if (!c.hasChanged() && !force) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (storage) {
|
switch (storage) {
|
||||||
case 1:
|
case 1:
|
||||||
@ -1005,7 +1034,7 @@ public class JailIO {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
pl.debug("Saving the cell " + c.getName());
|
jailMain.debug("Saving the cell " + c.getName());
|
||||||
boolean hasId = c.getDatabaseID() != -1;
|
boolean hasId = c.getDatabaseID() != -1;
|
||||||
|
|
||||||
PreparedStatement cPS = con.prepareStatement((hasId ? "REPLACE" : "INSERT")
|
PreparedStatement cPS = con.prepareStatement((hasId ? "REPLACE" : "INSERT")
|
||||||
@ -1061,8 +1090,8 @@ public class JailIO {
|
|||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while saving the cell '" + c.getName() + "' of the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while saving the cell '" + c.getName() + "' of the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@ -1104,26 +1133,27 @@ public class JailIO {
|
|||||||
PreparedStatement pp = con.prepareStatement("delete from `" + prefix + "prisoners` where uuid = ?");
|
PreparedStatement pp = con.prepareStatement("delete from `" + prefix + "prisoners` where uuid = ?");
|
||||||
pp.setString(1, p.getUUID().toString());
|
pp.setString(1, p.getUUID().toString());
|
||||||
|
|
||||||
pl.debug("Removing " + p.getLastKnownName() + " (" + p.getUUID().toString() + ") from " + (storage == 2 ? "MySQL" : "SQLite") + " database.");
|
jailMain.debug("Removing " + p.getLastKnownName() + " (" + p.getUUID().toString() + ") from " + (storage == 2 ? "MySQL" : "SQLite") + " database.");
|
||||||
|
|
||||||
pp.executeUpdate();
|
pp.executeUpdate();
|
||||||
pp.close();
|
pp.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while removing the prisoner '" + p.getLastKnownName() + "' (" + p.getUUID().toString() + ") from the database, please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while removing the prisoner '" + p.getLastKnownName() + "' (" + p.getUUID().toString() + ") from the database, please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (c == null)
|
if (c == null) {
|
||||||
flat.set("jails." + j.getName() + ".prisoners." + p.getUUID().toString(), null);
|
flat.set("jails." + j.getName() + ".prisoners." + p.getUUID().toString(), null);
|
||||||
else
|
} else {
|
||||||
flat.set("jails." + j.getName() + ".cells." + c.getName() + ".prisoner", null);
|
flat.set("jails." + j.getName() + ".cells." + c.getName() + ".prisoner", null);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
flat.save(new File(pl.getDataFolder(), "data.yml"));
|
flat.save(new File(jailMain.getDataFolder(), "data.yml"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
pl.getLogger().severe("Unable to save the Jail data: " + e.getMessage());
|
jailMain.getLogger().severe("Unable to save the Jail data: " + e.getMessage());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1137,11 +1167,13 @@ public class JailIO {
|
|||||||
*/
|
*/
|
||||||
public void removeCell(Jail j, Cell c) {
|
public void removeCell(Jail j, Cell c) {
|
||||||
//Clear the inventory before we delete it
|
//Clear the inventory before we delete it
|
||||||
if (c.hasChest()) c.getChest().getInventory().clear();
|
if (c.hasChest()) {
|
||||||
|
c.getChest().getInventory().clear();
|
||||||
|
}
|
||||||
|
|
||||||
//transfer the prisoner if it has one
|
//transfer the prisoner if it has one
|
||||||
if (c.hasPrisoner()) {
|
if (c.hasPrisoner()) {
|
||||||
pl.getLogger().warning("Removing of cell '" + c.getName() + "' from the jail '" + j.getName() + "' failed as it has a prisoner.");
|
jailMain.getLogger().warning("Removing of cell '" + c.getName() + "' from the jail '" + j.getName() + "' failed as it has a prisoner.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1161,8 +1193,8 @@ public class JailIO {
|
|||||||
p.close();
|
p.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while removing the cell '" + c.getName() + "' from the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while removing the cell '" + c.getName() + "' from the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@ -1180,8 +1212,8 @@ public class JailIO {
|
|||||||
p.close();
|
p.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while removing the cell '" + c.getName() + "' from the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while removing the cell '" + c.getName() + "' from the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1189,11 +1221,11 @@ public class JailIO {
|
|||||||
flat.set("jails." + j.getName() + ".cells." + c.getName(), null);
|
flat.set("jails." + j.getName() + ".cells." + c.getName(), null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
flat.save(new File(pl.getDataFolder(), "data.yml"));
|
flat.save(new File(jailMain.getDataFolder(), "data.yml"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Removing of the cell '" + c.getName() + "' from the jail '" + j.getName() + "' errored out while on saving.");
|
jailMain.getLogger().severe("Removing of the cell '" + c.getName() + "' from the jail '" + j.getName() + "' errored out while on saving.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1228,19 +1260,19 @@ public class JailIO {
|
|||||||
p.close();
|
p.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while removing the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while removing the Jail '" + j.getName() + "', please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
flat.set("jails." + name, null);
|
flat.set("jails." + name, null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
flat.save(new File(pl.getDataFolder(), "data.yml"));
|
flat.save(new File(jailMain.getDataFolder(), "data.yml"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Removing of the jail '" + j.getName() + "' errored out while on saving.");
|
jailMain.getLogger().severe("Removing of the jail '" + j.getName() + "' errored out while on saving.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1279,13 +1311,14 @@ public class JailIO {
|
|||||||
p.close();
|
p.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while adding a record entry for '" + username + "', please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while adding a record entry for '" + username + "', please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (records == null)
|
if (records == null) {
|
||||||
records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
|
records = YamlConfiguration.loadConfiguration(new File(jailMain.getDataFolder(), "records.yml"));
|
||||||
|
}
|
||||||
|
|
||||||
List<String> previous = records.getStringList(uuid);
|
List<String> previous = records.getStringList(uuid);
|
||||||
previous.add(Lang.RECORDENTRY.get(date, username, jailer, String.valueOf(time), reason, uuid));
|
previous.add(Lang.RECORDENTRY.get(date, username, jailer, String.valueOf(time), reason, uuid));
|
||||||
@ -1293,11 +1326,11 @@ public class JailIO {
|
|||||||
records.set(uuid, previous);
|
records.set(uuid, previous);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
records.save(new File(pl.getDataFolder(), "records.yml"));
|
records.save(new File(jailMain.getDataFolder(), "records.yml"));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Saving the records.yml file failed while putting an entry in for '" + username + "'.");
|
jailMain.getLogger().severe("Saving the records.yml file failed while putting an entry in for '" + username + "'.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1311,7 +1344,7 @@ public class JailIO {
|
|||||||
* @deprecated This calls getOfflinePlayer which is a blocking call from Bukkit
|
* @deprecated This calls getOfflinePlayer which is a blocking call from Bukkit
|
||||||
*/
|
*/
|
||||||
public List<String> getRecordEntries(String username) {
|
public List<String> getRecordEntries(String username) {
|
||||||
UUID uuid = pl.getServer().getOfflinePlayer(username).getUniqueId();
|
UUID uuid = jailMain.getServer().getOfflinePlayer(username).getUniqueId();
|
||||||
List<String> entries = new ArrayList<>();
|
List<String> entries = new ArrayList<>();
|
||||||
|
|
||||||
switch (storage) {
|
switch (storage) {
|
||||||
@ -1336,13 +1369,14 @@ public class JailIO {
|
|||||||
ps.close();
|
ps.close();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
pl.getLogger().severe("---------- Jail Error!!! ----------");
|
jailMain.getLogger().severe("---------- Jail Error!!! ----------");
|
||||||
pl.getLogger().severe("Error while getting all the record entries for '" + uuid + "', please check the error and fix what is wrong.");
|
jailMain.getLogger().severe("Error while getting all the record entries for '" + uuid + "', please check the error and fix what is wrong.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (records == null)
|
if (records == null) {
|
||||||
records = YamlConfiguration.loadConfiguration(new File(pl.getDataFolder(), "records.yml"));
|
records = YamlConfiguration.loadConfiguration(new File(jailMain.getDataFolder(), "records.yml"));
|
||||||
|
}
|
||||||
|
|
||||||
entries = records.getStringList(uuid.toString());
|
entries = records.getStringList(uuid.toString());
|
||||||
break;
|
break;
|
||||||
|
@ -20,10 +20,13 @@ import com.graywolf336.jail.listeners.ProtectionListener;
|
|||||||
import com.graywolf336.jail.listeners.WorldListener;
|
import com.graywolf336.jail.listeners.WorldListener;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -40,13 +43,13 @@ public class JailMain extends JavaPlugin {
|
|||||||
private HandCuffManager hcm;
|
private HandCuffManager hcm;
|
||||||
private JailHandler jh;
|
private JailHandler jh;
|
||||||
private JailIO io;
|
private JailIO io;
|
||||||
private JailManager jm;
|
private JailManager jailManager;
|
||||||
private IJailPayManager jpm;
|
private IJailPayManager jpm;
|
||||||
private IJailStickManager jsm;
|
private IJailStickManager jailStickManager;
|
||||||
private JailTimer jt;
|
private JailTimer jt;
|
||||||
private JailVoteManager jvm;
|
private JailVoteManager jvm;
|
||||||
private PrisonerManager pm;
|
private PrisonerManager pm;
|
||||||
private ScoreBoardManager sbm;
|
private ScoreBoardManager scoreBoardManager;
|
||||||
private MoveProtectionListener mpl;
|
private MoveProtectionListener mpl;
|
||||||
private Update update;
|
private Update update;
|
||||||
private boolean debug = false;
|
private boolean debug = false;
|
||||||
@ -57,10 +60,12 @@ public class JailMain extends JavaPlugin {
|
|||||||
loadConfig();
|
loadConfig();
|
||||||
|
|
||||||
debug = getConfig().getBoolean(Settings.DEBUG.getPath());
|
debug = getConfig().getBoolean(Settings.DEBUG.getPath());
|
||||||
if (debug) getLogger().info("Debugging enabled.");
|
if (debug) {
|
||||||
|
getLogger().info("Debugging enabled.");
|
||||||
|
}
|
||||||
|
|
||||||
hcm = new HandCuffManager();
|
hcm = new HandCuffManager();
|
||||||
jm = new JailManager(this);
|
jailManager = new JailManager(this);
|
||||||
io = new JailIO(this);
|
io = new JailIO(this);
|
||||||
io.loadLanguage();
|
io.loadLanguage();
|
||||||
|
|
||||||
@ -84,15 +89,15 @@ public class JailMain extends JavaPlugin {
|
|||||||
getLogger().severe("Failed to load the Jail Vote system, please see the stacktrace above (you probably misconfigured the time).");
|
getLogger().severe("Failed to load the Jail Vote system, please see the stacktrace above (you probably misconfigured the time).");
|
||||||
}
|
}
|
||||||
|
|
||||||
PluginManager plm = this.getServer().getPluginManager();
|
PluginManager pluginManager = this.getServer().getPluginManager();
|
||||||
plm.registerEvents(new CacheListener(this), this);
|
pluginManager.registerEvents(new CacheListener(this), this);
|
||||||
plm.registerEvents(new CellSignListener(this), this);
|
pluginManager.registerEvents(new CellSignListener(this), this);
|
||||||
plm.registerEvents(new EntityListener(this), this);
|
pluginManager.registerEvents(new EntityListener(this), this);
|
||||||
plm.registerEvents(new HandCuffListener(this), this);
|
pluginManager.registerEvents(new HandCuffListener(this), this);
|
||||||
plm.registerEvents(new JailingListener(this), this);
|
pluginManager.registerEvents(new JailingListener(this), this);
|
||||||
plm.registerEvents(new PlayerListener(this), this);
|
pluginManager.registerEvents(new PlayerListener(this), this);
|
||||||
plm.registerEvents(new ProtectionListener(this), this);
|
pluginManager.registerEvents(new ProtectionListener(this), this);
|
||||||
plm.registerEvents(new WorldListener(this), this);
|
pluginManager.registerEvents(new WorldListener(this), this);
|
||||||
|
|
||||||
//Only register the move protection listener if this is enabled in the
|
//Only register the move protection listener if this is enabled in the
|
||||||
//config when we first start the plugin. The reason for this change is
|
//config when we first start the plugin. The reason for this change is
|
||||||
@ -103,39 +108,43 @@ public class JailMain extends JavaPlugin {
|
|||||||
this.reloadMoveProtection();
|
this.reloadMoveProtection();
|
||||||
|
|
||||||
jt = new JailTimer(this);
|
jt = new JailTimer(this);
|
||||||
sbm = new ScoreBoardManager(this);
|
scoreBoardManager = new ScoreBoardManager(this);
|
||||||
reloadJailPayManager();
|
reloadJailPayManager();
|
||||||
reloadJailSticks();
|
reloadJailSticks();
|
||||||
reloadUpdateCheck();
|
reloadUpdateCheck();
|
||||||
|
|
||||||
new JailsAPI(this);
|
JailsAPI.initialize(this);
|
||||||
debug("Took " + (System.currentTimeMillis() - st) + " to enable the plugin.");
|
debug("Took " + (System.currentTimeMillis() - st) + " to enable the plugin.");
|
||||||
getLogger().info("Completed enablement.");
|
getLogger().info("Completed enablement.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (jm != null)
|
if (jailManager != null) {
|
||||||
for (Jail j : jm.getJails())
|
for (Jail j : jailManager.getJails())
|
||||||
io.saveJail(j);
|
io.saveJail(j);
|
||||||
|
}
|
||||||
|
|
||||||
if (jt != null)
|
if (jt != null) {
|
||||||
if (jt.getTimer() != null)
|
if (jt.getTimer() != null) {
|
||||||
jt.getTimer().stop();
|
jt.getTimer().stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (io != null)
|
if (io != null) {
|
||||||
io.closeConnection();
|
io.closeConnection();
|
||||||
|
}
|
||||||
|
|
||||||
getServer().getScheduler().cancelTasks(this);
|
getServer().getScheduler().cancelTasks(this);
|
||||||
|
|
||||||
update = null;
|
update = null;
|
||||||
jvm = null;
|
jvm = null;
|
||||||
jt = null;
|
jt = null;
|
||||||
sbm = null;
|
scoreBoardManager = null;
|
||||||
jpm = null;
|
jpm = null;
|
||||||
cmdHand = null;
|
cmdHand = null;
|
||||||
pm = null;
|
pm = null;
|
||||||
jm = null;
|
jailManager = null;
|
||||||
jsm = null;
|
jailStickManager = null;
|
||||||
io = null;
|
io = null;
|
||||||
hcm = null;
|
hcm = null;
|
||||||
}
|
}
|
||||||
@ -148,17 +157,19 @@ public class JailMain extends JavaPlugin {
|
|||||||
getConfig().options().copyDefaults(true);
|
getConfig().options().copyDefaults(true);
|
||||||
|
|
||||||
// Set the header and save
|
// Set the header and save
|
||||||
getConfig().options().header(getHeader());
|
getConfig().options().setHeader(getHeader());
|
||||||
saveConfig();
|
saveConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getHeader() {
|
private List<String> getHeader() {
|
||||||
String sep = System.getProperty("line.separator");
|
String sep = System.getProperty("line.separator");
|
||||||
|
List<String> header = new ArrayList<>();
|
||||||
return "###################" + sep
|
header.add("###################" + sep
|
||||||
+ "Jail v" + this.getDescription().getVersion() + " config file" + sep
|
+ "Jail v" + this.getDescription().getVersion() + " config file" + sep
|
||||||
+ "Note: You -must- use spaces instead of tabs!" + sep +
|
+ "Note: You -must- use spaces instead of tabs!" + sep +
|
||||||
"###################";
|
"###################");
|
||||||
|
|
||||||
|
return header;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Majority of the new command system was heavily influenced by the MobArena.
|
/* Majority of the new command system was heavily influenced by the MobArena.
|
||||||
@ -166,22 +177,24 @@ public class JailMain extends JavaPlugin {
|
|||||||
*
|
*
|
||||||
* Send the command off to the CommandHandler class, that way this main class doesn't get clogged up.
|
* Send the command off to the CommandHandler class, that way this main class doesn't get clogged up.
|
||||||
*/
|
*/
|
||||||
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) {
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String commandLabel,
|
||||||
|
@NotNull String[] args) {
|
||||||
if (jh == null || cmdHand == null) {
|
if (jh == null || cmdHand == null) {
|
||||||
sender.sendMessage(Lang.PLUGINNOTLOADED.get());
|
sender.sendMessage(Lang.PLUGINNOTLOADED.get());
|
||||||
getServer().getConsoleSender().sendMessage(Lang.PLUGINNOTLOADED.get());
|
getServer().getConsoleSender().sendMessage(Lang.PLUGINNOTLOADED.get());
|
||||||
} else {
|
} else {
|
||||||
if (commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) {
|
if (commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) {
|
||||||
jh.parseCommand(jm, sender, args);
|
jh.parseCommand(jailManager, sender, args);
|
||||||
} else {
|
} else {
|
||||||
cmdHand.handleCommand(jm, sender, command.getName().toLowerCase(), args);
|
cmdHand.handleCommand(jailManager, sender, command.getName().toLowerCase(), args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;//Always return true here, that way we can handle the help and command usage ourself.
|
return true;//Always return true here, that way we can handle the help and command usage ourself.
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String commandLabel, String[] args) {
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command,
|
||||||
|
@NotNull String commandLabel, @NotNull String[] args) {
|
||||||
if (jh == null || cmdHand == null) {
|
if (jh == null || cmdHand == null) {
|
||||||
sender.sendMessage(Lang.PLUGINNOTLOADED.get());
|
sender.sendMessage(Lang.PLUGINNOTLOADED.get());
|
||||||
getServer().getConsoleSender().sendMessage(Lang.PLUGINNOTLOADED.get());
|
getServer().getConsoleSender().sendMessage(Lang.PLUGINNOTLOADED.get());
|
||||||
@ -189,13 +202,14 @@ public class JailMain extends JavaPlugin {
|
|||||||
debug("Tab Complete Args (" + args.length + ") for '" + commandLabel + "': " + Util.getStringFromArray(", ", args));
|
debug("Tab Complete Args (" + args.length + ") for '" + commandLabel + "': " + Util.getStringFromArray(", ", args));
|
||||||
try {
|
try {
|
||||||
if (commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) {
|
if (commandLabel.equalsIgnoreCase("jail") || commandLabel.equalsIgnoreCase("j")) {
|
||||||
return jh.parseTabComplete(jm, sender, args);
|
return jh.parseTabComplete(jailManager, sender, args);
|
||||||
} else {
|
} else {
|
||||||
return cmdHand.parseTabComplete(jm, sender, command.getName().toLowerCase(), args);
|
return cmdHand.parseTabComplete(jailManager, sender, command.getName().toLowerCase(), args);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (this.debug)
|
if (this.debug) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
debug(e.getClass().getSimpleName() + " occured while providing tab complete: " + e.getMessage());
|
debug(e.getClass().getSimpleName() + " occured while providing tab complete: " + e.getMessage());
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
@ -256,15 +270,19 @@ public class JailMain extends JavaPlugin {
|
|||||||
* Reloads the scoreboard manager class, useful when something is changed in the config about it.
|
* Reloads the scoreboard manager class, useful when something is changed in the config about it.
|
||||||
*/
|
*/
|
||||||
private void reloadScoreBoardManager() {
|
private void reloadScoreBoardManager() {
|
||||||
this.sbm.removeAllScoreboards();
|
this.scoreBoardManager.removeAllScoreboards();
|
||||||
this.sbm = null;
|
this.scoreBoardManager = null;
|
||||||
this.sbm = new ScoreBoardManager(this);
|
this.scoreBoardManager = new ScoreBoardManager(this);
|
||||||
|
|
||||||
if (getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
if (getConfig().getBoolean(Settings.SCOREBOARDENABLED.getPath())) {
|
||||||
for (Jail j : jm.getJails()) {
|
for (Jail jail : jailManager.getJails()) {
|
||||||
for (Prisoner p : j.getAllPrisoners().values()) {
|
for (Prisoner prisoner : jail.getAllPrisoners().values()) {
|
||||||
if (getServer().getPlayer(p.getUUID()) != null) {
|
if (getServer().getPlayer(prisoner.getUUID()) != null) {
|
||||||
this.sbm.addScoreBoard(getServer().getPlayer(p.getUUID()), p);
|
Player uuid = getServer().getPlayer(prisoner.getUUID());
|
||||||
|
if (uuid == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.scoreBoardManager.addScoreBoard(uuid, prisoner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,12 +294,12 @@ public class JailMain extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
private void reloadJailSticks() {
|
private void reloadJailSticks() {
|
||||||
if (getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
if (getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
||||||
if (this.jsm != null) {
|
if (this.jailStickManager != null) {
|
||||||
this.jsm.removeAllStickUsers();
|
this.jailStickManager.removeAllStickUsers();
|
||||||
this.jsm = null;
|
this.jailStickManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.jsm = new JailStickManager(this);
|
this.jailStickManager = new JailStickManager(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -358,7 +376,7 @@ public class JailMain extends JavaPlugin {
|
|||||||
* @return {@link JailManager} instance
|
* @return {@link JailManager} instance
|
||||||
*/
|
*/
|
||||||
public JailManager getJailManager() {
|
public JailManager getJailManager() {
|
||||||
return this.jm;
|
return this.jailManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -385,7 +403,7 @@ public class JailMain extends JavaPlugin {
|
|||||||
* @return {@link JailStickManager}
|
* @return {@link JailStickManager}
|
||||||
*/
|
*/
|
||||||
public IJailStickManager getJailStickManager() {
|
public IJailStickManager getJailStickManager() {
|
||||||
return this.jsm;
|
return this.jailStickManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -394,7 +412,7 @@ public class JailMain extends JavaPlugin {
|
|||||||
* @return {@link ScoreBoardManager} instance
|
* @return {@link ScoreBoardManager} instance
|
||||||
*/
|
*/
|
||||||
public ScoreBoardManager getScoreBoardManager() {
|
public ScoreBoardManager getScoreBoardManager() {
|
||||||
return this.sbm;
|
return this.scoreBoardManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -446,7 +464,9 @@ public class JailMain extends JavaPlugin {
|
|||||||
* @param message the item to log as debugging
|
* @param message the item to log as debugging
|
||||||
*/
|
*/
|
||||||
public void debug(String message) {
|
public void debug(String message) {
|
||||||
if (inDebug()) getLogger().info("[Debug]: " + message);
|
if (inDebug()) {
|
||||||
|
getLogger().info("[Debug]: " + message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,23 +79,6 @@ public class JailManager {
|
|||||||
return new HashSet<>(jails.values());
|
return new HashSet<>(jails.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns an array of all the names of the jails.
|
|
||||||
*
|
|
||||||
* @return Array of the jail names
|
|
||||||
*/
|
|
||||||
public String[] getJailNames() {
|
|
||||||
String[] toReturn = new String[jails.size()];
|
|
||||||
|
|
||||||
int count = 0;
|
|
||||||
for (Jail j : this.jails.values()) {
|
|
||||||
toReturn[count] = j.getName();
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of Jail names that start with the provided prefix.
|
* Gets a list of Jail names that start with the provided prefix.
|
||||||
*
|
*
|
||||||
@ -110,8 +93,9 @@ public class JailManager {
|
|||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
|
|
||||||
for (Jail j : this.jails.values())
|
for (Jail j : this.jails.values())
|
||||||
if (prefix.isEmpty() || StringUtil.startsWithIgnoreCase(j.getName(), prefix))
|
if (prefix.isEmpty() || StringUtil.startsWithIgnoreCase(j.getName(), prefix)) {
|
||||||
results.add(j.getName());
|
results.add(j.getName());
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
@ -126,7 +110,9 @@ public class JailManager {
|
|||||||
*/
|
*/
|
||||||
public void addJail(Jail jail, boolean n) {
|
public void addJail(Jail jail, boolean n) {
|
||||||
this.jails.put(jail.getName().toLowerCase(), jail);
|
this.jails.put(jail.getName().toLowerCase(), jail);
|
||||||
if (n) plugin.getJailIO().saveJail(jail);
|
if (n) {
|
||||||
|
plugin.getJailIO().saveJail(jail);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -146,11 +132,12 @@ public class JailManager {
|
|||||||
* @return The {@link Jail} with the given name, if no jail found this <strong>will</strong> return null.
|
* @return The {@link Jail} with the given name, if no jail found this <strong>will</strong> return null.
|
||||||
*/
|
*/
|
||||||
public Jail getJail(String name) {
|
public Jail getJail(String name) {
|
||||||
if (name.isEmpty() && jails.isEmpty())
|
if (name.isEmpty() && jails.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
else
|
} else {
|
||||||
return name.isEmpty() ? this.jails.values().iterator().next() : this.jails.get(name.toLowerCase());
|
return name.isEmpty() ? this.jails.values().iterator().next() : this.jails.get(name.toLowerCase());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the nearest {@link Jail} to the player, if the sender is a player or else it will get the first jail defined.
|
* Gets the nearest {@link Jail} to the player, if the sender is a player or else it will get the first jail defined.
|
||||||
@ -159,24 +146,26 @@ public class JailManager {
|
|||||||
* @return The nearest {@link Jail} to the sender if it is a player or else the first jail defined.
|
* @return The nearest {@link Jail} to the sender if it is a player or else the first jail defined.
|
||||||
*/
|
*/
|
||||||
public Jail getNearestJail(CommandSender sender) {
|
public Jail getNearestJail(CommandSender sender) {
|
||||||
if (jails.isEmpty()) return null;
|
if (jails.isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Location loc = ((Player) sender).getLocation();
|
Location playerLocation = ((Player) sender).getLocation();
|
||||||
|
|
||||||
Jail j = null;
|
Jail nearestJail = null;
|
||||||
double len = -1;
|
double nearestJailDistance = -1;
|
||||||
|
|
||||||
for (Jail jail : jails.values()) {
|
for (Jail jail : jails.values()) {
|
||||||
double clen = jail.getDistance(loc);
|
double distance = jail.getDistance(playerLocation);
|
||||||
|
|
||||||
if (clen < len || len == -1) {
|
if (distance < nearestJailDistance || nearestJailDistance == -1) {
|
||||||
len = clen;
|
nearestJailDistance = distance;
|
||||||
j = jail;
|
nearestJail = jail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (j == null ? jails.values().iterator().next() : j);
|
return nearestJail;
|
||||||
} else {
|
} else {
|
||||||
return jails.values().iterator().next();
|
return jails.values().iterator().next();
|
||||||
}
|
}
|
||||||
@ -232,8 +221,8 @@ public class JailManager {
|
|||||||
public HashSet<Cell> getAllCells() {
|
public HashSet<Cell> getAllCells() {
|
||||||
HashSet<Cell> cells = new HashSet<>();
|
HashSet<Cell> cells = new HashSet<>();
|
||||||
|
|
||||||
for (Jail j : jails.values())
|
for (Jail jail : jails.values())
|
||||||
cells.addAll(j.getCells());
|
cells.addAll(jail.getCells());
|
||||||
|
|
||||||
return cells;
|
return cells;
|
||||||
}
|
}
|
||||||
@ -242,12 +231,11 @@ public class JailManager {
|
|||||||
* Adds a prisoner to the cache.
|
* Adds a prisoner to the cache.
|
||||||
*
|
*
|
||||||
* @param cache object to store
|
* @param cache object to store
|
||||||
* @return The same object given
|
|
||||||
*/
|
*/
|
||||||
public CachePrisoner addCacheObject(CachePrisoner cache) {
|
public void addCacheObject(CachePrisoner cache) {
|
||||||
plugin.debug("Adding " + cache.getPrisoner().getUUID().toString() + " to the cache.");
|
UUID uuid = cache.getPrisoner().getUUID();
|
||||||
this.cache.put(cache.getPrisoner().getUUID(), cache);
|
plugin.debug("Adding " + uuid.toString() + " to the cache.");
|
||||||
return this.cache.get(cache.getPrisoner().getUUID());
|
this.cache.put(uuid, cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -301,8 +289,11 @@ public class JailManager {
|
|||||||
* @return The jail the player is in, <strong>CAN BE NULL</strong>.
|
* @return The jail the player is in, <strong>CAN BE NULL</strong>.
|
||||||
*/
|
*/
|
||||||
public Jail getJailPrisonerIsIn(Prisoner prisoner) {
|
public Jail getJailPrisonerIsIn(Prisoner prisoner) {
|
||||||
if (prisoner == null) return null;
|
if (prisoner == null) {
|
||||||
else return getJailPlayerIsIn(prisoner.getUUID());
|
return null;
|
||||||
|
} else {
|
||||||
|
return getJailPlayerIsIn(prisoner.getUUID());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -322,8 +313,9 @@ public class JailManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Jail j : jails.values())
|
for (Jail j : jails.values())
|
||||||
if (j.isPlayerJailed(uuid))
|
if (j.isPlayerJailed(uuid)) {
|
||||||
return j;
|
return j;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -359,8 +351,9 @@ public class JailManager {
|
|||||||
public Jail getJailPlayerIsInByLastKnownName(String username) {
|
public Jail getJailPlayerIsInByLastKnownName(String username) {
|
||||||
for (Jail j : jails.values())
|
for (Jail j : jails.values())
|
||||||
for (Prisoner p : j.getAllPrisoners().values())
|
for (Prisoner p : j.getAllPrisoners().values())
|
||||||
if (p.getLastKnownName().equalsIgnoreCase(username))
|
if (p.getLastKnownName().equalsIgnoreCase(username)) {
|
||||||
return j;
|
return j;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -373,8 +366,9 @@ public class JailManager {
|
|||||||
*/
|
*/
|
||||||
public Prisoner getPrisonerByLastKnownName(String username) {
|
public Prisoner getPrisonerByLastKnownName(String username) {
|
||||||
for (Prisoner p : this.getAllPrisoners().values())
|
for (Prisoner p : this.getAllPrisoners().values())
|
||||||
if (p.getLastKnownName().equalsIgnoreCase(username))
|
if (p.getLastKnownName().equalsIgnoreCase(username)) {
|
||||||
return p;
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -586,38 +580,24 @@ public class JailManager {
|
|||||||
String message = "";
|
String message = "";
|
||||||
|
|
||||||
if (isCreatingACell(player)) {//Check whether it is a jail cell
|
if (isCreatingACell(player)) {//Check whether it is a jail cell
|
||||||
CreationPlayer cp = this.getCellCreationPlayer(player);
|
CreationPlayer creationPlayer = this.getCellCreationPlayer(player);
|
||||||
message = "You're already creating a Cell with the name '" + cp.getCellName() + "' and you still need to ";
|
message = "You're already creating a Cell with the name '" + creationPlayer.getCellName() + "' and you still need to ";
|
||||||
|
|
||||||
switch (cp.getStep()) {
|
switch (creationPlayer.getStep()) {
|
||||||
case 1:
|
case 1 -> message += "set the teleport in location.";
|
||||||
message += "set the teleport in location.";
|
case 2 -> message += "select all the signs.";
|
||||||
break;
|
case 3 -> message += "set the double chest location.";
|
||||||
case 2:
|
|
||||||
message += "select all the signs.";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
message += "set the double chest location.";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (isCreatingAJail(player)) {//If not a cell, then check if a jail.
|
} else if (isCreatingAJail(player)) {//If not a cell, then check if a jail.
|
||||||
CreationPlayer cp = this.getJailCreationPlayer(player);
|
CreationPlayer creationPlayer = this.getJailCreationPlayer(player);
|
||||||
message = "You're already creating a Jail with the name '" + cp.getJailName() + "' and you still need to ";
|
message = "You're already creating a Jail with the name '" + creationPlayer.getJailName() + "' and you still need to ";
|
||||||
|
|
||||||
switch (cp.getStep()) {
|
switch (creationPlayer.getStep()) {
|
||||||
case 1:
|
case 1 -> message += "select the first point.";
|
||||||
message += "select the first point.";
|
case 2 -> message += "select the second point.";
|
||||||
break;
|
case 3 -> message += "set the teleport in location.";
|
||||||
case 2:
|
case 4 -> message += "set the release location.";
|
||||||
message += "select the second point.";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
message += "set the teleport in location.";
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
message += "set the release location.";
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,9 @@ public class JailPayManager implements IJailPayManager {
|
|||||||
ItemStack it = p.getInventory().getItem(i);
|
ItemStack it = p.getInventory().getItem(i);
|
||||||
|
|
||||||
//The item is either air or we doesn't match out needs
|
//The item is either air or we doesn't match out needs
|
||||||
if (it == null || it.getType() != this.item) continue;
|
if (it == null || it.getType() != this.item) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//If the itemstack has more than or equal to the amount
|
//If the itemstack has more than or equal to the amount
|
||||||
//that we need, remove it and subject from the amt needed
|
//that we need, remove it and subject from the amt needed
|
||||||
@ -95,7 +97,9 @@ public class JailPayManager implements IJailPayManager {
|
|||||||
amtNeeded = 0;
|
amtNeeded = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (amtNeeded == 0) break;
|
if (amtNeeded == 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.economy.withdrawPlayer(p, amt);
|
this.economy.withdrawPlayer(p, amt);
|
||||||
@ -133,7 +137,9 @@ public class JailPayManager implements IJailPayManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean setupEconomy(JailMain plugin) {
|
private boolean setupEconomy(JailMain plugin) {
|
||||||
if (economy != null) return true;
|
if (economy != null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
RegisteredServiceProvider<Economy> economyProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
RegisteredServiceProvider<Economy> economyProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
|
||||||
if (economyProvider != null) {
|
if (economyProvider != null) {
|
||||||
|
@ -85,7 +85,9 @@ public class JailTimer {
|
|||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
after = event.getTimeAfterChange();
|
after = event.getTimeAfterChange();
|
||||||
p.setRemainingTime(after);
|
p.setRemainingTime(after);
|
||||||
if (p.getRemainingTime() == 0) pl.getPrisonerManager().schedulePrisonerRelease(p);
|
if (p.getRemainingTime() == 0) {
|
||||||
|
pl.getPrisonerManager().schedulePrisonerRelease(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -111,7 +113,9 @@ public class JailTimer {
|
|||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
after = event.getTimeAfterChange();
|
after = event.getTimeAfterChange();
|
||||||
p.setRemainingTime(after);
|
p.setRemainingTime(after);
|
||||||
if (p.getRemainingTime() == 0) pl.getPrisonerManager().schedulePrisonerRelease(p);
|
if (p.getRemainingTime() == 0) {
|
||||||
|
pl.getPrisonerManager().schedulePrisonerRelease(p);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,10 +15,15 @@ import com.graywolf336.jail.interfaces.IJailStickManager;
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class JailsAPI {
|
public class JailsAPI {
|
||||||
private static JailMain pl;
|
|
||||||
|
|
||||||
protected JailsAPI(JailMain plugin) {
|
private static JailMain jailMain;
|
||||||
pl = plugin;
|
|
||||||
|
private JailsAPI() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected static void initialize(JailMain plugin) {
|
||||||
|
jailMain = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -27,7 +32,7 @@ public class JailsAPI {
|
|||||||
* @return the build number of jail or -1 if an error occurred.
|
* @return the build number of jail or -1 if an error occurred.
|
||||||
*/
|
*/
|
||||||
public static int getBuildNumber() {
|
public static int getBuildNumber() {
|
||||||
String v = pl.getDescription().getVersion();
|
String v = jailMain.getDescription().getVersion();
|
||||||
String[] split = v.split("-");
|
String[] split = v.split("-");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -44,7 +49,7 @@ public class JailsAPI {
|
|||||||
* @see JailManager
|
* @see JailManager
|
||||||
*/
|
*/
|
||||||
public static JailManager getJailManager() {
|
public static JailManager getJailManager() {
|
||||||
return pl.getJailManager();
|
return jailMain.getJailManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +59,7 @@ public class JailsAPI {
|
|||||||
* @see PrisonerManager
|
* @see PrisonerManager
|
||||||
*/
|
*/
|
||||||
public static PrisonerManager getPrisonerManager() {
|
public static PrisonerManager getPrisonerManager() {
|
||||||
return pl.getPrisonerManager();
|
return jailMain.getPrisonerManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,7 +69,7 @@ public class JailsAPI {
|
|||||||
* @see IJailStickManager
|
* @see IJailStickManager
|
||||||
*/
|
*/
|
||||||
public static IJailStickManager getJailStickManager() {
|
public static IJailStickManager getJailStickManager() {
|
||||||
return pl.getJailStickManager();
|
return jailMain.getJailStickManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -74,7 +79,7 @@ public class JailsAPI {
|
|||||||
* @see HandCuffManager
|
* @see HandCuffManager
|
||||||
*/
|
*/
|
||||||
public static HandCuffManager getHandCuffManager() {
|
public static HandCuffManager getHandCuffManager() {
|
||||||
return pl.getHandCuffManager();
|
return jailMain.getHandCuffManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -84,7 +89,7 @@ public class JailsAPI {
|
|||||||
* @see JailVoteManager
|
* @see JailVoteManager
|
||||||
*/
|
*/
|
||||||
public static JailVoteManager getJailVoteManager() {
|
public static JailVoteManager getJailVoteManager() {
|
||||||
return pl.getJailVoteManager();
|
return jailMain.getJailVoteManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -86,17 +86,21 @@ public class PrisonerManager {
|
|||||||
*/
|
*/
|
||||||
public void prepareJail(final Jail jail, ICell cell, final Player player, final Prisoner prisoner) throws JailRequiredException, PrisonerAlreadyJailedException, PrisonerRequiredException {
|
public void prepareJail(final Jail jail, ICell cell, final Player player, final Prisoner prisoner) throws JailRequiredException, PrisonerAlreadyJailedException, PrisonerRequiredException {
|
||||||
//Do some checks of whether the passed params are null.
|
//Do some checks of whether the passed params are null.
|
||||||
if (jail == null)
|
if (jail == null) {
|
||||||
throw new JailRequiredException("jailing a prisoner");
|
throw new JailRequiredException("jailing a prisoner");
|
||||||
|
}
|
||||||
|
|
||||||
if (cell == null)
|
if (cell == null) {
|
||||||
cell = new NoCell();
|
cell = new NoCell();
|
||||||
|
}
|
||||||
|
|
||||||
if (prisoner == null)
|
if (prisoner == null) {
|
||||||
throw new PrisonerRequiredException("jailing a prisoner");
|
throw new PrisonerRequiredException("jailing a prisoner");
|
||||||
|
}
|
||||||
|
|
||||||
if (this.pl.getJailManager().isPlayerJailed(prisoner.getUUID()))
|
if (this.pl.getJailManager().isPlayerJailed(prisoner.getUUID())) {
|
||||||
throw new PrisonerAlreadyJailedException(prisoner.getLastKnownName(), prisoner.getUUID().toString());
|
throw new PrisonerAlreadyJailedException(prisoner.getLastKnownName(), prisoner.getUUID().toString());
|
||||||
|
}
|
||||||
|
|
||||||
//Set whether the prisoner is offline or not.
|
//Set whether the prisoner is offline or not.
|
||||||
prisoner.setOfflinePending(player == null);
|
prisoner.setOfflinePending(player == null);
|
||||||
@ -108,10 +112,11 @@ public class PrisonerManager {
|
|||||||
} else if (cell instanceof AnyCell) {
|
} else if (cell instanceof AnyCell) {
|
||||||
cell = jail.getFirstEmptyCell();
|
cell = jail.getFirstEmptyCell();
|
||||||
|
|
||||||
if (cell == null)
|
if (cell == null) {
|
||||||
jail.addPrisoner(prisoner);
|
jail.addPrisoner(prisoner);
|
||||||
else
|
} else {
|
||||||
cell.setPrisoner(prisoner);
|
cell.setPrisoner(prisoner);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
cell.setPrisoner(prisoner);
|
cell.setPrisoner(prisoner);
|
||||||
}
|
}
|
||||||
@ -127,10 +132,11 @@ public class PrisonerManager {
|
|||||||
//Get a message ready for broadcasting or logging.
|
//Get a message ready for broadcasting or logging.
|
||||||
String msg;
|
String msg;
|
||||||
|
|
||||||
if (prisoner.getRemainingTime() < 0L)
|
if (prisoner.getRemainingTime() < 0L) {
|
||||||
msg = Lang.BROADCASTMESSAGEFOREVER.get(prisoner.getLastKnownName(), prisoner.getReason(), jail.getName(), cell == null ? "" : cell.getName());
|
msg = Lang.BROADCASTMESSAGEFOREVER.get(prisoner.getLastKnownName(), prisoner.getReason(), jail.getName(), cell == null ? "" : cell.getName());
|
||||||
else
|
} else {
|
||||||
msg = Lang.BROADCASTMESSAGEFORMINUTES.get(prisoner.getLastKnownName(), String.valueOf(prisoner.getRemainingTimeInMinutes()), prisoner.getReason(), jail.getName(), cell == null ? "" : cell.getName());
|
msg = Lang.BROADCASTMESSAGEFORMINUTES.get(prisoner.getLastKnownName(), String.valueOf(prisoner.getRemainingTimeInMinutes()), prisoner.getReason(), jail.getName(), cell == null ? "" : cell.getName());
|
||||||
|
}
|
||||||
|
|
||||||
boolean broadcasted = false;
|
boolean broadcasted = false;
|
||||||
//Broadcast the message, if it is enabled
|
//Broadcast the message, if it is enabled
|
||||||
@ -164,10 +170,11 @@ public class PrisonerManager {
|
|||||||
* @param prisoner data containing everything pertaining to them
|
* @param prisoner data containing everything pertaining to them
|
||||||
*/
|
*/
|
||||||
protected void jailPrisoner(final Jail jail, ICell cell, final Player player, final Prisoner prisoner) {
|
protected void jailPrisoner(final Jail jail, ICell cell, final Player player, final Prisoner prisoner) {
|
||||||
if (cell instanceof NoCell)
|
if (cell instanceof NoCell) {
|
||||||
cell = null;
|
cell = null;
|
||||||
else if (cell instanceof AnyCell)
|
} else if (cell instanceof AnyCell) {
|
||||||
cell = null;
|
cell = null;
|
||||||
|
}
|
||||||
|
|
||||||
//If they have handcuffs on them, then let's remove them before we continue
|
//If they have handcuffs on them, then let's remove them before we continue
|
||||||
//this way the handcuff listeners and this aren't battleing each other
|
//this way the handcuff listeners and this aren't battleing each other
|
||||||
@ -208,8 +215,9 @@ public class PrisonerManager {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
StringBuilder gamemodes = new StringBuilder();
|
StringBuilder gamemodes = new StringBuilder();
|
||||||
for (GameMode m : GameMode.values()) {
|
for (GameMode m : GameMode.values()) {
|
||||||
if (gamemodes.length() != 0)
|
if (gamemodes.length() != 0) {
|
||||||
gamemodes.append(", ");
|
gamemodes.append(", ");
|
||||||
|
}
|
||||||
|
|
||||||
gamemodes.append(m.toString().toLowerCase());
|
gamemodes.append(m.toString().toLowerCase());
|
||||||
}
|
}
|
||||||
@ -279,14 +287,18 @@ public class PrisonerManager {
|
|||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
} else {
|
} else {
|
||||||
for (ItemStack item : player.getInventory().getContents())
|
for (ItemStack item : player.getInventory().getContents())
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
if (Util.isStringInsideList(item.getType().toString(), blacklist))
|
if (Util.isStringInsideList(item.getType().toString(), blacklist)) {
|
||||||
player.getInventory().remove(item);
|
player.getInventory().remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (ItemStack item : player.getInventory().getArmorContents())
|
for (ItemStack item : player.getInventory().getArmorContents())
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
if (Util.isStringInsideList(item.getType().toString(), blacklist))
|
if (Util.isStringInsideList(item.getType().toString(), blacklist)) {
|
||||||
player.getInventory().remove(item);
|
player.getInventory().remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
prisoner.setInventory(Util.toBase64(player.getInventory()));
|
prisoner.setInventory(Util.toBase64(player.getInventory()));
|
||||||
|
|
||||||
@ -307,14 +319,18 @@ public class PrisonerManager {
|
|||||||
List<String> blacklist = pl.getConfig().getStringList(Settings.JAILEDINVENTORYBLACKLIST.getPath());
|
List<String> blacklist = pl.getConfig().getStringList(Settings.JAILEDINVENTORYBLACKLIST.getPath());
|
||||||
|
|
||||||
for (ItemStack item : player.getInventory().getContents())
|
for (ItemStack item : player.getInventory().getContents())
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
if (Util.isStringInsideList(item.getType().toString(), blacklist))
|
if (Util.isStringInsideList(item.getType().toString(), blacklist)) {
|
||||||
player.getInventory().remove(item);
|
player.getInventory().remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (ItemStack item : player.getInventory().getArmorContents())
|
for (ItemStack item : player.getInventory().getArmorContents())
|
||||||
if (item != null)
|
if (item != null) {
|
||||||
if (Util.isStringInsideList(item.getType().toString(), blacklist))
|
if (Util.isStringInsideList(item.getType().toString(), blacklist)) {
|
||||||
player.getInventory().remove(item);
|
player.getInventory().remove(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
prisoner.setInventory(Util.toBase64(player.getInventory()));
|
prisoner.setInventory(Util.toBase64(player.getInventory()));
|
||||||
|
|
||||||
@ -415,19 +431,24 @@ public class PrisonerManager {
|
|||||||
* @throws PrisonerRequiredException when the provided prisoner data is null.
|
* @throws PrisonerRequiredException when the provided prisoner data is null.
|
||||||
*/
|
*/
|
||||||
public void unJail(final Jail jail, ICell cell, final Player player, final Prisoner prisoner, final CommandSender sender) throws AsyncUnJailingNotSupportedException, JailRequiredException, PrisonerRequiredException {
|
public void unJail(final Jail jail, ICell cell, final Player player, final Prisoner prisoner, final CommandSender sender) throws AsyncUnJailingNotSupportedException, JailRequiredException, PrisonerRequiredException {
|
||||||
if (!pl.getServer().isPrimaryThread()) throw new AsyncUnJailingNotSupportedException();
|
if (!pl.getServer().isPrimaryThread()) {
|
||||||
|
throw new AsyncUnJailingNotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
//Do some checks of whether the passed params are null.
|
//Do some checks of whether the passed params are null.
|
||||||
if (jail == null)
|
if (jail == null) {
|
||||||
throw new JailRequiredException("unjailing a prisoner");
|
throw new JailRequiredException("unjailing a prisoner");
|
||||||
|
}
|
||||||
|
|
||||||
if (cell instanceof NoCell)
|
if (cell instanceof NoCell) {
|
||||||
cell = null;
|
cell = null;
|
||||||
else if (cell instanceof AnyCell)
|
} else if (cell instanceof AnyCell) {
|
||||||
cell = null;
|
cell = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (prisoner == null)
|
if (prisoner == null) {
|
||||||
throw new PrisonerRequiredException("unjailing a prisoner");
|
throw new PrisonerRequiredException("unjailing a prisoner");
|
||||||
|
}
|
||||||
|
|
||||||
//Throw the custom event which is called before we start releasing them
|
//Throw the custom event which is called before we start releasing them
|
||||||
PrePrisonerReleasedEvent preEvent = new PrePrisonerReleasedEvent(jail, cell, prisoner, player);
|
PrePrisonerReleasedEvent preEvent = new PrePrisonerReleasedEvent(jail, cell, prisoner, player);
|
||||||
@ -461,7 +482,9 @@ public class PrisonerManager {
|
|||||||
Inventory chest = cell.getChest().getInventory();
|
Inventory chest = cell.getChest().getInventory();
|
||||||
|
|
||||||
for (ItemStack item : chest.getContents()) {
|
for (ItemStack item : chest.getContents()) {
|
||||||
if (item == null || item.getType() == Material.AIR) continue;
|
if (item == null || item.getType() == Material.AIR) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (item.getType().toString().toLowerCase().contains("helmet") && (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() == Material.AIR)) {
|
if (item.getType().toString().toLowerCase().contains("helmet") && (player.getInventory().getHelmet() == null || player.getInventory().getHelmet().getType() == Material.AIR)) {
|
||||||
player.getInventory().setHelmet(item);
|
player.getInventory().setHelmet(item);
|
||||||
@ -485,13 +508,17 @@ public class PrisonerManager {
|
|||||||
} else {
|
} else {
|
||||||
//Clear out the cell's chest just in case
|
//Clear out the cell's chest just in case
|
||||||
//they decided to store something there
|
//they decided to store something there
|
||||||
if (cell.hasChest()) cell.getChest().getInventory().clear();
|
if (cell.hasChest()) {
|
||||||
|
cell.getChest().getInventory().clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pl.getJailIO().removePrisoner(jail, (Cell) cell, prisoner);
|
pl.getJailIO().removePrisoner(jail, (Cell) cell, prisoner);
|
||||||
cell.removePrisoner();
|
cell.removePrisoner();
|
||||||
} else {
|
} else {
|
||||||
if (store) Util.restoreInventory(player, prisoner);
|
if (store) {
|
||||||
|
Util.restoreInventory(player, prisoner);
|
||||||
|
}
|
||||||
|
|
||||||
pl.getJailIO().removePrisoner(jail, prisoner);
|
pl.getJailIO().removePrisoner(jail, prisoner);
|
||||||
jail.removePrisoner(prisoner);
|
jail.removePrisoner(prisoner);
|
||||||
@ -506,9 +533,10 @@ public class PrisonerManager {
|
|||||||
//previous position then let's do that
|
//previous position then let's do that
|
||||||
boolean tpd = false;
|
boolean tpd = false;
|
||||||
if (pl.getConfig().getBoolean(Settings.RELEASETOPREVIOUSPOSITION.getPath(), false)) {
|
if (pl.getConfig().getBoolean(Settings.RELEASETOPREVIOUSPOSITION.getPath(), false)) {
|
||||||
if (prisoner.getPreviousLocation() != null)
|
if (prisoner.getPreviousLocation() != null) {
|
||||||
tpd = player.teleport(prisoner.getPreviousLocation());
|
tpd = player.teleport(prisoner.getPreviousLocation());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//If they haven't already been teleported and the config has us to teleport on release,
|
//If they haven't already been teleported and the config has us to teleport on release,
|
||||||
//then we teleport players to the jail's free spot
|
//then we teleport players to the jail's free spot
|
||||||
@ -543,7 +571,9 @@ public class PrisonerManager {
|
|||||||
pl.getServer().getPluginManager().callEvent(event);
|
pl.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
player.sendMessage(Lang.UNJAILED.get());
|
player.sendMessage(Lang.UNJAILED.get());
|
||||||
if (sender != null) sender.sendMessage(Lang.UNJAILSUCCESS.get(player.getName()));
|
if (sender != null) {
|
||||||
|
sender.sendMessage(Lang.UNJAILSUCCESS.get(player.getName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -600,11 +630,13 @@ public class PrisonerManager {
|
|||||||
* @throws PrisonerRequiredException when the provided prisoner data is null.
|
* @throws PrisonerRequiredException when the provided prisoner data is null.
|
||||||
*/
|
*/
|
||||||
public void forceUnJail(Jail jail, Cell cell, Player player, Prisoner prisoner, CommandSender sender) throws JailRequiredException, PrisonerRequiredException {
|
public void forceUnJail(Jail jail, Cell cell, Player player, Prisoner prisoner, CommandSender sender) throws JailRequiredException, PrisonerRequiredException {
|
||||||
if (jail == null)
|
if (jail == null) {
|
||||||
throw new JailRequiredException("jailing a prisoner");
|
throw new JailRequiredException("jailing a prisoner");
|
||||||
|
}
|
||||||
|
|
||||||
if (prisoner == null)
|
if (prisoner == null) {
|
||||||
throw new PrisonerRequiredException("jailing a prisoner");
|
throw new PrisonerRequiredException("jailing a prisoner");
|
||||||
|
}
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
//Player is offline, we just forcefully remove them from the database
|
//Player is offline, we just forcefully remove them from the database
|
||||||
@ -620,7 +652,9 @@ public class PrisonerManager {
|
|||||||
PrisonerReleasedEvent event = new PrisonerReleasedEvent(jail, cell, prisoner, player);
|
PrisonerReleasedEvent event = new PrisonerReleasedEvent(jail, cell, prisoner, player);
|
||||||
pl.getServer().getPluginManager().callEvent(event);
|
pl.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (sender != null) sender.sendMessage(Lang.FORCEUNJAILED.get(prisoner.getLastKnownName()));
|
if (sender != null) {
|
||||||
|
sender.sendMessage(Lang.FORCEUNJAILED.get(prisoner.getLastKnownName()));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
unJail(jail, cell, player, prisoner, sender);
|
unJail(jail, cell, player, prisoner, sender);
|
||||||
@ -718,8 +752,9 @@ public class PrisonerManager {
|
|||||||
if (targetCell.hasChest()) {
|
if (targetCell.hasChest()) {
|
||||||
//Loop through the origin's chest inventory and add it to the target cell's chest
|
//Loop through the origin's chest inventory and add it to the target cell's chest
|
||||||
for (ItemStack i : originCell.getChest().getInventory().getContents())
|
for (ItemStack i : originCell.getChest().getInventory().getContents())
|
||||||
if (i != null)
|
if (i != null) {
|
||||||
targetCell.getChest().getInventory().addItem(i);
|
targetCell.getChest().getInventory().addItem(i);
|
||||||
|
}
|
||||||
|
|
||||||
//Clear the origin cell's chest as it is clear now
|
//Clear the origin cell's chest as it is clear now
|
||||||
originCell.getChest().getInventory().clear();
|
originCell.getChest().getInventory().clear();
|
||||||
@ -736,10 +771,12 @@ public class PrisonerManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Update the signs of both cells
|
//Update the signs of both cells
|
||||||
if (originCell != null)
|
if (originCell != null) {
|
||||||
originCell.updateSigns();
|
originCell.updateSigns();
|
||||||
if (targetCell != null)
|
}
|
||||||
|
if (targetCell != null) {
|
||||||
targetCell.updateSigns();
|
targetCell.updateSigns();
|
||||||
|
}
|
||||||
|
|
||||||
//Throw our custom event PrisonerTransferredEvent to say it was successful
|
//Throw our custom event PrisonerTransferredEvent to say it was successful
|
||||||
PrisonerTransferredEvent event = new PrisonerTransferredEvent(originJail, originCell, targetJail, targetCell, prisoner, player);
|
PrisonerTransferredEvent event = new PrisonerTransferredEvent(originJail, originCell, targetJail, targetCell, prisoner, player);
|
||||||
|
@ -129,7 +129,7 @@ public class Update {
|
|||||||
* @return The result is a negative integer if str1 is _numerically_ less than str2.
|
* @return The result is a negative integer if str1 is _numerically_ less than str2.
|
||||||
* The result is a positive integer if str1 is _numerically_ greater than str2.
|
* The result is a positive integer if str1 is _numerically_ greater than str2.
|
||||||
* The result is zero if the strings are _numerically_ equal.
|
* The result is zero if the strings are _numerically_ equal.
|
||||||
* @note It does not work if "1.10" is supposed to be equal to "1.10.0".
|
* Note: It does not work if "1.10" is supposed to be equal to "1.10.0".
|
||||||
*/
|
*/
|
||||||
private Integer versionCompare(String str1, String str2) {
|
private Integer versionCompare(String str1, String str2) {
|
||||||
String[] vals1 = str1.split("\\.");
|
String[] vals1 = str1.split("\\.");
|
||||||
|
@ -88,8 +88,9 @@ public class Util {
|
|||||||
*/
|
*/
|
||||||
public static boolean isStringInsideArray(String value, String... array) {
|
public static boolean isStringInsideArray(String value, String... array) {
|
||||||
for (String s : array)
|
for (String s : array)
|
||||||
if (s.equalsIgnoreCase(value))
|
if (s.equalsIgnoreCase(value)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -105,8 +106,9 @@ public class Util {
|
|||||||
*/
|
*/
|
||||||
public static boolean isStringInsideList(String value, List<String> list) {
|
public static boolean isStringInsideList(String value, List<String> list) {
|
||||||
for (String s : list)
|
for (String s : list)
|
||||||
if (s.equalsIgnoreCase(value))
|
if (s.equalsIgnoreCase(value)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -122,7 +124,9 @@ public class Util {
|
|||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
for (String s : array) {
|
for (String s : array) {
|
||||||
if (result.length() != 0) result.append(separator);
|
if (result.length() != 0) {
|
||||||
|
result.append(separator);
|
||||||
|
}
|
||||||
result.append(s);
|
result.append(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +144,9 @@ public class Util {
|
|||||||
StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
for (String s : list) {
|
for (String s : list) {
|
||||||
if (result.length() != 0) result.append(separator);
|
if (result.length() != 0) {
|
||||||
|
result.append(separator);
|
||||||
|
}
|
||||||
result.append(s);
|
result.append(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,22 +242,24 @@ public class Util {
|
|||||||
* @throws Exception if there are no matches
|
* @throws Exception if there are no matches
|
||||||
*/
|
*/
|
||||||
public static Long getTime(String time) throws Exception {
|
public static Long getTime(String time) throws Exception {
|
||||||
if (time.equalsIgnoreCase("-1")) return -1L;
|
if (time.equalsIgnoreCase("-1")) {
|
||||||
|
return -1L;
|
||||||
|
}
|
||||||
|
|
||||||
long t;
|
long t;
|
||||||
Matcher match = DURATION_PATTERN.matcher(time);
|
Matcher match = DURATION_PATTERN.matcher(time);
|
||||||
|
|
||||||
if (match.matches()) {
|
if (match.matches()) {
|
||||||
String units = match.group(2);
|
String units = match.group(2);
|
||||||
if ("seconds".equals(units) || "second".equals(units) || "s".equals(units))
|
if ("seconds".equals(units) || "second".equals(units) || "s".equals(units)) {
|
||||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.SECONDS);
|
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.SECONDS);
|
||||||
else if ("minutes".equals(units) || "minute".equals(units) || "mins".equals(units) || "min".equals(units) || "m".equals(units))
|
} else if ("minutes".equals(units) || "minute".equals(units) || "mins".equals(units) || "min".equals(units) || "m".equals(units)) {
|
||||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.MINUTES);
|
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.MINUTES);
|
||||||
else if ("hours".equals(units) || "hour".equals(units) || "h".equals(units))
|
} else if ("hours".equals(units) || "hour".equals(units) || "h".equals(units)) {
|
||||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.HOURS);
|
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.HOURS);
|
||||||
else if ("days".equals(units) || "day".equals(units) || "d".equals(units))
|
} else if ("days".equals(units) || "day".equals(units) || "d".equals(units)) {
|
||||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.DAYS);
|
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(match.group(1)), TimeUnit.DAYS);
|
||||||
else {
|
} else {
|
||||||
try {
|
try {
|
||||||
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(time), TimeUnit.MINUTES);
|
t = TimeUnit.MILLISECONDS.convert(Long.parseLong(time), TimeUnit.MINUTES);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
@ -313,7 +321,9 @@ public class Util {
|
|||||||
* @throws Exception Throws an exception if there aren't exactly four lines.
|
* @throws Exception Throws an exception if there aren't exactly four lines.
|
||||||
*/
|
*/
|
||||||
public static void updateSignLinesCache(String[] lines) throws Exception {
|
public static void updateSignLinesCache(String[] lines) throws Exception {
|
||||||
if (lines.length != 4) throw new Exception("Exactly four lines are required for the signs.");
|
if (lines.length != 4) {
|
||||||
|
throw new Exception("Exactly four lines are required for the signs.");
|
||||||
|
}
|
||||||
signLines = lines;
|
signLines = lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -329,14 +339,19 @@ public class Util {
|
|||||||
public static List<String> getUnusedItems(List<String> items, String[] args, boolean useP) {
|
public static List<String> getUnusedItems(List<String> items, String[] args, boolean useP) {
|
||||||
List<String> used = new ArrayList<>();
|
List<String> used = new ArrayList<>();
|
||||||
for (String s : args)
|
for (String s : args)
|
||||||
if (s.contains("-"))
|
if (s.contains("-")) {
|
||||||
used.add(s.replace("-", ""));
|
used.add(s.replace("-", ""));
|
||||||
|
}
|
||||||
|
|
||||||
List<String> unused = new ArrayList<>();
|
List<String> unused = new ArrayList<>();
|
||||||
for (String t : items)
|
for (String t : items)
|
||||||
if (!used.contains(t)) //don't add it if it is already used
|
if (!used.contains(t)) //don't add it if it is already used
|
||||||
|
{
|
||||||
if (!t.equalsIgnoreCase("p") || (useP && t.equalsIgnoreCase("p")))//don't add -p unless otherwise stated
|
if (!t.equalsIgnoreCase("p") || (useP && t.equalsIgnoreCase("p")))//don't add -p unless otherwise stated
|
||||||
|
{
|
||||||
unused.add("-" + t);
|
unused.add("-" + t);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(unused);
|
Collections.sort(unused);
|
||||||
|
|
||||||
@ -423,7 +438,9 @@ public class Util {
|
|||||||
* @throws IOException if we were unable to parse the base64 string
|
* @throws IOException if we were unable to parse the base64 string
|
||||||
*/
|
*/
|
||||||
public static Inventory fromBase64(String data) throws IOException {
|
public static Inventory fromBase64(String data) throws IOException {
|
||||||
if (data.isEmpty()) return Bukkit.getServer().createInventory(null, 0);
|
if (data.isEmpty()) {
|
||||||
|
return Bukkit.getServer().createInventory(null, 0);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
|
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
|
||||||
@ -456,7 +473,9 @@ public class Util {
|
|||||||
* @throws IOException if we was unable to parse the base64 string
|
* @throws IOException if we was unable to parse the base64 string
|
||||||
*/
|
*/
|
||||||
public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
|
public static ItemStack[] itemStackArrayFromBase64(String data) throws IOException {
|
||||||
if (data.isEmpty()) return new ItemStack[]{};
|
if (data.isEmpty()) {
|
||||||
|
return new ItemStack[]{};
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
|
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64Coder.decodeLines(data));
|
||||||
@ -482,29 +501,33 @@ public class Util {
|
|||||||
|
|
||||||
for (ItemStack item : armor) {
|
for (ItemStack item : armor) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (item.getType().toString().toLowerCase().contains("helmet"))
|
if (item.getType().toString().toLowerCase().contains("helmet")) {
|
||||||
player.getInventory().setHelmet(item);
|
player.getInventory().setHelmet(item);
|
||||||
else if (item.getType().toString().toLowerCase().contains("chestplate"))
|
} else if (item.getType().toString().toLowerCase().contains("chestplate")) {
|
||||||
player.getInventory().setChestplate(item);
|
player.getInventory().setChestplate(item);
|
||||||
else if (item.getType().toString().toLowerCase().contains("leg"))
|
} else if (item.getType().toString().toLowerCase().contains("leg")) {
|
||||||
player.getInventory().setLeggings(item);
|
player.getInventory().setLeggings(item);
|
||||||
else if (item.getType().toString().toLowerCase().contains("boots"))
|
} else if (item.getType().toString().toLowerCase().contains("boots")) {
|
||||||
player.getInventory().setBoots(item);
|
player.getInventory().setBoots(item);
|
||||||
else if (player.getInventory().firstEmpty() == -1)
|
} else if (player.getInventory().firstEmpty() == -1) {
|
||||||
player.getWorld().dropItem(player.getLocation(), item);
|
player.getWorld().dropItem(player.getLocation(), item);
|
||||||
else
|
} else {
|
||||||
player.getInventory().addItem(item);
|
player.getInventory().addItem(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (ItemStack item : content.getContents()) {
|
for (ItemStack item : content.getContents()) {
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else if (player.getInventory().firstEmpty() == -1)
|
if (player.getInventory().firstEmpty() == -1) {
|
||||||
player.getWorld().dropItem(player.getLocation(), item);
|
player.getWorld().dropItem(player.getLocation(), item);
|
||||||
else
|
} else {
|
||||||
player.getInventory().addItem(item);
|
player.getInventory().addItem(item);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Bukkit.getLogger().severe("Unable to restore " + player.getName() + "'s inventory.");
|
Bukkit.getLogger().severe("Unable to restore " + player.getName() + "'s inventory.");
|
||||||
|
@ -23,7 +23,8 @@ import java.util.List;
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class Cell implements ICell {
|
public class Cell implements ICell {
|
||||||
private final int databaseid;
|
|
||||||
|
private final int databaseId;
|
||||||
private final String name;
|
private final String name;
|
||||||
private Prisoner p;
|
private Prisoner p;
|
||||||
private final HashSet<SimpleLocation> signs;
|
private final HashSet<SimpleLocation> signs;
|
||||||
@ -36,7 +37,7 @@ public class Cell implements ICell {
|
|||||||
* @param name The name of the cell.
|
* @param name The name of the cell.
|
||||||
*/
|
*/
|
||||||
public Cell(String name) {
|
public Cell(String name) {
|
||||||
this.databaseid = -1;
|
this.databaseId = -1;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.signs = new HashSet<>();
|
this.signs = new HashSet<>();
|
||||||
this.changed = false;
|
this.changed = false;
|
||||||
@ -49,14 +50,14 @@ public class Cell implements ICell {
|
|||||||
* @param name The name of the cell.
|
* @param name The name of the cell.
|
||||||
*/
|
*/
|
||||||
public Cell(int id, String name) {
|
public Cell(int id, String name) {
|
||||||
this.databaseid = id;
|
this.databaseId = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.signs = new HashSet<>();
|
this.signs = new HashSet<>();
|
||||||
this.changed = false;
|
this.changed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDatabaseID() {
|
public int getDatabaseID() {
|
||||||
return this.databaseid;
|
return this.databaseId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
@ -117,10 +118,9 @@ public class Cell implements ICell {
|
|||||||
List<String> invalid = new ArrayList<>();
|
List<String> invalid = new ArrayList<>();
|
||||||
|
|
||||||
for (SimpleLocation s : new HashSet<>(signs))
|
for (SimpleLocation s : new HashSet<>(signs))
|
||||||
if (s.getLocation().getBlock().getState() instanceof Sign) {
|
if (!(s.getLocation().getBlock().getState() instanceof Sign)) {
|
||||||
}
|
|
||||||
else
|
|
||||||
invalid.add(s.toString());
|
invalid.add(s.toString());
|
||||||
|
}
|
||||||
|
|
||||||
return invalid;
|
return invalid;
|
||||||
}
|
}
|
||||||
@ -129,8 +129,7 @@ public class Cell implements ICell {
|
|||||||
List<String> cleaned = new ArrayList<>();
|
List<String> cleaned = new ArrayList<>();
|
||||||
|
|
||||||
for (SimpleLocation s : new HashSet<>(signs)) {
|
for (SimpleLocation s : new HashSet<>(signs)) {
|
||||||
if (s.getLocation().getBlock().getState() instanceof Sign) {
|
if (!(s.getLocation().getBlock().getState() instanceof Sign)) {
|
||||||
} else {
|
|
||||||
changed = true;
|
changed = true;
|
||||||
signs.remove(s);
|
signs.remove(s);
|
||||||
cleaned.add(s.toString());
|
cleaned.add(s.toString());
|
||||||
@ -147,8 +146,7 @@ public class Cell implements ICell {
|
|||||||
for (SimpleLocation s : new HashSet<>(signs)) {
|
for (SimpleLocation s : new HashSet<>(signs)) {
|
||||||
BlockState bs = s.getLocation().getBlock().getState();
|
BlockState bs = s.getLocation().getBlock().getState();
|
||||||
|
|
||||||
if (bs instanceof Sign) {
|
if (bs instanceof Sign sign) {
|
||||||
Sign sign = (Sign) bs;
|
|
||||||
|
|
||||||
if (hasPrisoner()) {
|
if (hasPrisoner()) {
|
||||||
String[] lines = Util.replaceAllVariables(p, Util.getSignLines());
|
String[] lines = Util.replaceAllVariables(p, Util.getSignLines());
|
||||||
@ -157,14 +155,13 @@ public class Cell implements ICell {
|
|||||||
sign.setLine(1, lines[1]);
|
sign.setLine(1, lines[1]);
|
||||||
sign.setLine(2, lines[2]);
|
sign.setLine(2, lines[2]);
|
||||||
sign.setLine(3, lines[3]);
|
sign.setLine(3, lines[3]);
|
||||||
sign.update(true, false);
|
|
||||||
} else {
|
} else {
|
||||||
sign.setLine(0, "");
|
sign.setLine(0, "");
|
||||||
sign.setLine(1, Lang.CELLEMPTYSIGN.get());
|
sign.setLine(1, Lang.CELLEMPTYSIGN.get());
|
||||||
sign.setLine(2, "");
|
sign.setLine(2, "");
|
||||||
sign.setLine(3, "");
|
sign.setLine(3, "");
|
||||||
sign.update(true, false);
|
|
||||||
}
|
}
|
||||||
|
sign.update(true, false);
|
||||||
|
|
||||||
updated.add(s.toString());
|
updated.add(s.toString());
|
||||||
} else {
|
} else {
|
||||||
@ -200,10 +197,14 @@ public class Cell implements ICell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Chest getChest() {
|
public Chest getChest() {
|
||||||
if (this.chest == null) return null;
|
if (this.chest == null) {
|
||||||
if (this.chest.getLocation().getBlock() == null
|
return null;
|
||||||
|| (this.chest.getLocation().getBlock().getType() != Material.CHEST
|
}
|
||||||
&& this.chest.getLocation().getBlock().getType() != Material.TRAPPED_CHEST)) return null;
|
this.chest.getLocation().getBlock();
|
||||||
|
if (this.chest.getLocation().getBlock().getType() != Material.CHEST &&
|
||||||
|
this.chest.getLocation().getBlock().getType() != Material.TRAPPED_CHEST) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return (Chest) this.chest.getLocation().getBlock().getState();
|
return (Chest) this.chest.getLocation().getBlock().getState();
|
||||||
}
|
}
|
||||||
@ -211,15 +212,16 @@ public class Cell implements ICell {
|
|||||||
public boolean hasChest() {
|
public boolean hasChest() {
|
||||||
Chest c = getChest();
|
Chest c = getChest();
|
||||||
if (c != null) {
|
if (c != null) {
|
||||||
if (c.getInventory().getSize() >= 40)
|
if (c.getInventory().getSize() >= 40) {
|
||||||
return true;
|
return true;
|
||||||
else {
|
} else {
|
||||||
Bukkit.getLogger().severe("The cell " + this.name + " has chest that isn't a double chest, please fix.");
|
Bukkit.getLogger().severe("The cell " + this.name + " has chest that isn't a double chest, please fix.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean useChest() {
|
public boolean useChest() {
|
||||||
return this.chest != null;
|
return this.chest != null;
|
||||||
|
@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an instance of a player creating something, whether it be a jail or cell.
|
* Represents an instance of a player creating something, whether it be a jail or cell.
|
||||||
@ -184,7 +185,7 @@ public class CreationPlayer {
|
|||||||
* @param location the in location
|
* @param location the in location
|
||||||
*/
|
*/
|
||||||
public void setTeleportIn(Location location) {
|
public void setTeleportIn(Location location) {
|
||||||
this.inWorld = location.getWorld().getName();
|
this.inWorld = Objects.requireNonNull(location.getWorld()).getName();
|
||||||
this.inX = location.getX();
|
this.inX = location.getX();
|
||||||
this.inY = location.getY();
|
this.inY = location.getY();
|
||||||
this.inZ = location.getZ();
|
this.inZ = location.getZ();
|
||||||
@ -235,7 +236,7 @@ public class CreationPlayer {
|
|||||||
* @param location Sets the teleport free {@link Location}
|
* @param location Sets the teleport free {@link Location}
|
||||||
*/
|
*/
|
||||||
public void setTeleportFree(Location location) {
|
public void setTeleportFree(Location location) {
|
||||||
this.freeWorld = location.getWorld().getName();
|
this.freeWorld = Objects.requireNonNull(location.getWorld()).getName();
|
||||||
this.freeX = location.getX();
|
this.freeX = location.getX();
|
||||||
this.freeY = location.getY();
|
this.freeY = location.getY();
|
||||||
this.freeZ = location.getZ();
|
this.freeZ = location.getZ();
|
||||||
|
@ -87,7 +87,9 @@ public class Jail {
|
|||||||
* @param location the {@link Location} of the lowest point
|
* @param location the {@link Location} of the lowest point
|
||||||
*/
|
*/
|
||||||
public void setMinPoint(Location location) {
|
public void setMinPoint(Location location) {
|
||||||
if (this.world.isEmpty()) this.world = location.getWorld().getName();
|
if (this.world.isEmpty()) {
|
||||||
|
this.world = location.getWorld().getName();
|
||||||
|
}
|
||||||
|
|
||||||
this.minX = location.getBlockX();
|
this.minX = location.getBlockX();
|
||||||
this.minY = location.getBlockY();
|
this.minY = location.getBlockY();
|
||||||
@ -100,7 +102,9 @@ public class Jail {
|
|||||||
* @param coords the coordinates of the minimum point
|
* @param coords the coordinates of the minimum point
|
||||||
*/
|
*/
|
||||||
public void setMinPoint(int[] coords) {
|
public void setMinPoint(int[] coords) {
|
||||||
if (coords.length != 3) return;
|
if (coords.length != 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.minX = coords[0];
|
this.minX = coords[0];
|
||||||
this.minY = coords[1];
|
this.minY = coords[1];
|
||||||
@ -122,7 +126,9 @@ public class Jail {
|
|||||||
* @param location the {@link Location} of the maximum point
|
* @param location the {@link Location} of the maximum point
|
||||||
*/
|
*/
|
||||||
public void setMaxPoint(Location location) {
|
public void setMaxPoint(Location location) {
|
||||||
if (this.world.isEmpty()) this.world = location.getWorld().getName();
|
if (this.world.isEmpty()) {
|
||||||
|
this.world = location.getWorld().getName();
|
||||||
|
}
|
||||||
|
|
||||||
this.maxX = location.getBlockX();
|
this.maxX = location.getBlockX();
|
||||||
this.maxY = location.getBlockY();
|
this.maxY = location.getBlockY();
|
||||||
@ -142,7 +148,9 @@ public class Jail {
|
|||||||
* Accepts an array of ints as the coord, where <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong>.
|
* Accepts an array of ints as the coord, where <strong>0 = x</strong>, <strong>1 = y</strong>, <strong>2 = z</strong>.
|
||||||
*/
|
*/
|
||||||
public void setMaxPoint(int[] coords) {
|
public void setMaxPoint(int[] coords) {
|
||||||
if (coords.length != 3) return;
|
if (coords.length != 3) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.maxX = coords[0];
|
this.maxX = coords[0];
|
||||||
this.maxY = coords[1];
|
this.maxY = coords[1];
|
||||||
@ -174,7 +182,9 @@ public class Jail {
|
|||||||
* Sets the {@link Location location} of the teleport <strong>in</strong>.
|
* Sets the {@link Location location} of the teleport <strong>in</strong>.
|
||||||
*/
|
*/
|
||||||
public void setTeleportIn(Location location) {
|
public void setTeleportIn(Location location) {
|
||||||
if (this.world.isEmpty()) this.world = location.getWorld().getName();
|
if (this.world.isEmpty()) {
|
||||||
|
this.world = location.getWorld().getName();
|
||||||
|
}
|
||||||
|
|
||||||
this.in = location;
|
this.in = location;
|
||||||
}
|
}
|
||||||
@ -225,11 +235,16 @@ public class Jail {
|
|||||||
* Adds a cell to the Jail.
|
* Adds a cell to the Jail.
|
||||||
*/
|
*/
|
||||||
public boolean addCell(Cell cell, boolean save) {
|
public boolean addCell(Cell cell, boolean save) {
|
||||||
if (save) plugin.getJailIO().saveCell(this, cell, false);
|
if (save) {
|
||||||
|
plugin.getJailIO().saveCell(this, cell, false);
|
||||||
|
}
|
||||||
|
|
||||||
//Check if it already exists or not
|
//Check if it already exists or not
|
||||||
if (this.cells.containsKey(cell.getName())) return false;
|
if (this.cells.containsKey(cell.getName())) {
|
||||||
else this.cells.put(cell.getName(), cell);
|
return false;
|
||||||
|
} else {
|
||||||
|
this.cells.put(cell.getName(), cell);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,9 +293,11 @@ public class Jail {
|
|||||||
*/
|
*/
|
||||||
public Cell getCellPrisonerIsIn(UUID uuid) {
|
public Cell getCellPrisonerIsIn(UUID uuid) {
|
||||||
for (Cell c : cells.values())
|
for (Cell c : cells.values())
|
||||||
if (c.hasPrisoner())
|
if (c.hasPrisoner()) {
|
||||||
if (c.getPrisoner().getUUID().equals(uuid))
|
if (c.getPrisoner().getUUID().equals(uuid)) {
|
||||||
return c;
|
return c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -289,11 +306,10 @@ public class Jail {
|
|||||||
* Returns the first empty cell, returns null if there aren't any cells or any free cells.
|
* Returns the first empty cell, returns null if there aren't any cells or any free cells.
|
||||||
*/
|
*/
|
||||||
public Cell getFirstEmptyCell() {
|
public Cell getFirstEmptyCell() {
|
||||||
for (Cell c : getCells())
|
for (Cell cell : getCells())
|
||||||
if (c.hasPrisoner()) {
|
if (!cell.hasPrisoner()) {
|
||||||
|
return cell;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return c;
|
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -303,8 +319,9 @@ public class Jail {
|
|||||||
*/
|
*/
|
||||||
public boolean hasEmptyCell() {
|
public boolean hasEmptyCell() {
|
||||||
for (Cell c : getCells())
|
for (Cell c : getCells())
|
||||||
if (!c.hasPrisoner())
|
if (!c.hasPrisoner()) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -369,8 +386,9 @@ public class Jail {
|
|||||||
HashMap<UUID, Prisoner> all = new HashMap<>(nocellPrisoners); //initalize the temp one to return with the prisoners not in any cells
|
HashMap<UUID, Prisoner> all = new HashMap<>(nocellPrisoners); //initalize the temp one to return with the prisoners not in any cells
|
||||||
|
|
||||||
for (Cell c : cells.values())
|
for (Cell c : cells.values())
|
||||||
if (c.hasPrisoner())
|
if (c.hasPrisoner()) {
|
||||||
all.put(c.getPrisoner().getUUID(), c.getPrisoner());
|
all.put(c.getPrisoner().getUUID(), c.getPrisoner());
|
||||||
|
}
|
||||||
|
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
@ -382,8 +400,9 @@ public class Jail {
|
|||||||
HashSet<Prisoner> all = new HashSet<>();
|
HashSet<Prisoner> all = new HashSet<>();
|
||||||
|
|
||||||
for (Cell c : getCells())
|
for (Cell c : getCells())
|
||||||
if (c.hasPrisoner())
|
if (c.hasPrisoner()) {
|
||||||
all.add(c.getPrisoner());
|
all.add(c.getPrisoner());
|
||||||
|
}
|
||||||
|
|
||||||
return all;
|
return all;
|
||||||
}
|
}
|
||||||
@ -432,12 +451,16 @@ public class Jail {
|
|||||||
* @return true if is jailed in a cell, false if not.
|
* @return true if is jailed in a cell, false if not.
|
||||||
*/
|
*/
|
||||||
public boolean isJailedInACell(UUID uuid) {
|
public boolean isJailedInACell(UUID uuid) {
|
||||||
if (this.nocellPrisoners.containsKey(uuid)) return false;
|
if (this.nocellPrisoners.containsKey(uuid)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (Cell c : cells.values())
|
for (Cell c : cells.values())
|
||||||
if (c.getPrisoner() != null)
|
if (c.getPrisoner() != null) {
|
||||||
if (c.getPrisoner().getUUID().equals(uuid))
|
if (c.getPrisoner().getUUID().equals(uuid)) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -450,8 +473,9 @@ public class Jail {
|
|||||||
*/
|
*/
|
||||||
public Prisoner getPrisonerByLastKnownName(String name) {
|
public Prisoner getPrisonerByLastKnownName(String name) {
|
||||||
for (Prisoner p : this.getAllPrisoners().values())
|
for (Prisoner p : this.getAllPrisoners().values())
|
||||||
if (p.getLastKnownName().equalsIgnoreCase(name))
|
if (p.getLastKnownName().equalsIgnoreCase(name)) {
|
||||||
return p;
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -463,12 +487,16 @@ public class Jail {
|
|||||||
* @return the prisoner instance, can be null
|
* @return the prisoner instance, can be null
|
||||||
*/
|
*/
|
||||||
public Prisoner getPrisoner(UUID uuid) {
|
public Prisoner getPrisoner(UUID uuid) {
|
||||||
if (this.nocellPrisoners.containsKey(uuid)) return this.nocellPrisoners.get(uuid);
|
if (this.nocellPrisoners.containsKey(uuid)) {
|
||||||
|
return this.nocellPrisoners.get(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
for (Cell c : cells.values())
|
for (Cell c : cells.values())
|
||||||
if (c.hasPrisoner())
|
if (c.hasPrisoner()) {
|
||||||
if (c.getPrisoner().getUUID().equals(uuid))
|
if (c.getPrisoner().getUUID().equals(uuid)) {
|
||||||
return c.getPrisoner();
|
return c.getPrisoner();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -482,8 +510,11 @@ public class Jail {
|
|||||||
* @return Distance between the location provided and the teleport in location.
|
* @return Distance between the location provided and the teleport in location.
|
||||||
*/
|
*/
|
||||||
public double getDistance(Location loc) {
|
public double getDistance(Location loc) {
|
||||||
if (!loc.getWorld().getName().equalsIgnoreCase(getTeleportIn().getWorld().getName())) return Integer.MAX_VALUE;
|
if (!loc.getWorld().getName().equalsIgnoreCase(getTeleportIn().getWorld().getName())) {
|
||||||
else return loc.distance(getTeleportIn());
|
return Integer.MAX_VALUE;
|
||||||
|
} else {
|
||||||
|
return loc.distance(getTeleportIn());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,16 +164,21 @@ public class Prisoner {
|
|||||||
* Finishes the setup of the prisoner data, set to defaults.
|
* Finishes the setup of the prisoner data, set to defaults.
|
||||||
*/
|
*/
|
||||||
private void finishSetup() {
|
private void finishSetup() {
|
||||||
if (jailer == null)
|
if (jailer == null) {
|
||||||
jailer = Lang.DEFAULTJAILER.get();
|
jailer = Lang.DEFAULTJAILER.get();
|
||||||
if (reason == null)
|
}
|
||||||
|
if (reason == null) {
|
||||||
Lang.DEFAULTJAILEDREASON.get();
|
Lang.DEFAULTJAILEDREASON.get();
|
||||||
if (inventory == null)
|
}
|
||||||
|
if (inventory == null) {
|
||||||
inventory = "";
|
inventory = "";
|
||||||
if (armor == null)
|
}
|
||||||
|
if (armor == null) {
|
||||||
armor = "";
|
armor = "";
|
||||||
if (previousGameMode == null)
|
}
|
||||||
|
if (previousGameMode == null) {
|
||||||
previousGameMode = GameMode.SURVIVAL;
|
previousGameMode = GameMode.SURVIVAL;
|
||||||
|
}
|
||||||
previousPosition = null;
|
previousPosition = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -372,15 +377,19 @@ public class Prisoner {
|
|||||||
* Gets the previous location of this player, separated by a comma.
|
* Gets the previous location of this player, separated by a comma.
|
||||||
*/
|
*/
|
||||||
public String getPreviousLocationString() {
|
public String getPreviousLocationString() {
|
||||||
if (previousPosition == null) return "";
|
if (previousPosition == null) {
|
||||||
else if (previousPosition.getWorld() == null) return "";
|
return "";
|
||||||
else return previousPosition.getWorld().getName() + "," +
|
} else if (previousPosition.getWorld() == null) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
return previousPosition.getWorld().getName() + "," +
|
||||||
previousPosition.getX() + "," +
|
previousPosition.getX() + "," +
|
||||||
previousPosition.getY() + "," +
|
previousPosition.getY() + "," +
|
||||||
previousPosition.getZ() + "," +
|
previousPosition.getZ() + "," +
|
||||||
previousPosition.getYaw() + "," +
|
previousPosition.getYaw() + "," +
|
||||||
previousPosition.getPitch();
|
previousPosition.getPitch();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the previous location of this player.
|
* Sets the previous location of this player.
|
||||||
@ -393,8 +402,12 @@ public class Prisoner {
|
|||||||
* Sets the previous location of this player from a comma separated string.
|
* Sets the previous location of this player from a comma separated string.
|
||||||
*/
|
*/
|
||||||
public void setPreviousPosition(String location) {
|
public void setPreviousPosition(String location) {
|
||||||
if (location == null) return;
|
if (location == null) {
|
||||||
if (location.isEmpty()) return;
|
return;
|
||||||
|
}
|
||||||
|
if (location.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.changed = true;
|
this.changed = true;
|
||||||
String[] s = location.split(",");
|
String[] s = location.split(",");
|
||||||
@ -425,9 +438,13 @@ public class Prisoner {
|
|||||||
* Sets the previous gamemode of this player based upon the provided string.
|
* Sets the previous gamemode of this player based upon the provided string.
|
||||||
*/
|
*/
|
||||||
public void setPreviousGameMode(String previous) {
|
public void setPreviousGameMode(String previous) {
|
||||||
if (previous == null) return;
|
if (previous == null) {
|
||||||
else if (previous.isEmpty()) return;
|
return;
|
||||||
else this.previousGameMode = GameMode.valueOf(previous);
|
} else if (previous.isEmpty()) {
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
this.previousGameMode = GameMode.valueOf(previous);
|
||||||
|
}
|
||||||
this.changed = true;
|
this.changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,19 +38,26 @@ public class CommandHandler {
|
|||||||
public List<String> parseTabComplete(JailManager jm, CommandSender sender, String commandLine, String[] args) {
|
public List<String> parseTabComplete(JailManager jm, CommandSender sender, String commandLine, String[] args) {
|
||||||
List<Command> matches = getMatches(commandLine);
|
List<Command> matches = getMatches(commandLine);
|
||||||
|
|
||||||
if (matches.size() != 1) return Collections.emptyList();
|
if (matches.size() != 1) {
|
||||||
else {
|
return Collections.emptyList();
|
||||||
|
} else {
|
||||||
CommandInfo i = matches.get(0).getClass().getAnnotation(CommandInfo.class);
|
CommandInfo i = matches.get(0).getClass().getAnnotation(CommandInfo.class);
|
||||||
|
|
||||||
//Sender provided too many arguments which means there
|
//Sender provided too many arguments which means there
|
||||||
//is nothing to tab complete
|
//is nothing to tab complete
|
||||||
if (i.maxArgs() != -1 && i.maxArgs() < args.length) return Collections.emptyList();
|
if (i.maxArgs() != -1 && i.maxArgs() < args.length) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
//Don't return anything if a player is required and they're not a player
|
//Don't return anything if a player is required and they're not a player
|
||||||
if (i.needsPlayer() && !(sender instanceof Player)) return Collections.emptyList();
|
if (i.needsPlayer() && !(sender instanceof Player)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
//Don't return anything if they don't have permission
|
//Don't return anything if they don't have permission
|
||||||
if (!sender.hasPermission(i.permission())) return Collections.emptyList();
|
if (!sender.hasPermission(i.permission())) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
//Let the command handle the rest of it
|
//Let the command handle the rest of it
|
||||||
return matches.get(0).provideTabCompletions(jm, sender, args);
|
return matches.get(0).provideTabCompletions(jm, sender, args);
|
||||||
@ -73,12 +80,12 @@ public class CommandHandler {
|
|||||||
* <li>Then executes, upon failed execution it sends the usage command.</li>
|
* <li>Then executes, upon failed execution it sends the usage command.</li>
|
||||||
* </ol>
|
* </ol>
|
||||||
*
|
*
|
||||||
* @param jailmanager The instance of {@link JailManager}.
|
* @param jailManager The instance of {@link JailManager}.
|
||||||
* @param sender The sender of the command.
|
* @param sender The sender of the command.
|
||||||
* @param commandLine The name of the command.
|
* @param commandLine The name of the command.
|
||||||
* @param args The arguments passed to the command.
|
* @param args The arguments passed to the command.
|
||||||
*/
|
*/
|
||||||
public void handleCommand(JailManager jailmanager, CommandSender sender, String commandLine, String[] args) {
|
public void handleCommand(JailManager jailManager, CommandSender sender, String commandLine, String[] args) {
|
||||||
List<Command> matches = getMatches(commandLine);
|
List<Command> matches = getMatches(commandLine);
|
||||||
|
|
||||||
//If no matches were found, send them the unknown command message.
|
//If no matches were found, send them the unknown command message.
|
||||||
@ -90,9 +97,10 @@ public class CommandHandler {
|
|||||||
ArrayList<String> args2 = new ArrayList<>(Arrays.asList(args));
|
ArrayList<String> args2 = new ArrayList<>(Arrays.asList(args));
|
||||||
args2.add(a0);
|
args2.add(a0);
|
||||||
|
|
||||||
if (jailmanager.getPlugin().onCommand(sender, null, j, args2.toArray(new String[0])))
|
if (jailManager.getPlugin().onCommand(sender, null, j, args2.toArray(new String[0]))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sender.sendMessage(Lang.UNKNOWNCOMMAND.get(commandLine));
|
sender.sendMessage(Lang.UNKNOWNCOMMAND.get(commandLine));
|
||||||
return;
|
return;
|
||||||
@ -135,12 +143,12 @@ public class CommandHandler {
|
|||||||
// Since everything has been checked and we're all clear, let's execute it.
|
// Since everything has been checked and we're all clear, let's execute it.
|
||||||
// But if get back false, let's show the usage message.
|
// But if get back false, let's show the usage message.
|
||||||
try {
|
try {
|
||||||
if (!c.execute(jailmanager, sender, args)) {
|
if (!c.execute(jailManager, sender, args)) {
|
||||||
showUsage(sender, c);
|
showUsage(sender, c);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
jailmanager.getPlugin().getLogger().severe("An error occured while handling the command: " + i.usage());
|
jailManager.getPlugin().getLogger().severe("An error occured while handling the command: " + i.usage());
|
||||||
showUsage(sender, c);
|
showUsage(sender, c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,7 +173,9 @@ public class CommandHandler {
|
|||||||
*/
|
*/
|
||||||
private void showUsage(CommandSender sender, Command command) {
|
private void showUsage(CommandSender sender, Command command) {
|
||||||
CommandInfo info = command.getClass().getAnnotation(CommandInfo.class);
|
CommandInfo info = command.getClass().getAnnotation(CommandInfo.class);
|
||||||
if (!sender.hasPermission(info.permission())) return;
|
if (!sender.hasPermission(info.permission())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sender.sendMessage(info.usage());
|
sender.sendMessage(info.usage());
|
||||||
}
|
}
|
||||||
@ -183,7 +193,9 @@ public class CommandHandler {
|
|||||||
|
|
||||||
private void load(Class<? extends Command> c) {
|
private void load(Class<? extends Command> c) {
|
||||||
CommandInfo info = c.getAnnotation(CommandInfo.class);
|
CommandInfo info = c.getAnnotation(CommandInfo.class);
|
||||||
if (info == null) return;
|
if (info == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
commands.put(info.pattern(), c.newInstance());
|
commands.put(info.pattern(), c.newInstance());
|
||||||
|
@ -71,7 +71,9 @@ public class JailHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Skip if the command requires a player and the sender isn't a player
|
//Skip if the command requires a player and the sender isn't a player
|
||||||
if (i.needsPlayer() && !(sender instanceof Player)) continue;
|
if (i.needsPlayer() && !(sender instanceof Player)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//If the sender has permission to the command
|
//If the sender has permission to the command
|
||||||
//and the first argument (sub command) is empty OR
|
//and the first argument (sub command) is empty OR
|
||||||
@ -86,10 +88,11 @@ public class JailHandler {
|
|||||||
|
|
||||||
//If the results doesn't contain anything and they have permission to jail someone
|
//If the results doesn't contain anything and they have permission to jail someone
|
||||||
//then send let the jail command provide the tab completion
|
//then send let the jail command provide the tab completion
|
||||||
if (results.isEmpty() && hasJailPermission)
|
if (results.isEmpty() && hasJailPermission) {
|
||||||
return getMatches("jail").get(0).provideTabCompletions(jm, sender, args);
|
return getMatches("jail").get(0).provideTabCompletions(jm, sender, args);
|
||||||
else
|
} else {
|
||||||
return results;
|
return results;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
String arg0 = args[0].toLowerCase();
|
String arg0 = args[0].toLowerCase();
|
||||||
boolean hasJailPermission = false;
|
boolean hasJailPermission = false;
|
||||||
@ -105,17 +108,25 @@ public class JailHandler {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!arg0.toLowerCase().matches(i.pattern())) continue;
|
if (!arg0.toLowerCase().matches(i.pattern())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//Sender provided too many arguments which means there
|
//Sender provided too many arguments which means there
|
||||||
//is nothing to tab complete
|
//is nothing to tab complete
|
||||||
if (i.maxArgs() != -1 && i.maxArgs() < args.length - 1) continue;
|
if (i.maxArgs() != -1 && i.maxArgs() < args.length - 1) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//Skip if the command requires a player and the sender isn't a player
|
//Skip if the command requires a player and the sender isn't a player
|
||||||
if (i.needsPlayer() && !(sender instanceof Player)) continue;
|
if (i.needsPlayer() && !(sender instanceof Player)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
//If the sender doesn't have permission, we won't send them further
|
//If the sender doesn't have permission, we won't send them further
|
||||||
if (!sender.hasPermission(i.permission())) continue;
|
if (!sender.hasPermission(i.permission())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
return c.provideTabCompletions(jm, sender, args);
|
return c.provideTabCompletions(jm, sender, args);
|
||||||
}
|
}
|
||||||
@ -123,9 +134,10 @@ public class JailHandler {
|
|||||||
//By the time it has reached here no other command matched
|
//By the time it has reached here no other command matched
|
||||||
//which means they are probably jailing someone, or trying to
|
//which means they are probably jailing someone, or trying to
|
||||||
//so let's check permission first and go from there.
|
//so let's check permission first and go from there.
|
||||||
if (hasJailPermission)
|
if (hasJailPermission) {
|
||||||
return getMatches("jail").get(0).provideTabCompletions(jm, sender, args);
|
return getMatches("jail").get(0).provideTabCompletions(jm, sender, args);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@ -149,12 +161,12 @@ public class JailHandler {
|
|||||||
* @param args The arguments passed to the command.
|
* @param args The arguments passed to the command.
|
||||||
*/
|
*/
|
||||||
public boolean parseCommand(JailManager jailmanager, CommandSender sender, String[] args) {
|
public boolean parseCommand(JailManager jailmanager, CommandSender sender, String[] args) {
|
||||||
Command c;
|
Command command;
|
||||||
|
|
||||||
//If they didn't provide any arguments (aka just: /jail) then we will need to send them some help
|
//If they didn't provide any arguments (aka just: /jail) then we will need to send them some help
|
||||||
if (args.length == 0) {
|
if (args.length == 0) {
|
||||||
//TODO: Create the help page(s)
|
//TODO: Create the help page(s)
|
||||||
c = getMatches("jail").get(0);
|
command = getMatches("jail").get(0);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//Get the matches from the first argument passed
|
//Get the matches from the first argument passed
|
||||||
@ -162,7 +174,7 @@ public class JailHandler {
|
|||||||
|
|
||||||
if (matches.isEmpty()) {
|
if (matches.isEmpty()) {
|
||||||
//No matches found, thus it is more likely than not they are trying to jail someone
|
//No matches found, thus it is more likely than not they are trying to jail someone
|
||||||
c = getMatches("jail").get(0);
|
command = getMatches("jail").get(0);
|
||||||
|
|
||||||
} else if (matches.size() > 1) {
|
} else if (matches.size() > 1) {
|
||||||
//If there was found more than one match
|
//If there was found more than one match
|
||||||
@ -173,21 +185,21 @@ public class JailHandler {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
//Only one match was found, so let's continue
|
//Only one match was found, so let's continue
|
||||||
c = matches.get(0);
|
command = matches.get(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandInfo i = c.getClass().getAnnotation(CommandInfo.class);
|
CommandInfo commandInfo = command.getClass().getAnnotation(CommandInfo.class);
|
||||||
|
|
||||||
// First, let's check if the sender has permission for the command.
|
// First, let's check if the sender has permission for the command.
|
||||||
if (!i.permission().isEmpty() && !sender.hasPermission(i.permission())) {
|
if (!commandInfo.permission().isEmpty() && !sender.hasPermission(commandInfo.permission())) {
|
||||||
jailmanager.getPlugin().debug("Sender has no permission: " + i.permission());
|
jailmanager.getPlugin().debug("Sender has no permission: " + commandInfo.permission());
|
||||||
sender.sendMessage(Lang.NOPERMISSION.get() + (jailmanager.getPlugin().inDebug() ? " (" + i.permission() + ")" : ""));
|
sender.sendMessage(Lang.NOPERMISSION.get() + (jailmanager.getPlugin().inDebug() ? " (" + commandInfo.permission() + ")" : ""));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next, let's check if we need a player and then if the sender is actually a player
|
// Next, let's check if we need a player and then if the sender is actually a player
|
||||||
if (i.needsPlayer() && !(sender instanceof Player)) {
|
if (commandInfo.needsPlayer() && !(sender instanceof Player)) {
|
||||||
jailmanager.getPlugin().debug("Sender is not a player.");
|
jailmanager.getPlugin().debug("Sender is not a player.");
|
||||||
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
sender.sendMessage(Lang.PLAYERCONTEXTREQUIRED.get());
|
||||||
return true;
|
return true;
|
||||||
@ -195,36 +207,34 @@ public class JailHandler {
|
|||||||
|
|
||||||
// Now, let's check the size of the arguments passed. If it is shorter than the minimum required args, let's show the usage.
|
// Now, let's check the size of the arguments passed. If it is shorter than the minimum required args, let's show the usage.
|
||||||
// The reason we are subtracting one is because the command is now `/jail <subcommand>` and the subcommand is viewed as an argument
|
// The reason we are subtracting one is because the command is now `/jail <subcommand>` and the subcommand is viewed as an argument
|
||||||
if (args.length - 1 < i.minimumArgs()) {
|
if (args.length - 1 < commandInfo.minimumArgs()) {
|
||||||
jailmanager.getPlugin().debug("Sender didn't provide enough arguments.");
|
jailmanager.getPlugin().debug("Sender didn't provide enough arguments.");
|
||||||
showUsage(sender, c);
|
showUsage(sender, command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Then, if the maximumArgs doesn't equal -1, we need to check if the size of the arguments passed is greater than the maximum args.
|
// Then, if the maximumArgs doesn't equal -1, we need to check if the size of the arguments passed is greater than the maximum args.
|
||||||
// The reason we are subtracting one is because the command is now `/jail <subcommand>` and the subcommand is viewed as an argument
|
// The reason we are subtracting one is because the command is now `/jail <subcommand>` and the subcommand is viewed as an argument
|
||||||
if (i.maxArgs() != -1 && i.maxArgs() < args.length - 1) {
|
if (commandInfo.maxArgs() != -1 && commandInfo.maxArgs() < args.length - 1) {
|
||||||
jailmanager.getPlugin().debug("Sender provided too many arguments.");
|
jailmanager.getPlugin().debug("Sender provided too many arguments.");
|
||||||
showUsage(sender, c);
|
showUsage(sender, command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Since everything has been checked and we're all clear, let's execute it.
|
// Since everything has been checked and we're all clear, let's execute it.
|
||||||
// But if get back false, let's show the usage message.
|
// But if get back false, let's show the usage message.
|
||||||
try {
|
try {
|
||||||
if (!c.execute(jailmanager, sender, args)) {
|
if (!command.execute(jailmanager, sender, args)) {
|
||||||
showUsage(sender, c);
|
showUsage(sender, command);
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (jailmanager.getPlugin().inDebug()) {
|
if (jailmanager.getPlugin().inDebug()) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
jailmanager.getPlugin().getLogger().severe("An error occured while handling the command: " + i.usage());
|
jailmanager.getPlugin().getLogger().severe("An error occured while handling the command: " + commandInfo.usage());
|
||||||
showUsage(sender, c);
|
showUsage(sender, command);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -249,7 +259,9 @@ public class JailHandler {
|
|||||||
*/
|
*/
|
||||||
private void showUsage(CommandSender sender, Command command) {
|
private void showUsage(CommandSender sender, Command command) {
|
||||||
CommandInfo info = command.getClass().getAnnotation(CommandInfo.class);
|
CommandInfo info = command.getClass().getAnnotation(CommandInfo.class);
|
||||||
if (!sender.hasPermission(info.permission())) return;
|
if (!sender.hasPermission(info.permission())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
sender.sendMessage(info.usage());
|
sender.sendMessage(info.usage());
|
||||||
}
|
}
|
||||||
@ -286,7 +298,9 @@ public class JailHandler {
|
|||||||
|
|
||||||
private void load(Class<? extends Command> command) {
|
private void load(Class<? extends Command> command) {
|
||||||
CommandInfo info = command.getAnnotation(CommandInfo.class);
|
CommandInfo info = command.getAnnotation(CommandInfo.class);
|
||||||
if (info == null) return;
|
if (info == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
commands.put(info.pattern(), command.newInstance());
|
commands.put(info.pattern(), command.newInstance());
|
||||||
|
@ -48,9 +48,14 @@ public class HandCuffCommand implements Command {
|
|||||||
|
|
||||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
if (!jm.getPlugin().getHandCuffManager().isHandCuffed(p.getUniqueId())) //don't send someone who is already handcuffed
|
if (!jm.getPlugin().getHandCuffManager().isHandCuffed(p.getUniqueId())) //don't send someone who is already handcuffed
|
||||||
|
{
|
||||||
if (!p.hasPermission("jail.cantbehandcuffed")) //don't send someone who can't be handcuffed
|
if (!p.hasPermission("jail.cantbehandcuffed")) //don't send someone who can't be handcuffed
|
||||||
if (args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[0]))
|
{
|
||||||
|
if (args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[0])) {
|
||||||
results.add(p.getName());
|
results.add(p.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
@ -42,8 +42,11 @@ public class UnHandCuffCommand implements Command {
|
|||||||
|
|
||||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
if (jm.getPlugin().getHandCuffManager().isHandCuffed(p.getUniqueId())) //don't send someone who isn't already handcuffed
|
if (jm.getPlugin().getHandCuffManager().isHandCuffed(p.getUniqueId())) //don't send someone who isn't already handcuffed
|
||||||
if (args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[0]))
|
{
|
||||||
|
if (args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[0])) {
|
||||||
results.add(p.getName());
|
results.add(p.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
@ -71,8 +71,9 @@ public class UnJailCommand implements Command {
|
|||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
|
|
||||||
for (Prisoner p : jm.getAllPrisoners().values())
|
for (Prisoner p : jm.getAllPrisoners().values())
|
||||||
if (args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[0]))
|
if (args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[0])) {
|
||||||
results.add(p.getLastKnownName());
|
results.add(p.getLastKnownName());
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
@ -46,8 +46,9 @@ public class UnJailForceCommand implements Command {
|
|||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
|
|
||||||
for (Prisoner p : jm.getAllPrisoners().values())
|
for (Prisoner p : jm.getAllPrisoners().values())
|
||||||
if (args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[0]))
|
if (args[0].isEmpty() || StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[0])) {
|
||||||
results.add(p.getLastKnownName());
|
results.add(p.getLastKnownName());
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
@ -54,11 +54,14 @@ public class JailCheckCommand implements Command {
|
|||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
if (args.length == 2)
|
if (args.length == 2) {
|
||||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
if (args[1].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[1]))
|
if (args[1].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[1])) {
|
||||||
if (!results.contains(p.getName()))
|
if (!results.contains(p.getName())) {
|
||||||
results.add(p.getName());
|
results.add(p.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,9 @@ public class JailCommand implements Command {
|
|||||||
List<String> arguments = new LinkedList<>(Arrays.asList(args));
|
List<String> arguments = new LinkedList<>(Arrays.asList(args));
|
||||||
//Only add the "-p" if it doesn't already contain it, this way people can do `/jail -p check` in the event someone
|
//Only add the "-p" if it doesn't already contain it, this way people can do `/jail -p check` in the event someone
|
||||||
//has a name which is one of our subcommands
|
//has a name which is one of our subcommands
|
||||||
if (!arguments.contains("-p")) arguments.add(0, "-p");
|
if (!arguments.contains("-p")) {
|
||||||
|
arguments.add(0, "-p");
|
||||||
|
}
|
||||||
|
|
||||||
Jailing params;
|
Jailing params;
|
||||||
|
|
||||||
@ -233,10 +235,11 @@ public class JailCommand implements Command {
|
|||||||
|
|
||||||
//check if the event is cancelled
|
//check if the event is cancelled
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
if (event.getCancelledMessage().isEmpty())
|
if (event.getCancelledMessage().isEmpty()) {
|
||||||
sender.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(params.getPlayer()));
|
sender.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(params.getPlayer()));
|
||||||
else
|
} else {
|
||||||
sender.sendMessage(event.getCancelledMessage());
|
sender.sendMessage(event.getCancelledMessage());
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -278,20 +281,26 @@ public class JailCommand implements Command {
|
|||||||
String previous = args[args.length - 2];
|
String previous = args[args.length - 2];
|
||||||
jm.getPlugin().debug("args[args.length - 2]: " + previous);
|
jm.getPlugin().debug("args[args.length - 2]: " + previous);
|
||||||
|
|
||||||
if (previous.equalsIgnoreCase("-p")) return getPlayers(jm, last);
|
if (previous.equalsIgnoreCase("-p")) {
|
||||||
else if (previous.equalsIgnoreCase("-j")) return jm.getJailsByPrefix(last);
|
return getPlayers(jm, last);
|
||||||
else if (previous.equalsIgnoreCase("-c")) {
|
} else if (previous.equalsIgnoreCase("-j")) {
|
||||||
|
return jm.getJailsByPrefix(last);
|
||||||
|
} else if (previous.equalsIgnoreCase("-c")) {
|
||||||
//Since we need to give them a list of the cells in a jail
|
//Since we need to give them a list of the cells in a jail
|
||||||
//we need to get the jail they're giving
|
//we need to get the jail they're giving
|
||||||
int jailIndex = ArrayUtils.indexOf(args, "-j");
|
int jailIndex = ArrayUtils.indexOf(args, "-j");
|
||||||
if (jailIndex != -1) {
|
if (jailIndex != -1) {
|
||||||
String jail = args[jailIndex + 1];
|
String jail = args[jailIndex + 1];
|
||||||
jm.getPlugin().debug("The jail is: " + jail);
|
jm.getPlugin().debug("The jail is: " + jail);
|
||||||
if (jm.isValidJail(jail)) return getCells(jm, jail, last);
|
if (jm.isValidJail(jail)) {
|
||||||
|
return getCells(jm, jail, last);
|
||||||
}
|
}
|
||||||
} else if (previous.endsWith("r")) return Collections.emptyList();
|
}
|
||||||
else if (!commands.contains(args[args.length - 2].replace("-", "")))
|
} else if (previous.endsWith("r")) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
} else if (!commands.contains(args[args.length - 2].replace("-", ""))) {
|
||||||
return Util.getUnusedItems(commands, args, false);
|
return Util.getUnusedItems(commands, args, false);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return getPlayers(jm, last);
|
return getPlayers(jm, last);
|
||||||
}
|
}
|
||||||
@ -312,9 +321,12 @@ public class JailCommand implements Command {
|
|||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
|
|
||||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
if (first.isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), first))
|
if (first.isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), first)) {
|
||||||
if (!jm.isPlayerJailed(p.getUniqueId()) && !p.hasPermission(noJailPermission)) //don't send back them if they're already jailed or can't be jailed
|
if (!jm.isPlayerJailed(p.getUniqueId()) && !p.hasPermission(noJailPermission)) //don't send back them if they're already jailed or can't be jailed
|
||||||
|
{
|
||||||
results.add(p.getName());
|
results.add(p.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
jm.getPlugin().debug("The list we're returning is: " + Util.getStringFromList(", ", results));
|
jm.getPlugin().debug("The list we're returning is: " + Util.getStringFromList(", ", results));
|
||||||
@ -326,8 +338,9 @@ public class JailCommand implements Command {
|
|||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
|
|
||||||
for (Cell c : jm.getJail(jail).getCells())
|
for (Cell c : jm.getJail(jail).getCells())
|
||||||
if (!c.hasPrisoner() && (cell.isEmpty() || StringUtil.startsWithIgnoreCase(c.getName(), cell)))
|
if (!c.hasPrisoner() && (cell.isEmpty() || StringUtil.startsWithIgnoreCase(c.getName(), cell))) {
|
||||||
results.add(c.getName());
|
results.add(c.getName());
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
@ -46,7 +46,9 @@ public class JailCreateCellCommand implements Command {
|
|||||||
Jail j = jm.getJail(jail);
|
Jail j = jm.getJail(jail);
|
||||||
|
|
||||||
//If they didn't provide a cell name, let's provide one ourself.
|
//If they didn't provide a cell name, let's provide one ourself.
|
||||||
if (cell.isEmpty()) cell = "cell_n" + (j.getCellCount() + 1);
|
if (cell.isEmpty()) {
|
||||||
|
cell = "cell_n" + (j.getCellCount() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
if (j.getCell(cell) == null) {
|
if (j.getCell(cell) == null) {
|
||||||
if (jm.addCreatingCell(name, jail, cell)) {
|
if (jm.addCreatingCell(name, jail, cell)) {
|
||||||
@ -67,7 +69,9 @@ public class JailCreateCellCommand implements Command {
|
|||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||||
//We shouldn't provide when they want a cell name
|
//We shouldn't provide when they want a cell name
|
||||||
if (args.length >= 3) return Collections.emptyList();
|
if (args.length >= 3) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
return jm.getJailsByPrefix(args.length == 2 ? args[1] : "");
|
return jm.getJailsByPrefix(args.length == 2 ? args[1] : "");
|
||||||
}
|
}
|
||||||
|
@ -50,9 +50,10 @@ public class JailDeleteCellCommand implements Command {
|
|||||||
Jail j = jm.getJail(args[1]);
|
Jail j = jm.getJail(args[1]);
|
||||||
|
|
||||||
for (Cell c : j.getCells())
|
for (Cell c : j.getCells())
|
||||||
if (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(c.getName(), args[2]))
|
if (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(c.getName(), args[2])) {
|
||||||
results.add(c.getName());
|
results.add(c.getName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,11 +32,12 @@ public class JailListCommand implements Command {
|
|||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
//No jail provided, so give them a list of the jails
|
//No jail provided, so give them a list of the jails
|
||||||
for (Jail j : jm.getJails()) {
|
for (Jail j : jm.getJails()) {
|
||||||
if (j.isEnabled())
|
if (j.isEnabled()) {
|
||||||
sender.sendMessage(ChatColor.BLUE + " " + j.getName() + " (" + j.getAllPrisoners().size() + ")");
|
sender.sendMessage(ChatColor.BLUE + " " + j.getName() + " (" + j.getAllPrisoners().size() + ")");
|
||||||
else
|
} else {
|
||||||
sender.sendMessage(ChatColor.RED + " " + j.getName() + " (" + j.getAllPrisoners().size() + ") - WORLD UNLOADED");
|
sender.sendMessage(ChatColor.RED + " " + j.getName() + " (" + j.getAllPrisoners().size() + ") - WORLD UNLOADED");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Jail j = jm.getJail(args[1]);
|
Jail j = jm.getJail(args[1]);
|
||||||
|
|
||||||
|
@ -29,10 +29,11 @@ public class JailMuteCommand implements Command {
|
|||||||
jm.getPrisonerByLastKnownName(args[1]).setMuted(muted);
|
jm.getPrisonerByLastKnownName(args[1]).setMuted(muted);
|
||||||
|
|
||||||
//Send the message to the sender based upon whether they are muted or unmuted
|
//Send the message to the sender based upon whether they are muted or unmuted
|
||||||
if (muted)
|
if (muted) {
|
||||||
sender.sendMessage(Lang.NOWMUTED.get(args[1]));
|
sender.sendMessage(Lang.NOWMUTED.get(args[1]));
|
||||||
else
|
} else {
|
||||||
sender.sendMessage(Lang.NOWUNMUTED.get(args[1]));
|
sender.sendMessage(Lang.NOWUNMUTED.get(args[1]));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//The player provided is not jailed, so let's tell the sender that
|
//The player provided is not jailed, so let's tell the sender that
|
||||||
sender.sendMessage(Lang.NOTJAILED.get(args[1]));
|
sender.sendMessage(Lang.NOTJAILED.get(args[1]));
|
||||||
@ -45,8 +46,9 @@ public class JailMuteCommand implements Command {
|
|||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
if (StringUtil.startsWithIgnoreCase(p.getName(), args[1].toLowerCase()))
|
if (StringUtil.startsWithIgnoreCase(p.getName(), args[1].toLowerCase())) {
|
||||||
results.add(p.getName());
|
results.add(p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
return results;
|
return results;
|
||||||
|
@ -216,9 +216,14 @@ public class JailPayCommand implements Command {
|
|||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
for (Prisoner p : jm.getAllPrisoners().values())
|
for (Prisoner p : jm.getAllPrisoners().values())
|
||||||
if (!p.isOfflinePending()) //Don't list if they're offline pending
|
if (!p.isOfflinePending()) //Don't list if they're offline pending
|
||||||
|
{
|
||||||
if (p.getRemainingTime() != -1) //Don't list if they're jailed forever
|
if (p.getRemainingTime() != -1) //Don't list if they're jailed forever
|
||||||
if (StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[2]))
|
{
|
||||||
|
if (StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[2])) {
|
||||||
results.add(p.getLastKnownName());
|
results.add(p.getLastKnownName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
@ -108,9 +108,10 @@ public class JailSignsCommand implements Command {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
public List<String> provideTabCompletions(JailManager jm, CommandSender sender, String... args) {
|
||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
@ -118,17 +119,20 @@ public class JailSignsCommand implements Command {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
for (String s : options)
|
for (String s : options)
|
||||||
if (args[1].isEmpty() || StringUtil.startsWithIgnoreCase(s, args[1]))
|
if (args[1].isEmpty() || StringUtil.startsWithIgnoreCase(s, args[1])) {
|
||||||
results.add(s);
|
results.add(s);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
results.addAll(jm.getJailsByPrefix(args[2]));
|
results.addAll(jm.getJailsByPrefix(args[2]));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (jm.isValidJail(args[2]))
|
if (jm.isValidJail(args[2])) {
|
||||||
for (Cell c : jm.getJail(args[2]).getCells())
|
for (Cell c : jm.getJail(args[2]).getCells())
|
||||||
if (!Util.isStringInsideArray(c.getName(), args))
|
if (!Util.isStringInsideArray(c.getName(), args)) {
|
||||||
results.add(c.getName());
|
results.add(c.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,8 +64,9 @@ public class JailTeleInCommand implements Command {
|
|||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
|
|
||||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
if (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[2]))
|
if (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[2])) {
|
||||||
results.add(p.getName());
|
results.add(p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
@ -64,8 +64,9 @@ public class JailTeleOutCommand implements Command {
|
|||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
|
|
||||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
if (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[2]))
|
if (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[2])) {
|
||||||
results.add(p.getName());
|
results.add(p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
@ -65,13 +65,15 @@ public class JailTimeCommand implements Command {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
for (String s : options)
|
for (String s : options)
|
||||||
if (args[1].isEmpty() || StringUtil.startsWithIgnoreCase(s, args[1]))
|
if (args[1].isEmpty() || StringUtil.startsWithIgnoreCase(s, args[1])) {
|
||||||
results.add(s);
|
results.add(s);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
for (Prisoner p : jm.getAllPrisoners().values())
|
for (Prisoner p : jm.getAllPrisoners().values())
|
||||||
if (StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[2]))
|
if (StringUtil.startsWithIgnoreCase(p.getLastKnownName(), args[2])) {
|
||||||
results.add(p.getLastKnownName());
|
results.add(p.getLastKnownName());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -65,8 +65,9 @@ public class JailTransferAllCommand implements Command {
|
|||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
|
|
||||||
for (Jail j : jm.getJails())
|
for (Jail j : jm.getJails())
|
||||||
if (!j.getName().equalsIgnoreCase(args[1]) && (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(j.getName(), args[2])))
|
if (!j.getName().equalsIgnoreCase(args[1]) && (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(j.getName(), args[2]))) {
|
||||||
results.add(j.getName());
|
results.add(j.getName());
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
@ -153,20 +153,25 @@ public class JailTransferCommand implements Command {
|
|||||||
String previous = args[args.length - 2];
|
String previous = args[args.length - 2];
|
||||||
jm.getPlugin().debug("args[args.length - 2]: " + previous);
|
jm.getPlugin().debug("args[args.length - 2]: " + previous);
|
||||||
|
|
||||||
if (previous.equalsIgnoreCase("-p")) return getPlayers(jm, last);
|
if (previous.equalsIgnoreCase("-p")) {
|
||||||
else if (previous.equalsIgnoreCase("-j")) return jm.getJailsByPrefix(last);
|
return getPlayers(jm, last);
|
||||||
else if (previous.equalsIgnoreCase("-c")) {
|
} else if (previous.equalsIgnoreCase("-j")) {
|
||||||
|
return jm.getJailsByPrefix(last);
|
||||||
|
} else if (previous.equalsIgnoreCase("-c")) {
|
||||||
//Since we need to give them a list of the cells in a jail
|
//Since we need to give them a list of the cells in a jail
|
||||||
//we need to get the jail they're giving
|
//we need to get the jail they're giving
|
||||||
int jailIndex = ArrayUtils.indexOf(args, "-j");
|
int jailIndex = ArrayUtils.indexOf(args, "-j");
|
||||||
if (jailIndex != -1) {
|
if (jailIndex != -1) {
|
||||||
String jail = args[jailIndex + 1];
|
String jail = args[jailIndex + 1];
|
||||||
jm.getPlugin().debug("The jail is: " + jail);
|
jm.getPlugin().debug("The jail is: " + jail);
|
||||||
if (jm.isValidJail(jail)) return getCells(jm, jail, last);
|
if (jm.isValidJail(jail)) {
|
||||||
|
return getCells(jm, jail, last);
|
||||||
}
|
}
|
||||||
} else if (!commands.contains(args[args.length - 2].replace("-", "")))
|
}
|
||||||
|
} else if (!commands.contains(args[args.length - 2].replace("-", ""))) {
|
||||||
return Util.getUnusedItems(commands, args, true);
|
return Util.getUnusedItems(commands, args, true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else if (last.equalsIgnoreCase("-")) {
|
} else if (last.equalsIgnoreCase("-")) {
|
||||||
//add some smart checking so that it only returns a list of what isn't already
|
//add some smart checking so that it only returns a list of what isn't already
|
||||||
//in the command :)
|
//in the command :)
|
||||||
@ -182,8 +187,9 @@ public class JailTransferCommand implements Command {
|
|||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
|
|
||||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
if (first.isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), first))
|
if (first.isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), first)) {
|
||||||
results.add(p.getName());
|
results.add(p.getName());
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
@ -194,8 +200,9 @@ public class JailTransferCommand implements Command {
|
|||||||
List<String> results = new ArrayList<>();
|
List<String> results = new ArrayList<>();
|
||||||
|
|
||||||
for (Cell c : jm.getJail(jail).getCells())
|
for (Cell c : jm.getJail(jail).getCells())
|
||||||
if (!c.hasPrisoner() && (cell.isEmpty() || StringUtil.startsWithIgnoreCase(c.getName(), cell)))
|
if (!c.hasPrisoner() && (cell.isEmpty() || StringUtil.startsWithIgnoreCase(c.getName(), cell))) {
|
||||||
results.add(c.getName());
|
results.add(c.getName());
|
||||||
|
}
|
||||||
|
|
||||||
Collections.sort(results);
|
Collections.sort(results);
|
||||||
|
|
||||||
|
@ -111,13 +111,15 @@ public class JailVoteCommand implements Command {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
for (Player p : jm.getPlugin().getServer().getOnlinePlayers())
|
||||||
if (args[1].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[1]))
|
if (args[1].isEmpty() || StringUtil.startsWithIgnoreCase(p.getName(), args[1])) {
|
||||||
results.add(p.getName());
|
results.add(p.getName());
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
for (String s : options)
|
for (String s : options)
|
||||||
if (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(s, args[2]))
|
if (args[2].isEmpty() || StringUtil.startsWithIgnoreCase(s, args[2])) {
|
||||||
results.add(s);
|
results.add(s);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -583,7 +583,9 @@ public enum Lang {
|
|||||||
public String get(String... variables) {
|
public String get(String... variables) {
|
||||||
String message = lang.getString(path);
|
String message = lang.getString(path);
|
||||||
|
|
||||||
if (message == null) return "";
|
if (message == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
for (int i = 0; i < variables.length; i++) {
|
for (int i = 0; i < variables.length; i++) {
|
||||||
message = message.replaceAll("%" + i + "%", variables[i]);
|
message = message.replaceAll("%" + i + "%", variables[i]);
|
||||||
|
@ -3,6 +3,7 @@ package com.graywolf336.jail.events;
|
|||||||
import com.graywolf336.jail.JailMain;
|
import com.graywolf336.jail.JailMain;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event thrown after the plugin is reloaded, internal usage only.
|
* Event thrown after the plugin is reloaded, internal usage only.
|
||||||
@ -33,7 +34,7 @@ public class JailPluginReloadedEvent extends Event {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.graywolf336.jail.beans.Prisoner;
|
|||||||
import com.graywolf336.jail.interfaces.ICell;
|
import com.graywolf336.jail.interfaces.ICell;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event thrown when a prisoner is offline put will be put into jail next time they come online.
|
* Event thrown when a prisoner is offline put will be put into jail next time they come online.
|
||||||
@ -84,7 +85,7 @@ public class OfflinePrisonerJailedEvent extends Event {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event thrown before we a player is jailed by someone hitting them with a {@link Stick jail stick}.
|
* Event thrown before we a player is jailed by someone hitting them with a {@link Stick jail stick}.
|
||||||
@ -148,7 +149,7 @@ public class PrePrisonerJailedByJailStickEvent extends Event implements Cancella
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event thrown before we are jailing a player, both offline and online players.
|
* Event thrown before we are jailing a player, both offline and online players.
|
||||||
@ -163,7 +164,7 @@ public class PrePrisonerJailedEvent extends Event implements Cancellable {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.graywolf336.jail.interfaces.ICell;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event thrown after a prisoner is released.
|
* Event thrown after a prisoner is released.
|
||||||
@ -81,7 +82,7 @@ public class PrePrisonerReleasedEvent extends Event {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event thrown before we transfer a prisoner, both offline and online prisoner.
|
* Event thrown before we transfer a prisoner, both offline and online prisoner.
|
||||||
@ -95,8 +96,11 @@ public class PrePrisonerTransferredEvent extends Event implements Cancellable {
|
|||||||
* Will return null if the cell is not in the targetJail.
|
* Will return null if the cell is not in the targetJail.
|
||||||
*/
|
*/
|
||||||
public Cell getTargetCell() {
|
public Cell getTargetCell() {
|
||||||
if (this.targetJail.isValidCell(this.targetCell.getName())) return this.targetCell;
|
if (this.targetJail.isValidCell(this.targetCell.getName())) {
|
||||||
else return null;
|
return this.targetCell;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -192,7 +196,7 @@ public class PrePrisonerTransferredEvent extends Event implements Cancellable {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event thrown when a prisoner dies.
|
* Event thrown when a prisoner dies.
|
||||||
@ -86,7 +87,7 @@ public class PrisonerDeathEvent extends Event {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.graywolf336.jail.beans.Prisoner;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event thrown after a prisoner is put into jail.
|
* Event thrown after a prisoner is put into jail.
|
||||||
@ -95,7 +96,7 @@ public class PrisonerJailedEvent extends Event {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.graywolf336.jail.beans.Prisoner;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event thrown after a prisoner is released.
|
* Event thrown after a prisoner is released.
|
||||||
@ -81,7 +82,7 @@ public class PrisonerReleasedEvent extends Event {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event thrown when a prisoner's time changes.
|
* Event thrown when a prisoner's time changes.
|
||||||
@ -133,7 +134,7 @@ public class PrisonerTimeChangeEvent extends Event implements Cancellable {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import com.graywolf336.jail.beans.Prisoner;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event thrown after we transfer a prisoner, both an offline and an online prisoner.
|
* Event thrown after we transfer a prisoner, both an offline and an online prisoner.
|
||||||
@ -80,8 +81,11 @@ public class PrisonerTransferredEvent extends Event {
|
|||||||
* Will return null if the cell is not in the targetJail.
|
* Will return null if the cell is not in the targetJail.
|
||||||
*/
|
*/
|
||||||
public Cell getTargetCell() {
|
public Cell getTargetCell() {
|
||||||
if (this.targetJail.isValidCell(this.targetCell.getName())) return this.targetCell;
|
if (this.targetJail.isValidCell(this.targetCell.getName())) {
|
||||||
else return null;
|
return this.targetCell;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -116,7 +120,7 @@ public class PrisonerTransferredEvent extends Event {
|
|||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HandlerList getHandlers() {
|
public @NotNull HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.graywolf336.jail.exceptions;
|
package com.graywolf336.jail.exceptions;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exception thrown trying to unjail via a thread that is NOT the primary thread.
|
* The exception thrown trying to unjail via a thread that is NOT the primary thread.
|
||||||
*
|
*
|
||||||
@ -8,6 +10,7 @@ package com.graywolf336.jail.exceptions;
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class AsyncUnJailingNotSupportedException extends Exception {
|
public class AsyncUnJailingNotSupportedException extends Exception {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -1540695375715404835L;
|
private static final long serialVersionUID = -1540695375715404835L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.graywolf336.jail.exceptions;
|
package com.graywolf336.jail.exceptions;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exception thrown when a cell is required but wasn't provided.
|
* The exception thrown when a cell is required but wasn't provided.
|
||||||
*
|
*
|
||||||
@ -8,6 +10,7 @@ package com.graywolf336.jail.exceptions;
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class CellRequiredException extends Exception {
|
public class CellRequiredException extends Exception {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 6496748770371151376L;
|
private static final long serialVersionUID = 6496748770371151376L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.graywolf336.jail.exceptions;
|
package com.graywolf336.jail.exceptions;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exception thrown when a jail is required but wasn't provided.
|
* The exception thrown when a jail is required but wasn't provided.
|
||||||
*
|
*
|
||||||
@ -8,6 +10,7 @@ package com.graywolf336.jail.exceptions;
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class JailRequiredException extends Exception {
|
public class JailRequiredException extends Exception {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 1046287197309037470L;
|
private static final long serialVersionUID = 1046287197309037470L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.graywolf336.jail.exceptions;
|
package com.graywolf336.jail.exceptions;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exception thrown when a prisoner is already jailed.
|
* The exception thrown when a prisoner is already jailed.
|
||||||
*
|
*
|
||||||
@ -8,6 +10,7 @@ package com.graywolf336.jail.exceptions;
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class PrisonerAlreadyJailedException extends Exception {
|
public class PrisonerAlreadyJailedException extends Exception {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = -5830449694077279409L;
|
private static final long serialVersionUID = -5830449694077279409L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.graywolf336.jail.exceptions;
|
package com.graywolf336.jail.exceptions;
|
||||||
|
|
||||||
|
import java.io.Serial;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The exception thrown when a prisoner's data is required but wasn't provided.
|
* The exception thrown when a prisoner's data is required but wasn't provided.
|
||||||
*
|
*
|
||||||
@ -8,6 +10,7 @@ package com.graywolf336.jail.exceptions;
|
|||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
*/
|
*/
|
||||||
public class PrisonerRequiredException extends Exception {
|
public class PrisonerRequiredException extends Exception {
|
||||||
|
@Serial
|
||||||
private static final long serialVersionUID = 5289068334047189357L;
|
private static final long serialVersionUID = 5289068334047189357L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,10 +23,18 @@ public class CellSignListener implements Listener {
|
|||||||
pl = plugin;
|
pl = plugin;
|
||||||
List<String> lines = pl.getConfig().getStringList(Settings.CELLSIGNLINES.getPath());
|
List<String> lines = pl.getConfig().getStringList(Settings.CELLSIGNLINES.getPath());
|
||||||
|
|
||||||
if (lines.size() >= 1) lineOne = lines.get(0);
|
if (lines.size() >= 1) {
|
||||||
if (lines.size() >= 2) lineTwo = lines.get(1);
|
lineOne = lines.get(0);
|
||||||
if (lines.size() >= 3) lineThree = lines.get(2);
|
}
|
||||||
if (lines.size() >= 4) lineFour = lines.get(3);
|
if (lines.size() >= 2) {
|
||||||
|
lineTwo = lines.get(1);
|
||||||
|
}
|
||||||
|
if (lines.size() >= 3) {
|
||||||
|
lineThree = lines.get(2);
|
||||||
|
}
|
||||||
|
if (lines.size() >= 4) {
|
||||||
|
lineFour = lines.get(3);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Util.updateSignLinesCache(new String[]{lineOne, lineTwo, lineThree, lineFour});
|
Util.updateSignLinesCache(new String[]{lineOne, lineTwo, lineThree, lineFour});
|
||||||
@ -87,10 +95,18 @@ public class CellSignListener implements Listener {
|
|||||||
lineThree = "";
|
lineThree = "";
|
||||||
lineFour = "";
|
lineFour = "";
|
||||||
|
|
||||||
if (lines.size() >= 1) lineOne = lines.get(0);
|
if (lines.size() >= 1) {
|
||||||
if (lines.size() >= 2) lineTwo = lines.get(1);
|
lineOne = lines.get(0);
|
||||||
if (lines.size() >= 3) lineThree = lines.get(2);
|
}
|
||||||
if (lines.size() >= 4) lineFour = lines.get(3);
|
if (lines.size() >= 2) {
|
||||||
|
lineTwo = lines.get(1);
|
||||||
|
}
|
||||||
|
if (lines.size() >= 3) {
|
||||||
|
lineThree = lines.get(2);
|
||||||
|
}
|
||||||
|
if (lines.size() >= 4) {
|
||||||
|
lineFour = lines.get(3);
|
||||||
|
}
|
||||||
|
|
||||||
Util.updateSignLinesCache(new String[]{lineOne, lineTwo, lineThree, lineFour});
|
Util.updateSignLinesCache(new String[]{lineOne, lineTwo, lineThree, lineFour});
|
||||||
}
|
}
|
||||||
|
@ -15,57 +15,64 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class HandCuffListener implements Listener {
|
public class HandCuffListener implements Listener {
|
||||||
private final JailMain pl;
|
|
||||||
|
private final JailMain jailMain;
|
||||||
private final HashMap<String, Location> tos;
|
private final HashMap<String, Location> tos;
|
||||||
|
|
||||||
public HandCuffListener(JailMain plugin) {
|
public HandCuffListener(JailMain plugin) {
|
||||||
this.pl = plugin;
|
this.jailMain = plugin;
|
||||||
this.tos = new HashMap<>();
|
this.tos = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
if (false) return;
|
if (false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
if (jailMain.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||||
Location to = pl.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
|
Location to = jailMain.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
|
||||||
to.setPitch(event.getTo().getPitch());
|
to.setPitch(event.getTo().getPitch());
|
||||||
to.setYaw(event.getTo().getYaw());
|
to.setYaw(event.getTo().getYaw());
|
||||||
|
|
||||||
tos.put(event.getPlayer().getName(), to);
|
tos.put(event.getPlayer().getName(), to);
|
||||||
event.getPlayer().teleport(to);
|
event.getPlayer().teleport(to);
|
||||||
|
|
||||||
if (System.currentTimeMillis() >= pl.getHandCuffManager().getNextMessageTime(event.getPlayer().getUniqueId())) {
|
if (System.currentTimeMillis() >= jailMain.getHandCuffManager().getNextMessageTime(event.getPlayer().getUniqueId())) {
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and cant move!");
|
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and cant move!");
|
||||||
pl.getHandCuffManager().updateNextTime(event.getPlayer().getUniqueId());
|
jailMain.getHandCuffManager().updateNextTime(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
if (false) return;
|
if (false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId()) && event.getTo() != tos.get(event.getPlayer().getName())) {
|
if (jailMain.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId()) && event.getTo() != tos.get(event.getPlayer().getName())) {
|
||||||
Location to = pl.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
|
Location to = jailMain.getHandCuffManager().getLocation(event.getPlayer().getUniqueId());
|
||||||
to.setPitch(event.getTo().getPitch());
|
to.setPitch(event.getTo().getPitch());
|
||||||
to.setYaw(event.getTo().getYaw());
|
to.setYaw(event.getTo().getYaw());
|
||||||
|
|
||||||
tos.put(event.getPlayer().getName(), to);
|
tos.put(event.getPlayer().getName(), to);
|
||||||
event.getPlayer().teleport(to);
|
event.getPlayer().teleport(to);
|
||||||
|
|
||||||
if (System.currentTimeMillis() >= pl.getHandCuffManager().getNextMessageTime(event.getPlayer().getUniqueId())) {
|
if (System.currentTimeMillis() >= jailMain.getHandCuffManager().getNextMessageTime(event.getPlayer().getUniqueId())) {
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and cant move!");
|
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and cant move!");
|
||||||
pl.getHandCuffManager().updateNextTime(event.getPlayer().getUniqueId());
|
jailMain.getHandCuffManager().updateNextTime(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void playerChat(AsyncPlayerChatEvent event) {
|
public void playerChat(AsyncPlayerChatEvent event) {
|
||||||
if (false) return;
|
if (false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId()) && !event.getPlayer().hasPermission("jail.command.handcuff")) {
|
if (jailMain.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId()) && !event.getPlayer().hasPermission("jail.command.handcuff")) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to talk!");
|
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to talk!");
|
||||||
}
|
}
|
||||||
@ -73,9 +80,11 @@ public class HandCuffListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void blockBreak(BlockBreakEvent event) {
|
public void blockBreak(BlockBreakEvent event) {
|
||||||
if (false) return;
|
if (false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
if (jailMain.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to break blocks!");
|
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to break blocks!");
|
||||||
}
|
}
|
||||||
@ -83,9 +92,11 @@ public class HandCuffListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void blockPlace(BlockPlaceEvent event) {
|
public void blockPlace(BlockPlaceEvent event) {
|
||||||
if (false) return;
|
if (false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
if (jailMain.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to place blocks!");
|
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to place blocks!");
|
||||||
}
|
}
|
||||||
@ -93,9 +104,11 @@ public class HandCuffListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void preCommands(PlayerCommandPreprocessEvent event) {
|
public void preCommands(PlayerCommandPreprocessEvent event) {
|
||||||
if (false) return;
|
if (false) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (pl.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId()) && !event.getPlayer().hasPermission("jail.command.handcuff") && (!event.getMessage().startsWith("/r") || !event.getMessage().startsWith("/reply"))) {
|
if (jailMain.getHandCuffManager().isHandCuffed(event.getPlayer().getUniqueId()) && !event.getPlayer().hasPermission("jail.command.handcuff") && (!event.getMessage().startsWith("/r") || !event.getMessage().startsWith("/reply"))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to use commands!");
|
event.getPlayer().sendMessage(ChatColor.RED + "You are handcuffed and aren't allowed to use commands!");
|
||||||
}
|
}
|
||||||
|
@ -90,8 +90,9 @@ public class PlayerListener implements Listener {
|
|||||||
//If the config has receive messages set to false, let's remove all the prisoners
|
//If the config has receive messages set to false, let's remove all the prisoners
|
||||||
//from getting the chat messages.
|
//from getting the chat messages.
|
||||||
if (!pl.getConfig().getBoolean(Settings.RECIEVEMESSAGES.getPath())) {
|
if (!pl.getConfig().getBoolean(Settings.RECIEVEMESSAGES.getPath())) {
|
||||||
if (pl.inDebug())
|
if (pl.inDebug()) {
|
||||||
pl.getLogger().info("Debug - There are " + event.getRecipients().size() + " players getting the message before.");
|
pl.getLogger().info("Debug - There are " + event.getRecipients().size() + " players getting the message before.");
|
||||||
|
}
|
||||||
Set<Player> rec = new HashSet<>(event.getRecipients());
|
Set<Player> rec = new HashSet<>(event.getRecipients());
|
||||||
|
|
||||||
for (Jail j : pl.getJailManager().getJails())
|
for (Jail j : pl.getJailManager().getJails())
|
||||||
@ -100,10 +101,11 @@ public class PlayerListener implements Listener {
|
|||||||
|
|
||||||
event.getRecipients().clear();
|
event.getRecipients().clear();
|
||||||
event.getRecipients().addAll(rec);
|
event.getRecipients().addAll(rec);
|
||||||
if (pl.inDebug())
|
if (pl.inDebug()) {
|
||||||
pl.getLogger().info("Debug - There are now " + event.getRecipients().size() + " players getting the message.");
|
pl.getLogger().info("Debug - There are now " + event.getRecipients().size() + " players getting the message.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void checkForOfflineJailStuff(PlayerJoinEvent event) {
|
public void checkForOfflineJailStuff(PlayerJoinEvent event) {
|
||||||
@ -236,20 +238,27 @@ public class PlayerListener implements Listener {
|
|||||||
if (pl.getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
if (pl.getConfig().getBoolean(Settings.JAILSTICKENABLED.getPath())) {
|
||||||
//If the damager and the entity getting damage is not a player,
|
//If the damager and the entity getting damage is not a player,
|
||||||
//we don't want to handle it in this method
|
//we don't want to handle it in this method
|
||||||
if (!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof Player)) return;
|
if (!(event.getDamager() instanceof Player) || !(event.getEntity() instanceof Player)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Player attacker = (Player) event.getDamager();
|
Player attacker = (Player) event.getDamager();
|
||||||
Player player = (Player) event.getEntity();
|
Player player = (Player) event.getEntity();
|
||||||
|
|
||||||
//They aren't using the jail stick, they need to toggle themselves
|
//They aren't using the jail stick, they need to toggle themselves
|
||||||
if (!pl.getJailStickManager().isUsingJailStick(attacker.getUniqueId())) return;
|
if (!pl.getJailStickManager().isUsingJailStick(attacker.getUniqueId())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//They don't have a valid jail stick type
|
//They don't have a valid jail stick type
|
||||||
if (!pl.getJailStickManager().isValidStick(attacker.getInventory().getItemInMainHand().getType())) return;
|
if (!pl.getJailStickManager().isValidStick(attacker.getInventory().getItemInMainHand().getType())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//They don't have permission for that type of jail stick
|
//They don't have permission for that type of jail stick
|
||||||
if (!attacker.hasPermission("jail.usejailstick." + attacker.getInventory().getItemInMainHand().getType().toString().toLowerCase()))
|
if (!attacker.hasPermission("jail.usejailstick." + attacker.getInventory().getItemInMainHand().getType().toString().toLowerCase())) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//The player they hit is already jailed.
|
//The player they hit is already jailed.
|
||||||
if (pl.getJailManager().isPlayerJailed(player.getUniqueId())) {
|
if (pl.getJailManager().isPlayerJailed(player.getUniqueId())) {
|
||||||
@ -285,10 +294,11 @@ public class PlayerListener implements Listener {
|
|||||||
pl.getServer().getPluginManager().callEvent(jEvent);
|
pl.getServer().getPluginManager().callEvent(jEvent);
|
||||||
|
|
||||||
if (jEvent.isCancelled()) {
|
if (jEvent.isCancelled()) {
|
||||||
if (jEvent.getCancelledMessage().isEmpty())
|
if (jEvent.getCancelledMessage().isEmpty()) {
|
||||||
attacker.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(player.getName()));
|
attacker.sendMessage(Lang.CANCELLEDBYANOTHERPLUGIN.get(player.getName()));
|
||||||
else
|
} else {
|
||||||
attacker.sendMessage(jEvent.getCancelledMessage());
|
attacker.sendMessage(jEvent.getCancelledMessage());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//recall data from the event
|
//recall data from the event
|
||||||
Jail j = jEvent.getJail();
|
Jail j = jEvent.getJail();
|
||||||
|
@ -63,7 +63,9 @@ public class ProtectionListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
//The player is not jailed but they're trying to break blocks inside of the Jail
|
//The player is not jailed but they're trying to break blocks inside of the Jail
|
||||||
//If there is no jail let's skedaddle
|
//If there is no jail let's skedaddle
|
||||||
if (pl.getJailManager().getJailFromLocation(event.getBlock().getLocation()) == null) return;
|
if (pl.getJailManager().getJailFromLocation(event.getBlock().getLocation()) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//If the player doesn't have permission to modify the jail,
|
//If the player doesn't have permission to modify the jail,
|
||||||
//then we stop it here. We won't be doing any of the additions to
|
//then we stop it here. We won't be doing any of the additions to
|
||||||
@ -115,7 +117,9 @@ public class ProtectionListener implements Listener {
|
|||||||
} else {
|
} else {
|
||||||
//The player is not jailed but they're trying to place blocks inside of the Jail
|
//The player is not jailed but they're trying to place blocks inside of the Jail
|
||||||
//If there is no jail let's skedaddle
|
//If there is no jail let's skedaddle
|
||||||
if (pl.getJailManager().getJailFromLocation(event.getBlock().getLocation()) == null) return;
|
if (pl.getJailManager().getJailFromLocation(event.getBlock().getLocation()) == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//If the player doesn't have permission to modify the jail,
|
//If the player doesn't have permission to modify the jail,
|
||||||
//then we stop it here. We won't be doing any of the additions to
|
//then we stop it here. We won't be doing any of the additions to
|
||||||
@ -138,8 +142,9 @@ public class ProtectionListener implements Listener {
|
|||||||
boolean match = false;
|
boolean match = false;
|
||||||
|
|
||||||
for (String whited : pl.getConfig().getStringList(Settings.COMMANDWHITELIST.getPath()))
|
for (String whited : pl.getConfig().getStringList(Settings.COMMANDWHITELIST.getPath()))
|
||||||
if (event.getMessage().toLowerCase().startsWith(whited.toLowerCase()))
|
if (event.getMessage().toLowerCase().startsWith(whited.toLowerCase())) {
|
||||||
match = true;
|
match = true;
|
||||||
|
}
|
||||||
|
|
||||||
//If no match found in the whitelist, then let's block this command.
|
//If no match found in the whitelist, then let's block this command.
|
||||||
if (!match) {
|
if (!match) {
|
||||||
@ -195,8 +200,9 @@ public class ProtectionListener implements Listener {
|
|||||||
|
|
||||||
if (pos1 || pos2 || pos3 || pos4) {
|
if (pos1 || pos2 || pos3 || pos4) {
|
||||||
//it is a double chest, so they're free to go!
|
//it is a double chest, so they're free to go!
|
||||||
if (pl.inDebug())
|
if (pl.inDebug()) {
|
||||||
event.getPlayer().sendMessage("[Jail Debug]: You're opening up a double chest.");
|
event.getPlayer().sendMessage("[Jail Debug]: You're opening up a double chest.");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
//it is not a double chest, so we won't be allowing it.
|
//it is not a double chest, so we won't be allowing it.
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -18,12 +18,16 @@ public class WorldListener implements Listener {
|
|||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
||||||
public void worldLoaded(WorldLoadEvent event) {
|
public void worldLoaded(WorldLoadEvent event) {
|
||||||
for (Jail j : pl.getJailManager().getJails())
|
for (Jail j : pl.getJailManager().getJails())
|
||||||
if (j.getWorldName().equalsIgnoreCase(event.getWorld().getName())) j.setEnabled(true);
|
if (j.getWorldName().equalsIgnoreCase(event.getWorld().getName())) {
|
||||||
|
j.setEnabled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
||||||
public void worldUnload(WorldUnloadEvent event) {
|
public void worldUnload(WorldUnloadEvent event) {
|
||||||
for (Jail j : pl.getJailManager().getJails())
|
for (Jail j : pl.getJailManager().getJails())
|
||||||
if (j.getWorldName().equalsIgnoreCase(event.getWorld().getName())) j.setEnabled(false);
|
if (j.getWorldName().equalsIgnoreCase(event.getWorld().getName())) {
|
||||||
|
j.setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,8 +151,9 @@ public class CellCreationSteps {
|
|||||||
c.addAllSigns(cp.getSigns());
|
c.addAllSigns(cp.getSigns());
|
||||||
c.setTeleport(cp.getTeleportInSL());
|
c.setTeleport(cp.getTeleportInSL());
|
||||||
|
|
||||||
if (cp.getChestLocation() != null)
|
if (cp.getChestLocation() != null) {
|
||||||
c.setChestLocation(cp.getChestLocation());
|
c.setChestLocation(cp.getChestLocation());
|
||||||
|
}
|
||||||
|
|
||||||
j.addCell(c, true);
|
j.addCell(c, true);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user