Compare commits
128 Commits
Author | SHA1 | Date |
---|---|---|
|
89db325408 | |
|
4c2e95b76d | |
|
dc76f7e8e6 | |
|
9c011f1ccb | |
|
e68404aebd | |
|
cee3279061 | |
|
fed6c8f56f | |
|
e76289b1c5 | |
|
5cad6c0e0a | |
|
bb99fae5c9 | |
|
aa8fdb19ec | |
|
1d9e532f2f | |
|
32ddee809c | |
|
cb8c50e70f | |
|
1845b1fce7 | |
|
cd578df85f | |
|
546d3e58b8 | |
|
6a52d7e188 | |
|
2b0f1b4b23 | |
|
4ed9b5e1c5 | |
|
58f76c3342 | |
|
5a8ff8dd33 | |
|
28cdb97301 | |
|
43f94540aa | |
|
3575c508f8 | |
|
fc46312f1c | |
|
dd29b7b49b | |
|
f8cde33d59 | |
|
008eb27b3a | |
|
7965ac5865 | |
|
5db67e1b1e | |
|
7982d7e2f6 | |
|
d0c8e50c8e | |
|
e0f42f6665 | |
|
714ab2a14b | |
|
d3c5e09072 | |
|
74bcd22974 | |
|
687ba7bb1b | |
|
fb06833b27 | |
|
ae418a7a73 | |
|
fba65a23be | |
|
be8d660cb0 | |
|
ab4ba023dd | |
|
8f74226a87 | |
|
851e4afb1a | |
|
aee6494a25 | |
|
18899d2166 | |
|
070bb51eaa | |
|
a4e095c330 | |
|
3985df94c8 | |
|
8edc70f13f | |
|
f9c9ff8f07 | |
|
71b327d047 | |
|
a2d1e5a84f | |
|
20b8a7c65a | |
|
ac0844d34b | |
|
83e7256ada | |
|
4c44f73593 | |
|
427f428d1d | |
|
e86c6a342f | |
|
efd0019539 | |
|
a040bf26a9 | |
|
9bb8033ba8 | |
|
2c9255bced | |
|
c192449f55 | |
|
77571cdcf9 | |
|
3bf21b27f9 | |
|
1d984cef36 | |
|
4bbd7aaa79 | |
|
2a581fdb20 | |
|
5047e79ccf | |
|
aee2620109 | |
|
b1cd9d459d | |
|
153a213a0c | |
|
eff2de6360 | |
|
ae4c0da070 | |
|
0346950407 | |
|
8db3c9070c | |
|
ff36503381 | |
|
d43cbe2b46 | |
|
76a0c296a1 | |
|
0f64daeb5b | |
|
1f580ba083 | |
|
4e3665a661 | |
|
645afe9d60 | |
|
47b3fd58a3 | |
|
166d1c3a2c | |
|
b00dc9ec69 | |
|
ade1ebdede | |
|
e8e633164f | |
|
d7109d1258 | |
|
5c183748f7 | |
|
2f32e940e2 | |
|
d1533cd096 | |
|
4fcf8577c9 | |
|
51ca041eed | |
|
3fe08e370c | |
|
c523a76b8f | |
|
6f6f44b021 | |
|
d896464217 | |
|
ce91cf8372 | |
|
47554df3a7 | |
|
ba1244fbac | |
|
6a04685914 | |
|
5b2b1746d4 | |
|
a2d64d3bf5 | |
|
b4e748b732 | |
|
19f4270658 | |
|
40825c613e | |
|
ca40e0601e | |
|
838d1640ae | |
|
63caaef3db | |
|
855926936c | |
|
b54280abf0 | |
|
f30fedeb90 | |
|
83ec20e5ea | |
|
15bb7fc2e8 | |
|
deea035be4 | |
|
42d6ac9406 | |
|
c9fb8d7c8c | |
|
cbe3736ed4 | |
|
60501c5c3f | |
|
d7a4661b59 | |
|
7e0bcc2e9d | |
|
0ff769ca4b | |
|
e257f2a045 | |
|
d902a71857 | |
|
6f0c8a8ee2 |
|
@ -28,4 +28,7 @@ hs_err_pid*
|
|||
/build/
|
||||
/bin/
|
||||
/target/
|
||||
*.iml
|
||||
*.iml
|
||||
src/\.DS_Store
|
||||
|
||||
\.DS_Store
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
stages:
|
||||
- build
|
||||
|
||||
variables:
|
||||
name: "UltimateModeration"
|
||||
path: "/builds/$CI_PROJECT_PATH"
|
||||
version: "1.1.7"
|
||||
|
||||
build:
|
||||
stage: build
|
||||
image: maven:3.5.3-jdk-8
|
||||
script:
|
||||
- find $path/ -type f -name "*.xml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
|
||||
- find $path/ -type f -name "*.yml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
|
||||
- mvn clean package
|
||||
- find $path/ -depth -path '*original*' -delete
|
||||
- mv $path/target/*.jar $path/
|
||||
artifacts:
|
||||
name: $name-$version
|
||||
paths:
|
||||
- "$path/*.jar"
|
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 |
88
pom.xml
88
pom.xml
|
@ -2,24 +2,53 @@
|
|||
<groupId>com.songoda</groupId>
|
||||
<artifactId>UltimateModeration</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>maven-version-number</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>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
|
||||
<configuration>
|
||||
<file>${project.build.directory}/classes/plugin.yml</file>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}</value>
|
||||
</replacement>
|
||||
</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>
|
||||
|
@ -27,14 +56,17 @@
|
|||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
|
||||
<configuration>
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:songodaupdater</include>
|
||||
<include>com.songoda:SongodaCore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
|
@ -45,28 +77,64 @@
|
|||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.songoda.core</pattern>
|
||||
<shadedPattern>${project.groupId}.ultimatemoderation.core</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</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.14</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>songodaupdater</artifactId>
|
||||
<version>1</version>
|
||||
<artifactId>abledskyblock</artifactId>
|
||||
<version>79.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -1,375 +0,0 @@
|
|||
package com.songoda.ultimatemoderation;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Assists in the creation of multiple localizations and languages,
|
||||
* as well as the generation of default .lang files
|
||||
*
|
||||
* @author Parker Hawke - 2008Choco
|
||||
*/
|
||||
public class Locale {
|
||||
|
||||
private static final List<Locale> LOCALES = Lists.newArrayList();
|
||||
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.{1}\\w+)*)\\s*=\\s*\"(.*)\"");
|
||||
private static final String FILE_EXTENSION = ".lang";
|
||||
private static JavaPlugin plugin;
|
||||
private static File localeFolder;
|
||||
|
||||
private static String defaultLocale;
|
||||
|
||||
private final Map<String, String> nodes = new HashMap<>();
|
||||
|
||||
private final File file;
|
||||
private final String name, region;
|
||||
|
||||
private Locale(String name, String region) {
|
||||
if (plugin == null)
|
||||
throw new IllegalStateException("Cannot generate locales without first initializing the class (Locale#init(JavaPlugin))");
|
||||
|
||||
this.name = name.toLowerCase();
|
||||
this.region = region.toUpperCase();
|
||||
|
||||
String fileName = name + "_" + region + FILE_EXTENSION;
|
||||
this.file = new File(localeFolder, fileName);
|
||||
|
||||
if (this.reloadMessages()) return;
|
||||
|
||||
plugin.getLogger().info("Loaded locale " + fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the locale class to generate information and search for localizations.
|
||||
* This must be called before any other methods in the Locale class can be invoked.
|
||||
* Note that this will also call {@link #searchForLocales()}, so there is no need to
|
||||
* invoke it for yourself after the initialization
|
||||
*
|
||||
* @param plugin the plugin instance
|
||||
*/
|
||||
public static void init(JavaPlugin plugin) {
|
||||
Locale.plugin = plugin;
|
||||
|
||||
if (localeFolder == null) {
|
||||
localeFolder = new File(plugin.getDataFolder(), "locales/");
|
||||
}
|
||||
|
||||
localeFolder.mkdirs();
|
||||
Locale.searchForLocales();
|
||||
}
|
||||
|
||||
/**
|
||||
* Find all .lang file locales under the "locales" folder
|
||||
*/
|
||||
public static void searchForLocales() {
|
||||
if (!localeFolder.exists()) localeFolder.mkdirs();
|
||||
|
||||
for (File file : localeFolder.listFiles()) {
|
||||
String name = file.getName();
|
||||
if (!name.endsWith(".lang")) continue;
|
||||
|
||||
String fileName = name.substring(0, name.lastIndexOf('.'));
|
||||
String[] localeValues = fileName.split("_");
|
||||
|
||||
if (localeValues.length != 2) continue;
|
||||
if (localeExists(localeValues[0] + "_" + localeValues[1])) continue;
|
||||
|
||||
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
||||
plugin.getLogger().info("Found and loaded locale \"" + fileName + "\"");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale by its entire proper name (i.e. "en_US")
|
||||
*
|
||||
* @param name the full name of the locale
|
||||
* @return locale of the specified name
|
||||
*/
|
||||
public static Locale getLocale(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getLanguageTag().equalsIgnoreCase(name)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale from the cache by its name (i.e. "en" from "en_US")
|
||||
*
|
||||
* @param name the name of the language
|
||||
* @return locale of the specified language. Null if not cached
|
||||
*/
|
||||
public static Locale getLocaleByName(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getName().equalsIgnoreCase(name)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a locale from the cache by its region (i.e. "US" from "en_US")
|
||||
*
|
||||
* @param region the name of the region
|
||||
* @return locale of the specified region. Null if not cached
|
||||
*/
|
||||
public static Locale getLocaleByRegion(String region) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getRegion().equalsIgnoreCase(region)) return locale;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a locale exists and is registered or not
|
||||
*
|
||||
* @param name the whole language tag (i.e. "en_US")
|
||||
* @return true if it exists
|
||||
*/
|
||||
public static boolean localeExists(String name) {
|
||||
for (Locale locale : LOCALES)
|
||||
if (locale.getLanguageTag().equals(name)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an immutable list of all currently loaded locales
|
||||
*
|
||||
* @return list of all locales
|
||||
*/
|
||||
public static List<Locale> getLocales() {
|
||||
return ImmutableList.copyOf(LOCALES);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a default locale file from the project source directory, to the locale folder
|
||||
*
|
||||
* @param in file to save
|
||||
* @param fileName the name of the file to save
|
||||
* @return true if the operation was successful, false otherwise
|
||||
*/
|
||||
public static boolean saveDefaultLocale(InputStream in, String fileName) {
|
||||
if (!localeFolder.exists()) localeFolder.mkdirs();
|
||||
|
||||
if (!fileName.endsWith(FILE_EXTENSION))
|
||||
fileName = (fileName.lastIndexOf(".") == -1 ? fileName : fileName.substring(0, fileName.lastIndexOf('.'))) + FILE_EXTENSION;
|
||||
|
||||
File destinationFile = new File(localeFolder, fileName);
|
||||
if (destinationFile.exists()) {
|
||||
return compareFiles(plugin.getResource(fileName), destinationFile);
|
||||
}
|
||||
|
||||
try (OutputStream outputStream = new FileOutputStream(destinationFile)) {
|
||||
copy(in == null ? plugin.getResource(fileName) : in, outputStream);
|
||||
|
||||
fileName = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||
String[] localeValues = fileName.split("_");
|
||||
|
||||
if (localeValues.length != 2) return false;
|
||||
|
||||
LOCALES.add(new Locale(localeValues[0], localeValues[1]));
|
||||
if (defaultLocale == null) defaultLocale = fileName;
|
||||
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a default locale file from the project source directory, to the locale folder
|
||||
*
|
||||
* @param fileName the name of the file to save
|
||||
* @return true if the operation was successful, false otherwise
|
||||
*/
|
||||
public static boolean saveDefaultLocale(String fileName) {
|
||||
return saveDefaultLocale(null, fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear all current locale data
|
||||
*/
|
||||
public static void clearLocaleData() {
|
||||
for (Locale locale : LOCALES)
|
||||
locale.nodes.clear();
|
||||
LOCALES.clear();
|
||||
}
|
||||
|
||||
// Write new changes to existing files, if any at all
|
||||
private static boolean compareFiles(InputStream defaultFile, File existingFile) {
|
||||
// Look for default
|
||||
if (defaultFile == null) {
|
||||
defaultFile = plugin.getResource(defaultLocale != null ? defaultLocale : "en_US");
|
||||
if (defaultFile == null) return false; // No default at all
|
||||
}
|
||||
|
||||
boolean changed = false;
|
||||
|
||||
List<String> defaultLines, existingLines;
|
||||
try (BufferedReader defaultReader = new BufferedReader(new InputStreamReader(defaultFile));
|
||||
BufferedReader existingReader = new BufferedReader(new FileReader(existingFile));
|
||||
BufferedWriter writer = new BufferedWriter(new FileWriter(existingFile, true))) {
|
||||
defaultLines = defaultReader.lines().collect(Collectors.toList());
|
||||
existingLines = existingReader.lines().map(s -> s.split("\\s*=")[0]).collect(Collectors.toList());
|
||||
|
||||
for (String defaultValue : defaultLines) {
|
||||
if (defaultValue.isEmpty() || defaultValue.startsWith("#")) continue;
|
||||
|
||||
String key = defaultValue.split("\\s*=")[0];
|
||||
|
||||
if (!existingLines.contains(key)) {
|
||||
if (!changed) {
|
||||
writer.newLine();
|
||||
writer.newLine();
|
||||
writer.write("# New messages for " + plugin.getName() + " v" + plugin.getDescription().getVersion());
|
||||
}
|
||||
|
||||
writer.newLine();
|
||||
writer.write(defaultValue);
|
||||
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static void copy(InputStream input, OutputStream output) {
|
||||
int n;
|
||||
byte[] buffer = new byte[1024 * 4];
|
||||
|
||||
try {
|
||||
while ((n = input.read(buffer)) != -1) {
|
||||
output.write(buffer, 0, n);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the language that this locale is based on.
|
||||
* (i.e. "en" for English, or "fr" for French)
|
||||
*
|
||||
* @return the name of the language
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the region that this locale is from.
|
||||
* (i.e. "US" for United States or "CA" for Canada)
|
||||
*
|
||||
* @return the name of the region
|
||||
*/
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the entire locale tag (i.e. "en_US")
|
||||
*
|
||||
* @return the language tag
|
||||
*/
|
||||
public String getLanguageTag() {
|
||||
return name + "_" + region;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file that represents this locale
|
||||
*
|
||||
* @return the locale file (.lang)
|
||||
*/
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message set for a specific node
|
||||
*
|
||||
* @param node the node to get
|
||||
* @return the message for the specified node
|
||||
*/
|
||||
public String getMessage(String node) {
|
||||
return ChatColor.translateAlternateColorCodes('&', this.getMessageOrDefault(node, node));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message set for a specific node and replace its params with a supplied arguments.
|
||||
*
|
||||
* @param node the node to get
|
||||
* @param args the replacement arguments
|
||||
* @return the message for the specified node
|
||||
*/
|
||||
public String getMessage(String node, Object... args) {
|
||||
String message = getMessage(node);
|
||||
for (Object arg : args) {
|
||||
message = message.replaceFirst("\\%.*?\\%", arg.toString());
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message set for a specific node
|
||||
*
|
||||
* @param node the node to get
|
||||
* @param defaultValue the default value given that a value for the node was not found
|
||||
* @return the message for the specified node. Default if none found
|
||||
*/
|
||||
public String getMessageOrDefault(String node, String defaultValue) {
|
||||
return this.nodes.getOrDefault(node, defaultValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the key-value map of nodes to messages
|
||||
*
|
||||
* @return node-message map
|
||||
*/
|
||||
public Map<String, String> getMessageNodeMap() {
|
||||
return ImmutableMap.copyOf(nodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the previous message cache and load new messages directly from file
|
||||
*
|
||||
* @return reload messages from file
|
||||
*/
|
||||
public boolean reloadMessages() {
|
||||
if (!this.file.exists()) {
|
||||
plugin.getLogger().warning("Could not find file for locale " + this.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
this.nodes.clear(); // Clear previous data (if any)
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
for (int lineNumber = 0; (line = reader.readLine()) != null; lineNumber++) {
|
||||
if (line.trim().isEmpty() || line.startsWith("#") /* Comment */) continue;
|
||||
|
||||
Matcher matcher = NODE_PATTERN.matcher(line);
|
||||
if (!matcher.find()) {
|
||||
System.err.println("Invalid locale syntax at (line=" + lineNumber + ")");
|
||||
continue;
|
||||
}
|
||||
|
||||
nodes.put(matcher.group(1), matcher.group(2));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
package com.songoda.ultimatemoderation;
|
||||
|
||||
public class References {
|
||||
|
||||
private String prefix;
|
||||
|
||||
public References() {
|
||||
prefix = UltimateModeration.getInstance().getLocale().getMessage("general.nametag.prefix") + " ";
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
}
|
|
@ -1,244 +1,193 @@
|
|||
package com.songoda.ultimatemoderation;
|
||||
|
||||
import com.songoda.ultimatemoderation.command.CommandManager;
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.SongodaPlugin;
|
||||
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.StorageMysql;
|
||||
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.Metrics;
|
||||
import com.songoda.ultimatemoderation.utils.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.utils.gui.AbstractGUI;
|
||||
import com.songoda.ultimatemoderation.utils.settings.Setting;
|
||||
import com.songoda.ultimatemoderation.utils.settings.SettingsManager;
|
||||
import com.songoda.ultimatemoderation.utils.updateModules.LocaleModule;
|
||||
import com.songoda.update.Plugin;
|
||||
import com.songoda.update.SongodaUpdate;
|
||||
import org.apache.commons.lang.ArrayUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.List;
|
||||
|
||||
public class UltimateModeration extends JavaPlugin {
|
||||
private static CommandSender console = Bukkit.getConsoleSender();
|
||||
public class UltimateModeration extends SongodaPlugin {
|
||||
private static UltimateModeration INSTANCE;
|
||||
private References references;
|
||||
|
||||
private ServerVersion serverVersion = ServerVersion.fromPackageName(Bukkit.getServer().getClass().getPackage().getName());
|
||||
|
||||
private final GuiManager guiManager = new GuiManager(this);
|
||||
private TicketManager ticketManager;
|
||||
private TemplateManager templateManager;
|
||||
private SettingsManager settingsManager;
|
||||
private CommandManager commandManager;
|
||||
private PunishmentManager punishmentManager;
|
||||
private StaffChatManager staffChatManager;
|
||||
private ModerationManager moderationManager;
|
||||
|
||||
private Locale locale;
|
||||
private Storage storage;
|
||||
private DatabaseConnector databaseConnector;
|
||||
private DataManager dataManager;
|
||||
|
||||
public static UltimateModeration getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
public void onPluginLoad() {
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
console.sendMessage(Methods.formatText("&a============================="));
|
||||
console.sendMessage(Methods.formatText("&7UltimateModeration " + this.getDescription().getVersion() + " by &5Songoda <3!"));
|
||||
console.sendMessage(Methods.formatText("&7Action: &aEnabling&7..."));
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
}
|
||||
|
||||
this.settingsManager = new SettingsManager(this);
|
||||
this.settingsManager.setupConfig();
|
||||
@Override
|
||||
public void onPluginEnable() {
|
||||
// Run Songoda Updater
|
||||
SongodaCore.registerPlugin(this, 29, CompatibleMaterial.DIAMOND_CHESTPLATE);
|
||||
|
||||
// Setup language
|
||||
String langMode = Setting.LANGUGE_MODE.getString();
|
||||
Locale.init(this);
|
||||
Locale.saveDefaultLocale("en_US");
|
||||
this.locale = Locale.getLocale(getConfig().getString("System.Language Mode", langMode));
|
||||
// Setup Config
|
||||
Settings.setupConfig();
|
||||
this.setLocale(Settings.LANGUGE_MODE.getString(), false);
|
||||
|
||||
//Running Songoda Updater
|
||||
Plugin plugin = new Plugin(this, 29);
|
||||
plugin.addModule(new LocaleModule());
|
||||
SongodaUpdate.load(plugin);
|
||||
|
||||
this.references = new References();
|
||||
// Register commands
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.commandManager.addCommand(new CommandUltimateModeration(this))
|
||||
.addSubCommands(
|
||||
new CommandReload(this),
|
||||
new CommandSettings(this, guiManager),
|
||||
new CommandHelp(this)
|
||||
);
|
||||
this.commandManager.addCommand(new CommandBan(this));
|
||||
this.commandManager.addCommand(new CommandClearChat(this));
|
||||
this.commandManager.addCommand(new CommandKick(this));
|
||||
this.commandManager.addCommand(new CommandMute(this));
|
||||
this.commandManager.addCommand(new CommandRandomPlayer(this));
|
||||
this.commandManager.addCommand(new CommandRunTemplate(this));
|
||||
this.commandManager.addCommand(new CommandSlowMode(this));
|
||||
this.commandManager.addCommand(new CommandStaffChat(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.commandManager.addCommand(new CommandWarn(this));
|
||||
|
||||
// Setup Managers
|
||||
this.ticketManager = new TicketManager();
|
||||
this.templateManager = new TemplateManager();
|
||||
this.commandManager = new CommandManager(this);
|
||||
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
|
||||
AbstractGUI.initializeListeners(this);
|
||||
Bukkit.getPluginManager().registerEvents(new CommandListener(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new DeathListener(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new MoveListener(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new DropListener(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new InventoryListener(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new ChatListener(this), this);
|
||||
Bukkit.getPluginManager().registerEvents(new LoginListener(this), this);
|
||||
guiManager.init();
|
||||
PluginManager pluginManager = Bukkit.getPluginManager();
|
||||
pluginManager.registerEvents(new CommandListener(this), this);
|
||||
pluginManager.registerEvents(new DeathListener(this), this);
|
||||
pluginManager.registerEvents(new MoveListener(this), this);
|
||||
pluginManager.registerEvents(new DropListener(this), this);
|
||||
pluginManager.registerEvents(new InventoryListener(this), this);
|
||||
pluginManager.registerEvents(new ChatListener(this), this);
|
||||
pluginManager.registerEvents(new LoginListener(this), this);
|
||||
pluginManager.registerEvents(new MobTargetLister(), this);
|
||||
pluginManager.registerEvents(new BlockListener(this), this);
|
||||
if (pluginManager.isPluginEnabled("FabledSkyBlock"))
|
||||
pluginManager.registerEvents(new SkyBlockListener(this), this);
|
||||
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
pluginManager.registerEvents(new SpyingDismountListener(), this);
|
||||
|
||||
// Start tasks
|
||||
SlowModeTask.startTask(this);
|
||||
|
||||
// Starting Metrics
|
||||
new Metrics(this);
|
||||
|
||||
int timeout = Setting.AUTOSAVE.getInt() * 60 * 20;
|
||||
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> storage.doSave(), timeout, timeout);
|
||||
console.sendMessage(Methods.formatText("&a============================="));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
storage.doSave();
|
||||
this.storage.closeConnection();
|
||||
console.sendMessage(Methods.formatText("&a============================="));
|
||||
console.sendMessage(Methods.formatText("&7UltimateModeration " + this.getDescription().getVersion() + " by &5Songoda <3!"));
|
||||
console.sendMessage(Methods.formatText("&7Action: &cDisabling&7..."));
|
||||
console.sendMessage(Methods.formatText("&a============================="));
|
||||
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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void checkStorage() {
|
||||
if (getConfig().getBoolean("Database.Activate Mysql Support")) {
|
||||
this.storage = new StorageMysql(this);
|
||||
} else {
|
||||
this.storage = new StorageYaml(this);
|
||||
}
|
||||
@Override
|
||||
public void onConfigReload() {
|
||||
this.setLocale(getConfig().getString("System.Language Mode"), true);
|
||||
this.locale.reloadMessages();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
public ServerVersion getServerVersion() {
|
||||
return serverVersion;
|
||||
}
|
||||
|
||||
public boolean isServerVersion(ServerVersion version) {
|
||||
return serverVersion == version;
|
||||
}
|
||||
public boolean isServerVersion(ServerVersion... versions) {
|
||||
return ArrayUtils.contains(versions, serverVersion);
|
||||
}
|
||||
|
||||
public boolean isServerVersionAtLeast(ServerVersion version) {
|
||||
return serverVersion.ordinal() >= version.ordinal();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
locale.reloadMessages();
|
||||
references = new References();
|
||||
this.settingsManager.reloadConfig();
|
||||
@Override
|
||||
public List<Config> getExtraConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public SettingsManager getSettingsManager() {
|
||||
return settingsManager;
|
||||
}
|
||||
|
||||
public Locale getLocale() {
|
||||
return locale;
|
||||
}
|
||||
|
||||
public References getReferences() {
|
||||
return references;
|
||||
}
|
||||
|
||||
public TemplateManager getTemplateManager() {
|
||||
return templateManager;
|
||||
}
|
||||
|
@ -254,4 +203,20 @@ public class UltimateModeration extends JavaPlugin {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,71 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractCommand {
|
||||
|
||||
private final boolean noConsole;
|
||||
private AbstractCommand parent = null;
|
||||
private boolean hasArgs = false;
|
||||
private String command;
|
||||
|
||||
private List<String> subCommand = new ArrayList<>();
|
||||
|
||||
protected AbstractCommand(AbstractCommand parent, boolean noConsole, String... command) {
|
||||
if (parent != null) {
|
||||
this.subCommand = Arrays.asList(command);
|
||||
} else {
|
||||
this.command = Arrays.asList(command).get(0);
|
||||
}
|
||||
this.parent = parent;
|
||||
this.noConsole = noConsole;
|
||||
}
|
||||
|
||||
protected AbstractCommand(boolean noConsole, boolean hasArgs, String... command) {
|
||||
this.command = Arrays.asList(command).get(0);
|
||||
|
||||
this.hasArgs = hasArgs;
|
||||
this.noConsole = noConsole;
|
||||
}
|
||||
|
||||
public AbstractCommand getParent() {
|
||||
return parent;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return command;
|
||||
}
|
||||
|
||||
public List<String> getSubCommand() {
|
||||
return subCommand;
|
||||
}
|
||||
|
||||
public void addSubCommand(String command) {
|
||||
subCommand.add(command);
|
||||
}
|
||||
|
||||
protected abstract ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args);
|
||||
|
||||
protected abstract List<String> onTab(UltimateModeration instance, CommandSender sender, String... args);
|
||||
|
||||
public abstract String getPermissionNode();
|
||||
|
||||
public abstract String getSyntax();
|
||||
|
||||
public abstract String getDescription();
|
||||
|
||||
public boolean hasArgs() {
|
||||
return hasArgs;
|
||||
}
|
||||
|
||||
public boolean isNoConsole() {
|
||||
return noConsole;
|
||||
}
|
||||
|
||||
public enum ReturnType {SUCCESS, FAILURE, SYNTAX_ERROR}
|
||||
}
|
|
@ -1,127 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.commands.*;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandManager implements CommandExecutor {
|
||||
|
||||
private UltimateModeration instance;
|
||||
private TabManager tabManager;
|
||||
|
||||
private List<AbstractCommand> commands = new ArrayList<>();
|
||||
|
||||
public CommandManager(UltimateModeration instance) {
|
||||
this.instance = instance;
|
||||
this.tabManager = new TabManager(this);
|
||||
|
||||
instance.getCommand("UltimateModeration").setExecutor(this);
|
||||
instance.getCommand("ClearChat").setExecutor(this);
|
||||
instance.getCommand("ToggleChat").setExecutor(this);
|
||||
instance.getCommand("RandomPlayer").setExecutor(this);
|
||||
instance.getCommand("Vanish").setExecutor(this);
|
||||
instance.getCommand("ViewEnderChest").setExecutor(this);
|
||||
instance.getCommand("InvSee").setExecutor(this);
|
||||
instance.getCommand("Freeze").setExecutor(this);
|
||||
instance.getCommand("Revive").setExecutor(this);
|
||||
instance.getCommand("Spy").setExecutor(this);
|
||||
instance.getCommand("CommandSpy").setExecutor(this);
|
||||
instance.getCommand("Ban").setExecutor(this);
|
||||
instance.getCommand("UnBan").setExecutor(this);
|
||||
instance.getCommand("Kick").setExecutor(this);
|
||||
instance.getCommand("Mute").setExecutor(this);
|
||||
instance.getCommand("UnMute").setExecutor(this);
|
||||
instance.getCommand("Warn").setExecutor(this);
|
||||
instance.getCommand("RunTemplate").setExecutor(this);
|
||||
instance.getCommand("Ticket").setExecutor(this);
|
||||
instance.getCommand("StaffChat").setExecutor(this);
|
||||
instance.getCommand("SlowMode").setExecutor(this);
|
||||
|
||||
AbstractCommand commandUltimateModeration = addCommand(new CommandUltimateModeration());
|
||||
addCommand(new CommandClearChat());
|
||||
addCommand(new CommandToggleChat());
|
||||
addCommand(new CommandRandomPlayer());
|
||||
addCommand(new CommandVanish());
|
||||
addCommand(new CommandViewEnderChest());
|
||||
addCommand(new CommandInvSee());
|
||||
addCommand(new CommandFreeze());
|
||||
addCommand(new CommandRevive());
|
||||
addCommand(new CommandSpy());
|
||||
addCommand(new CommandCommandSpy());
|
||||
addCommand(new CommandBan());
|
||||
addCommand(new CommandUnBan());
|
||||
addCommand(new CommandKick());
|
||||
addCommand(new CommandMute());
|
||||
addCommand(new CommandUnMute());
|
||||
addCommand(new CommandWarn());
|
||||
addCommand(new CommandRunTemplate());
|
||||
addCommand(new CommandTicket());
|
||||
addCommand(new CommandStaffChat());
|
||||
addCommand(new CommandSlowMode());
|
||||
|
||||
addCommand(new CommandSettings(commandUltimateModeration));
|
||||
addCommand(new CommandHelp(commandUltimateModeration));
|
||||
addCommand(new CommandReload(commandUltimateModeration));
|
||||
|
||||
for (AbstractCommand abstractCommand : commands) {
|
||||
if (abstractCommand.getParent() != null) continue;
|
||||
instance.getCommand(abstractCommand.getCommand()).setTabCompleter(tabManager);
|
||||
}
|
||||
}
|
||||
|
||||
private AbstractCommand addCommand(AbstractCommand abstractCommand) {
|
||||
commands.add(abstractCommand);
|
||||
return abstractCommand;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
for (AbstractCommand abstractCommand : commands) {
|
||||
if (abstractCommand.getCommand() != null && abstractCommand.getCommand().equalsIgnoreCase(command.getName().toLowerCase())) {
|
||||
if (strings.length == 0 || abstractCommand.hasArgs()) {
|
||||
processRequirements(abstractCommand, commandSender, strings);
|
||||
return true;
|
||||
}
|
||||
} else if (strings.length != 0 && abstractCommand.getParent() != null && abstractCommand.getParent().getCommand().equalsIgnoreCase(command.getName())) {
|
||||
String cmd = strings[0];
|
||||
String cmd2 = strings.length >= 2 ? String.join(" ", strings[0], strings[1]) : null;
|
||||
for (String cmds : abstractCommand.getSubCommand()) {
|
||||
if (cmd.equalsIgnoreCase(cmds) || (cmd2 != null && cmd2.equalsIgnoreCase(cmds))) {
|
||||
processRequirements(abstractCommand, commandSender, strings);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
commandSender.sendMessage(instance.getReferences().getPrefix() + Methods.formatText("&7The command you entered does not exist or is spelt incorrectly."));
|
||||
return true;
|
||||
}
|
||||
|
||||
private void processRequirements(AbstractCommand command, CommandSender sender, String[] strings) {
|
||||
if (!(sender instanceof Player) && command.isNoConsole()) {
|
||||
sender.sendMessage("You must be a player to use this command.");
|
||||
return;
|
||||
}
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
AbstractCommand.ReturnType returnType = command.runCommand(instance, sender, strings);
|
||||
if (returnType == AbstractCommand.ReturnType.SYNTAX_ERROR) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Methods.formatText("&cInvalid Syntax!"));
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + Methods.formatText("&7The valid syntax is: &6" + command.getSyntax() + "&7."));
|
||||
}
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.general.nopermission"));
|
||||
}
|
||||
|
||||
public List<AbstractCommand> getCommands() {
|
||||
return Collections.unmodifiableList(commands);
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TabManager implements TabCompleter {
|
||||
|
||||
private final CommandManager commandManager;
|
||||
|
||||
TabManager(CommandManager commandManager) {
|
||||
this.commandManager = commandManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] strings) {
|
||||
for (AbstractCommand abstractCommand : commandManager.getCommands()) {
|
||||
if (abstractCommand.getCommand() != null && abstractCommand.getCommand().equalsIgnoreCase(command.getName()) && !abstractCommand.hasArgs()) {
|
||||
if (strings.length == 1) {
|
||||
List<String> subs = new ArrayList<>();
|
||||
for (AbstractCommand ac : commandManager.getCommands()) {
|
||||
if (ac.getSubCommand() == null) continue;
|
||||
subs.addAll(ac.getSubCommand());
|
||||
}
|
||||
subs.removeIf(s -> !s.toLowerCase().startsWith(strings[0].toLowerCase()));
|
||||
return subs;
|
||||
}
|
||||
} else if (strings.length != 0
|
||||
&& abstractCommand.getCommand() != null
|
||||
&& abstractCommand.getCommand().equalsIgnoreCase(command.getName().toLowerCase())) {
|
||||
String cmd = strings[0];
|
||||
String cmd2 = strings.length >= 2 ? String.join(" ", strings[0], strings[1]) : null;
|
||||
if (abstractCommand.hasArgs()) {
|
||||
return onCommand(abstractCommand, strings, sender);
|
||||
} else {
|
||||
for (String cmds : abstractCommand.getSubCommand()) {
|
||||
if (cmd.equalsIgnoreCase(cmds) || (cmd2 != null && cmd2.equalsIgnoreCase(cmds))) {
|
||||
return onCommand(abstractCommand, strings, sender);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
private List<String> onCommand(AbstractCommand abstractCommand, String[] strings, CommandSender sender) {
|
||||
List<String> list = abstractCommand.onTab(UltimateModeration.getInstance(), sender, strings);
|
||||
String str = strings[strings.length - 1];
|
||||
if (list != null && str != null && str.length() >= 1) {
|
||||
try {
|
||||
list.removeIf(s -> !s.toLowerCase().startsWith(str.toLowerCase()));
|
||||
} catch (UnsupportedOperationException ignored) {
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
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 static List<UUID> inSpy = new ArrayList<>();
|
||||
|
||||
public CommandCommandSpy() {
|
||||
super(true, false, "CommandSpy");
|
||||
}
|
||||
|
||||
public static boolean isSpying(Player player) {
|
||||
return !inSpy.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
Player player = ((Player) sender);
|
||||
|
||||
if (inSpy.contains(player.getUniqueId())) {
|
||||
inSpy.remove(player.getUniqueId());
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.commandspy.toggleOn"));
|
||||
} else {
|
||||
inSpy.add(player.getUniqueId());
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.commandspy.toggleOff"));
|
||||
}
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, 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,80 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CommandFreeze extends AbstractCommand {
|
||||
|
||||
private static List<UUID> frozen = new ArrayList<>();
|
||||
|
||||
public CommandFreeze() {
|
||||
super(true, true, "Freeze");
|
||||
}
|
||||
|
||||
public static void freeze(OfflinePlayer player, Player sender) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
if (frozen.contains(player.getUniqueId())) {
|
||||
frozen.remove(player.getUniqueId());
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.freeze.remove", player.getPlayer().getDisplayName()));
|
||||
player.getPlayer().sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.freeze.alertremove"));
|
||||
} else {
|
||||
frozen.add(player.getUniqueId());
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.freeze.add", player.getPlayer().getDisplayName()));
|
||||
player.getPlayer().sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.freeze.alertadd"));
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isFrozen(OfflinePlayer player) {
|
||||
return frozen.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist or is not online.");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
freeze(player, (Player) sender);
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, 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.";
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandInvSee extends AbstractCommand {
|
||||
|
||||
public CommandInvSee() {
|
||||
super(true, true, "InvSee");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist or is not online.");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
((Player) sender).openInventory(player.getInventory());
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, 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.invsee";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/InvSee <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to see inside of a players inventory.";
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandReload extends AbstractCommand {
|
||||
|
||||
public CommandReload(AbstractCommand parent) {
|
||||
super(parent, false, "reload");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
instance.reload();
|
||||
sender.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + "&7Configuration and Language files reloaded."));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/um reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Reload the Configuration and Language files.";
|
||||
}
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.listeners.DeathListener;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CommandRevive extends AbstractCommand {
|
||||
|
||||
public CommandRevive() {
|
||||
super(true, true, "Revive");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist or is not online.");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (!(revive(player, sender))) return ReturnType.FAILURE;
|
||||
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.revive.revived"));
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.revive.success", player.getName()));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, 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) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.revive.noloot"));
|
||||
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.";
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandSettings extends AbstractCommand {
|
||||
|
||||
public CommandSettings(AbstractCommand parent) {
|
||||
super(parent, true, "settings");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
instance.getSettingsManager().openSettingsManager(player);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/um settings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Edit UltimateModeration Settings.";
|
||||
}
|
||||
}
|
|
@ -1,130 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.utils.ServerVersion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class CommandSpy extends AbstractCommand {
|
||||
|
||||
private static Map<UUID, Spy> spying = new HashMap<>();
|
||||
|
||||
public CommandSpy() {
|
||||
super(true, true, "Spy");
|
||||
}
|
||||
|
||||
public static void spy(OfflinePlayer oPlayer, Player senderP) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
|
||||
if (!UltimateModeration.getInstance().isServerVersionAtLeast(ServerVersion.V1_12)) {
|
||||
senderP.sendMessage(instance.getReferences().getPrefix() + "This feature is not compatible with this version of spigot.");
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = oPlayer.getPlayer();
|
||||
|
||||
if (player == null) {
|
||||
senderP.sendMessage(instance.getReferences().getPrefix() + "That player does not exist or is not online.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (player == senderP) {
|
||||
senderP.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.spy.cant"));
|
||||
return;
|
||||
}
|
||||
|
||||
boolean didVanish = false;
|
||||
if (!CommandVanish.isVanished(senderP)) {
|
||||
CommandVanish.vanish(senderP);
|
||||
senderP.setCanPickupItems(false);
|
||||
}
|
||||
senderP.teleport(player.getPlayer().getLocation());
|
||||
|
||||
spying.put(senderP.getUniqueId(), new Spy(senderP.getLocation(), didVanish));
|
||||
player.getPlayer().addPassenger(senderP);
|
||||
|
||||
senderP.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.spy.success", player.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, 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;
|
||||
senderP.teleport(spying.get(senderP.getUniqueId()).getLastLocation());
|
||||
if (spying.get(senderP.getUniqueId()).isVanishApplied() && CommandVanish.isVanished(senderP))
|
||||
CommandVanish.vanish(senderP);
|
||||
|
||||
spying.remove(senderP.getUniqueId());
|
||||
senderP.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.spy.returned"));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist or is not online.");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
spy(player, senderP);
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, 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 class Spy {
|
||||
private Location lastLocation;
|
||||
private boolean vanishApplied;
|
||||
|
||||
public Spy(Location lastLocation, boolean vanishApplied) {
|
||||
this.lastLocation = lastLocation;
|
||||
this.vanishApplied = vanishApplied;
|
||||
}
|
||||
|
||||
public Location getLastLocation() {
|
||||
return lastLocation;
|
||||
}
|
||||
|
||||
public boolean isVanishApplied() {
|
||||
return vanishApplied;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChannel;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandStaffChat extends AbstractCommand {
|
||||
|
||||
public CommandStaffChat() {
|
||||
super(true, true, "StaffChat");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
String channelName = args[0];
|
||||
Player player = (Player)sender;
|
||||
|
||||
if (channelName.trim().equalsIgnoreCase("leave")) {
|
||||
for (StaffChannel channel : instance.getStaffChatManager().getChats().values()) {
|
||||
if (!channel.listMembers().contains(player.getUniqueId())) continue;
|
||||
channel.removeMember(player);
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.staffchat.leave", channel.getChannelName()));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.staffchat.nochannels"));
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
instance.getStaffChatManager().getChat(channelName).addMember(player);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
return new ArrayList<>(instance.getStaffChatManager().getChats().keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.staffchat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/sc <channel/leave>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Opens a staff chat channel.";
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.gui.GUITicketManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CommandTicket extends AbstractCommand {
|
||||
|
||||
public CommandTicket() {
|
||||
super(true, false, "Ticket");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
Player senderP = ((Player) sender);
|
||||
|
||||
new GUITicketManager(instance, senderP, senderP);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.ticket";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ticket";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Opens the ticket interface.";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.gui.GUIPlayers;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandUltimateModeration extends AbstractCommand {
|
||||
|
||||
public CommandUltimateModeration() {
|
||||
super(true, false, "UltimateModeration");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
new GUIPlayers(instance, (Player) sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.moderate";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/um";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Displays this page.";
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandViewEnderChest extends AbstractCommand {
|
||||
|
||||
public CommandViewEnderChest() {
|
||||
super(true, true, "ViewEnderChest");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist or is not online.");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
((Player) sender).openInventory(player.getEnderChest());
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, 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.";
|
||||
}
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
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,12 +18,15 @@ import java.util.List;
|
|||
|
||||
public class CommandBan extends AbstractCommand {
|
||||
|
||||
public CommandBan() {
|
||||
super(false, true, "Ban");
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandBan(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "Ban");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
|
@ -45,25 +49,33 @@ public class CommandBan extends AbstractCommand {
|
|||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist.");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (instance.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
if (plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player is already banned.");
|
||||
plugin.getLocale().newMessage("That player is already banned.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
new Punishment(PunishmentType.BAN, duration == 0 ? -1 : duration, reason.equals("") ? null : reason)
|
||||
.execute(sender, player);
|
||||
if (duration == 0 && !sender.hasPermission("um.ban.permanent")) {
|
||||
plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
@ -1,25 +1,26 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandClearChat extends AbstractCommand {
|
||||
|
||||
public CommandClearChat() {
|
||||
super(true, true, "ClearChat");
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandClearChat(UltimateModeration plugin) {
|
||||
super(CommandType.PLAYER_ONLY, "ClearChat");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
|
||||
if (args.length != 0 && !args[0].equalsIgnoreCase("force"))
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
@ -31,17 +32,18 @@ public class CommandClearChat extends AbstractCommand {
|
|||
player.sendMessage(toSend);
|
||||
}
|
||||
|
||||
player.sendMessage(instance.getReferences().getPrefix() + Methods.formatText(instance.getLocale().getMessage("command.clearchat.cleared", sender.getName())));
|
||||
plugin.getLocale().getMessage("command.clearchat.cleared")
|
||||
.processPlaceholder("player", sender.getName()).sendPrefixedMessage(player);
|
||||
|
||||
if (player.hasPermission("um.clearchat.bypass") && !isForced(args)) {
|
||||
player.sendMessage(instance.getLocale().getMessage("command.clearchat.immune"));
|
||||
plugin.getLocale().getMessage("command.clearchat.immune").sendMessage(player);
|
||||
}
|
||||
}
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
return Collections.singletonList("force");
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
@ -9,19 +9,23 @@ import java.util.List;
|
|||
|
||||
public class CommandHelp extends AbstractCommand {
|
||||
|
||||
public CommandHelp(AbstractCommand parent) {
|
||||
super(parent, false, "help");
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandHelp(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "help");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + "&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().getCommands()) {
|
||||
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()));
|
||||
}
|
||||
|
@ -32,7 +36,7 @@ public class CommandHelp extends AbstractCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -1,28 +1,29 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
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.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandKick extends AbstractCommand {
|
||||
|
||||
public CommandKick() {
|
||||
super(false, true, "Kick");
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandKick(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "Kick");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
|
@ -38,8 +39,8 @@ public class CommandKick extends AbstractCommand {
|
|||
|
||||
OfflinePlayer player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist or is not online.");
|
||||
if (sender instanceof Player && player.getPlayer().hasPermission("um.kick.exempt")) {
|
||||
plugin.getLocale().newMessage("You cannot kick this player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
|
@ -50,7 +51,7 @@ public class CommandKick extends AbstractCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
@ -1,10 +1,11 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
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,12 +18,15 @@ import java.util.List;
|
|||
|
||||
public class CommandMute extends AbstractCommand {
|
||||
|
||||
public CommandMute() {
|
||||
super(false, true, "Mute");
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandMute(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "Mute");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
|
@ -45,14 +49,14 @@ public class CommandMute extends AbstractCommand {
|
|||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist.");
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.mute.exempt")) {
|
||||
plugin.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)) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player is already muted.");
|
||||
plugin.getLocale().newMessage("That player is already muted.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
|
@ -63,7 +67,7 @@ public class CommandMute extends AbstractCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
@ -1,8 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -13,18 +12,21 @@ import java.util.List;
|
|||
|
||||
public class CommandRandomPlayer extends AbstractCommand {
|
||||
|
||||
public CommandRandomPlayer() {
|
||||
super(true, false, "RandomPlayer");
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandRandomPlayer(UltimateModeration plugin) {
|
||||
super(CommandType.PLAYER_ONLY, "RandomPlayer");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
List<Player> players = new ArrayList<>(Bukkit.getOnlinePlayers());
|
||||
Collections.shuffle(players);
|
||||
players.remove(sender);
|
||||
|
||||
if (players.size() == 0) {
|
||||
sender.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + "&c You are the only one online!"));
|
||||
plugin.getLocale().newMessage("&cYou are the only one online!").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
|
@ -33,7 +35,7 @@ public class CommandRandomPlayer extends AbstractCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandReload extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandReload(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "reload");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
plugin.reloadConfig();
|
||||
plugin.getLocale().newMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/um reload";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Reload the Configuration and Language files.";
|
||||
}
|
||||
}
|
|
@ -1,39 +1,32 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandRunTemplate extends AbstractCommand {
|
||||
|
||||
public CommandRunTemplate() {
|
||||
super(false, true, "RunTemplate");
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandRunTemplate(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "RunTemplate");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 2)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist.");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
StringBuilder templateBuilder = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
String line = args[i];
|
||||
|
@ -41,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...");
|
||||
|
@ -54,7 +47,7 @@ public class CommandRunTemplate extends AbstractCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
|
@ -63,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;
|
|
@ -0,0 +1,49 @@
|
|||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.configuration.editor.PluginConfigGui;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandSettings extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final GuiManager guiManager;
|
||||
|
||||
public CommandSettings(UltimateModeration plugin, GuiManager manager) {
|
||||
super(CommandType.PLAYER_ONLY, "settings");
|
||||
this.plugin = plugin;
|
||||
this.guiManager = manager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player player = (Player) sender;
|
||||
guiManager.showGUI((Player) sender, new PluginConfigGui(plugin));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/um settings";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Edit UltimateModeration Settings.";
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.listeners.ChatListener;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -13,15 +13,18 @@ import java.util.List;
|
|||
|
||||
public class CommandSlowMode extends AbstractCommand {
|
||||
|
||||
public CommandSlowMode() {
|
||||
super(true, true, "Slowmode");
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandSlowMode(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "Slowmode");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length == 0) {
|
||||
ChatListener.setSlowModeOverride(0);
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.slowmode.disabled"));
|
||||
plugin.getLocale().getMessage("event.slowmode.disabled").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
} else if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
@ -31,14 +34,14 @@ public class CommandSlowMode extends AbstractCommand {
|
|||
ChatListener.setSlowModeOverride(delay);
|
||||
|
||||
Bukkit.getOnlinePlayers().forEach(player ->
|
||||
player.sendMessage(instance.getReferences().getPrefix() +
|
||||
instance.getLocale().getMessage("event.slowmode.enabled", Methods.makeReadable(delay))));
|
||||
plugin.getLocale().getMessage("event.slowmode.enabled")
|
||||
.processPlaceholder("delay", Methods.makeReadable(delay)).sendPrefixedMessage(player));
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
@ -0,0 +1,66 @@
|
|||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.staffchat.StaffChannel;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandStaffChat extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandStaffChat(UltimateModeration plugin) {
|
||||
super(CommandType.PLAYER_ONLY, "StaffChat");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
String channelName = args[0];
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (channelName.trim().equalsIgnoreCase("leave")) {
|
||||
for (StaffChannel channel : plugin.getStaffChatManager().getChats().values()) {
|
||||
if (!channel.listMembers().contains(player.getUniqueId())) continue;
|
||||
channel.removeMember(player);
|
||||
plugin.getLocale().getMessage("event.staffchat.leave")
|
||||
.processPlaceholder("channel", channel.getChannelName()).sendPrefixedMessage(player);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
plugin.getLocale().getMessage("event.staffchat.nochannels").sendPrefixedMessage(player);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
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<>(plugin.getStaffChatManager().getChats().keySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.staffchat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/sc <channel/leave>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Opens a staff chat channel.";
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
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.TicketManagerGui;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandTicket extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final GuiManager guiManager;
|
||||
|
||||
public CommandTicket(UltimateModeration plugin, GuiManager guiManager) {
|
||||
super(CommandType.PLAYER_ONLY, "Ticket");
|
||||
this.plugin = plugin;
|
||||
this.guiManager = guiManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player senderP = ((Player) sender);
|
||||
guiManager.showGUI(senderP, new TicketManagerGui(plugin, senderP, senderP));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.ticket";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/ticket";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Opens the ticket interface.";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.ultimatemoderation.Locale;
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.locale.Message;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.listeners.ChatListener;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -13,45 +12,45 @@ import java.util.List;
|
|||
|
||||
public class CommandToggleChat extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
/*
|
||||
* Chat is enabled by default ;)
|
||||
*/
|
||||
private boolean toggled = true;
|
||||
|
||||
public CommandToggleChat() {
|
||||
super(false, false, "togglechat");
|
||||
public CommandToggleChat(UltimateModeration plugin) {
|
||||
super(CommandType.PLAYER_ONLY, "togglechat");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
toggled = !toggled;
|
||||
String prefix = instance.getReferences().getPrefix();
|
||||
|
||||
Locale locale = instance.getLocale();
|
||||
String strToggledOn = locale.getMessage("command.togglechat.toggledOn");
|
||||
String strToggledOff = locale.getMessage("command.togglechat.toggledOff");
|
||||
String messageToSend = prefix + Methods.formatText(toggled ? strToggledOn : strToggledOff);
|
||||
Message message = toggled ? plugin.getLocale().getMessage("command.togglechat.toggledOn")
|
||||
: plugin.getLocale().getMessage("command.togglechat.toggledOff");
|
||||
|
||||
ChatListener.setChatToggled(toggled);
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
|
||||
player.sendMessage(messageToSend);
|
||||
message.sendPrefixedMessage(player);
|
||||
|
||||
if (!player.hasPermission(getPermissionNode() + ".bypass"))
|
||||
continue;
|
||||
|
||||
player.sendMessage(Methods.formatText(locale.getMessage("command.togglechat.bypass")));
|
||||
plugin.getLocale().getMessage("command.togglechat.bypass").sendMessage(player);
|
||||
}
|
||||
|
||||
if (!(sender instanceof Player))
|
||||
sender.sendMessage(messageToSend);
|
||||
message.sendPrefixedMessage(sender);
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.gui.MainGui;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandUltimateModeration extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandUltimateModeration(UltimateModeration plugin) {
|
||||
super(CommandType.PLAYER_ONLY, "UltimateModeration");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
plugin.getGuiManager().showGUI((Player) sender, new MainGui(plugin, (Player) sender));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "um.moderate";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/um";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Displays the moderation panel.";
|
||||
}
|
||||
}
|
|
@ -1,8 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -11,44 +10,41 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandUnBan extends AbstractCommand {
|
||||
|
||||
public CommandUnBan() {
|
||||
super(false, true, "UnBan");
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandUnBan(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "UnBan");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist.");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (!instance.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
if (!plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.BAN)) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player isn't banned.");
|
||||
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);
|
||||
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.unban.success", player.getName()));
|
||||
plugin.getLocale().getMessage("event.unban.success")
|
||||
.processPlaceholder("player", player.getName()).sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
|
@ -71,6 +67,6 @@ public class CommandUnBan extends AbstractCommand {
|
|||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Allows you to ban players.";
|
||||
return "Allows you to unban players.";
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -10,44 +10,41 @@ import org.bukkit.command.CommandSender;
|
|||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandUnMute extends AbstractCommand {
|
||||
|
||||
public CommandUnMute() {
|
||||
super(false, true, "UnMute");
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandUnMute(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "UnMute");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist.");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
if (!instance.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
if (!plugin.getPunishmentManager().getPlayer(player).getActivePunishments()
|
||||
.stream().anyMatch(appliedPunishment -> appliedPunishment.getPunishmentType() == PunishmentType.MUTE)) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player isn't muted.");
|
||||
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);
|
||||
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.unmute.success", player.getName()));
|
||||
plugin.getLocale().newMessage(plugin.getLocale().getMessage("event.unmute.success")
|
||||
.processPlaceholder("player", player.getName()).getMessage()).sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
@ -1,16 +1,16 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.utils.settings.Setting;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -19,10 +19,10 @@ import java.util.UUID;
|
|||
|
||||
public class CommandVanish extends AbstractCommand {
|
||||
|
||||
private static List<UUID> inVanish = new ArrayList<>();
|
||||
private static final List<UUID> inVanish = new ArrayList<>();
|
||||
|
||||
public CommandVanish() {
|
||||
super(true, false, "Vanish");
|
||||
super(CommandType.PLAYER_ONLY, "Vanish");
|
||||
}
|
||||
|
||||
public static void registerVanishedPlayers(Player player) {
|
||||
|
@ -44,22 +44,22 @@ public class CommandVanish extends AbstractCommand {
|
|||
|
||||
if (inVanish.contains(uuid)) {
|
||||
inVanish.remove(uuid);
|
||||
if (instance.isServerVersionAtLeast(ServerVersion.V1_9))
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9))
|
||||
player.setInvulnerable(false);
|
||||
player.setCanPickupItems(true);
|
||||
player.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.vanish.toggledOff")));
|
||||
instance.getLocale().getMessage("command.vanish.toggledOff").sendPrefixedMessage(player);
|
||||
} else {
|
||||
inVanish.add(uuid);
|
||||
player.setCanPickupItems(false);
|
||||
|
||||
if (instance.isServerVersionAtLeast(ServerVersion.V1_9))
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9))
|
||||
player.setInvulnerable(true);
|
||||
player.sendMessage(Methods.formatText(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.vanish.toggledOn")));
|
||||
}
|
||||
if (Setting.VANISH_EFFECTS.getBoolean()) {
|
||||
player.getWorld().playSound(player.getLocation(), Sound.valueOf(Setting.VANISH_SOUND.getString()), 1L, 1L);
|
||||
instance.getLocale().getMessage("command.vanish.toggledOn").sendPrefixedMessage(player);
|
||||
|
||||
if (Setting.VANISH_BATS.getBoolean()) {
|
||||
}
|
||||
if (Settings.VANISH_EFFECTS.getBoolean()) {
|
||||
player.getWorld().playSound(player.getLocation(), Sound.valueOf(Settings.VANISH_SOUND.getString()), 1L, 1L);
|
||||
|
||||
if (Settings.VANISH_BATS.getBoolean()) {
|
||||
List<Entity> entities = new ArrayList<>();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
entities.add(player.getWorld().spawnEntity(player.getLocation().add(0, 1, 0), EntityType.BAT));
|
||||
|
@ -74,8 +74,8 @@ public class CommandVanish extends AbstractCommand {
|
|||
float xx = (float) (0 + (Math.random() * 1));
|
||||
float yy = (float) (0 + (Math.random() * 2));
|
||||
float zz = (float) (0 + (Math.random() * 1));
|
||||
if (instance.isServerVersionAtLeast(ServerVersion.V1_12))
|
||||
player.getWorld().spawnParticle(Particle.valueOf(Setting.VANISH_PARTICLE.getString()), player.getLocation().add(0, 1, 0), 35, xx, yy, zz, 0);
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_12))
|
||||
player.getWorld().spawnParticle(Particle.valueOf(Settings.VANISH_PARTICLE.getString()), player.getLocation().add(0, 1, 0), 35, xx, yy, zz, 0);
|
||||
}
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
@ -84,6 +84,11 @@ public class CommandVanish extends AbstractCommand {
|
|||
else
|
||||
p.showPlayer(player);
|
||||
}
|
||||
for (Entity e : player.getNearbyEntities(30, 30, 30)) {
|
||||
if (e instanceof Monster) {
|
||||
((Monster) e).setTarget(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isVanished(Player player) {
|
||||
|
@ -91,14 +96,14 @@ public class CommandVanish extends AbstractCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
Player player = ((Player) sender);
|
||||
vanish(player);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
@ -1,10 +1,11 @@
|
|||
package com.songoda.ultimatemoderation.command.commands;
|
||||
package com.songoda.ultimatemoderation.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.AbstractCommand;
|
||||
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,12 +18,15 @@ import java.util.List;
|
|||
|
||||
public class CommandWarn extends AbstractCommand {
|
||||
|
||||
public CommandWarn() {
|
||||
super(false, true, "Warn");
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
public CommandWarn(UltimateModeration plugin) {
|
||||
super(CommandType.CONSOLE_OK, "Warn");
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length < 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
|
@ -45,8 +49,8 @@ public class CommandWarn extends AbstractCommand {
|
|||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(instance.getReferences().getPrefix() + "That player does not exist.");
|
||||
if (sender instanceof Player && VaultPermissions.hasPermission(player, "um.warning.exempt")) {
|
||||
plugin.getLocale().newMessage("You cannot warn that player.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
|
@ -57,7 +61,7 @@ public class CommandWarn extends AbstractCommand {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(UltimateModeration instance, CommandSender sender, String... args) {
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
if (args.length == 1) {
|
||||
List<String> players = new ArrayList<>();
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
@ -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,70 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.commands.CommandFreeze;
|
||||
import com.songoda.ultimatemoderation.command.commands.CommandRevive;
|
||||
import com.songoda.ultimatemoderation.command.commands.CommandSpy;
|
||||
import com.songoda.ultimatemoderation.utils.ServerVersion;
|
||||
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 GUIModerate extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
public GUIModerate(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.moderate.title", toModerate.getName()), 45);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
|
||||
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back"));
|
||||
|
||||
createButton(10, plugin.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"));
|
||||
createButton(12, Material.SADDLE, "&6&lSpy", "&7Spy on this player");
|
||||
createButton(14, Material.CHEST, "&c&lInventory", "&7Access this players Inventory.");
|
||||
createButton(16, Material.ENDER_CHEST, "&a&lEnderchest", "&7Access this players Enderchest");
|
||||
|
||||
createButton(28, plugin.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)));
|
||||
|
||||
registerClickable(10, ((player1, inventory1, cursor, slot, type) -> {
|
||||
CommandFreeze.freeze(toModerate, player);
|
||||
constructGUI();
|
||||
}));
|
||||
|
||||
registerClickable(12, ((player1, inventory1, cursor, slot, type) -> {
|
||||
CommandSpy.spy(toModerate, player);
|
||||
player.closeInventory();
|
||||
}));
|
||||
|
||||
registerClickable(14, ((player1, inventory1, cursor, slot, type) ->
|
||||
player.openInventory(toModerate.getPlayer().getInventory())));
|
||||
|
||||
registerClickable(16, ((player1, inventory1, cursor, slot, type) ->
|
||||
player.openInventory(toModerate.getPlayer().getEnderChest())));
|
||||
|
||||
registerClickable(28, ((player1, inventory1, cursor, slot, type) ->
|
||||
CommandRevive.revive(toModerate.getPlayer(), player)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
import com.songoda.ultimatemoderation.utils.AbstractChatConfirm;
|
||||
import com.songoda.ultimatemoderation.utils.ServerVersion;
|
||||
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 GUINotesManager extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
private final OfflinePlayer toModerate;
|
||||
|
||||
private int page = 0;
|
||||
|
||||
public GUINotesManager(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.notes.title", player.getName()), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, plugin.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"));
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page --;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (page != maxPage) {
|
||||
createButton(3, Material.ARROW, plugin.getLocale().getMessage("gui.general.next"));
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page ++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back"));
|
||||
|
||||
createButton(6, Material.REDSTONE, plugin.getLocale().getMessage("gui.notes.create"));
|
||||
|
||||
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", Bukkit.getOfflinePlayer(note.getAuthor()).getName()));
|
||||
lore.add(plugin.getLocale().getMessage("gui.notes.createdon", format.format(new Date(note.getCreationDate()))));
|
||||
lore.add(plugin.getLocale().getMessage("gui.notes.remove"));
|
||||
|
||||
createButton(18 + i, Material.MAP, name, lore);
|
||||
|
||||
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)));
|
||||
|
||||
registerClickable(6, ((player1, inventory1, cursor, slot, type) -> {
|
||||
player.sendMessage(plugin.getLocale().getMessage("gui.notes.type"));
|
||||
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,74 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.utils.ServerVersion;
|
||||
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;
|
||||
|
||||
public GUIPlayer(UltimateModeration plugin, OfflinePlayer toModerate, Player player) {
|
||||
super(player);
|
||||
this.plugin = plugin;
|
||||
this.toModerate = toModerate;
|
||||
|
||||
init(plugin.getLocale().getMessage("gui.player.title", toModerate.getName()), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
ItemStack head = new ItemStack(plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.PLAYER_HEAD : Material.valueOf("SKULL_ITEM"), 1, (byte) 3);
|
||||
SkullMeta meta = ((SkullMeta) head.getItemMeta());
|
||||
if (plugin.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, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back"));
|
||||
|
||||
createButton(38, Material.ANVIL, plugin.getLocale().getMessage("gui.player.punish"));
|
||||
createButton(30, Material.CHEST, plugin.getLocale().getMessage("gui.player.tickets"));
|
||||
if (player.isOnline())
|
||||
createButton(32, Material.DIAMOND_SWORD, plugin.getLocale().getMessage("gui.player.punishments"));
|
||||
createButton(42, Material.MAP, plugin.getLocale().getMessage("gui.player.notes"));
|
||||
createButton(40, Material.DIAMOND_CHESTPLATE, plugin.getLocale().getMessage("gui.player.moderate"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayers(plugin, player1)));
|
||||
|
||||
registerClickable(38, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPunish(plugin, toModerate, null, player1)));
|
||||
|
||||
registerClickable(30, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUITicketManager(plugin, toModerate, player1)));
|
||||
|
||||
registerClickable(32, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPunishments(plugin, toModerate, player1)));
|
||||
|
||||
registerClickable(42, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUINotesManager(plugin, toModerate, player1)));
|
||||
|
||||
registerClickable(40, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIModerate(plugin, toModerate, player1)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,205 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
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.ServerVersion;
|
||||
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"), 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"));
|
||||
registerClickable(46, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page --;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (maxPage != page) {
|
||||
createButton(48, Material.ARROW, plugin.getLocale().getMessage("gui.general.next"));
|
||||
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(plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.PLAYER_HEAD : Material.valueOf("SKULL_ITEM"), 1, (byte) 3);
|
||||
SkullMeta meta = ((SkullMeta) head.getItemMeta());
|
||||
if (plugin.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"));
|
||||
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"));
|
||||
else {
|
||||
if (ticketAmt == 1)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.ticketsone"));
|
||||
else
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.tickets",ticketAmt));
|
||||
}
|
||||
|
||||
int warningAmt = playerPunishData.getActivePunishments(PunishmentType.WARNING).size();
|
||||
|
||||
if (warningAmt == 0)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.nowarnings"));
|
||||
else {
|
||||
if (warningAmt == 1)
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.warningsone"));
|
||||
else
|
||||
lore.add(plugin.getLocale().getMessage("gui.players.warnings",warningAmt));
|
||||
}
|
||||
|
||||
|
||||
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, plugin.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"));
|
||||
createButton(47, Material.HOPPER, "&6" + currentOnline.getTranslation());
|
||||
|
||||
createButton(51, Material.CHEST, plugin.getLocale().getMessage("gui.players.button.tickets"));
|
||||
createButton(52, Material.MAP, plugin.getLocale().getMessage("gui.players.button.templatemanager"));
|
||||
}
|
||||
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
player.sendMessage(plugin.getLocale().getMessage("gui.players.nonefound"));
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
ItemStack item = new ItemStack(Material.PAPER);
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
meta.setDisplayName(plugin.getLocale().getMessage("gui.players.name"));
|
||||
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();
|
||||
}));
|
||||
|
||||
registerClickable(51, (player1, inventory1, cursor, slot, type) ->
|
||||
new GUITicketManager(plugin, null, player));
|
||||
|
||||
registerClickable(52, (player1, inventory1, cursor, slot, type) ->
|
||||
new GUITemplateManager(plugin, player));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
registerOnClose(((player1, inventory1) -> Bukkit.getScheduler().cancelTask(task)));
|
||||
}
|
||||
}
|
|
@ -1,298 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
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.ServerVersion;
|
||||
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")
|
||||
: plugin.getLocale().getMessage("gui.punish.title", toModerate.getName()), 45);
|
||||
if (toModerate != null) runTask();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
|
||||
if (toModerate != null) {
|
||||
ItemStack head = new ItemStack(plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.PLAYER_HEAD : Material.valueOf("SKULL_ITEM"), 1, (byte) 3);
|
||||
SkullMeta meta = ((SkullMeta) head.getItemMeta());
|
||||
if (plugin.isServerVersionAtLeast(ServerVersion.V1_13))
|
||||
meta.setOwningPlayer(toModerate);
|
||||
else
|
||||
meta.setOwner(toModerate.getName());
|
||||
head.setItemMeta(meta);
|
||||
|
||||
createButton(13, head, "&7&l" + toModerate.getName());
|
||||
}
|
||||
|
||||
createButton(22, Material.EMERALD_BLOCK, plugin.getLocale().getMessage("gui.punish.submit"));
|
||||
|
||||
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back"));
|
||||
|
||||
createButton(28, Material.ANVIL, plugin.getLocale().getMessage("gui.punish.type.punishment"),
|
||||
"&7" + type.getTranslation(),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.punishment.click"));
|
||||
|
||||
if (toModerate != null) {
|
||||
createButton(30, Material.MAP, plugin.getLocale().getMessage("gui.punish.type.template"),
|
||||
plugin.getLocale().getMessage("gui.punish.type.template.current",
|
||||
(template == null ? plugin.getLocale().getMessage("gui.general.none") : template.getTemplateName())),
|
||||
"",
|
||||
plugin.getLocale().getMessage(plugin.getTemplateManager().getTemplates().size() == 0 ? "gui.punish.type.template.none" : "gui.punish.type.template.click"));
|
||||
} else {
|
||||
createButton(30, Material.MAP, plugin.getLocale().getMessage("gui.punish.type.name"),
|
||||
plugin.getLocale().getMessage("gui.punish.type.name.current",
|
||||
(templateName == null ? plugin.getLocale().getMessage("gui.general.none") : templateName)),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.name.current.click"));
|
||||
}
|
||||
|
||||
if (type != PunishmentType.KICK) {
|
||||
createButton(32, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.CLOCK : Material.valueOf("WATCH"), plugin.getLocale().getMessage("gui.punish.type.duration"),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.leftclick"),
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.rightclick"),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.duration.current"),
|
||||
"&6" + (duration == -1 ? plugin.getLocale().getMessage("gui.general.permanent") : Methods.makeReadable(duration)));
|
||||
}
|
||||
|
||||
createButton(34, Material.PAPER, plugin.getLocale().getMessage("gui.punish.type.reason"),
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason.click"),
|
||||
"",
|
||||
plugin.getLocale().getMessage("gui.punish.type.reason.current"), "&6" + reason);
|
||||
}
|
||||
|
||||
private void notifyTemplate() {
|
||||
if (reason == null || duration == 0 || (justSaved && template != null)) {
|
||||
inventory.setItem(4, null);
|
||||
return;
|
||||
}
|
||||
|
||||
Material material = plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.WHITE_WOOL : Material.valueOf("WOOL");
|
||||
String name = plugin.getLocale().getMessage("gui.punish.template.create");
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.create2"));
|
||||
|
||||
if (!justSaved && template != null) {
|
||||
name = plugin.getLocale().getMessage("gui.punish.template.leftclick");
|
||||
lore.clear();
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.leftclick2", template.getTemplateName()));
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punish.template.rightclick"));
|
||||
}
|
||||
|
||||
if (plugin.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;
|
||||
|
||||
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") : reason);
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}));
|
||||
|
||||
registerClickable(22, ((player1, inventory1, cursor, slot, type1) -> {
|
||||
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"));
|
||||
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,108 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.template.Template;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.ServerVersion;
|
||||
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.ArrayList;
|
||||
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"), 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"));
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page --;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (page != maxPage) {
|
||||
createButton(5, Material.ARROW, plugin.getLocale().getMessage("gui.general.next"));
|
||||
registerClickable(5, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page ++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
createButton(3 ,Material.DIAMOND_SWORD, Methods.formatText("&6" + punishmentType.name()));
|
||||
|
||||
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back"));
|
||||
|
||||
createButton(7, Material.REDSTONE, plugin.getLocale().getMessage("gui.templatemanager.create"));
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, plugin.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"),
|
||||
plugin.getLocale().getMessage("gui.templatemanager.rightclick"));
|
||||
|
||||
registerClickable(18 + i, ((player1, inventory1, cursor, slot, type) -> {
|
||||
if (type == ClickType.LEFT) {
|
||||
new GUIPunish(plugin, null, template, player);
|
||||
} else if (type == ClickType.RIGHT) {
|
||||
plugin.getTemplateManager().removeTemplate(template.getUUID());
|
||||
constructGUI();
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerClickables() {
|
||||
registerClickable(8, ((player1, inventory1, cursor, slot, type) ->
|
||||
new GUIPlayers(plugin, player)));
|
||||
|
||||
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,64 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
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.ServerVersion;
|
||||
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"), 54);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back"));
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, plugin.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"));
|
||||
|
||||
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,150 +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.tickets.TicketStatus;
|
||||
import com.songoda.ultimatemoderation.utils.AbstractChatConfirm;
|
||||
import com.songoda.ultimatemoderation.utils.ServerVersion;
|
||||
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 GUITicket extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
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", ticket.getTicketId()), 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"));
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page --;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (page != maxPage) {
|
||||
createButton(3, Material.ARROW, plugin.getLocale().getMessage("gui.general.next"));
|
||||
registerClickable(3, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page ++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.ticket.openclose"))
|
||||
createButton(5, Material.REDSTONE, "&6" + ticket.getStatus().getStatus());
|
||||
|
||||
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back"));
|
||||
|
||||
if (player.hasPermission("um.ticket.clicktotele") && ticket.getLocation() != null)
|
||||
createButton(7, Material.REDSTONE, plugin.getLocale().getMessage("gui.ticket.clicktotele"));
|
||||
|
||||
createButton(6, Material.REDSTONE, plugin.getLocale().getMessage("gui.ticket.respond"));
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, plugin.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", Bukkit.getOfflinePlayer(ticketResponse.getAuthor()).getName() ));
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon", format.format(new Date(ticketResponse.getPostedDate()))));
|
||||
|
||||
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.ticket.clicktotele") && ticket.getLocation() != null) {
|
||||
registerClickable(7, ((player1, inventory1, cursor, slot, type) ->
|
||||
player.teleport(ticket.getLocation())));
|
||||
}
|
||||
|
||||
if (player.hasPermission("um.ticket.openclose")) {
|
||||
registerClickable(5, ((player1, inventory1, cursor, slot, type) -> {
|
||||
ticket.setStatus(ticket.getStatus() == TicketStatus.OPEN ? TicketStatus.CLOSED : TicketStatus.OPEN);
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
registerClickable(6, ((player1, inventory1, cursor, slot, type) -> {
|
||||
player.sendMessage(plugin.getLocale().getMessage("gui.ticket.what"));
|
||||
AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event2 -> {
|
||||
ticket.addResponse(new TicketResponse(player, event2.getMessage(), System.currentTimeMillis()));
|
||||
constructGUI();
|
||||
});
|
||||
|
||||
abstractChatConfirm.setOnClose(() ->
|
||||
init(setTitle, inventory.getSize()));
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
|
@ -1,169 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.gui;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentNote;
|
||||
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.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.ServerVersion;
|
||||
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", toModerate != null ? toModerate.getName() : ""), 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"));
|
||||
registerClickable(1, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page --;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
if (maxPage >= 36) {
|
||||
createButton(5, Material.ARROW, plugin.getLocale().getMessage("gui.general.next"));
|
||||
registerClickable(5, ((player1, inventory1, cursor, slot, type) -> {
|
||||
page ++;
|
||||
constructGUI();
|
||||
}));
|
||||
}
|
||||
|
||||
createButton(3 ,Material.DIAMOND_SWORD, Methods.formatText("&6" + status.getStatus()));
|
||||
|
||||
if (toModerate != null)
|
||||
createButton(7, Material.REDSTONE, plugin.getLocale().getMessage("gui.tickets.create"));
|
||||
|
||||
if (player.hasPermission("um.ticket"))
|
||||
createButton(8, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back"));
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
createButton(9 + i, plugin.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", ticket.getStatus().getStatus()));
|
||||
|
||||
if (toModerate != null)
|
||||
lore.add(plugin.getLocale().getMessage("gui.tickets.player", Bukkit.getOfflinePlayer(ticket.getVictim()).getName()));
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.type", ticket.getType()));
|
||||
lore.add(plugin.getLocale().getMessage("gui.ticket.createdon", format.format(new Date(ticket.getCreationDate()))));
|
||||
lore.add(plugin.getLocale().getMessage("gui.tickets.click"));
|
||||
|
||||
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) {
|
||||
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"));
|
||||
item.setItemMeta(meta);
|
||||
|
||||
gui.setSlot(AbstractAnvilGUI.AnvilSlot.INPUT_LEFT, item);
|
||||
gui.open();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void registerOnCloses() {
|
||||
}
|
||||
}
|
|
@ -1,65 +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.utils.settings.Setting;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class GUITicketType extends AbstractGUI {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
|
||||
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"), 27);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void constructGUI() {
|
||||
inventory.clear();
|
||||
resetClickables();
|
||||
registerClickables();
|
||||
|
||||
List<String> types = Setting.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"));
|
||||
AbstractChatConfirm abstractChatConfirm = new AbstractChatConfirm(player, event2 -> {
|
||||
plugin.getTicketManager().addTicket(ticket);
|
||||
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,25 +1,24 @@
|
|||
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.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.Punishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
import com.songoda.ultimatemoderation.tickets.TicketResponse;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.ServerVersion;
|
||||
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.omg.PortableInterceptor.ACTIVE;
|
||||
|
||||
import java.util.*;
|
||||
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;
|
||||
|
@ -27,21 +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", toModerate.getName()), 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);
|
||||
|
||||
|
@ -68,98 +86,77 @@ 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"));
|
||||
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"));
|
||||
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, plugin.isServerVersionAtLeast(ServerVersion.V1_13) ? Material.OAK_DOOR : Material.valueOf("WOOD_DOOR"), plugin.getLocale().getMessage("gui.general.back"));
|
||||
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, plugin.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();
|
||||
|
||||
ArrayList<String> lore = new ArrayList<>();
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.reason"));
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.reason").getMessage());
|
||||
lore.add("&7" + appliedPunishment.getReason());
|
||||
if (appliedPunishment.getPunishmentType() != PunishmentType.KICK) {
|
||||
lore.add("");
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.duration"));
|
||||
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"));
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.punisher").getMessage());
|
||||
lore.add("&7" + (appliedPunishment.getPunisher() == null ? "Console" : Bukkit.getOfflinePlayer(appliedPunishment.getPunisher()).getName()));
|
||||
if (activity == Activity.ACTIVE) {
|
||||
lore.add("");
|
||||
if (appliedPunishment.getDuration() != -1) {
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.remaining"));
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.remaining").getMessage());
|
||||
lore.add("&7" + Methods.makeReadable(appliedPunishment.getTimeRemaining()));
|
||||
lore.add("");
|
||||
}
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.click"));
|
||||
|
||||
registerClickable(currentSlot, ((player1, inventory1, cursor, slot, type) -> {
|
||||
appliedPunishment.expire();
|
||||
constructGUI();
|
||||
}));
|
||||
lore.add(plugin.getLocale().getMessage("gui.punishments.click").getMessage());
|
||||
}
|
||||
}
|
||||
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 {
|
||||
|
||||
|
@ -191,7 +188,7 @@ public class GUIPunishments extends AbstractGUI {
|
|||
}
|
||||
|
||||
public String getTranslation() {
|
||||
return UltimateModeration.getInstance().getLocale().getMessage("gui.punishments.activity." + this.name().toLowerCase());
|
||||
return UltimateModeration.getInstance().getLocale().getMessage("gui.punishments.activity." + this.name().toLowerCase()).getMessage();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
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 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())) 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.utils.settings.Setting;
|
||||
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,44 +38,52 @@ 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()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
long slowmode = slowModeOverride == 0 ? Methods.parseTime(Setting.SLOW_MODE.getString()) : slowModeOverride;
|
||||
public static boolean onChat(Player player, String message) {
|
||||
UltimateModeration instance = UltimateModeration.getInstance();
|
||||
|
||||
long slowmode = slowModeOverride == 0 ? Methods.parseTime(Settings.SLOW_MODE.getString()) : slowModeOverride;
|
||||
|
||||
if (!player.hasPermission("um.slowmode.bypass") && slowmode != 0) {
|
||||
List<Log> chats = chatLog.stream().filter(log -> log.player == player.getUniqueId()).collect(Collectors.toList());
|
||||
if (chats.size() != 0) {
|
||||
Log last = chats.get(chats.size() - 1);
|
||||
if ((System.currentTimeMillis() - last.sent) < slowmode) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isCancelled = false;
|
||||
|
||||
for (StaffChannel channel : instance.getStaffChatManager().getChats().values()) {
|
||||
if (!channel.listMembers().contains(player.getUniqueId())) continue;
|
||||
event.setCancelled(true);
|
||||
channel.processMessage(event.getMessage(), player);
|
||||
isCancelled = true;
|
||||
channel.processMessage(message, player);
|
||||
}
|
||||
|
||||
if (!isChatToggled && !player.hasPermission("um.togglechat.bypass")) {
|
||||
event.setCancelled(true);
|
||||
player.sendMessage(instance.getReferences().getPrefix() + Methods.formatText(instance.getLocale().getMessage("command.togglechat.muted")));
|
||||
isCancelled = true;
|
||||
instance.getLocale().getMessage("command.togglechat.muted").sendPrefixedMessage(player);
|
||||
}
|
||||
|
||||
List<AppliedPunishment> appliedPunishments = instance.getPunishmentManager().getPlayer(player).getActivePunishments(PunishmentType.MUTE);
|
||||
if (!appliedPunishments.isEmpty()) {
|
||||
appliedPunishments.get(0).sendMessage(player);
|
||||
event.setCancelled(true);
|
||||
isCancelled = true;
|
||||
}
|
||||
|
||||
|
||||
// Log chat.
|
||||
chatLog.add(new Log(player.getUniqueId(), System.currentTimeMillis(), event.getMessage()));
|
||||
chatLog.add(new Log(player.getUniqueId(), System.currentTimeMillis(), message));
|
||||
|
||||
return !isCancelled;
|
||||
}
|
||||
|
||||
public static void setSlowModeOverride(long slowModeOverride) {
|
||||
|
@ -83,7 +94,7 @@ public class ChatListener implements Listener {
|
|||
return new ArrayList<>(chatLog);
|
||||
}
|
||||
|
||||
public class Log {
|
||||
public static class Log {
|
||||
|
||||
private UUID player;
|
||||
private long sent;
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.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.utils.settings.Setting;
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
@ -30,13 +29,13 @@ public class CommandListener implements Listener {
|
|||
|
||||
List<AppliedPunishment> appliedPunishments = instance.getPunishmentManager().getPlayer(player).getActivePunishments(PunishmentType.MUTE);
|
||||
if (!appliedPunishments.isEmpty()) {
|
||||
if (Setting.MUTE_DISABLED_COMMANDS.getStringList().stream()
|
||||
if (Settings.MUTE_DISABLED_COMMANDS.getStringList().stream()
|
||||
.anyMatch(s -> command.toUpperCase().startsWith("/" + s.toUpperCase())))
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
List<String> blockedCommands = Setting.BLOCKED_COMMANDS.getStringList();
|
||||
List<String> blockedCommands = Settings.BLOCKED_COMMANDS.getStringList();
|
||||
|
||||
for (String cmd : blockedCommands) {
|
||||
if (command.toUpperCase().startsWith("/" + cmd.toUpperCase())
|
||||
|
@ -44,14 +43,17 @@ public class CommandListener implements Listener {
|
|||
&& !player.hasPermission("um.commandblock.bypass")) {
|
||||
event.setCancelled(true);
|
||||
event.setMessage("-");
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("event.command.blocked"));
|
||||
instance.getLocale().getMessage("event.command.blocked").sendPrefixedMessage(player);
|
||||
}
|
||||
}
|
||||
|
||||
if (!player.hasPermission("um.commandspy.immune")) {
|
||||
for (Player pl : Bukkit.getOnlinePlayers()) {
|
||||
if (pl.hasPermission("um.commandspy") && CommandCommandSpy.isSpying(pl))
|
||||
pl.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.commandspy.deny", player.getName(), StringEscapeUtils.escapeJava(command)));
|
||||
if (pl != player && pl.hasPermission("um.commandspy") && SpyModeration.isSpying(pl))
|
||||
instance.getLocale().getMessage("command.commandspy.deny")
|
||||
.processPlaceholder("player", player.getName())
|
||||
.processPlaceholder("command", command)
|
||||
.sendPrefixedMessage(pl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.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,9 +18,9 @@ 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);
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.freeze.nope"));
|
||||
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.command.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);
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.freeze.nope"));
|
||||
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.command.commands.CommandVanish;
|
||||
import com.songoda.ultimatemoderation.commands.CommandVanish;
|
||||
import com.songoda.ultimatemoderation.punish.AppliedPunishment;
|
||||
import com.songoda.ultimatemoderation.punish.PunishmentType;
|
||||
import com.songoda.ultimatemoderation.punish.player.PlayerPunishData;
|
||||
|
@ -32,9 +32,10 @@ public class LoginListener implements Listener {
|
|||
|
||||
AppliedPunishment appliedPunishment = playerPunishData.getActivePunishments(PunishmentType.BAN).get(0);
|
||||
|
||||
event.setKickMessage(instance.getLocale().getMessage("event.ban.message",
|
||||
appliedPunishment.getReason() == null ? "" : appliedPunishment.getReason(),
|
||||
Methods.makeReadable(appliedPunishment.getTimeRemaining())));
|
||||
event.setKickMessage(instance.getLocale().getMessage("event.ban.message")
|
||||
.processPlaceholder("reason", appliedPunishment.getReason() == null ? "" : appliedPunishment.getReason())
|
||||
.processPlaceholder("duration", Methods.makeReadable(appliedPunishment.getTimeRemaining())).getMessage());
|
||||
|
||||
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_BANNED);
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.commands.CommandVanish;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
|
||||
public class MobTargetLister implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onMobTagetEvent(EntityTargetLivingEntityEvent e) {
|
||||
if (!(e.getTarget() instanceof Player)) return;
|
||||
if (!(e.getEntity() instanceof Monster)) return;
|
||||
if (CommandVanish.isVanished(((Player) e.getTarget()).getPlayer())) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.command.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,9 +18,9 @@ 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);
|
||||
player.sendMessage(instance.getReferences().getPrefix() + instance.getLocale().getMessage("command.freeze.nope"));
|
||||
instance.getLocale().getMessage("command.freeze.nope").sendPrefixedMessage(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.skyblock.api.event.player.PlayerIslandChatEvent;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class SkyBlockListener implements Listener {
|
||||
|
||||
private UltimateModeration instance;
|
||||
|
||||
public SkyBlockListener(UltimateModeration ultimateModeration) {
|
||||
this.instance = ultimateModeration;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onIslandChat(PlayerIslandChatEvent event) {
|
||||
if (!ChatListener.onChat(event.getPlayer(), event.getMessage()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.songoda.ultimatemoderation.listeners;
|
||||
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.moderate.moderations.SpyModeration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.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 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 (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(), () -> {
|
||||
|
||||
if (player.getGameMode() == GameMode.SPECTATOR)
|
||||
player.setSpectatorTarget(event.getDismounted());
|
||||
}, 5L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onSneak(PlayerToggleSneakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.isSneaking() || !SpyModeration.isSpying(player) || player.getGameMode() != GameMode.SPECTATOR)
|
||||
return;
|
||||
SpyModeration.spy(null, 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
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 GenericModerationCommand extends AbstractCommand {
|
||||
|
||||
private final UltimateModeration plugin;
|
||||
private final AbstractModeration moderation;
|
||||
|
||||
public GenericModerationCommand(UltimateModeration plugin, AbstractModeration moderation) {
|
||||
super(moderation.isAllowConsole() ? CommandType.CONSOLE_OK : CommandType.PLAYER_ONLY, moderation.getProper());
|
||||
this.plugin = plugin;
|
||||
this.moderation = moderation;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 1)
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
||||
|
||||
if (!player.hasPlayedBefore()) {
|
||||
plugin.getLocale().newMessage("&cThis player has never played this server before...");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
moderation.runPreModeration(sender, player);
|
||||
|
||||
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 moderation.getPermission();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/" + moderation.getProper() + " <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
package com.songoda.ultimatemoderation.moderate.moderations;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
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.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SpyModeration extends AbstractModeration {
|
||||
|
||||
private static Map<UUID, Spy> spying = new HashMap<>();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean didVanish = false;
|
||||
if (!CommandVanish.isVanished(senderP)) {
|
||||
CommandVanish.vanish(senderP);
|
||||
senderP.setCanPickupItems(false);
|
||||
didVanish = true;
|
||||
}
|
||||
spying.put(senderP.getUniqueId(), new Spy(senderP.getLocation(), didVanish));
|
||||
|
||||
senderP.teleport(player.getPlayer().getLocation());
|
||||
|
||||
player.getPlayer().addPassenger(senderP);
|
||||
|
||||
instance.getLocale().getMessage("command.spy.success")
|
||||
.processPlaceholder("player", player.getName()).sendPrefixedMessage(senderP);
|
||||
}
|
||||
|
||||
public static class Spy {
|
||||
private Location lastLocation;
|
||||
private boolean vanishApplied;
|
||||
|
||||
public Spy(Location lastLocation, boolean vanishApplied) {
|
||||
this.lastLocation = lastLocation;
|
||||
this.vanishApplied = vanishApplied;
|
||||
}
|
||||
|
||||
public Location getLastLocation() {
|
||||
return lastLocation;
|
||||
}
|
||||
|
||||
public boolean isVanishApplied() {
|
||||
return 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,53 +3,49 @@ 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) {
|
||||
UltimateModeration plugin = UltimateModeration.getInstance();
|
||||
|
||||
if (!punisher.hasPermission("Um." + punishmentType)) {
|
||||
punisher.sendMessage(plugin.getReferences().getPrefix() + plugin.getLocale().getMessage("event.general.nopermission"));
|
||||
plugin.getLocale().getMessage("event.general.nopermission").sendPrefixedMessage(punisher);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -57,48 +53,56 @@ public class Punishment {
|
|||
switch (punishmentType) {
|
||||
case BAN:
|
||||
if (!playerPunishData.getActivePunishments(PunishmentType.BAN).isEmpty()) {
|
||||
punisher.sendMessage(plugin.getReferences().getPrefix()
|
||||
+ plugin.getLocale().getMessage("event.ban.already"));
|
||||
plugin.getLocale().getMessage("event.ban.already").sendPrefixedMessage(punisher);
|
||||
return;
|
||||
}
|
||||
if (victim.isOnline()) {
|
||||
victim.getPlayer().kickPlayer(plugin.getLocale().getMessage("event.ban.message",
|
||||
reason == null ? "" : reason,
|
||||
Methods.makeReadable(duration)));
|
||||
}
|
||||
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()));
|
||||
break;
|
||||
case MUTE:
|
||||
if (!playerPunishData.getActivePunishments(PunishmentType.MUTE).isEmpty()) {
|
||||
punisher.sendMessage(plugin.getReferences().getPrefix()
|
||||
+ plugin.getLocale().getMessage("event.mute.already"));
|
||||
plugin.getLocale().getMessage("event.mute.already").sendPrefixedMessage(punisher);
|
||||
return;
|
||||
}
|
||||
sendMessage(victim);
|
||||
break;
|
||||
case KICK:
|
||||
if (victim.isOnline()) {
|
||||
victim.getPlayer().kickPlayer(plugin.getLocale().getMessage("event.kick.message",
|
||||
reason == null ? "" : reason,
|
||||
Methods.makeReadable(duration)));
|
||||
}
|
||||
if (victim.isOnline())
|
||||
Bukkit.getScheduler().runTask(plugin, () -> victim.getPlayer().kickPlayer(plugin.getLocale()
|
||||
.getMessage("event.kick.message")
|
||||
.processPlaceholder("reason", reason == null ? "" : reason).getMessage()));
|
||||
break;
|
||||
case WARNING:
|
||||
sendMessage(victim);
|
||||
break;
|
||||
}
|
||||
|
||||
String punishSuccess = plugin.getReferences().getPrefix()
|
||||
+ plugin.getLocale().getMessage("event." + punishmentType.name().toLowerCase() + ".success", victim.getName());
|
||||
String punishSuccess = plugin.getLocale()
|
||||
.getMessage("event." + punishmentType.name().toLowerCase() + ".success")
|
||||
.processPlaceholder("player", victim.getName())
|
||||
.getPrefixedMessage();
|
||||
|
||||
if (reason != null)
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.reason", reason);
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.reason")
|
||||
.processPlaceholder("reason", reason).getMessage();
|
||||
|
||||
if (duration != -1)
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.theirduration", Methods.makeReadable(duration));
|
||||
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) {
|
||||
|
@ -106,20 +110,26 @@ public class Punishment {
|
|||
Player victim = offlineVictim.getPlayer();
|
||||
UltimateModeration plugin = UltimateModeration.getInstance();
|
||||
|
||||
String punishSuccess = plugin.getReferences().getPrefix()
|
||||
+ plugin.getLocale().getMessage("event." + punishmentType.name().toLowerCase() + ".message");
|
||||
String punishSuccess = plugin.getLocale()
|
||||
.getMessage("event." + punishmentType.name().toLowerCase() + ".message").getPrefixedMessage();
|
||||
|
||||
if (reason != null)
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.reason", reason);
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.reason")
|
||||
.processPlaceholder("reason", reason).getMessage();
|
||||
|
||||
if (duration != -1)
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.yourduration", Methods.makeReadable(duration));
|
||||
punishSuccess += plugin.getLocale().getMessage("event.punish.yourduration")
|
||||
.processPlaceholder("duration", Methods.makeReadable(duration)).getMessage();
|
||||
|
||||
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() {
|
||||
|
@ -136,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() {
|
||||
|
|
|
@ -22,6 +22,6 @@ public enum PunishmentType {
|
|||
}
|
||||
|
||||
public String getTranslation() {
|
||||
return UltimateModeration.getInstance().getLocale().getMessage("gui.punishmenttypes." + this.name().toLowerCase());
|
||||
return UltimateModeration.getInstance().getLocale().getMessage("gui.punishmenttypes." + this.name().toLowerCase()).getMessage();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,87 @@
|
|||
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.ultimatemoderation.UltimateModeration;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Settings {
|
||||
|
||||
static final Config config = UltimateModeration.getInstance().getCoreConfig();
|
||||
|
||||
public static final ConfigSetting VANISH_EFFECTS = new ConfigSetting(config, "Main.Enable Vanish Effects", true,
|
||||
"Show particles and play sound when going in and out of vanish.");
|
||||
|
||||
public static final ConfigSetting VANISH_SOUND = new ConfigSetting(config, "Main.Vanish Sound", "ENTITY_GENERIC_EXPLODE",
|
||||
"Sound to be played when going into vanish.");
|
||||
|
||||
public static final ConfigSetting VANISH_BATS = new ConfigSetting(config, "Main.Release Bats On Vanish", true,
|
||||
"Shows bats when entering vanish.");
|
||||
|
||||
public static final ConfigSetting VANISH_PARTICLE = new ConfigSetting(config, "Main.Vanish Particle", "EXPLOSION_NORMAL",
|
||||
"Show particles when entering vanish.");
|
||||
|
||||
public static final ConfigSetting SLOW_MODE = new ConfigSetting(config, "Main.SLOW_MODE", "0s",
|
||||
"Limits how often a player can send a chat message by the corresponding amount.");
|
||||
|
||||
public static final ConfigSetting BLOCKED_COMMANDS = new ConfigSetting(config, "Main.Blocked Commands", Arrays.asList("Fly", "Op", "Plugins", "Pl"),
|
||||
"Prevents players from running the specified commands.");
|
||||
|
||||
public static final ConfigSetting AUTOSAVE = new ConfigSetting(config, "Main.Auto Save Interval In Seconds", 15,
|
||||
"The amount of time in between saving to file.",
|
||||
"This is purely a safety function to prevent against unplanned crashes or",
|
||||
"restarts. With that said it is advised to keep this enabled.",
|
||||
"If however you enjoy living on the edge, feel free to turn it off.");
|
||||
|
||||
public static final ConfigSetting STAFFCHAT_COLOR_CODE = new ConfigSetting(config, "Main.Staff Chat Color Code", 'b',
|
||||
"Color of messages sent in staff chat.");
|
||||
|
||||
public static final ConfigSetting TICKET_TYPES = new ConfigSetting(config, "Main.Ticket Types", Arrays.asList("Grief", "Player Report", "Bug Report", "Suggestion", "Other"),
|
||||
"Types of tickets players can open.");
|
||||
|
||||
public static final ConfigSetting MUTE_DISABLED_COMMANDS = new ConfigSetting(config, "Main.Mute Disabled Commands", Arrays.asList("minecraft:me", "minecraft:tell"),
|
||||
"Commands disabled when a player is muted.");
|
||||
|
||||
public static final ConfigSetting GLASS_TYPE_1 = new ConfigSetting(config, "Interfaces.Glass Type 1", "GRAY_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GLASS_TYPE_2 = new ConfigSetting(config, "Interfaces.Glass Type 2", "BLUE_STAINED_GLASS_PANE");
|
||||
public static final ConfigSetting GLASS_TYPE_3 = new ConfigSetting(config, "Interfaces.Glass Type 3", "LIGHT_BLUE_STAINED_GLASS_PANE");
|
||||
|
||||
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);
|
||||
|
||||
// convert glass pane settings
|
||||
int color;
|
||||
if ((color = GLASS_TYPE_1.getInt(-1)) != -1) {
|
||||
config.set(GLASS_TYPE_1.getKey(), CompatibleMaterial.getGlassPaneColor(color).name());
|
||||
}
|
||||
if ((color = GLASS_TYPE_2.getInt(-1)) != -1) {
|
||||
config.set(GLASS_TYPE_2.getKey(), CompatibleMaterial.getGlassPaneColor(color).name());
|
||||
}
|
||||
if ((color = GLASS_TYPE_3.getInt(-1)) != -1) {
|
||||
config.set(GLASS_TYPE_3.getKey(), CompatibleMaterial.getGlassPaneColor(color).name());
|
||||
}
|
||||
|
||||
config.saveChanges();
|
||||
}
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
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.utils.settings.Setting;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
@ -13,7 +13,7 @@ import java.util.UUID;
|
|||
public class StaffChannel {
|
||||
|
||||
private final String channelName;
|
||||
private char chatChar = Setting.STAFFCHAT_COLOR_CODE.getChar();
|
||||
private char chatChar = Settings.STAFFCHAT_COLOR_CODE.getChar();
|
||||
private final List<UUID> members = new ArrayList<>();
|
||||
private final List<String> chatLog = new ArrayList<>();
|
||||
|
||||
|
@ -27,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);
|
||||
|
@ -36,21 +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", chatChar, channelName, player.getDisplayName()));
|
||||
}
|
||||
|
||||
public void removeMember(Player player) {
|
||||
members.remove(player.getUniqueId());
|
||||
messageAll(UltimateModeration.getInstance().getLocale().getMessage("event.staffchat.format.leave", chatChar, channelName, player.getDisplayName()));
|
||||
messageAll(UltimateModeration.getInstance().getLocale()
|
||||
.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", chatChar, channelName, player.getDisplayName(), chatChar, message));
|
||||
messageAll(UltimateModeration.getInstance().getLocale()
|
||||
.getMessage("event.staffchat.format")
|
||||
.processPlaceholder("color", chatChar)
|
||||
.processPlaceholder("channel", channelName)
|
||||
.processPlaceholder("player", player.getDisplayName())
|
||||
.processPlaceholder("message", message).getMessage());
|
||||
}
|
||||
|
||||
private void messageAll(String message) {
|
||||
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,95 +0,0 @@
|
|||
package com.songoda.ultimatemoderation.storage;
|
||||
|
||||
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.tickets.TicketStatus;
|
||||
import com.songoda.ultimatemoderation.utils.ConfigWrapper;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public abstract class Storage {
|
||||
|
||||
protected final UltimateModeration instance;
|
||||
protected final ConfigWrapper dataFile;
|
||||
|
||||
public Storage(UltimateModeration instance) {
|
||||
this.instance = instance;
|
||||
this.dataFile = new ConfigWrapper(instance, "", "data.yml");
|
||||
this.dataFile.createNewFile(null, "UltimateModeration Data File");
|
||||
this.dataFile.getConfig().options().copyDefaults(true);
|
||||
this.dataFile.saveConfig();
|
||||
}
|
||||
|
||||
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().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,195 +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 com.songoda.ultimatemoderation.utils.MySQLDatabase;
|
||||
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class StorageMysql extends Storage {
|
||||
|
||||
private static Map<String, StorageItem[]> toSave = new HashMap<>();
|
||||
private static Map<String, StorageItem[]> lastSave = new HashMap<>();
|
||||
private MySQLDatabase database;
|
||||
|
||||
public StorageMysql(UltimateModeration instance) {
|
||||
super(instance);
|
||||
this.database = new MySQLDatabase(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsGroup(String group) {
|
||||
try {
|
||||
DatabaseMetaData dbm = database.getConnection().getMetaData();
|
||||
ResultSet rs = dbm.getTables(null, null, instance.getConfig().getString("Database.Prefix") + group, null);
|
||||
if (rs.next()) {
|
||||
return true;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageRow> getRowsByGroup(String group) {
|
||||
List<StorageRow> rows = new ArrayList<>();
|
||||
try {
|
||||
ResultSet set = database.getConnection().createStatement().executeQuery(String.format("SELECT * FROM `" + instance.getConfig().getString("Database.Prefix") + "%s`", group));
|
||||
while (set.next()) {
|
||||
Map<String, StorageItem> items = new HashMap<>();
|
||||
|
||||
String key = set.getString(1);
|
||||
for (int i = 2; i <= set.getMetaData().getColumnCount(); i++) {
|
||||
if (set.getObject(i) == null || set.getObject(i) == "") continue;
|
||||
StorageItem item = new StorageItem(set.getObject(i));
|
||||
items.put(set.getMetaData().getColumnName(i), item);
|
||||
}
|
||||
StorageRow row = new StorageRow(key, items);
|
||||
rows.add(row);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prepareSaveItem(String group, StorageItem... items) {
|
||||
toSave.put(group + "]" + items[0].asObject().toString(), items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSave() {
|
||||
this.updateData(instance);
|
||||
if (toSave.isEmpty()) return;
|
||||
Map<String, StorageItem[]> nextSave = new HashMap<>(toSave);
|
||||
|
||||
if (lastSave.isEmpty())
|
||||
lastSave.putAll(toSave);
|
||||
|
||||
this.makeBackup();
|
||||
this.save();
|
||||
|
||||
toSave.clear();
|
||||
lastSave.clear();
|
||||
lastSave.putAll(nextSave);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
try {
|
||||
Statement stmt = database.getConnection().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
|
||||
|
||||
last:
|
||||
for (Map.Entry<String, StorageItem[]> last : lastSave.entrySet()) {
|
||||
String lastKey = last.getKey().split("]")[0];
|
||||
String lastValue = last.getValue()[0].asObject().toString();
|
||||
|
||||
for (Map.Entry<String, StorageItem[]> to : toSave.entrySet()) {
|
||||
String toKey = to.getKey().split("]")[0];
|
||||
if (!toKey.equals(lastKey)
|
||||
|| !to.getValue()[0].asObject().equals(lastValue)
|
||||
|| to.getValue().length != last.getValue().length)
|
||||
continue;
|
||||
toSave.remove(toKey);
|
||||
for (int i = 0; i < to.getValue().length - 1; i ++) {
|
||||
if (to.getValue()[i].asObject() != null
|
||||
&& !to.getValue()[i].asObject().toString()
|
||||
.equals(last.getValue()[i].asObject().toString())) {
|
||||
//Update
|
||||
StorageItem[] items = to.getValue();
|
||||
StringBuilder sql = new StringBuilder(String.format("UPDATE `" + instance.getConfig().getString("Database.Prefix") + "%s`", toKey));
|
||||
|
||||
sql.append(" SET");
|
||||
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
String key = item.getKey().split("]")[0];
|
||||
sql.append(String.format("`%s` = '%s', ", key, item.asObject().toString()));
|
||||
}
|
||||
|
||||
sql = new StringBuilder(sql.substring(0, sql.length() - 2));
|
||||
|
||||
sql.append(String.format(" WHERE `%s`='%s'", last.getValue()[0].getKey(), last.getValue()[0].asObject().toString()));
|
||||
|
||||
stmt.addBatch(sql.toString());
|
||||
|
||||
continue last;
|
||||
}
|
||||
}
|
||||
// Already up to date.
|
||||
|
||||
continue last;
|
||||
}
|
||||
//Was not found delete.
|
||||
StringBuilder sql = new StringBuilder(String.format("DELETE FROM `" + instance.getConfig().getString("Database.Prefix") + "%s`", lastKey));
|
||||
sql.append(String.format(" WHERE `%s`='%s'", last.getValue()[0].getKey(), last.getValue()[0].asObject().toString()));
|
||||
stmt.addBatch(sql.toString());
|
||||
|
||||
}
|
||||
|
||||
for (Map.Entry<String, StorageItem[]> to : toSave.entrySet()) {
|
||||
String toKey = to.getKey().split("]")[0];
|
||||
//Add
|
||||
StorageItem[] items = to.getValue();
|
||||
StringBuilder sql = new StringBuilder(String.format("INSERT INTO `" + instance.getConfig().getString("Database.Prefix") + "%s`", toKey));
|
||||
|
||||
sql.append(" (");
|
||||
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
String key = item.getKey().split("]")[0];
|
||||
sql.append(String.format("`%s`, ", key));
|
||||
}
|
||||
|
||||
sql = new StringBuilder(sql.substring(0, sql.length() - 2));
|
||||
|
||||
sql.append(") VALUES (");
|
||||
|
||||
for (StorageItem item : items) {
|
||||
if (item == null || item.asObject() == null) continue;
|
||||
sql.append(String.format("'%s', ", item.asObject().toString()));
|
||||
}
|
||||
|
||||
sql = new StringBuilder(sql.substring(0, sql.length() - 2));
|
||||
|
||||
sql.append(");");
|
||||
|
||||
stmt.addBatch(sql.toString());
|
||||
}
|
||||
|
||||
stmt.executeBatch();
|
||||
|
||||
toSave.clear();
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeBackup() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeConnection() {
|
||||
try {
|
||||
database.getConnection().close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,147 +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 static final Map<String, Object> toSave = new HashMap<>();
|
||||
private static final Map<String, Object> lastSave = new HashMap<>();
|
||||
|
||||
public StorageYaml(UltimateModeration instance) {
|
||||
super(instance);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsGroup(String group) {
|
||||
return dataFile.getConfig().contains("data." + group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StorageRow> getRowsByGroup(String group) {
|
||||
List<StorageRow> rows = new ArrayList<>();
|
||||
ConfigurationSection currentSection = dataFile.getConfig().getConfigurationSection("data." + group);
|
||||
for (String key : currentSection.getKeys(false)) {
|
||||
|
||||
Map<String, StorageItem> items = new HashMap<>();
|
||||
ConfigurationSection currentSection2 = dataFile.getConfig().getConfigurationSection("data." + group + "." + key);
|
||||
for (String key2 : currentSection2.getKeys(false)) {
|
||||
String path = "data." + group + "." + key + "." + key2;
|
||||
items.put(key2, new StorageItem(dataFile.getConfig().get(path) instanceof MemorySection
|
||||
? convertToInLineList(path) : dataFile.getConfig().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.getConfig().getConfigurationSection(path).getKeys(false)) {
|
||||
converted.append(key).append(":").append(dataFile.getConfig().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].asObject()+ "." + item.getKey(), item.asObject());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doSave() {
|
||||
this.updateData(instance);
|
||||
if (toSave.isEmpty()) return;
|
||||
Map<String, Object> nextSave = new HashMap<>(toSave);
|
||||
|
||||
if (lastSave.isEmpty())
|
||||
lastSave.putAll(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.getConfig().set(entry.getKey(), entry.getValue());
|
||||
}
|
||||
toSave.remove(newValue);
|
||||
} else {
|
||||
dataFile.getConfig().set(entry.getKey(), null);
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Object> entry : toSave.entrySet()) {
|
||||
dataFile.getConfig().set(entry.getKey(), entry.getValue());
|
||||
}
|
||||
|
||||
dataFile.saveConfig();
|
||||
} catch (NullPointerException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void makeBackup() {
|
||||
File data = new File(instance.getDataFolder(), "data.yml");
|
||||
File dataClone = new File(instance.getDataFolder(), "data-backup-" + System.currentTimeMillis() + ".yml");
|
||||
try {
|
||||
copyFile(data, dataClone);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Deque<File> backups = new ArrayDeque<>();
|
||||
for (File file : Objects.requireNonNull(instance.getDataFolder().listFiles())) {
|
||||
if (file.getName().toLowerCase().contains("data-backup")) {
|
||||
backups.add(file);
|
||||
}
|
||||
}
|
||||
if (backups.size() > 3) {
|
||||
backups.getFirst().delete();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeConnection() {
|
||||
dataFile.saveConfig();
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package com.songoda.ultimatemoderation.tasks;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.UltimateModeration;
|
||||
import com.songoda.ultimatemoderation.listeners.ChatListener;
|
||||
import com.songoda.ultimatemoderation.settings.Settings;
|
||||
import com.songoda.ultimatemoderation.utils.Methods;
|
||||
import com.songoda.ultimatemoderation.utils.ServerVersion;
|
||||
import com.songoda.ultimatemoderation.utils.settings.Setting;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -34,7 +34,7 @@ public class SlowModeTask extends BukkitRunnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
long slowmode = ChatListener.getSlowModeOverride() == 0 ? Methods.parseTime(Setting.SLOW_MODE.getString()) : ChatListener.getSlowModeOverride();
|
||||
long slowmode = ChatListener.getSlowModeOverride() == 0 ? Methods.parseTime(Settings.SLOW_MODE.getString()) : ChatListener.getSlowModeOverride();
|
||||
|
||||
if (slowmode == 0) return;
|
||||
|
||||
|
@ -48,9 +48,11 @@ public class SlowModeTask extends BukkitRunnable {
|
|||
ChatListener.Log last = chats.get(chats.size() - 1);
|
||||
|
||||
if ((System.currentTimeMillis() - last.getSent()) < (slowmode + 1000)) {
|
||||
int remaining = (int)((slowmode / 1000) - (System.currentTimeMillis() - last.getSent()) / 1000);
|
||||
if (plugin.isServerVersionAtLeast(ServerVersion.V1_9))
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(remaining == 0 ? plugin.getLocale().getMessage("event.slowmode.done") : plugin.getLocale().getMessage("event.slowmode.wait", remaining)));
|
||||
int remaining = (int) ((slowmode / 1000) - (System.currentTimeMillis() - last.getSent()) / 1000);
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9))
|
||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(remaining == 0
|
||||
? plugin.getLocale().getMessage("event.slowmode.done").getMessage()
|
||||
: plugin.getLocale().getMessage("event.slowmode.wait").processPlaceholder("delay", remaining).getMessage()));
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue