Compare commits
70 Commits
Author | SHA1 | Date |
---|---|---|
craftaro-plugins-overview[bot] | 98b1aac16b | |
craftaro-plugins-overview[bot] | d060bb6e63 | |
Christian Koop | 3ba9983dd0 | |
ceze88 | e205a07318 | |
ceze88 | 5b776bf221 | |
ceze88 | b65cea5fa4 | |
Christian Koop | b4cb9b2569 | |
craftaro-plugins-overview[bot] | 17d2eb43eb | |
Christian Koop | e9b6a5ad80 | |
Christian Koop | b859303553 | |
Christian Koop | bdf5caec99 | |
Christian Koop | 6b930d3e25 | |
Christian Koop | 91be66c202 | |
Christian Koop | e0d19d701e | |
Christian Koop | b63bd350c6 | |
Christian Koop | 4aee977bfa | |
Christian Koop | a0a2351148 | |
Christian Koop | 29097b90c0 | |
craftaro-plugins-overview[bot] | bc4370730c | |
ceze88 | fdaf94a0a8 | |
ceze88 | 050d39b1e4 | |
Christian Koop | 67e3618405 | |
Christian Koop | 6505b291cf | |
Christian Koop | b872db8949 | |
Christian Koop | 8d2e93672e | |
Christian Koop | 947ee25f2e | |
Christian Koop | e9ba805d27 | |
Christian Koop | aa304ea01b | |
songoda-projects-overview[bot] | fcb03a7840 | |
songoda-projects-overview[bot] | 57ac4699d5 | |
Christian Koop | 7f9c748798 | |
Christian Koop | 148f88b2f3 | |
Christian Koop | e9fee6e0fd | |
Christian Koop | ce859401e5 | |
Christian Koop | 53d2cd5f79 | |
Christian Koop | bb45ef13d7 | |
Christian Koop | 1802ad3100 | |
Christian Koop | 0a3bafb953 | |
Christian Koop | e50f90d43a | |
Christian Koop | 4dcf2db057 | |
Christian Koop | b68fcadc45 | |
Christian Koop | 73d2059c1c | |
Christian Koop | 9c4951a73d | |
Christian Koop | ef88d992ca | |
Christian Koop | abdf9ae89d | |
Christian Koop | d366d51820 | |
Christian Koop | 87710a4772 | |
Christian Koop | 55cf082a57 | |
Christian Koop | a53dab9e18 | |
Christian Koop | d7801dd64f | |
Christian Koop | 063f7b0fee | |
Christian Koop | 8aa5173a60 | |
Christian Koop | a38f3b738a | |
Christian Koop | a943cc9389 | |
Brianna | 3d43b648a6 | |
Brianna | c6a4abf736 | |
Brianna | 8d1adcbd79 | |
Brianna | 8bea204b45 | |
Brianna | 24ee590f6b | |
Brianna | 20e40dd223 | |
Brianna | 4160786a30 | |
Brianna | f0d44f1756 | |
Brianna | 9ef1317157 | |
Brianna | d58cac4ee4 | |
MysteriousKyle | eaa92a3996 | |
MysteriousKyle | 1266f181d1 | |
Brianna | 6a47b238b4 | |
Fernando Pettinelli | b9baeaf2e1 | |
Fernando Pettinelli | 1fbb35d0e1 | |
Fernando Pettinelli | af6f67ff9c |
|
@ -0,0 +1,26 @@
|
|||
root = true
|
||||
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
# max_line_length = 120
|
||||
tab_width = 4
|
||||
trim_trailing_whitespace = true
|
||||
ij_continuation_indent_size = 8
|
||||
ij_formatter_off_tag = @formatter:off
|
||||
ij_formatter_on_tag = @formatter:on
|
||||
ij_formatter_tags_enabled = true
|
||||
|
||||
|
||||
[{*.yaml,*.yml,*.json,*.lang,*.graphqlconfig,*.har,*.jsb2,*.jsb3,*.webmanifest,.babelrc,.eslintrc,.prettierrc,.stylelintrc,bowerrc,jest.config}]
|
||||
indent_size = 2
|
||||
tab_width = 2
|
||||
|
||||
|
||||
[{*.markdown,*.md,*.html,*.htm,*.ng,*.sht,*.shtm,*.shtml,*.ts,*.ats,*.js,*.cjs,*.bash,*.sh,*.zsh}]
|
||||
indent_size = 2
|
||||
tab_width = 2
|
|
@ -0,0 +1 @@
|
|||
custom: [ 'https://craftaro.to/+' ]
|
|
@ -1,4 +1,10 @@
|
|||
\.idea
|
||||
\target
|
||||
EpicVouchers.iml
|
||||
## JetBrains IDEs
|
||||
/.idea/
|
||||
*.iml
|
||||
|
||||
## Maven
|
||||
/**/target/
|
||||
dependency-reduced-pom.xml
|
||||
|
||||
## Misc.
|
||||
.DS_Store
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||
<output url="file://$MODULE_DIR$/target/classes" />
|
||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.13.2" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.14" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.songoda:songodaupdater:1" level="project" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:acf-bukkit:0.5.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:acf-core:0.5.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:Table:1.0.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:DelegatingMap:1.0.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:locales:1.0-SNAPSHOT" level="project" />
|
||||
<orderEntry type="library" name="Maven: net.jodah:expiringmap:0.5.8" level="project" />
|
||||
<orderEntry type="library" name="Maven: co.aikar:minecraft-timings:1.0.4" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.jetbrains:annotations:13.0" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:1.4" level="project" />
|
||||
</component>
|
||||
</module>
|
328
LICENSE
328
LICENSE
|
@ -1,9 +1,327 @@
|
|||
Copyright (c) 2018 Brianna O’Keefe
|
||||
Creative Commons Attribution-NonCommercial-NoDerivatives 4.0
|
||||
International Public License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software with minimal restriction, including the rights to use, copy, modify or merge while excluding the rights to publish, (re)distribute, sub-license, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
By exercising the Licensed Rights (defined below), You accept and agree
|
||||
to be bound by the terms and conditions of this Creative Commons
|
||||
Attribution-NonCommercial-NoDerivatives 4.0 International Public
|
||||
License ("Public License"). To the extent this Public License may be
|
||||
interpreted as a contract, You are granted the Licensed Rights in
|
||||
consideration of Your acceptance of these terms and conditions, and the
|
||||
Licensor grants You such rights in consideration of benefits the
|
||||
Licensor receives from making the Licensed Material available under
|
||||
these terms and conditions.
|
||||
|
||||
The same distribution rights and limitations above shall similarly apply to any and all source code, and other means that can be used to emulate this work.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
Section 1 -- Definitions.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
a. Adapted Material means material subject to Copyright and Similar
|
||||
Rights that is derived from or based upon the Licensed Material
|
||||
and in which the Licensed Material is translated, altered,
|
||||
arranged, transformed, or otherwise modified in a manner requiring
|
||||
permission under the Copyright and Similar Rights held by the
|
||||
Licensor. For purposes of this Public License, where the Licensed
|
||||
Material is a musical work, performance, or sound recording,
|
||||
Adapted Material is always produced where the Licensed Material is
|
||||
synched in timed relation with a moving image.
|
||||
|
||||
b. Copyright and Similar Rights means copyright and/or similar rights
|
||||
closely related to copyright including, without limitation,
|
||||
performance, broadcast, sound recording, and Sui Generis Database
|
||||
Rights, without regard to how the rights are labeled or
|
||||
categorized. For purposes of this Public License, the rights
|
||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
||||
Rights.
|
||||
|
||||
c. Effective Technological Measures means those measures that, in the
|
||||
absence of proper authority, may not be circumvented under laws
|
||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
||||
Treaty adopted on December 20, 1996, and/or similar international
|
||||
agreements.
|
||||
|
||||
d. Exceptions and Limitations means fair use, fair dealing, and/or
|
||||
any other exception or limitation to Copyright and Similar Rights
|
||||
that applies to Your use of the Licensed Material.
|
||||
|
||||
e. Licensed Material means the artistic or literary work, database,
|
||||
or other material to which the Licensor applied this Public
|
||||
License.
|
||||
|
||||
f. Licensed Rights means the rights granted to You subject to the
|
||||
terms and conditions of this Public License, which are limited to
|
||||
all Copyright and Similar Rights that apply to Your use of the
|
||||
Licensed Material and that the Licensor has authority to license.
|
||||
|
||||
g. Licensor means the individual(s) or entity(ies) granting rights
|
||||
under this Public License.
|
||||
|
||||
h. NonCommercial means not primarily intended for or directed towards
|
||||
commercial advantage or monetary compensation. For purposes of
|
||||
this Public License, the exchange of the Licensed Material for
|
||||
other material subject to Copyright and Similar Rights by digital
|
||||
file-sharing or similar means is NonCommercial provided there is
|
||||
no payment of monetary compensation in connection with the
|
||||
exchange.
|
||||
|
||||
i. Share means to provide material to the public by any means or
|
||||
process that requires permission under the Licensed Rights, such
|
||||
as reproduction, public display, public performance, distribution,
|
||||
dissemination, communication, or importation, and to make material
|
||||
available to the public including in ways that members of the
|
||||
public may access the material from a place and at a time
|
||||
individually chosen by them.
|
||||
|
||||
j. Sui Generis Database Rights means rights other than copyright
|
||||
resulting from Directive 96/9/EC of the European Parliament and of
|
||||
the Council of 11 March 1996 on the legal protection of databases,
|
||||
as amended and/or succeeded, as well as other essentially
|
||||
equivalent rights anywhere in the world.
|
||||
|
||||
k. You means the individual or entity exercising the Licensed Rights
|
||||
under this Public License. Your has a corresponding meaning.
|
||||
|
||||
|
||||
Section 2 -- Scope.
|
||||
|
||||
a. License grant.
|
||||
|
||||
1. Subject to the terms and conditions of this Public License,
|
||||
the Licensor hereby grants You a worldwide, royalty-free,
|
||||
non-sublicensable, non-exclusive, irrevocable license to
|
||||
exercise the Licensed Rights in the Licensed Material to:
|
||||
|
||||
a. reproduce and Share the Licensed Material, in whole or
|
||||
in part, for NonCommercial purposes only; and
|
||||
|
||||
b. produce and reproduce, but not Share, Adapted Material
|
||||
for NonCommercial purposes only.
|
||||
|
||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
||||
Exceptions and Limitations apply to Your use, this Public
|
||||
License does not apply, and You do not need to comply with
|
||||
its terms and conditions.
|
||||
|
||||
3. Term. The term of this Public License is specified in Section
|
||||
6(a).
|
||||
|
||||
4. Media and formats; technical modifications allowed. The
|
||||
Licensor authorizes You to exercise the Licensed Rights in
|
||||
all media and formats whether now known or hereafter created,
|
||||
and to make technical modifications necessary to do so. The
|
||||
Licensor waives and/or agrees not to assert any right or
|
||||
authority to forbid You from making technical modifications
|
||||
necessary to exercise the Licensed Rights, including
|
||||
technical modifications necessary to circumvent Effective
|
||||
Technological Measures. For purposes of this Public License,
|
||||
simply making modifications authorized by this Section 2(a)
|
||||
(4) never produces Adapted Material.
|
||||
|
||||
5. Downstream recipients.
|
||||
|
||||
a. Offer from the Licensor -- Licensed Material. Every
|
||||
recipient of the Licensed Material automatically
|
||||
receives an offer from the Licensor to exercise the
|
||||
Licensed Rights under the terms and conditions of this
|
||||
Public License.
|
||||
|
||||
b. No downstream restrictions. You may not offer or impose
|
||||
any additional or different terms or conditions on, or
|
||||
apply any Effective Technological Measures to, the
|
||||
Licensed Material if doing so restricts exercise of the
|
||||
Licensed Rights by any recipient of the Licensed
|
||||
Material.
|
||||
|
||||
6. No endorsement. Nothing in this Public License constitutes or
|
||||
may be construed as permission to assert or imply that You
|
||||
are, or that Your use of the Licensed Material is, connected
|
||||
with, or sponsored, endorsed, or granted official status by,
|
||||
the Licensor or others designated to receive attribution as
|
||||
provided in Section 3(a)(1)(A)(i).
|
||||
|
||||
b. Other rights.
|
||||
|
||||
1. Moral rights, such as the right of integrity, are not
|
||||
licensed under this Public License, nor are publicity,
|
||||
privacy, and/or other similar personality rights; however, to
|
||||
the extent possible, the Licensor waives and/or agrees not to
|
||||
assert any such rights held by the Licensor to the limited
|
||||
extent necessary to allow You to exercise the Licensed
|
||||
Rights, but not otherwise.
|
||||
|
||||
2. Patent and trademark rights are not licensed under this
|
||||
Public License.
|
||||
|
||||
3. To the extent possible, the Licensor waives any right to
|
||||
collect royalties from You for the exercise of the Licensed
|
||||
Rights, whether directly or through a collecting society
|
||||
under any voluntary or waivable statutory or compulsory
|
||||
licensing scheme. In all other cases the Licensor expressly
|
||||
reserves any right to collect such royalties, including when
|
||||
the Licensed Material is used other than for NonCommercial
|
||||
purposes.
|
||||
|
||||
|
||||
Section 3 -- License Conditions.
|
||||
|
||||
Your exercise of the Licensed Rights is expressly made subject to the
|
||||
following conditions.
|
||||
|
||||
a. Attribution.
|
||||
|
||||
1. If You Share the Licensed Material, You must:
|
||||
|
||||
a. retain the following if it is supplied by the Licensor
|
||||
with the Licensed Material:
|
||||
|
||||
i. identification of the creator(s) of the Licensed
|
||||
Material and any others designated to receive
|
||||
attribution, in any reasonable manner requested by
|
||||
the Licensor (including by pseudonym if
|
||||
designated);
|
||||
|
||||
ii. a copyright notice;
|
||||
|
||||
iii. a notice that refers to this Public License;
|
||||
|
||||
iv. a notice that refers to the disclaimer of
|
||||
warranties;
|
||||
|
||||
v. a URI or hyperlink to the Licensed Material to the
|
||||
extent reasonably practicable;
|
||||
|
||||
b. indicate if You modified the Licensed Material and
|
||||
retain an indication of any previous modifications; and
|
||||
|
||||
c. indicate the Licensed Material is licensed under this
|
||||
Public License, and include the text of, or the URI or
|
||||
hyperlink to, this Public License.
|
||||
|
||||
For the avoidance of doubt, You do not have permission under
|
||||
this Public License to Share Adapted Material.
|
||||
|
||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
||||
reasonable manner based on the medium, means, and context in
|
||||
which You Share the Licensed Material. For example, it may be
|
||||
reasonable to satisfy the conditions by providing a URI or
|
||||
hyperlink to a resource that includes the required
|
||||
information.
|
||||
|
||||
3. If requested by the Licensor, You must remove any of the
|
||||
information required by Section 3(a)(1)(A) to the extent
|
||||
reasonably practicable.
|
||||
|
||||
|
||||
Section 4 -- Sui Generis Database Rights.
|
||||
|
||||
Where the Licensed Rights include Sui Generis Database Rights that
|
||||
apply to Your use of the Licensed Material:
|
||||
|
||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
||||
to extract, reuse, reproduce, and Share all or a substantial
|
||||
portion of the contents of the database for NonCommercial purposes
|
||||
only and provided You do not Share Adapted Material;
|
||||
|
||||
b. if You include all or a substantial portion of the database
|
||||
contents in a database in which You have Sui Generis Database
|
||||
Rights, then the database in which You have Sui Generis Database
|
||||
Rights (but not its individual contents) is Adapted Material; and
|
||||
|
||||
c. You must comply with the conditions in Section 3(a) if You Share
|
||||
all or a substantial portion of the contents of the database.
|
||||
|
||||
For the avoidance of doubt, this Section 4 supplements and does not
|
||||
replace Your obligations under this Public License where the Licensed
|
||||
Rights include other Copyright and Similar Rights.
|
||||
|
||||
|
||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
||||
|
||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
||||
|
||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
||||
|
||||
c. The disclaimer of warranties and limitation of liability provided
|
||||
above shall be interpreted in a manner that, to the extent
|
||||
possible, most closely approximates an absolute disclaimer and
|
||||
waiver of all liability.
|
||||
|
||||
|
||||
Section 6 -- Term and Termination.
|
||||
|
||||
a. This Public License applies for the term of the Copyright and
|
||||
Similar Rights licensed here. However, if You fail to comply with
|
||||
this Public License, then Your rights under this Public License
|
||||
terminate automatically.
|
||||
|
||||
b. Where Your right to use the Licensed Material has terminated under
|
||||
Section 6(a), it reinstates:
|
||||
|
||||
1. automatically as of the date the violation is cured, provided
|
||||
it is cured within 30 days of Your discovery of the
|
||||
violation; or
|
||||
|
||||
2. upon express reinstatement by the Licensor.
|
||||
|
||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
||||
right the Licensor may have to seek remedies for Your violations
|
||||
of this Public License.
|
||||
|
||||
c. For the avoidance of doubt, the Licensor may also offer the
|
||||
Licensed Material under separate terms or conditions or stop
|
||||
distributing the Licensed Material at any time; however, doing so
|
||||
will not terminate this Public License.
|
||||
|
||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
||||
License.
|
||||
|
||||
|
||||
Section 7 -- Other Terms and Conditions.
|
||||
|
||||
a. The Licensor shall not be bound by any additional or different
|
||||
terms or conditions communicated by You unless expressly agreed.
|
||||
|
||||
b. Any arrangements, understandings, or agreements regarding the
|
||||
Licensed Material not stated herein are separate from and
|
||||
independent of the terms and conditions of this Public License.
|
||||
|
||||
|
||||
Section 8 -- Interpretation.
|
||||
|
||||
a. For the avoidance of doubt, this Public License does not, and
|
||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
||||
conditions on any use of the Licensed Material that could lawfully
|
||||
be made without permission under this Public License.
|
||||
|
||||
b. To the extent possible, if any provision of this Public License is
|
||||
deemed unenforceable, it shall be automatically reformed to the
|
||||
minimum extent necessary to make it enforceable. If the provision
|
||||
cannot be reformed, it shall be severed from this Public License
|
||||
without affecting the enforceability of the remaining terms and
|
||||
conditions.
|
||||
|
||||
c. No term or condition of this Public License will be waived and no
|
||||
failure to comply consented to unless expressly agreed to by the
|
||||
Licensor.
|
||||
|
||||
d. Nothing in this Public License constitutes or may be interpreted
|
||||
as a limitation upon, or waiver of, any privileges and immunities
|
||||
that apply to the Licensor or You, including from the legal
|
||||
processes of any jurisdiction or authority.
|
||||
|
||||
=======================================================================
|
||||
|
|
110
README.md
110
README.md
|
@ -1,66 +1,44 @@
|
|||
## EpicVouchers
|
||||
EpicVouchers is the best solution for vouchers on any server with amazing features updated everyday by me (Songoda).</br>
|
||||
Quality, performance, and support are my priorities for this resource. Purchase it for $2.99 (sometimes cheaper with sales).
|
||||
> **Note:** Please consider purchasing this resource on Spigot if you want to really support me.
|
||||
</br>
|
||||
|
||||
## Developers
|
||||
Here is an example with built-in methods for developers that want to use the EpicVouchers API for their own resources.</br>
|
||||
This is a kinda long example so think about that too but I am sure that you will understand the usage of it quick and easy.
|
||||
```ruby
|
||||
@EventHandler
|
||||
public void redeemListener(VoucherRedeemEvent event) {
|
||||
# Returns the player that redeemed the voucher.
|
||||
Player player = event.getPlayer();
|
||||
# Returns the name of the redeemed voucher.
|
||||
String voucher = event.getVoucher();
|
||||
# Returns the ItemStack of the redeemed voucher.
|
||||
ItemStack item = event.getItem();
|
||||
# Returns if the voucher was redeemed manual or not.
|
||||
boolean manual = event.getManual();
|
||||
# Returns if the event is cancelled or not.
|
||||
boolean cancelled = event.isCancelled();
|
||||
# Get a list of handlers for this event.
|
||||
HandlerList handlers = event.getHandlers();
|
||||
# Cancel the event with a boolean.
|
||||
event.isCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void forceListener(ForceRedeemEvent event) {
|
||||
# Returns the player that redeemed the voucher.
|
||||
Player player = event.getPlayer();
|
||||
# Returns the name of the redeemed voucher.
|
||||
String voucher = event.getVoucher();
|
||||
# Returns the amount of vouchers that were redeemed.
|
||||
int amount = event.getAmount();
|
||||
# Returns the sender that forced the players.
|
||||
CommandSender sender = event.getSender();
|
||||
# Returns if the event is cancelled or not.
|
||||
boolean cancelled = event.isCancelled();
|
||||
# Get a list of handlers for this event.
|
||||
HandlerList handlers = event.getHandlers();
|
||||
# Cancel the event with a boolean.
|
||||
event.isCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void receiveListener(VoucherReceiveEvent event) {
|
||||
# Returns the player that received the voucher.
|
||||
Player player = event.getPlayer();
|
||||
# Returns the name of the received voucher.
|
||||
String voucher = event.getVoucher();
|
||||
# Returns the ItemStack of the received voucher.
|
||||
ItemStack item = event.getItem();
|
||||
# Returns the amount of vouchers that were received.
|
||||
int amount = event.getAmount();
|
||||
# Returns the sender that gave the vouchers.
|
||||
CommandSender sender = event.getSender();
|
||||
# Returns if the event is cancelled or not.
|
||||
boolean cancelled = event.isCancelled();
|
||||
# Get a list of handlers for this event.
|
||||
HandlerList handlers = event.getHandlers();
|
||||
# Cancel the event with a boolean.
|
||||
event.isCancelled(true);
|
||||
}
|
||||
```
|
||||
<!--suppress HtmlDeprecatedAttribute -->
|
||||
<div align="center">
|
||||
<img src="docs/Logo.png" width="128px">
|
||||
|
||||
# EpicVouchers
|
||||
**Create vouchers that players can claim for rewards with seemingly infinite possibilities**
|
||||
**Customize your server's vouchers through an intuitive in-game editor**
|
||||
|
||||
|
||||
[![Discord][Discord shield]][Discord invite]
|
||||
<br>
|
||||
[![Latest version][Latest version shield]][Plugin page]
|
||||
[![bStats Servers][bStats shield]][bStats page]
|
||||
</div>
|
||||
|
||||
|
||||
## Download (Marketplace)
|
||||
You can visit [our marketplace][Plugin page] to download EpicVouchers as well as take a
|
||||
look at many other fantastic plugins which are sure to catch your eye.
|
||||
|
||||
## Documentation
|
||||
You can find all the information about EpicVouchers, including dependencies, commands, permissions and incompatible
|
||||
plugins on [our wiki][Plugin wiki].
|
||||
|
||||
Feel free to also contribute to the wiki as a way to help others in the community with using the plugin.
|
||||
|
||||
## Support
|
||||
If you encounter any issues while using the plugin, feel free to contact us on
|
||||
[our Discord server][Discord invite].
|
||||
|
||||
## Suggestions
|
||||
For suggestions about features you think should be added to the plugin to increase its functionality, feel free to
|
||||
create a thread over on [our Discord server][Discord invite].
|
||||
|
||||
|
||||
[Plugin page]: https://songoda.com/product/12
|
||||
[Plugin wiki]: https://songoda.notion.site/EpicVouchers-a0ee496d84964191aec9903459c8906d
|
||||
[Discord invite]: https://discord.gg/7TXM8xr2Ng
|
||||
|
||||
[Discord shield]: https://img.shields.io/discord/1214289374506917889?color=5865F2&label=Discord&logo=discord&logoColor=5865F2
|
||||
[Latest version shield]: https://img.shields.io/badge/dynamic/xml?style=flat&color=blue&logo=github&logoColor=white&label=Latest&url=https%3A%2F%2Fraw.githubusercontent.com%2Fcraftaro%2FEpicVouchers%2Fmaster%2Fpom.xml&query=%2F*%5Blocal-name()%3D'project'%5D%2F*%5Blocal-name()%3D'version'%5D
|
||||
|
||||
[bStats page]: https://bstats.org/plugin/bukkit/EpicVouchers/4209
|
||||
[bStats shield]: https://img.shields.io/bstats/servers/4209?label=Servers
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
Hey loves,
|
||||
|
||||
Thanks for downloading our plugin ^_^ In order to
|
||||
run it you will need a plugin called arconix. It
|
||||
basically takes a bunch of methods that we use all
|
||||
over the place throughout our plugin lineup and
|
||||
stores it in one place so we don't have to write
|
||||
new code every time we need to get something simple
|
||||
done. So make sure to stay up to date with the latest
|
||||
updates for it.
|
||||
|
||||
Link to download:
|
||||
https://gitlab.com/Songoda/Arconix/-/jobs/artifacts/master/download?job=build
|
||||
|
||||
If you need help you can always join our
|
||||
discord in which is listed at the bottom of all of
|
||||
our plugin pages.
|
||||
|
||||
Enjoy <3
|
||||
Brianna & The Songoda Team.
|
Binary file not shown.
After Width: | Height: | Size: 59 KiB |
142
pom.xml
142
pom.xml
|
@ -1,83 +1,86 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0">
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicVouchers</artifactId>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>2.1.18</version>
|
||||
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>EpicVouchers-Plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
|
||||
<name>EpicVouchers</name>
|
||||
<description>Create vouchers that players can claim for rewards with seemingly infinite possibilities</description>
|
||||
<url>https://craftaro.com/marketplace/product/25</url>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.release>8</maven.compiler.release>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>EpicVouchers-${project.version}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.google.code.maven-replacer-plugin</groupId>
|
||||
<artifactId>replacer</artifactId>
|
||||
<version>1.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>replace</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<file>${project.build.directory}/classes/plugin.yml</file>
|
||||
<replacements>
|
||||
<replacement>
|
||||
<token>maven-version-number</token>
|
||||
<value>${project.version}</value>
|
||||
</replacement>
|
||||
</replacements>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.5.0</version>
|
||||
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
|
||||
<configuration>
|
||||
<finalName>${project.name}-${project.version}</finalName>
|
||||
|
||||
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>com.songoda:SongodaCore</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<useDependencyReducedPomInJar>true</useDependencyReducedPomInJar>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.craftaro.core</pattern>
|
||||
<shadedPattern>com.craftaro.epicvouchers.core</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>*:*</artifact>
|
||||
|
||||
<excludes>
|
||||
<exclude>META-INF/*.SF</exclude>
|
||||
<exclude>META-INF/*.DSA</exclude>
|
||||
<exclude>META-INF/*.RSA</exclude>
|
||||
<exclude>META-INF/**</exclude>
|
||||
<exclude>LICENSE</exclude>
|
||||
<exclude>LICENSE.**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
|
||||
<filter>
|
||||
<artifact>com.craftaro:CraftaroCore</artifact>
|
||||
<excludeDefaults>false</excludeDefaults>
|
||||
<excludes>
|
||||
<exclude>**/third_party/org/apache/**</exclude>
|
||||
<exclude>**/third_party/net/kyori/**</exclude>
|
||||
<exclude>**/third_party/com/zaxxer/**</exclude>
|
||||
<exclude>**/third_party/org/jooq/**</exclude>
|
||||
<exclude>**/third_party/org/mariadb/**</exclude>
|
||||
<exclude>**/third_party/com/h2database/**</exclude>
|
||||
<exclude>**/third_party/org/h2/**</exclude>
|
||||
<exclude>**/third_party/com/cryptomorin/**</exclude>
|
||||
<exclude>**/third_party/org/reactivestreams/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>com.songoda.core</pattern>
|
||||
<shadedPattern>${project.groupId}.epicvouchers.core</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
|
@ -88,32 +91,35 @@
|
|||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>private</id>
|
||||
<url>https://repo.songoda.com/artifactory/private/</url>
|
||||
<id>craftaro-minecraft-plugins</id>
|
||||
<url>https://repo.craftaro.com/repository/minecraft-plugins/</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<url>https://repo.songoda.com/artifactory/public/</url>
|
||||
<id>SpigotMC</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.15</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>SongodaCore</artifactId>
|
||||
<version>LATEST</version>
|
||||
<groupId>com.craftaro</groupId>
|
||||
<artifactId>CraftaroCore</artifactId>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.18-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.2</version>
|
||||
<version>1.18.20</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -0,0 +1,312 @@
|
|||
package com.craftaro.epicvouchers;
|
||||
|
||||
import com.craftaro.core.SongodaCore;
|
||||
import com.craftaro.core.SongodaPlugin;
|
||||
import com.craftaro.core.commands.CommandManager;
|
||||
import com.craftaro.core.configuration.Config;
|
||||
import com.craftaro.core.dependency.Dependency;
|
||||
import com.craftaro.core.gui.GuiManager;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.epicvouchers.commands.CommandEditor;
|
||||
import com.craftaro.epicvouchers.commands.CommandEpicVouchers;
|
||||
import com.craftaro.epicvouchers.commands.CommandForce;
|
||||
import com.craftaro.epicvouchers.commands.CommandForceAll;
|
||||
import com.craftaro.epicvouchers.commands.CommandGive;
|
||||
import com.craftaro.epicvouchers.commands.CommandGiveAll;
|
||||
import com.craftaro.epicvouchers.commands.CommandList;
|
||||
import com.craftaro.epicvouchers.commands.CommandReload;
|
||||
import com.craftaro.epicvouchers.handlers.Connections;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.listeners.PlayerCommandListener;
|
||||
import com.craftaro.epicvouchers.listeners.PlayerInteractListener;
|
||||
import com.craftaro.epicvouchers.settings.Settings;
|
||||
import com.craftaro.epicvouchers.utils.Callback;
|
||||
import com.craftaro.epicvouchers.utils.ThreadSync;
|
||||
import com.craftaro.epicvouchers.voucher.CoolDownManager;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.voucher.VoucherExecutor;
|
||||
import com.craftaro.epicvouchers.voucher.VoucherManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class EpicVouchers extends SongodaPlugin {
|
||||
private final GuiManager guiManager = new GuiManager(this);
|
||||
private CommandManager commandManager;
|
||||
private VoucherManager voucherManager;
|
||||
|
||||
private Connections connections;
|
||||
private CoolDownManager coolDowns;
|
||||
private VoucherExecutor voucherExecutor;
|
||||
private final Config vouchersConfig = new Config(this, "vouchers.yml");
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link org.bukkit.plugin.java.JavaPlugin#getPlugin(Class)} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static EpicVouchers getInstance() {
|
||||
return getPlugin(EpicVouchers.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Set<Dependency> getDependencies() {
|
||||
return new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
this.connections.closeMySQL();
|
||||
saveVouchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginEnable() {
|
||||
// Run Songoda Updater
|
||||
SongodaCore.registerPlugin(this, 25, XMaterial.EMERALD);
|
||||
|
||||
// Setup Config
|
||||
Settings.setupConfig();
|
||||
this.setLocale(Settings.LANGUGE_MODE.getString(), false);
|
||||
|
||||
// Register commands
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.commandManager.addCommand(new CommandEpicVouchers(this))
|
||||
.addSubCommands(
|
||||
new CommandEditor(this),
|
||||
new CommandForce(this),
|
||||
new CommandForceAll(this),
|
||||
new CommandGive(this),
|
||||
new CommandGiveAll(this),
|
||||
new CommandList(this),
|
||||
new CommandReload(this)
|
||||
);
|
||||
|
||||
FastInv.init(this);
|
||||
IconInv.init(this);
|
||||
|
||||
this.connections = new Connections(this);
|
||||
this.coolDowns = new CoolDownManager(this);
|
||||
this.voucherExecutor = new VoucherExecutor(this);
|
||||
this.voucherManager = new VoucherManager();
|
||||
|
||||
PluginManager manager = Bukkit.getServer().getPluginManager();
|
||||
|
||||
// Listeners
|
||||
this.guiManager.init();
|
||||
manager.registerEvents(new PlayerInteractListener(this), this);
|
||||
manager.registerEvents(new PlayerCommandListener(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataLoad() {
|
||||
if (!new File(this.getDataFolder(), "vouchers.yml").exists()) {
|
||||
saveResource("vouchers.yml", false);
|
||||
}
|
||||
|
||||
synchronized (this.vouchersConfig) {
|
||||
this.vouchersConfig.load();
|
||||
}
|
||||
|
||||
loadVouchersFromFile();
|
||||
|
||||
this.connections.openMySQL();
|
||||
|
||||
// FIXME: Config system needs to be greatly redone and only write changes when changes were made - Maybe even split it into multiple smaler files
|
||||
// Issue https://support.songoda.com/browse/SD-8155 has been hotfixed by writing changes to the file async and blocking the main thread when needed. This requires the use of `synchronized`
|
||||
// and expects every modifying code to use it (thread-safety)
|
||||
// Large vouchers.yml files cause huge performance problems otherwise...
|
||||
// Example file for testing: https://support.songoda.com/secure/attachment/17258/17258_vouchers.yml
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this,
|
||||
() -> saveVouchersAsync(ex -> {
|
||||
if (ex != null) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}), 5 * 60 * 20, 5 * 60 * 20); // 5 minutes
|
||||
}
|
||||
|
||||
private void loadVouchersFromFile() {
|
||||
synchronized (this.vouchersConfig) {
|
||||
this.voucherManager.clearVouchers();
|
||||
|
||||
if (this.vouchersConfig.contains("vouchers")) {
|
||||
for (String key : this.vouchersConfig.getConfigurationSection("vouchers").getKeys(false)) {
|
||||
Voucher voucher = new Voucher(key, this);
|
||||
ConfigurationSection cs = this.vouchersConfig.getConfigurationSection("vouchers." + key);
|
||||
|
||||
Material material;
|
||||
String stringMaterial = cs.getString("material");
|
||||
|
||||
if (stringMaterial == null || stringMaterial.isEmpty()) {
|
||||
material = Material.PAPER;
|
||||
} else {
|
||||
material = Material.matchMaterial(stringMaterial);
|
||||
if (material == null) {
|
||||
material = Material.PAPER;
|
||||
}
|
||||
}
|
||||
|
||||
voucher.setPermission(cs.getString("permission", ""))
|
||||
.setMaterial(material)
|
||||
.setData((short) cs.getInt("data", 0))
|
||||
.setName(cs.getString("name", "default"))
|
||||
.setLore(cs.getStringList("lore"))
|
||||
.setTexture(cs.getString("texture", ""))
|
||||
.setGlow(cs.getBoolean("glow", false))
|
||||
.setConfirm(cs.getBoolean("confirm", true))
|
||||
.setUnbreakable(cs.getBoolean("unbreakable", false))
|
||||
.setHideAttributes(cs.getBoolean("hide-attributes", false))
|
||||
.setRemoveItem(cs.getBoolean("remove-item", true))
|
||||
.setHealPlayer(cs.getBoolean("heal-player", false))
|
||||
.setSmiteEffect(cs.getBoolean("smite-effect", false))
|
||||
.setCoolDown(cs.getInt("coolDown", 0))
|
||||
.setBroadcasts(cs.getStringList("broadcasts"))
|
||||
.setMessages(cs.getStringList("messages"))
|
||||
.setCommands(cs.getStringList("commands"))
|
||||
.setActionBar(cs.getString("actionbar"))
|
||||
.setTitle(cs.getString("titles.title"))
|
||||
.setSubTitle(cs.getString("titles.subtitle"))
|
||||
.setTitleFadeIn(cs.getInt("titles.fade-in", 0))
|
||||
.setTitleStay(cs.getInt("titles.stay", 0))
|
||||
.setTitleFadeOut(cs.getInt("titles.fade-out", 0))
|
||||
.setSound(cs.getString("sounds.sound"))
|
||||
.setSoundPitch(cs.getInt("sounds.pitch", 0))
|
||||
.setParticle(cs.getString("particles.particle"))
|
||||
.setParticleAmount(cs.getInt("particles.amount", 0))
|
||||
.setEffect(cs.getString("effects.effect"))
|
||||
.setEffectAmplifier(cs.getInt("effects.amplifier"))
|
||||
.setItemStack(cs.getItemStack("itemstack", null));
|
||||
|
||||
this.voucherManager.addVoucher(voucher);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveVouchers() {
|
||||
ThreadSync tSync = new ThreadSync();
|
||||
|
||||
saveVouchersAsync(ex -> {
|
||||
if (ex != null) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
tSync.release();
|
||||
});
|
||||
|
||||
tSync.waitForRelease();
|
||||
}
|
||||
|
||||
private void saveVouchersAsync(Callback callback) {
|
||||
new Thread(() -> {
|
||||
try {
|
||||
synchronized (this.vouchersConfig) {
|
||||
Collection<Voucher> voucherList = this.voucherManager.getVouchers();
|
||||
|
||||
ConfigurationSection cfgSec = this.vouchersConfig.getConfigurationSection("vouchers");
|
||||
if (cfgSec != null) {
|
||||
for (String voucherName : cfgSec.getKeys(false)) {
|
||||
if (voucherList.stream().noneMatch(voucher -> voucher.getKey().equals(voucherName))) {
|
||||
this.vouchersConfig.set("vouchers." + voucherName, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Voucher voucher : voucherList) {
|
||||
String prefix = "vouchers." + voucher.getKey() + ".";
|
||||
|
||||
this.vouchersConfig.set(prefix + "permission", voucher.getPermission());
|
||||
this.vouchersConfig.set(prefix + "material", voucher.getMaterial().name());
|
||||
this.vouchersConfig.set(prefix + "data", voucher.getData());
|
||||
this.vouchersConfig.set(prefix + "name", voucher.getName());
|
||||
this.vouchersConfig.set(prefix + "lore", voucher.getLore());
|
||||
this.vouchersConfig.set(prefix + "texture", voucher.getTexture());
|
||||
this.vouchersConfig.set(prefix + "glow", voucher.isGlow());
|
||||
this.vouchersConfig.set(prefix + "confirm", voucher.isConfirm());
|
||||
this.vouchersConfig.set(prefix + "unbreakable", voucher.isUnbreakable());
|
||||
this.vouchersConfig.set(prefix + "hide-attributes", voucher.isHideAttributes());
|
||||
this.vouchersConfig.set(prefix + "remove-item", voucher.isRemoveItem());
|
||||
this.vouchersConfig.set(prefix + "heal-player", voucher.isHealPlayer());
|
||||
this.vouchersConfig.set(prefix + "smite-effect", voucher.isSmiteEffect());
|
||||
this.vouchersConfig.set(prefix + "coolDown", voucher.getCoolDown());
|
||||
this.vouchersConfig.set(prefix + "broadcasts", voucher.getBroadcasts());
|
||||
this.vouchersConfig.set(prefix + "messages", voucher.getMessages());
|
||||
this.vouchersConfig.set(prefix + "commands", voucher.getCommands());
|
||||
this.vouchersConfig.set(prefix + "actionbar", voucher.getActionBar());
|
||||
this.vouchersConfig.set(prefix + "titles.title", voucher.getTitle());
|
||||
this.vouchersConfig.set(prefix + "titles.subtitle", voucher.getSubTitle());
|
||||
this.vouchersConfig.set(prefix + "titles.fade-in", voucher.getTitleFadeIn());
|
||||
this.vouchersConfig.set(prefix + "titles.stay", voucher.getTitleStay());
|
||||
this.vouchersConfig.set(prefix + "titles.fade-out", voucher.getTitleFadeOut());
|
||||
this.vouchersConfig.set(prefix + "sounds.sound", voucher.getSound());
|
||||
this.vouchersConfig.set(prefix + "sounds.pitch", voucher.getSoundPitch());
|
||||
this.vouchersConfig.set(prefix + "particles.particle", voucher.getParticle());
|
||||
this.vouchersConfig.set(prefix + "particles.amount", voucher.getParticleAmount());
|
||||
this.vouchersConfig.set(prefix + "effects.effect", voucher.getEffect());
|
||||
this.vouchersConfig.set(prefix + "effects.amplifier", voucher.getEffectAmplifier());
|
||||
this.vouchersConfig.set(prefix + "itemstack", voucher.getItemStack());
|
||||
}
|
||||
|
||||
this.vouchersConfig.saveChanges();
|
||||
|
||||
callback.accept(null);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
callback.accept(ex);
|
||||
}
|
||||
}, getName() + "-AsyncConfigSave").start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigReload() {
|
||||
synchronized (this.vouchersConfig) {
|
||||
this.vouchersConfig.load();
|
||||
}
|
||||
|
||||
loadVouchersFromFile();
|
||||
|
||||
this.setLocale(getConfig().getString("System.Language Mode"), true);
|
||||
this.locale.reloadMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Config> getExtraConfig() {
|
||||
return Collections.singletonList(this.vouchersConfig);
|
||||
}
|
||||
|
||||
public Connections getConnections() {
|
||||
return this.connections;
|
||||
}
|
||||
|
||||
public CoolDownManager getCoolDowns() {
|
||||
return this.coolDowns;
|
||||
}
|
||||
|
||||
public VoucherExecutor getVoucherExecutor() {
|
||||
return this.voucherExecutor;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return this.commandManager;
|
||||
}
|
||||
|
||||
public VoucherManager getVoucherManager() {
|
||||
return this.voucherManager;
|
||||
}
|
||||
|
||||
public GuiManager getGuiManager() {
|
||||
return this.guiManager;
|
||||
}
|
||||
}
|
|
@ -1,25 +1,24 @@
|
|||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.menus.VoucherMenu;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.menus.VoucherMenu;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandEditor extends AbstractCommand {
|
||||
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandEditor(EpicVouchers instance) {
|
||||
super(true, "editor");
|
||||
super(CommandType.PLAYER_ONLY, "EpicVouchers");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
new VoucherMenu(instance).open((Player) sender);
|
||||
new VoucherMenu(this.instance).open((Player) sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
|
@ -1,28 +1,27 @@
|
|||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandEpicVouchers extends AbstractCommand {
|
||||
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandEpicVouchers(EpicVouchers instance) {
|
||||
super(false, "EpicVouchers");
|
||||
super(CommandType.CONSOLE_OK, "EpicVouchers");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
sender.sendMessage("");
|
||||
instance.getLocale().newMessage("&7Version " + instance.getDescription().getVersion()
|
||||
+ " Created with <3 by &5&l&oSongoda").sendPrefixedMessage(sender);
|
||||
this.instance.getLocale().newMessage("&7Version " + this.instance.getDescription().getVersion()
|
||||
+ " Created with <3 by &5&l&oCraftaro").sendPrefixedMessage(sender);
|
||||
|
||||
for (AbstractCommand command : instance.getCommandManager().getAllCommands()) {
|
||||
for (AbstractCommand command : this.instance.getCommandManager().getAllCommands()) {
|
||||
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8 - &a" + command.getSyntax() + "&7 - " + command.getDescription()));
|
||||
}
|
|
@ -1,47 +1,44 @@
|
|||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandForce extends AbstractCommand {
|
||||
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandForce(EpicVouchers instance) {
|
||||
super(false, "force");
|
||||
super(CommandType.CONSOLE_OK, "force");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 3)
|
||||
if (args.length != 3) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
if (Bukkit.getPlayer(args[0]) == null) {
|
||||
instance.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender);
|
||||
this.instance.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
Voucher voucher = instance.getVoucherManager().getVoucher(args[1]);
|
||||
Voucher voucher = this.instance.getVoucherManager().getVoucher(args[1]);
|
||||
if (voucher == null) {
|
||||
sender.sendMessage("Unknown voucher...");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
voucher.forceRedeem(sender, Collections.singletonList(player), Integer.parseInt(args[2]));
|
||||
instance.getLocale().getMessage("command.force.send")
|
||||
this.instance.getLocale().getMessage("command.force.send")
|
||||
.processPlaceholder("player", player.getName())
|
||||
.processPlaceholder("voucher", voucher.getName(true))
|
||||
.processPlaceholder("amount", args[2].trim())
|
||||
|
@ -51,14 +48,23 @@ public class CommandForce extends AbstractCommand {
|
|||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (args.length == 1) {
|
||||
return Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).collect(Collectors.toList());
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
result.add(online.getName());
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
return instance.getVoucherManager().getVouchers().stream().map(Voucher::getKey).collect(Collectors.toList());
|
||||
for (Voucher voucher : this.instance.getVoucherManager().getVouchers()) {
|
||||
result.add(voucher.getKey());
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
return Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
result.add(String.valueOf(i + 1));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,38 +1,36 @@
|
|||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandForceAll extends AbstractCommand {
|
||||
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandForceAll(EpicVouchers instance) {
|
||||
super(false, "forceall");
|
||||
super(CommandType.CONSOLE_OK, "forceall");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 2)
|
||||
if (args.length != 2) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
Voucher voucher = instance.getVoucherManager().getVoucher(args[0]);
|
||||
Voucher voucher = this.instance.getVoucherManager().getVoucher(args[0]);
|
||||
if (voucher == null) {
|
||||
sender.sendMessage("Unknown voucher...");
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
voucher.forceRedeem(sender, new ArrayList<>(Bukkit.getOnlinePlayers()), Integer.parseInt(args[1]));
|
||||
instance.getLocale().getMessage("command.force.send")
|
||||
this.instance.getLocale().getMessage("command.force.send")
|
||||
.processPlaceholder("player", "everyone")
|
||||
.processPlaceholder("voucher", voucher.getName(true))
|
||||
.processPlaceholder("amount", args[1].trim())
|
||||
|
@ -42,12 +40,19 @@ public class CommandForceAll extends AbstractCommand {
|
|||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (args.length == 1) {
|
||||
return instance.getVoucherManager().getVouchers().stream().map(Voucher::getKey).collect(Collectors.toList());
|
||||
for (Voucher voucher : this.instance.getVoucherManager().getVouchers()) {
|
||||
result.add(voucher.getKey());
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
return Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
result.add(String.valueOf(i + 1));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,41 +1,37 @@
|
|||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.menus.VoucherMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandGive extends AbstractCommand {
|
||||
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandGive(EpicVouchers instance) {
|
||||
super(false, "give");
|
||||
super(CommandType.CONSOLE_OK, "give");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 3)
|
||||
if (args.length != 3) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
if (Bukkit.getPlayer(args[0]) == null) {
|
||||
instance.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender);
|
||||
this.instance.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender);
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
Voucher voucher = instance.getVoucherManager().getVoucher(args[1]);
|
||||
Voucher voucher = this.instance.getVoucherManager().getVoucher(args[1]);
|
||||
if (voucher == null) {
|
||||
sender.sendMessage("Unknown voucher...");
|
||||
return ReturnType.FAILURE;
|
||||
|
@ -47,14 +43,23 @@ public class CommandGive extends AbstractCommand {
|
|||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (args.length == 1) {
|
||||
return Bukkit.getOnlinePlayers().stream().map(HumanEntity::getName).collect(Collectors.toList());
|
||||
for (Player online : Bukkit.getOnlinePlayers()) {
|
||||
result.add(online.getName());
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
return instance.getVoucherManager().getVouchers().stream().map(Voucher::getKey).collect(Collectors.toList());
|
||||
for (Voucher voucher : this.instance.getVoucherManager().getVouchers()) {
|
||||
result.add(voucher.getKey());
|
||||
}
|
||||
} else if (args.length == 3) {
|
||||
return Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
result.add(String.valueOf(i + 1));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,34 +1,28 @@
|
|||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandGiveAll extends AbstractCommand {
|
||||
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandGiveAll(EpicVouchers instance) {
|
||||
super(false, "giveall");
|
||||
super(CommandType.CONSOLE_OK, "giveall");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
if (args.length != 2)
|
||||
if (args.length != 2) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
Voucher voucher = instance.getVoucherManager().getVoucher(args[0]);
|
||||
Voucher voucher = this.instance.getVoucherManager().getVoucher(args[0]);
|
||||
if (voucher == null) {
|
||||
sender.sendMessage("Unknown voucher...");
|
||||
return ReturnType.FAILURE;
|
||||
|
@ -40,12 +34,19 @@ public class CommandGiveAll extends AbstractCommand {
|
|||
|
||||
@Override
|
||||
protected List<String> onTab(CommandSender sender, String... args) {
|
||||
List<String> result = new ArrayList<>();
|
||||
|
||||
if (args.length == 1) {
|
||||
return instance.getVoucherManager().getVouchers().stream().map(Voucher::getKey).collect(Collectors.toList());
|
||||
for (Voucher voucher : this.instance.getVoucherManager().getVouchers()) {
|
||||
result.add(voucher.getKey());
|
||||
}
|
||||
} else if (args.length == 2) {
|
||||
return Arrays.asList("1", "2", "3", "4", "5", "6", "7", "8", "9", "10");
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
result.add(String.valueOf(i + 1));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,30 +1,32 @@
|
|||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.menus.VoucherMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
public class CommandList extends AbstractCommand {
|
||||
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandList(EpicVouchers instance) {
|
||||
super(false, "list");
|
||||
super(CommandType.CONSOLE_OK, "list");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
instance.getLocale().getMessage("command.list.list")
|
||||
.processPlaceholder("list",
|
||||
instance.getVoucherManager().getVouchers().stream().map(Voucher::getKey).collect(Collectors.joining(", ")))
|
||||
StringJoiner joiner = new StringJoiner(", ");
|
||||
for (Voucher voucher : this.instance.getVoucherManager().getVouchers()) {
|
||||
joiner.add(voucher.getKey());
|
||||
}
|
||||
|
||||
this.instance.getLocale().getMessage("command.list.list")
|
||||
.processPlaceholder("list", joiner.toString())
|
||||
.sendPrefixedMessage(sender);
|
||||
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
|
@ -1,24 +1,23 @@
|
|||
package com.songoda.epicvouchers.commands;
|
||||
package com.craftaro.epicvouchers.commands;
|
||||
|
||||
import com.songoda.core.commands.AbstractCommand;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.core.commands.AbstractCommand;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CommandReload extends AbstractCommand {
|
||||
|
||||
final EpicVouchers instance;
|
||||
|
||||
public CommandReload(EpicVouchers instance) {
|
||||
super(false, "reload");
|
||||
super(CommandType.CONSOLE_OK, "reload");
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||
instance.reloadConfig();
|
||||
instance.getLocale().getMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||
this.instance.reloadConfig();
|
||||
this.instance.getLocale().getMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package com.songoda.epicvouchers.events;
|
||||
package com.craftaro.epicvouchers.events;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -7,8 +7,7 @@ import org.bukkit.event.Event;
|
|||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class ForceRedeemEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private final String voucher;
|
||||
|
@ -25,35 +24,35 @@ public class ForceRedeemEvent extends Event implements Cancellable {
|
|||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public String getVoucher() {
|
||||
return voucher;
|
||||
return this.voucher;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.songoda.epicvouchers.events;
|
||||
package com.craftaro.epicvouchers.events;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -8,8 +8,7 @@ import org.bukkit.event.HandlerList;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class VoucherReceiveEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private final String voucher;
|
||||
|
@ -28,39 +27,39 @@ public class VoucherReceiveEvent extends Event implements Cancellable {
|
|||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public String getVoucher() {
|
||||
return voucher;
|
||||
return this.voucher;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
return amount;
|
||||
return this.amount;
|
||||
}
|
||||
|
||||
public CommandSender getSender() {
|
||||
return sender;
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.songoda.epicvouchers.events;
|
||||
package com.craftaro.epicvouchers.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Cancellable;
|
||||
|
@ -7,8 +7,7 @@ import org.bukkit.event.HandlerList;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class VoucherRedeemEvent extends Event implements Cancellable {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private static final HandlerList HANDLER_LIST = new HandlerList();
|
||||
|
||||
private final Player player;
|
||||
private final String voucher;
|
||||
|
@ -25,35 +24,35 @@ public class VoucherRedeemEvent extends Event implements Cancellable {
|
|||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
public String getVoucher() {
|
||||
return voucher;
|
||||
return this.voucher;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
return this.item;
|
||||
}
|
||||
|
||||
public boolean getManual() {
|
||||
return manual;
|
||||
return this.manual;
|
||||
}
|
||||
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.cancelled = cancelled;
|
||||
public void setCancelled(boolean cancel) {
|
||||
this.cancelled = cancel;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
return HANDLER_LIST;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,13 +1,16 @@
|
|||
package com.songoda.epicvouchers.handlers;
|
||||
package com.craftaro.epicvouchers.handlers;
|
||||
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.sql.*;
|
||||
import java.sql.Connection;
|
||||
import java.sql.Date;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
public class Connections {
|
||||
|
||||
private final EpicVouchers instance;
|
||||
private Connection connection;
|
||||
|
||||
|
@ -16,18 +19,17 @@ public class Connections {
|
|||
}
|
||||
|
||||
public void openMySQL() {
|
||||
if (!instance.getConfig().getBoolean("Database.Activate Mysql Support") || connection == null) {
|
||||
if (!this.instance.getConfig().getBoolean("Database.Activate Mysql Support") || this.connection == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
String mysqlIP = instance.getConfig().getString("Database.IP");
|
||||
String mysqlPort = instance.getConfig().getString("Database.PORT");
|
||||
String mysqlDatabase = instance.getConfig().getString("Database.Database Name");
|
||||
String mysqlUsername = instance.getConfig().getString("Database.Username");
|
||||
String mysqlPassword = instance.getConfig().getString("Database.Password");
|
||||
String mysqlIP = this.instance.getConfig().getString("Database.IP");
|
||||
String mysqlPort = this.instance.getConfig().getString("Database.PORT");
|
||||
String mysqlDatabase = this.instance.getConfig().getString("Database.Database Name");
|
||||
String mysqlUsername = this.instance.getConfig().getString("Database.Username");
|
||||
String mysqlPassword = this.instance.getConfig().getString("Database.Password");
|
||||
|
||||
|
||||
connection = DriverManager.getConnection("jdbc:mysql://" + mysqlIP + ":" + mysqlPort + "/" + mysqlDatabase + "?useSSL=true?autoReconnect=true", mysqlUsername, mysqlPassword);
|
||||
this.connection = DriverManager.getConnection("jdbc:mysql://" + mysqlIP + ":" + mysqlPort + "/" + mysqlDatabase + "?useSSL=true?autoReconnect=true", mysqlUsername, mysqlPassword);
|
||||
System.out.println(TextUtils.formatText("&fSuccessfully created a connection with MySQL."));
|
||||
} catch (Exception error) {
|
||||
System.out.println(TextUtils.formatText("&cFailed to create a connection with MySQL."));
|
||||
|
@ -36,11 +38,11 @@ public class Connections {
|
|||
}
|
||||
|
||||
public void closeMySQL() {
|
||||
if (!instance.getConfig().getBoolean("Database.Activate Mysql Support") || connection == null) {
|
||||
if (!this.instance.getConfig().getBoolean("Database.Activate Mysql Support") || this.connection == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
connection.close();
|
||||
this.connection.close();
|
||||
System.out.println(TextUtils.formatText("&fSuccessfully closed the MySQL connection."));
|
||||
} catch (Exception error) {
|
||||
System.out.println(TextUtils.formatText("&cFailed to close the MySQL connection."));
|
||||
|
@ -49,14 +51,14 @@ public class Connections {
|
|||
}
|
||||
|
||||
public void saveRedeem(Player player, String voucher) {
|
||||
if (!instance.getConfig().getBoolean("Database.Activate Mysql Support") || connection == null) {
|
||||
if (!this.instance.getConfig().getBoolean("Database.Activate Mysql Support") || this.connection == null) {
|
||||
return;
|
||||
}
|
||||
Timestamp stamp = new Timestamp(System.currentTimeMillis());
|
||||
Date date = new Date(stamp.getTime());
|
||||
String time = date.toString();
|
||||
try {
|
||||
Statement statement = connection.createStatement();
|
||||
Statement statement = this.connection.createStatement();
|
||||
statement.execute("CREATE TABLE IF NOT EXISTS redeems (id INT NOT NULL AUTO_INCREMENT, player varchar(120) NOT NULL, voucher varchar(120) NOT NULL, timestamp varchar(120) NOT NULL, PRIMARY KEY (ID));");
|
||||
statement.execute("INSERT INTO redeems VALUES (default, '" + player.getName() + "', '" + voucher + "', '" + time + "');");
|
||||
statement.close();
|
||||
|
@ -66,5 +68,4 @@ public class Connections {
|
|||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.songoda.epicvouchers.libraries;
|
||||
package com.craftaro.epicvouchers.libraries;
|
||||
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.DyeColor;
|
||||
|
@ -7,7 +7,11 @@ import org.bukkit.block.banner.Pattern;
|
|||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.*;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
|
@ -18,13 +22,12 @@ import java.util.Set;
|
|||
|
||||
/**
|
||||
* A complete {@link ItemStack} inventory for FastInv (only works on 1.8+).
|
||||
*
|
||||
* <p>
|
||||
* The project is on <a href="https://github.com/MrMicky-FR/FastInv">GitHub</a>
|
||||
*
|
||||
* @author MrMicky
|
||||
*/
|
||||
public class ItemBuilder {
|
||||
|
||||
private final ItemStack item;
|
||||
private ItemMeta meta;
|
||||
|
||||
|
@ -60,7 +63,7 @@ public class ItemBuilder {
|
|||
}
|
||||
|
||||
public ItemMeta getMeta() {
|
||||
return meta;
|
||||
return this.meta;
|
||||
}
|
||||
|
||||
public ItemBuilder meta(ItemMeta meta) {
|
||||
|
@ -72,15 +75,15 @@ public class ItemBuilder {
|
|||
* Name:
|
||||
*/
|
||||
public boolean hasName() {
|
||||
return meta.hasDisplayName();
|
||||
return this.meta.hasDisplayName();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return meta.getDisplayName();
|
||||
return this.meta.getDisplayName();
|
||||
}
|
||||
|
||||
public ItemBuilder name(String name) {
|
||||
meta.setDisplayName(name);
|
||||
this.meta.setDisplayName(name);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -88,11 +91,11 @@ public class ItemBuilder {
|
|||
* Lore:
|
||||
*/
|
||||
public boolean hasLore() {
|
||||
return meta.hasLore();
|
||||
return this.meta.hasLore();
|
||||
}
|
||||
|
||||
public List<String> getLore() {
|
||||
return meta.getLore();
|
||||
return this.meta.getLore();
|
||||
}
|
||||
|
||||
public ItemBuilder lore(String... lore) {
|
||||
|
@ -100,7 +103,7 @@ public class ItemBuilder {
|
|||
}
|
||||
|
||||
public ItemBuilder lore(List<String> lore) {
|
||||
meta.setLore(lore);
|
||||
this.meta.setLore(lore);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -108,28 +111,28 @@ public class ItemBuilder {
|
|||
* Enchantments:
|
||||
*/
|
||||
public boolean hasEnchants() {
|
||||
return meta.hasEnchants();
|
||||
return this.meta.hasEnchants();
|
||||
}
|
||||
|
||||
public boolean hasEnchant(Enchantment enchantment) {
|
||||
return meta.hasEnchant(enchantment);
|
||||
return this.meta.hasEnchant(enchantment);
|
||||
}
|
||||
|
||||
public boolean hasConflictingEnchant(Enchantment enchantment) {
|
||||
return meta.hasConflictingEnchant(enchantment);
|
||||
return this.meta.hasConflictingEnchant(enchantment);
|
||||
}
|
||||
|
||||
public Map<Enchantment, Integer> getEnchants() {
|
||||
return meta.getEnchants();
|
||||
return this.meta.getEnchants();
|
||||
}
|
||||
|
||||
public ItemBuilder enchant(Enchantment enchantment, int level) {
|
||||
meta.addEnchant(enchantment, level, true);
|
||||
this.meta.addEnchant(enchantment, level, true);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder removeEnchant(Enchantment enchantment) {
|
||||
meta.removeEnchant(enchantment);
|
||||
this.meta.removeEnchant(enchantment);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -141,20 +144,20 @@ public class ItemBuilder {
|
|||
* Flags:
|
||||
*/
|
||||
public boolean hasFlag(ItemFlag flag) {
|
||||
return meta.hasItemFlag(flag);
|
||||
return this.meta.hasItemFlag(flag);
|
||||
}
|
||||
|
||||
public Set<ItemFlag> getFlags() {
|
||||
return meta.getItemFlags();
|
||||
return this.meta.getItemFlags();
|
||||
}
|
||||
|
||||
public ItemBuilder addFlags(ItemFlag... flags) {
|
||||
meta.addItemFlags(flags);
|
||||
this.meta.addItemFlags(flags);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder removeFlags(ItemFlag... flags) {
|
||||
meta.removeItemFlags(flags);
|
||||
this.meta.removeItemFlags(flags);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -162,16 +165,15 @@ public class ItemBuilder {
|
|||
* Unbreakability:
|
||||
*/
|
||||
public boolean isUnbreakable() {
|
||||
return meta.isUnbreakable();
|
||||
return this.meta.isUnbreakable();
|
||||
}
|
||||
|
||||
public ItemBuilder unbreakable() {
|
||||
return unbreakable(true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemBuilder unbreakable(boolean unbreakable) {
|
||||
meta.setUnbreakable(unbreakable);
|
||||
this.meta.setUnbreakable(unbreakable);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -187,36 +189,36 @@ public class ItemBuilder {
|
|||
* Banners:
|
||||
*/
|
||||
public DyeColor getBannerBaseColor() {
|
||||
return ((BannerMeta) meta).getBaseColor();
|
||||
return ((BannerMeta) this.meta).getBaseColor();
|
||||
}
|
||||
|
||||
public List<Pattern> getBannerPatterns() {
|
||||
return ((BannerMeta) meta).getPatterns();
|
||||
return ((BannerMeta) this.meta).getPatterns();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemBuilder bannerBaseColor(DyeColor color) {
|
||||
((BannerMeta) meta).setBaseColor(color);
|
||||
((BannerMeta) this.meta).setBaseColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder bannerPatterns(List<Pattern> patterns) {
|
||||
((BannerMeta) meta).setPatterns(patterns);
|
||||
((BannerMeta) this.meta).setPatterns(patterns);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder bannerPattern(int i, Pattern pattern) {
|
||||
((BannerMeta) meta).setPattern(i, pattern);
|
||||
((BannerMeta) this.meta).setPattern(i, pattern);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder addBannerPatterns(Pattern pattern) {
|
||||
((BannerMeta) meta).addPattern(pattern);
|
||||
((BannerMeta) this.meta).addPattern(pattern);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder removeBannerPattern(int i) {
|
||||
((BannerMeta) meta).removePattern(i);
|
||||
((BannerMeta) this.meta).removePattern(i);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -224,11 +226,11 @@ public class ItemBuilder {
|
|||
* Leather armor:
|
||||
*/
|
||||
public Color getLeatherArmorColor() {
|
||||
return ((LeatherArmorMeta) meta).getColor();
|
||||
return ((LeatherArmorMeta) this.meta).getColor();
|
||||
}
|
||||
|
||||
public ItemBuilder leatherArmorColor(Color color) {
|
||||
((LeatherArmorMeta) meta).setColor(color);
|
||||
((LeatherArmorMeta) this.meta).setColor(color);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -236,23 +238,23 @@ public class ItemBuilder {
|
|||
* Skulls:
|
||||
*/
|
||||
public boolean hasSkullOwner() {
|
||||
return ((SkullMeta) meta).hasOwner();
|
||||
return ((SkullMeta) this.meta).hasOwner();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public String getSkullOwner() {
|
||||
return ((SkullMeta) meta).getOwner();
|
||||
return ((SkullMeta) this.meta).getOwner();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public ItemBuilder skullOwner(String owner) {
|
||||
item.setDurability((short) 3);
|
||||
((SkullMeta) meta).setOwner(owner);
|
||||
this.item.setDurability((short) 3);
|
||||
((SkullMeta) this.meta).setOwner(owner);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemBuilder durability(int durability) {
|
||||
item.setDurability((short) durability);
|
||||
this.item.setDurability((short) durability);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -260,19 +262,19 @@ public class ItemBuilder {
|
|||
* Potions:
|
||||
*/
|
||||
public boolean hasPotionEffect(PotionEffectType type) {
|
||||
return ((PotionMeta) meta).hasCustomEffect(type);
|
||||
return ((PotionMeta) this.meta).hasCustomEffect(type);
|
||||
}
|
||||
|
||||
public boolean hasPotionEffects() {
|
||||
return ((PotionMeta) meta).hasCustomEffects();
|
||||
return ((PotionMeta) this.meta).hasCustomEffects();
|
||||
}
|
||||
|
||||
public List<PotionEffect> getPotionEffects() {
|
||||
return ((PotionMeta) meta).getCustomEffects();
|
||||
return ((PotionMeta) this.meta).getCustomEffects();
|
||||
}
|
||||
|
||||
public ItemBuilder addPotionEffect(PotionEffect effect, boolean overwrite) {
|
||||
((PotionMeta) meta).addCustomEffect(effect, overwrite);
|
||||
((PotionMeta) this.meta).addCustomEffect(effect, overwrite);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -280,7 +282,7 @@ public class ItemBuilder {
|
|||
* Build the ItemStack.
|
||||
*/
|
||||
public ItemStack build() {
|
||||
item.setItemMeta(meta);
|
||||
return item;
|
||||
this.item.setItemMeta(this.meta);
|
||||
return this.item;
|
||||
}
|
||||
}
|
|
@ -1,10 +1,14 @@
|
|||
package com.songoda.epicvouchers.libraries.inventory;
|
||||
package com.craftaro.epicvouchers.libraries.inventory;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
@ -25,13 +29,12 @@ import java.util.Set;
|
|||
* @version 2.0.3 - Now supports async operations
|
||||
*/
|
||||
public class FastInv implements InventoryHolder {
|
||||
|
||||
private static Plugin plugin = null;
|
||||
private boolean cancelTasksOnClose = true, cancelled = true;
|
||||
private Set<FastInvCloseListener> closeListeners = new HashSet<>();
|
||||
private Set<FastInvClickListener> clickListeners = new HashSet<>();
|
||||
private Map<Integer, FastInvClickListener> itemListeners = new HashMap<>();
|
||||
private Set<BukkitTask> tasks = new HashSet<>();
|
||||
private final Set<FastInvCloseListener> closeListeners = new HashSet<>();
|
||||
private final Set<FastInvClickListener> clickListeners = new HashSet<>();
|
||||
private final Map<Integer, FastInvClickListener> itemListeners = new HashMap<>();
|
||||
private final Set<BukkitTask> tasks = new HashSet<>();
|
||||
private Inventory inventory;
|
||||
|
||||
/**
|
||||
|
@ -80,9 +83,9 @@ public class FastInv implements InventoryHolder {
|
|||
|
||||
runSync(() -> {
|
||||
if (type == InventoryType.CHEST && size > 0) {
|
||||
inventory = Bukkit.createInventory(this, size, title);
|
||||
this.inventory = Bukkit.createInventory(this, size, title);
|
||||
} else {
|
||||
inventory = Bukkit.createInventory(this, type, title);
|
||||
this.inventory = Bukkit.createInventory(this, type, title);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -118,7 +121,7 @@ public class FastInv implements InventoryHolder {
|
|||
*/
|
||||
public FastInv addItem(ItemStack item, FastInvClickListener listener) {
|
||||
runSync(() -> {
|
||||
int slot = inventory.firstEmpty();
|
||||
int slot = this.inventory.firstEmpty();
|
||||
if (slot >= 0) {
|
||||
addItem(slot, item, listener);
|
||||
}
|
||||
|
@ -129,29 +132,29 @@ public class FastInv implements InventoryHolder {
|
|||
/**
|
||||
* Add an {@link ItemStack} to the menus on a specific slot.
|
||||
*
|
||||
* @param slot The slot of the item.
|
||||
* @param item The item to add.
|
||||
* @param slot The slot of the item.
|
||||
* @param itemStack The item to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int slot, ItemStack item) {
|
||||
return addItem(slot, item, null);
|
||||
public FastInv addItem(int slot, ItemStack itemStack) {
|
||||
return addItem(slot, itemStack, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on specific slot with a {@link FastInvClickListener} to handle clicks.
|
||||
*
|
||||
* @param slot The slot of the item.
|
||||
* @param itemStack The icon to add.
|
||||
* @param slot The slot of the item.
|
||||
* @param itemStack The icon to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int slot, ItemStack itemStack, FastInvClickListener listener) {
|
||||
runSync(() -> {
|
||||
inventory.setItem(slot, itemStack);
|
||||
this.inventory.setItem(slot, itemStack);
|
||||
|
||||
if (listener != null) {
|
||||
itemListeners.put(slot, listener);
|
||||
this.itemListeners.put(slot, listener);
|
||||
} else {
|
||||
itemListeners.remove(slot);
|
||||
this.itemListeners.remove(slot);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -161,27 +164,27 @@ public class FastInv implements InventoryHolder {
|
|||
/**
|
||||
* Add an {@link ItemStack} to the menus on a range of slots.
|
||||
*
|
||||
* @param slotFrom Starting slot to put the item in.
|
||||
* @param slotTo Ending slot to put the item in.
|
||||
* @param item The item to add.
|
||||
* @param slotFrom Starting slot to put the item in.
|
||||
* @param slotTo Ending slot to put the item in.
|
||||
* @param itemStack The item to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int slotFrom, int slotTo, ItemStack item) {
|
||||
return addItem(slotFrom, slotTo, item, null);
|
||||
public FastInv addItem(int slotFrom, int slotTo, ItemStack itemStack) {
|
||||
return addItem(slotFrom, slotTo, itemStack, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an {@link ItemStack} to the menus on a range of slots with a {@link FastInvClickListener} to handle clicks.
|
||||
*
|
||||
* @param slotFrom Starting slot to put the item in.
|
||||
* @param slotTo Ending slot to put the item in.
|
||||
* @param item The item to add.
|
||||
* @param listener The IconClickListener for the item.
|
||||
* @param slotFrom Starting slot to put the item in.
|
||||
* @param slotTo Ending slot to put the item in.
|
||||
* @param itemStack The item to add.
|
||||
* @param listener The IconClickListener for the item.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv addItem(int slotFrom, int slotTo, ItemStack item, FastInvClickListener listener) {
|
||||
public FastInv addItem(int slotFrom, int slotTo, ItemStack itemStack, FastInvClickListener listener) {
|
||||
for (int i = slotFrom; i <= slotTo; i++) {
|
||||
addItem(i, item, listener);
|
||||
addItem(i, itemStack, listener);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -204,10 +207,10 @@ public class FastInv implements InventoryHolder {
|
|||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv edge(ItemStack item) {
|
||||
int height = inventory.getSize() / 9;
|
||||
int height = this.inventory.getSize() / 9;
|
||||
|
||||
addItem(0, 9, item);
|
||||
addItem(inventory.getSize() - 9, inventory.getSize() - 1, item);
|
||||
addItem(this.inventory.getSize() - 9, this.inventory.getSize() - 1, item);
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
addItem(i * 9, item);
|
||||
|
@ -234,8 +237,8 @@ public class FastInv implements InventoryHolder {
|
|||
|
||||
public FastInv fill(ItemStack itemStack, FastInvClickListener listener) {
|
||||
runSync(() -> {
|
||||
for (int i = 0; i < inventory.getSize(); i++) {
|
||||
if (inventory.getItem(i) == null) {
|
||||
for (int i = 0; i < this.inventory.getSize(); i++) {
|
||||
if (this.inventory.getItem(i) == null) {
|
||||
addItem(i, itemStack, listener);
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +246,7 @@ public class FastInv implements InventoryHolder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public FastInv fill(ItemStack itemStack) {
|
||||
public FastInv fill(ItemStack itemStack) {
|
||||
return fill(itemStack, null);
|
||||
}
|
||||
|
||||
|
@ -254,7 +257,7 @@ public class FastInv implements InventoryHolder {
|
|||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv onClose(FastInvCloseListener listener) {
|
||||
closeListeners.add(listener);
|
||||
this.closeListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -265,17 +268,17 @@ public class FastInv implements InventoryHolder {
|
|||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public FastInv onClick(FastInvClickListener listener) {
|
||||
clickListeners.add(listener);
|
||||
this.clickListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
public FastInv setDefaultCancel(boolean value) {
|
||||
cancelled = value;
|
||||
this.cancelled = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean getDefaultCancel() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,7 +301,7 @@ public class FastInv implements InventoryHolder {
|
|||
* @return This FastInv instance, for chaining
|
||||
*/
|
||||
public FastInv onUpdate(long delay, long period, Runnable runnable) {
|
||||
tasks.add(Bukkit.getScheduler().runTaskTimer(plugin, runnable, delay, period));
|
||||
this.tasks.add(Bukkit.getScheduler().runTaskTimer(plugin, runnable, delay, period));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -308,7 +311,7 @@ public class FastInv implements InventoryHolder {
|
|||
* @param player The player to open the menu.
|
||||
*/
|
||||
public void open(Player player) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> player.openInventory(inventory));
|
||||
Bukkit.getScheduler().runTask(plugin, () -> player.openInventory(this.inventory));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -319,7 +322,7 @@ public class FastInv implements InventoryHolder {
|
|||
public void open(Player... players) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
for (Player p : players) {
|
||||
p.openInventory(inventory);
|
||||
p.openInventory(this.inventory);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -328,8 +331,8 @@ public class FastInv implements InventoryHolder {
|
|||
* Cancel all tasks.
|
||||
*/
|
||||
public void cancelTasks() {
|
||||
tasks.forEach(BukkitTask::cancel);
|
||||
tasks.clear();
|
||||
this.tasks.forEach(BukkitTask::cancel);
|
||||
this.tasks.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -355,8 +358,8 @@ public class FastInv implements InventoryHolder {
|
|||
|
||||
public static abstract class FastInvEvent {
|
||||
|
||||
private Player player;
|
||||
private FastInv inventory;
|
||||
private final Player player;
|
||||
private final FastInv inventory;
|
||||
private boolean cancelled;
|
||||
|
||||
FastInvEvent(Player player, FastInv inventory, boolean cancelled) {
|
||||
|
@ -371,7 +374,7 @@ public class FastInv implements InventoryHolder {
|
|||
* @return This associated FastInv instance.
|
||||
*/
|
||||
public FastInv getInventory() {
|
||||
return inventory;
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -380,7 +383,7 @@ public class FastInv implements InventoryHolder {
|
|||
* @return the player who clicked.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -389,7 +392,7 @@ public class FastInv implements InventoryHolder {
|
|||
* @return Whether the event was cancelled.
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -404,10 +407,10 @@ public class FastInv implements InventoryHolder {
|
|||
|
||||
public static class FastInvClickEvent extends FastInvEvent {
|
||||
|
||||
private int slot;
|
||||
private ItemStack item;
|
||||
private InventoryAction action;
|
||||
private ClickType clickType;
|
||||
private final int slot;
|
||||
private final ItemStack item;
|
||||
private final InventoryAction action;
|
||||
private final ClickType clickType;
|
||||
|
||||
private FastInvClickEvent(Player player, FastInv inventory, int slot, ItemStack item,
|
||||
boolean cancelled, InventoryAction action, ClickType clickType) {
|
||||
|
@ -468,7 +471,7 @@ public class FastInv implements InventoryHolder {
|
|||
*/
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
private static Listener getListener() {
|
||||
|
@ -542,7 +545,7 @@ public class FastInv implements InventoryHolder {
|
|||
public void reOpen(Player player) {
|
||||
player.closeInventory();
|
||||
refresh();
|
||||
player.openInventory(inventory);
|
||||
player.openInventory(this.inventory);
|
||||
}
|
||||
|
||||
public void refresh() {
|
|
@ -1,11 +1,15 @@
|
|||
package com.songoda.epicvouchers.libraries.inventory;
|
||||
package com.craftaro.epicvouchers.libraries.inventory;
|
||||
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.*;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
@ -27,13 +31,12 @@ import java.util.function.Consumer;
|
|||
* @version 2.0.3 - Now supports async operations
|
||||
*/
|
||||
public class IconInv implements InventoryHolder {
|
||||
|
||||
private static Plugin plugin = null;
|
||||
private boolean cancelTasksOnClose = true, cancelled = true;
|
||||
private Set<IconInvCloseListener> closeListeners = new HashSet<>();
|
||||
private Set<IconClickListener> clickListeners = new HashSet<>();
|
||||
private Map<Integer, Icon> itemListeners = new HashMap<>();
|
||||
private Set<BukkitTask> tasks = new HashSet<>();
|
||||
private final Set<IconInvCloseListener> closeListeners = new HashSet<>();
|
||||
private final Set<IconClickListener> clickListeners = new HashSet<>();
|
||||
private final Map<Integer, Icon> itemListeners = new HashMap<>();
|
||||
private final Set<BukkitTask> tasks = new HashSet<>();
|
||||
private Inventory inventory;
|
||||
|
||||
/**
|
||||
|
@ -82,9 +85,9 @@ public class IconInv implements InventoryHolder {
|
|||
|
||||
runSync(() -> {
|
||||
if (type == InventoryType.CHEST && size > 0) {
|
||||
inventory = Bukkit.createInventory(this, size, title);
|
||||
this.inventory = Bukkit.createInventory(this, size, title);
|
||||
} else {
|
||||
inventory = Bukkit.createInventory(this, type, title);
|
||||
this.inventory = Bukkit.createInventory(this, type, title);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -104,12 +107,12 @@ public class IconInv implements InventoryHolder {
|
|||
/**
|
||||
* Add an {@link ItemStack} to the menus with a {@link IconClickListener} to handle clicks.
|
||||
*
|
||||
* @param icon The icon to add.
|
||||
* @param icon The icon to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public IconInv addIcon(Icon icon) {
|
||||
runSync(() -> {
|
||||
int slot = inventory.firstEmpty();
|
||||
int slot = this.inventory.firstEmpty();
|
||||
if (slot >= 0) {
|
||||
addIcon(slot, icon);
|
||||
}
|
||||
|
@ -126,8 +129,8 @@ public class IconInv implements InventoryHolder {
|
|||
*/
|
||||
public IconInv addIcon(int slot, Icon icon) {
|
||||
runSync(() -> {
|
||||
inventory.setItem(slot, icon.getItemStack());
|
||||
itemListeners.put(slot, icon);
|
||||
this.inventory.setItem(slot, icon.getItemStack());
|
||||
this.itemListeners.put(slot, icon);
|
||||
});
|
||||
|
||||
return this;
|
||||
|
@ -155,10 +158,10 @@ public class IconInv implements InventoryHolder {
|
|||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public IconInv edge(Icon icon) {
|
||||
int height = inventory.getSize() / 9;
|
||||
int height = this.inventory.getSize() / 9;
|
||||
|
||||
addIcon(0, 9, icon);
|
||||
addIcon(inventory.getSize() - 9, inventory.getSize() - 1, icon);
|
||||
addIcon(this.inventory.getSize() - 9, this.inventory.getSize() - 1, icon);
|
||||
|
||||
for (int i = 0; i < height; i++) {
|
||||
addIcon(i * 9, icon);
|
||||
|
@ -171,8 +174,8 @@ public class IconInv implements InventoryHolder {
|
|||
/**
|
||||
* Add an {@link ItemStack} to the menus on multiples slots with a {@link IconClickListener} to handle click.
|
||||
*
|
||||
* @param slots The slots to place the item.
|
||||
* @param icon The icon to add.
|
||||
* @param slots The slots to place the item.
|
||||
* @param icon The icon to add.
|
||||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public IconInv addIcon(int[] slots, Icon icon) {
|
||||
|
@ -184,8 +187,8 @@ public class IconInv implements InventoryHolder {
|
|||
|
||||
public IconInv fill(Icon icon) {
|
||||
runSync(() -> {
|
||||
for (int i = 0; i < inventory.getSize(); i++) {
|
||||
if (inventory.getItem(i) == null) {
|
||||
for (int i = 0; i < this.inventory.getSize(); i++) {
|
||||
if (this.inventory.getItem(i) == null) {
|
||||
addIcon(i, icon);
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +215,7 @@ public class IconInv implements InventoryHolder {
|
|||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public IconInv onClose(IconInvCloseListener listener) {
|
||||
closeListeners.add(listener);
|
||||
this.closeListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -223,7 +226,7 @@ public class IconInv implements InventoryHolder {
|
|||
* @return This FastInv instance, for chaining.
|
||||
*/
|
||||
public IconInv onClick(IconClickListener listener) {
|
||||
clickListeners.add(listener);
|
||||
this.clickListeners.add(listener);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -247,7 +250,7 @@ public class IconInv implements InventoryHolder {
|
|||
* @return This FastInv instance, for chaining
|
||||
*/
|
||||
public IconInv onUpdate(long delay, long period, Runnable runnable) {
|
||||
tasks.add(Bukkit.getScheduler().runTaskTimer(plugin, runnable, delay, period));
|
||||
this.tasks.add(Bukkit.getScheduler().runTaskTimer(plugin, runnable, delay, period));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -257,7 +260,7 @@ public class IconInv implements InventoryHolder {
|
|||
* @param player The player to open the menu.
|
||||
*/
|
||||
public void open(Player player) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> player.openInventory(inventory));
|
||||
Bukkit.getScheduler().runTask(plugin, () -> player.openInventory(this.inventory));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -268,7 +271,7 @@ public class IconInv implements InventoryHolder {
|
|||
public void open(Player... players) {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
for (Player p : players) {
|
||||
p.openInventory(inventory);
|
||||
p.openInventory(this.inventory);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -277,8 +280,8 @@ public class IconInv implements InventoryHolder {
|
|||
* Cancel all tasks.
|
||||
*/
|
||||
public void cancelTasks() {
|
||||
tasks.forEach(BukkitTask::cancel);
|
||||
tasks.clear();
|
||||
this.tasks.forEach(BukkitTask::cancel);
|
||||
this.tasks.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -313,10 +316,9 @@ public class IconInv implements InventoryHolder {
|
|||
void onClose(IconInvCloseEvent event);
|
||||
}
|
||||
|
||||
public static abstract class IconEvent {
|
||||
|
||||
private Player player;
|
||||
private IconInv inventory;
|
||||
public abstract static class IconEvent {
|
||||
private final Player player;
|
||||
private final IconInv inventory;
|
||||
private boolean cancelled;
|
||||
|
||||
IconEvent(Player player, IconInv inventory, boolean cancelled) {
|
||||
|
@ -331,7 +333,7 @@ public class IconInv implements InventoryHolder {
|
|||
* @return This associated FastInv instance.
|
||||
*/
|
||||
public IconInv getInventory() {
|
||||
return inventory;
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -340,7 +342,7 @@ public class IconInv implements InventoryHolder {
|
|||
* @return the player who clicked.
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -349,7 +351,7 @@ public class IconInv implements InventoryHolder {
|
|||
* @return Whether the event was cancelled.
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -363,11 +365,10 @@ public class IconInv implements InventoryHolder {
|
|||
}
|
||||
|
||||
public static class IconClickEvent extends IconEvent {
|
||||
|
||||
private int slot;
|
||||
private ItemStack item;
|
||||
private InventoryAction action;
|
||||
private ClickType clickType;
|
||||
private final int slot;
|
||||
private final ItemStack item;
|
||||
private final InventoryAction action;
|
||||
private final ClickType clickType;
|
||||
|
||||
private IconClickEvent(Player player, IconInv inventory, int slot, ItemStack item,
|
||||
boolean cancelled, InventoryAction action, ClickType clickType) {
|
||||
|
@ -422,11 +423,11 @@ public class IconInv implements InventoryHolder {
|
|||
}
|
||||
|
||||
public boolean getDefaultCancel() {
|
||||
return cancelled;
|
||||
return this.cancelled;
|
||||
}
|
||||
|
||||
public IconInv setDefaultCancel(boolean value) {
|
||||
cancelled = value;
|
||||
this.cancelled = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -437,7 +438,7 @@ public class IconInv implements InventoryHolder {
|
|||
*/
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
return this.inventory;
|
||||
}
|
||||
|
||||
private static Listener getListener() {
|
|
@ -1,15 +1,16 @@
|
|||
package com.songoda.epicvouchers.libraries.inventory;
|
||||
package com.craftaro.epicvouchers.libraries.inventory;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.menus.ActionMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.SkullUtils;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.menus.ActionMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.BiConsumer;
|
||||
|
@ -41,65 +42,60 @@ public abstract class PlayersMenu extends FastInv {
|
|||
@Override
|
||||
public void refresh() {
|
||||
fill(null);
|
||||
final int startIndex = page * (players.size() - 1);
|
||||
final int startIndex = this.page * (this.players.size() - 1);
|
||||
|
||||
IntStream.rangeClosed(0, SLOTS).forEach(slot -> {
|
||||
IntStream.rangeClosed(0, this.SLOTS).forEach(slot -> {
|
||||
int index = startIndex + slot;
|
||||
|
||||
if (index >= players.size()) {
|
||||
if (index >= this.players.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = players.get(index);
|
||||
Player player = this.players.get(index);
|
||||
|
||||
ItemStack itemStack = CompatibleMaterial.PLAYER_HEAD.getItem();
|
||||
ItemStack itemStack = SkullUtils.getSkull(player.getUniqueId());
|
||||
|
||||
SkullMeta skullMeta = (SkullMeta) itemStack.getItemMeta();
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
itemMeta.setDisplayName(YELLOW + player.getName());
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
|
||||
try {
|
||||
skullMeta.setOwningPlayer(player);
|
||||
} catch (Throwable ignore) {
|
||||
}
|
||||
|
||||
skullMeta.setDisplayName(YELLOW + player.getName());
|
||||
itemStack.setItemMeta(skullMeta);
|
||||
|
||||
addItem(slot, itemStack, event -> playerConsumer.accept(event.getPlayer(), player));
|
||||
addItem(slot, itemStack, event -> this.playerConsumer.accept(event.getPlayer(), player));
|
||||
});
|
||||
|
||||
if (players.size() / SLOTS > page) {
|
||||
if (this.players.size() / this.SLOTS > this.page) {
|
||||
addItem(26, new ItemBuilder(ARROW)
|
||||
.name(YELLOW + "Next")
|
||||
.lore(GRAY + "Click to go to the next page of players")
|
||||
.build(), event -> {
|
||||
page++;
|
||||
this.page++;
|
||||
refresh();
|
||||
});
|
||||
} else {
|
||||
addItem(26, null);
|
||||
}
|
||||
|
||||
if (page > 0) {
|
||||
if (this.page > 0) {
|
||||
addItem(18, new ItemBuilder(ARROW)
|
||||
.name(YELLOW + "Previous")
|
||||
.lore(GRAY + "Click to go to the previous page of players")
|
||||
.build(), event -> {
|
||||
page--;
|
||||
this.page--;
|
||||
refresh();
|
||||
});
|
||||
} else {
|
||||
addItem(18, new ItemBuilder(BARRIER)
|
||||
.name(YELLOW + "Return")
|
||||
.lore(GRAY + "Return to the action menu")
|
||||
.addGlow().build(), event -> new ActionMenu(instance, voucher).open(event.getPlayer()));
|
||||
.addGlow().build(), event -> new ActionMenu(this.instance, this.voucher).open(event.getPlayer()));
|
||||
}
|
||||
|
||||
if (instance.getConfig().getBoolean("Interface.Fill Interfaces With Glass")) {
|
||||
ItemStack fillItem = CompatibleMaterial.GRAY_STAINED_GLASS_PANE.getItem();
|
||||
if (this.instance.getConfig().getBoolean("Interface.Fill Interfaces With Glass")) {
|
||||
ItemStack fillItem = XMaterial.GRAY_STAINED_GLASS_PANE.parseItem();
|
||||
|
||||
IntStream.rangeClosed(SLOTS + 1, 26).forEach(slot -> {
|
||||
if (getInventory().getItem(slot) == null)
|
||||
IntStream.rangeClosed(this.SLOTS + 1, 26).forEach(slot -> {
|
||||
if (getInventory().getItem(slot) == null) {
|
||||
addItem(slot, new ItemBuilder(fillItem).name(ChatColor.RESET.toString()).build());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Icon {
|
||||
private final ItemStack itemStack;
|
||||
private final Consumer<IconInv.IconClickEvent> consumer;
|
||||
|
||||
public Icon(ItemStack item) {
|
||||
this(item, event -> {
|
||||
});
|
||||
}
|
||||
|
||||
public Icon(ItemStack item, Consumer<IconInv.IconClickEvent> consumer) {
|
||||
this.itemStack = item;
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public void run(IconInv.IconClickEvent e) {
|
||||
this.consumer.accept(e);
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return this.itemStack;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
|
@ -0,0 +1,32 @@
|
|||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.craftaro.core.input.ChatPrompt;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.utils.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import static org.bukkit.ChatColor.GRAY;
|
||||
import static org.bukkit.ChatColor.YELLOW;
|
||||
import static org.bukkit.Material.PAPER;
|
||||
|
||||
public class ListEntryIcon extends Icon {
|
||||
public ListEntryIcon(EpicVouchers instance, String entry, BiConsumer<Player, String> onRemove, BiConsumer<Player, Pair<String, String>> onEdit) {
|
||||
super(new ItemBuilder(PAPER)
|
||||
.name(YELLOW + entry)
|
||||
.lore(GRAY + "Right click to edit", GRAY + "Left click to remove")
|
||||
.build(), clickEvent -> {
|
||||
if (clickEvent.getClickType() == ClickType.LEFT) {
|
||||
onRemove.accept(clickEvent.getPlayer(), entry);
|
||||
return;
|
||||
}
|
||||
ChatPrompt.showPrompt(instance, clickEvent.getPlayer(),
|
||||
pEvent -> Bukkit.getScheduler().runTaskLater(instance,
|
||||
() -> onEdit.accept(clickEvent.getPlayer(), new Pair<>(entry, pEvent.getMessage().trim())), 1L));
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.input.ChatPrompt;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -18,7 +19,6 @@ import static org.bukkit.ChatColor.GRAY;
|
|||
import static org.bukkit.ChatColor.WHITE;
|
||||
|
||||
public class StringIcon extends Icon {
|
||||
|
||||
public StringIcon(EpicVouchers instance, String string, String current, BiConsumer<Player, String> consumer) {
|
||||
this(instance, string, current, consumer, s -> true);
|
||||
}
|
||||
|
@ -38,31 +38,26 @@ public class StringIcon extends Icon {
|
|||
.lore(GRAY + "Current: " + WHITE + current, GRAY + "Right click to edit", GRAY + "Left click to clear").build(), current, consumer, predicate, noLeft);
|
||||
}
|
||||
|
||||
public StringIcon(EpicVouchers instance, ItemStack itemStack, String current, BiConsumer<Player, String> consumer) {
|
||||
this(instance, itemStack, current, consumer, s -> true, false);
|
||||
public StringIcon(EpicVouchers instance, ItemStack item, String current, BiConsumer<Player, String> consumer) {
|
||||
this(instance, item, current, consumer, s -> true, false);
|
||||
}
|
||||
|
||||
public StringIcon(EpicVouchers instance, ItemStack itemStack, String current, BiConsumer<Player, String> consumer, Predicate<String> predicate, boolean noLeft) {
|
||||
super(itemStack, event -> {
|
||||
public StringIcon(EpicVouchers instance, ItemStack item, String current, BiConsumer<Player, String> consumer, Predicate<String> predicate, boolean noLeft) {
|
||||
super(item, event -> {
|
||||
if (!noLeft && event.getClickType() == ClickType.LEFT) {
|
||||
consumer.accept(event.getPlayer(), "");
|
||||
event.getPlayer().sendMessage(TextUtils.formatText("&7Successfully cleared&7."));
|
||||
} else {
|
||||
AnvilGui gui = new AnvilGui(event.getPlayer());
|
||||
gui.setTitle("current:" + current);
|
||||
gui.setAction(aevent -> {
|
||||
final String msg = gui.getInputText().trim();
|
||||
ChatPrompt.showPrompt(instance, event.getPlayer(), TextUtils.formatText("&7Enter a new value. Current: &r" + current), aevent -> {
|
||||
final String msg = aevent.getMessage().trim();
|
||||
if (!predicate.test(msg)) {
|
||||
event.getPlayer().sendMessage(TextUtils.formatText("&cFailed to set value to: " + msg));
|
||||
return;
|
||||
}
|
||||
consumer.accept(event.getPlayer(), msg);
|
||||
event.getPlayer().sendMessage(TextUtils.formatText("&7Successfully set to &r" + msg + "&7."));
|
||||
Bukkit.getScheduler().runTaskLater(instance, () -> consumer.accept(event.getPlayer(), msg), 1L);
|
||||
});
|
||||
instance.getGuiManager().showGUI(event.getPlayer(), gui);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.StringListMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.StringListMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.craftaro.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ToggleableIcon extends Icon {
|
||||
private final Consumer<IconInv.IconClickEvent> consumer;
|
||||
|
||||
public ToggleableIcon(String displayname, Consumer<IconInv.IconClickEvent> consumer, boolean state) {
|
||||
super(new ItemBuilder(Material.PAPER)
|
||||
.name(ChatColor.YELLOW + displayname)
|
||||
.lore(state ? ChatColor.GREEN + "ENABLED" : ChatColor.RED + "DISABLED")
|
||||
.build(), event -> {
|
||||
});
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(IconInv.IconClickEvent e) {
|
||||
this.consumer.accept(e);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package com.songoda.epicvouchers.listeners;
|
||||
package com.craftaro.epicvouchers.listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
@ -8,7 +8,6 @@ import java.util.HashMap;
|
|||
import java.util.UUID;
|
||||
|
||||
public class PlayerCommandListener implements Listener {
|
||||
|
||||
private static final HashMap<UUID, String> commands = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
|
@ -23,8 +22,8 @@ public class PlayerCommandListener implements Listener {
|
|||
public static void addCommand(UUID uuid, String command) {
|
||||
commands.put(uuid, command);
|
||||
}
|
||||
|
||||
public static void removeCommand(UUID uuid) {
|
||||
commands.remove(uuid);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,112 @@
|
|||
package com.craftaro.epicvouchers.listeners;
|
||||
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.settings.Settings;
|
||||
import com.craftaro.epicvouchers.utils.CachedSet;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class PlayerInteractListener implements Listener {
|
||||
private final EpicVouchers instance;
|
||||
|
||||
private final CachedSet<ItemStack> itemsThatGotLegacyChecked = new CachedSet<>(3 * 60);
|
||||
|
||||
public PlayerInteractListener(EpicVouchers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void voucherListener(PlayerInteractEvent e) {
|
||||
boolean legacyCheckEnabled = Settings.CHECK_FOR_LEGACY_ITEMS.getBoolean();
|
||||
|
||||
ItemStack item = e.getItem();
|
||||
if (item == null || !isRightClickAction(e.getAction())) {
|
||||
return;
|
||||
}
|
||||
|
||||
NBTItem nbtItem = new NBTItem(item);
|
||||
|
||||
boolean itemHasVoucher = nbtItem.hasTag("epicvouchers:voucher");
|
||||
boolean itemHasBeenLegacyChecked = !legacyCheckEnabled || this.itemsThatGotLegacyChecked.contains(item);
|
||||
if (!itemHasVoucher && itemHasBeenLegacyChecked) {
|
||||
return;
|
||||
}
|
||||
|
||||
Voucher voucher;
|
||||
Collection<Voucher> allVouchers = this.instance.getVoucherManager().getVouchers();
|
||||
|
||||
if (itemHasVoucher) {
|
||||
String voucherKey = nbtItem.getString("epicvouchers:voucher");
|
||||
voucher = findVoucherForKey(voucherKey, allVouchers);
|
||||
if (voucher != null) {
|
||||
e.setCancelled(true);
|
||||
voucher.redeemVoucher(e);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Settings.CHECK_FOR_LEGACY_ITEMS.getBoolean()) {
|
||||
return;
|
||||
}
|
||||
|
||||
voucher = findVoucherForLegacyItem(item, allVouchers);
|
||||
if (voucher == null) {
|
||||
this.itemsThatGotLegacyChecked.add(item);
|
||||
return;
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
voucher.redeemVoucher(e);
|
||||
}
|
||||
|
||||
private boolean isRightClickAction(Action action) {
|
||||
return action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK;
|
||||
}
|
||||
|
||||
private Voucher findVoucherForKey(String voucherKey, Collection<Voucher> allVouchers) {
|
||||
for (Voucher voucher : allVouchers) {
|
||||
if (voucherKey.equals(voucher.getKey())) {
|
||||
return voucher;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated This is a legacy method that is only used for backwards compatibility
|
||||
* with vouchers that were created before the voucher key was stored in NBT.
|
||||
* Some checks in here don't even look like they make sense or look redundant... Hard to touch this.
|
||||
*/
|
||||
@Deprecated
|
||||
private Voucher findVoucherForLegacyItem(ItemStack item, Collection<Voucher> allVouchers) {
|
||||
for (Voucher voucher : allVouchers) {
|
||||
ItemStack voucherItem = voucher.toItemStack();
|
||||
|
||||
if (voucherItem != null && !voucherItem.isSimilar(item)) {
|
||||
continue;
|
||||
}
|
||||
if (item.getType() != voucher.getMaterial() || item.getDurability() != voucher.getData()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// material matches - verify the name + lore
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
if (meta != null && meta.hasDisplayName() && ChatColor.stripColor(meta.getDisplayName()).equals(ChatColor.stripColor(voucher.getName(true))) && (!meta.hasLore() || meta.getLore().equals(voucher.getLore(true)))) {
|
||||
return voucher;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package com.songoda.epicvouchers.menus;
|
||||
package com.craftaro.epicvouchers.menus;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.songoda.epicvouchers.menus.sub.action.ForceMenu;
|
||||
import com.songoda.epicvouchers.menus.sub.action.GiveMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.craftaro.epicvouchers.menus.sub.action.ForceMenu;
|
||||
import com.craftaro.epicvouchers.menus.sub.action.GiveMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
@ -20,7 +20,6 @@ import static org.bukkit.ChatColor.YELLOW;
|
|||
import static org.bukkit.Material.BARRIER;
|
||||
|
||||
public class ActionMenu extends FastInv {
|
||||
|
||||
public ActionMenu(EpicVouchers instance, Voucher voucher) {
|
||||
super(27, "Give menu");
|
||||
|
||||
|
@ -62,7 +61,7 @@ public class ActionMenu extends FastInv {
|
|||
.addGlow().build(), event -> new VoucherMenu(instance).open(event.getPlayer()));
|
||||
|
||||
if (instance.getConfig().getBoolean("Interface.Fill Interfaces With Glass")) {
|
||||
ItemStack fillItem = CompatibleMaterial.GRAY_STAINED_GLASS_PANE.getItem();
|
||||
ItemStack fillItem = XMaterial.GRAY_STAINED_GLASS_PANE.parseItem();
|
||||
|
||||
fill(new ItemBuilder(fillItem).name(ChatColor.RESET.toString()).build());
|
||||
}
|
|
@ -1,10 +1,9 @@
|
|||
package com.songoda.epicvouchers.menus;
|
||||
package com.craftaro.epicvouchers.menus;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.FastInv;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -13,7 +12,6 @@ import static org.bukkit.enchantments.Enchantment.DURABILITY;
|
|||
import static org.bukkit.inventory.ItemFlag.HIDE_ENCHANTS;
|
||||
|
||||
public class ConfirmMenu extends FastInv {
|
||||
|
||||
public ConfirmMenu(EpicVouchers instance, Runnable success, Runnable failure) {
|
||||
super(27, instance.getLocale().getMessage("interface.confirmsettings.title").getMessage());
|
||||
|
||||
|
@ -36,7 +34,7 @@ public class ConfirmMenu extends FastInv {
|
|||
});
|
||||
|
||||
if (instance.getConfig().getBoolean("Interface.Fill Interfaces With Glass")) {
|
||||
ItemStack fillItem = CompatibleMaterial.GRAY_STAINED_GLASS_PANE.getItem();
|
||||
ItemStack fillItem = XMaterial.GRAY_STAINED_GLASS_PANE.parseItem();
|
||||
|
||||
fill(new ItemBuilder(fillItem).name(ChatColor.RESET.toString()).build());
|
||||
}
|
|
@ -1,22 +1,22 @@
|
|||
package com.songoda.epicvouchers.menus;
|
||||
package com.craftaro.epicvouchers.menus;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.SetItemMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.SetItemMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import static org.bukkit.ChatColor.GRAY;
|
||||
import static org.bukkit.ChatColor.YELLOW;
|
||||
import static org.bukkit.Material.*;
|
||||
import static org.bukkit.Material.BARRIER;
|
||||
import static org.bukkit.Material.BOOK;
|
||||
import static org.bukkit.Material.FEATHER;
|
||||
import static org.bukkit.Material.STONE;
|
||||
|
||||
public class OptionMenu extends FastInv {
|
||||
|
||||
public OptionMenu(EpicVouchers instance, Voucher voucher) {
|
||||
super(27, "Options: " + voucher.getKey());
|
||||
|
||||
|
@ -43,7 +43,6 @@ public class OptionMenu extends FastInv {
|
|||
.lore(TextUtils.formatText("&eSet the options of your voucher."))
|
||||
.build(), event -> new VoucherEditorMenu(instance, voucher).open(event.getPlayer()));
|
||||
|
||||
fill(new ItemBuilder(CompatibleMaterial.GRAY_STAINED_GLASS_PANE.getItem()).name(ChatColor.RESET.toString()).build());
|
||||
fill(new ItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseMaterial()).name(ChatColor.RESET.toString()).build());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,17 +1,19 @@
|
|||
package com.songoda.epicvouchers.menus;
|
||||
package com.craftaro.epicvouchers.menus;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringListIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.ToggleableIcon;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.EffectsMenu;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.ParticlesMenu;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.SoundsMenu;
|
||||
import com.songoda.epicvouchers.menus.sub.editor.TitlesMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.utils.ItemUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringListIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.ToggleableIcon;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.EffectsMenu;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.ParticlesMenu;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.SoundsMenu;
|
||||
import com.craftaro.epicvouchers.menus.sub.editor.TitlesMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -61,7 +63,7 @@ public class VoucherEditorMenu extends IconInv {
|
|||
}));
|
||||
|
||||
addIcon(11, new StringIcon(instance, "Material", voucher.getMaterial().toString(), (player, editString) -> {
|
||||
if(editString.contains(":")) {
|
||||
if (editString.contains(":")) {
|
||||
voucher.setData(Short.parseShort(editString.split(":")[1]));
|
||||
voucher.setMaterial(Material.valueOf(editString.split(":")[0]));
|
||||
} else {
|
||||
|
@ -70,11 +72,11 @@ public class VoucherEditorMenu extends IconInv {
|
|||
|
||||
reopen(player);
|
||||
}, string -> {
|
||||
if (string.isEmpty()) {
|
||||
if (string.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(string.contains(":") && string.split(":").length == 2) {
|
||||
if (string.contains(":") && string.split(":").length == 2) {
|
||||
String[] split = string.split(":");
|
||||
return Material.matchMaterial(split[0]) != null && StringUtils.isNumeric(split[1]);
|
||||
}
|
||||
|
@ -87,6 +89,13 @@ public class VoucherEditorMenu extends IconInv {
|
|||
reopen(player);
|
||||
}));
|
||||
|
||||
addIcon(13, new StringIcon(instance, new ItemBuilder(voucher.getTexture() == null ? XMaterial.PLAYER_HEAD.parseItem() : ItemUtils.getCustomHead(voucher.getTexture()))
|
||||
.name(YELLOW + "Skull Texture")
|
||||
.lore(GRAY + "Right click to edit", GRAY + "Left click to clear").build(), voucher.getTexture(), (player, editString) -> {
|
||||
voucher.setTexture(editString);
|
||||
reopen(player);
|
||||
}));
|
||||
|
||||
// Sections
|
||||
|
||||
addIcon(18, new StringListIcon(instance, voucher.getCommands(), "Commands", voucher));
|
||||
|
@ -122,6 +131,6 @@ public class VoucherEditorMenu extends IconInv {
|
|||
}
|
||||
|
||||
private void reopen(Player player) {
|
||||
new VoucherEditorMenu(instance, voucher).open(player);
|
||||
new VoucherEditorMenu(this.instance, this.voucher).open(player);
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package com.songoda.epicvouchers.menus;
|
||||
package com.craftaro.epicvouchers.menus;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.core.gui.AnvilGui;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.Icon;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -15,9 +15,13 @@ import org.bukkit.inventory.ItemStack;
|
|||
import static org.bukkit.Material.PAPER;
|
||||
|
||||
public class VoucherMenu extends IconInv {
|
||||
|
||||
public VoucherMenu(EpicVouchers instance) {
|
||||
super((int) (Math.ceil(instance.getVoucherManager().getVouchers().size() / 9.0) * 9 + (instance.getVoucherManager().getVouchers().size() % 9 == 0 ? 9 : 0)), "Vouchers");
|
||||
// FIXME: Having too many vouchers throws an error:
|
||||
// Size for custom inventory must be a multiple of 9 between 9 and 54 slots (got 594)
|
||||
// Applied hotfix to use a maximum size of 54
|
||||
// Example file: https://support.songoda.com/secure/attachment/17258/17258_vouchers.yml
|
||||
|
||||
super(Math.min((int) (Math.ceil(instance.getVoucherManager().getVouchers().size() / 9.0) * 9 + (instance.getVoucherManager().getVouchers().size() % 9 == 0 ? 9 : 0)), 54), "Vouchers");
|
||||
|
||||
for (Voucher voucher : instance.getVoucherManager().getVouchers()) {
|
||||
if (getInventory().firstEmpty() != -1) {
|
||||
|
@ -30,7 +34,7 @@ public class VoucherMenu extends IconInv {
|
|||
.lore(TextUtils.formatText("&eCreate a new voucher with set id.")).build(), event -> {
|
||||
AnvilGui gui = new AnvilGui(event.getPlayer());
|
||||
gui.setTitle("Insert id");
|
||||
gui.setAction(aevent -> {
|
||||
gui.setAction(aEvent -> {
|
||||
final String msg = gui.getInputText().trim();
|
||||
if (instance.getVoucherManager().getVoucher(msg) != null) {
|
||||
event.getPlayer().sendMessage(TextUtils.formatText("&cAlready a voucher registered with the id: " + msg));
|
||||
|
@ -41,6 +45,7 @@ public class VoucherMenu extends IconInv {
|
|||
Voucher voucher = new Voucher(msg, instance);
|
||||
voucher.setMaterial(PAPER);
|
||||
voucher.setName("&f" + msg);
|
||||
voucher.setTexture("");
|
||||
|
||||
instance.getVoucherManager().addVoucher(voucher);
|
||||
event.getPlayer().sendMessage(TextUtils.formatText("&7Successfully created voucher with id &r" + msg + "&7."));
|
||||
|
@ -53,5 +58,4 @@ public class VoucherMenu extends IconInv {
|
|||
new ItemStack(Material.valueOf("GRAY_STAINED_GLASS_PANE")) :
|
||||
new ItemStack(Material.valueOf("STAINED_GLASS_PANE"), 1, (short) 7)).name(ChatColor.RESET.toString()).build()));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package com.songoda.epicvouchers.menus.sub.action;
|
||||
package com.craftaro.epicvouchers.menus.sub.action;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.inventory.PlayersMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.PlayersMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
|
@ -1,8 +1,8 @@
|
|||
package com.songoda.epicvouchers.menus.sub.action;
|
||||
package com.craftaro.epicvouchers.menus.sub.action;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.inventory.PlayersMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.PlayersMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -12,4 +12,4 @@ public class GiveMenu extends PlayersMenu {
|
|||
public GiveMenu(EpicVouchers instance, Voucher voucher) {
|
||||
super(instance, voucher, "Give Menu", (who, player) -> voucher.give(who, Collections.singletonList(player), 1), new ArrayList<>(Bukkit.getOnlinePlayers()));
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.songoda.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.craftaro.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import static org.bukkit.ChatColor.GRAY;
|
||||
|
@ -35,6 +35,5 @@ public class EffectsMenu extends IconInv {
|
|||
.name(YELLOW + "Return")
|
||||
.lore(GRAY + "Return to the editor")
|
||||
.build(), event -> new VoucherEditorMenu(instance, voucher).open(event.getPlayer()));
|
||||
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.songoda.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.craftaro.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import static org.bukkit.ChatColor.GRAY;
|
||||
|
@ -30,6 +30,5 @@ public class ParticlesMenu extends IconInv {
|
|||
.name(YELLOW + "Return")
|
||||
.lore(GRAY + "Return to the editor")
|
||||
.build(), event -> new VoucherEditorMenu(instance, voucher).open(event.getPlayer()));
|
||||
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.songoda.epicvouchers.menus.OptionMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.craftaro.epicvouchers.menus.OptionMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
@ -15,13 +15,12 @@ import static org.bukkit.ChatColor.GRAY;
|
|||
import static org.bukkit.ChatColor.YELLOW;
|
||||
|
||||
public class SetItemMenu extends FastInv {
|
||||
|
||||
public SetItemMenu(EpicVouchers instance, Voucher voucher) {
|
||||
super(27, "Set item");
|
||||
|
||||
setDefaultCancel(false);
|
||||
|
||||
fill(new ItemBuilder(CompatibleMaterial.GRAY_STAINED_GLASS_PANE.getItem())
|
||||
fill(new ItemBuilder(XMaterial.GRAY_STAINED_GLASS_PANE.parseItem())
|
||||
.name(ChatColor.RESET.toString()).build(), event -> event.setCancelled(true));
|
||||
|
||||
addItem(13, null);
|
||||
|
@ -74,6 +73,5 @@ public class SetItemMenu extends FastInv {
|
|||
|
||||
new OptionMenu(instance, voucher).open(event.getPlayer());
|
||||
});
|
||||
|
||||
}
|
||||
}
|
|
@ -1,13 +1,13 @@
|
|||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.craftaro.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import com.google.common.base.Enums;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.songoda.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
|
@ -32,6 +32,5 @@ public class SoundsMenu extends IconInv {
|
|||
.name(YELLOW + "Return")
|
||||
.lore(GRAY + "Return to the editor")
|
||||
.build(), event -> new VoucherEditorMenu(instance, voucher).open(event.getPlayer()));
|
||||
|
||||
}
|
||||
}
|
|
@ -1,22 +1,26 @@
|
|||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.ListEntryIcon;
|
||||
import com.songoda.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.core.input.ChatPrompt;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.ListEntryIcon;
|
||||
import com.craftaro.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.bukkit.ChatColor.*;
|
||||
import static org.bukkit.ChatColor.DARK_GRAY;
|
||||
import static org.bukkit.ChatColor.GRAY;
|
||||
import static org.bukkit.ChatColor.GREEN;
|
||||
import static org.bukkit.ChatColor.YELLOW;
|
||||
import static org.bukkit.Material.PAPER;
|
||||
|
||||
public class StringListMenu extends IconInv {
|
||||
|
||||
public StringListMenu(EpicVouchers instance, String key, List<String> list, String toEdit, Voucher voucher) {
|
||||
super((int) ((list.isEmpty() ? 9 : Math.ceil(list.size() / 9.0) * 9) + 9), key);
|
||||
int size = getInventory().getSize();
|
||||
|
@ -32,13 +36,11 @@ public class StringListMenu extends IconInv {
|
|||
.build());
|
||||
|
||||
addIcon(size - 1, new ItemBuilder(PAPER).name(GREEN + "Add to list").build(), event -> {
|
||||
AnvilGui gui = new AnvilGui(event.getPlayer());
|
||||
gui.setAction(aevent -> {
|
||||
list.add(gui.getInputText().trim());
|
||||
ChatPrompt.showPrompt(instance, event.getPlayer(), TextUtils.formatText("Enter a new value."), aevent -> {
|
||||
list.add(aevent.getMessage().trim());
|
||||
voucher.saveSetting(key.toLowerCase(), list);
|
||||
new StringListMenu(instance, key, list, toEdit, voucher).open(event.getPlayer());
|
||||
Bukkit.getScheduler().runTaskLater(instance, () -> new StringListMenu(instance, key, list, toEdit, voucher).open(event.getPlayer()), 1L);
|
||||
});
|
||||
instance.getGuiManager().showGUI(event.getPlayer(), gui);
|
||||
});
|
||||
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
|
@ -53,6 +55,5 @@ public class StringListMenu extends IconInv {
|
|||
new StringListMenu(instance, key, list, toEdit, voucher).open(player);
|
||||
}));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
package com.songoda.epicvouchers.menus.sub.editor;
|
||||
package com.craftaro.epicvouchers.menus.sub.editor;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.songoda.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.songoda.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.libraries.ItemBuilder;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.IntegerIcon;
|
||||
import com.craftaro.epicvouchers.libraries.inventory.icons.StringIcon;
|
||||
import com.craftaro.epicvouchers.menus.VoucherEditorMenu;
|
||||
import com.craftaro.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import static org.bukkit.ChatColor.GRAY;
|
||||
|
@ -45,6 +45,5 @@ public class TitlesMenu extends IconInv {
|
|||
.name(YELLOW + "Return")
|
||||
.lore(GRAY + "Return to the editor")
|
||||
.build(), event -> new VoucherEditorMenu(instance, voucher).open(event.getPlayer()));
|
||||
|
||||
}
|
||||
}
|
|
@ -1,19 +1,19 @@
|
|||
package com.songoda.epicvouchers.settings;
|
||||
package com.craftaro.epicvouchers.settings;
|
||||
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.configuration.ConfigSetting;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.core.configuration.Config;
|
||||
import com.craftaro.core.configuration.ConfigSetting;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
/**
|
||||
* Created by songo on 6/4/2017.
|
||||
*/
|
||||
public class Settings implements Listener {
|
||||
|
||||
static final Config config = EpicVouchers.getInstance().getCoreConfig();
|
||||
static final Config config = EpicVouchers.getPlugin(EpicVouchers.class).getCoreConfig();
|
||||
|
||||
public static final ConfigSetting FILL_GLASS = new ConfigSetting(config, "Interface.Fill Interfaces With Glass", true);
|
||||
public static final ConfigSetting COOLDOWN_DELAY = new ConfigSetting(config, "Main.Cooldown Delay", 10);
|
||||
public static final ConfigSetting CHECK_FOR_LEGACY_ITEMS = new ConfigSetting(config, "Main.Check For Legacy Items", false,
|
||||
"When you have a really old installation of EpicVouchers, some items in chests etc. might still be created with the old system.",
|
||||
"This enables checking/detection for those items.",
|
||||
"2 warnings: Enabling this comes with a performance impact with many vouchers configured + This check will be removed in the future");
|
||||
|
||||
public static final ConfigSetting DATABASE_SUPPORT = new ConfigSetting(config, "Database.Activate Mysql Support", false);
|
||||
public static final ConfigSetting DATABASE_IP = new ConfigSetting(config, "Database.IP", "127.0.0.1");
|
||||
|
@ -31,4 +31,4 @@ public class Settings implements Listener {
|
|||
config.setAutoremove(true).setAutosave(true);
|
||||
config.saveChanges();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.craftaro.epicvouchers.utils;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class CachedSet<K> {
|
||||
private final Map<K, Long> cache = new WeakHashMap<>(0);
|
||||
private final int ttl;
|
||||
|
||||
private long lastClear = System.currentTimeMillis();
|
||||
|
||||
/**
|
||||
* @param ttl Time-To-Live in seconds
|
||||
*/
|
||||
public CachedSet(int ttl) {
|
||||
this.ttl = ttl * 1000;
|
||||
}
|
||||
|
||||
public void add(K obj) {
|
||||
this.cache.put(obj, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public boolean contains(K obj) {
|
||||
if (shouldClear()) {
|
||||
clearStale();
|
||||
}
|
||||
|
||||
return this.cache.computeIfPresent(obj, (key, aLong) -> System.currentTimeMillis()) != null;
|
||||
}
|
||||
|
||||
public void clearStale() {
|
||||
this.cache.entrySet().removeIf(entry -> System.currentTimeMillis() - entry.getValue() >= this.ttl);
|
||||
|
||||
this.lastClear = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
private boolean shouldClear() {
|
||||
return !this.cache.isEmpty() && System.currentTimeMillis() - this.lastClear > this.ttl;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
package com.craftaro.epicvouchers.utils;
|
||||
|
||||
// TODO: Copied from EpicAnchors - Move to SongodaCore (maybe rename too?)
|
||||
public interface Callback {
|
||||
void accept(Exception ex);
|
||||
}
|
|
@ -1,38 +1,46 @@
|
|||
package com.songoda.epicvouchers.utils;
|
||||
package com.craftaro.epicvouchers.utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>A convenience class to represent name-value pairs.</p>
|
||||
*
|
||||
* @since JavaFX 2.0
|
||||
*/
|
||||
public class Pair<K,V> implements Serializable{
|
||||
|
||||
public class Pair<K, V> implements Serializable {
|
||||
/**
|
||||
* Key of this <code>Pair</code>.
|
||||
*/
|
||||
private String key;
|
||||
private final String key;
|
||||
|
||||
/**
|
||||
* Gets the key for this pair.
|
||||
*
|
||||
* @return key for this pair
|
||||
*/
|
||||
public String getKey() { return key; }
|
||||
public String getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Value of this this <code>Pair</code>.
|
||||
*/
|
||||
private String value;
|
||||
private final String value;
|
||||
|
||||
/**
|
||||
* Gets the value for this pair.
|
||||
*
|
||||
* @return value for this pair
|
||||
*/
|
||||
public String getValue() { return value; }
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new pair
|
||||
* @param key The key for this pair
|
||||
*
|
||||
* @param key The key for this pair
|
||||
* @param value The value to use for this pair
|
||||
*/
|
||||
public Pair(String key, String value) {
|
||||
|
@ -46,11 +54,11 @@ public class Pair<K,V> implements Serializable{
|
|||
*
|
||||
* <p>The default name/value delimiter '=' is always used.</p>
|
||||
*
|
||||
* @return <code>String</code> representation of this <code>Pair</code>
|
||||
* @return <code>String</code> representation of this <code>Pair</code>
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return key + "=" + value;
|
||||
return this.key + "=" + this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -68,7 +76,7 @@ public class Pair<K,V> implements Serializable{
|
|||
// these two parameters:
|
||||
// name: a value: aa
|
||||
// name: aa value: a
|
||||
return key.hashCode() * 13 + (value == null ? 0 : value.hashCode());
|
||||
return this.key.hashCode() * 13 + (this.value == null ? 0 : this.value.hashCode());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,20 +91,20 @@ public class Pair<K,V> implements Serializable{
|
|||
* both the names and values are equal.</p>
|
||||
*
|
||||
* @param o the <code>Object</code> to test for
|
||||
* equality with this <code>Pair</code>
|
||||
* equality with this <code>Pair</code>
|
||||
* @return <code>true</code> if the given <code>Object</code> is
|
||||
* equal to this <code>Pair</code> else <code>false</code>
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o instanceof Pair) {
|
||||
Pair pair = (Pair) o;
|
||||
if (key != null ? !key.equals(pair.key) : pair.key != null) return false;
|
||||
if (value != null ? !value.equals(pair.value) : pair.value != null) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Pair<?, ?> pair = (Pair<?, ?>) o;
|
||||
return Objects.equals(this.key, pair.key) && Objects.equals(this.value, pair.value);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
package com.craftaro.epicvouchers.utils;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
// TODO: Copied from EpicAnchors - Move to SongodaCore
|
||||
public class ThreadSync {
|
||||
private final Object syncObj = new Object();
|
||||
private final AtomicReference<Boolean> waiting = new AtomicReference<>(true);
|
||||
|
||||
public void waitForRelease() {
|
||||
synchronized (this.syncObj) {
|
||||
while (this.waiting.get()) {
|
||||
try {
|
||||
this.syncObj.wait();
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void release() {
|
||||
synchronized (this.syncObj) {
|
||||
this.waiting.set(false);
|
||||
this.syncObj.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.waiting.set(true);
|
||||
}
|
||||
}
|
|
@ -1,14 +1,14 @@
|
|||
package com.songoda.epicvouchers.voucher;
|
||||
package com.craftaro.epicvouchers.voucher;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class CoolDownManager {
|
||||
|
||||
private final HashMap<UUID, Long> entries = new HashMap<>();
|
||||
private final Map<UUID, Long> entries = new HashMap<>();
|
||||
private final EpicVouchers instance;
|
||||
|
||||
public CoolDownManager(EpicVouchers instance) {
|
||||
|
@ -21,14 +21,14 @@ public class CoolDownManager {
|
|||
}
|
||||
|
||||
if (voucher.getCoolDown() != 0) {
|
||||
entries.put(uuid, System.currentTimeMillis() + voucher.getCoolDown() * 1000);
|
||||
this.entries.put(uuid, System.currentTimeMillis() + voucher.getCoolDown() * 1000L);
|
||||
} else {
|
||||
entries.put(uuid, System.currentTimeMillis() + instance.getConfig().getInt("Main.Cooldown Delay") * 1000);
|
||||
this.entries.put(uuid, System.currentTimeMillis() + this.instance.getConfig().getInt("Main.Cooldown Delay") * 1000L);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isOnCoolDown(UUID uuid) {
|
||||
Long time = entries.get(uuid);
|
||||
Long time = this.entries.get(uuid);
|
||||
|
||||
if (time == null) {
|
||||
return false;
|
||||
|
@ -38,12 +38,12 @@ public class CoolDownManager {
|
|||
return true;
|
||||
}
|
||||
|
||||
entries.remove(uuid);
|
||||
this.entries.remove(uuid);
|
||||
return false;
|
||||
}
|
||||
|
||||
public long getTime(UUID uuid) {
|
||||
Long time = entries.get(uuid);
|
||||
Long time = this.entries.get(uuid);
|
||||
|
||||
if (time == null) {
|
||||
return 0L;
|
||||
|
@ -51,4 +51,4 @@ public class CoolDownManager {
|
|||
|
||||
return (time - System.currentTimeMillis()) / 1000;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,31 +1,34 @@
|
|||
package com.songoda.epicvouchers.voucher;
|
||||
package com.craftaro.epicvouchers.voucher;
|
||||
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.nms.NmsManager;
|
||||
import com.songoda.core.nms.nbt.NBTItem;
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.events.ForceRedeemEvent;
|
||||
import com.songoda.epicvouchers.events.VoucherReceiveEvent;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
|
||||
import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem;
|
||||
import com.craftaro.core.utils.ItemUtils;
|
||||
import com.craftaro.core.utils.TextUtils;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.events.ForceRedeemEvent;
|
||||
import com.craftaro.epicvouchers.events.VoucherReceiveEvent;
|
||||
import com.craftaro.epicvouchers.menus.ConfirmMenu;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.UUID;
|
||||
|
||||
import static org.bukkit.Material.PAPER;
|
||||
|
||||
@Accessors(chain = true)
|
||||
public class Voucher {
|
||||
|
||||
private final String key;
|
||||
private final EpicVouchers instance;
|
||||
private String permission = "";
|
||||
|
@ -34,6 +37,7 @@ public class Voucher {
|
|||
private int coolDown = 0;
|
||||
private String name;
|
||||
private List<String> lore = new ArrayList<>();
|
||||
private String texture;
|
||||
private boolean glow = true;
|
||||
private boolean confirm = true;
|
||||
private boolean unbreakable = false;
|
||||
|
@ -77,81 +81,114 @@ public class Voucher {
|
|||
}
|
||||
|
||||
public ItemStack toItemStack(int amount) {
|
||||
ItemStack item = itemStack == null ? new ItemStack(material, amount, data) : itemStack;
|
||||
ItemStack item = this.itemStack == null ? new ItemStack(this.material, amount, this.data) : this.itemStack;
|
||||
ItemMeta meta = item.getItemMeta();
|
||||
|
||||
if (meta == null) {
|
||||
meta = Bukkit.getItemFactory().getItemMeta(material);
|
||||
meta = Bukkit.getItemFactory().getItemMeta(this.material);
|
||||
}
|
||||
|
||||
if (!name.isEmpty()) {
|
||||
meta.setDisplayName(TextUtils.formatText(name));
|
||||
if (!this.name.isEmpty()) {
|
||||
meta.setDisplayName(TextUtils.formatText(this.name));
|
||||
}
|
||||
|
||||
if (lore != null) {
|
||||
if (this.lore != null) {
|
||||
meta.setLore(getLore(true));
|
||||
}
|
||||
|
||||
if (glow) {
|
||||
if (this.glow) {
|
||||
meta.addEnchant(Enchantment.DURABILITY, 1, false);
|
||||
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
}
|
||||
|
||||
if (hideAttributes) {
|
||||
if (this.hideAttributes) {
|
||||
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
|
||||
}
|
||||
|
||||
if (unbreakable) {
|
||||
if (this.unbreakable) {
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) {
|
||||
meta.setUnbreakable(true);
|
||||
item.setItemMeta(meta);
|
||||
} else {
|
||||
item.setItemMeta(meta);
|
||||
NBTItem nbtItem = NmsManager.getNbt().of(item);
|
||||
nbtItem.set("Unbreakable", (byte) 1);
|
||||
item = nbtItem.finish();
|
||||
|
||||
NBTItem nbtItem = new NBTItem(item);
|
||||
nbtItem.setByte("Unbreakable", (byte) 1);
|
||||
item = nbtItem.getItem();
|
||||
}
|
||||
}
|
||||
return item;
|
||||
|
||||
if (this.texture != null && !this.texture.isEmpty() && XMaterial.PLAYER_HEAD.parseMaterial() == this.material) {
|
||||
item = ItemUtils.getCustomHead(this.texture);
|
||||
}
|
||||
|
||||
NBTItem nbtItem = new NBTItem(item);
|
||||
nbtItem.setString("epicvouchers:voucher", this.key);
|
||||
|
||||
return nbtItem.getItem();
|
||||
}
|
||||
|
||||
public String getName(boolean applyFormatting) {
|
||||
return applyFormatting ? TextUtils.formatText(name) : name;
|
||||
return applyFormatting ? TextUtils.formatText(this.name) : this.name;
|
||||
}
|
||||
|
||||
public List<String> getLore(boolean applyFormatting) {
|
||||
return applyFormatting ? lore.stream().map(TextUtils::formatText).collect(Collectors.toList()) : lore;
|
||||
if (!applyFormatting) {
|
||||
return Collections.unmodifiableList(this.lore);
|
||||
}
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (String line : this.lore) {
|
||||
lore.add(TextUtils.formatText(line));
|
||||
}
|
||||
return lore;
|
||||
}
|
||||
|
||||
public List<String> getBroadcasts(boolean applyFormatting) {
|
||||
return applyFormatting ? broadcasts.stream().map(TextUtils::formatText).collect(Collectors.toList()) : broadcasts;
|
||||
if (!applyFormatting) {
|
||||
return this.broadcasts;
|
||||
}
|
||||
|
||||
List<String> result = new ArrayList<>();
|
||||
for (String broadcast : this.broadcasts) {
|
||||
result.add(TextUtils.formatText(broadcast));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<String> getMessages(boolean applyFormatting) {
|
||||
return applyFormatting ? messages.stream().map(TextUtils::formatText).collect(Collectors.toList()) : messages;
|
||||
if (!applyFormatting) {
|
||||
return this.messages;
|
||||
}
|
||||
|
||||
List<String> list = new ArrayList<>();
|
||||
for (String message : this.messages) {
|
||||
list.add(TextUtils.formatText(message));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public void saveSetting(String key, List<String> list) {
|
||||
switch (key) {
|
||||
case "Commands":
|
||||
commands = list;
|
||||
this.commands = list;
|
||||
break;
|
||||
case "Broadcasts":
|
||||
broadcasts = list;
|
||||
this.broadcasts = list;
|
||||
break;
|
||||
case "Messages":
|
||||
messages = list;
|
||||
this.messages = list;
|
||||
break;
|
||||
case "Lore":
|
||||
lore = list;
|
||||
this.lore = list;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return key;
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public void giveAll(CommandSender sender, int amount) {
|
||||
|
@ -159,13 +196,13 @@ public class Voucher {
|
|||
}
|
||||
|
||||
public void give(CommandSender sender, List<Player> players, int amount) {
|
||||
String giveMessage = instance.getLocale().getMessage("command.give.send")
|
||||
String giveMessage = this.instance.getLocale().getMessage("command.give.send")
|
||||
.processPlaceholder("player", players.size() == 1 ? players.get(0).getName() : "everyone")
|
||||
.processPlaceholder("voucher", getName(true))
|
||||
.processPlaceholder("amount", String.valueOf(amount)).getPrefixedMessage();
|
||||
|
||||
for (Player player : players) {
|
||||
String receiveMessage = instance.getLocale().getMessage("command.give.receive")
|
||||
String receiveMessage = this.instance.getLocale().getMessage("command.give.receive")
|
||||
.processPlaceholder("voucher", getName(true))
|
||||
.processPlaceholder("player", player.getName())
|
||||
.processPlaceholder("amount", String.valueOf(amount)).getPrefixedMessage();
|
||||
|
@ -174,7 +211,7 @@ public class Voucher {
|
|||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
instance.getLocale().getMessage("command.give.cancelled").sendPrefixedMessage(sender);
|
||||
this.instance.getLocale().getMessage("command.give.cancelled").sendPrefixedMessage(sender);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -195,21 +232,55 @@ public class Voucher {
|
|||
}
|
||||
|
||||
for (int i = 0; i < amount; i++) {
|
||||
instance.getVoucherExecutor().redeemVoucher(player, this, player.getItemInHand(), false, null);
|
||||
this.instance.getVoucherExecutor().redeemVoucher(player, this, player.getItemInHand(), false, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void redeemVoucher(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// does the player have permission to redeem this voucher?
|
||||
if (!this.permission.isEmpty() && !player.hasPermission(this.permission)) {
|
||||
player.sendMessage(this.instance.getLocale().getMessage("event.general.nopermission").getPrefixedMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
|
||||
if (this.instance.getCoolDowns().isOnCoolDown(uuid)) {
|
||||
this.instance.getLocale().getMessage("event.general.cooldown")
|
||||
.processPlaceholder("time", this.instance.getCoolDowns().getTime(uuid))
|
||||
.processPlaceholder("voucher", getName(true))
|
||||
.sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.confirm) {
|
||||
new ConfirmMenu(this.instance,
|
||||
() -> this.instance.getVoucherExecutor().redeemVoucher(player, this, event.getItem(), true, event),
|
||||
() -> {
|
||||
})
|
||||
.open(player);
|
||||
} else {
|
||||
this.instance.getVoucherExecutor().redeemVoucher(player, this, event.getItem(), true, event);
|
||||
}
|
||||
}
|
||||
|
||||
public String getTexture() {
|
||||
return this.texture;
|
||||
}
|
||||
|
||||
public String getActionBar() {
|
||||
return TextUtils.formatText(actionBar);
|
||||
return TextUtils.formatText(this.actionBar);
|
||||
}
|
||||
|
||||
public String getSubTitle() {
|
||||
return TextUtils.formatText(subTitle);
|
||||
return TextUtils.formatText(this.subTitle);
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return TextUtils.formatText(title);
|
||||
return TextUtils.formatText(this.title);
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
|
@ -417,6 +488,11 @@ public class Voucher {
|
|||
return this;
|
||||
}
|
||||
|
||||
public Voucher setTexture(String texture) {
|
||||
this.texture = texture;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Voucher setActionBar(String actionBar) {
|
||||
this.actionBar = actionBar;
|
||||
return this;
|
|
@ -1,14 +1,13 @@
|
|||
package com.songoda.epicvouchers.voucher;
|
||||
package com.craftaro.epicvouchers.voucher;
|
||||
|
||||
import com.songoda.core.utils.TextUtils;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.events.VoucherRedeemEvent;
|
||||
import com.songoda.epicvouchers.libraries.BountifulAPI;
|
||||
import com.songoda.epicvouchers.listeners.PlayerCommandListener;
|
||||
import com.craftaro.core.compatibility.CompatibleSound;
|
||||
import com.craftaro.core.compatibility.ServerVersion;
|
||||
import com.craftaro.epicvouchers.EpicVouchers;
|
||||
import com.craftaro.epicvouchers.events.VoucherRedeemEvent;
|
||||
import com.craftaro.epicvouchers.listeners.PlayerCommandListener;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
|
@ -52,7 +51,7 @@ public class VoucherExecutor {
|
|||
|
||||
if (!duplication) {
|
||||
if (manual) {
|
||||
instance.getCoolDowns().addCoolDown(player.getUniqueId(), voucher);
|
||||
this.instance.getCoolDowns().addCoolDown(player.getUniqueId(), voucher);
|
||||
if (voucher.isRemoveItem()) {
|
||||
if (item.getAmount() <= 1) {
|
||||
item = null;
|
||||
|
@ -117,17 +116,14 @@ public class VoucherExecutor {
|
|||
String delayCommand = StringUtils.substringBetween(command, "[", "]");
|
||||
int delay = Integer.parseInt(delayCommand.split("-", 2)[1]);
|
||||
final String finalCommand = command.replace("[" + delayCommand + "]", "");
|
||||
final ItemStack heldItem = item;
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(instance, () -> {
|
||||
runCommand(finalCommand, player);
|
||||
}, 20 * delay);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this.instance, () -> runCommand(finalCommand, player), 20L * delay);
|
||||
} else {
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
}
|
||||
if (voucher.getActionBar() != null && !voucher.getActionBar().isEmpty()) {
|
||||
String actionbar = voucher.getActionBar().replaceAll("%player%", name).replaceAll("%voucher%", voucher.getName(true));
|
||||
BountifulAPI.sendActionBar(player, actionbar);
|
||||
this.instance.getLocale().newMessage(actionbar).sendActionBar(player);
|
||||
}
|
||||
|
||||
if (voucher.getTitle() != null && !voucher.getTitle().isEmpty()) {
|
||||
|
@ -138,11 +134,19 @@ public class VoucherExecutor {
|
|||
int stay = voucher.getTitleStay();
|
||||
int fadeout = voucher.getTitleFadeOut();
|
||||
|
||||
BountifulAPI.sendTitle(player, fadein, stay, fadeout, title, subtitle);
|
||||
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_11)) {
|
||||
player.sendTitle(title, subtitle, fadein, stay, fadeout);
|
||||
} else {
|
||||
player.sendTitle(title, subtitle);
|
||||
}
|
||||
}
|
||||
|
||||
if (voucher.getSound() != null && !voucher.getSound().isEmpty()) {
|
||||
player.playSound(player.getLocation(), Sound.valueOf(voucher.getSound()), Integer.MAX_VALUE, voucher.getSoundPitch());
|
||||
try {
|
||||
CompatibleSound sound = CompatibleSound.valueOf(voucher.getSound());
|
||||
sound.play(player, Integer.MAX_VALUE, voucher.getSoundPitch());
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
String particle = voucher.getParticle();
|
||||
|
@ -159,14 +163,14 @@ public class VoucherExecutor {
|
|||
player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(effect), duration, amplifier));
|
||||
}
|
||||
|
||||
instance.getLogger().log(Level.INFO, TextUtils.formatText("&f" + player.getName() + " has successfully redeemed the voucher " + voucher.getKey() + "."));
|
||||
instance.getConnections().saveRedeem(player, voucher.getName(true));
|
||||
this.instance.getLogger().log(Level.INFO, player.getName() + " has successfully redeemed the voucher " + voucher.getKey() + ".");
|
||||
this.instance.getConnections().saveRedeem(player, voucher.getName(true));
|
||||
} else {
|
||||
instance.getLogger().log(Level.WARNING, TextUtils.formatText("&c" + player.getName() + " has failed to duplicate the voucher " + voucher.getKey() + "."));
|
||||
this.instance.getLogger().log(Level.WARNING, player.getName() + " has failed to duplicate the voucher " + voucher.getKey() + ".");
|
||||
}
|
||||
} catch (Exception error) {
|
||||
instance.getLogger().log(Level.SEVERE, TextUtils.formatText("&cFailed to redeem the voucher " + voucher.getKey() + " for the player " + player.getName() + "."));
|
||||
instance.getLogger().log(Level.SEVERE, error.getMessage());
|
||||
this.instance.getLogger().log(Level.SEVERE, "Failed to redeem the voucher " + voucher.getKey() + " for the player " + player.getName() + ".");
|
||||
this.instance.getLogger().log(Level.SEVERE, error.getMessage());
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -194,4 +198,4 @@ public class VoucherExecutor {
|
|||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.craftaro.epicvouchers.voucher;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class VoucherManager {
|
||||
private final Map<String, Voucher> registeredVouchers = new HashMap<>();
|
||||
|
||||
public Voucher addVoucher(Voucher voucher) {
|
||||
return this.registeredVouchers.put(voucher.getKey(), voucher);
|
||||
}
|
||||
|
||||
public Voucher removeVoucher(Voucher voucher) {
|
||||
return this.registeredVouchers.remove(voucher);
|
||||
}
|
||||
|
||||
public Voucher getVoucher(String key) {
|
||||
return this.registeredVouchers.get(key);
|
||||
}
|
||||
|
||||
public Collection<Voucher> getVouchers() {
|
||||
return this.registeredVouchers.values();
|
||||
}
|
||||
|
||||
public void clearVouchers() {
|
||||
this.registeredVouchers.clear();
|
||||
}
|
||||
}
|
|
@ -1,242 +0,0 @@
|
|||
package com.songoda.epicvouchers;
|
||||
|
||||
import com.songoda.core.SongodaCore;
|
||||
import com.songoda.core.SongodaPlugin;
|
||||
import com.songoda.core.commands.CommandManager;
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.epicvouchers.commands.*;
|
||||
import com.songoda.epicvouchers.handlers.Connections;
|
||||
import com.songoda.epicvouchers.libraries.BountifulAPI;
|
||||
import com.songoda.epicvouchers.libraries.inventory.FastInv;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv;
|
||||
import com.songoda.epicvouchers.listeners.PlayerCommandListener;
|
||||
import com.songoda.epicvouchers.listeners.PlayerInteractListener;
|
||||
import com.songoda.epicvouchers.settings.Settings;
|
||||
import com.songoda.epicvouchers.voucher.CoolDownManager;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import com.songoda.epicvouchers.voucher.VoucherExecutor;
|
||||
import com.songoda.epicvouchers.voucher.VoucherManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class EpicVouchers extends SongodaPlugin {
|
||||
|
||||
private static EpicVouchers INSTANCE;
|
||||
|
||||
private final GuiManager guiManager = new GuiManager(this);
|
||||
private CommandManager commandManager;
|
||||
private VoucherManager voucherManager;
|
||||
|
||||
private Connections connections;
|
||||
private CoolDownManager coolDowns;
|
||||
private VoucherExecutor voucherExecutor;
|
||||
private Config vouchersConfig = new Config(this, "vouchers.yml");
|
||||
|
||||
public static EpicVouchers getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginLoad() {
|
||||
INSTANCE = this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable() {
|
||||
connections.closeMySQL();
|
||||
saveVouchers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginEnable() {
|
||||
// Run Songoda Updater
|
||||
SongodaCore.registerPlugin(this, 25, CompatibleMaterial.EMERALD);
|
||||
|
||||
// Setup Config
|
||||
Settings.setupConfig();
|
||||
this.setLocale(Settings.LANGUGE_MODE.getString(), false);
|
||||
|
||||
// Register commands
|
||||
this.commandManager = new CommandManager(this);
|
||||
this.commandManager.addCommand(new CommandEpicVouchers(this))
|
||||
.addSubCommands(
|
||||
new CommandEditor(this),
|
||||
new CommandForce(this),
|
||||
new CommandForceAll(this),
|
||||
new CommandGive(this),
|
||||
new CommandGiveAll(this),
|
||||
new CommandList(this),
|
||||
new CommandReload(this)
|
||||
);
|
||||
|
||||
FastInv.init(this);
|
||||
IconInv.init(this);
|
||||
BountifulAPI.init(this);
|
||||
|
||||
this.connections = new Connections(this);
|
||||
this.coolDowns = new CoolDownManager(this);
|
||||
this.voucherExecutor = new VoucherExecutor(this);
|
||||
this.voucherManager = new VoucherManager();
|
||||
|
||||
PluginManager manager = Bukkit.getServer().getPluginManager();
|
||||
|
||||
// Listeners
|
||||
guiManager.init();
|
||||
manager.registerEvents(new PlayerInteractListener(this), this);
|
||||
manager.registerEvents(new PlayerCommandListener(), this);
|
||||
|
||||
|
||||
if (!new File(this.getDataFolder(), "vouchers.yml").exists())
|
||||
saveResource("vouchers.yml", false);
|
||||
vouchersConfig.load();
|
||||
|
||||
loadVouchersFromFile();
|
||||
|
||||
connections.openMySQL();
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::saveVouchers, 6000, 6000);
|
||||
}
|
||||
|
||||
private void loadVouchersFromFile() {
|
||||
voucherManager.clearVouchers();
|
||||
|
||||
if (vouchersConfig.contains("vouchers")) {
|
||||
for (String key : vouchersConfig.getConfigurationSection("vouchers").getKeys(false)) {
|
||||
Voucher voucher = new Voucher(key, this);
|
||||
ConfigurationSection cs = vouchersConfig.getConfigurationSection("vouchers." + key);
|
||||
|
||||
Material material;
|
||||
String stringMaterial = cs.getString("material");
|
||||
|
||||
if (stringMaterial == null || stringMaterial.isEmpty()) {
|
||||
material = Material.PAPER;
|
||||
} else {
|
||||
material = Material.matchMaterial(stringMaterial);
|
||||
if (material == null) material = Material.PAPER;
|
||||
}
|
||||
|
||||
voucher.setPermission(cs.getString("permission", ""))
|
||||
.setMaterial(material)
|
||||
.setData((short) cs.getInt("data", 0))
|
||||
.setName(cs.getString("name", "default"))
|
||||
.setLore(cs.getStringList("lore"))
|
||||
.setGlow(cs.getBoolean("glow", false))
|
||||
.setConfirm(cs.getBoolean("confirm", true))
|
||||
.setUnbreakable(cs.getBoolean("unbreakable", false))
|
||||
.setHideAttributes(cs.getBoolean("hide-attributes", false))
|
||||
.setRemoveItem(cs.getBoolean("remove-item", true))
|
||||
.setHealPlayer(cs.getBoolean("heal-player", false))
|
||||
.setSmiteEffect(cs.getBoolean("smite-effect", false))
|
||||
.setCoolDown(cs.getInt("coolDown", 0))
|
||||
.setBroadcasts(cs.getStringList("broadcasts"))
|
||||
.setMessages(cs.getStringList("messages"))
|
||||
.setCommands(cs.getStringList("commands"))
|
||||
.setActionBar(cs.getString("actionbar"))
|
||||
.setTitle(cs.getString("titles.title"))
|
||||
.setSubTitle(cs.getString("titles.subtitle"))
|
||||
.setTitleFadeIn(cs.getInt("titles.fade-in", 0))
|
||||
.setTitleStay(cs.getInt("titles.stay", 0))
|
||||
.setTitleFadeOut(cs.getInt("titles.fade-out", 0))
|
||||
.setSound(cs.getString("sounds.sound"))
|
||||
.setSoundPitch(cs.getInt("sounds.pitch", 0))
|
||||
.setParticle(cs.getString("particles.particle"))
|
||||
.setParticleAmount(cs.getInt("particles.amount", 0))
|
||||
.setEffect(cs.getString("effects.effect"))
|
||||
.setEffectAmplifier(cs.getInt("effects.amplifier"))
|
||||
.setItemStack(cs.getItemStack("itemstack", null));
|
||||
|
||||
voucherManager.addVoucher(voucher);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void saveVouchers() {
|
||||
for (String voucherName : vouchersConfig.getConfigurationSection("vouchers").getKeys(false)) {
|
||||
if (voucherManager.getVouchers().stream().noneMatch(voucher -> voucher.getKey().equals(voucherName)))
|
||||
vouchersConfig.set("vouchers." + voucherName, null);
|
||||
}
|
||||
|
||||
for (Voucher voucher : voucherManager.getVouchers()) {
|
||||
String prefix = "vouchers." + voucher.getKey() + ".";
|
||||
vouchersConfig.set(prefix + "permission", voucher.getPermission());
|
||||
vouchersConfig.set(prefix + "material", voucher.getMaterial().name());
|
||||
vouchersConfig.set(prefix + "data", voucher.getData());
|
||||
vouchersConfig.set(prefix + "name", voucher.getName());
|
||||
vouchersConfig.set(prefix + "lore", voucher.getLore());
|
||||
vouchersConfig.set(prefix + "glow", voucher.isGlow());
|
||||
vouchersConfig.set(prefix + "confirm", voucher.isConfirm());
|
||||
vouchersConfig.set(prefix + "unbreakable", voucher.isUnbreakable());
|
||||
vouchersConfig.set(prefix + "hide-attributes", voucher.isHideAttributes());
|
||||
vouchersConfig.set(prefix + "remove-item", voucher.isRemoveItem());
|
||||
vouchersConfig.set(prefix + "heal-player", voucher.isHealPlayer());
|
||||
vouchersConfig.set(prefix + "smite-effect", voucher.isSmiteEffect());
|
||||
vouchersConfig.set(prefix + "coolDown", voucher.getCoolDown());
|
||||
vouchersConfig.set(prefix + "broadcasts", voucher.getBroadcasts());
|
||||
vouchersConfig.set(prefix + "messages", voucher.getMessages());
|
||||
vouchersConfig.set(prefix + "commands", voucher.getCommands());
|
||||
vouchersConfig.set(prefix + "actionbar", voucher.getActionBar());
|
||||
vouchersConfig.set(prefix + "titles.title", voucher.getTitle());
|
||||
vouchersConfig.set(prefix + "titles.subtitle", voucher.getSubTitle());
|
||||
vouchersConfig.set(prefix + "titles.fade-in", voucher.getTitleFadeIn());
|
||||
vouchersConfig.set(prefix + "titles.stay", voucher.getTitleStay());
|
||||
vouchersConfig.set(prefix + "titles.fade-out", voucher.getTitleFadeOut());
|
||||
vouchersConfig.set(prefix + "sounds.sound", voucher.getSound());
|
||||
vouchersConfig.set(prefix + "sounds.pitch", voucher.getSoundPitch());
|
||||
vouchersConfig.set(prefix + "particles.particle", voucher.getParticle());
|
||||
vouchersConfig.set(prefix + "particles.amount", voucher.getParticleAmount());
|
||||
vouchersConfig.set(prefix + "effects.effect", voucher.getEffect());
|
||||
vouchersConfig.set(prefix + "effects.amplifier", voucher.getEffectAmplifier());
|
||||
vouchersConfig.set(prefix + "itemstack", voucher.getItemStack());
|
||||
}
|
||||
vouchersConfig.saveChanges();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onConfigReload() {
|
||||
vouchersConfig.load();
|
||||
loadVouchersFromFile();
|
||||
this.setLocale(getConfig().getString("System.Language Mode"), true);
|
||||
this.locale.reloadMessages();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Config> getExtraConfig() {
|
||||
return Collections.singletonList(vouchersConfig);
|
||||
}
|
||||
|
||||
public Connections getConnections() {
|
||||
return this.connections;
|
||||
}
|
||||
|
||||
public CoolDownManager getCoolDowns() {
|
||||
return this.coolDowns;
|
||||
}
|
||||
|
||||
public VoucherExecutor getVoucherExecutor() {
|
||||
return this.voucherExecutor;
|
||||
}
|
||||
|
||||
public Config getVouchersConfig() {
|
||||
return this.vouchersConfig;
|
||||
}
|
||||
|
||||
public CommandManager getCommandManager() {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public VoucherManager getVoucherManager() {
|
||||
return voucherManager;
|
||||
}
|
||||
|
||||
public GuiManager getGuiManager() {
|
||||
return guiManager;
|
||||
}
|
||||
}
|
|
@ -1,306 +0,0 @@
|
|||
package com.songoda.epicvouchers.libraries;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class BountifulAPI {
|
||||
public static String nmsver;
|
||||
private static boolean useOldMethods = false;
|
||||
private static EpicVouchers instance;
|
||||
|
||||
@Deprecated
|
||||
public static void sendTitle(Player player, Integer fadeIn, Integer stay, Integer fadeOut, String message) {
|
||||
sendTitle(player, fadeIn, stay, fadeOut, message, null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void sendSubtitle(Player player, Integer fadeIn, Integer stay, Integer fadeOut, String message) {
|
||||
sendTitle(player, fadeIn, stay, fadeOut, null, message);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void sendFullTitle(Player player, Integer fadeIn, Integer stay, Integer fadeOut, String title, String subtitle) {
|
||||
sendTitle(player, fadeIn, stay, fadeOut, title, subtitle);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static Integer getPlayerProtocol(Player player) {
|
||||
/* Returns the 1.8 protocol version as this is the only protocol a player can possibly be on with Spigot 1.8 */
|
||||
return 47;
|
||||
}
|
||||
|
||||
public static void sendPacket(Player player, Object packet) {
|
||||
try {
|
||||
Object handle = player.getClass().getMethod("getHandle").invoke(player);
|
||||
Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
|
||||
playerConnection.getClass().getMethod("sendPacket", getNMSClass("Packet")).invoke(playerConnection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getNMSClass(String name) {
|
||||
String version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
try {
|
||||
return Class.forName("net.minecraft.server." + version + "." + name);
|
||||
} catch (ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendTitle(Player player, Integer fadeIn, Integer stay, Integer fadeOut, String title, String subtitle) {
|
||||
try {
|
||||
Object e;
|
||||
Object chatTitle;
|
||||
Object chatSubtitle;
|
||||
Constructor subtitleConstructor;
|
||||
Object titlePacket;
|
||||
Object subtitlePacket;
|
||||
|
||||
if (title != null) {
|
||||
title = ChatColor.translateAlternateColorCodes('&', title);
|
||||
title = title.replaceAll("%player%", player.getDisplayName());
|
||||
// Times packets
|
||||
e = getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0].getField("TIMES").get((Object) null);
|
||||
chatTitle = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke((Object) null, new Object[]{"{\"text\":\"" + title + "\"}"});
|
||||
subtitleConstructor = getNMSClass("PacketPlayOutTitle").getConstructor(new Class[]{getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0], getNMSClass("IChatBaseComponent"), Integer.TYPE, Integer.TYPE, Integer.TYPE});
|
||||
titlePacket = subtitleConstructor.newInstance(new Object[]{e, chatTitle, fadeIn, stay, fadeOut});
|
||||
sendPacket(player, titlePacket);
|
||||
|
||||
e = getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0].getField("TITLE").get((Object) null);
|
||||
chatTitle = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke((Object) null, new Object[]{"{\"text\":\"" + title + "\"}"});
|
||||
subtitleConstructor = getNMSClass("PacketPlayOutTitle").getConstructor(new Class[]{getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0], getNMSClass("IChatBaseComponent")});
|
||||
titlePacket = subtitleConstructor.newInstance(new Object[]{e, chatTitle});
|
||||
sendPacket(player, titlePacket);
|
||||
}
|
||||
|
||||
if (subtitle != null) {
|
||||
subtitle = ChatColor.translateAlternateColorCodes('&', subtitle);
|
||||
subtitle = subtitle.replaceAll("%player%", player.getDisplayName());
|
||||
// Times packets
|
||||
e = getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0].getField("TIMES").get((Object) null);
|
||||
chatSubtitle = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke((Object) null, new Object[]{"{\"text\":\"" + title + "\"}"});
|
||||
subtitleConstructor = getNMSClass("PacketPlayOutTitle").getConstructor(new Class[]{getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0], getNMSClass("IChatBaseComponent"), Integer.TYPE, Integer.TYPE, Integer.TYPE});
|
||||
subtitlePacket = subtitleConstructor.newInstance(new Object[]{e, chatSubtitle, fadeIn, stay, fadeOut});
|
||||
sendPacket(player, subtitlePacket);
|
||||
|
||||
e = getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0].getField("SUBTITLE").get((Object) null);
|
||||
chatSubtitle = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", new Class[]{String.class}).invoke((Object) null, new Object[]{"{\"text\":\"" + subtitle + "\"}"});
|
||||
subtitleConstructor = getNMSClass("PacketPlayOutTitle").getConstructor(new Class[]{getNMSClass("PacketPlayOutTitle").getDeclaredClasses()[0], getNMSClass("IChatBaseComponent"), Integer.TYPE, Integer.TYPE, Integer.TYPE});
|
||||
subtitlePacket = subtitleConstructor.newInstance(new Object[]{e, chatSubtitle, fadeIn, stay, fadeOut});
|
||||
sendPacket(player, subtitlePacket);
|
||||
}
|
||||
} catch (Exception var11) {
|
||||
var11.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearTitle(Player player) {
|
||||
sendTitle(player, 0, 0, 0, "", "");
|
||||
}
|
||||
|
||||
public static void sendTabTitle(Player player, String header, String footer) {
|
||||
if (header == null) header = "";
|
||||
header = ChatColor.translateAlternateColorCodes('&', header);
|
||||
|
||||
if (footer == null) footer = "";
|
||||
footer = ChatColor.translateAlternateColorCodes('&', footer);
|
||||
|
||||
header = header.replaceAll("%player%", player.getDisplayName());
|
||||
footer = footer.replaceAll("%player%", player.getDisplayName());
|
||||
|
||||
try {
|
||||
Object tabHeader = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", String.class).invoke(null, "{\"text\":\"" + header + "\"}");
|
||||
Object tabFooter = getNMSClass("IChatBaseComponent").getDeclaredClasses()[0].getMethod("a", String.class).invoke(null, "{\"text\":\"" + footer + "\"}");
|
||||
Constructor<?> titleConstructor = getNMSClass("PacketPlayOutPlayerListHeaderFooter").getConstructor();
|
||||
Object packet = titleConstructor.newInstance();
|
||||
try {
|
||||
Field aField = packet.getClass().getDeclaredField("a");
|
||||
aField.setAccessible(true);
|
||||
aField.set(packet, tabHeader);
|
||||
Field bField = packet.getClass().getDeclaredField("b");
|
||||
bField.setAccessible(true);
|
||||
bField.set(packet, tabFooter);
|
||||
} catch (Exception e) {
|
||||
Field aField = packet.getClass().getDeclaredField("header");
|
||||
aField.setAccessible(true);
|
||||
aField.set(packet, tabHeader);
|
||||
Field bField = packet.getClass().getDeclaredField("footer");
|
||||
bField.setAccessible(true);
|
||||
bField.set(packet, tabFooter);
|
||||
}
|
||||
sendPacket(player, packet);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendActionBar(Player player, String message) {
|
||||
if (!player.isOnline()) {
|
||||
return; // Player may have logged out
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> craftPlayerClass = Class.forName("org.bukkit.craftbukkit." + nmsver + ".entity.CraftPlayer");
|
||||
Object craftPlayer = craftPlayerClass.cast(player);
|
||||
Object packet;
|
||||
Class<?> packetPlayOutChatClass = Class.forName("net.minecraft.server." + nmsver + ".PacketPlayOutChat");
|
||||
Class<?> packetClass = Class.forName("net.minecraft.server." + nmsver + ".Packet");
|
||||
if (useOldMethods) {
|
||||
Class<?> chatSerializerClass = Class.forName("net.minecraft.server." + nmsver + ".ChatSerializer");
|
||||
Class<?> iChatBaseComponentClass = Class.forName("net.minecraft.server." + nmsver + ".IChatBaseComponent");
|
||||
Method m3 = chatSerializerClass.getDeclaredMethod("a", String.class);
|
||||
Object cbc = iChatBaseComponentClass.cast(m3.invoke(chatSerializerClass, "{\"text\": \"" + message + "\"}"));
|
||||
packet = packetPlayOutChatClass.getConstructor(new Class<?>[]{iChatBaseComponentClass, byte.class}).newInstance(cbc, (byte) 2);
|
||||
} else {
|
||||
Class<?> chatComponentTextClass = Class.forName("net.minecraft.server." + nmsver + ".ChatComponentText");
|
||||
Class<?> iChatBaseComponentClass = Class.forName("net.minecraft.server." + nmsver + ".IChatBaseComponent");
|
||||
try {
|
||||
Class<?> chatMessageTypeClass = Class.forName("net.minecraft.server." + nmsver + ".ChatMessageType");
|
||||
Object[] chatMessageTypes = chatMessageTypeClass.getEnumConstants();
|
||||
Object chatMessageType = null;
|
||||
for (Object obj : chatMessageTypes) {
|
||||
if (obj.toString().equals("GAME_INFO")) {
|
||||
chatMessageType = obj;
|
||||
}
|
||||
}
|
||||
Object chatCompontentText = chatComponentTextClass.getConstructor(new Class<?>[]{String.class}).newInstance(message);
|
||||
packet = packetPlayOutChatClass.getConstructor(new Class<?>[]{iChatBaseComponentClass, chatMessageTypeClass}).newInstance(chatCompontentText, chatMessageType);
|
||||
} catch (ClassNotFoundException cnfe) {
|
||||
Object chatCompontentText = chatComponentTextClass.getConstructor(new Class<?>[]{String.class}).newInstance(message);
|
||||
packet = packetPlayOutChatClass.getConstructor(new Class<?>[]{iChatBaseComponentClass, byte.class}).newInstance(chatCompontentText, (byte) 2);
|
||||
}
|
||||
}
|
||||
Method craftPlayerHandleMethod = craftPlayerClass.getDeclaredMethod("getHandle");
|
||||
Object craftPlayerHandle = craftPlayerHandleMethod.invoke(craftPlayer);
|
||||
Field playerConnectionField = craftPlayerHandle.getClass().getDeclaredField("playerConnection");
|
||||
Object playerConnection = playerConnectionField.get(craftPlayerHandle);
|
||||
Method sendPacketMethod = playerConnection.getClass().getDeclaredMethod("sendPacket", packetClass);
|
||||
sendPacketMethod.invoke(playerConnection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendActionBarPost112(Player player, String message) {
|
||||
if (!player.isOnline()) {
|
||||
return; // Player may have logged out
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> craftPlayerClass = Class.forName("org.bukkit.craftbukkit." + nmsver + ".entity.CraftPlayer");
|
||||
Object craftPlayer = craftPlayerClass.cast(player);
|
||||
Object ppoc;
|
||||
Class<?> c4 = Class.forName("net.minecraft.server." + nmsver + ".PacketPlayOutChat");
|
||||
Class<?> c5 = Class.forName("net.minecraft.server." + nmsver + ".Packet");
|
||||
Class<?> c2 = Class.forName("net.minecraft.server." + nmsver + ".ChatComponentText");
|
||||
Class<?> c3 = Class.forName("net.minecraft.server." + nmsver + ".IChatBaseComponent");
|
||||
Class<?> chatMessageTypeClass = Class.forName("net.minecraft.server." + nmsver + ".ChatMessageType");
|
||||
Object[] chatMessageTypes = chatMessageTypeClass.getEnumConstants();
|
||||
Object chatMessageType = null;
|
||||
for (Object obj : chatMessageTypes) {
|
||||
if (obj.toString().equals("GAME_INFO")) {
|
||||
chatMessageType = obj;
|
||||
}
|
||||
}
|
||||
Object o = c2.getConstructor(new Class<?>[]{String.class}).newInstance(message);
|
||||
ppoc = c4.getConstructor(new Class<?>[]{c3, chatMessageTypeClass}).newInstance(o, chatMessageType);
|
||||
Method m1 = craftPlayerClass.getDeclaredMethod("getHandle");
|
||||
Object h = m1.invoke(craftPlayer);
|
||||
Field f1 = h.getClass().getDeclaredField("playerConnection");
|
||||
Object pc = f1.get(h);
|
||||
Method m5 = pc.getClass().getDeclaredMethod("sendPacket", c5);
|
||||
m5.invoke(pc, ppoc);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendActionBarPre112(Player player, String message) {
|
||||
if (!player.isOnline()) {
|
||||
return; // Player may have logged out
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> craftPlayerClass = Class.forName("org.bukkit.craftbukkit." + nmsver + ".entity.CraftPlayer");
|
||||
Object craftPlayer = craftPlayerClass.cast(player);
|
||||
Object ppoc;
|
||||
Class<?> c4 = Class.forName("net.minecraft.server." + nmsver + ".PacketPlayOutChat");
|
||||
Class<?> c5 = Class.forName("net.minecraft.server." + nmsver + ".Packet");
|
||||
if (useOldMethods) {
|
||||
Class<?> c2 = Class.forName("net.minecraft.server." + nmsver + ".ChatSerializer");
|
||||
Class<?> c3 = Class.forName("net.minecraft.server." + nmsver + ".IChatBaseComponent");
|
||||
Method m3 = c2.getDeclaredMethod("a", String.class);
|
||||
Object cbc = c3.cast(m3.invoke(c2, "{\"text\": \"" + message + "\"}"));
|
||||
ppoc = c4.getConstructor(new Class<?>[]{c3, byte.class}).newInstance(cbc, (byte) 2);
|
||||
} else {
|
||||
Class<?> c2 = Class.forName("net.minecraft.server." + nmsver + ".ChatComponentText");
|
||||
Class<?> c3 = Class.forName("net.minecraft.server." + nmsver + ".IChatBaseComponent");
|
||||
Object o = c2.getConstructor(new Class<?>[]{String.class}).newInstance(message);
|
||||
ppoc = c4.getConstructor(new Class<?>[]{c3, byte.class}).newInstance(o, (byte) 2);
|
||||
}
|
||||
Method m1 = craftPlayerClass.getDeclaredMethod("getHandle");
|
||||
Object h = m1.invoke(craftPlayer);
|
||||
Field f1 = h.getClass().getDeclaredField("playerConnection");
|
||||
Object pc = f1.get(h);
|
||||
Method m5 = pc.getClass().getDeclaredMethod("sendPacket", c5);
|
||||
m5.invoke(pc, ppoc);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendActionBar(final Player player, final String message, int duration) {
|
||||
sendActionBar(player, message);
|
||||
|
||||
if (duration >= 0) {
|
||||
// Sends empty message at the end of the duration. Allows messages shorter than 3 seconds, ensures precision.
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendActionBar(player, "");
|
||||
}
|
||||
}.runTaskLater(instance, duration + 1);
|
||||
}
|
||||
|
||||
// Re-sends the messages every 3 seconds so it doesn't go away from the player's screen.
|
||||
while (duration > 60) {
|
||||
duration -= 60;
|
||||
int sched = duration % 60;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sendActionBar(player, message);
|
||||
}
|
||||
}.runTaskLater(instance, (long) sched);
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendActionBarToAllPlayers(String message) {
|
||||
sendActionBarToAllPlayers(message, -1);
|
||||
}
|
||||
|
||||
public static void sendActionBarToAllPlayers(String message, int duration) {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
sendActionBar(p, message, duration);
|
||||
}
|
||||
}
|
||||
|
||||
public static void init(EpicVouchers epicVouchers) {
|
||||
instance = epicVouchers;
|
||||
nmsver = Bukkit.getServer().getClass().getPackage().getName();
|
||||
nmsver = nmsver.substring(nmsver.lastIndexOf(".") + 1);
|
||||
|
||||
if (nmsver.equalsIgnoreCase("v1_8_R1") || nmsver.equalsIgnoreCase("v1_7_")) { // Not sure if 1_7 works for the protocol hack?
|
||||
useOldMethods = true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv.IconClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Icon {
|
||||
private ItemStack itemStack;
|
||||
private Consumer<IconClickEvent> consumer;
|
||||
|
||||
public Icon(ItemStack itemStack) {
|
||||
this(itemStack, event -> {});
|
||||
}
|
||||
|
||||
public Icon(ItemStack item, Consumer<IconClickEvent> consumer) {
|
||||
this.itemStack = item;
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
public void run(IconClickEvent e) { consumer.accept(e); }
|
||||
|
||||
public ItemStack getItemStack() { return itemStack; }
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.core.gui.AnvilGui;
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.utils.Pair;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import static org.bukkit.ChatColor.GRAY;
|
||||
import static org.bukkit.ChatColor.YELLOW;
|
||||
import static org.bukkit.Material.PAPER;
|
||||
|
||||
public class ListEntryIcon extends Icon {
|
||||
public ListEntryIcon(EpicVouchers instance, String entry, BiConsumer<Player, String> onRemove, BiConsumer<Player, Pair<String, String>> onEdit) {
|
||||
super(new ItemBuilder(PAPER).name(YELLOW + entry).lore(GRAY + "Right click to edit",
|
||||
GRAY + "Left click to remove").build(), event -> {
|
||||
if (event.getClickType() == ClickType.LEFT) {
|
||||
onRemove.accept(event.getPlayer(), entry);
|
||||
return;
|
||||
}
|
||||
|
||||
AnvilGui gui = new AnvilGui(event.getPlayer());
|
||||
gui.setTitle("Current: " + entry);
|
||||
gui.setAction(aevent -> onEdit.accept(event.getPlayer(), new Pair<>(entry, gui.getInputText().trim())));
|
||||
instance.getGuiManager().showGUI(event.getPlayer(), gui);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package com.songoda.epicvouchers.libraries.inventory.icons;
|
||||
|
||||
import com.songoda.epicvouchers.libraries.ItemBuilder;
|
||||
import com.songoda.epicvouchers.libraries.inventory.IconInv.IconClickEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class ToggleableIcon extends Icon {
|
||||
private Consumer<IconClickEvent> consumer;
|
||||
|
||||
public ToggleableIcon(String displayname, Consumer<IconClickEvent> consumer, boolean state) {
|
||||
super(new ItemBuilder(Material.PAPER)
|
||||
.name(ChatColor.YELLOW + displayname)
|
||||
.lore(state ? ChatColor.GREEN + "ENABLED" : ChatColor.RED + "DISABLED")
|
||||
.build(), event -> {});
|
||||
this.consumer = consumer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(IconClickEvent event) {
|
||||
consumer.accept(event);
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
package com.songoda.epicvouchers.listeners;
|
||||
|
||||
import com.songoda.epicvouchers.EpicVouchers;
|
||||
import com.songoda.epicvouchers.menus.ConfirmMenu;
|
||||
import com.songoda.epicvouchers.voucher.Voucher;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerInteractListener implements Listener {
|
||||
|
||||
private final EpicVouchers instance;
|
||||
|
||||
public PlayerInteractListener(EpicVouchers instance) {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void voucherListener(PlayerInteractEvent event) {
|
||||
final ItemStack item = event.getItem();
|
||||
if (item == null || (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK))
|
||||
return;
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
for (Voucher voucher : instance.getVoucherManager().getVouchers()) {
|
||||
final ItemStack voucherItem = voucher.toItemStack();
|
||||
// does the item they're holding match this voucher?
|
||||
|
||||
if (voucherItem != null && !voucherItem.isSimilar(item)) continue;
|
||||
else if (item.getType() != voucher.getMaterial() || item.getDurability() != voucher.getData()) continue;
|
||||
else {
|
||||
// material matches - verify the name + lore
|
||||
final ItemMeta meta = item.getItemMeta();
|
||||
if (meta == null || !meta.hasDisplayName()
|
||||
|| !ChatColor.stripColor(meta.getDisplayName()).equals(ChatColor.stripColor(voucher.getName(true)))
|
||||
|| (meta.hasLore() && !meta.getLore().equals(voucher.getLore(true))))
|
||||
continue;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
// does the player have permission to redeem this voucher?
|
||||
if (!voucher.getPermission().isEmpty() && !player.hasPermission(voucher.getPermission())) {
|
||||
// todo: probably should send a message to the player...
|
||||
return;
|
||||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
|
||||
if (instance.getCoolDowns().isOnCoolDown(uuid)) {
|
||||
instance.getLocale().getMessage("event.general.cooldown")
|
||||
.processPlaceholder("time", instance.getCoolDowns().getTime(uuid))
|
||||
.processPlaceholder("voucher", voucher.getName(true))
|
||||
.sendPrefixedMessage(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (voucher.isConfirm()) {
|
||||
new ConfirmMenu(instance,
|
||||
() -> instance.getVoucherExecutor().redeemVoucher(player, voucher, item, true, event),
|
||||
() -> {
|
||||
})
|
||||
.open(player);
|
||||
} else {
|
||||
instance.getVoucherExecutor().redeemVoucher(player, voucher, item, true, event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,102 +0,0 @@
|
|||
package com.songoda.epicvouchers.utils;
|
||||
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
public class NMSUtil {
|
||||
|
||||
public static String getVersion() {
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
return name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
|
||||
public static int getVersionNumber() {
|
||||
String name = getVersion().substring(3);
|
||||
return Integer.valueOf(name.substring(0, name.length() - 4));
|
||||
}
|
||||
|
||||
public static int getVersionReleaseNumber() {
|
||||
String NMSVersion = getVersion();
|
||||
return Integer.valueOf(NMSVersion.substring(NMSVersion.length() - 2).replace(".", ""));
|
||||
}
|
||||
|
||||
public static Class<?> getNMSClass(String className) {
|
||||
try {
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
Class<?> clazz = Class.forName(fullName);
|
||||
return clazz;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Class<?> getCraftClass(String className) throws ClassNotFoundException {
|
||||
try {
|
||||
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
||||
Class<?> clazz = Class.forName(fullName);
|
||||
return clazz;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Field getField(Class<?> clazz, String name, boolean declared) {
|
||||
try {
|
||||
Field field;
|
||||
|
||||
if (declared) {
|
||||
field = clazz.getDeclaredField(name);
|
||||
} else {
|
||||
field = clazz.getField(name);
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static Object getFieldObject(Object object, Field field) {
|
||||
try {
|
||||
return field.get(object);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setField(Object object, String fieldName, Object fieldValue, boolean declared) {
|
||||
try {
|
||||
Field field;
|
||||
|
||||
if (declared) {
|
||||
field = object.getClass().getDeclaredField(fieldName);
|
||||
} else {
|
||||
field = object.getClass().getField(fieldName);
|
||||
}
|
||||
|
||||
field.setAccessible(true);
|
||||
field.set(object, fieldValue);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendPacket(Player player, Object packet) {
|
||||
try {
|
||||
Object handle = player.getClass().getMethod("getHandle").invoke(player);
|
||||
Object playerConnection = handle.getClass().getField("playerConnection").get(handle);
|
||||
playerConnection.getClass().getMethod("sendPacket", getNMSClass("Packet")).invoke(playerConnection, packet);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
package com.songoda.epicvouchers.voucher;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class VoucherManager {
|
||||
|
||||
private final Map<String, Voucher> registeredVouchers = new HashMap<>();
|
||||
|
||||
public Voucher addVoucher(Voucher voucher) {
|
||||
return registeredVouchers.put(voucher.getKey(), voucher);
|
||||
}
|
||||
|
||||
public Voucher removeVoucher(Voucher voucher) {
|
||||
return registeredVouchers.remove(voucher);
|
||||
}
|
||||
|
||||
public Voucher getVoucher(String key) {
|
||||
return registeredVouchers.get(key);
|
||||
}
|
||||
|
||||
public Collection<Voucher> getVouchers() {
|
||||
return registeredVouchers.values();
|
||||
}
|
||||
|
||||
public void clearVouchers() {
|
||||
registeredVouchers.clear();
|
||||
}
|
||||
}
|
|
@ -1,13 +1,14 @@
|
|||
name: EpicVouchers
|
||||
main: com.songoda.epicvouchers.EpicVouchers
|
||||
version: maven-version-number
|
||||
author: Songoda
|
||||
website: https://songoda.host/epicvouchers
|
||||
description: Enhance your server with awesome customizable vouchers with a lot of features.
|
||||
name: ${project.name}
|
||||
description: ${project.description}
|
||||
version: ${project.version}
|
||||
api-version: 1.13
|
||||
|
||||
main: com.craftaro.epicvouchers.EpicVouchers
|
||||
|
||||
author: Craftaro
|
||||
website: ${project.url}
|
||||
|
||||
commands:
|
||||
epicvouchers:
|
||||
description: View information on this plugin.
|
||||
EpicVouchers:
|
||||
default: true
|
||||
aliases: [ev]
|
||||
usage: /ev
|
||||
aliases: [ ev ]
|
||||
|
|
|
@ -12,7 +12,7 @@ vouchers:
|
|||
- "ðis nice cookie will tell you."
|
||||
- ""
|
||||
- "&cWhat could be inside this voucher?"
|
||||
- "&6- Songoda"
|
||||
- "&6- Craftaro"
|
||||
glow: true
|
||||
confirm: true
|
||||
unbreakable: true
|
||||
|
@ -51,4 +51,4 @@ vouchers:
|
|||
effects:
|
||||
effect: "SPEED"
|
||||
amplifier: 2
|
||||
duration: 10
|
||||
duration: 10
|
||||
|
|
Loading…
Reference in New Issue