mirror of
https://github.com/RoinujNosde/SimpleClans.git
synced 2026-11-05 17:12:34 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fce8399840 | ||
|
|
cc2fc201fe | ||
|
|
373f41f9ee | ||
|
|
f1e4bbf043 | ||
|
|
b902f5f71d | ||
|
|
6461b5bc8c | ||
|
|
169ebe543e | ||
|
|
6018c793d4 | ||
|
|
ded9077dda | ||
|
|
0dd519dabd | ||
|
|
9563fc383c | ||
|
|
846574e613 | ||
|
|
cd40fdc704 | ||
|
|
7f01696a56 | ||
|
|
52da3def88 | ||
|
|
baea60473a | ||
|
|
4d6d2b550a | ||
|
|
ae99204f58 | ||
|
|
03e95cfa23 | ||
|
|
25f854b155 | ||
|
|
a32c751aaa | ||
|
|
e212e17bef | ||
|
|
4a7036cd82 | ||
|
|
d7d7620c24 | ||
|
|
3d545acda5 | ||
|
|
1d5a8beb3d | ||
|
|
82a14a8f24 | ||
|
|
d07ff8aa17 | ||
|
|
855927e1cd | ||
|
|
a67beb0fda | ||
|
|
b3e2720bc9 | ||
|
|
99cb9e332a | ||
|
|
541e775fdb | ||
|
|
0c220c79f2 | ||
|
|
abc0bfe3ae | ||
|
|
ff28d67e4b | ||
|
|
a723e8acff | ||
|
|
9c20ef0575 | ||
|
|
00b19d8c99 | ||
|
|
8bcb1f2177 | ||
|
|
37be7fbfc7 | ||
|
|
29ef92e3b8 | ||
|
|
accddf319d | ||
|
|
dafae75b21 | ||
|
|
6e477ec091 | ||
|
|
8ae504024e | ||
|
|
665ac47150 | ||
|
|
f6d1356873 | ||
|
|
40a749b304 | ||
|
|
628b26543f | ||
|
|
c25c982264 | ||
|
|
32e21dbf50 | ||
|
|
7653b494fe | ||
|
|
d20def4647 | ||
|
|
759796402e | ||
|
|
13281ebff9 | ||
|
|
2d52da106b | ||
|
|
587f74e6aa | ||
|
|
74ba2ff568 | ||
|
|
7e658c08b6 | ||
|
|
cdda69d8b6 | ||
|
|
41721b02a7 | ||
|
|
6bb3afb707 | ||
|
|
3550d3909e | ||
|
|
1f0b251885 | ||
|
|
701d70681f | ||
|
|
9f312800e1 | ||
|
|
d892b03142 | ||
|
|
105ed018b1 | ||
|
|
7d872f1a4b | ||
|
|
5a1173f257 | ||
|
|
567e64462b | ||
|
|
95c5b11352 | ||
|
|
26ceb59564 | ||
|
|
ddf11b732f | ||
|
|
d35007b369 | ||
|
|
aa011357bc | ||
|
|
53296485e8 | ||
|
|
3f4fe0429f | ||
|
|
31389485fd | ||
|
|
c84f88b607 | ||
|
|
a3cee92371 | ||
|
|
8ae79e6b3d | ||
|
|
93fb4eafd4 | ||
|
|
5f2c20fe13 | ||
|
|
27b81f00d1 | ||
|
|
0d0ad0a73f | ||
|
|
7f20cd47f2 | ||
|
|
ddabe9f86e | ||
|
|
22cee2c494 | ||
|
|
4f74885e8f | ||
|
|
c4a253efb7 | ||
|
|
f34b947e59 | ||
|
|
5c98c1ecda | ||
|
|
61b37d0907 | ||
|
|
e974af3c0e | ||
|
|
182e6e15c8 | ||
|
|
c11a0e326c | ||
|
|
1087235ecb | ||
|
|
cf45e73448 | ||
|
|
6cf8517606 | ||
|
|
f73ac56bde | ||
|
|
be5dc77e24 | ||
|
|
db17074ac0 | ||
|
|
40d506c389 |
No files matched your search
@@ -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 }}
|
||||
@@ -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
|
||||
@@ -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
|
||||
+1
-2
@@ -1,10 +1,9 @@
|
||||
/target/
|
||||
/.idea/
|
||||
SimpleClans.iml
|
||||
/bin/
|
||||
/.classpath
|
||||
/.project
|
||||
/dependency-reduced-pom.xml
|
||||
/simpleclans-mc1.8.iml
|
||||
*.jar
|
||||
.settings
|
||||
.factorypath
|
||||
@@ -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>.
|
||||
@@ -1,3 +1,5 @@
|
||||
[](https://www.spigotmc.org/resources/simpleclans.71242/)
|
||||
|
||||
SimpleClans
|
||||
==========
|
||||
|
||||
@@ -8,10 +10,39 @@ Full featured clan system for PVP Minecraft Servers!
|
||||
[](https://github.com/RoinujNosde/SimpleClans/issues)
|
||||
[](https://crowdin.com/project/simpleclans)
|
||||
[](https://discord.gg/CkNwgdE)
|
||||
[](https://bstats.org/plugin/bukkit/SimpleClans/7131)
|
||||
[](https://bstats.org/plugin/bukkit/SimpleClans/7131)
|
||||
|
||||
Spigot resource page: https://www.spigotmc.org/resources/simpleclans.71242/
|
||||
|
||||
Wiki page: https://github.com/RoinujNosde/SimpleClans/wiki
|
||||
#### Download Link
|
||||
|
||||
* [Download from Spigot](https://www.spigotmc.org/resources/simpleclans.71242/)
|
||||
|
||||
#### Documentation
|
||||
|
||||
* [Documentation](https://simpleclans.gitbook.io/simpleclans/)
|
||||
* Commands & Permissions
|
||||
* [Permissions](https://simpleclans.gitbook.io/simpleclans/commands-and-permissions/permissions)
|
||||
* [Commands](https://simpleclans.gitbook.io/simpleclans/commands-and-permissions/commands)
|
||||
* [Clan Alliances and Rivalries](https://simpleclans.gitbook.io/simpleclans/commands-and-permissions/aliances-and-rivalries)
|
||||
* [Clan Ranks with Permissions](https://simpleclans.gitbook.io/simpleclans/commands-and-permissions/ranks-with-permissions)
|
||||
* How to Setup
|
||||
* [Configuration](https://simpleclans.gitbook.io/simpleclans/how-to-setup/configuration)
|
||||
* [Translation](https://simpleclans.gitbook.io/simpleclans/how-to-setup/translation)
|
||||
* [Clan Member Fee](https://simpleclans.gitbook.io/simpleclans/how-to-setup/member-fee)
|
||||
* [Clan Upkeep](https://simpleclans.gitbook.io/simpleclans/how-to-setup/clan-upkeep)
|
||||
* [Clan name above players head](https://simpleclans.gitbook.io/simpleclans/how-to-setup/clan-below-players-name)
|
||||
* [Clan name on Tablist](https://simpleclans.gitbook.io/simpleclans/how-to-setup/clan-on-tablist)
|
||||
* Plugins & Development
|
||||
* [SimpleClans API Example](https://simpleclans.gitbook.io/simpleclans/other/simpleclans-api)
|
||||
* [PlaceholderAPI Placeholders](https://simpleclans.gitbook.io/simpleclans/other/placeholderapi-support)
|
||||
* [Land Protection Plugins](https://simpleclans.gitbook.io/simpleclans/other/land-claims)
|
||||
|
||||
#### Support & Suggestions
|
||||
|
||||
* [Discord Support](https://discord.gg/CkNwgdE)
|
||||
* [Bugs and Suggestions](https://github.com/RoinujNosde/SimpleClans/issues)
|
||||
|
||||
|
||||
#### Developers
|
||||
|
||||
@@ -19,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.12.2</version>
|
||||
<version>2.15.0</version> <!-- You can find the latest version at the bottom -->
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -37,12 +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.12.2"
|
||||
compileOnly "net.sacredlabyrinth.phaed.simpleclans:SimpleClans:2.15.0"
|
||||
}
|
||||
```
|
||||
|
||||
Some examples on how to use the API: https://github.com/RoinujNosde/SimpleClans/wiki/SimpleClans-API-example
|
||||
##### Latest version:
|
||||
[]()
|
||||
##### API Examples
|
||||
* [Examples of how to use the API](https://simpleclans.gitbook.io/simpleclans/other/simpleclans-api)
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
<?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" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<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.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" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: me.clip:placeholderapi:2.10.9" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains:annotations:16.0.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: io.papermc:paperlib:1.0.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:acf-paper:0.5.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.github.cryptomorin:XSeries:7.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.12" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.26.0-GA" level="project" />
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.junit.jupiter:junit-jupiter-api:5.4.0" level="project" />
|
||||
<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" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:PlotSquared-Core:5.13.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:PlotSquared-Bukkit:5.13.3" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:plotsquared-api:3.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.plotsquared:plotsquared-bukkitapi:3.1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.milkbowl.vault:VaultAPI:1.7" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,3 @@
|
||||
files:
|
||||
- source: src/main/resources/messages.properties
|
||||
translation: /src/main/resources/%file_name%_%locale_with_underscore%.%file_extension%
|
||||
+144
-19
@@ -4,18 +4,8 @@
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<name>SimpleClans</name>
|
||||
<version>2.14.2</version>
|
||||
<version>2.15.1</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>
|
||||
@@ -86,6 +76,10 @@
|
||||
<pattern>com.cryptomorin.xseries</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.xseries</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.reflections</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
@@ -109,10 +103,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>
|
||||
@@ -121,12 +111,28 @@
|
||||
<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>IntellectualSites</id>
|
||||
<url>https://mvn.intellectualsites.com/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>plotsquared</id>
|
||||
<url>https://plotsquared.com/mvn/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</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>
|
||||
@@ -187,13 +193,132 @@
|
||||
<version>16.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>5.4.0</version>
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>apiguardian-api</artifactId>
|
||||
<groupId>org.apiguardian</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>opentest4j</artifactId>
|
||||
<groupId>org.opentest4j</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>junit-platform-commons</artifactId>
|
||||
<groupId>org.junit.platform</groupId>
|
||||
</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>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
<version>5.13.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Bukkit</artifactId>
|
||||
<version>5.13.3</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
<groupId>*</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-api</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>*</artifactId>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
<groupId>org.yaml</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>gson</artifactId>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-bukkitapi</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>*</artifactId>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>Core</artifactId>
|
||||
<groupId>PlotSquared</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>VaultAPI</artifactId>
|
||||
<groupId>net.milkbowl.vault</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>guava</artifactId>
|
||||
<groupId>com.google.guava</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<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>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
@@ -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=""_, _, -> !null""/>
|
||||
<val val=""_, _ -> !null""/>
|
||||
</annotation>
|
||||
</item>
|
||||
</root>
|
||||
@@ -3,7 +3,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>net.sacredlabyrinth.phaed.simpleclans</groupId>
|
||||
<artifactId>SimpleClans</artifactId>
|
||||
<version>2.14.2</version>
|
||||
<version>2.15.2</version>
|
||||
<name>SimpleClans</name>
|
||||
<url>http://dev.bukkit.org/server-mods/simpleclans/</url>
|
||||
|
||||
@@ -84,6 +84,10 @@
|
||||
<pattern>com.cryptomorin.xseries</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.xseries</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>org.reflections</pattern>
|
||||
<shadedPattern>net.sacredlabyrinth.phaed.simpleclans.reflections</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<artifactSet>
|
||||
<excludes>
|
||||
@@ -107,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>
|
||||
@@ -160,6 +164,70 @@
|
||||
<artifactId>reflections</artifactId>
|
||||
<version>0.9.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<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>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
<version>5.13.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>PlotSquared-Bukkit</artifactId>
|
||||
<version>5.13.3</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>*</groupId>
|
||||
<artifactId>PlotSquared-Core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-api</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.plotsquared</groupId>
|
||||
<artifactId>plotsquared-bukkitapi</artifactId>
|
||||
<version>3.1</version>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>*</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>PlotSquared</groupId>
|
||||
<artifactId>Core</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Repositories -->
|
||||
@@ -176,10 +244,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>
|
||||
@@ -188,22 +252,24 @@
|
||||
<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>IntellectualSites</id>
|
||||
<url>https://mvn.intellectualsites.com/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>plotsquared</id>
|
||||
<url>https://plotsquared.com/mvn/</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>
|
||||
@@ -212,9 +278,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,14 +1,16 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
@@ -24,41 +26,25 @@ 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;
|
||||
this.cropRight = cropRight;
|
||||
}
|
||||
|
||||
|
||||
public void setPadRight(boolean padRight) {
|
||||
this.padRight = padRight;
|
||||
this.padRight = padRight;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param columnAlignment
|
||||
*/
|
||||
|
||||
public void setAlignment(String... columnAlignment) {
|
||||
columnAlignments.addAll(Arrays.asList(columnAlignment));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param columnFlex
|
||||
*/
|
||||
public void setFlexibility(boolean... columnFlex) {
|
||||
for (boolean flex : columnFlex) {
|
||||
columnFlexes.add(flex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param columnPercentages
|
||||
* @param prefix
|
||||
*/
|
||||
public void setColumnSizes(String prefix, double... columnPercentages) {
|
||||
int ll = LINE_LENGTH;
|
||||
|
||||
@@ -71,73 +57,38 @@ public class ChatBlock {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean hasContent() {
|
||||
return !rows.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contents
|
||||
*/
|
||||
public void addRow(String... contents) {
|
||||
rows.add(contents);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public int size() {
|
||||
return rows.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return rows.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void clear() {
|
||||
rows.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public boolean sendBlock(CommandSender player) {
|
||||
return sendBlock(player, null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param prefix
|
||||
* @return
|
||||
*/
|
||||
public boolean sendBlock(CommandSender player, String prefix) {
|
||||
return sendBlock(player, prefix, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
public boolean sendBlock(CommandSender player, int amount) {
|
||||
return sendBlock(player, null, amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param prefix
|
||||
* @param amount
|
||||
* @return
|
||||
*/
|
||||
boolean sendBlock(CommandSender player, String prefix, int amount) {
|
||||
if (player == null) {
|
||||
return false;
|
||||
@@ -198,27 +149,27 @@ public class ChatBlock {
|
||||
}
|
||||
} else if (align.equalsIgnoreCase("l")) {
|
||||
if (msgLength(section) > colsize) {
|
||||
if (cropRight) {
|
||||
col = cropRightToFit(section, colsize);
|
||||
if (cropRight) {
|
||||
col = cropRightToFit(section, colsize);
|
||||
} else {
|
||||
col = section;
|
||||
col = section;
|
||||
}
|
||||
} else if (msgLength(section) < colsize) {
|
||||
if (padRight) {
|
||||
col = paddRightToFit(section, colsize);
|
||||
} else {
|
||||
col = section;
|
||||
}
|
||||
if (padRight) {
|
||||
col = paddRightToFit(section, colsize);
|
||||
} else {
|
||||
col = section;
|
||||
}
|
||||
}
|
||||
} else if (align.equalsIgnoreCase("c")) {
|
||||
if (msgLength(section) > colsize) {
|
||||
if (cropRight) {
|
||||
col = cropRightToFit(section, colsize);
|
||||
} else {
|
||||
col = section;
|
||||
}
|
||||
if (cropRight) {
|
||||
col = cropRightToFit(section, colsize);
|
||||
} else {
|
||||
col = section;
|
||||
}
|
||||
} else if (msgLength(section) < colsize) {
|
||||
col = centerInLineOf(section, colsize);
|
||||
col = centerInLineOf(section, colsize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +234,7 @@ public class ChatBlock {
|
||||
// crop and print out
|
||||
String msg = (prefix_used ? empty_prefix : prefix + " ") + finalString;
|
||||
if (cropRight) {
|
||||
msg = cropRightToFit(msg, LINE_LENGTH);
|
||||
msg = cropRightToFit(msg, LINE_LENGTH);
|
||||
}
|
||||
if (color.length() > 0) {
|
||||
msg = color + msg;
|
||||
@@ -308,10 +259,6 @@ public class ChatBlock {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param col
|
||||
* @return
|
||||
*/
|
||||
int getMaxWidth(int col) {
|
||||
double maxWidth = 0;
|
||||
|
||||
@@ -322,19 +269,10 @@ public class ChatBlock {
|
||||
return (int) maxWidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
* @return
|
||||
*/
|
||||
public static String centerInLine(String msg) {
|
||||
return centerInLineOf(msg, LINE_LENGTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
* @param lineLength
|
||||
* @return
|
||||
*/
|
||||
private static String centerInLineOf(String msg, double lineLength) {
|
||||
double length = msgLength(msg);
|
||||
double diff = lineLength - length;
|
||||
@@ -359,10 +297,6 @@ public class ChatBlock {
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static String makeEmpty(String str) {
|
||||
if (str == null) {
|
||||
return "";
|
||||
@@ -371,11 +305,6 @@ public class ChatBlock {
|
||||
return paddLeftToFit("", msgLength(str));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
* @param length
|
||||
* @return
|
||||
*/
|
||||
private static String cropRightToFit(String msg, double length) {
|
||||
if (msg == null || msg.length() == 0 || length == 0) {
|
||||
return "";
|
||||
@@ -388,11 +317,6 @@ public class ChatBlock {
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param msg
|
||||
* @param length
|
||||
* @return
|
||||
*/
|
||||
private static String cropLeftToFit(String msg, double length) {
|
||||
if (msg == null || msg.length() == 0 || length == 0) {
|
||||
return "";
|
||||
@@ -406,11 +330,11 @@ public class ChatBlock {
|
||||
}
|
||||
|
||||
/**
|
||||
* Padds left til the string is a certain size
|
||||
* Pads left til the string is a certain size
|
||||
*
|
||||
* @param msg
|
||||
* @param length
|
||||
* @return
|
||||
* @param msg the message to pad
|
||||
* @param length the message length
|
||||
* @return the padded message
|
||||
*/
|
||||
private static String paddLeftToFit(String msg, double length) {
|
||||
if (msgLength(msg) >= length) {
|
||||
@@ -425,11 +349,11 @@ public class ChatBlock {
|
||||
}
|
||||
|
||||
/**
|
||||
* Padds right til the string is a certain size
|
||||
* Pads right til the string is a certain size
|
||||
*
|
||||
* @param msg
|
||||
* @param length
|
||||
* @return
|
||||
* @param msg the message to pad
|
||||
* @param length the message length
|
||||
* @return the padded message
|
||||
*/
|
||||
private static String paddRightToFit(String msg, double length) {
|
||||
if (msgLength(msg) >= length) {
|
||||
@@ -445,9 +369,6 @@ public class ChatBlock {
|
||||
|
||||
/**
|
||||
* Finds the length on the screen of a string. Ignores colors.
|
||||
*
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
private static double msgLength(String str) {
|
||||
double length = 0;
|
||||
@@ -468,9 +389,6 @@ public class ChatBlock {
|
||||
|
||||
/**
|
||||
* Finds the visual length of the character on the screen.
|
||||
*
|
||||
* @param x
|
||||
* @return
|
||||
*/
|
||||
private static int charLength(char x) {
|
||||
String normalized = StringSimplifier.simplifiedString(x + "");
|
||||
@@ -496,15 +414,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
|
||||
|
||||
@@ -544,19 +458,15 @@ 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();
|
||||
for (String aString : string) {
|
||||
@@ -570,10 +480,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;
|
||||
@@ -607,9 +513,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) {
|
||||
@@ -621,39 +524,43 @@ public class ChatBlock {
|
||||
|
||||
/**
|
||||
* Outputs a message to a user
|
||||
*
|
||||
* @param receiver
|
||||
* @param msg
|
||||
*/
|
||||
public static void sendMessage(CommandSender receiver, String msg) {
|
||||
public static void sendMessage(@Nullable CommandSender receiver, @NotNull String msg) {
|
||||
if (receiver == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String[] message = colorize(wordWrap(msg));
|
||||
receiver.sendMessage(ChatUtils.parseColors(msg));
|
||||
// String[] message = colorize(wordWrap(msg));
|
||||
//
|
||||
// for (String out : message) {
|
||||
// receiver.sendMessage(out);
|
||||
// }
|
||||
}
|
||||
|
||||
for (String out : message) {
|
||||
receiver.sendMessage(out);
|
||||
public static void sendMessage(@Nullable ClanPlayer receiver, @NotNull String msg) {
|
||||
if (receiver == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = receiver.toPlayer();
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
player.sendMessage(ChatUtils.parseColors(msg));
|
||||
}
|
||||
|
||||
public static void sendMessageKey(@NotNull CommandSender receiver, @NotNull String key) {
|
||||
sendMessage(receiver, lang(key, receiver));
|
||||
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
|
||||
*
|
||||
* @param receiver
|
||||
* Send blank line
|
||||
*/
|
||||
public static void sendBlank(CommandSender receiver) {
|
||||
if (receiver == null) {
|
||||
@@ -665,22 +572,15 @@ public class ChatBlock {
|
||||
|
||||
/**
|
||||
* Colors each line
|
||||
*
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
public static String[] say(String message) {
|
||||
return colorize(wordWrap(message));
|
||||
}
|
||||
|
||||
|
||||
public static String[] getColorizedMessage(String msg) {
|
||||
return colorize(wordWrap(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
private static String[] colorize(String[] message) {
|
||||
try {
|
||||
return colorizeBase(message);
|
||||
@@ -689,21 +589,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
|
||||
|
||||
@@ -719,9 +610,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -733,6 +623,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,5 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
public enum EconomyResponse {
|
||||
SUCCESS, NEGATIVE_VALUE, NOT_ENOUGH_BALANCE, CANCELLED
|
||||
}
|
||||
@@ -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,10 +1,14 @@
|
||||
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;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
@@ -15,6 +19,8 @@ import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.HttpURLConnection;
|
||||
@@ -25,6 +31,7 @@ import java.time.LocalTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
@@ -76,51 +83,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(@Nullable 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(@Nullable 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>();
|
||||
|
||||
@@ -139,6 +169,7 @@ public class Helper {
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("ranks", array);
|
||||
object.put("defaultRank", defaultRank);
|
||||
return object.toJSONString();
|
||||
}
|
||||
|
||||
@@ -201,7 +232,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;
|
||||
@@ -374,6 +406,9 @@ public class Helper {
|
||||
if (hexValue == null) {
|
||||
return "";
|
||||
}
|
||||
if (hexValue.startsWith("&#")) {
|
||||
return ChatUtils.parseColors(hexValue);
|
||||
}
|
||||
|
||||
ChatColor color = ChatColor.getByChar(hexValue);
|
||||
if (color == null) {
|
||||
@@ -510,25 +545,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);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -751,6 +782,10 @@ public class Helper {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link VanishUtils#isVanished(CommandSender, Player)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Contract("_, null -> false")
|
||||
public static boolean isVanished(@Nullable CommandSender viewer, @Nullable Player player) {
|
||||
if (isVanished(player)) {
|
||||
@@ -763,6 +798,10 @@ public class Helper {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link VanishUtils#isVanished(Player)}
|
||||
*/
|
||||
@Deprecated
|
||||
@Contract("null -> false")
|
||||
public static boolean isVanished(@Nullable Player player) {
|
||||
if (player != null && player.hasMetadata("vanished") && !player.getMetadata("vanished").isEmpty()) {
|
||||
@@ -808,8 +847,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) {
|
||||
@@ -820,8 +859,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())
|
||||
@@ -842,8 +886,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);
|
||||
|
||||
@@ -860,7 +904,7 @@ public class Helper {
|
||||
*
|
||||
* @param cp Sender
|
||||
* @param msg The chat message
|
||||
* @return The formated message
|
||||
* @return The formatted message
|
||||
*/
|
||||
public static String formatSpyClanChat(ClanPlayer cp, String msg) {
|
||||
msg = stripColors(msg);
|
||||
@@ -871,4 +915,47 @@ public class Helper {
|
||||
return ChatColor.DARK_GRAY + "[" + cp.getTag() + "] " + msg;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Formats max inactive days to an infinity symbol if it's negative or 0
|
||||
*
|
||||
* @param max inactive days
|
||||
* @return formatted message
|
||||
*/
|
||||
public static String formatMaxInactiveDays(int max) {
|
||||
if (max <= 0) {
|
||||
return "∞";
|
||||
} else {
|
||||
return String.valueOf(max);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static String getFormattedClanStatus(Clan clan, CommandSender sender) {
|
||||
ArrayList<String> statuses = new ArrayList<>();
|
||||
if (clan.isPermanent()) {
|
||||
statuses.add(lang("permanent", sender));
|
||||
}
|
||||
if (clan.isVerified()) {
|
||||
statuses.add(lang("verified", sender));
|
||||
} else {
|
||||
statuses.add(lang("unverified", sender));
|
||||
}
|
||||
return String.join(", ", statuses);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if all passed materials are some kind of AIR
|
||||
*
|
||||
* @param materials materials to test
|
||||
* @return true if all materials are AIR
|
||||
*/
|
||||
public static boolean isAir(@NotNull Material... materials) {
|
||||
for (Material m : materials) {
|
||||
if (!m.name().contains("AIR")) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -27,7 +27,7 @@ public class Kill {
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
CIVILIAN("c"), RIVAL("r"), NEUTRAL("n");
|
||||
CIVILIAN("c"), RIVAL("r"), NEUTRAL("n"), ALLY("a");
|
||||
|
||||
Type(String shortName) {
|
||||
this.shortName = shortName;
|
||||
|
||||
@@ -1,61 +0,0 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class PlayerNameTabCompleter implements TabCompleter {
|
||||
private final SimpleClans plugin;
|
||||
|
||||
public PlayerNameTabCompleter() {
|
||||
plugin = SimpleClans.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(@NotNull CommandSender commandSender, Command command, @NotNull String s, String[] strings) {
|
||||
if (command.getName().equalsIgnoreCase(plugin.getSettingsManager().getCommandClan())) {
|
||||
if (strings.length < 2) {
|
||||
return null;
|
||||
}
|
||||
Player player = null;
|
||||
if (commandSender instanceof Player) {
|
||||
player = (Player) commandSender;
|
||||
}
|
||||
|
||||
if (strings[0].equalsIgnoreCase(lang("lookup.command", player)) ||
|
||||
strings[0].equalsIgnoreCase(lang("ban.command", player)) ||
|
||||
strings[0].equalsIgnoreCase(lang("unban.command", player)) ||
|
||||
strings[0].equalsIgnoreCase(lang("kick.command", player)) ||
|
||||
strings[0].equalsIgnoreCase(lang("trust.command", player)) ||
|
||||
strings[0].equalsIgnoreCase(lang("untrust.command", player)) ||
|
||||
strings[0].equalsIgnoreCase(lang("promote.command", player)) ||
|
||||
strings[0].equalsIgnoreCase(lang("demote.command", player)) ||
|
||||
strings[0].equalsIgnoreCase(lang("setrank.command", player)) ||
|
||||
strings[0].equalsIgnoreCase(lang("place.command", player)) ||
|
||||
strings[0].equalsIgnoreCase(lang("invite.command", player)) ||
|
||||
strings[0].equalsIgnoreCase(lang("kills.command", player))) {
|
||||
List<String> list = new ArrayList<>();
|
||||
|
||||
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
||||
if (p.getName().startsWith(strings[1])) {
|
||||
list.add(p.getName());
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(list);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -2,20 +2,21 @@ 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.SCEntityListener;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.listeners.SCPlayerListener;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.listeners.*;
|
||||
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;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -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();
|
||||
@@ -109,9 +114,13 @@ public class SimpleClans extends JavaPlugin {
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
getServer().getPluginManager().registerEvents(new SCEntityListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new SCPlayerListener(), this);
|
||||
getServer().getPluginManager().registerEvents(new InventoryController(), this);
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
pm.registerEvents(new PlayerDeath(), this);
|
||||
pm.registerEvents(new SCPlayerListener(), this);
|
||||
pm.registerEvents(new InventoryController(), this);
|
||||
pm.registerEvents(new TamableMobsSharing(this), this);
|
||||
pm.registerEvents(new PvPOnlyInWar(this), this);
|
||||
pm.registerEvents(new FriendlyFire(this), this);
|
||||
}
|
||||
|
||||
private void migrateChatFormat() {
|
||||
@@ -123,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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,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
|
||||
@@ -245,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,11 +59,13 @@ 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() {
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands.completions");
|
||||
Set<Class<? extends AbstractCompletion>> completions = reflections.getSubTypesOf(AbstractCompletion.class);
|
||||
plugin.getLogger().info(String.format("Registering %d command completions...", completions.size()));
|
||||
for (Class<? extends AbstractCompletion> c : completions) {
|
||||
if (Modifier.isAbstract(c.getModifiers())) {
|
||||
continue;
|
||||
@@ -90,6 +92,7 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
private void registerConditions() {
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands.conditions");
|
||||
Set<Class<? extends AbstractCondition>> conditions = reflections.getSubTypesOf(AbstractCondition.class);
|
||||
plugin.getLogger().info(String.format("Registering %d command conditions...", conditions.size()));
|
||||
for (Class<? extends AbstractCondition> c : conditions) {
|
||||
if (Modifier.isAbstract(c.getModifiers())) {
|
||||
continue;
|
||||
@@ -115,6 +118,7 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
private void registerContexts() {
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands.contexts");
|
||||
Set<Class<? extends AbstractContextResolver>> resolvers = reflections.getSubTypesOf(AbstractContextResolver.class);
|
||||
plugin.getLogger().info(String.format("Registering %d command contexts...", resolvers.size()));
|
||||
for (Class<? extends AbstractContextResolver> cr : resolvers) {
|
||||
if (Modifier.isAbstract(cr.getModifiers())) {
|
||||
continue;
|
||||
@@ -137,6 +141,7 @@ public class SCCommandManager extends PaperCommandManager {
|
||||
boolean forceCommandPriority = plugin.getSettingsManager().isForceCommandPriority();
|
||||
Reflections reflections = new Reflections("net.sacredlabyrinth.phaed.simpleclans.commands");
|
||||
Set<Class<? extends BaseCommand>> commands = reflections.getSubTypesOf(BaseCommand.class);
|
||||
plugin.getLogger().info(String.format("Registering %d base commands...", commands.size()));
|
||||
for (Class<? extends BaseCommand> c : commands) {
|
||||
//ACF already registers nested classes
|
||||
if (c.isMemberClass() || Modifier.isStatic(c.getModifiers())) {
|
||||
@@ -156,15 +161,22 @@ 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()
|
||||
);
|
||||
|
||||
SUBCOMMANDS.forEach(s ->
|
||||
getCommandReplacements().addReplacement(s, (lang(s + ".command") + "|" + s)));
|
||||
SUBCOMMANDS.forEach(s -> {
|
||||
String command = optionalLang(s + ".command", null);
|
||||
if (command == null) {
|
||||
command = s;
|
||||
}
|
||||
command = command.replace(" ", "");
|
||||
String replacement = command.equals(s) ? s : command + "|" + s;
|
||||
getCommandReplacements().addReplacement(s, replacement);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,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", "permanent", "take", "give");
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ public class AllyChatCommand extends BaseCommand {
|
||||
|
||||
@Default
|
||||
@HelpSearchTags("chat")
|
||||
@CommandCompletion("@chat_subcommands")
|
||||
public void sendMessage(Player player, @Name("message") String message) {
|
||||
if (!settingsManager.isAllyChatEnable()) {
|
||||
return;
|
||||
|
||||
@@ -4,7 +4,13 @@ import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.EconomyResponse;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.BankDepositEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.BankWithdrawEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
@@ -42,6 +48,7 @@ public class BankCommand extends BaseCommand {
|
||||
processWithdraw(player, clan, amount);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void processWithdraw(Player player, Clan clan, double amount) {
|
||||
if (!clan.isAllowWithdraw()) {
|
||||
String message = getCurrentCommandManager().getCommandReplacements()
|
||||
@@ -49,10 +56,26 @@ public class BankCommand extends BaseCommand {
|
||||
ChatBlock.sendMessage(player, RED + message);
|
||||
return;
|
||||
}
|
||||
if (amount < 0) {
|
||||
amount = amount * -1;
|
||||
amount = Math.abs(amount);
|
||||
BankWithdrawEvent event = new BankWithdrawEvent(player, clan, amount);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (clan.withdraw(player, ClanBalanceUpdateEvent.Cause.COMMAND, amount)) {
|
||||
case SUCCESS:
|
||||
if (SimpleClans.getInstance().getPermissionsManager().playerGrantMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.withdraw", player, amount));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.withdraw", amount));
|
||||
} else {
|
||||
clan.setBalance(player, ClanBalanceUpdateEvent.Cause.REVERT, clan.getBalance() + amount);
|
||||
}
|
||||
break;
|
||||
case NOT_ENOUGH_BALANCE:
|
||||
player.sendMessage(lang("clan.bank.not.enough.money", player));
|
||||
break;
|
||||
}
|
||||
clan.withdraw(amount, player);
|
||||
}
|
||||
|
||||
@Subcommand("%deposit %all")
|
||||
@@ -71,6 +94,7 @@ public class BankCommand extends BaseCommand {
|
||||
processDeposit(player, clan, amount);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void processDeposit(Player player, Clan clan, double amount) {
|
||||
if (!clan.isAllowDeposit()) {
|
||||
String message = getCurrentCommandManager().getCommandReplacements()
|
||||
@@ -78,9 +102,25 @@ public class BankCommand extends BaseCommand {
|
||||
ChatBlock.sendMessage(player, RED + message);
|
||||
return;
|
||||
}
|
||||
if (amount < 0) {
|
||||
amount = amount * -1;
|
||||
amount = Math.abs(amount);
|
||||
BankDepositEvent event = new BankDepositEvent(player, clan, amount);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
if (!permissions.playerHasMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("not.sufficient.money", player));
|
||||
return;
|
||||
}
|
||||
EconomyResponse response = clan.deposit(player, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
if (response == EconomyResponse.SUCCESS) {
|
||||
if (permissions.playerChargeMoney(player, amount)) {
|
||||
player.sendMessage(AQUA + lang("player.clan.deposit", player, amount));
|
||||
clan.addBb(player.getName(), AQUA + lang("bb.clan.deposit", amount));
|
||||
} else {
|
||||
//Reverts the deposit if something went wrong with Vault
|
||||
clan.setBalance(player, ClanBalanceUpdateEvent.Cause.REVERT, clan.getBalance() - amount);
|
||||
}
|
||||
}
|
||||
clan.deposit(amount, player);
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,7 @@ public class BbCommand extends BaseCommand {
|
||||
ChatBlock.sendMessage(player, RED + lang("cleared.bb", player));
|
||||
}
|
||||
|
||||
@Subcommand("%bb")
|
||||
@Subcommand("%bb %add")
|
||||
@CommandPermission("simpleclans.member.bb-add")
|
||||
@Conditions("rank:name=BB_ADD")
|
||||
@Description("{@@command.description.bb.post}")
|
||||
|
||||
@@ -20,6 +20,7 @@ public class ChatCommand extends BaseCommand {
|
||||
|
||||
@Default
|
||||
@HelpSearchTags("chat")
|
||||
@CommandCompletion("@chat_subcommands")
|
||||
public void sendMessage(Player player, ClanPlayer cp, @Name("message") String message) {
|
||||
if (!settingsManager.getClanChatEnable()) {
|
||||
return;
|
||||
|
||||
+16
-15
@@ -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;
|
||||
@@ -35,30 +36,29 @@ public class ClanCommands extends BaseCommand {
|
||||
private PermissionsManager permissions;
|
||||
@Dependency
|
||||
private RequestManager requestManager;
|
||||
@Dependency
|
||||
private ProtectionManager protectionManager;
|
||||
|
||||
@Subcommand("%war %start")
|
||||
@CommandPermission("simpleclans.leader.war")
|
||||
@Conditions("verified|rank:name=WAR_START")
|
||||
@Description("{@@command.description.war.start}")
|
||||
@CommandCompletion("@rivals")
|
||||
public void startWar(Player player, ClanPlayer cp, Clan issuerClan, @Name("clan") ClanInput other) {
|
||||
Clan war = other.getClan();
|
||||
if (!issuerClan.isRival(war.getTag())) {
|
||||
ChatBlock.sendMessage(player, RED + lang("you.can.only.start.war.with.rivals", player));
|
||||
return;
|
||||
}
|
||||
if (!issuerClan.isWarring(war.getTag())) {
|
||||
List<ClanPlayer> onlineLeaders = Helper.stripOffLinePlayers(issuerClan.getLeaders());
|
||||
public void startWar(Player player, ClanPlayer requester, Clan requestClan, @Conditions("can_war_target") @Name("clan") ClanInput targetClanInput) {
|
||||
Clan targetClan = targetClanInput.getClan();
|
||||
|
||||
List<ClanPlayer> onlineLeaders = Helper.stripOffLinePlayers(requestClan.getLeaders());
|
||||
|
||||
if (settings.isWarRequestEnabled()) {
|
||||
if (!onlineLeaders.isEmpty()) {
|
||||
requestManager.addWarStartRequest(cp, war, issuerClan);
|
||||
requestManager.addWarStartRequest(requester, targetClan, requestClan);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("leaders.have.been.asked.to.accept.the.war.request",
|
||||
player, war.getName()));
|
||||
player, targetClan.getName()));
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, RED + lang("at.least.one.leader.accept.the.alliance", player));
|
||||
}
|
||||
} else {
|
||||
ChatBlock.sendMessage(player, RED + lang("clans.already.at.war", player));
|
||||
protectionManager.addWar(requester, requestClan, targetClan);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,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);
|
||||
}
|
||||
@@ -126,11 +126,11 @@ public class ClanCommands extends BaseCommand {
|
||||
|
||||
@Subcommand("%invite")
|
||||
@CommandPermission("simpleclans.leader.invite")
|
||||
@CommandCompletion("@non_members")
|
||||
@CommandCompletion("@non_members:ignore_vanished")
|
||||
@Conditions("rank:name=INVITE")
|
||||
@Description("{@@command.description.invite}")
|
||||
public void invite(Player sender, ClanPlayer cp, Clan clan,
|
||||
@Conditions("not_banned|not_in_clan|online") @Name("player") ClanPlayerInput invited) {
|
||||
@Conditions("not_banned|not_in_clan|online:ignore_vanished") @Name("player") ClanPlayerInput invited) {
|
||||
Player invitedPlayer = invited.getClanPlayer().toPlayer();
|
||||
if (invitedPlayer == null) return;
|
||||
if (!permissions.has(invitedPlayer, "simpleclans.member.can-join")) {
|
||||
@@ -176,9 +176,10 @@ public class ClanCommands extends BaseCommand {
|
||||
|
||||
@Subcommand("%fee %set")
|
||||
@CommandPermission("simpleclans.leader.fee")
|
||||
@Conditions("rank:name=FEE_SET")
|
||||
@Conditions("rank:name=FEE_SET|change_fee")
|
||||
@Description("{@@command.description.fee.set}")
|
||||
public void setFee(Player player, Clan clan, @Name("fee") double fee) {
|
||||
fee = Math.abs(fee);
|
||||
double maxFee = settings.getMaxMemberFee();
|
||||
if (fee > maxFee) {
|
||||
ChatBlock.sendMessage(player, RED
|
||||
|
||||
@@ -6,6 +6,7 @@ import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.data.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -58,7 +59,7 @@ public class DataCommands extends BaseCommand {
|
||||
@HelpSearchTags("local location")
|
||||
@Description("{@@command.description.coords}")
|
||||
public void coords(Player player, Clan clan) {
|
||||
if (clan.getOnlineMembers().size() == 1) {
|
||||
if (VanishUtils.getNonVanished(player, clan).size() == 1) {
|
||||
ChatBlock.sendMessage(player, RED + lang("you.are.the.only.member.online", player));
|
||||
return;
|
||||
}
|
||||
|
||||
+18
-6
@@ -5,7 +5,11 @@ 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;
|
||||
|
||||
@@ -22,6 +26,8 @@ public class HomeCommands extends BaseCommand {
|
||||
@Dependency
|
||||
private SettingsManager settings;
|
||||
@Dependency
|
||||
private ProtectionManager protection;
|
||||
@Dependency
|
||||
private ClanManager cm;
|
||||
|
||||
@Subcommand("%regroup %me")
|
||||
@@ -34,18 +40,18 @@ public class HomeCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
processTeleport(player, cp, clan, player.getLocation());
|
||||
processRegroup(player, cp, clan, player.getLocation());
|
||||
}
|
||||
|
||||
private void processTeleport(Player player, ClanPlayer cp, Clan clan, Location location) {
|
||||
HomeRegroupEvent homeRegroupEvent = new HomeRegroupEvent(clan, cp, clan.getOnlineMembers(), location);
|
||||
private void processRegroup(Player player, ClanPlayer cp, Clan clan, Location location) {
|
||||
HomeRegroupEvent homeRegroupEvent = new HomeRegroupEvent(clan, cp, VanishUtils.getNonVanished(player, clan), location);
|
||||
plugin.getServer().getPluginManager().callEvent(homeRegroupEvent);
|
||||
|
||||
if (homeRegroupEvent.isCancelled() || !cm.purchaseHomeRegroup(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getTeleportManager().teleport(clan, location);
|
||||
plugin.getTeleportManager().teleport(player, clan, location);
|
||||
}
|
||||
|
||||
@Subcommand("%regroup %home")
|
||||
@@ -63,7 +69,7 @@ public class HomeCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
processTeleport(player, cp, clan, location);
|
||||
processRegroup(player, cp, clan, location);
|
||||
}
|
||||
|
||||
@Subcommand("%home")
|
||||
@@ -108,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,176 @@
|
||||
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 net.sacredlabyrinth.phaed.simpleclans.managers.SettingsManager;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Subcommand("%land")
|
||||
@Conditions("%basic_conditions|land_sharing|own_land")
|
||||
@CommandPermission("simpleclans.member.land")
|
||||
public class LandCommand extends BaseCommand {
|
||||
|
||||
@Dependency
|
||||
private ProtectionManager protection;
|
||||
@Dependency
|
||||
private SettingsManager settings;
|
||||
|
||||
private Set<Land> getLands(ClanPlayer cp, Location location) {
|
||||
Player player = Objects.requireNonNull(cp.toPlayer());
|
||||
if (settings.isEditAllLands()) {
|
||||
return protection.getLands(player, location);
|
||||
} else {
|
||||
return protection.getLandsAt(location).stream().filter(l -> l.getOwners().contains(player.getUniqueId()))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
||||
@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) {
|
||||
for (Land land : getLands(cp, location)) {
|
||||
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) {
|
||||
for (Land land : getLands(cp, location)) {
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-2
@@ -102,8 +102,7 @@ public class LeaderCommands extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
clan.clanAnnounce(player.getName(), AQUA + lang("clan.has.been.disbanded", clan.getName()));
|
||||
clan.disband();
|
||||
clan.disband(player, true, false);
|
||||
}
|
||||
|
||||
@Subcommand("%verify")
|
||||
|
||||
+48
-10
@@ -5,8 +5,12 @@ import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.conversation.CreateRankNamePrompt;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.DeleteRankEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PlayerRankUpdateEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
@@ -36,11 +40,17 @@ public class RankCommand extends BaseCommand {
|
||||
@CommandPermission("simpleclans.leader.rank.assign")
|
||||
@CommandCompletion("@clan_members @ranks")
|
||||
@Description("{@@command.description.rank.assign}")
|
||||
public void assign(Player player,
|
||||
public void assign(ClanPlayer player,
|
||||
Clan clan,
|
||||
@Name("member") @Conditions("same_clan") ClanPlayerInput member,
|
||||
@Name("rank") Rank rank) {
|
||||
ClanPlayer memberInput = member.getClanPlayer();
|
||||
|
||||
PlayerRankUpdateEvent event = new PlayerRankUpdateEvent(player, memberInput, clan, clan.getRank(memberInput.getRankId()), rank);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
if (memberInput.getRankId().equals(rank.getName())) {
|
||||
ChatBlock.sendMessage(player, lang("player.already.has.that.rank", player));
|
||||
return;
|
||||
@@ -55,10 +65,16 @@ public class RankCommand extends BaseCommand {
|
||||
@CommandPermission("simpleclans.leader.rank.unassign")
|
||||
@CommandCompletion("@clan_members")
|
||||
@Description("{@@command.description.rank.unassign}")
|
||||
public void unassign(Player player, @Conditions("same_clan") @Name("member") ClanPlayerInput cp) {
|
||||
ClanPlayer cpInput = cp.getClanPlayer();
|
||||
cpInput.setRank(null);
|
||||
storage.updateClanPlayer(cpInput);
|
||||
public void unassign(ClanPlayer player, Clan clan, @Conditions("same_clan") @Name("member") ClanPlayerInput cp) {
|
||||
ClanPlayer memberInput = cp.getClanPlayer();
|
||||
|
||||
PlayerRankUpdateEvent event = new PlayerRankUpdateEvent(player, memberInput, clan, clan.getRank(memberInput.getRankId()), null);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) return;
|
||||
|
||||
memberInput.setRank(null);
|
||||
storage.updateClanPlayer(memberInput);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("player.unassigned.from.rank", player));
|
||||
}
|
||||
|
||||
@@ -67,7 +83,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();
|
||||
}
|
||||
@@ -77,9 +93,14 @@ public class RankCommand extends BaseCommand {
|
||||
@CommandCompletion("@ranks")
|
||||
@Description("{@@command.description.rank.delete}")
|
||||
public void delete(Player player, Clan clan, @Name("rank") Rank rank) {
|
||||
clan.deleteRank(rank.getName());
|
||||
storage.updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("rank.0.deleted", player, rank.getDisplayName()));
|
||||
DeleteRankEvent event = new DeleteRankEvent(player, clan, rank);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
clan.deleteRank(rank.getName());
|
||||
storage.updateClan(clan, true);
|
||||
ChatBlock.sendMessage(player, AQUA + lang("rank.0.deleted", player, rank.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%list")
|
||||
@@ -98,7 +119,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 +138,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
-1
@@ -53,7 +53,7 @@ public class ToggleCommand extends BaseCommand {
|
||||
|
||||
@Subcommand("%fee")
|
||||
@CommandPermission("simpleclans.leader.fee")
|
||||
@Conditions("rank:name=FEE_ENABLE")
|
||||
@Conditions("rank:name=FEE_ENABLE|change_fee")
|
||||
@Description("{@@command.description.toggle.fee}")
|
||||
public void fee(Player player, Clan clan) {
|
||||
toggle(player, "feeon", "feeoff", clan.isMemberFeeEnabled(),
|
||||
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.completions;
|
||||
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class ChatSubcommandsCompletion extends AbstractSyncCompletion {
|
||||
|
||||
public ChatSubcommandsCompletion(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "chat_subcommands";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getCompletions(BukkitCommandCompletionContext context) throws InvalidCommandArgument {
|
||||
Player player = context.getPlayer();
|
||||
if (player == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String leave = lang("leave", player);
|
||||
List<String> subcommands = new ArrayList<>(Arrays.asList(lang("join", player), leave, lang("mute",
|
||||
player)));
|
||||
ClanPlayer cp = clanManager.getAnyClanPlayer(player.getUniqueId());
|
||||
if (cp != null) {
|
||||
if (cp.getChannel() == ClanPlayer.Channel.NONE) {
|
||||
subcommands.remove(leave);
|
||||
}
|
||||
}
|
||||
|
||||
return subcommands;
|
||||
}
|
||||
}
|
||||
+13
-6
@@ -3,12 +3,13 @@ package net.sacredlabyrinth.phaed.simpleclans.commands.completions;
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.InvalidCommandArgument;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class NonMembersCompletion extends AbstractSyncCompletion {
|
||||
@@ -23,10 +24,16 @@ public class NonMembersCompletion extends AbstractSyncCompletion {
|
||||
|
||||
@Override
|
||||
public Collection<String> getCompletions(BukkitCommandCompletionContext c) throws InvalidCommandArgument {
|
||||
Player player = c.getPlayer();
|
||||
return Bukkit.getOnlinePlayers().stream()
|
||||
.filter(p -> clanManager.getClanByPlayerUniqueId(p.getUniqueId()) == null
|
||||
&& (player == null || player.canSee(p)))
|
||||
.map(Player::getName).collect(Collectors.toList());
|
||||
Collection<String> onlinePlayers = new ArrayList<>();
|
||||
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
boolean vanished = VanishUtils.isVanished(c.getSender(), onlinePlayer);
|
||||
if (clanManager.getClanByPlayerUniqueId(onlinePlayer.getUniqueId()) != null || (c.hasConfig("ignore_vanished") && vanished)) {
|
||||
continue;
|
||||
}
|
||||
onlinePlayers.add(onlinePlayer.getName());
|
||||
}
|
||||
|
||||
return onlinePlayers;
|
||||
}
|
||||
}
|
||||
+3
-4
@@ -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();
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
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.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static java.time.temporal.ChronoUnit.MINUTES;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class CanChangeFeeCondition extends AbstractCommandCondition {
|
||||
|
||||
private static final float HOUR_IN_MINUTES = 60;
|
||||
|
||||
public CanChangeFeeCondition(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context) throws InvalidCommandArgument {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime collectTime = getCollectTime();
|
||||
long interval = now.until(collectTime, MINUTES);
|
||||
if (interval <= settingsManager.geteMemberFeeLastMinuteChangeInterval() * HOUR_IN_MINUTES) {
|
||||
BukkitCommandIssuer issuer = context.getIssuer();
|
||||
String error = lang("cannot.change.member.fee.now", issuer);
|
||||
if (interval <= 60) {
|
||||
error += lang("cannot.change.member.fee.minutes", issuer, interval);
|
||||
} else {
|
||||
error += lang("cannot.change.member.fee.hours", issuer, Math.ceil(interval / HOUR_IN_MINUTES));
|
||||
}
|
||||
throw new ConditionFailedException(error);
|
||||
}
|
||||
}
|
||||
|
||||
private LocalDateTime getCollectTime() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime collectTime = now.withHour(settingsManager.getTasksCollectFeeHour())
|
||||
.withMinute(settingsManager.getTasksCollectFeeMinute());
|
||||
if (collectTime.isBefore(now)) {
|
||||
collectTime = collectTime.plusDays(1);
|
||||
}
|
||||
return collectTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "change_fee";
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -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));
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
|
||||
|
||||
import co.aikar.commands.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class CanWarTargetCondition extends AbstractParameterCondition<ClanInput> {
|
||||
public CanWarTargetCondition(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<ClanInput> getType() {
|
||||
return ClanInput.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context, BukkitCommandExecutionContext execContext, ClanInput target) throws InvalidCommandArgument {
|
||||
BukkitCommandIssuer issuer = execContext.getIssuer();
|
||||
Clan issuerClan = Conditions.assertClanMember(clanManager, issuer);
|
||||
Clan targetClan = target.getClan();
|
||||
|
||||
if (!issuerClan.isRival(targetClan.getTag())) {
|
||||
throw new ConditionFailedException(lang("you.can.only.start.war.with.rivals", issuer));
|
||||
}
|
||||
|
||||
if (issuerClan.isWarring(targetClan)) {
|
||||
throw new ConditionFailedException(lang("clans.already.at.war", issuer));
|
||||
}
|
||||
|
||||
boolean isWarRequestEnabled = settingsManager.isWarRequestEnabled();
|
||||
int maxDifference = settingsManager.getMembersOnlineMaxDifference();
|
||||
|
||||
if (!isWarRequestEnabled && maxDifference >= 0) {
|
||||
int difference = Math.abs(issuerClan.getOnlineMembers().size() - targetClan.getOnlineMembers().size());
|
||||
if (difference > maxDifference)
|
||||
throw new ConditionFailedException(lang("you.cant.start.war.online.members.difference", issuer));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "can_war_target";
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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()));
|
||||
}
|
||||
}
|
||||
|
||||
+27
@@ -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";
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -3,6 +3,8 @@ package net.sacredlabyrinth.phaed.simpleclans.commands.conditions;
|
||||
import co.aikar.commands.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanPlayerInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
@@ -21,9 +23,16 @@ public class OnlineCondition extends AbstractParameterCondition<ClanPlayerInput>
|
||||
|
||||
@Override
|
||||
public void validateCondition(ConditionContext<BukkitCommandIssuer> context, BukkitCommandExecutionContext execContext, ClanPlayerInput value) throws InvalidCommandArgument {
|
||||
if (value.getClanPlayer().toPlayer() == null) {
|
||||
throw new ConditionFailedException(lang("other.player.must.be.online", execContext.getSender()));
|
||||
Player player = value.getClanPlayer().toPlayer();
|
||||
|
||||
if (player != null) {
|
||||
boolean isVanished = VanishUtils.isVanished(execContext.getSender(), player);
|
||||
if (!isVanished || !context.hasConfig("ignore_vanished")) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new ConditionFailedException(lang("other.player.must.be.online", execContext.getSender()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+31
@@ -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";
|
||||
}
|
||||
}
|
||||
+6
-3
@@ -18,9 +18,12 @@ public class ClanPlayerInputContextResolver extends AbstractInputOnlyContextReso
|
||||
@Override
|
||||
public ClanPlayerInput getContext(BukkitCommandExecutionContext context) throws InvalidCommandArgument {
|
||||
String arg = context.popFirstArg();
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(arg);
|
||||
ClanPlayer cp = clanManager.getCreateClanPlayer(offlinePlayer.getUniqueId());
|
||||
ClanPlayer cp = clanManager.getAnyClanPlayer(arg);
|
||||
if (cp == null) {
|
||||
@SuppressWarnings("deprecation")
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(arg);
|
||||
cp = clanManager.getCreateClanPlayer(offlinePlayer.getUniqueId());
|
||||
}
|
||||
|
||||
return new ClanPlayerInput(cp);
|
||||
}
|
||||
|
||||
@@ -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.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -27,7 +28,7 @@ public class ClanCoords extends Sendable {
|
||||
|
||||
private void populateRows() {
|
||||
Map<Integer, List<String>> rows = new TreeMap<>();
|
||||
for (ClanPlayer cpm : clan.getOnlineMembers()) {
|
||||
for (ClanPlayer cpm : VanishUtils.getNonVanished(player, clan)) {
|
||||
Player p = cpm.toPlayer();
|
||||
|
||||
if (p != null) {
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.data;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.KDRFormat;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.VanishUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -22,14 +24,15 @@ public class ClanProfile extends Sendable {
|
||||
String message = lang("clan.profile").replace("%clan_name%", clan.getName())
|
||||
.replace("%clan_color_tag%", clan.getColorTag())
|
||||
.replace("%clan_description%", getDescription())
|
||||
.replace("%clan_verified%", getVerifiedStatus())
|
||||
.replace("%clan_status%", Helper.getFormattedClanStatus(clan, sender))
|
||||
.replace("%clan_leaders%", clan.getLeadersString(sm.getPageLeaderColor(), subColor + ", "))
|
||||
.replace("%clan_online_count%", String.valueOf(clan.getOnlineMembers().size()))
|
||||
.replace("%clan_online_count%", String.valueOf(VanishUtils.getNonVanished(sender, clan).size()))
|
||||
.replace("%clan_size%", String.valueOf(clan.getSize()))
|
||||
.replace("%clan_kdr%", KDRFormat.format(clan.getTotalKDR()))
|
||||
.replace("%clan_rival_kills%", String.valueOf(clan.getTotalRival()))
|
||||
.replace("%clan_neutral_kills%", String.valueOf(clan.getTotalNeutral()))
|
||||
.replace("%clan_civilian_kills%", String.valueOf(clan.getTotalCivilian()))
|
||||
.replace("%clan_ally_kills%", String.valueOf(clan.getTotalAlly()))
|
||||
.replace("%clan_deaths%", String.valueOf(clan.getTotalDeaths()))
|
||||
.replace("%clan_fee_enabled%", getFeeEnabled())
|
||||
.replace("%clan_fee_value%", String.valueOf(clan.getMemberFee()))
|
||||
@@ -37,27 +40,15 @@ public class ClanProfile extends Sendable {
|
||||
.replace("%clan_rivals%", clan.getRivalString(subColor + ", "))
|
||||
.replace("%clan_founded%", clan.getFoundedString())
|
||||
.replace("%clan_inactive_days%", String.valueOf(clan.getInactiveDays()))
|
||||
.replace("%clan_max_inactive_days%", getMaxInactiveDays());
|
||||
.replace("%clan_max_inactive_days%", Helper.formatMaxInactiveDays(clan.getMaxInactiveDays()));
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getMaxInactiveDays() {
|
||||
return String.valueOf(clan.isVerified() ?
|
||||
sm.getPurgeClan() : sm.getPurgeUnverified());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getFeeEnabled() {
|
||||
return clan.isMemberFeeEnabled() ? lang("fee.enabled", sender) : lang("fee.disabled", sender);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getVerifiedStatus() {
|
||||
return clan.isVerified() ? sm.getPageTrustedColor() + lang("verified", sender) :
|
||||
sm.getPageUnTrustedColor() + lang("unverified", sender);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getDescription() {
|
||||
return clan.getDescription() != null && !clan.getDescription().isEmpty() ? clan.getDescription() :
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.data;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.KDRFormat;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -38,18 +39,19 @@ public class Lookup extends Sendable {
|
||||
String lookup = lang("player.lookup", sender)
|
||||
.replace("%player_name%", target.getName())
|
||||
.replace("%clan_name%", getClanName())
|
||||
.replace("%player_rank%", Helper.parseColors(target.getRankDisplayName()))
|
||||
.replace("%player_rank%", ChatUtils.parseColors(target.getRankDisplayName()))
|
||||
.replace("%player_status%", getPlayerStatus())
|
||||
.replace("%player_kdr%", KDRFormat.format(target.getKDR()))
|
||||
.replace("%player_rival_kills%", String.valueOf(target.getRivalKills()))
|
||||
.replace("%player_neutral_kills%", String.valueOf(target.getNeutralKills()))
|
||||
.replace("%player_civilian_kills%", String.valueOf(target.getCivilianKills()))
|
||||
.replace("%player_ally_kills%", String.valueOf(target.getAllyKills()))
|
||||
.replace("%player_deaths%", String.valueOf(target.getDeaths()))
|
||||
.replace("%player_join_date%", target.getJoinDateString())
|
||||
.replace("%player_last_seen%", target.getLastSeenString(sender))
|
||||
.replace("%player_past_clans%", target.getPastClansString(headColor + ", "))
|
||||
.replace("%player_inactive_days%", String.valueOf(target.getInactiveDays()))
|
||||
.replace("%player_max_inactive_days%", String.valueOf(sm.getPurgePlayers()))
|
||||
.replace("%player_max_inactive_days%", Helper.formatMaxInactiveDays(sm.getPurgePlayers()))
|
||||
.replace("%kill_type_line%", getKillTypeLine());
|
||||
sender.sendMessage(lookup);
|
||||
} else {
|
||||
@@ -75,10 +77,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().isEmpty()) {
|
||||
return sm.getPageTrustedColor() + lang("in.rank", sender);
|
||||
}
|
||||
return sm.getPageUnTrustedColor() + lang("untrusted", sender);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -89,8 +100,13 @@ public class Lookup extends Sendable {
|
||||
|
||||
if (targetClan == null) {
|
||||
killType = DARK_GRAY + lang("civilian", sender);
|
||||
} else if (senderClan != null && senderClan.isRival(targetClan.getTag())) {
|
||||
killType = WHITE + lang("rival", sender);
|
||||
} else if (senderClan != null) {
|
||||
if (senderClan.isRival(targetClan.getTag())) {
|
||||
killType = WHITE + lang("rival", sender);
|
||||
}
|
||||
if (senderClan.equals(targetClan) || senderClan.isAlly(targetClan.getTag())) {
|
||||
killType = RED + lang("ally", sender);
|
||||
}
|
||||
}
|
||||
|
||||
killTypeLine = lang("player.lookup.killtype", sender).replace("%player_kill_type%", killType);
|
||||
|
||||
+10
-4
@@ -25,7 +25,11 @@ import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.conversation.CreateClanNamePrompt.NAME_KEY;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.conversation.CreateClanTagPrompt.TAG_KEY;
|
||||
import static org.bukkit.ChatColor.*;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@@ -59,7 +63,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
@Subcommand("%create")
|
||||
@CommandPermission("simpleclans.leader.create")
|
||||
@Description("{@@command.description.create}")
|
||||
public void create(Player player) {
|
||||
public void create(Player player, @Optional @Name("tag") String tag, @Optional @Name("name") String name) {
|
||||
ClanPlayer cp = cm.getAnyClanPlayer(player.getUniqueId());
|
||||
|
||||
if (cp != null && cp.getClan() != null) {
|
||||
@@ -67,9 +71,11 @@ public class GeneralCommands extends BaseCommand {
|
||||
cp.getClan().getName()));
|
||||
return;
|
||||
}
|
||||
|
||||
HashMap<Object, Object> initialData = new HashMap<>();
|
||||
initialData.put(TAG_KEY, tag);
|
||||
initialData.put(NAME_KEY, name);
|
||||
Conversation conversation = new ConversationFactory(plugin).withFirstPrompt(new CreateClanTagPrompt())
|
||||
.withLocalEcho(true).buildConversation(player);
|
||||
.withLocalEcho(true).withTimeout(60).withInitialSessionData(initialData).buildConversation(player);
|
||||
conversation.begin();
|
||||
}
|
||||
|
||||
@@ -153,7 +159,7 @@ public class GeneralCommands extends BaseCommand {
|
||||
@Description("{@@command.description.resetkdr}")
|
||||
public void resetKdr(Player player, ClanPlayer cp) {
|
||||
if (!settings.isAllowResetKdr()) {
|
||||
ChatBlock.sendMessage(player, RED + lang("insufficient.permissions", player));
|
||||
ChatBlock.sendMessage(player, RED + lang("disabled.command", player));
|
||||
return;
|
||||
}
|
||||
if (cm.purchaseResetKdr(player)) {
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.commands.staff;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.EconomyResponse;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.commands.ClanInput;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.ClanBalanceUpdateEvent;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import static net.md_5.bungee.api.ChatColor.RED;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static org.bukkit.ChatColor.AQUA;
|
||||
|
||||
@CommandAlias("%clan")
|
||||
@Conditions("%basic_conditions")
|
||||
@Subcommand("%admin %bank")
|
||||
public class BankCommand extends BaseCommand {
|
||||
|
||||
@Subcommand("%status")
|
||||
@CommandPermission("simpleclans.admin.bank.status")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.bank.admin.status}")
|
||||
public void status(CommandSender sender, @Name("clan") ClanInput clanInput) {
|
||||
Clan clan = clanInput.getClan();
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.balance", sender, clan.getName(), clan.getBalance()));
|
||||
}
|
||||
|
||||
@Subcommand("%take")
|
||||
@CommandPermission("simpleclans.admin.bank.take")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.bank.admin.take}")
|
||||
public void take(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
Clan clan = clanInput.getClan();
|
||||
amount = Math.abs(amount);
|
||||
|
||||
EconomyResponse economyResponse = clan.withdraw(sender, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
switch (economyResponse) {
|
||||
case SUCCESS:
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.take", sender, amount, clan.getName()));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.take", sender, amount));
|
||||
break;
|
||||
case NOT_ENOUGH_BALANCE:
|
||||
sender.sendMessage(RED + lang("clan.admin.bank.not.enough.money", sender, clan.getName()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%give")
|
||||
@CommandPermission("simpleclans.admin.bank.give")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.bank.admin.give}")
|
||||
public void give(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
Clan clan = clanInput.getClan();
|
||||
amount = Math.abs(amount);
|
||||
|
||||
EconomyResponse economyResponse = clan.deposit(sender, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
if (economyResponse == EconomyResponse.SUCCESS) {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.give", sender, amount, clan.getName()));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.give", sender, amount));
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%set")
|
||||
@CommandPermission("simpleclans.admin.bank.set")
|
||||
@CommandCompletion("@clans")
|
||||
@Description("{@@command.description.bank.admin.set}")
|
||||
public void set(CommandSender sender, @Name("clan") ClanInput clanInput, @Name("amount") double amount) {
|
||||
Clan clan = clanInput.getClan();
|
||||
amount = Math.abs(amount);
|
||||
|
||||
EconomyResponse response = clan.setBalance(sender, ClanBalanceUpdateEvent.Cause.COMMAND, amount);
|
||||
if (response == EconomyResponse.SUCCESS) {
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("clan.admin.set", sender, clan.getName(), amount));
|
||||
clan.addBb(sender.getName(), AQUA + lang("bb.clan.set", sender, amount));
|
||||
}
|
||||
}
|
||||
}
|
||||
+80
-22
@@ -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")
|
||||
@@ -57,11 +60,9 @@ public class StaffCommands extends BaseCommand {
|
||||
ChatBlock.sendMessage(sender, lang("player.already.in.this.clan", sender));
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldClan.isLeader(player) && oldClan.getLeaders().size() <= 1) {
|
||||
oldClan.clanAnnounce(player.getName(), AQUA + lang("clan.has.been.disbanded",
|
||||
oldClan.getName()));
|
||||
oldClan.disband();
|
||||
if (!oldClan.isPermanent() && oldClan.isLeader(player) && oldClan.getLeaders().size() <= 1) {
|
||||
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 +76,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 +123,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 +135,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 +150,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 +170,7 @@ public class StaffCommands extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%unban")
|
||||
@Subcommand("%mod %unban")
|
||||
@CommandPermission("simpleclans.mod.ban")
|
||||
@CommandCompletion("@players")
|
||||
@Description("{@@command.description.unban}")
|
||||
@@ -159,7 +190,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 +202,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 +216,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 +232,7 @@ public class StaffCommands extends BaseCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Subcommand("%purge")
|
||||
@Subcommand("%admin %purge")
|
||||
@CommandPermission("simpleclans.admin.purge")
|
||||
@CommandCompletion("@players")
|
||||
@Description("{@@command.description.purge}")
|
||||
@@ -214,19 +244,35 @@ public class StaffCommands extends BaseCommand {
|
||||
|
||||
Clan clan = player.getClanPlayer().getClan();
|
||||
if (clan != null && clan.getMembers().size() == 1) {
|
||||
clan.disband();
|
||||
clan.disband(sender, false, false);
|
||||
}
|
||||
cm.deleteClanPlayer(player.getClanPlayer());
|
||||
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}")
|
||||
public void disband(CommandSender sender, @Name("clan") ClanInput clan) {
|
||||
cm.serverAnnounce(AQUA + lang("clan.has.been.disbanded", clan.getClan().getName()));
|
||||
clan.getClan().disband();
|
||||
clan.getClan().disband(sender, true, true);
|
||||
}
|
||||
|
||||
@Subcommand("%admin %promote")
|
||||
@@ -248,6 +294,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 +314,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 +324,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}")
|
||||
@@ -286,4 +333,15 @@ public class StaffCommands extends BaseCommand {
|
||||
cm.resetKdr(cp);
|
||||
ChatBlock.sendMessage(sender, RED + lang("you.have.reseted.0.kdr", sender, cp.getName()));
|
||||
}
|
||||
|
||||
@Subcommand("%admin %permanent")
|
||||
@CommandCompletion("@clans")
|
||||
@CommandPermission("simpleclans.admin.permanent")
|
||||
@Description("{@@command.description.admin.permanent}")
|
||||
public void togglePermanent(CommandSender sender, @Name("clan") ClanInput clan) {
|
||||
boolean permanent = !clan.getClan().isPermanent();
|
||||
clan.getClan().setPermanent(permanent);
|
||||
clan.getClan().addBb(sender.getName(), lang((permanent) ? "permanent.status.enabled" : "permanent.status.disabled", sender.getName()));
|
||||
ChatBlock.sendMessage(sender, AQUA + lang("you.have.toggled.permanent.status", sender, clan.getClan().getName()));
|
||||
}
|
||||
}
|
||||
+26
-5
@@ -2,8 +2,10 @@ package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PreCreateClanEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
@@ -14,25 +16,44 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.conversation.CreateClanTagPrompt.TAG_KEY;
|
||||
|
||||
public class CreateClanNamePrompt extends StringPrompt {
|
||||
public static final String NAME_KEY = "name";
|
||||
|
||||
@Override
|
||||
public @NotNull String getPromptText(@NotNull ConversationContext context) {
|
||||
if (context.getSessionData(NAME_KEY) != null) {
|
||||
return "";
|
||||
}
|
||||
return lang("insert.clan.name", (Player) context.getForWhom());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blocksForInput(@NotNull ConversationContext context) {
|
||||
return context.getSessionData(NAME_KEY) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Prompt acceptInput(@NotNull ConversationContext context, @Nullable String clanName) {
|
||||
SimpleClans plugin = (SimpleClans) context.getPlugin();
|
||||
Player player = (Player) context.getForWhom();
|
||||
clanName = clanName != null ? clanName : (String) context.getSessionData(NAME_KEY);
|
||||
context.setSessionData(NAME_KEY, null);
|
||||
if (plugin == null || clanName == null) return this;
|
||||
|
||||
Prompt errorPrompt = validateName(plugin, player, clanName);
|
||||
if (errorPrompt != null) return errorPrompt;
|
||||
|
||||
String finalClanName = clanName;
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
String tag = (String) context.getSessionData(TAG_KEY);
|
||||
//noinspection ConstantConditions
|
||||
processClanCreation(plugin, player, (String) context.getSessionData("tag"), clanName);
|
||||
PreCreateClanEvent event = new PreCreateClanEvent(player, tag, finalClanName);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
processClanCreation(plugin, player, tag, finalClanName);
|
||||
}
|
||||
});
|
||||
|
||||
return END_OF_CONVERSATION;
|
||||
@@ -63,13 +84,13 @@ 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 (Helper.stripColors(input).length() > plugin.getSettingsManager().getClanMaxLength()) {
|
||||
if (!bypass) {
|
||||
if (ChatUtils.stripColors(input).length() > plugin.getSettingsManager().getClanMaxLength()) {
|
||||
return new MessagePromptImpl(ChatColor.RED +
|
||||
lang("your.clan.name.cannot.be.longer.than.characters", player,
|
||||
plugin.getSettingsManager().getClanMaxLength()), this);
|
||||
}
|
||||
if (Helper.stripColors(input).length() <= plugin.getSettingsManager().getClanMinLength()) {
|
||||
if (ChatUtils.stripColors(input).length() <= plugin.getSettingsManager().getClanMinLength()) {
|
||||
return new MessagePromptImpl(ChatColor.RED +
|
||||
lang("your.clan.name.must.be.longer.than.characters", player,
|
||||
plugin.getSettingsManager().getClanMinLength()), this);
|
||||
|
||||
+15
-3
@@ -1,7 +1,7 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Helper;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.ChatUtils;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.TagValidator;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
@@ -14,27 +14,39 @@ import org.jetbrains.annotations.Nullable;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
public class CreateClanTagPrompt extends StringPrompt {
|
||||
public static final String TAG_KEY = "tag";
|
||||
|
||||
@Override
|
||||
public @NotNull String getPromptText(@NotNull ConversationContext context) {
|
||||
if (context.getSessionData(TAG_KEY) != null) {
|
||||
return "";
|
||||
}
|
||||
return lang("insert.clan.tag", (Player) context.getForWhom());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean blocksForInput(@NotNull ConversationContext context) {
|
||||
return context.getSessionData(TAG_KEY) == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Prompt acceptInput(@NotNull ConversationContext context, @Nullable String input) {
|
||||
Player player = (Player) context.getForWhom();
|
||||
SimpleClans plugin = (SimpleClans) context.getPlugin();
|
||||
input = input != null ? input : (String) context.getSessionData(TAG_KEY);
|
||||
context.setSessionData(TAG_KEY, null);
|
||||
if (input == null || plugin == null) return this;
|
||||
|
||||
Prompt errorPrompt = validateTag(plugin, player, input);
|
||||
if (errorPrompt != null) return errorPrompt;
|
||||
|
||||
context.setSessionData("tag", input);
|
||||
context.setSessionData(TAG_KEY, input);
|
||||
return new CreateClanNamePrompt();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Prompt validateTag(SimpleClans plugin, Player player, @NotNull String clanTag) {
|
||||
String cleanTag = Helper.stripColors(clanTag);
|
||||
String cleanTag = ChatUtils.stripColors(clanTag);
|
||||
if (plugin.getClanManager().isClan(cleanTag)) {
|
||||
return new MessagePromptImpl(ChatColor.RED +
|
||||
lang("clan.with.this.tag.already.exists", player), this);
|
||||
|
||||
+12
-1
@@ -2,6 +2,9 @@ package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.CreateRankEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.PreCreateRankEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.Prompt;
|
||||
@@ -27,11 +30,19 @@ public class CreateRankNamePrompt extends StringPrompt {
|
||||
if (input == null) return this;
|
||||
|
||||
String rank = input.toLowerCase().replace(" ", "_");
|
||||
PreCreateRankEvent event = new PreCreateRankEvent(player, clan, rank);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
rank = event.getRankName();
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return null;
|
||||
}
|
||||
if (clan.hasRank(rank)) {
|
||||
return new MessagePromptImpl(ChatColor.RED + lang("rank.already.exists", player), this);
|
||||
}
|
||||
|
||||
|
||||
clan.createRank(rank);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new CreateRankEvent(player, clan, clan.getRank(rank)));
|
||||
plugin.getStorageManager().updateClan(clan, true);
|
||||
return new MessagePromptImpl(ChatColor.AQUA + lang("rank.created", player));
|
||||
}
|
||||
|
||||
+11
-16
@@ -1,9 +1,5 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.conversation;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
@@ -15,10 +11,13 @@ import org.bukkit.conversations.StringPrompt;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author roinujnosde
|
||||
*/
|
||||
public class ResignPrompt extends StringPrompt {
|
||||
@@ -35,26 +34,22 @@ public class ResignPrompt extends StringPrompt {
|
||||
if (clan == null) {
|
||||
return END_OF_CONVERSATION;
|
||||
}
|
||||
|
||||
|
||||
if (yes.equalsIgnoreCase(input)) {
|
||||
if (!clan.isLeader(player) || clan.getLeaders().size() > 1) {
|
||||
if (clan.isPermanent() || !clan.isLeader(player) || clan.getLeaders().size() > 1) {
|
||||
clan.addBb(player.getName(), ChatColor.AQUA + lang("0.has.resigned", player.getName()));
|
||||
cp.addResignTime(clan.getTag());
|
||||
clan.removePlayerFromClan(player.getUniqueId());
|
||||
|
||||
|
||||
return new MessagePromptImpl(ChatColor.AQUA + lang("resign.success", player));
|
||||
} else if (clan.isLeader(player) && clan.getLeaders().size() == 1) {
|
||||
clan.disband();
|
||||
String msgKey = "clan.has.been.disbanded";
|
||||
//message for the server
|
||||
plugin.getClanManager().serverAnnounce(ChatColor.AQUA + lang(msgKey, clan.getName()));
|
||||
//message for the player
|
||||
return new MessagePromptImpl(ChatColor.AQUA + lang(msgKey, player, clan.getName()));
|
||||
clan.disband(player, true, false);
|
||||
return null;
|
||||
} else {
|
||||
return new MessagePromptImpl(ChatColor.RED + lang("last.leader.cannot.resign.you.must.appoint.another.leader.or.disband.the.clan", player));
|
||||
}
|
||||
} else {
|
||||
return new MessagePromptImpl(ChatColor.RED + lang("resign.request.cancelled", player));
|
||||
return new MessagePromptImpl(ChatColor.RED + lang("resign.request.cancelled", player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +58,7 @@ public class ResignPrompt extends StringPrompt {
|
||||
Player player = (Player) cc.getForWhom();
|
||||
return ChatColor.RED + MessageFormat.format(
|
||||
lang("resign.confirmation", player), Arrays.asList(
|
||||
lang("resign.yes", player), lang("resign.no", player)));
|
||||
lang("resign.yes", player), lang("resign.no", player)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@@ -10,12 +9,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class AddKillEvent extends Event implements Cancellable {
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private ClanPlayer victim;
|
||||
private ClanPlayer attacker;
|
||||
public AddKillEvent(ClanPlayer attacker, ClanPlayer victim){
|
||||
private final ClanPlayer victim;
|
||||
private final ClanPlayer attacker;
|
||||
|
||||
public AddKillEvent(@NotNull ClanPlayer attacker, @NotNull ClanPlayer victim) {
|
||||
this.attacker = attacker;
|
||||
this.victim = victim;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ClanBalanceUpdateEvent}
|
||||
*/
|
||||
@Deprecated
|
||||
public class BankDepositEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private final Clan clan;
|
||||
private double amount;
|
||||
private boolean cancelled;
|
||||
|
||||
public BankDepositEvent(@NotNull Player who, @NotNull Clan clan, double amount) {
|
||||
super(who);
|
||||
this.clan = clan;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public @NotNull Clan getClan() {
|
||||
return clan;
|
||||
}
|
||||
|
||||
public double getOldBalance() {
|
||||
return clan.getBalance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @deprecated use {@link ClanBalanceUpdateEvent}
|
||||
*/
|
||||
@Deprecated
|
||||
public class BankWithdrawEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private final Clan clan;
|
||||
private double amount;
|
||||
private boolean cancelled;
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
public BankWithdrawEvent(@NotNull Player who, @NotNull Clan clan, double amount) {
|
||||
super(who);
|
||||
this.clan = clan;
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public @NotNull Clan getClan() {
|
||||
return clan;
|
||||
}
|
||||
|
||||
public double getOldBalance() {
|
||||
return clan.getBalance();
|
||||
}
|
||||
|
||||
public void setAmount(double amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public double getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
}
|
||||
+127
@@ -0,0 +1,127 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ClanBalanceUpdateEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final CommandSender updater;
|
||||
private final Clan clan;
|
||||
private final Cause cause;
|
||||
private final double balance;
|
||||
private double newBalance;
|
||||
private boolean cancelled;
|
||||
|
||||
public ClanBalanceUpdateEvent(@Nullable CommandSender updater,
|
||||
@NotNull Clan clan,
|
||||
double balance,
|
||||
double newBalance,
|
||||
@NotNull Cause cause) {
|
||||
this.updater = updater;
|
||||
this.balance = balance;
|
||||
this.newBalance = newBalance;
|
||||
this.clan = clan;
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the balance updater, may be null
|
||||
*/
|
||||
public @Nullable CommandSender getUpdater() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Clan involved
|
||||
*/
|
||||
public @NotNull Clan getClan() {
|
||||
return clan;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Clan's current balance
|
||||
*/
|
||||
public double getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Clan's new balance
|
||||
*/
|
||||
public double getNewBalance() {
|
||||
return newBalance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Clan's new balance
|
||||
*
|
||||
* @param newBalance the new balance
|
||||
* @throws IllegalArgumentException if newBalance is negative
|
||||
*/
|
||||
public void setNewBalance(double newBalance) {
|
||||
if (newBalance < 0) {
|
||||
throw new IllegalArgumentException("newBalance cannot be negative");
|
||||
}
|
||||
this.newBalance = newBalance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the update cause
|
||||
*/
|
||||
public @NotNull Cause getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws IllegalStateException if the cause of the event is {@link Cause#REVERT}
|
||||
*/
|
||||
@Override
|
||||
public void setCancelled(boolean isCancelled) {
|
||||
if (getCause() == Cause.REVERT) {
|
||||
throw new IllegalStateException("cannot cancel REVERT update");
|
||||
}
|
||||
this.cancelled = isCancelled;
|
||||
}
|
||||
|
||||
public enum Cause {
|
||||
UPKEEP,
|
||||
MEMBER_FEE,
|
||||
/**
|
||||
* When a command such as /clan bank deposit causes the update
|
||||
*/
|
||||
COMMAND,
|
||||
/**
|
||||
* When the balance is updated via API methods
|
||||
*/
|
||||
API,
|
||||
/**
|
||||
* When the clan data is being loaded and the balance is set, usually on server start up or plugin reload
|
||||
*/
|
||||
LOADING,
|
||||
/**
|
||||
* When a failed deposit is being refunded, cannot be cancelled
|
||||
*/
|
||||
REVERT
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Rank;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Minat0_
|
||||
*/
|
||||
public class CreateRankEvent extends PlayerEvent {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private final Rank rank;
|
||||
private final Clan clan;
|
||||
|
||||
public CreateRankEvent(Player who, Clan clan, Rank rank) {
|
||||
super(who);
|
||||
this.clan = clan;
|
||||
this.rank = rank;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Rank getRank() {
|
||||
return rank;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Clan getClan() {
|
||||
return clan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Rank;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Minat0_
|
||||
*/
|
||||
public class DeleteRankEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private final Rank rank;
|
||||
private final Clan clan;
|
||||
private boolean cancelled;
|
||||
|
||||
public DeleteRankEvent(Player who, Clan clan, Rank rank) {
|
||||
super(who);
|
||||
this.rank = rank;
|
||||
this.clan = clan;
|
||||
}
|
||||
|
||||
public Rank getRank() {
|
||||
return rank;
|
||||
}
|
||||
|
||||
public Clan getClan() {
|
||||
return clan;
|
||||
}
|
||||
|
||||
@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 cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
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;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author Minat0_
|
||||
*/
|
||||
public class PlayerRankUpdateEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private final ClanPlayer target;
|
||||
private final ClanPlayer issuer;
|
||||
|
||||
private final Rank oldRank;
|
||||
private final Rank newRank;
|
||||
private final Clan clan;
|
||||
private boolean cancelled;
|
||||
|
||||
public PlayerRankUpdateEvent(@NotNull ClanPlayer issuer, @NotNull ClanPlayer target, @NotNull Clan clan,
|
||||
@Nullable Rank oldRank, @Nullable Rank newRank) {
|
||||
this.target = target;
|
||||
this.issuer = issuer;
|
||||
this.oldRank = oldRank;
|
||||
this.clan = clan;
|
||||
this.newRank = newRank;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Rank getOldRank() {
|
||||
return oldRank;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Clan getClan() {
|
||||
return clan;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Rank getNewRank() {
|
||||
return newRank;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClanPlayer getIssuer() {
|
||||
return issuer;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClanPlayer getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PreCreateClanEvent extends PlayerEvent implements Cancellable {
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private boolean cancelled;
|
||||
private final String tag;
|
||||
private final String name;
|
||||
|
||||
public PreCreateClanEvent(@NotNull Player who, @NotNull String tag, @NotNull String name) {
|
||||
super(who);
|
||||
this.tag = tag;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull HandlerList getHandlers() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.events;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author Minat0_
|
||||
*/
|
||||
public class PreCreateRankEvent extends PlayerEvent implements Cancellable {
|
||||
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
private String rankName;
|
||||
private final Clan clan;
|
||||
private boolean cancelled;
|
||||
|
||||
public PreCreateRankEvent(Player who, Clan clan, String rankName) {
|
||||
super(who);
|
||||
this.clan = clan;
|
||||
this.rankName = rankName;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Clan getClan() {
|
||||
return clan;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getRankName() {
|
||||
return rankName;
|
||||
}
|
||||
|
||||
public void setRankName(@NotNull String rankName) {
|
||||
this.rankName = rankName;
|
||||
}
|
||||
|
||||
@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 "";
|
||||
}
|
||||
+48
@@ -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();
|
||||
|
||||
}
|
||||
+184
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.papi.resolvers;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.hooks.papi.PlaceholderResolver;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.utils.KDRFormat;
|
||||
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 KdrResolver extends PlaceholderResolver {
|
||||
public KdrResolver(@NotNull SimpleClans plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getId() {
|
||||
return "kdr";
|
||||
}
|
||||
|
||||
@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 instanceof Number) {
|
||||
return KDRFormat.format(((Number) result).floatValue());
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
+41
@@ -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;
|
||||
}
|
||||
}
|
||||
+42
@@ -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();
|
||||
}
|
||||
}
|
||||
+37
@@ -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);
|
||||
}
|
||||
}
|
||||
+31
@@ -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();
|
||||
}
|
||||
}
|
||||
+65
@@ -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 "";
|
||||
}
|
||||
}
|
||||
+43
@@ -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);
|
||||
}
|
||||
}
|
||||
+35
@@ -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();
|
||||
}
|
||||
+89
@@ -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";
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.plotsquared.bukkit.events.PlayerClaimPlotEvent;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
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.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PlotSquared3Provider implements ProtectionProvider {
|
||||
|
||||
private Method getLocation;
|
||||
private Method getPlots;
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
try {
|
||||
Class.forName("com.intellectualcrafters.plot.object.Location");
|
||||
Class.forName("com.intellectualcrafters.plot.object.Plot");
|
||||
getLocation = BukkitUtil.class.getMethod("getLocation", Location.class);
|
||||
} catch (NoSuchMethodException | ClassNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
|
||||
Plot plot = getPlot(location);
|
||||
if (plot != null) {
|
||||
return Collections.singleton(getLand(plot));
|
||||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
private @Nullable Plot getPlot(@NotNull Location location) {
|
||||
try {
|
||||
return Plot.getPlot((com.intellectualcrafters.plot.object.Location) getLocation.invoke(null, location));
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Land getLand(@NotNull Plot plot) {
|
||||
String id = getIdPrefix() + plot.getId().toString();
|
||||
return new Land(id, plot.getOwners());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
|
||||
Set<Plot> plots = PS.get().getPlots(world.getName(), player.getUniqueId());
|
||||
|
||||
return plots.stream().map(this::getLand).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdPrefix() {
|
||||
return "ps";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLand(@NotNull String id, @NotNull World world) {
|
||||
id = id.replace(getIdPrefix(), "");
|
||||
Collection<Plot> plots = PS.get().getPlots(world.getName());
|
||||
for (Plot plot : plots) {
|
||||
if (plot.getId().toString().equals(id)) {
|
||||
plot.deletePlot(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Class<? extends Event> getCreateLandEvent() {
|
||||
return PlayerClaimPlotEvent.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Player getPlayer(Event event) {
|
||||
if (event instanceof PlayerClaimPlotEvent) {
|
||||
return ((PlayerClaimPlotEvent) event).getPlayer();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getRequiredPluginName() {
|
||||
return "PlotSquared";
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
|
||||
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.core.PlotSquared;
|
||||
import com.plotsquared.core.plot.Plot;
|
||||
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.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class PlotSquared5Provider implements ProtectionProvider {
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
|
||||
Plot plot = BukkitUtil.getPlot(location);
|
||||
if (plot != null) {
|
||||
return Collections.singleton(getLand(plot));
|
||||
}
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Land getLand(@NotNull Plot plot) {
|
||||
return new Land(getIdPrefix() + plot.getId().toString(), plot.getOwners());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsOf(@NotNull OfflinePlayer player, @NotNull World world) {
|
||||
Set<Plot> plots = PlotSquared.get().getPlots(world.getName(), player.getUniqueId());
|
||||
return plots.stream().map(this::getLand).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getIdPrefix() {
|
||||
return "ps";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteLand(@NotNull String id, @NotNull World world) {
|
||||
id = id.replace(getIdPrefix(), "");
|
||||
for (Plot plot : PlotSquared.get().getPlots(world.getName())) {
|
||||
if (plot.getId().toString().equals(id)) {
|
||||
plot.deletePlot(null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Class<? extends Event> getCreateLandEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Player getPlayer(Event event) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getRequiredPluginName() {
|
||||
return "PlotSquared";
|
||||
}
|
||||
}
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.hooks.protection.providers;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
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.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public class WorldGuard6Provider implements ProtectionProvider {
|
||||
|
||||
private WorldGuardPlugin worldGuard;
|
||||
private Method getRegionManager;
|
||||
private Method getApplicableRegions;
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
worldGuard = WorldGuardPlugin.inst();
|
||||
try {
|
||||
getRegionManager = worldGuard.getClass().getMethod("getRegionManager", World.class);
|
||||
//noinspection JavaReflectionMemberAccess
|
||||
getApplicableRegions = RegionManager.class.getMethod("getApplicableRegions", Location.class);
|
||||
} catch (NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private @Nullable RegionManager getRegionManager(@Nullable World world) {
|
||||
if (world != null) {
|
||||
try {
|
||||
return (RegionManager) getRegionManager.invoke(worldGuard, world);
|
||||
} catch (IllegalAccessException | InvocationTargetException ignored) {
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Set<ProtectedRegion> getApplicableRegions(RegionManager regionManager, Location location) {
|
||||
try {
|
||||
return ((ApplicableRegionSet) getApplicableRegions.invoke(regionManager, location)).getRegions();
|
||||
} catch (IllegalAccessException | InvocationTargetException e) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private Land getLand(ProtectedRegion region) {
|
||||
return new Land(getIdPrefix() + region.getId(), region.getOwners().getUniqueIds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Land> getLandsAt(@NotNull Location location) {
|
||||
HashSet<Land> lands = new HashSet<>();
|
||||
RegionManager regionManager = getRegionManager(location.getWorld());
|
||||
|
||||
if (regionManager != null) {
|
||||
for (ProtectedRegion region : getApplicableRegions(regionManager, location)) {
|
||||
lands.add(getLand(region));
|
||||
}
|
||||
}
|
||||
return lands;
|
||||
}
|
||||
|
||||
@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().getUniqueIds().contains(player.getUniqueId())) {
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable String getRequiredPluginName() {
|
||||
return "WorldGuard";
|
||||
}
|
||||
}
|
||||
+101
@@ -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;
|
||||
@@ -224,6 +230,9 @@ public class LanguageResource {
|
||||
if (!defaultAsFallback && candidateLocales.size() != 1) {
|
||||
candidateLocales.remove(Locale.ROOT);
|
||||
}
|
||||
if (baseName.startsWith("acf") && !candidateLocales.contains(Locale.ENGLISH) && defaultAsFallback) {
|
||||
candidateLocales.add(Locale.ENGLISH);
|
||||
}
|
||||
return candidateLocales;
|
||||
}
|
||||
|
||||
@@ -265,11 +274,12 @@ public class LanguageResource {
|
||||
if (!defaultAsFallback) {
|
||||
return null;
|
||||
}
|
||||
if (!locale.equals(defaultLocale) && !locale.equals(Locale.ROOT)) {
|
||||
Locale root = baseName.startsWith("acf") ? Locale.ENGLISH : Locale.ROOT;
|
||||
if (!locale.equals(defaultLocale) && !locale.equals(root)) {
|
||||
return defaultLocale;
|
||||
}
|
||||
if (locale.equals(defaultLocale) && !defaultLocale.equals(Locale.ROOT)) {
|
||||
return Locale.ROOT;
|
||||
if (locale.equals(defaultLocale) && !defaultLocale.equals(root)) {
|
||||
return root;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.listeners;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Events {
|
||||
|
||||
private Events() {}
|
||||
|
||||
@Nullable
|
||||
@Contract("null -> null")
|
||||
public static Player getAttacker(@Nullable EntityDamageEvent parentEvent) {
|
||||
if (parentEvent instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) parentEvent;
|
||||
|
||||
if (sub.getDamager() instanceof Player) {
|
||||
return (Player) sub.getDamager();
|
||||
}
|
||||
|
||||
if (sub.getDamager() instanceof Projectile) {
|
||||
Projectile projectile = (Projectile) sub.getDamager();
|
||||
|
||||
if (projectile.getShooter() instanceof Player) {
|
||||
return (Player) projectile.getShooter();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
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 org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.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;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof Player) ||
|
||||
plugin.getSettingsManager().isBlacklistedWorld(event.getEntity().getWorld())) {
|
||||
return;
|
||||
}
|
||||
Player victim = (Player) event.getEntity();
|
||||
Player attacker = Events.getAttacker(event);
|
||||
|
||||
if (attacker == null || attacker.getUniqueId().equals(victim.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer vcp = plugin.getClanManager().getClanPlayer(victim);
|
||||
|
||||
Clan victimClan = vcp == null ? null : vcp.getClan();
|
||||
Clan attackerClan = plugin.getClanManager().getClanByPlayerUniqueId(attacker.getUniqueId());
|
||||
|
||||
process(event, attacker, vcp, victimClan, attackerClan);
|
||||
}
|
||||
|
||||
private void process(EntityDamageEvent event,
|
||||
Player attacker,
|
||||
@Nullable ClanPlayer vcp,
|
||||
@Nullable Clan victimClan,
|
||||
@Nullable Clan attackerClan) {
|
||||
if (vcp == null || victimClan == null || attackerClan == null) {
|
||||
if (plugin.getSettingsManager().getSafeCivilians()) {
|
||||
ChatBlock.sendMessageKey(attacker, "cannot.attack.civilians");
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (vcp.isFriendlyFire() || victimClan.isFriendlyFire() || plugin.getSettingsManager().isGlobalff()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (victimClan.equals(attackerClan)) {
|
||||
warn(attacker, "cannot.attack.clan.member");
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (victimClan.isAlly(attackerClan.getTag())) {
|
||||
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,269 @@
|
||||
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.getMembers()) {
|
||||
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;
|
||||
Block block = blockPlaceEvent.getBlock();
|
||||
if (settingsManager.getIgnoredList(PLACE).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(PLACE, block.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) {
|
||||
Block block = event.getBlock();
|
||||
if (settingsManager.getIgnoredList(PLACE).contains(block.getType().name())) {
|
||||
return;
|
||||
}
|
||||
if (protectionManager.can(PLACE, block.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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.listeners;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.events.AddKillEvent;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class PlayerDeath implements Listener {
|
||||
|
||||
private final SimpleClans plugin;
|
||||
|
||||
public PlayerDeath() {
|
||||
plugin = SimpleClans.getInstance();
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
Player attacker = Events.getAttacker(victim.getLastDamageCause());
|
||||
if (isInvalidKill(victim, attacker)) return;
|
||||
|
||||
ClanPlayer victimCp = plugin.getClanManager().getCreateClanPlayer(victim.getUniqueId());
|
||||
ClanPlayer attackerCp = plugin.getClanManager().getCreateClanPlayer(attacker.getUniqueId());
|
||||
|
||||
addKill(victimCp, attackerCp);
|
||||
giveMoneyReward(victimCp, attackerCp);
|
||||
|
||||
// record death for victim
|
||||
victimCp.addDeath();
|
||||
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) {
|
||||
Clan victimClan = victim.getClan();
|
||||
Clan attackerClan = attacker.getClan();
|
||||
if (victimClan == null || attackerClan == null || !victimClan.isVerified() || !attackerClan.isVerified()) {
|
||||
addKill(Kill.Type.CIVILIAN, attacker, victim);
|
||||
} else if (attackerClan.isRival(victim.getTag())) {
|
||||
addKill(Kill.Type.RIVAL, attacker, victim);
|
||||
} else if (attackerClan.isAlly(victimClan.getTag()) || attackerClan.equals(victimClan)) {
|
||||
addKill(Kill.Type.ALLY, attacker, victim);
|
||||
} else {
|
||||
addKill(Kill.Type.NEUTRAL, attacker, victim);
|
||||
}
|
||||
}
|
||||
|
||||
private void giveMoneyReward(@NotNull ClanPlayer victim, @NotNull ClanPlayer attacker) {
|
||||
if (!plugin.getSettingsManager().isMoneyPerKill()) {
|
||||
return;
|
||||
}
|
||||
Clan attackerClan = attacker.getClan();
|
||||
if (attackerClan == null) {
|
||||
return;
|
||||
}
|
||||
double reward = calculateReward(attacker, victim);
|
||||
if (reward != 0) {
|
||||
for (ClanPlayer cp : attackerClan.getOnlineMembers()) {
|
||||
double money = Math.round((reward / attacker.getClan().getOnlineMembers().size()) * 100D) / 100D;
|
||||
Player player = cp.toPlayer();
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
player.sendMessage(ChatColor.AQUA + lang("player.got.money", player, money,
|
||||
victim.getName(), attacker.getKDR()));
|
||||
plugin.getPermissionsManager().playerGrantMoney(player, money);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
if (SimpleClans.getInstance().getSettingsManager().isDenySameIPKills()) {
|
||||
InetSocketAddress attackerAddress = attacker.getAddress();
|
||||
InetSocketAddress victimAddress = victim.getAddress();
|
||||
if (attackerAddress != null && victimAddress != null) {
|
||||
if (attackerAddress.getHostString().equals(victimAddress.getHostString())) {
|
||||
plugin.getLogger().log(Level.INFO, "Blocked same IP kill calculating: {0} killed {1}. IP: {2}",
|
||||
new Object[]{attacker.getDisplayName(), victim.getDisplayName(),
|
||||
attackerAddress.getHostString()});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
AddKillEvent addKillEvent = new AddKillEvent(plugin.getClanManager().getCreateClanPlayer(
|
||||
attacker.getUniqueId()), plugin.getClanManager().getCreateClanPlayer(victim.getUniqueId()));
|
||||
Bukkit.getServer().getPluginManager().callEvent(addKillEvent);
|
||||
if (addKillEvent.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String kdrExempt = "simpleclans.other.kdr-exempt";
|
||||
PermissionsManager pm = plugin.getPermissionsManager();
|
||||
return pm.has(attacker, kdrExempt) || pm.has(victim, kdrExempt);
|
||||
}
|
||||
|
||||
private void addKill(Kill.Type type, ClanPlayer attacker, ClanPlayer victim) {
|
||||
if (type == null || attacker == null || victim == null) {
|
||||
return;
|
||||
}
|
||||
final Kill kill = new Kill(attacker, victim, LocalDateTime.now());
|
||||
if (plugin.getSettingsManager().isDelayBetweenKills() && plugin.getClanManager().isKillBeforeDelay(kill)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isMaxKillsPerVictim()) {
|
||||
plugin.getStorageManager().getKillsPerPlayer(attacker.getName(), data -> {
|
||||
final int max = plugin.getSettingsManager().getMaxKillsPerVictim();
|
||||
Integer kills = data.get(kill.getVictim().getName());
|
||||
if (kills != null) {
|
||||
if (kills < max) {
|
||||
saveKill(kill, type);
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
saveKill(kill, type);
|
||||
}
|
||||
|
||||
private void saveKill(Kill kill, Kill.Type type) {
|
||||
plugin.getClanManager().addKill(kill);
|
||||
ClanPlayer killer = kill.getKiller();
|
||||
ClanPlayer victim = kill.getVictim();
|
||||
killer.addKill(type);
|
||||
plugin.getStorageManager().insertKill(killer, victim, type.getShortname());
|
||||
}
|
||||
|
||||
private double calculateReward(@NotNull ClanPlayer attacker, @NotNull ClanPlayer victim) {
|
||||
double reward;
|
||||
double multiplier = plugin.getSettingsManager().getKDRMultipliesPerKill();
|
||||
double kdr = attacker.getKDR() * multiplier;
|
||||
Clan attackerClan = attacker.getClan();
|
||||
Clan victimClan = victim.getClan();
|
||||
if (attackerClan == null || !attackerClan.isVerified() || victimClan == null || !victimClan.isVerified()) {
|
||||
return 0;
|
||||
}
|
||||
if (attackerClan.isRival(victimClan.getTag())) {
|
||||
if (attackerClan.isWarring(victimClan)) {
|
||||
reward = kdr * 4;
|
||||
} else reward = kdr * 2;
|
||||
} else if (attackerClan.isAlly(victimClan.getTag())) {
|
||||
reward = kdr * -1;
|
||||
} else {
|
||||
reward = kdr;
|
||||
}
|
||||
return reward;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.listeners;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PvPOnlyInWar implements Listener {
|
||||
|
||||
private final SimpleClans plugin;
|
||||
|
||||
public PvPOnlyInWar(@NotNull SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof Player) ||
|
||||
plugin.getSettingsManager().isBlacklistedWorld(event.getEntity().getWorld())) {
|
||||
return;
|
||||
}
|
||||
Player victim = (Player) event.getEntity();
|
||||
Player attacker = Events.getAttacker(event);
|
||||
|
||||
if (attacker == null || victim.getUniqueId().equals(attacker.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Clan attackerClan = plugin.getClanManager().getClanByPlayerUniqueId(attacker.getUniqueId());
|
||||
Clan victimClan = plugin.getClanManager().getClanByPlayerUniqueId(victim.getUniqueId());
|
||||
|
||||
if (plugin.getSettingsManager().isPvpOnlywhileInWar()) {
|
||||
process(event, attacker, victim, attackerClan, 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);
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getPermissionsManager().has(victim, "simpleclans.mod.nopvpinwar")) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!attackerClan.isWarring(victimClan)) {
|
||||
ChatBlock.sendMessageKey(attacker, "clans.not.at.war.pvp.denied", victimClan.getName());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,406 +0,0 @@
|
||||
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.events.AddKillEvent;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.PermissionsManager;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.managers.StorageManager.DataCallback;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* @author phaed
|
||||
*/
|
||||
public class SCEntityListener implements Listener
|
||||
{
|
||||
|
||||
private SimpleClans plugin;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public SCEntityListener()
|
||||
{
|
||||
plugin = SimpleClans.getInstance();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDeath(EntityDeathEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player)
|
||||
{
|
||||
Player victim = (Player) event.getEntity();
|
||||
|
||||
if (plugin.getSettingsManager().isBlacklistedWorld(victim.getLocation().getWorld().getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (victim.hasMetadata("NPC"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player attacker = null;
|
||||
|
||||
// find attacker
|
||||
|
||||
EntityDamageEvent lastDamageCause = victim.getLastDamageCause();
|
||||
|
||||
if (lastDamageCause instanceof EntityDamageByEntityEvent)
|
||||
{
|
||||
EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) lastDamageCause;
|
||||
|
||||
if (entityEvent.getDamager() instanceof Player)
|
||||
{
|
||||
attacker = (Player) entityEvent.getDamager();
|
||||
} else if (entityEvent.getDamager() instanceof Projectile)
|
||||
{
|
||||
Projectile projectile = (Projectile) entityEvent.getDamager();
|
||||
|
||||
if (projectile.getShooter() instanceof Player)
|
||||
{
|
||||
attacker = (Player) projectile.getShooter();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (attacker != null)
|
||||
{
|
||||
if (attacker.getUniqueId().equals(victim.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
if (SimpleClans.getInstance().getSettingsManager().isDenySameIPKills())
|
||||
{
|
||||
if (attacker.getAddress().getHostString().equals(victim.getAddress().getHostString()))
|
||||
{
|
||||
plugin.getLogger().log(Level.INFO, "Blocked same IP kill calculating: {0} killed {1}. IP: {2}", new Object[]{
|
||||
attacker.getDisplayName(), victim.getDisplayName(), attacker.getAddress().getHostString()
|
||||
});
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
||||
String kdrExempt = "simpleclans.other.kdr-exempt";
|
||||
PermissionsManager pm = plugin.getPermissionsManager();
|
||||
if (pm.has(attacker, kdrExempt) || pm.has(victim, kdrExempt)) {
|
||||
return;
|
||||
}
|
||||
|
||||
AddKillEvent addKillEvent = new AddKillEvent(plugin.getClanManager().getCreateClanPlayer(
|
||||
attacker.getUniqueId()),plugin.getClanManager().getCreateClanPlayer(victim.getUniqueId()));
|
||||
Bukkit.getServer().getPluginManager().callEvent(addKillEvent);
|
||||
if(addKillEvent.isCancelled()) return;
|
||||
|
||||
ClanPlayer victimCp = addKillEvent.getVictim();
|
||||
ClanPlayer attackerCp = addKillEvent.getAttacker();
|
||||
double reward = 0;
|
||||
double multipier = plugin.getSettingsManager().getKDRMultipliesPerKill();
|
||||
float kdr = attackerCp.getKDR();
|
||||
|
||||
if (victimCp.getClan() == null || attackerCp.getClan() == null || !victimCp.getClan().isVerified() || !attackerCp.getClan().isVerified())
|
||||
{
|
||||
addKill(Kill.Type.CIVILIAN, attackerCp, victimCp);
|
||||
} else if (attackerCp.getClan().isRival(victimCp.getTag()))
|
||||
{
|
||||
if (attackerCp.getClan().isWarring(victimCp.getClan()))
|
||||
{
|
||||
reward = (double) kdr * multipier * 4;
|
||||
} else
|
||||
{
|
||||
reward = (double) kdr * multipier * 2;
|
||||
}
|
||||
addKill(Kill.Type.RIVAL, attackerCp, victimCp);
|
||||
} else if (attackerCp.getClan().isAlly(victimCp.getTag()))
|
||||
{
|
||||
reward = (double) kdr * multipier * -1;
|
||||
} else
|
||||
{
|
||||
reward = (double) kdr * multipier;
|
||||
addKill(Kill.Type.NEUTRAL, attackerCp, victimCp);
|
||||
}
|
||||
|
||||
if (reward != 0 && plugin.getSettingsManager().isMoneyPerKill())
|
||||
{
|
||||
for (ClanPlayer cp : attackerCp.getClan().getOnlineMembers())
|
||||
{
|
||||
double money = Math.round((reward / attackerCp.getClan().getOnlineMembers().size()) * 100D) / 100D;
|
||||
cp.toPlayer().sendMessage(ChatColor.AQUA + MessageFormat.format(lang("player.got.money",cp.toPlayer()), money, victim.getName(), kdr));
|
||||
plugin.getPermissionsManager().playerGrantMoney(cp.toPlayer(), money);
|
||||
}
|
||||
}
|
||||
|
||||
// record death for victim
|
||||
victimCp.addDeath();
|
||||
plugin.getStorageManager().updateClanPlayer(victimCp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addKill(Kill.Type type, ClanPlayer attacker, ClanPlayer victim) {
|
||||
if (type == null || attacker == null || victim == null) {
|
||||
return;
|
||||
}
|
||||
final Kill kill = new Kill(attacker, victim, LocalDateTime.now());
|
||||
if (plugin.getSettingsManager().isDelayBetweenKills() && plugin.getClanManager().isKillBeforeDelay(kill)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isMaxKillsPerVictim()) {
|
||||
plugin.getStorageManager().getKillsPerPlayer(attacker.getName(), new DataCallback<Map<String,Integer>>() {
|
||||
|
||||
@Override
|
||||
public void onResultReady(Map<String, Integer> data) {
|
||||
final int max = plugin.getSettingsManager().getMaxKillsPerVictim();
|
||||
Integer kills = data.get(kill.getVictim().getName());
|
||||
if (kills != null) {
|
||||
if (kills < max) {
|
||||
saveKill(kill, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
saveKill(kill, type);
|
||||
}
|
||||
|
||||
private void saveKill(Kill kill, Kill.Type type) {
|
||||
plugin.getClanManager().addKill(kill);
|
||||
ClanPlayer killer = kill.getKiller();
|
||||
ClanPlayer victim = kill.getVictim();
|
||||
killer.addKill(type);
|
||||
plugin.getStorageManager().insertKill(killer, victim, type.getShortname());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerInteract(PlayerInteractEntityEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isTamableMobsSharing() && event.getRightClicked() instanceof Tameable)
|
||||
{
|
||||
Entity entity = event.getRightClicked();
|
||||
Player player = event.getPlayer();
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
Tameable tamed = (Tameable) entity;
|
||||
|
||||
if (tamed.isTamed())
|
||||
{
|
||||
if(entity instanceof Wolf && !((Wolf) entity).isSitting())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (cp.getClan().isMember((Player) tamed.getOwner()))
|
||||
{
|
||||
tamed.setOwner(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityTarget(EntityTargetLivingEntityEvent event)
|
||||
{
|
||||
if (plugin.getSettingsManager().isTamableMobsSharing())
|
||||
{
|
||||
if (event.getEntity() instanceof Tameable && event.getTarget() instanceof Player)
|
||||
{
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer((Player) event.getTarget());
|
||||
Tameable wolf = (Tameable) event.getEntity();
|
||||
|
||||
if (wolf.isTamed() && cp.getClan().isMember((Player) wolf.getOwner()))
|
||||
{
|
||||
// cancels the event if the attacker is one out of his clan
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Player attacker = null;
|
||||
Player victim = null;
|
||||
|
||||
|
||||
if (event instanceof EntityDamageByEntityEvent)
|
||||
{
|
||||
EntityDamageByEntityEvent sub = (EntityDamageByEntityEvent) event;
|
||||
|
||||
if (sub.getEntity() instanceof Player && sub.getDamager() instanceof Player)
|
||||
{
|
||||
attacker = (Player) sub.getDamager();
|
||||
victim = (Player) sub.getEntity();
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isTamableMobsSharing())
|
||||
{
|
||||
if (sub.getEntity() instanceof Wolf && sub.getDamager() instanceof Player)
|
||||
{
|
||||
attacker = (Player) sub.getDamager();
|
||||
Wolf wolf = (Wolf) sub.getEntity();
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(attacker);
|
||||
if (wolf.isTamed() && cp.getClan().isMember((Player) wolf.getOwner()))
|
||||
{
|
||||
// Sets the wolf to friendly if the attacker is one out of his clan
|
||||
wolf.setAngry(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (sub.getEntity() instanceof Player && sub.getDamager() instanceof Projectile)
|
||||
{
|
||||
Projectile projectile = (Projectile) sub.getDamager();
|
||||
|
||||
if (projectile.getShooter() instanceof Player)
|
||||
{
|
||||
attacker = (Player) projectile.getShooter();
|
||||
victim = (Player) sub.getEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (victim != null && plugin.getSettingsManager().isBlacklistedWorld(victim.getLocation().getWorld().getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (attacker != null && victim != null)
|
||||
{
|
||||
if (attacker.getUniqueId().equals(victim.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClanPlayer acp = plugin.getClanManager().getClanPlayer(attacker);
|
||||
ClanPlayer vcp = plugin.getClanManager().getClanPlayer(victim);
|
||||
|
||||
|
||||
Clan vclan = vcp == null ? null : vcp.getClan();
|
||||
Clan aclan = acp == null ? null : acp.getClan();
|
||||
|
||||
|
||||
if (plugin.getSettingsManager().isPvpOnlywhileInWar())
|
||||
{
|
||||
// if one doesn't have clan then they cant be at war
|
||||
|
||||
if (aclan == null || vclan == null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getPermissionsManager().has(victim, "simpleclans.mod.nopvpinwar")
|
||||
&& attacker != null && victim != null)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// if not warring no pvp
|
||||
|
||||
if (!aclan.isWarring(vclan))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (vclan != null)
|
||||
{
|
||||
if (aclan != null)
|
||||
{
|
||||
// personal ff enabled, allow damage
|
||||
|
||||
if (vcp.isFriendlyFire())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// clan ff enabled, allow damage
|
||||
|
||||
if (vclan.isFriendlyFire())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// global ff enabled, allow damage
|
||||
|
||||
if (plugin.getSettingsManager().isGlobalff())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// same clan, deny damage
|
||||
|
||||
if (vclan.equals(aclan))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// ally clan, deny damage
|
||||
|
||||
if (vclan.isAlly(aclan.getTag()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
} else
|
||||
{
|
||||
// not part of a clan - check if safeCivilians is set
|
||||
|
||||
if (plugin.getSettingsManager().getSafeCivilians())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
// not part of a clan - check if safeCivilians is set
|
||||
|
||||
if (plugin.getSettingsManager().getSafeCivilians())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+78
-88
@@ -1,6 +1,13 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.listeners;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.*;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ChatBlock;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.Clan;
|
||||
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;
|
||||
@@ -9,8 +16,10 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.*;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Objects;
|
||||
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.CLAN;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.ClanPlayer.Channel.NONE;
|
||||
import static net.sacredlabyrinth.phaed.simpleclans.SimpleClans.lang;
|
||||
|
||||
/**
|
||||
@@ -19,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)
|
||||
@@ -29,94 +40,69 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
if (plugin.getSettingsManager().isBlacklistedWorld(event.getPlayer().getLocation().getWorld())) {
|
||||
Player player = event.getPlayer();
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player.getUniqueId());
|
||||
if (cp == null || settingsManager.isBlacklistedWorld(player.getLocation().getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
String message = event.getMessage();
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(event.getPlayer());
|
||||
|
||||
if (cp != null && !event.isCancelled()) {
|
||||
if (cp.getChannel().equals(ClanPlayer.Channel.CLAN)) {
|
||||
event.setCancelled(true);
|
||||
if (!plugin.getPermissionsManager().has(cp.toPlayer(), "simpleclans.member.chat")) {
|
||||
ChatBlock.sendMessage(cp.toPlayer(), ChatColor.RED + lang("insufficient.permissions",cp.toPlayer()));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getClanManager().processClanChat(event.getPlayer(), message);
|
||||
} else if (cp.getChannel().equals(ClanPlayer.Channel.ALLY)) {
|
||||
event.setCancelled(true);
|
||||
if (!plugin.getPermissionsManager().has(cp.toPlayer(), "simpleclans.member.ally")) {
|
||||
ChatBlock.sendMessage(cp.toPlayer(), ChatColor.RED + lang("insufficient.permissions",cp.toPlayer()));
|
||||
return;
|
||||
}
|
||||
|
||||
plugin.getClanManager().processAllyChat(event.getPlayer(), message);
|
||||
Channel channel = cp.getChannel();
|
||||
if (channel != NONE) {
|
||||
PermissionsManager pm = plugin.getPermissionsManager();
|
||||
if ((channel == Channel.ALLY && !pm.has(player, "simpleclans.member.ally")) ||
|
||||
(channel == CLAN && !pm.has(player, "simpleclans.member.chat"))) {
|
||||
ChatBlock.sendMessage(player, ChatColor.RED + lang("insufficient.permissions", player));
|
||||
return;
|
||||
}
|
||||
switch (channel) {
|
||||
case CLAN:
|
||||
plugin.getClanManager().processClanChat(player, event.getMessage());
|
||||
break;
|
||||
case ALLY:
|
||||
plugin.getClanManager().processAllyChat(player, event.getMessage());
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void handleChatTags(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (settingsManager.isBlacklistedWorld(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!plugin.getPermissionsManager().has(event.getPlayer(), "simpleclans.mod.nohide")) {
|
||||
boolean isClanChat = event.getMessage().contains("" + ChatColor.RED + ChatColor.WHITE + ChatColor.RED + ChatColor.BLACK);
|
||||
boolean isAllyChat = event.getMessage().contains("" + ChatColor.AQUA + ChatColor.WHITE + ChatColor.AQUA + ChatColor.BLACK);
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
String tagLabel = cp != null && cp.isTagEnabled() ? cp.getTagLabel() : null;
|
||||
|
||||
for (Iterator<Player> iter = event.getRecipients().iterator(); iter.hasNext();) {
|
||||
Player player = iter.next();
|
||||
|
||||
ClanPlayer rcp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (rcp != null) {
|
||||
if (!rcp.isClanChat() && isClanChat) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!rcp.isAllyChat() && isAllyChat) {
|
||||
iter.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!rcp.isGlobalChat() && !isAllyChat && !isClanChat) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isCompatMode()) {
|
||||
if (plugin.getSettingsManager().isChatTags()) {
|
||||
if (cp != null && cp.isTagEnabled()) {
|
||||
String tagLabel = cp.getClan().getTagLabel(cp.isLeader());
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (player.getDisplayName().contains("{clan}")) {
|
||||
player.setDisplayName(player.getDisplayName().replace("{clan}", tagLabel));
|
||||
} else if (event.getFormat().contains("{clan}")) {
|
||||
event.setFormat(event.getFormat().replace("{clan}", tagLabel));
|
||||
} else {
|
||||
String format = event.getFormat();
|
||||
event.setFormat(tagLabel + format);
|
||||
}
|
||||
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}")) {
|
||||
event.setFormat(event.getFormat().replace("{clan}", tagLabel));
|
||||
} else {
|
||||
event.setFormat(event.getFormat().replace("{clan}", ""));
|
||||
event.setFormat(event.getFormat().replace("tagLabel", ""));
|
||||
String format = event.getFormat();
|
||||
event.setFormat(tagLabel + format);
|
||||
}
|
||||
} else {
|
||||
event.setFormat(event.getFormat().replace("{clan}", ""));
|
||||
event.setFormat(event.getFormat().replace("tagLabel", ""));
|
||||
}
|
||||
} else {
|
||||
plugin.getClanManager().updateDisplayName(event.getPlayer());
|
||||
plugin.getClanManager().updateDisplayName(player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,41 +132,45 @@ 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);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
if (plugin.getSettingsManager().isBlacklistedWorld(event.getPlayer().getLocation().getWorld())) {
|
||||
Player player = event.getPlayer();
|
||||
if (!settingsManager.isTeleportOnSpawn() || settingsManager.isBlacklistedWorld(player.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.getSettingsManager().isTeleportOnSpawn()) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
ClanPlayer cp = plugin.getClanManager().getClanPlayer(player);
|
||||
|
||||
if (cp != null) {
|
||||
Location loc = cp.getClan().getHomeLocation();
|
||||
|
||||
if (loc != null) {
|
||||
event.setRespawnLocation(loc);
|
||||
}
|
||||
Clan clan = plugin.getClanManager().getClanByPlayerUniqueId(player.getUniqueId());
|
||||
if (clan != null) {
|
||||
Location home = clan.getHomeLocation();
|
||||
if (home != null) {
|
||||
event.setRespawnLocation(home);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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());
|
||||
@@ -189,7 +179,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package net.sacredlabyrinth.phaed.simpleclans.listeners;
|
||||
|
||||
import net.sacredlabyrinth.phaed.simpleclans.ClanPlayer;
|
||||
import net.sacredlabyrinth.phaed.simpleclans.SimpleClans;
|
||||
import org.bukkit.entity.AnimalTamer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.Wolf;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityTargetLivingEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TamableMobsSharing implements Listener {
|
||||
|
||||
private final SimpleClans plugin;
|
||||
|
||||
public TamableMobsSharing(@NotNull SimpleClans plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event) {
|
||||
if (plugin.getSettingsManager().isTamableMobsSharing()) {
|
||||
if (event.getEntity() instanceof Wolf && event.getDamager() instanceof Player) {
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(event.getDamager().getUniqueId());
|
||||
if (cp == null || cp.getClan() == null) {
|
||||
return;
|
||||
}
|
||||
Wolf wolf = (Wolf) event.getEntity();
|
||||
AnimalTamer owner = wolf.getOwner();
|
||||
if (owner != null && cp.getClan().isMember(owner.getUniqueId())) {
|
||||
// Sets the wolf to friendly if the attacker is one out of his clan
|
||||
wolf.setAngry(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityTarget(EntityTargetLivingEntityEvent event) {
|
||||
if (plugin.getSettingsManager().isTamableMobsSharing()) {
|
||||
if (event.getEntity() instanceof Tameable && event.getTarget() instanceof Player) {
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(event.getTarget().getUniqueId());
|
||||
if (cp == null || cp.getClan() == null) {
|
||||
return;
|
||||
}
|
||||
Tameable wolf = (Tameable) event.getEntity();
|
||||
AnimalTamer owner = wolf.getOwner();
|
||||
if (owner == null) {
|
||||
return;
|
||||
}
|
||||
if (cp.getClan().isMember(owner.getUniqueId())) {
|
||||
// cancels the event if the attacker is one out of his clan
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEntityEvent event) {
|
||||
if (plugin.getSettingsManager().isTamableMobsSharing() && event.getRightClicked() instanceof Tameable) {
|
||||
Player player = event.getPlayer();
|
||||
ClanPlayer cp = plugin.getClanManager().getAnyClanPlayer(player.getUniqueId());
|
||||
if (cp == null || cp.getClan() == null) {
|
||||
return;
|
||||
}
|
||||
Tameable tamed = (Tameable) event.getRightClicked();
|
||||
|
||||
if (tamed.getOwner() != null) {
|
||||
if (tamed instanceof Wolf && !((Wolf) tamed).isSitting()) {
|
||||
return;
|
||||
}
|
||||
if (cp.getClan().isMember(tamed.getOwner().getUniqueId())) {
|
||||
tamed.setOwner(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -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;
|
||||
}
|
||||
}
|
||||
+24
-60
@@ -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 {
|
||||
|
||||
-440
@@ -1,440 +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 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(clan.getOnlineMembers().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;
|
||||
}
|
||||
}
|
||||
Loaded 100 of 203 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user