mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
Compare commits
27 Commits
feat/craft
...
old/iris3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d6224db08 | ||
|
|
4f53b058fa | ||
|
|
fdca73405e | ||
|
|
003087ee94 | ||
|
|
0a72a1acfc | ||
|
|
e88519f474 | ||
|
|
6d8c92b512 | ||
|
|
efe800c606 | ||
|
|
1634454700 | ||
|
|
d31a9605d5 | ||
|
|
f061b5848a | ||
|
|
a4b47dee6c | ||
|
|
54331d8e76 | ||
|
|
1a7ba74517 | ||
|
|
6285651194 | ||
|
|
3339f77e1c | ||
|
|
8b124bf298 | ||
|
|
0a2e3e5e88 | ||
|
|
6873051bcb | ||
|
|
5e2438d6f6 | ||
|
|
9d4caa7be4 | ||
|
|
cbfad43467 | ||
|
|
cc70a30315 | ||
|
|
c209895389 | ||
|
|
1f9f7101e2 | ||
|
|
ed89e7c845 | ||
|
|
80dff702fc |
63
.github/ISSUE_TEMPLATE/bug.yml
vendored
63
.github/ISSUE_TEMPLATE/bug.yml
vendored
@@ -1,63 +0,0 @@
|
||||
name: Iris Bug Report
|
||||
description: File a bug report for Iris
|
||||
labels: [ bug ]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thank you for taking the time to fill this out!
|
||||
If this does not work for you, feel free to use the [blank](https://github.com/VolmitSoftware/Iris/issues/new) format.
|
||||
- type: textarea
|
||||
id: how
|
||||
attributes:
|
||||
label: Problem
|
||||
description: Please give a text description of how you reached the problem
|
||||
value: |
|
||||
1. Install Iris...
|
||||
2. Do this...
|
||||
3. Do that...
|
||||
4. Observe the error...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: what
|
||||
attributes:
|
||||
label: Solution
|
||||
description: Explain where you think the problem comes from (optional)
|
||||
placeholder: The code to place a is missing b and c...
|
||||
validations:
|
||||
required: false
|
||||
- type: dropdown
|
||||
id: mcversion
|
||||
attributes:
|
||||
label: Minecraft Version
|
||||
description: What version of Minecraft is the server on?
|
||||
options:
|
||||
- 1.14.X
|
||||
- 1.15.X
|
||||
- 1.16.X
|
||||
- 1.17
|
||||
- 1.17.1
|
||||
- 1.18
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: irisversion
|
||||
attributes:
|
||||
label: Iris Version
|
||||
description: What version of Iris are you running? (see console)
|
||||
placeholder: DO NOT SAY "LATEST"
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: logs
|
||||
attributes:
|
||||
label: Log
|
||||
description: Paste a full log. Always use [mclogs](https://mclo.gs) Or [Pastebin](https://pastebin.com/). Must not be a crash report. Must be a full log. Must not be a screenshot of a log.
|
||||
placeholder: https://mslog.gs/...
|
||||
validations:
|
||||
required: true
|
||||
- type: markdown
|
||||
id: thanks
|
||||
attributes:
|
||||
value: "Thank you for filling out the form! We will be with you soon. Please do not ask support to review your report."
|
||||
46
.github/ISSUE_TEMPLATE/feature.yml
vendored
46
.github/ISSUE_TEMPLATE/feature.yml
vendored
@@ -1,46 +0,0 @@
|
||||
name: Iris Feature Request
|
||||
description: File a feature request for Iris. If you want to report a bug this is not the place.
|
||||
labels: [ feature ]
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
Thank you for taking the time to fill this out!
|
||||
If this does not work for you, feel free to use the [blank](https://github.com/VolmitSoftware/Iris/issues/new) format.
|
||||
- type: dropdown
|
||||
id: arc
|
||||
attributes:
|
||||
label: Adding, Removing, or Changing
|
||||
description: What are you doing
|
||||
options:
|
||||
- Adding
|
||||
- Removing
|
||||
- Changing
|
||||
validations:
|
||||
required: true
|
||||
- type: input
|
||||
id: atype
|
||||
attributes:
|
||||
label: Type of Modification
|
||||
description: What is it for?
|
||||
value: I want to ...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: desc
|
||||
attributes:
|
||||
label: What are you trying to modify
|
||||
description: Give as detailed of a description as you can for the modification that you want done (include pictures if applicable)
|
||||
value: The way I would implement this is ...
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
id: alternative
|
||||
attributes:
|
||||
label: Alternatives
|
||||
description: What alternatives have you considered?
|
||||
value: If this could not be implemented I would ...
|
||||
- type: markdown
|
||||
id: thanks
|
||||
attributes:
|
||||
value: "Thank you for filling out the form! We will be with you soon. Please do not ask support to review your report."
|
||||
518
LICENSE.md
518
LICENSE.md
@@ -1,518 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the
|
||||
works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all
|
||||
versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use
|
||||
the GNU General Public License for most of our software; it applies also to any other work released this way by its
|
||||
authors. You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make
|
||||
sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive
|
||||
source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and
|
||||
that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights.
|
||||
Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it:
|
||||
responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients
|
||||
the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must
|
||||
show them these terms so they know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute
|
||||
and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software.
|
||||
For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems
|
||||
will not be attributed erroneously to authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although
|
||||
the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the
|
||||
software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely
|
||||
where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we stand ready to extend this provision to those
|
||||
domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict
|
||||
development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger
|
||||
that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "
|
||||
Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission,
|
||||
other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a
|
||||
work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily
|
||||
liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy.
|
||||
Propagation includes copying, distribution (with or without modification), making available to the public, and in some
|
||||
countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction
|
||||
with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright
|
||||
notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the extent that warranties are provided), that
|
||||
licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a
|
||||
list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means
|
||||
any non-source form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body,
|
||||
or, in the case of interfaces specified for a particular programming language, one that is widely used among developers
|
||||
working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in
|
||||
the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to
|
||||
enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is
|
||||
available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used
|
||||
to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (
|
||||
for an executable work) run the object code and to modify the work, including scripts to control those activities.
|
||||
However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs
|
||||
which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding
|
||||
Source includes interface definition files associated with source files for the work, and the source code for shared
|
||||
libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data
|
||||
communication or control flow between those subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the
|
||||
Corresponding Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided
|
||||
the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program.
|
||||
The output from running a covered work is covered by this License only if the output, given its content, constitutes a
|
||||
covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license
|
||||
otherwise remains in force. You may convey covered works to others for the sole purpose of having them make
|
||||
modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do not control copyright. Those thus making or running
|
||||
the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that
|
||||
prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not
|
||||
allowed; section 10 makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling
|
||||
obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or
|
||||
restricting circumvention of such measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the
|
||||
extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you
|
||||
disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users,
|
||||
your or third parties' legal rights to forbid circumvention of technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating
|
||||
that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices
|
||||
of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for
|
||||
a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source
|
||||
code under the terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of
|
||||
the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or
|
||||
distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the
|
||||
compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause
|
||||
this License to apply to the other parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library,
|
||||
need not be included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used
|
||||
for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In
|
||||
determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a
|
||||
particular product received by a particular user, "normally used" refers to a typical or common use of that class of
|
||||
product, regardless of the status of the particular user or of the way in which the particular user actually uses, or
|
||||
expects or is expected to use, the product. A product is a consumer product regardless of whether the product has
|
||||
substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of
|
||||
the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods, procedures, authorization keys, or other information
|
||||
required to install and execute modified versions of a covered work in that User Product from a modified version of its
|
||||
Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code
|
||||
is in no case prevented or interfered with solely because modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the
|
||||
conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to
|
||||
the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding
|
||||
Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not
|
||||
apply if neither you nor any third party retains the ability to install modified object code on the User Product (for
|
||||
example, the work has been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a requirement to continue to provide support
|
||||
service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product
|
||||
in which it has been modified or installed. Access to a network may be denied when the modification itself materially
|
||||
and adversely affects the operation of the network or violates the rules and protocols for communication across the
|
||||
network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format
|
||||
that is publicly documented (and with an implementation available to the public in source code form), and must require
|
||||
no special password or key for unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of
|
||||
its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were
|
||||
included in this License, to the extent that they are valid under applicable law. If additional permissions apply only
|
||||
to part of the Program, that part may be used separately under those permissions, but the entire Program remains
|
||||
governed by this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or
|
||||
from any part of it. (Additional permissions may be written to require their own removal in certain cases when you
|
||||
modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have
|
||||
or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by
|
||||
the copyright holders of that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the
|
||||
Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with
|
||||
a term that is a further restriction, you may remove that term. If a license document contains a further restriction but
|
||||
permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of
|
||||
that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a
|
||||
statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as
|
||||
exceptions; the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to
|
||||
propagate or modify it is void, and will automatically terminate your rights under this License (including any patent
|
||||
licenses granted under the third paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your license from a particular copyright holder is
|
||||
reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b)
|
||||
permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days
|
||||
after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you
|
||||
of the violation by some reasonable means, this is the first time you have received notice of violation of this
|
||||
License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the
|
||||
notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or
|
||||
rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not
|
||||
qualify to receive new licenses for the same material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a
|
||||
covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not
|
||||
require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered
|
||||
work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run,
|
||||
modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third
|
||||
parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or
|
||||
subdividing an organization, or merging organizations. If propagation of a covered work results from an entity
|
||||
transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work
|
||||
the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with
|
||||
reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For
|
||||
example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License,
|
||||
and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using,
|
||||
selling, offering for sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the
|
||||
Program is based. The work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already
|
||||
acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or
|
||||
selling its contributor version, but do not include claims that would be infringed only as a consequence of further
|
||||
modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent
|
||||
sublicenses in a manner consistent with the requirements of this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential
|
||||
patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its
|
||||
contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not
|
||||
to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a
|
||||
patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not
|
||||
available for anyone to copy, free of charge and under the terms of this License, through a publicly available network
|
||||
server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available,
|
||||
or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a
|
||||
manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "
|
||||
Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in
|
||||
a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in
|
||||
that country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring
|
||||
conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing
|
||||
them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is
|
||||
automatically extended to all recipients of the covered work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of,
|
||||
or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You
|
||||
may not convey a covered work if you are a party to an arrangement with a third party that is in the business of
|
||||
distributing software, under which you make payment to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a
|
||||
discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from
|
||||
those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered
|
||||
work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to
|
||||
infringement that may otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this
|
||||
License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to
|
||||
satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence
|
||||
you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further
|
||||
conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License
|
||||
would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work
|
||||
licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the
|
||||
resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special
|
||||
requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply
|
||||
to the combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to
|
||||
time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new
|
||||
problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the
|
||||
GNU General Public License "or any later version" applies to it, you have the option of following the terms and
|
||||
conditions either of that numbered version or of any later version published by the Free Software Foundation. If the
|
||||
Program does not specify a version number of the GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used,
|
||||
that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the
|
||||
Program.
|
||||
|
||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed
|
||||
on any author or copyright holder as a result of your choosing to follow a later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING
|
||||
THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR
|
||||
IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU
|
||||
ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO
|
||||
MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL,
|
||||
INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO
|
||||
LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM
|
||||
TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to
|
||||
their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil
|
||||
liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program
|
||||
in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve
|
||||
this is to make it free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to
|
||||
most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer
|
||||
to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of
|
||||
course, your program's commands might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for
|
||||
the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is
|
||||
a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If
|
||||
this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
22
README.md
22
README.md
@@ -1,15 +1,18 @@
|
||||
# Iris
|
||||
# IrisBukkit
|
||||
|
||||
The master branch is for the latest version of minecraft.
|
||||
|
||||
# [Support](https://discord.gg/3xxPTpT) **|** [Documentation](https://docs.volmit.com/iris/) **|** [Git](https://github.com/IrisDimensions)
|
||||
# [Support](https://discord.gg/3xxPTpT) **|** [Documentation](https://docs.volmit.com/iris/) **
|
||||
|** [Git](https://github.com/IrisDimensions)
|
||||
|
||||
# Building
|
||||
|
||||
Building Iris is fairly simple, though you will need to setup a few things if your system has never been used for java
|
||||
Building IrisBukkit is fairly simple, though you will need to setup a few things if your system has never been used for
|
||||
java
|
||||
development.
|
||||
|
||||
Consider supporting our development by buying Iris on spigot! We work hard to make Iris the best it can be for everyone.
|
||||
Consider supporting our development by buying IrisBukkit on spigot! We work hard to make IrisBukkit the best it can be
|
||||
for everyone.
|
||||
|
||||
### Command Line Builds
|
||||
|
||||
@@ -28,20 +31,23 @@ Consider supporting our development by buying Iris on spigot! We work hard to ma
|
||||
3. Add `export JAVA_HOME=$(/usr/libexec/java_home)` as a new line
|
||||
4. Use `CTRL + X`, then Press `Y`, Then `ENTER`
|
||||
5. Quit & Reopen Terminal and verify with `echo $JAVA_HOME`. It should print a directory
|
||||
3. If this is your first time building Iris for MC 1.18+ run `gradlew setup` inside the root Iris project folder.
|
||||
3. If this is your first time building IrisBukkit for MC 1.18+ run `gradlew setup` inside the root IrisBukkit project
|
||||
folder.
|
||||
Otherwise, skip this step. Grab a coffee, this may take up to 5 minutes depending on your cpu & internet connection.
|
||||
4. Once the project has setup, run `gradlew iris`
|
||||
5. The Iris jar will be placed in `Iris/build/Iris-XXX-XXX.jar` Enjoy! Consider supporting us by buying it on spigot!
|
||||
5. The IrisBukkit jar will be placed in `IrisBukkit/build/IrisBukkit-XXX-XXX.jar` Enjoy! Consider supporting us by
|
||||
buying it on spigot!
|
||||
|
||||
### IDE Builds (for development)
|
||||
|
||||
* Run `gradlew setup` any time you get dependency issues with craftbukkit
|
||||
* Configure ITJ Gradle to use JDK 17 (in settings, search for gradle)
|
||||
* Add a build line in the build.gradle for your own build task to directly compile Iris into your plugins folder if you
|
||||
* Add a build line in the build.gradle for your own build task to directly compile IrisBukkit into your plugins folder
|
||||
if you
|
||||
prefer.
|
||||
* Resync the project & run your newly created task (under the development folder in gradle tasks!)
|
||||
|
||||
# Iris Toolbelt
|
||||
# IrisBukkit Toolbelt
|
||||
|
||||
Everyone needs a tool-belt.
|
||||
|
||||
|
||||
326
build.gradle
326
build.gradle
@@ -1,323 +1,41 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id 'java'
|
||||
id 'java-library'
|
||||
id "io.freefair.lombok" version "6.3.0"
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
id "de.undercouch.download" version "5.0.1"
|
||||
}
|
||||
|
||||
version '2.2.1-1.19' // Needs to be version specific
|
||||
def nmsVersion = "1.19"
|
||||
def apiVersion = '1.19'
|
||||
def spigotJarVersion = '1.19-R0.1-SNAPSHOT'
|
||||
def name = getRootProject().getName() // Defined in settings.gradle
|
||||
def main = 'com.volmit.iris.Iris'
|
||||
group 'com.volmit.iris'
|
||||
version '1.0-SNAPSHOT'
|
||||
|
||||
// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
|
||||
// ======================== WINDOWS =============================
|
||||
registerCustomOutputTask('Cyberpwn', 'C://Users/cyberpwn/Documents/development/server/plugins')
|
||||
registerCustomOutputTask('Psycho', 'D://Dan/MinecraftDevelopment/server/plugins')
|
||||
registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins')
|
||||
registerCustomOutputTask('Coco', 'D://Documents/MC/plugins')
|
||||
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
|
||||
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19/plugins')
|
||||
// ========================== UNIX ==============================
|
||||
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
|
||||
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins')
|
||||
// ==============================================================
|
||||
|
||||
/**
|
||||
* Gradle is weird sometimes, we need to delete the plugin yml from the build folder to actually filter properly.
|
||||
*/
|
||||
file(jar.archiveFile.get().getAsFile().getParentFile().getParentFile().getParentFile().getAbsolutePath() + '/build/resources/main/plugin.yml').delete()
|
||||
|
||||
/**
|
||||
* Expand properties into plugin yml
|
||||
*/
|
||||
processResources {
|
||||
filesMatching('**/plugin.yml') {
|
||||
expand(
|
||||
'name': name.toString(),
|
||||
'version': version.toString(),
|
||||
'main': main.toString(),
|
||||
'apiversion': apiVersion.toString()
|
||||
)
|
||||
jar {
|
||||
manifest {
|
||||
attributes('Contains-Sources': 'java,class')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unified repo
|
||||
*/
|
||||
repositories {
|
||||
mavenLocal {
|
||||
content {
|
||||
includeGroup("org.bukkit")
|
||||
includeGroup("org.spigotmc")
|
||||
}
|
||||
allprojects {
|
||||
apply plugin: 'java'
|
||||
|
||||
repositories {
|
||||
maven { url "https://arcanearts.jfrog.io/artifactory/archives" }
|
||||
mavenCentral()
|
||||
}
|
||||
maven { url "https://dl.cloudsmith.io/public/arcane/archive/maven/" }
|
||||
maven { url "https://maven.enginehub.org/repo/" }
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven { url "https://jitpack.io"}
|
||||
}
|
||||
|
||||
/**
|
||||
* We need parameter meta for the decree command system
|
||||
*/
|
||||
compileJava {
|
||||
options.compilerArgs << '-parameters'
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure Iris for shading
|
||||
*/
|
||||
shadowJar {
|
||||
//minimize()
|
||||
append("plugin.yml")
|
||||
relocate 'com.dfsek.paralithic', 'com.volmit.iris.util.paralithic'
|
||||
relocate 'io.papermc.lib', 'com.volmit.iris.util.paper'
|
||||
relocate 'net.kyori', 'com.volmit.iris.util.kyori'
|
||||
dependencies {
|
||||
include(dependency('io.papermc:paperlib'))
|
||||
include(dependency('com.dfsek:Paralithic'))
|
||||
include(dependency('net.kyori:'))
|
||||
compileOnly 'org.projectlombok:lombok:1.18.24'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.24'
|
||||
annotationProcessor 'systems.manifold:manifold-ext:2022.1.19'
|
||||
implementation 'art.arcane:Source:22.9.3'
|
||||
implementation 'art.arcane:Cram:22.9.3'
|
||||
implementation 'art.arcane:Amulet:22.9.5'
|
||||
implementation 'com.google.code.gson:gson:2.9.0'
|
||||
implementation 'com.github.ben-manes.caffeine:caffeine:3.1.1'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
|
||||
testAnnotationProcessor 'systems.manifold:manifold-ext:2022.1.19'
|
||||
}
|
||||
}
|
||||
|
||||
configurations.all {
|
||||
resolutionStrategy.cacheChangingModulesFor 60, 'minutes'
|
||||
resolutionStrategy.cacheDynamicVersionsFor 60, 'minutes'
|
||||
}
|
||||
|
||||
/**
|
||||
* Dependencies.
|
||||
*
|
||||
* Provided or classpath dependencies are not shaded and are available on the runtime classpath
|
||||
*
|
||||
* Shaded dependencies are not available at runtime, nor are they available on mvn central so they
|
||||
* need to be shaded into the jar (increasing binary size)
|
||||
*
|
||||
* Dynamically loaded dependencies are defined in the plugin.yml (updating these must be updated in the
|
||||
* plugin.yml also, otherwise they wont be available). These do not increase binary size). Only declare
|
||||
* these dependencies if they are available on mvn central.
|
||||
*/
|
||||
dependencies {
|
||||
// Provided or Classpath
|
||||
compileOnly 'org.projectlombok:lombok:1.18.24'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.24'
|
||||
implementation 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT'
|
||||
implementation 'me.clip:placeholderapi:2.11.1'
|
||||
implementation 'io.th0rgal:oraxen:1.94.0'
|
||||
implementation 'org.bukkit:craftbukkit:1.19-R0.1-SNAPSHOT:remapped-mojang'
|
||||
implementation 'com.github.LoneDev6:api-itemsadder:3.1.0b'
|
||||
|
||||
// Shaded
|
||||
implementation 'com.dfsek:Paralithic:0.4.0'
|
||||
implementation 'io.papermc:paperlib:1.0.5'
|
||||
implementation "net.kyori:adventure-text-minimessage:4.11.0"
|
||||
implementation 'net.kyori:adventure-platform-bukkit:4.1.0'
|
||||
implementation 'net.kyori:adventure-api:4.11.0'
|
||||
|
||||
// Dynamically Loaded
|
||||
implementation 'io.timeandspace:smoothie-map:2.0.2'
|
||||
implementation 'it.unimi.dsi:fastutil:8.5.8'
|
||||
implementation 'com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2'
|
||||
implementation 'org.zeroturnaround:zt-zip:1.14'
|
||||
implementation 'com.google.code.gson:gson:2.9.0'
|
||||
implementation 'org.ow2.asm:asm:9.2'
|
||||
implementation 'com.google.guava:guava:31.1-jre'
|
||||
implementation 'bsf:bsf:2.4.0'
|
||||
implementation 'rhino:js:1.7R2'
|
||||
implementation 'com.github.ben-manes.caffeine:caffeine:3.0.6'
|
||||
implementation 'org.apache.commons:commons-lang3:3.12.0'
|
||||
}
|
||||
|
||||
if (JavaVersion.current().toString() != "17") {
|
||||
System.err.println()
|
||||
System.err.println("=========================================================================================================")
|
||||
System.err.println("You must run gradle on Java 17. You are using " + JavaVersion.current())
|
||||
System.err.println()
|
||||
System.err.println("=== For IDEs ===")
|
||||
System.err.println("1. Configure the project for Java 17")
|
||||
System.err.println("2. Configure the bundled gradle to use Java 17 in settings")
|
||||
System.err.println()
|
||||
System.err.println("=== For Command Line (gradlew) ===")
|
||||
System.err.println("1. Install JDK 17 from https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html")
|
||||
System.err.println("2. Set JAVA_HOME environment variable to the new jdk installation folder such as C:\\Program Files\\Java\\jdk-17.0.1")
|
||||
System.err.println("3. Open a new command prompt window to get the new environment variables if need be.")
|
||||
System.err.println("=========================================================================================================")
|
||||
System.err.println()
|
||||
System.exit(69);
|
||||
}
|
||||
|
||||
def buildToolsJar = new File(buildDir, "buildtools/BuildTools.jar");
|
||||
def specialSourceJar = new File(buildDir, "specialsource/SpecialSource.jar");
|
||||
def buildToolsFolder = new File(buildDir, "buildtools");
|
||||
def specialSourceFolder = new File(buildDir, "specialsource");
|
||||
def buildToolsHint = new File(buildDir, "buildtools/craftbukkit-" + nmsVersion + ".jar");
|
||||
def outputShadeJar = new File(buildDir, "libs/Iris-" + version + "-all.jar");
|
||||
def ssiJar = new File(buildDir, "specialsource/Iris-" + version + "-all.jar");
|
||||
def ssobfJar = new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar");
|
||||
def ssJar = new File(buildDir, "specialsource/Iris-" + version + "-rma.jar");
|
||||
def homePath = System.properties['user.home']
|
||||
def m2 = new File(homePath + "/.m2/repository")
|
||||
def m2s = m2.getAbsolutePath();
|
||||
|
||||
// ======================== Building Mapped Jars =============================
|
||||
task downloadBuildtools(type: Download) {
|
||||
group "remapping"
|
||||
src 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar'
|
||||
dest buildToolsJar
|
||||
onlyIf {
|
||||
!buildToolsJar.exists()
|
||||
}
|
||||
}
|
||||
|
||||
task downloadSpecialSource(type: Download) {
|
||||
group "remapping"
|
||||
src 'https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar'
|
||||
dest specialSourceJar
|
||||
onlyIf {
|
||||
!specialSourceJar.exists()
|
||||
}
|
||||
}
|
||||
|
||||
task executeBuildTools(dependsOn: downloadBuildtools, type: JavaExec)
|
||||
{
|
||||
group "remapping"
|
||||
classpath = files(buildToolsJar)
|
||||
workingDir = buildToolsFolder
|
||||
args = [
|
||||
"--rev",
|
||||
nmsVersion,
|
||||
"--compile",
|
||||
"craftbukkit",
|
||||
"--remap"
|
||||
]
|
||||
onlyIf {
|
||||
!buildToolsHint.exists()
|
||||
}
|
||||
}
|
||||
|
||||
task copyBuildToSpecialSource(type: Copy)
|
||||
{
|
||||
group "remapping"
|
||||
from outputShadeJar
|
||||
into specialSourceFolder
|
||||
dependsOn(downloadSpecialSource, shadowJar)
|
||||
}
|
||||
|
||||
task specialSourceRemapObfuscate(type: JavaExec)
|
||||
{
|
||||
group "remapping"
|
||||
dependsOn(copyBuildToSpecialSource, downloadSpecialSource, shadowJar)
|
||||
workingDir = specialSourceFolder
|
||||
classpath = files(specialSourceJar,
|
||||
new File(m2s + "/org/spigotmc/spigot/" + spigotJarVersion + "/spigot-" + spigotJarVersion + "-remapped-mojang.jar"))
|
||||
mainClass = "net.md_5.specialsource.SpecialSource"
|
||||
args = [
|
||||
"--live",
|
||||
"-i",
|
||||
ssiJar.getName(),
|
||||
"-o",
|
||||
ssobfJar.getName(),
|
||||
"-m",
|
||||
m2s + "/org/spigotmc/minecraft-server/" + spigotJarVersion + "/minecraft-server-" + spigotJarVersion + "-maps-mojang.txt",
|
||||
"--reverse",
|
||||
]
|
||||
}
|
||||
|
||||
task specialSourceRemap(type: JavaExec)
|
||||
{
|
||||
group "remapping"
|
||||
dependsOn(specialSourceRemapObfuscate)
|
||||
workingDir = specialSourceFolder
|
||||
classpath = files(specialSourceJar,
|
||||
new File(m2s + "/org/spigotmc/spigot/" + spigotJarVersion + "/spigot-" + spigotJarVersion + "-remapped-obf.jar"))
|
||||
mainClass = "net.md_5.specialsource.SpecialSource"
|
||||
args = [
|
||||
"--live",
|
||||
"-i",
|
||||
ssobfJar.getName(),
|
||||
"-o",
|
||||
ssJar.getName(),
|
||||
"-m",
|
||||
m2s + "/org/spigotmc/minecraft-server/" + spigotJarVersion + "/minecraft-server-" + spigotJarVersion + "-maps-spigot.csrg"
|
||||
]
|
||||
}
|
||||
|
||||
tasks.compileJava.dependsOn(executeBuildTools)
|
||||
|
||||
compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
task setup()
|
||||
{
|
||||
group("iris")
|
||||
dependsOn(clean, executeBuildTools)
|
||||
}
|
||||
|
||||
task iris(type: Copy)
|
||||
{
|
||||
group "iris"
|
||||
from ssJar
|
||||
into buildDir
|
||||
rename { String fileName ->
|
||||
fileName.replace('Iris-' + version + '-rma.jar', "Iris-" + version + ".jar")
|
||||
}
|
||||
dependsOn(specialSourceRemap)
|
||||
}
|
||||
|
||||
def registerCustomOutputTask(name, path) {
|
||||
if (!System.properties['os.name'].toLowerCase().contains('windows')) {
|
||||
return;
|
||||
}
|
||||
|
||||
tasks.register('build' + name, Copy) {
|
||||
group('development')
|
||||
outputs.upToDateWhen { false }
|
||||
dependsOn(iris)
|
||||
from(new File(buildDir, "Iris-" + version + ".jar"))
|
||||
into(file(path))
|
||||
rename { String fileName ->
|
||||
fileName.replace("Iris-" + version + ".jar", "Iris.jar")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def registerCustomOutputTaskUnix(name, path) {
|
||||
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
||||
return;
|
||||
}
|
||||
|
||||
tasks.register('build' + name, Copy) {
|
||||
group('development')
|
||||
outputs.upToDateWhen { false }
|
||||
dependsOn(iris)
|
||||
from(new File(buildDir, "Iris-" + version + ".jar"))
|
||||
into(file(path))
|
||||
rename { String fileName ->
|
||||
fileName.replace("Iris-" + version + ".jar", "Iris.jar")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
290
bukkit/build.gradle
Normal file
290
bukkit/build.gradle
Normal file
@@ -0,0 +1,290 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id "io.freefair.lombok" version "6.3.0"
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
id "de.undercouch.download" version "5.0.1"
|
||||
}
|
||||
|
||||
group rootProject.group
|
||||
version rootProject.version
|
||||
|
||||
def nmsVersion = "1.19"
|
||||
def apiVersion = '1.19'
|
||||
def spigotJarVersion = '1.19-R0.1-SNAPSHOT'
|
||||
def name = getRootProject().getName() // Defined in settings.gradle
|
||||
def main = 'com.volmit.iris.platform.bukkit.IrisBukkit'
|
||||
|
||||
// ADD YOURSELF AS A NEW LINE IF YOU WANT YOUR OWN BUILD TASK GENERATED
|
||||
// ======================== WINDOWS =============================
|
||||
registerCustomOutputTask('Cyberpwn', 'C://Users/cyberpwn/Documents/development/server/plugins')
|
||||
registerCustomOutputTask('Psycho', 'D://Dan/MinecraftDevelopment/server/plugins')
|
||||
registerCustomOutputTask('ArcaneArts', 'C://Users/arcane/Documents/development/server/plugins')
|
||||
registerCustomOutputTask('Coco', 'D://Documents/MC/plugins')
|
||||
registerCustomOutputTask('Strange', 'D://Servers/1.17 Test Server/plugins')
|
||||
registerCustomOutputTask('Vatuu', 'D://Minecraft/Servers/1.19/plugins')
|
||||
// ========================== UNIX ==============================
|
||||
registerCustomOutputTaskUnix('CyberpwnLT', '/Users/danielmills/development/server/plugins')
|
||||
registerCustomOutputTaskUnix('PsychoLT', '/Users/brianfopiano/Desktop/REMOTES/RemoteMinecraft/plugins')
|
||||
// ==============================================================
|
||||
|
||||
/**
|
||||
* Gradle is weird sometimes, we need to delete the plugin yml from the build folder to actually filter properly.
|
||||
*/
|
||||
file(jar.archiveFile.get().getAsFile().getParentFile().getParentFile().getParentFile().getAbsolutePath() + '/build/resources/main/plugin.yml').delete()
|
||||
|
||||
/**
|
||||
* Expand properties into plugin yml
|
||||
*/
|
||||
processResources {
|
||||
filesMatching('**/plugin.yml') {
|
||||
expand(
|
||||
'name': name.toString(),
|
||||
'version': version.toString(),
|
||||
'main': main.toString(),
|
||||
'apiversion': apiVersion.toString()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* We need parameter meta for the decree command system
|
||||
*/
|
||||
compileJava {
|
||||
options.compilerArgs << '-parameters'
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure Iris for shading
|
||||
*/
|
||||
shadowJar {
|
||||
//minimize()
|
||||
append("plugin.yml")
|
||||
relocate 'com.dfsek.paralithic', 'com.volmit.iris.util.paralithic'
|
||||
relocate 'art.arcane', 'com.volmit.iris.util.arcane'
|
||||
relocate 'manifold', 'com.volmit.iris.util.manifold'
|
||||
relocate 'art.arcane.source', 'com.volmit.iris.util.source'
|
||||
relocate 'ChumBukkit.extensions', 'com.volmit.iris.util.extensions'
|
||||
relocate 'IrisBukkit.extensions', 'com.volmit.iris.util.extensions'
|
||||
relocate 'Fukkit.extensions', 'com.volmit.iris.util.extensions'
|
||||
relocate 'Amulet.extensions', 'com.volmit.iris.util.extensions'
|
||||
relocate 'Iris.extensions', 'com.volmit.iris.util.extensions'
|
||||
dependencies {
|
||||
include(dependency('art.arcane:'))
|
||||
include(dependency('systems.manifold:'))
|
||||
include(dependency("com.dfsek:Paralithic:"))
|
||||
include(dependency(":engine"))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Faster dependency caches
|
||||
*/
|
||||
configurations.all {
|
||||
resolutionStrategy.cacheChangingModulesFor 60, 'minutes'
|
||||
resolutionStrategy.cacheDynamicVersionsFor 60, 'minutes'
|
||||
}
|
||||
|
||||
configurations {
|
||||
testImplementation.extendsFrom annotationProcessor
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://arcanearts.jfrog.io/artifactory/archives" }
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'org.spigotmc:spigot-api:1.19-R0.1-SNAPSHOT'
|
||||
implementation 'art.arcane:Fukkit:22.9.2'
|
||||
implementation project(":engine")
|
||||
}
|
||||
|
||||
if (JavaVersion.current() != JavaVersion.VERSION_1_8 &&
|
||||
sourceSets.main.allJava.files.any { it.name == "module-info.java" }) {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs += ['-Xplugin:Manifold', '--module-path', it.classpath.asPath]
|
||||
}
|
||||
} else {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs += ['-Xplugin:Manifold']
|
||||
}
|
||||
}
|
||||
|
||||
if (JavaVersion.current().toString() != "17") {
|
||||
System.err.println()
|
||||
System.err.println("=========================================================================================================")
|
||||
System.err.println("You must run gradle on Java 17. You are using " + JavaVersion.current())
|
||||
System.err.println()
|
||||
System.err.println("=== For IDEs ===")
|
||||
System.err.println("1. Configure the project for Java 17")
|
||||
System.err.println("2. Configure the bundled gradle to use Java 17 in settings")
|
||||
System.err.println()
|
||||
System.err.println("=== For Command Line (gradlew) ===")
|
||||
System.err.println("1. Install JDK 17 from https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html")
|
||||
System.err.println("2. Set JAVA_HOME environment variable to the new jdk installation folder such as C:\\Program Files\\Java\\jdk-17.0.1")
|
||||
System.err.println("3. Open a new command prompt window to get the new environment variables if need be.")
|
||||
System.err.println("=========================================================================================================")
|
||||
System.err.println()
|
||||
System.exit(69);
|
||||
}
|
||||
|
||||
|
||||
System.out.println(buildDir);
|
||||
def buildToolsJar = new File(buildDir, "buildtools/BuildTools.jar");
|
||||
def specialSourceJar = new File(buildDir, "specialsource/SpecialSource.jar");
|
||||
def buildToolsFolder = new File(buildDir, "buildtools");
|
||||
def specialSourceFolder = new File(buildDir, "specialsource");
|
||||
def buildToolsHint = new File(buildDir, "buildtools/craftbukkit-" + nmsVersion + ".jar");
|
||||
def outputShadeJar = new File(buildDir, "libs/bukkit-" + version + "-all.jar");
|
||||
def ssiJar = new File(buildDir, "specialsource/bukkit-" + version + "-all.jar");
|
||||
def ssobfJar = new File(buildDir, "specialsource/Iris-" + version + "-rmo.jar");
|
||||
def ssJar = new File(buildDir, "specialsource/Iris-" + version + "-rma.jar");
|
||||
def homePath = System.properties['user.home']
|
||||
def m2 = new File(homePath + "/.m2/repository")
|
||||
def m2s = m2.getAbsolutePath();
|
||||
|
||||
// ======================== Building Mapped Jars =============================
|
||||
task downloadBuildtools(type: Download) {
|
||||
group "remapping"
|
||||
src 'https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar'
|
||||
dest buildToolsJar
|
||||
onlyIf {
|
||||
!buildToolsJar.exists()
|
||||
}
|
||||
}
|
||||
|
||||
task downloadSpecialSource(type: Download) {
|
||||
group "remapping"
|
||||
src 'https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/1.10.0/SpecialSource-1.10.0-shaded.jar'
|
||||
dest specialSourceJar
|
||||
onlyIf {
|
||||
!specialSourceJar.exists()
|
||||
}
|
||||
}
|
||||
|
||||
task executeBuildTools(dependsOn: downloadBuildtools, type: JavaExec)
|
||||
{
|
||||
group "remapping"
|
||||
classpath = files(buildToolsJar)
|
||||
workingDir = buildToolsFolder
|
||||
args = [
|
||||
"--rev",
|
||||
nmsVersion,
|
||||
"--compile",
|
||||
"craftbukkit",
|
||||
"--remap"
|
||||
]
|
||||
onlyIf {
|
||||
!buildToolsHint.exists()
|
||||
}
|
||||
}
|
||||
|
||||
task copyBuildToSpecialSource(type: Copy)
|
||||
{
|
||||
group "remapping"
|
||||
from outputShadeJar
|
||||
into specialSourceFolder
|
||||
dependsOn(downloadSpecialSource, shadowJar)
|
||||
}
|
||||
|
||||
task specialSourceRemapObfuscate(type: JavaExec)
|
||||
{
|
||||
group "remapping"
|
||||
dependsOn(copyBuildToSpecialSource, downloadSpecialSource, shadowJar)
|
||||
workingDir = specialSourceFolder
|
||||
classpath = files(specialSourceJar,
|
||||
new File(m2s + "/org/spigotmc/spigot/" + spigotJarVersion + "/spigot-" + spigotJarVersion + "-remapped-mojang.jar"))
|
||||
mainClass = "net.md_5.specialsource.SpecialSource"
|
||||
args = [
|
||||
"--live",
|
||||
"-i",
|
||||
ssiJar.getName(),
|
||||
"-o",
|
||||
ssobfJar.getName(),
|
||||
"-m",
|
||||
m2s + "/org/spigotmc/minecraft-server/" + spigotJarVersion + "/minecraft-server-" + spigotJarVersion + "-maps-mojang.txt",
|
||||
"--reverse",
|
||||
]
|
||||
}
|
||||
|
||||
task specialSourceRemap(type: JavaExec)
|
||||
{
|
||||
group "remapping"
|
||||
dependsOn(specialSourceRemapObfuscate)
|
||||
workingDir = specialSourceFolder
|
||||
classpath = files(specialSourceJar,
|
||||
new File(m2s + "/org/spigotmc/spigot/" + spigotJarVersion + "/spigot-" + spigotJarVersion + "-remapped-obf.jar"))
|
||||
mainClass = "net.md_5.specialsource.SpecialSource"
|
||||
args = [
|
||||
"--live",
|
||||
"-i",
|
||||
ssobfJar.getName(),
|
||||
"-o",
|
||||
ssJar.getName(),
|
||||
"-m",
|
||||
m2s + "/org/spigotmc/minecraft-server/" + spigotJarVersion + "/minecraft-server-" + spigotJarVersion + "-maps-spigot.csrg"
|
||||
]
|
||||
}
|
||||
|
||||
tasks.compileJava.dependsOn(executeBuildTools)
|
||||
|
||||
compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
task setup()
|
||||
{
|
||||
group("iris")
|
||||
dependsOn(clean, executeBuildTools)
|
||||
}
|
||||
|
||||
task iris(type: Copy)
|
||||
{
|
||||
group "iris"
|
||||
from ssJar
|
||||
into buildDir
|
||||
rename { String fileName ->
|
||||
fileName.replace('Iris-' + version + '-rma.jar', "Iris-" + version + ".jar")
|
||||
}
|
||||
dependsOn(specialSourceRemap)
|
||||
}
|
||||
|
||||
def registerCustomOutputTask(name, path) {
|
||||
if (!System.properties['os.name'].toLowerCase().contains('windows')) {
|
||||
return;
|
||||
}
|
||||
|
||||
tasks.register('build' + name, Copy) {
|
||||
group('development')
|
||||
outputs.upToDateWhen { false }
|
||||
dependsOn(iris)
|
||||
from(new File(buildDir, "Iris-" + version + ".jar"))
|
||||
into(file(path))
|
||||
rename { String fileName ->
|
||||
fileName.replace("Iris-" + version + ".jar", "Iris.jar")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def registerCustomOutputTaskUnix(name, path) {
|
||||
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
||||
return;
|
||||
}
|
||||
|
||||
tasks.register('build' + name, Copy) {
|
||||
group('development')
|
||||
outputs.upToDateWhen { false }
|
||||
dependsOn(iris)
|
||||
from(new File(buildDir, "Iris-" + version + ".jar"))
|
||||
into(file(path))
|
||||
rename { String fileName ->
|
||||
fileName.replace("Iris-" + version + ".jar", "Iris.jar")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package com.volmit.iris.platform.bukkit;
|
||||
|
||||
import art.arcane.amulet.io.IO;
|
||||
import art.arcane.amulet.logging.LogListener;
|
||||
import com.volmit.iris.engine.EngineConfiguration;
|
||||
import com.volmit.iris.platform.IrisPlatform;
|
||||
import com.volmit.iris.platform.PlatformBiome;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import com.volmit.iris.platform.PlatformWorld;
|
||||
import com.volmit.iris.platform.bukkit.wrapper.BukkitBiome;
|
||||
import com.volmit.iris.platform.bukkit.wrapper.BukkitBlock;
|
||||
import com.volmit.iris.platform.bukkit.wrapper.BukkitKey;
|
||||
import com.volmit.iris.platform.bukkit.wrapper.BukkitWorld;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Warning;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class IrisBukkit extends JavaPlugin implements IrisPlatform, LogListener {
|
||||
private static final String TAG = ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "Iris" + ChatColor.DARK_GREEN + "/";
|
||||
private static final String TAG_STRIPPED = ChatColor.stripColor(TAG);
|
||||
private static IrisBukkit instance;
|
||||
private ConsoleCommandSender consoleSender;
|
||||
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
consoleSender = Bukkit.getConsoleSender();
|
||||
LogListener.listener.set(this);
|
||||
|
||||
getServer().getScheduler().scheduleSyncDelayedTask(this, () -> {
|
||||
World world = Bukkit.createWorld(new WorldCreator("iristests/" + UUID.randomUUID()).generator(new IrisBukkitChunkGenerator(this, EngineConfiguration.builder()
|
||||
.timings(true).mutable(true)
|
||||
.build())));
|
||||
for(Player i : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
i.teleport(world.getSpawnLocation());
|
||||
}
|
||||
}, 10);
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
World w = null;
|
||||
for(World i : Bukkit.getWorlds()) {
|
||||
if(!i.getName().startsWith("iristest")) {
|
||||
w = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(World i : Bukkit.getWorlds()) {
|
||||
if(i.getName().startsWith("iristest"))
|
||||
{
|
||||
for(Player j : i.getPlayers())
|
||||
{
|
||||
j.teleport(w.getSpawnLocation());
|
||||
}
|
||||
|
||||
if(i.getGenerator() instanceof Closeable c)
|
||||
{
|
||||
try {
|
||||
c.close();
|
||||
} catch(IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
BukkitWorld.of(i).unloadChunks(false, true);
|
||||
File folder = i.getWorldFolder();
|
||||
Bukkit.unloadWorld(i, false);
|
||||
IO.delete(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IrisBukkit getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
private void messageConsole(String color, String key, Object o) {
|
||||
try {
|
||||
consoleSender.sendMessage(TAG + key + ChatColor.DARK_GRAY + "]: " + color + o.toString());
|
||||
}
|
||||
|
||||
catch(Throwable e) {
|
||||
System.out.println(TAG_STRIPPED + key + "]: " + o.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logError(String k, Object o) {
|
||||
messageConsole(ChatColor.RED.toString(), k, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logInfo(String k, Object o) {
|
||||
messageConsole(ChatColor.WHITE.toString(), k, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logWarning(String k, Object o) {
|
||||
messageConsole(ChatColor.YELLOW.toString(), k, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logDebug(String k, Object o) {
|
||||
messageConsole(ChatColor.GRAY.toString(), k, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlatformName() {
|
||||
return "Bukkit";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<PlatformBlock> getBlocks() {
|
||||
//This is because it's a method extension
|
||||
//noinspection Convert2MethodRef
|
||||
return Arrays.stream(Material.values())
|
||||
.filter(i -> !i.isLegacy())
|
||||
.filter(Material::isBlock)
|
||||
.map(Material::createBlockData).map(i -> BukkitBlock.of(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream<PlatformBiome> getBiomes() {
|
||||
//This is because it's a method extension
|
||||
//noinspection Convert2MethodRef
|
||||
return Arrays.stream(Biome.values()).parallel().filter((i) -> i != Biome.CUSTOM).map(i -> BukkitBiome.of(i));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldLoaded(String name) {
|
||||
return Bukkit.getWorlds().keepWhere(i -> i.getName().equals(name)).isNotEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformWorld getWorld(String name) {
|
||||
World w = Bukkit.getWorld(name);
|
||||
|
||||
if(w == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return BukkitWorld.of(w);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformBlock parseBlock(String raw) {
|
||||
return BukkitBlock.of(Bukkit.createBlockData(raw));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformNamespaceKey key(String namespace, String key) {
|
||||
return BukkitKey.of(namespace, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStudioFolder(String dimension) {
|
||||
File f = new File(getDataFolder(), "packs/" + dimension);
|
||||
f.mkdirs();
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getStudioFolder() {
|
||||
File f = new File(getDataFolder(), "packs/");
|
||||
f.mkdirs();
|
||||
return f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||
return new IrisBukkitChunkGenerator(this, EngineConfiguration.builder()
|
||||
.threads(4)
|
||||
.mutable(true)
|
||||
.timings(true)
|
||||
.build());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void i(String s, Object o) {
|
||||
logInfo(s, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void f(String s, Object o) {
|
||||
logError(s, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void w(String s, Object o) {
|
||||
logWarning(s, o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d(String s, Object o) {
|
||||
logDebug(s, o);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
package com.volmit.iris.platform.bukkit;
|
||||
|
||||
import art.arcane.chrono.Average;
|
||||
import art.arcane.chrono.PrecisionStopwatch;
|
||||
import art.arcane.spatial.hunk.Hunk;
|
||||
import com.volmit.iris.engine.EngineConfiguration;
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.engine.feature.FeatureSizedTarget;
|
||||
import com.volmit.iris.engine.feature.FeatureTarget;
|
||||
import com.volmit.iris.engine.pipeline.PipedHunkStack;
|
||||
import com.volmit.iris.platform.IrisPlatform;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import com.volmit.iris.platform.bukkit.util.StaticBiomeProvider;
|
||||
import com.volmit.iris.platform.bukkit.wrapper.BukkitWorld;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BiomeProvider;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import com.volmit.iris.platform.bukkit.util.ChunkDataHunkView;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class IrisBukkitChunkGenerator extends ChunkGenerator implements Closeable {
|
||||
private final IrisPlatform platform;
|
||||
private final EngineConfiguration configuration;
|
||||
private final AtomicReference<Engine> engine;
|
||||
private final ReentrantLock engineLock;
|
||||
private final AtomicInteger perSecond;
|
||||
private final PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
private final Average a = new Average(128);
|
||||
private final StaticBiomeProvider staticBiomeProvider;
|
||||
|
||||
public IrisBukkitChunkGenerator(IrisPlatform platform, EngineConfiguration configuration) {
|
||||
this.perSecond = new AtomicInteger(0);
|
||||
this.platform = platform;
|
||||
this.configuration = configuration;
|
||||
this.staticBiomeProvider = new StaticBiomeProvider(Biome.PLAINS);
|
||||
this.engine = new AtomicReference<>();
|
||||
this.engineLock = new ReentrantLock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkData generateChunkData(World world, Random random, int x, int z, BiomeGrid biome) {
|
||||
PrecisionStopwatch pp = PrecisionStopwatch.start();
|
||||
initEngine(world);
|
||||
ChunkData data = Bukkit.createChunkData(world);
|
||||
Hunk<PlatformBlock> chunk = new ChunkDataHunkView(data);
|
||||
FeatureSizedTarget targetSize = FeatureSizedTarget.builder()
|
||||
.width(chunk.getWidth())
|
||||
.height(chunk.getHeight())
|
||||
.depth(chunk.getDepth())
|
||||
.offsetX(x << 4)
|
||||
.offsetZ(z << 4)
|
||||
.offsetY(0)
|
||||
.build();
|
||||
FeatureTarget<PlatformBlock> blockTarget = new FeatureTarget<>(chunk, targetSize);
|
||||
PipedHunkStack stack = new PipedHunkStack();
|
||||
stack.register(PlatformBlock.class, blockTarget);
|
||||
engine.get().getPlumbing().generate(engine.get(), targetSize, stack);
|
||||
perSecond.incrementAndGet();
|
||||
a.put(pp.getMilliseconds());
|
||||
|
||||
if(p.getMilliseconds() > 1000)
|
||||
{
|
||||
p.reset();
|
||||
p.begin();
|
||||
System.out.println("PERSECOND: " + perSecond.getAndSet(0) + " AMS: " + ((int)Math.round(a.getAverage())) + "ms");
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private void initEngine(World world) {
|
||||
if(engine.get() == null)
|
||||
{
|
||||
engineLock.lock();
|
||||
|
||||
if(engine.get() == null)
|
||||
{
|
||||
try {
|
||||
engine.set(new Engine(platform, BukkitWorld.of(world), configuration));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
engineLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSpawn(World world, int x, int z) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeProvider getDefaultBiomeProvider(WorldInfo worldInfo) {
|
||||
return staticBiomeProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
engine.get().close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateNoise() {
|
||||
return super.shouldGenerateNoise();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateSurface() {
|
||||
return super.shouldGenerateSurface();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateBedrock() {
|
||||
return super.shouldGenerateBedrock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateCaves() {
|
||||
return super.shouldGenerateCaves();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateDecorations() {
|
||||
return super.shouldGenerateDecorations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateMobs() {
|
||||
return super.shouldGenerateMobs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateStructures() {
|
||||
return super.shouldGenerateStructures();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.volmit.iris.platform.bukkit.util;
|
||||
|
||||
import art.arcane.spatial.hunk.Hunk;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import com.volmit.iris.platform.bukkit.wrapper.BukkitBlock;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
@SuppressWarnings("ClassCanBeRecord")
|
||||
public class ChunkDataHunkView implements Hunk<PlatformBlock> {
|
||||
private final ChunkGenerator.ChunkData chunk;
|
||||
|
||||
public ChunkDataHunkView(ChunkGenerator.ChunkData chunk) {
|
||||
this.chunk = chunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDepth() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return chunk.getMaxHeight() - chunk.getMinHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void set(int x1, int y1, int z1, int x2, int y2, int z2, PlatformBlock t) {
|
||||
if(t == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
chunk.setRegion(x1, y1 + chunk.getMinHeight(), z1, x2, y2 + chunk.getMinHeight(), z2, ((BukkitBlock)t).getDelegate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setRaw(int x, int y, int z, PlatformBlock t) {
|
||||
if(t == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
chunk.setBlock(x, y + chunk.getMinHeight(), z, ((BukkitBlock)t).getDelegate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformBlock getRaw(int x, int y, int z) {
|
||||
return BukkitBlock.of(chunk.getBlockData(x, y + chunk.getMinHeight(), z));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.volmit.iris.platform.bukkit.util;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BiomeProvider;
|
||||
import org.bukkit.generator.WorldInfo;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class StaticBiomeProvider extends BiomeProvider {
|
||||
private static final List<Biome> ALL_BIOMES = Arrays.stream(Biome.values()).without((i) -> i.equals(Biome.CUSTOM)).toList().unmodifiable();
|
||||
private final Biome defaultBiome;
|
||||
|
||||
public StaticBiomeProvider(Biome defaultBiome) {
|
||||
this.defaultBiome = defaultBiome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(WorldInfo worldInfo, int x, int y, int z) {
|
||||
return defaultBiome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Biome> getBiomes(WorldInfo worldInfo) {
|
||||
return ALL_BIOMES;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.volmit.iris.platform.bukkit.wrapper;
|
||||
|
||||
import com.volmit.iris.platform.PlatformBiome;
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import lombok.Data;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
@Data
|
||||
public class BukkitBiome implements PlatformBiome {
|
||||
private final Biome delegate;
|
||||
|
||||
private BukkitBiome(Biome delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformNamespaceKey getKey() {
|
||||
return BukkitKey.of(delegate.getKey());
|
||||
}
|
||||
|
||||
public static BukkitBiome of(Biome biome) {
|
||||
return new BukkitBiome(biome);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.volmit.iris.platform.bukkit.wrapper;
|
||||
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.Ageable;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class BukkitBlock implements PlatformBlock {
|
||||
private final BlockData delegate;
|
||||
private final Map<String, String> properties;
|
||||
|
||||
private BukkitBlock(BlockData delegate, Map<String, String> properties) {
|
||||
this.delegate = delegate;
|
||||
this.properties = properties;
|
||||
}
|
||||
|
||||
private BukkitBlock(BlockData delegate) {
|
||||
this.delegate = delegate;
|
||||
String s = delegate.getAsString(true);
|
||||
|
||||
if(s.contains("[")) {
|
||||
Map<String, String> properties = new HashMap<>();
|
||||
String[] props = new String[] {s.split("\\Q[\\E")[1].split("\\Q]\\E")[0]};
|
||||
String[] p;
|
||||
if(props[0].contains(",")) {
|
||||
for(String i : props[0].split("\\Q,\\E")) {
|
||||
p = i.split("\\Q=\\E");
|
||||
properties.put(p[0], p[1]);
|
||||
}
|
||||
} else {
|
||||
p = props[0].split("\\Q=\\E");
|
||||
properties.put(p[0], p[1]);
|
||||
}
|
||||
|
||||
this.properties = Collections.unmodifiableMap(properties);
|
||||
} else {
|
||||
this.properties = Map.of();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getProperties() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformNamespaceKey getKey() {
|
||||
return BukkitKey.of(delegate.getMaterial().getKey());
|
||||
}
|
||||
|
||||
public static BukkitBlock of(BlockData blockData) {
|
||||
return new BukkitBlock(blockData);
|
||||
}
|
||||
|
||||
public static BukkitBlock of(Material material) {
|
||||
return of(material.createBlockData());
|
||||
}
|
||||
|
||||
public static BukkitBlock of(String raw) {
|
||||
return of(Bukkit.createBlockData(raw));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.volmit.iris.platform.bukkit.wrapper;
|
||||
|
||||
import com.volmit.iris.platform.PlatformChunk;
|
||||
import org.bukkit.Chunk;
|
||||
|
||||
public class BukkitChunk implements PlatformChunk {
|
||||
private final Chunk delegate;
|
||||
|
||||
private BukkitChunk(Chunk delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return delegate.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return delegate.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unload(boolean save, boolean force) {
|
||||
if(force) {
|
||||
delegate.getPluginChunkTickets().forEach(delegate::removePluginChunkTicket);
|
||||
}
|
||||
|
||||
delegate.unload(save);
|
||||
}
|
||||
|
||||
public static BukkitChunk of(Chunk chunk) {
|
||||
return new BukkitChunk(chunk);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.volmit.iris.platform.bukkit.wrapper;
|
||||
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import lombok.Data;
|
||||
import org.bukkit.NamespacedKey;
|
||||
|
||||
@Data
|
||||
public class BukkitKey implements PlatformNamespaceKey {
|
||||
private final NamespacedKey delegate;
|
||||
|
||||
private BukkitKey(NamespacedKey delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return delegate.getNamespace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return delegate.getKey();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return delegate.toString();
|
||||
}
|
||||
|
||||
public static BukkitKey of(String nsk) {
|
||||
if(nsk.contains(":")) {
|
||||
String[] f = nsk.split("\\Q:\\E");
|
||||
return of(f[0], f[1]);
|
||||
}
|
||||
|
||||
return of("minecraft", nsk);
|
||||
}
|
||||
|
||||
public static BukkitKey of(String namespace, String key) {
|
||||
return of(new NamespacedKey(namespace, key));
|
||||
}
|
||||
|
||||
public static BukkitKey of(NamespacedKey key) {
|
||||
return new BukkitKey(key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.volmit.iris.platform.bukkit.wrapper;
|
||||
|
||||
import art.arcane.amulet.geometry.Vec;
|
||||
import com.volmit.iris.platform.PlatformPlayer;
|
||||
import com.volmit.iris.platform.PlatformWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitPlayer implements PlatformPlayer {
|
||||
private final Player delegate;
|
||||
|
||||
private BukkitPlayer(Player delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return delegate.getUniqueId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return delegate.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec getLocation() {
|
||||
return delegate.getLocation().vec();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformWorld getWorld() {
|
||||
return BukkitWorld.of(delegate.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUseIris() {
|
||||
return delegate.isOp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
delegate.sendMessage(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendActionBar(String message) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendTitleMessage(String title, String subtitle, int in, int stay, int out) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
public static BukkitPlayer of(Player player) {
|
||||
return new BukkitPlayer(player);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.volmit.iris.platform.bukkit.wrapper;
|
||||
|
||||
import com.volmit.iris.platform.PlatformBiome;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import com.volmit.iris.platform.PlatformChunk;
|
||||
import com.volmit.iris.platform.PlatformPlayer;
|
||||
import com.volmit.iris.platform.PlatformWorld;
|
||||
import com.volmit.iris.util.WorldHeight;
|
||||
import lombok.Data;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
public class BukkitWorld implements PlatformWorld {
|
||||
private final World delegate;
|
||||
private final WorldHeight worldHeight;
|
||||
|
||||
private BukkitWorld(World delegate) {
|
||||
this.delegate = delegate;
|
||||
this.worldHeight = new WorldHeight(delegate.getMinHeight(), delegate.getMaxHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldHeight getHeight() {
|
||||
return worldHeight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return delegate.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getFolder() {
|
||||
return delegate.getWorldFolder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<PlatformPlayer> getPlayers() {
|
||||
//noinspection Convert2MethodRef
|
||||
return delegate.getPlayers().stream().map(i -> BukkitPlayer.of(i)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<PlatformChunk> getLoadedChunks() {
|
||||
//noinspection Convert2MethodRef
|
||||
return Arrays.stream(delegate.getLoadedChunks()).map(i -> BukkitChunk.of(i)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformChunk getOrLoadChunk(int x, int z) {
|
||||
return BukkitChunk.of(delegate.getChunkAt(x, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformBlock getBlock(int x, int y, int z) {
|
||||
return BukkitBlock.of(delegate.getBlockAt(x, y, z).getBlockData());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlatformBiome getBiome(int x, int y, int z) {
|
||||
return BukkitBiome.of(delegate.getBiome(x, y, z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSeed() {
|
||||
return delegate.getSeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkLoaded(int x, int z) {
|
||||
return delegate.isChunkLoaded(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlock(int x, int y, int z, PlatformBlock block) {
|
||||
delegate.setBlockData(x, y, z, ((BukkitBlock) block).getDelegate());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int y, int z, PlatformBiome biome) {
|
||||
delegate.setBiome(x, y, z, ((BukkitBiome) biome).getDelegate());
|
||||
}
|
||||
|
||||
public static BukkitWorld of(World world) {
|
||||
return new BukkitWorld(world);
|
||||
}
|
||||
}
|
||||
8
bukkit/src/main/resources/plugin.yml
Normal file
8
bukkit/src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
name: Iris
|
||||
main: com.volmit.iris.platform.bukkit.IrisBukkit
|
||||
version: 1.0.0
|
||||
api-version: 1.19
|
||||
libraries:
|
||||
- org.apache-extras.beanshell:bsh:2.0b6
|
||||
- com.google.code.gson:gson:2.8.9
|
||||
- com.github.ben-manes.caffeine:caffeine:3.1.1
|
||||
34
engine/build.gradle
Normal file
34
engine/build.gradle
Normal file
@@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
id "io.freefair.lombok" version "6.3.0"
|
||||
}
|
||||
|
||||
group rootProject.group
|
||||
version rootProject.version
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes('Contains-Sources': 'java,class')
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
testImplementation.extendsFrom annotationProcessor
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
}
|
||||
}
|
||||
|
||||
if (JavaVersion.current() != JavaVersion.VERSION_1_8 &&
|
||||
sourceSets.main.allJava.files.any { it.name == "module-info.java" }) {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs += ['-Xplugin:Manifold', '--module-path', it.classpath.asPath]
|
||||
}
|
||||
} else {
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs += ['-Xplugin:Manifold']
|
||||
}
|
||||
}
|
||||
91
engine/src/main/java/com/volmit/iris/engine/Engine.java
Normal file
91
engine/src/main/java/com/volmit/iris/engine/Engine.java
Normal file
@@ -0,0 +1,91 @@
|
||||
package com.volmit.iris.engine;
|
||||
|
||||
import com.volmit.iris.engine.feature.features.FeatureError;
|
||||
import com.volmit.iris.engine.feature.features.FeatureTerrain;
|
||||
import com.volmit.iris.engine.pipeline.EnginePipeline;
|
||||
import com.volmit.iris.engine.pipeline.EnginePlumbing;
|
||||
import com.volmit.iris.engine.pipeline.PipelinePhase;
|
||||
import com.volmit.iris.engine.pipeline.PipelineTask;
|
||||
import com.volmit.iris.platform.IrisPlatform;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import com.volmit.iris.platform.PlatformRegistry;
|
||||
import com.volmit.iris.platform.PlatformWorld;
|
||||
import lombok.Data;
|
||||
import manifold.util.concurrent.ConcurrentWeakHashMap;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
@Data
|
||||
public class Engine implements Closeable {
|
||||
private static final Map<Thread, WeakReference<Engine>> engineContext = new ConcurrentWeakHashMap<>();
|
||||
private final IrisPlatform platform;
|
||||
private final EngineRegistry registry;
|
||||
private final EngineConfiguration configuration;
|
||||
private final PlatformWorld world;
|
||||
private final EngineBlockCache blockCache;
|
||||
private final EngineExecutor executor;
|
||||
private final EnginePlumbing plumbing;
|
||||
private final EngineSeedManager seedManager;
|
||||
private final EngineData data;
|
||||
|
||||
public Engine(IrisPlatform platform, PlatformWorld world, EngineConfiguration configuration) throws IOException {
|
||||
this.configuration = configuration.validate();
|
||||
this.platform = platform;
|
||||
this.world = world;
|
||||
i("Initializing Iris Engine for " + platform.getPlatformName() + " in " + world.getName()
|
||||
+ " with " + configuration.getThreads() + " priority " + configuration.getThreadPriority()
|
||||
+ " threads in " + (configuration.isMutable() ? "edit mode" : "production mode"));
|
||||
this.blockCache = new EngineBlockCache(this);
|
||||
this.registry = EngineRegistry.builder()
|
||||
.blockRegistry(new PlatformRegistry<>("Block", platform.getBlocks()))
|
||||
.biomeRegistry(new PlatformRegistry<>("Biome", platform.getBiomes()))
|
||||
.build();
|
||||
this.data = new EngineData(this).loadData(
|
||||
getConfiguration().isMutable()
|
||||
? getPlatform().getStudioFolder()
|
||||
: getWorld().getIrisDataFolder(), getConfiguration().getDimension());
|
||||
this.seedManager = getSeedManager();
|
||||
this.executor = new EngineExecutor(this);
|
||||
this.plumbing = EnginePlumbing.builder().engine(this)
|
||||
.errorPipeline(EnginePipeline.builder()
|
||||
.phase(PipelinePhase.builder()
|
||||
.task(new PipelineTask<>(new FeatureError(this), PlatformBlock.class))
|
||||
.build())
|
||||
.build())
|
||||
.pipeline(EnginePipeline.builder()
|
||||
.phase(PipelinePhase.builder()
|
||||
.task(new PipelineTask<>(new FeatureTerrain(this), PlatformBlock.class))
|
||||
.build())
|
||||
.build())
|
||||
.build();
|
||||
}
|
||||
|
||||
public PlatformBlock block(String block) {
|
||||
return blockCache.get(block);
|
||||
}
|
||||
|
||||
public PlatformNamespaceKey key(String nsk) {
|
||||
return getPlatform().key(nsk);
|
||||
}
|
||||
|
||||
public static Optional<Engine> context() {
|
||||
WeakReference<Engine> reference = engineContext.get(Thread.currentThread());
|
||||
|
||||
if(reference != null)
|
||||
{
|
||||
return Optional.ofNullable(reference.get());
|
||||
}
|
||||
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
getExecutor().close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.volmit.iris.engine;
|
||||
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class EngineBlockCache
|
||||
{
|
||||
private final Engine engine;
|
||||
private final Map<String, PlatformBlock> cache;
|
||||
|
||||
public EngineBlockCache(Engine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.cache = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
public PlatformBlock get(String t)
|
||||
{
|
||||
return cache.computeIfAbsent(t, (key) -> engine.getPlatform().parseBlock(key));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.volmit.iris.engine;
|
||||
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import com.volmit.iris.platform.PlatformWorld;
|
||||
import com.volmit.iris.util.NSK;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class EngineConfiguration {
|
||||
@Builder.Default
|
||||
private int chunkSize = 16;
|
||||
|
||||
@Builder.Default
|
||||
private boolean mutable = false;
|
||||
|
||||
@Builder.Default
|
||||
private boolean timings = false;
|
||||
|
||||
@Builder.Default
|
||||
private int threads = Runtime.getRuntime().availableProcessors();
|
||||
|
||||
@Builder.Default
|
||||
private int threadPriority = 3;
|
||||
|
||||
@Builder.Default
|
||||
private PlatformNamespaceKey dimension = new NSK("overworld", "main");
|
||||
|
||||
public EngineConfiguration validate() throws IOException {
|
||||
validateChunkSize();
|
||||
return this;
|
||||
}
|
||||
|
||||
private void validateChunkSize() throws IOException {
|
||||
if(Arrays.binarySearch(allowedChunkSizes, chunkSize) < 0) {
|
||||
throw new IOException("Invalid Chunk Size: " + chunkSize + " Allowed Chunk Sizes are: " + Arrays.toString(allowedChunkSizes));
|
||||
}
|
||||
}
|
||||
|
||||
private static final int[] allowedChunkSizes;
|
||||
|
||||
static {
|
||||
allowedChunkSizes = new int[16];
|
||||
|
||||
for(int i = 0; i < allowedChunkSizes.length; i++) {
|
||||
allowedChunkSizes[i] = (int) Math.pow(2, i+1);
|
||||
}
|
||||
|
||||
Arrays.sort(allowedChunkSizes); // for binary sorting
|
||||
}
|
||||
}
|
||||
276
engine/src/main/java/com/volmit/iris/engine/EngineData.java
Normal file
276
engine/src/main/java/com/volmit/iris/engine/EngineData.java
Normal file
@@ -0,0 +1,276 @@
|
||||
package com.volmit.iris.engine;
|
||||
|
||||
import art.arcane.amulet.concurrent.J;
|
||||
import art.arcane.amulet.io.IO;
|
||||
import art.arcane.amulet.io.JarLoader;
|
||||
import art.arcane.cram.PakFile;
|
||||
import art.arcane.cram.PakKey;
|
||||
import art.arcane.cram.PakResource;
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.iris.engine.dimension.IrisDimension;
|
||||
import com.volmit.iris.engine.dimension.IrisGenerator;
|
||||
import com.volmit.iris.engine.dimension.IrisRange;
|
||||
import com.volmit.iris.engine.resolver.*;
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import com.volmit.iris.util.NSK;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
@Data
|
||||
public class EngineData implements TypeAdapterFactory {
|
||||
private final Engine engine;
|
||||
private final Gson gson;
|
||||
private List<Resolvable> resolvableTypes;
|
||||
private final Map<Class<?>, Resolver<?>> resolvers;
|
||||
|
||||
public EngineData(Engine engine) throws IOException {
|
||||
this.engine = engine;
|
||||
this.resolvers = new HashMap<>();
|
||||
this.resolvableTypes = J.attempt(() -> new JarLoader(getClass()).all().parallel()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(i -> !i.isInterface() && !i.isEnum())
|
||||
.filter(i -> i.isAssignableFrom(Resolvable.class) || Resolvable.class.isAssignableFrom(i))
|
||||
.filter(i -> !i.equals(EngineResolvable.class))
|
||||
.map(i -> J.attempt(() -> (Resolvable) i.getDeclaredConstructor().newInstance(), null)).toList(), List.of());
|
||||
GsonBuilder gsonBuilder = new GsonBuilder().registerTypeAdapterFactory(this);
|
||||
resolvableTypes.forEach(i -> i.apply(gsonBuilder));
|
||||
this.gson = gsonBuilder.setPrettyPrinting().create();
|
||||
i("Registered " + resolvableTypes.size() + " Mutators with " + resolvableTypes.stream().filter(i -> i instanceof TypeAdapterFactory).count() + " Type Adapter Factories");
|
||||
}
|
||||
|
||||
public void generateSchemas(File folder) throws IOException {
|
||||
folder.mkdirs();
|
||||
|
||||
for(Resolvable i : resolvableTypes) {
|
||||
IO.writeAll(new File(folder, i.entity().getId() + ".json"), i.generateSchema(this).toString());
|
||||
}
|
||||
}
|
||||
|
||||
public <T extends Resolvable> T resolve(Class<T> clazz, PlatformNamespaceKey key)
|
||||
{
|
||||
Resolver<?> r = resolvers.get(clazz);
|
||||
|
||||
if(r == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (T) r.resolve(key);
|
||||
}
|
||||
|
||||
public void registerResolver(Class<?> type, Resolver<?> resolver, String namespace)
|
||||
{
|
||||
if(resolvers.containsKey(type)) {
|
||||
Resolver r = resolvers.get(type);
|
||||
resolvers.put(type, r.and(namespace, r));
|
||||
}
|
||||
|
||||
else {
|
||||
resolvers.put(type, resolver);
|
||||
}
|
||||
}
|
||||
|
||||
public EngineData loadData(File folder, PlatformNamespaceKey dimension) throws IOException {
|
||||
i("Loading Data in " + folder.getPath());
|
||||
for(File i : folder.listFiles()) {
|
||||
if(i.isDirectory() && i.getName().equals(dimension.getNamespace())) {
|
||||
loadDataNamespaced(i, i.getName());
|
||||
|
||||
if(getEngine().getConfiguration().isMutable()) {
|
||||
generateSchemas(new File(i, ".iris/schema"));
|
||||
i("Generated " + new File(i, ".iris/schema").listFiles().length + " Schemas");
|
||||
generateCodeWorkspace(new File(i, dimension.getNamespace() + ".code-workspace"));
|
||||
i("Generated Code Workspace");
|
||||
}
|
||||
}
|
||||
|
||||
else if(i.getName().equals(dimension.getNamespace() + ".dat")) {
|
||||
loadPakFile(folder, i.getName().split("\\Q.\\E")[0]);
|
||||
}
|
||||
}
|
||||
|
||||
IrisDimension dim = resolve(IrisDimension.class, dimension);
|
||||
|
||||
if(dim == null) {
|
||||
f("Failed to load dimension " + dimension);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private void generateCodeWorkspace(File file) throws IOException {
|
||||
file.getParentFile().mkdirs();
|
||||
JsonObject ws = new JsonObject();
|
||||
JsonArray folders = new JsonArray();
|
||||
JsonObject folder = new JsonObject();
|
||||
folder.add("path", new JsonPrimitive("."));
|
||||
folders.add(folder);
|
||||
ws.add("folders", folders);
|
||||
JsonObject settings = new JsonObject();
|
||||
settings.add("workbench.colorTheme", new JsonPrimitive("Monokai"));
|
||||
settings.add("workbench.preferredDarkColorTheme", new JsonPrimitive("Solarized Dark"));
|
||||
settings.add("workbench.tips.enabled", new JsonPrimitive(false));
|
||||
settings.add("workbench.tree.indent", new JsonPrimitive(24));
|
||||
settings.add("files.autoSave", new JsonPrimitive("onFocusChange"));
|
||||
JsonObject jc = new JsonObject();
|
||||
jc.add("editor.autoIndent", new JsonPrimitive("brackets"));
|
||||
jc.add("editor.acceptSuggestionOnEnter", new JsonPrimitive("smart"));
|
||||
jc.add("editor.cursorSmoothCaretAnimation", new JsonPrimitive(true));
|
||||
jc.add("editor.dragAndDrop", new JsonPrimitive(false));
|
||||
jc.add("files.trimTrailingWhitespace", new JsonPrimitive(true));
|
||||
jc.add("diffEditor.ignoreTrimWhitespace", new JsonPrimitive(true));
|
||||
jc.add("files.trimFinalNewlines", new JsonPrimitive(true));
|
||||
jc.add("editor.suggest.showKeywords", new JsonPrimitive(false));
|
||||
jc.add("editor.suggest.showSnippets", new JsonPrimitive(false));
|
||||
jc.add("editor.suggest.showWords", new JsonPrimitive(false));
|
||||
JsonObject st = new JsonObject();
|
||||
st.add("strings", new JsonPrimitive(true));
|
||||
jc.add("editor.quickSuggestions", st);
|
||||
jc.add("editor.suggest.insertMode", new JsonPrimitive("replace"));
|
||||
settings.add("[json]", jc);
|
||||
settings.add("json.maxItemsComputed", new JsonPrimitive(30000));
|
||||
JsonArray schemas = new JsonArray();
|
||||
|
||||
for(Resolvable i : resolvableTypes) {
|
||||
String id = i.entity().getId();
|
||||
JsonObject o = new JsonObject();
|
||||
JsonArray fileMatch = new JsonArray();
|
||||
fileMatch.add("/" + id + "/*.json");
|
||||
o.add("fileMatch", fileMatch);
|
||||
o.add("url", new JsonPrimitive(".iris/schema/" + id + ".json"));
|
||||
schemas.add(o);
|
||||
}
|
||||
|
||||
settings.add("json.schemas", schemas);
|
||||
ws.add("settings", settings);
|
||||
IO.writeAll(file, ws.toString());
|
||||
}
|
||||
|
||||
public void loadDataNamespaced(File folder, String namespace) throws IOException {
|
||||
i("Loading Namespace " + namespace + " in " + folder.getPath());
|
||||
for(Resolvable i : resolvableTypes)
|
||||
{
|
||||
new File(folder, i.entity().getId()).mkdirs();
|
||||
IO.writeAll(new File(new File(folder, i.entity().getId()), "example.json"), gson.toJson(i));
|
||||
}
|
||||
|
||||
for(File i : folder.listFiles())
|
||||
{
|
||||
if(i.isDirectory()) {
|
||||
loadDataFolder(i, namespace);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void loadDataFolder(File folder, String namespace) {
|
||||
for(Resolvable i : resolvableTypes)
|
||||
{
|
||||
if(!folder.getName().equals(i.entity().getId())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
registerResolver(i.getClass(), Resolver.hotDirectoryJson(namespace, i.getClass(), folder, gson), namespace);
|
||||
}
|
||||
}
|
||||
|
||||
public void loadPakFile(File folder, String name) throws IOException {
|
||||
PakFile pakFile = new PakFile(folder, name);
|
||||
Map<PakKey, PakResource> resources = pakFile.getAllResources();
|
||||
|
||||
for(Resolvable i : resolvableTypes)
|
||||
{
|
||||
Class<? extends Resolvable> resolvableClass = i.getClass();
|
||||
CompositeResolver<?> composite = Resolver.frozen(resources, (p) -> p.getClass().equals(resolvableClass));
|
||||
|
||||
for(String j : composite.getResolvers().keySet())
|
||||
{
|
||||
Resolver<? extends Resolvable> resolver = composite.getResolvers().get(i);
|
||||
this.registerResolver(i.getClass(), resolver, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void printResolvers() {
|
||||
resolvers.forEach((k, i) -> i.print(k.simpleName(), this));
|
||||
}
|
||||
|
||||
private <T> void writeSafeJson(TypeAdapter<T> delegate, JsonWriter out, T value) {
|
||||
try {
|
||||
delegate.write(out, value);
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
delegate.write(out, null);
|
||||
} catch(IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
final TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
|
||||
|
||||
for(Resolvable i : resolvableTypes) {
|
||||
if(type.getRawType().equals(i.getClass())) {
|
||||
return new TypeAdapter<>() {
|
||||
public void write(JsonWriter out, T value) {writeSafeJson(delegate, out, value);}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T read(JsonReader in) throws IOException {
|
||||
JsonToken token = in.peek();
|
||||
|
||||
if(token == JsonToken.STRING) {
|
||||
Resolver<?> resolver = getResolvers().get(i.getClass());
|
||||
String key = in.nextString();
|
||||
|
||||
if(resolver == null) {
|
||||
w("Unable to find a resolver for " + i.getClass() + " received " + key);
|
||||
return null;
|
||||
}
|
||||
|
||||
T t = (T) resolver.resolve(new NSK(key));
|
||||
|
||||
if(t == null) {
|
||||
w("Unable to resolve " + i.getClass() + " " + key);
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
return delegate.read(in);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Resolvable getInstance(Class<?> type) {
|
||||
for(Resolvable i : resolvableTypes) {
|
||||
if(i.getClass().equals(type)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<PlatformNamespaceKey> getAllKeys(Class<?> type) {
|
||||
List<PlatformNamespaceKey> keys = new ArrayList<>();
|
||||
Resolver<?> resolver = resolvers.get(type);
|
||||
|
||||
if(resolver != null) {
|
||||
resolver.addAllKeys(keys);
|
||||
}
|
||||
|
||||
return keys;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.volmit.iris.engine;
|
||||
|
||||
import art.arcane.amulet.concurrent.J;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.ForkJoinWorkerThread;
|
||||
|
||||
@Data
|
||||
public class EngineExecutor implements ForkJoinPool.ForkJoinWorkerThreadFactory, Thread.UncaughtExceptionHandler, Closeable {
|
||||
private final Engine engine;
|
||||
private final ForkJoinPool forks;
|
||||
|
||||
public EngineExecutor(Engine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
forks = new ForkJoinPool(engine.getConfiguration().getThreads(), this, this, true);
|
||||
i("Started Pool with " + engine.getConfiguration().getThreads() + " priority " + engine.getConfiguration().getThreadPriority() + " threads.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uncaughtException(Thread t, Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
|
||||
final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
|
||||
worker.setName("Iris " + engine.getWorld().getName() + " Executor " + worker.getPoolIndex());
|
||||
return worker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
i("Shutting down generator pool");
|
||||
forks.shutdownNow().forEach((i) -> {
|
||||
try
|
||||
{
|
||||
i.run();
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
i("Generator pool shutdown");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.volmit.iris.engine;
|
||||
|
||||
import com.volmit.iris.platform.PlatformBiome;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import com.volmit.iris.platform.PlatformRegistry;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
public class EngineRegistry {
|
||||
private final PlatformRegistry<PlatformBlock> blockRegistry;
|
||||
private final PlatformRegistry<PlatformBiome> biomeRegistry;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.volmit.iris.engine;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EngineSeedManager {
|
||||
private final Engine engine;
|
||||
private final long worldSeed;
|
||||
|
||||
public EngineSeedManager(Engine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.worldSeed = engine.getWorld().getSeed();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "author")
|
||||
public class IrisAuthor extends EngineResolvable
|
||||
{
|
||||
private String name;
|
||||
private Map<String, String> social;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import com.volmit.iris.platform.PlatformBiome;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "biome")
|
||||
public class IrisBiome extends EngineResolvable {
|
||||
private String name;
|
||||
|
||||
@Builder.Default
|
||||
private IrisSurface surface = new IrisSurface();
|
||||
|
||||
@Builder.Default
|
||||
private IrisRange height = IrisRange.flat(1);
|
||||
|
||||
public PlatformBiome toPlatformBiome()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "chance", jsonTypes = {JsonToken.STRING, JsonToken.BEGIN_OBJECT})
|
||||
public class IrisChance extends EngineResolvable implements TypeAdapterFactory {
|
||||
@Builder.Default
|
||||
@TokenConstructor(JsonToken.NUMBER)
|
||||
private double threshold = 0.5;
|
||||
|
||||
@TokenConstructor(JsonToken.STRING)
|
||||
@Builder.Default
|
||||
private IrisGenerator generator = IrisGenerator.WHITE;
|
||||
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
final TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
|
||||
|
||||
if(!type.getRawType().equals(getClass())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new TypeAdapter<>() {
|
||||
public void write(JsonWriter out, T value) {writeSafeJson(delegate, out, value);}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T read(JsonReader in) throws IOException {
|
||||
JsonToken token = in.peek();
|
||||
|
||||
if(token == JsonToken.STRING) {
|
||||
return (T) IrisChance.half(gson.fromJson(in.nextString(), IrisGenerator.class));
|
||||
}
|
||||
|
||||
return delegate.read(in);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static IrisChance half(IrisGenerator generator) {
|
||||
return IrisChance.builder()
|
||||
.threshold(0.5)
|
||||
.generator(generator)
|
||||
.build();
|
||||
}
|
||||
|
||||
public static IrisChance white(double chance) {
|
||||
return IrisChance.builder()
|
||||
.threshold(chance)
|
||||
.generator(IrisGenerator.WHITE)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "decorator")
|
||||
public class IrisDecorator extends EngineResolvable {
|
||||
@Builder.Default
|
||||
private IrisPalette palette = IrisPalette.flat("minecraft:grass");
|
||||
|
||||
@Builder.Default
|
||||
private IrisChance chance = IrisChance.white(0.25);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Singular;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "dimension")
|
||||
public class IrisDimension extends EngineResolvable {
|
||||
@Builder.Default
|
||||
private IrisDimensionMeta meta = new IrisDimensionMeta();
|
||||
|
||||
@Singular
|
||||
@Type(IrisBiome.class)
|
||||
private List<IrisBiome> biomes = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Singular;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "dimension-meta")
|
||||
public class IrisDimensionMeta extends EngineResolvable
|
||||
{
|
||||
private String name;
|
||||
private String description;
|
||||
private String version;
|
||||
@Singular
|
||||
@Resolvable.Type(IrisAuthor.class)
|
||||
private List<IrisAuthor> authors = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import art.arcane.source.NoisePlane;
|
||||
import art.arcane.source.script.NoisePlaneConstructor;
|
||||
import art.arcane.source.util.NoisePreset;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.script.ScriptException;
|
||||
import java.io.IOException;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "generator", jsonTypes = {JsonToken.STRING, JsonToken.BEGIN_OBJECT})
|
||||
public class IrisGenerator extends EngineResolvable implements TypeAdapterFactory {
|
||||
public static final IrisGenerator NATURAL = IrisGenerator.builder().java("art.arcane.source.api.util.NoisePreset.NATURAL.create(seed)").build();
|
||||
public static final IrisGenerator WHITE = IrisGenerator.builder().java("Noise.white(seed)").build();
|
||||
public static final IrisGenerator FLAT = IrisGenerator.builder().java("Noise.flat(seed)").build();
|
||||
|
||||
@Builder.Default
|
||||
private String java = "art.arcane.source.api.util.NoisePreset.NATURAL.create(seed)";
|
||||
|
||||
@Builder.Default
|
||||
private IrisSeed seed = new IrisSeed();
|
||||
|
||||
public NoisePlane getNoisePlane(long seed)
|
||||
{
|
||||
try {
|
||||
return NoisePlaneConstructor.execute(seed, java);
|
||||
} catch(ScriptException e) {
|
||||
e.printStackTrace();
|
||||
return NoisePreset.NATURAL.create(seed);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
final TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
|
||||
|
||||
if(!type.getRawType().equals(getClass())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new TypeAdapter<>() {
|
||||
public void write(JsonWriter out, T value) {writeSafeJson(delegate, out, value);}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T read(JsonReader in) throws IOException {
|
||||
JsonToken token = in.peek();
|
||||
|
||||
if(token == JsonToken.STRING) {
|
||||
return (T) IrisGenerator.builder().java(in.nextString()).build();
|
||||
}
|
||||
|
||||
return delegate.read(in);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Singular;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "palette", jsonTypes = {JsonToken.STRING, JsonToken.BEGIN_OBJECT})
|
||||
public class IrisPalette extends EngineResolvable implements TypeAdapterFactory {
|
||||
@Singular
|
||||
@PlatformType(PlatformBlock.class)
|
||||
@Type(String.class)
|
||||
@TokenConstructor(JsonToken.STRING)
|
||||
private List<String> blocks = new ArrayList<>();
|
||||
|
||||
@Builder.Default
|
||||
private IrisGenerator generator = IrisGenerator.WHITE;
|
||||
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
final TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
|
||||
|
||||
if(!type.getRawType().equals(getClass())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new TypeAdapter<>() {
|
||||
public void write(JsonWriter out, T value) {
|
||||
writeSafeJson(delegate, out, value);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T read(JsonReader in) throws IOException {
|
||||
JsonToken token = in.peek();
|
||||
|
||||
if(token == JsonToken.STRING) {
|
||||
return (T) IrisPalette.flat(in.nextString());
|
||||
}
|
||||
|
||||
return delegate.read(in);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static IrisPalette flat(String block){
|
||||
return IrisPalette.builder()
|
||||
.block(block)
|
||||
.generator(IrisGenerator.FLAT)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "range", jsonTypes = {JsonToken.NUMBER, JsonToken.BEGIN_OBJECT})
|
||||
public class IrisRange extends EngineResolvable implements TypeAdapterFactory {
|
||||
@Builder.Default
|
||||
@TokenConstructor(JsonToken.NUMBER)
|
||||
private double max = 1;
|
||||
|
||||
@Builder.Default
|
||||
private double min = 1;
|
||||
|
||||
@Builder.Default
|
||||
private IrisGenerator generator = IrisGenerator.NATURAL;
|
||||
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
final TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
|
||||
|
||||
if(!type.getRawType().equals(getClass())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new TypeAdapter<>() {
|
||||
public void write(JsonWriter out, T value) {writeSafeJson(delegate, out, value);}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T read(JsonReader in) throws IOException {
|
||||
JsonToken token = in.peek();
|
||||
|
||||
if(token == JsonToken.NUMBER) {
|
||||
double d = in.nextDouble();
|
||||
return (T) IrisRange.builder().min(d).max(d).generator(IrisGenerator.FLAT).build();
|
||||
}
|
||||
|
||||
return delegate.read(in);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static IrisRange flat(double v) {
|
||||
return IrisRange.builder()
|
||||
.max(v)
|
||||
.min(v)
|
||||
.generator(IrisGenerator.FLAT)
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "seed", jsonTypes = {JsonToken.NUMBER, JsonToken.STRING, JsonToken.BEGIN_OBJECT})
|
||||
public class IrisSeed extends EngineResolvable implements TypeAdapterFactory {
|
||||
@Builder.Default
|
||||
private IrisSeedSetMode mode = IrisSeedSetMode.LOCAL_OFFSET;
|
||||
|
||||
@Builder.Default
|
||||
@TokenConstructor(JsonToken.NUMBER)
|
||||
private long offset = 0;
|
||||
|
||||
@TokenConstructor(JsonToken.STRING)
|
||||
private String hashOffset;
|
||||
|
||||
public long getOffset() {
|
||||
if(hashOffset != null && hashOffset.isNotEmpty()) {
|
||||
return hashOffset.hashCode() + offset;
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
public double getSeed(Engine engine, long localSeed) {
|
||||
return switch(mode)
|
||||
{
|
||||
case WORLD -> engine.getSeedManager().getWorldSeed();
|
||||
case LOCAL -> localSeed;
|
||||
case LOCAL_OFFSET -> localSeed + getOffset();
|
||||
case RAW -> getOffset();
|
||||
case WORLD_OFFSET -> engine.getSeedManager().getWorldSeed() + getOffset();
|
||||
case RANDOM -> (Math.random() * Long.MAX_VALUE) + (Math.random() * Long.MAX_VALUE);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
||||
final TypeAdapter<T> delegate = gson.getDelegateAdapter(this, type);
|
||||
|
||||
if(!type.getRawType().equals(getClass())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new TypeAdapter<>() {
|
||||
public void write(JsonWriter out, T value) {writeSafeJson(delegate, out, value);}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T read(JsonReader in) throws IOException {
|
||||
JsonToken token = in.peek();
|
||||
|
||||
if(token == JsonToken.STRING) {
|
||||
return (T) IrisSeed.builder().hashOffset(in.nextString()).build();
|
||||
}
|
||||
|
||||
if(token == JsonToken.NUMBER) {
|
||||
return (T) IrisSeed.builder().offset(Double.doubleToLongBits(in.nextDouble())).build();
|
||||
}
|
||||
|
||||
return delegate.read(in);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
public enum IrisSeedSetMode
|
||||
{
|
||||
WORLD,
|
||||
RAW,
|
||||
WORLD_OFFSET,
|
||||
LOCAL,
|
||||
LOCAL_OFFSET,
|
||||
RANDOM
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Singular;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "surface")
|
||||
public class IrisSurface extends EngineResolvable {
|
||||
@Singular
|
||||
@Type(IrisSurfaceLayer.class)
|
||||
private List<IrisSurfaceLayer> layers = new ArrayList<>();
|
||||
|
||||
@Singular
|
||||
@Type(IrisDecorator.class)
|
||||
private List<IrisDecorator> decorators = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.volmit.iris.engine.dimension;
|
||||
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.engine.resolver.Resolvable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
@Accessors(fluent = true, chain = true)
|
||||
@Resolvable.Entity(id = "surface-layer")
|
||||
public class IrisSurfaceLayer extends EngineResolvable {
|
||||
@Builder.Default
|
||||
private IrisPalette palette = IrisPalette.flat("minecraft:stone");
|
||||
|
||||
@Builder.Default
|
||||
private IrisRange thickness = IrisRange.flat(1);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.volmit.iris.engine.feature;
|
||||
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.platform.PlatformNamespaced;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public abstract class Feature<T extends PlatformNamespaced, S extends FeatureState> {
|
||||
private final String name;
|
||||
private final Engine engine;
|
||||
private boolean optimize;
|
||||
private boolean heightAgnostic;
|
||||
|
||||
public Feature(String name, Engine engine)
|
||||
{
|
||||
this.engine = engine;
|
||||
this.name = name;
|
||||
this.optimize = true;
|
||||
this.heightAgnostic = true;
|
||||
}
|
||||
|
||||
public FeatureTask<T, S> task(FeatureSizedTarget target, FeatureTarget<T> origin, FeatureStorage storage, int verticalExecutionSize, int horizontalExecutionSize, FeatureTaskTiming timings)
|
||||
{
|
||||
return new FeatureTask<>(engine, this, storage, target, origin, verticalExecutionSize, horizontalExecutionSize, heightAgnostic, timings);
|
||||
}
|
||||
|
||||
public FeatureTask<T, S> task(FeatureSizedTarget target, FeatureTarget<T> origin, FeatureStorage storage, int horizontalExecutionSize, FeatureTaskTiming timings)
|
||||
{
|
||||
return new FeatureTask<>(engine, this, storage, target, origin, Integer.MAX_VALUE, horizontalExecutionSize, heightAgnostic, timings);
|
||||
}
|
||||
|
||||
public abstract S prepare(Engine engine, FeatureSizedTarget target, FeatureStorage storage);
|
||||
|
||||
public abstract void generate(Engine engine, S state, FeatureTarget<T> target, FeatureStorage storage);
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
package com.volmit.iris.engine.feature;
|
||||
|
||||
import art.arcane.amulet.range.IntegerRange;
|
||||
import art.arcane.spatial.hunk.storage.ArrayHunk;
|
||||
import art.arcane.spatial.hunk.view.HunkView;
|
||||
import art.arcane.spatial.util.Consume;
|
||||
import com.volmit.iris.platform.PlatformNamespaced;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class FeatureSizedTarget {
|
||||
@Builder.Default
|
||||
private final int width = 16;
|
||||
@Builder.Default
|
||||
private final int height = 0;
|
||||
@Builder.Default
|
||||
private final int depth = 16;
|
||||
@Builder.Default
|
||||
private final int offsetX = 0;
|
||||
@Builder.Default
|
||||
private final int offsetY = 0;
|
||||
@Builder.Default
|
||||
private final int offsetZ = 0;
|
||||
|
||||
public <T extends PlatformNamespaced> FeatureTarget<T> hunked()
|
||||
{
|
||||
return new FeatureTarget<>(new ArrayHunk<>(width, height, depth), this);
|
||||
}
|
||||
|
||||
public <T extends PlatformNamespaced> FeatureTarget<T> hunked(FeatureTarget<T> origin)
|
||||
{
|
||||
return new FeatureTarget<>(new HunkView<>(origin.getHunk(), width, height, depth, offsetX - origin.getOffsetX(), offsetY - origin.getOffsetY(), offsetZ - origin.getOffsetZ()), this);
|
||||
}
|
||||
|
||||
Stream<FeatureSizedTarget> splitX() {
|
||||
if(width <= 1) {
|
||||
return Stream.of(this);
|
||||
}
|
||||
int wo2 = width/2;
|
||||
return Stream.of(FeatureSizedTarget.builder()
|
||||
.width(wo2).height(height).depth(depth)
|
||||
.offsetX(offsetX).offsetY(offsetY).offsetZ(offsetZ).build(),
|
||||
FeatureSizedTarget.builder()
|
||||
.width(width - wo2).height(height).depth(depth)
|
||||
.offsetX(offsetX + wo2).offsetY(offsetY).offsetZ(offsetZ).build());
|
||||
}
|
||||
|
||||
Stream<FeatureSizedTarget> splitY() {
|
||||
if(height <= 1) {
|
||||
return Stream.of(this);
|
||||
}
|
||||
|
||||
int ho2 = height / 2;
|
||||
return Stream.of(FeatureSizedTarget.builder()
|
||||
.width(width).height(ho2).depth(depth)
|
||||
.offsetX(offsetX).offsetY(offsetY).offsetZ(offsetZ).build(),
|
||||
FeatureSizedTarget.builder()
|
||||
.width(width).height(height - ho2).depth(depth)
|
||||
.offsetX(offsetX).offsetY(offsetY + ho2).offsetZ(offsetZ).build());
|
||||
}
|
||||
|
||||
Stream<FeatureSizedTarget> splitZ() {
|
||||
if(depth <= 1) {
|
||||
return Stream.of(this);
|
||||
}
|
||||
|
||||
int do2 = depth / 2;
|
||||
return Stream.of(FeatureSizedTarget.builder()
|
||||
.width(width).height(height).depth(do2)
|
||||
.offsetX(offsetX).offsetY(offsetY).offsetZ(offsetZ).build(),
|
||||
FeatureSizedTarget.builder()
|
||||
.width(width).height(height).depth(depth - do2)
|
||||
.offsetX(offsetX).offsetY(offsetY).offsetZ(offsetZ + do2).build());
|
||||
}
|
||||
|
||||
public int getAbsoluteMaxX()
|
||||
{
|
||||
return getOffsetX() + getWidth() - 1;
|
||||
}
|
||||
|
||||
public int getAbsoluteMaxY()
|
||||
{
|
||||
return getOffsetY() + getHeight() - 1;
|
||||
}
|
||||
|
||||
public int getAbsoluteMaxZ()
|
||||
{
|
||||
return getOffsetZ() + getDepth() - 1;
|
||||
}
|
||||
|
||||
public IntegerRange yCap(int max) {
|
||||
return new IntegerRange(y().getLeftEndpoint(), Math.min(y().getRightEndpoint(), max));
|
||||
}
|
||||
|
||||
public void forYCap(Consume.One<Integer> consumer, int max) {
|
||||
for(int y : yCap(max)) {
|
||||
consumer.accept(y);
|
||||
}
|
||||
}
|
||||
|
||||
public void forXZ(Consume.Two<Integer, Integer> consumer) {
|
||||
for(int x : x()) {
|
||||
for(int z : z()) {
|
||||
consumer.accept(x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public IntegerRange x()
|
||||
{
|
||||
return new IntegerRange(getOffsetX(), getAbsoluteMaxX());
|
||||
}
|
||||
|
||||
public IntegerRange y()
|
||||
{
|
||||
return new IntegerRange(getOffsetY(), getAbsoluteMaxY());
|
||||
}
|
||||
|
||||
public IntegerRange z()
|
||||
{
|
||||
return new IntegerRange(getOffsetZ(), getAbsoluteMaxZ());
|
||||
}
|
||||
|
||||
public IntegerRange localX()
|
||||
{
|
||||
return new IntegerRange(0, getWidth() - 1);
|
||||
}
|
||||
|
||||
public IntegerRange localY()
|
||||
{
|
||||
return new IntegerRange(0, getHeight() - 1);
|
||||
}
|
||||
|
||||
public IntegerRange localZ()
|
||||
{
|
||||
return new IntegerRange(0, getDepth() - 1);
|
||||
}
|
||||
|
||||
public static FeatureSizedTarget mergedSize(Stream<FeatureSizedTarget> targets, boolean x, boolean y, boolean z) {
|
||||
List<FeatureSizedTarget> t = targets.toList();
|
||||
return FeatureSizedTarget.builder()
|
||||
.width(x ? t.stream().mapToInt(FeatureSizedTarget::getWidth).sum() : t[0].getWidth())
|
||||
.height(y ? t.stream().mapToInt(FeatureSizedTarget::getHeight).sum() : t[0].getHeight())
|
||||
.depth(z ? t.stream().mapToInt(FeatureSizedTarget::getDepth).sum() : t[0].getDepth())
|
||||
.offsetX(x ? t.stream().mapToInt(FeatureSizedTarget::getOffsetX).min().orElse(0) : t[0].getOffsetX())
|
||||
.offsetY(y ? t.stream().mapToInt(FeatureSizedTarget::getOffsetY).min().orElse(0) : t[0].getOffsetY())
|
||||
.offsetZ(z ? t.stream().mapToInt(FeatureSizedTarget::getOffsetZ).min().orElse(0) : t[0].getOffsetZ())
|
||||
.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.volmit.iris.engine.feature;
|
||||
|
||||
public interface FeatureState {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.volmit.iris.engine.feature;
|
||||
|
||||
import com.volmit.iris.engine.dimension.IrisBiome;
|
||||
import com.volmit.iris.util.NoiseCache;
|
||||
import com.volmit.iris.util.ShortNoiseCache;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FeatureStorage {
|
||||
private ShortNoiseCache height;
|
||||
private NoiseCache<IrisBiome> biome;
|
||||
private final int w;
|
||||
private final int h;
|
||||
|
||||
public FeatureStorage(int w, int h)
|
||||
{
|
||||
this.w = w;
|
||||
this.h = h;
|
||||
this.height = new ShortNoiseCache(w, h);
|
||||
this.biome = new NoiseCache<>(w, h);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.volmit.iris.engine.feature;
|
||||
|
||||
import art.arcane.spatial.hunk.Hunk;
|
||||
import art.arcane.spatial.hunk.view.HunkView;
|
||||
import com.volmit.iris.platform.PlatformNamespaced;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class FeatureTarget<T extends PlatformNamespaced> extends FeatureSizedTarget {
|
||||
private final Hunk<T> hunk;
|
||||
|
||||
public FeatureTarget(Hunk<T> hunk, int offsetX, int offsetY, int offsetZ)
|
||||
{
|
||||
super(hunk.getWidth(), hunk.getHeight(), hunk.getDepth(), offsetX, offsetY, offsetZ);
|
||||
this.hunk = hunk;
|
||||
}
|
||||
|
||||
public FeatureTarget(Hunk<T> hunk, FeatureSizedTarget target)
|
||||
{
|
||||
this(hunk, target.getOffsetX(), target.getOffsetY(), target.getOffsetZ());
|
||||
}
|
||||
|
||||
public static <V extends PlatformNamespaced> FeatureTarget<V> mergedTarget(Stream<FeatureTarget<V>> targets, FeatureTarget<V> origin, boolean x, boolean y, boolean z)
|
||||
{
|
||||
List<FeatureTarget<V>> t = targets.toList();
|
||||
FeatureSizedTarget mergedSize = FeatureSizedTarget.mergedSize(t.stream().map(i -> i), x, y, z);
|
||||
Hunk<V> hunk = new HunkView<>(origin.getHunk(), mergedSize.getWidth(), mergedSize.getHeight(), mergedSize.getDepth(),
|
||||
mergedSize.getOffsetX() - origin.getOffsetX(),
|
||||
mergedSize.getOffsetY() - origin.getOffsetY(),
|
||||
mergedSize.getOffsetZ() - origin.getOffsetZ());
|
||||
return new FeatureTarget<>(hunk, mergedSize);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.volmit.iris.engine.feature;
|
||||
|
||||
import art.arcane.chrono.PrecisionStopwatch;
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.platform.PlatformNamespaced;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ForkJoinTask;
|
||||
import java.util.concurrent.RecursiveTask;
|
||||
|
||||
/**
|
||||
* Continuously splits up a hunk of work in all 3 dimensions until the job size is within the
|
||||
* specified limits. This allows a single hunk to be split until the ideal amount of tasks can run in parallel.
|
||||
* @param <T> The namespaced object type
|
||||
* @param <S> The feature state type
|
||||
*/
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class FeatureTask<T extends PlatformNamespaced, S extends FeatureState> extends RecursiveTask<FeatureTarget<T>> implements Callable<FeatureTarget<T>> {
|
||||
private final Engine engine;
|
||||
private final Feature<T, S> feature;
|
||||
private final FeatureStorage storage;
|
||||
private final FeatureSizedTarget size;
|
||||
private final FeatureTarget<T> origin;
|
||||
private final int verticalPrepareSize;
|
||||
private final int horizontalPrepareSize;
|
||||
private final boolean heightAgnostic;
|
||||
private final FeatureTaskTiming timings;
|
||||
|
||||
@Override
|
||||
protected FeatureTarget<T> compute() {
|
||||
FeatureTarget<T> result;
|
||||
PrecisionStopwatch p = null;
|
||||
|
||||
if(timings != null) {
|
||||
p = PrecisionStopwatch.start();
|
||||
}
|
||||
|
||||
if(!heightAgnostic && size.getHeight() > verticalPrepareSize * 2) {
|
||||
result = FeatureTarget.mergedTarget(size.splitY()
|
||||
.map(i -> engine.getExecutor().getForks().submit((ForkJoinTask<FeatureTarget<T>>) with(i)))
|
||||
.map(ForkJoinTask::join), origin, false, true, false);
|
||||
}
|
||||
|
||||
else if(size.getWidth() > horizontalPrepareSize * 2) {
|
||||
result = FeatureTarget.mergedTarget(size.splitX().map(i -> engine.getExecutor().getForks().submit((ForkJoinTask<FeatureTarget<T>>) with(i)))
|
||||
.map(ForkJoinTask::join), origin, true, false, false);
|
||||
}
|
||||
|
||||
else if(size.getDepth() > horizontalPrepareSize * 2) {
|
||||
result = FeatureTarget.mergedTarget(size.splitZ().map(i -> engine.getExecutor().getForks().submit((ForkJoinTask<FeatureTarget<T>>) with(i)))
|
||||
.map(ForkJoinTask::join), origin, false, false, true);
|
||||
}
|
||||
|
||||
else {
|
||||
IrisPreparedFeature<T, S> preparedFeature = new IrisPreparedFeature<>(engine, feature, size, feature.prepare(engine, size, storage));
|
||||
result = preparedFeature.generate(origin, storage);
|
||||
}
|
||||
|
||||
if(timings != null) {
|
||||
timings.onCompleted(p.getMilliseconds());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private FeatureTask<T, S> with(FeatureSizedTarget size)
|
||||
{
|
||||
return new FeatureTask<>(engine, feature, storage, size, origin, verticalPrepareSize, horizontalPrepareSize, heightAgnostic, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FeatureTarget<T> call() throws Exception {
|
||||
return compute();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.volmit.iris.engine.feature;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface FeatureTaskTiming {
|
||||
void onCompleted(double ms);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.volmit.iris.engine.feature;
|
||||
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.platform.PlatformNamespaced;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
||||
@Builder
|
||||
@Data
|
||||
public class IrisPreparedFeature<T extends PlatformNamespaced, S extends FeatureState> {
|
||||
private final Engine engine;
|
||||
private final Feature<T, S> feature;
|
||||
private final FeatureSizedTarget size;
|
||||
private final S state;
|
||||
|
||||
public FeatureTarget<T> generate(FeatureTarget<T> origin, FeatureStorage storage) {
|
||||
FeatureTarget<T> target = size.hunked(origin);
|
||||
feature.generate(engine, state, target, storage);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.volmit.iris.engine.feature;
|
||||
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.engine.feature.FeatureStorage;
|
||||
import com.volmit.iris.engine.feature.FeatureTarget;
|
||||
import com.volmit.iris.engine.feature.features.FeatureTerrain;
|
||||
import com.volmit.iris.engine.resolver.EngineResolvable;
|
||||
import com.volmit.iris.platform.PlatformNamespaced;
|
||||
|
||||
public interface SyntheticFeature<T extends PlatformNamespaced, V extends EngineResolvable, S extends FeatureState> {
|
||||
void generate(Engine engine, V component, FeatureTarget<T> target, S state);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.volmit.iris.engine.feature.features;
|
||||
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.engine.feature.Feature;
|
||||
import com.volmit.iris.engine.feature.FeatureSizedTarget;
|
||||
import com.volmit.iris.engine.feature.FeatureState;
|
||||
import com.volmit.iris.engine.feature.FeatureStorage;
|
||||
import com.volmit.iris.engine.feature.FeatureTarget;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
public class FeatureError extends Feature<PlatformBlock, FeatureError.State> {
|
||||
private static final State DEFAULT_STATE = new State();
|
||||
private final PlatformBlock ERROR_BLOCK;
|
||||
|
||||
public FeatureError(Engine engine) {
|
||||
super("error", engine);
|
||||
setOptimize(false);
|
||||
ERROR_BLOCK = engine.block("red_sandstone");
|
||||
}
|
||||
|
||||
@Override
|
||||
public State prepare(Engine engine, FeatureSizedTarget target, FeatureStorage storage) {
|
||||
return DEFAULT_STATE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Engine engine, State state, FeatureTarget<PlatformBlock> target, FeatureStorage storage) {
|
||||
target.forXZ((x, z) -> target.forYCap((y -> target.getHunk().set(x, y, z, ERROR_BLOCK)), 1));
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class State implements FeatureState {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.volmit.iris.engine.feature.features;
|
||||
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.engine.dimension.IrisBiome;
|
||||
import com.volmit.iris.engine.feature.*;
|
||||
import com.volmit.iris.platform.PlatformBiome;
|
||||
import com.volmit.iris.util.NoiseCache;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
public class FeatureOriginBiome extends Feature<PlatformBiome, FeatureOriginBiome.State> {
|
||||
public FeatureOriginBiome(Engine engine) {
|
||||
super("biome-origin", engine);
|
||||
}
|
||||
|
||||
@Override
|
||||
public State prepare(Engine engine, FeatureSizedTarget target, FeatureStorage storage) {
|
||||
final NoiseCache<IrisBiome> noise = storage.getBiome();
|
||||
|
||||
for(int x : target.x()) {
|
||||
for(int z : target.z()) {
|
||||
noise.set(x & storage.getW() - 1, z & storage.getH() - 1, null);
|
||||
}
|
||||
}
|
||||
|
||||
return new State(noise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Engine engine, State state, FeatureTarget<PlatformBiome> target, FeatureStorage storage) {
|
||||
for(int x : target.x()) {
|
||||
for(int z : target.z()) {
|
||||
IrisBiome b = state.getBiomes().get(x, z);
|
||||
target.getHunk().set(x, 0, z, b.toPlatformBiome());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class State implements FeatureState {
|
||||
private final NoiseCache<IrisBiome> biomes;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package com.volmit.iris.engine.feature.features;
|
||||
|
||||
import art.arcane.source.NoisePlane;
|
||||
import art.arcane.source.interpolator.CubicInterpolator;
|
||||
import art.arcane.source.interpolator.Interpolator;
|
||||
import art.arcane.source.interpolator.LinearInterpolator;
|
||||
import art.arcane.source.interpolator.StarcastInterpolator;
|
||||
import art.arcane.source.noise.provider.MirroredCacheProvider;
|
||||
import art.arcane.source.util.NoisePreset;
|
||||
import art.arcane.spatial.hunk.Hunk;
|
||||
import art.arcane.spatial.hunk.storage.ArrayHunk;
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.engine.feature.*;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
public class FeatureTerrain extends Feature<PlatformBlock, FeatureTerrain.State> {
|
||||
private final PlatformBlock stone;
|
||||
private final NoisePlane generator;
|
||||
private final NoisePlane generator2;
|
||||
|
||||
public FeatureTerrain(Engine engine) {
|
||||
super("terrain", engine);
|
||||
setOptimize(true);
|
||||
stone = engine.block("stone");
|
||||
this.generator = NoisePreset.NATURAL.create(1234);
|
||||
this.generator2 = NoisePreset.NATURAL.create(6664).fit(0, 1).scale(0.1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public State prepare(Engine engine, FeatureSizedTarget target, FeatureStorage storage) {
|
||||
Hunk<Double> snc = new ArrayHunk<>(target.getWidth(), target.getHeight(), target.getDepth());
|
||||
short n;
|
||||
int fdx,fdz;
|
||||
for(int x : target.x()) {
|
||||
fdx = Math.floorMod(x, target.getWidth());
|
||||
for(int z : target.z()) {
|
||||
fdz = Math.floorMod(z, target.getDepth());
|
||||
n = (short) generator.noise(x, z);
|
||||
for(int y = 0; y < n; y++) {
|
||||
if(generator2.noise(x,y,z) > 0.5) {
|
||||
snc.set(fdx, y, fdz, 1D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new State(snc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Engine engine, State state, FeatureTarget<PlatformBlock> target, FeatureStorage storage) {
|
||||
int y;
|
||||
for(int x : target.localX()) {
|
||||
for(int z : target.localZ()) {
|
||||
for(int i = 0; i < target.getHeight(); i++) {
|
||||
Double v = state.getNoise().get(x, i, z);
|
||||
v = v == null ? 0f : v;
|
||||
if(v >= 0.5) {
|
||||
target.getHunk().set(x,i, z, stone);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class State implements FeatureState {
|
||||
private final Hunk<Double> noise;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.volmit.iris.engine.feature.features.synthetic;
|
||||
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.engine.dimension.IrisBiome;
|
||||
import com.volmit.iris.engine.feature.FeatureStorage;
|
||||
import com.volmit.iris.engine.feature.FeatureTarget;
|
||||
import com.volmit.iris.engine.feature.SyntheticFeature;
|
||||
import com.volmit.iris.engine.feature.features.FeatureTerrain;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
|
||||
public class SyntheticBiomeTerrain implements SyntheticFeature<PlatformBlock, IrisBiome, FeatureTerrain.State>
|
||||
{
|
||||
@Override
|
||||
public void generate(Engine engine, IrisBiome component, FeatureTarget<PlatformBlock> target, FeatureTerrain.State state) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package com.volmit.iris.engine.network;
|
||||
|
||||
public class Network {
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.volmit.iris.engine.network.server;
|
||||
|
||||
import com.volmit.iris.engine.Engine;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EngineServer extends Thread {
|
||||
private final Engine engine;
|
||||
private final ServerSocket server;
|
||||
private final Map<UUID, EngineServerConnection> connections;
|
||||
|
||||
public EngineServer(Engine engine, int bindPort) throws IOException {
|
||||
this.engine = engine;
|
||||
this.connections = new HashMap<>();
|
||||
this.server = new ServerSocket(bindPort);
|
||||
this.server.setPerformancePreferences(0, 0, 1);
|
||||
this.server.setSoTimeout(5000);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while(!interrupted()) {
|
||||
try {
|
||||
Socket socket = server.accept();
|
||||
EngineServerConnection connection = new EngineServerConnection(this, socket);
|
||||
connections.put(connection.getConnectionId(), connection);
|
||||
}
|
||||
catch(SocketTimeoutException e) {
|
||||
continue;
|
||||
} catch (Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void close() throws IOException {
|
||||
this.interrupt();
|
||||
server.close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.volmit.iris.engine.network.server;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.net.Socket;
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
public class EngineServerConnection extends Thread {
|
||||
private final EngineServer server;
|
||||
private final Socket socket;
|
||||
private final UUID connectionId;
|
||||
|
||||
public EngineServerConnection(EngineServer server, Socket socket) {
|
||||
this.server = server;
|
||||
this.socket = socket;
|
||||
this.connectionId = UUID.randomUUID();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.volmit.iris.engine.optimizer;
|
||||
|
||||
import art.arcane.amulet.range.IntegerRange;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class HunkSlizeConfiguration {
|
||||
private final int verticalSlice;
|
||||
private final int horizontalSlize;
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return "H" + horizontalSlize + "" + ((verticalSlice < 8192) ? ("V" + verticalSlice) : "");
|
||||
}
|
||||
|
||||
public static List<HunkSlizeConfiguration> generateConfigurations(IntegerRange vertical, IntegerRange horizontal)
|
||||
{
|
||||
List<HunkSlizeConfiguration> configurations = new ArrayList<>();
|
||||
|
||||
for(int i : slice(vertical))
|
||||
{
|
||||
for(int j : slice(horizontal))
|
||||
{
|
||||
configurations.add(new HunkSlizeConfiguration(i, j));
|
||||
}
|
||||
}
|
||||
|
||||
return configurations;
|
||||
}
|
||||
|
||||
public static List<HunkSlizeConfiguration> generateConfigurations(int vertical, IntegerRange horizontal)
|
||||
{
|
||||
List<HunkSlizeConfiguration> configurations = new ArrayList<>();
|
||||
|
||||
for(int j : slice(horizontal))
|
||||
{
|
||||
configurations.add(new HunkSlizeConfiguration(vertical, j));
|
||||
}
|
||||
|
||||
return configurations;
|
||||
}
|
||||
|
||||
private static List<Integer> slice(IntegerRange range)
|
||||
{
|
||||
List<Integer> v = new ArrayList<>();
|
||||
v.add(range.getRightEndpoint());
|
||||
v.add(range.getLeftEndpoint());
|
||||
int i = (int) (range.getRightEndpoint() / 1.25);
|
||||
|
||||
while(i > range.getLeftEndpoint() && i >= 1)
|
||||
{
|
||||
v.add(i);
|
||||
i /= 1.25;
|
||||
}
|
||||
|
||||
return v.withoutDuplicates();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.volmit.iris.engine.optimizer;
|
||||
|
||||
import art.arcane.chrono.Average;
|
||||
import art.arcane.spatial.hunk.storage.AtomicDoubleHunk;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Data
|
||||
public class IrisOptimizationAttempt<T> {
|
||||
private double value;
|
||||
private final AtomicInteger runs;
|
||||
private final int testRuns;
|
||||
private final T parameters;
|
||||
|
||||
public IrisOptimizationAttempt(T parameters, int testRuns)
|
||||
{
|
||||
this.parameters = parameters;
|
||||
this.testRuns = testRuns;
|
||||
this.value = 0;
|
||||
this.runs = new AtomicInteger(0);
|
||||
}
|
||||
|
||||
public double getAverageTime()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isComplete()
|
||||
{
|
||||
return runs.get() >= testRuns;
|
||||
}
|
||||
|
||||
public void report(double ms) {
|
||||
value += ms;
|
||||
runs.incrementAndGet();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.volmit.iris.engine.optimizer;
|
||||
|
||||
import art.arcane.amulet.format.Form;
|
||||
import art.arcane.chrono.Average;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Singular;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Data
|
||||
public class IrisOptimizer<T> {
|
||||
private final String optimizedFeatureName;
|
||||
private final int testRuns;
|
||||
private int dummyRuns;
|
||||
private final List<T> options;
|
||||
private final Map<T, Double> results;
|
||||
private final Map<T, IrisOptimizationAttempt<T>> attempts = new ConcurrentHashMap<>();
|
||||
private T defaultOption;
|
||||
private final double chanceToTest;
|
||||
private double bestTime;
|
||||
|
||||
public IrisOptimizer(int testRuns, List<T> options, T defaultOption, double chanceToTest, String optimizedFeatureName) {
|
||||
this.bestTime = Double.MAX_VALUE;
|
||||
this.dummyRuns = 1024;
|
||||
this.testRuns = testRuns;
|
||||
this.results = new HashMap<>();
|
||||
this.options = options;
|
||||
this.optimizedFeatureName = optimizedFeatureName;
|
||||
this.defaultOption = defaultOption;
|
||||
this.chanceToTest = chanceToTest;
|
||||
|
||||
for(T i : options) {
|
||||
attempts.put(i, new IrisOptimizationAttempt<>(i, testRuns));
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "optimizer";
|
||||
}
|
||||
|
||||
public synchronized void report(T parameters, double ms)
|
||||
{
|
||||
if(dummyRuns-- > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IrisOptimizationAttempt<T> attempt = attempts.get(parameters);
|
||||
|
||||
if(attempt != null) {
|
||||
attempt.report(ms);
|
||||
|
||||
if(attempt.isComplete()) {
|
||||
results.put(parameters, attempt.getAverageTime());
|
||||
attempts.remove(parameters);
|
||||
double result = attempt.getAverageTime();
|
||||
|
||||
if(result < bestTime) {
|
||||
bestTime = result;
|
||||
defaultOption = attempt.getParameters();
|
||||
}
|
||||
|
||||
d("Attempted " + optimizedFeatureName + " with " + defaultOption.toString() + " " + Form.duration(attempt.getAverageTime(), 2));
|
||||
|
||||
if(attempts.isEmpty()) {
|
||||
d("Fully Optimized " + optimizedFeatureName + " with " + defaultOption.toString());
|
||||
|
||||
for(T i : results.keySet()) {
|
||||
d(i.toString() + ": " + Form.duration(results.get(i), 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public T nextParameters() {
|
||||
if(!attempts.isEmpty() && Math.r(chanceToTest)) {
|
||||
return attempts.k().popRandom();
|
||||
}
|
||||
|
||||
return defaultOption;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.volmit.iris.engine.pipeline;
|
||||
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.engine.feature.FeatureSizedTarget;
|
||||
import com.volmit.iris.engine.feature.FeatureStorage;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Singular;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EnginePipeline
|
||||
{
|
||||
@Singular
|
||||
private final List<PipelinePhase> phases;
|
||||
|
||||
public void generate(Engine engine, FeatureSizedTarget target, PipedHunkStack stack) {
|
||||
FeatureStorage storage = new FeatureStorage(engine.getConfiguration().getChunkSize(), engine.getConfiguration().getChunkSize());
|
||||
|
||||
for(PipelinePhase i : phases) {
|
||||
i.generate(engine, target, stack, storage);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.volmit.iris.engine.pipeline;
|
||||
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.engine.feature.FeatureSizedTarget;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Singular;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class EnginePlumbing {
|
||||
private final Engine engine;
|
||||
@Singular
|
||||
private final List<EnginePipeline> pipelines;
|
||||
private final EnginePipeline errorPipeline;
|
||||
|
||||
public void generate(Engine engine, FeatureSizedTarget target, PipedHunkStack stack) {
|
||||
for(EnginePipeline i : pipelines) {
|
||||
i.generate(engine, target, stack);
|
||||
}
|
||||
try {
|
||||
}
|
||||
|
||||
catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
getErrorPipeline().generate(engine, target, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.volmit.iris.engine.pipeline;
|
||||
|
||||
import com.volmit.iris.engine.feature.FeatureTarget;
|
||||
import com.volmit.iris.platform.PlatformNamespaced;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PipedHunkStack {
|
||||
private final Map<Class<? extends PlatformNamespaced>, FeatureTarget<? extends PlatformNamespaced>> hunks;
|
||||
|
||||
public PipedHunkStack()
|
||||
{
|
||||
this.hunks = new HashMap<>();
|
||||
}
|
||||
|
||||
public void register(Class<? extends PlatformNamespaced> clazz, FeatureTarget<? extends PlatformNamespaced> hunk)
|
||||
{
|
||||
hunks.put(clazz, hunk);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T extends PlatformNamespaced> FeatureTarget<T> hunk(Class<?> hunk)
|
||||
{
|
||||
return (FeatureTarget<T>) hunks.get(hunk);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.volmit.iris.engine.pipeline;
|
||||
|
||||
import com.volmit.iris.engine.Engine;
|
||||
import com.volmit.iris.engine.feature.FeatureSizedTarget;
|
||||
import com.volmit.iris.engine.feature.FeatureStorage;
|
||||
import com.volmit.iris.engine.feature.FeatureTarget;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.Singular;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
public class PipelinePhase
|
||||
{
|
||||
@Singular
|
||||
private final List<PipelineTask<?>> tasks;
|
||||
|
||||
public List<FeatureTarget<?>> generate(Engine engine, FeatureSizedTarget target, PipedHunkStack stack, FeatureStorage storage) {
|
||||
return engine.getExecutor().getForks().invokeAll(tasks.stream().map(i -> i.task(target, stack.hunk(i.getTarget()), storage))
|
||||
.collect(Collectors.toList())).stream().map(i -> {
|
||||
try {
|
||||
return i.get();
|
||||
} catch(Throwable e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.volmit.iris.engine.pipeline;
|
||||
|
||||
import art.arcane.amulet.range.IntegerRange;
|
||||
import com.volmit.iris.engine.feature.*;
|
||||
import com.volmit.iris.engine.optimizer.HunkSlizeConfiguration;
|
||||
import com.volmit.iris.engine.optimizer.IrisOptimizer;
|
||||
import com.volmit.iris.platform.PlatformNamespaced;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static art.arcane.amulet.MagicalSugar.*;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Data
|
||||
public class PipelineTask<T extends PlatformNamespaced>
|
||||
{
|
||||
private final Feature<T, ?> feature;
|
||||
private final Class<T> target;
|
||||
private final IntegerRange verticalEnvelope;
|
||||
private final IntegerRange horizontalEnvelope;
|
||||
private final IrisOptimizer<HunkSlizeConfiguration> optimizer;
|
||||
|
||||
public PipelineTask(Feature<T, ?> feature, Class<T> target, IntegerRange verticalEnvelope, IntegerRange horizontalEnvelope)
|
||||
{
|
||||
this.feature = feature;
|
||||
this.target = target;
|
||||
this.verticalEnvelope = verticalEnvelope;
|
||||
this.horizontalEnvelope = horizontalEnvelope;
|
||||
List<HunkSlizeConfiguration> configurations = feature.isHeightAgnostic() ? HunkSlizeConfiguration.generateConfigurations(Integer.MAX_VALUE, horizontalEnvelope)
|
||||
: HunkSlizeConfiguration.generateConfigurations(verticalEnvelope, horizontalEnvelope);
|
||||
this.optimizer = new IrisOptimizer<>(128, configurations, configurations[0], 1, feature.getName());
|
||||
}
|
||||
|
||||
public PipelineTask(Feature<T, ?> feature, Class<T> target) {
|
||||
this(feature, target, 1 to 16, 1 to 16);
|
||||
}
|
||||
|
||||
public FeatureTask<T, ?> task(FeatureSizedTarget target, FeatureTarget<T> origin, FeatureStorage storage){
|
||||
HunkSlizeConfiguration configuration = getFeature().isOptimize() ? optimizer.nextParameters() : optimizer.getDefaultOption();
|
||||
return feature.task(target, origin, storage, configuration.getVerticalSlice(), configuration.getHorizontalSlize(), (ms) -> optimizer.report(configuration, ms));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.volmit.iris.engine.resolver;
|
||||
|
||||
import art.arcane.amulet.format.Form;
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class CompositeResolver<T extends Resolvable> implements Resolver<T> {
|
||||
private final Map<String, Resolver<T>> resolvers;
|
||||
private final String[] namespaces;
|
||||
|
||||
public CompositeResolver(Map<String, Resolver<T>> resolvers)
|
||||
{
|
||||
this.resolvers = resolvers;
|
||||
this.namespaces = resolvers.keySet().toArray(new String[0]);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNamespace(String namespace) {
|
||||
return resolvers.containsKey(namespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T resolve(PlatformNamespaceKey key) {
|
||||
return resolvers.get(key.getNamespace()).resolve(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T resolve(String key) {
|
||||
for(String i : getNamespaces()) {
|
||||
if(resolvers.get(i).contains(i, key)) {
|
||||
return resolvers.get(i).resolve(key);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resolver<T> and(String namespace, Resolver<T> resolver) {
|
||||
Map<String, Resolver<T>> resolvers = this.resolvers.copy();
|
||||
|
||||
if(hasNamespace(namespace)) {
|
||||
resolvers.put(namespace, resolvers.get(namespace).and(namespace, resolver));
|
||||
}
|
||||
|
||||
else {
|
||||
resolvers.put(namespace, resolver);
|
||||
}
|
||||
|
||||
return new CompositeResolver<>(resolvers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String type, Object printer, int indent) {
|
||||
printer.i(Form.repeat(" ", indent) + "Composite[" + Arrays.toString(getNamespaces()) + "] " + type);
|
||||
|
||||
for(Resolver<T> i : getResolvers().values()) {
|
||||
i.print(type, printer, indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllKeys(List<PlatformNamespaceKey> keys) {
|
||||
resolvers.forEach((k, v) -> v.addAllKeys(keys));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.volmit.iris.engine.resolver;
|
||||
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EngineResolvable implements Resolvable {
|
||||
private PlatformNamespaceKey key;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.volmit.iris.engine.resolver;
|
||||
|
||||
import art.arcane.amulet.format.Form;
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import com.volmit.iris.util.NSK;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class FrozenResolver<T extends Resolvable> implements Resolver<T> {
|
||||
private final Map<String, T> registry;
|
||||
private final String namespace;
|
||||
|
||||
public FrozenResolver(String namespace, Map<String, T> registry)
|
||||
{
|
||||
this.registry = Collections.unmodifiableMap(registry);
|
||||
this.namespace = namespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNamespace(String namespace) {
|
||||
return this.namespace.equals(namespace);
|
||||
}
|
||||
|
||||
public T resolve(PlatformNamespaceKey key) {
|
||||
return registry.get(key.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public T resolve(String key) {
|
||||
return registry.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String type, Object printer, int indent) {
|
||||
printer.i(Form.repeat(" ", indent) + "Frozen[" + namespace + "] " + type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllKeys(List<PlatformNamespaceKey> keys) {
|
||||
registry.keySet().forEach((k) -> keys.add(new NSK(getNamespace(), k)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resolver<T> and(String namespace, Resolver<T> resolver) {
|
||||
if(!namespace.equals(getNamespace())) {
|
||||
return new CompositeResolver<>(Map.of(namespace, resolver, getNamespace(), this));
|
||||
}
|
||||
|
||||
return new MergedNamespaceResolver<>(namespace, this, resolver);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.volmit.iris.engine.resolver;
|
||||
|
||||
import art.arcane.amulet.format.Form;
|
||||
import com.github.benmanes.caffeine.cache.CacheLoader;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
import com.github.benmanes.caffeine.cache.LoadingCache;
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import com.volmit.iris.util.NSK;
|
||||
import lombok.Data;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Data
|
||||
public class HotResolver<T extends Resolvable> implements Resolver<T>, CacheLoader<String, T> {
|
||||
private final LoadingCache<String, T> cache;
|
||||
private final String namespace;
|
||||
private final Function<String, T> loader;
|
||||
private final Supplier<List<String>> keyGetter;
|
||||
|
||||
public HotResolver(String namespace, Function<String, T> loader, Supplier<List<String>> keyGetter)
|
||||
{
|
||||
this.namespace = namespace;
|
||||
this.keyGetter = keyGetter;
|
||||
this.loader = loader;
|
||||
cache = Caffeine.newBuilder().build(this);
|
||||
}
|
||||
|
||||
public T resolve(PlatformNamespaceKey key) {
|
||||
return cache.get(key.getKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
public T resolve(String key) {
|
||||
return cache.get(key);
|
||||
}
|
||||
|
||||
public boolean hasNamespace(String namespace) {
|
||||
return this.namespace.equals(namespace);
|
||||
}
|
||||
|
||||
public FrozenResolver<T> freeze()
|
||||
{
|
||||
cache.cleanUp();
|
||||
Map<String, T> map = new HashMap<>((int) cache.estimatedSize());
|
||||
Map<String, T> view = cache.asMap();
|
||||
|
||||
for(String i : view.keySet()) {
|
||||
map.put(i, view.get(i));
|
||||
}
|
||||
|
||||
return new FrozenResolver<>(getNamespace(), Collections.unmodifiableMap(map));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable T load(String key) {
|
||||
return loader.apply(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resolver<T> and(String namespace, Resolver<T> resolver) {
|
||||
if(!namespace.equals(getNamespace())) {
|
||||
return new CompositeResolver<>(Map.of(namespace, resolver, getNamespace(), this));
|
||||
}
|
||||
|
||||
return new MergedNamespaceResolver<>(namespace, this, resolver);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String type, Object printer, int indent) {
|
||||
printer.i(Form.repeat(" ", indent) + "Hot[" + namespace + "] " + type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllKeys(List<PlatformNamespaceKey> keys) {
|
||||
keys.addAll(keyGetter.get().stream().map(i -> new NSK(getNamespace(), i)).toList());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.volmit.iris.engine.resolver;
|
||||
|
||||
import art.arcane.amulet.format.Form;
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class MergedNamespaceResolver<T extends Resolvable> implements Resolver<T> {
|
||||
private final String namespace;
|
||||
private final List<Resolver<T>> resolvers;
|
||||
|
||||
public MergedNamespaceResolver(String namespace, Resolver<T>... resolvers)
|
||||
{
|
||||
this(namespace, Arrays.stream(resolvers).toList());
|
||||
}
|
||||
|
||||
public MergedNamespaceResolver(String namespace, List<Resolver<T>> resolvers)
|
||||
{
|
||||
this.namespace = namespace;
|
||||
this.resolvers = resolvers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasNamespace(String namespace) {
|
||||
return this.namespace.equals(namespace);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T resolve(PlatformNamespaceKey key) {
|
||||
for(Resolver<T> i : resolvers) {
|
||||
T t = i.resolve(key);
|
||||
|
||||
if(t != null)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T resolve(String key) {
|
||||
for(Resolver<T> i : resolvers) {
|
||||
T t = i.resolve(key);
|
||||
|
||||
if(t != null)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String type, Object printer, int indent) {
|
||||
printer.i(Form.repeat(" ", indent) + "Merged[" + namespace + "] " + type);
|
||||
|
||||
for(Resolver<T> i : getResolvers()) {
|
||||
i.print(type, printer, indent + 2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAllKeys(List<PlatformNamespaceKey> keys) {
|
||||
resolvers.forEach(i -> i.addAllKeys(keys));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Resolver<T> and(String namespace, Resolver<T> resolver) {
|
||||
if(namespace.equals(getNamespace()))
|
||||
{
|
||||
List<Resolver<T>> r = resolvers.copy();
|
||||
r.add(resolver);
|
||||
return new MergedNamespaceResolver<>(namespace, r);
|
||||
}
|
||||
|
||||
return new CompositeResolver<>(Map.of(getNamespace(), this, namespace, resolver));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
package com.volmit.iris.engine.resolver;
|
||||
|
||||
import art.arcane.amulet.format.Form;
|
||||
import art.arcane.cram.PakResource;
|
||||
import com.google.gson.*;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.volmit.iris.engine.EngineData;
|
||||
import com.volmit.iris.platform.PlatformBiome;
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import com.volmit.iris.platform.PlatformNamespaced;
|
||||
import com.volmit.iris.platform.PlatformNamespacedMutable;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public interface Resolvable extends PlatformNamespaced, PlatformNamespacedMutable, PakResource {
|
||||
String SCHEMA = "http://json-schema.org/draft-07/schema#";
|
||||
|
||||
default String getSchemaId() {
|
||||
return "https://art.arcane/iris/schemas/"+entity().getId()+".json";
|
||||
}
|
||||
|
||||
default String getSchemaRefId() {
|
||||
return entity().getId()+".json";
|
||||
}
|
||||
|
||||
default JsonObject generateSchema(EngineData data) {
|
||||
JsonObject object = new JsonObject();
|
||||
Entity.ResolverEntityData entity = entity();
|
||||
object.add("$schema", new JsonPrimitive(SCHEMA));
|
||||
object.add("$id", new JsonPrimitive(getSchemaId()));
|
||||
object.add("type", new JsonPrimitive("object"));
|
||||
object.add("description", new JsonPrimitive("No Description for " + entity.getName()));
|
||||
|
||||
JsonObject properties = new JsonObject();
|
||||
JsonObject definitions = new JsonObject();
|
||||
|
||||
for(Field i : getClass().getDeclaredFields()) {
|
||||
i.access();
|
||||
|
||||
if (Modifier.isStatic(i.getModifiers()) || Modifier.isTransient(i.getModifiers())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
properties.add(i.getName(), generateSchemaProperty(data, i.getName(), i.getType(), i.getDeclaredAnnotation(Type.class), i.getDeclaredAnnotation(PlatformType.class), definitions));
|
||||
}
|
||||
|
||||
object.add("properties", properties);
|
||||
object.add("definitions", definitions);
|
||||
return object;
|
||||
}
|
||||
|
||||
default String getSchemaDefinition(String name) {
|
||||
return "D" + name.hashCode();
|
||||
}
|
||||
|
||||
default JsonObject generateSchemaProperty(EngineData data, String name, Class<?> type, Type listType, PlatformType platformType, JsonObject definitions) {
|
||||
JsonObject main = new JsonObject();
|
||||
JsonArray anyOf = new JsonArray();
|
||||
JsonObject object = new JsonObject();
|
||||
anyOf.add(object);
|
||||
object.add("description", new JsonPrimitive("No Description for field " + name));
|
||||
|
||||
if(type.isAssignableFrom(Resolvable.class) || Resolvable.class.isAssignableFrom(type)) {
|
||||
Resolvable r = data.getInstance(type);
|
||||
|
||||
if(r != null) {
|
||||
String def = getSchemaDefinition(r.getClass().simpleName());
|
||||
object.add("$ref", new JsonPrimitive(r.getSchemaRefId()));
|
||||
JsonObject registry = new JsonObject();
|
||||
registry.add("description", new JsonPrimitive("No Description for field " + name));
|
||||
String defName = getSchemaDefinition("resolve" + type.getCanonicalName());
|
||||
registry.add("type", new JsonPrimitive("string"));
|
||||
registry.add("$ref", new JsonPrimitive("#/definitions/" + defName));
|
||||
|
||||
if(!definitions.has(defName)) {
|
||||
JsonObject enumDef = new JsonObject();
|
||||
JsonArray enums = new JsonArray();
|
||||
data.getAllKeys(type).forEach(i -> enums.add(i.toString()));
|
||||
enumDef.add("enum", enums);
|
||||
definitions.add(defName, enumDef);
|
||||
}
|
||||
|
||||
anyOf.add(registry);
|
||||
}
|
||||
}
|
||||
|
||||
else if(type.isAssignableFrom(List.class) || List.class.isAssignableFrom(type)) {
|
||||
if(listType != null) {
|
||||
JsonObject internal = generateSchemaProperty(data, "list", listType.value(), null, platformType, definitions);
|
||||
object.add("items", internal);
|
||||
}
|
||||
}
|
||||
|
||||
else if(type.isEnum()) {
|
||||
String defName = getSchemaDefinition(type.getCanonicalName());
|
||||
object.add("type", new JsonPrimitive("string"));
|
||||
object.add("$ref", new JsonPrimitive("#/definitions/" + defName));
|
||||
|
||||
if(!definitions.has(defName)) {
|
||||
try {
|
||||
JsonObject enumDef = new JsonObject();
|
||||
JsonArray enums = new JsonArray();
|
||||
Arrays.stream((Enum<?>[])type.getDeclaredMethod("values").invoke(null)).forEach(i -> enums.add(i.name()));
|
||||
enumDef.add("enum", enums);
|
||||
definitions.add(defName, enumDef);
|
||||
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if(type.equals(String.class)) {
|
||||
object.add("type", new JsonPrimitive("string"));
|
||||
|
||||
if(platformType != null) {
|
||||
String defName = getSchemaDefinition(platformType.value().getCanonicalName());
|
||||
object.add("$ref", new JsonPrimitive("#/definitions/" + defName));
|
||||
|
||||
if(!definitions.has(defName)) {
|
||||
JsonObject enumDef = new JsonObject();
|
||||
JsonArray enums = buildSchemaPlatformEnum(data, platformType.value());
|
||||
enumDef.add("enum", enums);
|
||||
definitions.add(defName, enumDef);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if(type.equals(int.class) || type.equals(Integer.class)
|
||||
|| type.equals(long.class) || type.equals(Long.class)
|
||||
|| type.equals(byte.class) || type.equals(Byte.class)
|
||||
|| type.equals(short.class) || type.equals(Short.class))
|
||||
{
|
||||
object.add("type", new JsonPrimitive("integer"));
|
||||
|
||||
if(type.equals(int.class) || type.equals(Integer.class)) {
|
||||
object.add("minimum", new JsonPrimitive(Integer.MIN_VALUE));
|
||||
object.add("maximum", new JsonPrimitive(Integer.MAX_VALUE));
|
||||
}
|
||||
|
||||
else if(type.equals(long.class) || type.equals(Long.class)) {
|
||||
object.add("minimum", new JsonPrimitive(Long.MIN_VALUE));
|
||||
object.add("maximum", new JsonPrimitive(Long.MAX_VALUE));
|
||||
}
|
||||
|
||||
else if(type.equals(short.class) || type.equals(Short.class)) {
|
||||
object.add("minimum", new JsonPrimitive(Short.MIN_VALUE));
|
||||
object.add("maximum", new JsonPrimitive(Short.MAX_VALUE));
|
||||
}
|
||||
|
||||
else {
|
||||
object.add("minimum", new JsonPrimitive(Byte.MIN_VALUE));
|
||||
object.add("maximum", new JsonPrimitive(Byte.MAX_VALUE));
|
||||
}
|
||||
}
|
||||
|
||||
if(anyOf.size() == 1)
|
||||
{
|
||||
return object;
|
||||
}
|
||||
|
||||
main.add("anyOf", anyOf);
|
||||
return main;
|
||||
}
|
||||
|
||||
default JsonArray buildSchemaPlatformEnum(EngineData data, Class<? extends PlatformNamespaced> value) {
|
||||
JsonArray a = new JsonArray();
|
||||
|
||||
if(value.equals(PlatformBlock.class)) {
|
||||
data.getEngine().getPlatform().getBlocks().map(i -> i.getKey().toString()).forEach(a::add);
|
||||
}
|
||||
|
||||
else if(value.equals(PlatformBiome.class)) {
|
||||
data.getEngine().getPlatform().getBiomes().map(i -> i.getKey().toString()).forEach(a::add);
|
||||
}
|
||||
|
||||
return a;
|
||||
}
|
||||
|
||||
default void apply(GsonBuilder builder) {
|
||||
if(this instanceof TypeAdapterFactory f) {
|
||||
builder.registerTypeAdapterFactory(f);
|
||||
}
|
||||
}
|
||||
|
||||
default Entity.ResolverEntityData entity() {
|
||||
return new Entity.ResolverEntityData(getClass().getDeclaredAnnotation(Resolvable.Entity.class));
|
||||
}
|
||||
|
||||
default <T> void writeSafeJson(TypeAdapter<T> delegate, JsonWriter out, T value) {
|
||||
try {
|
||||
delegate.write(out, value);
|
||||
} catch (IOException e) {
|
||||
try {
|
||||
delegate.write(out, null);
|
||||
} catch(IOException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface Entity {
|
||||
String id();
|
||||
String name() default "";
|
||||
String namePlural() default "";
|
||||
JsonToken[] jsonTypes() default JsonToken.BEGIN_OBJECT;
|
||||
|
||||
@AllArgsConstructor
|
||||
@lombok.Data
|
||||
class ResolverEntityData
|
||||
{
|
||||
private final Entity annotation;
|
||||
|
||||
public String getId() {
|
||||
return annotation.id();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return annotation.name().isEmpty() ? Form.capitalizeWords(getId().replaceAll("\\Q-\\E", " ")) : annotation.name();
|
||||
}
|
||||
|
||||
public String getNamePlural() {
|
||||
return annotation.namePlural().isEmpty() ? getName() + "s" : annotation.namePlural();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface TokenConstructor {
|
||||
JsonToken[] value();
|
||||
}
|
||||
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface Type {
|
||||
Class<?> value();
|
||||
}
|
||||
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@interface PlatformType {
|
||||
Class<? extends PlatformNamespaced> value();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.volmit.iris.engine.resolver;
|
||||
|
||||
import art.arcane.cram.PakKey;
|
||||
import art.arcane.cram.PakResource;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public interface Resolver<T extends Resolvable> {
|
||||
@SuppressWarnings("unchecked")
|
||||
static <F extends Resolvable> CompositeResolver<F> frozen(Map<PakKey, PakResource> resources, Predicate<PakResource> isTypePredicate) {
|
||||
Map<String, Map<String, F>> resolvables = new HashMap<>();
|
||||
Map<String, Resolver<F>> resolvers = new HashMap<>();
|
||||
|
||||
for(PakKey i : resources.keySet()) {
|
||||
PakResource r = resources.get(i);
|
||||
|
||||
if(isTypePredicate.test(r)) {
|
||||
Map<String, F> rs = resolvables.computeIfAbsent(i.getNamespace(), (k) -> new HashMap<>());
|
||||
rs.put(i.getKey(), (F) i);
|
||||
}
|
||||
}
|
||||
|
||||
for(String i : resolvables.keySet()) {
|
||||
resolvers.put(i, frozen(i, resolvables.get(i)));
|
||||
}
|
||||
|
||||
return new CompositeResolver<>(resolvers);
|
||||
}
|
||||
|
||||
static <F extends Resolvable> Resolver<F> frozen(String namespace, Map<String, F> map) {
|
||||
return new FrozenResolver<>(namespace, map);
|
||||
}
|
||||
|
||||
static <F extends Resolvable> Resolver<F> hot(String namespace, Function<String, F> loader, Supplier<List<String>> keyGetter) {
|
||||
return new HotResolver<>(namespace, loader, keyGetter);
|
||||
}
|
||||
|
||||
static <F extends Resolvable> Resolver<F> hotDirectoryJson(String namespace, Class<?> resolvableClass, File folder, Gson gson) {
|
||||
return hotDirectory(namespace, (in) -> (F) gson.fromJson(new InputStreamReader(in), resolvableClass), folder, "json");
|
||||
}
|
||||
|
||||
static <F extends Resolvable> Resolver<F> hotDirectory(String namespace, Function<InputStream, F> loader, File folder, String... extensions) {
|
||||
return new HotResolver<>(namespace, (key) -> {
|
||||
for(String i : extensions)
|
||||
{
|
||||
File f = new File(folder, key + "." + i);
|
||||
if(f.exists())
|
||||
{
|
||||
try {
|
||||
FileInputStream in = new FileInputStream(f);
|
||||
F ff = loader.apply(in);
|
||||
in.close();
|
||||
return ff;
|
||||
} catch(IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}, () -> {
|
||||
List<String> s = new ArrayList<>();
|
||||
|
||||
for(File i : folder.listFiles())
|
||||
{
|
||||
if(i.isFile()) {
|
||||
for(String j : extensions)
|
||||
{
|
||||
if(i.getName().endsWith(j))
|
||||
{
|
||||
s.add(i.getName().split("\\Q.\\E")[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return s;
|
||||
});
|
||||
}
|
||||
|
||||
boolean hasNamespace(String namespace);
|
||||
|
||||
T resolve(PlatformNamespaceKey key);
|
||||
|
||||
T resolve(String key);
|
||||
|
||||
default boolean contains(String namespace, String key) {
|
||||
return hasNamespace(namespace) && resolve(key) != null;
|
||||
}
|
||||
|
||||
default boolean contains(PlatformNamespaceKey key){
|
||||
return hasNamespace(key.getNamespace()) && resolve(key) != null;
|
||||
}
|
||||
|
||||
Resolver<T> and(String namespace, Resolver<T> resolver);
|
||||
|
||||
default void print(String type, Object printer)
|
||||
{
|
||||
print(type, printer, 0);
|
||||
}
|
||||
|
||||
void print(String type, Object printer, int index);
|
||||
|
||||
void addAllKeys(List<PlatformNamespaceKey> keys);
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.volmit.iris.platform;
|
||||
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public interface IrisPlatform {
|
||||
void logError(String k, Object o);
|
||||
|
||||
void logInfo(String k, Object o);
|
||||
|
||||
void logWarning(String k, Object o);
|
||||
|
||||
void logDebug(String k, Object o);
|
||||
|
||||
String getPlatformName();
|
||||
|
||||
Stream<PlatformBlock> getBlocks();
|
||||
|
||||
Stream<PlatformBiome> getBiomes();
|
||||
|
||||
boolean isWorldLoaded(String name);
|
||||
|
||||
PlatformWorld getWorld(String name);
|
||||
|
||||
PlatformBlock parseBlock(String raw);
|
||||
|
||||
PlatformNamespaceKey key(String namespace, String key);
|
||||
|
||||
default PlatformNamespaceKey key(String nsk)
|
||||
{
|
||||
return key("minecraft", nsk);
|
||||
}
|
||||
|
||||
File getStudioFolder();
|
||||
|
||||
File getStudioFolder(String dimension);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.volmit.iris.platform;
|
||||
|
||||
public interface PlatformBiome extends PlatformNamespaced {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.volmit.iris.platform;
|
||||
|
||||
public interface PlatformChunk {
|
||||
int getX();
|
||||
|
||||
int getZ();
|
||||
|
||||
void unload(boolean save, boolean force);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.volmit.iris.platform;
|
||||
|
||||
import art.arcane.cram.PakKey;
|
||||
import com.volmit.iris.util.NSK;
|
||||
|
||||
public interface PlatformNamespaceKey {
|
||||
String getNamespace();
|
||||
|
||||
String getKey();
|
||||
|
||||
String toString();
|
||||
|
||||
static PlatformNamespaceKey of(PakKey key) {
|
||||
return new NSK(key.getNamespace(), key.getKey());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.volmit.iris.platform;
|
||||
|
||||
public interface PlatformNamespaced {
|
||||
PlatformNamespaceKey getKey();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.volmit.iris.platform;
|
||||
|
||||
public interface PlatformNamespacedMutable {
|
||||
void setKey(PlatformNamespaceKey key);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.volmit.iris.platform;
|
||||
|
||||
import art.arcane.amulet.geometry.Vec;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface PlatformPlayer {
|
||||
UUID getUUID();
|
||||
|
||||
String getName();
|
||||
|
||||
Vec getLocation();
|
||||
|
||||
PlatformWorld getWorld();
|
||||
|
||||
boolean canUseIris();
|
||||
|
||||
void sendMessage(String message);
|
||||
|
||||
void sendActionBar(String message);
|
||||
|
||||
void sendTitleMessage(String title, String subtitle, int in, int stay, int out);
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.volmit.iris.platform;
|
||||
|
||||
import art.arcane.amulet.format.Form;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Data
|
||||
public class PlatformRegistry<T extends PlatformNamespaced> {
|
||||
private final Map<PlatformNamespaceKey, T> registry;
|
||||
private final String name;
|
||||
private final String namePlural;
|
||||
|
||||
public PlatformRegistry(String name, String namePlural, Stream<T> stream) {
|
||||
this.name = name;
|
||||
this.namePlural = namePlural;
|
||||
registry = Collections.unmodifiableMap(stream.collect(Collectors.toMap(PlatformNamespaced::getKey, (t) -> t)));
|
||||
i("Registered " + Form.f(registry.size()) + " " + namePlural);
|
||||
}
|
||||
|
||||
public PlatformRegistry(String name, Stream<T> stream) {
|
||||
this(name, name + "s", stream);
|
||||
}
|
||||
|
||||
|
||||
public T get(PlatformNamespaceKey key) {
|
||||
return registry.get(key);
|
||||
}
|
||||
|
||||
public Set<PlatformNamespaceKey> getKeys() {
|
||||
return Collections.unmodifiableSet(registry.keySet());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.volmit.iris.platform;
|
||||
|
||||
import com.volmit.iris.platform.block.PlatformBlock;
|
||||
import com.volmit.iris.util.WorldHeight;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public interface PlatformWorld {
|
||||
WorldHeight getHeight();
|
||||
|
||||
String getName();
|
||||
|
||||
File getFolder();
|
||||
|
||||
Iterable<PlatformPlayer> getPlayers();
|
||||
|
||||
Iterable<PlatformChunk> getLoadedChunks();
|
||||
|
||||
PlatformChunk getOrLoadChunk(int x, int z);
|
||||
|
||||
PlatformBlock getBlock(int x, int y, int z);
|
||||
|
||||
PlatformBiome getBiome(int x, int y, int z);
|
||||
|
||||
long getSeed();
|
||||
|
||||
boolean isChunkLoaded(int x, int z);
|
||||
|
||||
void setBlock(int x, int y, int z, PlatformBlock block);
|
||||
|
||||
void setBiome(int x, int y, int z, PlatformBiome biome);
|
||||
|
||||
default File getWorldFolder(String subfolder) {
|
||||
return new File(getFolder(), subfolder);
|
||||
}
|
||||
|
||||
default File getRegionFolder() {
|
||||
return getWorldFolder("region");
|
||||
}
|
||||
|
||||
default File getIrisFolder() {
|
||||
return getWorldFolder("iris");
|
||||
}
|
||||
|
||||
default File getIrisDataFolder() {
|
||||
File f = new File(getWorldFolder("iris"), "data");
|
||||
f.mkdirs();
|
||||
return f;
|
||||
}
|
||||
|
||||
default boolean isRegionLoaded(int x, int z) {
|
||||
for(PlatformChunk i : getLoadedChunks()) {
|
||||
if(i.getX() >> 5 == x && i.getZ() >> 5 == z) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
default void unloadChunks(boolean save, boolean force) {
|
||||
for(PlatformChunk i : getLoadedChunks()) {
|
||||
i.unload(save, force);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.volmit.iris.platform.block;
|
||||
|
||||
import com.volmit.iris.platform.PlatformNamespaced;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface PlatformBlock extends PlatformNamespaced {
|
||||
Map<String, String> getProperties();
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
public class FloatNoiseCache {
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final float[] cache;
|
||||
|
||||
public FloatNoiseCache(int width, int height)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
cache = new float[width * height];
|
||||
}
|
||||
|
||||
public void set(int x, int y, float v) {
|
||||
this.cache[y % this.height * this.width + x % this.width] = v;
|
||||
}
|
||||
|
||||
public float get(int x, int y) {
|
||||
return this.cache[y % this.height * this.width + x % this.width];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import art.arcane.source.NoisePlane;
|
||||
import art.arcane.spatial.hunk.Hunk;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class HunkedNoisePlane implements NoisePlane {
|
||||
private final Hunk<Double> noise;
|
||||
|
||||
@Override
|
||||
public double noise(double x, double y, double z) {
|
||||
Double d = noise.get(Math.floorMod((int)x, noise.getWidth()), Math.floorMod((int)y, noise.getHeight()), Math.floorMod((int)z, noise.getDepth()));
|
||||
|
||||
return d != null ? d : 0;
|
||||
}
|
||||
}
|
||||
32
engine/src/main/java/com/volmit/iris/util/NSK.java
Normal file
32
engine/src/main/java/com/volmit/iris/util/NSK.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import com.volmit.iris.platform.PlatformNamespaceKey;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class NSK implements PlatformNamespaceKey {
|
||||
private final String namespace;
|
||||
private final String key;
|
||||
|
||||
public NSK(String namespacedkey)
|
||||
{
|
||||
this(namespacedkey.contains(":") ? namespacedkey.split("\\Q:\\E")[0] : "minecraft",
|
||||
namespacedkey.contains(":") ? namespacedkey.split("\\Q:\\E")[1] : namespacedkey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNamespace() {
|
||||
return namespace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return namespace + ":" + key;
|
||||
}
|
||||
}
|
||||
23
engine/src/main/java/com/volmit/iris/util/NoiseCache.java
Normal file
23
engine/src/main/java/com/volmit/iris/util/NoiseCache.java
Normal file
@@ -0,0 +1,23 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
public class NoiseCache<T> {
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final Object[] cache;
|
||||
|
||||
public NoiseCache(int width, int height)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
cache = new Object[width * height];
|
||||
}
|
||||
|
||||
public void set(int x, int y, T v) {
|
||||
this.cache[y % this.height * this.width + x % this.width] = v;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public T get(int x, int y) {
|
||||
return (T) this.cache[y % this.height * this.width + x % this.width];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
public class ShortNoiseCache {
|
||||
private final int width;
|
||||
private final int height;
|
||||
private final short[] cache;
|
||||
|
||||
public ShortNoiseCache(int width, int height)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
cache = new short[width * height];
|
||||
}
|
||||
|
||||
public void set(int x, int y, short v) {
|
||||
this.cache[(Math.floorMod(y,this.height) * this.width) + Math.floorMod(x, this.width)] = v;
|
||||
}
|
||||
|
||||
public short get(int x, int y) {
|
||||
return this.cache[(Math.floorMod(y,this.height) * this.width) + Math.floorMod(x,this.width)];
|
||||
}
|
||||
}
|
||||
19
engine/src/main/java/com/volmit/iris/util/WorldHeight.java
Normal file
19
engine/src/main/java/com/volmit/iris/util/WorldHeight.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class WorldHeight {
|
||||
private final int minHeight;
|
||||
private final int maxHeight;
|
||||
|
||||
public WorldHeight(int maxHeight) {
|
||||
this(0, maxHeight);
|
||||
}
|
||||
|
||||
public int getTotalHeight() {
|
||||
return maxHeight - minHeight;
|
||||
}
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# Iris is a World Generator for Minecraft Bukkit Servers
|
||||
# Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
org.gradle.daemon=true
|
||||
org.gradle.parallel=true
|
||||
org.gradle.jvmargs=-Xmx3072m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
org.gradle.caching=true
|
||||
org.gradle.configureondemand=false
|
||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
178
gradlew.bat
vendored
178
gradlew.bat
vendored
@@ -1,89 +1,89 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
||||
10
listing.json
10
listing.json
@@ -1,10 +0,0 @@
|
||||
[
|
||||
"overworld IrisDimensions/overworld",
|
||||
"vanilla IrisDimensions/vanilla",
|
||||
"flat IrisDimensions/flat",
|
||||
"redstone IrisDimensions/redstone",
|
||||
"mars IrisDimensions/mars",
|
||||
"example IrisDimensions/example"
|
||||
"newhorizons IrisDimensions/newhorizons",
|
||||
"theend IrisDimensions/theend"
|
||||
]
|
||||
@@ -1,2 +0,0 @@
|
||||
# This file is generated by the 'io.freefair.lombok' Gradle plugin
|
||||
config.stopBubbling = true
|
||||
@@ -1,21 +0,0 @@
|
||||
name: ${name}
|
||||
version: ${version}
|
||||
main: ${main}
|
||||
load: STARTUP
|
||||
authors: [ cyberpwn, NextdoorPsycho ]
|
||||
website: volmit.com
|
||||
description: More than a Dimension!
|
||||
libraries:
|
||||
- org.zeroturnaround:zt-zip:1.14
|
||||
- com.googlecode.concurrentlinkedhashmap:concurrentlinkedhashmap-lru:1.4.2
|
||||
- org.ow2.asm:asm:9.2
|
||||
- com.google.code.gson:gson:2.8.7
|
||||
- it.unimi.dsi:fastutil:8.5.4
|
||||
- com.google.guava:guava:30.1.1-jre
|
||||
- bsf:bsf:2.4.0
|
||||
- rhino:js:1.7R2
|
||||
commands:
|
||||
iris:
|
||||
aliases: [ ir, irs ]
|
||||
api-version: ${apiversion}
|
||||
hotload-dependencies: false
|
||||
@@ -1,3 +0,0 @@
|
||||
.DS_Store
|
||||
*.code-workspace
|
||||
*.txt
|
||||
@@ -1,20 +1,3 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
pluginManagement {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
@@ -23,4 +6,9 @@ pluginManagement {
|
||||
maven { url "https://dl.cloudsmith.io/public/arcane/archive/maven/" }
|
||||
}
|
||||
}
|
||||
rootProject.name = 'Iris'
|
||||
|
||||
rootProject.name = 'Iris'
|
||||
include 'bukkit'
|
||||
include 'engine'
|
||||
include 'engine'
|
||||
|
||||
|
||||
@@ -1,729 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.volmit.iris.core.IrisSettings;
|
||||
import com.volmit.iris.core.ServerConfigurator;
|
||||
import com.volmit.iris.core.link.*;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.nms.INMS;
|
||||
import com.volmit.iris.core.service.StudioSVC;
|
||||
import com.volmit.iris.core.tools.IrisToolbelt;
|
||||
import com.volmit.iris.engine.EnginePanic;
|
||||
import com.volmit.iris.engine.object.IrisCompat;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.IrisWorld;
|
||||
import com.volmit.iris.engine.platform.BukkitChunkGenerator;
|
||||
import com.volmit.iris.engine.platform.DummyChunkGenerator;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.exceptions.IrisException;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.function.NastyRunnable;
|
||||
import com.volmit.iris.util.io.*;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.plugin.IrisService;
|
||||
import com.volmit.iris.util.plugin.Metrics;
|
||||
import com.volmit.iris.util.plugin.VolmitPlugin;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.reflect.ShadeFix;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.scheduling.Queue;
|
||||
import com.volmit.iris.util.scheduling.ShurikenQueue;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.generator.BiomeProvider;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.IllegalPluginAccessException;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@SuppressWarnings("CanBeFinal")
|
||||
public class Iris extends VolmitPlugin implements Listener {
|
||||
private static final Queue<Runnable> syncJobs = new ShurikenQueue<>();
|
||||
public static Iris instance;
|
||||
public static BukkitAudiences audiences;
|
||||
public static MultiverseCoreLink linkMultiverseCore;
|
||||
public static MythicMobsLink linkMythicMobs;
|
||||
public static IrisCompat compat;
|
||||
public static FileWatcher configWatcher;
|
||||
private static VolmitSender sender;
|
||||
|
||||
static {
|
||||
try {
|
||||
fixShading();
|
||||
InstanceState.updateInstanceId();
|
||||
} catch(Throwable ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private final KList<Runnable> postShutdown = new KList<>();
|
||||
private KMap<Class<? extends IrisService>, IrisService> services;
|
||||
|
||||
public static VolmitSender getSender() {
|
||||
return sender;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T service(Class<T> c) {
|
||||
return (T) instance.services.get(c);
|
||||
}
|
||||
|
||||
public static void callEvent(Event e) {
|
||||
if(!e.isAsynchronous()) {
|
||||
J.s(() -> Bukkit.getPluginManager().callEvent(e));
|
||||
} else {
|
||||
Bukkit.getPluginManager().callEvent(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static KList<Object> initialize(String s, Class<? extends Annotation> slicedClass) {
|
||||
JarScanner js = new JarScanner(instance.getJarFile(), s);
|
||||
KList<Object> v = new KList<>();
|
||||
J.attempt(js::scan);
|
||||
for(Class<?> i : js.getClasses()) {
|
||||
if(slicedClass == null || i.isAnnotationPresent(slicedClass)) {
|
||||
try {
|
||||
v.add(i.getDeclaredConstructor().newInstance());
|
||||
} catch(Throwable ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public static KList<Class<?>> getClasses(String s, Class<? extends Annotation> slicedClass) {
|
||||
JarScanner js = new JarScanner(instance.getJarFile(), s);
|
||||
KList<Class<?>> v = new KList<>();
|
||||
J.attempt(js::scan);
|
||||
for(Class<?> i : js.getClasses()) {
|
||||
if(slicedClass == null || i.isAnnotationPresent(slicedClass)) {
|
||||
try {
|
||||
v.add(i);
|
||||
} catch(Throwable ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
public static KList<Object> initialize(String s) {
|
||||
return initialize(s, null);
|
||||
}
|
||||
|
||||
public static void sq(Runnable r) {
|
||||
synchronized(syncJobs) {
|
||||
syncJobs.queue(r);
|
||||
}
|
||||
}
|
||||
|
||||
public static File getTemp() {
|
||||
return instance.getDataFolder("cache", "temp");
|
||||
}
|
||||
|
||||
public static void msg(String string) {
|
||||
try {
|
||||
sender.sendMessage(string);
|
||||
} catch(Throwable e) {
|
||||
try {
|
||||
System.out.println(instance.getTag() + string.replaceAll("(<([^>]+)>)", ""));
|
||||
} catch(Throwable ignored1) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
public static File getCached(String name, String url) {
|
||||
String h = IO.hash(name + "@" + url);
|
||||
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
|
||||
|
||||
if(!f.exists()) {
|
||||
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) {
|
||||
byte[] dataBuffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
Iris.verbose("Aquiring " + name);
|
||||
}
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
return f.exists() ? f : null;
|
||||
}
|
||||
|
||||
public static String getNonCached(String name, String url) {
|
||||
String h = IO.hash(name + "*" + url);
|
||||
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
|
||||
|
||||
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) {
|
||||
byte[] dataBuffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
}
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
|
||||
try {
|
||||
return IO.readAll(f);
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static File getNonCachedFile(String name, String url) {
|
||||
String h = IO.hash(name + "*" + url);
|
||||
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
|
||||
Iris.verbose("Download " + name + " -> " + url);
|
||||
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f)) {
|
||||
byte[] dataBuffer = new byte[1024];
|
||||
int bytesRead;
|
||||
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1) {
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
}
|
||||
|
||||
fileOutputStream.flush();
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
public static void warn(String format, Object... objs) {
|
||||
msg(C.YELLOW + String.format(format, objs));
|
||||
}
|
||||
|
||||
public static void error(String format, Object... objs) {
|
||||
msg(C.RED + String.format(format, objs));
|
||||
}
|
||||
|
||||
public static void debug(String string) {
|
||||
if(!IrisSettings.get().getGeneral().isDebug()) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
throw new RuntimeException();
|
||||
} catch(Throwable e) {
|
||||
try {
|
||||
String[] cc = e.getStackTrace()[1].getClassName().split("\\Q.\\E");
|
||||
|
||||
if(cc.length > 5) {
|
||||
debug(cc[3] + "/" + cc[4] + "/" + cc[cc.length - 1], e.getStackTrace()[1].getLineNumber(), string);
|
||||
} else {
|
||||
debug(cc[3] + "/" + cc[4], e.getStackTrace()[1].getLineNumber(), string);
|
||||
}
|
||||
} catch(Throwable ex) {
|
||||
debug("Origin", -1, string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void debug(String category, int line, String string) {
|
||||
if(!IrisSettings.get().getGeneral().isDebug()) {
|
||||
return;
|
||||
}
|
||||
if(IrisSettings.get().getGeneral().isUseConsoleCustomColors()) {
|
||||
msg("<gradient:#095fe0:#a848db>" + category + " <#bf3b76>" + line + "<reset> " + C.LIGHT_PURPLE + string.replaceAll("\\Q<\\E", "[").replaceAll("\\Q>\\E", "]"));
|
||||
} else {
|
||||
msg(C.BLUE + category + ":" + C.AQUA + line + C.RESET + C.LIGHT_PURPLE + " " + string.replaceAll("\\Q<\\E", "[").replaceAll("\\Q>\\E", "]"));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void verbose(String string) {
|
||||
debug(string);
|
||||
}
|
||||
|
||||
public static void success(String string) {
|
||||
msg(C.IRIS + string);
|
||||
}
|
||||
|
||||
public static void info(String string) {
|
||||
msg(C.WHITE + string);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void later(NastyRunnable object) {
|
||||
try {
|
||||
Bukkit.getScheduler().scheduleAsyncDelayedTask(instance, () ->
|
||||
{
|
||||
try {
|
||||
object.run();
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}, RNG.r.i(100, 1200));
|
||||
} catch(IllegalPluginAccessException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static int jobCount() {
|
||||
return syncJobs.size();
|
||||
}
|
||||
|
||||
public static void clearQueues() {
|
||||
synchronized(syncJobs) {
|
||||
syncJobs.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private static int getJavaVersion() {
|
||||
String version = System.getProperty("java.version");
|
||||
if(version.startsWith("1.")) {
|
||||
version = version.substring(2, 3);
|
||||
} else {
|
||||
int dot = version.indexOf(".");
|
||||
if(dot != -1) {
|
||||
version = version.substring(0, dot);
|
||||
}
|
||||
}
|
||||
return Integer.parseInt(version);
|
||||
}
|
||||
|
||||
public static void reportErrorChunk(int x, int z, Throwable e, String extra) {
|
||||
if(IrisSettings.get().getGeneral().isDebug()) {
|
||||
File f = instance.getDataFile("debug", "chunk-errors", "chunk." + x + "." + z + ".txt");
|
||||
|
||||
if(!f.exists()) {
|
||||
J.attempt(() -> {
|
||||
PrintWriter pw = new PrintWriter(f);
|
||||
pw.println("Thread: " + Thread.currentThread().getName());
|
||||
pw.println("First: " + new Date(M.ms()));
|
||||
e.printStackTrace(pw);
|
||||
pw.close();
|
||||
});
|
||||
}
|
||||
|
||||
Iris.debug("Chunk " + x + "," + z + " Exception Logged: " + e.getClass().getSimpleName() + ": " + C.RESET + "" + C.LIGHT_PURPLE + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public static void reportError(Throwable e) {
|
||||
if(IrisSettings.get().getGeneral().isDebug()) {
|
||||
String n = e.getClass().getCanonicalName() + "-" + e.getStackTrace()[0].getClassName() + "-" + e.getStackTrace()[0].getLineNumber();
|
||||
|
||||
if(e.getCause() != null) {
|
||||
n += "-" + e.getCause().getStackTrace()[0].getClassName() + "-" + e.getCause().getStackTrace()[0].getLineNumber();
|
||||
}
|
||||
|
||||
File f = instance.getDataFile("debug", "caught-exceptions", n + ".txt");
|
||||
|
||||
if(!f.exists()) {
|
||||
J.attempt(() -> {
|
||||
PrintWriter pw = new PrintWriter(f);
|
||||
pw.println("Thread: " + Thread.currentThread().getName());
|
||||
pw.println("First: " + new Date(M.ms()));
|
||||
e.printStackTrace(pw);
|
||||
pw.close();
|
||||
});
|
||||
}
|
||||
|
||||
Iris.debug("Exception Logged: " + e.getClass().getSimpleName() + ": " + C.RESET + "" + C.LIGHT_PURPLE + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void enable() {
|
||||
instance = this;
|
||||
services = new KMap<>();
|
||||
initialize("com.volmit.iris.core.service").forEach((i) -> services.put((Class<? extends IrisService>) i.getClass(), (IrisService) i));
|
||||
INMS.get();
|
||||
IO.delete(new File("iris"));
|
||||
setupAudience();
|
||||
sender = new VolmitSender(Bukkit.getConsoleSender());
|
||||
sender.setTag(getTag());
|
||||
instance = this;
|
||||
compat = IrisCompat.configured(getDataFile("compat.json"));
|
||||
linkMultiverseCore = new MultiverseCoreLink();
|
||||
linkMythicMobs = new MythicMobsLink();
|
||||
configWatcher = new FileWatcher(getDataFile("settings.json"));
|
||||
services.values().forEach(IrisService::onEnable);
|
||||
services.values().forEach(this::registerListener);
|
||||
J.s(() -> {
|
||||
J.a(() -> PaperLib.suggestPaper(this));
|
||||
J.a(() -> IO.delete(getTemp()));
|
||||
J.a(this::bstats);
|
||||
J.ar(this::checkConfigHotload, 60);
|
||||
J.sr(this::tickQueue, 0);
|
||||
J.s(this::setupPapi);
|
||||
J.a(ServerConfigurator::configure, 20);
|
||||
splash();
|
||||
autoStartStudio();
|
||||
checkForBukkitWorlds();
|
||||
IrisToolbelt.retainMantleDataForSlice(String.class.getCanonicalName());
|
||||
IrisToolbelt.retainMantleDataForSlice(BlockData.class.getCanonicalName());
|
||||
});
|
||||
}
|
||||
|
||||
private void checkForBukkitWorlds() {
|
||||
FileConfiguration fc = new YamlConfiguration();
|
||||
try {
|
||||
fc.load(new File("bukkit.yml"));
|
||||
searching: for(String i : fc.getKeys(true))
|
||||
{
|
||||
if(i.startsWith("worlds.") && i.endsWith(".generator")) {
|
||||
String worldName = i.split("\\Q.\\E")[1];
|
||||
String generator = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||
if(fc.getString(i).startsWith("Iris:")) {
|
||||
generator = fc.getString(i).split("\\Q:\\E")[1];
|
||||
} else if(fc.getString(i).equals("Iris")) {
|
||||
generator = IrisSettings.get().getGenerator().getDefaultWorldType();
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
|
||||
for(World j : Bukkit.getWorlds())
|
||||
{
|
||||
if(j.getName().equals(worldName))
|
||||
{
|
||||
continue searching;
|
||||
}
|
||||
}
|
||||
|
||||
Iris.warn("Detected an Iris World in the bukkit yml '" + worldName + "' using Iris that was not loaded by bukkit. Good Guy Iris will load it up for you!");
|
||||
Iris.info(C.LIGHT_PURPLE + "Preparing Spawn for " + worldName + "' using Iris:" + generator);
|
||||
World world = new WorldCreator(worldName)
|
||||
.generator(getDefaultWorldGenerator(worldName, generator))
|
||||
.environment(IrisData.loadAnyDimension(generator).getEnvironment())
|
||||
.createWorld();
|
||||
Iris.info(C.LIGHT_PURPLE + "Loaded " + worldName + "!");
|
||||
}
|
||||
}
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void autoStartStudio() {
|
||||
if(IrisSettings.get().getStudio().isAutoStartDefaultStudio()) {
|
||||
Iris.info("Starting up auto Studio!");
|
||||
try {
|
||||
Player r = new KList<>(getServer().getOnlinePlayers()).getRandom();
|
||||
Iris.service(StudioSVC.class).open(r != null ? new VolmitSender(r) : sender, 1337, IrisSettings.get().getGenerator().getDefaultWorldType(), (w) -> {
|
||||
J.s(() -> {
|
||||
for(Player i : getServer().getOnlinePlayers()) {
|
||||
i.setGameMode(GameMode.SPECTATOR);
|
||||
i.teleport(new Location(w, 0, 200, 0));
|
||||
}
|
||||
});
|
||||
});
|
||||
} catch(IrisException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setupAudience() {
|
||||
try {
|
||||
audiences = BukkitAudiences.create(this);
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
IrisSettings.get().getGeneral().setUseConsoleCustomColors(false);
|
||||
IrisSettings.get().getGeneral().setUseCustomColorsIngame(false);
|
||||
Iris.error("Failed to setup Adventure API... No custom colors :(");
|
||||
}
|
||||
}
|
||||
|
||||
public static void dump() {
|
||||
try {
|
||||
File fi = Iris.instance.getDataFile("dump", "td-" + new java.sql.Date(M.ms()) + ".txt");
|
||||
FileOutputStream fos = new FileOutputStream(fi);
|
||||
Map<Thread, StackTraceElement[]> f = Thread.getAllStackTraces();
|
||||
PrintWriter pw = new PrintWriter(fos);
|
||||
for(Thread i : f.keySet()) {
|
||||
pw.println("========================================");
|
||||
pw.println("Thread: '" + i.getName() + "' ID: " + i.getId() + " STATUS: " + i.getState().name());
|
||||
|
||||
for(StackTraceElement j : f.get(i)) {
|
||||
pw.println(" @ " + j.toString());
|
||||
}
|
||||
|
||||
pw.println("========================================");
|
||||
pw.println();
|
||||
pw.println();
|
||||
}
|
||||
|
||||
pw.close();
|
||||
System.out.println("DUMPED! See " + fi.getAbsolutePath());
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void postShutdown(Runnable r) {
|
||||
postShutdown.add(r);
|
||||
}
|
||||
|
||||
public static void panic() {
|
||||
EnginePanic.panic();
|
||||
}
|
||||
|
||||
public static void addPanic(String s, String v) {
|
||||
EnginePanic.add(s, v);
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
enable();
|
||||
super.onEnable();
|
||||
Bukkit.getPluginManager().registerEvents(this, this);
|
||||
}
|
||||
|
||||
public void onDisable() {
|
||||
services.values().forEach(IrisService::onDisable);
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
HandlerList.unregisterAll((Plugin) this);
|
||||
postShutdown.forEach(Runnable::run);
|
||||
services.clear();
|
||||
MultiBurst.burst.close();
|
||||
super.onDisable();
|
||||
}
|
||||
|
||||
private static void fixShading() {
|
||||
ShadeFix.fix(ComponentSerializer.class);
|
||||
}
|
||||
|
||||
private void setupPapi() {
|
||||
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||
new IrisPapiExpansion().register();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag(String subTag) {
|
||||
return C.BOLD + "" + C.DARK_GRAY + "[" + C.BOLD + "" + C.IRIS + "Iris" + C.BOLD + C.DARK_GRAY + "]" + C.RESET + "" + C.GRAY + ": ";
|
||||
}
|
||||
|
||||
private void checkConfigHotload() {
|
||||
if(configWatcher.checkModified()) {
|
||||
IrisSettings.invalidate();
|
||||
IrisSettings.get();
|
||||
configWatcher.checkModified();
|
||||
Iris.info("Hotloaded settings.json ");
|
||||
}
|
||||
}
|
||||
|
||||
private void tickQueue() {
|
||||
synchronized(Iris.syncJobs) {
|
||||
if(!Iris.syncJobs.hasNext()) {
|
||||
return;
|
||||
}
|
||||
|
||||
long ms = M.ms();
|
||||
|
||||
while(Iris.syncJobs.hasNext() && M.ms() - ms < 25) {
|
||||
try {
|
||||
Iris.syncJobs.next().run();
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void bstats() {
|
||||
if(IrisSettings.get().getGeneral().isPluginMetrics()) {
|
||||
J.s(() -> new Metrics(Iris.instance, 8757));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
return super.onCommand(sender, command, label, args);
|
||||
}
|
||||
|
||||
public void imsg(CommandSender s, String msg) {
|
||||
s.sendMessage(C.IRIS + "[" + C.DARK_GRAY + "Iris" + C.IRIS + "]" + C.GRAY + ": " + msg);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BiomeProvider getDefaultBiomeProvider(@NotNull String worldName, @Nullable String id) {
|
||||
Iris.debug("Biome Provider Called for " + worldName + " using ID: " + id);
|
||||
return super.getDefaultBiomeProvider(worldName, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
|
||||
Iris.debug("Default World Generator Called for " + worldName + " using ID: " + id);
|
||||
if(worldName.equals("test")) {
|
||||
try {
|
||||
throw new RuntimeException();
|
||||
} catch(Throwable e) {
|
||||
Iris.info(e.getStackTrace()[1].getClassName());
|
||||
if(e.getStackTrace()[1].getClassName().contains("com.onarandombox.MultiverseCore")) {
|
||||
Iris.debug("MVC Test detected, Quick! Send them the dummy!");
|
||||
return new DummyChunkGenerator();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IrisDimension dim;
|
||||
if(id == null || id.isEmpty()) {
|
||||
dim = IrisData.loadAnyDimension(IrisSettings.get().getGenerator().getDefaultWorldType());
|
||||
} else {
|
||||
dim = IrisData.loadAnyDimension(id);
|
||||
}
|
||||
Iris.debug("Generator ID: " + id + " requested by bukkit/plugin");
|
||||
|
||||
if(dim == null) {
|
||||
Iris.warn("Unable to find dimension type " + id + " Looking for online packs...");
|
||||
|
||||
service(StudioSVC.class).downloadSearch(new VolmitSender(Bukkit.getConsoleSender()), id, true);
|
||||
dim = IrisData.loadAnyDimension(id);
|
||||
|
||||
if(dim == null) {
|
||||
throw new RuntimeException("Can't find dimension " + id + "!");
|
||||
} else {
|
||||
Iris.info("Resolved missing dimension, proceeding with generation.");
|
||||
}
|
||||
}
|
||||
|
||||
Iris.debug("Assuming IrisDimension: " + dim.getName());
|
||||
|
||||
IrisWorld w = IrisWorld.builder()
|
||||
.name(worldName)
|
||||
.seed(1337)
|
||||
.environment(dim.getEnvironment())
|
||||
.worldFolder(new File(worldName))
|
||||
.minHeight(dim.getMinHeight())
|
||||
.maxHeight(dim.getMaxHeight())
|
||||
.build();
|
||||
|
||||
Iris.debug("Generator Config: " + w.toString());
|
||||
|
||||
File ff = new File(w.worldFolder(), "iris/pack");
|
||||
if(!ff.exists() || ff.listFiles().length == 0) {
|
||||
ff.mkdirs();
|
||||
service(StudioSVC.class).installIntoWorld(sender, dim.getLoadKey(), ff.getParentFile());
|
||||
}
|
||||
|
||||
return new BukkitChunkGenerator(w, false, ff, dim.getLoadKey());
|
||||
}
|
||||
|
||||
public void splash() {
|
||||
if(!IrisSettings.get().getGeneral().isSplashLogoStartup()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// @NoArgsConstructor
|
||||
String padd = Form.repeat(" ", 8);
|
||||
String padd2 = Form.repeat(" ", 4);
|
||||
String[] info = {"", "", "", "", "", padd2 + C.IRIS + " Iris", padd2 + C.GRAY + " by " + "<rainbow>Volmit Software", padd2 + C.GRAY + " v" + C.IRIS + getDescription().getVersion(),
|
||||
};
|
||||
String[] splash = {
|
||||
padd + C.GRAY + " @@@@@@@@@@@@@@" + C.DARK_GRAY + "@@@",
|
||||
padd + C.GRAY + " @@&&&&&&&&&" + C.DARK_GRAY + "&&&&&&" + C.IRIS + " .(((()))). ",
|
||||
padd + C.GRAY + "@@@&&&&&&&&" + C.DARK_GRAY + "&&&&&" + C.IRIS + " .((((((())))))). ",
|
||||
padd + C.GRAY + "@@@&&&&&" + C.DARK_GRAY + "&&&&&&&" + C.IRIS + " ((((((((())))))))) " + C.GRAY + " @",
|
||||
padd + C.GRAY + "@@@&&&&" + C.DARK_GRAY + "@@@@@&" + C.IRIS + " ((((((((-))))))))) " + C.GRAY + " @@",
|
||||
padd + C.GRAY + "@@@&&" + C.IRIS + " ((((((({ })))))))) " + C.GRAY + " &&@@@",
|
||||
padd + C.GRAY + "@@" + C.IRIS + " ((((((((-))))))))) " + C.DARK_GRAY + "&@@@@@" + C.GRAY + "&&&&@@@",
|
||||
padd + C.GRAY + "@" + C.IRIS + " ((((((((())))))))) " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&@@@",
|
||||
padd + C.GRAY + "" + C.IRIS + " '((((((()))))))' " + C.DARK_GRAY + "&&&&&" + C.GRAY + "&&&&&&&&@@@",
|
||||
padd + C.GRAY + "" + C.IRIS + " '(((())))' " + C.DARK_GRAY + "&&&&&&&&" + C.GRAY + "&&&&&&&@@",
|
||||
padd + C.GRAY + " " + C.DARK_GRAY + "@@@" + C.GRAY + "@@@@@@@@@@@@@@"
|
||||
};
|
||||
//@done
|
||||
Iris.info("Server type & version: " + Bukkit.getVersion());
|
||||
Iris.info("Bukkit version: " + Bukkit.getBukkitVersion());
|
||||
Iris.info("Java version: " + getJavaVersion());
|
||||
Iris.info("Custom Biomes: " + INMS.get().countCustomBiomes());
|
||||
printPacks();
|
||||
|
||||
for(int i = 0; i < info.length; i++) {
|
||||
splash[i] += info[i];
|
||||
}
|
||||
|
||||
Iris.info("\n\n " + new KList<>(splash).toString("\n") + "\n");
|
||||
}
|
||||
|
||||
private void printPacks() {
|
||||
File packFolder = Iris.service(StudioSVC.class).getWorkspaceFolder();
|
||||
File[] packs = packFolder.listFiles(File::isDirectory);
|
||||
if(packs == null || packs.length == 0)
|
||||
return;
|
||||
Iris.info("Custom Dimensions: " + packs.length);
|
||||
for(File f : packs)
|
||||
printPack(f);
|
||||
}
|
||||
|
||||
private void printPack(File pack) {
|
||||
String dimName = pack.getName();
|
||||
String version = "???";
|
||||
try(FileReader r = new FileReader(new File(pack, "dimensions/" + dimName + ".json"))) {
|
||||
JsonObject json = JsonParser.parseReader(r).getAsJsonObject();
|
||||
if(json.has("version"))
|
||||
version = json.get("version").getAsString();
|
||||
} catch(IOException | JsonParseException ignored) { }
|
||||
Iris.info(" " + dimName + " v" + version);
|
||||
}
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.core;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.json.JSONException;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings("SynchronizeOnNonFinalField")
|
||||
@Data
|
||||
public class IrisSettings {
|
||||
public static IrisSettings settings;
|
||||
private IrisSettingsGeneral general = new IrisSettingsGeneral();
|
||||
private IrisSettingsWorld world = new IrisSettingsWorld();
|
||||
private IrisSettingsGUI gui = new IrisSettingsGUI();
|
||||
private IrisSettingsAutoconfiguration autoConfiguration = new IrisSettingsAutoconfiguration();
|
||||
private IrisSettingsGenerator generator = new IrisSettingsGenerator();
|
||||
private IrisSettingsConcurrency concurrency = new IrisSettingsConcurrency();
|
||||
private IrisSettingsStudio studio = new IrisSettingsStudio();
|
||||
private IrisSettingsPerformance performance = new IrisSettingsPerformance();
|
||||
|
||||
public static int getThreadCount(int c) {
|
||||
return switch(c) {
|
||||
case -1, -2, -4 -> Runtime.getRuntime().availableProcessors() / -c;
|
||||
case 0, 1, 2 -> 1;
|
||||
default -> Math.max(c, 2);
|
||||
};
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsAutoconfiguration {
|
||||
public boolean configureSpigotTimeoutTime = true;
|
||||
public boolean configurePaperWatchdogDelay = true;
|
||||
public boolean autoRestartOnCustomBiomeInstall = true;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisAsyncTeleport {
|
||||
public boolean enabled = false;
|
||||
public int loadViewDistance = 2;
|
||||
public boolean urgent = false;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsWorld {
|
||||
public IrisAsyncTeleport asyncTeleport = new IrisAsyncTeleport();
|
||||
public boolean postLoadBlockUpdates = true;
|
||||
public boolean forcePersistEntities = true;
|
||||
public boolean anbientEntitySpawningSystem = true;
|
||||
public long asyncTickIntervalMS = 700;
|
||||
public double targetSpawnEntitiesPerChunk = 0.95;
|
||||
public boolean markerEntitySpawningSystem = true;
|
||||
public boolean effectSystem = true;
|
||||
public boolean worldEditWandCUI = true;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsConcurrency {
|
||||
public int parallelism = -1;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsPerformance {
|
||||
public boolean trimMantleInStudio = false;
|
||||
public int mantleKeepAlive = 30;
|
||||
public int cacheSize = 4_096;
|
||||
public int resourceLoaderCacheSize = 1_024;
|
||||
public int objectLoaderCacheSize = 4_096;
|
||||
public int scriptLoaderCacheSize = 512;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsGeneral {
|
||||
public boolean commandSounds = true;
|
||||
public boolean debug = false;
|
||||
public boolean disableNMS = false;
|
||||
public boolean pluginMetrics = true;
|
||||
public boolean splashLogoStartup = true;
|
||||
public boolean useConsoleCustomColors = true;
|
||||
public boolean useCustomColorsIngame = true;
|
||||
public String forceMainWorld = "";
|
||||
public int spinh = -20;
|
||||
public int spins = 7;
|
||||
public int spinb = 8;
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public boolean canUseCustomColors(VolmitSender volmitSender) {
|
||||
return volmitSender.isPlayer() ? useCustomColorsIngame : useConsoleCustomColors;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsGUI {
|
||||
public boolean useServerLaunchedGuis = true;
|
||||
public boolean maximumPregenGuiFPS = false;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsGenerator {
|
||||
public String defaultWorldType = "overworld";
|
||||
public int maxBiomeChildDepth = 4;
|
||||
public boolean preventLeafDecay = true;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class IrisSettingsStudio {
|
||||
public boolean studio = true;
|
||||
public boolean openVSCode = true;
|
||||
public boolean disableTimeAndWeather = true;
|
||||
public boolean autoStartDefaultStudio = false;
|
||||
}
|
||||
|
||||
public static IrisSettings get() {
|
||||
if(settings != null) {
|
||||
return settings;
|
||||
}
|
||||
|
||||
settings = new IrisSettings();
|
||||
|
||||
File s = Iris.instance.getDataFile("settings.json");
|
||||
|
||||
if(!s.exists()) {
|
||||
try {
|
||||
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
|
||||
} catch(JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
String ss = IO.readAll(s);
|
||||
settings = new Gson().fromJson(ss, IrisSettings.class);
|
||||
try {
|
||||
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch(Throwable ee) {
|
||||
// Iris.reportError(ee); causes a self-reference & stackoverflow
|
||||
Iris.error("Configuration Error in settings.json! " + ee.getClass().getSimpleName() + ": " + ee.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
public static void invalidate() {
|
||||
synchronized(settings) {
|
||||
settings = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void forceSave() {
|
||||
File s = Iris.instance.getDataFile("settings.json");
|
||||
|
||||
try {
|
||||
IO.writeAll(s, new JSONObject(new Gson().toJson(settings)).toString(4));
|
||||
} catch(JSONException | IOException e) {
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.core;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.nms.INMS;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisBiomeCustom;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.format.C;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ServerConfigurator {
|
||||
public static void configure() {
|
||||
IrisSettings.IrisSettingsAutoconfiguration s = IrisSettings.get().getAutoConfiguration();
|
||||
if(s.isConfigureSpigotTimeoutTime()) {
|
||||
J.attempt(ServerConfigurator::increaseKeepAliveSpigot);
|
||||
}
|
||||
|
||||
if(s.isConfigurePaperWatchdogDelay()) {
|
||||
J.attempt(ServerConfigurator::increasePaperWatchdog);
|
||||
}
|
||||
|
||||
installDataPacks(true);
|
||||
}
|
||||
|
||||
private static void increaseKeepAliveSpigot() throws IOException, InvalidConfigurationException {
|
||||
File spigotConfig = new File("config/spigot.yml");
|
||||
FileConfiguration f = new YamlConfiguration();
|
||||
f.load(spigotConfig);
|
||||
long tt = f.getLong("settings.timeout-time");
|
||||
|
||||
if(tt < TimeUnit.MINUTES.toSeconds(5)) {
|
||||
Iris.warn("Updating spigot.yml timeout-time: " + tt + " -> " + TimeUnit.MINUTES.toSeconds(5) + " (5 minutes)");
|
||||
Iris.warn("You can disable this change (autoconfigureServer) in Iris settings, then change back the value.");
|
||||
f.set("settings.timeout-time", TimeUnit.MINUTES.toSeconds(5));
|
||||
f.save(spigotConfig);
|
||||
}
|
||||
}
|
||||
|
||||
private static void increasePaperWatchdog() throws IOException, InvalidConfigurationException {
|
||||
File spigotConfig = new File("config/paper-global.yml");
|
||||
FileConfiguration f = new YamlConfiguration();
|
||||
f.load(spigotConfig);
|
||||
long tt = f.getLong("watchdog.early-warning-delay");
|
||||
|
||||
if(tt < TimeUnit.MINUTES.toMillis(3)) {
|
||||
Iris.warn("Updating paper.yml watchdog early-warning-delay: " + tt + " -> " + TimeUnit.MINUTES.toMillis(3) + " (3 minutes)");
|
||||
Iris.warn("You can disable this change (autoconfigureServer) in Iris settings, then change back the value.");
|
||||
f.set("watchdog.early-warning-delay", TimeUnit.MINUTES.toMillis(3));
|
||||
f.save(spigotConfig);
|
||||
}
|
||||
}
|
||||
|
||||
private static File getDatapacksFolder() {
|
||||
if(!IrisSettings.get().getGeneral().forceMainWorld.isEmpty()) {
|
||||
return new File(IrisSettings.get().getGeneral().forceMainWorld + "/datapacks");
|
||||
}
|
||||
|
||||
File props = new File("server.properties");
|
||||
|
||||
if(props.exists()) {
|
||||
try {
|
||||
KList<String> m = new KList<>(IO.readAll(props).split("\\Q\n\\E"));
|
||||
|
||||
for(String i : m) {
|
||||
if(i.trim().startsWith("level-name=")) {
|
||||
return new File(i.trim().split("\\Q=\\E")[1] + "/datapacks");
|
||||
}
|
||||
}
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void installDataPacks(boolean fullInstall) {
|
||||
Iris.info("Checking Data Packs...");
|
||||
boolean reboot = false;
|
||||
File packs = new File("plugins/Iris/packs");
|
||||
File dpacks = getDatapacksFolder();
|
||||
|
||||
if(dpacks == null) {
|
||||
Iris.error("Cannot find the datapacks folder! Please try generating a default world first maybe? Is this a new server?");
|
||||
return;
|
||||
}
|
||||
|
||||
if(packs.exists()) {
|
||||
for(File i : packs.listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
Iris.verbose("Checking Pack: " + i.getPath());
|
||||
IrisData data = IrisData.get(i);
|
||||
File dims = new File(i, "dimensions");
|
||||
|
||||
if(dims.exists()) {
|
||||
for(File j : dims.listFiles()) {
|
||||
if(j.getName().endsWith(".json")) {
|
||||
IrisDimension dim = data.getDimensionLoader().load(j.getName().split("\\Q.\\E")[0]);
|
||||
|
||||
if(dim == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Iris.verbose(" Checking Dimension " + dim.getLoadFile().getPath());
|
||||
if(dim.installDataPack(() -> data, dpacks)) {
|
||||
reboot = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iris.info("Data Packs Setup!");
|
||||
|
||||
if(fullInstall) {
|
||||
verifyDataPacksPost(IrisSettings.get().getAutoConfiguration().isAutoRestartOnCustomBiomeInstall());
|
||||
}
|
||||
}
|
||||
|
||||
private static void verifyDataPacksPost(boolean allowRestarting) {
|
||||
File packs = new File("plugins/Iris/packs");
|
||||
File dpacks = getDatapacksFolder();
|
||||
|
||||
if(dpacks == null) {
|
||||
Iris.error("Cannot find the datapacks folder! Please try generating a default world first maybe? Is this a new server?");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean bad = false;
|
||||
if(packs.exists()) {
|
||||
for(File i : packs.listFiles()) {
|
||||
if(i.isDirectory()) {
|
||||
Iris.verbose("Checking Pack: " + i.getPath());
|
||||
IrisData data = IrisData.get(i);
|
||||
File dims = new File(i, "dimensions");
|
||||
|
||||
if(dims.exists()) {
|
||||
for(File j : dims.listFiles()) {
|
||||
if(j.getName().endsWith(".json")) {
|
||||
IrisDimension dim = data.getDimensionLoader().load(j.getName().split("\\Q.\\E")[0]);
|
||||
|
||||
if(dim == null) {
|
||||
Iris.error("Failed to load " + j.getPath() + " ");
|
||||
continue;
|
||||
}
|
||||
|
||||
if(!verifyDataPackInstalled(dim)) {
|
||||
bad = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(bad) {
|
||||
if(allowRestarting) {
|
||||
restart();
|
||||
} else if(INMS.get().supportsDataPacks()) {
|
||||
Iris.error("============================================================================");
|
||||
Iris.error(C.ITALIC + "You need to restart your server to properly generate custom biomes.");
|
||||
Iris.error(C.ITALIC + "By continuing, Iris will use backup biomes in place of the custom biomes.");
|
||||
Iris.error("----------------------------------------------------------------------------");
|
||||
Iris.error(C.UNDERLINE + "IT IS HIGHLY RECOMMENDED YOU RESTART THE SERVER BEFORE GENERATING!");
|
||||
Iris.error("============================================================================");
|
||||
|
||||
for(Player i : Bukkit.getOnlinePlayers()) {
|
||||
if(i.isOp() || i.hasPermission("iris.all")) {
|
||||
VolmitSender sender = new VolmitSender(i, Iris.instance.getTag("WARNING"));
|
||||
sender.sendMessage("There are some Iris Packs that have custom biomes in them");
|
||||
sender.sendMessage("You need to restart your server to use these packs.");
|
||||
}
|
||||
}
|
||||
|
||||
J.sleep(3000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void restart() {
|
||||
J.s(() -> {
|
||||
Iris.warn("New data pack entries have been installed in Iris! Restarting server!");
|
||||
Iris.warn("This will only happen when your pack changes (updates/first time setup)");
|
||||
Iris.warn("(You can disable this auto restart in iris settings)");
|
||||
J.s(() -> {
|
||||
Iris.warn("Looks like the restart command diddn't work. Stopping the server instead!");
|
||||
Bukkit.shutdown();
|
||||
}, 100);
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "restart");
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean verifyDataPackInstalled(IrisDimension dimension) {
|
||||
IrisData idm = IrisData.get(Iris.instance.getDataFolder("packs", dimension.getLoadKey()));
|
||||
KSet<String> keys = new KSet<>();
|
||||
boolean warn = false;
|
||||
|
||||
for(IrisBiome i : dimension.getAllBiomes(() -> idm)) {
|
||||
if(i.isCustom()) {
|
||||
for(IrisBiomeCustom j : i.getCustomDerivitives()) {
|
||||
keys.add(dimension.getLoadKey() + ":" + j.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!INMS.get().supportsDataPacks()) {
|
||||
if(!keys.isEmpty()) {
|
||||
Iris.warn("===================================================================================");
|
||||
Iris.warn("Pack " + dimension.getLoadKey() + " has " + keys.size() + " custom biome(s). ");
|
||||
Iris.warn("Your server version does not yet support datapacks for iris.");
|
||||
Iris.warn("The world will generate these biomes as backup biomes.");
|
||||
Iris.warn("====================================================================================");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
for(String i : keys) {
|
||||
Object o = INMS.get().getCustomBiomeBaseFor(i);
|
||||
|
||||
if(o == null) {
|
||||
Iris.warn("The Biome " + i + " is not registered on the server.");
|
||||
warn = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(warn) {
|
||||
Iris.error("The Pack " + dimension.getLoadKey() + " is INCAPABLE of generating custom biomes");
|
||||
Iris.error("If not done automatically, restart your server before generating with this pack!");
|
||||
}
|
||||
|
||||
return !warn;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user