This commit is contained in:
disclearing 2019-01-21 21:31:02 +00:00
parent 791538a8ca
commit 207c6f9acf
1567 changed files with 428575 additions and 169 deletions

6
.classpath Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/bin/

17
.project Normal file
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CuraHQ</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

811
LICENSE
View File

@ -1,201 +1,674 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
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.
1. Definitions.
Preamble
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
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.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
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.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
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.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
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.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
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.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
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.
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
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.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
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.
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
The precise terms and conditions for copying, distribution and
modification follow.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
TERMS AND CONDITIONS
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
0. Definitions.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
"This License" refers to version 3 of the GNU General Public License.
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
"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.
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
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.
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
A "covered work" means either the unmodified Program or a work based
on the Program.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
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.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
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.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
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.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
1. Source Code.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
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.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
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.
END OF TERMS AND CONDITIONS
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.
APPENDIX: How to apply the Apache License to your work.
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.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
Copyright [yyyy] [name of copyright owner]
The Corresponding Source for a work in source code form is that
same work.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
2. Basic Permissions.
http://www.apache.org/licenses/LICENSE-2.0
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.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
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>.

49
config.yml Normal file
View File

@ -0,0 +1,49 @@
Scoreboard_title: '&6&lExample &7%straight_line% &fMap 1'
Timers:
protection: 'Invincibility'
teleport: 'Home'
home: 'Home'
archer: 'Archer Tag'
enderpearl: 'Enderpearl'
logout: 'Logout'
notch: 'Notch Apple'
warmup: 'Class Warmup'
spawntag: 'Combat'
Combat_building: true
Kitmap:
Sharpness: 1
Protection: 1
Kit-Map: true
PRIMAIRY-COLOR: '&2'
SECONDAIRY-COLOR: '&7'
THIRD-COLOR: '&e'
SERVER-NAME: 'Vorcide'
DEATHBAN-MAXTIME: 3
MAX-FACTION: 10
MAX-ALLY: 1
MAP-BORDER: 3000
CURRENT-MAP: 1
MAP-KIT: 'S1 P1'
WARZONE-RADIUS: 800
Help:
- '&8&m------------------------------------'
- '&6&lconfig.yml'
- '&8&m------------------------------------'
Teamspeak:
- '&6&lTeamspeak IP: ts.example.us'
teamspeak-frozen: ts.example.us
store: 'store.example.us'
top-rank: 'Vorcide'
website: 'www.example.us'
Coords:
- '&8&m----------------------------------------'
- '&6&lconfig.yml'
- '&8&m----------------------------------------'
spawn:
world: world
x: 0.538049846829157
y: 69.0
z: 0.6617853658512408
yaw: 0.78689575
pitch: 11.715501
warp-delay-millis: 0

7450
items.csv Normal file

File diff suppressed because it is too large Load Diff

191
plugin.yml Normal file
View File

@ -0,0 +1,191 @@
name: Core
version: SNAPSHOT-1.0
author: Cura Development | NV6
main: club.curahq.core.Core
softdepend:
- ProtocolLib
- Vault
commands:
prefix:
reply:
aliases:
- r
broadcast:
aliases:
- bc
message:
aliases:
- tell
- m
- msg
togglemessage:
aliases:
- togglepm
teleport:
aliases:
- tp
vanish:
aliases:
- v
stats: null
top: null
ignore: null
reset: null
copyinv: null
slowstop: null
focus: null
fsay: null
fight: null
lff: null
tl: null
whois: null
drop: null
messagespy: null
staffmode:
aliases:
- mod
- h
- staff
feed:
aliases:
- eat
spawndragon:
description: Spawns an Ender-Dragon
servertime:
description: Checks the date and time of server.
note: null
heal: null
skull: null
sudo: null
enchant: null
kit: null
playtime:
aliases:
- pt
endportal: null
setspawn: null
world: null
kill: null
clear:
aliases:
- ci
ping: null
togglesidebar:
aliases:
- tsb
- togglescoreboard
- togglesb
- tscoreboard
more: null
warp: null
staffchat:
aliases:
- sc
gamemode:
aliases:
- gm
coords: null
teleportall:
aliases:
- tpall
teleporthere:
aliases:
- tphere
- s
god: null
set: null
lag: null
invsee: null
rename: null
clearchat:
aliases:
- cc
fly: null
panic: null
focus: null
fix:
aliases:
- repair
give: null
item:
aliases:
- i
random:
description: Teleports or gets a random player.
tpcoords: null
sotw:
description: Starts a 30 minute SOTW timer.
refund:
description: Refunds an inventory.
crowbar:
description: Management of crowbar tools.
freeze:
aliases:
- ss
medic: null
gmc:
description: Management of crowbar tools.
gms:
description: Management of crowbar tools.
staffrevive: null
conquest:
description: Command used to handle Conquest events.
economy:
aliases:
- bal
- balance
- money
- eco
description: Command used to modify the economy.
eotw:
description: Sets if the server is in End of the World mode.
event:
aliases:
- e
- game
- events
description: Command used to manage minigame events.
faction:
aliases:
- f
- fac
description: Faction related commands.
gopple:
description: Command to check remaining OP apple cooldown time.
aliases:
- goppletimer
- goppletime
koth:
description: Make or delete KotH arenas.
lives:
description: Management of lives or deathbans.
key:
description: Management of lives or deathbans.
logout:
aliases:
- disconnect
description: Command to safely logout without an NPC spawning.
ores:
description: Obtain keys to unlock awesome loot.
pay:
description: Allow players to pay money.
pvptimer:
aliases:
- pvp
description: to enable or disable pvp timer protection.
setborder:
aliases:
- setbordersize
description: Sets the border size of an Environment.
teamspeak:
aliases:
- ts
description: Show's player the ip for the teamspeak.
spawn:
description: Teleport to the server spawn.
help: null
list: null
spawner: null
timer:
description: Command to manage timers.

8
prefixes.yml Normal file
View File

@ -0,0 +1,8 @@
menu_size: 45
prefixes_amount: 1
inventory_name: '&eSelect your Prefix'
prefixes:
1:
name: 'yolo'
display_name: '&8[&6&l#YOLO&8]'

View File

@ -0,0 +1,661 @@
package club.curahq.core;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import club.curahq.core.balance.EconomyCommand;
import club.curahq.core.balance.EconomyManager;
import club.curahq.core.balance.FlatFileEconomyManager;
import club.curahq.core.balance.PayCommand;
import club.curahq.core.balance.ShopSignListener;
import club.curahq.core.classes.PvpClassManager;
import club.curahq.core.classes.archer.ArcherClass;
import club.curahq.core.classes.bard.BardRestorer;
import club.curahq.core.classes.type.RogueClass;
import club.curahq.core.combatlog.CombatLogListener;
import club.curahq.core.combatlog.CustomEntityRegistration;
import club.curahq.core.commands.chat.ClearChatCommand;
import club.curahq.core.commands.chat.MessageCommand;
import club.curahq.core.commands.chat.ReplyCommand;
import club.curahq.core.commands.chat.ToggleMessageCommand;
import club.curahq.core.commands.essentials.CoordsCommand;
import club.curahq.core.commands.essentials.DonatorReviveCommand;
import club.curahq.core.commands.essentials.EnchantCommand;
import club.curahq.core.commands.essentials.EndPortalCommand;
import club.curahq.core.commands.essentials.FightCommand;
import club.curahq.core.commands.essentials.GoppleCommand;
import club.curahq.core.commands.essentials.HelpCommand;
import club.curahq.core.commands.essentials.LFFCommand;
import club.curahq.core.commands.essentials.ListCommand;
import club.curahq.core.commands.essentials.LogoutCommand;
import club.curahq.core.commands.essentials.OreStatsCommand;
import club.curahq.core.commands.essentials.PanicCommand;
import club.curahq.core.commands.essentials.PingCommand;
import club.curahq.core.commands.essentials.PlayTimeCommand;
import club.curahq.core.commands.essentials.PvpTimerCommand;
import club.curahq.core.commands.essentials.RandomCommand;
import club.curahq.core.commands.essentials.ResetCommand;
import club.curahq.core.commands.essentials.SkullCommand;
import club.curahq.core.commands.essentials.StatsCommand;
import club.curahq.core.commands.essentials.SudoCommand;
import club.curahq.core.commands.essentials.TLCommand;
import club.curahq.core.commands.essentials.TeamspeakCommand;
import club.curahq.core.commands.essentials.ToggleSidebarCommand;
import club.curahq.core.commands.note.NoteCommand;
import club.curahq.core.commands.staff.BroadCastCommand;
import club.curahq.core.commands.staff.ClearCommand;
import club.curahq.core.commands.staff.CrowbarCommand;
import club.curahq.core.commands.staff.FeedCommand;
import club.curahq.core.commands.staff.FixCommand;
import club.curahq.core.commands.staff.FlyCommand;
import club.curahq.core.commands.staff.FreezeCommand;
import club.curahq.core.commands.staff.GameModeCommand;
import club.curahq.core.commands.staff.GiveCommand;
import club.curahq.core.commands.staff.GodCommand;
import club.curahq.core.commands.staff.HealCommand;
import club.curahq.core.commands.staff.InvSeeCommand;
import club.curahq.core.commands.staff.KillCommand;
import club.curahq.core.commands.staff.LagCommand;
import club.curahq.core.commands.staff.MiscCommands;
import club.curahq.core.commands.staff.MoreCommand;
import club.curahq.core.commands.staff.RefundCommand;
import club.curahq.core.commands.staff.RenameCommand;
import club.curahq.core.commands.staff.SetBorderCommand;
import club.curahq.core.commands.staff.SetCommand;
import club.curahq.core.commands.staff.SpawnCommand;
import club.curahq.core.commands.staff.SpawnerCommand;
import club.curahq.core.commands.staff.StaffModeCommand;
import club.curahq.core.commands.staff.VanishCommand;
import club.curahq.core.commands.staff.WhoisCommand;
import club.curahq.core.commands.teleport.TeleportAllCommand;
import club.curahq.core.commands.teleport.TeleportCommand;
import club.curahq.core.commands.teleport.TeleportHereCommand;
import club.curahq.core.commands.teleport.TopCommand;
import club.curahq.core.commands.teleport.WorldCommand;
import club.curahq.core.deathban.Deathban;
import club.curahq.core.deathban.DeathbanListener;
import club.curahq.core.deathban.DeathbanManager;
import club.curahq.core.deathban.FlatFileDeathbanManager;
import club.curahq.core.deathban.lives.LivesExecutor;
import club.curahq.core.deathban.lives.LivesListener;
import club.curahq.core.deathban.lives.StaffReviveCommand;
import club.curahq.core.faction.FactionExecutor;
import club.curahq.core.faction.FactionManager;
import club.curahq.core.faction.FactionMember;
import club.curahq.core.faction.FlatFileFactionManager;
import club.curahq.core.faction.claim.Claim;
import club.curahq.core.faction.claim.ClaimHandler;
import club.curahq.core.faction.claim.ClaimWandListener;
import club.curahq.core.faction.claim.Subclaim;
import club.curahq.core.faction.type.ClaimableFaction;
import club.curahq.core.faction.type.EndPortalFaction;
import club.curahq.core.faction.type.Faction;
import club.curahq.core.faction.type.PlayerFaction;
import club.curahq.core.faction.type.RoadFaction;
import club.curahq.core.faction.type.SpawnFaction;
import club.curahq.core.game.CaptureZone;
import club.curahq.core.game.EventExecutor;
import club.curahq.core.game.conquest.ConquestExecutor;
import club.curahq.core.game.eotw.EOTWHandler;
import club.curahq.core.game.eotw.EotwCommand;
import club.curahq.core.game.eotw.EotwListener;
import club.curahq.core.game.faction.CapturableFaction;
import club.curahq.core.game.faction.ConquestFaction;
import club.curahq.core.game.faction.KothFaction;
import club.curahq.core.game.koth.KothExecutor;
import club.curahq.core.kitmap.SelectorListener;
import club.curahq.core.listener.AutoSmeltOreListener;
import club.curahq.core.listener.BookDeenchantListener;
import club.curahq.core.listener.BorderListener;
import club.curahq.core.listener.BottledExpListener;
import club.curahq.core.listener.ChatListener;
import club.curahq.core.listener.CombatBuildListener;
import club.curahq.core.listener.CrowbarListener;
import club.curahq.core.listener.DeathListener;
import club.curahq.core.listener.DeathMessageListener;
import club.curahq.core.listener.ElevatorListener;
import club.curahq.core.listener.EnderPearlFix;
import club.curahq.core.listener.ExpMultiplierListener;
import club.curahq.core.listener.FoundDiamondsListener;
import club.curahq.core.listener.FurnaceSmeltSpeederListener;
import club.curahq.core.listener.GodListener;
import club.curahq.core.listener.ItemStatTrackingListener;
import club.curahq.core.listener.LoginEvent;
import club.curahq.core.listener.PearlGlitch;
import club.curahq.core.listener.PlayTimeManager;
import club.curahq.core.listener.PotionListener;
import club.curahq.core.listener.SignSubclaimListener;
import club.curahq.core.listener.UnRepairableListener;
import club.curahq.core.listener.WorldListener;
import club.curahq.core.listener.core.CoreListener;
import club.curahq.core.listener.factions.FactionListener;
import club.curahq.core.listener.factions.FactionsCoreListener;
import club.curahq.core.listener.fixes.BeaconStrengthFixListener;
import club.curahq.core.listener.fixes.BlockHitFixListener;
import club.curahq.core.listener.fixes.BlockJumpGlitchFixListener;
import club.curahq.core.listener.fixes.BoatGlitchFixListener;
import club.curahq.core.listener.fixes.DupeGlitchFix;
import club.curahq.core.listener.fixes.EnchantLimitListener;
import club.curahq.core.listener.fixes.EnderChestRemovalListener;
import club.curahq.core.listener.fixes.HungerFixListener;
import club.curahq.core.listener.fixes.InfinityArrowFixListener;
import club.curahq.core.listener.fixes.KnockbackListener;
import club.curahq.core.listener.fixes.NaturalMobSpawnFixListener;
import club.curahq.core.listener.fixes.PearlGlitchListener;
import club.curahq.core.listener.fixes.PortalListener;
import club.curahq.core.listener.fixes.VoidGlitchFixListener;
import club.curahq.core.listener.fixes.WeatherFixListener;
import club.curahq.core.listener.staff.NoteListener;
import club.curahq.core.listener.staff.SkullListener;
import club.curahq.core.listener.staff.StaffModeListener;
import club.curahq.core.listener.staff.VanishListener;
import club.curahq.core.prefix.PrefixCommand;
import club.curahq.core.prefix.PrefixMenu;
import club.curahq.core.scoreboard.ScoreboardHandler;
import club.curahq.core.signs.EventSignListener;
import club.curahq.core.signs.KitSignListener;
import club.curahq.core.sotw.SotwCommand;
import club.curahq.core.sotw.SotwListener;
import club.curahq.core.sotw.SotwTimer;
import club.curahq.core.tablist.TablistManager;
import club.curahq.core.tablist.tablist.TablistAdapter;
import club.curahq.core.timer.TimerExecutor;
import club.curahq.core.timer.TimerManager;
import club.curahq.core.user.ConsoleUser;
import club.curahq.core.user.FactionUser;
import club.curahq.core.user.UserManager;
import club.curahq.core.util.SignHandler;
import club.curahq.core.util.config.PlayerData;
import club.curahq.core.util.config.PotionLimiterData;
import club.curahq.core.util.config.WorldData;
import club.curahq.core.util.core.BasePlugins;
import club.curahq.core.util.core.ConfigUtil;
import club.curahq.core.util.core.Cooldowns;
import club.curahq.core.util.core.DateTimeFormats;
import club.curahq.core.util.core.Message;
import club.curahq.core.util.core.ServerHandler;
import club.curahq.core.util.itemdb.ItemDb;
import club.curahq.core.util.itemdb.SimpleItemDb;
import club.curahq.core.visualise.ProtocolLibHook;
import club.curahq.core.visualise.VisualiseHandler;
import club.curahq.core.visualise.WallBorderListener;
import lombok.Getter;
import lombok.Setter;
import me.apache.commons.lang3.time.DurationFormatUtils;
import net.md_5.bungee.api.ChatColor;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import net.minecraft.util.com.google.common.base.Joiner;
import ru.tehkode.permissions.bukkit.PermissionsEx;
@Getter
@Setter
public class Core extends JavaPlugin implements CommandExecutor {
public void onEnable() {
plugin = this;
BasePlugins.getPlugin().init(this);
config = getConfig();
config.options().copyDefaults(true);
new TablistManager(this, new TablistAdapter(this), TimeUnit.SECONDS.toMillis((long) 0.5));
MinecraftServer.getServer().setMotd("§6§lCuraHQ §7 §fThe HCFactions Network"
+ "\n"
+ "§8» §6§lHCFactions §fin Development");
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "--------------------------------------------------------------------------");
// ====================================== //
// Config //
// ====================================== //
log("&7Registering config files...");
saveConfig();
conf = new File(getDataFolder(), "config.yml");
registerConfiguration();
WorldData.getInstance().setup(this);
PlayerData.getInstance().setup(this);
PotionLimiterData.getInstance().setup(this);
log("&aSuccess!");
// ====================================== //
// Hooks //
// ====================================== //
log("&7Registering hooks...");
ProtocolLibHook.hook(this);
Plugin wep = Bukkit.getPluginManager().getPlugin("WorldEdit");
this.worldEdit = (((wep instanceof WorldEditPlugin)) && (wep.isEnabled()) ? (WorldEditPlugin) wep : null);
log("&aSucces!");
CustomEntityRegistration.registerCustomEntities();
// ====================================== //
// Commands //
// ====================================== //
log("&7Registering config commands...");
registerCommands();
log("&aSuccess!");
// ====================================== //
// Manager //
// ====================================== //
log("&7Registering managers...");
registerManagers();
log("&aSuccess!");
// ====================================== //
// Listeners //
// ====================================== //
log("&7Registering listeners...");
registerListeners();
log("&aSuccess!");
// ====================================== //
// Classes //
// ====================================== //
log("&7Registering timers...");
Cooldowns.createCooldown("Assassin_item_cooldown");
Cooldowns.createCooldown("Archer_item_cooldown");
Cooldowns.createCooldown("revive_cooldown");
Cooldowns.createCooldown("report_cooldown");
Cooldowns.createCooldown("helpop_cooldown");
Cooldowns.createCooldown("rogue_cooldown");
Cooldowns.createCooldown("lff_cooldown");
log("&aSuccess!");
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + "--------------------------------------------------------------------------");
new BukkitRunnable()
{
public void run() {
Core.this.saveData();
}
}.runTaskTimerAsynchronously(plugin, TimeUnit.SECONDS.toMillis(20L), TimeUnit.SECONDS.toMillis(20L));
this.setupBroadcast();
}
private void saveData() {
this.deathbanManager.saveDeathbanData();
this.economyManager.saveEconomyData();
this.factionManager.saveFactionData();
this.playTimeManager.savePlaytimeData();
this.userManager.saveUserData();
this.signHandler.cancelTasks(null);
PlayerData.getInstance().saveConfig();
}
public void onDisable() {
this.pvpClassManager.onDisable();
CustomEntityRegistration.unregisterCustomEntities();
CombatLogListener.removeCombatLoggers();
this.scoreboardHandler.clearBoards();
this.deathbanManager.saveDeathbanData();
this.economyManager.saveEconomyData();
this.factionManager.saveFactionData();
this.playTimeManager.savePlaytimeData();
this.userManager.saveUserData();
StaffModeCommand.onDisableMod();
saveData();
plugin = null;
}
@SuppressWarnings("deprecation")
public void setupBroadcast() {
Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> {
List<String> players = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()) {
String primary = PermissionsEx.getPermissionManager().getUser(player).getGroups()[0].getName();
if (primary != null && primary.equalsIgnoreCase(ConfigUtil.TOP_RANK)) {
players.add(player.getName());
}
}
String message = ConfigUtil.GOLD + "Online " + ConfigUtil.TOP_RANK + " Donators " + ChatColor.DARK_GRAY + " » " + ConfigUtil.GRAY + Joiner.on(ConfigUtil.GRAY + ", ").join(players);
if (!players.isEmpty()) {
Bukkit.getScheduler().runTask(Core.this, () -> {
Bukkit.broadcastMessage(message);
Bukkit.broadcastMessage(ConfigUtil.YELLOW + "You can buy this rank at " + ConfigUtil.WHITE + ConfigUtil.STORE);
});
}
}, (20 * 60 * 5) + 45, 20 * 60 * 5);
}
private void log(String string) {
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "HCF » " + ChatColor.DARK_GRAY + " " + string.replace("&", "§"));
}
private void registerConfiguration() {
ConfigurationSerialization.registerClass(CaptureZone.class);
ConfigurationSerialization.registerClass(Deathban.class);
ConfigurationSerialization.registerClass(Claim.class);
ConfigurationSerialization.registerClass(ConsoleUser.class);
ConfigurationSerialization.registerClass(Subclaim.class);
ConfigurationSerialization.registerClass(Deathban.class);
ConfigurationSerialization.registerClass(FactionUser.class);
ConfigurationSerialization.registerClass(ClaimableFaction.class);
ConfigurationSerialization.registerClass(ConquestFaction.class);
ConfigurationSerialization.registerClass(CapturableFaction.class);
ConfigurationSerialization.registerClass(KothFaction.class);
ConfigurationSerialization.registerClass(EndPortalFaction.class);
ConfigurationSerialization.registerClass(Faction.class);
ConfigurationSerialization.registerClass(FactionMember.class);
ConfigurationSerialization.registerClass(PlayerFaction.class);
ConfigurationSerialization.registerClass(RoadFaction.class);
ConfigurationSerialization.registerClass(SpawnFaction.class);
ConfigurationSerialization.registerClass(RoadFaction.NorthRoadFaction.class);
ConfigurationSerialization.registerClass(RoadFaction.EastRoadFaction.class);
ConfigurationSerialization.registerClass(RoadFaction.SouthRoadFaction.class);
ConfigurationSerialization.registerClass(RoadFaction.WestRoadFaction.class);
}
private void registerListeners() {
PluginManager manager = getServer().getPluginManager();
manager.registerEvents(new KnockbackListener(), this);
manager.registerEvents(new NoteListener(), this);
manager.registerEvents(new OreStatsCommand(), this);
manager.registerEvents(new GodListener(), this);
manager.registerEvents(new VanishListener(), this);
manager.registerEvents(new ArcherClass(this), this);
manager.registerEvents(new RogueClass(this), this);
manager.registerEvents(new PotionListener(), this);
manager.registerEvents(new LoginEvent(), this);
manager.registerEvents(new DupeGlitchFix(), this);
manager.registerEvents(new PortalListener(this), this);
manager.registerEvents(new WeatherFixListener(), this);
manager.registerEvents(new NaturalMobSpawnFixListener(), this);
manager.registerEvents(new AutoSmeltOreListener(), this);
manager.registerEvents(new BlockHitFixListener(), this);
manager.registerEvents(new BlockJumpGlitchFixListener(), this);
manager.registerEvents(new BoatGlitchFixListener(), this);
manager.registerEvents(new BookDeenchantListener(), this);
manager.registerEvents(new BorderListener(), this);
manager.registerEvents(new ChatListener(this), this);
manager.registerEvents(new ClaimWandListener(this), this);
manager.registerEvents(new BottledExpListener(), this);
manager.registerEvents(new CombatLogListener(this), this);
manager.registerEvents(new CoreListener(this), this);
manager.registerEvents(new CrowbarListener(this), this);
manager.registerEvents(new DeathListener(this), this);
manager.registerEvents(new ElevatorListener(), this);
manager.registerEvents(new DeathMessageListener(this), this);
manager.registerEvents(new RefundCommand(this), this);
manager.registerEvents(new DeathbanListener(this), this);
manager.registerEvents(new EnchantLimitListener(), this);
manager.registerEvents(new EnderChestRemovalListener(), this);
manager.registerEvents(new FlatFileFactionManager(this), this);
manager.registerEvents(new EotwListener(this), this);
manager.registerEvents(new EventSignListener(), this);
manager.registerEvents(new LivesListener(), this);
manager.registerEvents(new ExpMultiplierListener(), this);
manager.registerEvents(new FactionListener(this), this);
manager.registerEvents(new FoundDiamondsListener(this), this);
manager.registerEvents(new FurnaceSmeltSpeederListener(), this);
manager.registerEvents(new InfinityArrowFixListener(), this);
manager.registerEvents(new ItemStatTrackingListener(), this);
manager.registerEvents(new HungerFixListener(), this);
manager.registerEvents(new PearlGlitchListener(this), this);
manager.registerEvents(new FactionsCoreListener(this), this);
manager.registerEvents(new PearlGlitch(this), this);
manager.registerEvents(new EnderPearlFix(this), this);
manager.registerEvents(new SignSubclaimListener(this), this);
manager.registerEvents(new EndPortalCommand(getPlugin()), this);
manager.registerEvents(new ShopSignListener(this), this);
manager.registerEvents(new SkullListener(), this);
manager.registerEvents(new BeaconStrengthFixListener(), this);
manager.registerEvents(new VoidGlitchFixListener(), this);
manager.registerEvents(new WallBorderListener(this), this);
manager.registerEvents(this.playTimeManager, this);
manager.registerEvents(new WorldListener(this), this);
manager.registerEvents(new UnRepairableListener(), this);
manager.registerEvents(new StaffModeListener(), this);
manager.registerEvents(new SotwListener(this), this);
manager.registerEvents(new KitSignListener(), this);
manager.registerEvents(new CombatBuildListener(), this);
manager.registerEvents(new PrefixMenu(), this);
manager.registerEvents(new PrefixCommand(), this);
if(ConfigUtil.KIT_MAP == true) {
manager.registerEvents(new SelectorListener(), this);
}
}
private void registerCommands() {
getCommand("prefix").setExecutor(new PrefixCommand());
getCommand("note").setExecutor(new NoteCommand());
getCommand("top").setExecutor(new TopCommand());
getCommand("list").setExecutor(new ListCommand());
getCommand("setborder").setExecutor(new SetBorderCommand());
getCommand("world").setExecutor(new WorldCommand());
getCommand("endportal").setExecutor(new EndPortalCommand(getPlugin()));
getCommand("fix").setExecutor(new FixCommand());
getCommand("enchant").setExecutor(new EnchantCommand());
getCommand("freeze").setExecutor(new FreezeCommand(this));
getCommand("staffrevive").setExecutor(new StaffReviveCommand(this));
getCommand("lag").setExecutor(new LagCommand());
getCommand("broadcast").setExecutor(new BroadCastCommand());
getCommand("togglemessage").setExecutor(new ToggleMessageCommand());
getCommand("reply").setExecutor(new ReplyCommand());
getCommand("message").setExecutor(new MessageCommand());
getCommand("feed").setExecutor(new FeedCommand());
getCommand("setspawn").setExecutor(new SpawnCommand());
getCommand("ping").setExecutor(new PingCommand());
getCommand("togglemessage").setExecutor(new ToggleMessageCommand());
getCommand("clearchat").setExecutor(new ClearChatCommand());
getCommand("togglesidebar").setExecutor(new ToggleSidebarCommand(this));
getCommand("teleportall").setExecutor(new TeleportAllCommand());
getCommand("teleporthere").setExecutor(new TeleportHereCommand());
getCommand("give").setExecutor(new GiveCommand());
getCommand("gamemode").setExecutor(new GameModeCommand());
getCommand("fly").setExecutor(new FlyCommand());
getCommand("invsee").setExecutor(new InvSeeCommand(this));
getCommand("god").setExecutor(new GodCommand());
getCommand("vanish").setExecutor(new VanishCommand());
getCommand("sotw").setExecutor(new SotwCommand(this));
getCommand("random").setExecutor(new RandomCommand(this));
getCommand("conquest").setExecutor(new ConquestExecutor(this));
getCommand("crowbar").setExecutor(new CrowbarCommand());
getCommand("economy").setExecutor(new EconomyCommand(this));
getCommand("eotw").setExecutor(new EotwCommand(this));
getCommand("event").setExecutor(new EventExecutor(this));
getCommand("faction").setExecutor(new FactionExecutor(this));
getCommand("playtime").setExecutor(new PlayTimeCommand(this));
getCommand("gopple").setExecutor(new GoppleCommand(this));
getCommand("koth").setExecutor(new KothExecutor(this));
getCommand("lives").setExecutor(new LivesExecutor(this));
getCommand("logout").setExecutor(new LogoutCommand(this));
getCommand("more").setExecutor(new MoreCommand());
getCommand("panic").setExecutor(new PanicCommand());
getCommand("heal").setExecutor(new HealCommand());
getCommand("pay").setExecutor(new PayCommand(this));
getCommand("pvptimer").setExecutor(new PvpTimerCommand(this));
getCommand("refund").setExecutor(new RefundCommand(this));
getCommand("spawn").setExecutor(new SpawnCommand());
getCommand("timer").setExecutor(new TimerExecutor(this));
getCommand("kill").setExecutor(new KillCommand());
getCommand("ores").setExecutor(new OreStatsCommand());
getCommand("help").setExecutor(new HelpCommand());
getCommand("rename").setExecutor(new RenameCommand());
getCommand("teamspeak").setExecutor(new TeamspeakCommand());
getCommand("coords").setExecutor(new CoordsCommand());
getCommand("fsay").setExecutor(new MiscCommands());
getCommand("medic").setExecutor(new DonatorReviveCommand(this));
getCommand("staffmode").setExecutor(new StaffModeCommand());
getCommand("spawner").setExecutor(new SpawnerCommand());
getCommand("set").setExecutor(new SetCommand(this));
getCommand("stats").setExecutor(new StatsCommand());
getCommand("ci").setExecutor(new ClearCommand());
getCommand("copyinv").setExecutor(new MiscCommands());
getCommand("slowstop").setExecutor(new MiscCommands());
getCommand("teleport").setExecutor(new TeleportCommand());
getCommand("skull").setExecutor(new SkullCommand());
getCommand("reset").setExecutor(new ResetCommand());
getCommand("sudo").setExecutor(new SudoCommand());
getCommand("lff").setExecutor(new LFFCommand());
getCommand("lff").setExecutor(new LFFCommand());
getCommand("whois").setExecutor(new WhoisCommand(this));
getCommand("fight").setExecutor(new FightCommand());
getCommand("tl").setExecutor(new TLCommand());
Map<String, Map<String, Object>> map = getDescription().getCommands();
for (Map.Entry<String, Map<String, Object>> entry : map.entrySet()) {
PluginCommand command = getCommand((String) entry.getKey());
command.setPermission("command." + (String) entry.getKey());
command.setPermissionMessage(ConfigUtil.PREFIX + ChatColor.RED.toString() + "You lack the sufficient permissions to execute this command.");
}
}
private void registerManagers() {
this.claimHandler = new ClaimHandler(this);
this.deathbanManager = new FlatFileDeathbanManager(this);
this.economyManager = new FlatFileEconomyManager(this);
this.eotwHandler = new EOTWHandler(this);
this.factionManager = new FlatFileFactionManager(this);
this.itemDb = new SimpleItemDb(this);
this.playTimeManager = new PlayTimeManager(this);
this.pvpClassManager = new PvpClassManager(this);
this.timerManager = new TimerManager(this);
this.scoreboardHandler = new ScoreboardHandler(this);
this.userManager = new UserManager(this);
this.visualiseHandler = new VisualiseHandler();
this.sotwTimer = new SotwTimer();
this.message = new Message(this);
this.signHandler = new SignHandler(this);
new BardRestorer(this);
}
public boolean checkLicense() {
try {
URL url = new URL("http://alphadev.pw/license/admin/api.php?plugin=zHub&license=" + this.getConfig().getString("License"));
BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
if ((reader.lines().count() != 0)) {
reader.close();
return true;
} else {
reader.close();
return false;
}
} catch (MalformedURLException e) {
e.printStackTrace();
return false;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}
public Core() {
this.random = new Random();
}
public static Core getPlugin() {
return plugin;
}
public static Core getInstance() {
return instance;
}
public static String getReaming(long millis) {
return getRemaining(millis, true, true);
}
public static String getRemaining(long millis, boolean milliseconds) {
return getRemaining(millis, milliseconds, true);
}
public static String getRemaining(long duration, boolean milliseconds, boolean trail) {
if ((milliseconds) && (duration < MINUTE)) {
return ((DecimalFormat) (trail ? DateTimeFormats.REMAINING_SECONDS_TRAILING
: DateTimeFormats.REMAINING_SECONDS).get()).format(duration * 0.001D) + 's';
}
return DurationFormatUtils.formatDuration(duration, (duration >= HOUR ? "HH:" : "") + "mm:ss");
}
public static String getCombatRemaining(long duration, boolean milliseconds, boolean trail) {
return DurationFormatUtils.formatDuration(duration, (duration >= HOUR ? "HH:" : "") + "mm:ss");
}
public static String getCombatRemaining(long millis, boolean milliseconds) {
return getCombatRemaining(millis, milliseconds, true);
}
public static File conf;
public static FileConfiguration config;
public static Core instance;
private ConfigUtil configuration;
private static final long MINUTE = TimeUnit.MINUTES.toMillis(1L);
private static final long HOUR = TimeUnit.HOURS.toMillis(1L);
private static Core plugin;
public static Plugin pl;
private ServerHandler serverHandler;
public BukkitRunnable clearEntityHandler;
public BukkitRunnable announcementTask;
private Message message;
public static final Joiner SPACE_JOINER = Joiner.on(' ');
public static final Joiner COMMA_JOINER = Joiner.on(", ");
private Random random;
private PlayTimeManager playTimeManager;
private WorldEditPlugin worldEdit;
private ClaimHandler claimHandler;
private ItemDb itemDb;
private DeathbanManager deathbanManager;
private EconomyManager economyManager;
private EOTWHandler eotwHandler;
private FactionManager factionManager;
private PvpClassManager pvpClassManager;
private VanishListener vanish;
private ScoreboardHandler scoreboardHandler;
private SotwTimer sotwTimer;
private TimerManager timerManager;
private UserManager userManager;
private VisualiseHandler visualiseHandler;
private SignHandler signHandler;
}

View File

@ -0,0 +1,131 @@
package club.curahq.core.balance;
import java.util.Collections;
import java.util.List;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import com.google.common.collect.ImmutableList;
import club.curahq.core.Core;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.JavaUtils;
import club.curahq.core.util.core.BaseConstants;
public class EconomyCommand
implements CommandExecutor, TabCompleter
{
private final Core plugin;
public EconomyCommand(Core plugin)
{
this.plugin = plugin;
}
@SuppressWarnings({ "deprecation", "unlikely-arg-type" })
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
boolean hasStaffPermission = sender.hasPermission(command.getPermission() + ".staff");
OfflinePlayer target;
if ((args.length > 0) && (hasStaffPermission))
{
target = BukkitUtils.offlinePlayerWithNameOrUUID(args[0]);
}
else
{
if (!(sender instanceof Player))
{
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playerName>");
return true;
}
target = (OfflinePlayer)sender;
}
if ((!target.hasPlayedBefore()) && (!target.isOnline()))
{
sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
UUID uuid = target.getUniqueId();
int balance = this.plugin.getEconomyManager().getBalance(uuid);
if ((args.length < 2) || (!hasStaffPermission))
{
sender.sendMessage(ChatColor.GRAY + (sender.equals(target) ? "Balance: " : new StringBuilder(String.valueOf(target.getName())).append("'s Balance: ").toString()) + ChatColor.GOLD + '$' + balance);
return true;
}
if (GIVE.contains(args[1].toLowerCase()))
{
if (args.length < 3)
{
sender.sendMessage(ChatColor.RED + "Usage: /" + label + ' ' + target.getName() + ' ' + args[1] + " <amount>");
return true;
}
Integer amount = JavaUtils.tryParseInt(args[2]);
if (amount == null)
{
sender.sendMessage(ChatColor.RED + "'" + args[2] + "' is not a valid number.");
return true;
}
int newBalance = this.plugin.getEconomyManager().addBalance(uuid, amount.intValue());
sender.sendMessage(new String[] { ChatColor.GRAY + "Added " + ChatColor.GREEN + '$' + JavaUtils.format(amount) + ChatColor.GRAY + " to balance of " + target.getName() + '.', ChatColor.GRAY + "Balance of " + target.getName() + " is now " + ChatColor.GREEN + '$' + newBalance + ChatColor.GRAY + '.' });
return true;
}
if (TAKE.contains(args[1].toLowerCase()))
{
if (args.length < 3)
{
sender.sendMessage(ChatColor.RED + "Usage: /" + label + ' ' + target.getName() + ' ' + args[1] + " <amount>");
return true;
}
Integer amount = JavaUtils.tryParseInt(args[2]);
if (amount == null)
{
sender.sendMessage(ChatColor.RED + "'" + args[2] + "' is not a valid number.");
return true;
}
int newBalance = this.plugin.getEconomyManager().subtractBalance(uuid, amount.intValue());
sender.sendMessage(new String[] { ChatColor.GRAY + "Taken " + '$' + JavaUtils.format(amount) + " from balance of " + target.getName() + '.', ChatColor.GRAY + "Balance of " + target.getName() + " is now " + '$' + newBalance + '.' });
return true;
}
if (!args[1].equalsIgnoreCase("set"))
{
sender.sendMessage(ChatColor.GOLD + (sender.equals(target) ? "Your balance" : new StringBuilder("Balance of ").append(target.getName()).toString()) + " is " + ChatColor.WHITE + '$' + balance + ChatColor.GOLD + '.');
return true;
}
if (args.length < 3)
{
sender.sendMessage(ChatColor.RED + "Usage: /" + label + ' ' + target.getName() + ' ' + args[1] + " <amount>");
return true;
}
Integer amount = JavaUtils.tryParseInt(args[2]);
if (amount == null)
{
sender.sendMessage(ChatColor.RED + "'" + args[2] + "' is not a valid number.");
return true;
}
int newBalance = this.plugin.getEconomyManager().setBalance(uuid, amount.intValue());
sender.sendMessage(ChatColor.GRAY + "Set balance of " + ChatColor.GOLD + target.getName() + ChatColor.GRAY + " to " + ChatColor.GREEN + '$' + JavaUtils.format(Integer.valueOf(newBalance)) + '.');
return true;
}
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args)
{
return args.length == 2 ? BukkitUtils.getCompletions(args, COMPLETIONS) : Collections.emptyList();
}
private static final ImmutableList<String> TAKE = ImmutableList.of("take", "negate", "minus", "subtract");
private static final ImmutableList<String> GIVE;
static
{
GIVE = ImmutableList.of("give", "add");
}
private static final ImmutableList<String> COMPLETIONS = ImmutableList.of("add", "set", "take");
}

View File

@ -0,0 +1,23 @@
package club.curahq.core.balance;
import java.util.UUID;
import net.minecraft.util.gnu.trove.map.TObjectIntMap;
public abstract interface EconomyManager
{
public static final char ECONOMY_SYMBOL = '$';
public abstract TObjectIntMap<UUID> getBalanceMap();
public abstract int getBalance(UUID paramUUID);
public abstract int setBalance(UUID paramUUID, int paramInt);
public abstract int addBalance(UUID paramUUID, int paramInt);
public abstract int subtractBalance(UUID paramUUID, int paramInt);
public abstract void reloadEconomyData();
public abstract void saveEconomyData();
}

View File

@ -0,0 +1,72 @@
package club.curahq.core.balance;
import net.minecraft.util.gnu.trove.map.TObjectIntMap;
import net.minecraft.util.gnu.trove.map.hash.TObjectIntHashMap;
import org.bukkit.configuration.MemorySection;
import club.curahq.core.Core;
import club.curahq.core.util.Config;
import java.util.*;
public class FlatFileEconomyManager implements EconomyManager {
private final Core plugin;
private TObjectIntMap<UUID> balanceMap;
private Config balanceConfig;
public FlatFileEconomyManager(final Core plugin) {
this.balanceMap = new TObjectIntHashMap<UUID>(10, 0.5f, 0);
this.plugin = plugin;
this.reloadEconomyData();
}
@Override
public TObjectIntMap<UUID> getBalanceMap() {
return this.balanceMap;
}
@Override
public int getBalance(final UUID uuid) {
return this.balanceMap.get((Object) uuid);
}
@Override
public int setBalance(final UUID uuid, final int amount) {
this.balanceMap.put(uuid, amount);
return amount;
}
@Override
public int addBalance(final UUID uuid, final int amount) {
return this.setBalance(uuid, this.getBalance(uuid) + amount);
}
@Override
public int subtractBalance(final UUID uuid, final int amount) {
return this.setBalance(uuid, this.getBalance(uuid) - amount);
}
@Override
public void reloadEconomyData() {
this.balanceConfig = new Config(this.plugin, "balances");
final Object object = this.balanceConfig.get("balances");
if (object instanceof MemorySection) {
final MemorySection section = (MemorySection)object;
final Set<String> keys = (Set<String>)section.getKeys(false);
for (final String id : keys) {
this.balanceMap.put((UUID) UUID.fromString(id), this.balanceConfig.getInt("balances." + id));
}
}
}
public void saveEconomyData() {
final Map<String, Integer> saveMap = new LinkedHashMap<String, Integer>(this.balanceMap.size());
this.balanceMap.forEachEntry((uuid, i) -> {
saveMap.put(uuid.toString(), i);
return true;
});
this.balanceConfig.set("balances", (Object)saveMap);
this.balanceConfig.save();
}
}

View File

@ -0,0 +1,83 @@
package club.curahq.core.balance;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import club.curahq.core.Core;
import club.curahq.core.util.JavaUtils;
import club.curahq.core.util.core.BaseConstants;
public class PayCommand
implements CommandExecutor, TabCompleter
{
private final Core plugin;
public PayCommand(Core plugin)
{
this.plugin = plugin;
}
@SuppressWarnings({ "deprecation", "unlikely-arg-type" })
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (args.length < 2)
{
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <playerName> <amount>");
return true;
}
Integer amount = JavaUtils.tryParseInt(args[1]);
if (amount == null)
{
sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a valid number.");
return true;
}
if (amount.intValue() <= 0)
{
sender.sendMessage(ChatColor.RED + "You must send money in positive quantities.");
return true;
}
Player senderPlayer = (Player)sender;
int senderBalance = senderPlayer != null ? this.plugin.getEconomyManager().getBalance(senderPlayer.getUniqueId()) : 1024;
if (senderBalance < amount.intValue())
{
sender.sendMessage(ChatColor.RED + "You do not have that much money, you have: " + ChatColor.GREEN + senderBalance);
return true;
}
OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
if (sender.equals(target))
{
sender.sendMessage(ChatColor.RED + "You cannot send money to yourself.");
return true;
}
Player targetPlayer = target.getPlayer();
if ((!target.hasPlayedBefore()) && (targetPlayer == null))
{
sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
if (targetPlayer == null) {
return false;
}
if (senderPlayer != null) {
this.plugin.getEconomyManager().subtractBalance(senderPlayer.getUniqueId(), amount.intValue());
}
this.plugin.getEconomyManager().addBalance(targetPlayer.getUniqueId(), amount.intValue());
targetPlayer.sendMessage(ChatColor.AQUA + sender.getName() + ChatColor.GRAY + " has sent you " + ChatColor.GREEN + '$' + amount + ChatColor.GRAY + '.');
sender.sendMessage(ChatColor.GRAY + "You have sent " + ChatColor.GREEN + '$' + amount + ChatColor.GRAY + " to " + ChatColor.AQUA + target.getName() + '.');
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args)
{
return args.length == 1 ? null : Collections.emptyList();
}
}

View File

@ -0,0 +1,114 @@
package club.curahq.core.balance;
import java.util.Arrays;
import java.util.Map;
import java.util.regex.Pattern;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import club.curahq.core.Core;
import club.curahq.core.crowbar.Crowbar;
import club.curahq.core.util.InventoryUtils;
import club.curahq.core.util.JavaUtils;
import club.curahq.core.util.core.BasePlugins;
public class ShopSignListener
implements Listener
{
public ShopSignListener(Core plugin)
{
this.plugin = plugin;
}
@SuppressWarnings("deprecation")
@EventHandler(ignoreCancelled=false, priority=EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event)
{
if (event.getAction() == Action.RIGHT_CLICK_BLOCK)
{
Block block = event.getClickedBlock();
BlockState state = block.getState();
if ((state instanceof Sign))
{
Sign sign = (Sign)state;
String[] lines = sign.getLines();
Integer quantity = JavaUtils.tryParseInt(lines[2]);
if (quantity == null) {
return;
}
Integer price = JavaUtils.tryParseInt(ALPHANUMERIC_REMOVER.matcher(lines[3]).replaceAll(""));
if (price == null) {
return;
}
ItemStack stack;
if (lines[1].equalsIgnoreCase("Crowbar")) {
stack = new Crowbar().getItemIfPresent();
} else if ((stack = BasePlugins.getPlugin().getItemDb().getItem(ALPHANUMERIC_REMOVER.matcher(lines[1]).replaceAll(""), (int) quantity)) == null) {
return;
}
Player player = event.getPlayer();
String[] fakeLines = (String[])Arrays.copyOf(sign.getLines(), 4);
if (((lines[0].contains("Sell")) && (lines[0].contains(ChatColor.RED.toString()))) || (lines[0].contains(ChatColor.AQUA.toString())))
{
int sellQuantity = Math.min(quantity.intValue(), InventoryUtils.countAmount(player.getInventory(), stack.getType(), stack.getDurability()));
if (sellQuantity <= 0)
{
fakeLines[0] = (ChatColor.RED + "Not carrying any");
fakeLines[2] = (ChatColor.RED + "on you.");
fakeLines[3] = "";
}
else
{
int newPrice = price.intValue() / quantity.intValue() * sellQuantity;
fakeLines[0] = (ChatColor.GREEN + "Sold " + sellQuantity);
fakeLines[3] = (ChatColor.GREEN + "for " + '$' + newPrice);
this.plugin.getEconomyManager().addBalance(player.getUniqueId(), newPrice);
InventoryUtils.removeItem(player.getInventory(), stack.getType(), (short)stack.getData().getData(), sellQuantity);
player.updateInventory();
}
}
else
{
if ((!lines[0].contains("Buy")) || (!lines[0].contains(ChatColor.GREEN.toString())) || (lines[0].contains(ChatColor.AQUA.toString()))) {
return;
}
if (price.intValue() > this.plugin.getEconomyManager().getBalance(player.getUniqueId()))
{
fakeLines[0] = (ChatColor.RED + "Cannot afford");
}
else
{
fakeLines[0] = (ChatColor.GREEN + "Item bought");
fakeLines[3] = (ChatColor.GREEN + "for " + '$' + price);
this.plugin.getEconomyManager().subtractBalance(player.getUniqueId(), price.intValue());
World world = player.getWorld();
Location location = player.getLocation();
Map<Integer, ItemStack> excess = player.getInventory().addItem(new ItemStack[] { stack });
for (Map.Entry<Integer, ItemStack> excessItemStack : excess.entrySet()) {
world.dropItemNaturally(location, (ItemStack)excessItemStack.getValue());
}
player.setItemInHand(player.getItemInHand());
player.updateInventory();
}
}
event.setCancelled(true);
BasePlugins.getPlugin().getSignHandler().showLines(player, sign, fakeLines, 100L, true);
}
}
}
private static final Pattern ALPHANUMERIC_REMOVER = Pattern.compile("[^A-Za-z0-9]");
private final Core plugin;
}

View File

@ -0,0 +1,58 @@
package club.curahq.core.classes;
import java.util.HashSet;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
public abstract class PvpClass
{
public PvpClass(String name, long warmupDelay)
{
this.passiveEffects = new HashSet<PotionEffect>();
this.name = name;
this.warmupDelay = warmupDelay;
}
public String getName()
{
return this.name;
}
public long getWarmupDelay()
{
return this.warmupDelay;
}
public boolean onEquip(Player player)
{
for (PotionEffect effect : this.passiveEffects) {
player.addPotionEffect(effect, true);
}
player.sendMessage(ChatColor.YELLOW + "Class " + ChatColor.GOLD + this.name + ChatColor.YELLOW + " has been equipped.");
return true;
}
public void onUnequip(Player player)
{
for (PotionEffect effect : this.passiveEffects) {
for (PotionEffect active : player.getActivePotionEffects()) {
if ((active.getDuration() > DEFAULT_MAX_DURATION) && (active.getType().equals(effect.getType())) && (active.getAmplifier() == effect.getAmplifier()))
{
player.removePotionEffect(effect.getType());
break;
}
}
}
player.sendMessage(ChatColor.YELLOW + "Class " + ChatColor.GOLD + this.name + ChatColor.YELLOW + " has been un-equipped.");
}
public static final long DEFAULT_MAX_DURATION = TimeUnit.MINUTES.toMillis(8L);
protected final Set<PotionEffect> passiveEffects;
protected final String name;
protected final long warmupDelay;
public abstract boolean isApplicableFor(Player paramPlayer);
}

View File

@ -0,0 +1,89 @@
package club.curahq.core.classes;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Nullable;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import club.curahq.core.Core;
import club.curahq.core.classes.PvpClass;
import club.curahq.core.classes.archer.ArcherClass;
import club.curahq.core.classes.bard.BardClass;
import club.curahq.core.classes.event.PvpClassEquipEvent;
import club.curahq.core.classes.event.PvpClassUnequipEvent;
import club.curahq.core.classes.type.MinerClass;
import club.curahq.core.classes.type.RogueClass;
public class PvpClassManager {
private final Map<UUID, PvpClass> equippedClass = new HashMap<UUID, PvpClass>();
private final Map<String, PvpClass> pvpClasses = new HashMap<String, PvpClass>();
public PvpClassManager(Core plugin) {
this.pvpClasses.put("Archer", new ArcherClass(plugin));
this.pvpClasses.put("Bard", new BardClass(plugin));
this.pvpClasses.put("Miner", new MinerClass(plugin));
this.pvpClasses.put("Rogue", new RogueClass(plugin));
for (PvpClass pvpClass : this.pvpClasses.values()) {
if (!(pvpClass instanceof Listener)) continue;
plugin.getServer().getPluginManager().registerEvents((Listener)pvpClass, (Plugin)plugin);
}
}
public void onDisable() {
for (Map.Entry<UUID, PvpClass> entry : new HashMap<UUID, PvpClass>(this.equippedClass).entrySet()) {
this.setEquippedClass(Bukkit.getPlayer((UUID)entry.getKey()), null);
}
this.pvpClasses.clear();
this.equippedClass.clear();
}
public Collection<PvpClass> getPvpClasses() {
return this.pvpClasses.values();
}
public PvpClass getPvpClass(String name) {
return this.pvpClasses.get(name);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public PvpClass getEquippedClass(Player player) {
Map<UUID, PvpClass> map = this.equippedClass;
synchronized (map) {
return this.equippedClass.get(player.getUniqueId());
}
}
public boolean hasClassEquipped(Player player, PvpClass pvpClass) {
PvpClass equipped = this.getEquippedClass(player);
if (equipped != null && equipped.equals(pvpClass)) {
return true;
}
return false;
}
public void setEquippedClass(Player player, @Nullable PvpClass pvpClass) {
PvpClass equipped = this.getEquippedClass(player);
if (equipped != null) {
if (pvpClass == null) {
this.equippedClass.remove(player.getUniqueId());
equipped.onUnequip(player);
Bukkit.getPluginManager().callEvent((Event)new PvpClassUnequipEvent(player, equipped));
return;
}
} else if (pvpClass == null) {
return;
}
if (pvpClass.onEquip(player)) {
this.equippedClass.put(player.getUniqueId(), pvpClass);
Bukkit.getPluginManager().callEvent((Event)new PvpClassEquipEvent(player, pvpClass));
}
}
}

View File

@ -0,0 +1,161 @@
package club.curahq.core.classes.archer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import net.minecraft.util.gnu.trove.map.TObjectLongMap;
import net.minecraft.util.gnu.trove.map.hash.TObjectLongHashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Entity;
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.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scheduler.BukkitRunnable;
import club.curahq.core.Core;
import club.curahq.core.classes.PvpClass;
import club.curahq.core.util.core.Cooldowns;
public class ArcherClass
extends PvpClass
implements Listener
{
public ArcherClass(Core plugin)
{
super("Archer", TimeUnit.SECONDS.toMillis(1L));
this.archerSpeedCooldowns = new TObjectLongHashMap<UUID>();
this.plugin = plugin;
this.passiveEffects.add(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1));
this.passiveEffects.add(new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 0));
this.passiveEffects.add(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2));
}
public boolean onEquip(Player player)
{
return super.onEquip(player);
}
@EventHandler
public void onPlayerClickSugar(PlayerInteractEvent e)
{
final Player p = e.getPlayer();
if ((this.plugin.getPvpClassManager().getEquippedClass(p) != null) && (this.plugin.getPvpClassManager().getEquippedClass(p).equals(this)) && (p.getItemInHand().getType() == Material.SUGAR))
{
if (Cooldowns.isOnCooldown("Archer_item_cooldown", p))
{
p.sendMessage(ChatColor.RED + "You cannot use this for another " + ChatColor.BOLD.toString() + Core.getRemaining(Cooldowns.getCooldownForPlayerLong("Archer_item_cooldown", p), true) + ChatColor.RED + '.');
e.setCancelled(true);
return;
}
Cooldowns.addCooldown("Archer_item_cooldown", p, ARCHER_SPEED_COOLDOWN_DELAY);
if (p.getItemInHand().getAmount() == 1) {
p.getInventory().remove(p.getItemInHand());
} else {
p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
}
p.removePotionEffect(PotionEffectType.SPEED);
p.addPotionEffect(ARCHER_SPEED_EFFECT);
new BukkitRunnable()
{
public void run()
{
if (ArcherClass.this.isApplicableFor(p))
{
p.removePotionEffect(PotionEffectType.SPEED);
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2));
}
}
}.runTaskLater(this.plugin, 180L);
}
}
@EventHandler
public void onQuit(PlayerQuitEvent e)
{
if (TAGGED.containsKey(e.getPlayer().getUniqueId())) {
TAGGED.remove(e.getPlayer().getUniqueId());
}
}
@SuppressWarnings("deprecation")
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onEntityDamage(EntityDamageByEntityEvent event)
{
Entity entity = event.getEntity();
Entity damager = event.getDamager();
if (((entity instanceof Player)) && ((damager instanceof Arrow)))
{
Arrow arrow = (Arrow)damager;
ProjectileSource source = arrow.getShooter();
if ((source instanceof Player))
{
Player damaged = (Player)event.getEntity();
Player shooter = (Player)source;
PvpClass equipped = this.plugin.getPvpClassManager().getEquippedClass(shooter);
if ((equipped == null) || (!equipped.equals(this))) {
return;
}
if (this.plugin.getTimerManager().archerTimer.getRemaining((Player)entity) == 0L)
{
if ((this.plugin.getPvpClassManager().getEquippedClass(damaged) != null) && (this.plugin.getPvpClassManager().getEquippedClass(damaged).equals(this))) {
return;
}
this.plugin.getTimerManager().archerTimer.setCooldown((Player)entity, entity.getUniqueId());
TAGGED.put(damaged.getUniqueId(), shooter.getUniqueId());
List<Player> onlinePlayers = new ArrayList<Player>();
Player[] arrayOfPlayer;
int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
for (int i = 0; i < j; i++)
{
Player player = arrayOfPlayer[i];
onlinePlayers.add(player);
this.plugin.getScoreboardHandler().getPlayerBoard(player.getUniqueId()).addUpdates(onlinePlayers);
}
double distance = shooter.getLocation().distance(damaged.getLocation());
double round = Math.round(distance*100) / 100;
shooter.sendMessage(ChatColor.YELLOW + "You marked " + ChatColor.BOLD + damaged.getName() + " for 10 seconds " + ChatColor.GRAY + "[distance: " + round + ChatColor.GRAY + ", damage: " + ChatColor.RED + event.getDamage() + ChatColor.GRAY + "]");
damaged.sendMessage(ChatColor.RED + "Archer Marked! " + ChatColor.YELLOW + "You have been Archer Tagged, any damage you take by a player will be increased by 25%");
}
}
}
}
public boolean isApplicableFor(Player player)
{
PlayerInventory playerInventory = player.getInventory();
ItemStack helmet = playerInventory.getHelmet();
if ((helmet == null) || (helmet.getType() != Material.LEATHER_HELMET)) {
return false;
}
ItemStack chestplate = playerInventory.getChestplate();
if ((chestplate == null) || (chestplate.getType() != Material.LEATHER_CHESTPLATE)) {
return false;
}
ItemStack leggings = playerInventory.getLeggings();
if ((leggings == null) || (leggings.getType() != Material.LEATHER_LEGGINGS)) {
return false;
}
ItemStack boots = playerInventory.getBoots();
return (boots != null) && (boots.getType() == Material.LEATHER_BOOTS);
}
public static final HashMap<UUID, UUID> TAGGED = new HashMap<UUID, UUID>();
private static final PotionEffect ARCHER_SPEED_EFFECT = new PotionEffect(PotionEffectType.SPEED, 180, 3);
private static final int ARCHER_SPEED_COOLDOWN_DELAY = 60;
public final TObjectLongMap<UUID> archerSpeedCooldowns;
private final Core plugin;
}

View File

@ -0,0 +1,321 @@
package club.curahq.core.classes.bard;
import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import net.minecraft.util.gnu.trove.map.TObjectLongMap;
import net.minecraft.util.gnu.trove.map.hash.TObjectLongHashMap;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import club.curahq.core.Core;
import club.curahq.core.classes.PvpClass;
import club.curahq.core.faction.type.Faction;
import club.curahq.core.faction.type.PlayerFaction;
public class BardClass
extends PvpClass
implements Listener
{
public static final int HELD_EFFECT_DURATION_TICKS = 100;
public BardClass(Core plugin)
{
super("Bard", TimeUnit.SECONDS.toMillis(1L));
this.bardDataMap = new HashMap<UUID, BardData>();
this.bardEffects = new EnumMap<Material, BardEffect>(Material.class);
this.msgCooldowns = new TObjectLongHashMap<UUID>();
this.plugin = plugin;
this.bardRestorer = new BardRestorer(plugin);
this.passiveEffects.add(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1));
this.passiveEffects.add(new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 0));
this.passiveEffects.add(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
this.bardEffects.put(Material.SUGAR, new BardEffect(45, new PotionEffect(PotionEffectType.SPEED, 120, 2), new PotionEffect(PotionEffectType.SPEED, 100, 1)));
this.bardEffects.put(Material.BLAZE_POWDER, new BardEffect(45, new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 120, 0), null));
this.bardEffects.put(Material.IRON_INGOT, new BardEffect(35, new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 80, 2), new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 100, 0)));
this.bardEffects.put(Material.GHAST_TEAR, new BardEffect(30, new PotionEffect(PotionEffectType.REGENERATION, 60, 2), new PotionEffect(PotionEffectType.REGENERATION, 100, 0)));
this.bardEffects.put(Material.FEATHER, new BardEffect(40, new PotionEffect(PotionEffectType.JUMP, 120, 3), new PotionEffect(PotionEffectType.JUMP, 100, 1)));
this.bardEffects.put(Material.SPIDER_EYE, new BardEffect(55, new PotionEffect(PotionEffectType.WITHER, 100, 1), null));
this.bardEffects.put(Material.MAGMA_CREAM, new BardEffect(10, new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 900, 0), new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 120, 0)));
}
public boolean onEquip(final Player player)
{
if (!super.onEquip(player)) {
return false;
}
if (BardClass.this.plugin.getTimerManager().invincibilityTimer.getRemaining(player.getUniqueId()) > 0L) {
player.sendMessage(ChatColor.RED + "You still have PvP Protection, you must enable it first.");
return false;
}
BardData bardData = new BardData();
this.bardDataMap.put(player.getUniqueId(), bardData);
bardData.startEnergyTracking();
bardData.heldTask = new BukkitRunnable()
{
int lastEnergy;
@SuppressWarnings("deprecation")
public void run()
{
ItemStack held = player.getItemInHand();
if (held != null)
{
BardEffect bardEffect = (BardEffect)BardClass.this.bardEffects.get(held.getType());
if ((bardEffect != null) && (!BardClass.this.plugin.getFactionManager().getFactionAt(player.getLocation()).isSafezone()))
{
PlayerFaction playerFaction = BardClass.this.plugin.getFactionManager().getPlayerFaction(player);
if (playerFaction != null)
{
Collection<Entity> nearbyEntities = player.getNearbyEntities(25.0D, 25.0D, 25.0D);
for (Entity nearby : nearbyEntities) {
if (((nearby instanceof Player)) && (!player.equals(nearby)))
{
Player target = (Player)nearby;
if (playerFaction.getMembers().containsKey(target.getUniqueId())) {
BardClass.this.bardRestorer.setRestoreEffect(target, bardEffect.heldable);
//NEED FIXING
}
}
}
}
}
}
int energy = (int)BardClass.this.getEnergy(player);
if ((energy != 0) && (energy != this.lastEnergy) && ((energy % 10 == 0) || (this.lastEnergy - energy - 1 > 0) || (energy == 120.0D)))
{
this.lastEnergy = energy;
player.sendMessage(ChatColor.YELLOW + BardClass.this.name + " Energy: " + ChatColor.GOLD + energy);
}
}
}.runTaskTimer(this.plugin, 0L, 20L);
return true;
}
public void onUnequip(Player player)
{
super.onUnequip(player);
clearBardData(player.getUniqueId());
}
private void clearBardData(UUID uuid)
{
BardData bardData = (BardData)this.bardDataMap.remove(uuid);
if ((bardData != null) && (bardData.heldTask != null)) {
bardData.heldTask.cancel();
}
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event)
{
clearBardData(event.getPlayer().getUniqueId());
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event)
{
clearBardData(event.getPlayer().getUniqueId());
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onItemHeld(PlayerItemHeldEvent event)
{
Player player = event.getPlayer();
PvpClass equipped = this.plugin.getPvpClassManager().getEquippedClass(player);
if ((equipped == null) || (!equipped.equals(this))) {
return;
}
UUID uuid = player.getUniqueId();
long lastMessage = this.msgCooldowns.get(uuid);
long millis = System.currentTimeMillis();
if ((lastMessage != this.msgCooldowns.getNoEntryValue()) && (lastMessage - millis > 0L)) {
return;
}
player.getInventory().getItem(event.getNewSlot());
}
@SuppressWarnings("deprecation")
@EventHandler(ignoreCancelled=false, priority=EventPriority.MONITOR)
public void onPlayerInteract(PlayerInteractEvent event)
{
if (!event.hasItem()) {
return;
}
Action action = event.getAction();
if ((action == Action.RIGHT_CLICK_AIR) || ((!event.isCancelled()) && (action == Action.RIGHT_CLICK_BLOCK)))
{
ItemStack stack = event.getItem();
BardEffect bardEffect = (BardEffect)this.bardEffects.get(stack.getType());
if ((bardEffect == null) || (bardEffect.clickable == null)) {
return;
}
event.setUseItemInHand(Result.DENY);
Player player = event.getPlayer();
BardData bardData = (BardData)this.bardDataMap.get(player.getUniqueId());
if (bardData != null)
{
if (!canUseBardEffect(player, bardData, bardEffect, true)) {
return;
}
if (stack.getAmount() > 1) {
stack.setAmount(stack.getAmount() - 1);
} else {
player.setItemInHand(new ItemStack(Material.AIR, 1));
}
if ((bardEffect != null) && (!this.plugin.getFactionManager().getFactionAt(player.getLocation()).isSafezone()))
{
PlayerFaction playerFaction = this.plugin.getFactionManager().getPlayerFaction(player);
if ((playerFaction != null) && (!bardEffect.clickable.getType().equals(PotionEffectType.WITHER)))
{
Collection<Entity> nearbyEntities = player.getNearbyEntities(25.0D, 25.0D, 25.0D);
for (Entity nearby : nearbyEntities) {
if (((nearby instanceof Player)) && (!player.equals(nearby)))
{
Player target = (Player)nearby;
if (playerFaction.getMembers().containsKey(target.getUniqueId())) {
this.bardRestorer.setRestoreEffect(target, bardEffect.clickable);
}
}
}
}
else if ((playerFaction != null) && (bardEffect.clickable.getType().equals(PotionEffectType.WITHER)))
{
Collection<Entity> nearbyEntities = player.getNearbyEntities(25.0D, 25.0D, 25.0D);
for (Entity nearby : nearbyEntities) {
if (((nearby instanceof Player)) && (!player.equals(nearby)))
{
Player target = (Player)nearby;
if (!playerFaction.getMembers().containsKey(target.getUniqueId())) {
this.bardRestorer.setRestoreEffect(target, bardEffect.clickable);
}
}
}
}
else if (bardEffect.clickable.getType().equals(PotionEffectType.WITHER))
{
Collection<Entity> nearbyEntities = player.getNearbyEntities(25.0D, 25.0D, 25.0D);
for (Entity nearby : nearbyEntities) {
if (((nearby instanceof Player)) && (!player.equals(nearby)))
{
Player target = (Player)nearby;
this.bardRestorer.setRestoreEffect(target, bardEffect.clickable);
}
}
}
}
if ((bardEffect.clickable.getType().equals(PotionEffectType.INCREASE_DAMAGE)))
{
this.bardRestorer.setRestoreEffect(player, bardEffect.clickable);
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 1, 0));
}
this.bardRestorer.setRestoreEffect(player, bardEffect.clickable);
setEnergy(player, bardData.getEnergy() - bardEffect.energyCost);
bardData.buffCooldown = (System.currentTimeMillis() + BUFF_COOLDOWN_MILLIS);
}
}
}
private boolean canUseBardEffect(Player player, BardData bardData, BardEffect bardEffect, boolean sendFeedback)
{
String errorFeedback = null;
double currentEnergy = bardData.getEnergy();
if (bardEffect.energyCost > currentEnergy) {
errorFeedback = ChatColor.RED + "You need at least " + ChatColor.BOLD + bardEffect.energyCost + ChatColor.RED + " energy to use this Bard buff, whilst you only have " + ChatColor.BOLD + currentEnergy + ChatColor.RED + '.';
}
long remaining = bardData.getRemainingBuffDelay();
if (remaining > 0L) {
errorFeedback = ChatColor.RED + "You still have a cooldown on this " + ChatColor.GREEN + ChatColor.BOLD + "Bard" + ChatColor.RED + " buff for another " + Core.getRemaining(remaining, true, false) + ChatColor.RED + '.';
}
Faction factionAt = this.plugin.getFactionManager().getFactionAt(player.getLocation());
if (factionAt.isSafezone()) {
errorFeedback = ChatColor.RED + "Bard Buffs are disabled in safe-zones.";
}
if ((sendFeedback) && (errorFeedback != null)) {
player.sendMessage(errorFeedback);
}
return errorFeedback == null;
}
public boolean isApplicableFor(Player player)
{
ItemStack helmet = player.getInventory().getHelmet();
if ((helmet == null) || (helmet.getType() != Material.GOLD_HELMET)) {
return false;
}
ItemStack chestplate = player.getInventory().getChestplate();
if ((chestplate == null) || (chestplate.getType() != Material.GOLD_CHESTPLATE)) {
return false;
}
ItemStack leggings = player.getInventory().getLeggings();
if ((leggings == null) || (leggings.getType() != Material.GOLD_LEGGINGS)) {
return false;
}
ItemStack boots = player.getInventory().getBoots();
return (boots != null) && (boots.getType() == Material.GOLD_BOOTS);
}
public long getRemainingBuffDelay(Player player)
{
synchronized (this.bardDataMap)
{
BardData bardData = (BardData)this.bardDataMap.get(player.getUniqueId());
return bardData == null ? 0L : bardData.getRemainingBuffDelay();
}
}
public double getEnergy(Player player)
{
synchronized (this.bardDataMap)
{
BardData bardData = (BardData)this.bardDataMap.get(player.getUniqueId());
return bardData == null ? 0.0D : bardData.getEnergy();
}
}
public long getEnergyMillis(Player player)
{
synchronized (this.bardDataMap)
{
BardData bardData = (BardData)this.bardDataMap.get(player.getUniqueId());
return bardData == null ? 0L : bardData.getEnergyMillis();
}
}
public double setEnergy(Player player, double energy)
{
BardData bardData = (BardData)this.bardDataMap.get(player.getUniqueId());
if (bardData == null) {
return 0.0D;
}
bardData.setEnergy(energy);
return bardData.getEnergy();
}
private static final long BUFF_COOLDOWN_MILLIS = TimeUnit.SECONDS.toMillis(8L);
private final Map<UUID, BardData> bardDataMap;
private final Map<Material, BardEffect> bardEffects;
private final BardRestorer bardRestorer;
private final Core plugin;
private final TObjectLongMap<UUID> msgCooldowns;
}

View File

@ -0,0 +1,40 @@
package club.curahq.core.classes.bard;
import com.google.common.base.Preconditions;
import org.bukkit.scheduler.BukkitTask;
public class BardData {
public static final double MIN_ENERGY = 0.0;
public static final double MAX_ENERGY = 120.0;
public static final long MAX_ENERGY_MILLIS = 120000L;
private static final double ENERGY_PER_MILLISECOND = 1.25;
public long buffCooldown;
public BukkitTask heldTask;
private long energyStart;
public long getRemainingBuffDelay() {
return this.buffCooldown - System.currentTimeMillis();
}
public void startEnergyTracking() {
this.setEnergy(0.0);
}
public long getEnergyMillis() {
if(this.energyStart == 0L) {
return 0L;
}
return Math.min(MAX_ENERGY_MILLIS, (long) (ENERGY_PER_MILLISECOND * (System.currentTimeMillis() - this.energyStart)));
}
public double getEnergy() {
final double value = this.getEnergyMillis() / 1000.0;
return Math.round(value * 10.0) / 10.0;
}
public void setEnergy(final double energy) {
Preconditions.checkArgument(energy >= MIN_ENERGY, (Object) "Energy cannot be less than 0.0");
Preconditions.checkArgument(energy <= MAX_ENERGY, (Object) "Energy cannot be more than 120.0");
this.energyStart = (long) (System.currentTimeMillis() - 1000.0 * energy);
}
}

View File

@ -0,0 +1,17 @@
package club.curahq.core.classes.bard;
import org.bukkit.potion.PotionEffect;
public class BardEffect
{
public final int energyCost;
public final PotionEffect clickable;
public final PotionEffect heldable;
public BardEffect(int energyCost, PotionEffect clickable, PotionEffect heldable)
{
this.energyCost = energyCost;
this.clickable = clickable;
this.heldable = heldable;
}
}

View File

@ -0,0 +1,83 @@
package club.curahq.core.classes.bard;
import com.google.common.collect.HashBasedTable;
import com.google.common.collect.Table;
import club.curahq.core.Core;
import club.curahq.core.classes.event.PvpClassUnequipEvent;
import java.util.Collection;
import java.util.UUID;
import org.bukkit.entity.LivingEntity;
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.PotionEffectExpireEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class BardRestorer
implements Listener
{
private final Table<UUID, PotionEffectType, PotionEffect> restores;
public BardRestorer(Core plugin)
{
this.restores = HashBasedTable.create();
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPvpClassUnequip(PvpClassUnequipEvent event)
{
this.restores.rowKeySet().remove(event.getPlayer().getUniqueId());
}
public void setRestoreEffect(Player player, PotionEffect effect) {
boolean shouldCancel = true;
Collection<PotionEffect> activeList = player.getActivePotionEffects();
for (PotionEffect active : activeList) {
if (!active.getType().equals(effect.getType()))
continue;
// If the current potion effect has a higher amplifier, ignore this one.
if (effect.getAmplifier() < active.getAmplifier()) {
return;
} else if (effect.getAmplifier() == active.getAmplifier()) {
// If the current potion effect has a longer duration, ignore this one.
if (effect.getDuration() < active.getDuration()) {
return;
}
}
restores.put(player.getUniqueId(), active.getType(), active);
shouldCancel = false;
break;
}
// Cancel the previous restore.
//NEED FIXING
player.addPotionEffect(effect, true);
if (shouldCancel && effect.getDuration() > BardClass.HELD_EFFECT_DURATION_TICKS && effect.getDuration() < BardClass.DEFAULT_MAX_DURATION) {
restores.remove(player.getUniqueId(), effect.getType());
}
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPotionEffectExpire(PotionEffectExpireEvent event)
{
LivingEntity livingEntity = event.getEntity();
if ((livingEntity instanceof Player))
{
Player player = (Player)livingEntity;
PotionEffect previous = (PotionEffect)this.restores.remove(player.getUniqueId(), event.getEffect().getType());
if (previous != null)
{
event.setCancelled(true);
player.addPotionEffect(previous, true);
}
}
}
}

View File

@ -0,0 +1,35 @@
package club.curahq.core.classes.event;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import club.curahq.core.classes.PvpClass;
public class PvpClassEquipEvent
extends PlayerEvent
{
public PvpClassEquipEvent(Player player, PvpClass pvpClass)
{
super(player);
this.pvpClass = pvpClass;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public PvpClass getPvpClass()
{
return this.pvpClass;
}
public HandlerList getHandlers()
{
return handlers;
}
private static final HandlerList handlers = new HandlerList();
private final PvpClass pvpClass;
}

View File

@ -0,0 +1,35 @@
package club.curahq.core.classes.event;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
import club.curahq.core.classes.PvpClass;
public class PvpClassUnequipEvent
extends PlayerEvent
{
public PvpClassUnequipEvent(Player player, PvpClass pvpClass)
{
super(player);
this.pvpClass = pvpClass;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public PvpClass getPvpClass()
{
return this.pvpClass;
}
public HandlerList getHandlers()
{
return handlers;
}
private static final HandlerList handlers = new HandlerList();
private final PvpClass pvpClass;
}

View File

@ -0,0 +1,233 @@
package club.curahq.core.classes.type;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import club.curahq.core.Core;
import club.curahq.core.classes.PvpClass;
import club.curahq.core.classes.event.PvpClassUnequipEvent;
import club.curahq.core.util.core.Cooldowns;
public class AssassinClass
extends PvpClass
implements Listener
{
private final Core plugin;
public HashMap<String, Integer> firstAssassinEffects;
public AssassinClass(Core plugin)
{
super("Reaper", TimeUnit.SECONDS.toMillis(3L));
this.firstAssassinEffects = new HashMap<String, Integer>();
this.plugin = plugin;
this.passiveEffects.add(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0));
this.passiveEffects.add(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1));
this.passiveEffects.add(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1));
}
@SuppressWarnings({ "deprecation", "unlikely-arg-type" })
@EventHandler
public void onUnEquip(PvpClassUnequipEvent e)
{
Player p = e.getPlayer();
Player[] arrayOfPlayer;
int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
for (int i = 0; i < j; i++)
{
Player on = arrayOfPlayer[i];
if ((!on.canSee(p)) && (!on.hasPermission("base.command.vanish"))) {
on.showPlayer(p);
}
}
this.firstAssassinEffects.remove(p);
}
@EventHandler
public void onDamageSelf(EntityDamageEvent e)
{
if ((e.getEntity() instanceof Player))
{
Player p = (Player)e.getEntity();
if ((this.plugin.getPvpClassManager().getEquippedClass(p) == null) || (!this.plugin.getPvpClassManager().getEquippedClass(p).equals(this))) {
return;
}
if ((this.firstAssassinEffects.containsKey(p.getName())) && (((Integer)this.firstAssassinEffects.get(p.getName())).intValue() == 1)) {
for (Entity entity : p.getNearbyEntities(20.0D, 20.0D, 20.0D)) {
if ((entity instanceof Player))
{
Player players = (Player)entity;
players.sendMessage(ChatColor.YELLOW + "A reaper has taken damage in stealth mode near you: " + ChatColor.GRAY + ChatColor.ITALIC + "(20 x 20)");
}
}
}
}
}
@EventHandler
public void onHitOtherPlayers(EntityDamageByEntityEvent e)
{
if (((e.getDamager() instanceof Player)) && ((e.getEntity() instanceof Player)))
{
Player p = (Player)e.getDamager();
e.getEntity();
if ((this.firstAssassinEffects.containsKey(p.getName())) && (((Integer)this.firstAssassinEffects.get(p.getName())).intValue() == 1)) {
afterFiveSeconds(p, true);
}
}
}
@SuppressWarnings("deprecation")
@EventHandler
public void onClickItem(PlayerInteractEvent e)
{
final Player p = e.getPlayer();
if ((e.getAction() == Action.RIGHT_CLICK_BLOCK) || (e.getAction() == Action.RIGHT_CLICK_AIR))
{
PvpClass equipped = this.plugin.getPvpClassManager().getEquippedClass(p);
if ((equipped == null) || (!equipped.equals(this))) {
return;
}
if (p.getItemInHand().getType() == Material.QUARTZ)
{
if (Cooldowns.isOnCooldown("Assassin_item_cooldown", p))
{
p.sendMessage(ChatColor.RED + "You still have an " + ChatColor.GREEN + ChatColor.BOLD + "Reaper" + ChatColor.RED + " cooldown for another " + Core.getRemaining(Cooldowns.getCooldownForPlayerLong("Assassin_item_cooldown", p), true) + ChatColor.RED + '.');
return;
}
if (p.getItemInHand().getAmount() == 1) {
p.getInventory().remove(p.getItemInHand());
}
p.getItemInHand().setAmount(p.getItemInHand().getAmount() - 1);
p.sendMessage(ChatColor.YELLOW + "You are now in " + ChatColor.GRAY + "Stealth" + ChatColor.YELLOW + " Mode");
Player[] arrayOfPlayer;
int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
for (int i = 0; i < j; i++)
{
Player on = arrayOfPlayer[i];
on.playEffect(p.getLocation().add(0.5D, 2.0D, 0.5D), Effect.ENDER_SIGNAL, 5);
on.playEffect(p.getLocation().add(0.5D, 1.5D, 0.5D), Effect.ENDER_SIGNAL, 5);
on.playEffect(p.getLocation().add(0.5D, 1.0D, 0.5D), Effect.ENDER_SIGNAL, 5);
on.playSound(p.getLocation(), Sound.ENDERMAN_TELEPORT, 1.0F, 1.0F);
if (!on.hasPermission("base.command.vanish")) {
on.hidePlayer(p);
}
}
Cooldowns.addCooldown("Assassin_item_cooldown", p, 60);
p.removePotionEffect(PotionEffectType.SPEED);
this.firstAssassinEffects.put(p.getName(), Integer.valueOf(1));
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 100, 4), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 100, 0), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 100, 0), true);
new BukkitRunnable()
{
public void run()
{
if ((AssassinClass.this.isApplicableFor(p)) && (AssassinClass.this.firstAssassinEffects.containsKey(p.getName())) && (((Integer)AssassinClass.this.firstAssassinEffects.get(p.getName())).intValue() == 1)) {
AssassinClass.this.afterFiveSeconds(p, false);
}
}
}.runTaskLater(this.plugin, 100L);
}
}
}
@SuppressWarnings("deprecation")
public void afterFiveSeconds(final Player p, boolean force)
{
if ((this.firstAssassinEffects.containsKey(p.getName())) && (isApplicableFor(p)))
{
Player[] arrayOfPlayer;
int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
for (int i = 0; i < j; i++)
{
Player on = arrayOfPlayer[i];
if ((!on.canSee(p)) && (!on.hasPermission("base.command.vanish"))) {
on.showPlayer(p);
}
on.playEffect(p.getLocation().add(0.0D, 2.0D, 0.0D), Effect.ENDER_SIGNAL, 3);
on.playEffect(p.getLocation().add(0.0D, 1.5D, 0.0D), Effect.ENDER_SIGNAL, 3);
on.playEffect(p.getLocation().add(0.0D, 1.0D, 0.0D), Effect.ENDER_SIGNAL, 3);
on.playEffect(p.getLocation().add(0.0D, 2.0D, 0.0D), Effect.BLAZE_SHOOT, 5);
on.playEffect(p.getLocation().add(0.0D, 1.5D, 0.0D), Effect.BLAZE_SHOOT, 5);
on.playEffect(p.getLocation().add(0.0D, 1.0D, 0.0D), Effect.BLAZE_SHOOT, 5);
}
new BukkitRunnable()
{
public void run()
{
if ((AssassinClass.this.firstAssassinEffects.containsKey(p.getName())) && (((Integer)AssassinClass.this.firstAssassinEffects.get(p.getName())).intValue() == 2))
{
AssassinClass.this.firstAssassinEffects.remove(p.getName());
p.sendMessage(ChatColor.YELLOW + "You are now in " + ChatColor.GREEN + "Normal" + ChatColor.YELLOW + " Mode");
if (AssassinClass.this.isApplicableFor(p))
{
p.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 1), true);
}
}
}
}.runTaskLater(this.plugin, 100L);
if (force)
{
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 0), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 120, 1), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 120, 0), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 120, 1), true);
p.removePotionEffect(PotionEffectType.INVISIBILITY);
this.firstAssassinEffects.remove(p.getName());
this.firstAssassinEffects.put(p.getName(), Integer.valueOf(2));
p.sendMessage(ChatColor.YELLOW + "You have been forced into " + ChatColor.RED + "Power" + ChatColor.YELLOW + " Mode" + ChatColor.GRAY.toString() + ChatColor.ITALIC + " (5 Seconds)");
return;
}
this.firstAssassinEffects.remove(p.getName());
this.firstAssassinEffects.put(p.getName(), Integer.valueOf(2));
p.sendMessage(ChatColor.YELLOW + "You are now in " + ChatColor.RED + "Power" + ChatColor.YELLOW + " Mode" + ChatColor.GRAY.toString() + ChatColor.ITALIC + " (5 Seconds)");
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 0), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 120, 1), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 120, 0), true);
p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 120, 1), true);
p.removePotionEffect(PotionEffectType.INVISIBILITY);
}
}
public boolean isApplicableFor(Player player)
{
PlayerInventory playerInventory = player.getInventory();
ItemStack helmet = playerInventory.getHelmet();
if ((helmet == null) || (helmet.getType() != Material.CHAINMAIL_HELMET)) {
return false;
}
ItemStack chestplate = playerInventory.getChestplate();
if ((chestplate == null) || (chestplate.getType() != Material.CHAINMAIL_CHESTPLATE)) {
return false;
}
ItemStack leggings = playerInventory.getLeggings();
if ((leggings == null) || (leggings.getType() != Material.CHAINMAIL_LEGGINGS)) {
return false;
}
ItemStack boots = playerInventory.getBoots();
return (boots != null) && (boots.getType() == Material.CHAINMAIL_BOOTS);
}
}

View File

@ -0,0 +1,138 @@
package club.curahq.core.classes.type;
import java.util.concurrent.TimeUnit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.entity.Entity;
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.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import club.curahq.core.Core;
import club.curahq.core.classes.PvpClass;
import club.curahq.core.classes.event.PvpClassEquipEvent;
import club.curahq.core.util.BukkitUtils;
public class MinerClass
extends PvpClass
implements Listener
{
public MinerClass(Core plugin)
{
super("Miner", TimeUnit.SECONDS.toMillis(10L));
this.plugin = plugin;
this.passiveEffects.add(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, Integer.MAX_VALUE, 0));
this.passiveEffects.add(new PotionEffect(PotionEffectType.FAST_DIGGING, Integer.MAX_VALUE, 1));
this.passiveEffects.add(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0));
}
private void removeInvisibilitySafely(Player player)
{
for (PotionEffect active : player.getActivePotionEffects()) {
if ((active.getType().equals(PotionEffectType.INVISIBILITY)) && (active.getDuration() > DEFAULT_MAX_DURATION))
{
player.sendMessage(ChatColor.LIGHT_PURPLE + getName() + ChatColor.YELLOW + " invisibility and haste disabled.");
player.removePotionEffect(active.getType());
break;
}
}
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPlayerDamage(EntityDamageByEntityEvent event)
{
Entity entity = event.getEntity();
if (((entity instanceof Player)) && (BukkitUtils.getFinalAttacker(event, false) != null))
{
Player player = (Player)entity;
if (this.plugin.getPvpClassManager().hasClassEquipped(player, this)) {
removeInvisibilitySafely(player);
}
}
}
public void onUnequip(Player player)
{
super.onUnequip(player);
removeInvisibilitySafely(player);
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event)
{
conformMinerInvisibility(event.getPlayer(), event.getFrom(), event.getTo());
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPlayerTeleport(PlayerTeleportEvent event)
{
conformMinerInvisibility(event.getPlayer(), event.getFrom(), event.getTo());
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onClassEquip(PvpClassEquipEvent event)
{
Player player = event.getPlayer();
if (event.getPvpClass().equals(this))
{
player.addPotionEffect(HEIGHT_INVISIBILITY, true);
player.sendMessage(ChatColor.LIGHT_PURPLE + getName() + ChatColor.YELLOW + " invisibility and haste enabled.");
if (player.getStatistic(Statistic.MINE_BLOCK, Material.DIAMOND_ORE) > 30) {
this.passiveEffects.add(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 0));
}
}
}
private void conformMinerInvisibility(Player player, Location from, Location to)
{
int fromY = from.getBlockY();
int toY = to.getBlockY();
if ((fromY != toY) && (this.plugin.getPvpClassManager().hasClassEquipped(player, this)))
{
boolean isInvisible = player.hasPotionEffect(PotionEffectType.INVISIBILITY);
if (toY > 30)
{
if ((fromY <= 30) && (isInvisible)) {
removeInvisibilitySafely(player);
}
}
else if (!isInvisible)
{
player.addPotionEffect(HEIGHT_INVISIBILITY, true);
player.sendMessage(ChatColor.LIGHT_PURPLE + getName() + ChatColor.YELLOW + " invisibility and haste enabled.");
}
}
}
public boolean isApplicableFor(Player player)
{
PlayerInventory playerInventory = player.getInventory();
ItemStack helmet = playerInventory.getHelmet();
if ((helmet == null) || (helmet.getType() != Material.IRON_HELMET) || (!helmet.getEnchantments().isEmpty())) {
return false;
}
ItemStack chestplate = playerInventory.getChestplate();
if ((chestplate == null) || (chestplate.getType() != Material.IRON_CHESTPLATE) || (!chestplate.getEnchantments().isEmpty())) {
return false;
}
ItemStack leggings = playerInventory.getLeggings();
if ((leggings == null) || (leggings.getType() != Material.IRON_LEGGINGS) || (!leggings.getEnchantments().isEmpty())) {
return false;
}
ItemStack boots = playerInventory.getBoots();
return (boots != null) && (boots.getType() == Material.IRON_BOOTS) && (boots.getEnchantments().isEmpty());
}
private static final PotionEffect HEIGHT_INVISIBILITY = new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0);
private final Core plugin;
}

View File

@ -0,0 +1,124 @@
package club.curahq.core.classes.type;
import java.util.concurrent.TimeUnit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Entity;
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.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import club.curahq.core.Core;
import club.curahq.core.classes.PvpClass;
import club.curahq.core.util.core.ConfigUtil;
import club.curahq.core.util.core.Cooldowns;
public class RogueClass
extends PvpClass
implements Listener
{
private final Core plugin;
public RogueClass(Core plugin)
{
super("Rogue", TimeUnit.SECONDS.toMillis(1L));
this.plugin = plugin;
this.passiveEffects.add(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, Integer.MAX_VALUE, 1));
this.passiveEffects.add(new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, 1));
this.passiveEffects.add(new PotionEffect(PotionEffectType.REGENERATION, Integer.MAX_VALUE, 0));
this.passiveEffects.add(new PotionEffect(PotionEffectType.SPEED, Integer.MAX_VALUE, 2));
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
{
Entity entity = event.getEntity();
Entity damager = event.getDamager();
if (((entity instanceof Player)) && ((damager instanceof Player)))
{
Player attacker = (Player)damager;
PvpClass equipped = this.plugin.getPvpClassManager().getEquippedClass(attacker);
if ((equipped != null) && (equipped.equals(this)))
{
ItemStack stack = attacker.getItemInHand();
if ((stack != null) && (stack.getType() == Material.GOLD_SWORD) && (stack.getEnchantments().isEmpty()))
{
Player player = (Player)entity;
if (player.isDead()) {
return;
}
if (Cooldowns.isOnCooldown("rogue_cooldown", attacker)) {
attacker.sendMessage(ChatColor.RED + "You are on cooldown for another " + Cooldowns.getCooldownForPlayerInt("rogue_cooldown", attacker) + "s.");
return;
}
if (rpGetPlayerDirection(attacker).equals(rpGetPlayerDirection(player))) {
player.sendMessage(ConfigUtil.ENEMY_COLOUR + attacker.getName() + ChatColor.YELLOW + " has backstabbed you.");
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);
attacker.sendMessage(ChatColor.YELLOW + "You have backstabbed " + ConfigUtil.ENEMY_COLOUR + player.getName() + ChatColor.YELLOW + '.');
attacker.setItemInHand(new ItemStack(Material.AIR, 1));
attacker.playSound(player.getLocation(), Sound.ITEM_BREAK, 1.0F, 1.0F);
attacker.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, Integer.valueOf(150), 1));
double hp = ((CraftPlayer)player).getHealth();
if (hp == 0) {
return;
}
double amount = hp - 6.0;
player.setHealth(amount);
Cooldowns.addCooldown("rogue_cooldown", attacker, 2);
}
}
}
}
}
public String rpGetPlayerDirection(Player playerSelf)
{
String dir = "";
float y = playerSelf.getLocation().getYaw();
if (y < 0.0F) {
y += 360.0F;
}
y %= 360.0F;
int i = (int)((y + 8.0F) / 22.5D);
if ((i == 0) || (i == 1) || (i == 15)) {
dir = "west";
} else if ((i == 4) || (i == 5) || (i == 6) || (i == 2) || (i == 3)) {
dir = "north";
} else if ((i == 8) || (i == 7) || (i == 9)) {
dir = "east";
} else if ((i == 11) || (i == 10) || (i == 12) || (i == 13) || (i == 14)) {
dir = "south";
} else {
dir = "west";
}
return dir;
}
public boolean isApplicableFor(Player player)
{
PlayerInventory playerInventory = player.getInventory();
ItemStack helmet = playerInventory.getHelmet();
if ((helmet == null) || (helmet.getType() != Material.CHAINMAIL_HELMET)) {
return false;
}
ItemStack chestplate = playerInventory.getChestplate();
if ((chestplate == null) || (chestplate.getType() != Material.CHAINMAIL_CHESTPLATE)) {
return false;
}
ItemStack leggings = playerInventory.getLeggings();
if ((leggings == null) || (leggings.getType() != Material.CHAINMAIL_LEGGINGS)) {
return false;
}
ItemStack boots = playerInventory.getBoots();
return (boots != null) && (boots.getType() == Material.CHAINMAIL_BOOTS);
}
}

View File

@ -0,0 +1,15 @@
package club.curahq.core.combatlog;
import org.bukkit.scheduler.BukkitTask;
public class CombatLogEntry
{
public final LoggerEntity loggerEntity;
public final BukkitTask task;
public CombatLogEntry(LoggerEntity loggerEntity, BukkitTask task)
{
this.loggerEntity = loggerEntity;
this.task = task;
}
}

View File

@ -0,0 +1,162 @@
package club.curahq.core.combatlog;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
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.EntityInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.scheduler.BukkitRunnable;
import org.spigotmc.event.player.PlayerSpawnLocationEvent;
import club.curahq.core.Core;
public class CombatLogListener
implements Listener
{
public CombatLogListener(Core plugin)
{
this.plugin = plugin;
}
public static void safelyDisconnect(Player player, String reason)
{
if (SAFE_DISCONNECTS.add(player.getUniqueId())) {
player.kickPlayer(reason);
}
}
public static void removeCombatLoggers()
{
Iterator<CombatLogEntry> iterator = LOGGERS.values().iterator();
while (iterator.hasNext())
{
CombatLogEntry entry = (CombatLogEntry)iterator.next();
entry.task.cancel();
entry.loggerEntity.getBukkitEntity().remove();
iterator.remove();
}
SAFE_DISCONNECTS.clear();
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onPlayerQuitSafe(PlayerQuitEvent event)
{
SAFE_DISCONNECTS.remove(event.getPlayer().getUniqueId());
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGH)
public void onLoggerInteract(EntityInteractEvent event)
{
Collection<CombatLogEntry> entries = LOGGERS.values();
for (CombatLogEntry entry : entries) {
if (entry.loggerEntity.getBukkitEntity().equals(event.getEntity()))
{
event.setCancelled(true);
break;
}
}
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.MONITOR)
public void onLoggerDeath(LoggerDeathEvent event)
{
CombatLogEntry entry = (CombatLogEntry)LOGGERS.remove(event.getLoggerEntity().getPlayerUUID());
if (entry != null) {
entry.task.cancel();
}
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.HIGHEST)
public void onPlayerSpawnLocation(PlayerSpawnLocationEvent event)
{
CombatLogEntry combatLogEntry = (CombatLogEntry)LOGGERS.remove(event.getPlayer().getUniqueId());
if (combatLogEntry != null)
{
CraftLivingEntity loggerEntity = combatLogEntry.loggerEntity.getBukkitEntity();
Player player = event.getPlayer();
event.setSpawnLocation(loggerEntity.getLocation());
player.setFallDistance(loggerEntity.getFallDistance());
player.setTicksLived(loggerEntity.getTicksLived());
player.setRemainingAir(loggerEntity.getRemainingAir());
loggerEntity.remove();
combatLogEntry.task.cancel();
}
}
@EventHandler(ignoreCancelled=true, priority=EventPriority.NORMAL)
public void onPlayerQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
PlayerInventory inventory = player.getInventory();
if ((player.getGameMode() != GameMode.CREATIVE) && (!player.isDead()) && (!SAFE_DISCONNECTS.contains(uuid)))
{
if ((this.plugin.getTimerManager().invincibilityTimer.getRemaining(uuid) > 0L)) {
return;
}
if (this.plugin.getTimerManager().teleportTimer.getNearbyEnemies(player, 64) <= 0) {
return;
}
Location location = player.getLocation();
if (this.plugin.getFactionManager().getFactionAt(location).isSafezone()) {
return;
}
if (LOGGERS.containsKey(player.getUniqueId())) {
return;
}
World world = location.getWorld();
LoggerEntity loggerEntity = new LoggerEntity(world, location, player);
LoggerSpawnEvent calledEvent = new LoggerSpawnEvent(loggerEntity);
Bukkit.getPluginManager().callEvent(calledEvent);
LOGGERS.put(uuid, new CombatLogEntry(loggerEntity, new LoggerRemovable(uuid, loggerEntity).runTaskLater(this.plugin, 600L)));
CraftEntity craftEntity = loggerEntity.getBukkitEntity();
if (craftEntity != null)
{
CraftLivingEntity craftLivingEntity = (CraftLivingEntity)craftEntity;
EntityEquipment entityEquipment = craftLivingEntity.getEquipment();
entityEquipment.setItemInHand(inventory.getItemInHand());
entityEquipment.setArmorContents(inventory.getArmorContents());
}
}
}
private static final Set<UUID> SAFE_DISCONNECTS = new HashSet<UUID>();
private static final Map<UUID, CombatLogEntry> LOGGERS = new HashMap<UUID, CombatLogEntry>();
private final Core plugin;
private static class LoggerRemovable
extends BukkitRunnable
{
private final UUID uuid;
private final LoggerEntity loggerEntity;
public LoggerRemovable(UUID uuid, LoggerEntity loggerEntity)
{
this.uuid = uuid;
this.loggerEntity = loggerEntity;
}
public void run()
{
if (CombatLogListener.LOGGERS.remove(this.uuid) != null) {
this.loggerEntity.dead = true;
}
}
}
}

View File

@ -0,0 +1,60 @@
package club.curahq.core.combatlog;
import java.lang.reflect.Field;
import java.util.Map;
import net.minecraft.server.v1_7_R4.EntityTypes;
public class CustomEntityRegistration
{
public static void registerCustomEntities()
{
try
{
registerCustomEntity(LoggerEntity.class, "CraftSkeleton", 51);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public static void registerCustomEntity(Class<LoggerEntity> entityClass, String name, int id)
{
setFieldPrivateStaticMap("d", entityClass, name);
setFieldPrivateStaticMap("f", entityClass, Integer.valueOf(id));
}
public static void unregisterCustomEntities() {}
@SuppressWarnings("unchecked")
public static void setFieldPrivateStaticMap(String fieldName, Object key, Object value)
{
try
{
Field field = EntityTypes.class.getDeclaredField(fieldName);
field.setAccessible(true);
Map<Object, Object> map = (Map<Object, Object>)field.get(null);
map.put(key, value);
field.set(null, map);
}
catch (NoSuchFieldException|SecurityException|IllegalArgumentException|IllegalAccessException ex3)
{
ex3.printStackTrace();
}
}
public static void setField(String fieldName, Object key, Object value)
{
try
{
Field field = key.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
field.set(key, value);
field.setAccessible(false);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}

View File

@ -0,0 +1,30 @@
package club.curahq.core.combatlog;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class LoggerDeathEvent extends Event {
private static final HandlerList handlers;
static {
handlers = new HandlerList();
}
private final LoggerEntity loggerEntity;
public LoggerDeathEvent(final LoggerEntity loggerEntity) {
this.loggerEntity = loggerEntity;
}
public static HandlerList getHandlerList() {
return LoggerDeathEvent.handlers;
}
public LoggerEntity getLoggerEntity() {
return this.loggerEntity;
}
public HandlerList getHandlers() {
return LoggerDeathEvent.handlers;
}
}

View File

@ -0,0 +1,199 @@
package club.curahq.core.combatlog;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.CraftServer;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_7_R4.event.CraftEventFactory;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import com.google.common.base.Function;
import net.minecraft.server.v1_7_R4.DamageSource;
import net.minecraft.server.v1_7_R4.Entity;
import net.minecraft.server.v1_7_R4.EntityAgeable;
import net.minecraft.server.v1_7_R4.EntityHuman;
import net.minecraft.server.v1_7_R4.EntityPlayer;
import net.minecraft.server.v1_7_R4.EntityVillager;
import net.minecraft.server.v1_7_R4.PlayerInteractManager;
import net.minecraft.server.v1_7_R4.WorldServer;
import net.minecraft.util.com.mojang.authlib.GameProfile;
public class LoggerEntity extends EntityVillager {
private static final Function<Double, Double> DAMAGE_FUNCTION;
static {
DAMAGE_FUNCTION = (f1 -> 0.0);
}
private final UUID playerUUID;
public LoggerEntity(final World world, final Location location, final Player player) {
super(((CraftWorld) world).getHandle());
this.lastDamager = ((CraftPlayer) player).getHandle().lastDamager;
final double x = location.getX();
final double y = location.getY();
final double z = location.getZ();
final String playerName = player.getName();
final boolean hasSpawned = ((CraftWorld) world).getHandle().addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + "Combat Logger for [" + playerName + "] " + (hasSpawned ? (ChatColor.GREEN + "successfully spawned") : (ChatColor.RED + "failed to spawn")) + ChatColor.GOLD + " at (" + String.format("%.1f", x) + ", " + String.format("%.1f", y) + ", " + String.format("%.1f", z) + ')');
this.playerUUID = player.getUniqueId();
if(hasSpawned) {
this.setCustomName(playerName);
this.setCustomNameVisible(true);
this.setPositionRotation(x, y, z, location.getYaw(), location.getPitch());
this.setCustomNameVisible(true);
}
}
private static PlayerNmsResult getResult(final World world, final UUID playerUUID) {
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(playerUUID);
if(offlinePlayer.hasPlayedBefore()) {
final WorldServer worldServer = ((CraftWorld) world).getHandle();
final EntityPlayer entityPlayer = new EntityPlayer(((CraftServer) Bukkit.getServer()).getServer(), worldServer, new GameProfile(playerUUID, offlinePlayer.getName()), new PlayerInteractManager((net.minecraft.server.v1_7_R4.World) worldServer));
final Player player = (Player) entityPlayer.getBukkitEntity();
if(player != null) {
player.loadData();
return new PlayerNmsResult(player, entityPlayer);
}
}
return null;
}
public UUID getPlayerUUID() {
return this.playerUUID;
}
public void move(final double d0, final double d1, final double d2) {
}
public void b(final int i) {
}
public void dropDeathLoot(final boolean flag, final int i) {
}
public Entity findTarget() {
return null;
}
public boolean damageEntity(final DamageSource damageSource, final float amount) {
final PlayerNmsResult nmsResult = getResult((World) this.world.getWorld(), this.playerUUID);
if(nmsResult == null) {
return true;
}
final EntityPlayer entityPlayer = nmsResult.entityPlayer;
if(entityPlayer != null) {
entityPlayer.setPosition(this.locX, this.locY, this.locZ);
final EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent((Entity) entityPlayer, damageSource, (double) amount, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, (Function<Double, Double>) LoggerEntity.DAMAGE_FUNCTION, (Function<Double, Double>) LoggerEntity.DAMAGE_FUNCTION, (Function<Double, Double>) LoggerEntity.DAMAGE_FUNCTION, (Function<Double, Double>) LoggerEntity.DAMAGE_FUNCTION, (Function<Double, Double>) LoggerEntity.DAMAGE_FUNCTION, (Function<Double, Double>) LoggerEntity.DAMAGE_FUNCTION);
if(event.isCancelled()) {
return false;
}
}
return super.damageEntity(damageSource, amount);
}
public EntityAgeable createChild(EntityAgeable entityAgeable) {
return null;
}
public boolean a(final EntityHuman entityHuman) {
return false;
}
public void h() {
super.h();
}
public void collide(final Entity entity) {
}
public void die(final DamageSource damageSource) {
final PlayerNmsResult playerNmsResult = getResult((World) this.world.getWorld(), this.playerUUID);
if(playerNmsResult == null) {
return;
}
final Player player = playerNmsResult.player;
final PlayerInventory inventory = player.getInventory();
final boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory");
final List<ItemStack> drops = new ArrayList<>();
if(!keepInventory) {
ItemStack[] deathMessage = inventory.getContents();
int entityPlayer = deathMessage.length;
int event;
ItemStack loggerDeathEvent;
for(event = 0; event < entityPlayer; ++event) {
loggerDeathEvent = deathMessage[event];
if(loggerDeathEvent != null && loggerDeathEvent.getType() != Material.AIR) {
drops.add(loggerDeathEvent);
}
}
deathMessage = inventory.getArmorContents();
entityPlayer = deathMessage.length;
for(event = 0; event < entityPlayer; ++event) {
loggerDeathEvent = deathMessage[event];
if(loggerDeathEvent != null && loggerDeathEvent.getType() != Material.AIR) {
drops.add(loggerDeathEvent);
}
}
}
String deathMessage = ChatColor.GRAY + "(Combat-Logger)" + ChatColor.YELLOW + this.combatTracker.b().c();
final EntityPlayer entityPlayer = playerNmsResult.entityPlayer;
entityPlayer.combatTracker = this.combatTracker;
if(Bukkit.getPlayer(entityPlayer.getName()) != null){
Bukkit.getPlayer(entityPlayer.getUniqueID()).getInventory().clear();
Bukkit.getPlayer(entityPlayer.getUniqueID()).kickPlayer("error");
}
final PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(entityPlayer, drops, deathMessage, keepInventory);
deathMessage = event.getDeathMessage();
if(deathMessage != null && !deathMessage.isEmpty()) {
Bukkit.broadcastMessage(deathMessage);
}
super.die(damageSource);
final LoggerDeathEvent loggerDeathEvent = new LoggerDeathEvent(this);
Bukkit.getPluginManager().callEvent(loggerDeathEvent);
if(!event.getKeepInventory()) {
inventory.clear();
inventory.setArmorContents(new ItemStack[inventory.getArmorContents().length]);
}
entityPlayer.setLocation(this.locX, this.locY, this.locZ, this.yaw, this.pitch);
entityPlayer.setHealth(0.0f);
player.saveData();
}
public CraftLivingEntity getBukkitEntity() {
return (CraftLivingEntity) super.getBukkitEntity();
}
public static final class PlayerNmsResult {
public final Player player;
public final EntityPlayer entityPlayer;
public PlayerNmsResult(final Player player, final EntityPlayer entityPlayer) {
this.player = player;
this.entityPlayer = entityPlayer;
}
}
}

View File

@ -0,0 +1,31 @@
package club.curahq.core.combatlog;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class LoggerSpawnEvent
extends Event
{
public LoggerSpawnEvent(LoggerEntity loggerEntity)
{
this.loggerEntity = loggerEntity;
}
public static HandlerList getHandlerList()
{
return handlers;
}
public LoggerEntity getLoggerEntity()
{
return this.loggerEntity;
}
public HandlerList getHandlers()
{
return handlers;
}
private static final HandlerList handlers = new HandlerList();
private final LoggerEntity loggerEntity;
}

View File

@ -0,0 +1,24 @@
package club.curahq.core.commands;
public class MessageEvent
{
public static String format(String message)
{
message = message.replaceAll("&", "§");
return message;
}
public static String toString(String[] arguments, int start)
{
String returnString = "";
for (int count = start; count < arguments.length; count++) {
if (count == start) {
returnString = arguments[count];
} else {
returnString = returnString + " " + arguments[count];
}
}
return returnString;
}
}

View File

@ -0,0 +1,37 @@
package club.curahq.core.commands;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class PlayerFreezeEvent extends PlayerEvent implements Cancellable {
public PlayerFreezeEvent(Player player, boolean frozen) {
super(player);
this.frozen = frozen;
}
public static HandlerList getHandlerList() {
return handlers;
}
public boolean isFrozen() {
return this.frozen;
}
public boolean isCancelled() {
return this.cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
public HandlerList getHandlers() {
return handlers;
}
private static final HandlerList handlers = new HandlerList();
private final boolean frozen;
private boolean cancelled;
}

View File

@ -0,0 +1,44 @@
package club.curahq.core.commands;
import java.util.Collection;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.player.PlayerEvent;
public class PlayerVanishEvent extends PlayerEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final boolean vanished;
private final Collection<Player> viewers;
private boolean cancelled;
public PlayerVanishEvent(Player player, Collection<Player> viewers, boolean vanished) {
super(player);
this.viewers = viewers;
this.vanished = vanished;
}
public static HandlerList getHandlerList() {
return handlers;
}
public Collection<Player> getViewers() {
return this.viewers;
}
public boolean isVanished() {
return this.vanished;
}
public boolean isCancelled() {
return this.cancelled;
}
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
public HandlerList getHandlers() {
return handlers;
}
}

View File

@ -0,0 +1,87 @@
package club.curahq.core.commands;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
import club.curahq.core.Core;
import club.curahq.core.util.TimeUtils;
import net.minecraft.util.org.apache.commons.lang3.text.WordUtils;
public class StaffInventory {
private final static Core plugin = Core.getPlugin();
public static String translate(String input) {
return ChatColor.translateAlternateColorCodes('&', input);
}
public static List<String> translateFromArray(List<String> text) {
List<String> messages = new ArrayList<String>();
for (String string : text) {
messages.add(translate(string));
}
return messages;
}
public static void inspector(Player player, Player target) {
Inventory inventory = Bukkit.getServer().createInventory(null, 45, ChatColor.translateAlternateColorCodes('&', "&eInspecting: " + target.getName()));
Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
public void run() {
PlayerInventory playerInventory = target.getInventory();
ItemStack cookedBeef = new ItemStack(Material.COOKED_BEEF, target.getFoodLevel());
ItemMeta cookedBeefMeta = cookedBeef.getItemMeta();
cookedBeefMeta.setDisplayName(translate("&aHunger"));
cookedBeef.setItemMeta(cookedBeefMeta);
ItemStack ip = new ItemStack(Material.BED);
ItemMeta ipMeta = ip.getItemMeta();
ipMeta.setDisplayName(ChatColor.GREEN + (player.hasPermission("core.seeip") ? target.getAddress().getAddress().getHostAddress() : "IP HIDDEN"));
ip.setItemMeta(ipMeta);
ItemStack brewingStand = new ItemStack(Material.BREWING_STAND_ITEM, target.getPlayer().getActivePotionEffects().size());
ItemMeta brewingStandMeta = brewingStand.getItemMeta();
brewingStandMeta.setDisplayName(translate("&aActive Effects"));
ArrayList<String> brewingStandLore = new ArrayList<String>();
for (PotionEffect potionEffect : target.getPlayer().getActivePotionEffects()) {
String effectName = potionEffect.getType().getName();
int effectLevel = potionEffect.getAmplifier();
effectLevel++;
brewingStandLore.add(translate("&e" + WordUtils.capitalizeFully(effectName).replace("_", " ") + " " + effectLevel + "&7: &c" + TimeUtils.IntegerCountdown.setFormat(Integer.valueOf(potionEffect.getDuration() / 20))));
}
brewingStandMeta.setLore(brewingStandLore);
brewingStand.setItemMeta(brewingStandMeta);
ItemStack compass = new ItemStack(Material.COMPASS, 1);
ItemMeta compassMeta = compass.getItemMeta();
compassMeta.setDisplayName(translate("&aPlayer Location"));
compassMeta.setLore(translateFromArray(Arrays.asList(new String[] { "&eWorld&7: &a" + player.getWorld().getName(),"&eCoords", " &eX&7: &c" + target.getLocation().getBlockX(), " &eY&7: &c" + target.getLocation().getBlockY(), " &eZ&7: &c" + target.getLocation().getBlockZ() })));
compass.setItemMeta(compassMeta);
inventory.setContents(playerInventory.getContents());
inventory.setItem(36, playerInventory.getHelmet());
inventory.setItem(37, playerInventory.getChestplate());
inventory.setItem(38, playerInventory.getLeggings());
inventory.setItem(39, playerInventory.getBoots());
inventory.setItem(40, playerInventory.getItemInHand());
inventory.setItem(41, cookedBeef);
inventory.setItem(42, brewingStand);
inventory.setItem(43, ip);
inventory.setItem(44, compass);
}
}, 0, 5);
player.openInventory(inventory);
}
}

View File

@ -0,0 +1,65 @@
package club.curahq.core.commands;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import club.curahq.core.commands.staff.StaffModeCommand;
public class StaffItems {
@SuppressWarnings("deprecation")
public static void modItems(Player p) {
Inventory inv = p.getInventory();
inv.clear();
ItemStack compass = new ItemStack(Material.COMPASS);
ItemStack book = new ItemStack(Material.BOOK);
ItemStack tp = new ItemStack(397, 1, (short) 3);
ItemStack vanish = new ItemStack(351, 1, (short) 10);
ItemStack carpet = new ItemStack(171, 1, (short) 15);
ItemMeta compassMeta = compass.getItemMeta();
ItemMeta bookMeta = book.getItemMeta();
ItemMeta eggMeta = tp.getItemMeta();
ItemMeta vanishMeta = vanish.getItemMeta();
ItemMeta carpetMeta = carpet.getItemMeta();
compassMeta.setDisplayName("§eZoom");
bookMeta.setDisplayName("§eInventory Inspector");
eggMeta.setDisplayName("§eFind Player");
vanishMeta.setDisplayName("§eVanish: §aOn");
carpetMeta.setDisplayName("§eView");
compass.setItemMeta(compassMeta);
book.setItemMeta(bookMeta);
tp.setItemMeta(eggMeta);
vanish.setItemMeta(vanishMeta);
carpet.setItemMeta(carpetMeta);
inv.setItem(0, compass);
inv.setItem(1, book);
inv.setItem(2, carpet);
inv.setItem(7, tp);
inv.setItem(8, vanish);
}
public static void saveInventory(Player p) {
StaffModeCommand.armorContents.put(p.getName(), p.getInventory().getArmorContents());
StaffModeCommand.inventoryContents.put(p.getName(), p.getInventory().getContents());
}
public static void loadInventory(Player p) {
p.getInventory().clear();
p.getInventory().setContents((ItemStack[]) StaffModeCommand.inventoryContents.get(p.getName()));
p.getInventory().setArmorContents((ItemStack[]) StaffModeCommand.armorContents.get(p.getName()));
StaffModeCommand.inventoryContents.remove(p.getName());
StaffModeCommand.armorContents.remove(p.getName());
}
}

View File

@ -0,0 +1,50 @@
package club.curahq.core.commands;
import com.google.common.collect.ImmutableMap;
import org.bukkit.entity.Player;
@SuppressWarnings({ "unchecked", "rawtypes" })
public enum StaffPriority {
OWNER(6),
HEADADMIN(5),
STAFFMANAGER(4),
ADMIN(3),
MODERATOR(2),
TRIAL(1),
NONE(0);
private static final ImmutableMap<Integer, StaffPriority> BY_ID;
private final int priorityLevel;
private StaffPriority(int priorityLevel) {
this.priorityLevel = priorityLevel;
}
public static StaffPriority of(int level) {
return (StaffPriority)((Object)BY_ID.get((Object)level));
}
public static StaffPriority of(Player player) {
for (StaffPriority staffPriority : StaffPriority.values()) {
if (!player.hasPermission("staffpriority." + staffPriority.priorityLevel)) continue;
return staffPriority;
}
return NONE;
}
public int getPriorityLevel() {
return this.priorityLevel;
}
public boolean isMoreThan(StaffPriority other) {
return this.priorityLevel > other.priorityLevel;
}
static {
ImmutableMap.Builder builder = new ImmutableMap.Builder();
for (StaffPriority staffPriority : StaffPriority.values()) {
builder.put((Object)staffPriority.priorityLevel, (Object)staffPriority);
}
BY_ID = builder.build();
}
}

View File

@ -0,0 +1,47 @@
package club.curahq.core.commands.chat;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.util.core.BaseCommand;
import net.minecraft.util.org.apache.commons.lang3.StringUtils;
public class ClearChatCommand
extends BaseCommand
{
private static final String[] CLEAR_MESSAGE = new String[101];
public ClearChatCommand()
{
super("clearchat", "Clears the server chat for players.");
setAliases(new String[] { "cc" });
setUsage("/(command) <reason>");
}
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (args.length == 0)
{
sender.sendMessage(getUsage());
return true;
}
String reason = StringUtils.join(args, ' ');
Player[] arrayOfPlayer;
int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
for (int i = 0; i < j; i++)
{
Player player = arrayOfPlayer[i];
if (!player.hasPermission("command.mod")) {
player.sendMessage(CLEAR_MESSAGE);
}
}
Command.broadcastCommandMessage(sender, ChatColor.WHITE + "In-Game Chat has been cleared by " + ChatColor.YELLOW + sender.getName() + ChatColor.WHITE + " for: " + reason, true);
Bukkit.getConsoleSender().sendMessage(ChatColor.YELLOW + sender.getName() + ChatColor.GRAY + " has cleared In-Game Chat for§7: §7" + reason);
return true;
}
}

View File

@ -0,0 +1,59 @@
package club.curahq.core.commands.chat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.commands.MessageEvent;
import net.md_5.bungee.api.ChatColor;
public class MessageCommand
implements CommandExecutor
{
public static List<String> toggle = new ArrayList<String>();
public static HashMap<CommandSender, Player> reply = new HashMap<CommandSender, Player>();
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
if (sender instanceof Player)
{
if (args.length <= 1)
{
sender.sendMessage(ChatColor.RED + "Usage: /message <player> <message>");
}
else if (Bukkit.getPlayer(args[0]) == null)
{
sender.sendMessage(ChatColor.RED + "Player isn't online.");
}
else if (Bukkit.getPlayer(args[0]).getName() == sender.getName())
{
sender.sendMessage(ChatColor.RED + "You cannot message yourself");
}
else if ((toggle.contains(Bukkit.getPlayer(args[0]).getDisplayName())) && (!sender.hasPermission("command.message.bypass")))
{
sender.sendMessage(MessageEvent.format("&c" + Bukkit.getPlayer(args[0]).getName() + "&7 has their messages disabled."));
}
else
{
String msgto = MessageEvent.format("&8(&7To " + "&f" + Bukkit.getPlayer(args[0]).getName() + "&8)&7 " + MessageEvent.toString(args, 1));
sender.sendMessage(msgto);
String msgrecieve = MessageEvent.format("&8(&7From &f" + sender.getName() + "&8) &7" + MessageEvent.toString(args, 1));
Bukkit.getPlayer(args[0]).sendMessage(msgrecieve);
reply.put(sender, Bukkit.getPlayer(args[0]));
reply.put(Bukkit.getPlayer(args[0]), (Player)sender);
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,48 @@
package club.curahq.core.commands.chat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.commands.MessageEvent;
import net.md_5.bungee.api.ChatColor;
public class ReplyCommand
implements CommandExecutor
{
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
if (args.length == 0)
{
sender.sendMessage(ChatColor.RED + "Usage: /reply <message>");
}
else if (MessageCommand.reply.get(sender) == null)
{
sender.sendMessage(ChatColor.RED + "You have nobody to reply to.");
}
else if (((Player)MessageCommand.reply.get(sender)).getName() == sender.getName())
{
sender.sendMessage(ChatColor.RED + "You cannot message yourself.");
}
else if (args[0].equalsIgnoreCase("who"))
{
sender.sendMessage(MessageEvent.format("&7You are currently in a conversation with &b" + ((Player)MessageCommand.reply.get(sender)).getName()));
}
else if ((MessageCommand.toggle.contains(((Player)MessageCommand.reply.get(sender)).getName())) && (!sender.hasPermission("command.message.bypass")))
{
sender.sendMessage(MessageEvent.format("&f" + ((Player)MessageCommand.reply.get(sender)).getName() + " has their messages disabled."));
}
else
{
String msgto = MessageEvent.format("&8(&7To " + "&f" + MessageCommand.reply.get(sender).getName() + "&8)&7 " + MessageEvent.toString(args, 0));
sender.sendMessage(msgto);
String msgget = MessageEvent.format("&8(&7From " + ChatColor.WHITE + sender.getName() + "&8)&7 " + MessageEvent.toString(args, 0));
((Player)MessageCommand.reply.get(sender)).sendMessage(MessageEvent.format(msgget));
return true;
}
return false;
}
}

View File

@ -0,0 +1,45 @@
package club.curahq.core.commands.chat;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.commands.MessageEvent;
public class ToggleMessageCommand
implements CommandExecutor
{
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
if (sender.hasPermission("command.togglemessage"))
{
if (!(sender instanceof Player))
{
sender.sendMessage(MessageEvent.format("&cOnly in-game player can execute this command."));
return false;
}
Player player = (Player)sender;
if (!MessageCommand.toggle.contains(player.getName()))
{
player.sendMessage(MessageEvent.format("&7You have &cdisabled &7your &3&lPrivate Messages"));
MessageCommand.toggle.add(sender.getName());
return true;
}
if (MessageCommand.toggle.contains(player.getName()))
{
player.sendMessage(MessageEvent.format("&7You have &aenabled &7your &3&lPrivate Messages"));
MessageCommand.toggle.remove(sender.getName());
return true;
}
if (args.length > 1) {
player.sendMessage(MessageEvent.format("&cYou have provided to many arguments"));
}
}
else
{
sender.sendMessage(MessageEvent.format("&cYou lack the sufficient permissions to execute this command."));
}
return false;
}
}

View File

@ -0,0 +1,20 @@
package club.curahq.core.commands.essentials;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import club.curahq.core.Core;
public class CoordsCommand implements CommandExecutor {
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (command.getName().equalsIgnoreCase("coords")) {
for (String msg : Core.config.getStringList("Coords")) {
commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
}
return true;
}
return false;
}
}

View File

@ -0,0 +1,61 @@
package club.curahq.core.commands.essentials;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.Core;
import club.curahq.core.deathban.Deathban;
import club.curahq.core.user.FactionUser;
import club.curahq.core.util.core.Cooldowns;
import java.util.UUID;
public class DonatorReviveCommand implements CommandExecutor {
private final Core plugin;
public DonatorReviveCommand(final Core plugin) {
this.plugin = plugin;
}
@SuppressWarnings({ "deprecation", "static-access" })
public boolean onCommand(final CommandSender sender, final Command command, final String label,
final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " [player]");
return true;
}
final Player player = (Player) sender;
final OfflinePlayer target = Bukkit.getOfflinePlayer(args[0]);
if (Cooldowns.isOnCooldown("revive_cooldown", player)) {
sender.sendMessage("§cYou cannot do this for another §l"
+ Cooldowns.getCooldownForPlayerInt("revive_cooldown", player) / 60 + " §cminutes.");
return true;
}
final UUID targetUUID = target.getUniqueId();
final FactionUser factionTarget = this.plugin.getUserManager().getUser(targetUUID);
final Deathban deathban = factionTarget.getDeathban();
if (deathban == null || !deathban.isActive()) {
sender.sendMessage(ChatColor.RED + target.getName() + " is not death-banned.");
return true;
}
factionTarget.removeDeathban();
sender.sendMessage(
ChatColor.GRAY + "You have revived " + ChatColor.GOLD + target.getName() + ChatColor.GRAY + '.');
Bukkit.broadcastMessage(ChatColor.GOLD + sender.getName() + ChatColor.GRAY + " has use their donator revive on " + ChatColor.GOLD + target.getName()
+ ChatColor.GRAY + "." + "You can purchase this at " + ChatColor.GOLD + Core.getPlugin().config.getString("store"));
Cooldowns.addCooldown("revive_cooldown", player, 3600);
return true;
}
}

View File

@ -0,0 +1,118 @@
package club.curahq.core.commands.essentials;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.JavaUtils;
import club.curahq.core.util.core.BaseCommand;
import club.curahq.core.util.core.BaseConstants;
public class EnchantCommand
extends BaseCommand
{
public EnchantCommand()
{
super("enchant", "Adds enchantment to items.");
setUsage("/(command) <enchantment> <level> [playerName]");
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (args.length < 2)
{
sender.sendMessage(getUsage());
return true;
}
Player target;
if ((args.length > 2) && (sender.hasPermission(command.getPermission() + ".others")))
{
target = BukkitUtils.playerWithNameOrUUID(args[2]);
}
else
{
if (!(sender instanceof Player))
{
sender.sendMessage(getUsage(label));
return true;
}
target = (Player)sender;
}
if ((target == null) || (!BaseCommand.canSee(sender, target)))
{
sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
Enchantment enchantment = Enchantment.getByName(args[0]);
if (enchantment == null)
{
sender.sendMessage(ChatColor.RED + "No enchantment named '" + args[0] + "' found.");
return true;
}
org.bukkit.inventory.ItemStack stack = target.getItemInHand();
if ((stack == null) || (stack.getType() == Material.AIR))
{
sender.sendMessage(ChatColor.RED + target.getName() + " is not holding an item.");
return true;
}
Integer level = JavaUtils.tryParseInt(args[1]);
if (level == null)
{
sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a number.");
return true;
}
int maxLevel = enchantment.getMaxLevel();
if ((level.intValue() > maxLevel) && (!sender.hasPermission(command.getPermission() + ".abovemaxlevel")))
{
sender.sendMessage(ChatColor.RED + "The maximum enchantment level for " + enchantment.getName() + " is " + maxLevel + '.');
return true;
}
if ((!enchantment.canEnchantItem(stack)))
{
sender.sendMessage(ChatColor.RED + "Enchantment " + enchantment.getName() + " cannot be applied to that item.");
return true;
}
stack.addUnsafeEnchantment(enchantment, level.intValue());
String itemName;
try
{
itemName = CraftItemStack.asNMSCopy(stack).getName();
}
catch (Error ex)
{
itemName = stack.getType().name();
}
Command.broadcastCommandMessage(sender, ChatColor.GRAY + "Enchanted " + enchantment.getName() + " at level " + level + " onto " + itemName + " of " + target.getName() + '.');
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args)
{
switch (args.length)
{
case 1:
Enchantment[] enchantments = Enchantment.values();
ArrayList<String> results = new ArrayList<String>(enchantments.length);
Enchantment[] arrayOfEnchantment1;
int j = (arrayOfEnchantment1 = enchantments).length;
for (int i = 0; i < j; i++)
{
Enchantment enchantment = arrayOfEnchantment1[i];
results.add(enchantment.getName());
}
return BukkitUtils.getCompletions(args, results);
case 3:
return null;
}
return Collections.emptyList();
}
}

View File

@ -0,0 +1,211 @@
package club.curahq.core.commands.essentials;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;
import club.curahq.core.Core;
public class EndPortalCommand
implements CommandExecutor, Listener
{
private Core mainPlugin;
private final String ITEM_DISPLAYNAME = ChatColor.RED.toString() + ChatColor.BOLD + "Endportal Maker";
private Map<String, LocationPair> playerSelections;
public EndPortalCommand(Core plugin)
{
this.mainPlugin = plugin;
this.playerSelections = new HashMap<String, LocationPair>();
}
@EventHandler
public void onInteract(final PlayerInteractEvent e)
{
if ((e.hasItem()) && (e.getClickedBlock() != null))
{
ItemStack itemStack = e.getItem();
Block b = e.getClickedBlock();
if ((itemStack.getItemMeta().hasDisplayName()) && (itemStack.getItemMeta().getDisplayName().equals(this.ITEM_DISPLAYNAME)))
{
LocationPair locationPair = (LocationPair)this.playerSelections.get(e.getPlayer().getName());
if (locationPair == null)
{
locationPair = new LocationPair(null, null);
this.playerSelections.put(e.getPlayer().getName(), locationPair);
}
if (e.getAction() == Action.LEFT_CLICK_BLOCK)
{
if (b.getType() != Material.ENDER_PORTAL_FRAME)
{
e.getPlayer().sendMessage(ChatColor.RED + "You must select an end portal frame.");
return;
}
locationPair.setFirstLoc(b.getLocation());
e.getPlayer().sendMessage(ChatColor.GREEN + "Successfully set the first location.");
}
else if (e.getAction() == Action.RIGHT_CLICK_BLOCK)
{
if (b.getType() != Material.ENDER_PORTAL_FRAME)
{
e.getPlayer().sendMessage(ChatColor.RED + "You must select an end portal frame.");
return;
}
if (locationPair.getFirstLoc() == null)
{
e.getPlayer().sendMessage(ChatColor.RED + "Please set the first location (by left clicking the end portal frame).");
return;
}
locationPair.setSecondLoc(b.getLocation());
e.getPlayer().sendMessage(ChatColor.GREEN + "Successfully set the second location.");
Location firstLoc = locationPair.getFirstLoc();
Location secondLoc = locationPair.getSecondLoc();
if (firstLoc.distance(secondLoc) > 6.0D)
{
e.getPlayer().sendMessage(ChatColor.RED + "You cannot create an end portal that big.");
return;
}
if (firstLoc.getBlockY() != secondLoc.getBlockY())
{
e.getPlayer().sendMessage(ChatColor.RED + "Make sure that the portals have the same elevation.");
return;
}
int minX = Math.min(firstLoc.getBlockX(), secondLoc.getBlockX());
int minY = Math.min(firstLoc.getBlockY(), secondLoc.getBlockY());
int minZ = Math.min(firstLoc.getBlockZ(), secondLoc.getBlockZ());
int maxX = Math.max(firstLoc.getBlockX(), secondLoc.getBlockX());
int maxY = Math.max(firstLoc.getBlockY(), secondLoc.getBlockY());
int maxZ = Math.max(firstLoc.getBlockZ(), secondLoc.getBlockZ());
int x = minX;
while (x <= maxX)
{
int y = minY;
while (y <= maxY)
{
int z = minZ;
while (z <= maxZ)
{
Block block = b.getWorld().getBlockAt(x, y, z);
if (block.isEmpty()) {
block.setType(Material.ENDER_PORTAL);
}
z++;
}
y++;
}
x++;
}
e.setCancelled(true);
new BukkitRunnable()
{
public void run()
{
e.getPlayer().setItemInHand(null);
e.getPlayer().updateInventory();
}
}.runTask(this.mainPlugin);
e.getPlayer().sendMessage(ChatColor.GREEN + "You have successfully created an End Portal.");
this.playerSelections.remove(e.getPlayer().getName());
}
}
}
}
@EventHandler
public void onDrop(PlayerDropItemEvent e)
{
ItemStack itemStack = e.getItemDrop().getItemStack();
if ((itemStack.getItemMeta().hasDisplayName()) && (itemStack.getItemMeta().getDisplayName().equals(this.ITEM_DISPLAYNAME))) {
e.getItemDrop().remove();
}
}
@EventHandler
public void onQuit(PlayerQuitEvent e)
{
this.playerSelections.remove(e.getPlayer().getName());
}
@EventHandler
public void onKick(PlayerKickEvent e)
{
this.playerSelections.remove(e.getPlayer().getName());
}
public boolean onCommand(CommandSender s, Command c, String alias, String[] args)
{
if (!s.hasPermission("command.endportal"))
{
s.sendMessage(ChatColor.RED + "You lack the sufficient permissions to execute this command.");
return true;
}
if (!(s instanceof Player))
{
s.sendMessage(ChatColor.RED + "You must be a player to perform this command.");
return true;
}
Player p = (Player)s;
if (p.getInventory().firstEmpty() == -1)
{
p.sendMessage(ChatColor.RED + "Please clear up your hotbar, and then perform this command again.");
return true;
}
ItemStack portalMaker = new ItemStack(Material.BLAZE_ROD);
ItemMeta itemMeta = portalMaker.getItemMeta();
itemMeta.setDisplayName(this.ITEM_DISPLAYNAME);
portalMaker.setItemMeta(itemMeta);
p.getInventory().addItem(new ItemStack[] { portalMaker });
p.sendMessage(ChatColor.GRAY + "You must select two points.");
return true;
}
private class LocationPair
{
private Location firstLoc;
private Location secondLoc;
public LocationPair(Location firstLoc, Location secondLoc)
{
this.firstLoc = firstLoc;
this.secondLoc = secondLoc;
}
public Location getFirstLoc()
{
return this.firstLoc;
}
public Location getSecondLoc()
{
return this.secondLoc;
}
public void setFirstLoc(Location firstLoc)
{
this.firstLoc = firstLoc;
}
public void setSecondLoc(Location secondLoc)
{
this.secondLoc = secondLoc;
}
}
}

View File

@ -0,0 +1,61 @@
package club.curahq.core.commands.essentials;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.apache.commons.lang.time.DurationFormatUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.minecraft.util.gnu.trove.map.TObjectLongMap;
import net.minecraft.util.gnu.trove.map.hash.TObjectLongHashMap;
@SuppressWarnings({ "unchecked", "rawtypes" })
public class FightCommand implements CommandExecutor
{
private static final long FIGHT_COOLDOWN_DELAY;
public static final TObjectLongMap<UUID> FIGHT_COOLDOWN;
static {
FIGHT_COOLDOWN_DELAY = TimeUnit.MINUTES.toMillis(30L);
FIGHT_COOLDOWN = (TObjectLongMap)new TObjectLongHashMap();
}
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("No Console");
return true;
}
final Player player = (Player)sender;
final int x = player.getLocation().getBlockX();
final int y = player.getLocation().getBlockY();
final int z = player.getLocation().getBlockZ();
if (command.getName().equalsIgnoreCase("fight")) {
if (!player.hasPermission("command.fight")) {
sender.sendMessage(ChatColor.RED + "You lack the sufficient permissions to execute this command.");
return true;
}
if (args.length == 0) {
final UUID uuid = player.getUniqueId();
final long timestamp = FightCommand.FIGHT_COOLDOWN.get(uuid);
final long millis = System.currentTimeMillis();
final long remaining = (timestamp == FightCommand.FIGHT_COOLDOWN.getNoEntryValue()) ? -1L : (timestamp - millis);
if (remaining > 0L) {
player.sendMessage(ChatColor.RED + "You cannot use this command for another " + ChatColor.BOLD + DurationFormatUtils.formatDurationWords(remaining, true, true) + ".");
return true;
}
Bukkit.broadcastMessage(ChatColor.DARK_GRAY + ChatColor.STRIKETHROUGH.toString() + "--------------------------------");
Bukkit.broadcastMessage(ChatColor.GOLD + ChatColor.BOLD.toString() + sender.getName() + ChatColor.GRAY + " has broadcasted their Location <20>f(" + x + ", " + y + ", " + z + ")");
Bukkit.broadcastMessage(ChatColor.DARK_GRAY + ChatColor.STRIKETHROUGH.toString() + "--------------------------------");
}
player.sendMessage(ChatColor.GRAY + "You have announced that you are looking for a fight, you must wait 30 minutes before doing this again.");
FightCommand.FIGHT_COOLDOWN.put((UUID)player.getUniqueId(), System.currentTimeMillis() + FightCommand.FIGHT_COOLDOWN_DELAY);
}
return true;
}
}

View File

@ -0,0 +1,43 @@
package club.curahq.core.commands.essentials;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import club.curahq.core.Core;
import club.curahq.core.timer.PlayerTimer;
public class GoppleCommand implements CommandExecutor, TabCompleter {
private final Core plugin;
public GoppleCommand(Core plugin) {
this.plugin = plugin;
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
Player player = (Player) sender;
PlayerTimer timer = this.plugin.getTimerManager().gappleTimer;
long remaining = timer.getRemaining(player);
if (remaining <= 0L) {
sender.sendMessage(ChatColor.RED + "No active Gopple timer.");
return true;
}
sender.sendMessage(
ChatColor.GRAY + "Your " + ChatColor.GOLD + timer.getDisplayName() + ChatColor.GRAY + " timer is active for another "
+ ChatColor.GOLD + Core.getRemaining(remaining, true, false) + ChatColor.GRAY + '.');
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return Collections.emptyList();
}
}

View File

@ -0,0 +1,20 @@
package club.curahq.core.commands.essentials;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import club.curahq.core.Core;
public class HelpCommand implements CommandExecutor {
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (command.getName().equalsIgnoreCase("help")) {
for (String msg : Core.config.getStringList("Help")) {
commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
}
return true;
}
return false;
}
}

View File

@ -0,0 +1,30 @@
package club.curahq.core.commands.essentials;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.Core;
import club.curahq.core.util.core.Cooldowns;
public class LFFCommand implements CommandExecutor
{
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This is a player only command");
return true;
}
if (Cooldowns.isOnCooldown("lff_cooldown", (Player)sender)) {
sender.sendMessage(ChatColor.RED + "You are still on cooldown for " + ChatColor.RED + ChatColor.BOLD.toString() + Core.getRemaining(Cooldowns.getCooldownForPlayerLong("lff_cooldown", (Player)sender), true));
return true;
}
Bukkit.broadcastMessage(ChatColor.DARK_GRAY + ChatColor.STRIKETHROUGH.toString() + "--------------------------------");
Bukkit.broadcastMessage(ChatColor.GOLD + ChatColor.BOLD.toString() + sender.getName() + ChatColor.GRAY + " is looking for a faction!");
Bukkit.broadcastMessage(ChatColor.DARK_GRAY + ChatColor.STRIKETHROUGH.toString() + "--------------------------------");
Cooldowns.addCooldown("lff_cooldown", (Player)sender, 900);
return false;
}
}

View File

@ -0,0 +1,38 @@
package club.curahq.core.commands.essentials;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.listener.staff.VanishListener;
import club.curahq.core.util.BukkitUtils;
public class ListCommand implements CommandExecutor{
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
if(cmd.getName().equalsIgnoreCase("list")){
if (!(sender instanceof Player)) {
return true;
}
ArrayList<String> playernames = new ArrayList<String>();
for(Player p : Bukkit.getOnlinePlayers()){
if (p.hasPermission("command.mod") && (!VanishListener.isVanished(p))) {
playernames.add(p.getName() + ChatColor.GOLD);
}
}
sender.sendMessage(ChatColor.DARK_GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
sender.sendMessage(ChatColor.GRAY + "There are currently " + ChatColor.GOLD + Bukkit.getOnlinePlayers().length + ChatColor.GRAY + " players online out of a maximum of " + ChatColor.GOLD + Bukkit.getMaxPlayers());
sender.sendMessage(ChatColor.DARK_GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
}
return true;
}
}

View File

@ -0,0 +1,43 @@
package club.curahq.core.commands.essentials;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import club.curahq.core.Core;
import club.curahq.core.timer.type.LogoutTimer;
public class LogoutCommand implements CommandExecutor, TabCompleter {
private final Core plugin;
public LogoutCommand(Core plugin) {
this.plugin = plugin;
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
Player player = (Player) sender;
LogoutTimer logoutTimer = this.plugin.getTimerManager().logoutTimer;
if (!logoutTimer.setCooldown(player, player.getUniqueId())) {
sender.sendMessage(ChatColor.RED + "Your " + logoutTimer.getDisplayName() + ChatColor.RED
+ " timer is already active.");
return true;
}
sender.sendMessage(
ChatColor.RED + "Your " + logoutTimer.getDisplayName() + ChatColor.RED + " timer has started.");
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return Collections.emptyList();
}
}

View File

@ -0,0 +1,112 @@
package club.curahq.core.commands.essentials;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Statistic;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class OreStatsCommand implements CommandExecutor, Listener {
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
Player player = (Player) sender;
if ((cmd.getName().equalsIgnoreCase("ores")) && ((sender instanceof Player)) && (args.length > 1)) {
sender.sendMessage("§cUsage: /ores <player>");
return true;
}
if (args.length == 0) {
sender.sendMessage("§cUsage: /ores <player>");
return true;
}
Player target = Bukkit.getServer().getPlayer(args[0]);
if ((args.length == 1) && (target == null)) {
player.sendMessage("§cPlayer not found");
return true;
}
this.onStatsGUI(player, target);
/*
* /sender.sendMessage("§7§m--------------------------------------------------")
* ; sender.sendMessage(" §eOres mined by: §6" +
* target.getDisplayName()); sender.sendMessage("§bDiamond(s): §7" +
* target.getStatistic(Statistic.MINE_BLOCK, Material.DIAMOND_ORE));
* sender.sendMessage("§aEmerald(s): §7" +
* target.getStatistic(Statistic.MINE_BLOCK, Material.EMERALD_ORE));
* sender.sendMessage("§7Iron(s): §7" +
* target.getStatistic(Statistic.MINE_BLOCK, Material.IRON_ORE));
* sender.sendMessage("§6Gold(s): §7" +
* target.getStatistic(Statistic.MINE_BLOCK, Material.GOLD_ORE));
* sender.sendMessage("§cRedstone(s): §7" +
* target.getStatistic(Statistic.MINE_BLOCK, Material.REDSTONE_ORE));
* sender.sendMessage("§8Coal(s): §7" +
* target.getStatistic(Statistic.MINE_BLOCK, Material.COAL_ORE));
* sender.sendMessage("§9Lapis(s): §7" +
* target.getStatistic(Statistic.MINE_BLOCK, Material.LAPIS_ORE));
* sender.sendMessage("§7§m--------------------------------------------------");
* /
*/
return false;
}
public void onStatsGUI(Player player, Player target) {
Inventory inv = Bukkit.createInventory(null, 9, ChatColor.DARK_AQUA + ChatColor.BOLD.toString() + "Ores §8- §7" + target.getName());
ItemStack Diamond_ore = new ItemStack(Material.DIAMOND_ORE);
ItemStack Emerald_ore = new ItemStack(Material.EMERALD_ORE);
ItemStack Gold_ore = new ItemStack(Material.GOLD_ORE);
ItemStack Iron_ore = new ItemStack(Material.IRON_ORE);
ItemStack Coal_ore = new ItemStack(Material.COAL_ORE);
ItemStack Lapis_ore = new ItemStack(Material.LAPIS_ORE);
ItemStack RedStone_ore = new ItemStack(Material.REDSTONE_ORE);
ItemMeta DiamondMeta = Diamond_ore.getItemMeta();
ItemMeta EmeraldMeta = Emerald_ore.getItemMeta();
ItemMeta GoldMeta = Gold_ore.getItemMeta();
ItemMeta IronMeta = Iron_ore.getItemMeta();
ItemMeta CoalMeta = Coal_ore.getItemMeta();
ItemMeta LapisMeta = Lapis_ore.getItemMeta();
ItemMeta RedStoneMeta = RedStone_ore.getItemMeta();
DiamondMeta.setDisplayName("§bDiamond(s): §7" + target.getStatistic(Statistic.MINE_BLOCK, Material.DIAMOND_ORE));
EmeraldMeta.setDisplayName("§aEmerald(s): §7" + target.getStatistic(Statistic.MINE_BLOCK, Material.EMERALD_ORE));
IronMeta.setDisplayName("§7Iron(s): §7" + target.getStatistic(Statistic.MINE_BLOCK, Material.IRON_ORE));
GoldMeta.setDisplayName("§6Gold(s): §7" + target.getStatistic(Statistic.MINE_BLOCK, Material.GOLD_ORE));
RedStoneMeta.setDisplayName("§cRedstone(s): §7" + target.getStatistic(Statistic.MINE_BLOCK, Material.REDSTONE_ORE));
CoalMeta.setDisplayName("§8Coal(s): §7" + target.getStatistic(Statistic.MINE_BLOCK, Material.COAL_ORE));
LapisMeta.setDisplayName("§9Lapis(s): §7" + target.getStatistic(Statistic.MINE_BLOCK, Material.LAPIS_ORE));
Diamond_ore.setItemMeta(DiamondMeta);
Emerald_ore.setItemMeta(EmeraldMeta);
Iron_ore.setItemMeta(IronMeta);
Gold_ore.setItemMeta(GoldMeta);
RedStone_ore.setItemMeta(RedStoneMeta);
Coal_ore.setItemMeta(CoalMeta);
Lapis_ore.setItemMeta(LapisMeta);
inv.setItem(0, Diamond_ore);
inv.setItem(1, Emerald_ore);
inv.setItem(2, Iron_ore);
inv.setItem(3, Gold_ore);
inv.setItem(4, RedStone_ore);
inv.setItem(5, Coal_ore);
inv.setItem(6, Lapis_ore);
player.openInventory(inv);
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (event.getInventory().getTitle().startsWith(ChatColor.DARK_AQUA + ChatColor.BOLD.toString() + "Ores §8- §7")) {
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,34 @@
package club.curahq.core.commands.essentials;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.ChatColor;
public class PanicCommand
implements CommandExecutor
{
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
{
if (commandLabel.equalsIgnoreCase("panic") && (sender.hasPermission("command.panic")))
{
sender.sendMessage(ChatColor.RED.toString() + ChatColor.BOLD + "You have entered panic mode. Please join Teamspeak for further assistance.");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "ss " + sender.getName());
Player[] arrayOfPlayer;
int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
for (int i = 0; i < j; i++)
{
Player players = arrayOfPlayer[i];
if (players.hasPermission("command.mod")) {
players.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8(&3&lPANIC&8) &b" + sender.getName() + " &7has just entered &6&lPanic Mode"));
}
}
}
return false;
}
}

View File

@ -0,0 +1,43 @@
package club.curahq.core.commands.essentials;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class PingCommand implements CommandExecutor {
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if ((cmd.getName().equalsIgnoreCase("ping"))) {
if (args.length < 1) {
if ((sender instanceof Player)) {
CraftPlayer handler = (CraftPlayer) sender;
sender.sendMessage(ChatColor.GRAY + "You have a ping of " + ChatColor.GOLD
+ handler.getHandle().playerConnection.player.ping + ChatColor.GRAY + " ms.");
} else {
sender.sendMessage(ChatColor.RED + "Correct usage: /ping <player>");
}
} else {
boolean found = false;
for (Player p : Bukkit.getOnlinePlayers()) {
String name = p.getName();
CraftPlayer handler = (CraftPlayer) p;
if (name.equalsIgnoreCase(args[0])) {
sender.sendMessage(ChatColor.GOLD + name + ChatColor.GRAY + " has a ping of " + ChatColor.GOLD
+ handler.getHandle().playerConnection.player.ping + ChatColor.GRAY + " ms.");
found = true;
break;
}
}
if (!found) {
sender.sendMessage(ChatColor.RED + "Player not found.");
}
}
}
return true;
}
}

View File

@ -0,0 +1,63 @@
package club.curahq.core.commands.essentials;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.time.DurationFormatUtils;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.Core;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseCommand;
import club.curahq.core.util.core.BaseConstants;
public class PlayTimeCommand
extends BaseCommand
{
private final Core plugin;
public PlayTimeCommand(Core plugin)
{
super("playtime", "Check the playtime of another player.");
setAliases(new String[] { "pt" });
setUsage("/(command) [playerName]");
this.plugin = plugin;
}
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
OfflinePlayer target;
if (args.length >= 1)
{
target = BukkitUtils.offlinePlayerWithNameOrUUID(args[0]);
}
else
{
if (!(sender instanceof Player))
{
sender.sendMessage(getUsage(label));
return true;
}
target = (OfflinePlayer)sender;
}
if ((!target.hasPlayedBefore()) && (!target.isOnline()))
{
sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
sender.sendMessage(ChatColor.DARK_GRAY.toString() + ChatColor.STRIKETHROUGH + "-------------------------------------------------");
sender.sendMessage(ChatColor.GOLD + target.getName() + " §7has a playtime of " + ChatColor.GREEN + DurationFormatUtils.formatDurationWords(this.plugin.getPlayTimeManager().getTotalPlayTime(target.getUniqueId()), true, true) + ChatColor.GRAY + " this map.");
sender.sendMessage(ChatColor.DARK_GRAY.toString() + ChatColor.STRIKETHROUGH + "-------------------------------------------------");
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args)
{
return args.length == 1 ? null : Collections.emptyList();
}
}

View File

@ -0,0 +1,82 @@
package club.curahq.core.commands.essentials;
import com.google.common.collect.ImmutableList;
import club.curahq.core.Core;
import club.curahq.core.timer.type.PvPTimerProtection;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.DurationFormatter;
import club.curahq.core.util.config.PlayerData;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
public class PvpTimerCommand implements CommandExecutor, TabCompleter {
private final Core plugin;
public PvpTimerCommand(Core plugin) {
this.plugin = plugin;
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
Player player = (Player) sender;
PvPTimerProtection pvpTimer = this.plugin.getTimerManager().invincibilityTimer;
if (args.length < 1) {
printUsage(sender, label, pvpTimer);
return true;
}
if ((args[0].equalsIgnoreCase("enable")) || (args[0].equalsIgnoreCase("remove"))
|| (args[0].equalsIgnoreCase("off"))) {
if (pvpTimer.getRemaining(player) <= 0L) {
sender.sendMessage(ChatColor.RED + "Your " + pvpTimer.getDisplayName() + ChatColor.RED
+ " is currently not active.");
return true;
}
sender.sendMessage(
ChatColor.RED + "Your " + pvpTimer.getDisplayName() + ChatColor.RED + " timer is now off.");
pvpTimer.clearCooldown(player);
PlayerData.getInstance().getConfig().set("UUID." + player.getUniqueId() + ".Pvp-Timer", Integer.valueOf(0));
PlayerData.getInstance().saveConfig();
return true;
}
if ((args[0].equalsIgnoreCase("remaining")) || (args[0].equalsIgnoreCase("time"))
|| (args[0].equalsIgnoreCase("left")) || (args[0].equalsIgnoreCase("check"))) {
long remaining = pvpTimer.getRemaining(player);
if (remaining <= 0L) {
sender.sendMessage(ChatColor.RED + "Your " + pvpTimer.getDisplayName() + ChatColor.RED
+ " timer is currently not active.");
return true;
}
sender.sendMessage(ChatColor.GRAY + "Your " + ChatColor.GOLD + pvpTimer.getDisplayName() + "Timer" + ChatColor.GRAY + " is active for another " + ChatColor.GOLD + DurationFormatter.getRemaining(remaining, true, false) + ChatColor.GRAY + (pvpTimer.isPaused(player) ? " and is currently paused" : "") + '.');
return true;
}
printUsage(sender, label, pvpTimer);
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return args.length == 1 ? BukkitUtils.getCompletions(args, COMPLETIONS) : Collections.emptyList();
}
private static final ImmutableList<String> COMPLETIONS = ImmutableList.of("enable", "time");
private void printUsage(CommandSender sender, String label, PvPTimerProtection pvpTimer) {
sender.sendMessage(ChatColor.DARK_GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
sender.sendMessage("§6PvP Help");
sender.sendMessage(ChatColor.YELLOW + " /pvp enable" + ChatColor.DARK_GRAY + " - " + ChatColor.GRAY + "Remove your PvP Protection.");
sender.sendMessage(ChatColor.YELLOW + " /pvp time" + ChatColor.DARK_GRAY + " - " + ChatColor.GRAY + "Check the remaining for your PvP Protection.");
sender.sendMessage(ChatColor.YELLOW + " /lives" + ChatColor.DARK_GRAY + " - " + ChatColor.GRAY + "Info about lives and deathbans.");
sender.sendMessage(ChatColor.DARK_GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
}
}

View File

@ -0,0 +1,48 @@
package club.curahq.core.commands.essentials;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.Core;
public class RandomCommand implements CommandExecutor {
public RandomCommand(Core plugin) {
}
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
Player player = (Player) sender;
List<Player> players = new ArrayList<Player>();
Player[] arrayOfPlayer;
int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
for (int i = 0; i < j; i++) {
Player players2 = arrayOfPlayer[i];
players.add(players2);
}
Collections.shuffle(players);
Random random = new Random();
Integer randoms = Integer.valueOf(random.nextInt(Bukkit.getOnlinePlayers().length));
Player p = (Player) players.get(randoms.intValue());
if ((player.canSee(p)) && (player.hasPermission(command.getPermission() + ".teleport"))) {
player.teleport(p);
player.sendMessage(ChatColor.GRAY + "You have teleported to " + ChatColor.GOLD + p.getName());
} else if (player.canSee(p)) {
player.sendMessage(ChatColor.GRAY + "You have found " + ChatColor.GOLD + p.getName());
} else {
player.sendMessage(ChatColor.RED + "Player not found");
}
return true;
}
}

View File

@ -0,0 +1,48 @@
package club.curahq.core.commands.essentials;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Statistic;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class ResetCommand implements CommandExecutor{
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
Player player = (Player)sender;
if ((command.getName().equalsIgnoreCase("reset")) && ((sender instanceof Player)) &&
(args.length > 1))
{
sender.sendMessage("<EFBFBD>cUsage: /Reset <player>");
return true;
}
if (args.length == 0)
{
sender.sendMessage("<EFBFBD>cUsage: /Reset <player>");
return true;
}
Player target = Bukkit.getServer().getPlayer(args[0]);
if ((args.length == 1) &&
(target == null))
{
player.sendMessage("<EFBFBD>cPlayer not found");
return true;
}
target.setStatistic(Statistic.DEATHS, 0);
target.setStatistic(Statistic.PLAYER_KILLS, 0);
sender.sendMessage(ChatColor.RED + "You have reset " + target.getPlayer().getName() + " 's stats!");
for (Player s : Bukkit.getOnlinePlayers()) {
if (s.hasPermission("command.reset")) {
s.sendMessage(ChatColor.translateAlternateColorCodes('&', "&e" + sender.getName() + " &fhas reset the &eStatistics &fof &e" + target.getName()));
return false;
}
}
return false;
}
}

View File

@ -0,0 +1,39 @@
package club.curahq.core.commands.essentials;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import net.md_5.bungee.api.ChatColor;
public class SkullCommand implements Listener, CommandExecutor
{
private ItemStack playerSkullForName(final String name) {
final ItemStack is = new ItemStack(Material.SKULL_ITEM, 1);
is.setDurability((short)3);
final ItemMeta meta = is.getItemMeta();
((SkullMeta) meta).setOwner(name);
is.setItemMeta(meta);
return is;
}
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (command.getName().equalsIgnoreCase("skull") && args.length == 1) {
if (sender instanceof Player) {
final Player p = (Player)sender;
p.getInventory().addItem(new ItemStack[] { this.playerSkullForName(args[0]) });
sender.sendMessage(ChatColor.GRAY + "Added " + ChatColor.GOLD + args[0] + ChatColor.GRAY + "'s skull to your inventory");
return true;
}
sender.sendMessage(ChatColor.RED + "You must run this command as a player.");
}
return false;
}
}

View File

@ -0,0 +1,49 @@
package club.curahq.core.commands.essentials;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Statistic;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.Core;
import club.curahq.core.util.BukkitUtils;
public class StatsCommand implements CommandExecutor{
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
{
Player player = (Player)sender;
if ((cmd.getName().equalsIgnoreCase("Stats")) && ((sender instanceof Player)) &&
(args.length > 1))
{
sender.sendMessage("§cUsage: /Stats <player>");
return true;
}
if (args.length == 0)
{
sender.sendMessage("§cUsage: /Stats <player>");
return true;
}
Player target = Bukkit.getServer().getPlayer(args[0]);
if ((args.length == 1) &&
(target == null))
{
player.sendMessage("§cPlayer not found");
return true;
}
int kills = target.getStatistic(Statistic.PLAYER_KILLS);
int deaths = target.getStatistic(Statistic.DEATHS);
double kdr = Math.abs(kills / deaths);
sender.sendMessage(ChatColor.DARK_GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
sender.sendMessage(" " + ChatColor.GOLD + target.getName() + "'s Stats ");
sender.sendMessage(" " + ChatColor.YELLOW + "Kills" + ChatColor.GOLD + " § " + ChatColor.GRAY + kills);
sender.sendMessage(" " + ChatColor.YELLOW + "Deaths" + ChatColor.GOLD + " § " + ChatColor.GRAY + deaths);
sender.sendMessage(" " + ChatColor.YELLOW + "KD" + ChatColor.GOLD + " § " + ChatColor.GRAY + kdr);
sender.sendMessage(ChatColor.DARK_GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
return false;
}
}

View File

@ -0,0 +1,104 @@
package club.curahq.core.commands.essentials;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseCommand;
import me.apache.commons.lang3.StringUtils;
public class SudoCommand extends BaseCommand {
public SudoCommand() {
super("sudo", "Forces a player to run command.");
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
boolean force;
if (args.length < 3) {
sender.sendMessage((Object)ChatColor.RED + "Usage: " + "/(command) <force> <all|playerName> <command args...> \n[Warning!] Forcing will give player temporary OP until executed.");
return true;
}
try {
force = Boolean.parseBoolean(args[0]);
}
catch (IllegalArgumentException ex) {
sender.sendMessage((Object)ChatColor.RED + "Usage: " + "/(command) <force> <all|playerName> <command args...> \n[Warning!] Forcing will give player temporary OP until executed.");
return true;
}
String executingCommand = StringUtils.join((Object[])args, (char)' ', (int)2, (int)args.length);
if (args[1].equalsIgnoreCase("all")) {
for (Player target : Bukkit.getOnlinePlayers()) {
this.executeCommand(target, executingCommand, force);
}
sender.sendMessage((Object)ChatColor.RED + "Forcing all players to run " + executingCommand + (force ? " with permission bypasses" : "") + '.');
return true;
}
Player target2 = Bukkit.getPlayer((String)args[1]);
if (target2 == null || !BaseCommand.canSee(sender, target2)) {
sender.sendMessage((Object)ChatColor.RED + "Player not found.");
return true;
}
this.executeCommand(target2, executingCommand, force);
Command.broadcastCommandMessage((CommandSender)sender, (String)((Object)ChatColor.RED + sender.getName() + (Object)ChatColor.RED + " made " + target2.getName() + " run " + executingCommand + (force ? " with permission bypasses" : "") + '.'));
sender.sendMessage((Object)ChatColor.RED + "Making " + target2.getName() + " to run " + executingCommand + (force ? " with permission bypasses" : "") + '.');
return true;
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
ArrayList<String> results;
if (args.length == 1) {
results = new ArrayList<String>(2);
results.add("true");
results.add("false");
} else {
if (args.length != 2) {
return Collections.emptyList();
}
results = new ArrayList();
results.add("ALL");
Player senderPlayer = sender instanceof Player ? (Player)sender : null;
for (Player target : Bukkit.getOnlinePlayers()) {
if (senderPlayer != null && !senderPlayer.canSee(target)) continue;
results.add(target.getName());
}
}
return BukkitUtils.getCompletions(args, results);
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
private boolean executeCommand(Player target, String executingCommand, boolean force) {
if (target.isOp()) {
force = false;
}
try {
if (force) {
target.setOp(true);
}
target.performCommand(executingCommand);
boolean bl = true;
return bl;
}
catch (Exception ex) {
boolean bl = false;
return bl;
}
finally {
if (force) {
target.setOp(false);
}
}
}
}

View File

@ -0,0 +1,27 @@
package club.curahq.core.commands.essentials;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class TLCommand implements CommandExecutor {
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("No Console");
return true;
}
final Player player = (Player)sender;
final int x = player.getLocation().getBlockX();
final int y = player.getLocation().getBlockY();
final int z = player.getLocation().getBlockZ();
if (command.getName().equalsIgnoreCase("tl")) {
player.chat("/f message " + x + ", " + y + ", " + z);
return true;
}
return true;
}
}

View File

@ -0,0 +1,20 @@
package club.curahq.core.commands.essentials;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import club.curahq.core.Core;
public class TeamspeakCommand implements CommandExecutor {
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (command.getName().equalsIgnoreCase("teamspeak")) {
for (String msg : Core.config.getStringList("Teamspeak")) {
commandSender.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
}
return true;
}
return false;
}
}

View File

@ -0,0 +1,38 @@
package club.curahq.core.commands.essentials;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.entity.Player;
import club.curahq.core.Core;
import club.curahq.core.scoreboard.PlayerBoard;
public class ToggleSidebarCommand implements CommandExecutor, TabExecutor {
private final Core plugin;
public ToggleSidebarCommand(Core plugin) {
this.plugin = plugin;
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
PlayerBoard playerBoard = this.plugin.getScoreboardHandler().getPlayerBoard(((Player) sender).getUniqueId());
boolean newVisibile = !playerBoard.isSidebarVisible();
playerBoard.setSidebarVisible(newVisibile);
sender.sendMessage(ChatColor.GRAY + "You have " + (newVisibile ? ChatColor.GREEN + "enabled" : new StringBuilder().append(ChatColor.RED).append("disabled").toString()) + ChatColor.GRAY + " your §6§lScoreboard");
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return Collections.emptyList();
}
}

View File

@ -0,0 +1,72 @@
package club.curahq.core.commands.note;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.util.config.PlayerData;
import club.curahq.core.util.core.BaseConstants;
import club.curahq.core.util.core.NoteApi;
public class NoteCommand implements CommandExecutor {
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender cs, Command cmd, String s, String[] args) {
if (!(cs instanceof Player)) {
cs.sendMessage(ChatColor.RED + "Please use the server to execute this command.");
return true;
}
Player player = (Player) cs;
if (args.length < 2) {
player.sendMessage(ChatColor.RED + "/note <add|remove|check> <player> <note>");
return true;
}
if ((Bukkit.getPlayer(args[1]) == null) && (Bukkit.getOfflinePlayer(args[1]) == null)) {
cs.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
OfflinePlayer starget = Bukkit.getOfflinePlayer(args[1]);
Player targetUser = (Player) starget;
if (targetUser == null) {
cs.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
String note = StringUtils.join(args, ' ', 2, args.length);
String time;
if (args[0].equalsIgnoreCase("add")) {
if (note == null) {
player.sendMessage(ChatColor.RED + "You need to add a note to this player.");
return true;
}
time = DateFormatUtils.format(System.currentTimeMillis(), "hh:mm");
NoteApi.addNote(targetUser, player, note, time);
player.sendMessage(ChatColor.GRAY + "You added a note to " + targetUser.getName() + ".");
return true;
}
if (args[0].equalsIgnoreCase("remove")) {
if (!player.hasPermission("command.note.remove")) {
player.sendMessage(ChatColor.RED + "No permission to this argument.");
return true;
}
if (PlayerData.getInstance().getConfig().contains("UUID." + targetUser.getUniqueId() + ".Reason")) {
player.sendMessage(
ChatColor.GOLD + targetUser.getName() + ChatColor.GRAY + " notes has been removed.");
NoteApi.removeNote(targetUser);
} else {
player.sendMessage(ChatColor.RED + "The player does not contain any notes.");
return true;
}
}
if (args[0].equalsIgnoreCase("check")) {
NoteApi.checkNote(targetUser, player);
}
return false;
}
}

View File

@ -0,0 +1,33 @@
package club.curahq.core.commands.staff;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import club.curahq.core.util.core.ConfigUtil;
public class BroadCastCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (cmd.getName().equalsIgnoreCase("broadcast")) {
String r = "";
if (sender.hasPermission("command.broadcast")) {
if (args.length > 0) {
for (int i = 0; i < args.length; i++) {
r = r + args[i] + " ";
}
r = r.replace("&", "§");
Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', ConfigUtil.PREFIX + "&7 " + r));
} else {
sender.sendMessage(ChatColor.RED + "Usage: /broadcast <message>");
}
} else {
sender.sendMessage("§§cYou lack the sufficient permissions to execute this command.");
}
}
return true;
}
}

View File

@ -0,0 +1,63 @@
package club.curahq.core.commands.staff;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import com.google.common.collect.ImmutableSet;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseConstants;
import net.md_5.bungee.api.ChatColor;
public class ClearCommand implements CommandExecutor {
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player onlyTarget = null;
Collection<Player> targets;
if ((args.length > 0) && (sender.hasPermission("command.clearinventory"))) {
if ((args[0].equalsIgnoreCase("all")) && (sender.hasPermission(command.getPermission() + ".all"))) {
targets = ImmutableSet.copyOf(Bukkit.getOnlinePlayers());
} else {
if (((onlyTarget = BukkitUtils.playerWithNameOrUUID(args[0])) == null)) {
sender.sendMessage(
String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
targets = ImmutableSet.of(onlyTarget);
}
} else {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Useage: /ci <player>");
return true;
}
targets = ImmutableSet.of(onlyTarget = (Player) sender);
}
for (Player target : targets) {
target.removePotionEffect(PotionEffectType.HUNGER);
target.setFoodLevel(20);
target.getInventory().clear();
target.getInventory().setHelmet(new ItemStack(Material.AIR));
target.getInventory().setChestplate(new ItemStack(Material.AIR));
target.getInventory().setLeggings(new ItemStack(Material.AIR));
target.getInventory().setBoots(new ItemStack(Material.AIR));
}
sender.sendMessage(ChatColor.GRAY.toString() + "Your inventory has been cleared.");
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return args.length == 1 ? null : Collections.emptyList();
}
}

View File

@ -0,0 +1,105 @@
package club.curahq.core.commands.staff;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import com.google.common.base.Optional;
import club.curahq.core.crowbar.Crowbar;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.JavaUtils;
public class CrowbarCommand implements CommandExecutor, TabCompleter {
private final List<String> completions;
public CrowbarCommand() {
this.completions = Arrays.asList(new String[] { "spawn", "setspawners", "setendframes" });
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <spawn|setspawners|setendframes>");
return true;
}
Player player = (Player) sender;
if (args[0].equalsIgnoreCase("spawn")) {
ItemStack stack = new Crowbar().getItemIfPresent();
player.getInventory().addItem(new ItemStack[] { stack });
sender.sendMessage(ChatColor.GRAY + "You have given yourself a " + ChatColor.AQUA + stack.getItemMeta().getDisplayName()
+ ChatColor.GRAY + '.');
return true;
}
Optional<Crowbar> crowbarOptional = Crowbar.fromStack(player.getItemInHand());
if (!crowbarOptional.isPresent()) {
sender.sendMessage(ChatColor.RED + "You are not holding a Crowbar.");
return true;
}
if (args[0].equalsIgnoreCase("setspawners")) {
if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Usage: /" + label + ' ' + args[0].toLowerCase() + " <amount>");
return true;
}
Integer amount = JavaUtils.tryParseInt(args[1]);
if (amount == null) {
sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a number.");
return true;
}
if (amount.intValue() < 0) {
sender.sendMessage(ChatColor.RED + "You cannot set Spawner uses to an amount less than " + 0 + '.');
return true;
}
if (amount.intValue() > 1) {
sender.sendMessage(ChatColor.RED + "Crowbars have maximum Spawner uses of " + 1 + '.');
return true;
}
Crowbar crowbar = (Crowbar) crowbarOptional.get();
crowbar.setSpawnerUses(amount.intValue());
player.setItemInHand(crowbar.getItemIfPresent());
sender.sendMessage(ChatColor.GRAY + "Set Spawner uses of held Crowbar to " + ChatColor.AQUA + amount + ChatColor.GRAY + '.');
return true;
}
if (!args[0].equalsIgnoreCase("setendframes")) {
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <spawn|setspawners|setendframes>");
return true;
}
if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Usage: /" + label + ' ' + args[0].toLowerCase() + " <amount>");
return true;
}
Integer amount = JavaUtils.tryParseInt(args[1]);
if (amount == null) {
sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a number.");
return true;
}
if (amount.intValue() < 0) {
sender.sendMessage(ChatColor.RED + "You cannot set End Frame uses to an amount less than " + 0 + '.');
return true;
}
if (amount.intValue() > 5) {
sender.sendMessage(ChatColor.RED + "Crowbars have maximum End Frame uses of " + 1 + '.');
return true;
}
Crowbar crowbar = (Crowbar) crowbarOptional.get();
crowbar.setEndFrameUses(amount.intValue());
player.setItemInHand(crowbar.getItemIfPresent());
sender.sendMessage(ChatColor.GRAY + "Set End Frame uses of held Crowbar to " + ChatColor.AQUA + amount + ChatColor.GRAY + '.');
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return args.length == 1 ? BukkitUtils.getCompletions(args, this.completions) : Collections.emptyList();
}
}

View File

@ -0,0 +1,60 @@
package club.curahq.core.commands.staff;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType;
import com.google.common.collect.ImmutableSet;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseConstants;
public class FeedCommand implements CommandExecutor {
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player onlyTarget = null;
Collection<Player> targets;
if ((args.length > 0) && (sender.hasPermission(command.getPermission() + ".others"))) {
if ((args[0].equalsIgnoreCase("all")) && (sender.hasPermission(command.getPermission() + ".all"))) {
targets = ImmutableSet.copyOf(Bukkit.getOnlinePlayers());
} else {
if (((onlyTarget = BukkitUtils.playerWithNameOrUUID(args[0])) == null)) {
sender.sendMessage(
String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
targets = ImmutableSet.of(onlyTarget);
}
} else {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Useage: /Feed <player>");
return true;
}
targets = ImmutableSet.of(onlyTarget = (Player) sender);
}
if ((onlyTarget != null) && (onlyTarget.getFoodLevel() == 20)) {
sender.sendMessage(ChatColor.RED + onlyTarget.getName() + " already has full hunger.");
return true;
}
for (Player target : targets) {
target.removePotionEffect(PotionEffectType.HUNGER);
target.setFoodLevel(20);
}
sender.sendMessage(ChatColor.GRAY.toString() + "Your hunger has been replenished"
+ (onlyTarget == null ? "all online players" : onlyTarget.getName()) + '.');
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return args.length == 1 ? null : Collections.emptyList();
}
}

View File

@ -0,0 +1,74 @@
package club.curahq.core.commands.staff;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseCommand;
import club.curahq.core.util.core.BaseConstants;
public class FixCommand
extends BaseCommand
{
public FixCommand()
{
super("fix", "Allows repairing of damaged tools for a player.");
setUsage("/(command) <playerName> [all]");
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
Player target;
if (args.length > 0)
{
target = BukkitUtils.playerWithNameOrUUID(args[0]);
}
else
{
if (!(sender instanceof Player))
{
sender.sendMessage(getUsage(label));
return true;
}
target = (Player)sender;
}
if ((target == null) || (!BaseCommand.canSee(sender, target)))
{
sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
Set<ItemStack> toRepair = new HashSet<ItemStack>();
if ((args.length >= 1) && (args[1].equalsIgnoreCase("all")))
{
PlayerInventory targetInventory = target.getInventory();
toRepair.addAll(Arrays.asList(targetInventory.getContents()));
toRepair.addAll(Arrays.asList(targetInventory.getArmorContents()));
}
else
{
toRepair.add(target.getItemInHand());
}
for (ItemStack stack : toRepair) {
if ((stack != null) && (stack.getType() != Material.AIR)) {
stack.setDurability((short)0);
}
}
sender.sendMessage(ChatColor.GRAY + "Repaired " + (toRepair.size() > 1 ? "all" : "item in hand") + " of " + target.getName() + '.');
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args)
{
return args.length == 1 ? null : Collections.emptyList();
}
}

View File

@ -0,0 +1,54 @@
package club.curahq.core.commands.staff;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class FlyCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("fly")) {
if (!sender.hasPermission("command.fly")) {
sender.sendMessage(ChatColor.RED + "You lack the sufficient permissions to execute this command.");
return true;
}
if (args.length < 1) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You must be a player to execute this command");
return true;
}
Player p = (Player) sender;
if (p.getAllowFlight()) {
p.setAllowFlight(false);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &cdisabled &fyour &eFlight Mode"));
return true;
}
p.setAllowFlight(true);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &aenabled &fyour &eFlight Mode"));
return true;
}
if (!sender.hasPermission("command.fly.others")) {
sender.sendMessage(ChatColor.RED + "You lack the sufficient permissions to execute this command.");
return true;
}
Player t = Bukkit.getPlayer(args[0]);
if (t == null) {
sender.sendMessage("<EFBFBD>cPlayer not found.");
return true;
}
if (t.getAllowFlight()) {
t.setAllowFlight(false);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &cdisabled &f" + t.getName() + "'s &eFlight Mode"));
return true;
}
t.setAllowFlight(true);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &aenabled &f" + t.getName() + "'s &eFlight Mode"));
return true;
}
return false;
}
}

View File

@ -0,0 +1,294 @@
package club.curahq.core.commands.staff;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitRunnable;
import club.curahq.core.Core;
import club.curahq.core.commands.PlayerFreezeEvent;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.chat.ClickAction;
import club.curahq.core.util.chat.Text;
import club.curahq.core.util.core.ConfigUtil;
import me.apache.commons.lang3.time.DurationFormatUtils;
import net.minecraft.util.gnu.trove.map.TObjectLongMap;
import net.minecraft.util.gnu.trove.map.hash.TObjectLongHashMap;
@SuppressWarnings("deprecation")
public class FreezeCommand implements Listener, CommandExecutor {
private final static TObjectLongMap<UUID> frozenPlayers = new TObjectLongHashMap<UUID>();
public static long defaultFreezeDuration;
private long serverFrozenMillis;
public static HashSet<String> frozen = new HashSet<String>();
public FreezeCommand(Core plugin) {
FreezeCommand.defaultFreezeDuration = TimeUnit.MINUTES.toMillis(60);
Bukkit.getServer().getPluginManager().registerEvents((Listener) this, (Plugin) plugin);
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length < 1) {
sender.sendMessage((Object) ChatColor.RED + "Usage: /Freeze <all|player>");
return true;
}
String reason = null;
Long freezeTicks = FreezeCommand.defaultFreezeDuration;
long millis = System.currentTimeMillis();
if (args[0].equalsIgnoreCase("all") && sender.hasPermission(command.getPermission() + ".all")) {
long oldTicks = this.getRemainingServerFrozenMillis();
if (oldTicks > 0) {
freezeTicks = (long) 0;
}
this.serverFrozenMillis = millis + FreezeCommand.defaultFreezeDuration;
Bukkit.getServer()
.broadcastMessage((Object) ChatColor.GRAY + "The server is " + (freezeTicks > 0
? new StringBuilder().append("now frozen for ")
.append(DurationFormatUtils.formatDurationWords((long) freezeTicks, (boolean) true,
(boolean) true))
.toString()
: "no longer frozen")
+ (reason == null ? ""
: new StringBuilder().append(" with reason ").append(reason).toString())
+ '.');
return true;
}
Player target = Bukkit.getServer().getPlayer(args[0]);
if (target == null) {
sender.sendMessage((Object) ChatColor.GOLD + "Player '" + (Object) ChatColor.WHITE + args[0]
+ (Object) ChatColor.GOLD + "' not found.");
return true;
}
if (target.equals((Object) sender)) {
sender.sendMessage((Object) ChatColor.RED + "You cannot freeze yourself.");
return true;
}
UUID targetUUID = target.getUniqueId();
boolean shouldFreeze = FreezeCommand.getRemainingPlayerFrozenMillis(targetUUID) > 0;
PlayerFreezeEvent playerFreezeEvent = new PlayerFreezeEvent(target, shouldFreeze);
Bukkit.getServer().getPluginManager().callEvent((Event) playerFreezeEvent);
if (playerFreezeEvent.isCancelled()) {
sender.sendMessage((Object) ChatColor.RED + "Unable to freeze " + target.getName() + '.');
return false;
}
if (shouldFreeze) {
FreezeCommand.frozen.remove(target.getName());
FreezeCommand.frozenPlayers.remove((Object) targetUUID);
target.sendMessage((Object) ChatColor.GREEN + "You have been un-frozen.");
Command.broadcastCommandMessage((CommandSender) sender,
(String) ((Object) ChatColor.GRAY + target.getName() + " is no longer frozen."));
} else {
FreezeCommand.frozen.add(target.getName());
FreezeCommand.frozenPlayers.put(targetUUID, millis + freezeTicks);
String timeString = DurationFormatUtils.formatDurationWords((long) freezeTicks, (boolean) true,
(boolean) true);
this.Message(target.getName());
Command.broadcastCommandMessage((CommandSender) sender,
(String) ((Object) ChatColor.GRAY + target.getName() + " is now frozen for " + timeString + '.'));
}
return true;
}
private void Message(final String name) {
new HashMap<Object, Object>();
final Player p = Bukkit.getPlayer((String) name);
new BukkitRunnable() {
public void run() {
if (FreezeCommand.frozen.contains(name)) {
p.sendMessage("");
p.sendMessage(ChatColor.GRAY + "§8§m---------§8§m-----------§8§m------");
p.sendMessage(ChatColor.GRAY + "You have been frozen by a staff member.");
p.sendMessage(ChatColor.GRAY + "If you disconnect you will be " + (Object) ChatColor.DARK_RED
+ (Object) ChatColor.BOLD + "BANNED" + (Object) ChatColor.GRAY + '.');
p.sendMessage(
ChatColor.GRAY + "Please connect to our Teamspeak" + (Object) ChatColor.GRAY + '.');
new Text(ChatColor.GRAY + " (" + ConfigUtil.TEAMSPEAK_URL + ") "
+ (Object) ChatColor.ITALIC + "Click me to download" + (Object) ChatColor.GRAY + '.')
.setClick(ClickAction.OPEN_URL, "http://www.teamspeak.com/downloads")
.send((CommandSender) p);
p.sendMessage(ChatColor.GRAY + "§8§m---------§8§m-----------§8§m------");
p.sendMessage("");
} else {
this.cancel();
}
}
}.runTaskTimerAsynchronously((Plugin) Core.getPlugin(), 0, 30);
}
public void onFreezeGUI(Player p) {
Inventory inv = Bukkit.getServer().createInventory(null, 9, ChatColor.RED + "You are frozen!");
ItemStack redglass = new ItemStack(Material.STAINED_GLASS_PANE, 1, (short) 14);
ItemStack freezepaper = new ItemStack(Material.PAPER);
ItemMeta redglassmeta = redglass.getItemMeta();
ItemMeta freezepapermeta = freezepaper.getItemMeta();
redglassmeta.setDisplayName(ChatColor.RED + "You are frozen!");
freezepapermeta.setDisplayName(ChatColor.RED + "Teamspeak: (ts.kitmap.us)");
redglass.setItemMeta(redglassmeta);
freezepaper.setItemMeta(freezepapermeta);
inv.setItem(0, redglass);
inv.setItem(1, redglass);
inv.setItem(2, redglass);
inv.setItem(3, redglass);
inv.setItem(4, freezepaper);
inv.setItem(5, redglass);
inv.setItem(6, redglass);
inv.setItem(7, redglass);
inv.setItem(8, redglass);
p.openInventory(inv);
}
@SuppressWarnings("unlikely-arg-type")
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onClick(InventoryClickEvent e) {
Player player = (Player) e.getWhoClicked();
if (FreezeCommand.frozen.contains(player)) {
e.setCancelled(true);
}
}
@SuppressWarnings("unlikely-arg-type")
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onDrop(PlayerDropItemEvent e) {
Player player = (Player) e.getPlayer();
if (FreezeCommand.frozen.contains(player)) {
e.setCancelled(true);
}
}
@SuppressWarnings("unlikely-arg-type")
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBreak(BlockBreakEvent e) {
Player player = (Player) e.getPlayer();
if (FreezeCommand.frozen.contains(player)) {
e.setCancelled(true);
}
}
@SuppressWarnings("unlikely-arg-type")
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onBreak(BlockPlaceEvent e) {
Player player = (Player) e.getPlayer();
if (FreezeCommand.frozen.contains(player)) {
e.setCancelled(true);
}
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return args.length == 1 ? null : Collections.emptyList();
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
Player attacker = BukkitUtils.getFinalAttacker((EntityDamageEvent) event, false);
if (attacker == null) {
return;
}
Player player = (Player) entity;
if (!(this.getRemainingServerFrozenMillis() <= 0
&& FreezeCommand.getRemainingPlayerFrozenMillis(player.getUniqueId()) <= 0
|| player.hasPermission("command.freeze.bypass"))) {
attacker.sendMessage(
(Object) ChatColor.RED + player.getName() + " is currently frozen, you may not attack.");
event.setCancelled(true);
return;
}
if (!(this.getRemainingServerFrozenMillis() <= 0
&& FreezeCommand.getRemainingPlayerFrozenMillis(attacker.getUniqueId()) <= 0
|| attacker.hasPermission("command.freeze.bypass"))) {
event.setCancelled(true);
attacker.sendMessage((Object) ChatColor.RED + "You may not attack players whilst frozen.");
}
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPreCommandProcess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
if (!(this.getRemainingServerFrozenMillis() <= 0
&& FreezeCommand.getRemainingPlayerFrozenMillis(player.getUniqueId()) <= 0
|| player.hasPermission("command.freeze.bypass"))) {
event.setCancelled(true);
player.sendMessage((Object) ChatColor.RED + "You may not use commands whilst frozen.");
}
}
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerMove(PlayerMoveEvent event) {
Location from = event.getFrom();
Location to = event.getTo();
if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) {
return;
}
Player player = event.getPlayer();
if (!(this.getRemainingServerFrozenMillis() <= 0
&& FreezeCommand.getRemainingPlayerFrozenMillis(player.getUniqueId()) <= 0
|| player.hasPermission("command.freeze.bypass"))) {
event.setTo(event.getFrom());
}
}
@EventHandler
public void onPlayerQuit(final PlayerQuitEvent e) {
if (FreezeCommand.frozen.contains(e.getPlayer().getName())) {
for (final Player online : Bukkit.getOnlinePlayers()) {
if (!online.hasPermission("command.command.freeze")) {
continue;
}
new Text(ChatColor.GRAY + e.getPlayer().getName() + " has " + ChatColor.DARK_RED + "QUIT" + ChatColor.GRAY + " while frozen. " + ChatColor.GRAY + ChatColor.ITALIC + "(Click here to ban)").setHoverText(ChatColor.GRAY + "Click here to permanently ban " + ChatColor.GRAY + e.getPlayer().getName()).setClick(ClickAction.RUN_COMMAND, "/ban " + e.getPlayer().getName() + " Disconnected whilst Frozen").send((CommandSender)online);
}
}
}
public long getRemainingServerFrozenMillis() {
return this.serverFrozenMillis - System.currentTimeMillis();
}
public static long getRemainingPlayerFrozenMillis(UUID uuid) {
long remaining = frozenPlayers.get((Object) uuid);
if (remaining == frozenPlayers.getNoEntryValue()) {
return 0;
}
return remaining - System.currentTimeMillis();
}
}

View File

@ -0,0 +1,93 @@
package club.curahq.core.commands.staff;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseConstants;
public class GameModeCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Usage: /gamemode <mode> <player>");
return true;
}
GameMode mode = getGameModeByName(args[0]);
if (mode == null) {
sender.sendMessage(ChatColor.RED + "Gamemode '" + args[0] + "' not found.");
return true;
}
Player target;
if (args.length > 1) {
if (sender.hasPermission(command.getPermission() + ".others")) {
target = BukkitUtils.playerWithNameOrUUID(args[1]);
} else {
target = null;
}
} else {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Usage: /gamemode <mode> <player>");
return true;
}
target = (Player) sender;
}
if ((target == null)) {
sender.sendMessage(
String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[1] }));
return true;
}
if (target.getGameMode() == mode) {
sender.sendMessage(ChatColor.RED + "Gamemode of " + target.getName() + " is already " + mode.name() + '.');
return true;
}
target.setGameMode(mode);
Command.broadcastCommandMessage(sender, ChatColor.WHITE + "Set gamemode of " + ChatColor.GOLD + target.getName() + ChatColor.WHITE + " to " + ChatColor.GOLD + mode.name() + ChatColor.WHITE + '.');
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 1) {
return Collections.emptyList();
}
GameMode[] gameModes = GameMode.values();
List<String> results = new ArrayList<String>(gameModes.length);
GameMode[] arrayOfGameMode1;
int j = (arrayOfGameMode1 = gameModes).length;
for (int i = 0; i < j; i++) {
GameMode mode = arrayOfGameMode1[i];
results.add(mode.name());
}
return BukkitUtils.getCompletions(args, results);
}
private GameMode getGameModeByName(String id) {
id = id.toLowerCase(Locale.ENGLISH);
if ((id.equalsIgnoreCase("gmc")) || (id.contains("creat")) || (id.equalsIgnoreCase("1"))
|| (id.equalsIgnoreCase("c"))) {
return GameMode.CREATIVE;
}
if ((id.equalsIgnoreCase("gms")) || (id.contains("survi")) || (id.equalsIgnoreCase("0"))
|| (id.equalsIgnoreCase("s"))) {
return GameMode.SURVIVAL;
}
if ((id.equalsIgnoreCase("gma")) || (id.contains("advent")) || (id.equalsIgnoreCase("2"))
|| (id.equalsIgnoreCase("a"))) {
return GameMode.ADVENTURE;
}
if ((id.equalsIgnoreCase("gmt")) || (id.contains("toggle")) || (id.contains("cycle"))
|| (id.equalsIgnoreCase("t"))) {
return null;
}
return null;
}
}

View File

@ -0,0 +1,75 @@
package club.curahq.core.commands.staff;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import club.curahq.core.Core;
import club.curahq.core.util.core.BaseCommand;
public class GiveCommand extends BaseCommand
{
public GiveCommand()
{
super("give", "Gives an item to a player.");
setUsage("/(command) <playerName> <itemName> [quantity]");
}
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable for players.");
return true;
}
Player p = (Player)sender;
if (args.length < 2) {
p.sendMessage(ChatColor.RED + getUsage());
return true;
}
if (Bukkit.getPlayer(args[0]) == null) {
sender.sendMessage(ChatColor.RED + "Player not found.");
return true;
}
Player t = Bukkit.getPlayer(args[0]);
if (Core.getPlugin().getItemDb().getItem(args[1]) == null) {
sender.sendMessage(ChatColor.RED + "Item named or with ID " + ChatColor.GOLD + args[1] + ChatColor.GRAY + " not found.");
return true;
}
if (args.length == 2) {
if (!t.getInventory().addItem(new ItemStack[] { Core.getPlugin().getItemDb().getItem(args[1], Core.getPlugin().getItemDb().getItem(args[1]).getMaxStackSize()) }).isEmpty()) {
p.sendMessage(ChatColor.RED + "The inventory of the player is full.");
return true;
}
for (Player on : Bukkit.getOnlinePlayers()) {
if (on.hasPermission("core.give")) {
if (on != p) {
on.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + p.getName() + ChatColor.GRAY + " has given " + t.getName() + ChatColor.GOLD + " 64 " + Core.getPlugin().getItemDb().getName(Core.getPlugin().getItemDb().getItem(args[1])) + "]");
} else {
on.sendMessage(ChatColor.GRAY + "You gave " + ChatColor.GOLD + ChatColor.BOLD + t.getName() + ChatColor.GRAY + " " + " 64 " + Core.getPlugin().getItemDb().getName(Core.getPlugin().getItemDb().getItem(args[1])));
}
}
}
}
if (args.length == 3) {
if (!t.getInventory().addItem(new ItemStack[] { Core.getPlugin().getItemDb().getItem(args[1], Integer.parseInt(args[2])) }).isEmpty()) {
p.sendMessage(ChatColor.RED + "The inventory of the player is full.");
return true;
}
for (Player on : Bukkit.getOnlinePlayers()) {
if (on.hasPermission("command.give")) {
if (on != p) {
on.sendMessage(ChatColor.GRAY + "[" + ChatColor.GOLD + p.getName() + ChatColor.GRAY + " has given " + ChatColor.GOLD + t.getName() + ChatColor.GRAY + " " + args[2] + " " + Core.getPlugin().getItemDb().getName(Core.getPlugin().getItemDb().getItem(args[1])) + "]");
} else {
on.sendMessage(ChatColor.GRAY + "You gave " + ChatColor.GOLD + ChatColor.BOLD + t.getName() + ChatColor.GRAY + " " + args[2] + " " + Core.getPlugin().getItemDb().getName(Core.getPlugin().getItemDb().getItem(args[1])));
}
}
}
}
return true;
}
}

View File

@ -0,0 +1,57 @@
package club.curahq.core.commands.staff;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.listener.GodListener;
public class GodCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("god")) {
if (!sender.hasPermission("command.god")) {
sender.sendMessage(ChatColor.RED + "You lack the sufficient permissions to execute this command.");
return true;
}
if (args.length < 1) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You cannot execute this command from CONSOLE");
return true;
}
Player p = (Player) sender;
if (GodListener.getInstance().isinGod(p)) {
GodListener.getInstance().setGod(p, false);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &cdisabled &fyour &6GOD MODE"));
return true;
}
GodListener.getInstance().setGod(p, true);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &aenabled &fyour &6GOD MODE"));
return true;
}
if (!sender.hasPermission("command.god.others")) {
sender.sendMessage(ChatColor.RED + "You lack the sufficient permissions to execute this command.");
return true;
}
Player t = Bukkit.getPlayer(args[0]);
if (t == null) {
sender.sendMessage("<EFBFBD>cPlayer not found.");
return true;
}
if (GodListener.getInstance().isinGod(t)) {
GodListener.getInstance().setGod(t, false);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &cdisabled &f" + t.getName() + "'s &6GOD MODE"));
return true;
}
GodListener.getInstance().setGod(t, true);
t.setAllowFlight(true);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &aenabled &f" + t.getName() + "'s &6GOD MODE"));
return true;
}
return false;
}
}

View File

@ -0,0 +1,60 @@
package club.curahq.core.commands.staff;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.google.common.collect.ImmutableSet;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseConstants;
import net.md_5.bungee.api.ChatColor;
public class HealCommand implements CommandExecutor {
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player onlyTarget = null;
Collection<Player> targets;
if ((args.length > 0) && (sender.hasPermission("command.heal"))) {
if ((args[0].equalsIgnoreCase("all")) && (sender.hasPermission(command.getPermission() + ".all"))) {
targets = ImmutableSet.copyOf(Bukkit.getOnlinePlayers());
} else {
if (((onlyTarget = BukkitUtils.playerWithNameOrUUID(args[0])) == null)) {
sender.sendMessage(
String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
targets = ImmutableSet.of(onlyTarget);
}
} else {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Useage: /heal <player>");
return true;
}
targets = ImmutableSet.of(onlyTarget = (Player) sender);
}
for (Player target : targets) {
target.removePotionEffect(PotionEffectType.HUNGER);
target.setHealth(20);
target.setFoodLevel(20);
for (PotionEffect effect : target.getActivePotionEffects())
target.removePotionEffect(effect.getType());
}for (Player target : targets) {
sender.sendMessage(ChatColor.GRAY.toString() + "You have healed " + target.getDisplayName() + "." ); }
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return args.length == 1 ? null : Collections.emptyList();
}
}

View File

@ -0,0 +1,122 @@
package club.curahq.core.commands.staff;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumMap;
import java.util.List;
import java.util.Map;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import club.curahq.core.Core;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseConstants;
public class InvSeeCommand implements Listener, CommandExecutor {
private final InventoryType[] types;
private final Map<InventoryType, Inventory> inventories;
public InvSeeCommand(Core plugin) {
this.types = new InventoryType[] { InventoryType.BREWING, InventoryType.CHEST, InventoryType.DISPENSER,
InventoryType.ENCHANTING, InventoryType.FURNACE, InventoryType.HOPPER, InventoryType.PLAYER,
InventoryType.WORKBENCH };
this.inventories = new EnumMap<InventoryType, Inventory>(InventoryType.class);
Bukkit.getPluginManager().registerEvents(this, plugin);
}
public boolean isPlayerOnlyCommand() {
return true;
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Usage: /invsee <player>");
return true;
}
Player target = BukkitUtils.playerWithNameOrUUID(args[0]);
if (target == null) {
sender.sendMessage(
String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
sender.sendMessage(ChatColor.GRAY + "This players inventory contains: ");
ItemStack[] arrayOfItemStack;
int j = (arrayOfItemStack = target.getInventory().getContents()).length;
for (int i = 0; i < j; i++) {
ItemStack items = arrayOfItemStack[i];
if (items != null) {
sender.sendMessage(ChatColor.GOLD + items.getType().toString().replace("_", "").toLowerCase() + ": "
+ items.getAmount());
}
}
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Usage: /Invsee <player>");
return true;
}
Player player = (Player) sender;
Inventory inventory = null;
InventoryType[] types = this.types;
int length = types.length;
int i = 0;
while (i < length) {
InventoryType type = types[i];
if (type.name().equalsIgnoreCase(args[0])) {
Inventory inventoryRevert;
inventory = (Inventory) this.inventories.putIfAbsent(type,
inventoryRevert = Bukkit.createInventory(player, type));
if (inventory != null) {
break;
}
inventory = inventoryRevert;
break;
}
i++;
}
if (inventory == null) {
Player target2 = BukkitUtils.playerWithNameOrUUID(args[0]);
if (sender.equals(target2)) {
sender.sendMessage(ChatColor.RED + "You cannot check the inventory of yourself.");
return true;
}
if ((target2 == null)) {
sender.sendMessage(
String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
inventory = target2.getInventory();
}
player.openInventory(inventory);
return true;
}
@SuppressWarnings("deprecation")
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 1) {
return Collections.emptyList();
}
InventoryType[] values = InventoryType.values();
List<String> results = new ArrayList<String>(values.length);
Player senderPlayer = (Player) sender;
Player[] arrayOfPlayer;
int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
for (int i = 0; i < j; i++) {
Player target = arrayOfPlayer[i];
if ((senderPlayer == null) || (senderPlayer.canSee(target))) {
results.add(target.getName());
}
}
return BukkitUtils.getCompletions(args, results);
}
}

View File

@ -0,0 +1,50 @@
package club.curahq.core.commands.staff;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import club.curahq.core.util.core.BasePlugins;
public class ItemCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable for players.");
return true;
}
String amount = "";
Player p = (Player) sender;
if (args.length == 0) {
p.sendMessage(ChatColor.RED + "Usage: /I <item>");
return true;
}
if (BasePlugins.getPlugin().getItemDb().getItem(args[0]) == null) {
sender.sendMessage(ChatColor.RED + "Item or ID not found.");
return true;
}
if (args.length == 1) {
if (!p.getInventory().addItem(new ItemStack[] { BasePlugins.getPlugin().getItemDb().getItem(args[0],
BasePlugins.getPlugin().getItemDb().getItem(args[0]).getMaxStackSize()) }).isEmpty()) {
p.sendMessage(ChatColor.RED + "Your inventory is full.");
return true;
}
}
if (args.length == 2) {
if (!p.getInventory().addItem(
new ItemStack[] { BasePlugins.getPlugin().getItemDb().getItem(args[0], Integer.parseInt(args[1])) })
.isEmpty()) {
p.sendMessage(ChatColor.RED + "Your inventory is full.");
return true;
}
amount = args[1];
}
Command.broadcastCommandMessage(sender, ChatColor.GRAY + p.getName() + " gave himself " + amount + ", "
+ BasePlugins.getPlugin().getItemDb().getName(BasePlugins.getPlugin().getItemDb().getItem(args[0])),
true);
return true;
}
}

View File

@ -0,0 +1,61 @@
package club.curahq.core.commands.staff;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseCommand;
public class KillCommand extends BaseCommand {
public KillCommand() {
super("kill", "Kills a player.");
setAliases(new String[] { "slay" });
setUsage("/(command) <player>");
}
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player target;
if ((args.length > 0)
&& (sender.hasPermission(String.valueOf(String.valueOf(command.getPermission())) + ".others"))) {
target = BukkitUtils.playerWithNameOrUUID(args[0]);
} else {
if (!(sender instanceof Player)) {
sender.sendMessage(getUsage(label));
return true;
}
target = (Player) sender;
}
if (target.isDead()) {
sender.sendMessage(ChatColor.RED + target.getName() + " is already dead.");
return true;
}
EntityDamageEvent event = new EntityDamageEvent(target, EntityDamageEvent.DamageCause.SUICIDE, 10000);
Bukkit.getPluginManager().callEvent(event);
if (event.isCancelled()) {
sender.sendMessage(ChatColor.RED + "You cannot kill " + target.getName() + '.');
return true;
}
target.setLastDamageCause(event);
target.setHealth(0.0D);
if (sender.equals(target)) {
sender.sendMessage(ChatColor.RED + "You have been killed.");
return true;
}
Command.broadcastCommandMessage(sender, ChatColor.GRAY + "Slain player " + ChatColor.GOLD + target.getName() + '.');
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return (args.length == 1)
&& (sender.hasPermission(String.valueOf(String.valueOf(command.getPermission())) + ".others")) ? null
: Collections.emptyList();
}
}

View File

@ -0,0 +1,61 @@
package club.curahq.core.commands.staff;
import java.util.Collection;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.event.Listener;
import me.apache.commons.lang3.text.WordUtils;
public class LagCommand implements Listener, CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
double tps = Bukkit.spigot().getTPS()[0];
double lag = Math.round((1.0D - tps / 20.0D) * 100.0D);
ChatColor colour;
if (tps >= 18.0D) {
colour = ChatColor.GREEN;
} else {
if (tps >= 15.0D) {
colour = ChatColor.YELLOW;
} else {
colour = ChatColor.RED;
}
}
sender.sendMessage("§7§m-----------------------------------------------------");
String nameOS= System.getProperty("os.name");
sender.sendMessage(colour + "OS: " + nameOS);
sender.sendMessage(colour + "Server TPS is currently at " + Math.round(tps * 10000.0D) / 10000.0D + '.');
sender.sendMessage(colour + "Server lag is currently at " + Math.round(lag * 10000.0D) / 10000.0D + '%');
if (sender.hasPermission(command.getPermission() + ".memory")) {
Runtime runtime = Runtime.getRuntime();
sender.sendMessage(colour + "Processor: " + System.getenv("PROCESSOR_IDENTIFIER"));
sender.sendMessage(colour + "Available Processors: " + runtime.availableProcessors());
sender.sendMessage(colour + "Max Memory: " + runtime.maxMemory() / 1048576L + "MB");
sender.sendMessage(colour + "Total Memory: " + runtime.totalMemory() / 1048576L + "MB");
sender.sendMessage(colour + "Free Memory: " + runtime.freeMemory() / 1048576L + "MB");
Collection<World> worlds = Bukkit.getWorlds();
for (World world : worlds) {
World.Environment environment = world.getEnvironment();
String environmentName = WordUtils.capitalizeFully(environment.name().replace('_', ' '));
int tileEntities = 0;
Chunk[] loadedChunks2;
Chunk[] loadedChunks = loadedChunks2 = world.getLoadedChunks();
for (Chunk chunk : loadedChunks2) {
tileEntities += chunk.getTileEntities().length;
}
sender.sendMessage(ChatColor.RED + world.getName() + '(' + environmentName + "): " + ChatColor.YELLOW
+ loadedChunks.length + " chunks, " + world.getEntities().size() + " entities, " + tileEntities
+ " tile entities.");
}
sender.sendMessage("§7§m-----------------------------------------------------");
}
return true;
}
}

View File

@ -0,0 +1,120 @@
package club.curahq.core.commands.staff;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import club.curahq.core.Core;
import net.md_5.bungee.api.ChatColor;
public class MiscCommands implements CommandExecutor {
public boolean onCommand (final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You cannot do this in console");
return true;
}
final Player p = (Player)sender;
p.getLocation();
p.getInventory();
String perm = ChatColor.translateAlternateColorCodes('&', "&cNo.");
perm = perm.replaceAll("&", "<EFBFBD>");
if (cmd.getName().equalsIgnoreCase("copyinv")) {
if (!p.hasPermission("copyinv.yes")) {
p.sendMessage(perm);
return true;
}
if (args.length == 0) {
p.sendMessage(ChatColor.GRAY + "/copyinv <Player>");
}
if (args.length == 1) {
final Player all2 = Bukkit.getPlayer(args[0]);
if (all2 == null) {
p.sendMessage(ChatColor.RED + "That player does not exist!");
}
else {
final ItemStack[] armor = all2.getInventory().getArmorContents();
p.getInventory().clear();
p.getInventory().setArmorContents((ItemStack[])null);
p.getInventory().setArmorContents(armor);
final ItemStack[] inv = all2.getInventory().getContents();
final HashMap<Player, ItemStack[]> itemhash = new HashMap<Player, ItemStack[]>();
itemhash.put(p, inv);
final ItemStack[] items = itemhash.get(p);
p.getInventory().setContents(items);
p.sendMessage(ChatColor.GRAY + "Copying " + ChatColor.RED + args[0] + ChatColor.GRAY + " Inventory");
}
}
}
if (cmd.getName().equalsIgnoreCase("fsay")) {
if (!p.hasPermission("fsay.yes")) {
p.sendMessage(perm);
return true;
}
if (args.length == 0) {
sender.sendMessage(ChatColor.GRAY + "/fsay <player> <message>");
return true;
}
if (args.length == 1) {
sender.sendMessage(ChatColor.GRAY + "/fsay <player> <message>");
}
else if (args.length >= 2) {
final Player user = Bukkit.getServer().getPlayer(args[0]);
if (user == null) {
final StringBuilder message = new StringBuilder(args[1]);
for (int arg2 = 2; arg2 < args.length; ++arg2) {
message.append(" ").append(args[arg2]);
}
return true;
}
final StringBuilder message = new StringBuilder(args[1]);
for (int arg2 = 2; arg2 < args.length; ++arg2) {
message.append(" ").append(args[arg2]);
}
user.chat(message.toString());
}
}
if (!cmd.getName().equalsIgnoreCase("slowstop")) {
return false;
}
if (!p.hasPermission("core.slowstop")) {
p.sendMessage(perm);
return true;
}
new BukkitRunnable() {
int i = 15;
@Override
public void run() {
if(i > 0) {
Bukkit.broadcastMessage(ChatColor.GOLD + "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588");
Bukkit.broadcastMessage(ChatColor.GOLD + "\u2588\u2588\u2588\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588\u2588\u2588");
Bukkit.broadcastMessage(ChatColor.GOLD + "\u2588\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588");
Bukkit.broadcastMessage(ChatColor.GOLD + "\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588");
Bukkit.broadcastMessage(ChatColor.GOLD + "\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588");
Bukkit.broadcastMessage(ChatColor.GOLD + "\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588\u2588\u2588\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588" + " " + ChatColor.RED + "Server Restarting in " + i + " seconds.");
Bukkit.broadcastMessage(ChatColor.GOLD + "\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588\u2588\u2588\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588");
Bukkit.broadcastMessage(ChatColor.GOLD + "\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588\u2588\u2588\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588");
Bukkit.broadcastMessage(ChatColor.GOLD + "\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588\u2588\u2588" + ChatColor.DARK_RED + "\u2588" + ChatColor.GOLD + "\u2588\u2588");
Bukkit.broadcastMessage(ChatColor.GOLD + "\u2588\u2588\u2588" + ChatColor.DARK_RED + "\u2588\u2588\u2588\u2588\u2588" + ChatColor.GOLD + "\u2588\u2588\u2588");
Bukkit.broadcastMessage(ChatColor.GOLD + "\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588");
}
if(i == 0) {
Bukkit.getServer().dispatchCommand((CommandSender)Bukkit.getConsoleSender(), "restart");
}
i--;
}
}.runTaskTimer(Core.getPlugin(), 20L, 20L);
return true;
}
}

View File

@ -0,0 +1,54 @@
package club.curahq.core.commands.staff;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import club.curahq.core.util.core.BaseCommand;
public class MoreCommand extends BaseCommand {
public MoreCommand() {
super("more", "Sets your item to its maximum amount.");
setUsage("/(command)");
}
public boolean isPlayerOnlyCommand() {
return true;
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable for players.");
return true;
}
Player player = (Player) sender;
ItemStack stack = player.getItemInHand();
if ((stack == null) || (stack.getType() == Material.AIR)) {
sender.sendMessage(ChatColor.RED + "You are not holding any item.");
return true;
}
Integer amount = null;
if (args.length > 0) {
Integer amount1 = Integer.valueOf(Integer.parseInt(args[0]));
if (amount1 == null) {
sender.sendMessage(ChatColor.RED + "'" + args[0] + "' is not a number.");
return true;
}
if (amount1.intValue() <= 0) {
sender.sendMessage(ChatColor.RED + "Item amounts must be positive.");
return true;
}
} else {
int curAmount = stack.getAmount();
if (curAmount >= (amount = Integer.valueOf(stack.getMaxStackSize())).intValue()) {
sender.sendMessage(ChatColor.RED + "You already have the maximum amount: " + amount + '.');
return true;
}
}
stack.setAmount(amount.intValue());
return true;
}
}

View File

@ -0,0 +1,92 @@
package club.curahq.core.commands.staff;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
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.bukkit.inventory.ItemStack;
import club.curahq.core.Core;
public class RefundCommand implements CommandExecutor, Listener {
private Core mainPlugin;
private Map<UUID, InventorySet> rollbackInv;
public Map<UUID, InventorySet> getRollbackInv() {
return this.rollbackInv;
}
public RefundCommand(Core mainPlugin) {
this.mainPlugin = mainPlugin;
this.mainPlugin.getServer().getPluginManager().registerEvents(this, this.mainPlugin);
this.rollbackInv = new HashMap<UUID, InventorySet>();
}
public class InventorySet {
private Player p;
private ItemStack[] inv;
private ItemStack[] armor;
public Player getP() {
return this.p;
}
public ItemStack[] getInv() {
return this.inv;
}
public ItemStack[] getArmor() {
return this.armor;
}
public InventorySet(Player p) {
this.p = p;
this.inv = p.getInventory().getContents();
this.armor = p.getInventory().getArmorContents();
}
}
public boolean onCommand(CommandSender s, Command c, String alias, String[] args) {
if (!s.hasPermission("core.refund")) {
s.sendMessage(ChatColor.RED + "You do not have permission.");
return true;
}
if (args.length != 1) {
s.sendMessage(ChatColor.RED + "Correct Usage: /" + c.getName() + " <player>");
return true;
}
Player p = this.mainPlugin.getServer().getPlayer(args[0]);
if (p == null) {
s.sendMessage(ChatColor.RED + "Player is not online.");
return true;
}
if (!this.rollbackInv.containsKey(p.getUniqueId())) {
s.sendMessage(ChatColor.RED + p.getName() + " does not have a stored record of his/her inventory.");
} else {
s.sendMessage(ChatColor.GREEN + p.getName() + "'s inventory has been restored.");
p.sendMessage(ChatColor.GREEN + "Your inventory was restored by " + s.getName() + ".");
InventorySet invSet = (InventorySet) this.rollbackInv.get(p.getUniqueId());
p.getInventory().setContents(invSet.getInv());
p.getInventory().setArmorContents(invSet.getArmor());
}
return true;
}
@EventHandler(priority = EventPriority.LOWEST)
public void onDeath(PlayerDeathEvent e) {
UUID entityUUID = e.getEntity().getUniqueId();
this.rollbackInv.put(entityUUID, new InventorySet(e.getEntity()));
}
}

View File

@ -0,0 +1,106 @@
package club.curahq.core.commands.staff;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import club.curahq.core.util.core.BaseCommand;
public class RenameCommand extends BaseCommand {
public static final List<String> DISALLOWED;
public RenameCommand() {
super("rename", "Rename your held item.");
this.setUsage("/(command) <newItemName>");
}
public void setUsage(String string) {
// TODO Auto-generated method stub
}
//.contains("nigger")) || (message.toLowerCase().contains("steal plugins")) || (message.toLowerCase().contains("take plugins")) || (message.toLowerCase().contains("kill yourself")) || (message.toLowerCase().contains("shit staff")
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Only players can execute this command.");
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Usage: " + "/rename <name>");
return true;
}
Player player = (Player)sender;
ItemStack stack = player.getItemInHand();
if (stack == null || stack.getType() == Material.AIR) {
sender.sendMessage(ChatColor.RED + "You are not holding anything.");
return true;
}
ItemMeta meta = stack.getItemMeta();
String oldName = meta.getDisplayName();
if (oldName != null) {
oldName = oldName.trim();
}
String newName = args[0].equalsIgnoreCase("none") || args[0].equalsIgnoreCase("null") ? null : ChatColor.translateAlternateColorCodes((char)'&', (String)StringUtils.join((Object[])args, (char)' ', (int)0, (int)args.length));
if (oldName == null && newName == null) {
sender.sendMessage(ChatColor.RED + "Your held item already has no name.");
return true;
}
if (oldName != null && oldName.equals(newName)) {
sender.sendMessage(ChatColor.RED + "Your held item is already named this.");
return true;
}
if(stack.getType() == Material.TRIPWIRE_HOOK){
sender.sendMessage(ChatColor.RED + "You cannot rename Trip wire hooks, as you can exploit it to create crate keys.");
Bukkit.broadcast(ChatColor.GRAY + player.getName() + " attempted to rename a tripwire hook to " + newName + ChatColor.GRAY + "! (Could potentially be trying to create a crate key)", "command.staffmode");
return true;
}
if (newName != null) {
final String lower = newName.toLowerCase();
for (final String word : DISALLOWED) {
if (lower.contains(word)) {
sender.sendMessage(ChatColor.RED + "You have attempted to rename your item to a disallowed name, you have now been warned.");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "warn -s " + sender.getName() + " Innapropriate renaming");
return true;
}
}
}
meta.setDisplayName(newName);
stack.setItemMeta(meta);
if (newName == null) {
sender.sendMessage(ChatColor.GRAY + "Removed name of held item from " + oldName + '.');
return true;
}
sender.sendMessage(ChatColor.GRAY + "Renamed held item from " + (oldName == null ? "no name" : oldName) + " to " + newName + ChatColor.GRAY + '.');
return true;
}
public String getUsage(String label) {
// TODO Auto-generated method stub
return null;
}
static {
DISALLOWED = Arrays.asList("hitler", "\u534d", "jews", "nigger", "n1gger", "brouard", "ddos", "nigga", "dox", "kys", "leaked", "shit staff", "my server", "join my server", "customkkk");
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return Collections.emptyList();
}
}

View File

@ -0,0 +1,28 @@
package club.curahq.core.commands.staff;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import club.curahq.core.util.core.ConfigUtil;
import me.apache.commons.lang3.time.FastDateFormat;
public class ServerTimeCommand implements CommandExecutor, TabCompleter {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
sender.sendMessage(ChatColor.GRAY + "The server time is " + ChatColor.GOLD
+ FORMAT.format(System.currentTimeMillis()) + ChatColor.GRAY + '.');
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return Collections.emptyList();
}
private static final FastDateFormat FORMAT = FastDateFormat.getInstance("E MMM dd h:mm:ssa z yyyy",
ConfigUtil.SERVER_TIME_ZONE);
}

View File

@ -0,0 +1,67 @@
package club.curahq.core.commands.staff;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import com.google.common.base.Optional;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.JavaUtils;
import club.curahq.core.util.config.WorldData;
import compat.com.google.common.collect.GuavaCompat;
public class SetBorderCommand implements CommandExecutor, TabCompleter {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Usage: /" + label + " <worldType> <amount>");
return true;
}
Optional<World.Environment> optional = GuavaCompat.getIfPresent(World.Environment.class, args[0]);
if (!optional.isPresent()) {
sender.sendMessage(ChatColor.RED + "Environment '" + args[0] + "' not found.");
return true;
}
Integer amount = JavaUtils.tryParseInt(args[1]);
if (amount == null) {
sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a valid number.");
return true;
}
if (amount.intValue() < 50) {
sender.sendMessage(ChatColor.RED + "Minimum border size is " + 50 + 100 + '.');
return true;
}
if (amount.intValue() > 250000) {
sender.sendMessage(ChatColor.RED + "Maximum border size is " + 250000 + '.');
return true;
}
World.Environment environment = (World.Environment) optional.get();
WorldData.getInstance().getConfig().set("world-" + environment + "-border", amount);
WorldData.getInstance().saveConfig();
Command.broadcastCommandMessage(sender,
ChatColor.GRAY + "Set border size of environment " + environment.name() + " to " + amount + '.');
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
if (args.length != 1) {
return Collections.emptyList();
}
World.Environment[] values = World.Environment.values();
List<String> results = new ArrayList<String>(values.length);
World.Environment[] arrayOfEnvironment1;
int j = (arrayOfEnvironment1 = values).length;
for (int i = 0; i < j; i++) {
World.Environment environment = arrayOfEnvironment1[i];
results.add(environment.name());
}
return BukkitUtils.getCompletions(args, results);
}
}

View File

@ -0,0 +1,55 @@
package club.curahq.core.commands.staff;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import club.curahq.core.Core;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.config.WorldData;
public class SetCommand implements CommandExecutor, Listener {
public SetCommand(Core plugin) {
}
public boolean onCommand(CommandSender s, Command c, String alias, String[] args) {
if (!s.hasPermission("core.admin")) {
s.sendMessage(ChatColor.RED + "You do not have permission to perform this command.");
return true;
}
Player p = (Player) s;
if ((args.length != 1)) {
p.sendMessage(ChatColor.RED + "/set <exit|end>");
p.sendMessage(ChatColor.GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
p.sendMessage(ChatColor.BLUE + ChatColor.BOLD.toString() + "Set Location " + ChatColor.GRAY + "(Page 1/1)");
p.sendMessage(ChatColor.GRAY + " /Set end" + ChatColor.GOLD + " <20> " + ChatColor.RESET
+ "Set the location for end-spawn.");
p.sendMessage(ChatColor.GRAY + " /Set exit" + ChatColor.GOLD + " <20> " + ChatColor.RESET
+ "Set the location for end-exit.");
p.sendMessage(ChatColor.GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
return true;
} else if (args[0].equalsIgnoreCase("exit")) {
Location loc = p.getLocation();
WorldData.getInstance().getConfig().set("world.exit.x", Double.valueOf(loc.getX()));
WorldData.getInstance().getConfig().set("world.exit.y", Double.valueOf(loc.getY()));
WorldData.getInstance().getConfig().set("world.exit.z", Double.valueOf(loc.getZ()));
WorldData.getInstance().saveConfig();
p.sendMessage(ChatColor.GREEN + "EndExit has been set!.");
} else if (args[0].equalsIgnoreCase("end")) {
Location loc = p.getLocation();
WorldData.getInstance().getConfig().set("world.end.entrace.x", Double.valueOf(loc.getX()));
WorldData.getInstance().getConfig().set("world.end.entrace.y", Double.valueOf(loc.getY()));
WorldData.getInstance().getConfig().set("world.end.entrace.z", Double.valueOf(loc.getZ()));
WorldData.getInstance().saveConfig();
p.sendMessage(ChatColor.GREEN + "End spawn has been set!.");
}
return true;
}
}

View File

@ -0,0 +1,64 @@
package club.curahq.core.commands.staff;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.Core;
public class SpawnCommand
implements CommandExecutor
{
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
{
Player player = (Player)sender;
if (cmd.getName().equalsIgnoreCase("spawn"))
{
if (args.length == 0) {
sendLocation(player);
return true;
}
Player target = Bukkit.getPlayer(args[0]);
if (target == null)
{
player.sendMessage(ChatColor.RED + "Player isnt online");
return true;
}
player.sendMessage(ChatColor.GREEN + target.getName() + " has been teleported to spawn!");
sendLocation(target);
return true;
}
if ((cmd.getName().equalsIgnoreCase("setspawn")) &&
(cmd.getName().equalsIgnoreCase("setspawn")))
{
Core.getPlugin().getConfig().set("spawn.world", player.getLocation().getWorld().getName());
Core.getPlugin().getConfig().set("spawn.x", Double.valueOf(player.getLocation().getX()));
Core.getPlugin().getConfig().set("spawn.y", Double.valueOf(player.getLocation().getY()));
Core.getPlugin().getConfig().set("spawn.z", Double.valueOf(player.getLocation().getZ()));
Core.getPlugin().getConfig().set("spawn.yaw", Float.valueOf(player.getLocation().getYaw()));
Core.getPlugin().getConfig().set("spawn.pitch", Float.valueOf(player.getLocation().getPitch()));
Core.getPlugin().saveConfig();
player.sendMessage(ChatColor.GREEN + "Spawn set!");
return true;
}
return false;
}
public static boolean sendLocation(Player player)
{
World w = Bukkit.getServer().getWorld(Core.getPlugin().getConfig().getString("spawn.world"));
double x = Core.getPlugin().getConfig().getDouble("spawn.x");
double y = Core.getPlugin().getConfig().getDouble("spawn.y");
double z = Core.getPlugin().getConfig().getDouble("spawn.z");
float yaw = (float)Core.getPlugin().getConfig().getDouble("spawn.yaw");
float pitch = (float)Core.getPlugin().getConfig().getDouble("spawn.pitch");
player.teleport(new Location(w, x, y, z, yaw, pitch));
return false;
}
}

View File

@ -0,0 +1,41 @@
package club.curahq.core.commands.staff;
import java.util.Collections;
import java.util.List;
import net.minecraft.util.org.apache.commons.lang3.text.WordUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import club.curahq.core.util.ItemBuilder;
public class SpawnerCommand implements CommandExecutor, TabCompleter {
public String C(String msg) {
return ChatColor.translateAlternateColorCodes('&', msg);
}
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
if (args.length == 0) {
sender.sendMessage(ChatColor.RED + "/spawner <entity>");
return false;
}
String spawner = args[0];
Player p = (Player) sender;
Inventory inv = p.getInventory();
inv.addItem(new ItemStack[] { new ItemBuilder(Material.MOB_SPAWNER).displayName(ChatColor.GREEN + "Spawner")
.loreLine(ChatColor.WHITE + WordUtils.capitalizeFully(spawner)).build() });
p.sendMessage(C("&7You just got a &6" + spawner + "&7."));
return false;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return Collections.emptyList();
}
}

View File

@ -0,0 +1,124 @@
package club.curahq.core.commands.staff;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import club.curahq.core.commands.StaffItems;
import club.curahq.core.listener.staff.VanishListener;
public class StaffModeCommand implements Listener, CommandExecutor {
public static ArrayList<Player> modMode = new ArrayList<Player>();
public static ArrayList<UUID> Staff = new ArrayList<UUID>();
public static ArrayList<Player> teleportList = new ArrayList<Player>();
public static HashMap<String, ItemStack[]> armorContents = new HashMap<>();
public static HashMap<String, ItemStack[]> inventoryContents = new HashMap<>();
public String color(String msg) {
return ChatColor.translateAlternateColorCodes('§', msg);
}
static StaffModeCommand instance = new StaffModeCommand();
public static StaffModeCommand getInstance() {
return instance;
}
public static boolean isMod(Player p) {
return Staff.contains(p.getUniqueId());
}
public static boolean enterMod(final Player p) {
modMode.add(p);
Staff.add(p.getUniqueId());
StaffItems.saveInventory(p);
VanishListener.getInstance().setVanish(p, true);
p.getInventory().clear();
p.getInventory().setHelmet(null);
p.getInventory().setChestplate(null);
p.getInventory().setLeggings(null);
p.getInventory().setBoots(null);
p.setExp(0.0F);
p.setAllowFlight(true);
p.setGameMode(GameMode.CREATIVE);
StaffItems.modItems(p);
p.sendMessage("§fYou have §aenabled §fyour §6Staff Mode");
return true;
}
public static boolean leaveMod(final Player p) {
modMode.remove(p);
Staff.remove(p.getUniqueId());
p.getInventory().clear();
StaffItems.loadInventory(p);
p.setAllowFlight(false);
VanishListener.getInstance().setVanish(p, false);
p.sendMessage(ChatColor.translateAlternateColorCodes('§', "§fYou have §cdisabled §fyour §6Staff Mode"));
p.setGameMode(GameMode.SURVIVAL);
return true;
}
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("staffmode")) {
if (!sender.hasPermission("command.mod")) {
sender.sendMessage(ChatColor.RED + "You lack the sufficient permissions to execute this command.");
return true;
}
if (args.length < 1) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "User command only");
return true;
}
if (modMode.contains(sender)) {
leaveMod((Player) sender);
return true;
}
enterMod((Player) sender);
return true;
}
if (!sender.hasPermission("command.mod.others")) {
sender.sendMessage(ChatColor.RED + "No.");
return true;
}
Player t = Bukkit.getPlayer(args[0]);
if (t == null) {
sender.sendMessage("§cPlayer not found.");
return true;
}
if (modMode.contains(t)) {
leaveMod(t);
sender.sendMessage("§fYou have §cdisabled §f" + t.getName() + "'s §6Staff Mode");
return true;
}
enterMod(t);
sender.sendMessage("§fYou have §aenabled §f" + t.getName() + "'s §6Staff Mode");
return true;
}
return false;
}
@SuppressWarnings({ "deprecation" })
public static void onDisableMod() {
Player[] arrayOfPlayer;
int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
for (int i = 0; i < j; i++) {
Player p = arrayOfPlayer[i];
if (Staff.contains(p.getUniqueId())) {
leaveMod(p);
p.sendMessage(ChatColor.RED.toString() + "You have been taken out of Staff Mode because of a reload.");
teleportList.remove(p);
}
}
}
}

View File

@ -0,0 +1,63 @@
package club.curahq.core.commands.staff;
import java.util.ArrayList;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.listener.staff.VanishListener;
public class VanishCommand implements CommandExecutor {
public static ArrayList<Player> staff = new ArrayList<Player>();
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("vanish")) {
if (!sender.hasPermission("command.vanish")) {
sender.sendMessage(ChatColor.RED + "You lack the sufficient permissions to execute this command.");
return true;
}
if (args.length < 1) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "You must be a player to execute this command");
return true;
}
Player p = (Player) sender;
VanishListener.getInstance();
if (VanishListener.isVanished(p.getPlayer())) {
VanishListener.getInstance().setVanish(p, false);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &cdisabled &fyour &6Vanish Mode"));
return true;
}
VanishListener.getInstance().setVanish(p, true);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &aenabled &fyour &6Vanish Mode"));
return true;
}
if (!sender.hasPermission("command.vanish.others")) {
sender.sendMessage(ChatColor.RED + "No.");
return true;
}
Player t = Bukkit.getPlayer(args[0]);
if (t == null) {
sender.sendMessage("§6Could not find player §f" + args[0].toString() + "§6.");
return true;
}
VanishListener.getInstance();
if (VanishListener.isVanished(t.getPlayer())) {
VanishListener.getInstance().setVanish(t, false);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &cdisabled &f" + t.getName() + "'s &6Vanish Mode"));
return true;
}
VanishListener.getInstance().setVanish(t, true);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&fYou have &aenabled &f" + t.getName() + "'s &6Vanish Mode"));
return true;
}
return false;
}
}

View File

@ -0,0 +1,68 @@
package club.curahq.core.commands.staff;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
import com.google.common.collect.ImmutableMap;
import club.curahq.core.Core;
import club.curahq.core.user.FactionUser;
import club.curahq.core.user.UserManager;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.chat.Text;
import club.curahq.core.util.core.BaseCommand;
import club.curahq.core.util.core.BaseConstants;
import club.curahq.core.util.core.StaffPriority;
import me.apache.commons.lang3.text.WordUtils;
import me.apache.commons.lang3.time.DurationFormatUtils;
public class WhoisCommand extends BaseCommand {
private final Core plugin;
public WhoisCommand(final Core plugin) {
super("whois", "Check information about a player.");
this.plugin = plugin;
this.setUsage("/(command) [playerName]");
}
@Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
if(args.length < 1) {
sender.sendMessage(this.getUsage());
return true;
}
final Player target = BukkitUtils.playerWithNameOrUUID(args[0]);
if(target == null || !BaseCommand.canSee(sender, target)) {
sender.sendMessage(String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, args[0]));
return true;
}
final Location location = target.getLocation();
final World world = location.getWorld();
sender.sendMessage(ChatColor.GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
sender.sendMessage(ChatColor.GRAY + " [" + ChatColor.GRAY + target.getDisplayName() + ChatColor.GRAY + ']');
sender.sendMessage(ChatColor.GOLD + " Hunger: " + ChatColor.GRAY + target.getFoodLevel() + '/' + 20 + " (" + target.getSaturation() + " saturation)");
sender.sendMessage(ChatColor.GOLD + " Exp/Level: " + ChatColor.GRAY + target.getExp() + '/' + target.getLevel());
sender.sendMessage(ChatColor.GOLD + " Location: " + ChatColor.GRAY + world.getName() + ' ' + ChatColor.GRAY + '[' + WordUtils.capitalizeFully(world.getEnvironment().name().replace('_', ' ')) + "] " + ChatColor.GRAY + '(' + location.getBlockX() + ", " + location.getBlockY() + ", " + location.getBlockZ() + ')');
sender.sendMessage(ChatColor.GOLD + " Operator: " + ChatColor.GRAY + target.isOp());
sender.sendMessage(ChatColor.GOLD + " GameMode: " + ChatColor.GRAY + WordUtils.capitalizeFully(target.getGameMode().name().replace('_', ' ')));
sender.sendMessage(ChatColor.GOLD + " Idle Time: " + ChatColor.GRAY + DurationFormatUtils.formatDurationWords(BukkitUtils.getIdleTime(target), true, true));
sender.sendMessage(ChatColor.GOLD + " IP4 Address: " + ChatColor.GRAY + (sender.hasPermission(command.getPermission() + ".ip") ? target.getAddress().getHostString(): ChatColor.STRIKETHROUGH + "1.1.1.1" ));
sender.sendMessage(ChatColor.GRAY + BukkitUtils.STRAIGHT_LINE_DEFAULT);
return true;
}
@Override
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) {
return (args.length == 1) ? null : Collections.emptyList();
}
}

View File

@ -0,0 +1,37 @@
package club.curahq.core.commands.teleport;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
public class TeleportAllCommand implements CommandExecutor {
@SuppressWarnings("deprecation")
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
Player player = (Player) sender;
Player[] arrayOfPlayer;
int j = (arrayOfPlayer = Bukkit.getOnlinePlayers()).length;
for (int i = 0; i < j; i++) {
Player target = arrayOfPlayer[i];
if ((!target.equals(player)) && (player.canSee(target))) {
target.teleport(player, PlayerTeleportEvent.TeleportCause.COMMAND);
}
}
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return args.length == 1 ? null : Collections.emptyList();
}
}

View File

@ -0,0 +1,75 @@
package club.curahq.core.commands.teleport;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseConstants;
public class TeleportCommand implements CommandExecutor {
static final int MAX_COORD = 30000000;
static final int MIN_COORD = -30000000;
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if ((args.length < 1) || (args.length > 4)) {
sender.sendMessage(ChatColor.RED + "Usage: /Teleport <player> | <x , y , z>");
return true;
}
Player targetA;
if ((args.length == 1) || (args.length == 3)) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Usage: /Teleport <player> | <x , y , z>");
return true;
}
targetA = (Player) sender;
} else {
targetA = BukkitUtils.playerWithNameOrUUID(args[0]);
}
if ((targetA == null)) {
sender.sendMessage(
String.format(BaseConstants.PLAYER_WITH_NAME_OR_UUID_NOT_FOUND, new Object[] { args[0] }));
return true;
}
if (args.length < 3) {
Player targetB = BukkitUtils.playerWithNameOrUUID(args[(args.length - 1)]);
if ((targetB == null)) {
sender.sendMessage(ChatColor.RED + "Player '" + ChatColor.GRAY + args[(args.length - 1)]
+ ChatColor.RED + "' not found.");
return true;
}
if (targetA.equals(targetB)) {
sender.sendMessage(ChatColor.RED + "The teleportee and teleported are the same player.");
return true;
}
if (targetA.teleport(targetB, PlayerTeleportEvent.TeleportCause.COMMAND)) {
sender.sendMessage(
ChatColor.GRAY + "Teleported " + targetA.getName() + " to " + targetB.getName() + '.');
} else {
sender.sendMessage(ChatColor.RED + "Failed to teleport you to " + targetB.getName() + '.');
}
} else if (targetA.getWorld() != null) {
Location loc = new Location(targetA.getLocation().getWorld(), Integer.parseInt(args[0]),
Integer.parseInt(args[1]), Integer.parseInt(args[2]));
targetA.teleport(loc);
if (targetA.teleport(loc, PlayerTeleportEvent.TeleportCause.COMMAND)) {
sender.sendMessage(
"You have been teleported to: " + ChatColor.GREEN + args[0] + ", " + args[1] + ", " + args[2]);
} else {
sender.sendMessage(ChatColor.RED + "Failed to teleport you.");
}
}
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return (args.length == 1) || (args.length == 2) ? null : Collections.emptyList();
}
}

View File

@ -0,0 +1,33 @@
package club.curahq.core.commands.teleport;
import java.util.Collections;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import club.curahq.core.util.BukkitUtils;
public class TeleportHereCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Usage: /teleporthere <player>");
return true;
}
Player player = (Player) sender;
BukkitUtils.playerWithNameOrUUID(args[0]).teleport(player);
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
return args.length == 1 ? null : Collections.emptyList();
}
}

View File

@ -0,0 +1,53 @@
package club.curahq.core.commands.teleport;
import java.util.Objects;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseCommand;
public class TopCommand
extends BaseCommand {
public TopCommand() {
super("top", "Teleports to the highest safe spot.");
this.setUsage("/(command)");
}
@Override
public boolean isPlayerOnlyCommand() {
return true;
}
/*
* Enabled aggressive block sorting
*/
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage((Object)ChatColor.RED + "This command is only executable for players.");
return true;
}
Player player = (Player)sender;
Location origin = player.getLocation().clone();
Location highestLocation = BukkitUtils.getHighestLocation(origin.clone());
if (highestLocation != null && !Objects.equals((Object)highestLocation, (Object)origin)) {
Block originBlock = origin.getBlock();
if ((highestLocation.getBlockY() - originBlock.getY() != 1 || originBlock.getType() != Material.WATER) && originBlock.getType() != Material.STATIONARY_WATER) {
player.teleport(highestLocation.add(0.0, 1.0, 0.0), PlayerTeleportEvent.TeleportCause.COMMAND);
sender.sendMessage((Object)ChatColor.AQUA + "Teleported to highest location.");
return true;
}
}
sender.sendMessage((Object)ChatColor.RED + "No highest location found.");
return true;
}
}

View File

@ -0,0 +1,73 @@
package club.curahq.core.commands.teleport;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerTeleportEvent;
import club.curahq.core.util.BukkitUtils;
import club.curahq.core.util.core.BaseCommand;
public class WorldCommand
extends BaseCommand
{
public WorldCommand()
{
super("world", "Change current world.");
setAliases(new String[] { "changeworld", "switchworld" });
setUsage("/(command) <worldName>");
}
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (!(sender instanceof Player))
{
sender.sendMessage(ChatColor.RED + "This command is only executable for players.");
return true;
}
if (args.length < 1)
{
sender.sendMessage(ChatColor.RED + getUsage());
return true;
}
World world = Bukkit.getWorld(args[0]);
if (world == null)
{
sender.sendMessage(ChatColor.RED + "World '" + args[0] + "' not found.");
return true;
}
Player player = (Player)sender;
if (player.getWorld().equals(world))
{
sender.sendMessage(ChatColor.RED + "You are already in that world.");
return true;
}
Location origin = player.getLocation();
Location location = new Location(world, origin.getX(), origin.getY(), origin.getZ(), origin.getYaw(), origin.getPitch());
player.teleport(location, PlayerTeleportEvent.TeleportCause.COMMAND);
sender.sendMessage(ChatColor.GRAY + "Switched world to '" + world.getName() + ChatColor.AQUA + " [" + WordUtils.capitalizeFully(world.getEnvironment().name().replace('_', ' ')) + ']' + ChatColor.AQUA + "'.");
return true;
}
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args)
{
if (args.length != 1) {
return Collections.emptyList();
}
List<?> worlds = Bukkit.getWorlds();
ArrayList<String> results = new ArrayList<String>(worlds.size());
for (World world : Bukkit.getWorlds()) {
results.add(world.getName());
}
return BukkitUtils.getCompletions(args, results);
}
}

View File

@ -0,0 +1,117 @@
package club.curahq.core.crowbar;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import java.util.Arrays;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public class Crowbar {
public static final int MAX_SPAWNER_USES = 1;
public static final int MAX_END_FRAME_USES = 6;
public Crowbar() {
this(1, 6, 1);
}
public Crowbar(int spawnerUses, int endFrameUses, int endDragonUses) {
this.stack = new ItemStack(CROWBAR_TYPE, 1);
Preconditions.checkArgument((spawnerUses > 0) || (endFrameUses > 0), "Cannot create a crowbar with empty uses");
setSpawnerUses(Math.min(1, spawnerUses));
setEndFrameUses(Math.min(6, endFrameUses));
}
public static Optional<Crowbar> fromStack(ItemStack stack) {
if ((stack == null) || (!stack.hasItemMeta())) {
return Optional.absent();
}
ItemMeta meta = stack.getItemMeta();
if ((!meta.hasDisplayName()) || (!meta.hasLore()) || (!meta.getDisplayName().equals(CROWBAR_NAME))) {
return Optional.absent();
}
Crowbar crowbar = new Crowbar();
List<String> loreList = meta.getLore();
for (String lore : loreList) {
lore = ChatColor.stripColor(lore);
int length = lore.length();
for (int i = 0; i < length; i++) {
char character = lore.charAt(i);
if (Character.isDigit(character)) {
int amount = Integer.parseInt(String.valueOf(character));
if (lore.startsWith("End Frame Uses")) {
crowbar.setEndFrameUses(amount);
break;
}
if (lore.startsWith("Spawner Uses")) {
crowbar.setSpawnerUses(amount);
break;
}
}
}
}
return Optional.of(crowbar);
}
public int getEndFrameUses() {
return this.endFrameUses;
}
public void setEndFrameUses(int uses) {
if (this.endFrameUses != uses) {
this.endFrameUses = Math.min(6, uses);
this.needsMetaUpdate = true;
}
}
public int getSpawnerUses() {
return this.spawnerUses;
}
public void setSpawnerUses(int uses) {
if (this.spawnerUses != uses) {
this.spawnerUses = Math.min(1, uses);
this.needsMetaUpdate = true;
}
}
public ItemStack getItemIfPresent() {
Optional<ItemStack> optional = toItemStack();
return optional.isPresent() ? (ItemStack) optional.get() : new ItemStack(Material.AIR, 1);
}
public Optional<ItemStack> toItemStack() {
if (this.needsMetaUpdate) {
double maxDurability;
double curDurability = maxDurability = CROWBAR_TYPE.getMaxDurability();
double increment = curDurability / 6.0D;
curDurability -= increment * (this.spawnerUses + this.endFrameUses);
if (Math.abs(curDurability - maxDurability) == 0.0D) {
return Optional.absent();
}
ItemMeta meta = this.stack.getItemMeta();
meta.setDisplayName(CROWBAR_NAME);
meta.setLore(
Arrays.asList(new String[] {
String.format(LORE_FORMAT,
new Object[] { "Spawner Uses", Integer.valueOf(this.spawnerUses),
Integer.valueOf(1) }),
String.format(LORE_FORMAT, new Object[] { "End Frame Uses",
Integer.valueOf(this.endFrameUses), Integer.valueOf(6) }) }));
this.stack.setItemMeta(meta);
this.stack.setDurability((short) (int) curDurability);
this.needsMetaUpdate = false;
}
return Optional.of(this.stack);
}
public static final Material CROWBAR_TYPE = Material.GOLD_HOE;
private static final String CROWBAR_NAME = ChatColor.RED.toString() + "Crowbar";
private static final String LORE_FORMAT = ChatColor.GRAY + "%1$s: " + ChatColor.YELLOW + "%2$s/%3$s";
private int endFrameUses;
private int spawnerUses;
private final ItemStack stack;
private boolean needsMetaUpdate;
}

View File

@ -0,0 +1,93 @@
package club.curahq.core.deathban;
import org.bukkit.Location;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import club.curahq.core.util.PersistableLocation;
import java.util.LinkedHashMap;
import java.util.Map;
public class Deathban implements ConfigurationSerializable {
private final String reason;
private final long creationMillis;
private final long expiryMillis;
private final PersistableLocation deathPoint;
public String getReason() {
return reason;
}
public long getCreationMillis() {
return creationMillis;
}
public Deathban(String reason, long duration, PersistableLocation deathPoint) {
this.reason = reason;
this.creationMillis = System.currentTimeMillis();
this.expiryMillis = this.creationMillis + duration;
this.deathPoint = deathPoint;
}
public Deathban(Map<String, Object> map) {
this.reason = (String) map.get("reason");
this.creationMillis = Long.parseLong((String) map.get("creationMillis"));
this.expiryMillis = Long.parseLong((String) map.get("expiryMillis"));
Object object = map.get("deathPoint");
this.deathPoint = object instanceof PersistableLocation ? (PersistableLocation) object : null;
}
@Override
public Map<String, Object> serialize() {
Map<String, Object> map = new LinkedHashMap<>();
map.put("reason", this.reason);
map.put("creationMillis", Long.toString(this.creationMillis));
map.put("expiryMillis", Long.toString(this.expiryMillis));
if (this.deathPoint != null) {
map.put("deathPoint", this.deathPoint);
}
return map;
}
/**
* Gets the initial duration of this {@link Deathban} in milliseconds.
*
* @return the initial duration
*/
public long getInitialDuration() {
return this.expiryMillis - this.creationMillis;
}
/**
* Checks if this {@link Deathban} is active.
*
* @return true if is active
*/
public boolean isActive() {
return this.getRemaining() > 0L;
}
/**
* Gets the remaining time in milliseconds until this {@link Deathban} is no longer active.
*
* @return the remaining time until expired
*/
public long getRemaining() {
return this.expiryMillis - System.currentTimeMillis();
}
/**
* Gets the {@link Location} where this player died during {@link Deathban}.
*
* @return death {@link Location}
*/
public Location getDeathPoint() {
return deathPoint == null ? null : deathPoint.getLocation();
}
}

Some files were not shown because too many files have changed in this diff Show More