Compare commits
99 Commits
Author | SHA1 | Date |
---|---|---|
songoda-plugins-overview[bot] | 89db325408 | |
craftaro-plugins-overview[bot] | 4c2e95b76d | |
Christian Koop | dc76f7e8e6 | |
craftaro-plugins-overview[bot] | 9c011f1ccb | |
ceze88 | e68404aebd | |
ceze88 | cee3279061 | |
ceze88 | fed6c8f56f | |
ceze88 | e76289b1c5 | |
Christian Koop | 5cad6c0e0a | |
ceze88 | bb99fae5c9 | |
Christian Koop | aa8fdb19ec | |
Christian Koop | 1d9e532f2f | |
ceze88 | 32ddee809c | |
Christian Koop | cb8c50e70f | |
Christian Koop | 1845b1fce7 | |
Christian Koop | cd578df85f | |
songoda-projects-overview[bot] | 546d3e58b8 | |
songoda-projects-overview[bot] | 6a52d7e188 | |
ceze88 | 2b0f1b4b23 | |
Christian Koop | 4ed9b5e1c5 | |
Christian Koop | 58f76c3342 | |
Christian Koop | 5a8ff8dd33 | |
Christian Koop | 28cdb97301 | |
Christian Koop | 43f94540aa | |
Christian Koop | 3575c508f8 | |
Christian Koop | fc46312f1c | |
Christian Koop | dd29b7b49b | |
Christian Koop | f8cde33d59 | |
Christian Koop | 008eb27b3a | |
Christian Koop | 7965ac5865 | |
Christian Koop | 5db67e1b1e | |
Christian Koop | 7982d7e2f6 | |
Christian Koop | d0c8e50c8e | |
Christian Koop | e0f42f6665 | |
Christian Koop | 714ab2a14b | |
Christian Koop | d3c5e09072 | |
Christian Koop | 74bcd22974 | |
Christian Koop | 687ba7bb1b | |
Christian Koop | fb06833b27 | |
Christian Koop | ae418a7a73 | |
Brianna | fba65a23be | |
Brianna | be8d660cb0 | |
Brianna | ab4ba023dd | |
Brianna | 8f74226a87 | |
Brianna | 851e4afb1a | |
Brianna | aee6494a25 | |
Brianna | 18899d2166 | |
Brianna | 070bb51eaa | |
Brianna | a4e095c330 | |
Brianna | 3985df94c8 | |
Brianna | 8edc70f13f | |
Brianna | f9c9ff8f07 | |
Brianna | 71b327d047 | |
Brianna | a2d1e5a84f | |
MysteriousKyle | 20b8a7c65a | |
Brianna | ac0844d34b | |
Brianna | 83e7256ada | |
Brianna | 4c44f73593 | |
Brianna | 427f428d1d | |
Brianna | e86c6a342f | |
Brianna | efd0019539 | |
Brianna | a040bf26a9 | |
Brianna | 9bb8033ba8 | |
Brianna | 2c9255bced | |
Brianna | c192449f55 | |
Brianna | 77571cdcf9 | |
Brianna | 3bf21b27f9 | |
Brianna | 1d984cef36 | |
Brianna | 4bbd7aaa79 | |
Brianna | 2a581fdb20 | |
Brianna | 5047e79ccf | |
Brianna | aee2620109 | |
Brianna | b1cd9d459d | |
Brianna | 153a213a0c | |
Brianna | eff2de6360 | |
Brianna | ae4c0da070 | |
Brianna | 0346950407 | |
Brianna | 8db3c9070c | |
Brianna | ff36503381 | |
Brianna | d43cbe2b46 | |
Brianna | 76a0c296a1 | |
Brianna | 0f64daeb5b | |
Brianna | 1f580ba083 | |
Brianna | 4e3665a661 | |
Brianna | 645afe9d60 | |
Brianna | 47b3fd58a3 | |
Brianna | 166d1c3a2c | |
Brianna | b00dc9ec69 | |
Brianna | ade1ebdede | |
Brianna | e8e633164f | |
Brianna | d7109d1258 | |
Brianna | 5c183748f7 | |
Brianna | 2f32e940e2 | |
Brianna | d1533cd096 | |
Brianna | 4fcf8577c9 | |
Brianna | 51ca041eed | |
Brianna | 3fe08e370c | |
Brianna | c523a76b8f | |
Brianna | 6f6f44b021 |
328
LICENSE
328
LICENSE
|
@ -1,9 +1,327 @@
|
|||
Copyright (c) 2018 Brianna O’Keefe
|
||||
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0
|
||||
International Public License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software with minimal restriction, including the rights to use, copy, modify or merge while excluding the rights to publish, (re)distribute, sub-license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution-NonCommercial-NoDerivatives 4.0 International Public
|
||||
License ("Public License"). To the extent this Public License may be
|
||||
interpreted as a contract, You are granted the Licensed Rights in
|
||||
consideration of Your acceptance of these terms and conditions, and the
|
||||
Licensor grants You such rights in consideration of benefits the
|
||||
Licensor receives from making the Licensed Material available under
|
||||
these terms and conditions.
|
||||
|
||||
The same distribution rights and limitations above shall similarly apply to any and all source code, and other means that can be used to emulate this work.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
Section 1 -- Definitions.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
c. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
d. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
e. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
f. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
g. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
h. NonCommercial means not primarily intended for or directed towards
|
||||
commercial advantage or monetary compensation. For purposes of
|
||||
this Public License, the exchange of the Licensed Material for
|
||||
other material subject to Copyright and Similar Rights by digital
|
||||
file-sharing or similar means is NonCommercial provided there is
|
||||
no payment of monetary compensation in connection with the
|
||||
exchange.
|
||||
|
||||
i. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part, for NonCommercial purposes only; and
|
||||
|
||||
b. produce and reproduce, but not Share, Adapted Material
|
||||
for NonCommercial purposes only.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties, including when
|
||||
the Licensed Material is used other than for NonCommercial
|
||||
purposes.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material, You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
For the avoidance of doubt, You do not have permission under
|
||||
this Public License to Share Adapted Material.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database for NonCommercial purposes
|
||||
only and provided You do not Share Adapted Material;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
=======================================================================
|
||||
|
|
44
README.md
44
README.md
|
@ -1 +1,43 @@
|
|||
ultimatemoderation
|
||||
<!--suppress HtmlDeprecatedAttribute -->
|
||||
<div align="center">
|
||||
<img src="docs/Logo.png" width="128px">
|
||||
|
||||
# UltimateModeration
|
||||
**Take complete control over your server with punishment templates via a simplified yet powerful moderation system**
|
||||
|
||||
|
||||
[![Discord][Discord shield]][Discord invite]
|
||||
<br>
|
||||
[![Latest version][Latest version shield]][Plugin page]
|
||||
[![bStats Servers][bStats shield]][bStats page]
|
||||
</div>
|
||||
|
||||
|
||||
## Download (Marketplace)
|
||||
You can visit [our marketplace][Plugin page] to download UltimateModeration as well as take a
|
||||
look at many other fantastic plugins which are sure to catch your eye.
|
||||
|
||||
## Documentation
|
||||
You can find all the information about UltimateModeration, including dependencies, commands, permissions and incompatible
|
||||
plugins on [our wiki][Plugin wiki].
|
||||
|
||||
Feel free to also contribute to the wiki as a way to help others in the community with using the plugin.
|
||||
|
||||
## Support
|
||||
If you encounter any issues while using the plugin, feel free to contact us on
|
||||
[our Discord server][Discord invite].
|
||||
|
||||
## Suggestions
|
||||
For suggestions about features you think should be added to the plugin to increase its functionality, feel free to
|
||||
create a thread over on [our Discord server][Discord invite].
|
||||
|
||||
|
||||
[Plugin page]: https://songoda.com/product/15
|
||||
[Plugin wiki]: https://songoda.notion.site/UltimateModeration-5864be55f762467a8accedc9368a53a2
|
||||
[Discord invite]: https://discord.gg/7TXM8xr2Ng
|
||||
|
||||
[Discord shield]: https://img.shields.io/discord/1214289374506917889?color=5865F2&label=Discord&logo=discord&logoColor=5865F2
|
||||
[Latest version shield]: https://img.shields.io/badge/dynamic/xml?style=flat&color=blue&logo=github&logoColor=white&label=Latest&url=https%3A%2F%2Fraw.githubusercontent.com%2Fcraftaro%2FUltimateModeration%2Fmaster%2Fpom.xml&query=%2F*%5Blocal-name()%3D'project'%5D%2F*%5Blocal-name()%3D'version'%5D
|
||||
|
||||
[bStats page]: https://bstats.org/plugin/bukkit/UltimateModeration/4346
|
||||
[bStats shield]: https://img.shields.io/bstats/servers/4346?label=Servers
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 114 KiB |
59
pom.xml
59
pom.xml
|
@ -2,24 +2,29 @@
|
|||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateModeration</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>1.2.4</version>
|
||||
<version>2.0.15</version>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>UltimateModeration-${project.version}</finalName>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.3</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>prepare-package</phase>
|
||||
|
@ -28,6 +33,7 @@
|
|||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
<configuration>
|
||||
<file>${project.build.directory}/classes/plugin.yml</file>
|
||||
<replacements>
|
||||
|
@ -38,10 +44,11 @@
|
|||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.3.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
|
@ -49,14 +56,17 @@
|
|||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:SongodaCore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
|
@ -67,6 +77,7 @@
|
|||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.songoda.core</pattern>
|
||||
|
@ -79,29 +90,51 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>private</id>
|
||||
<url>http://repo.songoda.com/artifactory/private/</url>
|
||||
<id>songoda-public</id>
|
||||
<url>https://repo.songoda.com/repository/public/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>spigotmc-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.15</version>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>2.6.19</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github.MilkBowl</groupId>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<version>1.7</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>abledskyblock</artifactId>
|
||||
<version>79.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>maven-version-number</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -6,33 +6,30 @@ import com.songoda.core.commands.CommandManager;
|
|||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.database.DataMigrationManager;
|
||||
import com.songoda.core.database.DatabaseConnector;
|
||||
import com.songoda.core.database.MySQLConnector;
|
||||
import com.songoda.core.database.SQLiteConnector;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.ultimatemoderation.commands.*;
|
||||
import com.songoda.ultimatemoderation.database.DataManager;
|
||||
import com.songoda.ultimatemoderation.database.migrations._1_InitialMigration;
|
||||
import com.songoda.ultimatemoderation.listeners.*;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationManager;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.punish.player.PunishmentManager;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.punish.template.TemplateManager;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import com.songoda.ultimatemoderation.storage.Storage;
|
||||
import com.songoda.ultimatemoderation.storage.StorageRow;
|
||||
import com.songoda.ultimatemoderation.storage.types.StorageYaml;
|
||||
import com.songoda.ultimatemoderation.tasks.SlowModeTask;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketManager;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UltimateModeration extends SongodaPlugin {
|
||||
private static UltimateModeration INSTANCE;
|
||||
|
@ -43,8 +40,10 @@ public class UltimateModeration extends SongodaPlugin {
|
|||
private CommandManager commandManager;
|
||||
private PunishmentManager punishmentManager;
|
||||
private StaffChatManager staffChatManager;
|
||||
private ModerationManager moderationManager;
|
||||
|
||||
private Storage storage;
|
||||
private DatabaseConnector databaseConnector;
|
||||
private DataManager dataManager;
|
||||
|
||||
public static UltimateModeration getInstance() {
|
||||
return INSTANCE;
|
||||
|
@ -57,8 +56,6 @@ public class UltimateModeration extends SongodaPlugin {
|
|||
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
storage.doSave();
|
||||
this.storage.closeConnection();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -80,23 +77,17 @@ public class UltimateModeration extends SongodaPlugin {
|
|||
);
|
||||
this.commandManager.addCommand(new CommandBan(this));
|
||||
this.commandManager.addCommand(new CommandClearChat(this));
|
||||
this.commandManager.addCommand(new CommandCommandSpy(this));
|
||||
this.commandManager.addCommand(new CommandFreeze(this));
|
||||
this.commandManager.addCommand(new CommandInvSee(this));
|
||||
this.commandManager.addCommand(new CommandKick(this));
|
||||
this.commandManager.addCommand(new CommandMute(this));
|
||||
this.commandManager.addCommand(new CommandRandomPlayer(this));
|
||||
this.commandManager.addCommand(new CommandRevive(this));
|
||||
this.commandManager.addCommand(new CommandRunTemplate(this));
|
||||
this.commandManager.addCommand(new CommandSlowMode(this));
|
||||
this.commandManager.addCommand(new CommandSpy(this));
|
||||
this.commandManager.addCommand(new CommandStaffChat(this));
|
||||
this.commandManager.addCommand(new CommandTicket(this));
|
||||
this.commandManager.addCommand(new CommandTicket(this, guiManager));
|
||||
this.commandManager.addCommand(new CommandToggleChat(this));
|
||||
this.commandManager.addCommand(new CommandUnBan(this));
|
||||
this.commandManager.addCommand(new CommandUnMute(this));
|
||||
this.commandManager.addCommand(new CommandVanish(this));
|
||||
this.commandManager.addCommand(new CommandViewEnderChest(this));
|
||||
this.commandManager.addCommand(new CommandVanish());
|
||||
this.commandManager.addCommand(new CommandWarn(this));
|
||||
|
||||
// Setup Managers
|
||||
|
@ -104,14 +95,40 @@ public class UltimateModeration extends SongodaPlugin {
|
|||
this.templateManager = new TemplateManager();
|
||||
this.punishmentManager = new PunishmentManager();
|
||||
this.staffChatManager = new StaffChatManager();
|
||||
this.moderationManager = new ModerationManager(this);
|
||||
|
||||
// Load data
|
||||
this.checkStorage();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, this::loadFromFile, 1L);
|
||||
|
||||
try {
|
||||
if (Settings.MYSQL_ENABLED.getBoolean()) {
|
||||
String hostname = Settings.MYSQL_HOSTNAME.getString();
|
||||
int port = Settings.MYSQL_PORT.getInt();
|
||||
String database = Settings.MYSQL_DATABASE.getString();
|
||||
String username = Settings.MYSQL_USERNAME.getString();
|
||||
String password = Settings.MYSQL_PASSWORD.getString();
|
||||
boolean useSSL = Settings.MYSQL_USE_SSL.getBoolean();
|
||||
int poolSize = Settings.MYSQL_POOL_SIZE.getInt();
|
||||
|
||||
this.databaseConnector = new MySQLConnector(this, hostname, port, database, username, password, useSSL, poolSize);
|
||||
this.getLogger().info("Data handler connected using MySQL.");
|
||||
} else {
|
||||
this.databaseConnector = new SQLiteConnector(this);
|
||||
this.getLogger().info("Data handler connected using SQLite.");
|
||||
}
|
||||
|
||||
this.dataManager = new DataManager(this.databaseConnector, this);
|
||||
DataMigrationManager dataMigrationManager = new DataMigrationManager(this.databaseConnector, this.dataManager,
|
||||
new _1_InitialMigration());
|
||||
dataMigrationManager.runMigrations();
|
||||
|
||||
} catch (Exception ex) {
|
||||
this.getLogger().severe("Fatal error trying to connect to database. " +
|
||||
"Please make sure all your connection settings are correct and try again. Plugin has been disabled.");
|
||||
emergencyStop();
|
||||
return;
|
||||
}
|
||||
|
||||
// Register Listeners
|
||||
guiManager.init();
|
||||
AbstractGUI.initializeListeners(this);
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
pluginManager.registerEvents(new CommandListener(this), this);
|
||||
pluginManager.registerEvents(new DeathListener(this), this);
|
||||
|
@ -130,85 +147,30 @@ public class UltimateModeration extends SongodaPlugin {
|
|||
|
||||
// Start tasks
|
||||
SlowModeTask.startTask(this);
|
||||
|
||||
int timeout = Settings.AUTOSAVE.getInt() * 60 * 20;
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> storage.doSave(), timeout, timeout);
|
||||
}
|
||||
|
||||
private void checkStorage() {
|
||||
this.storage = new StorageYaml(this);
|
||||
}
|
||||
|
||||
private void loadFromFile() {
|
||||
if (storage.containsGroup("templates")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("templates")) {
|
||||
Template template = new Template(PunishmentType.valueOf(row.get("type").asString()),
|
||||
row.get("duration").asLong(),
|
||||
row.get("reason").asString(),
|
||||
UUID.fromString(row.get("creator").asString()),
|
||||
row.get("name").asString(),
|
||||
UUID.fromString(row.get("uuid").asString()));
|
||||
templateManager.addTemplate(template);
|
||||
}
|
||||
}
|
||||
if (storage.containsGroup("punishments")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("punishments")) {
|
||||
UUID playerUUID = UUID.fromString(row.get("victim").asString());
|
||||
AppliedPunishment appliedPunishment = new AppliedPunishment(PunishmentType.valueOf(row.get("type").asString()),
|
||||
row.get("duration").asLong(),
|
||||
row.get("reason").asString(),
|
||||
UUID.fromString(row.get("victim").asString()),
|
||||
UUID.fromString(row.get("punisher").asString()),
|
||||
row.get("expiration").asLong(),
|
||||
playerUUID);
|
||||
PlayerPunishData playerPunishData = getPunishmentManager().getPlayer(playerUUID);
|
||||
playerPunishData.addPunishment(appliedPunishment);
|
||||
playerPunishData.audit();
|
||||
}
|
||||
}
|
||||
|
||||
if (storage.containsGroup("notes")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("notes")) {
|
||||
UUID playerUUID = UUID.fromString(row.get("subject").asString());
|
||||
PunishmentNote note = new PunishmentNote(UUID.fromString(row.get("uuid").asString()),
|
||||
row.get("note").asString(),
|
||||
UUID.fromString(row.get("author").asString()),
|
||||
UUID.fromString(row.get("subject").asString()),
|
||||
row.get("creation").asLong());
|
||||
|
||||
PlayerPunishData playerPunishData = getPunishmentManager().getPlayer(playerUUID);
|
||||
playerPunishData.addNotes(note);
|
||||
}
|
||||
}
|
||||
|
||||
if (storage.containsGroup("tickets")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("tickets")) {
|
||||
|
||||
int id = row.get("id").asInt();
|
||||
Ticket ticket = new Ticket(
|
||||
UUID.fromString(row.get("player").asString()),
|
||||
row.get("subject").asString(),
|
||||
row.get("type").asString());
|
||||
ticket.setTicketId(id);
|
||||
ticket.setLocation(Methods.unserializeLocation(row.get("location").asString()));
|
||||
ticket.setStatus(TicketStatus.valueOf(row.get("status").asString()));
|
||||
ticketManager.addTicket(ticket, id);
|
||||
}
|
||||
}
|
||||
|
||||
if (storage.containsGroup("ticketresponses")) {
|
||||
for (StorageRow row : storage.getRowsByGroup("ticketresponses")) {
|
||||
int id = row.get("ticketid").asInt();
|
||||
TicketResponse ticketResponse = new TicketResponse(
|
||||
UUID.fromString(row.get("author").asString()),
|
||||
row.get("message").asString(),
|
||||
row.get("posted").asLong());
|
||||
ticketResponse.setTicketId(id);
|
||||
ticketManager.getTicket(id).addResponse(ticketResponse);
|
||||
|
||||
}
|
||||
}
|
||||
storage.doSave();
|
||||
@Override
|
||||
public void onDataLoad() {
|
||||
getDataManager().runAsync(() -> {
|
||||
// Load data from DB
|
||||
this.dataManager.getTemplates((templates) -> {
|
||||
for (Template template : templates) {
|
||||
this.templateManager.addTemplate(template);
|
||||
}
|
||||
});
|
||||
this.dataManager.getAppliedPunishments((appliedPunishments) -> {
|
||||
for (AppliedPunishment punishment : appliedPunishments)
|
||||
this.punishmentManager.getPlayer(punishment.getVictim()).addPunishment(punishment);
|
||||
});
|
||||
this.dataManager.getNotes((notes) -> {
|
||||
for (PunishmentNote note : notes)
|
||||
this.punishmentManager.getPlayer(note.getSubject()).addNotes(note);
|
||||
});
|
||||
this.dataManager.getTickets((tickets) -> {
|
||||
for (Ticket ticket : tickets.values())
|
||||
this.ticketManager.addTicket(ticket);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -241,4 +203,20 @@ public class UltimateModeration extends SongodaPlugin {
|
|||
public StaffChatManager getStaffChatManager() {
|
||||
return staffChatManager;
|
||||
}
|
||||
|
||||
public DataManager getDataManager() {
|
||||
return dataManager;
|
||||
}
|
||||
|
||||
public DatabaseConnector getDatabaseConnector() {
|
||||
return databaseConnector;
|
||||
}
|
||||
|
||||
public GuiManager getGuiManager() {
|
||||
return guiManager;
|
||||
}
|
||||
|
||||
public ModerationManager getModerationManager() {
|
||||
return moderationManager;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.songoda.ultimatemoderation.UltimateModeration;
|
|||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.VaultPermissions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -17,11 +18,11 @@ import java.util.List;
|
|||
|
||||
public class CommandBan extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandBan(UltimateModeration instance) {
|
||||
public CommandBan(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "Ban");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,29 +49,27 @@ public class CommandBan extends AbstractCommand {
|
|||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist.").sendMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && player.getPlayer().hasPermission("um.ban.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot ban this player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (instance.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
if (plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) {
|
||||
instance.getLocale().newMessage("That player is already banned.").sendPrefixedMessage(sender);
|
||||
plugin.getLocale().newMessage("That player is already banned.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (duration == 0 && !sender.hasPermission("um.ban.permanent")) {
|
||||
instance.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender);
|
||||
plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
new Punishment(PunishmentType.BAN, duration == 0 ? -1 : duration, reason.equals("") ? null : reason)
|
||||
.execute(sender, player);
|
||||
long durationFinal = duration;
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.ban.exempt")) {
|
||||
plugin.getLocale().newMessage("You cannot ban this player.").sendPrefixedMessage(sender);
|
||||
return;
|
||||
}
|
||||
|
||||
new Punishment(PunishmentType.BAN, durationFinal == 0 ? -1 : durationFinal, reason.equals("") ? null : reason)
|
||||
.execute(sender, player);
|
||||
});
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
|
|
@ -12,11 +12,11 @@ import java.util.List;
|
|||
|
||||
public class CommandClearChat extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandClearChat(UltimateModeration instance) {
|
||||
public CommandClearChat(UltimateModeration plugin) {
|
||||
super(CommandType.PLAYER_ONLY, "ClearChat");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,11 +32,11 @@ public class CommandClearChat extends AbstractCommand {
|
|||
player.sendMessage(toSend);
|
||||
}
|
||||
|
||||
instance.getLocale().getMessage("command.clearchat.cleared")
|
||||
plugin.getLocale().getMessage("command.clearchat.cleared")
|
||||
.processPlaceholder("player", sender.getName()).sendPrefixedMessage(player);
|
||||
|
||||
if (player.hasPermission("um.clearchat.bypass") && !isForced(args)) {
|
||||
instance.getLocale().getMessage("command.clearchat.immune").sendMessage(player);
|
||||
plugin.getLocale().getMessage("command.clearchat.immune").sendMessage(player);
|
||||
}
|
||||
}
|
||||
return ReturnType.SUCCESS;
|
||||
|
|
|
@ -1,59 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandCommandSpy extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private static List<UUID> inSpy = new ArrayList<>();
|
||||
|
||||
public CommandCommandSpy(UltimateModeration instance) {
|
||||
super(CommandType.CONSOLE_OK, "CommandSpy");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public static boolean isSpying(Player player) {
|
||||
return !inSpy.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player player = ((Player) sender);
|
||||
|
||||
if (inSpy.contains(player.getUniqueId())) {
|
||||
inSpy.remove(player.getUniqueId());
|
||||
instance.getLocale().getMessage("command.commandspy.toggleOn").sendPrefixedMessage(player);
|
||||
} else {
|
||||
inSpy.add(player.getUniqueId());
|
||||
instance.getLocale().getMessage("command.commandspy.toggleOff").sendPrefixedMessage(player);
|
||||
}
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "Um.commandspy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/Commandspy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to see inside of a players enderchest.";
|
||||
}
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandFreeze extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private static List<UUID> frozen = new ArrayList<>();
|
||||
|
||||
public CommandFreeze(UltimateModeration instance) {
|
||||
super(CommandType.CONSOLE_OK, "Freeze");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public static void freeze(OfflinePlayer player, CommandSender sender) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
if (frozen.contains(player.getUniqueId())) {
|
||||
frozen.remove(player.getUniqueId());
|
||||
instance.getLocale().getMessage("command.freeze.remove")
|
||||
.processPlaceholder("player", player.getPlayer().getDisplayName()).sendPrefixedMessage(sender);
|
||||
instance.getLocale().getMessage("command.freeze.alertremove").sendPrefixedMessage(sender);
|
||||
} else {
|
||||
frozen.add(player.getUniqueId());
|
||||
instance.getLocale().getMessage("command.freeze.add")
|
||||
.processPlaceholder("player", player.getPlayer().getDisplayName()).sendPrefixedMessage(sender);
|
||||
instance.getLocale().getMessage("command.freeze.alertadd").sendPrefixedMessage(player.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFrozen(OfflinePlayer player) {
|
||||
return frozen.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && player.hasPermission("um.freeze.exempt")) {
|
||||
instance.getLocale().newMessage("That player cannot be frozen.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
freeze(player, sender);
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.freeze";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/Freeze <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to freeze a player.";
|
||||
}
|
||||
}
|
|
@ -9,23 +9,23 @@ import java.util.List;
|
|||
|
||||
public class CommandHelp extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandHelp(UltimateModeration instance) {
|
||||
public CommandHelp(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "help");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
instance.getLocale().getMessage("&7Version " + instance.getDescription().getVersion() + " Created with <3 by &5&l&oSongoda")
|
||||
plugin.getLocale().getMessage("&7Version " + plugin.getDescription().getVersion() + " Created with <3 by &5&l&oSongoda")
|
||||
.sendPrefixedMessage(sender);
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(Methods.formatText("&7Welcome to UltimateModeration! To get started try using the /um command to access the moderation panel."));
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(Methods.formatText("&6Commands:"));
|
||||
for (AbstractCommand command : instance.getCommandManager().getAllCommands()) {
|
||||
for (AbstractCommand command : plugin.getCommandManager().getAllCommands()) {
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
sender.sendMessage(Methods.formatText("&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||
}
|
||||
|
|
|
@ -15,11 +15,11 @@ import java.util.List;
|
|||
|
||||
public class CommandKick extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandKick(UltimateModeration instance) {
|
||||
public CommandKick(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "Kick");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -39,13 +39,8 @@ public class CommandKick extends AbstractCommand {
|
|||
|
||||
OfflinePlayer player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && player.getPlayer().hasPermission("um.kick.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot kick this player.").sendPrefixedMessage(sender);
|
||||
plugin.getLocale().newMessage("You cannot kick this player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.songoda.ultimatemoderation.UltimateModeration;
|
|||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.VaultPermissions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -17,11 +18,11 @@ import java.util.List;
|
|||
|
||||
public class CommandMute extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandMute(UltimateModeration instance) {
|
||||
public CommandMute(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "Mute");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,19 +49,14 @@ public class CommandMute extends AbstractCommand {
|
|||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist.").sendPrefixedMessage(sender);
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.mute.exempt")) {
|
||||
plugin.getLocale().newMessage("You cannot mute that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && player.getPlayer().hasPermission("um.mute.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot mute that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (instance.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
if (plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) {
|
||||
instance.getLocale().newMessage("That player is already muted.").sendPrefixedMessage(sender);
|
||||
plugin.getLocale().newMessage("That player is already muted.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,11 +12,11 @@ import java.util.List;
|
|||
|
||||
public class CommandRandomPlayer extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandRandomPlayer(UltimateModeration instance) {
|
||||
public CommandRandomPlayer(UltimateModeration plugin) {
|
||||
super(CommandType.PLAYER_ONLY, "RandomPlayer");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,7 +26,7 @@ public class CommandRandomPlayer extends AbstractCommand {
|
|||
players.remove(sender);
|
||||
|
||||
if (players.size() == 0) {
|
||||
instance.getLocale().newMessage("&c You are the only one online!").sendPrefixedMessage(sender);
|
||||
plugin.getLocale().newMessage("&cYou are the only one online!").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,17 +8,17 @@ import java.util.List;
|
|||
|
||||
public class CommandReload extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandReload(UltimateModeration instance) {
|
||||
public CommandReload(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "reload");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
instance.reloadConfig();
|
||||
instance.getLocale().newMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||
plugin.reloadConfig();
|
||||
plugin.getLocale().newMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,90 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.listeners.DeathListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandRevive extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
|
||||
public CommandRevive(UltimateModeration instance) {
|
||||
super(CommandType.CONSOLE_OK, "Revive");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (!(revive(player, sender))) return ReturnType.FAILURE;
|
||||
|
||||
instance.getLocale().getMessage("command.revive.revived").sendPrefixedMessage(player);
|
||||
instance.getLocale().getMessage("command.revive.success")
|
||||
.processPlaceholder("player", player.getName()).sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean revive(Player player, CommandSender sender) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
List<ItemStack> drops = DeathListener.getLastDrop(player);
|
||||
|
||||
if (drops == null) {
|
||||
instance.getLocale().getMessage("command.revive.noloot").sendPrefixedMessage(sender);
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack[] dropArr = new ItemStack[drops.size()];
|
||||
dropArr = drops.toArray(dropArr);
|
||||
|
||||
HashMap<Integer, ItemStack> leftOver = player.getInventory().addItem(dropArr);
|
||||
|
||||
for (ItemStack item : leftOver.values()) {
|
||||
player.getWorld().dropItemNaturally(player.getLocation(), item);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.revive";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/Revive <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to revive a player.";
|
||||
}
|
||||
}
|
|
@ -13,11 +13,11 @@ import java.util.List;
|
|||
|
||||
public class CommandRunTemplate extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandRunTemplate(UltimateModeration instance) {
|
||||
public CommandRunTemplate(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "RunTemplate");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,11 +27,6 @@ public class CommandRunTemplate extends AbstractCommand {
|
|||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
StringBuilder templateBuilder = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
String line = args[i];
|
||||
|
@ -39,7 +34,7 @@ public class CommandRunTemplate extends AbstractCommand {
|
|||
}
|
||||
String templateStr = templateBuilder.toString().trim();
|
||||
|
||||
Template template = instance.getTemplateManager().getTemplate(templateStr);
|
||||
Template template = plugin.getTemplateManager().getTemplate(templateStr);
|
||||
|
||||
if (template == null) {
|
||||
sender.sendMessage("That template does not exist...");
|
||||
|
@ -61,8 +56,8 @@ public class CommandRunTemplate extends AbstractCommand {
|
|||
return players;
|
||||
} else if (args.length == 2) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
for (Template template : instance.getTemplateManager().getTemplates().values()) {
|
||||
lines.add(template.getTemplateName());
|
||||
for (Template template : plugin.getTemplateManager().getTemplates()) {
|
||||
lines.add(template.getName());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -11,19 +11,19 @@ import java.util.List;
|
|||
|
||||
public class CommandSettings extends AbstractCommand {
|
||||
|
||||
final UltimateModeration instance;
|
||||
final GuiManager guiManager;
|
||||
private final UltimateModeration plugin;
|
||||
private final GuiManager guiManager;
|
||||
|
||||
public CommandSettings(UltimateModeration instance, GuiManager manager) {
|
||||
public CommandSettings(UltimateModeration plugin, GuiManager manager) {
|
||||
super(CommandType.PLAYER_ONLY, "settings");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
this.guiManager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
guiManager.showGUI((Player) sender, new PluginConfigGui(instance));
|
||||
guiManager.showGUI((Player) sender, new PluginConfigGui(plugin));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,18 +13,18 @@ import java.util.List;
|
|||
|
||||
public class CommandSlowMode extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandSlowMode(UltimateModeration instance) {
|
||||
public CommandSlowMode(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "Slowmode");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length == 0) {
|
||||
ChatListener.setSlowModeOverride(0);
|
||||
instance.getLocale().getMessage("event.slowmode.disabled").sendPrefixedMessage(sender);
|
||||
plugin.getLocale().getMessage("event.slowmode.disabled").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
} else if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
@ -34,7 +34,7 @@ public class CommandSlowMode extends AbstractCommand {
|
|||
ChatListener.setSlowModeOverride(delay);
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(player ->
|
||||
instance.getLocale().getMessage("event.slowmode.enabled")
|
||||
plugin.getLocale().getMessage("event.slowmode.enabled")
|
||||
.processPlaceholder("delay", Methods.makeReadable(delay)).sendPrefixedMessage(player));
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
|
|
|
@ -11,11 +11,11 @@ import java.util.List;
|
|||
|
||||
public class CommandStaffChat extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandStaffChat(UltimateModeration instance) {
|
||||
public CommandStaffChat(UltimateModeration plugin) {
|
||||
super(CommandType.PLAYER_ONLY, "StaffChat");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -27,24 +27,26 @@ public class CommandStaffChat extends AbstractCommand {
|
|||
Player player = (Player) sender;
|
||||
|
||||
if (channelName.trim().equalsIgnoreCase("leave")) {
|
||||
for (StaffChannel channel : instance.getStaffChatManager().getChats().values()) {
|
||||
for (StaffChannel channel : plugin.getStaffChatManager().getChats().values()) {
|
||||
if (!channel.listMembers().contains(player.getUniqueId())) continue;
|
||||
channel.removeMember(player);
|
||||
instance.getLocale().getMessage("event.staffchat.leave")
|
||||
plugin.getLocale().getMessage("event.staffchat.leave")
|
||||
.processPlaceholder("channel", channel.getChannelName()).sendPrefixedMessage(player);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
instance.getLocale().getMessage("event.staffchat.nochannels").sendPrefixedMessage(player);
|
||||
plugin.getLocale().getMessage("event.staffchat.nochannels").sendPrefixedMessage(player);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
instance.getStaffChatManager().getChat(channelName).addMember(player);
|
||||
plugin.getLocale().getMessage("event.staffchat.join")
|
||||
.processPlaceholder("channel", channelName).sendPrefixedMessage(player);
|
||||
plugin.getStaffChatManager().getChat(channelName).addMember(player);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return new ArrayList<>(instance.getStaffChatManager().getChats().keySet());
|
||||
return new ArrayList<>(plugin.getStaffChatManager().getChats().keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.gui.GUITicketManager;
|
||||
import com.songoda.ultimatemoderation.gui.TicketManagerGui;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -10,18 +11,19 @@ import java.util.List;
|
|||
|
||||
public class CommandTicket extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
private final GuiManager guiManager;
|
||||
|
||||
public CommandTicket(UltimateModeration instance) {
|
||||
public CommandTicket(UltimateModeration plugin, GuiManager guiManager) {
|
||||
super(CommandType.PLAYER_ONLY, "Ticket");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
this.guiManager = guiManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player senderP = ((Player) sender);
|
||||
|
||||
new GUITicketManager(instance, senderP, senderP);
|
||||
guiManager.showGUI(senderP, new TicketManagerGui(plugin, senderP, senderP));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,24 +12,24 @@ import java.util.List;
|
|||
|
||||
public class CommandToggleChat extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
/*
|
||||
* Chat is enabled by default ;)
|
||||
*/
|
||||
private boolean toggled = true;
|
||||
|
||||
public CommandToggleChat(UltimateModeration instance) {
|
||||
public CommandToggleChat(UltimateModeration plugin) {
|
||||
super(CommandType.PLAYER_ONLY, "togglechat");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
toggled = !toggled;
|
||||
|
||||
Message message = toggled ? instance.getLocale().getMessage("command.togglechat.toggledOn")
|
||||
: instance.getLocale().getMessage("command.togglechat.toggledOff");
|
||||
Message message = toggled ? plugin.getLocale().getMessage("command.togglechat.toggledOn")
|
||||
: plugin.getLocale().getMessage("command.togglechat.toggledOff");
|
||||
|
||||
ChatListener.setChatToggled(toggled);
|
||||
|
||||
|
@ -40,7 +40,7 @@ public class CommandToggleChat extends AbstractCommand {
|
|||
if (!player.hasPermission(getPermissionNode() + ".bypass"))
|
||||
continue;
|
||||
|
||||
instance.getLocale().getMessage("command.togglechat.bypass").sendMessage(player);
|
||||
plugin.getLocale().getMessage("command.togglechat.bypass").sendMessage(player);
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
|
|
|
@ -2,7 +2,7 @@ package com.songoda.ultimatemoderation.commands;
|
|||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.gui.GUIPlayers;
|
||||
import com.songoda.ultimatemoderation.gui.MainGui;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -10,16 +10,16 @@ import java.util.List;
|
|||
|
||||
public class CommandUltimateModeration extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandUltimateModeration(UltimateModeration instance) {
|
||||
public CommandUltimateModeration(UltimateModeration plugin) {
|
||||
super(CommandType.PLAYER_ONLY, "UltimateModeration");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
new GUIPlayers(instance, (Player) sender);
|
||||
plugin.getGuiManager().showGUI((Player) sender, new MainGui(plugin, (Player) sender));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -40,6 +40,6 @@ public class CommandUltimateModeration extends AbstractCommand {
|
|||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Displays this page.";
|
||||
return "Displays the moderation panel.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ import java.util.List;
|
|||
|
||||
public class CommandUnBan extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandUnBan(UltimateModeration instance) {
|
||||
public CommandUnBan(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "UnBan");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,22 +28,17 @@ public class CommandUnBan extends AbstractCommand {
|
|||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (!instance.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
if (!plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) {
|
||||
instance.getLocale().newMessage("That player isn't banned.").sendPrefixedMessage(sender);
|
||||
plugin.getLocale().newMessage("That player isn't banned.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
PlayerPunishData playerPunishData = instance.getPunishmentManager().getPlayer(player);
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(player);
|
||||
|
||||
playerPunishData.expirePunishments(PunishmentType.BAN);
|
||||
|
||||
instance.getLocale().getMessage("event.unban.success")
|
||||
plugin.getLocale().getMessage("event.unban.success")
|
||||
.processPlaceholder("player", player.getName()).sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
@ -72,6 +67,6 @@ public class CommandUnBan extends AbstractCommand {
|
|||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to ban players.";
|
||||
return "Allows you to unban players.";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ import java.util.List;
|
|||
|
||||
public class CommandUnMute extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandUnMute(UltimateModeration instance) {
|
||||
public CommandUnMute(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "UnMute");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -28,22 +28,17 @@ public class CommandUnMute extends AbstractCommand {
|
|||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (!instance.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
if (!plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) {
|
||||
instance.getLocale().newMessage("That player isn't muted.").sendPrefixedMessage(sender);
|
||||
plugin.getLocale().newMessage("That player isn't muted.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
PlayerPunishData playerPunishData = instance.getPunishmentManager().getPlayer(player);
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(player);
|
||||
|
||||
playerPunishData.expirePunishments(PunishmentType.MUTE);
|
||||
|
||||
instance.getLocale().newMessage(instance.getLocale().getMessage("event.unmute.success")
|
||||
plugin.getLocale().newMessage(plugin.getLocale().getMessage("event.unmute.success")
|
||||
.processPlaceholder("player", player.getName()).getMessage()).sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
|
|
@ -19,13 +19,10 @@ import java.util.UUID;
|
|||
|
||||
public class CommandVanish extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private static final List<UUID> inVanish = new ArrayList<>();
|
||||
|
||||
private static List<UUID> inVanish = new ArrayList<>();
|
||||
|
||||
public CommandVanish(UltimateModeration instance) {
|
||||
public CommandVanish() {
|
||||
super(CommandType.PLAYER_ONLY, "Vanish");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
public static void registerVanishedPlayers(Player player) {
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandViewEnderChest extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
|
||||
public CommandViewEnderChest(UltimateModeration instance) {
|
||||
super(CommandType.PLAYER_ONLY, "ViewEnderChest");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.viewenderchest.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot view the enderchest of that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
((Player) sender).openInventory(player.getEnderChest());
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.viewenderchest";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ViewEnderChest <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to see inside of a players enderchest.";
|
||||
}
|
||||
}
|
|
@ -5,6 +5,7 @@ import com.songoda.ultimatemoderation.UltimateModeration;
|
|||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.VaultPermissions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -17,11 +18,11 @@ import java.util.List;
|
|||
|
||||
public class CommandWarn extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandWarn(UltimateModeration instance) {
|
||||
public CommandWarn(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "Warn");
|
||||
this.instance = instance;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,13 +49,8 @@ public class CommandWarn extends AbstractCommand {
|
|||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (sender instanceof Player && player.getPlayer().hasPermission("um.warning.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot warn that player.").sendPrefixedMessage(sender);
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.warning.exempt")) {
|
||||
plugin.getLocale().newMessage("You cannot warn that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,375 @@
|
|||
package com.songoda.ultimatemoderation.database;
|
||||
|
||||
import com.songoda.core.database.DataManagerAbstract;
|
||||
import com.songoda.core.database.DatabaseConnector;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class DataManager extends DataManagerAbstract {
|
||||
|
||||
public DataManager(DatabaseConnector databaseConnector, Plugin plugin) {
|
||||
super(databaseConnector, plugin);
|
||||
}
|
||||
|
||||
public void createTemplate(Template template) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String createTemplate = "INSERT INTO " + this.getTablePrefix() + "templates (punishment_type, duration, reason, name, creator) VALUES (?, ?, ?, ?, ?)";
|
||||
PreparedStatement statement = connection.prepareStatement(createTemplate);
|
||||
statement.setString(1, template.getPunishmentType().name());
|
||||
statement.setLong(2, template.getDuration());
|
||||
statement.setString(3, template.getReason());
|
||||
statement.setString(4, template.getName());
|
||||
statement.setString(5, template.getCreator().toString());
|
||||
statement.executeUpdate();
|
||||
|
||||
int templateId = this.lastInsertedId(connection, "templates");
|
||||
template.setId(templateId);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteTemplate(Template template) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String deleteTemplate = "DELETE FROM " + this.getTablePrefix() + "templates WHERE id = ?";
|
||||
PreparedStatement statement = connection.prepareStatement(deleteTemplate);
|
||||
statement.setLong(1, template.getId());
|
||||
statement.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getTemplates(Consumer<List<Template>> callback) {
|
||||
List<Template> templates = new ArrayList<>();
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
Statement statement = connection.createStatement();
|
||||
String selectTemplates = "SELECT * FROM " + this.getTablePrefix() + "templates";
|
||||
ResultSet result = statement.executeQuery(selectTemplates);
|
||||
while (result.next()) {
|
||||
int id = result.getInt("id");
|
||||
PunishmentType punishmentType = PunishmentType.valueOf(result.getString("punishment_type"));
|
||||
long duration = result.getLong("duration");
|
||||
String reason = result.getString("reason");
|
||||
String name = result.getString("name");
|
||||
UUID creator = UUID.fromString(result.getString("creator"));
|
||||
Template template = new Template(punishmentType, duration, reason, creator, name);
|
||||
template.setId(id);
|
||||
templates.add(template);
|
||||
}
|
||||
|
||||
this.sync(() -> callback.accept(templates));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createAppliedPunishment(AppliedPunishment punishment) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String createPunishment = "INSERT INTO " + this.getTablePrefix() + "punishments (type, duration, reason, victim, punisher, expiration) VALUES (?, ?, ?, ?, ?, ?)";
|
||||
PreparedStatement statement = connection.prepareStatement(createPunishment);
|
||||
statement.setString(1, punishment.getPunishmentType().name());
|
||||
statement.setLong(2, punishment.getDuration());
|
||||
statement.setString(3, punishment.getReason());
|
||||
statement.setString(4, punishment.getVictim().toString());
|
||||
statement.setString(5, punishment.getPunisher().toString());
|
||||
statement.setLong(6, punishment.getExpiration());
|
||||
statement.executeUpdate();
|
||||
|
||||
int punishmentId = this.lastInsertedId(connection, "punishments");
|
||||
punishment.setId(punishmentId);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteAppliedPunishment(AppliedPunishment punishment) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String deletePunishment = "DELETE FROM " + this.getTablePrefix() + "punishments WHERE id = ?";
|
||||
PreparedStatement statement = connection.prepareStatement(deletePunishment);
|
||||
statement.setLong(1, punishment.getId());
|
||||
statement.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateAppliedPunishment(AppliedPunishment punishment) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String updatePunishment = "UPDATE " + this.getTablePrefix() + "punishments set type = ?, duration = ?, reason = ?, victim = ?, punisher = ?, expiration = ? WHERE id = ?";
|
||||
PreparedStatement statement = connection.prepareStatement(updatePunishment);
|
||||
statement.setString(1, punishment.getPunishmentType().name());
|
||||
statement.setLong(2, punishment.getDuration());
|
||||
statement.setString(3, punishment.getReason());
|
||||
statement.setString(4, punishment.getVictim().toString());
|
||||
statement.setString(5, punishment.getPunisher().toString());
|
||||
statement.setLong(6, punishment.getExpiration());
|
||||
statement.setLong(7, punishment.getId());
|
||||
statement.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getAppliedPunishments(Consumer<List<AppliedPunishment>> callback) {
|
||||
List<AppliedPunishment> appliedPunishments = new ArrayList<>();
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
Statement statement = connection.createStatement();
|
||||
String selectPunishments = "SELECT * FROM " + this.getTablePrefix() + "punishments";
|
||||
ResultSet result = statement.executeQuery(selectPunishments);
|
||||
while (result.next()) {
|
||||
int id = result.getInt("id");
|
||||
PunishmentType punishmentType = PunishmentType.valueOf(result.getString("type"));
|
||||
long duration = result.getLong("duration");
|
||||
String reason = result.getString("reason");
|
||||
UUID victim = UUID.fromString(result.getString("victim"));
|
||||
UUID punisher = UUID.fromString(result.getString("punisher"));
|
||||
long expiration = result.getLong("expiration");
|
||||
appliedPunishments.add(new AppliedPunishment(punishmentType, duration, reason, victim, punisher, expiration, id));
|
||||
}
|
||||
|
||||
this.sync(() -> callback.accept(appliedPunishments));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createNote(PunishmentNote note) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String createNote = "INSERT INTO " + this.getTablePrefix() + "notes (note, author, subject, creation) VALUES (?, ?, ?, ?)";
|
||||
PreparedStatement statement = connection.prepareStatement(createNote);
|
||||
statement.setString(1, note.getNote());
|
||||
statement.setString(2, note.getAuthor().toString());
|
||||
statement.setString(3, note.getSubject().toString());
|
||||
statement.setLong(4, note.getCreationDate());
|
||||
statement.executeUpdate();
|
||||
|
||||
int noteId = this.lastInsertedId(connection, "notes");
|
||||
note.setId(noteId);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteNote(PunishmentNote note) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String deleteNote = "DELETE FROM " + this.getTablePrefix() + "notes WHERE id = ?";
|
||||
PreparedStatement statement = connection.prepareStatement(deleteNote);
|
||||
statement.setLong(1, note.getId());
|
||||
statement.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getNotes(Consumer<List<PunishmentNote>> callback) {
|
||||
List<PunishmentNote> notes = new ArrayList<>();
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
Statement statement = connection.createStatement();
|
||||
String getNotes = "SELECT * FROM " + this.getTablePrefix() + "notes";
|
||||
ResultSet result = statement.executeQuery(getNotes);
|
||||
while (result.next()) {
|
||||
int id = result.getInt("id");
|
||||
String note = result.getString("note");
|
||||
UUID author = UUID.fromString(result.getString("author"));
|
||||
UUID subject = UUID.fromString(result.getString("subject"));
|
||||
long creation = result.getLong("creation");
|
||||
notes.add(new PunishmentNote(id, note, author, subject, creation));
|
||||
}
|
||||
|
||||
this.sync(() -> callback.accept(notes));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createTicket(Ticket ticket) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String createTicket = "INSERT INTO " + this.getTablePrefix() + "tickets (victim, subject, type, status, world, x, y, z, pitch, yaw) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
PreparedStatement statement = connection.prepareStatement(createTicket);
|
||||
statement.setString(1, ticket.getVictim().toString());
|
||||
statement.setString(2, ticket.getSubject());
|
||||
statement.setString(3, ticket.getType());
|
||||
statement.setString(4, ticket.getStatus().name());
|
||||
|
||||
Location location = ticket.getLocation();
|
||||
|
||||
statement.setString(5, location.getWorld().getName());
|
||||
statement.setDouble(6, location.getX());
|
||||
statement.setDouble(7, location.getY());
|
||||
statement.setDouble(8, location.getZ());
|
||||
statement.setFloat(9, location.getPitch());
|
||||
statement.setFloat(10, location.getYaw());
|
||||
statement.executeUpdate();
|
||||
|
||||
for (TicketResponse response : ticket.getResponses()) {
|
||||
createTicketResponse(response);
|
||||
}
|
||||
|
||||
int ticketId = this.lastInsertedId(connection, "tickets");
|
||||
ticket.setId(ticketId);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void deleteTicket(Ticket ticket) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String deleteTicket = "DELETE FROM " + this.getTablePrefix() + "tickets WHERE id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(deleteTicket)) {
|
||||
statement.setLong(1, ticket.getId());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
|
||||
String deleteTicketResponses = "DELETE FROM " + this.getTablePrefix() + "ticket_responses WHERE ticket_id = ?";
|
||||
try (PreparedStatement statement = connection.prepareStatement(deleteTicketResponses)) {
|
||||
statement.setLong(1, ticket.getId());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void updateTicket(Ticket ticket) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String updateTicket = "UPDATE " + this.getTablePrefix() + "tickets SET victim = ?, subject = ?, type = ?, status = ?, world = ?, x = ?, y = ?, z = ?, pitch = ?, yaw = ? WHERE id = ?";
|
||||
PreparedStatement statement = connection.prepareStatement(updateTicket);
|
||||
statement.setString(1, ticket.getVictim().toString());
|
||||
statement.setString(2, ticket.getSubject());
|
||||
statement.setString(3, ticket.getType());
|
||||
statement.setString(4, ticket.getStatus().name());
|
||||
|
||||
Location location = ticket.getLocation();
|
||||
|
||||
statement.setString(5, location.getWorld().getName());
|
||||
statement.setDouble(6, location.getX());
|
||||
statement.setDouble(7, location.getY());
|
||||
statement.setDouble(8, location.getZ());
|
||||
statement.setFloat(9, location.getPitch());
|
||||
statement.setFloat(10, location.getYaw());
|
||||
statement.setInt(11, ticket.getId());
|
||||
statement.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void getTickets(Consumer<Map<Integer, Ticket>> callback) {
|
||||
Map<Integer, Ticket> tickets = new TreeMap<>();
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
String selectTickets = "SELECT * FROM " + this.getTablePrefix() + "tickets";
|
||||
ResultSet result = statement.executeQuery(selectTickets);
|
||||
while (result.next()) {
|
||||
int id = result.getInt("id");
|
||||
UUID victim = UUID.fromString(result.getString("victim"));
|
||||
String subject = result.getString("subject");
|
||||
String type = result.getString("type");
|
||||
TicketStatus status = TicketStatus.valueOf(result.getString("status"));
|
||||
|
||||
String world = result.getString("world");
|
||||
double x = result.getDouble("x");
|
||||
double y = result.getDouble("y");
|
||||
double z = result.getDouble("z");
|
||||
float pitch = result.getFloat("pitch");
|
||||
float yaw = result.getFloat("yaw");
|
||||
|
||||
Location location = Bukkit.getWorld(world) == null ? null : new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch);
|
||||
|
||||
Ticket ticket = new Ticket(id, victim, subject, type, status, location);
|
||||
ticket.setId(id)
|
||||
;
|
||||
tickets.put(id, ticket);
|
||||
}
|
||||
}
|
||||
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
String selectTickets = "SELECT * FROM " + this.getTablePrefix() + "ticket_responses";
|
||||
ResultSet result = statement.executeQuery(selectTickets);
|
||||
while (result.next()) {
|
||||
int id = result.getInt("ticket_id");
|
||||
|
||||
Ticket ticket = tickets.get(id);
|
||||
if (ticket == null) continue;
|
||||
|
||||
UUID author = UUID.fromString(result.getString("author"));
|
||||
String message = result.getString("message");
|
||||
long postedDate = result.getLong("posted_date");
|
||||
|
||||
TicketResponse ticketResponse = new TicketResponse(author, message, postedDate);
|
||||
ticketResponse.setTicketId(id);
|
||||
|
||||
ticket.addResponse(ticketResponse);
|
||||
}
|
||||
}
|
||||
|
||||
this.sync(() -> callback.accept(tickets));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void createTicketResponse(TicketResponse ticketResponse) {
|
||||
this.runAsync(() -> {
|
||||
try (Connection connection = this.databaseConnector.getConnection()) {
|
||||
String createTicketResponse = "INSERT INTO " + this.getTablePrefix() + "ticket_responses (ticket_id, author, message, posted_date) VALUES (?, ?, ?, ?)";
|
||||
PreparedStatement statement = connection.prepareStatement(createTicketResponse);
|
||||
statement.setInt(1, ticketResponse.getTicketId());
|
||||
statement.setString(2, ticketResponse.getAuthor().toString());
|
||||
statement.setString(3, ticketResponse.getMessage());
|
||||
statement.setLong(4, ticketResponse.getPostedDate());
|
||||
statement.executeUpdate();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
package com.songoda.ultimatemoderation.database.migrations;
|
||||
|
||||
import com.songoda.core.database.DataMigration;
|
||||
import com.songoda.core.database.MySQLConnector;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
public class _1_InitialMigration extends DataMigration {
|
||||
|
||||
public _1_InitialMigration() {
|
||||
super(1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void migrate(Connection connection, String tablePrefix) throws SQLException {
|
||||
String autoIncrement = UltimateModeration.getInstance().getDatabaseConnector() instanceof MySQLConnector ? " AUTO_INCREMENT" : "";
|
||||
|
||||
// Create templates table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE " + tablePrefix + "templates (" +
|
||||
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
|
||||
"punishment_type VARCHAR(15) NOT NULL, " +
|
||||
"duration BIGINT NOT NULL," + // If -1 then its permanent
|
||||
"reason TEXT," + // If null then no reason is given
|
||||
"name VARCHAR(100), " +
|
||||
"creator VARCHAR(36) NOT NULL" +
|
||||
")");
|
||||
}
|
||||
|
||||
// Create punishments table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE " + tablePrefix + "punishments (" +
|
||||
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
|
||||
"type VARCHAR(15) NOT NULL, " +
|
||||
"duration BIGINT," + // If null then its permanent
|
||||
"reason TEXT," + // If null then no reason is given
|
||||
"victim VARCHAR(36) NOT NULL," +
|
||||
"punisher VARCHAR(36) NOT NULL," +
|
||||
"expiration BIGINT" + // If null then its permanent
|
||||
")");
|
||||
}
|
||||
|
||||
// Create notes table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE " + tablePrefix + "notes (" +
|
||||
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
|
||||
"note TEXT NOT NULL, " +
|
||||
"author VARCHAR(36) NOT NULL," +
|
||||
"subject VARCHAR (36) NOT NULL," +
|
||||
"creation BIGINT" +
|
||||
")");
|
||||
}
|
||||
|
||||
// Create tickets table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE " + tablePrefix + "tickets (" +
|
||||
"id INTEGER PRIMARY KEY" + autoIncrement + ", " +
|
||||
"victim VARCHAR(36) NOT NULL," +
|
||||
"subject TEXT NOT NULL," +
|
||||
"type VARCHAR(50) NOT NULL, " +
|
||||
"status VARCHAR(10) NOT NULL, " +
|
||||
"world TEXT NOT NULL, " +
|
||||
"x DOUBLE NOT NULL, " +
|
||||
"y DOUBLE NOT NULL, " +
|
||||
"z DOUBLE NOT NULL, " +
|
||||
"pitch FLOAT NOT NULL, " +
|
||||
"yaw FLOAT NOT NULL " +
|
||||
")");
|
||||
}
|
||||
|
||||
// Create ticket responses table
|
||||
try (Statement statement = connection.createStatement()) {
|
||||
statement.execute("CREATE TABLE " + tablePrefix + "ticket_responses (" +
|
||||
"ticket_id INTEGER NOT NULL, " +
|
||||
"author VARCHAR(36) NOT NULL," +
|
||||
"message TEXT NOT NULL," +
|
||||
"posted_date BIGINT" +
|
||||
")");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandFreeze;
|
||||
import com.songoda.ultimatemoderation.commands.CommandRevive;
|
||||
import com.songoda.ultimatemoderation.commands.CommandSpy;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GUIModerate extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final OfflinePlayer toModerate;
|
||||
private boolean freeze, spy, invsee, enderview, revive;
|
||||
|
||||
public GUIModerate(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
this.freeze = !toModerate.getPlayer().hasPermission("um.freeze.exempt") && player.hasPermission("um.freeze");
|
||||
this.spy = !toModerate.getPlayer().hasPermission("um.spy.exempt") && player.hasPermission("um.spy");
|
||||
this.invsee = !toModerate.getPlayer().hasPermission("um.invsee.exempt") && player.hasPermission("um.invsee");
|
||||
this.enderview = !toModerate.getPlayer().hasPermission("um.viewenderchest.exempt") && player.hasPermission("um.viewenderchest");
|
||||
this.revive = player.hasPermission("um.revive");
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.moderate.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage(), 45);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
|
||||
createButton(8, CompatibleMaterial.OAK_DOOR.getMaterial(), plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
if (freeze)
|
||||
createButton(10, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.BLUE_ICE : Material.valueOf("PACKED_ICE"), "&6&lFreeze", "&7Stop this player from moving.", "", "&7Currently:&6 " + (CommandFreeze.isFrozen(toModerate) ? "Frozen" : "Unfrozen"));
|
||||
if (spy) createButton(12, Material.SADDLE, "&6&lSpy", "&7Spy on this player");
|
||||
if (invsee) createButton(14, Material.CHEST, "&c&lInventory", "&7Access this players Inventory.");
|
||||
if (enderview) createButton(16, Material.ENDER_CHEST, "&a&lEnderchest", "&7Access this players Enderchest");
|
||||
if (revive)
|
||||
createButton(28, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.SPLASH_POTION : Material.valueOf("POTION"), "&c&lRevive", "&7Revive this player.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayer(plugin, toModerate, player1)));
|
||||
|
||||
if (freeze) {
|
||||
registerClickable(10, ((player1, inventory1, cursor, slot, type) -> {
|
||||
CommandFreeze.freeze(toModerate, player);
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (spy) {
|
||||
registerClickable(12, ((player1, inventory1, cursor, slot, type) -> {
|
||||
CommandSpy.spy(toModerate, player);
|
||||
player.closeInventory();
|
||||
}));
|
||||
}
|
||||
|
||||
if (invsee) {
|
||||
registerClickable(14, ((player1, inventory1, cursor, slot, type) ->
|
||||
player.openInventory(toModerate.getPlayer().getInventory())));
|
||||
}
|
||||
|
||||
if (enderview) {
|
||||
registerClickable(16, ((player1, inventory1, cursor, slot, type) ->
|
||||
player.openInventory(toModerate.getPlayer().getEnderChest())));
|
||||
}
|
||||
|
||||
if (revive) {
|
||||
registerClickable(28, ((player1, inventory1, cursor, slot, type) ->
|
||||
CommandRevive.revive(toModerate.getPlayer(), player)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
|
@ -1,148 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.utils.AbstractChatConfirm;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUINotesManager extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private int page = 0;
|
||||
|
||||
private boolean create, delete;
|
||||
|
||||
public GUINotesManager(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
this.create = player.hasPermission("um.notes.create");
|
||||
this.delete = player.hasPermission("um.notes.delete");
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.notes.title")
|
||||
.processPlaceholder("tonotes", player.getName()).getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
int numNotes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().size();
|
||||
int maxPage = (int) Math.floor(numNotes / 36.0);
|
||||
|
||||
List<PunishmentNote> notes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().stream()
|
||||
.skip(page * 36).limit(36).collect(Collectors.toList());
|
||||
|
||||
if (page != 0) {
|
||||
createButton(1, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (page != maxPage) {
|
||||
createButton(3, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
createButton(8, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.OAK_DOOR
|
||||
: Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
if (create) createButton(6, Material.REDSTONE, plugin.getLocale().getMessage("gui.notes.create").getMessage());
|
||||
|
||||
for (int i = 0; i < notes.size(); i++) {
|
||||
PunishmentNote note = notes.get(i);
|
||||
|
||||
String noteStr = note.getNote();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < noteStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (noteStr.charAt(n) == ' ') {
|
||||
lore.add("&6" + noteStr.substring(lastIndex, n).trim());
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - noteStr.length() < 20)
|
||||
lore.add("&6" + noteStr.substring(lastIndex, noteStr.length()).trim());
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.notes.createdby")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(note.getAuthor()).getName())
|
||||
.getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.notes.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(note.getCreationDate())))
|
||||
.getMessage());
|
||||
if (delete) lore.add(plugin.getLocale().getMessage("gui.notes.remove").getMessage());
|
||||
|
||||
createButton(18 + i, Material.MAP, name, lore);
|
||||
|
||||
if (delete) {
|
||||
registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) -> {
|
||||
plugin.getPunishmentManager().getPlayer(toModerate).removeNote(note);
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayer(plugin, toModerate, player1)));
|
||||
|
||||
if (create) {
|
||||
registerClickable(6, ((player1, inventory1, cursor, slot, type) -> {
|
||||
plugin.getLocale().getMessage("gui.notes.type").sendMessage(player);
|
||||
AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event -> {
|
||||
plugin.getPunishmentManager().getPlayer(toModerate).addNotes(new PunishmentNote(event.getMessage(),
|
||||
player.getUniqueId(), toModerate.getUniqueId(), System.currentTimeMillis()));
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
abstractChatConfirm.setOnClose(() ->
|
||||
init(setTitle, inventory.getSize()));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
|
@ -1,94 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
public class GUIPlayer extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private boolean punish, tickets, punishments, notes, moderate;
|
||||
|
||||
public GUIPlayer(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
this.punish = player.hasPermission("um.punish");
|
||||
this.tickets = player.hasPermission("um.tickets");
|
||||
this.punishments = player.hasPermission("um.punishments");
|
||||
this.notes = player.hasPermission("um.notes");
|
||||
this.moderate = player.hasPermission("um.moderation");
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.player.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
ItemStack head = new ItemStack(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.PLAYER_HEAD : Material.valueOf("SKULL_ITEM"), 1, (byte) 3);
|
||||
SkullMeta meta = ((SkullMeta) head.getItemMeta());
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
meta.setOwningPlayer(toModerate);
|
||||
else
|
||||
meta.setOwner(toModerate.getName());
|
||||
head.setItemMeta(meta);
|
||||
|
||||
createButton(13, head, "&7&l" + toModerate.getName(),
|
||||
player.isOnline() ? "&a" + plugin.getLocale().getMessage("gui.players.online.online") : "&c" + plugin.getLocale().getMessage("gui.players.online.offline"));
|
||||
|
||||
createButton(8, CompatibleMaterial.OAK_DOOR.getMaterial(), plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
if (punish) createButton(38, Material.ANVIL, plugin.getLocale().getMessage("gui.player.punish").getMessage());
|
||||
if (tickets) createButton(30, Material.CHEST, plugin.getLocale().getMessage("gui.player.tickets").getMessage());
|
||||
if (player.isOnline() && punishments)
|
||||
createButton(32, Material.DIAMOND_SWORD, plugin.getLocale().getMessage("gui.player.punishments").getMessage());
|
||||
if (notes) createButton(42, Material.MAP, plugin.getLocale().getMessage("gui.player.notes").getMessage());
|
||||
if (moderate)
|
||||
createButton(40, Material.DIAMOND_CHESTPLATE, plugin.getLocale().getMessage("gui.player.moderate").getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayers(plugin, player1)));
|
||||
|
||||
if (punish) {
|
||||
registerClickable(38, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPunish(plugin, toModerate, null, player1)));
|
||||
}
|
||||
|
||||
if (tickets) {
|
||||
registerClickable(30, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUITicketManager(plugin, toModerate, player1)));
|
||||
}
|
||||
|
||||
if (punishments) {
|
||||
registerClickable(32, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPunishments(plugin, toModerate, player1)));
|
||||
}
|
||||
|
||||
if (notes) {
|
||||
registerClickable(42, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUINotesManager(plugin, toModerate, player1)));
|
||||
}
|
||||
|
||||
if (moderate) {
|
||||
registerClickable(40, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIModerate(plugin, toModerate, player1)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,217 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractAnvilGUI;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUIPlayers extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private int task;
|
||||
private int page = 0;
|
||||
private Online currentOnline = Online.ONLINE;
|
||||
|
||||
public GUIPlayers(UltimateModeration plugin, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.players.title").getMessage(), 54);
|
||||
runTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
|
||||
int numNotes = Bukkit.getOnlinePlayers().size();
|
||||
int maxPage = (int) Math.floor(numNotes / 36.0);
|
||||
|
||||
List<UUID> players = new ArrayList<>();
|
||||
|
||||
if (currentOnline == Online.ONLINE || currentOnline == Online.BOTH) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
if (currentOnline == Online.OFFLINE || currentOnline == Online.BOTH) {
|
||||
for (UUID uuid : plugin.getPunishmentManager().getPunishments().keySet()) {
|
||||
if (Bukkit.getOfflinePlayer(uuid).isOnline()) continue;
|
||||
players.add(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
players = players.stream()
|
||||
.skip(page * 36).limit(36).collect(Collectors.toList());
|
||||
|
||||
if (page != 0) {
|
||||
createButton(46, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(46, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (maxPage != page) {
|
||||
createButton(48, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(48, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
for (int i = 0; i < players.size(); i++) {
|
||||
OfflinePlayer pl = Bukkit.getOfflinePlayer(players.get(i));
|
||||
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(pl);
|
||||
|
||||
ItemStack head = new ItemStack(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.PLAYER_HEAD : Material.valueOf("SKULL_ITEM"), 1, (byte) 3);
|
||||
SkullMeta meta = ((SkullMeta) head.getItemMeta());
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
meta.setOwningPlayer(pl);
|
||||
else
|
||||
meta.setOwner(pl.getName());
|
||||
head.setItemMeta(meta);
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.click").getMessage());
|
||||
lore.add("");
|
||||
|
||||
int ticketAmt = (int) plugin.getTicketManager().getTicketsAbout(pl).stream()
|
||||
.filter(t -> t.getStatus() == TicketStatus.OPEN).count();
|
||||
|
||||
if (ticketAmt == 0)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.notickets").getMessage());
|
||||
else {
|
||||
if (ticketAmt == 1)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.ticketsone").getMessage());
|
||||
else
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.tickets")
|
||||
.processPlaceholder("amount", ticketAmt).getMessage());
|
||||
}
|
||||
|
||||
int warningAmt = playerPunishData.getActivePunishments(PunishmentType.WARNING).size();
|
||||
|
||||
if (warningAmt == 0)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.nowarnings").getMessage());
|
||||
else {
|
||||
if (warningAmt == 1)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.warningsone").getMessage());
|
||||
else
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.warnings")
|
||||
.processPlaceholder("amount", warningAmt).getMessage());
|
||||
}
|
||||
|
||||
|
||||
createButton(i, head, "&7&l" + pl.getName(), lore);
|
||||
registerClickable(i, (player1, inventory1, cursor, slot, type) -> new GUIPlayer(plugin, pl, player));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(36 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
createButton(46, Material.ENDER_PEARL, plugin.getLocale().getMessage("gui.players.search").getMessage());
|
||||
createButton(47, Material.HOPPER, "&6" + currentOnline.getTranslation());
|
||||
|
||||
if (player.hasPermission("um.tickets"))
|
||||
createButton(51, Material.CHEST, plugin.getLocale().getMessage("gui.players.button.tickets").getMessage());
|
||||
|
||||
if (player.hasPermission("um.templates"))
|
||||
createButton(52, Material.MAP, plugin.getLocale().getMessage("gui.players.button.templatemanager").getMessage());
|
||||
}
|
||||
|
||||
|
||||
private enum Online {
|
||||
|
||||
ONLINE, OFFLINE, BOTH;
|
||||
|
||||
private static Online[] vals = values();
|
||||
|
||||
public Online next() {
|
||||
return vals[(this.ordinal() != vals.length - 1 ? this.ordinal() + 1 : 0)];
|
||||
}
|
||||
|
||||
public String getTranslation() {
|
||||
return UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("gui.players.online." + this.name().toLowerCase()).getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
private void runTask() {
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::constructGUI, 5L, 5L);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
|
||||
registerClickable(46, ((player1, inventory1, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
List<UUID> players = new ArrayList<>(plugin.getPunishmentManager().getPunishments().keySet());
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (players.contains(player.getUniqueId())) continue;
|
||||
players.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
List<UUID> found = players.stream().filter(uuid -> Bukkit.getOfflinePlayer(uuid).getName().equalsIgnoreCase(event.getName())).collect(Collectors.toList());
|
||||
|
||||
if (found.size() == 1) {
|
||||
new GUIPlayer(plugin, Bukkit.getOfflinePlayer(found.get(0)), player);
|
||||
} else {
|
||||
plugin.getLocale().getMessage("gui.players.nonefound").sendMessage(player);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(plugin.getLocale().getMessage("gui.players.name").getMessage());
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}));
|
||||
|
||||
registerClickable(47, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.currentOnline = currentOnline.next();
|
||||
this.page = 0;
|
||||
constructGUI();
|
||||
}));
|
||||
|
||||
if (player.hasPermission("um.tickets")) {
|
||||
registerClickable(51, (player1, inventory1, cursor, slot, type) -> {
|
||||
new GUITicketManager(plugin, null, player);
|
||||
});
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.templates")) {
|
||||
registerClickable(52, (player1, inventory1, cursor, slot, type) -> {
|
||||
if (player.hasPermission("um.templates")) new GUITemplateManager(plugin, player);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
registerOnClose(((player1, inventory1) -> Bukkit.getScheduler().cancelTask(task)));
|
||||
}
|
||||
}
|
|
@ -1,325 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractAnvilGUI;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GUIPunish extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private Template template;
|
||||
private boolean justSaved = false;
|
||||
|
||||
private PunishmentType type = PunishmentType.BAN;
|
||||
private long duration = -1;
|
||||
private String reason = null;
|
||||
|
||||
private String templateName = null;
|
||||
|
||||
private int task;
|
||||
|
||||
public GUIPunish(UltimateModeration plugin, OfflinePlayer toModerate, Template template, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
if (template != null) {
|
||||
this.template = template;
|
||||
this.type = template.getPunishmentType();
|
||||
this.duration = template.getDuration();
|
||||
this.reason = template.getReason();
|
||||
this.templateName = template.getTemplateName();
|
||||
}
|
||||
|
||||
init(toModerate == null ? plugin.getLocale().getMessage("gui.punish.title.template").getMessage()
|
||||
: plugin.getLocale().getMessage("gui.punish.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage(), 45);
|
||||
if (toModerate != null) runTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
|
||||
if (toModerate != null) {
|
||||
ItemStack head = new ItemStack(ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.PLAYER_HEAD : Material.valueOf("SKULL_ITEM"), 1, (byte) 3);
|
||||
SkullMeta meta = ((SkullMeta) head.getItemMeta());
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
meta.setOwningPlayer(toModerate);
|
||||
else
|
||||
meta.setOwner(toModerate.getName());
|
||||
head.setItemMeta(meta);
|
||||
|
||||
createButton(13, head, "&7&l" + toModerate.getName());
|
||||
}
|
||||
|
||||
if (player.hasPermission("um." + type.toString().toLowerCase()))
|
||||
createButton(22, Material.EMERALD_BLOCK, plugin.getLocale().getMessage("gui.punish.submit").getMessage());
|
||||
|
||||
createButton(8, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.OAK_DOOR
|
||||
: Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
createButton(28, Material.ANVIL,
|
||||
plugin.getLocale().getMessage("gui.punish.type.punishment").getMessage(),
|
||||
"&7" + type.getTranslation(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.punishment.click").getMessage());
|
||||
|
||||
if (toModerate != null) {
|
||||
createButton(30, Material.MAP,
|
||||
plugin.getLocale().getMessage("gui.punish.type.template").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.template.current")
|
||||
.processPlaceholder("template",
|
||||
template == null
|
||||
? plugin.getLocale().getMessage("gui.general.none")
|
||||
: template.getTemplateName()).getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage(plugin.getTemplateManager().getTemplates().size() == 0
|
||||
? "gui.punish.type.template.none"
|
||||
: "gui.punish.type.template.click").getMessage());
|
||||
} else {
|
||||
createButton(30, Material.MAP,
|
||||
plugin.getLocale().getMessage("gui.punish.type.name").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.name.current")
|
||||
.processPlaceholder("template",
|
||||
templateName == null
|
||||
? plugin.getLocale().getMessage("gui.punish.type.name.current").getMessage()
|
||||
: templateName).getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.name.current.click").getMessage());
|
||||
}
|
||||
|
||||
if (type != PunishmentType.KICK) {
|
||||
createButton(32, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.CLOCK
|
||||
: Material.valueOf("WATCH"),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.leftclick").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.rightclick").getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.current").getMessage(),
|
||||
"&6" + (duration == -1 ? plugin.getLocale().getMessage("gui.general.permanent").getMessage()
|
||||
: Methods.makeReadable(duration)));
|
||||
}
|
||||
|
||||
createButton(34, Material.PAPER,
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason.click").getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason.current").getMessage(),
|
||||
"&6" + reason);
|
||||
}
|
||||
|
||||
private void notifyTemplate() {
|
||||
if (reason == null || duration == 0 || (justSaved && template != null)) {
|
||||
inventory.setItem(4, null);
|
||||
return;
|
||||
}
|
||||
|
||||
Material material = ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.WHITE_WOOL : Material.valueOf("WOOL");
|
||||
String name = plugin.getLocale().getMessage("gui.punish.template.create").getMessage();
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.create2").getMessage());
|
||||
|
||||
if (!justSaved && template != null) {
|
||||
name = plugin.getLocale().getMessage("gui.punish.template.leftclick").getMessage();
|
||||
lore.clear();
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.leftclick2")
|
||||
.processPlaceholder("template", template.getTemplateName()).getMessage());
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.rightclick").getMessage());
|
||||
}
|
||||
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) && inventory.getItem(4) != null && inventory.getItem(4).getType() == Material.WHITE_WOOL)
|
||||
material = Material.YELLOW_WOOL;
|
||||
|
||||
createButton(4, material, name, lore);
|
||||
}
|
||||
|
||||
public void runTask() {
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::notifyTemplate, 10L, 10L);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (toModerate != null)
|
||||
new GUIPlayer(plugin, toModerate, player);
|
||||
else
|
||||
new GUITemplateManager(plugin, player);
|
||||
}));
|
||||
|
||||
registerClickable(28, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.type = this.type.next();
|
||||
justSaved = false;
|
||||
constructGUI();
|
||||
}));
|
||||
|
||||
registerClickable(4, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (reason == null || duration == 0) return;
|
||||
|
||||
if (template != null && type == ClickType.LEFT) {
|
||||
updateTemplate();
|
||||
return;
|
||||
}
|
||||
nameTemplate();
|
||||
}));
|
||||
|
||||
registerClickable(30, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (toModerate == null) {
|
||||
nameTemplate();
|
||||
return;
|
||||
}
|
||||
if (plugin.getTemplateManager().getTemplates().size() == 0) return;
|
||||
|
||||
if (player.hasPermission("um.templates.use")) new GUITemplateSelector(plugin, this, player);
|
||||
}));
|
||||
|
||||
registerClickable(32, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (this.type == PunishmentType.KICK) return;
|
||||
if (type == ClickType.LEFT) {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
this.duration = Methods.parseTime(event.getName());
|
||||
justSaved = false;
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
meta.setDisplayName(duration == -1 || duration == 0 ? "1d 1h 1m" : Methods.makeReadable(duration));
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
} else {
|
||||
duration = -1;
|
||||
constructGUI();
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
registerClickable(34, ((player1, inventory1, cursor, slot, type) -> {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
this.reason = event.getName();
|
||||
justSaved = false;
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) -> init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(reason == null ? plugin.getLocale().getMessage("gui.general.reason").getMessage() : reason);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}));
|
||||
|
||||
registerClickable(22, ((player1, inventory1, cursor, slot, type1) -> {
|
||||
if (!player.hasPermission("um." + type.toString().toLowerCase())) return;
|
||||
if (duration == -1 && type == PunishmentType.BAN && !player.hasPermission("um.ban.permanent")) return;
|
||||
|
||||
if (toModerate == null) {
|
||||
if (reason == null || duration == 0 || templateName == null) return;
|
||||
|
||||
if (template == null)
|
||||
finishTemplate();
|
||||
else
|
||||
updateTemplate();
|
||||
return;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case BAN:
|
||||
case MUTE:
|
||||
case WARNING:
|
||||
new Punishment(type, duration, reason).execute(player, toModerate);
|
||||
break;
|
||||
case KICK:
|
||||
new Punishment(type, reason).execute(player, toModerate);
|
||||
break;
|
||||
}
|
||||
|
||||
new GUIPlayer(plugin, toModerate, player);
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
registerOnClose(((player1, inventory1) -> Bukkit.getScheduler().cancelTask(task)));
|
||||
}
|
||||
|
||||
private void nameTemplate() {
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event -> {
|
||||
this.templateName = event.getName();
|
||||
|
||||
if (toModerate != null)
|
||||
finishTemplate();
|
||||
|
||||
justSaved = true;
|
||||
});
|
||||
|
||||
gui.setOnClose((player2, inventory3) ->
|
||||
init(setTitle, inventory.getSize()));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(plugin.getLocale().getMessage("gui.general.templatename").getMessage());
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}
|
||||
|
||||
private void updateTemplate() {
|
||||
Template template = new Template(this.type, this.duration, this.reason, this.template.getCreator(), this.templateName);
|
||||
plugin.getTemplateManager().updateTemplate(this.template.getUUID(), template);
|
||||
justSaved = true;
|
||||
if (toModerate == null)
|
||||
new GUITemplateManager(plugin, player);
|
||||
}
|
||||
|
||||
private void finishTemplate() {
|
||||
Template template = new Template(this.type, this.duration, this.reason, player, templateName);
|
||||
plugin.getTemplateManager().addTemplate(template);
|
||||
this.template = template;
|
||||
if (toModerate == null)
|
||||
new GUITemplateManager(plugin, player);
|
||||
}
|
||||
|
||||
public void setTemplate(Template template) {
|
||||
this.justSaved = true;
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public void setType(PunishmentType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUITemplateManager extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private int page = 0;
|
||||
|
||||
private PunishmentType punishmentType = PunishmentType.ALL;
|
||||
|
||||
public GUITemplateManager(UltimateModeration plugin, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.templatemanager.title").getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
int numTemplates = plugin.getTemplateManager().getTemplates().size();
|
||||
int maxPage = (int) Math.floor(numTemplates / 36.0);
|
||||
|
||||
List<Template> templates = plugin.getTemplateManager().getTemplates().values().stream().skip(page * 36).limit(36)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (page != 0) {
|
||||
createButton(1, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (page != maxPage) {
|
||||
createButton(5, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(5, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
createButton(3, Material.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name()));
|
||||
|
||||
createButton(8, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.OAK_DOOR
|
||||
: Material.valueOf("WOOD_DOOR"),
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
if (player.hasPermission("um.templates.create"))
|
||||
createButton(7, Material.REDSTONE, plugin.getLocale().getMessage("gui.templatemanager.create").getMessage());
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
if (punishmentType != PunishmentType.ALL)
|
||||
templates.removeIf(template -> template.getPunishmentType() != punishmentType);
|
||||
for (int i = 0; i < templates.size(); i++) {
|
||||
Template template = templates.get(i);
|
||||
createButton(18 + i, Material.MAP, "&6&l" + template.getTemplateName(),
|
||||
plugin.getLocale().getMessage("gui.templatemanager.leftclick").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.templatemanager.rightclick").getMessage());
|
||||
|
||||
registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (type == ClickType.LEFT) {
|
||||
if (player.hasPermission("um.templates.edit")) new GUIPunish(plugin, null, template, player);
|
||||
} else if (type == ClickType.RIGHT) {
|
||||
if (player.hasPermission("um.templates.destroy"))
|
||||
plugin.getTemplateManager().removeTemplate(template.getUUID());
|
||||
constructGUI();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayers(plugin, player)));
|
||||
|
||||
if (player.hasPermission("um.templates.create")) {
|
||||
registerClickable(7, ((player1, inventory1, cursor, slot, type) -> {
|
||||
new GUIPunish(plugin, null, null, player);
|
||||
}));
|
||||
}
|
||||
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.punishmentType = punishmentType.nextFilter();
|
||||
this.page = 0;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GUITemplateSelector extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private GUIPunish punish;
|
||||
|
||||
public GUITemplateSelector(UltimateModeration plugin, GUIPunish punish, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.punish = punish;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.templateselector.title").getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
createButton(8, CompatibleMaterial.OAK_DOOR.getMaterial(),
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
ArrayList<Template> templates = new ArrayList<>(plugin.getTemplateManager().getTemplates().values());
|
||||
for (int i = 0; i < templates.size(); i++) {
|
||||
Template template = templates.get(i);
|
||||
createButton(18 + i, Material.MAP, "&6&l" + template.getTemplateName(),
|
||||
plugin.getLocale().getMessage("gui.templateselector.click").getMessage());
|
||||
|
||||
registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) -> {
|
||||
punish.setType(template.getPunishmentType());
|
||||
punish.setDuration(template.getDuration());
|
||||
punish.setReason(template.getReason());
|
||||
punish.setTemplate(template);
|
||||
punish.init(setTitle, punish.getInventory().getSize());
|
||||
punish.runTask();
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) -> {
|
||||
punish.init(punish.getSetTitle(), punish.getInventory().getSize());
|
||||
punish.runTask();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,164 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import com.songoda.ultimatemoderation.utils.AbstractChatConfirm;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import com.songoda.ultimatemoderation.staffchat.*;
|
||||
|
||||
public class GUITicket extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private StaffChatManager chatManager = UltimateModeration.getInstance().getStaffChatManager();
|
||||
|
||||
private final Ticket ticket;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
private int page = 0;
|
||||
|
||||
public GUITicket(UltimateModeration plugin, Ticket ticket, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.ticket = ticket;
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.ticket.title")
|
||||
.processPlaceholder("id", ticket.getTicketId()).getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
int numNotes = ticket.getResponses().size();
|
||||
int maxPage = (int) Math.floor(numNotes / 36.0);
|
||||
|
||||
List<TicketResponse> responses = ticket.getResponses().stream().skip(page * 36).limit(36)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (page != 0) {
|
||||
createButton(1, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (page != maxPage) {
|
||||
createButton(3, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.tickets.openclose"))
|
||||
createButton(5, Material.REDSTONE, "&6" + ticket.getStatus().getStatus());
|
||||
|
||||
createButton(8, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.OAK_DOOR
|
||||
: Material.valueOf("WOOD_DOOR"),
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
if (player.hasPermission("um.ticket.clicktotele") && ticket.getLocation() != null)
|
||||
createButton(7, Material.REDSTONE,
|
||||
plugin.getLocale().getMessage("gui.ticket.clicktotele").getMessage());
|
||||
|
||||
if (player.hasPermission("um.tickets.respond"))
|
||||
createButton(6, Material.REDSTONE, plugin.getLocale().getMessage("gui.ticket.respond").getMessage());
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
for (int i = 0; i < responses.size(); i++) {
|
||||
TicketResponse ticketResponse = responses.get(i);
|
||||
|
||||
String subjectStr = ticketResponse.getMessage();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < subjectStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (subjectStr.charAt(n) == ' ') {
|
||||
lore.add("&6" + subjectStr.substring(lastIndex, n).trim());
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - subjectStr.length() < 20)
|
||||
lore.add("&6" + subjectStr.substring(lastIndex, subjectStr.length()).trim());
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.postedby")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticketResponse.getAuthor()).getName()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(ticketResponse.getPostedDate()))).getMessage());
|
||||
|
||||
createButton(18 + i, Material.MAP, name, lore);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUITicketManager(plugin, toModerate, player)));
|
||||
|
||||
if (player.hasPermission("um.tickets.clicktotele") && ticket.getLocation() != null) {
|
||||
registerClickable(7, ((player1, inventory1, cursor, slot, type) ->
|
||||
player.teleport(ticket.getLocation())));
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.tickets.openclose")) {
|
||||
registerClickable(5, ((player1, inventory1, cursor, slot, type) -> {
|
||||
ticket.setStatus(ticket.getStatus() == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN);
|
||||
// Notify staff of ticket status
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.status").getMessage().replace("%tid%", ""+ticket.getTicketId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()).replace("%status%", ticket.getStatus().toString()));
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.tickets.respond")) {
|
||||
registerClickable(6, ((player1, inventory1, cursor, slot, type) -> {
|
||||
player.sendMessage(plugin.getLocale().getMessage("gui.ticket.what").getMessage());
|
||||
AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event2 -> {
|
||||
ticket.addResponse(new TicketResponse(player, event2.getMessage(), System.currentTimeMillis()));
|
||||
// Notify staff of ticket response.
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.response").getMessage().replace("%tid%", ""+ticket.getTicketId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()));
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
abstractChatConfirm.setOnClose(() ->
|
||||
init(setTitle, inventory.getSize()));
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
|
@ -1,173 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractAnvilGUI;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUITicketManager extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private TicketStatus status = TicketStatus.OPEN;
|
||||
|
||||
private int page = 0;
|
||||
|
||||
public GUITicketManager(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
|
||||
init(plugin.getLocale().getMessage(toModerate != null ? "gui.tickets.titlesingle" : "gui.tickets.title")
|
||||
.processPlaceholder("toModerate", toModerate != null ? toModerate.getName() : "").getMessage(), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
List<Ticket> tickets = toModerate != null ? plugin.getTicketManager().getTicketsAbout(toModerate, status) : plugin.getTicketManager().getTickets(status);
|
||||
|
||||
int numTickets = tickets.size();
|
||||
int maxPage = (int) Math.floor(numTickets / 36.0);
|
||||
|
||||
tickets = tickets.stream().skip(page * 36).limit(36).collect(Collectors.toList());
|
||||
|
||||
if (page != 0) {
|
||||
createButton(1, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (maxPage >= 36) {
|
||||
createButton(5, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(5, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
createButton(3, Material.DIAMOND_SWORD, Methods.formatText("&6" + status.getStatus()));
|
||||
|
||||
if (toModerate != null && player.hasPermission("um.tickets.create"))
|
||||
createButton(7, Material.REDSTONE, plugin.getLocale().getMessage("gui.tickets.create").getMessage());
|
||||
|
||||
if (player.hasPermission("um.ticket"))
|
||||
createButton(8, CompatibleMaterial.OAK_DOOR.getMaterial(),
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
for (int i = 0; i < tickets.size(); i++) {
|
||||
Ticket ticket = tickets.get(i);
|
||||
|
||||
String subjectStr = ticket.getSubject();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < subjectStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (subjectStr.charAt(n) == ' ') {
|
||||
lore.add("&6" + subjectStr.substring(lastIndex, n).trim());
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - subjectStr.length() < 20)
|
||||
lore.add("&6" + subjectStr.substring(lastIndex, subjectStr.length()).trim() + " &7- " + ticket.getTicketId());
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.status")
|
||||
.processPlaceholder("status", ticket.getStatus().getStatus()).getMessage());
|
||||
|
||||
if (toModerate != null)
|
||||
lore.add(plugin.getLocale().getMessage("gui.tickets.player")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticket.getVictim()).getName()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.type")
|
||||
.processPlaceholder("type", ticket.getType()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(ticket.getCreationDate()))).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.tickets.click").getMessage());
|
||||
|
||||
createButton(18 + i, Material.MAP, name, lore);
|
||||
|
||||
registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUITicket(plugin, ticket, toModerate, player)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
if (player.hasPermission("um.moderate")) {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (toModerate == null)
|
||||
new GUIPlayers(plugin, player);
|
||||
else
|
||||
new GUIPlayer(plugin, toModerate, player1);
|
||||
}));
|
||||
}
|
||||
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.status = status == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN;
|
||||
this.page = 0;
|
||||
constructGUI();
|
||||
}));
|
||||
|
||||
if (toModerate != null && player.hasPermission("um.tickets.create")) {
|
||||
registerClickable(7, ((player1, inventory1, cursor, slot, type) ->
|
||||
createNew(player, toModerate)));
|
||||
}
|
||||
}
|
||||
|
||||
public static void createNew(Player player, OfflinePlayer toModerate) {
|
||||
UltimateModeration plugin = UltimateModeration.getInstance();
|
||||
|
||||
AbstractAnvilGUI gui = new AbstractAnvilGUI(player, event ->
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
new GUITicketType(plugin, toModerate, player, event.getName()), 1L));
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(plugin.getLocale().getMessage("gui.tickets.subject").getMessage());
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.utils.AbstractChatConfirm;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.songoda.ultimatemoderation.staffchat.*;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class GUITicketType extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private StaffChatManager chatManager = UltimateModeration.getInstance().getStaffChatManager();
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
private final String subject;
|
||||
|
||||
public GUITicketType(UltimateModeration plugin, OfflinePlayer toModerate, Player player, String subject) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
this.subject = subject;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.ticket.picktype").getMessage(), 27);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
List<String> types = Settings.TICKET_TYPES.getStringList();
|
||||
|
||||
for (int i = 0; i < types.size(); i ++) {
|
||||
createButton(i, Material.PAPER, types.get(i));
|
||||
final int fi = i;
|
||||
registerClickable(i, (player1, inventory1, cursor, slot, type) -> {
|
||||
Ticket ticket = new Ticket(toModerate, subject, types.get(fi));
|
||||
player.sendMessage(plugin.getLocale().getMessage("gui.tickets.what").getMessage());
|
||||
AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event2 -> {
|
||||
plugin.getTicketManager().addTicket(ticket);
|
||||
// Notify staff
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.created").getMessage().replace("%tid%", ""+ticket.getTicketId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()));
|
||||
if (player == toModerate)
|
||||
ticket.setLocation(player.getLocation());
|
||||
ticket.addResponse(new TicketResponse(player, event2.getMessage(), System.currentTimeMillis()));
|
||||
});
|
||||
|
||||
abstractChatConfirm.setOnClose(() ->
|
||||
new GUITicket(plugin, ticket, toModerate, player));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
|
@ -0,0 +1,201 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MainGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private Online currentOnline = Online.ONLINE;
|
||||
|
||||
private final List<UUID> players = new ArrayList<>();
|
||||
private final Player viewer;
|
||||
|
||||
public MainGui(UltimateModeration plugin, Player viewer) {
|
||||
this.plugin = plugin;
|
||||
setRows(6);
|
||||
setDefaultItem(null);
|
||||
this.viewer = viewer;
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
players.add(player.getUniqueId());
|
||||
for (UUID uuid : plugin.getPunishmentManager().getPunishments().keySet()) {
|
||||
if (Bukkit.getOfflinePlayer(uuid).isOnline()) continue;
|
||||
players.add(uuid);
|
||||
}
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.players.title").getMessage());
|
||||
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
setButton(5, 2, GuiUtils.createButtonItem(CompatibleMaterial.ENDER_PEARL,
|
||||
plugin.getLocale().getMessage("gui.players.search").getMessage()),
|
||||
(event) -> {
|
||||
AnvilGui gui = new AnvilGui(event.player, this);
|
||||
gui.setAction(event2 -> {
|
||||
List<UUID> players = new ArrayList<>(plugin.getPunishmentManager().getPunishments().keySet());
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (players.contains(p.getUniqueId())) continue;
|
||||
players.add(p.getUniqueId());
|
||||
}
|
||||
|
||||
List<UUID> found = players.stream().filter(uuid -> Bukkit.getOfflinePlayer(uuid).getName().toLowerCase().contains(gui.getInputText().toLowerCase())).collect(Collectors.toList());
|
||||
|
||||
if (found.size() >= 1) {
|
||||
this.players.clear();
|
||||
this.players.addAll(found);
|
||||
showPage();
|
||||
} else {
|
||||
plugin.getLocale().getMessage("gui.players.nonefound").sendMessage(event.player);
|
||||
}
|
||||
event2.player.closeInventory();
|
||||
});
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(plugin.getLocale().getMessage("gui.players.name").getMessage());
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setInput(item);
|
||||
guiManager.showGUI(event.player, gui);
|
||||
});
|
||||
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.HOPPER, TextUtils.formatText("&6" + currentOnline.getTranslation())),
|
||||
(event) -> {
|
||||
this.currentOnline = currentOnline.next();
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
|
||||
if (viewer.hasPermission("um.tickets"))
|
||||
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.CHEST,
|
||||
plugin.getLocale().getMessage("gui.players.button.tickets").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new TicketManagerGui(plugin, null, viewer)));
|
||||
|
||||
if (viewer.hasPermission("um.templates"))
|
||||
setButton(5, 6, GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
plugin.getLocale().getMessage("gui.players.button.templatemanager").getMessage()),
|
||||
(events) -> guiManager.showGUI(events.player, new TemplateManagerGui(plugin, viewer)));
|
||||
|
||||
|
||||
List<UUID> toUse = players.stream()
|
||||
.filter(u -> currentOnline == Online.BOTH
|
||||
|| currentOnline == Online.ONLINE && Bukkit.getOfflinePlayer(u).isOnline()
|
||||
|| currentOnline == Online.OFFLINE && !Bukkit.getOfflinePlayer(u).isOnline()).collect(Collectors.toList());
|
||||
|
||||
this.pages = (int) Math.max(1, Math.ceil(toUse.size() / ((double) 28)));
|
||||
|
||||
final List<UUID> toUseFinal = toUse.stream().skip((page - 1) * 28).limit(28).collect(Collectors.toList());
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
int num = 11;
|
||||
for (UUID uuid : toUseFinal) {
|
||||
if (num == 16 || num == 36)
|
||||
num = num + 2;
|
||||
OfflinePlayer pl = Bukkit.getOfflinePlayer(uuid);
|
||||
ItemStack skull = ItemUtils.getPlayerSkull(pl);
|
||||
setItem(num, skull);
|
||||
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(pl);
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.click").getMessage());
|
||||
lore.add("");
|
||||
|
||||
int ticketAmt = (int) plugin.getTicketManager().getTicketsAbout(pl).stream()
|
||||
.filter(t -> t.getStatus() == TicketStatus.OPEN).count();
|
||||
|
||||
if (ticketAmt == 0)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.notickets").getMessage());
|
||||
else {
|
||||
if (ticketAmt == 1)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.ticketsone").getMessage());
|
||||
else
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.tickets")
|
||||
.processPlaceholder("amount", ticketAmt).getMessage());
|
||||
}
|
||||
|
||||
int warningAmt = playerPunishData.getActivePunishments(PunishmentType.WARNING).size();
|
||||
|
||||
if (warningAmt == 0)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.nowarnings").getMessage());
|
||||
else {
|
||||
if (warningAmt == 1)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.warningsone").getMessage());
|
||||
else
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.warnings")
|
||||
.processPlaceholder("amount", warningAmt).getMessage());
|
||||
}
|
||||
|
||||
setButton(num, GuiUtils.createButtonItem(skull, TextUtils.formatText("&7&l" + pl.getName()), lore),
|
||||
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, pl, viewer)));
|
||||
|
||||
num++;
|
||||
}
|
||||
});
|
||||
|
||||
// enable page events
|
||||
setNextPage(4, 7, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(4, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
}
|
||||
|
||||
private enum Online {
|
||||
|
||||
ONLINE, OFFLINE, BOTH;
|
||||
|
||||
private static Online[] vals = values();
|
||||
|
||||
public Online next() {
|
||||
return vals[(this.ordinal() != vals.length - 1 ? this.ordinal() + 1 : 0)];
|
||||
}
|
||||
|
||||
public String getTranslation() {
|
||||
return UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("gui.players.online." + this.name().toLowerCase()).getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ModerateGui extends Gui {
|
||||
|
||||
public ModerateGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(5);
|
||||
setDefaultItem(null);
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.moderate.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(2, 0, false, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player)));
|
||||
|
||||
int[] slots = new int[]{11, 13, 15, 29, 31, 33};
|
||||
|
||||
List<AbstractModeration> moderations = new ArrayList<>(plugin.getModerationManager().getModerations().values());
|
||||
|
||||
int i = 0;
|
||||
for (AbstractModeration moderation : moderations) {
|
||||
if (!moderation.hasPermission(player) || moderation.isExempt(toModerate)) continue;
|
||||
int slot = slots[i];
|
||||
setButton(slot, GuiUtils.createButtonItem(moderation.getIcon(),
|
||||
TextUtils.formatText("&6&l" + moderation.getProper()),
|
||||
TextUtils.formatText("&7" + moderation.getDescription())),
|
||||
(event) -> moderation.runPreModeration(player, toModerate));
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,143 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class NotesManagerGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private final boolean create, delete;
|
||||
|
||||
public NotesManagerGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
this.plugin = plugin;
|
||||
setRows(6);
|
||||
setDefaultItem(null);
|
||||
this.toModerate = toModerate;
|
||||
this.create = player.hasPermission("um.notes.create");
|
||||
this.delete = player.hasPermission("um.notes.delete");
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.notes.title")
|
||||
.processPlaceholder("tonotes", player.getName()).getMessage());
|
||||
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
int numNotes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().size();
|
||||
this.pages = (int) Math.max(1, Math.ceil(numNotes / ((double) 28)));
|
||||
|
||||
List<PunishmentNote> notes = plugin.getPunishmentManager().getPlayer(toModerate).getNotes().stream()
|
||||
.skip((page - 1) * 28).limit(28).collect(Collectors.toList());
|
||||
|
||||
// enable page events
|
||||
setNextPage(0, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(0, 3, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player)));
|
||||
|
||||
if (create)
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE,
|
||||
plugin.getLocale().getMessage("gui.notes.create").getMessage()),
|
||||
(event) -> {
|
||||
ChatPrompt.showPrompt(plugin, event.player,
|
||||
plugin.getLocale().getMessage("gui.notes.type").getMessage(),
|
||||
(response) -> {
|
||||
PunishmentNote note = new PunishmentNote(response.getMessage(),
|
||||
event.player.getUniqueId(), toModerate.getUniqueId(),
|
||||
System.currentTimeMillis());
|
||||
plugin.getPunishmentManager().getPlayer(toModerate).addNotes(note);
|
||||
plugin.getDataManager().createNote(note);
|
||||
|
||||
showPage();
|
||||
}).setOnClose(() -> guiManager.showGUI(event.player, new NotesManagerGui(plugin, toModerate, event.player)));
|
||||
});
|
||||
|
||||
int num = 11;
|
||||
for (PunishmentNote note : notes) {
|
||||
if (num == 16 || num == 36)
|
||||
num = num + 2;
|
||||
String noteStr = note.getNote();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < noteStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (noteStr.charAt(n) == ' ') {
|
||||
lore.add("&6" + noteStr.substring(lastIndex, n).trim());
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - noteStr.length() < 20)
|
||||
lore.add("&6" + noteStr.substring(lastIndex).trim());
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.notes.createdby")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(note.getAuthor()).getName())
|
||||
.getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.notes.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(note.getCreationDate())))
|
||||
.getMessage());
|
||||
if (delete) lore.add(plugin.getLocale().getMessage("gui.notes.remove").getMessage());
|
||||
|
||||
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText(name), TextUtils.formatText(lore)),
|
||||
(event) -> {
|
||||
if (delete) {
|
||||
plugin.getPunishmentManager().getPlayer(toModerate).removeNotes(note);
|
||||
plugin.getDataManager().deleteNote(note);
|
||||
showPage();
|
||||
}
|
||||
});
|
||||
|
||||
num++;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class PlayerGui extends Gui {
|
||||
|
||||
public PlayerGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
boolean punish = player.hasPermission("um.punish");
|
||||
boolean tickets = player.hasPermission("um.tickets");
|
||||
boolean punishments = player.hasPermission("um.punishments");
|
||||
boolean notes = player.hasPermission("um.notes");
|
||||
boolean moderate = player.hasPermission("um.moderation");
|
||||
|
||||
setDefaultItem(null);
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.player.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
ItemStack head = ItemUtils.getPlayerSkull(toModerate);
|
||||
|
||||
setItem(13, GuiUtils.createButtonItem(head, TextUtils.formatText("&7&l" + toModerate.getName()),
|
||||
TextUtils.formatText(toModerate.isOnline() ? "&a"
|
||||
+ plugin.getLocale().getMessage("gui.players.online.online").getMessage()
|
||||
: "&c" + plugin.getLocale().getMessage("gui.players.online.offline").getMessage())));
|
||||
|
||||
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new MainGui(plugin, event.player)));
|
||||
|
||||
if (punish)
|
||||
setButton(38, GuiUtils.createButtonItem(CompatibleMaterial.ANVIL,
|
||||
plugin.getLocale().getMessage("gui.player.punish").getMessage()),
|
||||
(event) -> plugin.getGuiManager().showGUI(player,
|
||||
new PunishGui(plugin, toModerate, null, event.player)));
|
||||
|
||||
if (tickets)
|
||||
setButton(30, GuiUtils.createButtonItem(CompatibleMaterial.CHEST,
|
||||
plugin.getLocale().getMessage("gui.player.tickets").getMessage()),
|
||||
(event) -> plugin.getGuiManager().showGUI(player,
|
||||
new TicketManagerGui(plugin, toModerate, event.player)));
|
||||
|
||||
if (toModerate.isOnline() && punishments)
|
||||
setButton(32, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD,
|
||||
plugin.getLocale().getMessage("gui.player.punishments").getMessage()),
|
||||
(event) -> plugin.getGuiManager().showGUI(player, new PunishmentsGui(plugin, toModerate)));
|
||||
|
||||
if (notes)
|
||||
setButton(42, GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
plugin.getLocale().getMessage("gui.player.notes").getMessage()),
|
||||
(event) -> plugin.getGuiManager().showGUI(player,
|
||||
new NotesManagerGui(plugin, toModerate, event.player)));
|
||||
|
||||
if (moderate)
|
||||
setButton(40, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_CHESTPLATE,
|
||||
plugin.getLocale().getMessage("gui.player.moderate").getMessage()),
|
||||
(event) -> guiManager.showGUI(player, new ModerateGui(plugin, toModerate, event.player)));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,329 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.ItemUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class PunishGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final Player player;
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private Template template;
|
||||
private boolean justSaved = false;
|
||||
|
||||
private PunishmentType type = PunishmentType.BAN;
|
||||
private long duration = -1;
|
||||
private String reason = null;
|
||||
|
||||
private String templateName = null;
|
||||
|
||||
private int task;
|
||||
|
||||
public PunishGui(UltimateModeration plugin, OfflinePlayer toModerate, Template template, Player player) {
|
||||
super(5);
|
||||
setDefaultItem(null);
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
if (template != null) {
|
||||
this.template = template;
|
||||
this.type = template.getPunishmentType();
|
||||
this.duration = template.getDuration();
|
||||
this.reason = template.getReason();
|
||||
this.templateName = template.getName();
|
||||
}
|
||||
|
||||
setTitle(toModerate == null ? plugin.getLocale().getMessage("gui.punish.title.template").getMessage()
|
||||
: plugin.getLocale().getMessage("gui.punish.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage());
|
||||
if (toModerate != null) runTask();
|
||||
|
||||
setOnClose((event) -> Bukkit.getScheduler().cancelTask(task));
|
||||
paint();
|
||||
}
|
||||
|
||||
public void paint() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(2, 0, false, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
if (toModerate != null)
|
||||
setItem(13, GuiUtils.createButtonItem(ItemUtils.getPlayerSkull(toModerate),
|
||||
TextUtils.formatText("&6&l" + toModerate.getName())));
|
||||
|
||||
if (player.hasPermission("um." + type.toString().toLowerCase()))
|
||||
setButton(22, GuiUtils.createButtonItem(CompatibleMaterial.EMERALD_BLOCK,
|
||||
plugin.getLocale().getMessage("gui.punish.submit").getMessage()),
|
||||
(event) -> {
|
||||
if (!player.hasPermission("um." + type.toString().toLowerCase())) return;
|
||||
if (duration == -1 && type == PunishmentType.BAN && !player.hasPermission("um.ban.permanent"))
|
||||
return;
|
||||
|
||||
if (toModerate == null) {
|
||||
if (reason == null || templateName == null) return;
|
||||
|
||||
if (template == null)
|
||||
finishTemplate();
|
||||
else
|
||||
updateTemplate();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
switch (type) {
|
||||
case BAN:
|
||||
case MUTE:
|
||||
case WARNING:
|
||||
new Punishment(type, duration, reason).execute(player, toModerate);
|
||||
break;
|
||||
case KICK:
|
||||
new Punishment(type, reason).execute(player, toModerate);
|
||||
break;
|
||||
}
|
||||
player.closeInventory();
|
||||
});
|
||||
|
||||
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
if (toModerate != null)
|
||||
guiManager.showGUI(player, new PlayerGui(plugin, toModerate, player));
|
||||
else
|
||||
guiManager.showGUI(player, new TemplateManagerGui(plugin, player));
|
||||
});
|
||||
|
||||
setButton(28, GuiUtils.createButtonItem(CompatibleMaterial.ANVIL,
|
||||
plugin.getLocale().getMessage("gui.punish.type.punishment").getMessage(),
|
||||
TextUtils.formatText("&7" + type.getTranslation()),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.punishment.click").getMessage()),
|
||||
(event) -> {
|
||||
this.type = this.type.next();
|
||||
justSaved = false;
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack templateItem = toModerate != null ? GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
plugin.getLocale().getMessage("gui.punish.type.template").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.template.current")
|
||||
.processPlaceholder("template",
|
||||
template == null
|
||||
? plugin.getLocale().getMessage("gui.general.none").getMessage()
|
||||
: template.getName()).getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage(plugin.getTemplateManager().getTemplates().size() == 0
|
||||
? "gui.punish.type.template.none"
|
||||
: "gui.punish.type.template.click").getMessage())
|
||||
: GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
plugin.getLocale().getMessage("gui.punish.type.name").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.name.current")
|
||||
.processPlaceholder("name",
|
||||
templateName == null
|
||||
? plugin.getLocale().getMessage("gui.punish.type.name.current").getMessage()
|
||||
: templateName).getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.name.current.click").getMessage());
|
||||
|
||||
setButton(30, templateItem, (event) -> {
|
||||
if (toModerate == null) {
|
||||
nameTemplate();
|
||||
return;
|
||||
}
|
||||
if (plugin.getTemplateManager().getTemplates().size() == 0) return;
|
||||
|
||||
if (player.hasPermission("um.templates.use"))
|
||||
guiManager.showGUI(player, new TemplateSelectorGui(plugin, this, player));
|
||||
});
|
||||
|
||||
if (type != PunishmentType.KICK) {
|
||||
setButton(32, GuiUtils.createButtonItem(CompatibleMaterial.CLOCK,
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.leftclick").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.rightclick").getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.current").getMessage(),
|
||||
TextUtils.formatText("&6" + (duration == -1 ? plugin.getLocale().getMessage("gui.general.permanent").getMessage()
|
||||
: Methods.makeReadable(duration)))),
|
||||
(event) -> {
|
||||
if (this.type == PunishmentType.KICK) return;
|
||||
if (event.clickType == ClickType.LEFT) {
|
||||
AnvilGui gui = new AnvilGui(player, this);
|
||||
gui.setAction(evt -> {
|
||||
this.duration = Methods.parseTime(gui.getInputText());
|
||||
justSaved = false;
|
||||
guiManager.showGUI(player, this);
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
meta.setDisplayName(duration == -1 || duration == 0 ? "1d 1h 1m" : Methods.makeReadable(duration));
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setInput(item);
|
||||
guiManager.showGUI(player, gui);
|
||||
} else {
|
||||
duration = -1;
|
||||
paint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setButton(34, GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason.click").getMessage(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason.current").getMessage(),
|
||||
TextUtils.formatText("&6" + reason)), (event) -> {
|
||||
|
||||
AnvilGui gui = new AnvilGui(player, this);
|
||||
gui.setAction(evnt -> {
|
||||
this.reason = gui.getInputText();
|
||||
justSaved = false;
|
||||
guiManager.showGUI(player, this);
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
|
||||
reason == null ? plugin.getLocale().getMessage("gui.general.reason").getMessage() : reason);
|
||||
|
||||
gui.setInput(item);
|
||||
guiManager.showGUI(player, gui);
|
||||
});
|
||||
}
|
||||
|
||||
private void notifyTemplate() {
|
||||
if (reason == null || (justSaved && template != null)) {
|
||||
inventory.setItem(4, null);
|
||||
return;
|
||||
}
|
||||
|
||||
CompatibleMaterial material = CompatibleMaterial.WHITE_WOOL;
|
||||
String name = plugin.getLocale().getMessage("gui.punish.template.create").getMessage();
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.create2").getMessage());
|
||||
|
||||
if (!justSaved && template != null) {
|
||||
name = plugin.getLocale().getMessage("gui.punish.template.leftclick").getMessage();
|
||||
lore.clear();
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.leftclick2")
|
||||
.processPlaceholder("template", template.getName()).getMessage());
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.rightclick").getMessage());
|
||||
}
|
||||
|
||||
if (getItem(4) != null && CompatibleMaterial.getMaterial(getItem(4)) == CompatibleMaterial.WHITE_WOOL)
|
||||
material = CompatibleMaterial.YELLOW_WOOL;
|
||||
|
||||
setButton(4, GuiUtils.createButtonItem(material, name, lore), (event) -> {
|
||||
|
||||
if (reason == null || duration == 0) return;
|
||||
|
||||
if (template != null && event.clickType == ClickType.LEFT) {
|
||||
updateTemplate();
|
||||
return;
|
||||
}
|
||||
nameTemplate();
|
||||
});
|
||||
}
|
||||
|
||||
public void runTask() {
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, this::notifyTemplate, 10L, 10L);
|
||||
}
|
||||
|
||||
private void nameTemplate() {
|
||||
AnvilGui gui = new AnvilGui(player, this);
|
||||
gui.setAction(event -> {
|
||||
this.templateName = gui.getInputText();
|
||||
|
||||
if (reason != null && templateName != null) {
|
||||
if (template == null)
|
||||
finishTemplate();
|
||||
else
|
||||
updateTemplate();
|
||||
}
|
||||
|
||||
justSaved = true;
|
||||
guiManager.showGUI(player, this);
|
||||
paint();
|
||||
});
|
||||
|
||||
ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
|
||||
template == null ? plugin.getLocale().getMessage("gui.general.templatename").getMessage() : template.getName());
|
||||
|
||||
gui.setInput(item);
|
||||
guiManager.showGUI(player, gui);
|
||||
}
|
||||
|
||||
private void updateTemplate() {
|
||||
Template template = new Template(this.type, this.duration, this.reason, this.template.getCreator(), this.templateName);
|
||||
plugin.getTemplateManager().removeTemplate(this.template);
|
||||
plugin.getTemplateManager().addTemplate(template);
|
||||
plugin.getDataManager().deleteTemplate(this.template);
|
||||
plugin.getDataManager().createTemplate(template);
|
||||
justSaved = true;
|
||||
if (toModerate == null)
|
||||
guiManager.showGUI(player, new TemplateManagerGui(plugin, player));
|
||||
}
|
||||
|
||||
private void finishTemplate() {
|
||||
Template template = new Template(this.type, this.duration, this.reason, player, templateName);
|
||||
plugin.getTemplateManager().addTemplate(template);
|
||||
plugin.getDataManager().createTemplate(template);
|
||||
this.template = template;
|
||||
if (toModerate == null)
|
||||
guiManager.showGUI(player, new TemplateManagerGui(plugin, player));
|
||||
}
|
||||
|
||||
public void setTemplate(Template template) {
|
||||
this.justSaved = true;
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public void setType(PunishmentType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public void setDuration(long duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
|
@ -1,23 +1,24 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GUIPunishments extends AbstractGUI {
|
||||
public class PunishmentsGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final OfflinePlayer toModerate;
|
||||
|
@ -25,22 +26,40 @@ public class GUIPunishments extends AbstractGUI {
|
|||
private Activity currentActivity = Activity.BOTH;
|
||||
private PunishmentType punishmentType = PunishmentType.ALL;
|
||||
|
||||
private int page = 0;
|
||||
|
||||
public GUIPunishments(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
public PunishmentsGui(UltimateModeration plugin, OfflinePlayer toModerate) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.punishments.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage(), 54);
|
||||
setTitle(plugin.getLocale().getMessage("gui.punishments.title")
|
||||
.processPlaceholder("toModerate", toModerate.getName()).getMessage());
|
||||
|
||||
showPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
protected void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
|
||||
setNextPage(0, 5, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(0, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
PlayerPunishData playerPunishData = plugin.getPunishmentManager().getPlayer(toModerate);
|
||||
|
||||
|
@ -67,39 +86,33 @@ public class GUIPunishments extends AbstractGUI {
|
|||
}
|
||||
|
||||
int numNotes = punishments.size();
|
||||
int maxPage = (int) Math.floor(numNotes / 36.0);
|
||||
this.pages = (int) Math.floor(numNotes / 28.0);
|
||||
|
||||
punishments = punishments.stream().skip(page * 36).limit(36)
|
||||
punishments = punishments.stream().skip((page - 1) * 28).limit(28)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (page != 0) {
|
||||
createButton(1, Material.ARROW, plugin.getLocale().getMessage("gui.general.previous").getMessage());
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page--;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new PlayerGui(plugin, toModerate, event.player)));
|
||||
|
||||
if (page != maxPage) {
|
||||
createButton(6, Material.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage());
|
||||
registerClickable(6, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.APPLE, Methods.formatText("&6" + currentActivity.getTranslation())),
|
||||
(event) -> {
|
||||
this.currentActivity = currentActivity.next();
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
createButton(8, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13)
|
||||
? Material.OAK_DOOR
|
||||
: Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back").getMessage());
|
||||
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name())),
|
||||
(event) -> {
|
||||
this.punishmentType = punishmentType.nextFilter();
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
createButton(3, Material.APPLE, Methods.formatText("&6" + currentActivity.getTranslation()));
|
||||
createButton(4, Material.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name()));
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.GRAY_STAINED_GLASS_PANE : new ItemStack(Material.valueOf("STAINED_GLASS_PANE")), "&1");
|
||||
|
||||
int currentSlot = 18;
|
||||
int num = 11;
|
||||
for (PunishmentHolder punishmentHolder : punishments) {
|
||||
if (num == 16 || num == 36)
|
||||
num = num + 2;
|
||||
AppliedPunishment appliedPunishment = punishmentHolder.getAppliedPunishment();
|
||||
Activity activity = punishmentHolder.getActivity();
|
||||
|
||||
|
@ -112,7 +125,7 @@ public class GUIPunishments extends AbstractGUI {
|
|||
lore.add(plugin.getLocale().getMessage("gui.punishments.duration").getMessage());
|
||||
lore.add("&7" + (appliedPunishment.getDuration() != -1
|
||||
? Methods.makeReadable(appliedPunishment.getDuration())
|
||||
: plugin.getLocale().getMessage("gui.general.permanent")));
|
||||
: plugin.getLocale().getMessage("gui.general.permanent").getMessage()));
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.punisher").getMessage());
|
||||
lore.add("&7" + (appliedPunishment.getPunisher() == null ? "Console" : Bukkit.getOfflinePlayer(appliedPunishment.getPunisher()).getName()));
|
||||
|
@ -124,43 +137,26 @@ public class GUIPunishments extends AbstractGUI {
|
|||
lore.add("");
|
||||
}
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.click").getMessage());
|
||||
|
||||
registerClickable(currentSlot, ((player1, inventory1, cursor, slot, type) -> {
|
||||
appliedPunishment.expire();
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
}
|
||||
lore.add("");
|
||||
createButton(currentSlot, Material.MAP,
|
||||
"&6&l" + appliedPunishment.getPunishmentType().getTranslation() + " - &7&l" + activity.getTranslation(), lore);
|
||||
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
TextUtils.formatText("&6&l" + appliedPunishment.getPunishmentType().getTranslation() + " - &7&l" + activity.getTranslation()),
|
||||
TextUtils.formatText(lore)),
|
||||
(event) -> {
|
||||
if (appliedPunishment.getPunishmentType() != PunishmentType.KICK
|
||||
&& activity == Activity.ACTIVE) {
|
||||
appliedPunishment.expire();
|
||||
plugin.getDataManager().updateAppliedPunishment(appliedPunishment);
|
||||
showPage();
|
||||
}
|
||||
});
|
||||
|
||||
currentSlot++;
|
||||
num++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayer(plugin, toModerate, player)));
|
||||
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.currentActivity = currentActivity.next();
|
||||
this.page = 0;
|
||||
constructGUI();
|
||||
}));
|
||||
|
||||
registerClickable(4, ((player1, inventory1, cursor, slot, type) -> {
|
||||
this.punishmentType = punishmentType.nextFilter();
|
||||
this.page = 0;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
|
||||
private class PunishmentHolder {
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TemplateManagerGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private PunishmentType punishmentType = PunishmentType.ALL;
|
||||
private final Player player;
|
||||
|
||||
private int page = 1;
|
||||
|
||||
public TemplateManagerGui(UltimateModeration plugin, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.templatemanager.title").getMessage());
|
||||
toCurrentPage();
|
||||
}
|
||||
|
||||
private void toPrevPage() {
|
||||
if (this.page <= 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
--this.page;
|
||||
toCurrentPage();
|
||||
}
|
||||
|
||||
private void toNextPage() {
|
||||
if (findTemplates(this.page + 1, this.punishmentType).size() > 0) {
|
||||
++this.page;
|
||||
toCurrentPage();
|
||||
}
|
||||
}
|
||||
|
||||
private void toCurrentPage() {
|
||||
if (inventory != null) {
|
||||
inventory.clear();
|
||||
}
|
||||
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
int numTemplates = plugin.getTemplateManager().getTemplates().size();
|
||||
this.pages = (int) Math.floor(numTemplates / 28.0);
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name())),
|
||||
(event) -> {
|
||||
this.punishmentType = punishmentType.nextFilter();
|
||||
this.page = 1;
|
||||
toCurrentPage();
|
||||
});
|
||||
|
||||
setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new MainGui(plugin, event.player)));
|
||||
|
||||
if (player.hasPermission("um.templates.create")) {
|
||||
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE,
|
||||
plugin.getLocale().getMessage("gui.templatemanager.create").getMessage()),
|
||||
(event) -> guiManager.showGUI(event.player, new PunishGui(plugin, null, null, player)));
|
||||
}
|
||||
|
||||
List<Template> templates = findTemplates(this.page, this.punishmentType);
|
||||
|
||||
int num = 11;
|
||||
for (Template template : templates) {
|
||||
if (num == 16 || num == 36) {
|
||||
num = num + 2;
|
||||
}
|
||||
|
||||
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText("&6&l" + template.getName()),
|
||||
plugin.getLocale().getMessage("gui.templatemanager.leftclick").getMessage(),
|
||||
plugin.getLocale().getMessage("gui.templatemanager.rightclick").getMessage()),
|
||||
(event) -> {
|
||||
if (event.clickType == ClickType.LEFT) {
|
||||
if (player.hasPermission("um.templates.edit"))
|
||||
guiManager.showGUI(player, new PunishGui(plugin, null, template, player));
|
||||
} else if (event.clickType == ClickType.RIGHT) {
|
||||
if (player.hasPermission("um.templates.destroy")) {
|
||||
plugin.getTemplateManager().removeTemplate(template);
|
||||
plugin.getDataManager().deleteTemplate(template);
|
||||
}
|
||||
|
||||
toCurrentPage();
|
||||
}
|
||||
});
|
||||
|
||||
++num;
|
||||
}
|
||||
|
||||
setButton(0, 3, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()), (event) -> toPrevPage());
|
||||
setButton(0, 5, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()), (event) -> toNextPage());
|
||||
}
|
||||
|
||||
private List<Template> findTemplates(int page, PunishmentType punishmentType) {
|
||||
return plugin.getTemplateManager().getTemplates().stream()
|
||||
.filter(template -> punishmentType == PunishmentType.ALL || template.getPunishmentType() == punishmentType)
|
||||
.skip((page - 1) * 28L)
|
||||
.limit(28)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TemplateSelectorGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final PunishGui punish;
|
||||
|
||||
public TemplateSelectorGui(UltimateModeration plugin, PunishGui punish, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.plugin = plugin;
|
||||
this.punish = punish;
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.templateselector.title").getMessage());
|
||||
paint();
|
||||
}
|
||||
|
||||
private void paint() {
|
||||
setButton(8, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
guiManager.showGUI(event.player, punish);
|
||||
punish.runTask();
|
||||
});
|
||||
|
||||
ArrayList<Template> templates = new ArrayList<>(plugin.getTemplateManager().getTemplates());
|
||||
for (int i = 0; i < templates.size(); i++) {
|
||||
Template template = templates.get(i);
|
||||
setButton(18 + i, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText("&6&l" + template.getName()),
|
||||
plugin.getLocale().getMessage("gui.templateselector.click").getMessage()),
|
||||
(event) -> {
|
||||
punish.setType(template.getPunishmentType());
|
||||
punish.setDuration(template.getDuration());
|
||||
punish.setReason(template.getReason());
|
||||
punish.setTemplate(template);
|
||||
punish.runTask();
|
||||
punish.paint();
|
||||
guiManager.showGUI(event.player, punish);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,153 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TicketGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final StaffChatManager chatManager = UltimateModeration.getInstance().getStaffChatManager();
|
||||
|
||||
private final Ticket ticket;
|
||||
|
||||
private final Player player;
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
|
||||
public TicketGui(UltimateModeration plugin, Ticket ticket, OfflinePlayer toModerate, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.ticket = ticket;
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
this.toModerate = toModerate;
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.ticket.title")
|
||||
.processPlaceholder("subject", ticket.getSubject())
|
||||
.processPlaceholder("id", ticket.getId()).getMessage());
|
||||
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
int numNotes = ticket.getResponses().size();
|
||||
this.pages = (int) Math.floor(numNotes / 28.0);
|
||||
|
||||
List<TicketResponse> responses = ticket.getResponses().stream().skip((page - 1) * 28).limit(28)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
// enable page event
|
||||
setNextPage(4, 7, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(4, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
if (player.hasPermission("um.tickets.openclose"))
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.LEVER, TextUtils.formatText("&6" + ticket.getStatus().getStatus())),
|
||||
(event) -> {
|
||||
ticket.setStatus(ticket.getStatus() == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN);
|
||||
plugin.getDataManager().updateTicket(ticket);
|
||||
// Notify staff of ticket status
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.status").getMessage().replace("%tid%", "" + ticket.getId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()).replace("%status%", ticket.getStatus().toString()));
|
||||
showPage();
|
||||
});
|
||||
|
||||
setButton(4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
plugin.getGuiManager().showGUI(event.player, new TicketManagerGui(plugin, toModerate, event.player));
|
||||
});
|
||||
|
||||
if (player.hasPermission("um.ticket.clicktotele") && ticket.getLocation() != null)
|
||||
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.ENDER_PEARL,
|
||||
plugin.getLocale().getMessage("gui.ticket.clicktotele").getMessage()),
|
||||
(event) -> player.teleport(ticket.getLocation()));
|
||||
|
||||
if (player.hasPermission("um.tickets.respond"))
|
||||
setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.WRITABLE_BOOK, plugin.getLocale().getMessage("gui.ticket.respond").getMessage()),
|
||||
(event) -> {
|
||||
ChatPrompt.showPrompt(plugin, player, plugin.getLocale().getMessage("gui.ticket.what").getMessage(), (evnt) -> {
|
||||
TicketResponse response = ticket.addResponse(new TicketResponse(player, evnt.getMessage(), System.currentTimeMillis()));
|
||||
plugin.getDataManager().createTicketResponse(response);
|
||||
// Notify staff of ticket response.
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.response").getMessage().replace("%tid%", "" + ticket.getId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()));
|
||||
showPage();
|
||||
}).setOnClose(() -> guiManager.showGUI(event.player, this));
|
||||
});
|
||||
|
||||
|
||||
int num = 11;
|
||||
for (TicketResponse ticketResponse : responses) {
|
||||
if (num == 16 || num == 36)
|
||||
num = num + 2;
|
||||
|
||||
String subjectStr = ticketResponse.getMessage();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < subjectStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (subjectStr.charAt(n) == ' ') {
|
||||
lore.add(TextUtils.formatText("&6" + subjectStr.substring(lastIndex, n).trim()));
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - subjectStr.length() < 20)
|
||||
lore.add(TextUtils.formatText("&6" + subjectStr.substring(lastIndex).trim()));
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.postedby")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticketResponse.getAuthor()).getName()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(ticketResponse.getPostedDate()))).getMessage());
|
||||
|
||||
setItem(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP, TextUtils.formatText(name), lore));
|
||||
num++;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketStatus;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
// FIXME: Pagination not working (probably in other GUIs too) (copy own one from TemplateManagerGui)
|
||||
public class TicketManagerGui extends Gui {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private TicketStatus status = TicketStatus.OPEN;
|
||||
|
||||
private final Player player;
|
||||
|
||||
public TicketManagerGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(6);
|
||||
setDefaultItem(null);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
this.player = player;
|
||||
|
||||
setTitle(plugin.getLocale().getMessage(toModerate != null ? "gui.tickets.titlesingle" : "gui.tickets.title")
|
||||
.processPlaceholder("toModerate", toModerate != null ? toModerate.getName() : "").getMessage());
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void showPage() {
|
||||
if (inventory != null)
|
||||
inventory.clear();
|
||||
setActionForRange(0, 53, null);
|
||||
|
||||
List<Ticket> tickets = toModerate != null
|
||||
? plugin.getTicketManager().getTicketsAbout(toModerate, status)
|
||||
: plugin.getTicketManager().getTickets(status);
|
||||
|
||||
int numTickets = tickets.size();
|
||||
this.pages = (int) Math.floor(numTickets / 28.0);
|
||||
|
||||
tickets = tickets.stream().skip((page - 1) * 28).limit(28).collect(Collectors.toList());
|
||||
|
||||
// decorate the edges
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_2.getMaterial(CompatibleMaterial.BLUE_STAINED_GLASS_PANE));
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Settings.GLASS_TYPE_3.getMaterial(CompatibleMaterial.LIGHT_BLUE_STAINED_GLASS_PANE));
|
||||
|
||||
// edges will be type 3
|
||||
mirrorFill(0, 2, true, true, glass3);
|
||||
mirrorFill(1, 1, true, true, glass3);
|
||||
|
||||
// decorate corners with type 2
|
||||
mirrorFill(0, 0, true, true, glass2);
|
||||
mirrorFill(1, 0, true, true, glass2);
|
||||
mirrorFill(0, 1, true, true, glass2);
|
||||
|
||||
// enable page event
|
||||
setNextPage(4, 7, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.next").getMessage()));
|
||||
setPrevPage(4, 1, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("gui.general.back").getMessage()));
|
||||
setOnPage((event) -> showPage());
|
||||
|
||||
setButton(5, 3, GuiUtils.createButtonItem(CompatibleMaterial.LEVER, TextUtils.formatText("&6" + status.getStatus())),
|
||||
(event) -> {
|
||||
this.status = status == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN;
|
||||
this.page = 1;
|
||||
showPage();
|
||||
});
|
||||
|
||||
if (toModerate != null && player.hasPermission("um.tickets.create"))
|
||||
setButton(5, 5, GuiUtils.createButtonItem(CompatibleMaterial.REDSTONE,
|
||||
plugin.getLocale().getMessage("gui.tickets.create").getMessage()),
|
||||
(event) -> createNew(player, toModerate));
|
||||
|
||||
if (player.hasPermission("um.ticket"))
|
||||
setButton(5, 4, GuiUtils.createButtonItem(CompatibleMaterial.OAK_DOOR,
|
||||
plugin.getLocale().getMessage("gui.general.back").getMessage()),
|
||||
(event) -> {
|
||||
if (toModerate == null)
|
||||
plugin.getGuiManager().showGUI(player, new MainGui(plugin, player));
|
||||
else
|
||||
plugin.getGuiManager().showGUI(event.player, new PlayerGui(plugin, toModerate, event.player));
|
||||
});
|
||||
|
||||
int num = 11;
|
||||
for (Ticket ticket : tickets) {
|
||||
if (num == 16 || num == 36)
|
||||
num = num + 2;
|
||||
|
||||
String subjectStr = ticket.getSubject();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
int lastIndex = 0;
|
||||
for (int n = 0; n < subjectStr.length(); n++) {
|
||||
if (n - lastIndex < 20)
|
||||
continue;
|
||||
|
||||
if (subjectStr.charAt(n) == ' ') {
|
||||
lore.add("&6" + subjectStr.substring(lastIndex, n).trim());
|
||||
lastIndex = n;
|
||||
}
|
||||
}
|
||||
|
||||
if (lastIndex - subjectStr.length() < 20)
|
||||
lore.add("&6" + subjectStr.substring(lastIndex).trim() + " &7- " + ticket.getId());
|
||||
|
||||
String name = lore.get(0);
|
||||
lore.remove(0);
|
||||
|
||||
lore.add("");
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("MM-dd-yyyy");
|
||||
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.status")
|
||||
.processPlaceholder("status", ticket.getStatus().getStatus()).getMessage());
|
||||
|
||||
if (toModerate != null)
|
||||
lore.add(plugin.getLocale().getMessage("gui.tickets.player")
|
||||
.processPlaceholder("player", Bukkit.getOfflinePlayer(ticket.getVictim()).getName()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.type")
|
||||
.processPlaceholder("type", ticket.getType()).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon")
|
||||
.processPlaceholder("sent", format.format(new Date(ticket.getCreationDate()))).getMessage());
|
||||
lore.add(plugin.getLocale().getMessage("gui.tickets.click").getMessage());
|
||||
|
||||
setButton(num, GuiUtils.createButtonItem(CompatibleMaterial.MAP,
|
||||
TextUtils.formatText(name), TextUtils.formatText(lore)),
|
||||
(event) -> guiManager.showGUI(player, new TicketGui(plugin, ticket, toModerate, player)));
|
||||
num++;
|
||||
}
|
||||
}
|
||||
|
||||
public static void createNew(Player player, OfflinePlayer toModerate) {
|
||||
UltimateModeration plugin = UltimateModeration.getInstance();
|
||||
|
||||
AnvilGui gui = new AnvilGui(player);
|
||||
gui.setAction((event) ->
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
plugin.getGuiManager().showGUI(player,
|
||||
new TicketTypeGui(plugin, toModerate, player, gui.getInputText())), 1L));
|
||||
|
||||
ItemStack item = GuiUtils.createButtonItem(CompatibleMaterial.PAPER,
|
||||
plugin.getLocale().getMessage("gui.tickets.subject").getMessage());
|
||||
|
||||
gui.setInput(item);
|
||||
plugin.getGuiManager().showGUI(player, gui);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TicketTypeGui extends Gui {
|
||||
|
||||
private final StaffChatManager chatManager = UltimateModeration.getInstance().getStaffChatManager();
|
||||
|
||||
public TicketTypeGui(UltimateModeration plugin, OfflinePlayer toModerate, Player player, String subject) {
|
||||
super(3);
|
||||
setDefaultItem(null);
|
||||
|
||||
setTitle(plugin.getLocale().getMessage("gui.ticket.picktype").getMessage());
|
||||
|
||||
|
||||
List<String> types = Settings.TICKET_TYPES.getStringList();
|
||||
|
||||
for (int i = 0; i < types.size(); i++) {
|
||||
final int fi = i;
|
||||
setButton(i, GuiUtils.createButtonItem(CompatibleMaterial.PAPER, types.get(i)),
|
||||
(event) -> {
|
||||
Ticket ticket = new Ticket(toModerate, subject, types.get(fi));
|
||||
ChatPrompt.showPrompt(plugin,
|
||||
player, plugin.getLocale().getMessage("gui.tickets.what").getMessage(),
|
||||
event2 -> {
|
||||
plugin.getTicketManager().addTicket(ticket);
|
||||
|
||||
// Notify staff
|
||||
chatManager.getChat("ticket").messageAll(UltimateModeration.getInstance().getLocale().getMessage("notify.ticket.created").getMessage().replace("%tid%", "" + ticket.getId()).replace("%type%", ticket.getType()).replace("%player%", Bukkit.getPlayer(ticket.getVictim()).getDisplayName()));
|
||||
if (player == toModerate)
|
||||
ticket.setLocation(player.getLocation());
|
||||
ticket.addResponse(new TicketResponse(player, event2.getMessage(), System.currentTimeMillis()));
|
||||
plugin.getDataManager().createTicket(ticket);
|
||||
}).setOnClose(() ->
|
||||
guiManager.showGUI(event.player, new TicketGui(plugin, ticket, toModerate, player)));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,7 +2,6 @@ package com.songoda.ultimatemoderation.listeners;
|
|||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -11,32 +10,34 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BlockListener implements Listener {
|
||||
|
||||
|
||||
private UltimateModeration instance;
|
||||
private StaffChatManager chat = UltimateModeration.getInstance().getStaffChatManager();
|
||||
|
||||
|
||||
public BlockListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
Material material = block.getType();
|
||||
|
||||
|
||||
List<String> blocks = instance.getConfig().getStringList("Main.Notify Blocks List");
|
||||
|
||||
for(String broken : blocks) {
|
||||
if(broken.equalsIgnoreCase(material.name())) {
|
||||
if(player.hasPermission("um.staffchat.join") && instance.getConfig().getBoolean("Main.Notify Blocks")) {
|
||||
chat.getChat("notify").messageAll("&7[UM] &a" + Bukkit.getPlayer(player.getUniqueId()).getDisplayName()
|
||||
+ UltimateModeration.getInstance().getLocale().getMessage("notify.block.main").getMessage().replace("%material%", material.name()) + "(" + block.getX() + ", " + block.getY() + ", " + block.getZ() + ")&a!");
|
||||
}
|
||||
|
||||
for (String broken : blocks) {
|
||||
if (!broken.equalsIgnoreCase(material.name())) continue;
|
||||
|
||||
if (player.hasPermission("um.trackblockbreaks") && instance.getConfig().getBoolean("Main.Notify Blocks")) {
|
||||
chat.getChat("notify").messageAll("&7[UM] &a" + Bukkit.getPlayer(player.getUniqueId()).getDisplayName()
|
||||
+ UltimateModeration.getInstance().getLocale().getMessage("notify.block.main").getMessage().replace("%material%", material.name()) + "(" + block.getX() + ", " + block.getY() + ", " + block.getZ() + ")&a!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,15 +3,18 @@ package com.songoda.ultimatemoderation.listeners;
|
|||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChannel;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ChatListener implements Listener {
|
||||
|
@ -35,7 +38,7 @@ public class ChatListener implements Listener {
|
|||
return slowModeOverride;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!onChat(player, event.getMessage()))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandCommandSpy;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.SpyModeration;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
|
@ -49,7 +49,7 @@ public class CommandListener implements Listener {
|
|||
|
||||
if (!player.hasPermission("um.commandspy.immune")) {
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if (pl != player && pl.hasPermission("um.commandspy") && CommandCommandSpy.isSpying(pl))
|
||||
if (pl != player && pl.hasPermission("um.commandspy") && SpyModeration.isSpying(pl))
|
||||
instance.getLocale().getMessage("command.commandspy.deny")
|
||||
.processPlaceholder("player", player.getName())
|
||||
.processPlaceholder("command", command)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandFreeze;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
@ -18,7 +18,7 @@ public class DropListener implements Listener {
|
|||
@EventHandler
|
||||
public void onMove(PlayerDropItemEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (CommandFreeze.isFrozen(player)) {
|
||||
if (FreezeModeration.isFrozen(player)) {
|
||||
event.setCancelled(true);
|
||||
instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandFreeze;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
@ -9,19 +9,19 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||
|
||||
public class InventoryListener implements Listener {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private UltimateModeration plugin;
|
||||
|
||||
public InventoryListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
this.plugin = ultimateModeration;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMove(InventoryClickEvent event) {
|
||||
if (!(event.getWhoClicked() instanceof Player)) return;
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
if (CommandFreeze.isFrozen(player)) {
|
||||
if (FreezeModeration.isFrozen(player)) {
|
||||
event.setCancelled(true);
|
||||
instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
plugin.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandFreeze;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
@ -18,7 +18,7 @@ public class MoveListener implements Listener {
|
|||
@EventHandler
|
||||
public void onMove(PlayerMoveEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (CommandFreeze.isFrozen(player)) {
|
||||
if (FreezeModeration.isFrozen(player)) {
|
||||
event.setCancelled(true);
|
||||
instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
}
|
||||
|
|
|
@ -2,16 +2,8 @@ package com.songoda.ultimatemoderation.listeners;
|
|||
|
||||
import com.songoda.skyblock.api.event.player.PlayerIslandChatEvent;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChatManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SkyBlockListener implements Listener {
|
||||
|
||||
|
@ -20,11 +12,11 @@ public class SkyBlockListener implements Listener {
|
|||
public SkyBlockListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onIslandChat(PlayerIslandChatEvent event) {
|
||||
if (!ChatListener.onChat(event.getPlayer(), event.getMessage()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.commands.CommandSpy;
|
||||
import com.songoda.ultimatemoderation.commands.CommandVanish;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.SpyModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -12,37 +11,40 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.player.PlayerToggleSneakEvent;
|
||||
import org.spigotmc.event.entity.EntityDismountEvent;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpyingDismountListener implements Listener {
|
||||
|
||||
private Map<UUID, GameMode> gamemodes = new HashMap<>();
|
||||
private static Map<UUID, GameMode> gamemodes = new HashMap<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityDismountEvent(EntityDismountEvent event) {
|
||||
if (!(event.getDismounted() instanceof Player)) return;
|
||||
if (!(event.getEntity() instanceof Player)) return;
|
||||
if (CommandSpy.isSpying((((Player) event.getEntity()).getPlayer()))) {
|
||||
if (SpyModeration.isSpying((((Player) event.getEntity()).getPlayer()))) {
|
||||
Player player = (Player) event.getEntity();
|
||||
gamemodes.put(player.getUniqueId(), player.getGameMode());
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateModeration.getInstance(), () ->
|
||||
player.setSpectatorTarget(event.getDismounted()), 5L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateModeration.getInstance(), () -> {
|
||||
|
||||
if (player.getGameMode() == GameMode.SPECTATOR)
|
||||
player.setSpectatorTarget(event.getDismounted());
|
||||
}, 5L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSneak(PlayerToggleSneakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.isSneaking() || !CommandSpy.isSpying(player) || player.getGameMode() != GameMode.SPECTATOR) return;
|
||||
CommandSpy.Spy spyingEntry = CommandSpy.getSpying().remove(player.getUniqueId());
|
||||
player.teleport(spyingEntry.getLastLocation());
|
||||
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(player))
|
||||
CommandVanish.vanish(player);
|
||||
player.setGameMode(gamemodes.get(player.getUniqueId()));
|
||||
if (player.isSneaking() || !SpyModeration.isSpying(player) || player.getGameMode() != GameMode.SPECTATOR)
|
||||
return;
|
||||
SpyModeration.spy(null, player);
|
||||
}
|
||||
|
||||
UltimateModeration.getInstance().getLocale().getMessage("command.spy.returned").sendPrefixedMessage(player);
|
||||
public static Map<UUID, GameMode> getGamemodes() {
|
||||
return Collections.unmodifiableMap(gamemodes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,67 @@
|
|||
package com.songoda.ultimatemoderation.moderate;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.VaultPermissions;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public abstract class AbstractModeration {
|
||||
|
||||
protected final UltimateModeration plugin;
|
||||
private final boolean requireOnline, allowConsole;
|
||||
|
||||
protected AbstractModeration(UltimateModeration plugin, boolean requireOnline, boolean allowConsole) {
|
||||
this.plugin = plugin;
|
||||
this.requireOnline = requireOnline;
|
||||
this.allowConsole = allowConsole;
|
||||
}
|
||||
|
||||
public abstract ModerationType getType();
|
||||
|
||||
public abstract CompatibleMaterial getIcon();
|
||||
|
||||
public abstract String getProper();
|
||||
|
||||
public abstract String getDescription();
|
||||
|
||||
public String getPermission() {
|
||||
return "um." + getProper().toLowerCase();
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player player) {
|
||||
return player.hasPermission(getPermission());
|
||||
}
|
||||
|
||||
public boolean isExempt(OfflinePlayer player) {
|
||||
return VaultPermissions.hasPermission(player, getPermission() + ".exempt");
|
||||
}
|
||||
|
||||
protected void registerCommand(UltimateModeration plugin) {
|
||||
plugin.getCommandManager().addCommand(new GenericModerationCommand(plugin, this));
|
||||
}
|
||||
|
||||
public boolean runPreModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
if (requireOnline && !toModerate.isOnline()) {
|
||||
plugin.getLocale().newMessage(toModerate.getName() + " must be online for this moderation.").sendPrefixedMessage(runner);
|
||||
}
|
||||
|
||||
if (isExempt(toModerate)) {
|
||||
plugin.getLocale().newMessage(toModerate.getName() + " is exempt from this moderation.").sendPrefixedMessage(runner);
|
||||
return false;
|
||||
}
|
||||
|
||||
return runModeration(runner, toModerate);
|
||||
}
|
||||
|
||||
protected abstract boolean runModeration(CommandSender runner, OfflinePlayer toModerate);
|
||||
|
||||
public boolean isRequireOnline() {
|
||||
return requireOnline;
|
||||
}
|
||||
|
||||
public boolean isAllowConsole() {
|
||||
return allowConsole;
|
||||
}
|
||||
}
|
|
@ -1,21 +1,24 @@
|
|||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.songoda.ultimatemoderation.moderate;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandInvSee extends AbstractCommand {
|
||||
public class GenericModerationCommand extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private final UltimateModeration plugin;
|
||||
private final AbstractModeration moderation;
|
||||
|
||||
public CommandInvSee(UltimateModeration instance) {
|
||||
super(CommandType.PLAYER_ONLY, "InvSee");
|
||||
this.instance = instance;
|
||||
public GenericModerationCommand(UltimateModeration plugin, AbstractModeration moderation) {
|
||||
super(moderation.isAllowConsole() ? CommandType.CONSOLE_OK : CommandType.PLAYER_ONLY, moderation.getProper());
|
||||
this.plugin = plugin;
|
||||
this.moderation = moderation;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -23,19 +26,15 @@ public class CommandInvSee extends AbstractCommand {
|
|||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online").sendPrefixedMessage(sender);
|
||||
if (!player.hasPlayedBefore()) {
|
||||
plugin.getLocale().newMessage("&cThis player has never played this server before...");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.invsee.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot invsee that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
moderation.runPreModeration(sender, player);
|
||||
|
||||
((Player) sender).openInventory(player.getInventory());
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -53,16 +52,16 @@ public class CommandInvSee extends AbstractCommand {
|
|||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.invsee";
|
||||
return moderation.getPermission();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/InvSee <player>";
|
||||
return "/" + moderation.getProper() + " <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to see inside of a players inventory.";
|
||||
return moderation.getDescription();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.songoda.ultimatemoderation.moderate;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.FreezeModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.InvSeeModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.ReviveModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.SpyModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.ViewEnderChestModeration;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class ModerationManager {
|
||||
|
||||
private static final Map<ModerationType, AbstractModeration> moderations = new TreeMap<>();
|
||||
|
||||
public ModerationManager(UltimateModeration plugin) {
|
||||
|
||||
addAllModerations(new FreezeModeration(plugin),
|
||||
new ReviveModeration(plugin),
|
||||
new InvSeeModeration(plugin),
|
||||
new ViewEnderChestModeration(plugin),
|
||||
new SpyModeration(plugin));
|
||||
}
|
||||
|
||||
public AbstractModeration addModeration(AbstractModeration moderation) {
|
||||
return moderations.put(moderation.getType(), moderation);
|
||||
}
|
||||
|
||||
public void addAllModerations(AbstractModeration... moderations) {
|
||||
for (AbstractModeration moderation : moderations) {
|
||||
ModerationManager.moderations.put(moderation.getType(), moderation);
|
||||
}
|
||||
}
|
||||
|
||||
public Map<ModerationType, AbstractModeration> getModerations() {
|
||||
return Collections.unmodifiableMap(moderations);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.moderate;
|
||||
|
||||
public enum ModerationType {
|
||||
|
||||
FREEZE, SPY, INV_SEE, ENDER_VIEW, REVIVE
|
||||
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FreezeModeration extends AbstractModeration {
|
||||
|
||||
private static final List<UUID> frozen = new ArrayList<>();
|
||||
|
||||
public FreezeModeration(UltimateModeration plugin) {
|
||||
super(plugin, false, true);
|
||||
registerCommand(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModerationType getType() {
|
||||
return ModerationType.FREEZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.BLUE_ICE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProper() {
|
||||
return "Freeze";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to freeze a player.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
if (frozen.contains(toModerate.getUniqueId())) {
|
||||
frozen.remove(toModerate.getUniqueId());
|
||||
plugin.getLocale().getMessage("command.freeze.remove")
|
||||
.processPlaceholder("player", toModerate.getPlayer().getDisplayName()).sendPrefixedMessage(runner);
|
||||
if (toModerate.isOnline())
|
||||
plugin.getLocale().getMessage("command.freeze.alertremove").sendPrefixedMessage(toModerate.getPlayer());
|
||||
} else {
|
||||
frozen.add(toModerate.getUniqueId());
|
||||
plugin.getLocale().getMessage("command.freeze.add")
|
||||
.processPlaceholder("player", toModerate.getPlayer().getDisplayName()).sendPrefixedMessage(runner);
|
||||
if (toModerate.isOnline())
|
||||
plugin.getLocale().getMessage("command.freeze.alertadd").sendPrefixedMessage(toModerate.getPlayer());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isFrozen(OfflinePlayer player) {
|
||||
return frozen.contains(player.getUniqueId());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class InvSeeModeration extends AbstractModeration {
|
||||
|
||||
public InvSeeModeration(UltimateModeration plugin) {
|
||||
super(plugin, true, false);
|
||||
registerCommand(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModerationType getType() {
|
||||
return ModerationType.INV_SEE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.CHEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProper() {
|
||||
return "InvSee";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to see inside of a players inventory.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
Player toModeratePlayer = (Player) toModerate;
|
||||
|
||||
((Player) runner).openInventory(toModeratePlayer.getInventory());
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.utils.PlayerUtils;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.listeners.DeathListener;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReviveModeration extends AbstractModeration {
|
||||
|
||||
public ReviveModeration(UltimateModeration plugin) {
|
||||
super(plugin, true, true);
|
||||
registerCommand(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModerationType getType() {
|
||||
return ModerationType.REVIVE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.POTION;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProper() {
|
||||
return "Revive";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to revive a player.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
Player toModeratePlayer = (Player) toModerate;
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
List<ItemStack> drops = DeathListener.getLastDrop(toModeratePlayer);
|
||||
|
||||
if (drops == null) {
|
||||
instance.getLocale().getMessage("command.revive.noloot").sendPrefixedMessage(runner);
|
||||
return false;
|
||||
}
|
||||
|
||||
ItemStack[] dropArr = new ItemStack[drops.size()];
|
||||
dropArr = drops.toArray(dropArr);
|
||||
|
||||
PlayerUtils.giveItem(toModeratePlayer, dropArr);
|
||||
|
||||
instance.getLocale().getMessage("command.revive.revived").sendPrefixedMessage(toModeratePlayer);
|
||||
instance.getLocale().getMessage("command.revive.success")
|
||||
.processPlaceholder("player", toModerate.getName()).sendPrefixedMessage(runner);
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -1,41 +1,96 @@
|
|||
package com.songoda.ultimatemoderation.commands;
|
||||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.songoda.ultimatemoderation.commands.CommandVanish;
|
||||
import com.songoda.ultimatemoderation.listeners.SpyingDismountListener;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandSpy extends AbstractCommand {
|
||||
|
||||
private UltimateModeration instance;
|
||||
public class SpyModeration extends AbstractModeration {
|
||||
|
||||
private static Map<UUID, Spy> spying = new HashMap<>();
|
||||
|
||||
public CommandSpy(UltimateModeration instance) {
|
||||
super(CommandType.PLAYER_ONLY, "Spy");
|
||||
this.instance = instance;
|
||||
public SpyModeration(UltimateModeration plugin) {
|
||||
super(plugin, true, false);
|
||||
registerCommand(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModerationType getType() {
|
||||
return ModerationType.SPY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.ENDER_EYE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProper() {
|
||||
return "Spy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to spy on a player.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
Player toModeratePlayer = (Player) toModerate;
|
||||
Player runnerPlayer = (Player) runner;
|
||||
|
||||
if (spying.containsKey(runnerPlayer.getUniqueId())) {
|
||||
Spy spyingEntry = spying.remove(runnerPlayer.getUniqueId());
|
||||
runnerPlayer.teleport(spyingEntry.getLastLocation());
|
||||
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(runnerPlayer))
|
||||
CommandVanish.vanish(runnerPlayer);
|
||||
|
||||
plugin.getLocale().getMessage("command.spy.returned").sendPrefixedMessage(runner);
|
||||
return true;
|
||||
}
|
||||
|
||||
spy(toModeratePlayer, runnerPlayer);
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isSpying(OfflinePlayer player) {
|
||||
return spying.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static void spy(OfflinePlayer oPlayer, Player senderP) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
|
||||
if (spying.containsKey(senderP) && oPlayer == null) {
|
||||
Spy spyingEntry = spying.remove(senderP.getUniqueId());
|
||||
senderP.teleport(spyingEntry.getLastLocation());
|
||||
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(senderP))
|
||||
CommandVanish.vanish(senderP);
|
||||
senderP.setGameMode(SpyingDismountListener.getGamemodes().get(senderP.getUniqueId()));
|
||||
|
||||
UltimateModeration.getInstance().getLocale().getMessage("command.spy.returned").sendPrefixedMessage(senderP);
|
||||
}
|
||||
|
||||
if (!ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12)) {
|
||||
instance.getLocale().newMessage("This feature is not compatible with this version of spigot.").sendPrefixedMessage(senderP);
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = oPlayer.getPlayer();
|
||||
|
||||
if (player == null) {
|
||||
if (oPlayer == null || !oPlayer.isOnline()) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online.").sendPrefixedMessage(senderP);
|
||||
return;
|
||||
}
|
||||
Player player = oPlayer.getPlayer();
|
||||
|
||||
if (player == senderP) {
|
||||
instance.getLocale().getMessage("command.spy.cant").sendPrefixedMessage(senderP);
|
||||
|
@ -58,77 +113,6 @@ public class CommandSpy extends AbstractCommand {
|
|||
.processPlaceholder("player", player.getName()).sendPrefixedMessage(senderP);
|
||||
}
|
||||
|
||||
public static boolean isSpying(OfflinePlayer player) {
|
||||
return spying.containsKey(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length > 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player senderP = ((Player) sender);
|
||||
|
||||
if (args.length == 0) {
|
||||
if (!spying.containsKey(senderP.getUniqueId()))
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
Spy spyingEntry = spying.remove(senderP.getUniqueId());
|
||||
senderP.teleport(spyingEntry.getLastLocation());
|
||||
if (spyingEntry.isVanishApplied() && CommandVanish.isVanished(senderP))
|
||||
CommandVanish.vanish(senderP);
|
||||
|
||||
instance.getLocale().getMessage("command.spy.returned").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
instance.getLocale().newMessage("That player does not exist or is not online.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.spy.exempt")) {
|
||||
instance.getLocale().newMessage("You cannot spy on that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
spy(player, senderP);
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
players.add(player.getName());
|
||||
}
|
||||
return players;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.spy";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/Spy [player]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to spy on a player.";
|
||||
}
|
||||
|
||||
public static Map<UUID, Spy> getSpying() {
|
||||
return spying;
|
||||
}
|
||||
|
||||
public static class Spy {
|
||||
private Location lastLocation;
|
||||
private boolean vanishApplied;
|
|
@ -0,0 +1,45 @@
|
|||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.AbstractModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.ModerationType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ViewEnderChestModeration extends AbstractModeration {
|
||||
|
||||
public ViewEnderChestModeration(UltimateModeration plugin) {
|
||||
super(plugin, true, false);
|
||||
registerCommand(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModerationType getType() {
|
||||
return ModerationType.ENDER_VIEW;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompatibleMaterial getIcon() {
|
||||
return CompatibleMaterial.ENDER_CHEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProper() {
|
||||
return "ViewEnderChest";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to see inside of a players ender chest.";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean runModeration(CommandSender runner, OfflinePlayer toModerate) {
|
||||
Player toModeratePlayer = (Player) toModerate;
|
||||
|
||||
((Player) runner).openInventory(toModeratePlayer.getEnderChest());
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -8,8 +8,8 @@ public class AppliedPunishment extends Punishment {
|
|||
private final UUID punisher;
|
||||
private long expiration;
|
||||
|
||||
public AppliedPunishment(PunishmentType punishmentType, long duration, String reason, UUID victim, UUID punisher, long expiration, UUID uuid) {
|
||||
super(punishmentType, duration, reason, uuid);
|
||||
public AppliedPunishment(PunishmentType punishmentType, long duration, String reason, UUID victim, UUID punisher, long expiration, int id) {
|
||||
super(punishmentType, duration, reason, id);
|
||||
this.victim = victim;
|
||||
this.punisher = punisher;
|
||||
this.expiration = expiration;
|
||||
|
|
|
@ -3,46 +3,42 @@ package com.songoda.ultimatemoderation.punish;
|
|||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class Punishment {
|
||||
|
||||
private final UUID uuid;
|
||||
private int id;
|
||||
|
||||
private final PunishmentType punishmentType;
|
||||
private final long duration;
|
||||
private final String reason;
|
||||
|
||||
public Punishment(PunishmentType punishmentType, long duration, String reason, UUID uuid) {
|
||||
public Punishment(PunishmentType punishmentType, long duration, String reason, int id) {
|
||||
this.punishmentType = punishmentType;
|
||||
this.duration = duration;
|
||||
this.reason = reason;
|
||||
this.uuid = uuid;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Punishment(PunishmentType punishmentType, long duration, String reason) {
|
||||
this.punishmentType = punishmentType;
|
||||
this.duration = duration;
|
||||
this.reason = reason;
|
||||
this.uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
public Punishment(PunishmentType punishmentType, String reason) {
|
||||
this.punishmentType = punishmentType;
|
||||
this.duration = -1;
|
||||
this.duration = 0;
|
||||
this.reason = reason;
|
||||
this.uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
protected Punishment(Punishment punishment) {
|
||||
this.punishmentType = punishment.getPunishmentType();
|
||||
this.duration = punishment.getDuration();
|
||||
this.reason = punishment.getReason();
|
||||
this.uuid = punishment.getUUID();
|
||||
}
|
||||
|
||||
public void execute(CommandSender punisher, OfflinePlayer victim) {
|
||||
|
@ -60,12 +56,11 @@ public class Punishment {
|
|||
plugin.getLocale().getMessage("event.ban.already").sendPrefixedMessage(punisher);
|
||||
return;
|
||||
}
|
||||
if (victim.isOnline()) {
|
||||
victim.getPlayer().kickPlayer(plugin.getLocale()
|
||||
if (victim.isOnline())
|
||||
Bukkit.getScheduler().runTask(plugin, () -> victim.getPlayer().kickPlayer(plugin.getLocale()
|
||||
.getMessage("event.ban.message")
|
||||
.processPlaceholder("reason", reason == null ? "" : reason)
|
||||
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage());
|
||||
}
|
||||
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage()));
|
||||
break;
|
||||
case MUTE:
|
||||
if (!playerPunishData.getActivePunishments(PunishmentType.MUTE).isEmpty()) {
|
||||
|
@ -75,12 +70,10 @@ public class Punishment {
|
|||
sendMessage(victim);
|
||||
break;
|
||||
case KICK:
|
||||
if (victim.isOnline()) {
|
||||
victim.getPlayer().kickPlayer(plugin.getLocale()
|
||||
if (victim.isOnline())
|
||||
Bukkit.getScheduler().runTask(plugin, () -> victim.getPlayer().kickPlayer(plugin.getLocale()
|
||||
.getMessage("event.kick.message")
|
||||
.processPlaceholder("reason", reason == null ? "" : reason)
|
||||
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage());
|
||||
}
|
||||
.processPlaceholder("reason", reason == null ? "" : reason).getMessage()));
|
||||
break;
|
||||
case WARNING:
|
||||
sendMessage(victim);
|
||||
|
@ -96,13 +89,20 @@ public class Punishment {
|
|||
punishSuccess += plugin.getLocale().getMessage("event.punish.reason")
|
||||
.processPlaceholder("reason", reason).getMessage();
|
||||
|
||||
if (duration != -1)
|
||||
if (duration != -1 && duration != 0)
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.theirduration")
|
||||
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage();
|
||||
|
||||
punisher.sendMessage(punishSuccess + Methods.formatText("&7."));
|
||||
|
||||
playerPunishData.addPunishment(apply(victim, punisher));
|
||||
AppliedPunishment appliedPunishment = apply(victim, punisher);
|
||||
if (duration != 0) {
|
||||
playerPunishData.addPunishment(appliedPunishment);
|
||||
} else {
|
||||
appliedPunishment.expire();
|
||||
playerPunishData.addExpiredPunishment(appliedPunishment);
|
||||
}
|
||||
plugin.getDataManager().createAppliedPunishment(appliedPunishment);
|
||||
}
|
||||
|
||||
public void sendMessage(OfflinePlayer offlineVictim) {
|
||||
|
@ -124,8 +124,12 @@ public class Punishment {
|
|||
victim.sendMessage(punishSuccess + Methods.formatText("&7."));
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public PunishmentType getPunishmentType() {
|
||||
|
@ -142,7 +146,7 @@ public class Punishment {
|
|||
|
||||
private AppliedPunishment apply(OfflinePlayer player, CommandSender punisher) {
|
||||
return new AppliedPunishment(this, player.getUniqueId(),
|
||||
punisher == null ? null : punisher instanceof OfflinePlayer ? ((OfflinePlayer)punisher).getUniqueId() : null, System.currentTimeMillis() + this.duration);
|
||||
punisher == null ? null : punisher instanceof OfflinePlayer ? ((OfflinePlayer) punisher).getUniqueId() : null, System.currentTimeMillis() + this.duration);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,15 +4,15 @@ import java.util.UUID;
|
|||
|
||||
public class PunishmentNote {
|
||||
|
||||
private final UUID uuid;
|
||||
private int id;
|
||||
|
||||
private final String note;
|
||||
private final UUID author;
|
||||
private final UUID subject;
|
||||
private final long creationDate;
|
||||
|
||||
public PunishmentNote(UUID uuid, String note, UUID author, UUID subject, long creationDate) {
|
||||
this.uuid = uuid;
|
||||
public PunishmentNote(int id, String note, UUID author, UUID subject, long creationDate) {
|
||||
this.id = id;
|
||||
this.note = note;
|
||||
this.author = author;
|
||||
this.subject = subject;
|
||||
|
@ -20,15 +20,18 @@ public class PunishmentNote {
|
|||
}
|
||||
|
||||
public PunishmentNote(String note, UUID author, UUID subject, long creationDate) {
|
||||
this.uuid = UUID.randomUUID();
|
||||
this.note = note;
|
||||
this.author = author;
|
||||
this.subject = subject;
|
||||
this.creationDate = creationDate;
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return uuid;
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getNote() {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package com.songoda.ultimatemoderation.punish.player;
|
||||
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -57,6 +58,11 @@ public class PlayerPunishData {
|
|||
return appliedPunishments;
|
||||
}
|
||||
|
||||
public AppliedPunishment[] addExpiredPunishment(AppliedPunishment... appliedPunishments) {
|
||||
this.expiredPunishments.addAll(Arrays.asList(appliedPunishments));
|
||||
return appliedPunishments;
|
||||
}
|
||||
|
||||
public AppliedPunishment[] removePunishment(AppliedPunishment... appliedPunishments) {
|
||||
this.activePunishments.removeAll(Arrays.asList(appliedPunishments));
|
||||
return appliedPunishments;
|
||||
|
@ -76,7 +82,7 @@ public class PlayerPunishData {
|
|||
return notes;
|
||||
}
|
||||
|
||||
public PunishmentNote[] removeNote(PunishmentNote... notes) {
|
||||
public PunishmentNote[] removeNotes(PunishmentNote... notes) {
|
||||
this.punishmentNotes.removeAll(Arrays.asList(notes));
|
||||
return notes;
|
||||
}
|
||||
|
@ -100,6 +106,7 @@ public class PlayerPunishData {
|
|||
activePunishments.stream().filter(appliedPunishment ->
|
||||
type == appliedPunishment.getPunishmentType()).forEach(appliedPunishment -> {
|
||||
appliedPunishment.expire();
|
||||
UltimateModeration.getInstance().getDataManager().updateAppliedPunishment(appliedPunishment);
|
||||
toAudit.add(appliedPunishment);
|
||||
});
|
||||
toAudit.forEach(appliedPunishment -> this.audit(true, type));
|
||||
|
|
|
@ -11,25 +11,25 @@ public class Template extends Punishment {
|
|||
private final String templateName;
|
||||
private final UUID creator;
|
||||
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, Player creator, String templateName) {
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, Player creator, String name) {
|
||||
super(punishmentType, duration, reason);
|
||||
this.creator = creator.getUniqueId();
|
||||
this.templateName = templateName;
|
||||
this.templateName = name;
|
||||
}
|
||||
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, UUID creator, String templateName, UUID uuid) {
|
||||
super(punishmentType, duration, reason, uuid);
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, UUID creator, String name, int id) {
|
||||
super(punishmentType, duration, reason, id);
|
||||
this.creator = creator;
|
||||
this.templateName = templateName;
|
||||
this.templateName = name;
|
||||
}
|
||||
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, UUID creator, String templateName) {
|
||||
public Template(PunishmentType punishmentType, long duration, String reason, UUID creator, String name) {
|
||||
super(punishmentType, duration, reason);
|
||||
this.creator = creator;
|
||||
this.templateName = templateName;
|
||||
this.templateName = name;
|
||||
}
|
||||
|
||||
public String getTemplateName() {
|
||||
public String getName() {
|
||||
return templateName;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,36 +2,34 @@ package com.songoda.ultimatemoderation.punish.template;
|
|||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TemplateManager {
|
||||
|
||||
private static final Map<UUID, Template> templates = new HashMap<>();
|
||||
private static final List<Template> templates = new LinkedList<>();
|
||||
|
||||
public Template getTemplate(String name) {
|
||||
for (Template template : templates.values()) {
|
||||
if (formatName(template.getTemplateName()).equals(formatName(name)))
|
||||
for (Template template : templates) {
|
||||
if (formatName(template.getName()).equals(formatName(name)))
|
||||
return template;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Template addTemplate(Template template) {
|
||||
return templates.put(template.getUUID(), template);
|
||||
templates.add(template);
|
||||
return template;
|
||||
}
|
||||
|
||||
public Template removeTemplate(UUID uuid) {
|
||||
return templates.remove(uuid);
|
||||
public Template removeTemplate(Template template) {
|
||||
templates.remove(template);
|
||||
return template;
|
||||
}
|
||||
|
||||
public Template updateTemplate(UUID uuid, Template template) {
|
||||
templates.remove(uuid);
|
||||
return addTemplate(template);
|
||||
}
|
||||
|
||||
public Map<UUID, Template> getTemplates() {
|
||||
return Collections.unmodifiableMap(templates);
|
||||
public List<Template> getTemplates() {
|
||||
return Collections.unmodifiableList(templates);
|
||||
}
|
||||
|
||||
private String formatName(String name) {
|
||||
|
@ -40,5 +38,4 @@ public class TemplateManager {
|
|||
name = name.replace(" ", "_");
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,11 +3,9 @@ package com.songoda.ultimatemoderation.settings;
|
|||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.configuration.ConfigSetting;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Settings {
|
||||
|
||||
|
@ -53,12 +51,21 @@ public class Settings {
|
|||
public static final ConfigSetting LANGUGE_MODE = new ConfigSetting(config, "System.Language Mode", "en_US",
|
||||
"The enabled language file.",
|
||||
"More language files (if available) can be found in the plugins data folder.");
|
||||
|
||||
|
||||
public static final ConfigSetting NOTIFY_BLOCK = new ConfigSetting(config, "Main.Notify Blocks", true, "Notify Staff on Block Break");
|
||||
|
||||
|
||||
public static final ConfigSetting NOTIFY_BLOCK_LIST = new ConfigSetting(config, "Main.Notify Blocks List", Arrays.asList("DIAMOND_ORE", "EMERALD_ORE"),
|
||||
"Blocks that will give a notification when mined.");
|
||||
|
||||
public static final ConfigSetting MYSQL_ENABLED = new ConfigSetting(config, "MySQL.Enabled", false, "Set to 'true' to use MySQL instead of SQLite for data storage.");
|
||||
public static final ConfigSetting MYSQL_HOSTNAME = new ConfigSetting(config, "MySQL.Hostname", "localhost");
|
||||
public static final ConfigSetting MYSQL_PORT = new ConfigSetting(config, "MySQL.Port", 3306);
|
||||
public static final ConfigSetting MYSQL_DATABASE = new ConfigSetting(config, "MySQL.Database", "your-database");
|
||||
public static final ConfigSetting MYSQL_USERNAME = new ConfigSetting(config, "MySQL.Username", "user");
|
||||
public static final ConfigSetting MYSQL_PASSWORD = new ConfigSetting(config, "MySQL.Password", "pass");
|
||||
public static final ConfigSetting MYSQL_USE_SSL = new ConfigSetting(config, "MySQL.Use SSL", false);
|
||||
public static final ConfigSetting MYSQL_POOL_SIZE = new ConfigSetting(config, "MySQL.Pool Size", 3, "Determines the number of connections the pool is using. Increase this value if you are getting timeout errors when more players online.");
|
||||
|
||||
public static void setupConfig() {
|
||||
config.load();
|
||||
config.setAutoremove(true).setAutosave(true);
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.songoda.ultimatemoderation.staffchat;
|
|||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -28,6 +27,10 @@ public class StaffChannel {
|
|||
|
||||
public void addMember(Player player) {
|
||||
if (members.contains(player.getUniqueId())) return;
|
||||
messageAll(UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("event.staffchat.alljoin")
|
||||
.processPlaceholder("player", player.getName()).getMessage(), player);
|
||||
|
||||
UltimateModeration.getInstance().getStaffChatManager().getChats().values().stream().forEach(members1 -> {
|
||||
if (members1.listMembers().contains(player.getUniqueId())) {
|
||||
members1.removeMember(player);
|
||||
|
@ -37,34 +40,32 @@ public class StaffChannel {
|
|||
if (chatLog.size() > 5) {
|
||||
chatLog.stream().skip(chatLog.size() - 3).forEach(message -> player.sendMessage(Methods.formatText(message)));
|
||||
}
|
||||
messageAll(UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("event.staffchat.format.join")
|
||||
.processPlaceholder("color", chatChar)
|
||||
.processPlaceholder("channel", channelName)
|
||||
.processPlaceholder("player", player.getDisplayName()).getMessage());
|
||||
}
|
||||
|
||||
public void removeMember(Player player) {
|
||||
members.remove(player.getUniqueId());
|
||||
messageAll(UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("event.staffchat.format.leave")
|
||||
.processPlaceholder("color", chatChar)
|
||||
.processPlaceholder("channel", channelName)
|
||||
.processPlaceholder("player", player.getDisplayName()).getMessage());
|
||||
.getMessage("event.staffchat.allleave")
|
||||
.processPlaceholder("player", player.getName()).getMessage(), player);
|
||||
}
|
||||
|
||||
public void processMessage(String message, Player player) {
|
||||
messageAll(UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("event.staffchat.format")
|
||||
.processPlaceholder("color", chatChar)
|
||||
.processPlaceholder("channel", channelName)
|
||||
.processPlaceholder("player", player.getDisplayName())
|
||||
.processPlaceholder("message", message).getMessage());
|
||||
.getMessage("event.staffchat.format")
|
||||
.processPlaceholder("color", chatChar)
|
||||
.processPlaceholder("channel", channelName)
|
||||
.processPlaceholder("player", player.getDisplayName())
|
||||
.processPlaceholder("message", message).getMessage());
|
||||
}
|
||||
|
||||
public void messageAll(String message) {
|
||||
messageAll(message, null);
|
||||
}
|
||||
|
||||
public void messageAll(String message, Player exempt) {
|
||||
chatLog.add(message);
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (exempt != null && player == exempt) continue;
|
||||
if (!members.contains(player.getUniqueId()) && !player.hasPermission("um.staffchat.spy")) continue;
|
||||
player.sendMessage(Methods.formatText(message));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.songoda.ultimatemoderation.staffchat;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class StaffChatManager {
|
||||
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.storage;
|
||||
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.tickets.Ticket;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class Storage {
|
||||
|
||||
protected final UltimateModeration plugin;
|
||||
protected final Config dataFile;
|
||||
|
||||
public Storage(UltimateModeration plugin) {
|
||||
this.plugin = plugin;
|
||||
this.dataFile = new Config(plugin, "data.yml");
|
||||
this.dataFile.load();
|
||||
}
|
||||
|
||||
public abstract boolean containsGroup(String group);
|
||||
|
||||
public abstract List<StorageRow> getRowsByGroup(String group);
|
||||
|
||||
public abstract void prepareSaveItem(String group, StorageItem... items);
|
||||
|
||||
public void updateData(UltimateModeration instance) {
|
||||
// Save game data
|
||||
for (Template template : instance.getTemplateManager().getTemplates().values()) {
|
||||
prepareSaveItem("templates", new StorageItem("uuid", template.getUUID().toString()),
|
||||
new StorageItem("type", template.getPunishmentType().name()),
|
||||
new StorageItem("duration", template.getDuration()),
|
||||
new StorageItem("reason", template.getReason()),
|
||||
new StorageItem("name", template.getTemplateName()),
|
||||
new StorageItem("creator", template.getCreator().toString()));
|
||||
}
|
||||
|
||||
for (PlayerPunishData playerPunishData : instance.getPunishmentManager().getPunishments().values()) {
|
||||
List<AppliedPunishment> appliedPunishments = playerPunishData.getActivePunishments();
|
||||
appliedPunishments.addAll(playerPunishData.getExpiredPunishments());
|
||||
for (AppliedPunishment appliedPunishment : appliedPunishments) {
|
||||
prepareSaveItem("punishments", new StorageItem("uuid", appliedPunishment.getUUID().toString()),
|
||||
new StorageItem("type", appliedPunishment.getPunishmentType().name()),
|
||||
new StorageItem("duration", appliedPunishment.getDuration()),
|
||||
new StorageItem("reason", appliedPunishment.getReason()),
|
||||
new StorageItem("victim", appliedPunishment.getVictim().toString()),
|
||||
new StorageItem("punisher", appliedPunishment.getPunisher() == null ? null : appliedPunishment.getPunisher().toString()),
|
||||
new StorageItem("expiration", appliedPunishment.getExpiration()));
|
||||
}
|
||||
|
||||
List<PunishmentNote> notes = playerPunishData.getNotes();
|
||||
for (PunishmentNote note : notes) {
|
||||
prepareSaveItem("notes", new StorageItem("uuid", note.getUUID().toString()),
|
||||
new StorageItem("note", note.getNote()),
|
||||
new StorageItem("author", note.getAuthor().toString()),
|
||||
new StorageItem("subject", note.getSubject().toString()),
|
||||
new StorageItem("creation", note.getCreationDate()));
|
||||
}
|
||||
}
|
||||
|
||||
for (Ticket ticket : instance.getTicketManager().getTickets()) {
|
||||
prepareSaveItem("tickets", new StorageItem("id", ticket.getTicketId()),
|
||||
new StorageItem("player", ticket.getVictim().toString()),
|
||||
new StorageItem("subject", ticket.getSubject()),
|
||||
new StorageItem("type", ticket.getType()),
|
||||
new StorageItem("location", Methods.serializeLocation(ticket.getLocation())),
|
||||
new StorageItem("status", ticket.getStatus().toString()));
|
||||
|
||||
for (TicketResponse ticketResponse : ticket.getResponses()) {
|
||||
prepareSaveItem("ticketresponses", new StorageItem("posted", ticketResponse.getPostedDate()),
|
||||
new StorageItem("ticketid", ticket.getTicketId()),
|
||||
new StorageItem("author", ticketResponse.getAuthor().toString()),
|
||||
new StorageItem("message", ticketResponse.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void doSave();
|
||||
|
||||
public abstract void save();
|
||||
|
||||
public abstract void makeBackup();
|
||||
|
||||
public abstract void closeConnection();
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.storage;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StorageItem {
|
||||
|
||||
private final Object object;
|
||||
private String key = null;
|
||||
|
||||
public StorageItem(Object object) {
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public StorageItem(String key, Object object) {
|
||||
this.key = key;
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public StorageItem(String key, List<Material> material) {
|
||||
String object = "";
|
||||
for (Material m : material) {
|
||||
object += m.name() + ";";
|
||||
}
|
||||
this.key = key;
|
||||
this.object = object;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String asString() {
|
||||
if (object == null) return null;
|
||||
return (String) object;
|
||||
}
|
||||
|
||||
public long asLong() {
|
||||
if (object == null) return -1;
|
||||
if (object instanceof Integer) {
|
||||
return (long)((int)object);
|
||||
}
|
||||
return (long) object;
|
||||
}
|
||||
|
||||
public boolean asBoolean() {
|
||||
if (object == null) return false;
|
||||
return (boolean) object;
|
||||
}
|
||||
|
||||
public int asInt() {
|
||||
if (object == null) return 0;
|
||||
return (int) object;
|
||||
}
|
||||
|
||||
public Object asObject() {
|
||||
return object;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.storage;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
public class StorageRow {
|
||||
|
||||
private final String key;
|
||||
|
||||
private final Map<String, StorageItem> items;
|
||||
|
||||
public StorageRow(String key, Map<String, StorageItem> items) {
|
||||
this.key = key;
|
||||
this.items = items;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public Map<String, StorageItem> getItems() {
|
||||
return Collections.unmodifiableMap(items);
|
||||
}
|
||||
|
||||
public StorageItem get(String key) {
|
||||
if (!items.containsKey(key) || items.get(key).asObject().toString().equals("")) return new StorageItem(null);
|
||||
return items.get(key);
|
||||
}
|
||||
}
|
|
@ -1,148 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.storage.types;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.storage.Storage;
|
||||
import com.songoda.ultimatemoderation.storage.StorageItem;
|
||||
import com.songoda.ultimatemoderation.storage.StorageRow;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.MemorySection;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class StorageYaml extends Storage {
|
||||
|
||||
private final Map<String, Object> toSave = new HashMap<>();
|
||||
private Map<String, Object> lastSave = null;
|
||||
|
||||
public StorageYaml(UltimateModeration plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsGroup(String group) {
|
||||
return dataFile.contains("data." + group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageRow> getRowsByGroup(String group) {
|
||||
List<StorageRow> rows = new ArrayList<>();
|
||||
ConfigurationSection currentSection = dataFile.getConfigurationSection("data." + group);
|
||||
for (String key : currentSection.getKeys(false)) {
|
||||
|
||||
Map<String, StorageItem> items = new HashMap<>();
|
||||
ConfigurationSection currentSection2 = dataFile.getConfigurationSection("data." + group + "." + key);
|
||||
for (String key2 : currentSection2.getKeys(false)) {
|
||||
String path = "data." + group + "." + key + "." + key2;
|
||||
items.put(key2, new StorageItem(dataFile.get(path) instanceof MemorySection
|
||||
? convertToInLineList(path) : dataFile.get(path)));
|
||||
}
|
||||
if (items.isEmpty()) continue;
|
||||
StorageRow row = new StorageRow(key, items);
|
||||
rows.add(row);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
private String convertToInLineList(String path) {
|
||||
StringBuilder converted = new StringBuilder();
|
||||
for (String key : dataFile.getConfigurationSection(path).getKeys(false)) {
|
||||
converted.append(key).append(":").append(dataFile.getInt(path + "." + key)).append(";");
|
||||
}
|
||||
return converted.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareSaveItem(String group, StorageItem... items) {
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
toSave.put("data." + group + "." + items[0].asString() + "." + item.getKey(), item.asObject());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSave() {
|
||||
this.updateData(plugin);
|
||||
|
||||
if (lastSave == null)
|
||||
lastSave = new HashMap<>(toSave);
|
||||
|
||||
if (toSave.isEmpty()) return;
|
||||
Map<String, Object> nextSave = new HashMap<>(toSave);
|
||||
|
||||
this.makeBackup();
|
||||
this.save();
|
||||
|
||||
toSave.clear();
|
||||
lastSave.clear();
|
||||
lastSave.putAll(nextSave);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
try {
|
||||
for (Map.Entry<String, Object> entry : lastSave.entrySet()) {
|
||||
if (toSave.containsKey(entry.getKey())) {
|
||||
Object newValue = toSave.get(entry.getKey());
|
||||
if (!entry.getValue().equals(newValue)) {
|
||||
dataFile.set(entry.getKey(), newValue);
|
||||
}
|
||||
toSave.remove(entry.getKey());
|
||||
} else {
|
||||
dataFile.set(entry.getKey(), null);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Object> entry : toSave.entrySet()) {
|
||||
dataFile.set(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
dataFile.save();
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeBackup() {
|
||||
File data = new File(plugin.getDataFolder(), "data.yml");
|
||||
File dataClone = new File(plugin.getDataFolder(), "data-backup-" + System.currentTimeMillis() + ".yml");
|
||||
try {
|
||||
if (data.exists())
|
||||
copyFile(data, dataClone);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Deque<File> backups = new ArrayDeque<>();
|
||||
for (File file : Objects.requireNonNull(plugin.getDataFolder().listFiles())) {
|
||||
if (file.getName().toLowerCase().contains("data-backup")) {
|
||||
backups.add(file);
|
||||
}
|
||||
}
|
||||
if (backups.size() > 3) {
|
||||
backups.getFirst().delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeConnection() {
|
||||
dataFile.save();
|
||||
}
|
||||
|
||||
private static void copyFile(File source, File dest) throws IOException {
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
is = new FileInputStream(source);
|
||||
os = new FileOutputStream(dest);
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = is.read(buffer)) > 0) {
|
||||
os.write(buffer, 0, length);
|
||||
}
|
||||
} finally {
|
||||
is.close();
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ import java.util.UUID;
|
|||
|
||||
public class Ticket {
|
||||
|
||||
private int ticketId;
|
||||
private int id;
|
||||
|
||||
private TicketStatus status = TicketStatus.OPEN;
|
||||
private Location location = null;
|
||||
|
@ -32,26 +32,21 @@ public class Ticket {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public Ticket(OfflinePlayer victim, String subject, String type, TicketResponse response) {
|
||||
this.victim = victim.getUniqueId();
|
||||
this.subject = subject;
|
||||
this.type = type;
|
||||
this.tickets.add(response);
|
||||
}
|
||||
|
||||
public Ticket(UUID victim, String subject, String type, TicketResponse response) {
|
||||
public Ticket(int id, UUID victim, String subject, String type, TicketStatus status, Location location) {
|
||||
this.id = id;
|
||||
this.victim = victim;
|
||||
this.subject = subject;
|
||||
this.type = type;
|
||||
this.tickets.add(response);
|
||||
this.status = status;
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
public int getTicketId() {
|
||||
return ticketId;
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setTicketId(int ticketId) {
|
||||
this.ticketId = ticketId;
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public List<TicketResponse> getResponses() {
|
||||
|
@ -59,7 +54,7 @@ public class Ticket {
|
|||
}
|
||||
|
||||
public TicketResponse addResponse(TicketResponse response) {
|
||||
response.setTicketId(ticketId);
|
||||
response.setTicketId(id);
|
||||
tickets.add(response);
|
||||
return response;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package com.songoda.ultimatemoderation.tickets;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TicketManager {
|
||||
|
@ -11,8 +13,8 @@ public class TicketManager {
|
|||
private final TreeMap<Integer, Ticket> registeredTickets = new TreeMap<>();
|
||||
|
||||
public Ticket addTicket(Ticket ticket) {
|
||||
int id = registeredTickets.isEmpty() ? 1 : registeredTickets.lastEntry().getValue().getTicketId() + 1;
|
||||
ticket.setTicketId(id);
|
||||
int id = registeredTickets.isEmpty() ? 1 : registeredTickets.lastEntry().getValue().getId() + 1;
|
||||
ticket.setId(id);
|
||||
return addTicket(ticket, id);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.utils;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AbstractChatConfirm implements Listener {
|
||||
|
||||
private static final List<UUID> registered = new ArrayList<>();
|
||||
|
||||
private final Player player;
|
||||
private final ChatConfirmHandler handler;
|
||||
|
||||
private OnClose onClose = null;
|
||||
|
||||
public AbstractChatConfirm(Player player, ChatConfirmHandler hander) {
|
||||
this.player = player;
|
||||
this.handler = hander;
|
||||
player.closeInventory();
|
||||
initializeListeners(UltimateModeration.getInstance());
|
||||
registered.add(player.getUniqueId());
|
||||
}
|
||||
|
||||
private Listener listener;
|
||||
|
||||
public void initializeListeners(JavaPlugin plugin) {
|
||||
|
||||
this.listener = new Listener() {
|
||||
@EventHandler
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!AbstractChatConfirm.isRegistered(player)) return;
|
||||
|
||||
AbstractChatConfirm.unregister(player);
|
||||
event.setCancelled(true);
|
||||
|
||||
ChatConfirmEvent chatConfirmEvent = new ChatConfirmEvent(player, event.getMessage());
|
||||
|
||||
handler.onChat(chatConfirmEvent);
|
||||
|
||||
if (onClose != null) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(UltimateModeration.getInstance(), () ->
|
||||
onClose.onClose(), 0L);
|
||||
}
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(listener, UltimateModeration.getInstance());
|
||||
}
|
||||
|
||||
public static boolean isRegistered(Player player) {
|
||||
return registered.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static boolean unregister(Player player) {
|
||||
return registered.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public interface ChatConfirmHandler {
|
||||
void onChat(ChatConfirmEvent event);
|
||||
}
|
||||
|
||||
public void setOnClose(OnClose onClose) {
|
||||
this.onClose = onClose;
|
||||
}
|
||||
|
||||
public interface OnClose {
|
||||
void onClose();
|
||||
}
|
||||
|
||||
public class ChatConfirmEvent {
|
||||
|
||||
private final Player player;
|
||||
private final String message;
|
||||
|
||||
public ChatConfirmEvent(Player player, String message) {
|
||||
this.player = player;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -2,7 +2,11 @@ package com.songoda.ultimatemoderation.utils;
|
|||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package com.songoda.ultimatemoderation.utils;
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class VaultPermissions {
|
||||
|
||||
// Vault
|
||||
private static Permission vaultPermission = null;
|
||||
|
||||
static {
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) {
|
||||
RegisteredServiceProvider<Permission> permissionRsp = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
||||
if (permissionRsp != null) vaultPermission = permissionRsp.getProvider();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasPermission(OfflinePlayer offlinePlayer, String perm) {
|
||||
if (vaultPermission != null)
|
||||
return vaultPermission.playerHas(Bukkit.getWorlds().get(0).getName(), offlinePlayer, perm);
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,289 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.utils.gui;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.version.NMSUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AbstractAnvilGUI {
|
||||
private static Class<?> BlockPositionClass;
|
||||
private static Class<?> PacketPlayOutOpenWindowClass;
|
||||
private static Class<?> IChatBaseComponentClass;
|
||||
private static Class<?> ICraftingClass;
|
||||
private static Class<?> ContainerAnvilClass;
|
||||
private static Class<?> ChatMessageClass;
|
||||
private static Class<?> EntityHumanClass;
|
||||
private static Class<?> ContainerClass;
|
||||
private static Class<?> ContainerAccessClass;
|
||||
private static Class<?> WorldClass;
|
||||
private static Class<?> PlayerInventoryClass;
|
||||
private static Class<?> ContainersClass;
|
||||
private static Class<?> CraftPlayerClass;
|
||||
|
||||
private Player player;
|
||||
private Map<AnvilSlot, ItemStack> items = new HashMap<>();
|
||||
private OnClose onClose = null;
|
||||
private Inventory inv;
|
||||
private Listener listener;
|
||||
|
||||
static {
|
||||
BlockPositionClass = NMSUtil.getNMSClass("BlockPosition");
|
||||
PacketPlayOutOpenWindowClass = NMSUtil.getNMSClass("PacketPlayOutOpenWindow");
|
||||
IChatBaseComponentClass = NMSUtil.getNMSClass("IChatBaseComponent");
|
||||
ICraftingClass = NMSUtil.getNMSClass("ICrafting");
|
||||
ContainerAnvilClass = NMSUtil.getNMSClass("ContainerAnvil");
|
||||
EntityHumanClass = NMSUtil.getNMSClass("EntityHuman");
|
||||
ChatMessageClass = NMSUtil.getNMSClass("ChatMessage");
|
||||
ContainerClass = NMSUtil.getNMSClass("Container");
|
||||
WorldClass = NMSUtil.getNMSClass("World");
|
||||
PlayerInventoryClass = NMSUtil.getNMSClass("PlayerInventory");
|
||||
CraftPlayerClass = NMSUtil.getCraftClass("entity.CraftPlayer");
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
ContainerAccessClass = NMSUtil.getNMSClass("ContainerAccess");
|
||||
ContainersClass = NMSUtil.getNMSClass("Containers");
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractAnvilGUI(Player player, AnvilClickEventHandler handler) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
this.player = player;
|
||||
|
||||
this.listener = new Listener() {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getWhoClicked() instanceof Player && event.getInventory().equals(AbstractAnvilGUI.this.inv)) {
|
||||
event.setCancelled(true);
|
||||
|
||||
ItemStack item = event.getCurrentItem();
|
||||
int slot = event.getRawSlot();
|
||||
|
||||
if (item == null || item.getType().equals(Material.AIR) || slot != 2)
|
||||
return;
|
||||
|
||||
String name = "";
|
||||
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null && meta.hasDisplayName())
|
||||
name = meta.getDisplayName();
|
||||
|
||||
AnvilClickEvent clickEvent = new AnvilClickEvent(AnvilSlot.bySlot(slot), name);
|
||||
handler.onAnvilClick(clickEvent);
|
||||
|
||||
if (clickEvent.getWillClose())
|
||||
event.getWhoClicked().closeInventory();
|
||||
|
||||
if (clickEvent.getWillDestroy())
|
||||
AbstractAnvilGUI.this.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
if (event.getPlayer() instanceof Player && AbstractAnvilGUI.this.inv.equals(event.getInventory())) {
|
||||
Inventory inv = event.getInventory();
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
inv.clear();
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
if (AbstractAnvilGUI.this.onClose != null)
|
||||
AbstractAnvilGUI.this.onClose.onClose(player, inv);
|
||||
AbstractAnvilGUI.this.destroy();
|
||||
}, 1L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (event.getPlayer().equals(AbstractAnvilGUI.this.player)) {
|
||||
player.setLevel(player.getLevel() - 1);
|
||||
AbstractAnvilGUI.this.destroy();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(this.listener, instance);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public void setSlot(AnvilSlot slot, ItemStack item) {
|
||||
this.items.put(slot, item);
|
||||
}
|
||||
|
||||
public void open() {
|
||||
this.player.setLevel(this.player.getLevel() + 1);
|
||||
|
||||
try {
|
||||
Object craftPlayer = CraftPlayerClass.cast(this.player);
|
||||
Method getHandleMethod = CraftPlayerClass.getMethod("getHandle");
|
||||
Object entityPlayer = getHandleMethod.invoke(craftPlayer);
|
||||
Object playerInventory = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "inventory", false));
|
||||
Object world = NMSUtil.getFieldObject(entityPlayer, NMSUtil.getField(entityPlayer.getClass(), "world", false));
|
||||
Object blockPosition = BlockPositionClass.getConstructor(int.class, int.class, int.class).newInstance(0, 0, 0);
|
||||
|
||||
Object container;
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
container = ContainerAnvilClass
|
||||
.getConstructor(int.class, PlayerInventoryClass, ContainerAccessClass)
|
||||
.newInstance(7, playerInventory, ContainerAccessClass.getMethod("at", WorldClass, BlockPositionClass).invoke(null, world, blockPosition));
|
||||
} else {
|
||||
container = ContainerAnvilClass
|
||||
.getConstructor(PlayerInventoryClass, WorldClass, BlockPositionClass, EntityHumanClass)
|
||||
.newInstance(playerInventory, world, blockPosition, entityPlayer);
|
||||
}
|
||||
|
||||
NMSUtil.getField(ContainerClass, "checkReachable", true).set(container, false);
|
||||
|
||||
Method getBukkitViewMethod = container.getClass().getMethod("getBukkitView");
|
||||
Object bukkitView = getBukkitViewMethod.invoke(container);
|
||||
Method getTopInventoryMethod = bukkitView.getClass().getMethod("getTopInventory");
|
||||
this.inv = (Inventory) getTopInventoryMethod.invoke(bukkitView);
|
||||
|
||||
for (AnvilSlot slot : this.items.keySet()) {
|
||||
this.inv.setItem(slot.getSlot(), this.items.get(slot));
|
||||
}
|
||||
|
||||
Method nextContainerCounterMethod = entityPlayer.getClass().getMethod("nextContainerCounter");
|
||||
int c = (int) nextContainerCounterMethod.invoke(entityPlayer);
|
||||
|
||||
Constructor<?> chatMessageConstructor = ChatMessageClass.getConstructor(String.class, Object[].class);
|
||||
Object inventoryTitle = chatMessageConstructor.newInstance("Repairing", new Object[]{});
|
||||
|
||||
Object packet;
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
packet = PacketPlayOutOpenWindowClass
|
||||
.getConstructor(int.class, ContainersClass, IChatBaseComponentClass)
|
||||
.newInstance(c, ContainersClass.getField("ANVIL").get(null), inventoryTitle);
|
||||
} else {
|
||||
packet = PacketPlayOutOpenWindowClass
|
||||
.getConstructor(int.class, String.class, IChatBaseComponentClass, int.class)
|
||||
.newInstance(c, "minecraft:anvil", inventoryTitle, 0);
|
||||
}
|
||||
|
||||
NMSUtil.sendPacket(this.player, packet);
|
||||
|
||||
Field activeContainerField = NMSUtil.getField(EntityHumanClass, "activeContainer", true);
|
||||
|
||||
if (activeContainerField != null) {
|
||||
activeContainerField.set(entityPlayer, container);
|
||||
NMSUtil.getField(ContainerClass, "windowId", true).set(activeContainerField.get(entityPlayer), c);
|
||||
Method addSlotListenerMethod = activeContainerField.get(entityPlayer).getClass().getMethod("addSlotListener", ICraftingClass);
|
||||
addSlotListenerMethod.invoke(activeContainerField.get(entityPlayer), entityPlayer);
|
||||
|
||||
if (NMSUtil.getVersionNumber() > 13) {
|
||||
ContainerClass.getMethod("setTitle", IChatBaseComponentClass).invoke(container, inventoryTitle);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
this.player = null;
|
||||
this.items = null;
|
||||
|
||||
HandlerList.unregisterAll(this.listener);
|
||||
|
||||
this.listener = null;
|
||||
}
|
||||
|
||||
private OnClose getOnClose() {
|
||||
return this.onClose;
|
||||
}
|
||||
|
||||
public void setOnClose(OnClose onClose) {
|
||||
this.onClose = onClose;
|
||||
}
|
||||
|
||||
public enum AnvilSlot {
|
||||
INPUT_LEFT(0),
|
||||
INPUT_RIGHT(1),
|
||||
OUTPUT(2);
|
||||
|
||||
private int slot;
|
||||
|
||||
AnvilSlot(int slot) {
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public static AnvilSlot bySlot(int slot) {
|
||||
for (AnvilSlot anvilSlot : values()) {
|
||||
if (anvilSlot.getSlot() == slot) {
|
||||
return anvilSlot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public int getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface AnvilClickEventHandler {
|
||||
void onAnvilClick(AnvilClickEvent event);
|
||||
}
|
||||
|
||||
public class AnvilClickEvent {
|
||||
private AnvilSlot slot;
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean close = true;
|
||||
private boolean destroy = true;
|
||||
|
||||
public AnvilClickEvent(AnvilSlot slot, String name) {
|
||||
this.slot = slot;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public AnvilSlot getSlot() {
|
||||
return this.slot;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean getWillClose() {
|
||||
return this.close;
|
||||
}
|
||||
|
||||
public void setWillClose(boolean close) {
|
||||
this.close = close;
|
||||
}
|
||||
|
||||
public boolean getWillDestroy() {
|
||||
return this.destroy;
|
||||
}
|
||||
|
||||
public void setWillDestroy(boolean destroy) {
|
||||
this.destroy = destroy;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,245 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.utils.gui;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class AbstractGUI implements Listener {
|
||||
|
||||
private static boolean listenersInitialized = false;
|
||||
protected final Player player;
|
||||
protected Inventory inventory = null;
|
||||
protected String setTitle = null;
|
||||
protected boolean cancelBottom = false;
|
||||
private Map<Range, Clickable> clickables = new HashMap<>();
|
||||
private List<OnClose> onCloses = new ArrayList<>();
|
||||
private Map<Range, Boolean> draggableRanges = new HashMap<>();
|
||||
|
||||
public AbstractGUI(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public static void initializeListeners(JavaPlugin plugin) {
|
||||
if (listenersInitialized) return;
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new Listener() {
|
||||
@EventHandler
|
||||
public void onClickGUI(InventoryClickEvent event) {
|
||||
Inventory inventory = event.getClickedInventory();
|
||||
if (inventory == null) return;
|
||||
AbstractGUI gui = getGUIFromInventory(inventory);
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
|
||||
boolean bottom = false;
|
||||
|
||||
InventoryType type = event.getClickedInventory().getType();
|
||||
if (type != InventoryType.CHEST && type != InventoryType.PLAYER) return;
|
||||
|
||||
if (gui == null && event.getWhoClicked().getOpenInventory().getTopInventory() != null) {
|
||||
Inventory top = event.getWhoClicked().getOpenInventory().getTopInventory();
|
||||
gui = getGUIFromInventory(top);
|
||||
|
||||
if (gui != null && gui.cancelBottom) event.setCancelled(true);
|
||||
bottom = true;
|
||||
}
|
||||
|
||||
if (gui == null) return;
|
||||
|
||||
if (!bottom) event.setCancelled(true);
|
||||
|
||||
if (!gui.draggableRanges.isEmpty() && !bottom) {
|
||||
for (Map.Entry<Range, Boolean> entry : gui.draggableRanges.entrySet()) {
|
||||
Range range = entry.getKey();
|
||||
if (range.getMax() == range.getMin() && event.getSlot() == range.getMin()
|
||||
|| event.getSlot() >= range.getMin() && event.getSlot() <= range.getMax()) {
|
||||
event.setCancelled(!entry.getValue());
|
||||
if (!entry.getValue()) break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Map<Range, Clickable> entries = new HashMap<>(gui.clickables);
|
||||
|
||||
for (Map.Entry<Range, Clickable> entry : entries.entrySet()) {
|
||||
Range range = entry.getKey();
|
||||
if (range.isBottom() && !bottom || !range.isBottom() && bottom || range.getClickType() != null && range.getClickType() != event.getClick())
|
||||
continue;
|
||||
if (event.getSlot() >= range.getMin() && event.getSlot() <= range.getMax()) {
|
||||
entry.getValue().Clickable(player, inventory, event.getCursor(), event.getSlot(), event.getClick());
|
||||
player.playSound(player.getLocation(), entry.getKey().getOnClickSound(), 1F, 1F);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCloseGUI(InventoryCloseEvent event) {
|
||||
Inventory inventory = event.getInventory();
|
||||
AbstractGUI gui = getGUIFromInventory(inventory);
|
||||
|
||||
if (gui == null || gui.inventory == null) return;
|
||||
|
||||
for (OnClose onClose : gui.onCloses) {
|
||||
onClose.onClose((Player) event.getPlayer(), inventory);
|
||||
}
|
||||
gui.destory();
|
||||
}
|
||||
|
||||
private AbstractGUI getGUIFromInventory(Inventory inventory) {
|
||||
if (inventory.getHolder() == null) return null;
|
||||
InventoryHolder holder = inventory.getHolder();
|
||||
if (!(holder instanceof GUIHolder)) return null;
|
||||
|
||||
return ((AbstractGUI.GUIHolder) holder).getGUI();
|
||||
}
|
||||
}, plugin);
|
||||
listenersInitialized = true;
|
||||
}
|
||||
|
||||
public void init(String title, int slots) {
|
||||
if (inventory == null
|
||||
|| inventory.getSize() != slots
|
||||
|| Methods.formatTitle(title) != player.getOpenInventory().getTitle()) {
|
||||
this.inventory = Bukkit.getServer().createInventory(new GUIHolder(), slots, Methods.formatTitle(title));
|
||||
this.setTitle = Methods.formatTitle(title);
|
||||
if (this.clickables.size() == 0)
|
||||
registerClickables();
|
||||
if (this.onCloses.size() == 0)
|
||||
registerOnCloses();
|
||||
}
|
||||
constructGUI();
|
||||
initializeListeners(UltimateModeration.getInstance());
|
||||
player.openInventory(inventory);
|
||||
}
|
||||
|
||||
private void destory() {
|
||||
onCloses.clear();
|
||||
clickables.clear();
|
||||
draggableRanges.clear();
|
||||
}
|
||||
|
||||
protected abstract void constructGUI();
|
||||
|
||||
protected void addDraggable(Range range, boolean option) {
|
||||
this.draggableRanges.put(range, option);
|
||||
}
|
||||
|
||||
protected void removeDraggable() {
|
||||
this.draggableRanges.clear();
|
||||
}
|
||||
|
||||
protected abstract void registerClickables();
|
||||
|
||||
protected abstract void registerOnCloses();
|
||||
|
||||
protected ItemStack createButton(int slot, Inventory inventory, ItemStack item, String name, String... lore) {
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
if (lore != null && lore.length != 0) {
|
||||
List<String> newLore = new ArrayList<>();
|
||||
for (String line : lore) newLore.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
meta.setLore(newLore);
|
||||
}
|
||||
item.setItemMeta(meta);
|
||||
inventory.setItem(slot, item);
|
||||
return item;
|
||||
}
|
||||
|
||||
protected ItemStack createButton(int slot, ItemStack item, String name, ArrayList<String> lore) {
|
||||
return createButton(slot, inventory, item, name, lore.toArray(new String[0]));
|
||||
}
|
||||
|
||||
|
||||
protected ItemStack createButton(int slot, ItemStack item, String name, String... lore) {
|
||||
return createButton(slot, inventory, item, name, lore);
|
||||
}
|
||||
|
||||
protected ItemStack createButton(int slot, Object item, String name, String... lore) {
|
||||
if (item instanceof ItemStack)
|
||||
return createButton(slot, inventory, (ItemStack)item, name, lore);
|
||||
else
|
||||
return createButton(slot, inventory, (Material)item, name, lore);
|
||||
}
|
||||
|
||||
protected ItemStack createButton(int slot, Inventory inventory, Material material, String name, String... lore) {
|
||||
return createButton(slot, inventory, new ItemStack(material), name, lore);
|
||||
}
|
||||
|
||||
protected ItemStack createButton(int slot, Material material, String name, String... lore) {
|
||||
return createButton(slot, inventory, new ItemStack(material), name, lore);
|
||||
}
|
||||
|
||||
protected ItemStack createButton(int slot, Material material, String name, ArrayList<String> lore) {
|
||||
return createButton(slot, material, name, lore.toArray(new String[0]));
|
||||
}
|
||||
|
||||
protected void registerClickable(int min, int max, ClickType clickType, boolean bottom, Clickable clickable) {
|
||||
clickables.put(new Range(min, max, clickType, bottom), clickable);
|
||||
}
|
||||
|
||||
protected void registerClickable(int min, int max, ClickType clickType, Clickable clickable) {
|
||||
registerClickable(min, max, clickType, false, clickable);
|
||||
}
|
||||
|
||||
protected void registerClickable(int slot, ClickType clickType, Clickable clickable) {
|
||||
registerClickable(slot, slot, clickType, false, clickable);
|
||||
}
|
||||
|
||||
protected void registerClickable(int min, int max, Clickable clickable) {
|
||||
registerClickable(min, max, null, false, clickable);
|
||||
}
|
||||
|
||||
protected void registerClickable(int slot, boolean bottom, Clickable clickable) {
|
||||
registerClickable(slot, slot, null, bottom, clickable);
|
||||
}
|
||||
|
||||
protected void registerClickable(int slot, Clickable clickable) {
|
||||
registerClickable(slot, slot, null, false, clickable);
|
||||
}
|
||||
|
||||
protected void resetClickables() {
|
||||
clickables.clear();
|
||||
}
|
||||
|
||||
protected void registerOnClose(OnClose onClose) {
|
||||
onCloses.add(onClose);
|
||||
}
|
||||
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public class GUIHolder implements InventoryHolder {
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public AbstractGUI getGUI() {
|
||||
return AbstractGUI.this;
|
||||
}
|
||||
}
|
||||
|
||||
public String getSetTitle() {
|
||||
return setTitle;
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.utils.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public interface Clickable {
|
||||
|
||||
void Clickable(Player player, Inventory inventory, ItemStack cursor, int slot, ClickType type);
|
||||
}
|
|
@ -1,10 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.utils.gui;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public interface OnClose {
|
||||
|
||||
void onClose(Player player, Inventory inventory);
|
||||
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.utils.gui;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
public class Range {
|
||||
|
||||
private int min;
|
||||
private int max;
|
||||
private ClickType clickType;
|
||||
private boolean bottom;
|
||||
private Sound onClickSound;
|
||||
|
||||
public Range(int min, int max, ClickType clickType, boolean bottom) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.clickType = clickType;
|
||||
this.bottom = bottom;
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) onClickSound = Sound.UI_BUTTON_CLICK;
|
||||
}
|
||||
|
||||
public Range(int min, int max, Sound onClickSound, ClickType clickType, boolean bottom) {
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.onClickSound = onClickSound;
|
||||
this.clickType = clickType;
|
||||
this.bottom = bottom;
|
||||
}
|
||||
|
||||
public int getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public ClickType getClickType() {
|
||||
return clickType;
|
||||
}
|
||||
|
||||
public boolean isBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
public Sound getOnClickSound() {
|
||||
return onClickSound;
|
||||
}
|
||||
}
|
|
@ -1,100 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.utils.version;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class NMSUtil {
|
||||
|
||||
public static String getVersion() {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
|
||||
public static int getVersionNumber() {
|
||||
String name = getVersion().substring(3);
|
||||
return Integer.valueOf(name.substring(0, name.length() - 4));
|
||||
}
|
||||
|
||||
public static int getVersionReleaseNumber() {
|
||||
String NMSVersion = getVersion();
|
||||
return Integer.valueOf(NMSVersion.substring(NMSVersion.length() - 2).replace(".", ""));
|
||||
}
|
||||
|
||||
public static Class<?> getNMSClass(String className) {
|
||||
try {
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
Class<?> clazz = Class.forName(fullName);
|
||||
return clazz;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getCraftClass(String className) {
|
||||
try {
|
||||
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
||||
Class<?> clazz = Class.forName(fullName);
|
||||
return clazz;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Field getField(Class<?> clazz, String name, boolean declared) {
|
||||
try {
|
||||
Field field;
|
||||
|
||||
if (declared) {
|
||||
field = clazz.getDeclaredField(name);
|
||||
} else {
|
||||
field = clazz.getField(name);
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getFieldObject(Object object, Field field) {
|
||||
try {
|
||||
return field.get(object);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setField(Object object, String fieldName, Object fieldValue, boolean declared) {
|
||||
try {
|
||||
Field field;
|
||||
|
||||
if (declared) {
|
||||
field = object.getClass().getDeclaredField(fieldName);
|
||||
} else {
|
||||
field = object.getClass().getField(fieldName);
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
field.set(object, fieldValue);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPacket(Player player, Object packet) {
|
||||
try {
|
||||
Object handle = player.getClass().getMethod("getHandle").invoke(player);
|
||||
Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
|
||||
playerConnection.getClass().getMethod("sendPacket", getNMSClass("Packet")).invoke(playerConnection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -51,7 +51,7 @@ event:
|
|||
yourduration: '&7. &7Your punishment will be lifted in &6%duration%'
|
||||
ban:
|
||||
success: '&7You have banned &6%player%'
|
||||
message: '&7You have been banned'
|
||||
message: '&7You have been banned for &6%reason%&7. Your ban will expire after &6%duration%&7.'
|
||||
already: '&cThis user is already banned.'
|
||||
unban:
|
||||
success: '&7You have unbanned &6%player%'
|
||||
|
@ -63,12 +63,15 @@ event:
|
|||
success: '&7You have unmuted &6%player%'
|
||||
kick:
|
||||
success: '&7You have kicked &6%player%'
|
||||
message: '&7You have been kicked'
|
||||
message: '&7You have been kicked for &6%reason%&7.'
|
||||
warning:
|
||||
success: '&7You have warned &6%player%'
|
||||
message: '&7You have been warned'
|
||||
staffchat:
|
||||
leave: '&7You left &6%channel% &7successfully.'
|
||||
join: '&7You joined &6%channel% &7successfully.'
|
||||
allleave: '&6%player% &7has left the channel.'
|
||||
alljoin: '&6%player% has joined the channel.'
|
||||
nochannels: '&cYou are not in any channels.'
|
||||
format: '&%color%[%channel%] %player%&%color%: %message%'
|
||||
slowmode:
|
||||
|
@ -191,7 +194,7 @@ gui:
|
|||
what: '&6What would you like to say in your first ticket post?'
|
||||
subject: Ticket Subject
|
||||
ticket:
|
||||
title: '&8Tickets > %id%'
|
||||
title: '&8Tickets > %subject% %id%'
|
||||
type: '&7Type &6%type%&7.'
|
||||
picktype: '&8Pick a ticket type.'
|
||||
clicktotele: '&6Teleport to ticket location.'
|
||||
|
|
|
@ -31,11 +31,14 @@ commands:
|
|||
default: false
|
||||
aliases: [v]
|
||||
usage: /v
|
||||
ViewEnderChest:
|
||||
description: ViewEnderChest
|
||||
Spy:
|
||||
description: Spy
|
||||
default: false
|
||||
aliases: [vec]
|
||||
usage: /vec
|
||||
usage: /spy
|
||||
Revive:
|
||||
description: Revive
|
||||
default: false
|
||||
usage: /revive
|
||||
InvSee:
|
||||
description: InvSee
|
||||
default: false
|
||||
|
@ -44,18 +47,10 @@ commands:
|
|||
description: Freeze
|
||||
default: false
|
||||
usage: /freeze
|
||||
Revive:
|
||||
description: Revive
|
||||
ViewEnderChest:
|
||||
description: ViewEnderChest
|
||||
default: false
|
||||
usage: /revive
|
||||
Spy:
|
||||
description: Spy
|
||||
default: false
|
||||
usage: /spy
|
||||
CommandSpy:
|
||||
description: CommandSpy
|
||||
default: false
|
||||
usage: /commandspy
|
||||
usage: /ViewEnderChest
|
||||
Ban:
|
||||
description: Ban
|
||||
default: false
|
||||
|
|
Loading…
Reference in New Issue