feat: transition to VexlioHub, clean up modules, add effects & localize configs
- Rename and relocate package from DeluxeHubReloaded to VexlioHub - Remove deprecated modules: antiwdl, scoreboard, tablist, pvp_mode, teleportation_bow, anti_swear, lockchat, vanish, holograms - Refactor all commands to standard Bukkit CommandExecutor/TabCompleter registered dynamically via Bukkit CommandMap - Add particle, sound, and trail configurations for launchpad and double jump modules - Implement actionbar announcements and join title welcome animation modules - Fully customize, translate to Czech, and restyle all configuration files in the 'uprava/' directory with the purple-cyan gradient theme
This commit is contained in:
+91
@@ -0,0 +1,91 @@
|
|||||||
|
### Mac ###
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
### Gradle ###
|
||||||
|
|
||||||
|
build/
|
||||||
|
.gradle
|
||||||
|
gradle
|
||||||
|
|
||||||
|
### Intellij ###
|
||||||
|
.idea/
|
||||||
|
*.iws
|
||||||
|
out/
|
||||||
|
*.iml
|
||||||
|
.idea_modules/
|
||||||
|
atlassian-ide-plugin.xml
|
||||||
|
|
||||||
|
### Eclipse ###
|
||||||
|
|
||||||
|
.classpath
|
||||||
|
.project
|
||||||
|
codetemplates.xml
|
||||||
|
bin/
|
||||||
|
.metadata
|
||||||
|
tmp/
|
||||||
|
*.tmp
|
||||||
|
*.bak
|
||||||
|
*.swp
|
||||||
|
*~.nib
|
||||||
|
local.properties
|
||||||
|
.settings/
|
||||||
|
.loadpath
|
||||||
|
.recommenders
|
||||||
|
|
||||||
|
## EXTERNAL TOOLS ##
|
||||||
|
|
||||||
|
.externalToolBuilders/
|
||||||
|
|
||||||
|
# Locally stored "Eclipse launch configurations"
|
||||||
|
*.launch
|
||||||
|
|
||||||
|
# PyDev specific (Python IDE for Eclipse)
|
||||||
|
*.pydevproject
|
||||||
|
|
||||||
|
# CDT-specific (C/C++ Development Tooling)
|
||||||
|
.cproject
|
||||||
|
|
||||||
|
# CDT- autotools
|
||||||
|
.autotools
|
||||||
|
|
||||||
|
# Java annotation processor (APT)
|
||||||
|
.factorypath
|
||||||
|
|
||||||
|
# PDT-specific (PHP Development Tools)
|
||||||
|
.buildpath
|
||||||
|
|
||||||
|
# sbteclipse plugin
|
||||||
|
.target
|
||||||
|
target
|
||||||
|
|
||||||
|
# Tern plugin
|
||||||
|
.tern-project
|
||||||
|
|
||||||
|
# TeXlipse plugin
|
||||||
|
.texlipse
|
||||||
|
|
||||||
|
# STS (Spring Tool Suite)
|
||||||
|
.springBeans
|
||||||
|
|
||||||
|
# Code Recommenders
|
||||||
|
.recommenders/
|
||||||
|
|
||||||
|
# Annotation Processing
|
||||||
|
.apt_generated/
|
||||||
|
|
||||||
|
# Scala IDE specific (Scala & Java development for Eclipse)
|
||||||
|
.cache-main
|
||||||
|
.scala_dependencies
|
||||||
|
.worksheet
|
||||||
|
|
||||||
|
# Annotation Processing
|
||||||
|
.apt_generated
|
||||||
|
|
||||||
|
.sts4-cache/
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.ear
|
||||||
|
/lib
|
||||||
|
**/*~
|
||||||
@@ -0,0 +1,674 @@
|
|||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<div align="center">
|
||||||
|
<img src="https://i.imgur.com/TmuOX8L.png" alt="Header">
|
||||||
|
<p align="center">
|
||||||
|
DeluxeHub is the all-in-one hub server solution compacting a large amount of hub essentials into one plugin.
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<a href="https://strafbefehl.github.io/DeluxeHubReloadedDocs/welcome">Wiki</a>
|
||||||
|
·
|
||||||
|
<a href="https://www.spigotmc.org/resources/deluxehubreloaded-3-professional-hub-management.118904/">SpigotMC</a>
|
||||||
|
·
|
||||||
|
<a href="https://discord.gg/uQkg8ZeHzK">Discord</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
This project is licensed under the GNU General Public License v3.0 License - see the [LICENSE](LICENSE) file for details.
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
plugins {
|
||||||
|
id 'java'
|
||||||
|
id 'com.gradleup.shadow' version '9.4.2'
|
||||||
|
id 'xyz.jpenilla.run-paper' version '2.3.1'
|
||||||
|
}
|
||||||
|
|
||||||
|
group = 'eu.milujukockoholky'
|
||||||
|
version = '3.7.4-beta.1'
|
||||||
|
description = 'An all-in-one hub management system'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
maven { url 'https://oss.sonatype.org/content/groups/public/' }
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
|
maven { url 'https://repo.codemc.org/repository/maven-public' }
|
||||||
|
maven { url 'https://repo.extendedclip.com/content/repositories/placeholderapi/' }
|
||||||
|
maven { url 'https://libraries.minecraft.net/' }
|
||||||
|
maven { url 'https://repo.opencollab.dev/main/' }
|
||||||
|
maven { url 'https://repo.aikar.co/content/groups/aikar/' }
|
||||||
|
maven { url 'https://repo.papermc.io/repository/maven-public/' }
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// Provided dependencies
|
||||||
|
compileOnly 'io.papermc.paper:paper-api:26.1.2.build.+'
|
||||||
|
compileOnly 'com.mojang:authlib:1.5.25'
|
||||||
|
compileOnly 'me.clip:placeholderapi:2.11.6'
|
||||||
|
compileOnly 'de.tr7zw:item-nbt-api:2.14.0'
|
||||||
|
compileOnly 'com.github.shynixn.headdatabase:hdb-api:1.0'
|
||||||
|
|
||||||
|
// Implementation dependencies (will be included in the jar)
|
||||||
|
implementation 'org.bstats:bstats-bukkit-lite:1.7'
|
||||||
|
implementation 'javax.inject:javax.inject:1'
|
||||||
|
implementation 'javax.annotation:javax.annotation-api:1.2'
|
||||||
|
implementation 'co.aikar:acf-paper:0.5.1-SNAPSHOT'
|
||||||
|
implementation 'net.kyori:adventure-api:4.21.0'
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
runServer {
|
||||||
|
minecraftVersion("26.1.2")
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
archiveClassifier.set('')
|
||||||
|
|
||||||
|
relocate 'org.bstats', 'eu.milujukockoholky.vexliolobby.libs.metrics'
|
||||||
|
relocate 'co.aikar', 'eu.milujukockoholky.vexliolobby.libs.aikar'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
include(dependency('org.bstats:bstats-bukkit-lite'))
|
||||||
|
include(dependency('javax.inject:javax.inject'))
|
||||||
|
include(dependency('co.aikar:acf-paper'))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
build {
|
||||||
|
dependsOn shadowJar
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
sourceCompatibility = JavaVersion.VERSION_25
|
||||||
|
targetCompatibility = JavaVersion.VERSION_25
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile).configureEach {
|
||||||
|
options.encoding = 'UTF-8'
|
||||||
|
options.fork = true
|
||||||
|
options.forkOptions.executable = "C:/Program Files/Eclipse Adoptium/jdk-25.0.3.9-hotspot/bin/javac.exe"
|
||||||
|
}
|
||||||
|
|
||||||
|
processResources {
|
||||||
|
def props = [
|
||||||
|
'name': rootProject.name,
|
||||||
|
'version': project.version,
|
||||||
|
'description': project.description ?: 'An all-in-one hub management system',
|
||||||
|
'url': 'https://www.spigotmc.org/resources/118904/'
|
||||||
|
]
|
||||||
|
inputs.properties props
|
||||||
|
filteringCharset 'UTF-8'
|
||||||
|
filesMatching('plugin.yml') {
|
||||||
|
expand props
|
||||||
|
}
|
||||||
|
filesMatching('paper-plugin.yml') {
|
||||||
|
expand props
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,251 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright © 2015-2021 the original authors.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
#
|
||||||
|
|
||||||
|
##############################################################################
|
||||||
|
#
|
||||||
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
|
#
|
||||||
|
# Important for running:
|
||||||
|
#
|
||||||
|
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||||
|
# noncompliant, but you have some other compliant shell such as ksh or
|
||||||
|
# bash, then to run this script, type that shell name before the whole
|
||||||
|
# command line, like:
|
||||||
|
#
|
||||||
|
# ksh Gradle
|
||||||
|
#
|
||||||
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
|
# requires all of these POSIX shell features:
|
||||||
|
# * functions;
|
||||||
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
|
#
|
||||||
|
# Important for patching:
|
||||||
|
#
|
||||||
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
|
#
|
||||||
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
|
# space-separated string is a well documented source of bugs and security
|
||||||
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
|
# options in "$@", and eventually passing that to Java.
|
||||||
|
#
|
||||||
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
|
# see the in-line comments for details.
|
||||||
|
#
|
||||||
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
|
# Darwin, MinGW, and NonStop.
|
||||||
|
#
|
||||||
|
# (3) This script is generated from the Groovy template
|
||||||
|
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
|
# within the Gradle project.
|
||||||
|
#
|
||||||
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
|
#
|
||||||
|
##############################################################################
|
||||||
|
|
||||||
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
|
# Resolve links: $0 may be a link
|
||||||
|
app_path=$0
|
||||||
|
|
||||||
|
# Need this for daisy-chained symlinks.
|
||||||
|
while
|
||||||
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
|
[ -h "$app_path" ]
|
||||||
|
do
|
||||||
|
ls=$( ls -ld "$app_path" )
|
||||||
|
link=${ls#*' -> '}
|
||||||
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
APP_BASE_NAME=${0##*/}
|
||||||
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
|
|
||||||
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
|
MAX_FD=maximum
|
||||||
|
|
||||||
|
warn () {
|
||||||
|
echo "$*"
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
die () {
|
||||||
|
echo
|
||||||
|
echo "$*"
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
} >&2
|
||||||
|
|
||||||
|
# OS specific support (must be 'true' or 'false').
|
||||||
|
cygwin=false
|
||||||
|
msys=false
|
||||||
|
darwin=false
|
||||||
|
nonstop=false
|
||||||
|
case "$( uname )" in #(
|
||||||
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
|
Darwin* ) darwin=true ;; #(
|
||||||
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
|
NONSTOP* ) nonstop=true ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
CLASSPATH="\\\"\\\""
|
||||||
|
|
||||||
|
|
||||||
|
# Determine the Java command to use to start the JVM.
|
||||||
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
|
else
|
||||||
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
|
fi
|
||||||
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
JAVACMD=java
|
||||||
|
if ! command -v java >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
|
|
||||||
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
|
location of your Java installation."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Increase the maximum file descriptors if we can.
|
||||||
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
|
case $MAX_FD in #(
|
||||||
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
|
warn "Could not query maximum file descriptor limit"
|
||||||
|
esac
|
||||||
|
case $MAX_FD in #(
|
||||||
|
'' | soft) :;; #(
|
||||||
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC2039,SC3045
|
||||||
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
|
# * args from the command line
|
||||||
|
# * the main class name
|
||||||
|
# * -classpath
|
||||||
|
# * -D...appname settings
|
||||||
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
|
if "$cygwin" || "$msys" ; then
|
||||||
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
|
for arg do
|
||||||
|
if
|
||||||
|
case $arg in #(
|
||||||
|
-*) false ;; # don't mess with options #(
|
||||||
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
|
[ -e "$t" ] ;; #(
|
||||||
|
*) false ;;
|
||||||
|
esac
|
||||||
|
then
|
||||||
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
|
fi
|
||||||
|
# Roll the args list around exactly as many times as the number of
|
||||||
|
# args, so each arg winds up back in the position where it started, but
|
||||||
|
# possibly modified.
|
||||||
|
#
|
||||||
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
|
# changing the positional parameters here affects neither the number of
|
||||||
|
# iterations, nor the values presented in `arg`.
|
||||||
|
shift # remove old arg
|
||||||
|
set -- "$@" "$arg" # push replacement arg
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
|
# Collect all arguments for the java command:
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
|
# and any embedded shellness will be escaped.
|
||||||
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|
||||||
|
set -- \
|
||||||
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
|
-classpath "$CLASSPATH" \
|
||||||
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# Stop when "xargs" is not available.
|
||||||
|
if ! command -v xargs >/dev/null 2>&1
|
||||||
|
then
|
||||||
|
die "xargs is not available"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Use "xargs" to parse quoted args.
|
||||||
|
#
|
||||||
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
#
|
||||||
|
# In Bash we could simply go:
|
||||||
|
#
|
||||||
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
|
# set -- "${ARGS[@]}" "$@"
|
||||||
|
#
|
||||||
|
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||||
|
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||||
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
|
# the whole thing up as a single "set" statement.
|
||||||
|
#
|
||||||
|
# This will of course break if any of these variables contains a newline or
|
||||||
|
# an unmatched quote.
|
||||||
|
#
|
||||||
|
|
||||||
|
eval "set -- $(
|
||||||
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
|
xargs -n1 |
|
||||||
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
|
tr '\n' ' '
|
||||||
|
)" '"$@"'
|
||||||
|
|
||||||
|
exec "$JAVACMD" "$@"
|
||||||
Vendored
+95
@@ -0,0 +1,95 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
@rem SPDX-License-Identifier: Apache-2.0
|
||||||
|
@rem
|
||||||
|
|
||||||
|
@if "%DEBUG%"=="" @echo off
|
||||||
|
@rem ##########################################################################
|
||||||
|
@rem
|
||||||
|
@rem Gradle startup script for Windows
|
||||||
|
@rem
|
||||||
|
@rem ##########################################################################
|
||||||
|
|
||||||
|
@rem Set local scope for the variables with windows NT shell
|
||||||
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
|
set DIRNAME=%~dp0
|
||||||
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem set JAVA_HOME=C:\Program Files\Eclipse Adoptium\jdk-25.0.3.9-hotspot
|
||||||
|
@rem This is normally unused
|
||||||
|
set APP_BASE_NAME=%~n0
|
||||||
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
|
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||||
|
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||||
|
|
||||||
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
|
@rem Find java.exe
|
||||||
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|
||||||
|
set JAVA_EXE=java.exe
|
||||||
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:findJavaFromJavaHome
|
||||||
|
set JAVA_HOME=%JAVA_HOME:"=%
|
||||||
|
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||||
|
|
||||||
|
if exist "%JAVA_EXE%" goto execute
|
||||||
|
|
||||||
|
echo. 1>&2
|
||||||
|
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||||
|
echo. 1>&2
|
||||||
|
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||||
|
echo location of your Java installation. 1>&2
|
||||||
|
|
||||||
|
goto fail
|
||||||
|
|
||||||
|
:execute
|
||||||
|
@rem Setup the command line
|
||||||
|
|
||||||
|
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
|
@rem Execute Gradle
|
||||||
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||||
|
|
||||||
|
:end
|
||||||
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
|
:fail
|
||||||
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
|
rem the _cmd.exe /c_ return code!
|
||||||
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
|
:mainEnd
|
||||||
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|
||||||
|
:omega
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
rootProject.name = 'VexlioHub'
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby;
|
||||||
|
|
||||||
|
public enum Permissions {
|
||||||
|
|
||||||
|
// Command permissions
|
||||||
|
COMMAND_VEXLIOHUB_HELP("command.help"),
|
||||||
|
COMMAND_VEXLIOHUB_RELOAD("command.reload"),
|
||||||
|
COMMAND_OPEN_MENUS("command.openmenu"),
|
||||||
|
|
||||||
|
|
||||||
|
COMMAND_GAMEMODE("command.gamemode"),
|
||||||
|
COMMAND_GAMEMODE_OTHERS("command.gamemode.others"),
|
||||||
|
COMMAND_CLEARCHAT("command.clearchat"),
|
||||||
|
COMMAND_FLIGHT("command.fly"),
|
||||||
|
COMMAND_FLIGHT_OTHERS("command.fly.others"),
|
||||||
|
COMMAND_SET_LOBBY("command.setlobby"),
|
||||||
|
COMMAND_BUILD_MODE("command.buildmode"),
|
||||||
|
COMMAND_BUILD_MODE_OTHERS("command.buildmode.others"),
|
||||||
|
|
||||||
|
// Module stuff
|
||||||
|
BLOCKED_COMMANDS_BYPASS("bypass.commands"),
|
||||||
|
DOUBLE_JUMP_BYPASS("bypass.doublejump"),
|
||||||
|
|
||||||
|
// Legacy system
|
||||||
|
EVENT_ITEM_DROP("item.drop"),
|
||||||
|
EVENT_ITEM_PICKUP("item.pickup"),
|
||||||
|
EVENT_BLOCK_INTERACT("block.interact"),
|
||||||
|
EVENT_BLOCK_BREAK("block.break"),
|
||||||
|
EVENT_BLOCK_PLACE("block.place");
|
||||||
|
|
||||||
|
private final String perm;
|
||||||
|
|
||||||
|
Permissions(String perm) {
|
||||||
|
this.perm = perm;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final String getPermission() {
|
||||||
|
return "vexliolobby." + this.perm;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.ActionManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.world.BuildMode;
|
||||||
|
import eu.milujukockoholky.vexliolobby.command.CommandManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Version;
|
||||||
|
import eu.milujukockoholky.vexliolobby.cooldown.CooldownManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.hook.HooksManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.inventory.InventoryManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.NamespacedKeys;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import org.bstats.bukkit.MetricsLite;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class VexlioHubPlugin extends JavaPlugin {
|
||||||
|
|
||||||
|
private static final int BSTATS_ID = 23061;
|
||||||
|
|
||||||
|
private ConfigManager configManager;
|
||||||
|
private ActionManager actionManager;
|
||||||
|
private HooksManager hooksManager;
|
||||||
|
private CommandManager commandManager;
|
||||||
|
private CooldownManager cooldownManager;
|
||||||
|
private ModuleManager moduleManager;
|
||||||
|
private InventoryManager inventoryManager;
|
||||||
|
private Version currentVersion;
|
||||||
|
|
||||||
|
public void onEnable() {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
getLogger().log(Level.INFO, "VexlioHub - Lobby System");
|
||||||
|
getLogger().log(Level.INFO, "Modified, and maintained by Athar42 & Strafbefehl, 2025-2026");
|
||||||
|
|
||||||
|
// Check if running on Paper
|
||||||
|
try {
|
||||||
|
Class.forName("io.papermc.paper.configuration.Configuration");
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
getLogger().severe("============= PAPER NOT DETECTED =============");
|
||||||
|
getLogger().severe("VexlioHub requires Paper to run.");
|
||||||
|
getLogger().severe("Download Paper here: https://papermc.io/downloads/paper");
|
||||||
|
getLogger().severe("The plugin will now disable.");
|
||||||
|
getLogger().severe("============= PAPER NOT DETECTED =============");
|
||||||
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check server version (requires 1.21+ or 26.x+)
|
||||||
|
String rawVersion = Bukkit.getBukkitVersion().split("-")[0];
|
||||||
|
if (rawVersion.startsWith("1.")) {
|
||||||
|
try {
|
||||||
|
int minor = Integer.parseInt(rawVersion.split("\\.")[1]);
|
||||||
|
if (minor < 21) {
|
||||||
|
getLogger().severe("============= UNSUPPORTED SERVER VERSION =============");
|
||||||
|
getLogger().severe("VexlioHub requires Paper 1.21 or newer to run.");
|
||||||
|
getLogger().severe("The plugin will now disable.");
|
||||||
|
getLogger().severe("============= UNSUPPORTED SERVER VERSION =============");
|
||||||
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (NumberFormatException ignored) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enable bStats metrics
|
||||||
|
new MetricsLite(this, BSTATS_ID);
|
||||||
|
|
||||||
|
NamespacedKeys.registerKeys();
|
||||||
|
|
||||||
|
// Check plugin hooks
|
||||||
|
hooksManager = new HooksManager(this);
|
||||||
|
|
||||||
|
// Load config files
|
||||||
|
configManager = new ConfigManager();
|
||||||
|
configManager.loadFiles(this);
|
||||||
|
currentVersion = Version.parse(getPluginMeta().getVersion());
|
||||||
|
|
||||||
|
// If there were any configuration errors we should not continue
|
||||||
|
if (!getServer().getPluginManager().isPluginEnabled(this)) return;
|
||||||
|
|
||||||
|
// Command manager
|
||||||
|
commandManager = new CommandManager(this);
|
||||||
|
commandManager.reload();
|
||||||
|
|
||||||
|
// Cooldown manager
|
||||||
|
cooldownManager = new CooldownManager();
|
||||||
|
|
||||||
|
// Inventory (GUI) manager
|
||||||
|
inventoryManager = new InventoryManager();
|
||||||
|
inventoryManager.onEnable(this);
|
||||||
|
|
||||||
|
// Core plugin modules
|
||||||
|
moduleManager = new ModuleManager();
|
||||||
|
moduleManager.loadModules(this);
|
||||||
|
|
||||||
|
// Action system
|
||||||
|
actionManager = new ActionManager(this);
|
||||||
|
|
||||||
|
// build.gradle / other initializations
|
||||||
|
BuildMode.getInstance();
|
||||||
|
|
||||||
|
// Register BungeeCord channels
|
||||||
|
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||||
|
|
||||||
|
getLogger().log(Level.INFO, "");
|
||||||
|
getLogger().log(Level.INFO, "Successfully loaded in " + (System.currentTimeMillis() - start) + "ms");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisable() {
|
||||||
|
Bukkit.getScheduler().cancelTasks(this);
|
||||||
|
moduleManager.unloadModules();
|
||||||
|
inventoryManager.onDisable();
|
||||||
|
//configManager.saveFiles();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reload() {
|
||||||
|
Bukkit.getScheduler().cancelTasks(this);
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
|
||||||
|
configManager.reloadFiles();
|
||||||
|
|
||||||
|
BuildMode.getInstance().runScheduler();
|
||||||
|
|
||||||
|
inventoryManager.onDisable();
|
||||||
|
inventoryManager.onEnable(this);
|
||||||
|
|
||||||
|
getCommandManager().reload();
|
||||||
|
|
||||||
|
moduleManager.loadModules(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public HooksManager getHookManager() {
|
||||||
|
return hooksManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModuleManager getModuleManager() {
|
||||||
|
return moduleManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandManager getCommandManager() {
|
||||||
|
return commandManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CooldownManager getCooldownManager() {
|
||||||
|
return cooldownManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryManager getInventoryManager() {
|
||||||
|
return inventoryManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigManager getConfigManager() {
|
||||||
|
return configManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Version getCurrentVersion() {
|
||||||
|
return currentVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActionManager getActionManager() {
|
||||||
|
return actionManager;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface Action {
|
||||||
|
|
||||||
|
String getIdentifier();
|
||||||
|
|
||||||
|
void execute(VexlioHubPlugin plugin, Player player, String data);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.actions.*;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.PlaceholderUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ActionManager {
|
||||||
|
|
||||||
|
private final VexlioHubPlugin plugin;
|
||||||
|
private final Map<String, Action> actions;
|
||||||
|
|
||||||
|
public ActionManager(VexlioHubPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
actions = new HashMap<>();
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void load() {
|
||||||
|
registerAction(
|
||||||
|
new MessageAction(),
|
||||||
|
new BroadcastMessageAction(),
|
||||||
|
new CommandAction(),
|
||||||
|
new SoundAction(),
|
||||||
|
new PotionEffectAction(),
|
||||||
|
new GamemodeAction(),
|
||||||
|
new ProxyAction(),
|
||||||
|
new CloseInventoryAction(),
|
||||||
|
new ActionbarAction(),
|
||||||
|
new TitleAction(),
|
||||||
|
new MenuAction()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerAction(Action... actions) {
|
||||||
|
Arrays.asList(actions).forEach(action -> this.actions.put(action.getIdentifier(), action));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void executeActions(Player player, List<String> items) {
|
||||||
|
items.forEach(item -> {
|
||||||
|
String actionName = StringUtils.substringBetween(item, "[", "]");
|
||||||
|
Action action = actionName == null ? null : actions.get(actionName.toUpperCase());
|
||||||
|
|
||||||
|
if (action != null) {
|
||||||
|
item = item.contains(" ") ? item.split(" ", 2)[1] : "";
|
||||||
|
item = PlaceholderUtil.setPlaceholders(item, player);
|
||||||
|
|
||||||
|
action.execute(plugin, player, item);
|
||||||
|
} else {
|
||||||
|
plugin.getLogger().warning("There was a problem attempting to process action: '" + item + "'");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action.actions;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.Action;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.reflection.ActionBar;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ActionbarAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "ACTIONBAR";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(VexlioHubPlugin plugin, Player player, String data) {
|
||||||
|
ActionBar.sendActionBar(player, TextUtil.color(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action.actions;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.Action;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class BroadcastMessageAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "BROADCAST";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(VexlioHubPlugin plugin, Player player, String data) {
|
||||||
|
if (data.contains("<center>") && data.contains("</center>")) data = TextUtil.getCenteredMessage(data);
|
||||||
|
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
p.sendMessage(TextUtil.color(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
@@ -0,0 +1,18 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action.actions;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.Action;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CloseInventoryAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "CLOSE";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(VexlioHubPlugin plugin, Player player, String data) {
|
||||||
|
player.closeInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action.actions;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.Action;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CommandAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "COMMAND";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(VexlioHubPlugin plugin, Player player, String data) {
|
||||||
|
player.chat(data.contains("/") ? data : "/" + data);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action.actions;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.Action;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class GamemodeAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "GAMEMODE";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(VexlioHubPlugin plugin, Player player, String data) {
|
||||||
|
try {
|
||||||
|
player.setGameMode(GameMode.valueOf(data.toUpperCase()));
|
||||||
|
if ((player.getGameMode() == GameMode.ADVENTURE || player.getGameMode() == GameMode.SURVIVAL)
|
||||||
|
&& plugin.getModuleManager().isEnabled(ModuleType.DOUBLE_JUMP)) {
|
||||||
|
player.setAllowFlight(true);
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException ex) {
|
||||||
|
Bukkit.getLogger().warning("[VexlioHub Action] Invalid gamemode name: " + data.toUpperCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action.actions;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.Action;
|
||||||
|
import eu.milujukockoholky.vexliolobby.inventory.AbstractInventory;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class MenuAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "MENU";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(VexlioHubPlugin plugin, Player player, String data) {
|
||||||
|
AbstractInventory inventory = plugin.getInventoryManager().getInventory(data);
|
||||||
|
|
||||||
|
if (inventory != null) {
|
||||||
|
inventory.openInventory(player);
|
||||||
|
} else {
|
||||||
|
plugin.getLogger().warning("[MENU] Action Failed: Menu '" + data + "' not found.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action.actions;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.Action;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class MessageAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "MESSAGE";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(VexlioHubPlugin plugin, Player player, String data) {
|
||||||
|
if (data.contains("<center>") && data.contains("</center>")) data = TextUtil.getCenteredMessage(data);
|
||||||
|
player.sendMessage(TextUtil.color(data));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action.actions;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.Action;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.Registry;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
public class PotionEffectAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "EFFECT";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(VexlioHubPlugin plugin, Player player, String data) {
|
||||||
|
String[] args = data.split(";");
|
||||||
|
PotionEffectType type = Registry.EFFECT.get(NamespacedKey.minecraft(args[0].toLowerCase()));
|
||||||
|
if (type == null || args.length < 2) return;
|
||||||
|
int amplifier = Integer.parseInt(args[1]) - 1;
|
||||||
|
boolean showIcon = args.length > 2 && Boolean.parseBoolean(args[2]);
|
||||||
|
player.addPotionEffect(new PotionEffect(type, -1, amplifier, false, false, showIcon));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action.actions;
|
||||||
|
|
||||||
|
import com.google.common.io.ByteArrayDataOutput;
|
||||||
|
import com.google.common.io.ByteStreams;
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.Action;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ProxyAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "PROXY";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(VexlioHubPlugin plugin, Player player, String data) {
|
||||||
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||||
|
out.writeUTF("ConnectOther");
|
||||||
|
out.writeUTF(player.getName());
|
||||||
|
out.writeUTF(data);
|
||||||
|
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action.actions;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.Action;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.Registry;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class SoundAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "SOUND";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(VexlioHubPlugin plugin, Player player, String data) {
|
||||||
|
try {
|
||||||
|
player.playSound(player.getLocation(), Registry.SOUNDS.getOrThrow(NamespacedKey.minecraft(data.toLowerCase().replaceFirst("^_", ".").replaceFirst("_$", ".").replaceAll("_(?=.*_)", "."))), 1L, 1L);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
Bukkit.getLogger().warning("[VexlioHub Action] Invalid sound name: " + data.toUpperCase());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.action.actions;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.action.Action;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import net.kyori.adventure.title.Title;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
public class TitleAction implements Action {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getIdentifier() {
|
||||||
|
return "TITLE";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(VexlioHubPlugin plugin, Player player, String data) {
|
||||||
|
String[] args = data.split(";");
|
||||||
|
|
||||||
|
String mainTitle = args.length > 0 ? TextUtil.color(args[0]) : "";
|
||||||
|
String subTitle = args.length > 1 ? TextUtil.color(args[1]) : "";
|
||||||
|
|
||||||
|
int fadeIn;
|
||||||
|
int stay;
|
||||||
|
int fadeOut;
|
||||||
|
try {
|
||||||
|
fadeIn = Integer.parseInt(args[2]);
|
||||||
|
stay = Integer.parseInt(args[3]);
|
||||||
|
fadeOut = Integer.parseInt(args[4]);
|
||||||
|
} catch (NumberFormatException ex) {
|
||||||
|
fadeIn = 1;
|
||||||
|
stay = 3;
|
||||||
|
fadeOut = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (XMaterial.supports(10)) {
|
||||||
|
player.showTitle(Title.title(
|
||||||
|
LegacyComponentSerializer.legacySection().deserialize(mainTitle),
|
||||||
|
LegacyComponentSerializer.legacySection().deserialize(subTitle),
|
||||||
|
Title.Times.times(
|
||||||
|
Duration.ofMillis(fadeIn * 20 * 50L),
|
||||||
|
Duration.ofMillis(stay * 20 * 50L),
|
||||||
|
Duration.ofMillis(fadeOut * 20 * 50L)
|
||||||
|
)
|
||||||
|
));
|
||||||
|
// } else {
|
||||||
|
// Titles.sendTitle(player, fadeIn * 20, stay * 20, fadeOut * 20, mainTitle, subTitle);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.command.commands.*;
|
||||||
|
import eu.milujukockoholky.vexliolobby.command.commands.gamemode.*;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CommandManager {
|
||||||
|
|
||||||
|
private final VexlioHubPlugin plugin;
|
||||||
|
private final FileConfiguration config;
|
||||||
|
private final List<CustomCommand> customCommands;
|
||||||
|
|
||||||
|
public CommandManager(VexlioHubPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.config = plugin.getConfigManager().getFile(ConfigType.COMMANDS).getConfig();
|
||||||
|
this.customCommands = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reload() {
|
||||||
|
// Register main command
|
||||||
|
List<String> mainAliases = config.getStringList("commands.vexliohub.aliases");
|
||||||
|
if (mainAliases == null || mainAliases.isEmpty()) {
|
||||||
|
mainAliases = new ArrayList<>();
|
||||||
|
mainAliases.add("vexliohub");
|
||||||
|
mainAliases.add("vhub");
|
||||||
|
}
|
||||||
|
VexlioHubCommand mainExecutor = new VexlioHubCommand(plugin);
|
||||||
|
registerCommandToMap("vexliohub", mainAliases, mainExecutor, mainExecutor);
|
||||||
|
|
||||||
|
// Register enabled commands
|
||||||
|
if (config.contains("commands")) {
|
||||||
|
for (String command : config.getConfigurationSection("commands").getKeys(false)) {
|
||||||
|
if (command.equalsIgnoreCase("vexliohub")) continue;
|
||||||
|
if (!config.getBoolean("commands." + command + ".enabled")) continue;
|
||||||
|
|
||||||
|
List<String> aliases = config.getStringList("commands." + command + ".aliases");
|
||||||
|
registerCommand(command, aliases);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
reloadCustomCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerCommandToMap(String name, List<String> aliases, org.bukkit.command.CommandExecutor executor, org.bukkit.command.TabCompleter completer) {
|
||||||
|
try {
|
||||||
|
java.lang.reflect.Field commandMapField = Bukkit.getServer().getClass().getDeclaredField("commandMap");
|
||||||
|
commandMapField.setAccessible(true);
|
||||||
|
org.bukkit.command.CommandMap commandMap = (org.bukkit.command.CommandMap) commandMapField.get(Bukkit.getServer());
|
||||||
|
|
||||||
|
VexlioCommand cmd = new VexlioCommand(name, "VexlioHub Command", "/" + name, aliases, executor, completer);
|
||||||
|
commandMap.register("vexliolobby", cmd);
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().warning("Failed to dynamically register command /" + name + ": " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reloadCustomCommands() {
|
||||||
|
if (!customCommands.isEmpty()) customCommands.clear();
|
||||||
|
if (!config.isSet("custom_commands")) return;
|
||||||
|
|
||||||
|
for (String entry : config.getConfigurationSection("custom_commands").getKeys(false)) {
|
||||||
|
|
||||||
|
CustomCommand customCommand = new CustomCommand(entry, config.getStringList("custom_commands." + entry + ".actions"));
|
||||||
|
|
||||||
|
if (config.contains("custom_commands." + entry + ".aliases")) {
|
||||||
|
customCommand.addAliases(config.getStringList("custom_commands." + entry + ".aliases"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.contains("custom_commands." + entry + ".permission")) {
|
||||||
|
customCommand.setPermission(config.getString("custom_commands." + entry + ".permission"));
|
||||||
|
}
|
||||||
|
|
||||||
|
customCommands.add(customCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerCommand(String cmd, List<String> aliases) {
|
||||||
|
switch (cmd.toUpperCase()) {
|
||||||
|
case "GAMEMODE":
|
||||||
|
GamemodeCommand gm = new GamemodeCommand(plugin);
|
||||||
|
registerCommandToMap("gamemode", aliases, gm, gm);
|
||||||
|
break;
|
||||||
|
case "GMS":
|
||||||
|
SurvivalCommand gms = new SurvivalCommand(plugin);
|
||||||
|
registerCommandToMap("gms", aliases, gms, gms);
|
||||||
|
break;
|
||||||
|
case "GMC":
|
||||||
|
CreativeCommand gmc = new CreativeCommand(plugin);
|
||||||
|
registerCommandToMap("gmc", aliases, gmc, gmc);
|
||||||
|
break;
|
||||||
|
case "GMA":
|
||||||
|
AdventureCommand gma = new AdventureCommand(plugin);
|
||||||
|
registerCommandToMap("gma", aliases, gma, gma);
|
||||||
|
break;
|
||||||
|
case "GMSP":
|
||||||
|
SpectatorCommand gmsp = new SpectatorCommand(plugin);
|
||||||
|
registerCommandToMap("gmsp", aliases, gmsp, gmsp);
|
||||||
|
break;
|
||||||
|
case "CLEARCHAT":
|
||||||
|
ClearchatCommand cc = new ClearchatCommand(plugin);
|
||||||
|
registerCommandToMap("clearchat", aliases, cc, cc);
|
||||||
|
break;
|
||||||
|
case "FLY":
|
||||||
|
FlyCommand fly = new FlyCommand(plugin);
|
||||||
|
registerCommandToMap("fly", aliases, fly, fly);
|
||||||
|
break;
|
||||||
|
case "SETLOBBY":
|
||||||
|
SetLobbyCommand sl = new SetLobbyCommand(plugin);
|
||||||
|
registerCommandToMap("setlobby", aliases, sl, null);
|
||||||
|
break;
|
||||||
|
case "LOBBY":
|
||||||
|
LobbyCommand lc = new LobbyCommand(plugin);
|
||||||
|
registerCommandToMap("lobby", aliases, lc, null);
|
||||||
|
break;
|
||||||
|
case "BUILDMODE":
|
||||||
|
BuildModeCommand bm = new BuildModeCommand(plugin);
|
||||||
|
registerCommandToMap("buildmode", aliases, bm, bm);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CustomCommand> getCustomCommands() {
|
||||||
|
return customCommands;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CustomCommand {
|
||||||
|
|
||||||
|
private String permission;
|
||||||
|
private final List<String> aliases;
|
||||||
|
private final List<String> actions;
|
||||||
|
|
||||||
|
public CustomCommand(String command, List<String> actions) {
|
||||||
|
this.aliases = new ArrayList<>();
|
||||||
|
this.aliases.add(command);
|
||||||
|
this.actions = actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAliases(List<String> aliases) {
|
||||||
|
this.aliases.addAll(aliases);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPermission() {
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPermission(String permission) {
|
||||||
|
this.permission = permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAliases() {
|
||||||
|
return aliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getActions() {
|
||||||
|
return actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command;
|
||||||
|
|
||||||
|
import co.aikar.commands.PaperCommandManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.Module;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class CustomCommandHandler extends Module {
|
||||||
|
|
||||||
|
private List<CustomCommand> commands;
|
||||||
|
|
||||||
|
public CustomCommandHandler(VexlioHubPlugin plugin) {
|
||||||
|
super(plugin, ModuleType.CUSTOM_COMMANDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
final PaperCommandManager commandManager = new PaperCommandManager(this.getPlugin());
|
||||||
|
commands = getPlugin().getCommandManager().getCustomCommands();
|
||||||
|
|
||||||
|
commandManager.getCommandReplacements().addReplacement("%custom-commands",
|
||||||
|
this.commands.stream().map(CustomCommand::getAliases)
|
||||||
|
.flatMap(List::stream).collect(Collectors.joining("|")));
|
||||||
|
commandManager.registerCommand(new CustomCommandLoader(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
//does nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CustomCommand> getCommands() {
|
||||||
|
return commands;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command;
|
||||||
|
|
||||||
|
import co.aikar.commands.BaseCommand;
|
||||||
|
import co.aikar.commands.annotation.CommandAlias;
|
||||||
|
import co.aikar.commands.annotation.Default;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandAlias("%custom-commands")
|
||||||
|
public final class CustomCommandLoader extends BaseCommand {
|
||||||
|
|
||||||
|
private final CustomCommandHandler module;
|
||||||
|
|
||||||
|
public CustomCommandLoader(CustomCommandHandler module) {
|
||||||
|
this.module = module;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Default
|
||||||
|
public void onDefault(Player player) {
|
||||||
|
if (module.inDisabledWorld(player.getLocation())) return;
|
||||||
|
|
||||||
|
String command = this.getExecCommandLabel().toLowerCase();
|
||||||
|
|
||||||
|
for (CustomCommand customCommand : module.getCommands()) {
|
||||||
|
if (customCommand.getAliases().stream().anyMatch(alias -> alias.equals(command))) {
|
||||||
|
if (customCommand.getPermission() != null) if (!player.hasPermission(customCommand.getPermission())) {
|
||||||
|
Messages.CUSTOM_COMMAND_NO_PERMISSION.send(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
module.getPlugin().getActionManager().executeActions(player, customCommand.getActions());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class VexlioCommand extends org.bukkit.command.Command {
|
||||||
|
|
||||||
|
private final CommandExecutor executor;
|
||||||
|
private final TabCompleter completer;
|
||||||
|
|
||||||
|
public VexlioCommand(String name, String description, String usageMessage, List<String> aliases, CommandExecutor executor, TabCompleter completer) {
|
||||||
|
super(name, description, usageMessage, aliases);
|
||||||
|
this.executor = executor;
|
||||||
|
this.completer = completer;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||||
|
return executor.onCommand(sender, this, commandLabel, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException {
|
||||||
|
if (completer != null) {
|
||||||
|
List<String> list = completer.onTabComplete(sender, this, alias, args);
|
||||||
|
if (list != null) return list;
|
||||||
|
}
|
||||||
|
return super.tabComplete(sender, alias, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,95 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command.commands;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.Permissions;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.world.BuildMode;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class BuildModeCommand implements CommandExecutor, TabCompleter {
|
||||||
|
private final VexlioHubPlugin plugin;
|
||||||
|
private static final VexlioHubPlugin PLUGIN = JavaPlugin.getPlugin(VexlioHubPlugin.class);
|
||||||
|
|
||||||
|
public BuildModeCommand(VexlioHubPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
FileConfiguration config = PLUGIN.getConfigManager().getFile(ConfigType.SETTINGS).getConfig();
|
||||||
|
final BuildMode bm = BuildMode.getInstance();
|
||||||
|
Player target;
|
||||||
|
if (args.length >= 1) {
|
||||||
|
if (!(sender.hasPermission(Permissions.COMMAND_BUILD_MODE_OTHERS.getPermission()))) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
target = Bukkit.getPlayer(args[0]);
|
||||||
|
if (target == null) {
|
||||||
|
Messages.BUILD_MODE_COMMAND_TARGET_NOT_FOUND.send(sender, "%target%", args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("Console cannot use build mode");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
target = (Player) sender;
|
||||||
|
|
||||||
|
if (!(sender.hasPermission(Permissions.COMMAND_BUILD_MODE.getPermission())) || !(sender.hasPermission(Permissions.COMMAND_BUILD_MODE_OTHERS.getPermission()))) {
|
||||||
|
if (BuildMode.getInstance().isPresent(((Player) sender).getUniqueId())) {
|
||||||
|
remove(bm, target);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bm.isPresent(target.getUniqueId())) {
|
||||||
|
remove(bm, target);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
bm.addPlayer(target);
|
||||||
|
Messages.BUILD_MODE_ENABLED.send(target);
|
||||||
|
if (args.length >= 1) {
|
||||||
|
Messages.BUILD_MODE_COMMAND_ENABLED_FOR_TARGET.send(sender, "%target%", LegacyComponentSerializer.legacySection().serialize(target.displayName()));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void remove(BuildMode instance, Player target) {
|
||||||
|
instance.removePlayer(target.getUniqueId());
|
||||||
|
boolean shouldHaveFlight = PLUGIN.getModuleManager().isEnabled(ModuleType.DOUBLE_JUMP)
|
||||||
|
|| Boolean.TRUE.equals(FlyCommand.allowPlayerFly.get(target.getUniqueId()));
|
||||||
|
target.setAllowFlight(shouldHaveFlight);
|
||||||
|
Messages.BUILD_MODE_DISABLED.send(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String alias, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
String current = args[0].toLowerCase();
|
||||||
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
|
.map(Player::getName)
|
||||||
|
.filter(name -> name.toLowerCase().startsWith(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command.commands;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.Permissions;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
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.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class ClearchatCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
public ClearchatCommand(VexlioHubPlugin plugin) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
|
||||||
|
if (!(sender.hasPermission(Permissions.COMMAND_CLEARCHAT.getPermission()))) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
player.sendMessage("");
|
||||||
|
}
|
||||||
|
Messages.CLEARCHAT.send(player, "%player%", sender.getName());
|
||||||
|
}
|
||||||
|
} else if (args.length == 1) {
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(args[0]);
|
||||||
|
if (player == null) {
|
||||||
|
Messages.INVALID_PLAYER.send(sender, "%player%", args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
player.sendMessage("");
|
||||||
|
}
|
||||||
|
Messages.CLEARCHAT_PLAYER.send(player, "%player%", sender.getName());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String alias, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
String current = args[0].toLowerCase();
|
||||||
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
|
.map(Player::getName)
|
||||||
|
.filter(name -> name.toLowerCase().startsWith(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command.commands;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.Permissions;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
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.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class FlyCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
public static Map<UUID, Boolean> allowPlayerFly = new HashMap<>();
|
||||||
|
|
||||||
|
public FlyCommand(VexlioHubPlugin plugin) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 0) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("Console cannot use fly without specifying a player.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender.hasPermission(Permissions.COMMAND_FLIGHT.getPermission()))) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
allowPlayerFly.putIfAbsent(player.getUniqueId(), false);
|
||||||
|
if (allowPlayerFly.get(player.getUniqueId())) {
|
||||||
|
Messages.FLIGHT_DISABLE.send(player);
|
||||||
|
toggleFlight(player, false);
|
||||||
|
allowPlayerFly.put(player.getUniqueId(), false);
|
||||||
|
player.setAllowFlight(true);
|
||||||
|
} else {
|
||||||
|
Messages.FLIGHT_ENABLE.send(player);
|
||||||
|
toggleFlight(player, true);
|
||||||
|
allowPlayerFly.put(player.getUniqueId(), true);
|
||||||
|
}
|
||||||
|
} else if (args.length == 1) {
|
||||||
|
if (!(sender.hasPermission(Permissions.COMMAND_FLIGHT_OTHERS.getPermission()))) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(args[0]);
|
||||||
|
if (player == null) {
|
||||||
|
Messages.INVALID_PLAYER.send(sender, "%player%", args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (player.getAllowFlight()) {
|
||||||
|
Messages.FLIGHT_DISABLE.send(player);
|
||||||
|
Messages.FLIGHT_DISABLE_OTHER.send(sender, "%player%", player.getName());
|
||||||
|
toggleFlight(player, false);
|
||||||
|
allowPlayerFly.put(player.getUniqueId(), false);
|
||||||
|
} else {
|
||||||
|
Messages.FLIGHT_ENABLE.send(player);
|
||||||
|
Messages.FLIGHT_ENABLE_OTHER.send(sender, "%player%", player.getName());
|
||||||
|
toggleFlight(player, true);
|
||||||
|
allowPlayerFly.put(player.getUniqueId(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void toggleFlight(Player player, boolean value) {
|
||||||
|
player.setAllowFlight(value);
|
||||||
|
player.setFlying(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String alias, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
String current = args[0].toLowerCase();
|
||||||
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
|
.map(Player::getName)
|
||||||
|
.filter(name -> name.toLowerCase().startsWith(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command.commands;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.world.LobbySpawn;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
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.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class LobbyCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final VexlioHubPlugin plugin;
|
||||||
|
|
||||||
|
public LobbyCommand(VexlioHubPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("Console cannot teleport to spawn");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location location = ((LobbySpawn) plugin.getModuleManager().getModule(ModuleType.LOBBY)).getLocation();
|
||||||
|
if (location == null) {
|
||||||
|
sender.sendMessage(TextUtil.color("&cThe spawn location has not been set &7(/setlobby)&c."));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> ((Player) sender).teleport(location), 3L);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command.commands;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.Permissions;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.world.LobbySpawn;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
public class SetLobbyCommand implements CommandExecutor {
|
||||||
|
|
||||||
|
private final VexlioHubPlugin plugin;
|
||||||
|
|
||||||
|
public SetLobbyCommand(VexlioHubPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
|
||||||
|
if (!sender.hasPermission(Permissions.COMMAND_SET_LOBBY.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("Console cannot set the spawn location.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (plugin.getModuleManager().getDisabledWorlds().contains(player.getWorld().getName())) {
|
||||||
|
sender.sendMessage(TextUtil.color("&cYou cannot set the lobby location in a disabled world."));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
LobbySpawn lobbyModule = ((LobbySpawn) plugin.getModuleManager().getModule(ModuleType.LOBBY));
|
||||||
|
lobbyModule.setLocation(player.getLocation());
|
||||||
|
Messages.SET_LOBBY.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command.commands;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.Permissions;
|
||||||
|
import eu.milujukockoholky.vexliolobby.command.CommandManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import eu.milujukockoholky.vexliolobby.inventory.AbstractInventory;
|
||||||
|
import eu.milujukockoholky.vexliolobby.inventory.InventoryManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.hotbar.HotbarItem;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.hotbar.HotbarManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.world.LobbySpawn;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
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.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class VexlioHubCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
private final VexlioHubPlugin plugin;
|
||||||
|
|
||||||
|
public VexlioHubCommand(VexlioHubPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
String pluginVersion = plugin.getPluginMeta().getVersion();
|
||||||
|
|
||||||
|
if (args.length == 0 || args[0].equalsIgnoreCase("help")) {
|
||||||
|
|
||||||
|
if (!sender.hasPermission(Permissions.COMMAND_VEXLIOHUB_HELP.getPermission())) {
|
||||||
|
sender.sendMessage(TextUtil.color("&8&l> &7Server is running <gradient:#9333EA:#06B6D4><bold>VexlioHub</bold></gradient> &ev" + pluginVersion + " &7By &6tp3x"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage("");
|
||||||
|
sender.sendMessage(TextUtil.color("<gradient:#9333EA:#06B6D4><bold>VexlioHub</bold></gradient> " + "&fv" + pluginVersion));
|
||||||
|
sender.sendMessage(TextUtil.color("&7Author: &ftp3x"));
|
||||||
|
sender.sendMessage("");
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/vexliohub info &8- &7&oDisplays information about the current config"));
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/vexliohub open <menu> &8- &7&oOpen a custom menu"));
|
||||||
|
sender.sendMessage("");
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/fly &8- &7&oToggle flight mode"));
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/setlobby &8- &7&oSet the spawn location"));
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/lobby &8- &7&oTeleport to the spawn location"));
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/gamemode <gamemode> &8- &7&oSet your gamemode"));
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/gmc &8- &7&oGo into creative mode"));
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/gms &8- &7&oGo into survival mode"));
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/gma &8- &7&oGo into adventure mode"));
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/gmsp &8- &7&oGo into spectator mode"));
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/clearchat &8- &7&oClear global chat"));
|
||||||
|
sender.sendMessage(TextUtil.color(" &d/build &8- &7&oToggle build mode"));
|
||||||
|
sender.sendMessage("");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (args[0].equalsIgnoreCase("reload")) {
|
||||||
|
|
||||||
|
if (!sender.hasPermission(Permissions.COMMAND_VEXLIOHUB_RELOAD.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
plugin.reload();
|
||||||
|
Messages.CONFIG_RELOAD.send(sender, "%time%", String.valueOf(System.currentTimeMillis() - start));
|
||||||
|
int inventories = plugin.getInventoryManager().getInventories().size();
|
||||||
|
if (inventories > 0) {
|
||||||
|
sender.sendMessage(TextUtil.color("&8- &7Loaded &a" + inventories + "&7 custom menus."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (args[0].equalsIgnoreCase("info")) {
|
||||||
|
|
||||||
|
if (!sender.hasPermission(Permissions.COMMAND_VEXLIOHUB_HELP.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage("");
|
||||||
|
sender.sendMessage(TextUtil.color("<gradient:#9333EA:#06B6D4><bold>Plugin Information</bold></gradient>"));
|
||||||
|
sender.sendMessage("");
|
||||||
|
|
||||||
|
Location location = ((LobbySpawn) plugin.getModuleManager().getModule(ModuleType.LOBBY)).getLocation();
|
||||||
|
sender.sendMessage(TextUtil.color("&7Spawn set &8- " + (location != null ? "&ayes" : "&cno &7&o(/setlobby)")));
|
||||||
|
|
||||||
|
sender.sendMessage("");
|
||||||
|
|
||||||
|
ModuleManager moduleManager = plugin.getModuleManager();
|
||||||
|
sender.sendMessage(TextUtil.color("&7Disabled Worlds (" + moduleManager.getDisabledWorlds().size() + ") &8- &a" + (String.join(", ", moduleManager.getDisabledWorlds()))));
|
||||||
|
|
||||||
|
InventoryManager inventoryManager = plugin.getInventoryManager();
|
||||||
|
sender.sendMessage(TextUtil.color("&7Custom menus (" + inventoryManager.getInventories().size() + ")" + " &8- &a" + (String.join(", ", inventoryManager.getInventories().keySet()))));
|
||||||
|
|
||||||
|
HotbarManager hotbarManager = ((HotbarManager) plugin.getModuleManager().getModule(ModuleType.HOTBAR_ITEMS));
|
||||||
|
sender.sendMessage(TextUtil.color("&7Hotbar items (" + hotbarManager.getHotbarItems().size() + ")" + " &8- &a" + (hotbarManager.getHotbarItems().stream().map(HotbarItem::getKey).collect(Collectors.joining(", ")))));
|
||||||
|
|
||||||
|
CommandManager commandManager = plugin.getCommandManager();
|
||||||
|
sender.sendMessage(TextUtil.color("&7Custom commands (" + commandManager.getCustomCommands().size() + ")" + " &8- &a" + (commandManager.getCustomCommands().stream().map(command -> command.getAliases().get(0)).collect(Collectors.joining(", ")))));
|
||||||
|
|
||||||
|
sender.sendMessage("");
|
||||||
|
|
||||||
|
sender.sendMessage(TextUtil.color("&7PlaceholderAPI Hook: " + (plugin.getHookManager().isHookEnabled("PLACEHOLDER_API") ? "&ayes" : "&cno")));
|
||||||
|
|
||||||
|
sender.sendMessage("");
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (args[0].equalsIgnoreCase("open")) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("Console cannot open menus");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sender.hasPermission(Permissions.COMMAND_OPEN_MENUS.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
sender.sendMessage(TextUtil.color("&cUsage: /vexliohub open <menu>"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
AbstractInventory inventory = plugin.getInventoryManager().getInventory(args[1]);
|
||||||
|
if (inventory == null) {
|
||||||
|
sender.sendMessage(TextUtil.color("&c" + args[1] + " is not a valid menu ID."));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
inventory.openInventory((Player) sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String alias, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
String current = args[0].toLowerCase();
|
||||||
|
return Arrays.asList("help", "reload", "info", "open").stream()
|
||||||
|
.filter(sub -> sub.startsWith(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
} else if (args.length == 2 && args[0].equalsIgnoreCase("open")) {
|
||||||
|
String current = args[1].toLowerCase();
|
||||||
|
return plugin.getInventoryManager().getInventories().keySet().stream()
|
||||||
|
.filter(menu -> menu.toLowerCase().startsWith(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command.commands.gamemode;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.Permissions;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
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.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class AdventureCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
public AdventureCommand(VexlioHubPlugin plugin) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
if (args.length == 0) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("Console cannot change gamemode without specifying a player.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (!player.hasPermission(Permissions.COMMAND_GAMEMODE.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Messages.GAMEMODE_CHANGE.send(player, "%gamemode%", "ADVENTURE");
|
||||||
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
|
} else if (args.length == 1) {
|
||||||
|
if (!sender.hasPermission(Permissions.COMMAND_GAMEMODE_OTHERS.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(args[0]);
|
||||||
|
if (player == null) {
|
||||||
|
Messages.INVALID_PLAYER.send(sender, "%player%", args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Messages.GAMEMODE_CHANGE.send(player, "%gamemode%", "ADVENTURE");
|
||||||
|
Messages.GAMEMODE_CHANGE_OTHER.send(sender, "%player%", player.getName(), "%gamemode%", "ADVENTURE");
|
||||||
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String alias, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
String current = args[0].toLowerCase();
|
||||||
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
|
.map(Player::getName)
|
||||||
|
.filter(name -> name.toLowerCase().startsWith(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command.commands.gamemode;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.Permissions;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
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.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class CreativeCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
public CreativeCommand(VexlioHubPlugin plugin) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
if (args.length == 0) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("Console cannot change gamemode without specifying a player.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (!player.hasPermission(Permissions.COMMAND_GAMEMODE.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Messages.GAMEMODE_CHANGE.send(player, "%gamemode%", "CREATIVE");
|
||||||
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
|
} else if (args.length == 1) {
|
||||||
|
if (!sender.hasPermission(Permissions.COMMAND_GAMEMODE_OTHERS.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(args[0]);
|
||||||
|
if (player == null) {
|
||||||
|
Messages.INVALID_PLAYER.send(sender, "%player%", args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Messages.GAMEMODE_CHANGE.send(player, "%gamemode%", "CREATIVE");
|
||||||
|
Messages.GAMEMODE_CHANGE_OTHER.send(sender, "%player%", player.getName(), "%gamemode%", "CREATIVE");
|
||||||
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String alias, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
String current = args[0].toLowerCase();
|
||||||
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
|
.map(Player::getName)
|
||||||
|
.filter(name -> name.toLowerCase().startsWith(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
+111
@@ -0,0 +1,111 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command.commands.gamemode;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.Permissions;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
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.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class GamemodeCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
public GamemodeCommand(VexlioHubPlugin plugin) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
|
||||||
|
if (args.length == 1) {
|
||||||
|
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("Console cannot change gamemode without specifying a player.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (!player.hasPermission(Permissions.COMMAND_GAMEMODE.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameMode gamemode = getGamemode(args[0]);
|
||||||
|
|
||||||
|
if (gamemode == null) {
|
||||||
|
Messages.GAMEMODE_INVALID.send(sender, "%gamemode%", args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Messages.GAMEMODE_CHANGE.send(player, "%gamemode%", gamemode.toString().toUpperCase());
|
||||||
|
player.setGameMode(gamemode);
|
||||||
|
|
||||||
|
} else if (args.length == 2) {
|
||||||
|
if (!sender.hasPermission(Permissions.COMMAND_GAMEMODE_OTHERS.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(args[1]);
|
||||||
|
if (player == null) {
|
||||||
|
Messages.INVALID_PLAYER.send(sender, "%player%", args[1]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
GameMode gamemode = getGamemode(args[0]);
|
||||||
|
|
||||||
|
if (gamemode == null) {
|
||||||
|
Messages.GAMEMODE_INVALID.send(sender, "%gamemode%", args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender.getName().equals(player.getName())) {
|
||||||
|
Messages.GAMEMODE_CHANGE.send(player, "%gamemode%", gamemode.toString().toUpperCase());
|
||||||
|
} else {
|
||||||
|
Messages.GAMEMODE_CHANGE.send(player, "%gamemode%", gamemode.toString().toUpperCase());
|
||||||
|
Messages.GAMEMODE_CHANGE_OTHER.send(sender, "%player%", player.getName(), "%gamemode%", gamemode.toString().toUpperCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setGameMode(gamemode);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Usage: /gamemode <gamemode> [player]");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private GameMode getGamemode(String gamemode) {
|
||||||
|
if (gamemode.equals("0") || gamemode.equalsIgnoreCase("survival") || gamemode.equalsIgnoreCase("s")) {
|
||||||
|
return GameMode.SURVIVAL;
|
||||||
|
} else if (gamemode.equals("1") || gamemode.equalsIgnoreCase("creative") || gamemode.equalsIgnoreCase("c")) {
|
||||||
|
return GameMode.CREATIVE;
|
||||||
|
} else if (gamemode.equals("2") || gamemode.equalsIgnoreCase("adventure") || gamemode.equalsIgnoreCase("a")) {
|
||||||
|
return GameMode.ADVENTURE;
|
||||||
|
} else if (gamemode.equals("3") || gamemode.equalsIgnoreCase("spectator") || gamemode.equalsIgnoreCase("sp")) {
|
||||||
|
return GameMode.SPECTATOR;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String alias, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
String current = args[0].toLowerCase();
|
||||||
|
return Arrays.asList("survival", "creative", "adventure", "spectator", "0", "1", "2", "3", "s", "c", "a", "sp").stream()
|
||||||
|
.filter(gm -> gm.startsWith(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
} else if (args.length == 2) {
|
||||||
|
String current = args[1].toLowerCase();
|
||||||
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
|
.map(Player::getName)
|
||||||
|
.filter(name -> name.toLowerCase().startsWith(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command.commands.gamemode;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.Permissions;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
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.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class SpectatorCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
public SpectatorCommand(VexlioHubPlugin plugin) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
if (args.length == 0) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("Console cannot change gamemode without specifying a player.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (!player.hasPermission(Permissions.COMMAND_GAMEMODE.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Messages.GAMEMODE_CHANGE.send(player, "%gamemode%", "SPECTATOR");
|
||||||
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
|
} else if (args.length == 1) {
|
||||||
|
if (!sender.hasPermission(Permissions.COMMAND_GAMEMODE_OTHERS.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(args[0]);
|
||||||
|
if (player == null) {
|
||||||
|
Messages.INVALID_PLAYER.send(sender, "%player%", args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Messages.GAMEMODE_CHANGE.send(player, "%gamemode%", "SPECTATOR");
|
||||||
|
Messages.GAMEMODE_CHANGE_OTHER.send(sender, "%player%", player.getName(), "%gamemode%", "SPECTATOR");
|
||||||
|
player.setGameMode(GameMode.SPECTATOR);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String alias, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
String current = args[0].toLowerCase();
|
||||||
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
|
.map(Player::getName)
|
||||||
|
.filter(name -> name.toLowerCase().startsWith(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.command.commands.gamemode;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.Permissions;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
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.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class SurvivalCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
|
public SurvivalCommand(VexlioHubPlugin plugin) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, String[] args) {
|
||||||
|
if (args.length == 0) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
sender.sendMessage("Console cannot change gamemode without specifying a player.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (!player.hasPermission(Permissions.COMMAND_GAMEMODE.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Messages.GAMEMODE_CHANGE.send(player, "%gamemode%", "SURVIVAL");
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
} else if (args.length == 1) {
|
||||||
|
if (!sender.hasPermission(Permissions.COMMAND_GAMEMODE_OTHERS.getPermission())) {
|
||||||
|
Messages.NO_PERMISSION.send(sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = Bukkit.getPlayer(args[0]);
|
||||||
|
if (player == null) {
|
||||||
|
Messages.INVALID_PLAYER.send(sender, "%player%", args[0]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Messages.GAMEMODE_CHANGE.send(player, "%gamemode%", "SURVIVAL");
|
||||||
|
Messages.GAMEMODE_CHANGE_OTHER.send(sender, "%player%", player.getName(), "%gamemode%", "SURVIVAL");
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String alias, String[] args) {
|
||||||
|
if (args.length == 1) {
|
||||||
|
String current = args[0].toLowerCase();
|
||||||
|
return Bukkit.getOnlinePlayers().stream()
|
||||||
|
.map(Player::getName)
|
||||||
|
.filter(name -> name.toLowerCase().startsWith(current))
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.config;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class ConfigHandler {
|
||||||
|
|
||||||
|
private final JavaPlugin plugin;
|
||||||
|
private final String name;
|
||||||
|
private final File file;
|
||||||
|
private FileConfiguration configuration;
|
||||||
|
private boolean needsMigration;
|
||||||
|
|
||||||
|
public ConfigHandler(JavaPlugin plugin, String name) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.name = name + ".yml";
|
||||||
|
this.file = new File(plugin.getDataFolder(), this.name);
|
||||||
|
this.configuration = new YamlConfiguration();
|
||||||
|
this.needsMigration = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the default config if it doesn't exist, otherwise loads the existing config
|
||||||
|
* and marks it for migration.
|
||||||
|
*/
|
||||||
|
public void saveDefaultConfig() {
|
||||||
|
boolean fileExists = file.exists();
|
||||||
|
|
||||||
|
if (!fileExists) {
|
||||||
|
plugin.saveResource(name, false);
|
||||||
|
} else {
|
||||||
|
// If file exists, it might need migration when plugin updates
|
||||||
|
needsMigration = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
configuration.load(file);
|
||||||
|
} catch (InvalidConfigurationException | IOException e) {
|
||||||
|
handleConfigError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the current configuration to file
|
||||||
|
*/
|
||||||
|
public void save() {
|
||||||
|
if (configuration == null || file == null) return;
|
||||||
|
try {
|
||||||
|
getConfig().save(file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
plugin.getLogger().severe("Failed to save configuration file: " + name + " — " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reloads the configuration from file
|
||||||
|
*/
|
||||||
|
public void reload() {
|
||||||
|
try {
|
||||||
|
configuration = YamlConfiguration.loadConfiguration(file);
|
||||||
|
} catch (Exception e) {
|
||||||
|
handleConfigError(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the file configuration
|
||||||
|
*/
|
||||||
|
public FileConfiguration getConfig() {
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the file associated with this config handler
|
||||||
|
*/
|
||||||
|
public File getFile() {
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this configuration needs migration
|
||||||
|
*/
|
||||||
|
public boolean needsMigration() {
|
||||||
|
return needsMigration;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marks this configuration as migrated
|
||||||
|
*/
|
||||||
|
public void setMigrated() {
|
||||||
|
this.needsMigration = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle configuration errors
|
||||||
|
*/
|
||||||
|
private void handleConfigError(Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
plugin.getLogger().severe("============= CONFIGURATION ERROR =============");
|
||||||
|
plugin.getLogger().severe("There was an error loading " + name);
|
||||||
|
plugin.getLogger().severe("Please check for any obvious configuration mistakes");
|
||||||
|
plugin.getLogger().severe("such as using tabs for spaces or forgetting to end quotes");
|
||||||
|
plugin.getLogger().severe("before reporting to the developer. The plugin will now disable..");
|
||||||
|
plugin.getLogger().severe("============= CONFIGURATION ERROR =============");
|
||||||
|
plugin.getServer().getPluginManager().disablePlugin(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.config;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ConfigManager {
|
||||||
|
|
||||||
|
private final Map<ConfigType, ConfigHandler> configurations;
|
||||||
|
private ConfigMigrator migrator;
|
||||||
|
|
||||||
|
public ConfigManager() {
|
||||||
|
configurations = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFiles(VexlioHubPlugin plugin) {
|
||||||
|
// Initialize the config migrator
|
||||||
|
migrator = new ConfigMigrator(plugin);
|
||||||
|
|
||||||
|
// Register all config files
|
||||||
|
registerFile(ConfigType.SETTINGS, new ConfigHandler(plugin, "config"));
|
||||||
|
registerFile(ConfigType.MESSAGES, new ConfigHandler(plugin, "messages"));
|
||||||
|
registerFile(ConfigType.DATA, new ConfigHandler(plugin, "data"));
|
||||||
|
registerFile(ConfigType.COMMANDS, new ConfigHandler(plugin, "commands"));
|
||||||
|
|
||||||
|
// Load all configs
|
||||||
|
configurations.values().forEach(ConfigHandler::saveDefaultConfig);
|
||||||
|
|
||||||
|
// Perform migrations if needed
|
||||||
|
migrateConfigs();
|
||||||
|
|
||||||
|
// Set the Messages configuration
|
||||||
|
Messages.setConfiguration(getFile(ConfigType.MESSAGES).getConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrates all configurations that need updating
|
||||||
|
*/
|
||||||
|
private void migrateConfigs() {
|
||||||
|
for (Map.Entry<ConfigType, ConfigHandler> entry : configurations.entrySet()) {
|
||||||
|
ConfigHandler handler = entry.getValue();
|
||||||
|
if (handler.needsMigration()) {
|
||||||
|
if (migrator.migrateConfig(entry.getKey(), handler)) {
|
||||||
|
handler.setMigrated();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigHandler getFile(ConfigType type) {
|
||||||
|
return configurations.get(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reloadFiles() {
|
||||||
|
configurations.values().forEach(ConfigHandler::reload);
|
||||||
|
// Perform migrations after reload in case plugin has been updated
|
||||||
|
migrateConfigs();
|
||||||
|
Messages.setConfiguration(getFile(ConfigType.MESSAGES).getConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveFiles() {
|
||||||
|
configurations.values().forEach(ConfigHandler::save);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerFile(ConfigType type, ConfigHandler config) {
|
||||||
|
configurations.put(type, config);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileConfiguration getFileConfiguration(File file) {
|
||||||
|
return YamlConfiguration.loadConfiguration(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,254 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.config;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
public class ConfigMigrator {
|
||||||
|
|
||||||
|
private final JavaPlugin plugin;
|
||||||
|
private final Version currentVersion;
|
||||||
|
private final List<VersionMigration> versionMigrations;
|
||||||
|
private final Set<String> excludedPaths;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new ConfigMigrator with the current plugin version
|
||||||
|
*/
|
||||||
|
public ConfigMigrator(JavaPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.currentVersion = Version.parse(plugin.getPluginMeta().getVersion());
|
||||||
|
this.versionMigrations = new ArrayList<>();
|
||||||
|
this.excludedPaths = new HashSet<>();
|
||||||
|
|
||||||
|
// Register paths to exclude from migration
|
||||||
|
registerExcludedPaths();
|
||||||
|
|
||||||
|
// Register any version-specific migrations here
|
||||||
|
registerMigrations();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register paths that should be excluded from migration
|
||||||
|
*/
|
||||||
|
private void registerExcludedPaths() {
|
||||||
|
// Add the announcements section to excluded paths
|
||||||
|
excludedPaths.add("announcements");
|
||||||
|
excludedPaths.add("custom_join_items");
|
||||||
|
excludedPaths.add("join_events");
|
||||||
|
excludedPaths.add("custom_commands");
|
||||||
|
excludedPaths.add("commands");
|
||||||
|
excludedPaths.add("command_block");
|
||||||
|
excludedPaths.add("anti_swear");
|
||||||
|
excludedPaths.add("join_settings");
|
||||||
|
excludedPaths.add("pvp_mode");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Add other paths to exclude if needed
|
||||||
|
// excludedPaths.add("another.path.to.exclude");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerMigrations() {
|
||||||
|
// Example: Add migrations for specific version jumps
|
||||||
|
// versionMigrations.add(new VersionMigration(
|
||||||
|
// Version.parse("1.0.0"),
|
||||||
|
// Version.parse("1.1.0"),
|
||||||
|
// this::migrateFrom1_0_0To1_1_0
|
||||||
|
// ));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Migrates a configuration file, adding missing options from the default config
|
||||||
|
* while preserving existing values.
|
||||||
|
*
|
||||||
|
* @param configType The type of config to migrate
|
||||||
|
* @param configHandler The config handler containing the file
|
||||||
|
* @return True if changes were made, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean migrateConfig(ConfigType configType, ConfigHandler configHandler) {
|
||||||
|
String fileName = getFileNameForType(configType);
|
||||||
|
if (fileName == null) {
|
||||||
|
plugin.getLogger().warning("No file name found for config type: " + configType);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the resource from jar
|
||||||
|
InputStream defaultConfigStream = plugin.getResource(fileName);
|
||||||
|
if (defaultConfigStream == null) {
|
||||||
|
plugin.getLogger().warning("Could not find default configuration for: " + fileName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load default config from jar
|
||||||
|
FileConfiguration defaultConfig = YamlConfiguration.loadConfiguration(
|
||||||
|
new InputStreamReader(defaultConfigStream));
|
||||||
|
|
||||||
|
// Get current config
|
||||||
|
FileConfiguration currentConfig = configHandler.getConfig();
|
||||||
|
|
||||||
|
// Track if we made changes
|
||||||
|
boolean changes = false;
|
||||||
|
|
||||||
|
// Check if we need to perform version-specific migrations
|
||||||
|
String storedVersion = currentConfig.getString("version", "0.0.0");
|
||||||
|
Version configVersion = Version.parse(storedVersion);
|
||||||
|
|
||||||
|
// Run version-specific migrations if config version is older than current version
|
||||||
|
if (configVersion.isOlderThan(currentVersion)) {
|
||||||
|
for (VersionMigration migration : versionMigrations) {
|
||||||
|
if (configVersion.isOlderThan(migration.getTargetVersion()) &&
|
||||||
|
(migration.getSourceVersion().isSameAs(configVersion) ||
|
||||||
|
migration.getSourceVersion().isOlderThan(configVersion))) {
|
||||||
|
|
||||||
|
plugin.getLogger().info("Applying migration from " +
|
||||||
|
migration.getSourceVersion() + " to " + migration.getTargetVersion() +
|
||||||
|
" for " + fileName);
|
||||||
|
|
||||||
|
// Apply the migration
|
||||||
|
if (migration.apply(configType, currentConfig)) {
|
||||||
|
changes = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the version in the config
|
||||||
|
currentConfig.set("version", currentVersion.toString());
|
||||||
|
changes = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add missing sections and values
|
||||||
|
if (addMissingEntries(defaultConfig, currentConfig, "")) {
|
||||||
|
changes = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save if changes were made
|
||||||
|
if (changes) {
|
||||||
|
try {
|
||||||
|
configHandler.save();
|
||||||
|
plugin.getLogger().info("Updated configuration file: " + fileName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().log(Level.SEVERE, "Could not save updated configuration for: " + fileName, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively adds missing entries from default config to current config,
|
||||||
|
* but skips excluded paths
|
||||||
|
*
|
||||||
|
* @param defaultConfig The default configuration from resources
|
||||||
|
* @param currentConfig The current configuration file
|
||||||
|
* @param path The current path being examined
|
||||||
|
* @return True if changes were made, false otherwise
|
||||||
|
*/
|
||||||
|
private boolean addMissingEntries(FileConfiguration defaultConfig, FileConfiguration currentConfig, String path) {
|
||||||
|
boolean changes = false;
|
||||||
|
|
||||||
|
// Skip this path and its children if it's in the excluded paths
|
||||||
|
for (String excludedPath : excludedPaths) {
|
||||||
|
if (path.equals(excludedPath) || path.startsWith(excludedPath + ".")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> defaultKeys = path.isEmpty()
|
||||||
|
? defaultConfig.getKeys(false)
|
||||||
|
: defaultConfig.getConfigurationSection(path).getKeys(false);
|
||||||
|
|
||||||
|
for (String key : defaultKeys) {
|
||||||
|
String fullPath = path.isEmpty() ? key : path + "." + key;
|
||||||
|
|
||||||
|
// Skip excluded paths
|
||||||
|
boolean shouldSkip = false;
|
||||||
|
for (String excludedPath : excludedPaths) {
|
||||||
|
if (fullPath.equals(excludedPath) || fullPath.startsWith(excludedPath + ".")) {
|
||||||
|
shouldSkip = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shouldSkip) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!currentConfig.contains(fullPath)) {
|
||||||
|
// This key doesn't exist in the current config, so add it
|
||||||
|
currentConfig.set(fullPath, defaultConfig.get(fullPath));
|
||||||
|
changes = true;
|
||||||
|
plugin.getLogger().info("Added missing config option: " + fullPath);
|
||||||
|
} else if (defaultConfig.isConfigurationSection(fullPath)) {
|
||||||
|
// This is a section, so recursively check its children
|
||||||
|
changes |= addMissingEntries(defaultConfig, currentConfig, fullPath);
|
||||||
|
}
|
||||||
|
// If the path exists and isn't a section, keep the user's current value
|
||||||
|
}
|
||||||
|
|
||||||
|
return changes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the file name for the given config type
|
||||||
|
*/
|
||||||
|
private String getFileNameForType(ConfigType type) {
|
||||||
|
switch (type) {
|
||||||
|
case SETTINGS:
|
||||||
|
return "config.yml";
|
||||||
|
case MESSAGES:
|
||||||
|
return "messages.yml";
|
||||||
|
case COMMANDS:
|
||||||
|
return "commands.yml";
|
||||||
|
case DATA:
|
||||||
|
return "data.yml";
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class representing a migration between two specific versions
|
||||||
|
*/
|
||||||
|
private class VersionMigration {
|
||||||
|
private final Version sourceVersion;
|
||||||
|
private final Version targetVersion;
|
||||||
|
private final MigrationFunction migrationFunction;
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
public VersionMigration(Version sourceVersion, Version targetVersion,
|
||||||
|
MigrationFunction migrationFunction) {
|
||||||
|
this.sourceVersion = sourceVersion;
|
||||||
|
this.targetVersion = targetVersion;
|
||||||
|
this.migrationFunction = migrationFunction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Version getSourceVersion() {
|
||||||
|
return sourceVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Version getTargetVersion() {
|
||||||
|
return targetVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean apply(ConfigType configType, FileConfiguration config) {
|
||||||
|
return migrationFunction.migrate(configType, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Functional interface for migration functions
|
||||||
|
*/
|
||||||
|
@FunctionalInterface
|
||||||
|
private interface MigrationFunction {
|
||||||
|
boolean migrate(ConfigType configType, FileConfiguration config);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.config;
|
||||||
|
|
||||||
|
public enum ConfigType {
|
||||||
|
|
||||||
|
SETTINGS,
|
||||||
|
MESSAGES,
|
||||||
|
COMMANDS,
|
||||||
|
DATA
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.config;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public enum Messages {
|
||||||
|
|
||||||
|
PREFIX("GENERAL.PREFIX"),
|
||||||
|
NO_PERMISSION("GENERAL.NO_PERMISSION"),
|
||||||
|
CUSTOM_COMMAND_NO_PERMISSION("GENERAL.CUSTOM_COMMAND_NO_PERMISSION"),
|
||||||
|
INVALID_PLAYER("GENERAL.INVALID_PLAYER"),
|
||||||
|
CONFIG_RELOAD("GENERAL.CONFIG_RELOAD"),
|
||||||
|
COOLDOWN_ACTIVE("GENERAL.COOLDOWN_ACTIVE"),
|
||||||
|
|
||||||
|
GAMEMODE_CHANGE("GAMEMODE.GAMEMODE_CHANGE"),
|
||||||
|
GAMEMODE_CHANGE_OTHER("GAMEMODE.GAMEMODE_CHANGE_OTHER"),
|
||||||
|
GAMEMODE_INVALID("GAMEMODE.GAMEMODE_INVALID"),
|
||||||
|
|
||||||
|
FLIGHT_ENABLE("FLIGHT.ENABLE"),
|
||||||
|
FLIGHT_ENABLE_OTHER("FLIGHT.ENABLE_OTHER"),
|
||||||
|
FLIGHT_DISABLE("FLIGHT.DISABLE"),
|
||||||
|
FLIGHT_DISABLE_OTHER("FLIGHT.DISABLE_OTHER"),
|
||||||
|
|
||||||
|
PLAYER_HIDER_HIDDEN("PLAYER_HIDER.HIDDEN"),
|
||||||
|
PLAYER_HIDER_SHOWN("PLAYER_HIDER.SHOWN"),
|
||||||
|
|
||||||
|
SET_LOBBY("LOBBY.SET_LOBBY"),
|
||||||
|
|
||||||
|
CLEARCHAT("CHAT.CLEARCHAT"),
|
||||||
|
CLEARCHAT_PLAYER("CHAT.CLEARCHAT_PLAYER"),
|
||||||
|
|
||||||
|
DOUBLE_JUMP_COOLDOWN("DOUBLE_JUMP.COOLDOWN_ACTIVE"),
|
||||||
|
|
||||||
|
EVENT_ITEM_DROP("WORLD_EVENT_MODIFICATIONS.ITEM_DROP"),
|
||||||
|
EVENT_ITEM_PICKUP("WORLD_EVENT_MODIFICATIONS.ITEM_PICKUP"),
|
||||||
|
EVENT_BLOCK_PLACE("WORLD_EVENT_MODIFICATIONS.BLOCK_PLACE"),
|
||||||
|
EVENT_BLOCK_BREAK("WORLD_EVENT_MODIFICATIONS.BLOCK_BREAK"),
|
||||||
|
EVENT_BLOCK_INTERACT("WORLD_EVENT_MODIFICATIONS.BLOCK_INTERACT"),
|
||||||
|
|
||||||
|
BUILD_MODE_ENABLED_ACTIONBAR("BUILD_MODE.ENABLED_ACTION_BAR"),
|
||||||
|
BUILD_MODE_ENABLED("BUILD_MODE.ENABLED"),
|
||||||
|
BUILD_MODE_DISABLED("BUILD_MODE.DISABLED"),
|
||||||
|
BUILD_MODE_COMMAND_TARGET_NOT_FOUND("BUILD_MODE.TARGET_NOT_FOUND"),
|
||||||
|
BUILD_MODE_COMMAND_ENABLED_FOR_TARGET("BUILD_MODE.ENABLED_FOR_TARGET");
|
||||||
|
|
||||||
|
private static FileConfiguration config;
|
||||||
|
private final String path;
|
||||||
|
|
||||||
|
Messages(String path) {
|
||||||
|
this.path = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setConfiguration(FileConfiguration c) {
|
||||||
|
config = c;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
Object value = config.get("Messages." + this.path);
|
||||||
|
String message;
|
||||||
|
if (value == null) {
|
||||||
|
message = "VexlioHub: message not found (" + this.path + ") - Check your messages.yml!";
|
||||||
|
} else {
|
||||||
|
message = value instanceof List ? TextUtil.fromList((List<?>) value) : value.toString();
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void send(CommandSender receiver, Object... replacements) {
|
||||||
|
String message = toString();
|
||||||
|
if (!message.isEmpty()) {
|
||||||
|
receiver.sendMessage(TextUtil.color(replace(message, replacements)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String replace(String message, Object... replacements) {
|
||||||
|
for (int i = 0; i < replacements.length; i += 2) {
|
||||||
|
if (i + 1 >= replacements.length) break;
|
||||||
|
message = message.replace(String.valueOf(replacements[i]), String.valueOf(replacements[i + 1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
String prefix = config.getString("Messages." + PREFIX.getPath());
|
||||||
|
return message.replace("%prefix%", prefix != null && !prefix.isEmpty() ? prefix : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPath() {
|
||||||
|
return this.path;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.config;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a version in the format major.minor.patch
|
||||||
|
* Used for tracking plugin versions and migrations
|
||||||
|
*/
|
||||||
|
public class Version implements Comparable<Version> {
|
||||||
|
private final int major;
|
||||||
|
private final int minor;
|
||||||
|
private final int patch;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a version from major, minor, and patch values
|
||||||
|
*/
|
||||||
|
public Version(int major, int minor, int patch) {
|
||||||
|
this.major = major;
|
||||||
|
this.minor = minor;
|
||||||
|
this.patch = patch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses a version string in the format "major.minor.patch"
|
||||||
|
*/
|
||||||
|
public static Version parse(String versionStr) {
|
||||||
|
String[] parts = versionStr.split("\\.");
|
||||||
|
|
||||||
|
int major = 0, minor = 0, patch = 0;
|
||||||
|
|
||||||
|
if (parts.length >= 1) {
|
||||||
|
try {
|
||||||
|
major = Integer.parseInt(parts[0]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// Ignore and use default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parts.length >= 2) {
|
||||||
|
try {
|
||||||
|
minor = Integer.parseInt(parts[1]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// Ignore and use default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parts.length >= 3) {
|
||||||
|
try {
|
||||||
|
patch = Integer.parseInt(parts[2]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// Ignore and use default
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Version(major, minor, patch);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares this version with another version
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int compareTo(Version other) {
|
||||||
|
if (this.major != other.major) {
|
||||||
|
return Integer.compare(this.major, other.major);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.minor != other.minor) {
|
||||||
|
return Integer.compare(this.minor, other.minor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Integer.compare(this.patch, other.patch);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this version is newer than another version
|
||||||
|
*/
|
||||||
|
public boolean isNewerThan(Version other) {
|
||||||
|
return compareTo(other) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this version is the same as another version
|
||||||
|
*/
|
||||||
|
public boolean isSameAs(Version other) {
|
||||||
|
return compareTo(other) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if this version is older than another version
|
||||||
|
*/
|
||||||
|
public boolean isOlderThan(Version other) {
|
||||||
|
return compareTo(other) < 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return major + "." + minor + "." + patch;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.cooldown;
|
||||||
|
|
||||||
|
import com.google.common.collect.HashBasedTable;
|
||||||
|
import com.google.common.collect.Table;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class CooldownManager {
|
||||||
|
|
||||||
|
private final Table<String, CooldownType, Long> cooldowns = HashBasedTable.create();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the number of milliseconds left until a given cooldown expires.
|
||||||
|
* <p>
|
||||||
|
* Check for a negative value to determine if a given cooldown has expired. <br>
|
||||||
|
* Cooldowns that have never been defined will return {@link Long#MIN_VALUE}.
|
||||||
|
*
|
||||||
|
* @param uuid - the uuid of the player.
|
||||||
|
* @param key - cooldown to locate.
|
||||||
|
* @return Number of milliseconds until the cooldown expires.
|
||||||
|
*/
|
||||||
|
public long getCooldown(UUID uuid, CooldownType key) {
|
||||||
|
return calculateRemainder(cooldowns.get(uuid.toString(), key));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a cooldown for the specified player.
|
||||||
|
*
|
||||||
|
* @param uuid - uuid of the player.
|
||||||
|
* @param key - cooldown to update.
|
||||||
|
* @param delay - number of milliseconds until the cooldown will expire again.
|
||||||
|
* @return The previous number of milliseconds until expiration.
|
||||||
|
*/
|
||||||
|
public long setCooldown(UUID uuid, CooldownType key, long delay) {
|
||||||
|
return calculateRemainder(cooldowns.put(uuid.toString(), key, System.currentTimeMillis() + (delay * 1000)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if a given cooldown has expired. If it has, refresh the cooldown. If not, do nothing.
|
||||||
|
*
|
||||||
|
* @param uuid - uuid of the player.
|
||||||
|
* @param key - cooldown to update.
|
||||||
|
* @param delay - number of milliseconds until the cooldown will expire again.
|
||||||
|
* @return TRUE if the cooldown was expired/unset and has now been reset, FALSE otherwise.
|
||||||
|
*/
|
||||||
|
public boolean tryCooldown(UUID uuid, CooldownType key, long delay) {
|
||||||
|
if (getCooldown(uuid, key) / 1000 > 0) return false;
|
||||||
|
setCooldown(uuid, key, delay + 1);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove any cooldowns associated with the given player.
|
||||||
|
*
|
||||||
|
* @param uuid - the uuid of the player we will reset.
|
||||||
|
*/
|
||||||
|
public void removeCooldowns(UUID uuid) {
|
||||||
|
cooldowns.row(uuid.toString()).clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private long calculateRemainder(Long expireTime) {
|
||||||
|
return expireTime != null ? expireTime - System.currentTimeMillis() : Long.MIN_VALUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.cooldown;
|
||||||
|
|
||||||
|
public enum CooldownType {
|
||||||
|
BLOCK_BREAK,
|
||||||
|
BLOCK_PLACE,
|
||||||
|
BLOCK_INTERACT,
|
||||||
|
ITEM_DROP,
|
||||||
|
ITEM_PICKUP,
|
||||||
|
DOUBLE_JUMP,
|
||||||
|
LAUNCHPAD,
|
||||||
|
PLAYER_HIDER
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.hook;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.PlaceholderUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class HooksManager {
|
||||||
|
|
||||||
|
private final Map<String, PluginHook> hooks;
|
||||||
|
|
||||||
|
public HooksManager(VexlioHubPlugin plugin) {
|
||||||
|
hooks = new HashMap<>();
|
||||||
|
|
||||||
|
// PlaceholderAPI
|
||||||
|
if (Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI")) {
|
||||||
|
hooks.put("PLACEHOLDER_API", null);
|
||||||
|
PlaceholderUtil.PAPI = true;
|
||||||
|
plugin.getLogger().info(" Hooked into PlaceholderAPI");
|
||||||
|
}
|
||||||
|
|
||||||
|
hooks.values().stream().filter(Objects::nonNull).forEach(pluginHook -> pluginHook.onEnable(plugin));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHookEnabled(String id) {
|
||||||
|
return hooks.containsKey(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PluginHook getPluginHook(String id) {
|
||||||
|
return hooks.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.hook;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
|
||||||
|
public interface PluginHook {
|
||||||
|
|
||||||
|
void onEnable(VexlioHubPlugin plugin);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,115 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.inventory;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.ItemStackBuilder;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.NamespacedKeys;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public abstract class AbstractInventory implements Listener {
|
||||||
|
|
||||||
|
private final VexlioHubPlugin plugin;
|
||||||
|
private final List<UUID> openInventories;
|
||||||
|
private boolean refreshEnabled = false;
|
||||||
|
|
||||||
|
public AbstractInventory(VexlioHubPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
openInventories = new ArrayList<>();
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInventoryRefresh(long value) {
|
||||||
|
if (value <= 0) return;
|
||||||
|
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new InventoryTask(this), 0L, value);
|
||||||
|
refreshEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void onEnable();
|
||||||
|
|
||||||
|
protected abstract Inventory getInventory();
|
||||||
|
|
||||||
|
protected VexlioHubPlugin getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Inventory refreshInventory(Player player, Inventory inventory) {
|
||||||
|
if (!(inventory.getHolder() instanceof InventoryBuilder holder)) return inventory;
|
||||||
|
|
||||||
|
for (Map.Entry<Integer, List<InventoryItem>> entry : holder.getIcons().entrySet()) {
|
||||||
|
int slot = entry.getKey();
|
||||||
|
InventoryItem inventoryItem = holder.getIcon(slot, player);
|
||||||
|
|
||||||
|
if (inventoryItem == null) {
|
||||||
|
inventory.setItem(slot, null);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack item = inventoryItem.getItemStack().clone();
|
||||||
|
if (item.getType() == Material.AIR || !item.hasItemMeta()) {
|
||||||
|
inventory.setItem(slot, item);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item.getType() == Material.PLAYER_HEAD) {
|
||||||
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (itemMeta != null) {
|
||||||
|
PersistentDataContainer dataContainer = itemMeta.getPersistentDataContainer();
|
||||||
|
if (dataContainer.get(NamespacedKeys.Keys.PLAYER_HEAD.get(), PersistentDataType.BOOLEAN) != null) {
|
||||||
|
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
meta.setPlayerProfile(player.getPlayerProfile());
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStackBuilder newItem = new ItemStackBuilder(item);
|
||||||
|
if (item.getItemMeta().hasDisplayName()) newItem.withName(
|
||||||
|
LegacyComponentSerializer.legacySection().serialize(item.getItemMeta().displayName()), player);
|
||||||
|
if (item.getItemMeta().hasLore()) newItem.withLore(
|
||||||
|
item.getItemMeta().lore().stream()
|
||||||
|
.map(c -> LegacyComponentSerializer.legacySection().serialize(c))
|
||||||
|
.toList(), player);
|
||||||
|
inventory.setItem(slot, newItem.build());
|
||||||
|
}
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void openInventory(Player player) {
|
||||||
|
if (getInventory() == null) return;
|
||||||
|
|
||||||
|
player.openInventory(refreshInventory(player, getInventory()));
|
||||||
|
if (refreshEnabled && !openInventories.contains(player.getUniqueId())) {
|
||||||
|
openInventories.add(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<UUID> getOpenInventories() {
|
||||||
|
return openInventories;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClose(InventoryCloseEvent event) {
|
||||||
|
if (event.getView().getTopInventory().getHolder() instanceof InventoryBuilder && refreshEnabled) {
|
||||||
|
openInventories.remove(event.getPlayer().getUniqueId());
|
||||||
|
//System.out.println("removed " + event.getPlayer().getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.inventory;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface ClickAction {
|
||||||
|
void execute(final Player p0);
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.inventory;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class InventoryBuilder implements InventoryHolder {
|
||||||
|
|
||||||
|
private final Map<Integer, List<InventoryItem>> icons;
|
||||||
|
private int size;
|
||||||
|
private final String title;
|
||||||
|
|
||||||
|
public InventoryBuilder(int size, String title) {
|
||||||
|
this.icons = new HashMap<>();
|
||||||
|
this.size = size;
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItem(int slot, InventoryItem item) {
|
||||||
|
icons.computeIfAbsent(slot, k -> new ArrayList<>()).add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryItem getIcon(final int slot) {
|
||||||
|
List<InventoryItem> items = icons.get(slot);
|
||||||
|
return (items != null && !items.isEmpty()) ? items.get(0) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryItem getIcon(final int slot, Player player) {
|
||||||
|
List<InventoryItem> items = icons.get(slot);
|
||||||
|
if (items == null) return null;
|
||||||
|
return items.stream()
|
||||||
|
.filter(item -> item.hasPermission(player))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, List<InventoryItem>> getIcons() {
|
||||||
|
return icons;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Inventory getInventory() {
|
||||||
|
if (size > 54) size = 54;
|
||||||
|
else if (size < 9) size = 9;
|
||||||
|
|
||||||
|
Inventory inventory = Bukkit.createInventory(this, size,
|
||||||
|
LegacyComponentSerializer.legacyAmpersand().deserialize(title));
|
||||||
|
for (Map.Entry<Integer, List<InventoryItem>> entry : icons.entrySet()) {
|
||||||
|
if (!entry.getValue().isEmpty()) {
|
||||||
|
inventory.setItem(entry.getKey(), entry.getValue().get(0).getItemStack());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return inventory;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.inventory;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class InventoryItem {
|
||||||
|
|
||||||
|
public final ItemStack itemStack;
|
||||||
|
public final List<ClickAction> clickActions;
|
||||||
|
private String permission;
|
||||||
|
|
||||||
|
public InventoryItem(final ItemStack itemStack) {
|
||||||
|
this.clickActions = new ArrayList<>();
|
||||||
|
this.itemStack = itemStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryItem addClickAction(final ClickAction clickAction) {
|
||||||
|
this.clickActions.add(clickAction);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public InventoryItem withPermission(String permission) {
|
||||||
|
this.permission = permission;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPermission() {
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermission(Player player) {
|
||||||
|
return permission == null || player.hasPermission(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClickAction> getClickActions() {
|
||||||
|
return this.clickActions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getItemStack() {
|
||||||
|
return this.itemStack;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.inventory;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.world.BuildMode;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
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.ItemStack;
|
||||||
|
|
||||||
|
public class InventoryListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
|
if (BuildMode.getInstance().isPresent(event.getWhoClicked().getUniqueId())) return;
|
||||||
|
if (event.getView().getTopInventory().getHolder() instanceof InventoryBuilder) {
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
if (event.getWhoClicked() instanceof Player) {
|
||||||
|
|
||||||
|
Player player = (Player) event.getWhoClicked();
|
||||||
|
ItemStack itemStack = event.getCurrentItem();
|
||||||
|
|
||||||
|
if (itemStack == null || itemStack.getType() == Material.AIR) return;
|
||||||
|
|
||||||
|
InventoryBuilder customHolder = (InventoryBuilder) event.getView().getTopInventory().getHolder();
|
||||||
|
InventoryItem item = customHolder.getIcon(event.getRawSlot(), player);
|
||||||
|
|
||||||
|
if (item == null) return;
|
||||||
|
|
||||||
|
for (final ClickAction clickAction : item.getClickActions()) {
|
||||||
|
clickAction.execute(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.inventory;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.inventory.inventories.CustomGUI;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class InventoryManager {
|
||||||
|
|
||||||
|
private VexlioHubPlugin plugin;
|
||||||
|
|
||||||
|
private final Map<String, AbstractInventory> inventories;
|
||||||
|
|
||||||
|
public InventoryManager() {
|
||||||
|
inventories = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onEnable(VexlioHubPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
loadCustomMenus();
|
||||||
|
|
||||||
|
inventories.values().forEach(AbstractInventory::onEnable);
|
||||||
|
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(new InventoryListener(), plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadCustomMenus() {
|
||||||
|
|
||||||
|
File directory = new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "menus");
|
||||||
|
|
||||||
|
if (!directory.exists()) {
|
||||||
|
directory.mkdir();
|
||||||
|
File file = new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "menus", "serverselector.yml");
|
||||||
|
try (final InputStream inputStream = this.plugin.getResource("serverselector.yml")) {
|
||||||
|
file.createNewFile();
|
||||||
|
byte[] buffer = new byte[inputStream.available()];
|
||||||
|
inputStream.read(buffer);
|
||||||
|
|
||||||
|
final OutputStream outputStream = new FileOutputStream(file);
|
||||||
|
outputStream.write(buffer);
|
||||||
|
outputStream.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load all menu files
|
||||||
|
File[] yamlFiles = new File(plugin.getDataFolder().getAbsolutePath() + File.separator + "menus").listFiles((dir, name) -> name.toLowerCase().endsWith(".yml"));
|
||||||
|
if (yamlFiles == null) return;
|
||||||
|
|
||||||
|
for (File file : yamlFiles) {
|
||||||
|
String name = file.getName().replace(".yml", "");
|
||||||
|
if (inventories.containsKey(name)) {
|
||||||
|
plugin.getLogger().warning("Inventory with name '" + file.getName() + "' already exists, skipping duplicate..");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
CustomGUI customGUI;
|
||||||
|
try {
|
||||||
|
customGUI = new CustomGUI(plugin, YamlConfiguration.loadConfiguration(file));
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().severe("Could not load file '" + name + "' (YAML error).");
|
||||||
|
e.printStackTrace();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
inventories.put(name, customGUI);
|
||||||
|
plugin.getLogger().info("Loaded custom menu '" + name + "'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addInventory(String key, AbstractInventory inventory) {
|
||||||
|
inventories.put(key, inventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, AbstractInventory> getInventories() {
|
||||||
|
return inventories;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AbstractInventory getInventory(String key) {
|
||||||
|
return inventories.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisable() {
|
||||||
|
inventories.values().forEach(abstractInventory -> {
|
||||||
|
for (UUID uuid : abstractInventory.getOpenInventories()) {
|
||||||
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
|
if (player != null) player.closeInventory();
|
||||||
|
}
|
||||||
|
abstractInventory.getOpenInventories().clear();
|
||||||
|
});
|
||||||
|
inventories.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.inventory;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class InventoryTask implements Runnable {
|
||||||
|
|
||||||
|
private final AbstractInventory inventory;
|
||||||
|
|
||||||
|
InventoryTask(AbstractInventory inventory) {
|
||||||
|
this.inventory = inventory;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
for (UUID uuid : inventory.getOpenInventories()) {
|
||||||
|
Player player = Bukkit.getPlayer(uuid);
|
||||||
|
if (player != null) {
|
||||||
|
inventory.refreshInventory(player, player.getOpenInventory().getTopInventory());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.inventory.inventories;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.inventory.AbstractInventory;
|
||||||
|
import eu.milujukockoholky.vexliolobby.inventory.InventoryBuilder;
|
||||||
|
import eu.milujukockoholky.vexliolobby.inventory.InventoryItem;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.ItemStackBuilder;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CustomGUI extends AbstractInventory {
|
||||||
|
|
||||||
|
private InventoryBuilder inventory;
|
||||||
|
private final FileConfiguration config;
|
||||||
|
|
||||||
|
public CustomGUI(VexlioHubPlugin plugin, FileConfiguration config) {
|
||||||
|
super(plugin);
|
||||||
|
this.config = config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
|
||||||
|
InventoryBuilder inventoryBuilder = new InventoryBuilder(config.getInt("slots"), TextUtil.color(config.getString("title")));
|
||||||
|
|
||||||
|
if (config.contains("refresh") && config.getBoolean("refresh.enabled")) {
|
||||||
|
setInventoryRefresh(config.getLong("refresh.rate"));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<InventoryItem> fillerItems = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String entry : config.getConfigurationSection("items").getKeys(false)) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
ItemStackBuilder builder = ItemStackBuilder.getItemStack(config.getConfigurationSection("items." + entry));
|
||||||
|
|
||||||
|
InventoryItem inventoryItem;
|
||||||
|
if (!config.contains("items." + entry + ".actions")) {
|
||||||
|
inventoryItem = new InventoryItem(builder.build());
|
||||||
|
} else {
|
||||||
|
inventoryItem = new InventoryItem(builder.build()).addClickAction(p -> getPlugin().getActionManager().executeActions(p, config.getStringList("items." + entry + ".actions")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.contains("items." + entry + ".permission")) {
|
||||||
|
inventoryItem.withPermission(config.getString("items." + entry + ".permission"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.contains("items." + entry + ".slots")) {
|
||||||
|
for (String slot : config.getStringList("items." + entry + ".slots")) {
|
||||||
|
inventoryBuilder.setItem(Integer.parseInt(slot), inventoryItem);
|
||||||
|
}
|
||||||
|
} else if (config.contains("items." + entry + ".slot")) {
|
||||||
|
int slot = config.getInt("items." + entry + ".slot");
|
||||||
|
if (slot == -1) {
|
||||||
|
fillerItems.add(inventoryItem);
|
||||||
|
} else {
|
||||||
|
inventoryBuilder.setItem(slot, inventoryItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
getPlugin().getLogger().warning("There was an error loading GUI item ID '" + entry + "', skipping..");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fill remaining empty slots with filler items after all specific-slot items are loaded.
|
||||||
|
if (!fillerItems.isEmpty()) {
|
||||||
|
int totalSlots = Math.max(9, Math.min(54, config.getInt("slots")));
|
||||||
|
for (InventoryItem fillerItem : fillerItems) {
|
||||||
|
for (int s = 0; s < totalSlots; s++) {
|
||||||
|
if (!inventoryBuilder.getIcons().containsKey(s)) {
|
||||||
|
inventoryBuilder.setItem(s, fillerItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inventory = inventoryBuilder;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Inventory getInventory() {
|
||||||
|
return inventory.getInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.cooldown.CooldownManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.cooldown.CooldownType;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public abstract class Module implements Listener {
|
||||||
|
|
||||||
|
private final VexlioHubPlugin plugin;
|
||||||
|
private final ModuleType moduleType;
|
||||||
|
private List<String> disabledWorlds;
|
||||||
|
private final CooldownManager cooldownManager;
|
||||||
|
|
||||||
|
public Module(VexlioHubPlugin plugin, ModuleType type) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.moduleType = type;
|
||||||
|
this.cooldownManager = plugin.getCooldownManager();
|
||||||
|
this.disabledWorlds = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisabledWorlds(List<String> disabledWorlds) {
|
||||||
|
this.disabledWorlds = disabledWorlds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VexlioHubPlugin getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inDisabledWorld(Location location) {
|
||||||
|
return disabledWorlds.contains(location.getWorld().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inDisabledWorld(World world) {
|
||||||
|
return disabledWorlds.contains(world.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean tryCooldown(UUID uuid, CooldownType type, long delay) {
|
||||||
|
return cooldownManager.tryCooldown(uuid, type, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCooldown(UUID uuid, CooldownType type) {
|
||||||
|
return String.valueOf(cooldownManager.getCooldown(uuid, type) / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileConfiguration getConfig(ConfigType type) {
|
||||||
|
return getPlugin().getConfigManager().getFile(type).getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void executeActions(Player player, List<String> actions) {
|
||||||
|
getPlugin().getActionManager().executeActions(player, actions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModuleType getModuleType() {
|
||||||
|
return moduleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void onEnable();
|
||||||
|
|
||||||
|
public abstract void onDisable();
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.command.CustomCommandHandler;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.hotbar.HotbarManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.player.*;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.world.*;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.visual.ActionBarAnnouncements;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class ModuleManager {
|
||||||
|
|
||||||
|
private VexlioHubPlugin plugin;
|
||||||
|
private List<String> disabledWorlds;
|
||||||
|
private final Map<ModuleType, Module> modules = new HashMap<>();
|
||||||
|
|
||||||
|
public void loadModules(VexlioHubPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
if (!modules.isEmpty()) unloadModules();
|
||||||
|
|
||||||
|
FileConfiguration config = plugin.getConfigManager().getFile(ConfigType.SETTINGS).getConfig();
|
||||||
|
disabledWorlds = config.getStringList("disabled-worlds.worlds");
|
||||||
|
|
||||||
|
if (config.getBoolean("disabled-worlds.invert")) {
|
||||||
|
disabledWorlds = Bukkit.getWorlds().stream().map(World::getName).collect(Collectors.toList());
|
||||||
|
for (String world : config.getStringList("disabled-worlds.worlds")) disabledWorlds.remove(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
registerModule(new StaticTime(plugin), "static_time.enabled");
|
||||||
|
registerModule(new DoubleJump(plugin), "double_jump.enabled");
|
||||||
|
registerModule(new Launchpad(plugin), "launchpad.enabled");
|
||||||
|
registerModule(new CustomCommandHandler(plugin));
|
||||||
|
registerModule(new PlayerListener(plugin));
|
||||||
|
registerModule(new HotbarManager(plugin));
|
||||||
|
registerModule(new WorldProtect(plugin));
|
||||||
|
registerModule(new LobbySpawn(plugin));
|
||||||
|
registerModule(new ActionBarAnnouncements(plugin), "actionbar_announcements.enabled");
|
||||||
|
|
||||||
|
// Requires 1.9+
|
||||||
|
// if (XMaterial.supports(9)) {
|
||||||
|
// registerModule(new PlayerOffHandSwap(plugin), "world_settings.disable_off_hand_swap");
|
||||||
|
// }
|
||||||
|
|
||||||
|
for (Module module : modules.values()) {
|
||||||
|
try {
|
||||||
|
module.setDisabledWorlds(disabledWorlds);
|
||||||
|
module.onEnable();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
plugin.getLogger().severe("============= VEXLIOHUB MODULE LOAD ERROR =============");
|
||||||
|
plugin.getLogger().severe("There was an error loading the " + module.getModuleType() + " module");
|
||||||
|
plugin.getLogger().severe("The plugin will now disable..");
|
||||||
|
plugin.getLogger().severe("============= VEXLIOHUB MODULE LOAD ERROR =============");
|
||||||
|
plugin.getServer().getPluginManager().disablePlugin(plugin);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getLogger().info("Loaded " + modules.size() + " plugin modules.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unloadModules() {
|
||||||
|
for (Module module : modules.values()) {
|
||||||
|
try {
|
||||||
|
HandlerList.unregisterAll(module);
|
||||||
|
module.onDisable();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
plugin.getLogger().severe("There was an error unloading the " + module.getModuleType().toString() + " module.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modules.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Module getModule(ModuleType type) {
|
||||||
|
return modules.get(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerModule(Module module) {
|
||||||
|
registerModule(module, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerModule(Module module, String isEnabledPath) {
|
||||||
|
VexlioHubPlugin plugin = module.getPlugin();
|
||||||
|
if (isEnabledPath != null && !plugin.getConfigManager().getFile(ConfigType.SETTINGS).getConfig().getBoolean(isEnabledPath, false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(module, plugin);
|
||||||
|
modules.put(module.getModuleType(), module);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled(ModuleType type) {
|
||||||
|
return modules.containsKey(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getDisabledWorlds() {
|
||||||
|
return disabledWorlds;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module;
|
||||||
|
|
||||||
|
public enum ModuleType {
|
||||||
|
STATIC_TIME,
|
||||||
|
CUSTOM_COMMANDS,
|
||||||
|
DOUBLE_JUMP,
|
||||||
|
LAUNCHPAD,
|
||||||
|
WORLD_PROTECT,
|
||||||
|
LOBBY,
|
||||||
|
HOTBAR_ITEMS,
|
||||||
|
PLAYER_LISTENER,
|
||||||
|
PLAYER_OFFHAND_LISTENER,
|
||||||
|
ACTIONBAR_ANNOUNCEMENTS
|
||||||
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.hotbar;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.world.BuildMode;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.ItemStackBuilder;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
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.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.player.*;
|
||||||
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public abstract class HotbarItem implements Listener {
|
||||||
|
|
||||||
|
private final HotbarManager hotbarManager;
|
||||||
|
private final ItemStack item;
|
||||||
|
private final String key;
|
||||||
|
private final int slot;
|
||||||
|
private ConfigurationSection configurationSection;
|
||||||
|
private String permission = null;
|
||||||
|
private boolean allowMovement;
|
||||||
|
|
||||||
|
public HotbarItem(HotbarManager hotbarManager, ItemStack item, int slot, String key) {
|
||||||
|
this.hotbarManager = hotbarManager;
|
||||||
|
this.key = key;
|
||||||
|
this.slot = slot;
|
||||||
|
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
meta.getPersistentDataContainer().set(new NamespacedKey(getPlugin(), "hotbarItem"), PersistentDataType.STRING, key);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
this.item = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public VexlioHubPlugin getPlugin() {
|
||||||
|
return hotbarManager.getPlugin();
|
||||||
|
}
|
||||||
|
|
||||||
|
public HotbarManager getHotbarManager() {
|
||||||
|
return hotbarManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack getItem() {
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected abstract void onInteract(Player player);
|
||||||
|
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSlot() {
|
||||||
|
return slot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAllowMovement(boolean allowMovement) {
|
||||||
|
this.allowMovement = allowMovement;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPermission() {
|
||||||
|
return permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPermission(String permission) {
|
||||||
|
this.permission = permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigurationSection getConfigurationSection() {
|
||||||
|
return configurationSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setConfigurationSection(ConfigurationSection configurationSection) {
|
||||||
|
this.configurationSection = configurationSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void giveItem(Player player) {
|
||||||
|
if (permission != null && !player.hasPermission(permission)) return;
|
||||||
|
|
||||||
|
ItemStack newItem = item.clone();
|
||||||
|
if (getConfigurationSection() != null && getConfigurationSection().contains("username")) {
|
||||||
|
newItem = new ItemStackBuilder(newItem).setSkullOwner(player.getName()).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().setItem(slot, newItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeItem(Player player) {
|
||||||
|
PlayerInventory inventory = player.getInventory();
|
||||||
|
ItemStack item = inventory.getItem(slot);
|
||||||
|
if (item == null) return;
|
||||||
|
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
String hotbarItem = meta.getPersistentDataContainer().get(new NamespacedKey(getPlugin(), "hotbarItem"), PersistentDataType.STRING);
|
||||||
|
if (hotbarItem != null && hotbarItem.equals(key)) {
|
||||||
|
inventory.remove(Objects.requireNonNull(inventory.getItem(slot)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
|
if (!allowMovement) return;
|
||||||
|
if (BuildMode.getInstance().isPresent(event.getWhoClicked().getUniqueId())) return;
|
||||||
|
|
||||||
|
Player player = (Player) event.getWhoClicked();
|
||||||
|
if (getHotbarManager().inDisabledWorld(player.getLocation())) return;
|
||||||
|
|
||||||
|
ItemStack clicked = event.getCurrentItem();
|
||||||
|
if (clicked == null || clicked.getType() == Material.AIR) return;
|
||||||
|
|
||||||
|
ItemMeta meta = clicked.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
String hotbarItem = meta.getPersistentDataContainer().get(new NamespacedKey(getPlugin(), "hotbarItem"), PersistentDataType.STRING);
|
||||||
|
if (hotbarItem != null && event.getSlot() == slot && hotbarItem.equals(key))
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void hotbarItemInteract(PlayerInteractEvent event) {
|
||||||
|
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) return;
|
||||||
|
if (event.getHand() != EquipmentSlot.HAND) return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
|
if (item.getType() == Material.AIR) return;
|
||||||
|
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
String hotbarItem = meta.getPersistentDataContainer().get(new NamespacedKey(getPlugin(), "hotbarItem"), PersistentDataType.STRING);
|
||||||
|
if (hotbarItem != null && getHotbarManager().inDisabledWorld(player.getLocation()) && hotbarItem.equals(key)) return;
|
||||||
|
else if (hotbarItem != null && hotbarItem.equals(key)) {
|
||||||
|
onInteract(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void hotbarPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (!getHotbarManager().inDisabledWorld(player.getLocation())) giveItem(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void hotbarPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (!getHotbarManager().inDisabledWorld(player.getLocation())) removeItem(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void hotbarWorldChange(PlayerChangedWorldEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> {
|
||||||
|
if (getHotbarManager().inDisabledWorld(player.getLocation())) {
|
||||||
|
removeItem(player);
|
||||||
|
} else {
|
||||||
|
giveItem(player);
|
||||||
|
}
|
||||||
|
}, 5L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void hotbarPlayerRespawn(PlayerRespawnEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
if (!getHotbarManager().inDisabledWorld(player.getLocation())) giveItem(player);
|
||||||
|
if (getPlugin().getModuleManager().isEnabled(ModuleType.DOUBLE_JUMP)) {
|
||||||
|
player.setAllowFlight(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+111
@@ -0,0 +1,111 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.hotbar;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.world.BuildMode;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.Module;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.hotbar.items.CustomItem;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.hotbar.items.PlayerHider;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.ItemStackBuilder;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class HotbarManager extends Module {
|
||||||
|
|
||||||
|
private List<HotbarItem> hotbarItems;
|
||||||
|
private int _joinSlot;
|
||||||
|
|
||||||
|
public HotbarManager(VexlioHubPlugin plugin) {
|
||||||
|
super(plugin, ModuleType.HOTBAR_ITEMS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
changeToJoinSlot(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
hotbarItems = new ArrayList<>();
|
||||||
|
FileConfiguration config = getConfig(ConfigType.SETTINGS);
|
||||||
|
|
||||||
|
if (config.getBoolean("hotbar.joinslot")) {
|
||||||
|
_joinSlot = config.getInt("hotbar.slot_number");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("custom_join_items.enabled")) {
|
||||||
|
|
||||||
|
for (String entry : Objects.requireNonNull(config.getConfigurationSection("custom_join_items.items")).getKeys(false)) {
|
||||||
|
ItemStack item = ItemStackBuilder.getItemStack(config.getConfigurationSection("custom_join_items.items." + entry)).build();
|
||||||
|
CustomItem customItem = new CustomItem(this, item, config.getInt("custom_join_items.items." + entry + ".slot"), entry);
|
||||||
|
|
||||||
|
if (config.contains("custom_join_items.items." + entry + ".permission")) {
|
||||||
|
customItem.setPermission(config.getString("custom_join_items.items." + entry + ".permission"));
|
||||||
|
}
|
||||||
|
|
||||||
|
customItem.setConfigurationSection(config.getConfigurationSection("custom_join_items.items." + entry));
|
||||||
|
customItem.setAllowMovement(config.getBoolean("custom_join_items.disable_inventory_movement"));
|
||||||
|
registerHotbarItem(customItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("player_hider.enabled")) {
|
||||||
|
ItemStack item = ItemStackBuilder.getItemStack(config.getConfigurationSection("player_hider.not_hidden")).build();
|
||||||
|
PlayerHider playerHider = new PlayerHider(this, item, config.getInt("player_hider.slot"), "PLAYER_HIDER");
|
||||||
|
|
||||||
|
playerHider.setAllowMovement(config.getBoolean("player_hider.disable_inventory_movement"));
|
||||||
|
|
||||||
|
registerHotbarItem(playerHider);
|
||||||
|
}
|
||||||
|
|
||||||
|
giveItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
removeItems();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<HotbarItem> getHotbarItems() {
|
||||||
|
return hotbarItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerHotbarItem(HotbarItem hotbarItem) {
|
||||||
|
getPlugin().getServer().getPluginManager().registerEvents(hotbarItem, getPlugin());
|
||||||
|
hotbarItems.add(hotbarItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void changeToJoinSlot(Player player) {
|
||||||
|
player.getInventory().setHeldItemSlot(_joinSlot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void giveItems(Player player) {
|
||||||
|
hotbarItems.stream()
|
||||||
|
.filter(p -> !inDisabledWorld(player.getLocation()) && !BuildMode.getInstance().isPresent(player.getUniqueId()))
|
||||||
|
.forEach(hotbarItem -> hotbarItem.giveItem(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void giveItems() {
|
||||||
|
Bukkit.getOnlinePlayers().stream()
|
||||||
|
.filter(player -> !inDisabledWorld(player.getLocation())
|
||||||
|
&& !BuildMode.getInstance().isPresent(player.getUniqueId()))
|
||||||
|
.forEach(player -> hotbarItems.forEach(hotbarItem -> hotbarItem.giveItem(player)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeItems() {
|
||||||
|
Bukkit.getOnlinePlayers().stream()
|
||||||
|
.filter(player -> !inDisabledWorld(player.getLocation()))
|
||||||
|
.forEach(player -> hotbarItems.forEach(hotbarItem -> hotbarItem.removeItem(player)));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.hotbar.items;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.hotbar.HotbarItem;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.hotbar.HotbarManager;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CustomItem extends HotbarItem {
|
||||||
|
|
||||||
|
private final List<String> actions;
|
||||||
|
|
||||||
|
public CustomItem(HotbarManager hotbarManager, ItemStack item, int slot, String key) {
|
||||||
|
super(hotbarManager, item, slot, key);
|
||||||
|
actions = getPlugin().getConfigManager().getFile(ConfigType.SETTINGS).getConfig().getStringList("custom_join_items.items." + key + ".actions");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onInteract(Player player) {
|
||||||
|
getPlugin().getActionManager().executeActions(player, actions);
|
||||||
|
}
|
||||||
|
}
|
||||||
+130
@@ -0,0 +1,130 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.hotbar.items;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import eu.milujukockoholky.vexliolobby.cooldown.CooldownType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.hotbar.HotbarItem;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.hotbar.HotbarManager;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.ItemStackBuilder;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class PlayerHider extends HotbarItem {
|
||||||
|
|
||||||
|
private final int cooldown;
|
||||||
|
private final ItemStack hiddenItem;
|
||||||
|
private final List<UUID> hidden;
|
||||||
|
|
||||||
|
public PlayerHider(HotbarManager hotbarManager, ItemStack item, int slot, String key) {
|
||||||
|
super(hotbarManager, item, slot, key);
|
||||||
|
hidden = new ArrayList<>();
|
||||||
|
FileConfiguration config = getHotbarManager().getConfig(ConfigType.SETTINGS);
|
||||||
|
ItemStackBuilder builder = ItemStackBuilder.getItemStack(config.getConfigurationSection("player_hider.hidden"));
|
||||||
|
ItemMeta meta = builder.build().getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
meta.getPersistentDataContainer().set(new NamespacedKey(getPlugin(), "hotbarItem"), PersistentDataType.STRING, key);
|
||||||
|
hiddenItem = builder.build();
|
||||||
|
hiddenItem.setItemMeta(meta);
|
||||||
|
} else {
|
||||||
|
hiddenItem = null;
|
||||||
|
}
|
||||||
|
cooldown = config.getInt("player_hider.cooldown");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHiding(Player player) {
|
||||||
|
return hidden.contains(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isVanished(Player player) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onInteract(Player player) {
|
||||||
|
|
||||||
|
if (!getHotbarManager().tryCooldown(player.getUniqueId(), CooldownType.PLAYER_HIDER, cooldown)) {
|
||||||
|
Messages.COOLDOWN_ACTIVE.send(player, "%time%", getHotbarManager().getCooldown(player.getUniqueId(), CooldownType.PLAYER_HIDER));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hidden.contains(player.getUniqueId())) {
|
||||||
|
for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
|
player.hidePlayer(getPlugin(), pl);
|
||||||
|
}
|
||||||
|
hidden.add(player.getUniqueId());
|
||||||
|
Messages.PLAYER_HIDER_HIDDEN.send(player);
|
||||||
|
|
||||||
|
player.getInventory().setItem(getSlot(), hiddenItem);
|
||||||
|
} else {
|
||||||
|
for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
|
player.showPlayer(getPlugin(), pl);
|
||||||
|
if (isVanished(pl)) player.hidePlayer(getPlugin(), pl);
|
||||||
|
}
|
||||||
|
hidden.remove(player.getUniqueId());
|
||||||
|
Messages.PLAYER_HIDER_SHOWN.send(player);
|
||||||
|
|
||||||
|
player.getInventory().setItem(getSlot(), getItem());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (hidden.contains(player.getUniqueId())) {
|
||||||
|
for (Player pl : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
|
player.showPlayer(getPlugin(), pl);
|
||||||
|
if (isVanished(pl)) player.hidePlayer(getPlugin(), pl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hidden.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
hidden.forEach(uuid -> {
|
||||||
|
Bukkit.getPlayer(uuid).hidePlayer(getPlugin(), player);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onWorldChange(PlayerChangedWorldEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (getHotbarManager().inDisabledWorld(player.getLocation()) && hidden.contains(player.getUniqueId())) {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
player.showPlayer(getPlugin(), p);
|
||||||
|
if (isVanished(p)) player.hidePlayer(getPlugin(), p);
|
||||||
|
}
|
||||||
|
hidden.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onRespawnEvent(PlayerRespawnEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (hidden.contains(player.getUniqueId())) {
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||||
|
player.showPlayer(getPlugin(), p);
|
||||||
|
if (isVanished(p)) player.hidePlayer(getPlugin(), p);
|
||||||
|
}
|
||||||
|
hidden.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,159 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.player;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.command.commands.FlyCommand;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.Module;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Particle;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DoubleJump extends Module {
|
||||||
|
|
||||||
|
private long cooldownDelay;
|
||||||
|
private double launch;
|
||||||
|
private double launchY;
|
||||||
|
private List<String> actions;
|
||||||
|
|
||||||
|
private Particle particle;
|
||||||
|
private int particleCount;
|
||||||
|
private Sound sound;
|
||||||
|
private float soundVolume;
|
||||||
|
private float soundPitch;
|
||||||
|
private boolean trailEnabled;
|
||||||
|
private Particle trailParticle;
|
||||||
|
|
||||||
|
public DoubleJump(VexlioHubPlugin plugin) {
|
||||||
|
super(plugin, ModuleType.DOUBLE_JUMP);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
|
public void onEnable() {
|
||||||
|
FileConfiguration config = getConfig(ConfigType.SETTINGS);
|
||||||
|
cooldownDelay = config.getLong("double_jump.cooldown", 0);
|
||||||
|
launch = config.getDouble("double_jump.launch_power", 1.3);
|
||||||
|
launchY = config.getDouble("double_jump.launch_power_y", 1.2);
|
||||||
|
actions = config.getStringList("double_jump.actions");
|
||||||
|
|
||||||
|
if (launch > 4.0) launch = 4.0;
|
||||||
|
if (launchY > 4.0) launchY = 4.0;
|
||||||
|
|
||||||
|
// Load effects
|
||||||
|
try {
|
||||||
|
particle = Particle.valueOf(config.getString("double_jump.particle", "CLOUD").toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
particle = Particle.CLOUD;
|
||||||
|
}
|
||||||
|
particleCount = config.getInt("double_jump.particle_count", 15);
|
||||||
|
|
||||||
|
try {
|
||||||
|
sound = Sound.valueOf(config.getString("double_jump.sound", "ENTITY_BAT_TAKEOFF").toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
sound = Sound.ENTITY_BAT_TAKEOFF;
|
||||||
|
}
|
||||||
|
soundVolume = (float) config.getDouble("double_jump.sound_volume", 1.0);
|
||||||
|
soundPitch = (float) config.getDouble("double_jump.sound_pitch", 1.0);
|
||||||
|
|
||||||
|
trailEnabled = config.getBoolean("double_jump.trail.enabled", true);
|
||||||
|
try {
|
||||||
|
trailParticle = Particle.valueOf(config.getString("double_jump.trail.particle", "CLOUD").toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
trailParticle = Particle.CLOUD;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) continue;
|
||||||
|
if (inDisabledWorld(player.getLocation())) continue;
|
||||||
|
player.setAllowFlight(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) continue;
|
||||||
|
if (Boolean.TRUE.equals(FlyCommand.allowPlayerFly.get(player.getUniqueId()))) continue;
|
||||||
|
player.setAllowFlight(false);
|
||||||
|
player.setFlying(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
// Perform checks
|
||||||
|
if (FlyCommand.allowPlayerFly.putIfAbsent(player.getUniqueId(), false) == null) ;
|
||||||
|
if (FlyCommand.allowPlayerFly.get(player.getUniqueId())) return;
|
||||||
|
else if (inDisabledWorld(player.getLocation())) return;
|
||||||
|
else if (player.getGameMode() == GameMode.CREATIVE || player.getGameMode() == GameMode.SPECTATOR) return;
|
||||||
|
else if (!event.isFlying()) return;
|
||||||
|
|
||||||
|
// Execute double jump
|
||||||
|
player.setVelocity(player.getLocation().getDirection().multiply(launch).setY(launchY));
|
||||||
|
executeActions(player, actions);
|
||||||
|
|
||||||
|
// Play sound & start particles
|
||||||
|
if (sound != null) {
|
||||||
|
player.getWorld().playSound(player.getLocation(), sound, soundVolume, soundPitch);
|
||||||
|
}
|
||||||
|
if (particle != null && particleCount > 0) {
|
||||||
|
player.getWorld().spawnParticle(particle, player.getLocation(), particleCount, 0.5, 0.2, 0.5, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn particle trail
|
||||||
|
if (trailEnabled && trailParticle != null) {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
int ticks = 0;
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (ticks >= 20 || !player.isOnline() || player.isOnGround()) {
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.getWorld().spawnParticle(trailParticle, player.getLocation(), 3, 0.1, 0.1, 0.1, 0.01);
|
||||||
|
ticks += 2;
|
||||||
|
}
|
||||||
|
}.runTaskTimer(getPlugin(), 0L, 2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.setAllowFlight(false);
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
player.setAllowFlight(true);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}.runTaskLater(getPlugin(), 20 * cooldownDelay);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onWorldChange(PlayerChangedWorldEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (player.getGameMode() != GameMode.CREATIVE && player.getGameMode() != GameMode.SPECTATOR && !inDisabledWorld(player.getLocation())) {
|
||||||
|
player.getPlayer().setAllowFlight(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (player.getGameMode() != GameMode.CREATIVE && player.getGameMode() != GameMode.SPECTATOR
|
||||||
|
&& !inDisabledWorld(player.getLocation()))
|
||||||
|
player.getPlayer().setAllowFlight(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
+191
@@ -0,0 +1,191 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.player;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.command.commands.FlyCommand;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.Module;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.PlaceholderUtil;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.FireworkEffect;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Firework;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.inventory.meta.FireworkMeta;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PlayerListener extends Module {
|
||||||
|
|
||||||
|
private boolean joinQuitMessagesEnabled;
|
||||||
|
private String joinMessage;
|
||||||
|
private String quitMessage;
|
||||||
|
|
||||||
|
private List<String> joinActions;
|
||||||
|
|
||||||
|
private boolean joinTitleEnabled;
|
||||||
|
private String joinTitle;
|
||||||
|
private String joinSubtitle;
|
||||||
|
private int joinFadeIn;
|
||||||
|
private int joinStay;
|
||||||
|
private int joinFadeOut;
|
||||||
|
|
||||||
|
private boolean spawnHeal;
|
||||||
|
private boolean extinguish;
|
||||||
|
private boolean clearInventory;
|
||||||
|
|
||||||
|
private boolean fireworkEnabled;
|
||||||
|
private boolean fireworkFirstJoin;
|
||||||
|
private boolean fireworkFlicker;
|
||||||
|
private boolean fireworkTrail;
|
||||||
|
private int fireworkPower;
|
||||||
|
private String fireworkType;
|
||||||
|
private List<Color> fireworkColors;
|
||||||
|
|
||||||
|
public PlayerListener(VexlioHubPlugin plugin) {
|
||||||
|
super(plugin, ModuleType.PLAYER_LISTENER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
|
||||||
|
// Load config stuff
|
||||||
|
FileConfiguration config = getConfig(ConfigType.SETTINGS);
|
||||||
|
joinQuitMessagesEnabled = config.getBoolean("join_leave_messages.enabled");
|
||||||
|
joinMessage = config.getString("join_leave_messages.join_message");
|
||||||
|
quitMessage = config.getString("join_leave_messages.quit_message");
|
||||||
|
|
||||||
|
joinActions = config.getStringList("join_events");
|
||||||
|
|
||||||
|
spawnHeal = config.getBoolean("join_settings.heal", false);
|
||||||
|
extinguish = config.getBoolean("join_settings.extinguish", false);
|
||||||
|
clearInventory = config.getBoolean("join_settings.clear_inventory", false);
|
||||||
|
|
||||||
|
joinTitleEnabled = config.getBoolean("join_title.enabled", false);
|
||||||
|
if (joinTitleEnabled) {
|
||||||
|
joinTitle = config.getString("join_title.title", "");
|
||||||
|
joinSubtitle = config.getString("join_title.subtitle", "");
|
||||||
|
joinFadeIn = config.getInt("join_title.fadeIn", 20);
|
||||||
|
joinStay = config.getInt("join_title.stay", 60);
|
||||||
|
joinFadeOut = config.getInt("join_title.fadeOut", 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
fireworkEnabled = config.getBoolean("join_settings.firework.enabled", true);
|
||||||
|
if (fireworkEnabled) {
|
||||||
|
fireworkFirstJoin = config.getBoolean("join_settings.firework.first_join_only", true);
|
||||||
|
fireworkType = config.getString("join_settings.firework.type", "BALL_LARGE");
|
||||||
|
fireworkPower = config.getInt("join_settings.firework.power", 1);
|
||||||
|
fireworkFlicker = config.getBoolean("join_settings.firework.flicker", true);
|
||||||
|
fireworkTrail = config.getBoolean("join_settings.firework.trail", true);
|
||||||
|
|
||||||
|
fireworkColors = new ArrayList<>();
|
||||||
|
config.getStringList("join_settings.firework.colors").forEach(c -> {
|
||||||
|
Color color = TextUtil.getColor(c);
|
||||||
|
if (color != null) fireworkColors.add(color);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (inDisabledWorld(player.getLocation())) return;
|
||||||
|
|
||||||
|
// Join message handling
|
||||||
|
if (joinQuitMessagesEnabled) {
|
||||||
|
if (joinMessage.equals("")) event.joinMessage(null);
|
||||||
|
else {
|
||||||
|
String message = PlaceholderUtil.setPlaceholders(joinMessage, player);
|
||||||
|
event.joinMessage(LegacyComponentSerializer.legacySection().deserialize(TextUtil.color(message)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Heal the player
|
||||||
|
if (spawnHeal) {
|
||||||
|
player.setFoodLevel(20);
|
||||||
|
player.setHealth(player.getAttribute(Attribute.MAX_HEALTH).getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extinguish
|
||||||
|
if (extinguish) player.setFireTicks(0);
|
||||||
|
|
||||||
|
// Clear the player inventory
|
||||||
|
if (clearInventory) player.getInventory().clear();
|
||||||
|
|
||||||
|
if (joinTitleEnabled) {
|
||||||
|
String title = PlaceholderUtil.setPlaceholders(joinTitle, player);
|
||||||
|
String subtitle = PlaceholderUtil.setPlaceholders(joinSubtitle, player);
|
||||||
|
player.sendTitle(TextUtil.color(title), TextUtil.color(subtitle), joinFadeIn, joinStay, joinFadeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> {
|
||||||
|
// Join events
|
||||||
|
executeActions(player, joinActions);
|
||||||
|
|
||||||
|
// Firework
|
||||||
|
if (fireworkEnabled) {
|
||||||
|
if (fireworkFirstJoin) {
|
||||||
|
if (!player.hasPlayedBefore()) spawnFirework(player);
|
||||||
|
} else {
|
||||||
|
spawnFirework(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 3L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (inDisabledWorld(player.getLocation())) return;
|
||||||
|
|
||||||
|
if (joinQuitMessagesEnabled) {
|
||||||
|
if (quitMessage.equals("")) event.quitMessage(null);
|
||||||
|
else {
|
||||||
|
String message = PlaceholderUtil.setPlaceholders(quitMessage, player);
|
||||||
|
event.quitMessage(LegacyComponentSerializer.legacySection().deserialize(TextUtil.color(message)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FlyCommand.allowPlayerFly.remove(player.getUniqueId());
|
||||||
|
|
||||||
|
player.getActivePotionEffects().forEach(effect -> player.removePotionEffect(effect.getType()));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onWorldChange(PlayerChangedWorldEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (inDisabledWorld(player.getLocation()))
|
||||||
|
player.getActivePotionEffects().forEach(effect -> player.removePotionEffect(effect.getType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void spawnFirework(Player player) {
|
||||||
|
Firework f = player.getWorld().spawn(player.getLocation(), Firework.class);
|
||||||
|
FireworkMeta fm = f.getFireworkMeta();
|
||||||
|
fm.addEffect(FireworkEffect.builder()
|
||||||
|
.flicker(fireworkFlicker)
|
||||||
|
.trail(fireworkTrail)
|
||||||
|
.with(FireworkEffect.Type.valueOf(fireworkType))
|
||||||
|
.withColor(fireworkColors).build());
|
||||||
|
fm.setPower(fireworkPower);
|
||||||
|
f.setFireworkMeta(fm);
|
||||||
|
|
||||||
|
//Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> f.remove(), 100L);
|
||||||
|
}
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.player;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.modules.world.BuildMode;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.Module;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||||
|
|
||||||
|
public class PlayerOffHandSwap extends Module {
|
||||||
|
|
||||||
|
public PlayerOffHandSwap(VexlioHubPlugin plugin) {
|
||||||
|
super(plugin, ModuleType.PLAYER_OFFHAND_LISTENER);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerSwapItem(PlayerSwapHandItemsEvent event) {
|
||||||
|
if (BuildMode.getInstance().isPresent(event.getPlayer().getUniqueId())) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
|
if (BuildMode.getInstance().isPresent(event.getWhoClicked().getUniqueId())) return;
|
||||||
|
if (event.getRawSlot() != event.getSlot() && event.getCursor() != null && event.getSlot() == 40) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.visual;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.Module;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ActionBarAnnouncements extends Module {
|
||||||
|
|
||||||
|
private BukkitTask task;
|
||||||
|
private List<String> messages;
|
||||||
|
private int interval;
|
||||||
|
private int currentIndex = 0;
|
||||||
|
|
||||||
|
public ActionBarAnnouncements(VexlioHubPlugin plugin) {
|
||||||
|
super(plugin, ModuleType.ACTIONBAR_ANNOUNCEMENTS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
FileConfiguration config = getConfig(ConfigType.SETTINGS);
|
||||||
|
messages = config.getStringList("actionbar_announcements.messages");
|
||||||
|
interval = config.getInt("actionbar_announcements.interval", 200);
|
||||||
|
|
||||||
|
if (messages == null || messages.isEmpty()) return;
|
||||||
|
|
||||||
|
task = new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (messages.isEmpty()) return;
|
||||||
|
|
||||||
|
String rawMessage = messages.get(currentIndex);
|
||||||
|
currentIndex = (currentIndex + 1) % messages.size();
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (inDisabledWorld(player.getLocation())) continue;
|
||||||
|
|
||||||
|
String colored = TextUtil.color(rawMessage.replace("%player%", player.getName()));
|
||||||
|
player.sendActionBar(LegacyComponentSerializer.legacySection().deserialize(colored));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskTimer(getPlugin(), interval, interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
if (task != null) {
|
||||||
|
task.cancel();
|
||||||
|
task = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.world;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.TextUtil;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class BuildMode implements Listener {
|
||||||
|
private static BuildMode _instance;
|
||||||
|
private final VexlioHubPlugin _plugin;
|
||||||
|
private final ArrayList<UUID> _players = new ArrayList<>();
|
||||||
|
private final HashMap<UUID, ItemStack[]> _inventories = new HashMap<>();
|
||||||
|
private final List<String> _worlds;
|
||||||
|
private boolean _actionbar_enabled = true;
|
||||||
|
private boolean _invertedWorlds = false;
|
||||||
|
|
||||||
|
|
||||||
|
public BuildMode() {
|
||||||
|
_instance = this;
|
||||||
|
this._plugin = VexlioHubPlugin.getPlugin(VexlioHubPlugin.class);
|
||||||
|
this.runScheduler();
|
||||||
|
FileConfiguration config = _plugin.getConfigManager().getFile(ConfigType.SETTINGS).getConfig();
|
||||||
|
this._actionbar_enabled = config.getBoolean("build_mode.use_actionbar_message");
|
||||||
|
this._invertedWorlds = config.getBoolean("disabled-worlds.inverted");
|
||||||
|
this._worlds = config.getStringList("disabled-worlds.worlds");
|
||||||
|
|
||||||
|
this._plugin.getServer().getPluginManager().registerEvents(this, _plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BuildMode getInstance() {
|
||||||
|
if (_instance == null) {
|
||||||
|
_instance = new BuildMode();
|
||||||
|
}
|
||||||
|
return _instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void runScheduler() {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (_plugin.getServer().getOnlinePlayers().isEmpty()) return;
|
||||||
|
for (Player p : _plugin.getServer().getOnlinePlayers()) {
|
||||||
|
if (_players.contains(p.getUniqueId())) {
|
||||||
|
if (!isInPermittedWorld(Objects.requireNonNull(p.getLocation().getWorld()).getName())) {
|
||||||
|
p.getInventory().clear();
|
||||||
|
removePlayer(p.getUniqueId());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (p.getGameMode() != GameMode.CREATIVE) p.setGameMode(GameMode.CREATIVE);
|
||||||
|
if (_actionbar_enabled)
|
||||||
|
p.sendActionBar(LegacyComponentSerializer.legacySection().deserialize(TextUtil.color(String.valueOf(Messages.BUILD_MODE_ENABLED_ACTIONBAR))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskTimer(_plugin, 5L, 5L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||||
|
public void PlayerQuit(PlayerQuitEvent event) {
|
||||||
|
final UUID uuid = event.getPlayer().getUniqueId();
|
||||||
|
if (isPresent(uuid)) removePlayer(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPlayer(Player player) {
|
||||||
|
_players.add(player.getUniqueId());
|
||||||
|
_inventories.put(player.getUniqueId(), player.getInventory().getContents()); // Save inventory
|
||||||
|
player.getInventory().clear();
|
||||||
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
|
player.getInventory().setHeldItemSlot(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePlayer(UUID uuid) {
|
||||||
|
Player player = _plugin.getServer().getPlayer(uuid);
|
||||||
|
if (player == null) return;
|
||||||
|
_players.remove(uuid);
|
||||||
|
player.getInventory().clear();
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
if (_inventories.containsKey(uuid)) {
|
||||||
|
player.getInventory().setContents(_inventories.get(uuid)); // Restore inventory
|
||||||
|
_inventories.remove(uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPresent(UUID uuid) {
|
||||||
|
return _players.contains(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInPermittedWorld(String world) {
|
||||||
|
return _invertedWorlds == _worlds.contains(world);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.world;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.cooldown.CooldownType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.Module;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Particle;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class Launchpad extends Module {
|
||||||
|
|
||||||
|
private double launch;
|
||||||
|
private double launchY;
|
||||||
|
private List<String> actions;
|
||||||
|
private Material topBlock;
|
||||||
|
private Material bottomBlock;
|
||||||
|
|
||||||
|
private Particle particle;
|
||||||
|
private int particleCount;
|
||||||
|
private Sound sound;
|
||||||
|
private float soundVolume;
|
||||||
|
private float soundPitch;
|
||||||
|
private boolean trailEnabled;
|
||||||
|
private Particle trailParticle;
|
||||||
|
|
||||||
|
public Launchpad(VexlioHubPlugin plugin) {
|
||||||
|
super(plugin, ModuleType.LAUNCHPAD);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@SuppressWarnings({"deprecation", "removal"})
|
||||||
|
public void onEnable() {
|
||||||
|
FileConfiguration config = getConfig(ConfigType.SETTINGS);
|
||||||
|
launch = config.getDouble("launchpad.launch_power", 1.3);
|
||||||
|
launchY = config.getDouble("launchpad.launch_power_y", 1.2);
|
||||||
|
actions = config.getStringList("launchpad.actions");
|
||||||
|
|
||||||
|
try {
|
||||||
|
topBlock = Material.valueOf(config.getString("launchpad.top_block").toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
topBlock = Material.STONE_PRESSURE_PLATE;
|
||||||
|
getPlugin().getLogger().warning("Invalid top block material in config. Defaulting to STONE_PRESSURE_PLATE");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
bottomBlock = Material.valueOf(config.getString("launchpad.bottom_block").toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
bottomBlock = Material.REDSTONE_BLOCK;
|
||||||
|
getPlugin().getLogger().warning("Invalid bottom block material in config. Defaulting to REDSTONE_BLOCK");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (launch > 4.0) launch = 4.0;
|
||||||
|
if (launchY > 4.0) launchY = 4.0;
|
||||||
|
|
||||||
|
// Load effects
|
||||||
|
try {
|
||||||
|
particle = Particle.valueOf(config.getString("launchpad.particle", "CLOUD").toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
particle = Particle.CLOUD;
|
||||||
|
}
|
||||||
|
particleCount = config.getInt("launchpad.particle_count", 15);
|
||||||
|
|
||||||
|
try {
|
||||||
|
sound = Sound.valueOf(config.getString("launchpad.sound", "ENTITY_BAT_TAKEOFF").toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
sound = Sound.ENTITY_BAT_TAKEOFF;
|
||||||
|
}
|
||||||
|
soundVolume = (float) config.getDouble("launchpad.sound_volume", 1.0);
|
||||||
|
soundPitch = (float) config.getDouble("launchpad.sound_pitch", 1.0);
|
||||||
|
|
||||||
|
trailEnabled = config.getBoolean("launchpad.trail.enabled", true);
|
||||||
|
try {
|
||||||
|
trailParticle = Particle.valueOf(config.getString("launchpad.trail.particle", "CLOUD").toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
trailParticle = Particle.CLOUD;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Location location = player.getLocation();
|
||||||
|
if (inDisabledWorld(location)) return;
|
||||||
|
|
||||||
|
// Check for launchpad block
|
||||||
|
if (location.getBlock().getType() == topBlock && location.subtract(0, 1, 0).getBlock().getType() == bottomBlock) {
|
||||||
|
|
||||||
|
// Check for cooldown
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.LAUNCHPAD, 1)) {
|
||||||
|
player.setVelocity(location.getDirection().multiply(launch).setY(launchY));
|
||||||
|
executeActions(player, actions);
|
||||||
|
|
||||||
|
// Play sound & spawn start particle
|
||||||
|
if (sound != null) {
|
||||||
|
player.getWorld().playSound(player.getLocation(), sound, soundVolume, soundPitch);
|
||||||
|
}
|
||||||
|
if (particle != null && particleCount > 0) {
|
||||||
|
player.getWorld().spawnParticle(particle, player.getLocation().add(0, 0.1, 0), particleCount, 0.5, 0.1, 0.5, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spawn particle trail
|
||||||
|
if (trailEnabled && trailParticle != null) {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
int ticks = 0;
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (ticks >= 20 || !player.isOnline() || player.isOnGround()) {
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.getWorld().spawnParticle(trailParticle, player.getLocation(), 3, 0.1, 0.1, 0.1, 0.01);
|
||||||
|
ticks += 2;
|
||||||
|
}
|
||||||
|
}.runTaskTimer(getPlugin(), 0L, 2L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.world;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.Module;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
|
public class LobbySpawn extends Module {
|
||||||
|
|
||||||
|
private boolean spawnJoin;
|
||||||
|
private Location location = null;
|
||||||
|
|
||||||
|
public LobbySpawn(VexlioHubPlugin plugin) {
|
||||||
|
super(plugin, ModuleType.LOBBY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
Bukkit.getScheduler().runTask(getPlugin(), () -> {
|
||||||
|
FileConfiguration config = getConfig(ConfigType.DATA);
|
||||||
|
if (config.contains("spawn")) location = (Location) config.get("spawn");
|
||||||
|
});
|
||||||
|
spawnJoin = getConfig(ConfigType.SETTINGS).getBoolean("join_settings.spawn_join", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
getConfig(ConfigType.DATA).set("spawn", location);
|
||||||
|
getPlugin().getConfigManager().getFile(ConfigType.DATA).save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLocation(Location location) {
|
||||||
|
this.location = location;
|
||||||
|
getConfig(ConfigType.DATA).set("spawn", location);
|
||||||
|
getPlugin().getConfigManager().getFile(ConfigType.DATA).save();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (!player.hasPlayedBefore()) {
|
||||||
|
Bukkit.getScheduler().runTaskLater(getPlugin(), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (spawnJoin && location != null) player.teleport(location);
|
||||||
|
}
|
||||||
|
}, 2L);
|
||||||
|
} else {
|
||||||
|
if (spawnJoin && location != null) player.teleport(location);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (location != null && !inDisabledWorld(player.getLocation())) event.setRespawnLocation(location);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.world;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.Module;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class StaticTime extends Module {
|
||||||
|
private int _time;
|
||||||
|
|
||||||
|
public StaticTime(VexlioHubPlugin plugin) {
|
||||||
|
super(plugin, ModuleType.STATIC_TIME);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
FileConfiguration config = getConfig(ConfigType.SETTINGS);
|
||||||
|
_time = config.getInt("static_time.time");
|
||||||
|
runScheduler();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void runScheduler() {
|
||||||
|
final VexlioHubPlugin plugin = VexlioHubPlugin.getPlugin(VexlioHubPlugin.class);
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
Bukkit.getWorlds().forEach(world -> {
|
||||||
|
if (plugin.getModuleManager().getDisabledWorlds().contains(world.getName())) return;
|
||||||
|
if (world.getTime() != _time) world.setTime(_time);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, 2L, 2L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,659 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.module.modules.world;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import eu.milujukockoholky.vexliolobby.Permissions;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.ConfigType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.config.Messages;
|
||||||
|
import eu.milujukockoholky.vexliolobby.cooldown.CooldownType;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.Module;
|
||||||
|
import eu.milujukockoholky.vexliolobby.module.ModuleType;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.*;
|
||||||
|
import org.bukkit.entity.minecart.CommandMinecart;
|
||||||
|
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||||
|
import org.bukkit.entity.minecart.HopperMinecart;
|
||||||
|
import org.bukkit.entity.minecart.StorageMinecart;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.*;
|
||||||
|
import org.bukkit.event.entity.*;
|
||||||
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
|
import org.bukkit.event.player.*;
|
||||||
|
import org.bukkit.event.vehicle.VehicleDestroyEvent;
|
||||||
|
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class WorldProtect extends Module {
|
||||||
|
private FileConfiguration config;
|
||||||
|
private final List<Material> interactables = Arrays.asList(
|
||||||
|
Material.ANVIL,
|
||||||
|
Material.ARMOR_STAND,
|
||||||
|
Material.BARREL,
|
||||||
|
Material.BEACON,
|
||||||
|
Material.BREWING_STAND,
|
||||||
|
Material.CAULDRON,
|
||||||
|
Material.CARTOGRAPHY_TABLE,
|
||||||
|
Material.CHISELED_BOOKSHELF,
|
||||||
|
Material.COMMAND_BLOCK,
|
||||||
|
Material.COMPARATOR,
|
||||||
|
Material.COMPOSTER,
|
||||||
|
Material.CRAFTING_TABLE,
|
||||||
|
Material.CRAFTER,
|
||||||
|
Material.DAYLIGHT_DETECTOR,
|
||||||
|
Material.DECORATED_POT,
|
||||||
|
Material.DISPENSER,
|
||||||
|
Material.DROPPER,
|
||||||
|
Material.ENCHANTING_TABLE,
|
||||||
|
Material.FLETCHING_TABLE,
|
||||||
|
Material.FLOWER_POT,
|
||||||
|
Material.FURNACE,
|
||||||
|
Material.GRINDSTONE,
|
||||||
|
Material.HOPPER,
|
||||||
|
Material.HOPPER_MINECART,
|
||||||
|
Material.ITEM_FRAME,
|
||||||
|
Material.JUKEBOX,
|
||||||
|
Material.LEAD,
|
||||||
|
Material.LEVER,
|
||||||
|
Material.LOOM,
|
||||||
|
Material.MINECART,
|
||||||
|
Material.NOTE_BLOCK,
|
||||||
|
Material.PAINTING,
|
||||||
|
Material.REDSTONE_WIRE,
|
||||||
|
Material.REPEATER,
|
||||||
|
Material.RESPAWN_ANCHOR,
|
||||||
|
Material.SMITHING_TABLE,
|
||||||
|
Material.SMOKER,
|
||||||
|
Material.SPAWNER,
|
||||||
|
Material.STONECUTTER,
|
||||||
|
Material.STRUCTURE_BLOCK,
|
||||||
|
Material.TRIAL_SPAWNER,
|
||||||
|
Material.BLAST_FURNACE,
|
||||||
|
Material.CHIPPED_ANVIL,
|
||||||
|
Material.DAMAGED_ANVIL
|
||||||
|
);
|
||||||
|
|
||||||
|
private boolean hungerLoss;
|
||||||
|
private boolean fallDamage;
|
||||||
|
private boolean weatherChange;
|
||||||
|
private boolean deathMessage;
|
||||||
|
private boolean fireSpread;
|
||||||
|
private boolean leafDecay;
|
||||||
|
private boolean mobSpawning;
|
||||||
|
private boolean blockBurn;
|
||||||
|
private boolean voidDeath;
|
||||||
|
private boolean itemDrop;
|
||||||
|
private boolean itemPickup;
|
||||||
|
private boolean blockBreak;
|
||||||
|
private boolean blockPlace;
|
||||||
|
private boolean blockInteract;
|
||||||
|
private boolean playerPvP;
|
||||||
|
private boolean playerDrowning;
|
||||||
|
private boolean fireDamage;
|
||||||
|
private boolean hidePotionIcons;
|
||||||
|
|
||||||
|
public WorldProtect(VexlioHubPlugin plugin) {
|
||||||
|
super(plugin, ModuleType.WORLD_PROTECT);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
config = getConfig(ConfigType.SETTINGS);
|
||||||
|
hungerLoss = config.getBoolean("world_settings.disable_hunger_loss");
|
||||||
|
fallDamage = config.getBoolean("world_settings.disable_fall_damage");
|
||||||
|
playerPvP = config.getBoolean("world_settings.disable_player_pvp");
|
||||||
|
voidDeath = config.getBoolean("world_settings.disable_void_death");
|
||||||
|
weatherChange = config.getBoolean("world_settings.disable_weather_change");
|
||||||
|
deathMessage = config.getBoolean("world_settings.disable_death_message");
|
||||||
|
mobSpawning = config.getBoolean("world_settings.disable_mob_spawning");
|
||||||
|
itemDrop = config.getBoolean("world_settings.disable_item_drop");
|
||||||
|
itemPickup = config.getBoolean("world_settings.disable_item_pickup");
|
||||||
|
blockBreak = config.getBoolean("world_settings.disable_block_break");
|
||||||
|
blockPlace = config.getBoolean("world_settings.disable_block_place");
|
||||||
|
blockInteract = config.getBoolean("world_settings.disable_block_interact");
|
||||||
|
blockBurn = config.getBoolean("world_settings.disable_block_burn");
|
||||||
|
fireSpread = config.getBoolean("world_settings.disable_block_fire_spread");
|
||||||
|
leafDecay = config.getBoolean("world_settings.disable_block_leaf_decay");
|
||||||
|
playerDrowning = config.getBoolean("world_settings.disable_drowning");
|
||||||
|
fireDamage = config.getBoolean("world_settings.disable_fire_damage");
|
||||||
|
hidePotionIcons = config.getBoolean("world_settings.hide_potion_icons");
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (inDisabledWorld(player.getLocation())) continue;
|
||||||
|
for (PotionEffect effect : player.getActivePotionEffects()) {
|
||||||
|
boolean needsUpdate = hidePotionIcons
|
||||||
|
? (effect.hasIcon() || effect.hasParticles())
|
||||||
|
: (!effect.hasIcon() && !effect.hasParticles());
|
||||||
|
if (!needsUpdate) continue;
|
||||||
|
player.addPotionEffect(new PotionEffect(
|
||||||
|
effect.getType(), effect.getDuration(), effect.getAmplifier(),
|
||||||
|
effect.isAmbient(), !hidePotionIcons, !hidePotionIcons
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPotionEffect(EntityPotionEffectEvent event) {
|
||||||
|
if (!hidePotionIcons) return;
|
||||||
|
if (!(event.getEntity() instanceof Player player)) return;
|
||||||
|
if (inDisabledWorld(player.getLocation())) return;
|
||||||
|
PotionEffect newEffect = event.getNewEffect();
|
||||||
|
if (newEffect == null || (!newEffect.hasIcon() && !newEffect.hasParticles())) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.addPotionEffect(new PotionEffect(
|
||||||
|
newEffect.getType(),
|
||||||
|
newEffect.getDuration(),
|
||||||
|
newEffect.getAmplifier(),
|
||||||
|
newEffect.isAmbient(),
|
||||||
|
false,
|
||||||
|
false
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent sign editing
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onSignChange(SignChangeEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (inDisabledWorld(player.getLocation())) return;
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_INTERACT.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_INTERACT, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_INTERACT.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
if (!blockBreak || event.isCancelled()) return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (inDisabledWorld(player.getLocation())) return;
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_BREAK.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_BREAK, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_BREAK.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
if (!blockPlace || event.isCancelled()) return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (inDisabledWorld(player.getLocation())) return;
|
||||||
|
ItemStack item = event.getItemInHand();
|
||||||
|
if (item.getType() == Material.AIR) return;
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
String hotbarItem = meta.getPersistentDataContainer().get(new NamespacedKey(getPlugin(), "hotbarItem"), PersistentDataType.STRING);
|
||||||
|
if (hotbarItem != null) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_PLACE.getPermission())) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
if (tryCooldown(event.getPlayer().getUniqueId(), CooldownType.BLOCK_PLACE, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_PLACE.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockInteract(PlayerInteractEvent event) {
|
||||||
|
if (!blockInteract || inDisabledWorld(event.getPlayer().getLocation())) return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_INTERACT.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
Block block = event.getClickedBlock();
|
||||||
|
if (block == null) return;
|
||||||
|
|
||||||
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
Material type = block.getType();
|
||||||
|
|
||||||
|
// Check generic interactables first
|
||||||
|
if (interactables.contains(type)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_INTERACT, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_INTERACT.send(player);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check type patterns
|
||||||
|
if (type.name().contains("_DOOR") || type.name().contains("_TRAPDOOR") || type.name().contains("_BUTTON") || type.name().contains("_SIGN") || type.name().contains("_GATE") || type.name().contains("CHEST") || type.name().contains("_FENCE_GATE") || type.name().contains("POTTED_") || type.name().contains("_BED") || type.name().contains("_BOAT")) {
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_INTERACT, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_INTERACT.send(player);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (event.getAction() == Action.PHYSICAL && block.getType() == Material.FARMLAND) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockBurn(BlockBurnEvent event) {
|
||||||
|
if (!blockBurn) return;
|
||||||
|
if (inDisabledWorld(event.getBlock().getLocation())) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onFireSpread(BlockIgniteEvent event) {
|
||||||
|
if (!fireSpread) return;
|
||||||
|
if (inDisabledWorld(event.getBlock().getLocation())) return;
|
||||||
|
if (event.getCause() == BlockIgniteEvent.IgniteCause.SPREAD) event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onFoodChange(FoodLevelChangeEvent event) {
|
||||||
|
if (!hungerLoss) return;
|
||||||
|
|
||||||
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
|
Player player = (Player) event.getEntity();
|
||||||
|
|
||||||
|
if (inDisabledWorld(player.getLocation())) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerDropEvent(PlayerDropItemEvent event) {
|
||||||
|
if (!itemDrop) return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (inDisabledWorld(player.getLocation())) return;
|
||||||
|
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_ITEM_DROP.getPermission())) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.ITEM_DROP, 3)) {
|
||||||
|
Messages.EVENT_ITEM_DROP.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerPickupEvent(EntityPickupItemEvent event) {
|
||||||
|
if (!itemPickup) return;
|
||||||
|
if (event.getEntity() instanceof Player) {
|
||||||
|
Player player = (Player) event.getEntity();
|
||||||
|
if (inDisabledWorld(player.getLocation())) return;
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_ITEM_PICKUP.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.ITEM_PICKUP, 3)) {
|
||||||
|
Messages.EVENT_ITEM_PICKUP.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onLeafDecay(LeavesDecayEvent event) {
|
||||||
|
if (!leafDecay) return;
|
||||||
|
if (inDisabledWorld(event.getBlock().getLocation())) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onCreatureSpawn(CreatureSpawnEvent event) {
|
||||||
|
if (!mobSpawning) return;
|
||||||
|
if (inDisabledWorld(event.getEntity().getLocation())) return;
|
||||||
|
if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.CUSTOM) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onWeatherChange(WeatherChangeEvent event) {
|
||||||
|
if (!weatherChange || inDisabledWorld(event.getWorld())) return;
|
||||||
|
event.setCancelled(event.toWeatherState());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
|
if (!deathMessage || inDisabledWorld(event.getEntity().getLocation())) return;
|
||||||
|
if (BuildMode.getInstance().isPresent(event.getEntity().getUniqueId())) event.setKeepInventory(true);
|
||||||
|
event.getDrops().clear();
|
||||||
|
event.setKeepLevel(true);
|
||||||
|
event.deathMessage(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
|
if (!(event.getEntity() instanceof Player)) return;
|
||||||
|
Player player = (Player) event.getEntity();
|
||||||
|
if (inDisabledWorld(player.getLocation())) return;
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
EntityDamageEvent.DamageCause cause = event.getCause();
|
||||||
|
switch (cause) {
|
||||||
|
case FALL:
|
||||||
|
if (fallDamage) event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
case DROWNING:
|
||||||
|
if (playerDrowning) event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
case FIRE:
|
||||||
|
case FIRE_TICK:
|
||||||
|
if (!playerPvP) return;
|
||||||
|
case LAVA:
|
||||||
|
if (fireDamage) event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
case VOID: {
|
||||||
|
if (voidDeath) {
|
||||||
|
player.setFallDistance(0.0F);
|
||||||
|
Location location = ((LobbySpawn) getPlugin().getModuleManager().getModule(ModuleType.LOBBY)).getLocation();
|
||||||
|
if (location == null) return;
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> player.teleport(location), 3L);
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onEntityDamage(EntityDamageByEntityEvent event) {
|
||||||
|
if (!playerPvP) return;
|
||||||
|
|
||||||
|
if (!(event.getEntity() instanceof Player victim)) return;
|
||||||
|
if (inDisabledWorld(victim.getLocation())) return;
|
||||||
|
|
||||||
|
Player attacker = null;
|
||||||
|
if (event.getDamager() instanceof Player p) {
|
||||||
|
attacker = p;
|
||||||
|
} else if (event.getDamager() instanceof Projectile proj && proj.getShooter() instanceof Player p) {
|
||||||
|
attacker = p;
|
||||||
|
}
|
||||||
|
if (attacker == null) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent destroying of item frame/paintings (including via projectiles)
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onEntityDestroy(HangingBreakByEntityEvent event) {
|
||||||
|
if (!blockBreak || inDisabledWorld(event.getEntity().getLocation())) return;
|
||||||
|
Entity entity = event.getEntity();
|
||||||
|
if (!(entity instanceof Painting) && !(entity instanceof ItemFrame)) return;
|
||||||
|
|
||||||
|
Entity remover = event.getRemover();
|
||||||
|
Player player = null;
|
||||||
|
if (remover instanceof Player p) {
|
||||||
|
player = p;
|
||||||
|
} else if (remover instanceof Projectile proj && proj.getShooter() instanceof Player p) {
|
||||||
|
player = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player == null) return;
|
||||||
|
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_BREAK.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_BREAK, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_BREAK.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent items being rotated in item frame
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onEntityInteract(PlayerInteractEntityEvent event) {
|
||||||
|
if (!blockInteract || inDisabledWorld(event.getRightClicked().getLocation())) return;
|
||||||
|
Entity entity = event.getRightClicked();
|
||||||
|
Entity player = event.getPlayer();
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_INTERACT.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
if (entity instanceof ItemFrame) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_INTERACT, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_INTERACT.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent items being taken from item frames (including via projectiles)
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||||
|
if (!blockInteract || inDisabledWorld(event.getEntity().getLocation())) return;
|
||||||
|
if (!(event.getEntity() instanceof ItemFrame)) return;
|
||||||
|
|
||||||
|
Entity damager = event.getDamager();
|
||||||
|
Player player = null;
|
||||||
|
if (damager instanceof Player p) {
|
||||||
|
player = p;
|
||||||
|
} else if (damager instanceof Projectile proj && proj.getShooter() instanceof Player p) {
|
||||||
|
player = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player == null) return;
|
||||||
|
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_INTERACT.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_INTERACT, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_INTERACT.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent books being taken from lecterns
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onEntityInteract(PlayerTakeLecternBookEvent event) {
|
||||||
|
if (!blockInteract || inDisabledWorld(event.getLectern().getLocation())) return;
|
||||||
|
Entity player = event.getPlayer();
|
||||||
|
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_INTERACT.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_INTERACT, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_INTERACT.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBoatInteract(PlayerInteractEvent event) {
|
||||||
|
if (!blockInteract || inDisabledWorld(event.getPlayer().getLocation())) return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_INTERACT.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
// Check for all boat types
|
||||||
|
if (event.getItem() != null &&
|
||||||
|
(event.getItem().getType().name().contains("_BOAT"))) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_INTERACT, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_INTERACT.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerBoatInteraction(PlayerInteractEntityEvent event) {
|
||||||
|
if (!blockInteract || inDisabledWorld(event.getPlayer().getLocation())) return;
|
||||||
|
|
||||||
|
Entity entity = event.getRightClicked();
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_INTERACT.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
if (entity instanceof Boat) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_INTERACT, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_INTERACT.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onVehicleBreak(VehicleDestroyEvent event) {
|
||||||
|
if (!blockBreak || inDisabledWorld(event.getVehicle().getLocation())) return;
|
||||||
|
if (!(event.getVehicle() instanceof Boat) && !(event.getVehicle() instanceof Minecart)) return;
|
||||||
|
|
||||||
|
Entity attacker = event.getAttacker();
|
||||||
|
Player player = null;
|
||||||
|
if (attacker instanceof Player p) {
|
||||||
|
player = p;
|
||||||
|
} else if (attacker instanceof Projectile proj && proj.getShooter() instanceof Player p) {
|
||||||
|
player = p;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player == null) return;
|
||||||
|
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_BREAK.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_BREAK, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_BREAK.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (event.getPlayer().hasPermission(Permissions.EVENT_BLOCK_INTERACT.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(event.getPlayer().getUniqueId())) return;
|
||||||
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
Block clickedBlock = event.getClickedBlock();
|
||||||
|
if (clickedBlock != null && (clickedBlock.getType() == Material.CHISELED_BOOKSHELF || clickedBlock.getType() == Material.DECORATED_POT)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
if (tryCooldown(event.getPlayer().getUniqueId(), CooldownType.BLOCK_INTERACT, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_INTERACT.send(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent decorated pots being shattered by projectiles
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onProjectileHitDecoratedPot(ProjectileHitEvent event) {
|
||||||
|
if (!blockBreak || event.getHitBlock() == null) return;
|
||||||
|
if (inDisabledWorld(event.getHitBlock().getLocation())) return;
|
||||||
|
if (event.getHitBlock().getType() != Material.DECORATED_POT) return;
|
||||||
|
if (!(event.getEntity().getShooter() instanceof Player player)) return;
|
||||||
|
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_BREAK.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onMinecartInteraction(PlayerInteractEntityEvent event) {
|
||||||
|
if (!blockInteract || inDisabledWorld(event.getPlayer().getLocation())) return;
|
||||||
|
|
||||||
|
Entity entity = event.getRightClicked();
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_INTERACT.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
if (entity instanceof Minecart ||
|
||||||
|
entity instanceof StorageMinecart ||
|
||||||
|
entity instanceof HopperMinecart ||
|
||||||
|
entity instanceof CommandMinecart ||
|
||||||
|
entity instanceof ExplosiveMinecart) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_INTERACT, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_INTERACT.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onMinecartPlacement(PlayerInteractEvent event) {
|
||||||
|
if (!blockInteract || inDisabledWorld(event.getPlayer().getLocation())) return;
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (config.getBoolean("legacySystems.permissionsEnabled")) {
|
||||||
|
if (player.hasPermission(Permissions.EVENT_BLOCK_INTERACT.getPermission())) return;
|
||||||
|
}
|
||||||
|
if (BuildMode.getInstance().isPresent(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
// Check for all minecart types
|
||||||
|
if (event.getItem() != null &&
|
||||||
|
(event.getItem().getType() == Material.MINECART ||
|
||||||
|
event.getItem().getType() == Material.CHEST_MINECART ||
|
||||||
|
event.getItem().getType() == Material.FURNACE_MINECART ||
|
||||||
|
event.getItem().getType() == Material.HOPPER_MINECART ||
|
||||||
|
event.getItem().getType() == Material.TNT_MINECART ||
|
||||||
|
event.getItem().getType() == Material.COMMAND_BLOCK_MINECART)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
if (tryCooldown(player.getUniqueId(), CooldownType.BLOCK_INTERACT, 3)) {
|
||||||
|
Messages.EVENT_BLOCK_INTERACT.send(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,130 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility;
|
||||||
|
|
||||||
|
public enum DefaultFontInfo {
|
||||||
|
|
||||||
|
A('A', 5),
|
||||||
|
a('a', 5),
|
||||||
|
B('B', 5),
|
||||||
|
b('b', 5),
|
||||||
|
C('C', 5),
|
||||||
|
c('c', 5),
|
||||||
|
D('D', 5),
|
||||||
|
d('d', 5),
|
||||||
|
E('E', 5),
|
||||||
|
e('e', 5),
|
||||||
|
F('F', 5),
|
||||||
|
f('f', 4),
|
||||||
|
G('G', 5),
|
||||||
|
g('g', 5),
|
||||||
|
H('H', 5),
|
||||||
|
h('h', 5),
|
||||||
|
I('I', 3),
|
||||||
|
i('i', 1),
|
||||||
|
J('J', 5),
|
||||||
|
j('j', 5),
|
||||||
|
K('K', 5),
|
||||||
|
k('k', 4),
|
||||||
|
L('L', 5),
|
||||||
|
l('l', 1),
|
||||||
|
M('M', 5),
|
||||||
|
m('m', 5),
|
||||||
|
N('N', 5),
|
||||||
|
n('n', 5),
|
||||||
|
O('O', 5),
|
||||||
|
o('o', 5),
|
||||||
|
P('P', 5),
|
||||||
|
p('p', 5),
|
||||||
|
Q('Q', 5),
|
||||||
|
q('q', 5),
|
||||||
|
R('R', 5),
|
||||||
|
r('r', 5),
|
||||||
|
S('S', 5),
|
||||||
|
s('s', 5),
|
||||||
|
T('T', 5),
|
||||||
|
t('t', 4),
|
||||||
|
U('U', 5),
|
||||||
|
u('u', 5),
|
||||||
|
V('V', 5),
|
||||||
|
v('v', 5),
|
||||||
|
W('W', 5),
|
||||||
|
w('w', 5),
|
||||||
|
X('X', 5),
|
||||||
|
x('x', 5),
|
||||||
|
Y('Y', 5),
|
||||||
|
y('y', 5),
|
||||||
|
Z('Z', 5),
|
||||||
|
z('z', 5),
|
||||||
|
NUM_1('1', 5),
|
||||||
|
NUM_2('2', 5),
|
||||||
|
NUM_3('3', 5),
|
||||||
|
NUM_4('4', 5),
|
||||||
|
NUM_5('5', 5),
|
||||||
|
NUM_6('6', 5),
|
||||||
|
NUM_7('7', 5),
|
||||||
|
NUM_8('8', 5),
|
||||||
|
NUM_9('9', 5),
|
||||||
|
NUM_0('0', 5),
|
||||||
|
EXCLAMATION_POINT('!', 1),
|
||||||
|
AT_SYMBOL('@', 6),
|
||||||
|
NUM_SIGN('#', 5),
|
||||||
|
DOLLAR_SIGN('$', 5),
|
||||||
|
PERCENT('%', 5),
|
||||||
|
UP_ARROW('^', 5),
|
||||||
|
AMPERSAND('&', 5),
|
||||||
|
ASTERISK('*', 5),
|
||||||
|
LEFT_PARENTHESIS('(', 4),
|
||||||
|
RIGHT_PERENTHESIS(')', 4),
|
||||||
|
MINUS('-', 5),
|
||||||
|
UNDERSCORE('_', 5),
|
||||||
|
PLUS_SIGN('+', 5),
|
||||||
|
EQUALS_SIGN('=', 5),
|
||||||
|
LEFT_CURL_BRACE('{', 4),
|
||||||
|
RIGHT_CURL_BRACE('}', 4),
|
||||||
|
LEFT_BRACKET('[', 3),
|
||||||
|
RIGHT_BRACKET(']', 3),
|
||||||
|
COLON(':', 1),
|
||||||
|
SEMI_COLON(';', 1),
|
||||||
|
DOUBLE_QUOTE('"', 3),
|
||||||
|
SINGLE_QUOTE('\'', 1),
|
||||||
|
LEFT_ARROW('<', 4),
|
||||||
|
RIGHT_ARROW('>', 4),
|
||||||
|
QUESTION_MARK('?', 5),
|
||||||
|
SLASH('/', 5),
|
||||||
|
BACK_SLASH('\\', 5),
|
||||||
|
LINE('|', 1),
|
||||||
|
TILDE('~', 5),
|
||||||
|
TICK('`', 2),
|
||||||
|
PERIOD('.', 1),
|
||||||
|
COMMA(',', 1),
|
||||||
|
SPACE(' ', 3),
|
||||||
|
DEFAULT('a', 4);
|
||||||
|
|
||||||
|
private final char character;
|
||||||
|
private final int length;
|
||||||
|
|
||||||
|
DefaultFontInfo(char character, int length) {
|
||||||
|
this.character = character;
|
||||||
|
this.length = length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DefaultFontInfo getDefaultFontInfo(char c) {
|
||||||
|
for (DefaultFontInfo dFI : DefaultFontInfo.values()) {
|
||||||
|
if (dFI.getCharacter() == c) return dFI;
|
||||||
|
}
|
||||||
|
return DefaultFontInfo.DEFAULT;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getCharacter() {
|
||||||
|
return this.character;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getLength() {
|
||||||
|
return this.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBoldLength() {
|
||||||
|
if (this == DefaultFontInfo.SPACE) return this.getLength();
|
||||||
|
return this.length + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,322 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import io.papermc.paper.registry.RegistryAccess;
|
||||||
|
import io.papermc.paper.registry.RegistryKey;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class ItemStackBuilder {
|
||||||
|
|
||||||
|
private static final VexlioHubPlugin PLUGIN = JavaPlugin.getPlugin(VexlioHubPlugin.class);
|
||||||
|
private final ItemStack ITEM_STACK;
|
||||||
|
|
||||||
|
public ItemStackBuilder(ItemStack item) {
|
||||||
|
this.ITEM_STACK = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStackBuilder getItemStack(ItemStack item, ConfigurationSection section, Player player) {
|
||||||
|
ItemStackBuilder builder = new ItemStackBuilder(item);
|
||||||
|
|
||||||
|
if (section.contains("amount")) {
|
||||||
|
builder.withAmount(section.getInt("amount"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (section.contains("username") && player != null) {
|
||||||
|
builder.setSkullOwner(section.getString("username").replace("%player%", player.getName()));
|
||||||
|
} else if (section.contains("username") && player == null) {
|
||||||
|
if (section.getString("username").equalsIgnoreCase("%player%")) {
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
PersistentDataContainer dataContainer = meta.getPersistentDataContainer();
|
||||||
|
dataContainer.set(NamespacedKeys.Keys.PLAYER_HEAD.get(), PersistentDataType.BOOLEAN, true);
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (section.contains("display_name")) {
|
||||||
|
if (player != null) builder.withName(section.getString("display_name"), player);
|
||||||
|
else builder.withName(section.getString("display_name"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (section.contains("lore")) {
|
||||||
|
if (player != null) builder.withLore(section.getStringList("lore"), player);
|
||||||
|
else builder.withLore(section.getStringList("lore"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (section.contains("glow") && section.getBoolean("glow")) {
|
||||||
|
builder.withGlow();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (section.contains("custom_model_data")) {
|
||||||
|
builder.withCustomModelData(section.getInt("custom_model_data"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (section.contains("item_flags")) {
|
||||||
|
List<ItemFlag> flags = new ArrayList<>();
|
||||||
|
section.getStringList("item_flags").forEach(text -> {
|
||||||
|
try {
|
||||||
|
ItemFlag flag = ItemFlag.valueOf(text);
|
||||||
|
flags.add(flag);
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
builder.withFlags(flags.toArray(new ItemFlag[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(section.contains("custom_model_data")) {
|
||||||
|
builder.setCustomModelData(section.getInt("custom_model_data"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(section.contains("enchantments")) {
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<LinkedHashMap<String, Integer>> enchantments = (List<LinkedHashMap<String, Integer>>) section.getList("enchantments");
|
||||||
|
for (LinkedHashMap<String, Integer> enchantmentMap : enchantments) {
|
||||||
|
for (Map.Entry<String, Integer> entry : enchantmentMap.entrySet()) {
|
||||||
|
String enchantmentName = entry.getKey();
|
||||||
|
int level = entry.getValue();
|
||||||
|
Enchantment enchantment = RegistryAccess.registryAccess()
|
||||||
|
.getRegistry(RegistryKey.ENCHANTMENT)
|
||||||
|
.get(NamespacedKey.minecraft(enchantmentName.toLowerCase()));
|
||||||
|
if (enchantment != null) {
|
||||||
|
builder.withEnchantment(enchantment, level);
|
||||||
|
} else {
|
||||||
|
PLUGIN.getLogger().warning("Enchantment " + enchantmentName + " not found!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStackBuilder getItemStack(ConfigurationSection section, Player player) {
|
||||||
|
Material material;
|
||||||
|
try {
|
||||||
|
material = Material.valueOf(section.getString("material").toUpperCase());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
// Fallback to a default material if the configured one is invalid
|
||||||
|
material = Material.STONE;
|
||||||
|
// You might want to log this error
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack item = new ItemStack(material);
|
||||||
|
|
||||||
|
if (material == Material.PLAYER_HEAD) {
|
||||||
|
if (section.contains("base64")) {
|
||||||
|
item = getBase64Head(section.getString("base64"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return getItemStack(item, section, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStackBuilder getItemStack(ConfigurationSection section) {
|
||||||
|
return getItemStack(section, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder withAmount(int amount) {
|
||||||
|
ITEM_STACK.setAmount(amount);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder withFlags(ItemFlag... flags) {
|
||||||
|
ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||||
|
meta.addItemFlags(flags);
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder withName(String name) {
|
||||||
|
final ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||||
|
meta.displayName(LegacyComponentSerializer.legacySection().deserialize(TextUtil.color(name)));
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder withName(String name, Player player) {
|
||||||
|
final ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||||
|
meta.displayName(LegacyComponentSerializer.legacySection().deserialize(
|
||||||
|
TextUtil.color(PlaceholderUtil.setPlaceholders(name, player))));
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ItemStackBuilder setCustomModelData(int data) {
|
||||||
|
final ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||||
|
meta.setCustomModelData(data);
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder setSkullOwner(String owner) {
|
||||||
|
try {
|
||||||
|
SkullMeta im = (SkullMeta) ITEM_STACK.getItemMeta();
|
||||||
|
if (im != null) {
|
||||||
|
if (Bukkit.getPlayer(owner) != null) {
|
||||||
|
im.setPlayerProfile(Bukkit.getPlayer(owner).getPlayerProfile());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ITEM_STACK.setItemMeta(im);
|
||||||
|
} catch (ClassCastException ignored) {
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder withLore(List<String> lore, Player player) {
|
||||||
|
final ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||||
|
meta.lore(lore.stream()
|
||||||
|
.map(s -> LegacyComponentSerializer.legacySection().deserialize(
|
||||||
|
TextUtil.color(PlaceholderUtil.setPlaceholders(s, player))))
|
||||||
|
.toList());
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder withLore(List<String> lore) {
|
||||||
|
final ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||||
|
meta.lore(lore.stream()
|
||||||
|
.map(s -> LegacyComponentSerializer.legacySection().deserialize(TextUtil.color(s)))
|
||||||
|
.toList());
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ItemStackBuilder withCustomModelData(int data) {
|
||||||
|
final ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||||
|
meta.setCustomModelData(data);
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ItemStackBuilder withDurability(int durability) {
|
||||||
|
ITEM_STACK.setDurability((short) durability);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ItemStackBuilder withData(int data) {
|
||||||
|
ITEM_STACK.setDurability((short) data);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder withEnchantment(Enchantment enchantment, final int level) {
|
||||||
|
final ItemMeta im = ITEM_STACK.getItemMeta();
|
||||||
|
if(im == null) return this;
|
||||||
|
im.addEnchant(enchantment, level, true);
|
||||||
|
ITEM_STACK.setItemMeta(im);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder withEnchantment(Enchantment enchantment) {
|
||||||
|
return withEnchantment(enchantment, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder withGlow() {
|
||||||
|
final ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||||
|
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
return withEnchantment(Enchantment.INFINITY, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public ItemStackBuilder withType(Material material) {
|
||||||
|
ITEM_STACK.setType(material);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder clearLore() {
|
||||||
|
final ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||||
|
meta.lore(new ArrayList<>());
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder clearEnchantments() {
|
||||||
|
for (Enchantment enchantment : ITEM_STACK.getEnchantments().keySet()) {
|
||||||
|
ITEM_STACK.removeEnchantment(enchantment);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder withColor(Color color) {
|
||||||
|
Material type = ITEM_STACK.getType();
|
||||||
|
if (type == Material.LEATHER_BOOTS || type == Material.LEATHER_CHESTPLATE || type == Material.LEATHER_HELMET || type == Material.LEATHER_LEGGINGS) {
|
||||||
|
LeatherArmorMeta meta = (LeatherArmorMeta) ITEM_STACK.getItemMeta();
|
||||||
|
meta.setColor(color);
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
return this;
|
||||||
|
} else {
|
||||||
|
throw new IllegalArgumentException("withColor is only applicable for leather armor!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder addPartialData(ConfigurationSection section){
|
||||||
|
return getItemStack(ITEM_STACK, section, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder addPartialData(ConfigurationSection section, Player player){
|
||||||
|
return getItemStack(ITEM_STACK, section, player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <P, C> ItemStackBuilder addNamespacedKey(NamespacedKey key, PersistentDataType<P, C> type, C value) {
|
||||||
|
ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
PersistentDataContainer dataContainer = meta.getPersistentDataContainer();
|
||||||
|
dataContainer.set(key, type, value);
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStackBuilder setUnbreakable(boolean unbreakable) {
|
||||||
|
ItemMeta meta = ITEM_STACK.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
meta.setUnbreakable(unbreakable);
|
||||||
|
ITEM_STACK.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ItemStack build() {
|
||||||
|
return ITEM_STACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final java.util.Map<String, ItemStack> headCache = new java.util.HashMap<>();
|
||||||
|
|
||||||
|
private static ItemStack getBase64Head(String base64) {
|
||||||
|
if (headCache.containsKey(base64)) return headCache.get(base64).clone();
|
||||||
|
|
||||||
|
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
||||||
|
SkullMeta meta = (SkullMeta) head.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
com.destroystokyo.paper.profile.PlayerProfile profile = Bukkit.createProfile(java.util.UUID.randomUUID(), null);
|
||||||
|
profile.setProperty(new com.destroystokyo.paper.profile.ProfileProperty("textures", base64));
|
||||||
|
meta.setPlayerProfile(profile);
|
||||||
|
head.setItemMeta(meta);
|
||||||
|
}
|
||||||
|
headCache.put(base64, head);
|
||||||
|
return head.clone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility;
|
||||||
|
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
|
||||||
|
public class NamespacedKeys{
|
||||||
|
public enum Keys {
|
||||||
|
PLAYER_HEAD("dhub.cgui.playerhead");
|
||||||
|
|
||||||
|
private final String key;
|
||||||
|
|
||||||
|
Keys(String key) {
|
||||||
|
this.key = key;
|
||||||
|
}
|
||||||
|
public String getKey() {
|
||||||
|
return key;
|
||||||
|
}
|
||||||
|
public NamespacedKey get() {
|
||||||
|
return NamespacedKey.fromString(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void registerKeys(){}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility;
|
||||||
|
|
||||||
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class PlaceholderUtil {
|
||||||
|
|
||||||
|
public static boolean PAPI;
|
||||||
|
|
||||||
|
public static String setPlaceholders(String text, Player player) {
|
||||||
|
|
||||||
|
if (text.contains("%player%") && player != null) text = text.replace("%player%", player.getName());
|
||||||
|
|
||||||
|
if (text.contains("%online%"))
|
||||||
|
text = text.replace("%online%", String.valueOf(Bukkit.getServer().getOnlinePlayers().size()));
|
||||||
|
|
||||||
|
if (text.contains("%online_max%"))
|
||||||
|
text = text.replace("%online_max%", String.valueOf(Bukkit.getServer().getMaxPlayers()));
|
||||||
|
|
||||||
|
if (text.contains("%location%") && player != null) {
|
||||||
|
Location location = player.getLocation();
|
||||||
|
text = text.replace("%location%", location.getBlockX() + ", " + location.getBlockY() + ", " + location.getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PAPI && player != null) text = PlaceholderAPI.setPlaceholders(player, text);
|
||||||
|
|
||||||
|
return text;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.color.IridiumColorAPI;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class TextUtil {
|
||||||
|
|
||||||
|
private static final int CENTER_PX = 154;
|
||||||
|
|
||||||
|
public static String color(final String string) {
|
||||||
|
return IridiumColorAPI.process(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getCenteredMessage(String message) {
|
||||||
|
if (message == null || message.isEmpty()) return "";
|
||||||
|
|
||||||
|
message = color(message).replace("<center>", "").replace("</center>", "");
|
||||||
|
|
||||||
|
int messagePxSize = 0;
|
||||||
|
boolean previousCode = false;
|
||||||
|
boolean isBold = false;
|
||||||
|
|
||||||
|
for (char c : message.toCharArray()) {
|
||||||
|
if (c == '�') {
|
||||||
|
previousCode = true;
|
||||||
|
|
||||||
|
} else if (previousCode) {
|
||||||
|
previousCode = false;
|
||||||
|
isBold = c == 'l' || c == 'L';
|
||||||
|
|
||||||
|
} else {
|
||||||
|
DefaultFontInfo dFI = DefaultFontInfo.getDefaultFontInfo(c);
|
||||||
|
messagePxSize += isBold ? dFI.getBoldLength() : dFI.getLength();
|
||||||
|
messagePxSize++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int halvedMessageSize = messagePxSize / 2;
|
||||||
|
int toCompensate = CENTER_PX - halvedMessageSize;
|
||||||
|
int spaceLength = DefaultFontInfo.SPACE.getLength() + 1;
|
||||||
|
int compensated = 0;
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
while (compensated < toCompensate) {
|
||||||
|
sb.append(" ");
|
||||||
|
compensated += spaceLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
return sb + message;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static String fromList(List<?> list) {
|
||||||
|
if (list == null || list.isEmpty()) return null;
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
if (org.bukkit.ChatColor.stripColor(list.get(i).toString()).equals("")) builder.append("\n&r");
|
||||||
|
else builder.append(list.get(i).toString()).append(i + 1 != list.size() ? "\n" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String joinString(int index, String[] args) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (int i = index; i < args.length; i++) {
|
||||||
|
builder.append(args[i]).append(" ");
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Color getColor(String s) {
|
||||||
|
switch (s.toUpperCase()) {
|
||||||
|
case "AQUA":
|
||||||
|
return Color.AQUA;
|
||||||
|
case "BLACK":
|
||||||
|
return Color.BLACK;
|
||||||
|
case "BLUE":
|
||||||
|
return Color.BLUE;
|
||||||
|
case "FUCHSIA":
|
||||||
|
return Color.FUCHSIA;
|
||||||
|
case "GRAY":
|
||||||
|
return Color.GRAY;
|
||||||
|
case "GREEN":
|
||||||
|
return Color.GREEN;
|
||||||
|
case "LIME":
|
||||||
|
return Color.LIME;
|
||||||
|
case "MAROON":
|
||||||
|
return Color.MAROON;
|
||||||
|
case "NAVY":
|
||||||
|
return Color.NAVY;
|
||||||
|
case "OLIVE":
|
||||||
|
return Color.OLIVE;
|
||||||
|
case "ORANGE":
|
||||||
|
return Color.ORANGE;
|
||||||
|
case "PURPLE":
|
||||||
|
return Color.PURPLE;
|
||||||
|
case "RED":
|
||||||
|
return Color.RED;
|
||||||
|
case "SILVER":
|
||||||
|
return Color.SILVER;
|
||||||
|
case "TEAL":
|
||||||
|
return Color.TEAL;
|
||||||
|
case "WHITE":
|
||||||
|
return Color.WHITE;
|
||||||
|
case "YELLOW":
|
||||||
|
return Color.YELLOW;
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,238 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility.color;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.color.patterns.GradientPattern;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.color.patterns.Pattern;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.color.patterns.RainbowPattern;
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.color.patterns.SolidPattern;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class IridiumColorAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cached result if the server version is after the v1.16 RGB update.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private static final boolean SUPPORTS_RGB = true;
|
||||||
|
|
||||||
|
private static final List<String> SPECIAL_COLORS = Arrays.asList("&l", "&n", "&o", "&k", "&m");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cached result of all legacy colors.
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private static final Map<Color, ChatColor> COLORS = ImmutableMap.<Color, ChatColor>builder()
|
||||||
|
.put(new Color(0), ChatColor.getByChar('0'))
|
||||||
|
.put(new Color(170), ChatColor.getByChar('1'))
|
||||||
|
.put(new Color(43520), ChatColor.getByChar('2'))
|
||||||
|
.put(new Color(43690), ChatColor.getByChar('3'))
|
||||||
|
.put(new Color(11141120), ChatColor.getByChar('4'))
|
||||||
|
.put(new Color(11141290), ChatColor.getByChar('5'))
|
||||||
|
.put(new Color(16755200), ChatColor.getByChar('6'))
|
||||||
|
.put(new Color(11184810), ChatColor.getByChar('7'))
|
||||||
|
.put(new Color(5592405), ChatColor.getByChar('8'))
|
||||||
|
.put(new Color(5592575), ChatColor.getByChar('9'))
|
||||||
|
.put(new Color(5635925), ChatColor.getByChar('a'))
|
||||||
|
.put(new Color(5636095), ChatColor.getByChar('b'))
|
||||||
|
.put(new Color(16733525), ChatColor.getByChar('c'))
|
||||||
|
.put(new Color(16733695), ChatColor.getByChar('d'))
|
||||||
|
.put(new Color(16777045), ChatColor.getByChar('e'))
|
||||||
|
.put(new Color(16777215), ChatColor.getByChar('f')).build();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cached result of patterns.
|
||||||
|
*
|
||||||
|
* @since 1.0.2
|
||||||
|
*/
|
||||||
|
private static final List<Pattern> PATTERNS = Arrays.asList(new GradientPattern(), new SolidPattern(), new RainbowPattern());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes a string to add color to it.
|
||||||
|
* Thanks to Distressing for helping with the regex <3
|
||||||
|
*
|
||||||
|
* @param string The string we want to process
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static String process(String string) {
|
||||||
|
for (Pattern pattern : PATTERNS) {
|
||||||
|
string = pattern.process(string);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes multiple strings in a list.
|
||||||
|
*
|
||||||
|
* @param strings The list of the strings we are processing
|
||||||
|
* @return The list of processed strings
|
||||||
|
* @since 1.0.3
|
||||||
|
*/
|
||||||
|
public static List<String> process(List<String> strings) {
|
||||||
|
return strings.stream().map(IridiumColorAPI::process).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Colors a String.
|
||||||
|
*
|
||||||
|
* @param string The string we want to color
|
||||||
|
* @param color The color we want to set it to
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static String color(String string, Color color) {
|
||||||
|
return (SUPPORTS_RGB ? ChatColor.of(color) : getClosestColor(color)) + string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Colors a String with a gradiant.
|
||||||
|
*
|
||||||
|
* @param string The string we want to color
|
||||||
|
* @param start The starting gradiant
|
||||||
|
* @param end The ending gradiant
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static String color(String string, Color start, Color end) {
|
||||||
|
StringBuilder specialColors = new StringBuilder();
|
||||||
|
for (String color : SPECIAL_COLORS) {
|
||||||
|
if (string.contains(color)) {
|
||||||
|
specialColors.append(color);
|
||||||
|
string = string.replace(color, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
ChatColor[] colors = createGradient(start, end, string.length());
|
||||||
|
String[] characters = string.split("");
|
||||||
|
for (int i = 0; i < string.length(); i++) {
|
||||||
|
stringBuilder.append(colors[i]).append(specialColors).append(characters[i]);
|
||||||
|
}
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Colors a String with rainbow colors.
|
||||||
|
*
|
||||||
|
* @param string The string which should have rainbow colors
|
||||||
|
* @param saturation The saturation of the rainbow colors
|
||||||
|
* @since 1.0.3
|
||||||
|
*/
|
||||||
|
public static String rainbow(String string, float saturation) {
|
||||||
|
StringBuilder specialColors = new StringBuilder();
|
||||||
|
for (String color : SPECIAL_COLORS) {
|
||||||
|
if (string.contains(color)) {
|
||||||
|
specialColors.append(color);
|
||||||
|
string = string.replace(color, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
ChatColor[] colors = createRainbow(string.length(), saturation);
|
||||||
|
String[] characters = string.split("");
|
||||||
|
for (int i = 0; i < string.length(); i++) {
|
||||||
|
stringBuilder.append(colors[i]).append(specialColors).append(characters[i]);
|
||||||
|
}
|
||||||
|
return stringBuilder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a color from hex code.
|
||||||
|
*
|
||||||
|
* @param string The hex code of the color
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static ChatColor getColor(String string) {
|
||||||
|
return SUPPORTS_RGB ? ChatColor.of(new Color(Integer.parseInt(string, 16))) : getClosestColor(new Color(Integer.parseInt(string, 16)));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes all color codes from the provided String, including IridiumColorAPI patterns.
|
||||||
|
*
|
||||||
|
* @param string The String which should be stripped
|
||||||
|
* @return The stripped string without color codes
|
||||||
|
* @since 1.0.5
|
||||||
|
*/
|
||||||
|
public static String stripColorFormatting(String string) {
|
||||||
|
return string.replaceAll("<#[0-9A-F]{6}>|[&§][a-f0-9lnokm]|<[/]?[A-Z]{5,8}(:[0-9A-F]{6})?[0-9]*>", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a rainbow array of chat colors.
|
||||||
|
*
|
||||||
|
* @param step How many colors we return
|
||||||
|
* @param saturation The saturation of the rainbow
|
||||||
|
* @return The array of colors
|
||||||
|
* @since 1.0.3
|
||||||
|
*/
|
||||||
|
private static ChatColor[] createRainbow(int step, float saturation) {
|
||||||
|
ChatColor[] colors = new ChatColor[step];
|
||||||
|
double colorStep = (1.00 / step);
|
||||||
|
for (int i = 0; i < step; i++) {
|
||||||
|
Color color = Color.getHSBColor((float) (colorStep * i), saturation, saturation);
|
||||||
|
if (SUPPORTS_RGB) {
|
||||||
|
colors[i] = ChatColor.of(color);
|
||||||
|
} else {
|
||||||
|
colors[i] = getClosestColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a gradient array of chat colors.
|
||||||
|
*
|
||||||
|
* @param start The starting color.
|
||||||
|
* @param end The ending color.
|
||||||
|
* @param step How many colors we return.
|
||||||
|
* @author TheViperShow
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private static ChatColor[] createGradient(Color start, Color end, int step) {
|
||||||
|
ChatColor[] colors = new ChatColor[step];
|
||||||
|
int stepR = Math.abs(start.getRed() - end.getRed()) / (step - 1);
|
||||||
|
int stepG = Math.abs(start.getGreen() - end.getGreen()) / (step - 1);
|
||||||
|
int stepB = Math.abs(start.getBlue() - end.getBlue()) / (step - 1);
|
||||||
|
int[] direction = new int[]{
|
||||||
|
start.getRed() < end.getRed() ? +1 : -1,
|
||||||
|
start.getGreen() < end.getGreen() ? +1 : -1,
|
||||||
|
start.getBlue() < end.getBlue() ? +1 : -1
|
||||||
|
};
|
||||||
|
|
||||||
|
for (int i = 0; i < step; i++) {
|
||||||
|
Color color = new Color(start.getRed() + ((stepR * i) * direction[0]), start.getGreen() + ((stepG * i) * direction[1]), start.getBlue() + ((stepB * i) * direction[2]));
|
||||||
|
if (SUPPORTS_RGB) {
|
||||||
|
colors[i] = ChatColor.of(color);
|
||||||
|
} else {
|
||||||
|
colors[i] = getClosestColor(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return colors;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the closest legacy color from an rgb color
|
||||||
|
*
|
||||||
|
* @param color The color we want to transform
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
private static ChatColor getClosestColor(Color color) {
|
||||||
|
Color nearestColor = null;
|
||||||
|
double nearestDistance = Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
for (Color constantColor : COLORS.keySet()) {
|
||||||
|
double distance = Math.pow(color.getRed() - constantColor.getRed(), 2) + Math.pow(color.getGreen() - constantColor.getGreen(), 2) + Math.pow(color.getBlue() - constantColor.getBlue(), 2);
|
||||||
|
if (nearestDistance > distance) {
|
||||||
|
nearestColor = constantColor;
|
||||||
|
nearestDistance = distance;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return COLORS.get(nearestColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+55
@@ -0,0 +1,55 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility.color.patterns;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.color.IridiumColorAPI;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a gradient color pattern which can be applied to a String.
|
||||||
|
*/
|
||||||
|
public class GradientPattern implements Pattern {
|
||||||
|
|
||||||
|
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("\\{#([A-Fa-f0-9]{6})[>}](.*?)[<{]/#([A-Fa-f0-9]{6})}");
|
||||||
|
java.util.regex.Pattern miniMessagePattern = java.util.regex.Pattern.compile("(?i)<gradient:#([A-Fa-f0-9]{6}):#([A-Fa-f0-9]{6})>(.*?)</gradient>");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a gradient pattern to the provided String.
|
||||||
|
* Output might me the same as the input if this pattern is not present.
|
||||||
|
*
|
||||||
|
* @param string The String to which this pattern should be applied to
|
||||||
|
* @return The new String with applied pattern
|
||||||
|
*/
|
||||||
|
public String process(String string) {
|
||||||
|
Matcher matcher = pattern.matcher(string);
|
||||||
|
while (matcher.find()) {
|
||||||
|
String start = matcher.group(1);
|
||||||
|
String end = matcher.group(3);
|
||||||
|
String content = matcher.group(2);
|
||||||
|
string = string.replace(matcher.group(), IridiumColorAPI.color(content, new Color(Integer.parseInt(start, 16)), new Color(Integer.parseInt(end, 16))));
|
||||||
|
}
|
||||||
|
|
||||||
|
Matcher mmMatcher = miniMessagePattern.matcher(string);
|
||||||
|
while (mmMatcher.find()) {
|
||||||
|
String start = mmMatcher.group(1);
|
||||||
|
String end = mmMatcher.group(2);
|
||||||
|
String content = mmMatcher.group(3);
|
||||||
|
|
||||||
|
// Map MiniMessage style tags inside the gradient text
|
||||||
|
content = content.replaceAll("(?i)<bold>|<b>", "&l")
|
||||||
|
.replaceAll("(?i)</bold>|</b>", "")
|
||||||
|
.replaceAll("(?i)<italic>|<i>", "&o")
|
||||||
|
.replaceAll("(?i)</italic>|</i>", "")
|
||||||
|
.replaceAll("(?i)<underlined>|<u>", "&n")
|
||||||
|
.replaceAll("(?i)</underlined>|</u>", "")
|
||||||
|
.replaceAll("(?i)<strikethrough>|<st>", "&m")
|
||||||
|
.replaceAll("(?i)</strikethrough>|</st>", "")
|
||||||
|
.replaceAll("(?i)<obfuscated>|<obf>", "&k")
|
||||||
|
.replaceAll("(?i)</obfuscated>|</obf>", "");
|
||||||
|
|
||||||
|
string = string.replace(mmMatcher.group(), IridiumColorAPI.color(content, new Color(Integer.parseInt(start, 16)), new Color(Integer.parseInt(end, 16))));
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility.color.patterns;
|
||||||
|
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
public class HexUtils {
|
||||||
|
|
||||||
|
public static final Pattern HEX_PATTERN = Pattern.compile("&#([A-Fa-f0-9]{6})");
|
||||||
|
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static String colorize(final String message) {
|
||||||
|
return ChatColor.translateAlternateColorCodes('&', message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
public static String translateHexColorCodes(final String message) {
|
||||||
|
final char colorChar = ChatColor.COLOR_CHAR;
|
||||||
|
|
||||||
|
final Matcher matcher = HEX_PATTERN.matcher(message);
|
||||||
|
final StringBuffer buffer = new StringBuffer(message.length() + 4 * 8);
|
||||||
|
|
||||||
|
while (matcher.find()) {
|
||||||
|
final String group = matcher.group(1);
|
||||||
|
|
||||||
|
matcher.appendReplacement(buffer, colorChar + "x"
|
||||||
|
+ colorChar + group.charAt(0) + colorChar + group.charAt(1)
|
||||||
|
+ colorChar + group.charAt(2) + colorChar + group.charAt(3)
|
||||||
|
+ colorChar + group.charAt(4) + colorChar + group.charAt(5));
|
||||||
|
}
|
||||||
|
|
||||||
|
return matcher.appendTail(buffer).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility.color.patterns;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a color pattern which can be applied to a String.
|
||||||
|
*/
|
||||||
|
public interface Pattern {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies this pattern to the provided String.
|
||||||
|
* Output might be the same as the input if this pattern is not present.
|
||||||
|
*
|
||||||
|
* @param string The String to which this pattern should be applied to
|
||||||
|
* @return The new String with applied pattern
|
||||||
|
*/
|
||||||
|
String process(String string);
|
||||||
|
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility.color.patterns;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.color.IridiumColorAPI;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
public class RainbowPattern implements Pattern {
|
||||||
|
|
||||||
|
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("<RAINBOW([0-9]{1,3})>(.*?)</RAINBOW>");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a rainbow pattern to the provided String.
|
||||||
|
* Output might be the same as the input if this pattern is not present.
|
||||||
|
*
|
||||||
|
* @param string The String to which this pattern should be applied to
|
||||||
|
* @return The new String with applied pattern
|
||||||
|
*/
|
||||||
|
public String process(String string) {
|
||||||
|
Matcher matcher = pattern.matcher(string);
|
||||||
|
while (matcher.find()) {
|
||||||
|
String saturation = matcher.group(1);
|
||||||
|
String content = matcher.group(2);
|
||||||
|
string = string.replace(matcher.group(), IridiumColorAPI.rainbow(content, Float.parseFloat(saturation)));
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility.color.patterns;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.utility.color.IridiumColorAPI;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
|
public class SolidPattern implements Pattern {
|
||||||
|
|
||||||
|
public static final java.util.regex.Pattern PATTERN = java.util.regex.Pattern.compile("\\{#([A-Fa-f0-9]{6})}|[&]?#([A-Fa-f0-9]{6})");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies a solid RGB color to the provided String.
|
||||||
|
* Output might be the same as the input if this pattern is not present.
|
||||||
|
*
|
||||||
|
* @param string The String to which this pattern should be applied to
|
||||||
|
* @return The new String with applied pattern
|
||||||
|
*/
|
||||||
|
public String process(String string) {
|
||||||
|
Matcher matcher = PATTERN.matcher(string);
|
||||||
|
while (matcher.find()) {
|
||||||
|
String color = matcher.group(1);
|
||||||
|
if (color == null) color = matcher.group(2);
|
||||||
|
|
||||||
|
string = string.replace(matcher.group(), IridiumColorAPI.getColor(color) + "");
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,231 @@
|
|||||||
|
/*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Crypto Morin
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package eu.milujukockoholky.vexliolobby.utility.reflection;
|
||||||
|
|
||||||
|
import eu.milujukockoholky.vexliolobby.VexlioHubPlugin;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.lang.invoke.MethodHandle;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.invoke.MethodType;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* References
|
||||||
|
*
|
||||||
|
* * * GitHub: https://github.com/CryptoMorin/XSeries/blob/master/ActionBar.java
|
||||||
|
* * XSeries: https://www.spigotmc.org/threads/378136/
|
||||||
|
* PacketPlayOutTitle: https://wiki.vg/Protocol#Title
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reflection API for action bars in Minecraft.
|
||||||
|
* Fully optimized - Supports 1.8.8+ and above.
|
||||||
|
* Requires ReflectionUtils.
|
||||||
|
* Messages are not colorized by default.
|
||||||
|
* <p>
|
||||||
|
* Action bars are text messages that appear above
|
||||||
|
* the player's <a href="https://minecraft.gamepedia.com/Heads-up_display">hotbar</a>
|
||||||
|
* Note that this is different than the text appeared when switching between items.
|
||||||
|
* Those messages show the item's name and are different from action bars.
|
||||||
|
* The only natural way of displaying action bars is when mounting.
|
||||||
|
*
|
||||||
|
* @author Crypto Morin
|
||||||
|
* @version 1.0.0
|
||||||
|
* @see ReflectionUtils
|
||||||
|
*/
|
||||||
|
public class ActionBar {
|
||||||
|
|
||||||
|
private static final JavaPlugin PLUGIN = JavaPlugin.getProvidingPlugin(VexlioHubPlugin.class);
|
||||||
|
private static final MethodHandle CHAT_COMPONENT_TEXT;
|
||||||
|
private static final MethodHandle PACKET;
|
||||||
|
private static final Object CHAT_MESSAGE_TYPE;
|
||||||
|
|
||||||
|
static {
|
||||||
|
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||||
|
Class<?> packetPlayOutChatClass = ReflectionUtils.getNMSClass("PacketPlayOutChat");
|
||||||
|
Class<?> iChatBaseComponentClass = ReflectionUtils.getNMSClass("IChatBaseComponent");
|
||||||
|
|
||||||
|
MethodHandle packet = null;
|
||||||
|
MethodHandle chatComp = null;
|
||||||
|
Object chatMsgType = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Game Info Message Type
|
||||||
|
Class<?> chatMessageTypeClass = Class.forName("net.minecraft.server." + ReflectionUtils.VERSION + ".ChatMessageType");
|
||||||
|
for (Object obj : chatMessageTypeClass.getEnumConstants()) {
|
||||||
|
if (obj.toString().equals("GAME_INFO")) {
|
||||||
|
chatMsgType = obj;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSON Message Builder
|
||||||
|
Class<?> chatComponentTextClass = ReflectionUtils.getNMSClass("ChatComponentText");
|
||||||
|
chatComp = lookup.findConstructor(chatComponentTextClass, MethodType.methodType(void.class, String.class));
|
||||||
|
|
||||||
|
// Packet Constructor
|
||||||
|
packet = lookup.findConstructor(packetPlayOutChatClass, MethodType.methodType(void.class, iChatBaseComponentClass, chatMessageTypeClass));
|
||||||
|
} catch (NoSuchMethodException | IllegalAccessException | ClassNotFoundException ignored) {
|
||||||
|
try {
|
||||||
|
// Game Info Message Type
|
||||||
|
chatMsgType = (byte) 2;
|
||||||
|
|
||||||
|
// JSON Message Builder
|
||||||
|
Class<?> chatComponentTextClass = ReflectionUtils.getNMSClass("ChatComponentText");
|
||||||
|
chatComp = lookup.findConstructor(chatComponentTextClass, MethodType.methodType(void.class, String.class));
|
||||||
|
|
||||||
|
// Packet Constructor
|
||||||
|
packet = lookup.findConstructor(packetPlayOutChatClass, MethodType.methodType(void.class, iChatBaseComponentClass, byte.class));
|
||||||
|
} catch (NoSuchMethodException | IllegalAccessException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CHAT_MESSAGE_TYPE = chatMsgType;
|
||||||
|
CHAT_COMPONENT_TEXT = chatComp;
|
||||||
|
PACKET = packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an action bar to a player.
|
||||||
|
*
|
||||||
|
* @param player the player to send the action bar to.
|
||||||
|
* @param message the message to send.
|
||||||
|
* @see #sendActionBar(Player, String, long)
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static void sendActionBar(Player player, String message) {
|
||||||
|
Objects.requireNonNull(player, "Cannot send action bar to null player");
|
||||||
|
Object packet = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Object component = CHAT_COMPONENT_TEXT.invoke(message);
|
||||||
|
packet = PACKET.invoke(component, CHAT_MESSAGE_TYPE);
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
|
ReflectionUtils.sendPacket(player, packet);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an action bar all the online players.
|
||||||
|
*
|
||||||
|
* @param message the message to send.
|
||||||
|
* @see #sendActionBar(Player, String)
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static void sendAllActionBar(String message) {
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) sendActionBar(player, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an action bar to a player for a specific amount of ticks.
|
||||||
|
* Plugin instance should be changed in this method for the schedulers.
|
||||||
|
* <p>
|
||||||
|
* If the caller returns true, the action bar will continue.
|
||||||
|
* If the caller returns false, action bar will not be sent anymore.
|
||||||
|
*
|
||||||
|
* @param player the player to send the action bar to.
|
||||||
|
* @param message the message to send. The message will not be updated.
|
||||||
|
* @param callable the condition for the action bar to continue.
|
||||||
|
* @see #sendActionBar(Player, String, long)
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static void sendActionBarWhile(Player player, String message, Callable<Boolean> callable) {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
if (!callable.call()) {
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
sendActionBar(player, message);
|
||||||
|
}
|
||||||
|
// Re-sends the messages every 2 seconds so it doesn't go away from the player's screen.
|
||||||
|
}.runTaskTimerAsynchronously(PLUGIN, 0L, 40L);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an action bar to a player for a specific amount of ticks.
|
||||||
|
* <p>
|
||||||
|
* If the caller returns true, the action bar will continue.
|
||||||
|
* If the caller returns false, action bar will not be sent anymore.
|
||||||
|
*
|
||||||
|
* @param player the player to send the action bar to.
|
||||||
|
* @param message the message to send. The message will be updated.
|
||||||
|
* @param callable the condition for the action bar to continue.
|
||||||
|
* @see #sendActionBarWhile(Player, String, Callable)
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static void sendActionBarWhile(Player player, Callable<String> message, Callable<Boolean> callable) {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
if (!callable.call()) {
|
||||||
|
cancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sendActionBar(player, message.call());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Re-sends the messages every 2 seconds so it doesn't go away from the player's screen.
|
||||||
|
}.runTaskTimerAsynchronously(PLUGIN, 0L, 40L);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an action bar to a player for a specific amount of ticks.
|
||||||
|
*
|
||||||
|
* @param player the player to send the action bar to.
|
||||||
|
* @param message the message to send.
|
||||||
|
* @param duration the duration to keep the action bar in ticks.
|
||||||
|
* @see #sendActionBarWhile(Player, String, Callable)
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
public static void sendActionBar(Player player, String message, long duration) {
|
||||||
|
if (duration < 1) return;
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
long repeater = duration;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sendActionBar(player, message);
|
||||||
|
repeater -= 40L;
|
||||||
|
if (repeater - 40L < -20L) cancel();
|
||||||
|
}
|
||||||
|
// Re-sends the messages every 2 seconds so it doesn't go away from the player's screen.
|
||||||
|
}.runTaskTimerAsynchronously(PLUGIN, 0L, 40L);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility.reflection;
|
||||||
|
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
|
||||||
|
public class ArmorStandName {
|
||||||
|
|
||||||
|
public static String getName(ArmorStand stand) {
|
||||||
|
Component name = stand.customName();
|
||||||
|
return name != null ? LegacyComponentSerializer.legacySection().serialize(name) : "";
|
||||||
|
}
|
||||||
|
}
|
||||||
+208
@@ -0,0 +1,208 @@
|
|||||||
|
/*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2021 Crypto Morin
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
package eu.milujukockoholky.vexliolobby.utility.reflection;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.lang.invoke.MethodHandle;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.invoke.MethodType;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <b>ReflectionUtils</b> - Reflection handler for NMS and CraftBukkit.<br>
|
||||||
|
* Caches the packet related methods and is asynchronous.
|
||||||
|
* <p>
|
||||||
|
* This class does not handle null checks as most of the requests are from the
|
||||||
|
* other utility classes that already handle null checks.
|
||||||
|
* <p>
|
||||||
|
* <a href="https://wiki.vg/Protocol">Clientbound Packets</a> are considered fake
|
||||||
|
* updates to the client without changing the actual data. Since all the data is handled
|
||||||
|
* by the server.
|
||||||
|
* <p>
|
||||||
|
* A useful resource used to compare mappings is <a href="https://minidigger.github.io/MiniMappingViewer/#/spigot">Mini's Mapping Viewer</a>
|
||||||
|
*
|
||||||
|
* @author Crypto Morin
|
||||||
|
* @version 3.0.0
|
||||||
|
*/
|
||||||
|
public class ReflectionUtils {
|
||||||
|
/**
|
||||||
|
* A nullable public accessible field only available in {@code EntityPlayer}.
|
||||||
|
* This can be null if the player is offline.
|
||||||
|
*/
|
||||||
|
private static final MethodHandle PLAYER_CONNECTION; /**
|
||||||
|
* We use reflection mainly to avoid writing a new class for version barrier.
|
||||||
|
* The version barrier is for NMS that uses the Minecraft version as the main package name.
|
||||||
|
* <p>
|
||||||
|
* E.g. EntityPlayer in 1.15 is in the class {@code net.minecraft.server.v1_15_R1}
|
||||||
|
* but in 1.14 it's in {@code net.minecraft.server.v1_14_R1}
|
||||||
|
* In order to maintain cross-version compatibility we cannot import these classes.
|
||||||
|
* <p>
|
||||||
|
* Performance is not a concern for these specific statically initialized values.
|
||||||
|
*/
|
||||||
|
public static final String
|
||||||
|
VERSION = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3],
|
||||||
|
CRAFTBUKKIT = "org.bukkit.craftbukkit." + VERSION + '.',
|
||||||
|
NMS = "net.minecraft.server." + VERSION + '.';
|
||||||
|
/**
|
||||||
|
* Responsible for getting the NMS handler {@code EntityPlayer} object for the player.
|
||||||
|
* {@code CraftPlayer} is simply a wrapper for {@code EntityPlayer}.
|
||||||
|
* Used mainly for handling packet related operations.
|
||||||
|
* <p>
|
||||||
|
* This is also where the famous player {@code ping} field comes from!
|
||||||
|
*/
|
||||||
|
private static final MethodHandle GET_HANDLE;
|
||||||
|
/**
|
||||||
|
* Sends a packet to the player's client through a {@code NetworkManager} which
|
||||||
|
* is where {@code ProtocolLib} controls packets by injecting channels!
|
||||||
|
*/
|
||||||
|
private static final MethodHandle SEND_PACKET;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Class<?> entityPlayer = getNMSClass("EntityPlayer");
|
||||||
|
Class<?> craftPlayer = getCraftClass("entity.CraftPlayer");
|
||||||
|
Class<?> playerConnection = getNMSClass("PlayerConnection");
|
||||||
|
|
||||||
|
MethodHandles.Lookup lookup = MethodHandles.lookup();
|
||||||
|
MethodHandle sendPacket = null;
|
||||||
|
MethodHandle getHandle = null;
|
||||||
|
MethodHandle connection = null;
|
||||||
|
try {
|
||||||
|
connection = lookup.findGetter(entityPlayer, "playerConnection", playerConnection);
|
||||||
|
getHandle = lookup.findVirtual(craftPlayer, "getHandle", MethodType.methodType(entityPlayer));
|
||||||
|
sendPacket = lookup.findVirtual(playerConnection, "sendPacket", MethodType.methodType(void.class, getNMSClass("Packet")));
|
||||||
|
} catch (NoSuchMethodException | NoSuchFieldException | IllegalAccessException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
PLAYER_CONNECTION = connection;
|
||||||
|
SEND_PACKET = sendPacket;
|
||||||
|
GET_HANDLE = getHandle;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ReflectionUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a NMS (net.minecraft.server) class.
|
||||||
|
*
|
||||||
|
* @param name the name of the class.
|
||||||
|
* @return the NMS class or null if not found.
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static Class<?> getNMSClass(@Nonnull String name) {
|
||||||
|
try {
|
||||||
|
return Class.forName(NMS + name);
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a packet to the player asynchronously if they're online.
|
||||||
|
* Packets are thread-safe.
|
||||||
|
*
|
||||||
|
* @param player the player to send the packet to.
|
||||||
|
* @param packets the packets to send.
|
||||||
|
* @return the async thread handling the packet.
|
||||||
|
* @see #sendPacketSync(Player, Object...)
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public static CompletableFuture<Void> sendPacket(@Nonnull Player player, @Nonnull Object... packets) {
|
||||||
|
return CompletableFuture.runAsync(() -> sendPacketSync(player, packets))
|
||||||
|
.exceptionally(ex -> {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a packet to the player synchronously if they're online.
|
||||||
|
*
|
||||||
|
* @param player the player to send the packet to.
|
||||||
|
* @param packets the packets to send.
|
||||||
|
* @see #sendPacket(Player, Object...)
|
||||||
|
* @since 2.0.0
|
||||||
|
*/
|
||||||
|
public static void sendPacketSync(@Nonnull Player player, @Nonnull Object... packets) {
|
||||||
|
try {
|
||||||
|
Object handle = GET_HANDLE.invoke(player);
|
||||||
|
Object connection = PLAYER_CONNECTION.invoke(handle);
|
||||||
|
|
||||||
|
// Checking if the connection is not null is enough. There is no need to check if the player is online.
|
||||||
|
if (connection != null) {
|
||||||
|
for (Object packet : packets) SEND_PACKET.invoke(connection, packet);
|
||||||
|
}
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static Object getHandle(@Nonnull Player player) {
|
||||||
|
Objects.requireNonNull(player, "Cannot get handle of null player");
|
||||||
|
try {
|
||||||
|
return GET_HANDLE.invoke(player);
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static Object getConnection(@Nonnull Player player) {
|
||||||
|
Objects.requireNonNull(player, "Cannot get connection of null player");
|
||||||
|
try {
|
||||||
|
Object handle = GET_HANDLE.invoke(player);
|
||||||
|
return PLAYER_CONNECTION.invoke(handle);
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a CraftBukkit (org.bukkit.craftbukkit) class.
|
||||||
|
*
|
||||||
|
* @param name the name of the class to load.
|
||||||
|
* @return the CraftBukkit class or null if not found.
|
||||||
|
* @since 1.0.0
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public static Class<?> getCraftClass(@Nonnull String name) {
|
||||||
|
try {
|
||||||
|
return Class.forName(CRAFTBUKKIT + name);
|
||||||
|
} catch (ClassNotFoundException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,149 @@
|
|||||||
|
package eu.milujukockoholky.vexliolobby.utility.reflection;
|
||||||
|
/*
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2019 Crypto Morin
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
|
||||||
|
* FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||||
|
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.invoke.MethodHandle;
|
||||||
|
import java.lang.invoke.MethodHandles;
|
||||||
|
import java.lang.invoke.MethodType;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* References
|
||||||
|
*
|
||||||
|
* * * GitHub: https://github.com/CryptoMorin/XSeries/blob/master/Titles.java
|
||||||
|
* * XSeries: https://www.spigotmc.org/threads/378136/
|
||||||
|
* PacketPlayOutTitle: https://wiki.vg/Protocol#Title
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A reflection API for titles in Minecraft.
|
||||||
|
* Fully optimized - Supports 1.8.8+ and above.
|
||||||
|
* Requires ReflectionUtils.
|
||||||
|
* Messages are not colorized by default.
|
||||||
|
* <p>
|
||||||
|
* Titles are text messages that appear in the
|
||||||
|
* middle of the players screen: https://minecraft.gamepedia.com/Commands/title
|
||||||
|
* PacketPlayOutTitle: https://wiki.vg/Protocol#Title
|
||||||
|
*
|
||||||
|
* @author Crypto Morin
|
||||||
|
* @version 1.0.0
|
||||||
|
* @see ReflectionUtils
|
||||||
|
*/
|
||||||
|
public class Titles {
|
||||||
|
|
||||||
|
private static final Object TIMES;
|
||||||
|
private static final Object TITLE;
|
||||||
|
private static final Object SUBTITLE;
|
||||||
|
private static final Object CLEAR;
|
||||||
|
|
||||||
|
private static final MethodHandle PACKET;
|
||||||
|
private static final MethodHandle CHAT_COMPONENT_TEXT;
|
||||||
|
|
||||||
|
static {
|
||||||
|
Class<?> chatComponentText = ReflectionUtils.getNMSClass("ChatComponentText");
|
||||||
|
Class<?> packet = ReflectionUtils.getNMSClass("PacketPlayOutTitle");
|
||||||
|
Class<?> titleTypes = packet.getDeclaredClasses()[0];
|
||||||
|
MethodHandle packetCtor = null;
|
||||||
|
MethodHandle chatComp = null;
|
||||||
|
|
||||||
|
Object times = null;
|
||||||
|
Object title = null;
|
||||||
|
Object subtitle = null;
|
||||||
|
Object clear = null;
|
||||||
|
|
||||||
|
for (Object type : titleTypes.getEnumConstants()) {
|
||||||
|
switch (type.toString()) {
|
||||||
|
case "TIMES":
|
||||||
|
times = type;
|
||||||
|
break;
|
||||||
|
case "TITLE":
|
||||||
|
title = type;
|
||||||
|
break;
|
||||||
|
case "SUBTITLE":
|
||||||
|
subtitle = type;
|
||||||
|
break;
|
||||||
|
case "CLEAR":
|
||||||
|
clear = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
chatComp = MethodHandles.lookup().findConstructor(chatComponentText,
|
||||||
|
MethodType.methodType(void.class, String.class));
|
||||||
|
|
||||||
|
packetCtor = MethodHandles.lookup().findConstructor(packet,
|
||||||
|
MethodType.methodType(void.class, titleTypes,
|
||||||
|
ReflectionUtils.getNMSClass("IChatBaseComponent"),
|
||||||
|
int.class, int.class, int.class));
|
||||||
|
} catch (NoSuchMethodException | IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
TITLE = title;
|
||||||
|
SUBTITLE = subtitle;
|
||||||
|
TIMES = times;
|
||||||
|
CLEAR = clear;
|
||||||
|
|
||||||
|
PACKET = packetCtor;
|
||||||
|
CHAT_COMPONENT_TEXT = chatComp;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sendTitle(Player player,
|
||||||
|
int fadeIn, int stay, int fadeOut,
|
||||||
|
String title, String subtitle) {
|
||||||
|
Objects.requireNonNull(player, "Cannot send title to null player");
|
||||||
|
if (title == null && subtitle == null) return;
|
||||||
|
|
||||||
|
try {
|
||||||
|
Object timesPacket = PACKET.invoke(TIMES, CHAT_COMPONENT_TEXT.invoke(title), fadeIn, stay, fadeOut);
|
||||||
|
ReflectionUtils.sendPacket(player, timesPacket);
|
||||||
|
|
||||||
|
if (title != null) {
|
||||||
|
Object titlePacket = PACKET.invoke(TITLE, CHAT_COMPONENT_TEXT.invoke(title), fadeIn, stay, fadeOut);
|
||||||
|
ReflectionUtils.sendPacket(player, titlePacket);
|
||||||
|
}
|
||||||
|
if (subtitle != null) {
|
||||||
|
Object subtitlePacket = PACKET.invoke(SUBTITLE, CHAT_COMPONENT_TEXT.invoke(subtitle), fadeIn, stay, fadeOut);
|
||||||
|
ReflectionUtils.sendPacket(player, subtitlePacket);
|
||||||
|
}
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearTitle(Player player) {
|
||||||
|
Objects.requireNonNull(player, "Cannot clear title from null player");
|
||||||
|
Object clearPacket = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
clearPacket = PACKET.invoke(CLEAR, null, -1, -1, -1);
|
||||||
|
} catch (Throwable throwable) {
|
||||||
|
throwable.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
ReflectionUtils.sendPacket(player, clearPacket);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | CUSTOM COMMANDS |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
version: 3.7.0
|
||||||
|
custom_commands:
|
||||||
|
|
||||||
|
# Command name, this will be used as the main command
|
||||||
|
website:
|
||||||
|
# List any aliases for the command here
|
||||||
|
aliases:
|
||||||
|
- web
|
||||||
|
# Actions to be executed
|
||||||
|
actions:
|
||||||
|
- '[MESSAGE] &bWebsite: &fwww.examplemc.net'
|
||||||
|
clearinventory:
|
||||||
|
# Players will require this permission to execute this command.
|
||||||
|
permission: vexliolobby.clearinventory
|
||||||
|
aliases:
|
||||||
|
- ci
|
||||||
|
actions:
|
||||||
|
- '[COMMAND] minecraft:clear'
|
||||||
|
- '[MESSAGE] <gradient:#9333EA:#06B6D4><bold>VexlioHub</bold></gradient> &eYour inventory has been cleared!'
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | VEXLIOHUB COMMANDS |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# It's highly recommended to restart your server if you edit anything below
|
||||||
|
|
||||||
|
commands:
|
||||||
|
gamemode:
|
||||||
|
enabled: true
|
||||||
|
aliases:
|
||||||
|
- gm
|
||||||
|
gms:
|
||||||
|
enabled: true
|
||||||
|
gmc:
|
||||||
|
enabled: true
|
||||||
|
gma:
|
||||||
|
enabled: true
|
||||||
|
gmsp:
|
||||||
|
enabled: true
|
||||||
|
clearchat:
|
||||||
|
enabled: true
|
||||||
|
fly:
|
||||||
|
enabled: true
|
||||||
|
setlobby:
|
||||||
|
enabled: true
|
||||||
|
lobby:
|
||||||
|
enabled: true
|
||||||
|
buildmode:
|
||||||
|
enabled: true
|
||||||
|
aliases:
|
||||||
|
- build
|
||||||
@@ -0,0 +1,323 @@
|
|||||||
|
# ··························································································
|
||||||
|
# : ____ _ _ _ _ ____ _ _ _ :
|
||||||
|
# :| _ \ ___| |_ ___ _____| | | |_ _| |__ | _ \ ___| | ___ __ _ __| | ___ __| |:
|
||||||
|
# :| | | |/ _ \ | | | \ \/ / _ \ |_| | | | | '_ \| |_) / _ \ |/ _ \ / _` |/ _` |/ _ \/ _` |:
|
||||||
|
# :| |_| | __/ | |_| |> < __/ _ | |_| | |_) | _ < __/ | (_) | (_| | (_| | __/ (_| |:
|
||||||
|
# :|____/ \___|_|\__,_/_/\_\___|_| |_|\__,_|_.__/|_| \_\___|_|\___/ \__,_|\__,_|\___|\__,_|:
|
||||||
|
# ··························································································
|
||||||
|
# AUTHOR: tp3x
|
||||||
|
# Copyright (c) tp3x 2026. All rights reserved.
|
||||||
|
#--------
|
||||||
|
# CUSTOM MENUS
|
||||||
|
# You can add more menus to the "VexlioHub/menus" directory,
|
||||||
|
# copy and paste the default, server selector, menu and edit the file.
|
||||||
|
# Use the name of the file as the action ID.
|
||||||
|
#--------
|
||||||
|
# BUILT IN PLUGIN PLACEHOLDERS:
|
||||||
|
#
|
||||||
|
# %player% - Returns player name
|
||||||
|
# %location% - Returns player location
|
||||||
|
# %online% - Returns number of players online
|
||||||
|
# %online_max% - Returns number of max player slots
|
||||||
|
#
|
||||||
|
# *** USE PLACEHOLDERAPI TO GET MORE ***
|
||||||
|
# (https://www.spigotmc.org/resources/placeholderapi.6245/)
|
||||||
|
#--------
|
||||||
|
# ACTIONS:
|
||||||
|
#
|
||||||
|
# [MESSAGE] - Send a message to the player
|
||||||
|
# [BROADCAST] - Broadcast a message to everyone
|
||||||
|
# [TITLE] e.g. MainTitle;Subtitle;FadeIn;Stay:FadeOut - Send the player a title message
|
||||||
|
# [ACTIONBAR] Send an actionbar message
|
||||||
|
# [SOUND] - Send the player a sound
|
||||||
|
# [COMMAND] - Execute a command as the player
|
||||||
|
# [GAMEMODE] - Change a players' gamemode
|
||||||
|
# [PROXY] - Send a player to a server
|
||||||
|
# [EFFECT] e.g. EFFECT;LEVEL - Give a potion effect
|
||||||
|
# [MENU] - Open a menu from (plugins/VexlioHub/menus)
|
||||||
|
# [CLOSE] - Close an open inventory gui
|
||||||
|
#--------
|
||||||
|
# MESSAGE FORMATTING:
|
||||||
|
# HEX colors formatting: {#FFFFFF} and for Gradients {#12C2E9} Your Message {/#C471ED}
|
||||||
|
# <center> Centered message! </center> - Centers a message in chat
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | GENERAL SETTINGS |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
version: 3.7.0
|
||||||
|
|
||||||
|
# If you use multiple worlds set this to true
|
||||||
|
multiple_worlds: false
|
||||||
|
|
||||||
|
# Disable specific worlds
|
||||||
|
disabled-worlds:
|
||||||
|
# Should we invert the list making it a whitelist rather than a blacklist?
|
||||||
|
invert: false
|
||||||
|
# List your disabled worlds HERE or "worlds: []" to disable
|
||||||
|
worlds:
|
||||||
|
- world_nether
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | BUILD MODE |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
build_mode:
|
||||||
|
# Should privileged players see an actionbar message when build mode is turned on?
|
||||||
|
use_actionbar_message: true
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | STATIC TIME |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
static_time:
|
||||||
|
# Should StaticTime be enabled?
|
||||||
|
enabled: false
|
||||||
|
# Which time should be set permanently in hub worlds?
|
||||||
|
time: 12000
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | LAUNCHPAD |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
launchpad:
|
||||||
|
# Should the launchpad feature be enabled ?
|
||||||
|
enabled: true
|
||||||
|
# Launch power for launchpad (max 4.0)
|
||||||
|
launch_power: 3.0
|
||||||
|
launch_power_y: 1.0
|
||||||
|
# Top and bottom block required to make a launchpad
|
||||||
|
top_block: STONE_PRESSURE_PLATE
|
||||||
|
bottom_block: REDSTONE_BLOCK
|
||||||
|
# Actions executed upon use of a launchpad
|
||||||
|
actions:
|
||||||
|
- '[SOUND] entity.bat.takeoff'
|
||||||
|
# Effect settings
|
||||||
|
particle: "CLOUD"
|
||||||
|
particle_count: 15
|
||||||
|
sound: "ENTITY_BAT_TAKEOFF"
|
||||||
|
sound_volume: 1.0
|
||||||
|
sound_pitch: 1.0
|
||||||
|
trail:
|
||||||
|
enabled: true
|
||||||
|
particle: "CLOUD"
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | DOUBLE JUMP |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
double_jump:
|
||||||
|
# Should the double jump feature be enabled?
|
||||||
|
enabled: true
|
||||||
|
# Launch power for double jump (max 4.0)
|
||||||
|
launch_power: 1.0
|
||||||
|
launch_power_y: 0.9
|
||||||
|
# Cooldown time in seconds (0 to disable)
|
||||||
|
cooldown: 3
|
||||||
|
# Actions executed upon use of double jump
|
||||||
|
actions:
|
||||||
|
- '[SOUND] entity.bat.takeoff'
|
||||||
|
# Effect settings
|
||||||
|
particle: "CLOUD"
|
||||||
|
particle_count: 15
|
||||||
|
sound: "ENTITY_BAT_TAKEOFF"
|
||||||
|
sound_volume: 1.0
|
||||||
|
sound_pitch: 1.0
|
||||||
|
trail:
|
||||||
|
enabled: true
|
||||||
|
particle: "CLOUD"
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | CHAT MANAGEMENT |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | WORLD EVENT SETTINGS |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
world_settings:
|
||||||
|
# Player
|
||||||
|
disable_hunger_loss: true
|
||||||
|
disable_fall_damage: true
|
||||||
|
disable_player_pvp: true
|
||||||
|
disable_void_death: true
|
||||||
|
disable_fire_damage: true
|
||||||
|
disable_drowning: true
|
||||||
|
disable_off_hand_swap: true # Requires 1.9+
|
||||||
|
hide_potion_icons: false
|
||||||
|
# Misc
|
||||||
|
disable_weather_change: true
|
||||||
|
disable_death_message: true
|
||||||
|
disable_mob_spawning: true
|
||||||
|
# Item entities
|
||||||
|
disable_item_drop: true
|
||||||
|
disable_item_pickup: true
|
||||||
|
# Blocks
|
||||||
|
disable_block_break: true
|
||||||
|
disable_block_place: true
|
||||||
|
disable_block_interact: true # Chest, furnace, crop tample, etc
|
||||||
|
disable_block_burn: true
|
||||||
|
disable_block_fire_spread: true
|
||||||
|
disable_block_leaf_decay: true
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | PLAYER JOIN EVENT |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
join_leave_messages:
|
||||||
|
# Should VexlioHub handle join/quit messages?
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Set to '' if you want silent join/quit messages
|
||||||
|
join_message: "&2&l+ &6%player% &7Connected"
|
||||||
|
quit_message: "&4&l- &6%player% &7Disconnected"
|
||||||
|
|
||||||
|
# Actions executed upon join
|
||||||
|
join_events:
|
||||||
|
- "[MESSAGE] &8&m+---------------***---------------+"
|
||||||
|
- "[MESSAGE] &r"
|
||||||
|
- "[MESSAGE] &r &7Welcome, &b&n%player%&r &7to the server"
|
||||||
|
- "[MESSAGE] &r"
|
||||||
|
- "[MESSAGE] &r &2&lWEBSITE &fwww.examplemc.net"
|
||||||
|
- "[MESSAGE] &r &3&lSTORE &fstore.examplemc.net"
|
||||||
|
- "[MESSAGE] &r &9&lDISCORD &fdiscord.examplemc.net"
|
||||||
|
- "[MESSAGE] &r"
|
||||||
|
- "[MESSAGE] &r &7&oPowered By <gradient:#9333EA:#06B6D4><bold>VexlioHub</bold></gradient>"
|
||||||
|
- "[MESSAGE] &8&m+---------------***---------------+"
|
||||||
|
- "[TITLE] &b&lWELCOME;&f%player%;1;2;1"
|
||||||
|
- "[SOUND] entity.player.levelup"
|
||||||
|
- "[GAMEMODE] survival"
|
||||||
|
- "[EFFECT] SPEED;1"
|
||||||
|
|
||||||
|
join_settings:
|
||||||
|
# Should we teleport the player to the spawn point (if set) on join?
|
||||||
|
spawn_join: true
|
||||||
|
# Should we heal the player?
|
||||||
|
heal: true
|
||||||
|
# Should we extinguish the player?
|
||||||
|
extinguish: true
|
||||||
|
# Should we clear their inventory?
|
||||||
|
clear_inventory: false
|
||||||
|
# Spawn a firework on join
|
||||||
|
firework:
|
||||||
|
# Should we send a firework on join?
|
||||||
|
enabled: true
|
||||||
|
# Should we only send the firework on their first join?
|
||||||
|
first_join_only: true
|
||||||
|
|
||||||
|
type: BALL_LARGE
|
||||||
|
power: 1
|
||||||
|
flicker: true
|
||||||
|
trail: true
|
||||||
|
colors:
|
||||||
|
- AQUA
|
||||||
|
- RED
|
||||||
|
- TEAL
|
||||||
|
- WHITE
|
||||||
|
|
||||||
|
hotbar:
|
||||||
|
joinslot: true
|
||||||
|
slot_number: 4 # Slot which is selected at join 0-8
|
||||||
|
|
||||||
|
custom_join_items:
|
||||||
|
# Should custom join items be enabled?
|
||||||
|
enabled: true
|
||||||
|
# Should we prevent them from moving/dropping the items?
|
||||||
|
disable_inventory_movement: true
|
||||||
|
|
||||||
|
items:
|
||||||
|
infobook:
|
||||||
|
material: BOOK
|
||||||
|
amount: 1
|
||||||
|
slot: 0
|
||||||
|
display_name: "&dServer Information"
|
||||||
|
lore:
|
||||||
|
- "&7Right-click to see information about the server!"
|
||||||
|
actions:
|
||||||
|
- "[MESSAGE] &r"
|
||||||
|
- "[MESSAGE] &e&lServer Information"
|
||||||
|
- "[MESSAGE] &r"
|
||||||
|
- "[MESSAGE] &bWebsite: &fwww.examplemc.net"
|
||||||
|
- "[MESSAGE] &cStore: &fbuy.examplemc.net"
|
||||||
|
- "[MESSAGE] &dDiscord: &fdiscord.examplemc.net"
|
||||||
|
- "[MESSAGE] &r"
|
||||||
|
server_selector:
|
||||||
|
material: NETHER_STAR
|
||||||
|
amount: 1
|
||||||
|
slot: 4
|
||||||
|
display_name: "{#9863E7}Server Selector{/#545eb6}"
|
||||||
|
lore:
|
||||||
|
- "&7Right-click to open the server selector!"
|
||||||
|
actions:
|
||||||
|
- "[MENU] serverselector"
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | PLAYER HIDER |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
player_hider:
|
||||||
|
# Should the player hider feature be enabled?
|
||||||
|
enabled: true
|
||||||
|
# Slot the item should be given to?
|
||||||
|
slot: 8
|
||||||
|
# Should we prevent them from moving/dropping the item?
|
||||||
|
disable_inventory_movement: true
|
||||||
|
# Cooldown in seconds
|
||||||
|
# Set to 0 to disable
|
||||||
|
cooldown: 3
|
||||||
|
|
||||||
|
not_hidden:
|
||||||
|
material: LIME_DYE
|
||||||
|
amount: 1
|
||||||
|
display_name: '&dPlayers &8&l> &aShown &7(Right-Click)'
|
||||||
|
lore:
|
||||||
|
- '&7Click to hide all players!'
|
||||||
|
|
||||||
|
hidden:
|
||||||
|
material: GRAY_DYE
|
||||||
|
amount: 1
|
||||||
|
display_name: '&dPlayers &8&l> &cHidden &7(Right-Click)'
|
||||||
|
lore:
|
||||||
|
- '&7Click to show all players!'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | LEGACY SYSTEMS |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
legacySystems:
|
||||||
|
# Should we use the new lobby permission system?
|
||||||
|
# If this is disabled build, destroy, interact, pvp, pickup and drop will be only possible in the build mode instead all the time as a admin
|
||||||
|
# If this is enabled, the old system will be used (permission based https://strafbefehl.github.io/DeluxeHubReloadedDocs/goodtoknow/worldprotection)
|
||||||
|
permissionsEnabled: false
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | ACTIONBAR ANNOUNCEMENTS |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
actionbar_announcements:
|
||||||
|
enabled: true
|
||||||
|
# Interval in ticks (20 ticks = 1 second)
|
||||||
|
interval: 200
|
||||||
|
messages:
|
||||||
|
- "<gradient:#9333EA:#06B6D4><bold>VexlioHub</bold></gradient> &8❙ &7Vítejte na našem serveru!"
|
||||||
|
- "<gradient:#9333EA:#06B6D4><bold>Website</bold></gradient> &8❙ &fwww.vexliomc.net"
|
||||||
|
- "<gradient:#9333EA:#06B6D4><bold>Store</bold></gradient> &8❙ &fstore.vexliomc.net &7(50% SLEVA!)"
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | WELCOME TITLE ANIMATION |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
join_title:
|
||||||
|
enabled: true
|
||||||
|
title: "<gradient:#9333EA:#06B6D4><bold>VEXLIOHUB</bold></gradient>"
|
||||||
|
subtitle: "&7Vítej, &f%player% &7na lobby serveru!"
|
||||||
|
fadeIn: 20
|
||||||
|
stay: 60
|
||||||
|
fadeOut: 20
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
version: 3.7.0
|
||||||
|
chat_locked: false
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# PLUGIN MESSAGES
|
||||||
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
version: 3.7.0
|
||||||
|
Messages:
|
||||||
|
GENERAL:
|
||||||
|
PREFIX: "<gradient:#9333EA:#06B6D4><bold>VexlioHub</bold></gradient> &8❙"
|
||||||
|
NO_PERMISSION: "%prefix% &cYou are forbidden to use this."
|
||||||
|
CUSTOM_COMMAND_NO_PERMISSION: "&cYou are not allowed to execute this command."
|
||||||
|
INVALID_PLAYER: "%prefix% &c%player% is not online!"
|
||||||
|
CONFIG_RELOAD: "%prefix% &aAll configuration files has been reloaded in &7%time%ms"
|
||||||
|
COOLDOWN_ACTIVE: "%prefix% &cYou must wait &e%time%s &cbefore doing this again!"
|
||||||
|
|
||||||
|
GAMEMODE:
|
||||||
|
GAMEMODE_CHANGE: "%prefix% &7You have changed gamemode to &a%gamemode%"
|
||||||
|
GAMEMODE_CHANGE_OTHER: "%prefix% &7You have changed gamemode to &a%gamemode% &7for &e%player%"
|
||||||
|
GAMEMODE_INVALID: "%prefix% &e%gamemode% &cis not a valid gamemode"
|
||||||
|
|
||||||
|
FLIGHT:
|
||||||
|
ENABLE: "%prefix% &aYou have enabled flight"
|
||||||
|
DISABLE: "%prefix% &cYou have disabled flight"
|
||||||
|
ENABLE_OTHER: "%prefix% &cYou have enabled flight for &7%player%"
|
||||||
|
DISABLE_OTHER: "%prefix% &cYou have disabled flight for &7%player%"
|
||||||
|
|
||||||
|
PLAYER_HIDER:
|
||||||
|
HIDDEN: "%prefix% &cPlayer visibility disabled"
|
||||||
|
SHOWN: "%prefix% &aPlayer visibility enabled"
|
||||||
|
|
||||||
|
LOBBY:
|
||||||
|
SET_LOBBY: "%prefix% &aYou have successfully set the lobby spawn point"
|
||||||
|
|
||||||
|
CHAT:
|
||||||
|
CLEARCHAT: "&b&l* &fChat has been cleared by &e%player% &b&l*"
|
||||||
|
CLEARCHAT_PLAYER: "&cYour chat has been cleared by an administrator."
|
||||||
|
|
||||||
|
WORLD_EVENT_MODIFICATIONS:
|
||||||
|
ITEM_DROP: "%prefix% &cYou are not allowed to drop items."
|
||||||
|
ITEM_PICKUP: "%prefix% &cYou are not allowed to pickup items."
|
||||||
|
BLOCK_PLACE: "%prefix% &cYou are not allowed to place blocks."
|
||||||
|
BLOCK_BREAK: "%prefix% &cYou are not allowed to break blocks."
|
||||||
|
BLOCK_INTERACT: "%prefix% &cYou are not allowed to use this."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
BUILD_MODE:
|
||||||
|
ENABLED_ACTION_BAR: "<gradient:#9333EA:#06B6D4><bold>VexlioHub</bold></gradient> &7 | &fBuild mode &a&lenabled&7. Use &b/buildmode &fto leave."
|
||||||
|
ENABLED: "%prefix% &7Build mode has been &a&lenabled&7."
|
||||||
|
DISABLED: "%prefix% &7Build mode has been &c&ldisabled&7."
|
||||||
|
TARGET_NOT_FOUND: "%prefix% &cTarget \"%target%\" not found."
|
||||||
|
ENABLED_FOR_TARGET: "%prefix% &7Build mode has been &a&lenabled&7 for target &b&l%target%&7."
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
name: ${name}
|
||||||
|
version: '${version}'
|
||||||
|
main: eu.milujukockoholky.vexliolobby.VexlioHubPlugin
|
||||||
|
description: ${description}
|
||||||
|
authors: ["tp3x"]
|
||||||
|
website: ${url}
|
||||||
|
api-version: '26.1'
|
||||||
|
|
||||||
|
dependencies:
|
||||||
|
server:
|
||||||
|
Essentials:
|
||||||
|
load: AFTER
|
||||||
|
required: false
|
||||||
|
join-classpath: false
|
||||||
|
PlaceholderAPI:
|
||||||
|
load: BEFORE
|
||||||
|
required: false
|
||||||
|
join-classpath: true
|
||||||
|
HeadDatabase:
|
||||||
|
load: BEFORE
|
||||||
|
required: false
|
||||||
|
join-classpath: true
|
||||||
|
Multiverse-Core:
|
||||||
|
load: BEFORE
|
||||||
|
required: false
|
||||||
|
join-classpath: false
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
vexliolobby.*:
|
||||||
|
description: Gives access to all VexlioHub permissions
|
||||||
|
children:
|
||||||
|
vexliolobby.command.*: true
|
||||||
|
vexliolobby.bypass.*: true
|
||||||
|
vexliolobby.alert.*: true
|
||||||
|
vexliolobby.item.*: true
|
||||||
|
vexliolobby.player.*: true
|
||||||
|
vexliolobby.block.*: true
|
||||||
|
vexliolobby.command.*:
|
||||||
|
description: Gives access to all command permissions
|
||||||
|
children:
|
||||||
|
vexliolobby.command.help: true
|
||||||
|
vexliolobby.command.reload: true
|
||||||
|
vexliolobby.command.openmenu: true
|
||||||
|
vexliolobby.command.gamemode: true
|
||||||
|
vexliolobby.command.gamemode.others: true
|
||||||
|
vexliolobby.command.clearchat: true
|
||||||
|
vexliolobby.command.fly: true
|
||||||
|
vexliolobby.command.fly.others: true
|
||||||
|
vexliolobby.command.setlobby: true
|
||||||
|
vexliolobby.bypass.*:
|
||||||
|
description: Gives access to all bypass permissions
|
||||||
|
children:
|
||||||
|
vexliolobby.bypass.commands: true
|
||||||
|
vexliolobby.bypass.doublejump: false
|
||||||
|
vexliolobby.alert.*:
|
||||||
|
description: Gives access to all alert permissions
|
||||||
|
children: {}
|
||||||
|
vexliolobby.item.*:
|
||||||
|
description: Gives access to all item based permissions
|
||||||
|
children:
|
||||||
|
vexliolobby.item.drop: true
|
||||||
|
vexliolobby.item.pickup: true
|
||||||
|
vexliolobby.player.*:
|
||||||
|
description: Gives access to all player based permissions
|
||||||
|
children: {}
|
||||||
|
vexliolobby.block.*:
|
||||||
|
description: Gives access to all block based permissions
|
||||||
|
children:
|
||||||
|
vexliolobby.block.break: true
|
||||||
|
vexliolobby.block.place: true
|
||||||
|
vexliolobby.block.interact: true
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
name: ${name}
|
||||||
|
authors: ["tp3x"]
|
||||||
|
version: ${version}
|
||||||
|
description: ${description}
|
||||||
|
website: ${url}
|
||||||
|
api-version: 26.1
|
||||||
|
main: eu.milujukockoholky.vexliolobby.VexlioHubPlugin
|
||||||
|
loadbefore: [Essentials]
|
||||||
|
softdepend: [PlaceholderAPI, HeadDatabase, Multiverse-Core]
|
||||||
|
permissions:
|
||||||
|
vexliolobby.*:
|
||||||
|
description: Gives access to all VexlioHub permissions
|
||||||
|
children:
|
||||||
|
vexliolobby.command.*: true
|
||||||
|
vexliolobby.bypass.*: true
|
||||||
|
vexliolobby.alert.*: true
|
||||||
|
vexliolobby.item.*: true
|
||||||
|
vexliolobby.player.*: true
|
||||||
|
vexliolobby.block.*: true
|
||||||
|
vexliolobby.command.*:
|
||||||
|
description: Gives access to all command permissions
|
||||||
|
children:
|
||||||
|
vexliolobby.command.help: true
|
||||||
|
vexliolobby.command.reload: true
|
||||||
|
vexliolobby.command.openmenu: true
|
||||||
|
vexliolobby.command.gamemode: true
|
||||||
|
vexliolobby.command.gamemode.others: true
|
||||||
|
vexliolobby.command.clearchat: true
|
||||||
|
vexliolobby.command.fly: true
|
||||||
|
vexliolobby.command.fly.others: true
|
||||||
|
vexliolobby.command.setlobby: true
|
||||||
|
vexliolobby.bypass.*:
|
||||||
|
description: Gives access to all bypass permissions
|
||||||
|
children:
|
||||||
|
vexliolobby.bypass.commands: true
|
||||||
|
vexliolobby.bypass.doublejump: false
|
||||||
|
vexliolobby.alert.*:
|
||||||
|
description: Gives access to all alert permissions
|
||||||
|
children: {}
|
||||||
|
vexliolobby.item.*:
|
||||||
|
description: Gives access to all item based permissions
|
||||||
|
children:
|
||||||
|
vexliolobby.item.drop: true
|
||||||
|
vexliolobby.item.pickup: true
|
||||||
|
vexliolobby.player.*:
|
||||||
|
description: Gives access to all player based permissions
|
||||||
|
children: {}
|
||||||
|
vexliolobby.block.*:
|
||||||
|
description: Gives access to all block based permissions
|
||||||
|
children:
|
||||||
|
vexliolobby.block.break: true
|
||||||
|
vexliolobby.block.place: true
|
||||||
|
vexliolobby.block.interact: true
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
# Server Selector GUI
|
||||||
|
# The ID of this inventory is 'serverselector' which you can open using the [MENU] action (e.g. "[MENU] serverselector").
|
||||||
|
# You can create more custom GUIs, just copy this entire file and paste a new one in the menus directory. The name of the file is the menu ID.
|
||||||
|
#
|
||||||
|
# PLAYER HEADS
|
||||||
|
# You can have player heads, using player names, base64 or HeadDatabase IDs.
|
||||||
|
# Examples
|
||||||
|
# Username (must have logged into the server once)
|
||||||
|
# material: PLAYER_HEAD
|
||||||
|
# username: <name>
|
||||||
|
#
|
||||||
|
# Base64
|
||||||
|
# material: PLAYER_HEAD
|
||||||
|
# base64: <base64 id>
|
||||||
|
#
|
||||||
|
# HeadDatabase
|
||||||
|
# material: PLAYER_HEAD
|
||||||
|
# hdb: <hdb id>
|
||||||
|
#
|
||||||
|
# ITEM FLAGS
|
||||||
|
# You can add flags to the item (https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/ItemFlag.html)
|
||||||
|
# Example:
|
||||||
|
# item_flags:
|
||||||
|
# - HIDE_ATTRIBUTES
|
||||||
|
# - HIDE_DESTROYS
|
||||||
|
# - HIDE_ENCHANTS
|
||||||
|
# - HIDE_PLACED_ON
|
||||||
|
# - HIDE_POTION_EFFECTS
|
||||||
|
# - HIDE_UNBREAKABLE
|
||||||
|
#
|
||||||
|
# ITEM ACTIONS
|
||||||
|
version: 3.7.0
|
||||||
|
|
||||||
|
# Slots of the GUI
|
||||||
|
slots: 27
|
||||||
|
|
||||||
|
# Title of the GUI
|
||||||
|
title: "Server Selector"
|
||||||
|
|
||||||
|
# Automatically update open inventories.
|
||||||
|
# This can be used to update placeholders in the GUI.
|
||||||
|
refresh:
|
||||||
|
enabled: false
|
||||||
|
rate: 40
|
||||||
|
|
||||||
|
# The items inside the GUI can be listed here
|
||||||
|
items:
|
||||||
|
filler:
|
||||||
|
material: GRAY_STAINED_GLASS_PANE
|
||||||
|
slot: -1 # Setting the slot to -1 will fill every empty slot, you can also do "slots: [0, 1, 2]"
|
||||||
|
factions:
|
||||||
|
material: TNT
|
||||||
|
slot: 11
|
||||||
|
amount: 1
|
||||||
|
glow: true
|
||||||
|
display_name: '&eFactions'
|
||||||
|
lore:
|
||||||
|
- '&7Join now!'
|
||||||
|
- '&aPlaceholderAPI support!'
|
||||||
|
actions:
|
||||||
|
- '[CLOSE]'
|
||||||
|
- '[MESSAGE] &7Sending you to: &eFactions'
|
||||||
|
- '[PROXY] factions'
|
||||||
|
# For multi-world servers using Multiverse-Core, use the action:
|
||||||
|
# - '[COMMAND] mvtp world'
|
||||||
|
survival:
|
||||||
|
material: GRASS_BLOCK
|
||||||
|
slot: 15
|
||||||
|
amount: 1
|
||||||
|
glow: false
|
||||||
|
display_name: '&aSurvival'
|
||||||
|
lore:
|
||||||
|
- '&7Join now!'
|
||||||
|
- '&aMulti lore support too!'
|
||||||
|
actions:
|
||||||
|
- '[CLOSE]'
|
||||||
|
- '[MESSAGE] &7Sending you to: &eSurvival'
|
||||||
|
- '[PROXY] survival'
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | VLASTNÍ PŘÍKAZY (CUSTOM COMMANDS) |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# Pro úpravu těchto příkazů není nutný restart serveru.
|
||||||
|
|
||||||
|
version: 3.7.0
|
||||||
|
|
||||||
|
custom_commands:
|
||||||
|
# Název příkazu (hlavní příkaz)
|
||||||
|
website:
|
||||||
|
# Aliasy pro příkaz
|
||||||
|
aliases:
|
||||||
|
- web
|
||||||
|
# Akce, které se mají provést
|
||||||
|
actions:
|
||||||
|
- '[MESSAGE] <gradient:#9333EA:#06B6D4><bold>Web</bold></gradient> &8❙ &fwww.vexliomc.net'
|
||||||
|
|
||||||
|
clearinventory:
|
||||||
|
# Hráči budou k provedení příkazu potřebovat toto oprávnění.
|
||||||
|
permission: vexliolobby.clearinventory
|
||||||
|
aliases:
|
||||||
|
- ci
|
||||||
|
actions:
|
||||||
|
- '[COMMAND] minecraft:clear'
|
||||||
|
- '[MESSAGE] %prefix% &7Tvůj inventář byl úspěšně vymazán.'
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | VEXLIOHUB PŘÍKAZY |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# Při úpravě níže uvedených příkazů doporučujeme restartovat server.
|
||||||
|
|
||||||
|
commands:
|
||||||
|
gamemode:
|
||||||
|
enabled: true
|
||||||
|
aliases:
|
||||||
|
- gm
|
||||||
|
gms:
|
||||||
|
enabled: true
|
||||||
|
gmc:
|
||||||
|
enabled: true
|
||||||
|
gma:
|
||||||
|
enabled: true
|
||||||
|
gmsp:
|
||||||
|
enabled: true
|
||||||
|
clearchat:
|
||||||
|
enabled: true
|
||||||
|
fly:
|
||||||
|
enabled: true
|
||||||
|
setlobby:
|
||||||
|
enabled: true
|
||||||
|
lobby:
|
||||||
|
enabled: true
|
||||||
|
buildmode:
|
||||||
|
enabled: true
|
||||||
|
aliases:
|
||||||
|
- build
|
||||||
@@ -0,0 +1,289 @@
|
|||||||
|
# ··························································································
|
||||||
|
# : ____ _ _ _ _ ____ _ _ _ :
|
||||||
|
# :| _ \ ___| |_ ___ _____| | | |_ _| |__ | _ \ ___| | ___ __ _ __| | ___ __| |:
|
||||||
|
# :| | | |/ _ \ | | | \ \/ / _ \ |_| | | | | '_ \| |_) / _ \ |/ _ \ / _` |/ _` |/ _ \/ _` |:
|
||||||
|
# :| |_| | __/ | |_| |> < __/ _ | |_| | |_) | _ < __/ | (_) | (_| | (_| | __/ (_| |:
|
||||||
|
# :|____/ \___|_|\__,_/_/\_\___|_| |_|\__,_|_.__/|_| \_\___|_|\___/ \__,_|\__,_|\___|\__,_|:
|
||||||
|
# ··························································································
|
||||||
|
# AUTOR: tp3x & Strafbefehl
|
||||||
|
# Verze VexlioHub pro Lobby
|
||||||
|
# --------
|
||||||
|
# AKCE:
|
||||||
|
#
|
||||||
|
# [MESSAGE] - Pošle zprávu hráči
|
||||||
|
# [BROADCAST] - Pošle zprávu všem hráčům
|
||||||
|
# [TITLE] např. HlavniTitle;Subtitle;FadeIn;Stay;FadeOut - Pošle title zprávu hráči
|
||||||
|
# [ACTIONBAR] Pošle actionbar zprávu hráči
|
||||||
|
# [SOUND] - Spustí zvuk pro hráče
|
||||||
|
# [COMMAND] - Spustí příkaz jako hráč
|
||||||
|
# [CONSOLE] - Spustí příkaz jako konzole
|
||||||
|
# [GAMEMODE] - Změní herní mód hráče
|
||||||
|
# [PROXY] - Pošle hráče na jiný bungeecord server
|
||||||
|
# [EFFECT] např. EFFECT;LEVEL - Udělí hráči efekt lektvaru
|
||||||
|
# [MENU] - Otevře menu ze složky plugins/VexlioHub/menus
|
||||||
|
# [CLOSE] - Zavře otevřené menu hráče
|
||||||
|
# --------
|
||||||
|
# FORMÁTOVÁNÍ ZPRÁV:
|
||||||
|
# HEX barvy: {#FFFFFF} a pro Přechody (Gradienty) <gradient:#9333EA:#06B6D4><bold>TEXT</bold></gradient>
|
||||||
|
# <center> Vycentrovaná zpráva </center> - Vycentruje zprávu v chatu
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | OBECNÁ NASTAVENÍ |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
version: 3.7.0
|
||||||
|
|
||||||
|
# Pokud používáte více světů, nastavte na true
|
||||||
|
multiple_worlds: false
|
||||||
|
|
||||||
|
# Zakázané světy
|
||||||
|
disabled-worlds:
|
||||||
|
# Máme seznam brát jako whitelist namísto blacklistu?
|
||||||
|
invert: false
|
||||||
|
# Seznam zakázaných světů
|
||||||
|
worlds:
|
||||||
|
- world_nether
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | STAVEBNÍ REŽIM |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
build_mode:
|
||||||
|
# Zobrazit actionbar zprávu při zapnutém stavebním režimu?
|
||||||
|
use_actionbar_message: true
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | STATICKÝ ČAS |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
static_time:
|
||||||
|
# Aktivovat statický čas?
|
||||||
|
enabled: false
|
||||||
|
|
||||||
|
# Čas, který bude trvale nastaven v lobby světě
|
||||||
|
time: 12000
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | LAUNCHPAD |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
launchpad:
|
||||||
|
# Aktivovat odrazové plošiny?
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Síla odhozu (max 4.0)
|
||||||
|
launch_power: 3.0
|
||||||
|
launch_power_y: 1.0
|
||||||
|
|
||||||
|
# Horní a dolní blok potřebný pro fungování plošiny
|
||||||
|
top_block: STONE_PRESSURE_PLATE
|
||||||
|
bottom_block: REDSTONE_BLOCK
|
||||||
|
|
||||||
|
# Akce spuštěné při použití plošiny
|
||||||
|
actions:
|
||||||
|
- '[SOUND] entity.bat.takeoff'
|
||||||
|
|
||||||
|
# Nastavení efektů plošiny
|
||||||
|
particle: CLOUD
|
||||||
|
particle_count: 15
|
||||||
|
sound: ENTITY_BAT_TAKEOFF
|
||||||
|
sound_volume: 1.0
|
||||||
|
sound_pitch: 1.0
|
||||||
|
trail:
|
||||||
|
enabled: true
|
||||||
|
particle: CLOUD
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | DOUBLE JUMP |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
double_jump:
|
||||||
|
# Aktivovat dvojitý skok?
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Síla odhozu (max 4.0)
|
||||||
|
launch_power: 1.0
|
||||||
|
launch_power_y: 0.9
|
||||||
|
|
||||||
|
# Cooldown v sekundách (0 pro vypnutí)
|
||||||
|
cooldown: 3
|
||||||
|
|
||||||
|
# Akce spuštěné při použití dvojitého skoku
|
||||||
|
actions:
|
||||||
|
- '[SOUND] entity.bat.takeoff'
|
||||||
|
|
||||||
|
# Nastavení efektů dvojitého skoku
|
||||||
|
particle: CLOUD
|
||||||
|
particle_count: 15
|
||||||
|
sound: ENTITY_BAT_TAKEOFF
|
||||||
|
sound_volume: 1.0
|
||||||
|
sound_pitch: 1.0
|
||||||
|
trail:
|
||||||
|
enabled: true
|
||||||
|
particle: CLOUD
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | NASTAVENÍ SVĚTA & OCHRANY |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
world_settings:
|
||||||
|
# Nastavení pro hráče
|
||||||
|
disable_hunger_loss: true
|
||||||
|
disable_fall_damage: true
|
||||||
|
disable_player_pvp: true
|
||||||
|
disable_void_death: true
|
||||||
|
disable_fire_damage: true
|
||||||
|
disable_drowning: true
|
||||||
|
disable_off_hand_swap: true # Vyžaduje verzi 1.9+
|
||||||
|
hide_potion_icons: false
|
||||||
|
|
||||||
|
# Různé
|
||||||
|
disable_weather_change: true
|
||||||
|
disable_death_message: true
|
||||||
|
disable_mob_spawning: true
|
||||||
|
|
||||||
|
# Dropování a sbírání
|
||||||
|
disable_item_drop: true
|
||||||
|
disable_item_pickup: true
|
||||||
|
|
||||||
|
# Bloky
|
||||||
|
disable_block_break: true
|
||||||
|
disable_block_place: true
|
||||||
|
disable_block_interact: true # Truhly, pece atd.
|
||||||
|
disable_block_burn: true
|
||||||
|
disable_block_fire_spread: true
|
||||||
|
disable_block_leaf_decay: true
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | EVENTY PŘI PŘIPOJENÍ |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
join_leave_messages:
|
||||||
|
# Má plugin spravovat připojovací/odpojovací zprávy?
|
||||||
|
enabled: true
|
||||||
|
|
||||||
|
# Nastavte na '' pro tiché připojení/odpojení
|
||||||
|
join_message: '<gradient:#9333EA:#06B6D4><bold>»</bold></gradient> &f%player% &7se připojil na lobby.'
|
||||||
|
quit_message: '<gradient:#9333EA:#06B6D4><bold>«</bold></gradient> &f%player% &7se odpojil z lobby.'
|
||||||
|
|
||||||
|
# Akce spuštěné při připojení hráče
|
||||||
|
join_events:
|
||||||
|
- '[CONSOLE] cp welcome %player_name%'
|
||||||
|
- '[GAMEMODE] survival'
|
||||||
|
- '[EFFECT] SPEED;1'
|
||||||
|
|
||||||
|
join_settings:
|
||||||
|
# Teleportovat hráče na spawn při připojení?
|
||||||
|
spawn_join: true
|
||||||
|
# Vyléčit hráče?
|
||||||
|
heal: true
|
||||||
|
# Uhasit hráče?
|
||||||
|
extinguish: true
|
||||||
|
# Vymazat inventář hráče?
|
||||||
|
clear_inventory: false
|
||||||
|
# Ohňostroj při připojení
|
||||||
|
firework:
|
||||||
|
# Má se spawnovat ohňostroj?
|
||||||
|
enabled: true
|
||||||
|
# Pouze při prvním připojení?
|
||||||
|
first_join_only: true
|
||||||
|
|
||||||
|
type: BALL_LARGE
|
||||||
|
power: 1
|
||||||
|
flicker: true
|
||||||
|
trail: true
|
||||||
|
colors:
|
||||||
|
- AQUA
|
||||||
|
- RED
|
||||||
|
- TEAL
|
||||||
|
- WHITE
|
||||||
|
|
||||||
|
hotbar:
|
||||||
|
joinslot: true
|
||||||
|
slot_number: 4 # Vybraný slot při připojení (0-8)
|
||||||
|
|
||||||
|
custom_join_items:
|
||||||
|
# Aktivovat vlastní připojovací předměty?
|
||||||
|
enabled: true
|
||||||
|
# Zabránit hráčům v přesouvání a vyhazování předmětů?
|
||||||
|
disable_inventory_movement: true
|
||||||
|
|
||||||
|
items:
|
||||||
|
server_selector:
|
||||||
|
material: FEATHER
|
||||||
|
amount: 1
|
||||||
|
slot: 0
|
||||||
|
custom_model_data: 1337
|
||||||
|
display_name: '<gradient:#9333EA:#06B6D4><bold>Výběr Serverů</bold></gradient>'
|
||||||
|
lore:
|
||||||
|
- '&7Kliknutím otevřeš výběr serverů!'
|
||||||
|
actions:
|
||||||
|
- '[MENU] casual_server'
|
||||||
|
- '[SOUND] block.sniffer.egg.plop'
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | SKRÝVÁNÍ HRÁČŮ |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
player_hider:
|
||||||
|
# Aktivovat skrývání hráčů?
|
||||||
|
enabled: true
|
||||||
|
# Slot pro předmět v hotbaru?
|
||||||
|
slot: 1
|
||||||
|
# Zabránit přesouvání a vyhazování předmětu?
|
||||||
|
disable_inventory_movement: true
|
||||||
|
# Cooldown v sekundách (0 pro vypnutí)
|
||||||
|
cooldown: 0
|
||||||
|
|
||||||
|
not_hidden:
|
||||||
|
material: FEATHER
|
||||||
|
hide_tooltip: true
|
||||||
|
custom_model_data: 5001
|
||||||
|
amount: 1
|
||||||
|
display_name: '<gradient:#9333EA:#06B6D4><bold>Skrýt Hráče</bold></gradient>'
|
||||||
|
lore:
|
||||||
|
- '&7Kliknutím skryješ všechny hráče.'
|
||||||
|
|
||||||
|
hidden:
|
||||||
|
material: FEATHER
|
||||||
|
hide_tooltip: true
|
||||||
|
custom_model_data: 5002
|
||||||
|
amount: 1
|
||||||
|
display_name: '<gradient:#9333EA:#06B6D4><bold>Zobrazit Hráče</bold></gradient>'
|
||||||
|
lore:
|
||||||
|
- '&7Kliknutím zobrazíš všechny hráče.'
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | OSTATNÍ SYSTÉMY |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
legacySystems:
|
||||||
|
# Má se použít starý lobby permission systém?
|
||||||
|
permissionsEnabled: false
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | OZNÁMENÍ V ACTIONBARU |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
actionbar_announcements:
|
||||||
|
# Aktivovat automatická oznámení v actionbaru?
|
||||||
|
enabled: true
|
||||||
|
# Interval v ticích (20 tiků = 1 sekunda)
|
||||||
|
interval: 200
|
||||||
|
messages:
|
||||||
|
- '<gradient:#9333EA:#06B6D4><bold>VexlioHub</bold></gradient> &8❙ &fVítejte na našem serveru!'
|
||||||
|
- '<gradient:#9333EA:#06B6D4><bold>Discord</bold></gradient> &8❙ &fdiscord.vexliomc.net'
|
||||||
|
- '<gradient:#9333EA:#06B6D4><bold>Obchod</bold></gradient> &8❙ &fstore.vexliomc.net'
|
||||||
|
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | UVÍTACÍ TITLE ANIMACE |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
join_title:
|
||||||
|
# Zobrazit uvítací title zprávu při připojení?
|
||||||
|
enabled: true
|
||||||
|
title: '<gradient:#9333EA:#06B6D4><bold>VEXLIOHUB</bold></gradient>'
|
||||||
|
subtitle: '&7Vítej, &f%player% &7na lobby serveru!'
|
||||||
|
fadeIn: 20
|
||||||
|
stay: 60
|
||||||
|
fadeOut: 20
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
version: 3.7.0
|
||||||
|
spawn:
|
||||||
|
==: org.bukkit.Location
|
||||||
|
world_key: minecraft:overworld
|
||||||
|
x: 2009.4762993366098
|
||||||
|
y: 209.0625
|
||||||
|
z: 1993.5852924372634
|
||||||
|
pitch: -1.0203131
|
||||||
|
yaw: 179.52112
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
# | ZPRÁVY PLUGINU (MESSAGES) |
|
||||||
|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~#
|
||||||
|
|
||||||
|
version: 3.7.0
|
||||||
|
|
||||||
|
Messages:
|
||||||
|
GENERAL:
|
||||||
|
# Prefix, který se bude zobrazovat před většinou zpráv.
|
||||||
|
PREFIX: '<gradient:#9333EA:#06B6D4><bold>VexlioHub</bold></gradient> &8❙'
|
||||||
|
# Zpráva, pokud hráč nemá oprávnění k příkazu.
|
||||||
|
NO_PERMISSION: '%prefix% &cNa tento příkaz nemáš dostatečná oprávnění!'
|
||||||
|
# Zpráva, pokud hráč nemá oprávnění k vlastnímu příkazu.
|
||||||
|
CUSTOM_COMMAND_NO_PERMISSION: '&cK tomuto příkazu nemáš přístup!'
|
||||||
|
# Zpráva, pokud zadaný hráč není online.
|
||||||
|
INVALID_PLAYER: '%prefix% &cHráč &e%player% &cnení online!'
|
||||||
|
# Zpráva o úspěšném načtení konfigurací.
|
||||||
|
CONFIG_RELOAD: '%prefix% &aVšechny konfigurace byly úspěšně načteny za &7%time%ms&a.'
|
||||||
|
# Zpráva, pokud je na akce nastaven cooldown.
|
||||||
|
COOLDOWN_ACTIVE: '%prefix% &cMusíš počkat &e%time%s &cpřed dalším použitím!'
|
||||||
|
|
||||||
|
GAMEMODE:
|
||||||
|
# Zpráva o změně herního módu.
|
||||||
|
GAMEMODE_CHANGE: '%prefix% &7Tvůj herní mód byl změněn na &e%gamemode%&7.'
|
||||||
|
# Zpráva o změně herního módu jiného hráče.
|
||||||
|
GAMEMODE_CHANGE_OTHER: '%prefix% &7Herní mód hráče &e%player% &7byl změněn na &e%gamemode%&7.'
|
||||||
|
# Zpráva o neplatném herním módu.
|
||||||
|
GAMEMODE_INVALID: '%prefix% &e%gamemode% &cnení platný herní mód!'
|
||||||
|
|
||||||
|
FLIGHT:
|
||||||
|
# Zpráva o zapnutí létání.
|
||||||
|
ENABLE: '%prefix% &7Létání bylo &a&lpovoleno&7.'
|
||||||
|
# Zpráva o vypnutí létání.
|
||||||
|
DISABLE: '%prefix% &7Létání bylo &c&lzakázáno&7.'
|
||||||
|
# Zpráva o zapnutí létání pro jiného hráče.
|
||||||
|
ENABLE_OTHER: '%prefix% &7Létání bylo &a&lpovoleno &7pro hráče &e%player%&7.'
|
||||||
|
# Zpráva o vypnutí létání pro jiného hráče.
|
||||||
|
DISABLE_OTHER: '%prefix% &7Létání bylo &c&lzakázáno &7pro hráče &e%player%&7.'
|
||||||
|
|
||||||
|
PLAYER_HIDER:
|
||||||
|
# Zpráva při skrytí hráčů.
|
||||||
|
HIDDEN: '%prefix% &7Viditelnost hráčů byla &c&lskryta&7.'
|
||||||
|
# Zpráva při zobrazení hráčů.
|
||||||
|
SHOWN: '%prefix% &7Viditelnost hráčů byla &a&lzobrazena&7.'
|
||||||
|
|
||||||
|
LOBBY:
|
||||||
|
# Zpráva o nastavení lobby spawn pointu.
|
||||||
|
SET_LOBBY: '%prefix% &aLobby spawn byl úspěšně nastaven!'
|
||||||
|
|
||||||
|
CHAT:
|
||||||
|
# Globální zpráva o promazání chatu.
|
||||||
|
CLEARCHAT: '&r\n<gradient:#9333EA:#06B6D4><bold>Chat byl promazán administrátorem %player%!</bold></gradient>\n&r'
|
||||||
|
# Zpráva zobrazená hráči po promazání chatu.
|
||||||
|
CLEARCHAT_PLAYER: '&cTvůj chat byl promazán administrátorem.'
|
||||||
|
|
||||||
|
DOUBLE_JUMP:
|
||||||
|
# Zpráva při pokusu o dvojitý skok v cooldownu.
|
||||||
|
COOLDOWN_ACTIVE: '%prefix% &cDouble Jump můžeš znovu použít za &e%time%s&c!'
|
||||||
|
|
||||||
|
WORLD_EVENT_MODIFICATIONS:
|
||||||
|
# Ochrany světa (vyhazování, sbírání, pokládání, ničení, interakce)
|
||||||
|
ITEM_DROP: '%prefix% &cNa lobby nemůžeš vyhazovat předměty!'
|
||||||
|
ITEM_PICKUP: '%prefix% &cNa lobby nemůžeš sbírat předměty!'
|
||||||
|
BLOCK_PLACE: '%prefix% &cNa lobby nemůžeš stavět!'
|
||||||
|
BLOCK_BREAK: '%prefix% &cNa lobby nemůžeš ničit bloky!'
|
||||||
|
BLOCK_INTERACT: '%prefix% &cZde nemůžeš interagovat s bloky!'
|
||||||
|
|
||||||
|
BUILD_MODE:
|
||||||
|
# Actionbar při zapnutém stavebním režimu.
|
||||||
|
ENABLED_ACTION_BAR: '<gradient:#9333EA:#06B6D4><bold>VexlioHub</bold></gradient> &8❙ &fStavební režim &a&lpovolen&7. Vypni pomocí &b/buildmode'
|
||||||
|
# Zpráva po zapnutí stavebního režimu pro sebe.
|
||||||
|
ENABLED: '%prefix% &7Stavební režim byl &a&lpovolen&7.'
|
||||||
|
# Zpráva po vypnutí stavebního režimu pro sebe.
|
||||||
|
DISABLED: '%prefix% &7Stavební režim byl &c&lzakázán&7.'
|
||||||
|
# Zpráva pokud cílový hráč nebyl nalezen.
|
||||||
|
TARGET_NOT_FOUND: '%prefix% &cHráč &e%target% &cnebyl nalezen!'
|
||||||
|
# Zpráva po zapnutí stavebního režimu pro jiného hráče.
|
||||||
|
ENABLED_FOR_TARGET: '%prefix% &7Stavební režim byl &a&lpovolen &7pro hráče &e%target%&7.'
|
||||||
Reference in New Issue
Block a user