Compare commits

..
18 Commits
Author SHA1 Message Date
Edson Passos d892b03142 Bump version 2021-03-16 19:44:31 -03:00
Edson PassosandMinat0_ 105ed018b1 v2.15.1 (#145)
Updated messages
Add event for deleting a rank
Fixes InventoryOpenEvent on older versions
Fixed players without rank unable to send chat messages

Co-authored-by: Minat0_ <42711312+Tomut0@users.noreply.github.com>
2021-03-16 19:39:00 -03:00
Edson Passos 53296485e8 Update Crowdin configuration file 2021-03-06 00:07:26 -03:00
Edson Passos 3f4fe0429f Update Crowdin configuration file 2021-03-06 00:00:16 -03:00
Edson Passos 31389485fd Deleted test action 2021-03-05 23:23:34 -03:00
Edson Passos c84f88b607 Fixed wrong path in publish action 2021-03-05 23:20:53 -03:00
Edson Passos a3cee92371 Update test_curseforge.yml 2021-03-05 22:54:52 -03:00
Edson Passos 8ae79e6b3d Testing curse forge action 2021-03-05 22:42:39 -03:00
Edson Passos 93fb4eafd4 Attemps to fix publish_curseforge action 2021-03-05 22:39:22 -03:00
RoinujNosde 5f2c20fe13 Deleted bintray action
Updated readme with new repo
2021-03-05 22:16:09 -03:00
Edson Passos 27b81f00d1 v2.15.0 (#132)
Added War and protection
Added clan color placeholder (#130)
Refactored flags
Fixed invitation message being sent even after invited created clan
Probably fixed exception thrown when two players modify the same part of the Clan via GUI
Fixed inverted bypass permission
Fixed allowDeposit and allowWithdraw not saving to db #125
2021-03-05 21:31:19 -03:00
RoinujNosde 0d0ad0a73f Changes maven repo to CodeMC 2021-03-05 20:50:40 -03:00
Edson Passos 7f20cd47f2 Renamed bintray action 2021-02-16 20:22:00 -03:00
Edson Passos ddabe9f86e Creates action to publish to CurseForge 2021-02-16 20:19:27 -03:00
Edson Passos 22cee2c494 Create LICENSE 2021-02-15 18:55:45 -03:00
Edson Passos 4f74885e8f v2.14.7 (#122)
Fixes wrapping long colored strings/words
Fixes kicking players via GUI
Probably fixes purge message
Fixes clickable accept and deny not working on translated configs
Refactored PAPI Expansion
Fixes RGB colors on BB
Fixes next button on some frames
Probably fixes placeholder not found warning
Ignore comments when loading translation status
Stores clan home location x, y and z as double
Stops wrapping messages to fit in one line
Players with bypass permission can view the profile/roster of non-verified clans
Adds kick command for moderators
Allows the removal of lines from lore
Adds debug messages to permission checks and deaths
Added topplayers placeholder
2021-02-08 20:46:35 -03:00
Edson Passos c4a253efb7 v2.14.6 (#115)
Adds delay for PvP denied messages #106
Adds 60 seconds timeout for conversations
Adds message for admin promote success
Adds Default Ranks #110
Adds warning about LuckPerms and auto-group-groupname
Warns when moving the last leader from a clan #94
PlayerDetailsFrame now gets the nickname from ClanPlayer to avoid rare cases where the player data file was deleted
Updated StaffFrame to reflect command changes #114
Fixes parsing large colored strings on wordWrap
Fixes clickable messages on <=1.12
Updated language files
2021-01-03 12:31:44 -03:00
Edson Passos f34b947e59 v2.14.5 (#108)
Adds clickable messages (accept and deny)
Added support to RGB colors
Added modtag for staff
Request messages are now 100% customizable
Moved mod commands to subcommand "mod"
Clan home now saves yaw and pitch
Fixed {clan} showing on chat when not in clan
Shows status "in rank" for untrusted players
Increased color_tag column size to 255
2020-12-17 20:19:11 -03:00
170 changed files with 6360 additions and 3581 deletions

No files matched your search

Binary file not shown.

Before

Width:  |  Height:  |  Size: 418 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 MiB

-29
View File
@@ -1,29 +0,0 @@
name: Publish to Bintray (Spigot 1.13+)
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
server-id: bintray-roinujnosde-bukkit-plugins # Value of the distributionManagement/repository/id field of the pom.xml
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Publish to Bintray
run: mvn -B deploy
env:
MAVEN_USERNAME: ${{ secrets.BINTRAY_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.BINTRAY_TOKEN }}
+1 -3
View File
@@ -22,10 +22,8 @@ jobs:
java-version: 1.8
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Create Staging
run: mkdir staging && cp target/SimpleClans.jar staging
- name: Upload a Build Artifact
uses: actions/upload-artifact@v2
with:
name: SimpleClans
path: staging
path: target/SimpleClans.jar
+29
View File
@@ -0,0 +1,29 @@
name: Publish to CurseForge
on:
release:
types: [created]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Upload artifact
uses: itsmeow/curseforge-upload@v3
with:
token: ${{ secrets.CURSEFORGE_TOKEN }}
project_id: 380814
game_endpoint: minecraft
file_path: target/SimpleClans.jar
changelog: ${{ github.event.release.body }}
display_name: ${{ github.event.release.tag_name }}
game_versions: 7915,7667,7330,7105,6588,630,591,585,531
release_type: release
relations: vault:optionalDependency,worldguard:optionalDependency,grief-prevention:optionalDependency
+674
View File
@@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.
+9 -8
View File
@@ -1,4 +1,4 @@
[![SimpleClans Logo](https://i.imgur.com/Z8XWayV.png)](https://www.spigotmc.org/resources/simpleclans.71242/)
[![SimpleClans Logo](https://i.imgur.com/9vgfVdX.png)](https://www.spigotmc.org/resources/simpleclans.71242/)
SimpleClans
==========
@@ -50,15 +50,17 @@ Including SimpleClans with Maven:
```xml
<repositories>
<repository>
<id>bintray-roinujnosde-bukkit-plugins</id>
<url>https://dl.bintray.com/roinujnosde/bukkit-plugins</url>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
</repositories>
```
```xml
<dependencies>
<dependency>
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
<artifactId>SimpleClans</artifactId>
<version>2.14.3</version> <!-- You can find the latest version at the bottom -->
<version>2.15.0</version> <!-- You can find the latest version at the bottom -->
<scope>provided</scope>
</dependency>
</dependencies>
@@ -68,16 +70,15 @@ Using Gradle:
```groovy
repositories {
maven {
url "https://dl.bintray.com/roinujnosde/bukkit-plugins"
url "https://repo.codemc.org/repository/maven-public"
}
}
dependencies {
compileOnly "net.sacredlabyrinth.phaed.simpleclans:SimpleClans:2.14.3" // You can find the latest version at the bottom
compileOnly "net.sacredlabyrinth.phaed.simpleclans:SimpleClans:2.15.0"
}
```
##### Latest version:
[![Bintray](https://img.shields.io/bintray/v/roinujnosde/bukkit-plugins/SimpleClans)](https://bintray.com/roinujnosde/bukkit-plugins/SimpleClans/_latestVersion)
[![](https://jitpack.io/v/roinujnosde/simpleclans.svg?label=Maven)]()
##### API Examples
* [Examples of how to use the API](https://simpleclans.gitbook.io/simpleclans/other/simpleclans-api)
+183 -3
View File
@@ -1,5 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
@@ -11,12 +20,126 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.13.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-default_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.13.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-http:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-spec:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-annotations:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:3.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-cio:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-io:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-services:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-logging:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.inject:javax.inject:1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.5.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.4.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:jcl-over-slf4j:1.7.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-odf:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zipdriver:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bouncycastle:bcprov-jdk15on:1.63" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-tardriver:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-bzip2:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-gzip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-xz:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.tukaani:xz:1.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip-raes:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-base_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access-swing:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-file:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-jar:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-ibm437:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-impl_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-console:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-default:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-swing:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-macosx:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-spec:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-shed:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.dev.jna:jna:4.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mozilla:rhino-runtime:1.7.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.26" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TechFortress:GriefPrevention:16.17.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-default_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.13.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-http:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-spec:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-annotations:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:3.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-cio:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-io:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-services:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-logging:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.inject:javax.inject:1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.5.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.4.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:jcl-over-slf4j:1.7.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-odf:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zipdriver:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bouncycastle:bcprov-jdk15on:1.63" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-tardriver:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-bzip2:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-gzip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-xz:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.tukaani:xz:1.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip-raes:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-base_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access-swing:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-file:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-jar:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-ibm437:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-impl_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-console:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-default:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-swing:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-macosx:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-spec:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-shed:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.dev.jna:jna:4.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mozilla:rhino-runtime:1.7.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.26" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TechFortress:GriefPrevention:16.17.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.23" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.MilkBowl:VaultAPI:1.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
@@ -34,5 +157,62 @@
<orderEntry type="library" scope="TEST" name="Maven: org.apiguardian:apiguardian-api:1.0.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.opentest4j:opentest4j:1.1.1" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.junit.platform:junit-platform-commons:1.4.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.4" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.2.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-default_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.13.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-http:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-spec:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-annotations:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:3.0.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-cio:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-io:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-services:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-logging:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.inject:javax.inject:1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.5.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.4.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-codec:commons-codec:1.11" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:jcl-over-slf4j:1.7.28" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-odf:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zipdriver:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bouncycastle:bcprov-jdk15on:1.63" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-tardriver:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-bzip2:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-gzip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-xz:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.tukaani:xz:1.8" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip-raes:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-base_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access-swing:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-file:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-jar:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-ibm437:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-impl_2.13:0.12.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-console:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-default:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-swing:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-macosx:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-spec:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-shed:2.5.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.dev.jna:jna:4.1.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mozilla:rhino-runtime:1.7.12" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:1.3.9" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.26" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TechFortress:GriefPrevention:16.17.1" level="project" />
</component>
</module>
+3
View File
@@ -0,0 +1,3 @@
files:
- source: src/main/resources/messages.properties
translation: /src/main/resources/%file_name%_%locale_with_underscore%.%file_extension%
+36 -12
View File
@@ -4,18 +4,8 @@
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
<artifactId>SimpleClans</artifactId>
<name>SimpleClans</name>
<version>2.14.3</version>
<version>2.14.7</version>
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
<ciManagement>
<system>jenkins</system>
<url>http://104.236.246.108:8080</url>
</ciManagement>
<scm>
<connection>scm:git:git:@github.com:marcelo-mason/SimpleClans.git</connection>
<developerConnection>scm:git:git:@github.com:marcelo-mason/SimpleClans.git</developerConnection>
<tag>SimpleClans</tag>
<url>http://github.com/marcelo-mason/SimpleClans.git/tree/master/</url>
</scm>
<build>
<resources>
<resource>
@@ -125,12 +115,16 @@
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
@@ -211,6 +205,36 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.4</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>worldedit-bukkit</artifactId>
<groupId>com.sk89q.worldedit</groupId>
</exclusion>
<exclusion>
<artifactId>worldguard-core</artifactId>
<groupId>com.sk89q.worldguard</groupId>
</exclusion>
<exclusion>
<artifactId>commandbook</artifactId>
<groupId>com.sk89q</groupId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.TechFortress</groupId>
<artifactId>GriefPrevention</artifactId>
<version>16.17.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<distributionManagement>
<repository>
+1 -1
View File
@@ -1,7 +1,7 @@
<root>
<item name='org.bukkit.configuration.MemorySection java.lang.String getString(java.lang.String, java.lang.String)'>
<annotation name='org.jetbrains.annotations.Contract'>
<val val="&quot;_, _, -&gt; !null&quot;"/>
<val val="&quot;_, _ -&gt; !null&quot;"/>
</annotation>
</item>
</root>
+28 -23
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
<artifactId>SimpleClans</artifactId>
<version>2.14.4.1</version>
<version>2.15.1</version>
<name>SimpleClans</name>
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
@@ -111,7 +111,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -170,6 +170,18 @@
<version>5.4.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.TechFortress</groupId>
<artifactId>GriefPrevention</artifactId>
<version>16.17.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
<!-- Repositories -->
@@ -186,10 +198,6 @@
<id>bstats-repo</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
@@ -198,22 +206,16 @@
<id>aikar</id>
<url>https://repo.aikar.co/content/groups/aikar/</url>
</repository>
<repository>
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<!-- GitHub/Jenkins -->
<ciManagement>
<system>jenkins</system>
<url>http://104.236.246.108:8080</url>
</ciManagement>
<scm>
<connection>scm:git:git:@github.com:marcelo-mason/SimpleClans.git</connection>
<developerConnection>scm:git:git:@github.com:marcelo-mason/SimpleClans.git</developerConnection>
<url>http://github.com/marcelo-mason/SimpleClans.git/tree/master/</url>
<tag>SimpleClans</tag>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -222,9 +224,12 @@
<distributionManagement>
<repository>
<id>bintray-roinujnosde-bukkit-plugins</id>
<name>roinujnosde-bukkit-plugins</name>
<url>https://api.bintray.com/maven/roinujnosde/bukkit-plugins/SimpleClans/;publish=1</url>
<id>codemc-releases</id>
<url>https://repo.codemc.io/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>codemc-snapshots</id>
<url>https://repo.codemc.io/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
@@ -1,5 +1,6 @@
package net.sacredlabyrinth.phaed.simpleclans;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
@@ -25,13 +26,7 @@ public class ChatBlock {
private String color = "";
private boolean cropRight = true;
private boolean padRight = true;
/**
*
*/
public static final Logger LOG = Logger.getLogger("Minecraft");
public void setCropRight(boolean cropRight) {
this.cropRight = cropRight;
}
@@ -498,14 +493,11 @@ public class ChatBlock {
/**
* Cuts the message apart into whole words short enough to fit on one line
*
* @param msg
* @return
*/
private static String[] wordWrap(String msg) {
// Split each word apart
ArrayList<String> split = new ArrayList<>();
split.addAll(Arrays.asList(msg.split(" ")));
ArrayList<String> split = new ArrayList<>(Arrays.asList(msg.split(" ")));
// Create an array list for the output
@@ -545,18 +537,16 @@ public class ChatBlock {
// Merge the words into a sentence (that now fits into a single chat line) and add them to the output array.
String merged = combineSplit(words.toArray(new String[words.size()]));
String merged = combineSplit(words.toArray(new String[0]));
out.add(merged);
}
// Convert to an array and return
return out.toArray(new String[out.size()]);
return out.toArray(new String[0]);
}
/**
* @param string
* @return
*/
private static String combineSplit(String[] string) {
StringBuilder builder = new StringBuilder();
@@ -572,9 +562,6 @@ public class ChatBlock {
/**
* Cuts apart a word that is too long to fit on one line
*
* @param lengthBefore
* @param str
* @return
*/
private static String[] wordCut(int lengthBefore, String str) {
int length = lengthBefore;
@@ -609,8 +596,6 @@ public class ChatBlock {
/**
* Outputs a single line out, crops overflow
*
* @param receiver
* @param msg
*/
public static void saySingle(CommandSender receiver, String msg) {
if (receiver == null) {
@@ -623,38 +608,31 @@ public class ChatBlock {
/**
* Outputs a message to a user
*
* @param receiver
* @param msg
*/
public static void sendMessage(@Nullable CommandSender receiver, @NotNull String msg) {
if (receiver == null) {
return;
}
String[] message = colorize(wordWrap(msg));
for (String out : message) {
receiver.sendMessage(out);
}
receiver.sendMessage(ChatUtils.parseColors(msg));
// String[] message = colorize(wordWrap(msg));
//
// for (String out : message) {
// receiver.sendMessage(out);
// }
}
public static void sendMessageKey(@Nullable CommandSender receiver, @NotNull String key, @NotNull Object... args) {
sendMessage(receiver, lang(key, receiver, args));
}
/**
* Send blank lie
*
* @param color
*/
public void startColor(String color) {
this.color = color;
}
/**
* Send blank lie
* Send blank line
*
* @param receiver
*/
public static void sendBlank(CommandSender receiver) {
if (receiver == null) {
@@ -667,8 +645,6 @@ public class ChatBlock {
/**
* Colors each line
*
* @param message
* @return
*/
public static String[] say(String message) {
return colorize(wordWrap(message));
@@ -678,10 +654,6 @@ public class ChatBlock {
return colorize(wordWrap(msg));
}
/**
* @param message
* @return
*/
private static String[] colorize(String[] message) {
try {
return colorizeBase(message);
@@ -690,21 +662,12 @@ public class ChatBlock {
}
}
/**
* @param message
* @return
*/
public static String colorize(String message) {
return colorizeBase(new String[]{
message
})[0];
public static @Nullable String colorize(String message) {
return colorizeBase(new String[]{ message })[0];
}
/**
* @param message
* @return
*/
private static String[] colorizeBase(String[] message) {
private static @Nullable String[] colorizeBase(String[] message) {
if (message != null && message[0] != null && !message[0].isEmpty()) {
// Go through each line
@@ -720,9 +683,8 @@ public class ChatBlock {
// advance x to the next character
x += 1;
try {
lastColor = ChatColor.getByChar(msg.charAt(x)) + "";
} catch (Exception ignored) {
if (x < msg.length()) {
lastColor = ChatColor.COLOR_CHAR + "" + msg.charAt(x);
}
}
}
@@ -734,6 +696,7 @@ public class ChatBlock {
}
}
//noinspection ConstantConditions
return message;
}
}
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
@@ -15,111 +15,51 @@ public class Dates {
private Dates() {
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInMonths(Timestamp date1, Timestamp date2) {
return differenceInMonths(new Date(date1.getTime()), new Date(date2.getTime()));
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInYears(Timestamp date1, Timestamp date2) {
return differenceInYears(new Date(date1.getTime()), new Date(date2.getTime()));
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInDays(Timestamp date1, Timestamp date2) {
return differenceInDays(new Date(date1.getTime()), new Date(date2.getTime()));
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInHours(Timestamp date1, Timestamp date2) {
return differenceInHours(new Date(date1.getTime()), new Date(date2.getTime()));
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInMinutes(Timestamp date1, Timestamp date2) {
return differenceInMinutes(new Date(date1.getTime()), new Date(date2.getTime()));
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInSeconds(Timestamp date1, Timestamp date2) {
return differenceInSeconds(new Date(date1.getTime()), new Date(date2.getTime()));
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInMonths(Date date1, Date date2) {
return differenceInYears(date1, date2) * 12;
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInYears(Date date1, Date date2) {
double days = differenceInDays(date1, date2);
return days / 365.2425;
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInDays(Date date1, Date date2) {
return differenceInHours(date1, date2) / 24.0;
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInHours(Date date1, Date date2) {
return differenceInMinutes(date1, date2) / 60.0;
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInMinutes(Date date1, Date date2) {
return differenceInSeconds(date1, date2) / 60.0;
}
/**
* @param date1
* @param date2
* @return
*/
public static double differenceInSeconds(Date date1, Date date2) {
return differenceInMilliseconds(date1, date2) / 1000.0;
}
@@ -135,15 +75,12 @@ public class Dates {
}
/**
* Returns the string representation of the amount of time labeled as days, hours, minutes, seconds
* @author RoboMWM, LaxWasHere
* @param seconds the time in seconds
* @param depth Max amount of detail (e.g. only display days and hours if set to 1 and seconds > 1 day)
* @return
* @return the string representation of the amount of time labeled as days, hours, minutes, seconds
*/
public static String formatTime(Long seconds, int depth)
{
SimpleClans plugin = SimpleClans.getInstance();
public static String formatTime(Long seconds, int depth) {
if (seconds == null || seconds < 1) {
return lang("bb.moments");
}
@@ -0,0 +1,93 @@
package net.sacredlabyrinth.phaed.simpleclans;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.JSONValue;
import java.util.ArrayList;
import java.util.List;
public class Flags {
private final JSONObject flags;
public Flags(@Nullable String json) {
JSONObject flags = null;
if (json != null && !json.isEmpty()) {
flags = (JSONObject) JSONValue.parse(json);
}
if (flags == null) {
flags = new JSONObject();
}
this.flags = flags;
}
@NotNull
public List<String> getStringList(@NotNull String key) {
Object object = flags.get(key);
ArrayList<String> list = new ArrayList<>();
if (object instanceof JSONArray) {
for (Object o : ((JSONArray) object)) {
list.add(String.valueOf(o));
}
}
return list;
}
@Nullable
public String getString(@NotNull String key) {
Object object = flags.get(key);
if (object == null) {
return null;
}
return String.valueOf(object);
}
@NotNull
public String getString(@NotNull String key, @NotNull String def) {
String string = getString(key);
if (string == null) {
return def;
}
return string;
}
@NotNull
public Number getNumber(@NotNull String key) {
Object object = flags.get(key);
if (object instanceof Number) {
return (Number) object;
}
return 0;
}
public boolean getBoolean(@NotNull String key) {
return getBoolean(key, false);
}
public boolean getBoolean(@NotNull String key, boolean def) {
Object object = flags.get(key);
if (object instanceof Boolean) {
return (Boolean) object;
}
return def;
}
@SuppressWarnings("unchecked")
public void put(@NotNull String key, @NotNull List<?> value) {
JSONArray array = new JSONArray();
array.addAll(value);
flags.put(key, array);
}
@SuppressWarnings("unchecked")
public void put(@NotNull String key, @NotNull Object object) {
flags.put(key, object);
}
public String toJSONString() {
return flags.toJSONString();
}
}
@@ -1,6 +1,8 @@
package net.sacredlabyrinth.phaed.simpleclans;
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.utils.KDRFormat;
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
import org.bukkit.Bukkit;
@@ -77,51 +79,74 @@ public class Helper {
}
return null;
}
/**
* Converts a JSON String to a list of Ranks
*
* @param json the JSON String
* @return a list of ranks or null if the JSON String is null/empty
*/
public static @Nullable List<Rank> ranksFromJson(String json) {
if (json != null && !json.isEmpty()) {
try {
JSONObject jo = (JSONObject) new JSONParser().parse(json);
Object ranks = jo.get("ranks");
if (ranks != null) {
JSONArray array = (JSONArray) ranks;
List<Rank> rankList = new ArrayList<>();
for (Object o : array) {
JSONObject r = (JSONObject) o;
String name = (String) r.get("name");
String displayName = (String) r.get("displayName");
Set<String> permissions = new HashSet<>();
for (Object p : (JSONArray) r.get("permissions")) {
permissions.add((String) p);
}
Rank rank = new Rank(name, displayName, permissions);
rankList.add(rank);
}
return rankList;
}
} catch (ParseException e) {
e.printStackTrace();
}
}
return null;
public static @Nullable JSONObject parseJson(String json) {
if (json != null && !json.isEmpty()) {
try {
return (JSONObject) new JSONParser().parse(json);
} catch (ParseException e) {
e.printStackTrace();
}
}
return null;
}
/**
* Converts a list of Ranks to a JSON String
* Parses a list of ranks from the specified JSONObject
*
* @param ranks
* @param jo the JSON Object
* @return a list of ranks or null if the JSON String is null/empty
*/
public static @Nullable List<Rank> ranksFromJson(JSONObject jo) {
if (jo != null && !jo.isEmpty()) {
Object ranks = jo.get("ranks");
if (ranks != null) {
JSONArray array = (JSONArray) ranks;
List<Rank> rankList = new ArrayList<>();
for (Object o : array) {
JSONObject r = (JSONObject) o;
String name = (String) r.get("name");
String displayName = (String) r.get("displayName");
Set<String> permissions = new HashSet<>();
for (Object p : (JSONArray) r.get("permissions")) {
permissions.add((String) p);
}
Rank rank = new Rank(name, displayName, permissions);
rankList.add(rank);
}
return rankList;
}
}
return null;
}
/**
* Parses the default rank from the specified JSONObject
*
* @param jo the JSON object
* @return the default rank or null if not found and/or it does not exist
*/
public static @Nullable String defaultRankFromJson(JSONObject jo) {
if (jo != null && !jo.isEmpty()) {
if (!jo.containsKey("defaultRank")) {
return null;
} else {
return (String) jo.get("defaultRank");
}
}
return null;
}
/**
* Converts a list of ranks and the default rank to a JSON String
*
* @param ranks the ranks
* @param defaultRank the default rank
* @return a JSON String
*/
@SuppressWarnings("unchecked")
public static String ranksToJson(List<Rank> ranks) {
public static String ranksToJson(List<Rank> ranks, @Nullable String defaultRank) {
if (ranks == null)
ranks = new ArrayList<Rank>();
@@ -140,6 +165,7 @@ public class Helper {
JSONObject object = new JSONObject();
object.put("ranks", array);
object.put("defaultRank", defaultRank);
return object.toJSONString();
}
@@ -202,7 +228,8 @@ public class Helper {
List<Player> players = SimpleClans.getInstance().getServer().matchPlayer(playerName);
if (players.size() == 1) {
return SimpleClans.getInstance().getPermissionsManager().getPrefix(players.get(0)) + players.get(0).getName() + SimpleClans.getInstance().getPermissionsManager().getSuffix(players.get(0));
PermissionsManager pm = SimpleClans.getInstance().getPermissionsManager();
return pm.getPrefix(players.get(0)) + players.get(0).getName() + pm.getSuffix(players.get(0));
}
return playerName;
@@ -375,6 +402,9 @@ public class Helper {
if (hexValue == null) {
return "";
}
if (hexValue.startsWith("&#")) {
return ChatUtils.parseColors(hexValue);
}
ChatColor color = ChatColor.getByChar(hexValue);
if (color == null) {
@@ -511,25 +541,21 @@ public class Helper {
}
/**
* Convert color hex values with ampersand to special character
*
* @param msg
* @return
* @deprecated use {@link ChatUtils#parseColors(String)}
*/
@Deprecated
public static String parseColors(String msg) {
return msg.replace("&", "\u00a7");
return ChatUtils.parseColors(msg);
}
/**
* Removes color codes from strings
*
* @param msg
* @return
* @deprecated use {@link ChatUtils#stripColors(String)}
*/
@Deprecated
public static String stripColors(String msg) {
String out = msg.replaceAll("[&][0-9a-fk-or]", "");
out = out.replaceAll(String.valueOf((char) 194), "");
return out.replaceAll("[\u00a7][0-9a-fk-or]", "");
return ChatUtils.stripColors(msg);
}
/*
@@ -817,8 +843,8 @@ public class Helper {
String leaderColor = sm.getAllyChatLeaderColor();
String memberColor = sm.getAllyChatMemberColor();
String rank = cp.getRankId().isEmpty() ? null : ChatColor.translateAlternateColorCodes('&', cp.getRankDisplayName());
String rankFormat = rank != null ? ChatColor.translateAlternateColorCodes('&', sm.getAllyChatRank()).replace("%rank%", rank) : "";
String rank = cp.getRankId().isEmpty() ? null : ChatUtils.parseColors(cp.getRankDisplayName());
String rankFormat = rank != null ? ChatUtils.parseColors(sm.getAllyChatRank()).replace("%rank%", rank) : "";
String message = replacePlaceholders(sm.getAllyChatFormat(), cp, leaderColor, memberColor, rankFormat, msg);
if (placeholders != null) {
@@ -829,8 +855,13 @@ public class Helper {
return message;
}
private static String replacePlaceholders(String messageFormat, ClanPlayer cp, String leaderColor, String memberColor, String rankFormat, String msg) {
return ChatColor.translateAlternateColorCodes('&', messageFormat)
private static String replacePlaceholders(String messageFormat,
ClanPlayer cp,
String leaderColor,
String memberColor,
String rankFormat,
String msg) {
return ChatUtils.parseColors(messageFormat)
.replace("%clan%", Objects.requireNonNull(cp.getClan()).getColorTag())
.replace("%nick-color%", (cp.isLeader() ? leaderColor : memberColor))
.replace("%player%", cp.getName())
@@ -851,8 +882,8 @@ public class Helper {
String leaderColor = sm.getClanChatLeaderColor();
String memberColor = sm.getClanChatMemberColor();
String rank = cp.getRankId().isEmpty() ? null : ChatColor.translateAlternateColorCodes('&', cp.getRankDisplayName());
String rankFormat = rank != null ? ChatColor.translateAlternateColorCodes('&', sm.getClanChatRank()).replace("%rank%", rank) : "";
String rank = cp.getRankId().isEmpty() ? null : ChatUtils.parseColors(cp.getRankDisplayName());
String rankFormat = rank != null ? ChatUtils.parseColors(sm.getClanChatRank()).replace("%rank%", rank) : "";
String message = replacePlaceholders(sm.getClanChatFormat(), cp, leaderColor, memberColor, rankFormat, msg);
@@ -2,6 +2,7 @@ package net.sacredlabyrinth.phaed.simpleclans;
import co.aikar.commands.BukkitCommandIssuer;
import net.sacredlabyrinth.phaed.simpleclans.commands.SCCommandManager;
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.SimpleClansExpansion;
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageMigration;
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
import net.sacredlabyrinth.phaed.simpleclans.listeners.*;
@@ -9,10 +10,10 @@ import net.sacredlabyrinth.phaed.simpleclans.managers.*;
import net.sacredlabyrinth.phaed.simpleclans.tasks.*;
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatFormatMigration;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.utils.UpdateChecker;
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
import org.bstats.bukkit.Metrics;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
@@ -36,7 +37,7 @@ public class SimpleClans extends JavaPlugin {
private final ArrayList<String> messages = new ArrayList<>();
private static SimpleClans instance;
private static LanguageResource languageResource;
private static final Logger logger = Logger.getLogger("Minecraft");
private static final Logger logger = Logger.getLogger("SimpleClans");
private SCCommandManager commandManager;
private ClanManager clanManager;
private RequestManager requestManager;
@@ -44,7 +45,9 @@ public class SimpleClans extends JavaPlugin {
private SettingsManager settingsManager;
private PermissionsManager permissionsManager;
private TeleportManager teleportManager;
private ProtectionManager protectionManager;
private boolean hasUUID;
private static final Pattern ACF_PLACEHOLDER_PATTERN = Pattern.compile("\\{(?<key>[a-zA-Z]+?)}");
/**
* @return the logger
@@ -89,6 +92,8 @@ public class SimpleClans extends JavaPlugin {
clanManager = new ClanManager();
storageManager = new StorageManager();
teleportManager = new TeleportManager();
protectionManager = new ProtectionManager();
protectionManager.registerListeners();
migrateChatFormat();
registerEvents();
permissionsManager.loadPermissions();
@@ -127,7 +132,7 @@ public class SimpleClans extends JavaPlugin {
private void hookIntoPAPI() {
if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
getLogger().info("PlaceholderAPI found. Registering hook...");
new PlaceholdersManager(this).register();
new SimpleClansExpansion(this).register();
}
}
@@ -221,6 +226,10 @@ public class SimpleClans extends JavaPlugin {
return commandManager;
}
public ProtectionManager getProtectionManager() {
return protectionManager;
}
/**
* @param key the path within the language file
* @return the lang
@@ -249,9 +258,9 @@ public class SimpleClans extends JavaPlugin {
if (lang == null) {
return null;
}
String message = ChatColor.translateAlternateColorCodes('&', lang);
String message = ChatUtils.parseColors(lang);
// contains acf placeholders like {commandprefix}
if (Pattern.compile("\\{(?<key>[a-zA-Z]+?)}").matcher(message).find()) {
if (ACF_PLACEHOLDER_PATTERN.matcher(message).find()) {
return message;
}
return MessageFormat.format(message, arguments);
@@ -0,0 +1,46 @@
package net.sacredlabyrinth.phaed.simpleclans;
import org.jetbrains.annotations.NotNull;
import java.util.*;
public class War {
private final Map<Clan, Integer> clans = new HashMap<>();
public War(@NotNull Clan clan1, @NotNull Clan clan2) {
clans.put(clan1, 0);
clans.put(clan2, 0);
}
public List<Clan> getClans() {
return new ArrayList<>(clans.keySet());
}
public int getTotalCasualties() {
return clans.values().stream().mapToInt(value -> value).sum();
}
public int getCasualties(@NotNull Clan clan) {
return clans.getOrDefault(clan, 0);
}
public void increaseCasualties(@NotNull Clan clan) {
clans.computeIfPresent(clan, (c, i) -> i + 1);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof War) {
return clans.equals(((War) obj).clans);
}
return false;
}
@Override
public int hashCode() {
return clans.hashCode();
}
}
@@ -59,6 +59,7 @@ public class SCCommandManager extends PaperCommandManager {
registerDependency(StorageManager.class, plugin.getStorageManager());
registerDependency(PermissionsManager.class, plugin.getPermissionsManager());
registerDependency(RequestManager.class, plugin.getRequestManager());
registerDependency(ProtectionManager.class, plugin.getProtectionManager());
}
private void registerCompletions() {
@@ -160,10 +161,10 @@ public class SCCommandManager extends PaperCommandManager {
getCommandReplacements().addReplacements(
"basic_conditions", "not_blacklisted|not_banned",
"clan", sm.getCommandClan(),
"deny", sm.getCommandDeny(),
"deny", sm.getCommandDeny() + "|deny",
"more", sm.getCommandMore(),
"ally_chat", sm.getCommandAlly(),
"accept", sm.getCommandAccept(),
"accept", sm.getCommandAccept() + "|accept",
"clan_chat", sm.getCommandClanChat()
);
@@ -216,6 +217,8 @@ public class SCCommandManager extends PaperCommandManager {
"modtag", "bb", "clear", "rival", "ally", "add", "remove", "stats", "coords", "vitals", "rivalries",
"alliances", "leaderboard", "allow", "block", "auto", "check", "assign", "unassign", "delete", "me",
"setdisplayname", "permissions", "tag", "deposit", "withdraw", "set", "status", "tp", "all", "everyone",
"lookup", "roster", "profile", "list", "create", "description", "start", "end", "admin", "help");
"lookup", "roster", "profile", "list", "create", "description", "start", "end", "admin", "help", "mod",
"setdefault", "removedefault", "land", "break", "interact", "place_block", "damage", "interact_entity",
"container");
}
}
@@ -8,6 +8,7 @@ import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
import net.sacredlabyrinth.phaed.simpleclans.conversation.ResignPrompt;
import net.sacredlabyrinth.phaed.simpleclans.events.TagChangeEvent;
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
import org.bukkit.conversations.ConversationFactory;
import org.bukkit.entity.Player;
@@ -102,7 +103,7 @@ public class ClanCommands extends BaseCommand {
return;
}
clan.addBb(player.getName(), AQUA + lang("tag.changed.to.0", Helper.parseColors(tag)));
clan.addBb(player.getName(), AQUA + lang("tag.changed.to.0", ChatUtils.parseColors(tag)));
clan.changeClanTag(tag);
cm.updateDisplayName(player);
}
@@ -5,7 +5,10 @@ import co.aikar.commands.annotation.*;
import net.sacredlabyrinth.phaed.simpleclans.*;
import net.sacredlabyrinth.phaed.simpleclans.events.HomeRegroupEvent;
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerHomeSetEvent;
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.ProtectionManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -23,6 +26,8 @@ public class HomeCommands extends BaseCommand {
@Dependency
private SettingsManager settings;
@Dependency
private ProtectionManager protection;
@Dependency
private ClanManager cm;
@Subcommand("%regroup %me")
@@ -109,6 +114,12 @@ public class HomeCommands extends BaseCommand {
ChatBlock.sendMessage(player, RED + lang("home.base.only.once", player));
return;
}
if (settings.isSetBaseOnlyInLand()) {
if (!protection.isOwner(player, player.getLocation())) {
ChatBlock.sendMessageKey(player, "you.can.only.set.base.in.your.land");
return;
}
}
PlayerHomeSetEvent homeSetEvent = new PlayerHomeSetEvent(clan, cp, player.getLocation());
plugin.getServer().getPluginManager().callEvent(homeSetEvent);
@@ -0,0 +1,164 @@
package net.sacredlabyrinth.phaed.simpleclans.commands.clan;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
import net.sacredlabyrinth.phaed.simpleclans.managers.ProtectionManager;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import java.util.Objects;
import java.util.Set;
@CommandAlias("%clan")
@Subcommand("%land")
@Conditions("%basic_conditions|land_sharing|own_land")
@CommandPermission("simpleclans.member.land")
public class LandCommand extends BaseCommand {
@Dependency
private ProtectionManager protection;
@Subcommand("%allow")
public class AllowCommand extends BaseCommand {
private void allow(ClanPlayer cp, ProtectionManager.Action action, Location location) {
allow(cp, action, location, true);
}
private void allow(ClanPlayer cp, ProtectionManager.Action action, Location location, boolean notify) {
Set<Land> lands = protection.getLands(Objects.requireNonNull(cp.toPlayer()), location);
for (Land land : lands) {
cp.allow(action, land.getId());
}
if (notify) {
ChatBlock.sendMessageKey(cp.toPlayer(), "land.allowed.action");
}
}
@Subcommand("%container")
@Description("{@@command.description.land.allow.container}")
@CommandPermission("simpleclans.member.land.allow.container")
public void container(Player player, ClanPlayer cp) {
allow(cp, ProtectionManager.Action.CONTAINER, player.getLocation());
}
@Subcommand("%place")
@Description("{@@command.description.land.allow.place}")
@CommandPermission("simpleclans.member.land.allow.place")
public void place(Player player, ClanPlayer cp) {
allow(cp, ProtectionManager.Action.PLACE, player.getLocation());
}
@Subcommand("%damage")
@Description("{@@command.description.land.allow.damage}")
@CommandPermission("simpleclans.member.land.allow.damage")
public void damage(Player player, ClanPlayer cp) {
allow(cp, ProtectionManager.Action.DAMAGE, player.getLocation());
}
@Subcommand("%interact_entity")
@Description("{@@command.description.land.allow.interact_entity}")
@CommandPermission("simpleclans.member.land.allow.interact_entity")
public void interactEntity(Player player, ClanPlayer cp) {
allow(cp, ProtectionManager.Action.INTERACT_ENTITY, player.getLocation());
}
@Subcommand("%interact")
@Description("{@@command.description.land.allow.interact}")
@CommandPermission("simpleclans.member.land.allow.interact")
public void interact(Player player, ClanPlayer cp) {
allow(cp, ProtectionManager.Action.INTERACT, player.getLocation());
}
@Subcommand("%break")
@Description("{@@command.description.land.allow.break}")
@CommandPermission("simpleclans.member.land.allow.break")
public void allowBreak(Player player, ClanPlayer cp) {
allow(cp, ProtectionManager.Action.BREAK, player.getLocation());
}
@Subcommand("%all")
@Description("{@@command.description.land.allow.all}")
@CommandPermission("simpleclans.member.land.allow.all")
public void all(Player player, ClanPlayer cp) {
for (ProtectionManager.Action action : ProtectionManager.Action.values()) {
allow(cp, action, player.getLocation(), false);
}
ChatBlock.sendMessageKey(player, "land.allowed.all.actions");
}
}
@Subcommand("%block")
public class BlockCommand extends BaseCommand {
private void block(ClanPlayer cp, ProtectionManager.Action action, Location location) {
block(cp, action, location, true);
}
private void block(ClanPlayer cp, ProtectionManager.Action action, Location location, boolean notify) {
Set<Land> lands = protection.getLands(Objects.requireNonNull(cp.toPlayer()), location);
for (Land land : lands) {
cp.disallow(action, land.getId());
}
if (notify) {
ChatBlock.sendMessageKey(cp.toPlayer(), "land.blocked.action");
}
}
@Subcommand("%container")
@Description("{@@command.description.land.block.container}")
@CommandPermission("simpleclans.member.land.block.container")
public void container(Player player, ClanPlayer cp) {
block(cp, ProtectionManager.Action.CONTAINER, player.getLocation());
}
@Subcommand("%place")
@Description("{@@command.description.land.block.place}")
@CommandPermission("simpleclans.member.land.block.place")
public void place(Player player, ClanPlayer cp) {
block(cp, ProtectionManager.Action.PLACE, player.getLocation());
}
@Subcommand("%damage")
@Description("{@@command.description.land.block.damage}")
@CommandPermission("simpleclans.member.land.block.damage")
public void damage(Player player, ClanPlayer cp) {
block(cp, ProtectionManager.Action.DAMAGE, player.getLocation());
}
@Subcommand("%interact_entity")
@Description("{@@command.description.land.block.interact_entity}")
@CommandPermission("simpleclans.member.land.block.interact_entity")
public void interactEntity(Player player, ClanPlayer cp) {
block(cp, ProtectionManager.Action.INTERACT_ENTITY, player.getLocation());
}
@Subcommand("%interact")
@Description("{@@command.description.land.block.interact}")
@CommandPermission("simpleclans.member.land.block.interact")
public void interact(Player player, ClanPlayer cp) {
block(cp, ProtectionManager.Action.INTERACT, player.getLocation());
}
@Subcommand("%break")
@Description("{@@command.description.land.block.break}")
@CommandPermission("simpleclans.member.land.block.break")
public void blockBreak(Player player, ClanPlayer cp) {
block(cp, ProtectionManager.Action.BREAK, player.getLocation());
}
@Subcommand("%all")
@Description("{@@command.description.land.block.all}")
@CommandPermission("simpleclans.member.land.block.all")
public void all(Player player, ClanPlayer cp) {
protection.getLandsAt(player.getLocation());
for (ProtectionManager.Action action : ProtectionManager.Action.values()) {
block(cp, action, player.getLocation(), false);
}
ChatBlock.sendMessageKey(player, "land.blocked.all.actions");
}
}
}
@@ -7,6 +7,7 @@ import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
import net.sacredlabyrinth.phaed.simpleclans.conversation.CreateRankNamePrompt;
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import org.bukkit.ChatColor;
import org.bukkit.conversations.Conversation;
import org.bukkit.conversations.ConversationFactory;
@@ -67,7 +68,7 @@ public class RankCommand extends BaseCommand {
@Description("{@@command.description.rank.create}")
public void create(Player player, Clan clan) {
Conversation conversation = new ConversationFactory(plugin).withFirstPrompt(new CreateRankNamePrompt())
.withLocalEcho(true).buildConversation(player);
.withLocalEcho(true).withTimeout(60).buildConversation(player);
conversation.getContext().setSessionData("clan", clan);
conversation.begin();
}
@@ -98,7 +99,7 @@ public class RankCommand extends BaseCommand {
int count = 1;
for (Rank rank : ranks) {
ChatBlock.sendMessage(player, AQUA + lang("ranks.list.item", player, count,
Helper.parseColors(rank.getDisplayName()) + AQUA, rank.getName()));
ChatUtils.parseColors(rank.getDisplayName()) + AQUA, rank.getName()));
count++;
}
}
@@ -117,6 +118,23 @@ public class RankCommand extends BaseCommand {
ChatBlock.sendMessage(player, ChatColor.AQUA + lang("rank.displayname.updated", player));
}
@Subcommand("%setdefault")
@CommandPermission("simpleclans.leader.rank.setdefault")
@CommandCompletion("@ranks")
@Description("{@@command.description.rank.setdefault}")
public void setDefault(Player player, Clan clan, @Name("rank") Rank rank) {
clan.setDefaultRank(rank.getName());
ChatBlock.sendMessage(player, AQUA + lang("rank.setdefault", player, rank.getDisplayName()));
}
@Subcommand("%removedefault")
@CommandPermission("simpleclans.leader.rank.removedefault")
@Description("{@@command.description.rank.removedefault}")
public void removeDefault(Player player, Clan clan) {
clan.setDefaultRank(null);
ChatBlock.sendMessage(player, AQUA + lang("rank.removedefault", player));
}
@Subcommand("%permissions")
public class PermissionsCommand extends BaseCommand {
private final String validPermissionsToMessage = Helper.toMessage(Helper.fromPermissionArray(), ",");
@@ -1,10 +1,7 @@
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.RequestManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.*;
import org.jetbrains.annotations.NotNull;
public abstract class AbstractCondition implements IdentifiableCondition {
@@ -14,6 +11,7 @@ public abstract class AbstractCondition implements IdentifiableCondition {
protected final ClanManager clanManager;
protected final RequestManager requestManager;
protected final SettingsManager settingsManager;
protected final ProtectionManager protectionManager;
public AbstractCondition(@NotNull SimpleClans plugin) {
this.plugin = plugin;
@@ -21,5 +19,6 @@ public abstract class AbstractCondition implements IdentifiableCondition {
clanManager = plugin.getClanManager();
requestManager = plugin.getRequestManager();
settingsManager = plugin.getSettingsManager();
protectionManager = plugin.getProtectionManager();
}
}
@@ -23,12 +23,12 @@ public class CanVoteCondition extends AbstractCommandCondition {
ClanPlayer cp = clanManager.getCreateClanPlayer(player.getUniqueId());
Clan clan = cp.getClan();
if (clan != null) {
if (!clan.isLeader(player)) {
throw new ConditionFailedException(RED + lang("no.leader.permissions", player));
}
if (!requestManager.hasRequest(clan.getTag())) {
throw new ConditionFailedException(lang("nothing.to.vote", player));
}
if (!clan.isLeader(player)) {
throw new ConditionFailedException(RED + lang("no.leader.permissions", player));
}
if (cp.getVote() != null) {
throw new ConditionFailedException(RED + lang("you.have.already.voted", player));
}
@@ -24,7 +24,7 @@ public class InputVerifiedCondition extends AbstractParameterCondition<ClanInput
BukkitCommandExecutionContext execContext,
ClanInput value)
throws InvalidCommandArgument {
if (!value.getClan().isVerified()) {
if (!value.getClan().isVerified() && !context.getIssuer().hasPermission("simpleclans.mod.bypass")) {
throw new ConditionFailedException(lang("other.clan.not.verified", execContext.getSender()));
}
}
@@ -0,0 +1,27 @@
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
import co.aikar.commands.*;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import org.jetbrains.annotations.NotNull;
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
@SuppressWarnings("unused")
public class LandSharingCondition extends AbstractCommandCondition {
public LandSharingCondition(@NotNull SimpleClans plugin) {
super(plugin);
}
@Override
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
if (!settingsManager.isLandSharing()) {
throw new ConditionFailedException(lang("land.sharing.disabled", context.getIssuer()));
}
}
@Override
public @NotNull String getId() {
return "land_sharing";
}
}
@@ -0,0 +1,31 @@
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
import co.aikar.commands.BukkitCommandIssuer;
import co.aikar.commands.ConditionContext;
import co.aikar.commands.ConditionFailedException;
import co.aikar.commands.InvalidCommandArgument;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
@SuppressWarnings("unused")
public class OwnLandCondition extends AbstractCommandCondition {
public OwnLandCondition(@NotNull SimpleClans plugin) {
super(plugin);
}
@Override
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
Player player = Conditions.assertPlayer(context.getIssuer());
if (protectionManager.getLands(player, player.getLocation()).isEmpty()) {
throw new ConditionFailedException(lang("you.do.not.own.lands", player));
}
}
@Override
public @NotNull String getId() {
return "own_land";
}
}
@@ -1,6 +1,7 @@
package net.sacredlabyrinth.phaed.simpleclans.commands.data;
import net.sacredlabyrinth.phaed.simpleclans.*;
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@@ -35,7 +36,7 @@ public class ClanRoster extends Sendable {
Player p = cp.toPlayer();
String name = (cp.isTrusted() ? sm.getPageTrustedColor() : sm.getPageUnTrustedColor()) + cp.getName();
String lastSeen = p != null && p.isOnline() && !Helper.isVanished(sender, p) ? GREEN + lang("online", sender) : WHITE + cp.getLastSeenDaysString(sender);
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender) : WHITE + cp.getLastSeenDaysString(sender);
chatBlock.addRow(" " + name, YELLOW + Helper.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
}
@@ -48,7 +49,7 @@ public class ClanRoster extends Sendable {
Player p = cp.toPlayer();
String name = sm.getPageLeaderColor() + cp.getName();
String lastSeen = p != null && p.isOnline() && !Helper.isVanished(sender, p) ? GREEN + lang("online", sender)
String lastSeen = p != null && p.isOnline() && !VanishUtils.isVanished(sender, p) ? GREEN + lang("online", sender)
: WHITE + cp.getLastSeenDaysString(sender);
chatBlock.addRow(" " + name, YELLOW + Helper.parseColors(cp.getRankDisplayName()) + RESET, lastSeen);
@@ -75,10 +75,19 @@ public class Lookup extends Sendable {
@NotNull
private String getPlayerStatus() {
return target == null || targetClan == null ? lang("free.agent", sender) : (target.isLeader() ?
sm.getPageLeaderColor() + lang("leader", sender) : (target.isTrusted() ?
sm.getPageTrustedColor() + lang("trusted", sender) : sm.getPageUnTrustedColor() +
lang("untrusted", sender)));
if (target == null || targetClan == null) {
return lang("free.agent", sender);
}
if (target.isLeader()) {
return sm.getPageLeaderColor() + lang("leader", sender);
}
if (target.isTrusted()) {
return sm.getPageTrustedColor() + lang("trusted", sender);
}
if (target.getRankId() != null && !target.getRankId().isEmpty()) {
return sm.getPageTrustedColor() + lang("in.rank", sender);
}
return sm.getPageUnTrustedColor() + lang("untrusted", sender);
}
@NotNull
@@ -75,7 +75,7 @@ public class GeneralCommands extends BaseCommand {
initialData.put(TAG_KEY, tag);
initialData.put(NAME_KEY, name);
Conversation conversation = new ConversationFactory(plugin).withFirstPrompt(new CreateClanTagPrompt())
.withLocalEcho(true).withInitialSessionData(initialData).buildConversation(player);
.withLocalEcho(true).withTimeout(60).withInitialSessionData(initialData).buildConversation(player);
conversation.begin();
}
@@ -6,12 +6,15 @@ import co.aikar.commands.bukkit.contexts.OnlinePlayer;
import net.sacredlabyrinth.phaed.simpleclans.*;
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
import net.sacredlabyrinth.phaed.simpleclans.events.TagChangeEvent;
import net.sacredlabyrinth.phaed.simpleclans.language.LanguageResource;
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryController;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@@ -41,7 +44,7 @@ public class StaffCommands extends BaseCommand {
@Dependency
private StorageManager storage;
@Subcommand("%place")
@Subcommand("%mod %place")
@CommandPermission("simpleclans.mod.place")
@CommandCompletion("@players @clans")
@HelpSearchTags("move put")
@@ -59,9 +62,8 @@ public class StaffCommands extends BaseCommand {
}
if (oldClan.isLeader(player) && oldClan.getLeaders().size() <= 1) {
oldClan.clanAnnounce(player.getName(), AQUA + lang("clan.has.been.disbanded",
oldClan.getName()));
oldClan.disband();
ChatBlock.sendMessage(sender, RED + lang("you.cannot.move.the.last.leader", sender));
return;
} else {
oldClan.addBb(player.getName(), AQUA + lang("0.has.resigned", player.getName()));
oldClan.removePlayerFromClan(player.getUniqueId());
@@ -75,7 +77,37 @@ public class StaffCommands extends BaseCommand {
newClanInput.addPlayerToClan(cp);
}
@Subcommand("%reload")
@Subcommand("%mod %modtag")
@CommandPermission("simpleclans.mod.modtag")
@Description("{@@command.description.modtag.other}")
public void modtag(Player player, @Name("clan") ClanInput clanInput, @Single @Name("tag") String tag) {
Clan clan = clanInput.getClan();
TagChangeEvent event = new TagChangeEvent(player, clan, tag);
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
tag = event.getNewTag();
String cleanTag = Helper.cleanTag(tag);
TagValidator validator = new TagValidator(plugin, player, tag);
if (validator.getErrorMessage() != null) {
ChatBlock.sendMessage(player, validator.getErrorMessage());
return;
}
if (!cleanTag.equals(clan.getTag())) {
ChatBlock.sendMessage(player, RED + lang("you.can.only.modify.the.color.and.case.of.the.tag",
player));
return;
}
clan.addBb(player.getName(), AQUA + lang("tag.changed.to.0", ChatUtils.parseColors(tag)));
clan.changeClanTag(tag);
player.sendMessage(lang("0.tag.changed.to.1", player, clan.getTag(), tag));
}
@Subcommand("%admin %reload")
@CommandPermission("simpleclans.admin.reload")
@Description("{@@command.description.reload}")
public void reload(CommandSender sender) {
@@ -92,7 +124,7 @@ public class StaffCommands extends BaseCommand {
ChatBlock.sendMessage(sender, AQUA + lang("configuration.reloaded", sender));
}
@Subcommand("%home %set")
@Subcommand("%mod %home %set")
@CommandPermission("simpleclans.mod.home")
@CommandCompletion("@clans")
@Description("{@@command.description.mod.home.set}")
@@ -104,7 +136,7 @@ public class StaffCommands extends BaseCommand {
ChatColor.YELLOW + Helper.toLocationString(loc));
}
@Subcommand("%home %tp")
@Subcommand("%mod %home %tp")
@CommandCompletion("@clans:has_home")
@CommandPermission("simpleclans.mod.hometp")
@Description("{@@command.description.mod.home.tp}")
@@ -119,7 +151,7 @@ public class StaffCommands extends BaseCommand {
plugin.getTeleportManager().teleportToHome(player, clan.getClan());
}
@Subcommand("%ban")
@Subcommand("%mod %ban")
@CommandPermission("simpleclans.mod.ban")
@CommandCompletion("@players")
@Description("{@@command.description.ban}")
@@ -139,7 +171,7 @@ public class StaffCommands extends BaseCommand {
}
}
@Subcommand("%unban")
@Subcommand("%mod %unban")
@CommandPermission("simpleclans.mod.ban")
@CommandCompletion("@players")
@Description("{@@command.description.unban}")
@@ -159,7 +191,7 @@ public class StaffCommands extends BaseCommand {
ChatBlock.sendMessage(sender, AQUA + lang("player.removed.from.the.banned.list", sender));
}
@Subcommand("%globalff %allow")
@Subcommand("%mod %globalff %allow")
@CommandPermission("simpleclans.mod.globalff")
@Description("{@@command.description.globalff.allow}")
public void allowGlobalFf(CommandSender sender) {
@@ -171,7 +203,7 @@ public class StaffCommands extends BaseCommand {
}
}
@Subcommand("%globalff %auto")
@Subcommand("%mod %globalff %auto")
@CommandPermission("simpleclans.mod.globalff")
@Description("{@@command.description.globalff.auto}")
public void autoGlobalFf(CommandSender sender) {
@@ -185,8 +217,7 @@ public class StaffCommands extends BaseCommand {
}
}
@Subcommand("%verify")
@Subcommand("%mod %verify")
@CommandPermission("simpleclans.mod.verify")
@CommandCompletion("@clans:unverified")
@Description("{@@command.description.mod.verify}")
@@ -202,7 +233,7 @@ public class StaffCommands extends BaseCommand {
}
}
@Subcommand("%purge")
@Subcommand("%admin %purge")
@CommandPermission("simpleclans.admin.purge")
@CommandCompletion("@players")
@Description("{@@command.description.purge}")
@@ -220,7 +251,24 @@ public class StaffCommands extends BaseCommand {
ChatBlock.sendMessage(sender, AQUA + lang("player.purged", sender));
}
@Subcommand("%disband")
@Subcommand("%mod %kick")
@Description("{@@command.description.mod.kick}")
@CommandPermission("simpleclans.mod.kick")
@CommandCompletion("@all_non_leaders|@all_leaders")
public void kick(CommandSender sender, @Conditions("clan_member") @Name("player") ClanPlayerInput cp) {
ClanPlayer clanPlayer = cp.getClanPlayer();
Clan clan = Objects.requireNonNull(clanPlayer.getClan());
if (clan.getLeaders().size() == 1) {
ChatBlock.sendMessageKey(sender, "cannot.kick.last.leader");
return;
}
clan.addBb(sender.getName(), AQUA + lang("has.been.kicked.by", clanPlayer.getName(),
sender.getName(), sender));
clan.removePlayerFromClan(clanPlayer.getUniqueId());
}
@Subcommand("%mod %disband")
@CommandCompletion("@clans")
@CommandPermission("simpleclans.mod.disband")
@Description("{@@command.description.mod.disband}")
@@ -248,6 +296,7 @@ public class StaffCommands extends BaseCommand {
clan.addBb(sender.getName(), AQUA + lang("promoted.to.leader", promotePl.getName()));
clan.promote(promotePl.getUniqueId());
ChatBlock.sendMessage(sender, AQUA + lang("player.successfully.promoted", sender));
}
@Subcommand("%admin %demote")
@@ -267,7 +316,7 @@ public class StaffCommands extends BaseCommand {
ChatBlock.sendMessage(sender, AQUA + lang("player.successfully.demoted", sender));
}
@Subcommand("%resetkdr %everyone")
@Subcommand("%admin %resetkdr %everyone")
@CommandPermission("simpleclans.admin.resetkdr")
@Description("{@@command.description.resetkdr.everyone}")
public void resetKdr(CommandSender sender) {
@@ -277,7 +326,7 @@ public class StaffCommands extends BaseCommand {
ChatBlock.sendMessage(sender, RED + lang("you.have.reseted.kdr.of.all.players", sender));
}
@Subcommand("%resetkdr")
@Subcommand("%admin %resetkdr")
@CommandCompletion("@players")
@CommandPermission("simpleclans.admin.resetkdr")
@Description("{@@command.description.resetkdr.player}")
@@ -83,7 +83,7 @@ public class CreateClanNamePrompt extends StringPrompt {
@Nullable
private Prompt validateName(@NotNull SimpleClans plugin, @NotNull Player player, @NotNull String input) {
boolean bypass = plugin.getPermissionsManager().has(player, "simpleclans.mod.bypass");
if (bypass) {
if (!bypass) {
if (Helper.stripColors(input).length() > plugin.getSettingsManager().getClanMaxLength()) {
return new MessagePromptImpl(ChatColor.RED +
lang("your.clan.name.cannot.be.longer.than.characters", player,
@@ -0,0 +1,44 @@
package net.sacredlabyrinth.phaed.simpleclans.events;
import net.sacredlabyrinth.phaed.simpleclans.Rank;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* @author Minat0_
*/
public class DeleteRankEvent extends Event implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private final Rank rank;
private boolean cancelled;
public DeleteRankEvent(Rank rank) {
this.rank = rank;
}
public Rank getRank() {
return rank;
}
@Override
public @NotNull HandlerList getHandlers() {
return HANDLER_LIST;
}
public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean isCancelled) {
this.cancelled = isCancelled;
}
}
@@ -3,6 +3,7 @@ package net.sacredlabyrinth.phaed.simpleclans.events;
import net.sacredlabyrinth.phaed.simpleclans.Request;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
*
@@ -22,7 +23,7 @@ public class RequestEvent extends Event {
}
@Override
public HandlerList getHandlers() {
public @NotNull HandlerList getHandlers() {
return handlers;
}
@@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
public class TagChangeEvent extends PlayerEvent implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private final @NotNull Clan clan;
private final @NotNull Clan clan;
private @NotNull String newTag;
private boolean cancelled;
@@ -0,0 +1,42 @@
package net.sacredlabyrinth.phaed.simpleclans.events;
import net.sacredlabyrinth.phaed.simpleclans.War;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class WarEndEvent extends Event {
private static final HandlerList HANDLER_LIST = new HandlerList();
private final War war;
private final Reason reason;
public WarEndEvent(@NotNull War war, @NotNull Reason reason) {
this.war = war;
this.reason = reason;
}
@NotNull
public War getWar() {
return war;
}
@NotNull
public Reason getReason() {
return reason;
}
@NotNull
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}
public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
public enum Reason {
REQUEST, EXPIRATION
}
}
@@ -0,0 +1,43 @@
package net.sacredlabyrinth.phaed.simpleclans.events;
import net.sacredlabyrinth.phaed.simpleclans.War;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class WarStartEvent extends Event implements Cancellable {
private static final HandlerList HANDLER_LIST = new HandlerList();
private final War war;
private boolean cancel;
public WarStartEvent(@NotNull War war) {
this.war = war;
}
@NotNull
public War getWar() {
return war;
}
@NotNull
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}
public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
@Override
public boolean isCancelled() {
return cancel;
}
@Override
public void setCancelled(boolean cancel) {
this.cancel = cancel;
}
}
@@ -0,0 +1,13 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi;
import java.lang.annotation.*;
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
@Repeatable(Placeholders.class)
public @interface Placeholder {
String value();
String resolver() default "method_return";
String config() default "";
}
@@ -0,0 +1,48 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.logging.Level;
public abstract class PlaceholderResolver {
protected final SimpleClans plugin;
public PlaceholderResolver(@NotNull SimpleClans plugin) {
this.plugin = plugin;
}
@NotNull
public abstract String getId();
/**
* Resolves the placeholder and returns its value
*
* @param player the player involved in the placeholder request
* @param object the subject of the Placeholder, usually a {@link Clan} or a {@link ClanPlayer}
* @param method the annotated method
* @param placeholder the placeholder to resolve
* @param config configuration for the resolver
*/
@NotNull
public abstract String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
@NotNull String placeholder, @NotNull Map<String, String> config);
@Nullable
protected Object invoke(@NotNull Object object, @NotNull Method method, @NotNull String placeholder) {
try {
return method.invoke(object);
} catch (IllegalAccessException | InvocationTargetException e) {
plugin.getLogger().log(Level.SEVERE, String.format("Error parsing placeholder %s", placeholder), e);
}
return "";
}
}
@@ -0,0 +1,14 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Placeholders {
Placeholder[] value();
}
@@ -0,0 +1,184 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.reflections.Reflections;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import java.util.function.Consumer;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SimpleClansExpansion extends PlaceholderExpansion {
private static final Pattern TOP_CLANS_PATTERN = Pattern.compile("(?<strip>^topclans_(?<position>\\d+)_)clan_");
private static final Pattern TOP_PLAYERS_PATTERN = Pattern.compile("(?<strip>^topplayers_(?<position>\\d+)_)");
private static final Map<String, PlaceholderResolver> RESOLVERS = new HashMap<>();
private List<String> placeholders;
private final SimpleClans plugin;
private final ClanManager clanManager;
public SimpleClansExpansion(SimpleClans plugin) {
this.plugin = plugin;
clanManager = plugin.getClanManager();
registerResolvers();
}
@Override
public @NotNull String getName() {
return plugin.getName();
}
@Override
public @NotNull String getIdentifier() {
return getName().toLowerCase();
}
@Override
public @NotNull String getAuthor() {
return plugin.getDescription().getAuthors().toString();
}
@Override
public @NotNull String getVersion() {
return plugin.getDescription().getVersion();
}
@Override
public boolean persist() {
return true;
}
@Override
public @NotNull List<String> getPlaceholders() {
if (placeholders == null) {
this.placeholders = new ArrayList<>();
addPlaceholders("simpleclans_", ClanPlayer.class, placeholders);
addPlaceholders("simpleclans_clan_", Clan.class, placeholders);
}
return placeholders;
}
private void addPlaceholders(String prefix, Class<?> clazz, List<String> placeholders) {
for (Method method : clazz.getDeclaredMethods()) {
Placeholder[] annotations = method.getAnnotationsByType(Placeholder.class);
for (Placeholder annotation : annotations) {
placeholders.add("%" + prefix + annotation.value() + "%");
//Commented because the list would be very long
//placeholders.add("%simpleclans_topplayers_<number>_" + annotation.value() + "%");
}
}
}
@Override
public boolean canRegister() {
return true;
}
@Override
public String onRequest(@Nullable OfflinePlayer player, @NotNull String params) {
ClanPlayer cp = null;
if (player != null) {
cp = clanManager.getAnyClanPlayer(player.getUniqueId());
}
Clan clan = cp != null ? cp.getClan() : null;
Matcher matcher = TOP_CLANS_PATTERN.matcher(params);
if (matcher.find()) {
int position = Integer.parseInt(matcher.group("position"));
clan = getFromPosition(clanManager.getClans(), position, clanManager::sortClansByKDR);
params = params.replace(matcher.group("strip"), "");
}
matcher = TOP_PLAYERS_PATTERN.matcher(params);
if (matcher.find()) {
int position = Integer.parseInt(matcher.group("position"));
cp = getFromPosition(clanManager.getAllClanPlayers(), position, clanManager::sortClanPlayersByKDR);
params = params.replace(matcher.group("strip"), "");
}
return getValue(player, cp, clan, params);
}
@Nullable
private <T> T getFromPosition(List<T> list, int position, Consumer<List<T>> sort) {
if (isPositionValid(list, position)) {
sort.accept(list);
return list.get(position - 1);
}
return null;
}
private boolean isPositionValid(@NotNull Collection<?> collection, int position) {
return position >= 1 && position <= collection.size();
}
@NotNull
private String getValue(@Nullable OfflinePlayer player, @Nullable ClanPlayer cp, @Nullable Clan clan,
@NotNull String placeholder) {
if (placeholder.startsWith("clan_")) {
placeholder = placeholder.replace("clan_", "");
return getValue(player, clan, placeholder);
}
return getValue(player, cp, placeholder);
}
@NotNull
private String getValue(@Nullable OfflinePlayer player, @Nullable Object object, @NotNull String placeholder) {
if (object != null) {
for (Method declaredMethod : object.getClass().getDeclaredMethods()) {
Placeholder[] annotations = declaredMethod.getAnnotationsByType(Placeholder.class);
for (Placeholder p : annotations) {
if (p.value().equals(placeholder)) {
return resolve(player, object, declaredMethod, p.resolver(), placeholder, p.config());
}
}
}
plugin.getLogger().warning(String.format("Placeholder %s not found", placeholder));
}
return "";
}
private String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
@NotNull String resolverId, @NotNull String placeholder, @NotNull String config) {
PlaceholderResolver resolver = RESOLVERS.get(resolverId);
if (resolver != null) {
return resolver.resolve(player, object, method, placeholder, getConfigMap(config));
}
plugin.getLogger().warning(String.format("Resolver %s for %s not found", resolverId, placeholder));
return "";
}
@NotNull
private Map<String, String> getConfigMap(@NotNull String config) {
HashMap<String, String> map = new HashMap<>();
String[] elements = config.split(",");
for (String element : elements) {
String[] keyAndValue = element.split(":");
map.put(keyAndValue[0], keyAndValue.length > 1 ? keyAndValue[1] : null);
}
return map;
}
private void registerResolvers() {
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers");
Set<Class<? extends PlaceholderResolver>> resolvers = reflections.getSubTypesOf(PlaceholderResolver.class);
plugin.getLogger().info(String.format("Registering %d placeholder resolvers...", resolvers.size()));
for (Class<? extends PlaceholderResolver> r : resolvers) {
try {
PlaceholderResolver resolver = r.getConstructor(SimpleClans.class).newInstance(plugin);
RESOLVERS.put(resolver.getId(), resolver);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException |
NoSuchMethodException e) {
plugin.getLogger().log(Level.SEVERE, "Error registering placeholder resolver", e);
}
}
}
}
@@ -0,0 +1,41 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
@SuppressWarnings("unused")
public class ListSizeResolver extends PlaceholderResolver {
public ListSizeResolver(@NotNull SimpleClans plugin) {
super(plugin);
}
@Override
public @NotNull String getId() {
return "list_size";
}
@SuppressWarnings("unchecked")
@Override
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
@NotNull String placeholder, @NotNull Map<String, String> config) {
Object result = invoke(object, method, placeholder);
String size = "";
if (result instanceof List) {
size = String.valueOf(((List<?>) result).size());
if (config.containsKey("filter_vanished")) {
size = String.valueOf(VanishUtils.getNonVanished(player != null ? player.getPlayer() : null,
(List<ClanPlayer>) result).size());
}
}
return size;
}
}
@@ -0,0 +1,42 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Method;
import java.util.Map;
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanFalse;
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanTrue;
@SuppressWarnings("unused")
public class MemberStatusResolver extends PlaceholderResolver {
public MemberStatusResolver(@NotNull SimpleClans plugin) {
super(plugin);
}
@Override
public @NotNull String getId() {
return "member_status";
}
@Override
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
@NotNull String placeholder, @NotNull Map<String, String> config) {
boolean result = false;
if (object instanceof ClanPlayer) {
ClanPlayer cp = (ClanPlayer) object;
if (placeholder.equals("is_member")) {
result = cp.getClan() != null && !cp.isTrusted();
}
if (placeholder.equals("is_trusted")) {
result = cp.getClan() != null && !cp.isLeader() && cp.isTrusted();
}
}
return result ? booleanTrue() : booleanFalse();
}
}
@@ -0,0 +1,37 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
import me.clip.placeholderapi.PlaceholderAPIPlugin;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Method;
import java.util.Map;
@SuppressWarnings("unused")
public class MethodReturnResolver extends PlaceholderResolver {
public MethodReturnResolver(@NotNull SimpleClans plugin) {
super(plugin);
}
@Override
public @NotNull String getId() {
return "method_return";
}
@Override
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
@NotNull String placeholder, @NotNull Map<String, String> config) {
Object result = invoke(object, method, placeholder);
if (result == null) {
return "";
}
if (result instanceof Boolean) {
return ((Boolean) result) ? PlaceholderAPIPlugin.booleanTrue() : PlaceholderAPIPlugin.booleanFalse();
}
return String.valueOf(result);
}
}
@@ -0,0 +1,31 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Method;
import java.util.Map;
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanFalse;
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanTrue;
@SuppressWarnings("unused")
public class NotNullReturnResolver extends PlaceholderResolver {
public NotNullReturnResolver(@NotNull SimpleClans plugin) {
super(plugin);
}
@Override
public @NotNull String getId() {
return "not_null_return";
}
@Override
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
@NotNull String placeholder, @NotNull Map<String, String> config) {
return invoke(object, method, placeholder) != null ? booleanTrue() : booleanFalse();
}
}
@@ -0,0 +1,65 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Method;
import java.util.Map;
@SuppressWarnings("unused")
public class PlayerColorResolver extends PlaceholderResolver {
public PlayerColorResolver(@NotNull SimpleClans plugin) {
super(plugin);
}
@Override
public @NotNull String getId() {
return "player_color";
}
@Override
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
@NotNull String placeholder, @NotNull Map<String, String> config) {
ClanPlayer cp = object instanceof ClanPlayer ? ((ClanPlayer) object) : null;
if (cp == null) return "";
switch (placeholder) {
case "clanchat_player_color": {
return getClanChatColor(cp);
}
case "allychat_player_color": {
return getAllyChatColor(cp);
}
}
return "";
}
private String getClanChatColor(ClanPlayer player) {
if (player.isLeader()) {
return plugin.getSettingsManager().getClanChatLeaderColor();
}
if (player.isTrusted()) {
return plugin.getSettingsManager().getClanChatTrustedColor();
}
if (player.getClan() != null) {
return plugin.getSettingsManager().getClanChatMemberColor();
}
return "";
}
private String getAllyChatColor(ClanPlayer player) {
if (player.isLeader()) {
return plugin.getSettingsManager().getAllyChatLeaderColor();
}
if (player.isTrusted()) {
return plugin.getSettingsManager().getAllyChatTrustedColor();
}
if (player.getClan() != null) {
return plugin.getSettingsManager().getAllyChatMemberColor();
}
return "";
}
}
@@ -0,0 +1,43 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
import org.bukkit.OfflinePlayer;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
public class RankingPositionResolver extends PlaceholderResolver {
public RankingPositionResolver(@NotNull SimpleClans plugin) {
super(plugin);
}
@Override
public @NotNull String getId() {
return "ranking_position";
}
@Override
public @NotNull String resolve(@Nullable OfflinePlayer player, @NotNull Object object, @NotNull Method method,
@NotNull String placeholder, @NotNull Map<String, String> config) {
if (object instanceof Clan) {
List<Clan> clans = plugin.getClanManager().getClans();
plugin.getClanManager().sortClansByKDR(clans);
return String.valueOf(clans.indexOf(object) + 1);
}
if (object instanceof ClanPlayer) {
List<ClanPlayer> clanPlayers = plugin.getClanManager().getAllClanPlayers();
plugin.getClanManager().sortClanPlayersByKDR(clanPlayers);
return String.valueOf(clanPlayers.indexOf(object) + 1);
}
return "";
}
}
@@ -0,0 +1,41 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
public class Land {
private final String id;
private final Set<UUID> owners;
public Land(@NotNull String id, @NotNull Set<UUID> owners) {
this.id = id;
this.owners = owners;
}
@NotNull
public String getId() {
return id;
}
@NotNull
public Set<UUID> getOwners() {
return owners;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Land land = (Land) o;
return id.equals(land.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}
@@ -0,0 +1,35 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
public interface ProtectionProvider {
void setup();
@NotNull
Set<Land> getLandsAt(@NotNull Location location);
@NotNull
Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world);
@NotNull
String getIdPrefix();
void deleteLand(@NotNull String id, @NotNull World world);
@Nullable Class<? extends Event> getCreateLandEvent();
@Nullable
Player getPlayer(Event event);
@Nullable
String getRequiredPluginName();
}
@@ -0,0 +1,89 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
import me.ryanhamshire.GriefPrevention.Claim;
import me.ryanhamshire.GriefPrevention.DataStore;
import me.ryanhamshire.GriefPrevention.GriefPrevention;
import me.ryanhamshire.GriefPrevention.events.ClaimCreatedEvent;
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@SuppressWarnings("unused")
public class GriefPreventionProvider implements ProtectionProvider {
@Override
public void setup() {}
@Override
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
Claim claim = GriefPrevention.instance.dataStore.getClaimAt(location, true, null);
if (claim == null) {
return Collections.emptySet();
}
return Collections.singleton(getLand(claim));
}
@Nullable
private Land getLand(@Nullable Claim claim) {
if (claim == null) {
return null;
}
return new Land(getIdPrefix() + claim.getID().toString(), Collections.singleton(claim.getOwnerID()));
}
@Override
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
HashSet<Land> lands = new HashSet<>();
for (Claim claim : GriefPrevention.instance.dataStore.getPlayerData(player.getUniqueId()).getClaims()) {
if (claim == null) {
continue;
}
lands.add(getLand(claim));
}
return lands;
}
@Override
public @NotNull String getIdPrefix() {
return "gp";
}
@Override
public void deleteLand(@NotNull String id, @NotNull World world) {
DataStore dataStore = GriefPrevention.instance.dataStore;
Claim claim = dataStore.getClaim(Long.parseLong(id.replaceFirst(getIdPrefix(), "")));
if (claim != null) {
dataStore.deleteClaim(claim);
}
}
@Override
public @Nullable Class<? extends Event> getCreateLandEvent() {
return ClaimCreatedEvent.class;
}
@Override
public @Nullable Player getPlayer(Event event) {
if (event instanceof ClaimCreatedEvent) {
if (((ClaimCreatedEvent) event).getCreator() instanceof Player) {
return ((Player) ((ClaimCreatedEvent) event).getCreator());
}
}
return null;
}
@Override
public @Nullable String getRequiredPluginName() {
return "GriefPrevention";
}
}
@@ -0,0 +1,101 @@
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.ApplicableRegionSet;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
@SuppressWarnings({"unused"})
public class WorldGuardProvider implements ProtectionProvider {
private RegionContainer regionContainer;
public void setup() {
regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
}
@Override
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
RegionManager regionManager = getRegionManager(location.getWorld());
if (regionManager == null) {
return Collections.emptySet();
}
ApplicableRegionSet regions = regionManager.getApplicableRegions(BukkitAdapter.asBlockVector(location));
Set<Land> lands = new HashSet<>();
for (ProtectedRegion region : regions) {
lands.add(getLand(region));
}
return lands;
}
@NotNull
private Land getLand(ProtectedRegion region) {
return new Land(getIdPrefix() + region.getId(), region.getOwners().getUniqueIds());
}
@Override
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
HashSet<Land> lands = new HashSet<>();
RegionManager regionManager = getRegionManager(world);
if (regionManager != null) {
for (ProtectedRegion region : regionManager.getRegions().values()) {
if (region.getOwners().contains(player.getUniqueId())) {
lands.add(getLand(region));
}
}
}
return lands;
}
@Override
public @NotNull String getIdPrefix() {
return "wg";
}
@Override
public void deleteLand(@NotNull String id, @NotNull World world) {
id = id.replaceFirst(getIdPrefix(), "");
RegionManager regionManager = getRegionManager(world);
if (regionManager != null) {
regionManager.removeRegion(id);
}
}
@Override
public @Nullable Class<? extends Event> getCreateLandEvent() {
return null;
}
@Override
public @Nullable Player getPlayer(Event event) {
return null;
}
@Nullable
private RegionManager getRegionManager(@Nullable World world) {
if (world == null) {
return null;
}
return regionContainer.get(BukkitAdapter.adapt(world));
}
@Override
public @Nullable String getRequiredPluginName() {
return "WorldGuard";
}
}
@@ -163,8 +163,14 @@ public class LanguageResource {
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
int lineCount = 0;
try {
while (reader.readLine() != null) {
lineCount++;
while (true) {
String line = reader.readLine();
if (line == null) {
break;
}
if (!line.startsWith("#")) {
lineCount++;
}
}
} catch (IOException ex) {
lineCount = -1;
@@ -12,9 +12,15 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
public class FriendlyFire implements Listener {
private final SimpleClans plugin;
private final Map<UUID, Long> warned = new HashMap<>();
private static final long WARN_DELAY = 10000;
public FriendlyFire(@NotNull SimpleClans plugin) {
this.plugin = plugin;
@@ -59,14 +65,24 @@ public class FriendlyFire implements Listener {
}
if (victimClan.equals(attackerClan)) {
ChatBlock.sendMessageKey(attacker, "cannot.attack.clan.member");
warn(attacker, "cannot.attack.clan.member");
event.setCancelled(true);
return;
}
if (victimClan.isAlly(attackerClan.getTag())) {
ChatBlock.sendMessageKey(attacker, "cannot.attack.ally");
warn(attacker, "cannot.attack.ally");
event.setCancelled(true);
}
}
private void warn(Player attacker, String messageKey) {
long timestamp = warned.getOrDefault(attacker.getUniqueId(), 0L);
long currentTimeMillis = System.currentTimeMillis();
if (timestamp + WARN_DELAY <= currentTimeMillis) {
ChatBlock.sendMessageKey(attacker, messageKey);
warned.put(attacker.getUniqueId(), currentTimeMillis);
}
}
}
@@ -0,0 +1,261 @@
package net.sacredlabyrinth.phaed.simpleclans.listeners;
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.ProtectionManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.*;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Set;
import static net.sacredlabyrinth.phaed.simpleclans.managers.ProtectionManager.Action.*;
public class LandProtection implements Listener {
private final SimpleClans plugin;
private final ProtectionManager protectionManager;
private final ClanManager clanManager;
private final SettingsManager settingsManager;
private final EventPriority priority;
public LandProtection(@NotNull SimpleClans plugin) {
this.plugin = plugin;
protectionManager = plugin.getProtectionManager();
clanManager = plugin.getClanManager();
settingsManager = plugin.getSettingsManager();
priority = settingsManager.getWarListenerPriority();
}
public void registerListeners() {
Bukkit.getPluginManager().registerEvents(this, plugin);
registerBlockBreakListener();
registerBlockPlaceListener();
registerEntityDamageListener();
registerInteractEntityListener();
registerInteractListener();
registerInventoryOpenListener();
}
public void registerCreateLandEvent(ProtectionProvider provider, @Nullable Class<? extends Event> createLandEvent) {
if (createLandEvent == null) return;
Bukkit.getPluginManager().registerEvent(createLandEvent, this, EventPriority.NORMAL, (listener, event) -> {
if (!createLandEvent.isInstance(createLandEvent)) {
return;
}
Player player = provider.getPlayer(event);
if (player == null) return;
Clan clan = clanManager.getClanByPlayerUniqueId(player.getUniqueId());
if ((clan == null || !clan.isLeader(player)) && settingsManager.isOnlyLeadersCanCreateLands()) {
cancelWithMessage(player, event, "only.leaders.can.create.lands");
return;
}
if (settingsManager.isOnlyOneLandPerClan()) {
if (clan == null) {
cancelWithMessage(player, event, "only.clan.members.can.create.lands");
return;
}
for (ClanPlayer member : clan.getAllMembers()) {
Set<Land> lands = protectionManager.getLandsOf(Bukkit.getOfflinePlayer(member.getUniqueId()), player.getWorld());
if (lands.size() > 0) {
cancelWithMessage(player, event, "only.one.land.per.clan");
return;
}
}
}
}, plugin, true);
}
private void cancelWithMessage(Player player, Event event, String messageKey) {
if (!(event instanceof Cancellable)) {
return;
}
ChatBlock.sendMessageKey(player, messageKey);
((Cancellable) event).setCancelled(true);
}
private void registerBlockBreakListener() {
Bukkit.getPluginManager().registerEvent(BlockBreakEvent.class, this, priority, (listener, event) -> {
if (!(event instanceof BlockBreakEvent)) {
return;
}
BlockBreakEvent blockBreakEvent = (BlockBreakEvent) event;
if (protectionManager.can(BREAK, blockBreakEvent.getBlock().getLocation(), blockBreakEvent.getPlayer())) {
blockBreakEvent.setCancelled(false);
}
}, plugin, false);
}
private void registerBlockPlaceListener() {
Bukkit.getPluginManager().registerEvent(BlockPlaceEvent.class, this, priority, (listener, event) -> {
if (!(event instanceof BlockPlaceEvent)) {
return;
}
BlockPlaceEvent blockPlaceEvent = (BlockPlaceEvent) event;
if (protectionManager.can(PLACE, blockPlaceEvent.getBlock().getLocation(), blockPlaceEvent.getPlayer())) {
blockPlaceEvent.setCancelled(false);
}
}, plugin, false);
}
private void registerEntityDamageListener() {
Bukkit.getPluginManager().registerEvent(EntityDamageByEntityEvent.class, this, priority,
(listener, event) -> {
if (!(event instanceof EntityDamageByEntityEvent)) {
return;
}
EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) event;
if (!(entityEvent.getDamager() instanceof Player)) {
return;
}
Player attacker = ((Player) entityEvent.getDamager());
Player victim = entityEvent.getEntity() instanceof Player ? ((Player) entityEvent.getEntity()) : null;
if (protectionManager.can(DAMAGE, entityEvent.getEntity().getLocation(), attacker, victim)) {
entityEvent.setCancelled(false);
}
}, plugin, false);
}
private void registerInteractEntityListener() {
Bukkit.getPluginManager().registerEvent(PlayerInteractEntityEvent.class, this, priority, (listener, event) -> {
if (!(event instanceof PlayerInteractEntityEvent)) {
return;
}
PlayerInteractEntityEvent interactEvent = (PlayerInteractEntityEvent) event;
if (protectionManager.can(INTERACT_ENTITY, interactEvent.getRightClicked().getLocation(), interactEvent.getPlayer())) {
interactEvent.setCancelled(false);
}
}, plugin, false);
}
private void registerInventoryOpenListener() {
Bukkit.getPluginManager().registerEvent(InventoryOpenEvent.class, this, priority, (l, e) -> {
if (!(e instanceof InventoryOpenEvent)) {
return;
}
InventoryOpenEvent event = ((InventoryOpenEvent) e);
InventoryHolder holder = event.getInventory().getHolder();
Location location = getLocation(holder);
if (holder instanceof Entity && holder == event.getPlayer()) return;
if (location == null) return;
if (protectionManager.can(CONTAINER, location, ((Player) event.getPlayer()))) {
event.setCancelled(false);
}
}, plugin, false);
}
private void registerInteractListener() {
Bukkit.getPluginManager().registerEvent(PlayerInteractEvent.class, this, priority, (listener, event) -> {
if (!(event instanceof PlayerInteractEvent)) {
return;
}
PlayerInteractEvent interactEvent = (PlayerInteractEvent) event;
if (interactEvent.getClickedBlock() == null) {
return;
}
ProtectionManager.Action action = getInteractEventAction(interactEvent);
if (protectionManager.can(action, interactEvent.getClickedBlock().getLocation(), interactEvent.getPlayer())) {
interactEvent.setUseInteractedBlock(Event.Result.ALLOW);
interactEvent.setUseItemInHand(Event.Result.ALLOW);
interactEvent.setCancelled(false);
}
}, plugin, false);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onBreak(BlockBreakEvent event) {
if (protectionManager.can(BREAK, event.getBlock().getLocation(), event.getPlayer())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlace(BlockPlaceEvent event) {
if (protectionManager.can(PLACE, event.getBlock().getLocation(), event.getPlayer())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onDamage(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
if (!(damager instanceof Player)) {
return;
}
Player victim = event.getEntity() instanceof Player ? ((Player) event.getEntity()) : null;
if (protectionManager.can(DAMAGE, event.getEntity().getLocation(), (Player) damager, victim)) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onInventoryOpen(InventoryOpenEvent event) {
InventoryHolder holder = event.getInventory().getHolder();
Location location = getLocation(holder);
if (holder instanceof Entity && holder == event.getPlayer()) return;
if (location == null) return;
if (protectionManager.can(CONTAINER, location, ((Player) event.getPlayer()))) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onInteractEntity(PlayerInteractEntityEvent event) {
if (protectionManager.can(INTERACT_ENTITY, event.getRightClicked().getLocation(), event.getPlayer())) {
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onInteract(PlayerInteractEvent event) {
if (event.getClickedBlock() == null) {
return;
}
ProtectionManager.Action action = getInteractEventAction(event);
if (protectionManager.can(action, event.getClickedBlock().getLocation(), event.getPlayer())) {
event.setUseItemInHand(Event.Result.DENY);
event.setUseInteractedBlock(Event.Result.DENY);
event.setCancelled(true);
}
}
private @Nullable Location getLocation(@Nullable InventoryHolder holder) {
if (holder instanceof BlockState) {
return ((BlockState) holder).getLocation();
}
return null;
}
@NotNull
private ProtectionManager.Action getInteractEventAction(PlayerInteractEvent event) {
ProtectionManager.Action action;
Block clickedBlock = event.getClickedBlock();
if (clickedBlock != null && clickedBlock.getState() instanceof InventoryHolder) {
action = CONTAINER;
} else {
action = INTERACT;
}
return action;
}
}
@@ -1,9 +1,6 @@
package net.sacredlabyrinth.phaed.simpleclans.listeners;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.Kill;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.*;
import net.sacredlabyrinth.phaed.simpleclans.events.AddKillEvent;
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
import org.bukkit.Bukkit;
@@ -36,9 +33,11 @@ public class PlayerDeath implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void onEntityDeath(PlayerDeathEvent event) {
SimpleClans.debug("A player died");
Player victim = event.getEntity();
if (plugin.getSettingsManager().isBlacklistedWorld(victim.getLocation().getWorld())
|| victim.hasMetadata("NPC")) {
SimpleClans.debug("Blacklisted world");
return;
}
@@ -56,6 +55,22 @@ public class PlayerDeath implements Listener {
plugin.getStorageManager().updateClanPlayer(victimCp);
}
@EventHandler
public void onWarDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
Player killer = player.getKiller();
if (killer == null) {
return;
}
Clan victimClan = plugin.getClanManager().getClanByPlayerUniqueId(player.getUniqueId());
Clan killerClan = plugin.getClanManager().getClanByPlayerUniqueId(killer.getUniqueId());
War war = plugin.getProtectionManager().getWar(victimClan, killerClan);
if (war == null || victimClan == null) {
return;
}
war.increaseCasualties(victimClan);
}
private void addKill(@NotNull ClanPlayer victim, @NotNull ClanPlayer attacker) {
if (victim.getClan() == null || attacker.getClan() == null || !victim.getClan().isVerified() ||
!attacker.getClan().isVerified()) {
@@ -93,6 +108,7 @@ public class PlayerDeath implements Listener {
@Contract("_, null -> true")
private boolean isInvalidKill(@NotNull Player victim, @Nullable Player attacker) {
if (attacker == null || attacker.getUniqueId().equals(victim.getUniqueId())) {
SimpleClans.debug("Attacker is not a player or victim and attacker have the same UUID");
return true;
}
@@ -9,6 +9,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class PvPOnlyInWar implements Listener {
@@ -39,7 +40,8 @@ public class PvPOnlyInWar implements Listener {
}
}
private void process(EntityDamageEvent event, Player attacker, Player victim, Clan attackerClan, Clan victimClan) {
private void process(EntityDamageEvent event, Player attacker, Player victim, @Nullable Clan attackerClan,
@Nullable Clan victimClan) {
if (attackerClan == null || victimClan == null) {
ChatBlock.sendMessageKey(attacker, "must.be.in.clan.to.pvp", victim.getName());
event.setCancelled(true);
@@ -6,6 +6,8 @@ import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -26,9 +28,11 @@ import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
public class SCPlayerListener implements Listener {
private final SimpleClans plugin;
private final SettingsManager settingsManager;
public SCPlayerListener() {
plugin = SimpleClans.getInstance();
settingsManager = plugin.getSettingsManager();
}
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
@@ -36,12 +40,12 @@ public class SCPlayerListener implements Listener {
String[] split = event.getMessage().substring(1).split(" ");
String command = split[0];
if (plugin.getSettingsManager().isTagBasedClanChat()) {
if (settingsManager.isTagBasedClanChat()) {
Clan clan = plugin.getClanManager().getClan(command);
if (clan == null || !clan.isMember(event.getPlayer())) {
return;
}
String replaced = event.getMessage().replaceFirst(command, plugin.getSettingsManager().getCommandClanChat());
String replaced = event.getMessage().replaceFirst(command, settingsManager.getCommandClanChat());
event.setMessage(replaced);
}
}
@@ -50,7 +54,7 @@ public class SCPlayerListener implements Listener {
public void onPlayerChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player.getUniqueId());
if (cp == null || plugin.getSettingsManager().isBlacklistedWorld(player.getLocation().getWorld())) {
if (cp == null || settingsManager.isBlacklistedWorld(player.getLocation().getWorld())) {
return;
}
@@ -76,14 +80,15 @@ public class SCPlayerListener implements Listener {
@EventHandler
public void handleChatTags(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player.getUniqueId());
if (cp == null || plugin.getSettingsManager().isBlacklistedWorld(player.getWorld())) {
if (settingsManager.isBlacklistedWorld(player.getWorld())) {
return;
}
Clan clan = Objects.requireNonNull(cp.getClan());
if (plugin.getSettingsManager().isCompatMode() && plugin.getSettingsManager().isChatTags()) {
if (cp.isTagEnabled()) {
String tagLabel = clan.getTagLabel(cp.isLeader());
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(player.getUniqueId());
String tagLabel = cp != null && cp.isTagEnabled() ? cp.getTagLabel() : null;
if (settingsManager.isCompatMode() && settingsManager.isChatTags()) {
if (tagLabel != null) {
if (player.getDisplayName().contains("{clan}")) {
player.setDisplayName(player.getDisplayName().replace("{clan}", tagLabel));
} else if (event.getFormat().contains("{clan}")) {
@@ -127,8 +132,8 @@ public class SCPlayerListener implements Listener {
SimpleClans.getInstance().getPermissionsManager().addPlayerPermissions(cp);
if (plugin.getSettingsManager().isBbShowOnLogin() && cp.isBbEnabled() && cp.getClan() != null) {
cp.getClan().displayBb(player, plugin.getSettingsManager().getBbLoginSize());
if (settingsManager.isBbShowOnLogin() && cp.isBbEnabled() && cp.getClan() != null) {
cp.getClan().displayBb(player, settingsManager.getBbLoginSize());
}
SimpleClans.getInstance().getPermissionsManager().addClanPermissions(cp);
@@ -137,8 +142,8 @@ public class SCPlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
if (!plugin.getSettingsManager().isTeleportOnSpawn() ||
plugin.getSettingsManager().isBlacklistedWorld(player.getWorld())) {
if (!settingsManager.isTeleportOnSpawn() ||
settingsManager.isBlacklistedWorld(player.getWorld())) {
return;
}
@@ -153,11 +158,20 @@ public class SCPlayerListener implements Listener {
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
if (plugin.getSettingsManager().isBlacklistedWorld(event.getPlayer().getLocation().getWorld())) {
ClanPlayer cp = plugin.getClanManager().getClanPlayer(event.getPlayer());
if (cp != null) {
Clan clan = Objects.requireNonNull(cp.getClan());
Bukkit.getScheduler().runTask(plugin, () -> {
if (clan.getOnlineMembers().isEmpty()) {
plugin.getProtectionManager().setWarExpirationTime(cp.getClan(),
settingsManager.getWarDisconnectExpirationTime());
}
});
}
if (settingsManager.isBlacklistedWorld(event.getPlayer().getLocation().getWorld())) {
return;
}
ClanPlayer cp = plugin.getClanManager().getClanPlayer(event.getPlayer());
SimpleClans.getInstance().getPermissionsManager().removeClanPlayerPermissions(cp);
plugin.getClanManager().updateLastSeen(event.getPlayer());
@@ -166,7 +180,7 @@ public class SCPlayerListener implements Listener {
@EventHandler
public void onPlayerKick(PlayerKickEvent event) {
if (plugin.getSettingsManager().isBlacklistedWorld(event.getPlayer().getLocation().getWorld())) {
if (settingsManager.isBlacklistedWorld(event.getPlayer().getLocation().getWorld())) {
return;
}
@@ -55,20 +55,15 @@ public final class ClanManager {
/**
* Adds a kill to the memory
*
* @param kill
*/
public void addKill(Kill kill) {
if (kill == null) {
return;
}
List<Kill> list = kills.get(kill.getKiller());
if (list == null) {
list = new ArrayList<>();
kills.put(kill.getKiller(), list);
}
Iterator<Kill> iterator = list.iterator();
List<Kill> list = kills.computeIfAbsent(kill.getKiller(), k -> new ArrayList<>());
Iterator<Kill> iterator = list.iterator();
while (iterator.hasNext()) {
Kill oldKill = iterator.next();
if (oldKill.getVictim().equals(kill.getKiller())) {
@@ -89,9 +84,7 @@ public final class ClanManager {
/**
* Checks if this kill respects the delay
*
* @param kill
* @return
*
*/
public boolean isKillBeforeDelay(Kill kill) {
if (kill == null) {
@@ -102,19 +95,16 @@ public final class ClanManager {
return false;
}
Iterator<Kill> iterator = list.iterator();
while (iterator.hasNext()) {
for (Kill oldKill : list) {
if (oldKill.getVictim().equals(kill.getVictim())) {
Kill oldKill = iterator.next();
if (oldKill.getVictim().equals(kill.getVictim())) {
final int delay = plugin.getSettingsManager().getDelayBetweenKills();
long timePassed = oldKill.getTime().until(kill.getTime(), ChronoUnit.MINUTES);
if (timePassed < delay) {
return true;
}
}
}
final int delay = plugin.getSettingsManager().getDelayBetweenKills();
long timePassed = oldKill.getTime().until(kill.getTime(), ChronoUnit.MINUTES);
if (timePassed < delay) {
return true;
}
}
}
return false;
}
@@ -122,7 +112,6 @@ public final class ClanManager {
/**
* Import a clan into the in-memory store
*
* @param clan
*/
public void importClan(Clan clan) {
this.clans.put(clan.getTag(), clan);
@@ -131,7 +120,6 @@ public final class ClanManager {
/**
* Import a clan player into the in-memory store
*
* @param cp
*/
public void importClanPlayer(ClanPlayer cp) {
if (cp.getUniqueId() != null) {
@@ -142,9 +130,6 @@ public final class ClanManager {
/**
* Create a new clan
*
* @param player
* @param colorTag
* @param name
*/
public void createClan(Player player, String colorTag, String name) {
ClanPlayer cp = getCreateClanPlayer(player.getUniqueId());
@@ -159,6 +144,7 @@ public final class ClanManager {
importClan(clan);
plugin.getStorageManager().updateClanPlayer(cp);
plugin.getRequestManager().deny(cp); //denies any previous invitation
SimpleClans.getInstance().getPermissionsManager().updateClanPermissions(clan);
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new CreateClanEvent(clan));
}
@@ -166,7 +152,6 @@ public final class ClanManager {
/**
* Reset a player's KDR
*
* @param cp
*/
public void resetKdr(ClanPlayer cp) {
cp.setCivilianKills(0);
@@ -179,7 +164,6 @@ public final class ClanManager {
/**
* Delete a players data file
*
* @param cp
*/
public void deleteClanPlayer(ClanPlayer cp) {
Clan clan = cp.getClan();
@@ -193,7 +177,6 @@ public final class ClanManager {
/**
* Delete a player data from memory
*
* @param playerUniqueId
*/
public void deleteClanPlayerFromMemory(UUID playerUniqueId) {
clanPlayers.remove(playerUniqueId.toString());
@@ -202,7 +185,6 @@ public final class ClanManager {
/**
* Remove a clan from memory
*
* @param tag
*/
public void removeClan(String tag) {
clans.remove(tag);
@@ -211,8 +193,6 @@ public final class ClanManager {
/**
* Whether the tag belongs to a clan
*
* @param tag
* @return
*/
public boolean isClan(String tag) {
return clans.containsKey(Helper.cleanTag(tag));
@@ -221,8 +201,6 @@ public final class ClanManager {
/**
* Returns the clan the tag belongs to
*
* @param tag
* @return
*/
public Clan getClan(String tag) {
return clans.get(Helper.cleanTag(tag));
@@ -237,7 +215,6 @@ public final class ClanManager {
/**
* Get a player's clan
*
* @param playerUniqueId
* @return null if not in a clan
*/
@Nullable
@@ -261,7 +238,6 @@ public final class ClanManager {
/**
* Returns the collection of all clan players, including the disabled ones
*
* @return
*/
public List<ClanPlayer> getAllClanPlayers() {
return new ArrayList<>(clanPlayers.values());
@@ -271,10 +247,8 @@ public final class ClanManager {
* Gets the ClanPlayer data object if a player is currently in a clan, null
* if he's not in a clan Used for BungeeCord Reload ClanPlayer and your Clan
*
* @param player
* @return
*/
public ClanPlayer getClanPlayerJoinEvent(Player player) {
public @Nullable ClanPlayer getClanPlayerJoinEvent(Player player) {
SimpleClans.getInstance().getStorageManager().importFromDatabaseOnePlayer(player);
return getClanPlayer(player.getUniqueId());
}
@@ -283,10 +257,8 @@ public final class ClanManager {
* Gets the ClanPlayer data object if a player is currently in a clan, null
* if he's not in a clan
*
* @param player
* @return
*/
public ClanPlayer getClanPlayer(OfflinePlayer player) {
public @Nullable ClanPlayer getClanPlayer(OfflinePlayer player) {
return getClanPlayer(player.getUniqueId());
}
@@ -294,10 +266,8 @@ public final class ClanManager {
* Gets the ClanPlayer data object if a player is currently in a clan, null
* if he's not in a clan
*
* @param player
* @return
*/
public ClanPlayer getClanPlayer(Player player) {
public @Nullable ClanPlayer getClanPlayer(Player player) {
return getClanPlayer((OfflinePlayer) player);
}
@@ -305,10 +275,8 @@ public final class ClanManager {
* Gets the ClanPlayer data object if a player is currently in a clan, null
* if he's not in a clan
*
* @param playerUniqueId
* @return
*/
public ClanPlayer getClanPlayer(UUID playerUniqueId) {
public @Nullable ClanPlayer getClanPlayer(UUID playerUniqueId) {
ClanPlayer cp = clanPlayers.get(playerUniqueId.toString());
if (cp == null) {
@@ -332,10 +300,8 @@ public final class ClanManager {
* Gets the ClanPlayer data object if a player is currently in a clan, null
* if he's not in a clan
*
* @param playerDisplayName
* @return
*/
public ClanPlayer getClanPlayerName(String playerDisplayName) {
public @Nullable ClanPlayer getClanPlayerName(String playerDisplayName) {
UUID uuid = UUIDMigration.getForcedPlayerUUID(playerDisplayName);
if (uuid == null) {
@@ -361,8 +327,6 @@ public final class ClanManager {
* not currently in one, their data file persists and can be accessed. their
* clan will be null though.
*
* @param playerUniqueId
* @return
*/
@Nullable
public ClanPlayer getAnyClanPlayer(UUID playerUniqueId) {
@@ -377,10 +341,8 @@ public final class ClanManager {
/**
* Gets the ClanPlayer object for the player, creates one if not found
*
* @param playerDisplayName
* @return
*/
public ClanPlayer getCreateClanPlayerUUID(String playerDisplayName) {
public @Nullable ClanPlayer getCreateClanPlayerUUID(String playerDisplayName) {
UUID playerUniqueId = UUIDMigration.getForcedPlayerUUID(playerDisplayName);
if (playerUniqueId != null) {
return getCreateClanPlayer(playerUniqueId);
@@ -392,8 +354,6 @@ public final class ClanManager {
/**
* Gets the ClanPlayer object for the player, creates one if not found
*
* @param playerUniqueId
* @return
*/
public ClanPlayer getCreateClanPlayer(UUID playerUniqueId) {
if (clanPlayers.containsKey(playerUniqueId.toString())) {
@@ -435,9 +395,8 @@ public final class ClanManager {
/**
* Update the players display name with his clan's tag
*
* @param player
*/
public void updateDisplayName(Player player) {
public void updateDisplayName(@Nullable Player player) {
// do not update displayname if in compat mode
if (plugin.getSettingsManager().isCompatMode()) {
@@ -477,7 +436,6 @@ public final class ClanManager {
/**
* Process a player and his clan's last seen date
*
* @param player
*/
public void updateLastSeen(Player player) {
ClanPlayer cp = getAnyClanPlayer(player.getUniqueId());
@@ -533,7 +491,6 @@ public final class ClanManager {
/**
* Get a count of rivable clans
*
* @return
*/
public int getRivableClanCount() {
int clanCount = 0;
@@ -550,8 +507,6 @@ public final class ClanManager {
/**
* Returns a formatted string detailing the players armor
*
* @param inv
* @return
*/
public String getArmorString(PlayerInventory inv) {
String out = "";
@@ -649,8 +604,6 @@ public final class ClanManager {
/**
* Returns a formatted string detailing the players weapons
*
* @param inv
* @return
*/
public String getWeaponString(PlayerInventory inv) {
String headColor = plugin.getSettingsManager().getPageHeadingsColor();
@@ -811,56 +764,50 @@ public final class ClanManager {
/**
* Returns a formatted string detailing the players health
*
* @param health
* @return
*/
public String getHealthString(double health) {
String out = "";
StringBuilder out = new StringBuilder();
if (health >= 16) {
out += ChatColor.GREEN;
out.append(ChatColor.GREEN);
} else if (health >= 8) {
out += ChatColor.GOLD;
out.append(ChatColor.GOLD);
} else {
out += ChatColor.RED;
out.append(ChatColor.RED);
}
for (int i = 0; i < health; i++) {
out += '|';
out.append('|');
}
return out;
return out.toString();
}
/**
* Returns a formatted string detailing the players hunger
*
* @param health
* @return
*/
public String getHungerString(int health) {
String out = "";
StringBuilder out = new StringBuilder();
if (health >= 16) {
out += ChatColor.GREEN;
out.append(ChatColor.GREEN);
} else if (health >= 8) {
out += ChatColor.GOLD;
out.append(ChatColor.GOLD);
} else {
out += ChatColor.RED;
out.append(ChatColor.RED);
}
for (int i = 0; i < health; i++) {
out += '|';
out.append('|');
}
return out;
return out.toString();
}
/**
* Sort clans by active
*
* @param clans
* @param asc
*
*/
public void sortClansByActive(List<Clan> clans, boolean asc) {
clans.sort((c1, c2) -> {
@@ -869,15 +816,13 @@ public final class ClanManager {
o = -1;
}
return ((Long) c1.getLastUsed()).compareTo(c2.getLastUsed()) * o;
return Long.compare(c1.getLastUsed(), c2.getLastUsed()) * o;
});
}
/**
* Sort clans by founded date
*
* @param clans
* @param asc
*
*/
public void sortClansByFounded(List<Clan> clans, boolean asc) {
clans.sort((c1, c2) -> {
@@ -886,15 +831,13 @@ public final class ClanManager {
o = -1;
}
return ((Long) c1.getFounded()).compareTo(c2.getFounded()) * o;
return Long.compare(c1.getFounded(), c2.getFounded()) * o;
});
}
/**
* Sort clans by kdr
*
* @param clans
* @param asc
*
*/
public void sortClansByKDR(List<Clan> clans, boolean asc) {
clans.sort((c1, c2) -> {
@@ -903,15 +846,13 @@ public final class ClanManager {
o = -1;
}
return ((Float) c1.getTotalKDR()).compareTo(c2.getTotalKDR()) * o;
return Float.compare(c1.getTotalKDR(), c2.getTotalKDR()) * o;
});
}
/**
* Sort clans by size
*
* @param clans
* @param asc
*
*/
public void sortClansBySize(List<Clan> clans, boolean asc) {
clans.sort((c1, c2) -> {
@@ -920,14 +861,13 @@ public final class ClanManager {
o = -1;
}
return ((Integer) c1.getSize()).compareTo(c2.getSize()) * o;
return Integer.compare(c1.getSize(), c2.getSize()) * o;
});
}
/**
* Sort clans by name
*
* @param clans
*/
public void sortClansByName(List<Clan> clans, boolean asc) {
clans.sort((c1, c2) -> {
@@ -943,74 +883,52 @@ public final class ClanManager {
/**
* Sort clans by KDR
*
* @param clans
* @return
*/
public void sortClansByKDR(List<Clan> clans) {
Collections.sort(clans, new Comparator<Clan>() {
clans.sort((c1, c2) -> {
Float o1 = c1.getTotalKDR();
Float o2 = c2.getTotalKDR();
@Override
public int compare(Clan c1, Clan c2) {
Float o1 = c1.getTotalKDR();
Float o2 = c2.getTotalKDR();
return o2.compareTo(o1);
}
return o2.compareTo(o1);
});
}
/**
* Sort clans by KDR
*
* @param clans
*/
public void sortClansBySize(List<Clan> clans) {
Collections.sort(clans, new Comparator<Clan>() {
clans.sort((c1, c2) -> {
Integer o1 = c1.getAllMembers().size();
Integer o2 = c2.getAllMembers().size();
@Override
public int compare(Clan c1, Clan c2) {
Integer o1 = c1.getAllMembers().size();
Integer o2 = c2.getAllMembers().size();
return o2.compareTo(o1);
}
return o2.compareTo(o1);
});
}
/**
* Sort clan players by KDR
*
* @param cps
* @return
*/
public void sortClanPlayersByKDR(List<ClanPlayer> cps) {
Collections.sort(cps, new Comparator<ClanPlayer>() {
cps.sort((c1, c2) -> {
Float o1 = c1.getKDR();
Float o2 = c2.getKDR();
@Override
public int compare(ClanPlayer c1, ClanPlayer c2) {
Float o1 = c1.getKDR();
Float o2 = c2.getKDR();
return o2.compareTo(o1);
}
return o2.compareTo(o1);
});
}
/**
* Sort clan players by last seen days
*
* @param cps
*/
public void sortClanPlayersByLastSeen(List<ClanPlayer> cps) {
Collections.sort(cps, new Comparator<ClanPlayer>() {
cps.sort((c1, c2) -> {
Double o1 = c1.getLastSeenDays();
Double o2 = c2.getLastSeenDays();
@Override
public int compare(ClanPlayer c1, ClanPlayer c2) {
Double o1 = c1.getLastSeenDays();
Double o2 = c2.getLastSeenDays();
return o1.compareTo(o2);
}
return o1.compareTo(o2);
});
}
@@ -1032,8 +950,6 @@ public final class ClanManager {
/**
* Purchase member fee set
*
* @param player
* @return
*/
public boolean purchaseMemberFeeSet(Player player) {
if (!plugin.getSettingsManager().isePurchaseMemberFeeSet()) {
@@ -1058,8 +974,6 @@ public final class ClanManager {
/**
* Purchase clan creation
*
* @param player
* @return
*/
public boolean purchaseCreation(Player player) {
if (!plugin.getSettingsManager().isePurchaseCreation()) {
@@ -1084,8 +998,6 @@ public final class ClanManager {
/**
* Purchase invite
*
* @param player
* @return
*/
public boolean purchaseInvite(Player player) {
if (!plugin.getSettingsManager().isePurchaseInvite()) {
@@ -1110,8 +1022,6 @@ public final class ClanManager {
/**
* Purchase Home Teleport
*
* @param player
* @return
*/
public boolean purchaseHomeTeleport(Player player) {
if (!plugin.getSettingsManager().isePurchaseHomeTeleport()) {
@@ -1136,8 +1046,6 @@ public final class ClanManager {
/**
* Purchase Home Teleport Set
*
* @param player
* @return
*/
public boolean purchaseHomeTeleportSet(Player player) {
if (!plugin.getSettingsManager().isePurchaseHomeTeleportSet()) {
@@ -1162,8 +1070,6 @@ public final class ClanManager {
/**
* Purchase Reset Kdr
*
* @param player
* @return
*/
public boolean purchaseResetKdr(Player player) {
if (!plugin.getSettingsManager().isePurchaseResetKdr()) {
@@ -1188,8 +1094,6 @@ public final class ClanManager {
/**
* Purchase Home Regroup
*
* @param player
* @return
*/
public boolean purchaseHomeRegroup(Player player) {
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
@@ -1229,8 +1133,6 @@ public final class ClanManager {
/**
* Purchase clan verification
*
* @param player
* @return
*/
public boolean purchaseVerification(Player player) {
if (!plugin.getSettingsManager().isePurchaseVerification()) {
@@ -1255,9 +1157,6 @@ public final class ClanManager {
/**
* Processes a clan chat command
*
* @param player
* @param tag
* @param msg
*/
public void processClanChat(Player player, String tag, String msg) {
Clan clan = plugin.getClanManager().getClan(tag);
@@ -1272,8 +1171,6 @@ public final class ClanManager {
/**
* Processes a clan chat command
*
* @param player
* @param msg
*/
public void processClanChat(Player player, final String msg) {
final ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
@@ -1367,8 +1264,6 @@ public final class ClanManager {
/**
* Processes a ally chat command
*
* @param player
* @param msg
*/
public void processAllyChat(Player player, final String msg) {
final ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
@@ -1442,9 +1337,6 @@ public final class ClanManager {
/**
* Processes a global chat command
*
* @param player
* @param msg
* @return boolean
*/
public boolean processGlobalChat(Player player, String msg) {
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player.getUniqueId());
@@ -1,90 +0,0 @@
package net.sacredlabyrinth.phaed.simpleclans.managers;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import org.yaml.snakeyaml.DumperOptions;
import org.yaml.snakeyaml.Yaml;
import java.io.*;
import java.util.HashMap;
@SuppressWarnings("unchecked")
@Deprecated
public class LanguageManager {
private File file;
private HashMap<String, String> language;
private String[] comments = new String[]{};
public LanguageManager() {
//load();
}
public void load() {
file = new File(SimpleClans.getInstance().getDataFolder() + File.separator + "language.yml");
check();
}
private void check() {
boolean exists = (file).exists();
loadDefaults();
if (exists) {
loadFile();
}
saveFile();
}
private void loadDefaults() {
try {
InputStream defaultLanguage = getClass().getResourceAsStream("/language.yml");
language = (HashMap<String, String>) new Yaml().load(defaultLanguage);
} catch (Exception e) {
e.printStackTrace();
}
}
private void loadFile() {
try {
InputStream fileLanguage = new FileInputStream(file);
language = (HashMap<String, String>) new Yaml().load(fileLanguage);
} catch (FileNotFoundException e) {
// file not found
}
}
private void saveFile() {
DumperOptions options = new DumperOptions();
options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
options.setWidth(99999999);
options.setAllowUnicode(true);
try {
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file), "UTF-8"));
try {
new Yaml(options).dump(language, out);
for (String comment : comments) {
out.write(comment);
}
} finally {
out.close();
}
} catch (IOException e) {
// could not save
e.printStackTrace();
}
}
public String get(String key) {
Object o = language.get(key);
if (o != null) {
return o.toString();
}
return "Missing language for "+key;
}
}
@@ -3,12 +3,7 @@ package net.sacredlabyrinth.phaed.simpleclans.managers;
import net.milkbowl.vault.chat.Chat;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.PermissionLevel;
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.*;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
@@ -62,7 +57,6 @@ public final class PermissionsManager {
/**
* Whether economy plugin exists and is enabled
*
* @return
*/
public boolean hasEconomy() {
return economy != null && economy.isEnabled();
@@ -95,7 +89,6 @@ public final class PermissionsManager {
/**
* Adds all permissions for a clan
*
* @param clan
*/
public void updateClanPermissions(Clan clan) {
for (ClanPlayer cp : clan.getMembers()) {
@@ -106,7 +99,6 @@ public final class PermissionsManager {
/**
* Adds permissions for a player
*
* @param cp
*/
public void addPlayerPermissions(@Nullable ClanPlayer cp) {
if (cp == null) {
@@ -137,7 +129,6 @@ public final class PermissionsManager {
/**
* Removes permissions for a clan (when it gets disbanded for example)
*
* @param clan
*/
public void removeClanPermissions(Clan clan) {
for (ClanPlayer cp : clan.getMembers()) {
@@ -148,12 +139,11 @@ public final class PermissionsManager {
/**
* Removes permissions for a player (when he gets kicked for example)
*
* @param cp
*/
public void removeClanPlayerPermissions(ClanPlayer cp) {
public void removeClanPlayerPermissions(@Nullable ClanPlayer cp) {
if (cp != null && cp.getClan() != null && cp.toPlayer() != null) {
Player player = cp.toPlayer();
if (player.isOnline() && permissions.containsKey(cp.getClan().getTag()) && permAttaches.containsKey(player)) {
if (player != null && permissions.containsKey(cp.getClan().getTag()) && permAttaches.containsKey(player)) {
permAttaches.get(player).remove();
permAttaches.remove(player);
}
@@ -161,7 +151,6 @@ public final class PermissionsManager {
}
/**
* @param clan
* @return the permissions for a clan
*/
public List<String> getPermissions(Clan clan) {
@@ -178,9 +167,6 @@ public final class PermissionsManager {
/**
* Charge a player some money
*
* @param player
* @param money
* @return
*/
@Deprecated
public boolean playerChargeMoney(String player, double money) {
@@ -190,9 +176,6 @@ public final class PermissionsManager {
/**
* Charge a player some money
*
* @param player
* @param money
* @return
*/
public boolean playerChargeMoney(OfflinePlayer player, double money) {
return economy.withdrawPlayer(player, money).transactionSuccess();
@@ -201,9 +184,6 @@ public final class PermissionsManager {
/**
* Charge a player some money
*
* @param player
* @param money
* @return
*/
public boolean playerChargeMoney(Player player, double money) {
return playerChargeMoney((OfflinePlayer) player, money);
@@ -212,9 +192,6 @@ public final class PermissionsManager {
/**
* Grants a player some money
*
* @param player
* @param money
* @return
*/
public boolean playerGrantMoney(Player player, double money) {
return economy.depositPlayer(player, money).transactionSuccess();
@@ -223,9 +200,6 @@ public final class PermissionsManager {
/**
* Grants a player some money
*
* @param player
* @param money
* @return
*/
@Deprecated
public boolean playerGrantMoney(String player, double money) {
@@ -235,9 +209,6 @@ public final class PermissionsManager {
/**
* Grants a player some money
*
* @param player
* @param money
* @return
*/
public boolean playerGrantMoney(OfflinePlayer player, double money) {
return economy.depositPlayer(player, money).transactionSuccess();
@@ -246,8 +217,6 @@ public final class PermissionsManager {
/**
* Check if a user has the money
*
* @param player
* @param money
* @return whether he has the money
*/
public boolean playerHasMoney(Player player, double money) {
@@ -257,7 +226,6 @@ public final class PermissionsManager {
/**
* Returns the players money
*
* @param player
* @return the players money
*/
public double playerGetMoney(Player player) {
@@ -272,7 +240,7 @@ public final class PermissionsManager {
* @param perm the permission
* @return whether he has the permission
*/
public boolean has(String world, OfflinePlayer player, String perm) {
public boolean has(@Nullable String world, OfflinePlayer player, String perm) {
if (player != null && permission != null) {
return permission.playerHas(world, player, perm);
}
@@ -289,14 +257,18 @@ public final class PermissionsManager {
*/
public boolean has(Player player, String perm) {
if (player == null) {
SimpleClans.debug("null player");
return false;
}
boolean hasPermission;
if (permission != null) {
return permission.has(player, perm);
hasPermission = permission.has(player, perm);
} else {
return player.hasPermission(perm);
hasPermission = player.hasPermission(perm);
}
SimpleClans.debug(String.format("Permission %s is %s for %s", perm, hasPermission, player.getName()));
return hasPermission;
}
/**
@@ -305,7 +277,6 @@ public final class PermissionsManager {
* @param player the player
* @param permission the rank permission
* @param notify notify the player if they don't have permission
* @return
*/
@Deprecated
public boolean has(Player player, RankPermission permission, PermissionLevel level, boolean notify) {
@@ -338,8 +309,10 @@ public final class PermissionsManager {
boolean hasRankPermission = false;
String rankName = clanPlayer.getRankId();
Clan clan = clanPlayer.getClan();
if (clan.hasRank(rankName)) {
hasRankPermission = clan.getRank(rankName).getPermissions().contains(permission.toString());
//noinspection ConstantConditions
if (clan.hasRank(rankName)) {
//noinspection ConstantConditions
hasRankPermission = clan.getRank(rankName).getPermissions().contains(permission.toString());
} else {
if (rankName != null && !rankName.isEmpty()) {
clanPlayer.setRank(null);
@@ -360,7 +333,6 @@ public final class PermissionsManager {
* @param player the player
* @param permission the rank permission
* @param notify notify the player if they don't have permission
* @return
*/
public boolean has(Player player, RankPermission permission, boolean notify) {
if (player == null || permission == null) {
@@ -396,8 +368,11 @@ public final class PermissionsManager {
boolean hasRankPermission = false;
String rankName = clanPlayer.getRankId();
Clan clan = clanPlayer.getClan();
if (clan.hasRank(rankName)) {
hasRankPermission = clan.getRank(rankName).getPermissions().contains(permission.toString());
if (clan != null) {
Rank rank = clan.getRank(rankName);
if (rank != null) {
hasRankPermission = rank.getPermissions().contains(permission.toString());
}
} else {
if (rankName != null && !rankName.isEmpty()) {
clanPlayer.setRank(null);
@@ -415,7 +390,6 @@ public final class PermissionsManager {
/**
* Gives the player permissions linked to a clan
*
* @param cp
*/
public void addClanPermissions(ClanPlayer cp) {
if (!plugin.getSettingsManager().isEnableAutoGroups()) {
@@ -450,13 +424,11 @@ public final class PermissionsManager {
if (!permission.playerInGroup(cp.toPlayer(), "sc_untrusted")) {
permission.playerAddGroup(cp.toPlayer(), "sc_untrusted");
}
permission.playerRemoveGroup(cp.toPlayer(), "sc_trusted");
permission.playerRemoveGroup(cp.toPlayer(), "sc_leader");
} else {
permission.playerRemoveGroup(cp.toPlayer(), "sc_untrusted");
permission.playerRemoveGroup(cp.toPlayer(), "sc_trusted");
permission.playerRemoveGroup(cp.toPlayer(), "sc_leader");
}
permission.playerRemoveGroup(cp.toPlayer(), "sc_trusted");
permission.playerRemoveGroup(cp.toPlayer(), "sc_leader");
}
}
}
@@ -464,7 +436,6 @@ public final class PermissionsManager {
/**
* Removes permissions linked to a clan from the player
*
* @param cp
*/
public void removeClanPermissions(ClanPlayer cp) {
if (!plugin.getSettingsManager().isEnableAutoGroups()) {
@@ -479,35 +450,30 @@ public final class PermissionsManager {
}
}
private Boolean setupPermissions() {
private void setupPermissions() {
RegisteredServiceProvider<Permission> permissionProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.permission.Permission.class);
if (permissionProvider != null) {
permission = permissionProvider.getProvider();
}
return permission != null;
}
private Boolean setupChat() {
private void setupChat() {
RegisteredServiceProvider<Chat> chatProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.chat.Chat.class);
if (chatProvider != null) {
chat = chatProvider.getProvider();
}
return chat != null;
}
private Boolean setupEconomy() {
private void setupEconomy() {
RegisteredServiceProvider<Economy> economyProvider = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
economy = economyProvider.getProvider();
}
return economy != null;
}
/**
* @param p
* @return
*/
public String getPrefix(Player p) {
String out = "";
@@ -552,8 +518,6 @@ public final class PermissionsManager {
}
/**
* @param p
* @return
*/
public String getSuffix(Player p) {
try {
@@ -1,442 +0,0 @@
package net.sacredlabyrinth.phaed.simpleclans.managers;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanFalse;
import static me.clip.placeholderapi.PlaceholderAPIPlugin.booleanTrue;
/**
* {@link Class} to manage and hook {@link SimpleClans} into {@link PlaceholderAPI}
*
* @since 2.10.1
*
* @author Peng1104
*/
public final class PlaceholdersManager extends PlaceholderExpansion {
/**
* The {@link Pattern} that identifies the top {@link Clan}s placeholder
*
* @since 1.12.3
*/
private static final Pattern TOP_CLANS_PATTERN = Pattern.compile("^topclans_\\d+_clan_");
/**
* The {@link List} containing all the placeholders of the {@link SimpleClans} {@link Plugin}
*
* @since 1.12.3
*/
private static final List<String> PLACEHOLDERS_LIST = new ArrayList<>();
static {
PLACEHOLDERS_LIST.add("%simpleclans_neutral_kills%");
PLACEHOLDERS_LIST.add("%simpleclans_rival_kills%");
PLACEHOLDERS_LIST.add("%simpleclans_civilian_kills%");
PLACEHOLDERS_LIST.add("%simpleclans_total_kills%");
PLACEHOLDERS_LIST.add("%simpleclans_weighted_kills%");
PLACEHOLDERS_LIST.add("%simpleclans_deaths%");
PLACEHOLDERS_LIST.add("%simpleclans_kdr%");
PLACEHOLDERS_LIST.add("%simpleclans_in_clan%");
PLACEHOLDERS_LIST.add("%simpleclans_is_leader%");
PLACEHOLDERS_LIST.add("%simpleclans_is_trusted%");
PLACEHOLDERS_LIST.add("%simpleclans_is_member%");
PLACEHOLDERS_LIST.add("%simpleclans_is_bb_enabled%");
PLACEHOLDERS_LIST.add("%simpleclans_is_usechatshortcut%");
PLACEHOLDERS_LIST.add("%simpleclans_is_allychat%");
PLACEHOLDERS_LIST.add("%simpleclans_is_clanchat%");
PLACEHOLDERS_LIST.add("%simpleclans_is_globalchat%");
PLACEHOLDERS_LIST.add("%simpleclans_is_cape_enabled%");
PLACEHOLDERS_LIST.add("%simpleclans_is_tag_enabled%");
PLACEHOLDERS_LIST.add("%simpleclans_is_friendlyfire_on%");
PLACEHOLDERS_LIST.add("%simpleclans_is_muted%");
PLACEHOLDERS_LIST.add("%simpleclans_is_mutedally%");
PLACEHOLDERS_LIST.add("%simpleclans_join_date%");
PLACEHOLDERS_LIST.add("%simpleclans_inactive_days%");
PLACEHOLDERS_LIST.add("%simpleclans_lastseen%");
PLACEHOLDERS_LIST.add("%simpleclans_lastseendays%");
PLACEHOLDERS_LIST.add("%simpleclans_tag%");
PLACEHOLDERS_LIST.add("%simpleclans_tag_label%");
PLACEHOLDERS_LIST.add("%simpleclans_rank%");
PLACEHOLDERS_LIST.add("%simpleclans_rank_displayname%");
PLACEHOLDERS_LIST.add("%simpleclans_clanchat_player_color%");
PLACEHOLDERS_LIST.add("%simpleclans_allychat_player_color%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_neutral%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_civilian%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_rival%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_kills%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_deaths%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_total_kdr%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_average_wk%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_leader_size%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_balance%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_allow_withdraw%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_allow_deposit%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_size%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_name%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_color_tag%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_tag%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_founded%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_friendly_fire%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_is_unrivable%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_is_anyonline%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_is_verified%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_capeurl%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_inactivedays%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_onlinemembers_count%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_allies_count%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_rivals_count%");
PLACEHOLDERS_LIST.add("%simpleclans_clan_topclans_position%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_neutral%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_civilian%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_rival%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_kills%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_deaths%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_total_kdr%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_average_wk%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_leader_size%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_balance%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_allow_withdraw%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_allow_deposit%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_size%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_name%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_color_tag%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_tag%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_founded%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_friendly_fire%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_is_unrivable%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_is_anyonline%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_is_verified%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_capeurl%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_inactivedays%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_onlinemembers_count%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_allies_count%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_rivals_count%");
PLACEHOLDERS_LIST.add("%simpleclans_topclans_<Number>_clan_topclans_position%");
}
/**
* The {@link SimpleClans} {@link Plugin} instance
*
* @since 2.10.1
*/
private final SimpleClans simpleClans;
/**
* The {@link PlaceholdersManager} constructor
*
* @param simpleClans The {@link SimpleClans} {@link Plugin}
*
* @since 2.10.1
*/
public PlaceholdersManager(@NotNull SimpleClans simpleClans) {
this.simpleClans = simpleClans;
}
/**
* Gets a value for the requested {@link ClanPlayer} and identifier
*
* @param player The {@link ClanPlayer} to request the placeholders value for
* @param identifier String that determine what value to return
*
* @return value for the requested {@link ClanPlayer} and params
*
* @since 2.10.1
*/
@NotNull
public String getPlaceholderValue(@Nullable ClanPlayer player, @NotNull String identifier) {
Clan clan = null;
if (TOP_CLANS_PATTERN.matcher(identifier).find()) {
// getting the position
int position = Integer.parseInt(identifier.substring(9, identifier.indexOf('_', 9)));
List<Clan> clans = simpleClans.getClanManager().getClans();
// validating position
if (position < 1 || position > clans.size()) {
return "";
}
simpleClans.getClanManager().sortClansByKDR(clans);
clan = clans.get(position - 1);
identifier = identifier.substring(identifier.indexOf('_', 9) + 1);
}
if (clan == null) {
if (player == null) {
return "";
}
clan = player.getClan();
switch (identifier) {
case "neutral_kills": {
return String.valueOf(player.getNeutralKills());
}
case "rival_kills": {
return String.valueOf(player.getRivalKills());
}
case "civilian_kills": {
return String.valueOf(player.getCivilianKills());
}
case "total_kills": {
return String.valueOf(player.getNeutralKills() + player.getRivalKills()
+ player.getCivilianKills());
}
case "weighted_kills": {
return String.valueOf(player.getWeightedKills());
}
case "deaths": {
return String.valueOf(player.getDeaths());
}
case "kdr": {
return String.valueOf(player.getKDR());
}
case "in_clan": {
return (clan != null) ? booleanTrue() : booleanFalse();
}
case "is_leader": {
return player.isLeader() ? booleanTrue() : booleanFalse();
}
case "is_trusted": {
return (!player.isLeader() && player.isTrusted()) ? booleanTrue()
: booleanFalse();
}
case "is_member": {
return (!player.isTrusted() && !player.isLeader() && clan != null)
? booleanTrue()
: booleanFalse();
}
case "is_bb_enabled": {
return player.isBbEnabled() ? booleanTrue() : booleanFalse();
}
case "is_usechatshortcut": {
return player.isUseChatShortcut() ? booleanTrue() : booleanFalse();
}
case "is_allychat": {
return player.isAllyChat() ? booleanTrue() : booleanFalse();
}
case "is_clanchat": {
return player.isClanChat() ? booleanTrue() : booleanFalse();
}
case "is_globalchat": {
return player.isGlobalChat() ? booleanTrue() : booleanFalse();
}
case "is_cape_enabled": {
return player.isCapeEnabled() ? booleanTrue() : booleanFalse();
}
case "is_tag_enabled": {
return player.isTagEnabled() ? booleanTrue() : booleanFalse();
}
case "is_friendlyfire_on": {
return player.isFriendlyFire() ? booleanTrue() : booleanFalse();
}
case "is_muted": {
return player.isMuted() ? booleanTrue() : booleanFalse();
}
case "is_mutedally": {
return player.isMutedAlly() ? booleanTrue() : booleanFalse();
}
case "join_date": {
return player.getJoinDateString();
}
case "inactive_days": {
return String.valueOf(player.getInactiveDays());
}
case "lastseen": {
return player.getLastSeenString();
}
case "lastseendays": {
return player.getLastSeenDaysString();
}
case "tag": {
return player.getTag();
}
case "tag_label": {
return player.getTagLabel();
}
case "rank": {
return player.getRankId();
}
case "rank_displayname": {
return player.getRankDisplayName();
}
case "clanchat_player_color": {
if (player.isLeader()) {
return simpleClans.getSettingsManager().getClanChatLeaderColor();
}
if (player.isTrusted()) {
return simpleClans.getSettingsManager().getClanChatTrustedColor();
}
if (clan != null) {
return simpleClans.getSettingsManager().getClanChatMemberColor();
}
return "";
}
case "allychat_player_color": {
if (player.isLeader()) {
return simpleClans.getSettingsManager().getAllyChatLeaderColor();
}
if (player.isTrusted()) {
return simpleClans.getSettingsManager().getAllyChatTrustedColor();
}
if (clan != null) {
return simpleClans.getSettingsManager().getAllyChatMemberColor();
}
return "";
}
default:
break;
}
if (clan == null) {
return "";
}
}
switch (identifier) {
case "clan_total_neutral": {
return String.valueOf(clan.getTotalNeutral());
}
case "clan_total_civilian": {
return String.valueOf(clan.getTotalCivilian());
}
case "clan_total_rival": {
return String.valueOf(clan.getTotalRival());
}
case "clan_total_kills": {
return String.valueOf(
clan.getTotalRival() + clan.getTotalNeutral() + clan.getTotalCivilian());
}
case "clan_total_deaths": {
return String.valueOf(clan.getTotalDeaths());
}
case "clan_total_kdr": {
return String.valueOf(clan.getTotalKDR());
}
case "clan_average_wk": {
return String.valueOf(clan.getAverageWK());
}
case "clan_leader_size": {
return String.valueOf(clan.getLeaders().size());
}
case "clan_balance": {
return String.valueOf(clan.getBalance());
}
case "clan_allow_withdraw": {
return clan.isAllowWithdraw() ? booleanTrue() : booleanFalse();
}
case "clan_allow_deposit": {
return clan.isAllowDeposit() ? booleanTrue() : booleanFalse();
}
case "clan_size": {
return String.valueOf(clan.getSize());
}
case "clan_name": {
return clan.getName();
}
case "clan_color_tag": {
return clan.getColorTag();
}
case "clan_tag": {
return clan.getTag();
}
case "clan_founded": {
return clan.getFoundedString();
}
case "clan_friendly_fire": {
return clan.isFriendlyFire() ? booleanTrue() : booleanFalse();
}
case "clan_is_unrivable": {
return clan.isUnrivable() ? booleanTrue() : booleanFalse();
}
case "clan_is_anyonline": {
return clan.isAnyOnline() ? booleanTrue() : booleanFalse();
}
case "clan_is_verified": {
return clan.isVerified() ? booleanTrue() : booleanFalse();
}
case "clan_capeurl": {
return clan.getCapeUrl();
}
case "clan_inactivedays": {
return String.valueOf(clan.getInactiveDays());
}
case "clan_onlinemembers_count": {
return String.valueOf(VanishUtils.getNonVanished(player == null ? null : player.toPlayer(),
clan).size());
}
case "clan_allies_count": {
return String.valueOf(clan.getAllies().size());
}
case "clan_rivals_count": {
return String.valueOf(clan.getRivals().size());
}
case "clan_topclans_position": {
List<Clan> clans = simpleClans.getClanManager().getClans();
simpleClans.getClanManager().sortClansByKDR(clans);
return String.valueOf(clans.indexOf(clan) + 1);
}
default:
break;
}
return "";
}
@Override
public String getIdentifier() {
return getName().toLowerCase();
}
@Override
public @NotNull String getAuthor() {
List<String> authors = new ArrayList<>(simpleClans.getDescription().getAuthors());
authors.add("Peng1104");
return authors.toString();
}
@Override
public String getVersion() {
return simpleClans.getDescription().getVersion();
}
@Override
public String onRequest(@Nullable OfflinePlayer player, @NotNull String params) {
ClanPlayer clanPlayer = null;
if (player != null) {
clanPlayer = simpleClans.getClanManager().getAnyClanPlayer(player.getUniqueId());
}
return getPlaceholderValue(clanPlayer, params);
}
@Override
public String getName() {
return simpleClans.getName();
}
@Override
public @NotNull List<String> getPlaceholders() {
return PLACEHOLDERS_LIST;
}
@Override
public boolean persist() {
return true;
}
@Override
public boolean canRegister() {
return true;
}
}
@@ -0,0 +1,285 @@
package net.sacredlabyrinth.phaed.simpleclans.managers;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.War;
import net.sacredlabyrinth.phaed.simpleclans.events.WarEndEvent;
import net.sacredlabyrinth.phaed.simpleclans.events.WarStartEvent;
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.Land;
import net.sacredlabyrinth.phaed.simpleclans.hooks.protection.ProtectionProvider;
import net.sacredlabyrinth.phaed.simpleclans.listeners.LandProtection;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.lang.reflect.InvocationTargetException;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
public class ProtectionManager {
private final SettingsManager settingsManager;
private final ClanManager clanManager;
private final Logger logger;
private final Map<War, BukkitTask> wars = new HashMap<>();
private final List<ProtectionProvider> providers = new ArrayList<>();
private LandProtection landProtection;
private final SimpleClans plugin;
public ProtectionManager() {
plugin = SimpleClans.getInstance();
settingsManager = plugin.getSettingsManager();
clanManager = plugin.getClanManager();
logger = plugin.getLogger();
if (!settingsManager.isWarEnabled() && !settingsManager.isLandSharing()) {
return;
}
//running on next tick, so all plugins are already loaded
Bukkit.getScheduler().runTask(plugin, this::registerProviders);
clearWars();
}
public void registerListeners() {
landProtection = new LandProtection(plugin);
if (!settingsManager.isWarEnabled() && !settingsManager.isLandSharing()) {
return;
}
landProtection.registerListeners();
}
/**
* Gets the Player's lands at the given Location, if not found, returns all Player's lands in the World
*
* @param player the Player
* @param location the Location
* @return the lands
*/
public Set<Land> getLands(@NotNull Player player, @NotNull Location location) {
Set<Land> lands = getLandsAt(location);
lands.removeIf(land -> !land.getOwners().contains(player.getUniqueId()));
if (lands.isEmpty()) {
lands = getLandsOf(player, player.getWorld());
}
return lands;
}
@NotNull
public Set<Land> getLandsAt(@NotNull Location location) {
Set<Land> lands = new HashSet<>();
for (ProtectionProvider provider : providers) {
lands.addAll(provider.getLandsAt(location));
}
return lands;
}
public boolean isOwner(@NotNull OfflinePlayer player, @NotNull Location location) {
for (Land land : getLandsAt(location)) {
if (land.getOwners().contains(player.getUniqueId())) {
return true;
}
}
return false;
}
@NotNull
public Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
Set<Land> lands = new HashSet<>();
for (ProtectionProvider provider : providers) {
lands.addAll(provider.getLandsOf(player, world));
}
return lands;
}
public boolean can(@NotNull Action action, @NotNull Location location, @NotNull Player player) {
return can(action, location, player, null);
}
public boolean can(@NotNull Action action, @NotNull Location location, @NotNull Player player, @Nullable Player other) {
for (Land land : getLandsAt(location)) {
for (UUID owner : land.getOwners()) {
Player involved;
if (other != null && player.getUniqueId().equals(owner)) {
involved = other;
} else {
involved = player;
}
if (isWarringAndAllowed(action, owner, involved) ||
isSameClanAndAllowed(action, owner, involved, land.getId())) {
return true;
}
}
}
return false;
}
public boolean addWar(@NotNull War war) {
if (wars.containsKey(war)) {
return false;
}
WarStartEvent event = new WarStartEvent(war);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
return false;
}
wars.put(war, scheduleTask(war, settingsManager.getWarNormalExpirationTime()));
return true;
}
@Nullable
private BukkitTask scheduleTask(@NotNull War war, int expirationTime) {
BukkitTask timeoutTask = null;
if (expirationTime > 0) {
timeoutTask = Bukkit.getScheduler().runTaskLater(plugin, new WarTimeoutTask(war), expirationTime);
}
return timeoutTask;
}
public void setWarExpirationTime(@NotNull Clan clan, int expirationTime) {
if (expirationTime < 1) {
return;
}
for (Map.Entry<War, BukkitTask> entry : wars.entrySet()) {
War war = entry.getKey();
if (!war.getClans().contains(clan)) {
continue;
}
BukkitTask task = entry.getValue();
if (task != null && !task.isCancelled()) {
task.cancel();
}
entry.setValue(scheduleTask(war, expirationTime));
}
}
public void removeWar(@Nullable War war, @NotNull WarEndEvent.Reason reason) {
if (war == null) {
return;
}
wars.remove(war);
Clan clan1 = war.getClans().get(0);
Clan clan2 = war.getClans().get(1);
clan1.removeWarringClan(clan2);
clan2.removeWarringClan(clan1);
WarEndEvent event = new WarEndEvent(war, reason);
Bukkit.getPluginManager().callEvent(event);
}
public @Nullable War getWar(@Nullable Clan clan1, @Nullable Clan clan2) {
if (clan1 == null || clan2 == null) {
return null;
}
for (War war : wars.keySet()) {
List<Clan> clans = war.getClans();
if (clans.contains(clan1) && clans.contains(clan2)) {
return war;
}
}
return null;
}
private void clearWars() {
if (!settingsManager.isWarEnabled()) {
return;
}
for (Clan clan : clanManager.getClans()) {
for (Clan warringClan : clan.getWarringClans()) {
clan.removeWarringClan(warringClan);
}
}
}
private boolean isSameClanAndAllowed(Action action, UUID owner, Player involved, String landId) {
if (!settingsManager.isLandSharing()) {
return false;
}
ClanPlayer cp = clanManager.getCreateClanPlayer(owner);
Clan involvedClan = clanManager.getClanByPlayerUniqueId(involved.getUniqueId());
if (cp.getClan() == null || !cp.getClan().equals(involvedClan)) {
return false;
}
return cp.isAllowed(action, landId);
}
private boolean isWarringAndAllowed(@NotNull Action action, @NotNull UUID owner, @NotNull Player involved) {
if (!settingsManager.isActionAllowedInWar(action) || !settingsManager.isWarEnabled()) {
return false;
}
Clan ownerClan = clanManager.getClanByPlayerUniqueId(owner);
Clan involvedClan = clanManager.getClanByPlayerUniqueId(involved.getUniqueId());
if (ownerClan == null || involvedClan == null) {
return false;
}
return ownerClan.isWarring(involvedClan);
}
private void registerProviders() {
for (String className : settingsManager.getProtectionProviders()) {
Object instance = null;
try {
Class<?> clazz = getProviderClass(className);
instance = clazz.getConstructor().newInstance();
} catch (ClassNotFoundException ex) {
logger.log(Level.WARNING, String.format("Provider %s not found!", className), ex);
} catch (NoSuchMethodException | InvocationTargetException | InstantiationException |
IllegalAccessException ex) {
logger.log(Level.WARNING, String.format("Error instantiating provider %s", className), ex);
}
if (instance instanceof ProtectionProvider) {
ProtectionProvider provider = (ProtectionProvider) instance;
String requiredPlugin = provider.getRequiredPluginName();
if (requiredPlugin != null && Bukkit.getPluginManager().getPlugin(requiredPlugin) == null) {
logger.warning(String.format("Required plugin %s for the provider %s was not found!",
requiredPlugin, instance.getClass().getSimpleName()));
continue;
}
provider.setup();
providers.add(provider);
landProtection.registerCreateLandEvent(provider, provider.getCreateLandEvent());
} else {
logger.warning(String.format("%s is not an instance of ProtectionProvider", className));
}
}
}
@NotNull
private Class<?> getProviderClass(String className) throws ClassNotFoundException {
try {
return Class.forName("net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers." + className);
} catch (ClassNotFoundException ignored) {
}
return Class.forName(className);
}
public enum Action {
BREAK, INTERACT, INTERACT_ENTITY, PLACE, DAMAGE, CONTAINER
}
private class WarTimeoutTask implements Runnable {
private final War war;
private WarTimeoutTask(War war) {
this.war = war;
}
@Override
public void run() {
removeWar(war, WarEndEvent.Reason.EXPIRATION);
Clan clan1 = war.getClans().get(0);
Clan clan2 = war.getClans().get(1);
clan1.addBb(clan1.getColorTag(), lang("war.expired", clan2.getTag()));
clan2.addBb(clan2.getColorTag(), lang("war.expired", clan1.getTag()));
}
}
}
@@ -3,14 +3,16 @@ package net.sacredlabyrinth.phaed.simpleclans.managers;
import net.sacredlabyrinth.phaed.simpleclans.*;
import net.sacredlabyrinth.phaed.simpleclans.events.RequestEvent;
import net.sacredlabyrinth.phaed.simpleclans.events.RequestFinishedEvent;
import net.sacredlabyrinth.phaed.simpleclans.events.WarEndEvent;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.text.MessageFormat;
import java.util.*;
import org.bukkit.scheduler.BukkitRunnable;
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
@@ -29,6 +31,7 @@ public final class RequestManager {
askerTask();
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean hasRequest(String tag) {
return requests.containsKey(tag);
}
@@ -104,7 +107,7 @@ public final class RequestManager {
if (requests.containsKey(warClan.getTag())) {
return;
}
String msg = MessageFormat.format(lang("proposing.war"), requestingClan.getName(), Helper.stripColors(warClan.getColorTag()));
String msg = MessageFormat.format(lang("proposing.war"), requestingClan.getName(), ChatUtils.stripColors(warClan.getColorTag()));
List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(warClan.getLeaders());
acceptors.remove(requester);
@@ -118,7 +121,7 @@ public final class RequestManager {
if (requests.containsKey(warClan.getTag())) {
return;
}
String msg = MessageFormat.format(lang("proposing.to.end.the.war"), requestingClan.getName(), Helper.stripColors(warClan.getColorTag()));
String msg = MessageFormat.format(lang("proposing.to.end.the.war"), requestingClan.getName(), ChatUtils.stripColors(warClan.getColorTag()));
List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(warClan.getLeaders());
acceptors.remove(requester);
@@ -132,7 +135,7 @@ public final class RequestManager {
if (requests.containsKey(allyClan.getTag())) {
return;
}
String msg = MessageFormat.format(lang("proposing.an.alliance"), requestingClan.getName(), Helper.stripColors(allyClan.getColorTag()));
String msg = MessageFormat.format(lang("proposing.an.alliance"), requestingClan.getName(), ChatUtils.stripColors(allyClan.getColorTag()));
List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(allyClan.getLeaders());
acceptors.remove(requester);
@@ -146,7 +149,7 @@ public final class RequestManager {
if (requests.containsKey(rivalClan.getTag())) {
return;
}
String msg = MessageFormat.format(lang("proposing.to.end.the.rivalry"), requestingClan.getName(), Helper.stripColors(rivalClan.getColorTag()));
String msg = MessageFormat.format(lang("proposing.to.end.the.rivalry"), requestingClan.getName(), ChatUtils.stripColors(rivalClan.getColorTag()));
List<ClanPlayer> acceptors = Helper.stripOffLinePlayers(rivalClan.getLeaders());
acceptors.remove(requester);
@@ -329,6 +332,8 @@ public final class RequestManager {
List<String> denies) {
if (requesterClan != null && targetClan != null) {
if (!accepts.isEmpty()) {
War war = plugin.getProtectionManager().getWar(requesterClan, requesterClan);
plugin.getProtectionManager().removeWar(war, WarEndEvent.Reason.REQUEST);
requesterClan.removeWarringClan(targetClan);
targetClan.removeWarringClan(requesterClan);
@@ -345,14 +350,21 @@ public final class RequestManager {
List<String> denies) {
if (requesterClan != null && targetClan != null) {
if (!accepts.isEmpty()) {
if (!plugin.getProtectionManager().addWar(new War(requesterClan, targetClan))) {
return;
}
requesterClan.addWarringClan(targetClan);
targetClan.addWarringClan(requesterClan);
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + lang("you.are.at.war", targetClan.getName(), requesterClan.getColorTag()));
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + lang("you.are.at.war", requesterClan.getName(), targetClan.getColorTag()));
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + lang("you.are.at.war",
targetClan.getName(), requesterClan.getColorTag()));
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + lang("you.are.at.war",
requesterClan.getName(), targetClan.getColorTag()));
} else {
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + lang("denied.war.req", denies.get(0), requesterClan.getName()));
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + lang("end.war.denied", targetClan.getName()));
targetClan.addBb(requesterCp.getName(), ChatColor.AQUA + lang("denied.war.req", denies.get(0),
requesterClan.getName()));
requesterClan.addBb(requesterCp.getName(), ChatColor.AQUA + lang("end.war.denied",
targetClan.getName()));
}
}
}
@@ -406,42 +418,24 @@ public final class RequestManager {
* @param req the Request
*/
public void ask(final Request req) {
final String tag = plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketLeft() + plugin.getSettingsManager().getTagDefaultColor() + req.getClan().getColorTag() + plugin.getSettingsManager().getClanChatBracketColor() + plugin.getSettingsManager().getClanChatTagBracketRight();
final String message = tag + " " + plugin.getSettingsManager().getRequestMessageColor() + req.getMsg();
if (req.getType().equals(ClanRequest.INVITE)) {
Player player = Bukkit.getPlayerExact(req.getTarget());
if (player != null) {
String options = lang("accept.or.deny", player, ChatBlock.makeEmpty(Helper.stripColors(tag)) + " " + ChatColor.DARK_GREEN + "/" + plugin.getSettingsManager().getCommandAccept() + plugin.getSettingsManager().getPageHeadingsColor(), ChatColor.DARK_RED + "/" + plugin.getSettingsManager().getCommandDeny());
ChatBlock.sendBlank(player);
ChatBlock.sendMessage(player, message);
ChatBlock.sendMessage(player, options);
ChatBlock.sendBlank(player);
}
String message = lang("request.message", req.getClan().getColorTag(), req.getMsg());
ArrayList<Player> recipients = new ArrayList<>();
if (req.getType() == ClanRequest.INVITE) {
recipients.add(Bukkit.getPlayerExact(req.getTarget()));
} else {
for (ClanPlayer cp : req.getAcceptors()) {
if (cp.getVote() == null) {
Player player = cp.toPlayer();
if (player != null) {
String options = lang("accept.or.deny", player, ChatBlock.makeEmpty(Helper.stripColors(tag)) + " " + ChatColor.DARK_GREEN + "/" + plugin.getSettingsManager().getCommandAccept() + plugin.getSettingsManager().getPageHeadingsColor(), ChatColor.DARK_RED + "/" + plugin.getSettingsManager().getCommandDeny());
ChatBlock.sendBlank(player);
ChatBlock.sendMessage(player, message);
ChatBlock.sendMessage(player, options);
ChatBlock.sendBlank(player);
}
recipients.add(cp.toPlayer());
}
}
}
new BukkitRunnable() {
@Override
public void run() {
SimpleClans.getInstance().getServer().getPluginManager().callEvent(new RequestEvent(req));
for (Player recipient : recipients) {
if (recipient != null) {
recipient.spigot().sendMessage(ChatUtils.toBaseComponents(recipient, message));
}
}.runTask(plugin);
}
Bukkit.getScheduler().runTask(plugin, () -> Bukkit.getPluginManager().callEvent(new RequestEvent(req)));
}
}
@@ -13,6 +13,8 @@ import org.bukkit.configuration.file.FileConfiguration;
import net.sacredlabyrinth.phaed.simpleclans.Helper;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import org.bukkit.event.EventPriority;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -21,7 +23,7 @@ import org.jetbrains.annotations.Nullable;
* @author phaed
*/
public final class SettingsManager {
private boolean enableGUI;
private boolean enableGUI;
private boolean disableMessages;
private String clanChatRankColor;
private boolean tagBasedClanChat;
@@ -177,7 +179,7 @@ public final class SettingsManager {
private boolean moneyperkill;
private double KDRMultipliesPerKill;
private boolean teleportBlocks;
private boolean AutoGroupGroupName;
private boolean autoGroupGroupName;
private boolean tamableMobsSharing;
private boolean allowReGroupCommand;
private boolean useThreads;
@@ -189,13 +191,20 @@ public final class SettingsManager {
private int maxKillsPerVictim;
private boolean delayBetweenKillsEnabled;
private int delayBetweenKills;
private String language;
private boolean languagePerPlayer;
private boolean savePeriodically;
private boolean cachePlayerHeads;
private int saveInterval;
private String rankingType;
private int loreLength;
private String language;
private boolean languagePerPlayer;
private boolean savePeriodically;
private boolean cachePlayerHeads;
private int saveInterval;
private String rankingType;
private int loreLength;
private boolean warEnabled;
private boolean landSharing;
private List<String> protectionProviders;
private EventPriority warListenerPriority;
private boolean onlyLeadersCanCreateLands;
private boolean onlyOneLandPerClan;
private boolean setBaseOnlyInLand;
/**
*
@@ -205,6 +214,7 @@ public final class SettingsManager {
config = plugin.getConfig();
main = new File(plugin.getDataFolder() + File.separator + "config.yml");
load();
warnAboutAutoGroupGroupName();
}
/**
@@ -231,14 +241,14 @@ public final class SettingsManager {
teleportOnSpawn = getConfig().getBoolean("settings.teleport-home-on-spawn");
dropOnHome = getConfig().getBoolean("settings.drop-items-on-clan-home");
keepOnHome = getConfig().getBoolean("settings.keep-items-on-clan-home");
for (String material : getConfig().getStringList("settings.item-list")) {
for (String material : getConfig().getStringList("settings.item-list")) {
Optional<XMaterial> x = XMaterial.matchXMaterial(material);
if (x.isPresent()) {
itemsList.add(x.get().parseMaterial());
} else {
plugin.getLogger().warning("Error with Material: " + material);
}
}
}
debugging = getConfig().getBoolean("settings.show-debug-info");
mChatIntegration = getConfig().getBoolean("settings.mchat-integration");
pvpOnlywhileInWar = getConfig().getBoolean("settings.pvp-only-while-at-war");
@@ -391,7 +401,7 @@ public final class SettingsManager {
teleportBlocks = getConfig().getBoolean("settings.teleport-blocks");
language = getConfig().getString("settings.language", "");
languagePerPlayer = getConfig().getBoolean("settings.user-language-selector", true);
AutoGroupGroupName = getConfig().getBoolean("permissions.auto-group-groupname");
autoGroupGroupName = getConfig().getBoolean("permissions.auto-group-groupname");
tamableMobsSharing = getConfig().getBoolean("settings.tameable-mobs-sharing");
allowReGroupCommand = getConfig().getBoolean("settings.allow-regroup-command");
loreLength = getConfig().getInt("settings.lore-length", 38);
@@ -405,7 +415,14 @@ public final class SettingsManager {
maxKillsPerVictimEnabled = getConfig().getBoolean("kdr-grinding-prevention.enable-max-kills");
delayBetweenKills = getConfig().getInt("kdr-grinding-prevention.delay-between-kills");
delayBetweenKillsEnabled = getConfig().getBoolean("kdr-grinding-prevention.enable-kill-delay");
warEnabled = getConfig().getBoolean("war-and-protection.war-enabled", false);
landSharing = getConfig().getBoolean("war-and-protection.land-sharing", true);
protectionProviders = getConfig().getStringList("war-and-protection.protection-providers");
warListenerPriority = EventPriority.valueOf(getConfig().getString("war-and-protection.listener-priority", "HIGHEST"));
onlyLeadersCanCreateLands = getConfig().getBoolean("war-and-protection.land-creation.only-leaders", false);
onlyOneLandPerClan = getConfig().getBoolean("war-and-protection.land-creation.only-one-per-clan", false);
setBaseOnlyInLand = getConfig().getBoolean("war-and-protection.set-base-only-in-land", false);
// migrate from old way of adding ports
if (database.contains(":")) {
String[] strings = database.split(":");
@@ -425,6 +442,57 @@ public final class SettingsManager {
}
}
private void warnAboutAutoGroupGroupName() {
Plugin luckPerms = Bukkit.getServer().getPluginManager().getPlugin("LuckPerms");
if (luckPerms != null && autoGroupGroupName) {
plugin.getLogger().warning("LuckPerms was found and the setting auto-group-groupname is enabled.");
plugin.getLogger().warning("Be careful with that as players will be automatically added in the group" +
" that matches their clan tag.");
}
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isWarEnabled() {
return warEnabled;
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean isLandSharing() {
return landSharing;
}
public int getWarNormalExpirationTime() {
return getConfig().getInt("war-and-protection.war-normal-expiration-time", 60) * 60 * 20;
}
public int getWarDisconnectExpirationTime() {
return getConfig().getInt("war-and-protection.war-disconnect-expiration-time", 10) * 60 * 20;
}
public List<String> getProtectionProviders() {
return protectionProviders;
}
public EventPriority getWarListenerPriority() {
return warListenerPriority;
}
public boolean isActionAllowedInWar(@NotNull ProtectionManager.Action action) {
return getConfig().getBoolean("war-and-protection.war-actions." + action.name(), false);
}
public boolean isOnlyLeadersCanCreateLands() {
return onlyLeadersCanCreateLands;
}
public boolean isOnlyOneLandPerClan() {
return onlyOneLandPerClan;
}
public boolean isSetBaseOnlyInLand() {
return setBaseOnlyInLand;
}
public int getLoreLength() {
return loreLength;
}
@@ -432,33 +500,32 @@ public final class SettingsManager {
public boolean isCachePlayerHeads() {
return cachePlayerHeads;
}
public boolean isEnableGUI() {
return enableGUI;
}
return enableGUI;
}
public void setEnableGUI(boolean enableGUI) {
this.enableGUI = enableGUI;
this.enableGUI = enableGUI;
getConfig().set("settings.enable-gui", enableGUI);
save();
}
/**
*
* @return if the tag can contain letters from other alphabets
*/
public boolean isAcceptOtherAlphabetsLettersOnTag() {
return acceptOtherAlphabetsLettersOnTag;
}
public Locale getLanguage() {
String[] split = language.split("_");
if (split.length == 2) {
return new Locale(split[0], split[1]);
}
return new Locale(language);
public Locale getLanguage() {
String[] split = language.split("_");
if (split.length == 2) {
return new Locale(split[0], split[1]);
}
return new Locale(language);
}
@NotNull
@@ -471,95 +538,95 @@ public final class SettingsManager {
}
public boolean isLanguagePerPlayer() {
return languagePerPlayer;
return languagePerPlayer;
}
public int getTasksCollectUpkeepHour() {
return tasksCollectUpkeepHour;
}
return tasksCollectUpkeepHour;
}
public void setTasksCollectUpkeepHour(int tasksCollectUpkeepHour) {
this.tasksCollectUpkeepHour = tasksCollectUpkeepHour;
}
public void setTasksCollectUpkeepHour(int tasksCollectUpkeepHour) {
this.tasksCollectUpkeepHour = tasksCollectUpkeepHour;
}
public int getTasksCollectUpkeepMinute() {
return tasksCollectUpkeepMinute;
}
public int getTasksCollectUpkeepMinute() {
return tasksCollectUpkeepMinute;
}
public void setTasksCollectUpkeepMinute(int tasksCollectUpkeepMinute) {
this.tasksCollectUpkeepMinute = tasksCollectUpkeepMinute;
}
public void setTasksCollectUpkeepMinute(int tasksCollectUpkeepMinute) {
this.tasksCollectUpkeepMinute = tasksCollectUpkeepMinute;
}
public int getTasksCollectUpkeepWarningHour() {
return tasksCollectUpkeepWarningHour;
}
public int getTasksCollectUpkeepWarningHour() {
return tasksCollectUpkeepWarningHour;
}
public void setTasksCollectUpkeepWarningHour(int tasksCollectUpkeepWarningHour) {
this.tasksCollectUpkeepWarningHour = tasksCollectUpkeepWarningHour;
}
public void setTasksCollectUpkeepWarningHour(int tasksCollectUpkeepWarningHour) {
this.tasksCollectUpkeepWarningHour = tasksCollectUpkeepWarningHour;
}
public int getTasksCollectUpkeepWarningMinute() {
return tasksCollectUpkeepWarningMinute;
}
public int getTasksCollectUpkeepWarningMinute() {
return tasksCollectUpkeepWarningMinute;
}
public void setTasksCollectUpkeepWarningMinute(int tasksCollectUpkeepWarningMinute) {
this.tasksCollectUpkeepWarningMinute = tasksCollectUpkeepWarningMinute;
}
public void setTasksCollectUpkeepWarningMinute(int tasksCollectUpkeepWarningMinute) {
this.tasksCollectUpkeepWarningMinute = tasksCollectUpkeepWarningMinute;
}
public int getTasksCollectFeeHour() {
return tasksCollectFeeHour;
}
public int getTasksCollectFeeHour() {
return tasksCollectFeeHour;
}
public void setTasksCollectFeeHour(int tasksCollectFeeHour) {
this.tasksCollectFeeHour = tasksCollectFeeHour;
}
public void setTasksCollectFeeHour(int tasksCollectFeeHour) {
this.tasksCollectFeeHour = tasksCollectFeeHour;
}
public int getTasksCollectFeeMinute() {
return tasksCollectFeeMinute;
}
public int getTasksCollectFeeMinute() {
return tasksCollectFeeMinute;
}
public void setTasksCollectFeeMinute(int tasksCollectFeeMinute) {
this.tasksCollectFeeMinute = tasksCollectFeeMinute;
}
public void setTasksCollectFeeMinute(int tasksCollectFeeMinute) {
this.tasksCollectFeeMinute = tasksCollectFeeMinute;
}
public int getMinToVerify() {
public int getMinToVerify() {
return minToVerify;
}
/**
/**
* Returns the delay between kills
*
*
* @return
*/
public int getDelayBetweenKills() {
return delayBetweenKills;
return delayBetweenKills;
}
/**
* Checks if the delay between kills is enabled
*
*
* @return
*/
public boolean isDelayBetweenKills() {
return delayBetweenKillsEnabled;
return delayBetweenKillsEnabled;
}
/**
* Returns the max number of kills per victim
*
*
* @return
*/
public int getMaxKillsPerVictim() {
return maxKillsPerVictim;
return maxKillsPerVictim;
}
/**
* Checks if there is a max number of kills per victim
*
*
* @return
*/
public boolean isMaxKillsPerVictim() {
return maxKillsPerVictimEnabled;
return maxKillsPerVictimEnabled;
}
/**
@@ -574,7 +641,7 @@ public final class SettingsManager {
/**
* Gets the command set as the clan chat command
*
*
* @return the clan chat command
*/
public String getCommandClanChat() {
@@ -621,38 +688,38 @@ public final class SettingsManager {
return word.equalsIgnoreCase("clan") || word.equalsIgnoreCase(commandMore) || word.equalsIgnoreCase(commandDeny) || word.equalsIgnoreCase(commandAccept);
}
/**
* Checks if the upkeep is to be charged only from clans with the member fee enabled
*
*
* @return
*/
public boolean isChargeUpkeepOnlyIfMemberFeeEnabled() {
return eChargeUpkeepOnlyIfMemberFeeEnabled;
return eChargeUpkeepOnlyIfMemberFeeEnabled;
}
/**
* Checks if the upkeep should be multiplied by the clan size
*
* @return
*
* @return
*/
public boolean isMultiplyUpkeepBySize() {
return eMultiplyUpkeepBySize;
}
/**
* Checks if the upkeep is enabled
*
* @return
*
* @return
*/
public boolean isClanUpkeep() {
return eClanUpkeepEnabled;
}
/**
* Returns the upkeep
*
* @return
*
* @return
*/
public double getClanUpkeep() {
if (eClanUpkeep < 0) {
@@ -660,19 +727,21 @@ public final class SettingsManager {
}
return eClanUpkeep;
}
/**
* Returns the max member fee allowed
* @return
*
* @return
*/
public double getMaxMemberFee() {
return eMaxMemberFee;
}
/**
* Checks if the member fee is enabled
* @return
*
* @return
*/
public boolean isMemberFee() {
return eMemberFee;
@@ -685,10 +754,10 @@ public final class SettingsManager {
public boolean isePurchaseResetKdr() {
return ePurchaseResetKdr;
}
/**
* Gets the price to pay for setting the member fee
*
*
* @return the price
*/
public double geteMemberFeeSetPrice() {
@@ -701,6 +770,7 @@ public final class SettingsManager {
/**
* Do leaders need to pay for setting the member fee?
*
* @return true if so
*/
public boolean isePurchaseMemberFeeSet() {
@@ -709,12 +779,13 @@ public final class SettingsManager {
/**
* Gets the price to reset the KDR
*
* @return the price
*/
public double geteResetKdr() {
return eResetKdr;
}
/**
* Check whether a string has a disallowed color
*
@@ -790,7 +861,7 @@ public final class SettingsManager {
if (!bannedPlayers.contains(playerUniqueId.toString())) {
bannedPlayers.add(playerUniqueId.toString());
}
getConfig().set("settings.banned-players", bannedPlayers);
save();
}
@@ -807,7 +878,7 @@ public final class SettingsManager {
*/
public void removeBanned(UUID playerUniqueId) {
bannedPlayers.remove(playerUniqueId.toString());
getConfig().set("settings.banned-players", bannedPlayers);
save();
}
@@ -830,61 +901,61 @@ public final class SettingsManager {
public boolean isRequireVerification() {
return requireVerification;
}
public boolean isRejoinCooldown() {
return rejoinCooldownEnabled;
return rejoinCooldownEnabled;
}
public int getRejoinCooldown() {
return rejoinCooldown;
return rejoinCooldown;
}
@NotNull
public String getListDefaultOrderBy() {
return listDefaultOrderBy;
}
return listDefaultOrderBy;
}
@Deprecated
public String getListDefault() {
@Deprecated
public String getListDefault() {
return getListDefaultOrderBy();
}
@Deprecated
public String getListSize() {
return "size";
}
@Deprecated
public String getListKdr() {
return "kdr";
}
@Deprecated
public String getListName() {
return "name";
}
@Deprecated
public String getListFounded() {
return "founded";
}
@Deprecated
public String getListSize() {
return "size";
}
@Deprecated
public String getListActive() {
return "active";
}
public String getListKdr() {
return "kdr";
}
@Deprecated
public String getListAsc() {
return "asc";
}
@Deprecated
public String getListName() {
return "name";
}
@Deprecated
public String getListDesc() {
return "desc";
}
@Deprecated
public String getListFounded() {
return "founded";
}
/**
@Deprecated
public String getListActive() {
return "active";
}
@Deprecated
public String getListAsc() {
return "asc";
}
@Deprecated
public String getListDesc() {
return "desc";
}
/**
* @return the bannedPlayers
*/
public List<String> getBannedPlayers() {
@@ -1065,32 +1136,32 @@ public final class SettingsManager {
public int getClanMinSizeToRival() {
return clanMinSizeToRival;
}
/**
* Returns the max length of the clan description
*
*
* @return the max length
*/
public int getClanMaxDescriptionLength() {
if (clanMaxDescriptionLength > 255 || clanMaxDescriptionLength < 0) {
clanMaxDescriptionLength = 255;
}
return clanMaxDescriptionLength;
}
if (clanMaxDescriptionLength > 255 || clanMaxDescriptionLength < 0) {
clanMaxDescriptionLength = 255;
}
return clanMaxDescriptionLength;
}
/**
* Returns the min length of the clan description
*
*
* @return the min length
*/
public int getClanMinDescriptionLength() {
if (clanMinDescriptionLength < 0 || clanMinDescriptionLength > getClanMaxDescriptionLength()) {
clanMinDescriptionLength = 0;
}
return clanMinDescriptionLength;
}
public int getClanMinDescriptionLength() {
if (clanMinDescriptionLength < 0 || clanMinDescriptionLength > getClanMaxDescriptionLength()) {
clanMinDescriptionLength = 0;
}
return clanMinDescriptionLength;
}
/**
/**
* @return the clanMinLength
*/
public int getClanMinLength() {
@@ -1098,7 +1169,6 @@ public final class SettingsManager {
}
/**
*
* @return the max number of alliances a clan can have
*/
public int getClanMaxAlliances() {
@@ -1161,23 +1231,23 @@ public final class SettingsManager {
public String getTagSeparatorColor() {
return Helper.toColor(tagSeparatorColor);
}
public String getClanChatFormat() {
return clanChatFormat;
}
public String getClanChatRank() {
return clanChatRank;
}
public String getClanChatLeaderColor() {
return Helper.toColor(clanChatLeaderColor);
}
public String getClanChatTrustedColor() {
return Helper.toColor(clanChatTrustedColor);
}
return Helper.toColor(clanChatTrustedColor);
}
public String getClanChatMemberColor() {
return Helper.toColor(clanChatMemberColor);
}
@@ -1204,7 +1274,7 @@ public final class SettingsManager {
public String getClanChatNameColor() {
return clanChatNameColor;
}
@Deprecated
/**
* @return the clanChatTagBracketLeft
@@ -1435,10 +1505,10 @@ public final class SettingsManager {
public boolean isConfirmationForDemote() {
return confirmationForDemote;
}
/**
* Returns the min percentage of leaders online required to demote someone
*
*
* @return the percentage
*/
public double getPercentageOnlineToDemote() {
@@ -1468,23 +1538,23 @@ public final class SettingsManager {
public String getAllyChatMessageColor() {
return allyChatMessageColor;
}
public String getAllyChatFormat() {
return allyChatFormat;
}
public String getAllyChatRank() {
return allyChatRank;
}
public String getAllyChatLeaderColor() {
return Helper.toColor(allyChatLeaderColor);
}
public String getAllyChatTrustedColor() {
return Helper.toColor(allyChatTrustedColor);
}
return Helper.toColor(allyChatTrustedColor);
}
public String getAllyChatMemberColor() {
return Helper.toColor(allyChatMemberColor);
}
@@ -1518,7 +1588,7 @@ public final class SettingsManager {
public String getAllyChatPlayerBracketRight() {
return allyChatPlayerBracketRight;
}
public String getCommandGlobal() {
return commandGlobal;
}
@@ -1598,7 +1668,7 @@ public final class SettingsManager {
public boolean isePurchaseHomeTeleport() {
return ePurchaseHomeTeleport;
}
/**
* @return the eUniqueTaxOnRegroup
*/
@@ -1607,13 +1677,12 @@ public final class SettingsManager {
}
/**
*
* @return the eIssuerPaysRegroup
*/
public boolean iseIssuerPaysRegroup() {
return eIssuerPaysRegroup;
}
/**
* @return the ePurchaseHomeRegroup
*/
@@ -1627,7 +1696,7 @@ public final class SettingsManager {
public double getHomeTeleportPrice() {
return eHomeTeleportPrice;
}
/**
* @return the HomeRegroupPrice
*/
@@ -1681,7 +1750,7 @@ public final class SettingsManager {
* @return the AutoGroupGroupName
*/
public boolean isAutoGroupGroupName() {
return AutoGroupGroupName;
return autoGroupGroupName;
}
/**
@@ -1754,20 +1823,20 @@ public final class SettingsManager {
return this.maxMembers;
}
public boolean isSavePeriodically() {
return savePeriodically;
}
public boolean isSavePeriodically() {
return savePeriodically;
}
/**
* Gets the interval to save the data
*
* @return the interval in seconds
*/
public int getSaveInterval() {
if (saveInterval < 1) {
saveInterval = 5;
}
return saveInterval * 60;
}
/**
* Gets the interval to save the data
*
* @return the interval in seconds
*/
public int getSaveInterval() {
if (saveInterval < 1) {
saveInterval = 5;
}
return saveInterval * 60;
}
}
@@ -7,6 +7,7 @@ import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
import net.sacredlabyrinth.phaed.simpleclans.storage.DBCore;
import net.sacredlabyrinth.phaed.simpleclans.storage.MySQLCore;
import net.sacredlabyrinth.phaed.simpleclans.storage.SQLiteCore;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.utils.YAMLSerializer;
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDFetcher;
import net.sacredlabyrinth.phaed.simpleclans.uuid.UUIDMigration;
@@ -17,6 +18,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import org.json.simple.JSONObject;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -86,20 +88,20 @@ public final class StorageManager {
plugin.getLogger().info("Creating table: sc_clans");
String query = "CREATE TABLE IF NOT EXISTS `sc_clans` ("
+ " `id` bigint(20) NOT NULL auto_increment,"
+ " `verified` tinyint(1) default '0',"
+ " `tag` varchar(25) NOT NULL,"
+ " `color_tag` varchar(25) NOT NULL,"
+ " `name` varchar(100) NOT NULL,"
+ " `description` varchar(255),"
+ " `friendly_fire` tinyint(1) default '0',"
+ " `founded` bigint NOT NULL,"
+ " `last_used` bigint NOT NULL,"
+ " `packed_allies` text NOT NULL,"
+ " `packed_rivals` text NOT NULL,"
+ " `packed_bb` mediumtext NOT NULL,"
+ " `cape_url` varchar(255) NOT NULL,"
+ " `flags` text NOT NULL,"
+ " `id` bigint(20) NOT NULL auto_increment,"
+ " `verified` tinyint(1) default '0',"
+ " `tag` varchar(25) NOT NULL,"
+ " `color_tag` varchar(255) NOT NULL,"
+ " `name` varchar(100) NOT NULL,"
+ " `description` varchar(255),"
+ " `friendly_fire` tinyint(1) default '0',"
+ " `founded` bigint NOT NULL,"
+ " `last_used` bigint NOT NULL,"
+ " `packed_allies` text NOT NULL,"
+ " `packed_rivals` text NOT NULL,"
+ " `packed_bb` mediumtext NOT NULL,"
+ " `cape_url` varchar(255) NOT NULL,"
+ " `flags` text NOT NULL,"
+ " `balance` double(64,2),"
+ " `fee_enabled` tinyint(1) default '0',"
+ " `fee_value` double(64,2),"
@@ -162,20 +164,20 @@ public final class StorageManager {
plugin.getLogger().info("Creating table: sc_clans");
String query = "CREATE TABLE IF NOT EXISTS `sc_clans` ("
+ " `id` bigint(20),"
+ " `verified` tinyint(1) default '0',"
+ " `tag` varchar(25) NOT NULL,"
+ " `color_tag` varchar(25) NOT NULL,"
+ " `name` varchar(100) NOT NULL,"
+ " `description` varchar(255),"
+ " `friendly_fire` tinyint(1) default '0',"
+ " `founded` bigint NOT NULL,"
+ " `last_used` bigint NOT NULL,"
+ " `packed_allies` text NOT NULL,"
+ " `packed_rivals` text NOT NULL,"
+ " `packed_bb` mediumtext NOT NULL,"
+ " `cape_url` varchar(255) NOT NULL,"
+ " `flags` text NOT NULL,"
+ " `id` bigint(20),"
+ " `verified` tinyint(1) default '0',"
+ " `tag` varchar(25) NOT NULL,"
+ " `color_tag` varchar(255) NOT NULL,"
+ " `name` varchar(100) NOT NULL,"
+ " `description` varchar(255),"
+ " `friendly_fire` tinyint(1) default '0',"
+ " `founded` bigint NOT NULL,"
+ " `last_used` bigint NOT NULL,"
+ " `packed_allies` text NOT NULL,"
+ " `packed_rivals` text NOT NULL,"
+ " `packed_bb` mediumtext NOT NULL,"
+ " `cape_url` varchar(255) NOT NULL,"
+ " `flags` text NOT NULL,"
+ " `balance` double(64,2) default 0.0,"
+ " `fee_enabled` tinyint(1) default '0',"
+ " `fee_value` double(64,2),"
@@ -316,7 +318,7 @@ public final class StorageManager {
}
for (Clan clan : purge) {
plugin.getLogger().info(MessageFormat.format(lang("purging.clan"), clan.getName()));
plugin.getLogger().info(lang("purging.clan", clan.getName()));
deleteClan(clan);
clans.remove(clan);
}
@@ -336,7 +338,7 @@ public final class StorageManager {
}
for (ClanPlayer cp : purge) {
plugin.getLogger().info(MessageFormat.format(lang("purging.player.data"), cp.getName()));
plugin.getLogger().info(lang("purging.player.data", cp.getName()));
deleteClanPlayer(cp);
cps.remove(cp);
}
@@ -360,15 +362,14 @@ public final class StorageManager {
boolean verified = res.getBoolean("verified");
boolean friendly_fire = res.getBoolean("friendly_fire");
String tag = res.getString("tag");
String color_tag = Helper.parseColors(res.getString("color_tag"));
String color_tag = ChatUtils.parseColors(res.getString("color_tag"));
String name = res.getString("name");
String description = res.getString("description");
String packed_allies = res.getString("packed_allies");
String packed_rivals = res.getString("packed_rivals");
String packed_bb = res.getString("packed_bb");
String cape_url = res.getString("cape_url");
String flags = res.getString("flags");
String ranks = res.getString("ranks");
JSONObject ranks = Helper.parseJson(res.getString("ranks"));
long founded = res.getLong("founded");
long last_used = res.getLong("last_used");
double balance = res.getDouble("balance");
@@ -395,20 +396,18 @@ public final class StorageManager {
clan.setPackedAllies(packed_allies);
clan.setPackedRivals(packed_rivals);
clan.setPackedBb(packed_bb);
clan.setCapeUrl(cape_url);
clan.setFounded(founded);
clan.setLastUsed(last_used);
clan.setBalance(balance);
clan.setMemberFee(feeValue);
clan.setMemberFeeEnabled(feeEnabled);
clan.setRanks(Helper.ranksFromJson(ranks));
clan.setDefaultRank(Helper.defaultRankFromJson(ranks));
clan.setBanner(banner);
out.add(clan);
} catch (Exception ex) {
for (StackTraceElement el : ex.getStackTrace()) {
System.out.print(el.toString());
}
ex.printStackTrace();
}
}
} catch (SQLException ex) {
@@ -440,15 +439,14 @@ public final class StorageManager {
boolean verified = res.getBoolean("verified");
boolean friendly_fire = res.getBoolean("friendly_fire");
String tag = res.getString("tag");
String color_tag = Helper.parseColors(res.getString("color_tag"));
String color_tag = ChatUtils.parseColors(res.getString("color_tag"));
String name = res.getString("name");
String description = res.getString("description");
String packed_allies = res.getString("packed_allies");
String packed_rivals = res.getString("packed_rivals");
String packed_bb = res.getString("packed_bb");
String cape_url = res.getString("cape_url");
String flags = res.getString("flags");
String ranks = res.getString("ranks");
JSONObject ranks = Helper.parseJson(res.getString("ranks"));
long founded = res.getLong("founded");
long last_used = res.getLong("last_used");
double balance = res.getDouble("balance");
@@ -475,20 +473,18 @@ public final class StorageManager {
clan.setPackedAllies(packed_allies);
clan.setPackedRivals(packed_rivals);
clan.setPackedBb(packed_bb);
clan.setCapeUrl(cape_url);
clan.setFounded(founded);
clan.setLastUsed(last_used);
clan.setBalance(balance);
clan.setMemberFee(feeValue);
clan.setMemberFeeEnabled(feeEnabled);
clan.setRanks(Helper.ranksFromJson(ranks));
clan.setDefaultRank(Helper.defaultRankFromJson(ranks));
clan.setBanner(banner);
out = clan;
} catch (Exception ex) {
for (StackTraceElement el : ex.getStackTrace()) {
System.out.print(el.toString());
}
ex.printStackTrace();
}
}
} catch (SQLException ex) {
@@ -528,7 +524,7 @@ public final class StorageManager {
long last_seen = res.getLong("last_seen");
long join_date = res.getLong("join_date");
String flags = res.getString("flags");
String packed_past_clans = Helper.parseColors(res.getString("packed_past_clans"));
String packed_past_clans = ChatUtils.parseColors(res.getString("packed_past_clans"));
String resign_times = res.getString("resign_times");
Locale locale = Helper.forLanguageTag(res.getString("locale"));
@@ -569,9 +565,7 @@ public final class StorageManager {
out.add(cp);
} catch (Exception ex) {
for (StackTraceElement el : ex.getStackTrace()) {
System.out.print(el.toString());
}
ex.printStackTrace();
}
}
} catch (SQLException ex) {
@@ -659,7 +653,6 @@ public final class StorageManager {
clanReSync.setPackedAllies(clanDB.getPackedAllies());
clanReSync.setPackedRivals(clanDB.getPackedRivals());
clanReSync.setPackedBb(clanDB.getPackedBb());
clanReSync.setCapeUrl(clanDB.getCapeUrl());
clanReSync.setFounded(clanDB.getFounded());
clanReSync.setLastUsed(clanDB.getLastUsed());
clanReSync.setBalance(clanDB.getBalance());
@@ -674,9 +667,7 @@ public final class StorageManager {
out = cp;
} catch (Exception ex) {
for (StackTraceElement el : ex.getStackTrace()) {
System.out.print(el.toString());
}
ex.printStackTrace();
}
}
} catch (SQLException ex) {
@@ -699,7 +690,7 @@ public final class StorageManager {
"`packed_bb`, `cape_url`, `flags`, `balance`) ";
String values = "VALUES ( '"
+ Helper.escapeQuotes(YAMLSerializer.serialize(clan.getBanner())) + "','"
+ Helper.escapeQuotes(Helper.ranksToJson(clan.getRanks())) + "','"
+ Helper.escapeQuotes(Helper.ranksToJson(clan.getRanks(), clan.getDefaultRank())) + "','"
+ Helper.escapeQuotes(clan.getDescription())+ "',"
+ (clan.isMemberFeeEnabled() ? 1 : 0) +","
+ Helper.escapeQuotes(String.valueOf(clan.getMemberFee())) + ","
@@ -787,7 +778,7 @@ public final class StorageManager {
private String getUpdateClanQuery(Clan clan) {
String query = "UPDATE `sc_clans`" +
" SET ranks = '"+ Helper.escapeQuotes(Helper.ranksToJson(clan.getRanks())) +"'," +
" SET ranks = '"+ Helper.escapeQuotes(Helper.ranksToJson(clan.getRanks(), clan.getDefaultRank())) +"'," +
" banner = '" + Helper.escapeQuotes(YAMLSerializer.serialize(clan.getBanner())) + "'," +
" description = '" + Helper.escapeQuotes(clan.getDescription())+ "'," +
" fee_enabled = "+ (clan.isMemberFeeEnabled() ? 1 : 0) +"," +
@@ -1062,15 +1053,15 @@ public final class StorageManager {
private void updateDatabase() {
String query = null;
/**
/*
* From 2.2.6.3 to 2.3
*/
if (!core.existsColumn("sc_clans", "balance")) {
query = "ALTER TABLE sc_clans ADD COLUMN `balance` double(64,2);";
core.execute(query);
}
/**
/*
* From 2.7.16 to 2.7.17
*/
if (!core.existsColumn("sc_clans", "fee_enabled")) {
@@ -1081,24 +1072,24 @@ public final class StorageManager {
query = "ALTER TABLE sc_clans ADD COLUMN `fee_value` double(64,2);";
core.execute(query);
}
/**
/*
* From 2.7.21 to 2.7.22
*/
if (!core.existsColumn("sc_clans", "description")) {
query = "ALTER TABLE sc_clans ADD COLUMN `description` varchar(255);";
core.execute(query);
}
/**
/*
* From 2.7.22 to 2.7.23
*/
if (!core.existsColumn("sc_players", "resign_times")) {
query = "ALTER TABLE sc_players ADD COLUMN `resign_times` text;";
core.execute(query);
}
/**
/*
* From 2.8.2 to 2.9
*/
if (!core.existsColumn("sc_clans", "ranks")) {
@@ -1115,7 +1106,11 @@ public final class StorageManager {
core.execute("ALTER TABLE sc_clans ADD COLUMN `banner` text;");
}
/**
if (plugin.getSettingsManager().isUseMysql()) {
core.execute("ALTER TABLE sc_clans MODIFY color_tag VARCHAR(255);");
}
/*
* Bukkit 1.7.5+ UUID Migration
*/
if (!core.existsColumn("sc_kills", "attacker_uuid")) {
@@ -84,7 +84,7 @@ public final class TeleportManager {
z = z + zz;
plugin.getTeleportManager().addPlayer(player, new Location(location.getWorld(), x + .5,
location.getBlockY(), z + .5), clan.getName());
location.getBlockY(), z + .5, location.getYaw(), location.getPitch()), clan.getName());
}
}
@@ -23,8 +23,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
import java.util.*;
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
/**
@@ -2,13 +2,13 @@ package net.sacredlabyrinth.phaed.simpleclans.ui;
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
import net.sacredlabyrinth.phaed.simpleclans.events.FrameOpenEvent;
import net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
import net.sacredlabyrinth.phaed.simpleclans.utils.WordWrapper;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.util.ChatPaginator;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -69,6 +69,10 @@ public class InventoryDrawer {
return inventory;
}
/**
*
* @deprecated use {@link InventoryDrawer#open(SCFrame)}
*/
@Deprecated
public static void update(@NotNull SCFrame frame) {
open(frame);
@@ -105,8 +109,11 @@ public class InventoryDrawer {
if (oldLore != null) {
ArrayList<String> newLore = new ArrayList<>();
for (String line : oldLore) {
String[] strings = ChatPaginator.wordWrap(line, plugin.getSettingsManager().getLoreLength());
newLore.addAll(Arrays.asList(strings));
if (line.isEmpty()) {
continue;
}
WordWrapper wrapper = new WordWrapper(line, plugin.getSettingsManager().getLoreLength());
newLore.addAll(Arrays.asList(wrapper.wrap()));
}
itemMeta.setLore(newLore);
c.setItemMeta(itemMeta);
@@ -26,7 +26,7 @@ public class AddAllyFrame extends SCFrame {
notAllies = plugin.getClanManager().getClans().stream()
.filter(c -> !c.equals(subject) && !c.isRival(subject.getTag()) && !c.isAlly(subject.getTag()))
.collect(Collectors.toList());
paginator = new Paginator(getSize() - 9, notAllies.size());
paginator = new Paginator(getSize() - 9, notAllies);
}
@Override
@@ -28,7 +28,7 @@ public class ClanListFrame extends SCFrame {
public ClanListFrame(SCFrame parent, Player viewer) {
super(parent, viewer);
paginator = new Paginator(getSize() - 9, clans.size());
paginator = new Paginator(getSize() - 9, clans);
plugin.getClanManager().sortClansByKDR(clans);
rankingResolver = new RankingNumberResolver<>(clans, c -> KDRFormat.toBigDecimal(c.getTotalKDR()), false,
@@ -3,9 +3,9 @@ package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
import com.cryptomorin.xseries.XMaterial;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.Helper;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.utils.KDRFormat;
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
@@ -41,16 +41,14 @@ public class Components {
boolean openDetails) {
SimpleClans pl = SimpleClans.getInstance();
String status = cp.getClan() == null ? lang("free.agent",viewer)
: (cp.isLeader() ? lang("leader",viewer)
: (cp.isTrusted() ? lang("trusted",viewer) : lang("untrusted",viewer)));
String status = getPlayerStatus(viewer, cp);
SCComponent c = new SCComponentImpl(lang("gui.playerdetails.player.title",viewer, cp.getName()),
Arrays.asList(
cp.getClan() == null ? lang("gui.playerdetails.player.lore.noclan",viewer)
: lang("gui.playerdetails.player.lore.clan",viewer, cp.getClan().getColorTag(),
cp.getClan().getName()),
lang("gui.playerdetails.player.lore.rank",viewer,
Helper.parseColors(cp.getRankDisplayName())),
ChatUtils.parseColors(cp.getRankDisplayName())),
lang("gui.playerdetails.player.lore.status",viewer, status),
lang("gui.playerdetails.player.lore.kdr",viewer,
new DecimalFormat("#.#").format(cp.getKDR())),
@@ -78,6 +76,23 @@ public class Components {
return c;
}
@NotNull
private static String getPlayerStatus(Player viewer, ClanPlayer cp) {
if (cp.getClan() == null) {
return lang("free.agent", viewer);
}
if (cp.isLeader()) {
return lang("leader", viewer);
}
if (cp.isTrusted()) {
return lang("trusted", viewer);
}
if (cp.getRankId() != null && !cp.getRankId().isEmpty()) {
return lang("in.rank", viewer);
}
return lang("untrusted", viewer);
}
public static SCComponent getClanComponent(@NotNull SCFrame frame, @NotNull Player viewer,
@Nullable Clan clan, int slot, boolean openDetails) {
SimpleClans pl = SimpleClans.getInstance();
@@ -167,6 +182,7 @@ public class Components {
return c;
}
@SuppressWarnings("deprecation")
public static void setOwningPlayer(@NotNull ItemStack item, @NotNull OfflinePlayer player) {
SkullMeta itemMeta = (SkullMeta) item.getItemMeta();
if (itemMeta == null) {
@@ -25,22 +25,19 @@ import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
public class CoordsFrame extends SCFrame {
private final Clan subject;
private Paginator paginator;
private final List<ClanPlayer> allMembers;
private final Paginator paginator;
public CoordsFrame(Player viewer, SCFrame parent, Clan subject) {
super(parent, viewer);
allMembers = VanishUtils.getNonVanished(getViewer(), subject);
allMembers.sort((cp1, cp2) -> Boolean.compare(cp1.isLeader(), cp2.isLeader()));
this.subject = subject;
paginator = new Paginator(getSize() - 9, allMembers);
}
@Override
public void createComponents() {
List<ClanPlayer> allMembers = VanishUtils.getNonVanished(getViewer(), subject);
allMembers.sort((cp1, cp2) -> Boolean.compare(cp1.isLeader(), cp2.isLeader()));
paginator = new Paginator(getSize() - 9, allMembers.size());
for (int slot = 0; slot < 9; slot++) {
if (slot == 2 || slot == 6 || slot == 7)
continue;
@@ -24,12 +24,15 @@ public class LanguageSelectorFrame extends SCFrame {
private final ClanPlayer clanPlayer;
private final SimpleClans plugin;
private Paginator paginator;
private final Paginator paginator;
private final List<Locale> languages;
public LanguageSelectorFrame(@Nullable SCFrame parent, @NotNull Player viewer) {
super(parent, viewer);
plugin = SimpleClans.getInstance();
clanPlayer = plugin.getClanManager().getCreateClanPlayer(viewer.getUniqueId());
languages = LanguageResource.getAvailableLocales();
paginator = new Paginator(getSize() - 9, languages);
}
@Override
@@ -44,8 +47,6 @@ public class LanguageSelectorFrame extends SCFrame {
@Override
public void createComponents() {
List<Locale> languages = LanguageResource.getAvailableLocales();
paginator = new Paginator(getSize() - 9, languages.size());
addHeader();
int slot = 9;
for (int i = paginator.getMinIndex(); paginator.isValidIndex(i); i++) {
@@ -36,7 +36,7 @@ public class LeaderboardFrame extends SCFrame {
rankingResolver = new RankingNumberResolver<>(clanPlayers, c -> KDRFormat.toBigDecimal(c.getKDR()), false,
plugin.getSettingsManager().getRankingType());
paginator = new Paginator(getSize() - 9, this.clanPlayers.size());
paginator = new Paginator(getSize() - 9, this.clanPlayers);
}
@Override
@@ -14,17 +14,18 @@ import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
public class PermissionsFrame extends SCFrame {
private final Rank rank;
private Paginator paginator;
private final Paginator paginator;
private final String[] permissions;
public PermissionsFrame(SCFrame parent, Player viewer, Rank rank) {
super(parent, viewer);
this.rank = rank;
permissions = rank.getPermissions().toArray(new String[0]);
paginator = new Paginator(getSize() - 9, permissions.length);
}
@Override
public void createComponents() {
String[] permissions = rank.getPermissions().toArray(new String[0]);
paginator = new Paginator(getSize() - 9, permissions.length);
for (int slot = 0; slot < 9; slot++) {
if (slot == 2 || slot == 4 || slot == 6 || slot == 7)
@@ -71,7 +72,7 @@ public class PermissionsFrame extends SCFrame {
}
private void updateFrame() {
InventoryDrawer.update(this);
InventoryDrawer.open(this);
}
@Override
@@ -2,6 +2,7 @@ package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
import com.cryptomorin.xseries.XMaterial;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
@@ -18,17 +19,19 @@ public class PlayerDetailsFrame extends SCFrame {
private final SimpleClans plugin = SimpleClans.getInstance();
private final OfflinePlayer subject;
private final String subjectName;
private final Clan clan;
public PlayerDetailsFrame(Player viewer, SCFrame parent, OfflinePlayer subject) {
super(parent, viewer);
this.subject = subject;
clan = plugin.getClanManager().getAnyClanPlayer(viewer.getUniqueId()).getClan();
ClanPlayer cp = plugin.getClanManager().getCreateClanPlayer(subject.getUniqueId());
subjectName = cp.getName();
clan = cp.getClan();
}
@Override
public void createComponents() {
String subjectName = subject.getName();
for (int slot = 0; slot < 9; slot++) {
if (slot == 4)
continue;
@@ -41,14 +44,23 @@ public class PlayerDetailsFrame extends SCFrame {
if (!isSameClan()) {
return;
}
addKick();
addPromoteDemote();
addAssignUnassign();
addTrustUntrust();
}
private void addKick() {
SCComponent kick = new SCComponentImpl(lang("gui.playerdetails.kick.title",getViewer()), null, XMaterial.RED_WOOL,
28);
kick.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(), "kick", true, subjectName));
kick.setConfirmationRequired(ClickType.LEFT);
kick.setPermission(ClickType.LEFT, RankPermission.KICK);
add(kick);
}
private void addPromoteDemote() {
SCComponent promoteDemote = new SCComponentImpl(lang("gui.playerdetails.promote.demote.title",getViewer()),
Arrays.asList(lang("gui.playerdetails.promote.lore.left.click",getViewer()),
lang("gui.playerdetails.demote.lore.right.click",getViewer())),
@@ -62,7 +74,9 @@ public class PlayerDetailsFrame extends SCFrame {
promoteDemote.setConfirmationRequired(ClickType.RIGHT);
add(promoteDemote);
promoteDemote.setPermission(ClickType.RIGHT, "simpleclans.leader.demote");
}
private void addAssignUnassign() {
SCComponentImpl assignUnassign = new SCComponentImpl(lang("gui.playerdetails.assign.unassign.title",getViewer()),
Arrays.asList(lang("gui.playerdetails.assign.lore.left.click",getViewer()),
lang("gui.playerdetails.unassign.lore.right.click",getViewer())),
@@ -75,7 +89,9 @@ public class PlayerDetailsFrame extends SCFrame {
() -> InventoryDrawer.open(new RanksFrame(this, getViewer(), clan, subject)));
add(assignUnassign);
assignUnassign.setPermission(ClickType.LEFT, "simpleclans.leader.rank.assign");
}
private void addTrustUntrust() {
SCComponent trustUntrust = new SCComponentImpl(lang("gui.playerdetails.trust.untrust.title",getViewer()),
Arrays.asList(lang("gui.playerdetails.trust.lore.left.click",getViewer()),
lang("gui.playerdetails.untrust.lore.right.click",getViewer())),
@@ -93,7 +109,7 @@ public class PlayerDetailsFrame extends SCFrame {
@Override
public @NotNull String getTitle() {
return lang("gui.playerdetails.title",getViewer(), subject.getName());
return lang("gui.playerdetails.title",getViewer(), subjectName);
}
@Override
@@ -2,10 +2,11 @@ package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
import com.cryptomorin.xseries.XMaterial;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.Helper;
import net.sacredlabyrinth.phaed.simpleclans.Rank;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.managers.ClanManager;
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@@ -21,21 +22,19 @@ import java.util.List;
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
public class RanksFrame extends SCFrame {
private Paginator paginator;
private final Clan subject;
private final Paginator paginator;
private final OfflinePlayer toEdit;
private final List<Rank> ranks;
public RanksFrame(SCFrame parent, Player viewer, Clan subject, @Nullable OfflinePlayer toEdit) {
super(parent, viewer);
this.subject = subject;
this.toEdit = toEdit;
ranks = subject != null ? subject.getRanks() : new ArrayList<>();
paginator = new Paginator(getSize() - 9, ranks);
}
@Override
public void createComponents() {
List<Rank> ranks = subject != null ? subject.getRanks() : new ArrayList<>();
paginator = new Paginator(getSize() - 9, ranks.size());
for (int slot = 0; slot < 9; slot++) {
if (slot == 2 || slot == 4 || slot == 6 || slot == 7)
continue;
@@ -61,13 +60,13 @@ public class RanksFrame extends SCFrame {
if (toEdit == null) {
lore = Arrays.asList(
lang("gui.ranks.rank.displayname.lore",getViewer(),
Helper.parseColors(rank.getDisplayName())),
ChatUtils.parseColors(rank.getDisplayName())),
lang("gui.ranks.rank.edit.permissions.lore",getViewer()),
lang("gui.ranks.rank.remove.lore",getViewer()));
} else {
lore = Arrays.asList(
lang("gui.ranks.rank.displayname.lore",getViewer(),
Helper.parseColors(rank.getDisplayName())),
ChatUtils.parseColors(rank.getDisplayName())),
lang("gui.ranks.rank.assign.lore",getViewer(), toEdit.getName()));
}
SCComponent c = new SCComponentImpl(lang("gui.ranks.rank.title",getViewer(), rank.getName()), lore,
@@ -111,7 +110,8 @@ public class RanksFrame extends SCFrame {
@Override
public @NotNull String getTitle() {
if (toEdit != null) {
String rank = SimpleClans.getInstance().getClanManager().getAnyClanPlayer(toEdit.getUniqueId()).getRankId();
ClanManager clanManager = SimpleClans.getInstance().getClanManager();
String rank = clanManager.getCreateClanPlayer(toEdit.getUniqueId()).getRankId();
return lang("gui.ranks.title.set.rank",getViewer(), rank);
}
return lang("gui.ranks.title",getViewer());
@@ -17,18 +17,19 @@ import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
public class RivalsFrame extends SCFrame {
private final SimpleClans plugin = SimpleClans.getInstance();
private Paginator paginator;
private final Paginator paginator;
private final Clan subject;
private final List<String> rivals;
public RivalsFrame(Player viewer, SCFrame parent, Clan subject) {
super(parent, viewer);
this.subject = subject;
rivals = subject.getRivals();
paginator = new Paginator(getSize() - 9, rivals);
}
@Override
public void createComponents() {
List<String> rivals = subject.getRivals();
paginator = new Paginator(getSize() - 9, rivals.size());
for (int slot = 0; slot < 9; slot++) {
if (slot == 2 || slot == 4 || slot == 6 || slot == 7)
@@ -3,13 +3,13 @@ package net.sacredlabyrinth.phaed.simpleclans.ui.frames;
import com.cryptomorin.xseries.XMaterial;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.Helper;
import net.sacredlabyrinth.phaed.simpleclans.RankPermission;
import net.sacredlabyrinth.phaed.simpleclans.ui.InventoryDrawer;
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponent;
import net.sacredlabyrinth.phaed.simpleclans.ui.SCComponentImpl;
import net.sacredlabyrinth.phaed.simpleclans.ui.SCFrame;
import net.sacredlabyrinth.phaed.simpleclans.ui.frames.staff.PlayerDetailsFrame;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import net.sacredlabyrinth.phaed.simpleclans.utils.Paginator;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -97,7 +97,7 @@ public class RosterFrame extends SCFrame {
@Override
public @NotNull String getTitle() {
return lang("gui.roster.title", getViewer(), Helper.stripColors(subject.getColorTag()));
return lang("gui.roster.title", getViewer(), ChatUtils.stripColors(subject.getColorTag()));
}
@Override
@@ -3,10 +3,10 @@ package net.sacredlabyrinth.phaed.simpleclans.ui.frames.staff;
import com.cryptomorin.xseries.XMaterial;
import net.sacredlabyrinth.phaed.simpleclans.Clan;
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
import net.sacredlabyrinth.phaed.simpleclans.Helper;
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
import net.sacredlabyrinth.phaed.simpleclans.ui.frames.Components;
import net.sacredlabyrinth.phaed.simpleclans.ui.frames.RosterFrame;
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
@@ -50,7 +50,7 @@ public class ClanDetailsFrame extends SCFrame {
Collections.singletonList(lang("gui.staffclandetails.disband.lore", getViewer())),
XMaterial.BARRIER, 34);
disband.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
"disband", false, clan.getTag()));
"mod disband", false, clan.getTag()));
disband.setConfirmationRequired(ClickType.LEFT);
disband.setPermission(ClickType.LEFT, "simpleclans.mod.disband");
add(disband);
@@ -71,7 +71,7 @@ public class ClanDetailsFrame extends SCFrame {
verify.setPermission(ClickType.LEFT, "simpleclans.mod.verify");
verify.setConfirmationRequired(ClickType.LEFT);
verify.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
"verify", false, clan.getTag()));
"mod verify", false, clan.getTag()));
}
add(verify);
}
@@ -84,10 +84,10 @@ public class ClanDetailsFrame extends SCFrame {
SCComponent home = new SCComponentImpl(lang("gui.clandetails.home.title", getViewer()), lore,
XMaterial.MAGENTA_BED, 30);
home.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
"home tp", false, clan.getTag()));
"mod home tp", false, clan.getTag()));
home.setPermission(ClickType.LEFT, "simpleclans.mod.hometp");
home.setListener(ClickType.RIGHT, () -> InventoryController.runSubcommand(getViewer(),
"home set", false, clan.getTag()));
"mod home set", false, clan.getTag()));
home.setPermission(ClickType.RIGHT, "simpleclans.mod.home");
home.setConfirmationRequired(ClickType.RIGHT);
add(home);
@@ -111,7 +111,7 @@ public class ClanDetailsFrame extends SCFrame {
@Override
public @NotNull String getTitle() {
return lang("gui.clandetails.title", getViewer(), Helper.stripColors(clan.getColorTag()),
return lang("gui.clandetails.title", getViewer(), ChatUtils.stripColors(clan.getColorTag()),
clan.getName());
}
@@ -34,7 +34,7 @@ public class ClanListFrame extends SCFrame {
if (type == Type.UNVERIFIED) {
clans = clans.stream().filter(c -> !c.isVerified()).collect(Collectors.toList());
}
paginator = new Paginator(getSize() - 9, clans.size());
paginator = new Paginator(getSize() - 9, clans);
plugin.getClanManager().sortClansByName(clans, true);
}
@@ -60,7 +60,7 @@ public class ClanListFrame extends SCFrame {
} else {
if (toPlace != null) {
c.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
"place", false, toPlace.getName(), clan.getTag()));
"mod place", false, toPlace.getName(), clan.getTag()));
c.setConfirmationRequired(ClickType.LEFT);
c.setPermission(ClickType.LEFT, "simpleclans.mod.place");
}
@@ -83,7 +83,7 @@ public class ClanListFrame extends SCFrame {
}
private void updateFrame() {
InventoryDrawer.update(this);
InventoryDrawer.open(this);
}
@Override
@@ -1,6 +1,7 @@
package net.sacredlabyrinth.phaed.simpleclans.ui.frames.staff;
import com.cryptomorin.xseries.XMaterial;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import net.sacredlabyrinth.phaed.simpleclans.ui.*;
import net.sacredlabyrinth.phaed.simpleclans.ui.frames.Components;
import org.bukkit.OfflinePlayer;
@@ -21,7 +22,7 @@ public class PlayerDetailsFrame extends SCFrame {
public PlayerDetailsFrame(@NotNull Player viewer, SCFrame parent, @NotNull OfflinePlayer subject) {
super(parent, viewer);
this.subject = subject;
subjectName = subject.getName();
subjectName = SimpleClans.getInstance().getClanManager().getCreateClanPlayer(subject.getUniqueId()).getName();
}
@Override
@@ -64,7 +65,7 @@ public class PlayerDetailsFrame extends SCFrame {
lang("gui.playerdetails.purge.lore", getViewer())).build();
purge.setConfirmationRequired(ClickType.LEFT);
purge.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
"purge", false, subjectName));
"admin purge", false, subjectName));
purge.setPermission(ClickType.LEFT, "simpleclans.admin.purge");
add(purge);
}
@@ -74,7 +75,7 @@ public class PlayerDetailsFrame extends SCFrame {
.withSlot(30).withDisplayName(lang("gui.main.reset.kdr.title", getViewer()))
.withLoreLine(lang("gui.playerdetails.resetkdr.lore", getViewer())).build();
resetKdr.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
"resetkdr", false, subjectName));
"admin resetkdr", false, subjectName));
resetKdr.setConfirmationRequired(ClickType.LEFT);
resetKdr.setPermission(ClickType.LEFT, "simpleclans.admin.resetkdr");
add(resetKdr);
@@ -100,15 +101,15 @@ public class PlayerDetailsFrame extends SCFrame {
banUnban.setPermission(ClickType.LEFT, "simpleclans.mod.ban");
banUnban.setPermission(ClickType.RIGHT, "simpleclans.mod.ban");
banUnban.setListener(ClickType.LEFT, () -> InventoryController.runSubcommand(getViewer(),
"ban", false, subjectName));
"mod ban", false, subjectName));
banUnban.setListener(ClickType.RIGHT, () -> InventoryController.runSubcommand(getViewer(),
"unban", false, subjectName));
"mod unban", false, subjectName));
add(banUnban);
}
@Override
public @NotNull String getTitle() {
return lang("gui.playerdetails.title", getViewer(), subject.getName());
return lang("gui.playerdetails.title", getViewer(), subjectName);
}
@Override
@@ -73,7 +73,7 @@ public class StaffFrame extends SCFrame {
reload.setPermission(ClickType.LEFT, "simpleclans.admin.reload");
reload.setConfirmationRequired(ClickType.LEFT);
reload.setListener(ClickType.LEFT, () ->
InventoryController.runSubcommand(getViewer(), "reload", false));
InventoryController.runSubcommand(getViewer(), "admin reload", false));
add(reload);
}
@@ -93,7 +93,7 @@ public class StaffFrame extends SCFrame {
} else {
arg = "allow";
}
InventoryController.runSubcommand(getViewer(), "globalff", true, arg);
InventoryController.runSubcommand(getViewer(), "mod globalff", true, arg);
});
add(globalFf);
}
@@ -0,0 +1,146 @@
package net.sacredlabyrinth.phaed.simpleclans.utils;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.*;
import net.md_5.bungee.api.chat.ComponentBuilder.FormatRetention;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static net.md_5.bungee.api.ChatColor.COLOR_CHAR;
import static net.md_5.bungee.api.chat.ClickEvent.Action.RUN_COMMAND;
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
public class ChatUtils {
private static final Pattern PLACEHOLDER_PATTERN = Pattern.compile("(%([A-Za-z]+)%)");
private static final Pattern HEX_COLOR_PATTERN = Pattern.compile("&#(\\w{5}[0-9A-Fa-f])");
private static boolean supportsHexColors;
static {
try {
ChatColor.class.getDeclaredMethod("of", String.class);
supportsHexColors = true;
} catch (NoSuchMethodException e) {
supportsHexColors = false;
}
}
private ChatUtils() {
}
public static String parseColors(@NotNull String text) {
// Special thanks to the Spigot community!
// https://www.spigotmc.org/threads/hex-color-code-translate.449748/#post-3867795
if (supportsHexColors) {
Matcher matcher = HEX_COLOR_PATTERN.matcher(text);
StringBuffer buffer = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(buffer, ChatColor.of("#" + matcher.group(1)).toString());
}
text = matcher.appendTail(buffer).toString();
}
return ChatColor.translateAlternateColorCodes('&', text);
}
public static String stripColors(String text) {
if (supportsHexColors) {
Matcher matcher = HEX_COLOR_PATTERN.matcher(text);
StringBuffer buffer = new StringBuffer();
while (matcher.find()) {
matcher.appendReplacement(buffer, "");
}
text = matcher.appendTail(buffer).toString();
}
return oldStripColors(text);
}
private static String oldStripColors(String text) {
return text.replaceAll("[&][0-9A-Fa-fk-orx]", "")
.replaceAll(String.valueOf((char) 194), "") //don't know why
.replaceAll("[\u00a7][0-9A-Fa-fk-orx]", "");
}
public static BaseComponent[] toBaseComponents(@Nullable CommandSender receiver, @NotNull String text) {
ComponentBuilder builder = new ComponentBuilder("");
ArrayList<String> placeholders = new ArrayList<>();
Matcher matcher = PLACEHOLDER_PATTERN.matcher(text);
while (matcher.find()) {
placeholders.add(matcher.group(0));
}
String[] split = PLACEHOLDER_PATTERN.split(text);
for (int i = 0; i < split.length; i++) {
builder.append(split[i]);
if (i >= placeholders.size()) {
continue;
}
appendPlaceholder(receiver, builder, placeholders.get(i));
}
return builder.create();
}
@SuppressWarnings("deprecation")
private static void appendPlaceholder(@Nullable CommandSender receiver, ComponentBuilder builder, String placeholder) {
Matcher matcher = PLACEHOLDER_PATTERN.matcher(placeholder);
if (!matcher.find()) {
return;
}
placeholder = matcher.group(2);
builder.retain(FormatRetention.FORMATTING).append(lang("clickable." + placeholder, receiver))
.event(new ClickEvent(RUN_COMMAND, "/" + placeholder))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(
(lang("hover.click.to." + placeholder, receiver)))));
}
/**
* Loops through the input and returns the last color codes
*
* @param input the input
* @return the last color codes
*/
@NotNull
public static String getLastColors(@NotNull String input) {
StringBuilder result = new StringBuilder();
int length = input.length();
for (int index = length - 1; index > -1; index--) {
boolean found = false;
String color = String.valueOf(input.charAt(index));
if (ChatColor.ALL_CODES.contains(color)) {
if (index - 1 >= 0) {
char section = input.charAt(index - 1);
if (section == COLOR_CHAR) {
index--;
result.insert(0, section + color);
found = true;
}
}
}
if (!found && result.length() != 0) {
break;
}
}
return result.toString();
}
public static void applyLastColorToFollowingLines(@NotNull List<String> lines) {
if (lines.get(0).length() == 0 || lines.get(0).charAt(0) != COLOR_CHAR) {
lines.set(0, ChatColor.WHITE + lines.get(0));
}
for (int i = 1; i < lines.size(); i++) {
final String pLine = lines.get(i - 1);
final String subLine = lines.get(i);
if (subLine.length() == 0 || subLine.charAt(0) != COLOR_CHAR) {
lines.set(i, getLastColors(pLine) + subLine);
}
}
}
}
@@ -1,5 +1,9 @@
package net.sacredlabyrinth.phaed.simpleclans.utils;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
/**
*
* @author RoinujNosde
@@ -9,8 +13,9 @@ public class Paginator {
private int currentPage;
private final int sizePerPage;
private final int totalElements;
private int totalElements;
private Collection<?> collection;
public Paginator(int sizePerPage, int totalElements) {
if (sizePerPage < 1) {
throw new IllegalArgumentException("sizePerPage cannot be less than 1");
@@ -21,6 +26,14 @@ public class Paginator {
this.sizePerPage = sizePerPage;
this.totalElements = totalElements;
}
public Paginator(int sizePerPage, @NotNull Collection<?> collection) {
if (sizePerPage < 1) {
throw new IllegalArgumentException("sizePerPage cannot be less than 1");
}
this.sizePerPage = sizePerPage;
this.collection = collection;
}
/**
*
@@ -29,6 +42,9 @@ public class Paginator {
* @author RoinujNosde
*/
public int getTotalElements() {
if (collection != null) {
return collection.size();
}
return totalElements;
}
@@ -88,8 +104,9 @@ public class Paginator {
/**
* @return if there is a next page
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean hasNextPage() {
return !((sizePerPage * (currentPage + 1)) > totalElements);
return !((sizePerPage * (currentPage + 1)) > getTotalElements());
}
/**
@@ -7,8 +7,6 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.text.MessageFormat;
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
public class TagValidator {
@@ -31,9 +29,9 @@ public class TagValidator {
*/
@Nullable
public String getErrorMessage() {
String cleanTag = Helper.stripColors(this.tag);
if (tag.length() > 25) {
return lang("your.clan.color.tag.cannot.be.longer.than.characters", player, 25);
String cleanTag = ChatUtils.stripColors(this.tag);
if (tag.length() > 255 && plugin.getSettingsManager().isUseMysql()) {
return lang("your.clan.color.tag.cannot.be.longer.than.characters", player, 255);
}
if (!plugin.getPermissionsManager().has(player, "simpleclans.mod.bypass")) {
@@ -14,6 +14,7 @@ import com.google.gson.JsonParseException;
import com.google.gson.JsonParser;
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
import org.jetbrains.annotations.NotNull;
/**
*
@@ -52,7 +53,7 @@ public class UpdateChecker {
if (parse.isJsonObject()) {
String latestVersion = parse.getAsJsonObject().get("name").getAsString();
if (!version.equals(latestVersion)) {
if (compareVersions(version, latestVersion) < 0) {
plugin.getLogger().info(String.format("You're running an outdated version (%s).", version));
plugin.getLogger().info(String.format("The latest version is %s. Download it at:", latestVersion));
plugin.getLogger().info("https://www.spigotmc.org/resources/simpleclans.71242/");
@@ -69,4 +70,18 @@ public class UpdateChecker {
}.runTaskAsynchronously(plugin);
}
public static int compareVersions(@NotNull String a, @NotNull String b) {
String[] aSplit = a.split("\\.");
String[] bSplit = b.split("\\.");
int length = Math.max(aSplit.length, bSplit.length);
for (int i = 0; i < length; i++) {
int aPart = aSplit.length > i ? Integer.parseInt(aSplit[i]) : 0;
int bPart = bSplit.length > i ? Integer.parseInt(bSplit[i]) : 0;
if (aPart != bPart) {
return Integer.compare(aPart, bPart);
}
}
return 0;
}
}
@@ -0,0 +1,150 @@
package net.sacredlabyrinth.phaed.simpleclans.utils;
import net.md_5.bungee.api.ChatColor;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import static net.md_5.bungee.api.ChatColor.COLOR_CHAR;
import static net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils.applyLastColorToFollowingLines;
public class WordWrapper {
private final String rawString;
private final int lineLength;
char[] rawChars;
StringBuilder word = new StringBuilder();
StringBuilder line = new StringBuilder();
List<String> lines = new LinkedList<>();
int lineColorChars = 0;
public WordWrapper(@NotNull String rawString, int lineLength) {
this.rawString = rawString;
this.lineLength = lineLength > 0 ? lineLength : 319;
rawChars = (rawString + ' ').toCharArray(); // add a trailing space to trigger pagination
}
@NotNull
public String[] wrap() {
// A string shorter than the lineWidth is a single line
if (rawString.length() <= lineLength && !rawString.contains("\n")) {
return new String[]{rawString};
}
for (int i = 0; i < rawChars.length; i++) {
char c = rawChars[i];
// skip chat color modifiers
if (c == COLOR_CHAR) {
processChatColorModifiers(rawChars[i + 1]);
i++; // Eat the next character as we have already processed it
continue;
}
if (c == ' ' || c == '\n') {
processSpace();
processLineBreak(c);
} else {
word.append(c);
}
}
addLastLine();
// Iterate over the wrapped lines, applying the last color from one line to the beginning of the next
applyLastColorToFollowingLines(lines);
return lines.toArray(new String[0]);
}
private void addLastLine() {
if (line.length() > 0) { // Only add the last line if there is anything to add
lines.add(line.toString());
}
}
private void processLineBreak(char c) {
if (c == '\n') { // Newline forces the line to flush
lines.add(line.toString());
line = new StringBuilder();
}
}
private void processSpace() {
if (line.length() == 0 && word.length() - lineColorChars > lineLength) { // special case: extremely long word begins a line
lines.addAll(split(word.toString(), lineLength));
} else if (line.length() + 1 + word.length() - lineColorChars == lineLength) { // Line exactly the correct length...newline
processLineCorrectLength();
} else if (line.length() + 1 + word.length() - lineColorChars > lineLength) { // Line too long...break the line
processLineTooLong();
} else {
appendWord();
}
word = new StringBuilder();
}
private void appendWord() {
if (line.length() > 0) {
line.append(' ');
}
line.append(word);
}
private void processLineTooLong() {
for (String partialWord : split(word.toString(), lineLength)) {
if (line.length() > 0) {
lines.add(line.toString());
}
line = new StringBuilder(partialWord);
}
lineColorChars = 0;
}
private void processLineCorrectLength() {
appendWord();
lines.add(line.toString());
line = new StringBuilder();
lineColorChars = 0;
}
private void processChatColorModifiers(char rawChar) {
word.append(COLOR_CHAR);
word.append(rawChar);
lineColorChars += 2;
}
/**
* Breaks a String, using the passed length and respecting color codes, into a List of Strings
*
* @param input the input
* @return the split input
*/
@NotNull
public static List<String> split(@NotNull String input, int length) {
List<String> split = new ArrayList<>();
int nonColorCount = 0;
for (int i = 0; i < input.length(); i++) {
if (nonColorCount == length) {
split.add(input.substring(0, i));
input = input.substring(i);
nonColorCount = 0;
i = 0;
}
char c = input.charAt(i);
if (c == COLOR_CHAR) {
if (i + 1 < input.length()) {
String s = String.valueOf(input.charAt(i + 1));
if (ChatColor.ALL_CODES.contains(s)) {
i++;
continue;
}
}
}
nonColorCount++;
}
if (!input.isEmpty()) {
split.add(input);
}
return split;
}
}
+20
View File
@@ -52,6 +52,26 @@ settings:
ranking-type: "DENSE"
list-default-order-by: kdr
lore-length: 36
war-and-protection:
war-enabled: false
land-sharing: true
protection-providers:
- WorldGuardProvider
- GriefPreventionProvider
listener-priority: HIGHEST
set-base-only-in-land: false
war-normal-expiration-time: 0
war-disconnect-expiration-time: 0
land-creation:
only-leaders: false
only-one-per-clan: false
war-actions:
CONTAINER: true
INTERACT: true
BREAK: true
PLACE: true
DAMAGE: true
INTERACT_ENTITY: true
kdr-grinding-prevention:
enable-max-kills: false
max-kills-per-victim: 10
Loaded 100 of 170 files, more files were not shown because too many files have changed in this diff. Show more