Import the original MinecartTrains Paper plugin sources.
EOF Co-authored-by: Cursor <cursoragent@cursor.com>
@@ -0,0 +1,2 @@
1
# Auto detect text files and perform LF normalization
2
* text=auto
@@ -0,0 +1,2 @@1
# Auto detect text files and perform LF normalization2
* text=auto@@ -0,0 +1,113 @@
1
# User-specific stuff
2
.idea/
3
4
*.iml
5
*.ipr
6
*.iws
7
8
# IntelliJ
9
out/
10
11
# Compiled class file
12
*.class
13
14
# Log file
15
*.log
16
17
# BlueJ files
18
*.ctxt
19
20
# Package Files #
21
*.jar
22
*.war
23
*.nar
24
*.ear
25
*.zip
26
*.tar.gz
27
*.rar
28
29
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
30
hs_err_pid*
31
32
*~
33
34
# temporary files which can be created if a process still has a handle open of a deleted file
35
.fuse_hidden*
36
37
# KDE directory preferences
38
.directory
39
40
# Linux trash folder which might appear on any partition or disk
41
.Trash-*
42
43
# .nfs files are created when an open file is removed but is still being accessed
44
.nfs*
45
46
# General
47
.DS_Store
48
.AppleDouble
49
.LSOverride
50
51
# Icon must end with two \r
52
Icon
53
54
# Thumbnails
55
._*
56
57
# Files that might appear in the root of a volume
58
.DocumentRevisions-V100
59
.fseventsd
60
.Spotlight-V100
61
.TemporaryItems
62
.Trashes
63
.VolumeIcon.icns
64
.com.apple.timemachine.donotpresent
65
66
# Directories potentially created on remote AFP share
67
.AppleDB
68
.AppleDesktop
69
Network Trash Folder
70
Temporary Items
71
.apdisk
72
73
# Windows thumbnail cache files
74
Thumbs.db
75
Thumbs.db:encryptable
76
ehthumbs.db
77
ehthumbs_vista.db
78
79
# Dump file
80
*.stackdump
81
82
# Folder config file
83
[Dd]esktop.ini
84
85
# Recycle Bin used on file shares
86
$RECYCLE.BIN/
87
88
# Windows Installer files
89
*.cab
90
*.msi
91
*.msix
92
*.msm
93
*.msp
94
95
# Windows shortcuts
96
*.lnk
97
98
target/
99
100
pom.xml.tag
101
pom.xml.releaseBackup
102
pom.xml.versionsBackup
103
pom.xml.next
104
105
release.properties
106
dependency-reduced-pom.xml
107
buildNumber.properties
108
.mvn/timing.properties
109
.mvn/wrapper/maven-wrapper.jar
110
.flattened-pom.xml
111
112
# Common working directory
113
run/
@@ -0,0 +1,113 @@1
# User-specific stuff2
.idea/3
4
*.iml5
*.ipr6
*.iws7
8
# IntelliJ9
out/10
11
# Compiled class file12
*.class13
14
# Log file15
*.log16
17
# BlueJ files18
*.ctxt19
20
# Package Files #21
*.jar22
*.war23
*.nar24
*.ear25
*.zip26
*.tar.gz27
*.rar28
29
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml30
hs_err_pid*31
32
*~33
34
# temporary files which can be created if a process still has a handle open of a deleted file35
.fuse_hidden*36
37
# KDE directory preferences38
.directory39
40
# Linux trash folder which might appear on any partition or disk41
.Trash-*42
43
# .nfs files are created when an open file is removed but is still being accessed44
.nfs*45
46
# General47
.DS_Store48
.AppleDouble49
.LSOverride50
51
# Icon must end with two \r52
Icon53
54
# Thumbnails55
._*56
57
# Files that might appear in the root of a volume58
.DocumentRevisions-V10059
.fseventsd60
.Spotlight-V10061
.TemporaryItems62
.Trashes63
.VolumeIcon.icns64
.com.apple.timemachine.donotpresent65
66
# Directories potentially created on remote AFP share67
.AppleDB68
.AppleDesktop69
Network Trash Folder70
Temporary Items71
.apdisk72
73
# Windows thumbnail cache files74
Thumbs.db75
Thumbs.db:encryptable76
ehthumbs.db77
ehthumbs_vista.db78
79
# Dump file80
*.stackdump81
82
# Folder config file83
[Dd]esktop.ini84
85
# Recycle Bin used on file shares86
$RECYCLE.BIN/87
88
# Windows Installer files89
*.cab90
*.msi91
*.msix92
*.msm93
*.msp94
95
# Windows shortcuts96
*.lnk97
98
target/99
100
pom.xml.tag101
pom.xml.releaseBackup102
pom.xml.versionsBackup103
pom.xml.next104
105
release.properties106
dependency-reduced-pom.xml107
buildNumber.properties108
.mvn/timing.properties109
.mvn/wrapper/maven-wrapper.jar110
.flattened-pom.xml111
112
# Common working directory113
run/@@ -0,0 +1,504 @@
1
GNU LESSER GENERAL PUBLIC LICENSE
2
Version 2.1, February 1999
3
4
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
Everyone is permitted to copy and distribute verbatim copies
7
of this license document, but changing it is not allowed.
8
9
[This is the first released version of the Lesser GPL. It also counts
10
as the successor of the GNU Library Public License, version 2, hence
11
the version number 2.1.]
12
13
Preamble
14
15
The licenses for most software are designed to take away your
16
freedom to share and change it. By contrast, the GNU General Public
17
Licenses are intended to guarantee your freedom to share and change
18
free software--to make sure the software is free for all its users.
19
20
This license, the Lesser General Public License, applies to some
21
specially designated software packages--typically libraries--of the
22
Free Software Foundation and other authors who decide to use it. You
23
can use it too, but we suggest you first think carefully about whether
24
this license or the ordinary General Public License is the better
25
strategy to use in any particular case, based on the explanations below.
26
27
When we speak of free software, we are referring to freedom of use,
28
not price. Our General Public Licenses are designed to make sure that
29
you have the freedom to distribute copies of free software (and charge
30
for this service if you wish); that you receive source code or can get
31
it if you want it; that you can change the software and use pieces of
32
it in new free programs; and that you are informed that you can do
33
these things.
34
35
To protect your rights, we need to make restrictions that forbid
36
distributors to deny you these rights or to ask you to surrender these
37
rights. These restrictions translate to certain responsibilities for
38
you if you distribute copies of the library or if you modify it.
39
40
For example, if you distribute copies of the library, whether gratis
41
or for a fee, you must give the recipients all the rights that we gave
42
you. You must make sure that they, too, receive or can get the source
43
code. If you link other code with the library, you must provide
44
complete object files to the recipients, so that they can relink them
45
with the library after making changes to the library and recompiling
46
it. And you must show them these terms so they know their rights.
47
48
We protect your rights with a two-step method: (1) we copyright the
49
library, and (2) we offer you this license, which gives you legal
50
permission to copy, distribute and/or modify the library.
51
52
To protect each distributor, we want to make it very clear that
53
there is no warranty for the free library. Also, if the library is
54
modified by someone else and passed on, the recipients should know
55
that what they have is not the original version, so that the original
56
author's reputation will not be affected by problems that might be
57
introduced by others.
58
59
Finally, software patents pose a constant threat to the existence of
60
any free program. We wish to make sure that a company cannot
61
effectively restrict the users of a free program by obtaining a
62
restrictive license from a patent holder. Therefore, we insist that
63
any patent license obtained for a version of the library must be
64
consistent with the full freedom of use specified in this license.
65
66
Most GNU software, including some libraries, is covered by the
67
ordinary GNU General Public License. This license, the GNU Lesser
68
General Public License, applies to certain designated libraries, and
69
is quite different from the ordinary General Public License. We use
70
this license for certain libraries in order to permit linking those
71
libraries into non-free programs.
72
73
When a program is linked with a library, whether statically or using
74
a shared library, the combination of the two is legally speaking a
75
combined work, a derivative of the original library. The ordinary
76
General Public License therefore permits such linking only if the
77
entire combination fits its criteria of freedom. The Lesser General
78
Public License permits more lax criteria for linking other code with
79
the library.
80
81
We call this license the "Lesser" General Public License because it
82
does Less to protect the user's freedom than the ordinary General
83
Public License. It also provides other free software developers Less
84
of an advantage over competing non-free programs. These disadvantages
85
are the reason we use the ordinary General Public License for many
86
libraries. However, the Lesser license provides advantages in certain
87
special circumstances.
88
89
For example, on rare occasions, there may be a special need to
90
encourage the widest possible use of a certain library, so that it becomes
91
a de-facto standard. To achieve this, non-free programs must be
92
allowed to use the library. A more frequent case is that a free
93
library does the same job as widely used non-free libraries. In this
94
case, there is little to gain by limiting the free library to free
95
software only, so we use the Lesser General Public License.
96
97
In other cases, permission to use a particular library in non-free
98
programs enables a greater number of people to use a large body of
99
free software. For example, permission to use the GNU C Library in
100
non-free programs enables many more people to use the whole GNU
101
operating system, as well as its variant, the GNU/Linux operating
102
system.
103
104
Although the Lesser General Public License is Less protective of the
105
users' freedom, it does ensure that the user of a program that is
106
linked with the Library has the freedom and the wherewithal to run
107
that program using a modified version of the Library.
108
109
The precise terms and conditions for copying, distribution and
110
modification follow. Pay close attention to the difference between a
111
"work based on the library" and a "work that uses the library". The
112
former contains code derived from the library, whereas the latter must
113
be combined with the library in order to run.
114
115
GNU LESSER GENERAL PUBLIC LICENSE
116
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117
118
0. This License Agreement applies to any software library or other
119
program which contains a notice placed by the copyright holder or
120
other authorized party saying it may be distributed under the terms of
121
this Lesser General Public License (also called "this License").
122
Each licensee is addressed as "you".
123
124
A "library" means a collection of software functions and/or data
125
prepared so as to be conveniently linked with application programs
126
(which use some of those functions and data) to form executables.
127
128
The "Library", below, refers to any such software library or work
129
which has been distributed under these terms. A "work based on the
130
Library" means either the Library or any derivative work under
131
copyright law: that is to say, a work containing the Library or a
132
portion of it, either verbatim or with modifications and/or translated
133
straightforwardly into another language. (Hereinafter, translation is
134
included without limitation in the term "modification".)
135
136
"Source code" for a work means the preferred form of the work for
137
making modifications to it. For a library, complete source code means
138
all the source code for all modules it contains, plus any associated
139
interface definition files, plus the scripts used to control compilation
140
and installation of the library.
141
142
Activities other than copying, distribution and modification are not
143
covered by this License; they are outside its scope. The act of
144
running a program using the Library is not restricted, and output from
145
such a program is covered only if its contents constitute a work based
146
on the Library (independent of the use of the Library in a tool for
147
writing it). Whether that is true depends on what the Library does
148
and what the program that uses the Library does.
149
150
1. You may copy and distribute verbatim copies of the Library's
151
complete source code as you receive it, in any medium, provided that
152
you conspicuously and appropriately publish on each copy an
153
appropriate copyright notice and disclaimer of warranty; keep intact
154
all the notices that refer to this License and to the absence of any
155
warranty; and distribute a copy of this License along with the
156
Library.
157
158
You may charge a fee for the physical act of transferring a copy,
159
and you may at your option offer warranty protection in exchange for a
160
fee.
161
162
2. You may modify your copy or copies of the Library or any portion
163
of it, thus forming a work based on the Library, and copy and
164
distribute such modifications or work under the terms of Section 1
165
above, provided that you also meet all of these conditions:
166
167
a) The modified work must itself be a software library.
168
169
b) You must cause the files modified to carry prominent notices
170
stating that you changed the files and the date of any change.
171
172
c) You must cause the whole of the work to be licensed at no
173
charge to all third parties under the terms of this License.
174
175
d) If a facility in the modified Library refers to a function or a
176
table of data to be supplied by an application program that uses
177
the facility, other than as an argument passed when the facility
178
is invoked, then you must make a good faith effort to ensure that,
179
in the event an application does not supply such function or
180
table, the facility still operates, and performs whatever part of
181
its purpose remains meaningful.
182
183
(For example, a function in a library to compute square roots has
184
a purpose that is entirely well-defined independent of the
185
application. Therefore, Subsection 2d requires that any
186
application-supplied function or table used by this function must
187
be optional: if the application does not supply it, the square
188
root function must still compute square roots.)
189
190
These requirements apply to the modified work as a whole. If
191
identifiable sections of that work are not derived from the Library,
192
and can be reasonably considered independent and separate works in
193
themselves, then this License, and its terms, do not apply to those
194
sections when you distribute them as separate works. But when you
195
distribute the same sections as part of a whole which is a work based
196
on the Library, the distribution of the whole must be on the terms of
197
this License, whose permissions for other licensees extend to the
198
entire whole, and thus to each and every part regardless of who wrote
199
it.
200
201
Thus, it is not the intent of this section to claim rights or contest
202
your rights to work written entirely by you; rather, the intent is to
203
exercise the right to control the distribution of derivative or
204
collective works based on the Library.
205
206
In addition, mere aggregation of another work not based on the Library
207
with the Library (or with a work based on the Library) on a volume of
208
a storage or distribution medium does not bring the other work under
209
the scope of this License.
210
211
3. You may opt to apply the terms of the ordinary GNU General Public
212
License instead of this License to a given copy of the Library. To do
213
this, you must alter all the notices that refer to this License, so
214
that they refer to the ordinary GNU General Public License, version 2,
215
instead of to this License. (If a newer version than version 2 of the
216
ordinary GNU General Public License has appeared, then you can specify
217
that version instead if you wish.) Do not make any other change in
218
these notices.
219
220
Once this change is made in a given copy, it is irreversible for
221
that copy, so the ordinary GNU General Public License applies to all
222
subsequent copies and derivative works made from that copy.
223
224
This option is useful when you wish to copy part of the code of
225
the Library into a program that is not a library.
226
227
4. You may copy and distribute the Library (or a portion or
228
derivative of it, under Section 2) in object code or executable form
229
under the terms of Sections 1 and 2 above provided that you accompany
230
it with the complete corresponding machine-readable source code, which
231
must be distributed under the terms of Sections 1 and 2 above on a
232
medium customarily used for software interchange.
233
234
If distribution of object code is made by offering access to copy
235
from a designated place, then offering equivalent access to copy the
236
source code from the same place satisfies the requirement to
237
distribute the source code, even though third parties are not
238
compelled to copy the source along with the object code.
239
240
5. A program that contains no derivative of any portion of the
241
Library, but is designed to work with the Library by being compiled or
242
linked with it, is called a "work that uses the Library". Such a
243
work, in isolation, is not a derivative work of the Library, and
244
therefore falls outside the scope of this License.
245
246
However, linking a "work that uses the Library" with the Library
247
creates an executable that is a derivative of the Library (because it
248
contains portions of the Library), rather than a "work that uses the
249
library". The executable is therefore covered by this License.
250
Section 6 states terms for distribution of such executables.
251
252
When a "work that uses the Library" uses material from a header file
253
that is part of the Library, the object code for the work may be a
254
derivative work of the Library even though the source code is not.
255
Whether this is true is especially significant if the work can be
256
linked without the Library, or if the work is itself a library. The
257
threshold for this to be true is not precisely defined by law.
258
259
If such an object file uses only numerical parameters, data
260
structure layouts and accessors, and small macros and small inline
261
functions (ten lines or less in length), then the use of the object
262
file is unrestricted, regardless of whether it is legally a derivative
263
work. (Executables containing this object code plus portions of the
264
Library will still fall under Section 6.)
265
266
Otherwise, if the work is a derivative of the Library, you may
267
distribute the object code for the work under the terms of Section 6.
268
Any executables containing that work also fall under Section 6,
269
whether or not they are linked directly with the Library itself.
270
271
6. As an exception to the Sections above, you may also combine or
272
link a "work that uses the Library" with the Library to produce a
273
work containing portions of the Library, and distribute that work
274
under terms of your choice, provided that the terms permit
275
modification of the work for the customer's own use and reverse
276
engineering for debugging such modifications.
277
278
You must give prominent notice with each copy of the work that the
279
Library is used in it and that the Library and its use are covered by
280
this License. You must supply a copy of this License. If the work
281
during execution displays copyright notices, you must include the
282
copyright notice for the Library among them, as well as a reference
283
directing the user to the copy of this License. Also, you must do one
284
of these things:
285
286
a) Accompany the work with the complete corresponding
287
machine-readable source code for the Library including whatever
288
changes were used in the work (which must be distributed under
289
Sections 1 and 2 above); and, if the work is an executable linked
290
with the Library, with the complete machine-readable "work that
291
uses the Library", as object code and/or source code, so that the
292
user can modify the Library and then relink to produce a modified
293
executable containing the modified Library. (It is understood
294
that the user who changes the contents of definitions files in the
295
Library will not necessarily be able to recompile the application
296
to use the modified definitions.)
297
298
b) Use a suitable shared library mechanism for linking with the
299
Library. A suitable mechanism is one that (1) uses at run time a
300
copy of the library already present on the user's computer system,
301
rather than copying library functions into the executable, and (2)
302
will operate properly with a modified version of the library, if
303
the user installs one, as long as the modified version is
304
interface-compatible with the version that the work was made with.
305
306
c) Accompany the work with a written offer, valid for at
307
least three years, to give the same user the materials
308
specified in Subsection 6a, above, for a charge no more
309
than the cost of performing this distribution.
310
311
d) If distribution of the work is made by offering access to copy
312
from a designated place, offer equivalent access to copy the above
313
specified materials from the same place.
314
315
e) Verify that the user has already received a copy of these
316
materials or that you have already sent this user a copy.
317
318
For an executable, the required form of the "work that uses the
319
Library" must include any data and utility programs needed for
320
reproducing the executable from it. However, as a special exception,
321
the materials to be distributed need not include anything that is
322
normally distributed (in either source or binary form) with the major
323
components (compiler, kernel, and so on) of the operating system on
324
which the executable runs, unless that component itself accompanies
325
the executable.
326
327
It may happen that this requirement contradicts the license
328
restrictions of other proprietary libraries that do not normally
329
accompany the operating system. Such a contradiction means you cannot
330
use both them and the Library together in an executable that you
331
distribute.
332
333
7. You may place library facilities that are a work based on the
334
Library side-by-side in a single library together with other library
335
facilities not covered by this License, and distribute such a combined
336
library, provided that the separate distribution of the work based on
337
the Library and of the other library facilities is otherwise
338
permitted, and provided that you do these two things:
339
340
a) Accompany the combined library with a copy of the same work
341
based on the Library, uncombined with any other library
342
facilities. This must be distributed under the terms of the
343
Sections above.
344
345
b) Give prominent notice with the combined library of the fact
346
that part of it is a work based on the Library, and explaining
347
where to find the accompanying uncombined form of the same work.
348
349
8. You may not copy, modify, sublicense, link with, or distribute
350
the Library except as expressly provided under this License. Any
351
attempt otherwise to copy, modify, sublicense, link with, or
352
distribute the Library is void, and will automatically terminate your
353
rights under this License. However, parties who have received copies,
354
or rights, from you under this License will not have their licenses
355
terminated so long as such parties remain in full compliance.
356
357
9. You are not required to accept this License, since you have not
358
signed it. However, nothing else grants you permission to modify or
359
distribute the Library or its derivative works. These actions are
360
prohibited by law if you do not accept this License. Therefore, by
361
modifying or distributing the Library (or any work based on the
362
Library), you indicate your acceptance of this License to do so, and
363
all its terms and conditions for copying, distributing or modifying
364
the Library or works based on it.
365
366
10. Each time you redistribute the Library (or any work based on the
367
Library), the recipient automatically receives a license from the
368
original licensor to copy, distribute, link with or modify the Library
369
subject to these terms and conditions. You may not impose any further
370
restrictions on the recipients' exercise of the rights granted herein.
371
You are not responsible for enforcing compliance by third parties with
372
this License.
373
374
11. If, as a consequence of a court judgment or allegation of patent
375
infringement or for any other reason (not limited to patent issues),
376
conditions are imposed on you (whether by court order, agreement or
377
otherwise) that contradict the conditions of this License, they do not
378
excuse you from the conditions of this License. If you cannot
379
distribute so as to satisfy simultaneously your obligations under this
380
License and any other pertinent obligations, then as a consequence you
381
may not distribute the Library at all. For example, if a patent
382
license would not permit royalty-free redistribution of the Library by
383
all those who receive copies directly or indirectly through you, then
384
the only way you could satisfy both it and this License would be to
385
refrain entirely from distribution of the Library.
386
387
If any portion of this section is held invalid or unenforceable under any
388
particular circumstance, the balance of the section is intended to apply,
389
and the section as a whole is intended to apply in other circumstances.
390
391
It is not the purpose of this section to induce you to infringe any
392
patents or other property right claims or to contest validity of any
393
such claims; this section has the sole purpose of protecting the
394
integrity of the free software distribution system which is
395
implemented by public license practices. Many people have made
396
generous contributions to the wide range of software distributed
397
through that system in reliance on consistent application of that
398
system; it is up to the author/donor to decide if he or she is willing
399
to distribute software through any other system and a licensee cannot
400
impose that choice.
401
402
This section is intended to make thoroughly clear what is believed to
403
be a consequence of the rest of this License.
404
405
12. If the distribution and/or use of the Library is restricted in
406
certain countries either by patents or by copyrighted interfaces, the
407
original copyright holder who places the Library under this License may add
408
an explicit geographical distribution limitation excluding those countries,
409
so that distribution is permitted only in or among countries not thus
410
excluded. In such case, this License incorporates the limitation as if
411
written in the body of this License.
412
413
13. The Free Software Foundation may publish revised and/or new
414
versions of the Lesser General Public License from time to time.
415
Such new versions will be similar in spirit to the present version,
416
but may differ in detail to address new problems or concerns.
417
418
Each version is given a distinguishing version number. If the Library
419
specifies a version number of this License which applies to it and
420
"any later version", you have the option of following the terms and
421
conditions either of that version or of any later version published by
422
the Free Software Foundation. If the Library does not specify a
423
license version number, you may choose any version ever published by
424
the Free Software Foundation.
425
426
14. If you wish to incorporate parts of the Library into other free
427
programs whose distribution conditions are incompatible with these,
428
write to the author to ask for permission. For software which is
429
copyrighted by the Free Software Foundation, write to the Free
430
Software Foundation; we sometimes make exceptions for this. Our
431
decision will be guided by the two goals of preserving the free status
432
of all derivatives of our free software and of promoting the sharing
433
and reuse of software generally.
434
435
NO WARRANTY
436
437
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446
447
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456
DAMAGES.
457
458
END OF TERMS AND CONDITIONS
459
460
How to Apply These Terms to Your New Libraries
461
462
If you develop a new library, and you want it to be of the greatest
463
possible use to the public, we recommend making it free software that
464
everyone can redistribute and change. You can do so by permitting
465
redistribution under these terms (or, alternatively, under the terms of the
466
ordinary General Public License).
467
468
To apply these terms, attach the following notices to the library. It is
469
safest to attach them to the start of each source file to most effectively
470
convey the exclusion of warranty; and each file should have at least the
471
"copyright" line and a pointer to where the full notice is found.
472
473
<one line to give the library's name and a brief idea of what it does.>
474
Copyright (C) <year> <name of author>
475
476
This library is free software; you can redistribute it and/or
477
modify it under the terms of the GNU Lesser General Public
478
License as published by the Free Software Foundation; either
479
version 2.1 of the License, or (at your option) any later version.
480
481
This library is distributed in the hope that it will be useful,
482
but WITHOUT ANY WARRANTY; without even the implied warranty of
483
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484
Lesser General Public License for more details.
485
486
You should have received a copy of the GNU Lesser General Public
487
License along with this library; if not, write to the Free Software
488
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
489
USA
490
491
Also add information on how to contact you by electronic and paper mail.
492
493
You should also get your employer (if you work as a programmer) or your
494
school, if any, to sign a "copyright disclaimer" for the library, if
495
necessary. Here is a sample; alter the names:
496
497
Yoyodyne, Inc., hereby disclaims all copyright interest in the
498
library `Frob' (a library for tweaking knobs) written by James Random
499
Hacker.
500
501
<signature of Ty Coon>, 1 April 1990
502
Ty Coon, President of Vice
503
504
That's all there is to it!
@@ -0,0 +1,504 @@1
GNU LESSER GENERAL PUBLIC LICENSE2
Version 2.1, February 19993
4
Copyright (C) 1991, 1999 Free Software Foundation, Inc.5
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA6
Everyone is permitted to copy and distribute verbatim copies7
of this license document, but changing it is not allowed.8
9
[This is the first released version of the Lesser GPL. It also counts10
as the successor of the GNU Library Public License, version 2, hence11
the version number 2.1.]12
13
Preamble14
15
The licenses for most software are designed to take away your16
freedom to share and change it. By contrast, the GNU General Public17
Licenses are intended to guarantee your freedom to share and change18
free software--to make sure the software is free for all its users.19
20
This license, the Lesser General Public License, applies to some21
specially designated software packages--typically libraries--of the22
Free Software Foundation and other authors who decide to use it. You23
can use it too, but we suggest you first think carefully about whether24
this license or the ordinary General Public License is the better25
strategy to use in any particular case, based on the explanations below.26
27
When we speak of free software, we are referring to freedom of use,28
not price. Our General Public Licenses are designed to make sure that29
you have the freedom to distribute copies of free software (and charge30
for this service if you wish); that you receive source code or can get31
it if you want it; that you can change the software and use pieces of32
it in new free programs; and that you are informed that you can do33
these things.34
35
To protect your rights, we need to make restrictions that forbid36
distributors to deny you these rights or to ask you to surrender these37
rights. These restrictions translate to certain responsibilities for38
you if you distribute copies of the library or if you modify it.39
40
For example, if you distribute copies of the library, whether gratis41
or for a fee, you must give the recipients all the rights that we gave42
you. You must make sure that they, too, receive or can get the source43
code. If you link other code with the library, you must provide44
complete object files to the recipients, so that they can relink them45
with the library after making changes to the library and recompiling46
it. And you must show them these terms so they know their rights.47
48
We protect your rights with a two-step method: (1) we copyright the49
library, and (2) we offer you this license, which gives you legal50
permission to copy, distribute and/or modify the library.51
52
To protect each distributor, we want to make it very clear that53
there is no warranty for the free library. Also, if the library is54
modified by someone else and passed on, the recipients should know55
that what they have is not the original version, so that the original56
author's reputation will not be affected by problems that might be57
introduced by others.58
59
Finally, software patents pose a constant threat to the existence of60
any free program. We wish to make sure that a company cannot61
effectively restrict the users of a free program by obtaining a62
restrictive license from a patent holder. Therefore, we insist that63
any patent license obtained for a version of the library must be64
consistent with the full freedom of use specified in this license.65
66
Most GNU software, including some libraries, is covered by the67
ordinary GNU General Public License. This license, the GNU Lesser68
General Public License, applies to certain designated libraries, and69
is quite different from the ordinary General Public License. We use70
this license for certain libraries in order to permit linking those71
libraries into non-free programs.72
73
When a program is linked with a library, whether statically or using74
a shared library, the combination of the two is legally speaking a75
combined work, a derivative of the original library. The ordinary76
General Public License therefore permits such linking only if the77
entire combination fits its criteria of freedom. The Lesser General78
Public License permits more lax criteria for linking other code with79
the library.80
81
We call this license the "Lesser" General Public License because it82
does Less to protect the user's freedom than the ordinary General83
Public License. It also provides other free software developers Less84
of an advantage over competing non-free programs. These disadvantages85
are the reason we use the ordinary General Public License for many86
libraries. However, the Lesser license provides advantages in certain87
special circumstances.88
89
For example, on rare occasions, there may be a special need to90
encourage the widest possible use of a certain library, so that it becomes91
a de-facto standard. To achieve this, non-free programs must be92
allowed to use the library. A more frequent case is that a free93
library does the same job as widely used non-free libraries. In this94
case, there is little to gain by limiting the free library to free95
software only, so we use the Lesser General Public License.96
97
In other cases, permission to use a particular library in non-free98
programs enables a greater number of people to use a large body of99
free software. For example, permission to use the GNU C Library in100
non-free programs enables many more people to use the whole GNU101
operating system, as well as its variant, the GNU/Linux operating102
system.103
104
Although the Lesser General Public License is Less protective of the105
users' freedom, it does ensure that the user of a program that is106
linked with the Library has the freedom and the wherewithal to run107
that program using a modified version of the Library.108
109
The precise terms and conditions for copying, distribution and110
modification follow. Pay close attention to the difference between a111
"work based on the library" and a "work that uses the library". The112
former contains code derived from the library, whereas the latter must113
be combined with the library in order to run.114
115
GNU LESSER GENERAL PUBLIC LICENSE116
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION117
118
0. This License Agreement applies to any software library or other119
program which contains a notice placed by the copyright holder or120
other authorized party saying it may be distributed under the terms of121
this Lesser General Public License (also called "this License").122
Each licensee is addressed as "you".123
124
A "library" means a collection of software functions and/or data125
prepared so as to be conveniently linked with application programs126
(which use some of those functions and data) to form executables.127
128
The "Library", below, refers to any such software library or work129
which has been distributed under these terms. A "work based on the130
Library" means either the Library or any derivative work under131
copyright law: that is to say, a work containing the Library or a132
portion of it, either verbatim or with modifications and/or translated133
straightforwardly into another language. (Hereinafter, translation is134
included without limitation in the term "modification".)135
136
"Source code" for a work means the preferred form of the work for137
making modifications to it. For a library, complete source code means138
all the source code for all modules it contains, plus any associated139
interface definition files, plus the scripts used to control compilation140
and installation of the library.141
142
Activities other than copying, distribution and modification are not143
covered by this License; they are outside its scope. The act of144
running a program using the Library is not restricted, and output from145
such a program is covered only if its contents constitute a work based146
on the Library (independent of the use of the Library in a tool for147
writing it). Whether that is true depends on what the Library does148
and what the program that uses the Library does.149
150
1. You may copy and distribute verbatim copies of the Library's151
complete source code as you receive it, in any medium, provided that152
you conspicuously and appropriately publish on each copy an153
appropriate copyright notice and disclaimer of warranty; keep intact154
all the notices that refer to this License and to the absence of any155
warranty; and distribute a copy of this License along with the156
Library.157
158
You may charge a fee for the physical act of transferring a copy,159
and you may at your option offer warranty protection in exchange for a160
fee.161
162
2. You may modify your copy or copies of the Library or any portion163
of it, thus forming a work based on the Library, and copy and164
distribute such modifications or work under the terms of Section 1165
above, provided that you also meet all of these conditions:166
167
a) The modified work must itself be a software library.168
169
b) You must cause the files modified to carry prominent notices170
stating that you changed the files and the date of any change.171
172
c) You must cause the whole of the work to be licensed at no173
charge to all third parties under the terms of this License.174
175
d) If a facility in the modified Library refers to a function or a176
table of data to be supplied by an application program that uses177
the facility, other than as an argument passed when the facility178
is invoked, then you must make a good faith effort to ensure that,179
in the event an application does not supply such function or180
table, the facility still operates, and performs whatever part of181
its purpose remains meaningful.182
183
(For example, a function in a library to compute square roots has184
a purpose that is entirely well-defined independent of the185
application. Therefore, Subsection 2d requires that any186
application-supplied function or table used by this function must187
be optional: if the application does not supply it, the square188
root function must still compute square roots.)189
190
These requirements apply to the modified work as a whole. If191
identifiable sections of that work are not derived from the Library,192
and can be reasonably considered independent and separate works in193
themselves, then this License, and its terms, do not apply to those194
sections when you distribute them as separate works. But when you195
distribute the same sections as part of a whole which is a work based196
on the Library, the distribution of the whole must be on the terms of197
this License, whose permissions for other licensees extend to the198
entire whole, and thus to each and every part regardless of who wrote199
it.200
201
Thus, it is not the intent of this section to claim rights or contest202
your rights to work written entirely by you; rather, the intent is to203
exercise the right to control the distribution of derivative or204
collective works based on the Library.205
206
In addition, mere aggregation of another work not based on the Library207
with the Library (or with a work based on the Library) on a volume of208
a storage or distribution medium does not bring the other work under209
the scope of this License.210
211
3. You may opt to apply the terms of the ordinary GNU General Public212
License instead of this License to a given copy of the Library. To do213
this, you must alter all the notices that refer to this License, so214
that they refer to the ordinary GNU General Public License, version 2,215
instead of to this License. (If a newer version than version 2 of the216
ordinary GNU General Public License has appeared, then you can specify217
that version instead if you wish.) Do not make any other change in218
these notices.219
220
Once this change is made in a given copy, it is irreversible for221
that copy, so the ordinary GNU General Public License applies to all222
subsequent copies and derivative works made from that copy.223
224
This option is useful when you wish to copy part of the code of225
the Library into a program that is not a library.226
227
4. You may copy and distribute the Library (or a portion or228
derivative of it, under Section 2) in object code or executable form229
under the terms of Sections 1 and 2 above provided that you accompany230
it with the complete corresponding machine-readable source code, which231
must be distributed under the terms of Sections 1 and 2 above on a232
medium customarily used for software interchange.233
234
If distribution of object code is made by offering access to copy235
from a designated place, then offering equivalent access to copy the236
source code from the same place satisfies the requirement to237
distribute the source code, even though third parties are not238
compelled to copy the source along with the object code.239
240
5. A program that contains no derivative of any portion of the241
Library, but is designed to work with the Library by being compiled or242
linked with it, is called a "work that uses the Library". Such a243
work, in isolation, is not a derivative work of the Library, and244
therefore falls outside the scope of this License.245
246
However, linking a "work that uses the Library" with the Library247
creates an executable that is a derivative of the Library (because it248
contains portions of the Library), rather than a "work that uses the249
library". The executable is therefore covered by this License.250
Section 6 states terms for distribution of such executables.251
252
When a "work that uses the Library" uses material from a header file253
that is part of the Library, the object code for the work may be a254
derivative work of the Library even though the source code is not.255
Whether this is true is especially significant if the work can be256
linked without the Library, or if the work is itself a library. The257
threshold for this to be true is not precisely defined by law.258
259
If such an object file uses only numerical parameters, data260
structure layouts and accessors, and small macros and small inline261
functions (ten lines or less in length), then the use of the object262
file is unrestricted, regardless of whether it is legally a derivative263
work. (Executables containing this object code plus portions of the264
Library will still fall under Section 6.)265
266
Otherwise, if the work is a derivative of the Library, you may267
distribute the object code for the work under the terms of Section 6.268
Any executables containing that work also fall under Section 6,269
whether or not they are linked directly with the Library itself.270
271
6. As an exception to the Sections above, you may also combine or272
link a "work that uses the Library" with the Library to produce a273
work containing portions of the Library, and distribute that work274
under terms of your choice, provided that the terms permit275
modification of the work for the customer's own use and reverse276
engineering for debugging such modifications.277
278
You must give prominent notice with each copy of the work that the279
Library is used in it and that the Library and its use are covered by280
this License. You must supply a copy of this License. If the work281
during execution displays copyright notices, you must include the282
copyright notice for the Library among them, as well as a reference283
directing the user to the copy of this License. Also, you must do one284
of these things:285
286
a) Accompany the work with the complete corresponding287
machine-readable source code for the Library including whatever288
changes were used in the work (which must be distributed under289
Sections 1 and 2 above); and, if the work is an executable linked290
with the Library, with the complete machine-readable "work that291
uses the Library", as object code and/or source code, so that the292
user can modify the Library and then relink to produce a modified293
executable containing the modified Library. (It is understood294
that the user who changes the contents of definitions files in the295
Library will not necessarily be able to recompile the application296
to use the modified definitions.)297
298
b) Use a suitable shared library mechanism for linking with the299
Library. A suitable mechanism is one that (1) uses at run time a300
copy of the library already present on the user's computer system,301
rather than copying library functions into the executable, and (2)302
will operate properly with a modified version of the library, if303
the user installs one, as long as the modified version is304
interface-compatible with the version that the work was made with.305
306
c) Accompany the work with a written offer, valid for at307
least three years, to give the same user the materials308
specified in Subsection 6a, above, for a charge no more309
than the cost of performing this distribution.310
311
d) If distribution of the work is made by offering access to copy312
from a designated place, offer equivalent access to copy the above313
specified materials from the same place.314
315
e) Verify that the user has already received a copy of these316
materials or that you have already sent this user a copy.317
318
For an executable, the required form of the "work that uses the319
Library" must include any data and utility programs needed for320
reproducing the executable from it. However, as a special exception,321
the materials to be distributed need not include anything that is322
normally distributed (in either source or binary form) with the major323
components (compiler, kernel, and so on) of the operating system on324
which the executable runs, unless that component itself accompanies325
the executable.326
327
It may happen that this requirement contradicts the license328
restrictions of other proprietary libraries that do not normally329
accompany the operating system. Such a contradiction means you cannot330
use both them and the Library together in an executable that you331
distribute.332
333
7. You may place library facilities that are a work based on the334
Library side-by-side in a single library together with other library335
facilities not covered by this License, and distribute such a combined336
library, provided that the separate distribution of the work based on337
the Library and of the other library facilities is otherwise338
permitted, and provided that you do these two things:339
340
a) Accompany the combined library with a copy of the same work341
based on the Library, uncombined with any other library342
facilities. This must be distributed under the terms of the343
Sections above.344
345
b) Give prominent notice with the combined library of the fact346
that part of it is a work based on the Library, and explaining347
where to find the accompanying uncombined form of the same work.348
349
8. You may not copy, modify, sublicense, link with, or distribute350
the Library except as expressly provided under this License. Any351
attempt otherwise to copy, modify, sublicense, link with, or352
distribute the Library is void, and will automatically terminate your353
rights under this License. However, parties who have received copies,354
or rights, from you under this License will not have their licenses355
terminated so long as such parties remain in full compliance.356
357
9. You are not required to accept this License, since you have not358
signed it. However, nothing else grants you permission to modify or359
distribute the Library or its derivative works. These actions are360
prohibited by law if you do not accept this License. Therefore, by361
modifying or distributing the Library (or any work based on the362
Library), you indicate your acceptance of this License to do so, and363
all its terms and conditions for copying, distributing or modifying364
the Library or works based on it.365
366
10. Each time you redistribute the Library (or any work based on the367
Library), the recipient automatically receives a license from the368
original licensor to copy, distribute, link with or modify the Library369
subject to these terms and conditions. You may not impose any further370
restrictions on the recipients' exercise of the rights granted herein.371
You are not responsible for enforcing compliance by third parties with372
this License.373
374
11. If, as a consequence of a court judgment or allegation of patent375
infringement or for any other reason (not limited to patent issues),376
conditions are imposed on you (whether by court order, agreement or377
otherwise) that contradict the conditions of this License, they do not378
excuse you from the conditions of this License. If you cannot379
distribute so as to satisfy simultaneously your obligations under this380
License and any other pertinent obligations, then as a consequence you381
may not distribute the Library at all. For example, if a patent382
license would not permit royalty-free redistribution of the Library by383
all those who receive copies directly or indirectly through you, then384
the only way you could satisfy both it and this License would be to385
refrain entirely from distribution of the Library.386
387
If any portion of this section is held invalid or unenforceable under any388
particular circumstance, the balance of the section is intended to apply,389
and the section as a whole is intended to apply in other circumstances.390
391
It is not the purpose of this section to induce you to infringe any392
patents or other property right claims or to contest validity of any393
such claims; this section has the sole purpose of protecting the394
integrity of the free software distribution system which is395
implemented by public license practices. Many people have made396
generous contributions to the wide range of software distributed397
through that system in reliance on consistent application of that398
system; it is up to the author/donor to decide if he or she is willing399
to distribute software through any other system and a licensee cannot400
impose that choice.401
402
This section is intended to make thoroughly clear what is believed to403
be a consequence of the rest of this License.404
405
12. If the distribution and/or use of the Library is restricted in406
certain countries either by patents or by copyrighted interfaces, the407
original copyright holder who places the Library under this License may add408
an explicit geographical distribution limitation excluding those countries,409
so that distribution is permitted only in or among countries not thus410
excluded. In such case, this License incorporates the limitation as if411
written in the body of this License.412
413
13. The Free Software Foundation may publish revised and/or new414
versions of the Lesser General Public License from time to time.415
Such new versions will be similar in spirit to the present version,416
but may differ in detail to address new problems or concerns.417
418
Each version is given a distinguishing version number. If the Library419
specifies a version number of this License which applies to it and420
"any later version", you have the option of following the terms and421
conditions either of that version or of any later version published by422
the Free Software Foundation. If the Library does not specify a423
license version number, you may choose any version ever published by424
the Free Software Foundation.425
426
14. If you wish to incorporate parts of the Library into other free427
programs whose distribution conditions are incompatible with these,428
write to the author to ask for permission. For software which is429
copyrighted by the Free Software Foundation, write to the Free430
Software Foundation; we sometimes make exceptions for this. Our431
decision will be guided by the two goals of preserving the free status432
of all derivatives of our free software and of promoting the sharing433
and reuse of software generally.434
435
NO WARRANTY436
437
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO438
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.439
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR440
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY441
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE442
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR443
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE444
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME445
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.446
447
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN448
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY449
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU450
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR451
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE452
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING453
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A454
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF455
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH456
DAMAGES.457
458
END OF TERMS AND CONDITIONS459
460
How to Apply These Terms to Your New Libraries461
462
If you develop a new library, and you want it to be of the greatest463
possible use to the public, we recommend making it free software that464
everyone can redistribute and change. You can do so by permitting465
redistribution under these terms (or, alternatively, under the terms of the466
ordinary General Public License).467
468
To apply these terms, attach the following notices to the library. It is469
safest to attach them to the start of each source file to most effectively470
convey the exclusion of warranty; and each file should have at least the471
"copyright" line and a pointer to where the full notice is found.472
473
<one line to give the library's name and a brief idea of what it does.>474
Copyright (C) <year> <name of author>475
476
This library is free software; you can redistribute it and/or477
modify it under the terms of the GNU Lesser General Public478
License as published by the Free Software Foundation; either479
version 2.1 of the License, or (at your option) any later version.480
481
This library is distributed in the hope that it will be useful,482
but WITHOUT ANY WARRANTY; without even the implied warranty of483
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU484
Lesser General Public License for more details.485
486
You should have received a copy of the GNU Lesser General Public487
License along with this library; if not, write to the Free Software488
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301489
USA490
491
Also add information on how to contact you by electronic and paper mail.492
493
You should also get your employer (if you work as a programmer) or your494
school, if any, to sign a "copyright disclaimer" for the library, if495
necessary. Here is a sample; alter the names:496
497
Yoyodyne, Inc., hereby disclaims all copyright interest in the498
library `Frob' (a library for tweaking knobs) written by James Random499
Hacker.500
501
<signature of Ty Coon>, 1 April 1990502
Ty Coon, President of Vice503
504
That's all there is to it!@@ -0,0 +1,92 @@
1
[](https://www.spigotmc.org/)
2
[]()
3
[]()
4
[]()
5
[](https://github.com/Fridtjof-DE/MinecartTrains/issues)
6
[](https://discord.gg/fT6VJurHCT)
7
8
[](https://modrinth.com/plugin/minecart-trains/versions)
9
10
[](https://bstats.org/plugin/bukkit/Minecart%20Trains/18918)
11
[](https://bstats.org/plugin/bukkit/Minecart%20Trains/18918)
12
13
# <img src="./docs/images/icon.png" data-canonical-src="./icon.png" width="32" height="32" /> Minecart Trains
14
15
Introducing Minecart Trains! Experience a whole new level of immersion as you connect minecarts together, transforming them into powerful and efficient trains.
16
17

18
### Features:
19
- linking minecarts to form a train
20
- freezing furnace minecarts with non-powered booster rails (to stop trains)
21
- minecarts at high velocity kill mobs on the track (configurable)
22
- arrows can't destroy minecarts (configurable)
23
- coal carts which the furnace cart will refuel from
24
- fuel consumption of the furnace minecart is configurable
25
- highspeed tracks inspired by hsrails (only on adapted railways)
26
27
### How it works:
28
**Coupling:**
29
30
The standard coupling tool is the chain. With this you click on two minecarts one after the other. The second one will follow the first one. With a train you work your way through from front to back. (I am working on making the order irrelevant).
31
32
**Coal Carts:**
33
34
Furnace minecarts will, if already going, refuel from a coal cart nearby. Coal carts can be crafting with a minecart and a coal block. Coal carts will only interact with hoppers to refill but only coal and charcoal.
35
36
### What is planned:
37
- safe chunk unloading
38
- auto. chunk loading
39
- making the linking order irrelevant
40
- some kind of fuel gauge
41
42
### What is not (yet) possible:
43
- trains that push backwards (w.i.p.)
44
- trains going around 2x2 curves
45
46
### Dependencies
47
48
- PuddingAPI ([plugin jar](https://modrinth.com/plugin/puddingapi)) ([source](https://github.com/Fridtjof-DE/PuddingAPI))
49
50
### Relevant Links
51
52
- modrinth: https://modrinth.com/plugin/minecart-trains
53
- bStats: https://bstats.org/plugin/bukkit/Minecart%20Trains/18918
54
55
## How to Build
56
57
If you are looking to make changes, then you'll need to get both a JDK 17 and Maven installed on your computer. I recommend just using an IDE like Intellij IDEA or Eclipse.
58
59
### Building Pudding API
60
61
If only want to make changes to `main-branch` of MinecartTrains you can just download the latest ([PuddingAPI jar](https://modrinth.com/plugin/puddingapi)) from Modrith.
62
63
If you want to make changes to a `dev-branch` of MinecartTrains you might need to download the latest ([PuddingAPI dev-build](https://github.com/Fridtjof-DE/PuddingAPI/tree/master/builds)) from GitHub.
64
65
If you also want to make changes to the PuddingAPI you'll need to have the [PuddingAPI](https://github.com/Fridtjof-DE/PuddingAPI) source installed. On more information on how to build PuddingAPI look at it's GitHub.
66
67
Either way PuddingAPI has to be in the correct sister folder specified in the MinecartTrains `pom.xml`.
68
69
### Building Minecart Trains
70
71
Once you have Pudding API built and the jar generated, update the
72
`puddingapi.jar` property in the `pom.xml` file of the current
73
project, to ensure it points to the jar generated in the 'Building
74
PuddingAPI' section.
75
76
Once the `pom.xml` file has been updated, you can kick off the build:
77
78
```
79
mvn package
80
```
81
82
Results will be in the `target` folder, with base name
83
`MinecartTrains`. Assuming the current marked release is 2.0.0
84
(see version value in pom.xml), you'll have the following file:
85
86
- `MinecartTrains-2.0.0.jar`
87
88
Copy this file over to the plugins folder of your Minecraft server. Also, don't forget to have copied the PuddingAPI jar as well, to your
89
server's plugins folder.
90
91
## bStats
92

@@ -0,0 +1,92 @@1
[](https://www.spigotmc.org/)2
[]()3
[]()4
[]()5
[](https://github.com/Fridtjof-DE/MinecartTrains/issues)6
[](https://discord.gg/fT6VJurHCT)7
8
[](https://modrinth.com/plugin/minecart-trains/versions)9
10
[](https://bstats.org/plugin/bukkit/Minecart%20Trains/18918)11
[](https://bstats.org/plugin/bukkit/Minecart%20Trains/18918)12
13
# <img src="./docs/images/icon.png" data-canonical-src="./icon.png" width="32" height="32" /> Minecart Trains14
15
Introducing Minecart Trains! Experience a whole new level of immersion as you connect minecarts together, transforming them into powerful and efficient trains.16
17
18
### Features:19
- linking minecarts to form a train20
- freezing furnace minecarts with non-powered booster rails (to stop trains)21
- minecarts at high velocity kill mobs on the track (configurable)22
- arrows can't destroy minecarts (configurable)23
- coal carts which the furnace cart will refuel from24
- fuel consumption of the furnace minecart is configurable25
- highspeed tracks inspired by hsrails (only on adapted railways)26
27
### How it works:28
**Coupling:**29
30
The standard coupling tool is the chain. With this you click on two minecarts one after the other. The second one will follow the first one. With a train you work your way through from front to back. (I am working on making the order irrelevant).31
32
**Coal Carts:**33
34
Furnace minecarts will, if already going, refuel from a coal cart nearby. Coal carts can be crafting with a minecart and a coal block. Coal carts will only interact with hoppers to refill but only coal and charcoal.35
36
### What is planned:37
- safe chunk unloading38
- auto. chunk loading39
- making the linking order irrelevant40
- some kind of fuel gauge41
42
### What is not (yet) possible:43
- trains that push backwards (w.i.p.)44
- trains going around 2x2 curves45
46
### Dependencies47
48
- PuddingAPI ([plugin jar](https://modrinth.com/plugin/puddingapi)) ([source](https://github.com/Fridtjof-DE/PuddingAPI))49
50
### Relevant Links51
52
- modrinth: https://modrinth.com/plugin/minecart-trains53
- bStats: https://bstats.org/plugin/bukkit/Minecart%20Trains/1891854
55
## How to Build56
57
If you are looking to make changes, then you'll need to get both a JDK 17 and Maven installed on your computer. I recommend just using an IDE like Intellij IDEA or Eclipse.58
59
### Building Pudding API60
61
If only want to make changes to `main-branch` of MinecartTrains you can just download the latest ([PuddingAPI jar](https://modrinth.com/plugin/puddingapi)) from Modrith.62
63
If you want to make changes to a `dev-branch` of MinecartTrains you might need to download the latest ([PuddingAPI dev-build](https://github.com/Fridtjof-DE/PuddingAPI/tree/master/builds)) from GitHub.64
65
If you also want to make changes to the PuddingAPI you'll need to have the [PuddingAPI](https://github.com/Fridtjof-DE/PuddingAPI) source installed. On more information on how to build PuddingAPI look at it's GitHub.66
67
Either way PuddingAPI has to be in the correct sister folder specified in the MinecartTrains `pom.xml`.68
69
### Building Minecart Trains70
71
Once you have Pudding API built and the jar generated, update the72
`puddingapi.jar` property in the `pom.xml` file of the current 73
project, to ensure it points to the jar generated in the 'Building74
PuddingAPI' section.75
76
Once the `pom.xml` file has been updated, you can kick off the build:77
78
```79
mvn package80
```81
82
Results will be in the `target` folder, with base name83
`MinecartTrains`. Assuming the current marked release is 2.0.084
(see version value in pom.xml), you'll have the following file:85
86
- `MinecartTrains-2.0.0.jar`87
88
Copy this file over to the plugins folder of your Minecraft server. Also, don't forget to have copied the PuddingAPI jar as well, to your89
server's plugins folder.90
91
## bStats92
The contents of this binary file are not shown.
The contents of this binary file are not shown.
The contents of this binary file are not shown.
@@ -0,0 +1,85 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<project xmlns="http://maven.apache.org/POM/4.0.0"
3
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5
<modelVersion>4.0.0</modelVersion>
6
7
<groupId>me.fridtjof</groupId>
8
<artifactId>minecarttrains</artifactId>
9
<version>1.4.3</version>
10
<packaging>jar</packaging>
11
12
<name>MinecartTrains</name>
13
14
<properties>
15
<java.version>21</java.version>
16
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17
<puddingapi.jar>${project.basedir}/../PuddingAPI/builds/PuddingAPI-2602011954.jar</puddingapi.jar>
18
</properties>
19
20
<url>https://www.fridtjof.me</url>
21
22
<build>
23
<finalName>${project.name}-${project.version}</finalName>
24
<plugins>
25
<plugin>
26
<groupId>org.apache.maven.plugins</groupId>
27
<artifactId>maven-compiler-plugin</artifactId>
28
<version>3.8.1</version>
29
<configuration>
30
<source>${java.version}</source>
31
<target>${java.version}</target>
32
</configuration>
33
</plugin>
34
<plugin>
35
<groupId>org.apache.maven.plugins</groupId>
36
<artifactId>maven-shade-plugin</artifactId>
37
<version>3.2.4</version>
38
<executions>
39
<execution>
40
<phase>package</phase>
41
<goals>
42
<goal>shade</goal>
43
</goals>
44
<configuration>
45
<createDependencyReducedPom>false</createDependencyReducedPom>
46
</configuration>
47
</execution>
48
</executions>
49
</plugin>
50
</plugins>
51
<resources>
52
<resource>
53
<directory>src/main/resources</directory>
54
<filtering>true</filtering>
55
</resource>
56
</resources>
57
</build>
58
59
<repositories>
60
<repository>
61
<id>spigotmc-repo</id>
62
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
63
</repository>
64
<repository>
65
<id>sonatype</id>
66
<url>https://oss.sonatype.org/content/groups/public/</url>
67
</repository>
68
</repositories>
69
70
<dependencies>
71
<dependency>
72
<groupId>org.spigotmc</groupId>
73
<artifactId>spigot-api</artifactId>
74
<version>1.21-R0.1-SNAPSHOT</version>
75
<scope>provided</scope>
76
</dependency>
77
<dependency>
78
<groupId>me.fridtjof</groupId>
79
<artifactId>puddingapi</artifactId>
80
<version>Snapshot</version>
81
<scope>system</scope>
82
<systemPath>${puddingapi.jar}</systemPath>
83
</dependency>
84
</dependencies>
85
</project>
@@ -0,0 +1,85 @@1
<?xml version="1.0" encoding="UTF-8"?>2
<project xmlns="http://maven.apache.org/POM/4.0.0"3
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"4
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">5
<modelVersion>4.0.0</modelVersion>6
7
<groupId>me.fridtjof</groupId>8
<artifactId>minecarttrains</artifactId>9
<version>1.4.3</version>10
<packaging>jar</packaging>11
12
<name>MinecartTrains</name>13
14
<properties>15
<java.version>21</java.version>16
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>17
<puddingapi.jar>${project.basedir}/../PuddingAPI/builds/PuddingAPI-2602011954.jar</puddingapi.jar>18
</properties>19
20
<url>https://www.fridtjof.me</url>21
22
<build>23
<finalName>${project.name}-${project.version}</finalName>24
<plugins>25
<plugin>26
<groupId>org.apache.maven.plugins</groupId>27
<artifactId>maven-compiler-plugin</artifactId>28
<version>3.8.1</version>29
<configuration>30
<source>${java.version}</source>31
<target>${java.version}</target>32
</configuration>33
</plugin>34
<plugin>35
<groupId>org.apache.maven.plugins</groupId>36
<artifactId>maven-shade-plugin</artifactId>37
<version>3.2.4</version>38
<executions>39
<execution>40
<phase>package</phase>41
<goals>42
<goal>shade</goal>43
</goals>44
<configuration>45
<createDependencyReducedPom>false</createDependencyReducedPom>46
</configuration>47
</execution>48
</executions>49
</plugin>50
</plugins>51
<resources>52
<resource>53
<directory>src/main/resources</directory>54
<filtering>true</filtering>55
</resource>56
</resources>57
</build>58
59
<repositories>60
<repository>61
<id>spigotmc-repo</id>62
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>63
</repository>64
<repository>65
<id>sonatype</id>66
<url>https://oss.sonatype.org/content/groups/public/</url>67
</repository>68
</repositories>69
70
<dependencies>71
<dependency>72
<groupId>org.spigotmc</groupId>73
<artifactId>spigot-api</artifactId>74
<version>1.21-R0.1-SNAPSHOT</version>75
<scope>provided</scope>76
</dependency>77
<dependency>78
<groupId>me.fridtjof</groupId>79
<artifactId>puddingapi</artifactId>80
<version>Snapshot</version>81
<scope>system</scope>82
<systemPath>${puddingapi.jar}</systemPath>83
</dependency>84
</dependencies>85
</project>@@ -0,0 +1,50 @@
1
package me.fridtjof.minecarttrains;
2
3
import me.fridtjof.minecarttrains.managers.ConfigManager;
4
import me.fridtjof.minecarttrains.managers.EventManager;
5
import me.fridtjof.minecarttrains.managers.LinkageManager;
6
import me.fridtjof.minecarttrains.managers.RecipeManager;
7
import me.fridtjof.puddingapi.bukkit.utils.*;
8
import org.bukkit.plugin.java.JavaPlugin;
9
10
public final class MinecartTrains extends JavaPlugin
11
{
12
13
private static MinecartTrains instance;
14
15
public MinecartTrains()
16
{
17
instance = this;
18
}
19
20
public static MinecartTrains getInstance()
21
{
22
return instance;
23
}
24
25
Logger logger = new Logger(this);
26
27
public ConfigManager configManager;
28
public LinkageManager linkageManager;
29
30
@Override
31
public void onEnable()
32
{
33
new PuddingAPIVersionChecker(this, 2602011954L);
34
35
configManager = new ConfigManager(this);
36
linkageManager = new LinkageManager();
37
38
new RecipeManager();
39
new EventManager(this);
40
new ModrinthUpdateChecker(this,"plRff0I9", "spigot");
41
new Metrics(this, 18918);
42
43
}
44
45
@Override
46
public void onDisable()
47
{
48
49
}
50
}
@@ -0,0 +1,50 @@1
package me.fridtjof.minecarttrains;2
3
import me.fridtjof.minecarttrains.managers.ConfigManager;4
import me.fridtjof.minecarttrains.managers.EventManager;5
import me.fridtjof.minecarttrains.managers.LinkageManager;6
import me.fridtjof.minecarttrains.managers.RecipeManager;7
import me.fridtjof.puddingapi.bukkit.utils.*;8
import org.bukkit.plugin.java.JavaPlugin;9
10
public final class MinecartTrains extends JavaPlugin11
{12
13
private static MinecartTrains instance;14
15
public MinecartTrains()16
{17
instance = this;18
}19
20
public static MinecartTrains getInstance()21
{22
return instance;23
}24
25
Logger logger = new Logger(this);26
27
public ConfigManager configManager;28
public LinkageManager linkageManager;29
30
@Override31
public void onEnable()32
{33
new PuddingAPIVersionChecker(this, 2602011954L);34
35
configManager = new ConfigManager(this);36
linkageManager = new LinkageManager();37
38
new RecipeManager();39
new EventManager(this);40
new ModrinthUpdateChecker(this,"plRff0I9", "spigot");41
new Metrics(this, 18918);42
43
}44
45
@Override46
public void onDisable()47
{48
49
}50
}@@ -0,0 +1,105 @@
1
package me.fridtjof.minecarttrains.events;
2
3
import me.fridtjof.minecarttrains.MinecartTrains;
4
import me.fridtjof.puddingapi.bukkit.items.HopperUtils;
5
import org.bukkit.Material;
6
import org.bukkit.block.Hopper;
7
import org.bukkit.entity.minecart.StorageMinecart;
8
import org.bukkit.event.EventHandler;
9
import org.bukkit.event.Listener;
10
import org.bukkit.event.inventory.InventoryAction;
11
import org.bukkit.event.inventory.InventoryMoveItemEvent;
12
import org.bukkit.inventory.Inventory;
13
import org.bukkit.inventory.InventoryHolder;
14
import org.bukkit.inventory.ItemStack;
15
16
public class OnInventoryMoveItemEvent implements Listener
17
{
18
19
static MinecartTrains plugin = MinecartTrains.getInstance();
20
21
// config vars
22
private final String FUEL_CART_NAME = plugin.configManager.mainConfig.getConfig().getString("trains.fuel.cart_name");
23
boolean doHopperLogic = plugin.configManager.mainConfig.getConfig().getBoolean("trains.fuel.do_hopper_logic");
24
25
//stop hoppers from unloading fuel carts
26
@EventHandler
27
public void onMoveItemOutOffFuelCartEvent(InventoryMoveItemEvent event)
28
{
29
// made this part optional because it can cause problems with other plugins
30
if(!doHopperLogic)
31
{
32
return;
33
}
34
35
if(!(event.getSource().getHolder() instanceof StorageMinecart))
36
{
37
return;
38
}
39
40
if(!(event.getDestination().getHolder() instanceof Hopper))
41
{
42
return;
43
}
44
45
if(isFuelCart((StorageMinecart) event.getSource().getHolder()))
46
{
47
event.setCancelled(true);
48
}
49
}
50
51
//prevent hoppers from filling non coal items in carts
52
@EventHandler
53
public void onMoveItemIntoFuelCartEvent(InventoryMoveItemEvent event)
54
{
55
if(!doHopperLogic)
56
{
57
return;
58
}
59
60
if(!(event.getDestination().getHolder() instanceof StorageMinecart))
61
{
62
return;
63
}
64
65
if(!(event.getSource().getHolder() instanceof Hopper))
66
{
67
return;
68
}
69
70
if((event.getItem().getType() == Material.COAL) || (event.getItem().getType() == Material.CHARCOAL))
71
{
72
return;
73
}
74
75
if(isFuelCart((StorageMinecart) event.getDestination().getHolder()))
76
{
77
event.setCancelled(true);
78
79
//rearrange to possibly let other itemstacks get through
80
if(!HopperUtils.rearrangeHopper(event.getSource(), Material.COAL))
81
{
82
if(!HopperUtils.rearrangeHopper(event.getSource(), Material.CHARCOAL))
83
{
84
//rearranging was not successful
85
return;
86
}
87
}
88
}
89
}
90
91
public boolean isFuelCart(StorageMinecart cart)
92
{
93
if(cart.getCustomName() == null)
94
{
95
return false;
96
}
97
98
if(cart.getCustomName().equalsIgnoreCase(FUEL_CART_NAME))
99
{
100
return true;
101
}
102
103
return false;
104
}
105
}
@@ -0,0 +1,105 @@1
package me.fridtjof.minecarttrains.events;2
3
import me.fridtjof.minecarttrains.MinecartTrains;4
import me.fridtjof.puddingapi.bukkit.items.HopperUtils;5
import org.bukkit.Material;6
import org.bukkit.block.Hopper;7
import org.bukkit.entity.minecart.StorageMinecart;8
import org.bukkit.event.EventHandler;9
import org.bukkit.event.Listener;10
import org.bukkit.event.inventory.InventoryAction;11
import org.bukkit.event.inventory.InventoryMoveItemEvent;12
import org.bukkit.inventory.Inventory;13
import org.bukkit.inventory.InventoryHolder;14
import org.bukkit.inventory.ItemStack;15
16
public class OnInventoryMoveItemEvent implements Listener17
{18
19
static MinecartTrains plugin = MinecartTrains.getInstance();20
21
// config vars22
private final String FUEL_CART_NAME = plugin.configManager.mainConfig.getConfig().getString("trains.fuel.cart_name");23
boolean doHopperLogic = plugin.configManager.mainConfig.getConfig().getBoolean("trains.fuel.do_hopper_logic");24
25
//stop hoppers from unloading fuel carts26
@EventHandler27
public void onMoveItemOutOffFuelCartEvent(InventoryMoveItemEvent event)28
{29
// made this part optional because it can cause problems with other plugins30
if(!doHopperLogic)31
{32
return;33
}34
35
if(!(event.getSource().getHolder() instanceof StorageMinecart))36
{37
return;38
}39
40
if(!(event.getDestination().getHolder() instanceof Hopper))41
{42
return;43
}44
45
if(isFuelCart((StorageMinecart) event.getSource().getHolder()))46
{47
event.setCancelled(true);48
}49
}50
51
//prevent hoppers from filling non coal items in carts52
@EventHandler53
public void onMoveItemIntoFuelCartEvent(InventoryMoveItemEvent event)54
{55
if(!doHopperLogic)56
{57
return;58
}59
60
if(!(event.getDestination().getHolder() instanceof StorageMinecart))61
{62
return;63
}64
65
if(!(event.getSource().getHolder() instanceof Hopper))66
{67
return;68
}69
70
if((event.getItem().getType() == Material.COAL) || (event.getItem().getType() == Material.CHARCOAL))71
{72
return;73
}74
75
if(isFuelCart((StorageMinecart) event.getDestination().getHolder()))76
{77
event.setCancelled(true);78
79
//rearrange to possibly let other itemstacks get through80
if(!HopperUtils.rearrangeHopper(event.getSource(), Material.COAL))81
{82
if(!HopperUtils.rearrangeHopper(event.getSource(), Material.CHARCOAL))83
{84
//rearranging was not successful85
return;86
}87
}88
}89
}90
91
public boolean isFuelCart(StorageMinecart cart)92
{93
if(cart.getCustomName() == null)94
{95
return false;96
}97
98
if(cart.getCustomName().equalsIgnoreCase(FUEL_CART_NAME))99
{100
return true;101
}102
103
return false;104
}105
}@@ -0,0 +1,114 @@
1
package me.fridtjof.minecarttrains.events;
2
3
import me.fridtjof.minecarttrains.managers.LinkageManager;
4
import me.fridtjof.minecarttrains.MinecartTrains;
5
import org.bukkit.Bukkit;
6
import org.bukkit.Material;
7
import org.bukkit.entity.Entity;
8
import org.bukkit.entity.Minecart;
9
import org.bukkit.entity.Player;
10
import org.bukkit.event.EventHandler;
11
import org.bukkit.event.Listener;
12
import org.bukkit.event.player.PlayerInteractEntityEvent;
13
import org.bukkit.inventory.EquipmentSlot;
14
15
import java.util.HashMap;
16
import java.util.Map;
17
import java.util.UUID;
18
19
public class OnPlayerInteractEntityEvent implements Listener
20
{
21
22
// --> coupling tool
23
static MinecartTrains plugin = MinecartTrains.getInstance();
24
25
26
// minecart storage
27
Map<String, Integer> selectedCarts = new HashMap<String, Integer>();
28
Map<String, UUID> firstCarts = new HashMap<String, UUID>();
29
Map<String, UUID> secondCarts = new HashMap<String, UUID>();
30
Map<String, Long> lastCouplings = new HashMap<String, Long>();
31
32
// get config vars
33
Material couplingTool = Material.getMaterial(plugin.configManager.mainConfig.getConfig().getString("trains.coupling.tool"));
34
double maxDistance = plugin.configManager.physicsConfig.getConfig().getDouble("coupling.max_distance");
35
36
LinkageManager linkageManager = new LinkageManager();
37
38
@EventHandler
39
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event)
40
{
41
42
if(event.getHand() != EquipmentSlot.HAND)
43
{
44
return;
45
}
46
47
Player player = event.getPlayer();
48
String playerId = player.getUniqueId() + "";
49
Material material = player.getInventory().getItemInMainHand().getType();
50
Entity target = event.getRightClicked();
51
Minecart minecart;
52
53
if(material != couplingTool)
54
{
55
return;
56
}
57
58
if(!(target instanceof Minecart))
59
{
60
return;
61
}
62
minecart = (Minecart) target;
63
64
event.setCancelled(true);
65
66
//forget first selection
67
if(selectedCarts.get(playerId) == null)
68
{
69
selectedCarts.put(playerId, 1);
70
lastCouplings.put(playerId, System.currentTimeMillis());
71
}
72
else if(lastCouplings.get(playerId) < System.currentTimeMillis() - 10000)
73
{
74
selectedCarts.put(playerId, 1);
75
lastCouplings.put(playerId, System.currentTimeMillis());
76
}
77
78
int selectedCart = selectedCarts.get(playerId);
79
80
if(selectedCart == 1)
81
{
82
firstCarts.put(playerId, minecart.getUniqueId());
83
selectedCarts.put(player.getUniqueId() + "", 2);
84
player.sendMessage(plugin.configManager.messagesFile.getConfig().getString("trains.coupling_1-2") + minecart.getName());
85
}
86
else if(selectedCart == 2)
87
{
88
secondCarts.put(playerId, minecart.getUniqueId());
89
selectedCarts.put(player.getUniqueId() + "", 1);
90
player.sendMessage(plugin.configManager.messagesFile.getConfig().getString("trains.coupling_2-2") + minecart.getName());
91
92
Entity firstCart = Bukkit.getEntity(firstCarts.get(playerId));
93
Entity secondCart = Bukkit.getEntity(secondCarts.get(playerId));
94
95
// check distance
96
if(firstCart.getLocation().distance(secondCart.getLocation()) > maxDistance)
97
{
98
player.sendMessage(plugin.configManager.messagesFile.getConfig().getString("trains.coupling_failed_distance"));
99
return;
100
}
101
102
// check trying to couple with itself
103
if(firstCart == secondCart)
104
{
105
player.sendMessage(plugin.configManager.messagesFile.getConfig().getString("trains.coupling_failed_self"));
106
return;
107
}
108
109
linkageManager.setLink((Minecart) secondCart, firstCarts.get(playerId) + "");
110
111
player.sendMessage(plugin.configManager.messagesFile.getConfig().getString("trains.coupling_successful"));
112
}
113
}
114
}
@@ -0,0 +1,114 @@1
package me.fridtjof.minecarttrains.events;2
3
import me.fridtjof.minecarttrains.managers.LinkageManager;4
import me.fridtjof.minecarttrains.MinecartTrains;5
import org.bukkit.Bukkit;6
import org.bukkit.Material;7
import org.bukkit.entity.Entity;8
import org.bukkit.entity.Minecart;9
import org.bukkit.entity.Player;10
import org.bukkit.event.EventHandler;11
import org.bukkit.event.Listener;12
import org.bukkit.event.player.PlayerInteractEntityEvent;13
import org.bukkit.inventory.EquipmentSlot;14
15
import java.util.HashMap;16
import java.util.Map;17
import java.util.UUID;18
19
public class OnPlayerInteractEntityEvent implements Listener20
{21
22
// --> coupling tool23
static MinecartTrains plugin = MinecartTrains.getInstance();24
25
26
// minecart storage27
Map<String, Integer> selectedCarts = new HashMap<String, Integer>();28
Map<String, UUID> firstCarts = new HashMap<String, UUID>();29
Map<String, UUID> secondCarts = new HashMap<String, UUID>();30
Map<String, Long> lastCouplings = new HashMap<String, Long>();31
32
// get config vars33
Material couplingTool = Material.getMaterial(plugin.configManager.mainConfig.getConfig().getString("trains.coupling.tool"));34
double maxDistance = plugin.configManager.physicsConfig.getConfig().getDouble("coupling.max_distance");35
36
LinkageManager linkageManager = new LinkageManager();37
38
@EventHandler39
public void onPlayerInteractEntityEvent(PlayerInteractEntityEvent event)40
{41
42
if(event.getHand() != EquipmentSlot.HAND)43
{44
return;45
}46
47
Player player = event.getPlayer();48
String playerId = player.getUniqueId() + "";49
Material material = player.getInventory().getItemInMainHand().getType();50
Entity target = event.getRightClicked();51
Minecart minecart;52
53
if(material != couplingTool)54
{55
return;56
}57
58
if(!(target instanceof Minecart))59
{60
return;61
}62
minecart = (Minecart) target;63
64
event.setCancelled(true);65
66
//forget first selection67
if(selectedCarts.get(playerId) == null)68
{69
selectedCarts.put(playerId, 1);70
lastCouplings.put(playerId, System.currentTimeMillis());71
}72
else if(lastCouplings.get(playerId) < System.currentTimeMillis() - 10000)73
{74
selectedCarts.put(playerId, 1);75
lastCouplings.put(playerId, System.currentTimeMillis());76
}77
78
int selectedCart = selectedCarts.get(playerId);79
80
if(selectedCart == 1)81
{82
firstCarts.put(playerId, minecart.getUniqueId());83
selectedCarts.put(player.getUniqueId() + "", 2);84
player.sendMessage(plugin.configManager.messagesFile.getConfig().getString("trains.coupling_1-2") + minecart.getName());85
}86
else if(selectedCart == 2)87
{88
secondCarts.put(playerId, minecart.getUniqueId());89
selectedCarts.put(player.getUniqueId() + "", 1);90
player.sendMessage(plugin.configManager.messagesFile.getConfig().getString("trains.coupling_2-2") + minecart.getName());91
92
Entity firstCart = Bukkit.getEntity(firstCarts.get(playerId));93
Entity secondCart = Bukkit.getEntity(secondCarts.get(playerId));94
95
// check distance96
if(firstCart.getLocation().distance(secondCart.getLocation()) > maxDistance)97
{98
player.sendMessage(plugin.configManager.messagesFile.getConfig().getString("trains.coupling_failed_distance"));99
return;100
}101
102
// check trying to couple with itself103
if(firstCart == secondCart)104
{105
player.sendMessage(plugin.configManager.messagesFile.getConfig().getString("trains.coupling_failed_self"));106
return;107
}108
109
linkageManager.setLink((Minecart) secondCart, firstCarts.get(playerId) + "");110
111
player.sendMessage(plugin.configManager.messagesFile.getConfig().getString("trains.coupling_successful"));112
}113
}114
}@@ -0,0 +1,36 @@
1
package me.fridtjof.minecarttrains.events;
2
3
import me.fridtjof.minecarttrains.MinecartTrains;
4
import org.bukkit.entity.Arrow;
5
import org.bukkit.entity.Minecart;
6
import org.bukkit.event.EventHandler;
7
import org.bukkit.event.Listener;
8
import org.bukkit.event.entity.ProjectileHitEvent;
9
10
public class OnProjectileHitEvent implements Listener {
11
12
static MinecartTrains plugin = MinecartTrains.getInstance();
13
boolean cancelBeHit = plugin.configManager.mainConfig.getConfig().getBoolean("trains.can_get_hit_by_arrows");
14
15
//canceling arrow hit
16
@EventHandler
17
public void onProjectileHitEvent(ProjectileHitEvent event)
18
{
19
if(cancelBeHit)
20
{
21
return;
22
}
23
24
if(!(event.getEntity() instanceof Arrow))
25
{
26
return;
27
}
28
29
if(!(event.getHitEntity() instanceof Minecart))
30
{
31
return;
32
}
33
34
event.setCancelled(true);
35
}
36
}
@@ -0,0 +1,36 @@1
package me.fridtjof.minecarttrains.events;2
3
import me.fridtjof.minecarttrains.MinecartTrains;4
import org.bukkit.entity.Arrow;5
import org.bukkit.entity.Minecart;6
import org.bukkit.event.EventHandler;7
import org.bukkit.event.Listener;8
import org.bukkit.event.entity.ProjectileHitEvent;9
10
public class OnProjectileHitEvent implements Listener {11
12
static MinecartTrains plugin = MinecartTrains.getInstance();13
boolean cancelBeHit = plugin.configManager.mainConfig.getConfig().getBoolean("trains.can_get_hit_by_arrows");14
15
//canceling arrow hit16
@EventHandler17
public void onProjectileHitEvent(ProjectileHitEvent event)18
{19
if(cancelBeHit)20
{21
return;22
}23
24
if(!(event.getEntity() instanceof Arrow))25
{26
return;27
}28
29
if(!(event.getHitEntity() instanceof Minecart))30
{31
return;32
}33
34
event.setCancelled(true);35
}36
}@@ -0,0 +1,40 @@
1
package me.fridtjof.minecarttrains.events;
2
3
import me.fridtjof.minecarttrains.MinecartTrains;
4
import org.bukkit.Material;
5
import org.bukkit.entity.minecart.StorageMinecart;
6
import org.bukkit.event.EventHandler;
7
import org.bukkit.event.Listener;
8
import org.bukkit.event.vehicle.VehicleCreateEvent;
9
10
public class OnVehicleCreateEvent implements Listener
11
{
12
13
static MinecartTrains plugin = MinecartTrains.getInstance();
14
15
private final String FUEL_CART_NAME = plugin.configManager.mainConfig.getConfig().getString("trains.fuel.cart_name");
16
17
//create fuel cart
18
@EventHandler
19
public void onVehicleCreateEvent(VehicleCreateEvent event)
20
{
21
if(!(event.getVehicle() instanceof StorageMinecart))
22
{
23
return;
24
}
25
26
StorageMinecart cart = (StorageMinecart) event.getVehicle();
27
28
if(cart.getCustomName() == null)
29
{
30
return;
31
}
32
33
if(!cart.getCustomName().equalsIgnoreCase(FUEL_CART_NAME))
34
{
35
return;
36
}
37
38
cart.setDisplayBlockData(Material.COAL_BLOCK.createBlockData());
39
}
40
}
@@ -0,0 +1,40 @@1
package me.fridtjof.minecarttrains.events;2
3
import me.fridtjof.minecarttrains.MinecartTrains;4
import org.bukkit.Material;5
import org.bukkit.entity.minecart.StorageMinecart;6
import org.bukkit.event.EventHandler;7
import org.bukkit.event.Listener;8
import org.bukkit.event.vehicle.VehicleCreateEvent;9
10
public class OnVehicleCreateEvent implements Listener11
{12
13
static MinecartTrains plugin = MinecartTrains.getInstance();14
15
private final String FUEL_CART_NAME = plugin.configManager.mainConfig.getConfig().getString("trains.fuel.cart_name");16
17
//create fuel cart18
@EventHandler19
public void onVehicleCreateEvent(VehicleCreateEvent event)20
{21
if(!(event.getVehicle() instanceof StorageMinecart))22
{23
return;24
}25
26
StorageMinecart cart = (StorageMinecart) event.getVehicle();27
28
if(cart.getCustomName() == null)29
{30
return;31
}32
33
if(!cart.getCustomName().equalsIgnoreCase(FUEL_CART_NAME))34
{35
return;36
}37
38
cart.setDisplayBlockData(Material.COAL_BLOCK.createBlockData());39
}40
}@@ -0,0 +1,70 @@
1
package me.fridtjof.minecarttrains.events;
2
3
import me.fridtjof.minecarttrains.MinecartTrains;
4
import org.bukkit.GameMode;
5
import org.bukkit.entity.*;
6
import org.bukkit.entity.minecart.RideableMinecart;
7
import org.bukkit.event.EventHandler;
8
import org.bukkit.event.Listener;
9
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
10
11
public class OnVehicleEntityCollisionEvent implements Listener
12
{
13
14
static MinecartTrains plugin = MinecartTrains.getInstance();
15
16
// get config vars
17
boolean runOver = plugin.configManager.mainConfig.getConfig().getBoolean("trains.run_over.entities");
18
double damage = plugin.configManager.mainConfig.getConfig().getDouble("trains.run_over.damage");
19
double minVelocity = plugin.configManager.mainConfig.getConfig().getDouble("trains.run_over.min_velocity");
20
21
// killing entities when run over
22
@EventHandler
23
public void onVehicleEntityCollision(VehicleEntityCollisionEvent event)
24
{
25
26
if(!runOver)
27
{
28
return;
29
}
30
31
Vehicle vehicle = event.getVehicle();
32
Entity entity = event.getEntity();
33
34
if(!(vehicle instanceof Minecart))
35
{
36
return;
37
}
38
if(entity instanceof Minecart)
39
{
40
return;
41
}
42
if(!(entity instanceof Damageable))
43
{
44
return;
45
}
46
47
if(vehicle instanceof RideableMinecart)
48
{
49
if(vehicle.getPassenger() == null)
50
{
51
return;
52
}
53
}
54
55
//fixing rare situations where a player riding the cart was killed
56
if(entity.isInsideVehicle())
57
{
58
return;
59
}
60
61
if(vehicle.getVelocity().length() < minVelocity)
62
{
63
return;
64
}
65
66
Damageable damageable = (Damageable) entity;
67
//damageable.setHealth(0); this also killed player in gamemode 1
68
damageable.damage(damage, vehicle);
69
}
70
}
@@ -0,0 +1,70 @@1
package me.fridtjof.minecarttrains.events;2
3
import me.fridtjof.minecarttrains.MinecartTrains;4
import org.bukkit.GameMode;5
import org.bukkit.entity.*;6
import org.bukkit.entity.minecart.RideableMinecart;7
import org.bukkit.event.EventHandler;8
import org.bukkit.event.Listener;9
import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;10
11
public class OnVehicleEntityCollisionEvent implements Listener12
{13
14
static MinecartTrains plugin = MinecartTrains.getInstance();15
16
// get config vars17
boolean runOver = plugin.configManager.mainConfig.getConfig().getBoolean("trains.run_over.entities");18
double damage = plugin.configManager.mainConfig.getConfig().getDouble("trains.run_over.damage");19
double minVelocity = plugin.configManager.mainConfig.getConfig().getDouble("trains.run_over.min_velocity");20
21
// killing entities when run over22
@EventHandler23
public void onVehicleEntityCollision(VehicleEntityCollisionEvent event)24
{25
26
if(!runOver)27
{28
return;29
}30
31
Vehicle vehicle = event.getVehicle();32
Entity entity = event.getEntity();33
34
if(!(vehicle instanceof Minecart))35
{36
return;37
}38
if(entity instanceof Minecart)39
{40
return;41
}42
if(!(entity instanceof Damageable))43
{44
return;45
}46
47
if(vehicle instanceof RideableMinecart)48
{49
if(vehicle.getPassenger() == null)50
{51
return;52
}53
}54
55
//fixing rare situations where a player riding the cart was killed56
if(entity.isInsideVehicle())57
{58
return;59
}60
61
if(vehicle.getVelocity().length() < minVelocity)62
{63
return;64
}65
66
Damageable damageable = (Damageable) entity;67
//damageable.setHealth(0); this also killed player in gamemode 168
damageable.damage(damage, vehicle);69
}70
}@@ -0,0 +1,79 @@
1
package me.fridtjof.minecarttrains.events;
2
3
import me.fridtjof.minecarttrains.MinecartTrains;
4
import me.fridtjof.minecarttrains.managers.LinkageManager;
5
import org.bukkit.Bukkit;
6
import org.bukkit.Location;
7
import org.bukkit.Material;
8
import org.bukkit.World;
9
import org.bukkit.block.Block;
10
import org.bukkit.entity.Minecart;
11
import org.bukkit.event.EventHandler;
12
import org.bukkit.event.Listener;
13
import org.bukkit.event.vehicle.VehicleMoveEvent;
14
import org.bukkit.util.Vector;
15
16
public class OnVehicleMoveEvent implements Listener {
17
18
19
static MinecartTrains plugin = MinecartTrains.getInstance();
20
LinkageManager linkageManager = plugin.linkageManager;
21
22
double defaultSpeed = 0.4;
23
boolean doHighSpeed = plugin.configManager.mainConfig.getConfig().getBoolean("tracks.high_speed_tracks.enable");
24
Material highSpeedBlock = Material.getMaterial(plugin.configManager.mainConfig.getConfig().getString("tracks.high_speed_tracks.bed_block"));
25
double maxHighSpeedSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("track.high_speed.max_speed");
26
double acceleration = plugin.configManager.physicsConfig.getConfig().getDouble("track.high_speed.acceleration");
27
28
@EventHandler
29
public void onVehicleMove(VehicleMoveEvent event)
30
{
31
if(!doHighSpeed)
32
{
33
return;
34
}
35
36
// only continue if vehicle is a minecart
37
if(!(event.getVehicle() instanceof Minecart))
38
{
39
return;
40
}
41
42
Minecart minecart = (Minecart) event.getVehicle();
43
World world = minecart.getWorld();
44
Location location = minecart.getLocation();
45
46
if(linkageManager.hasLink(minecart))
47
{
48
Minecart parent = (Minecart) Bukkit.getEntity(linkageManager.getLinkUniqueId(minecart));
49
50
minecart.setMaxSpeed(parent.getMaxSpeed());
51
return;
52
}
53
54
Block track = world.getBlockAt(location);
55
Block bed = world.getBlockAt(location.add(0, -1, 0));
56
57
if(track.getType() != Material.POWERED_RAIL)
58
{
59
return;
60
}
61
if(bed.getType() != highSpeedBlock)
62
{
63
minecart.setMaxSpeed(defaultSpeed);
64
return;
65
}
66
67
double currentMaxSpeed = minecart.getMaxSpeed();
68
69
if(currentMaxSpeed < maxHighSpeedSpeed)
70
{
71
//minecart.setMaxSpeed(currentMaxSpeed * acceleration);
72
minecart.setMaxSpeed(currentMaxSpeed + acceleration);
73
}
74
if(currentMaxSpeed > maxHighSpeedSpeed)
75
{
76
minecart.setMaxSpeed(maxHighSpeedSpeed);
77
}
78
}
79
}
@@ -0,0 +1,79 @@1
package me.fridtjof.minecarttrains.events;2
3
import me.fridtjof.minecarttrains.MinecartTrains;4
import me.fridtjof.minecarttrains.managers.LinkageManager;5
import org.bukkit.Bukkit;6
import org.bukkit.Location;7
import org.bukkit.Material;8
import org.bukkit.World;9
import org.bukkit.block.Block;10
import org.bukkit.entity.Minecart;11
import org.bukkit.event.EventHandler;12
import org.bukkit.event.Listener;13
import org.bukkit.event.vehicle.VehicleMoveEvent;14
import org.bukkit.util.Vector;15
16
public class OnVehicleMoveEvent implements Listener {17
18
19
static MinecartTrains plugin = MinecartTrains.getInstance();20
LinkageManager linkageManager = plugin.linkageManager;21
22
double defaultSpeed = 0.4;23
boolean doHighSpeed = plugin.configManager.mainConfig.getConfig().getBoolean("tracks.high_speed_tracks.enable");24
Material highSpeedBlock = Material.getMaterial(plugin.configManager.mainConfig.getConfig().getString("tracks.high_speed_tracks.bed_block"));25
double maxHighSpeedSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("track.high_speed.max_speed");26
double acceleration = plugin.configManager.physicsConfig.getConfig().getDouble("track.high_speed.acceleration");27
28
@EventHandler29
public void onVehicleMove(VehicleMoveEvent event)30
{31
if(!doHighSpeed)32
{33
return;34
}35
36
// only continue if vehicle is a minecart37
if(!(event.getVehicle() instanceof Minecart))38
{39
return;40
}41
42
Minecart minecart = (Minecart) event.getVehicle();43
World world = minecart.getWorld();44
Location location = minecart.getLocation();45
46
if(linkageManager.hasLink(minecart))47
{48
Minecart parent = (Minecart) Bukkit.getEntity(linkageManager.getLinkUniqueId(minecart));49
50
minecart.setMaxSpeed(parent.getMaxSpeed());51
return;52
}53
54
Block track = world.getBlockAt(location);55
Block bed = world.getBlockAt(location.add(0, -1, 0));56
57
if(track.getType() != Material.POWERED_RAIL)58
{59
return;60
}61
if(bed.getType() != highSpeedBlock)62
{63
minecart.setMaxSpeed(defaultSpeed);64
return;65
}66
67
double currentMaxSpeed = minecart.getMaxSpeed();68
69
if(currentMaxSpeed < maxHighSpeedSpeed)70
{71
//minecart.setMaxSpeed(currentMaxSpeed * acceleration);72
minecart.setMaxSpeed(currentMaxSpeed + acceleration);73
}74
if(currentMaxSpeed > maxHighSpeedSpeed)75
{76
minecart.setMaxSpeed(maxHighSpeedSpeed);77
}78
}79
}@@ -0,0 +1,251 @@
1
package me.fridtjof.minecarttrains.events;
2
3
import me.fridtjof.minecarttrains.managers.LinkageManager;
4
import me.fridtjof.minecarttrains.MinecartTrains;
5
import org.bukkit.Bukkit;
6
import org.bukkit.Location;
7
import org.bukkit.Material;
8
import org.bukkit.World;
9
import org.bukkit.block.Block;
10
import org.bukkit.block.data.type.RedstoneRail;
11
import org.bukkit.entity.Entity;
12
import org.bukkit.entity.Minecart;
13
import org.bukkit.entity.Player;
14
import org.bukkit.entity.Vehicle;
15
import org.bukkit.entity.minecart.PoweredMinecart;
16
import org.bukkit.event.EventHandler;
17
import org.bukkit.event.Listener;
18
import org.bukkit.event.vehicle.VehicleUpdateEvent;
19
import org.bukkit.util.Vector;
20
21
public class OnVehicleUpdateEvent implements Listener
22
{
23
24
static MinecartTrains plugin = MinecartTrains.getInstance();
25
LinkageManager linkageManager = plugin.linkageManager;
26
27
// config vars
28
int fuelPerTick = plugin.configManager.mainConfig.getConfig().getInt("trains.fuel.consumption_per_tick");
29
30
double maxDistance = plugin.configManager.physicsConfig.getConfig().getDouble("link.distance.max");
31
double minDistance = plugin.configManager.physicsConfig.getConfig().getDouble("link.distance.min");
32
33
double couplingPullSpeedLowSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.low_speed.speed.pull");
34
double couplingPushSpeedLowSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.low_speed.speed.push");
35
double aimedDistanceLowSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.low_speed.distance.aimed");
36
double aimedDistanceToleranceLowSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.low_speed.distance.aimed_tolerance");
37
38
double couplingPullSpeedHighSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.high_speed.speed.pull");
39
double couplingPushSpeedHighSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.high_speed.speed.push");
40
double aimedDistanceHighSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.high_speed.distance.aimed");
41
double aimedDistanceToleranceHighSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.high_speed.distance.aimed_tolerance");
42
43
double highSpeedGate = plugin.configManager.physicsConfig.getConfig().getDouble("link.high_speed.gate_speed");
44
45
46
@EventHandler
47
public void onVehicleUpdate(VehicleUpdateEvent event)
48
{
49
Vehicle vehicle = event.getVehicle();
50
Minecart minecart;
51
String uniqueId;
52
Entity parent;
53
54
if(!(vehicle instanceof Minecart))
55
{
56
return;
57
}
58
minecart = (Minecart) vehicle;
59
60
//DEBUG
61
/*if(!minecart.getPassengers().isEmpty())
62
{
63
Entity passenger = minecart.getPassengers().get(0);
64
if((passenger instanceof Player))
65
{
66
double shownSpeed = minecart.getVelocity().length() * 72;
67
passenger.sendMessage("Speed: " + (int)shownSpeed + " km/h");
68
}
69
}*/
70
71
// ensures the below function only works on trains, not on single minecarts
72
if(!linkageManager.hasLink((minecart)))
73
{
74
75
// causes a full stop for Furnace Minecart on un-powered rail, and pauses Fuel Consumption.
76
if(!(minecart instanceof PoweredMinecart))
77
{
78
return;
79
}
80
81
PoweredMinecart poweredCart = (PoweredMinecart) minecart;
82
83
int fuelAfterConsumption = poweredCart.getFuel() - fuelPerTick + 1;
84
85
if(fuelAfterConsumption < 0)
86
{
87
fuelAfterConsumption = 0;
88
}
89
poweredCart.setFuel(fuelAfterConsumption);
90
91
Block block = poweredCart.getLocation().getBlock();
92
if(block.getType() != Material.POWERED_RAIL) {
93
return;
94
}
95
RedstoneRail redstoneRail = (RedstoneRail) block.getBlockData();
96
if(redstoneRail.isPowered()) {
97
return;
98
}
99
poweredCart.setVelocity(new Vector(0 ,0 ,0));
100
101
//to stop fuel consumption just re-add the consumed
102
poweredCart.setFuel(((PoweredMinecart) poweredCart).getFuel() + fuelPerTick);
103
104
return;
105
}
106
107
parent = Bukkit.getEntity(linkageManager.getLinkUniqueId(minecart));
108
109
// breaks link if parent cart is broken
110
if(parent == null)
111
{
112
linkageManager.removeLink(minecart);
113
return;
114
}
115
116
// breaks link if the parent and child are the same cart
117
if(parent == minecart)
118
{
119
plugin.getLogger().warning(plugin.configManager.mainConfig.getConfig().getString("trains.coupling_already_coupled_with_itself"));
120
linkageManager.removeLink(minecart);
121
return;
122
}
123
124
125
//check if parent is in same world
126
World childWorld = minecart.getWorld();
127
World parentWorld = parent.getWorld();
128
if(childWorld != parentWorld)
129
{
130
linkageManager.removeLink(minecart);
131
return;
132
}
133
134
135
// may cause problems
136
//check if parent is derailed
137
Location minecartLocation = minecart.getLocation();
138
Material parentTrack = parentWorld.getBlockAt(parent.getLocation()).getType();
139
Material parentTrackOnHill = parentWorld.getBlockAt(parent.getLocation().add(0, -1, 0)).getType();
140
if(!isAnyKindOfTrack(parentTrack) && !isAnyKindOfTrack(parentTrackOnHill))
141
{
142
linkageManager.removeLink(minecart);
143
return;
144
}
145
146
147
// defines the distance value as (parent's location)-(child's location)
148
double distance = minecart.getLocation().distance(parent.getLocation());
149
150
/* Sets the speed at which carts move towards their dependant. At HSRail speeds, this value must be high
151
to avoid breaking trains during acceleration.
152
Values in excess of 5 require more precision for the 'else if' statements, or else carts will overshoot
153
and collide, disrupting momentum and causing the 'jiggle' bug.*/
154
double pullSpeed;
155
double pushSpeed;
156
157
double aimedDistance;
158
double aimedDistanceTolerance;
159
160
// sets the parts pull vars based on the speed of the parent
161
if(parent.getVelocity().length() <= highSpeedGate)
162
{
163
//low speed
164
pullSpeed = couplingPullSpeedLowSpeed;
165
aimedDistance = this.aimedDistanceLowSpeed;
166
aimedDistanceTolerance = this.aimedDistanceToleranceLowSpeed;
167
}
168
else
169
{
170
//high speed
171
pullSpeed = couplingPullSpeedHighSpeed;
172
aimedDistance = this.aimedDistanceHighSpeed;
173
aimedDistanceTolerance = this.aimedDistanceToleranceHighSpeed;
174
}
175
176
177
// sets the carts push speed based on its own speed
178
if(minecart.getVelocity().length() <= highSpeedGate)
179
{
180
//low speed
181
pushSpeed = couplingPushSpeedLowSpeed;
182
}
183
else
184
{
185
//high speed
186
pushSpeed = couplingPushSpeedHighSpeed;
187
}
188
189
190
/* Sets max/min distance for links. Shorter distances are more reliable along corners, however, until the
191
linkageManager can be reworked, longer maximums are needed to handle acceleration.
192
If distance is out of bonds the links get removed and the cart stopped to prevent runaway trains. */
193
if((distance > maxDistance) || distance < minDistance)
194
{
195
linkageManager.removeLink(minecart);
196
minecart.setVelocity(new Vector(0, 0, 0));
197
parent.setVelocity(new Vector(0, 0, 0));
198
}
199
200
/* Handles gap between parent and dependant. Values set too low result in collisions between carts
201
while train is sitting still, especially on declines, causing 'jiggling' that kills momentum
202
More precise parameters helps to eliminate the 'jiggling' behavior that interferes with momentum
203
Slower 'away' speeds compared to 'toward' speeds also help to eliminate 'jiggling' */
204
// acceleration if distance to small
205
else if(distance < (aimedDistance - aimedDistanceTolerance))
206
{
207
moveToward(minecart, parent, pushSpeed, (distance - aimedDistance));
208
}
209
// acceleration if distance to large
210
else if(distance > (aimedDistance + aimedDistanceTolerance))
211
{
212
moveToward(minecart, parent, pullSpeed, (distance - aimedDistance));
213
}
214
}
215
216
// defines moveToward, which handles the elastic movement of dependant carts. Uses the speed and direction set earlier
217
public void moveToward(Entity child, Entity parent, double speed, double distance)
218
{
219
Location childLoc = child.getLocation();
220
Location parentLoc = parent.getLocation();
221
222
double x = childLoc.getX() - parentLoc.getX();
223
double y = childLoc.getY() - parentLoc.getY();
224
double z = childLoc.getZ() - parentLoc.getZ();
225
Vector velocity = new Vector(x, y, z).normalize().multiply(-speed);
226
child.setVelocity(velocity.multiply((distance * distance * distance)));
227
}
228
229
230
//TODO move to puddingapi
231
public boolean isAnyKindOfTrack(Material material)
232
{
233
if(material == Material.POWERED_RAIL)
234
{
235
return true;
236
}
237
if(material == Material.RAIL)
238
{
239
return true;
240
}
241
if(material == Material.ACTIVATOR_RAIL)
242
{
243
return true;
244
}
245
if(material == Material.DETECTOR_RAIL)
246
{
247
return true;
248
}
249
return false;
250
}
251
}
@@ -0,0 +1,251 @@1
package me.fridtjof.minecarttrains.events;2
3
import me.fridtjof.minecarttrains.managers.LinkageManager;4
import me.fridtjof.minecarttrains.MinecartTrains;5
import org.bukkit.Bukkit;6
import org.bukkit.Location;7
import org.bukkit.Material;8
import org.bukkit.World;9
import org.bukkit.block.Block;10
import org.bukkit.block.data.type.RedstoneRail;11
import org.bukkit.entity.Entity;12
import org.bukkit.entity.Minecart;13
import org.bukkit.entity.Player;14
import org.bukkit.entity.Vehicle;15
import org.bukkit.entity.minecart.PoweredMinecart;16
import org.bukkit.event.EventHandler;17
import org.bukkit.event.Listener;18
import org.bukkit.event.vehicle.VehicleUpdateEvent;19
import org.bukkit.util.Vector;20
21
public class OnVehicleUpdateEvent implements Listener22
{23
24
static MinecartTrains plugin = MinecartTrains.getInstance();25
LinkageManager linkageManager = plugin.linkageManager;26
27
// config vars28
int fuelPerTick = plugin.configManager.mainConfig.getConfig().getInt("trains.fuel.consumption_per_tick");29
30
double maxDistance = plugin.configManager.physicsConfig.getConfig().getDouble("link.distance.max");31
double minDistance = plugin.configManager.physicsConfig.getConfig().getDouble("link.distance.min");32
33
double couplingPullSpeedLowSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.low_speed.speed.pull");34
double couplingPushSpeedLowSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.low_speed.speed.push");35
double aimedDistanceLowSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.low_speed.distance.aimed");36
double aimedDistanceToleranceLowSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.low_speed.distance.aimed_tolerance");37
38
double couplingPullSpeedHighSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.high_speed.speed.pull");39
double couplingPushSpeedHighSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.high_speed.speed.push");40
double aimedDistanceHighSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.high_speed.distance.aimed");41
double aimedDistanceToleranceHighSpeed = plugin.configManager.physicsConfig.getConfig().getDouble("link.high_speed.distance.aimed_tolerance");42
43
double highSpeedGate = plugin.configManager.physicsConfig.getConfig().getDouble("link.high_speed.gate_speed");44
45
46
@EventHandler47
public void onVehicleUpdate(VehicleUpdateEvent event)48
{49
Vehicle vehicle = event.getVehicle();50
Minecart minecart;51
String uniqueId;52
Entity parent;53
54
if(!(vehicle instanceof Minecart))55
{56
return;57
}58
minecart = (Minecart) vehicle;59
60
//DEBUG61
/*if(!minecart.getPassengers().isEmpty())62
{63
Entity passenger = minecart.getPassengers().get(0);64
if((passenger instanceof Player))65
{66
double shownSpeed = minecart.getVelocity().length() * 72;67
passenger.sendMessage("Speed: " + (int)shownSpeed + " km/h");68
}69
}*/70
71
// ensures the below function only works on trains, not on single minecarts72
if(!linkageManager.hasLink((minecart)))73
{74
75
// causes a full stop for Furnace Minecart on un-powered rail, and pauses Fuel Consumption.76
if(!(minecart instanceof PoweredMinecart))77
{78
return;79
}80
81
PoweredMinecart poweredCart = (PoweredMinecart) minecart;82
83
int fuelAfterConsumption = poweredCart.getFuel() - fuelPerTick + 1;84
85
if(fuelAfterConsumption < 0)86
{87
fuelAfterConsumption = 0;88
}89
poweredCart.setFuel(fuelAfterConsumption);90
91
Block block = poweredCart.getLocation().getBlock();92
if(block.getType() != Material.POWERED_RAIL) {93
return;94
}95
RedstoneRail redstoneRail = (RedstoneRail) block.getBlockData();96
if(redstoneRail.isPowered()) {97
return;98
}99
poweredCart.setVelocity(new Vector(0 ,0 ,0));100
101
//to stop fuel consumption just re-add the consumed102
poweredCart.setFuel(((PoweredMinecart) poweredCart).getFuel() + fuelPerTick);103
104
return;105
}106
107
parent = Bukkit.getEntity(linkageManager.getLinkUniqueId(minecart));108
109
// breaks link if parent cart is broken110
if(parent == null)111
{112
linkageManager.removeLink(minecart);113
return;114
}115
116
// breaks link if the parent and child are the same cart117
if(parent == minecart)118
{119
plugin.getLogger().warning(plugin.configManager.mainConfig.getConfig().getString("trains.coupling_already_coupled_with_itself"));120
linkageManager.removeLink(minecart);121
return;122
}123
124
125
//check if parent is in same world126
World childWorld = minecart.getWorld();127
World parentWorld = parent.getWorld();128
if(childWorld != parentWorld)129
{130
linkageManager.removeLink(minecart);131
return;132
}133
134
135
// may cause problems136
//check if parent is derailed137
Location minecartLocation = minecart.getLocation();138
Material parentTrack = parentWorld.getBlockAt(parent.getLocation()).getType();139
Material parentTrackOnHill = parentWorld.getBlockAt(parent.getLocation().add(0, -1, 0)).getType();140
if(!isAnyKindOfTrack(parentTrack) && !isAnyKindOfTrack(parentTrackOnHill))141
{142
linkageManager.removeLink(minecart);143
return;144
}145
146
147
// defines the distance value as (parent's location)-(child's location)148
double distance = minecart.getLocation().distance(parent.getLocation());149
150
/* Sets the speed at which carts move towards their dependant. At HSRail speeds, this value must be high151
to avoid breaking trains during acceleration.152
Values in excess of 5 require more precision for the 'else if' statements, or else carts will overshoot153
and collide, disrupting momentum and causing the 'jiggle' bug.*/154
double pullSpeed;155
double pushSpeed;156
157
double aimedDistance;158
double aimedDistanceTolerance;159
160
// sets the parts pull vars based on the speed of the parent161
if(parent.getVelocity().length() <= highSpeedGate)162
{163
//low speed164
pullSpeed = couplingPullSpeedLowSpeed;165
aimedDistance = this.aimedDistanceLowSpeed;166
aimedDistanceTolerance = this.aimedDistanceToleranceLowSpeed;167
}168
else169
{170
//high speed171
pullSpeed = couplingPullSpeedHighSpeed;172
aimedDistance = this.aimedDistanceHighSpeed;173
aimedDistanceTolerance = this.aimedDistanceToleranceHighSpeed;174
}175
176
177
// sets the carts push speed based on its own speed178
if(minecart.getVelocity().length() <= highSpeedGate)179
{180
//low speed181
pushSpeed = couplingPushSpeedLowSpeed;182
}183
else184
{185
//high speed186
pushSpeed = couplingPushSpeedHighSpeed;187
}188
189
190
/* Sets max/min distance for links. Shorter distances are more reliable along corners, however, until the191
linkageManager can be reworked, longer maximums are needed to handle acceleration.192
If distance is out of bonds the links get removed and the cart stopped to prevent runaway trains. */193
if((distance > maxDistance) || distance < minDistance)194
{195
linkageManager.removeLink(minecart);196
minecart.setVelocity(new Vector(0, 0, 0));197
parent.setVelocity(new Vector(0, 0, 0));198
}199
200
/* Handles gap between parent and dependant. Values set too low result in collisions between carts201
while train is sitting still, especially on declines, causing 'jiggling' that kills momentum202
More precise parameters helps to eliminate the 'jiggling' behavior that interferes with momentum203
Slower 'away' speeds compared to 'toward' speeds also help to eliminate 'jiggling' */204
// acceleration if distance to small205
else if(distance < (aimedDistance - aimedDistanceTolerance))206
{207
moveToward(minecart, parent, pushSpeed, (distance - aimedDistance));208
}209
// acceleration if distance to large210
else if(distance > (aimedDistance + aimedDistanceTolerance))211
{212
moveToward(minecart, parent, pullSpeed, (distance - aimedDistance));213
}214
}215
216
// defines moveToward, which handles the elastic movement of dependant carts. Uses the speed and direction set earlier217
public void moveToward(Entity child, Entity parent, double speed, double distance)218
{219
Location childLoc = child.getLocation();220
Location parentLoc = parent.getLocation();221
222
double x = childLoc.getX() - parentLoc.getX();223
double y = childLoc.getY() - parentLoc.getY();224
double z = childLoc.getZ() - parentLoc.getZ();225
Vector velocity = new Vector(x, y, z).normalize().multiply(-speed);226
child.setVelocity(velocity.multiply((distance * distance * distance)));227
}228
229
230
//TODO move to puddingapi231
public boolean isAnyKindOfTrack(Material material)232
{233
if(material == Material.POWERED_RAIL)234
{235
return true;236
}237
if(material == Material.RAIL)238
{239
return true;240
}241
if(material == Material.ACTIVATOR_RAIL)242
{243
return true;244
}245
if(material == Material.DETECTOR_RAIL)246
{247
return true;248
}249
return false;250
}251
}@@ -0,0 +1,96 @@
1
package me.fridtjof.minecarttrains.events;
2
3
import me.fridtjof.minecarttrains.managers.LinkageManager;
4
import me.fridtjof.minecarttrains.MinecartTrains;
5
import org.bukkit.Material;
6
import org.bukkit.entity.Entity;
7
import org.bukkit.entity.Vehicle;
8
import org.bukkit.entity.minecart.PoweredMinecart;
9
import org.bukkit.entity.minecart.StorageMinecart;
10
import org.bukkit.event.EventHandler;
11
import org.bukkit.event.EventPriority;
12
import org.bukkit.event.Listener;
13
import org.bukkit.event.vehicle.VehicleUpdateEvent;
14
import org.bukkit.inventory.Inventory;
15
import org.bukkit.inventory.ItemStack;
16
17
import java.util.List;
18
19
public class OnVehicleUpdateEventLowestPriority implements Listener
20
{
21
22
static MinecartTrains plugin = MinecartTrains.getInstance();
23
LinkageManager linkageManager = new LinkageManager();
24
25
private final int FUEL_PER_TICK = plugin.configManager.mainConfig.getConfig().getInt("trains.fuel.consumption_per_tick");
26
private final boolean REFILL_ONLY_FROM_TENDER = plugin.configManager.mainConfig.getConfig().getBoolean("trains.fuel.refill_only_from_fuel_cart");
27
private final String FUEL_CART_NAME = plugin.configManager.mainConfig.getConfig().getString("trains.fuel.cart_name");
28
29
@EventHandler(priority = EventPriority.LOWEST)
30
public void OnFuelEmptyEvent(VehicleUpdateEvent event) {
31
Vehicle vehicle = event.getVehicle();
32
String uniqueId;
33
Entity parent;
34
35
if (!(vehicle instanceof PoweredMinecart)) {
36
return;
37
}
38
39
PoweredMinecart cart = (PoweredMinecart) vehicle;
40
41
//TODO
42
//maybe adding for particles
43
/*if(cart.getFuel() != 0)
44
{
45
cart.getWorld().spawnParticle(Particle.CAMPFIRE_SIGNAL_SMOKE, cart.getLocation().add(new Vector(0, 2, 0)), 1);
46
}*/
47
48
if((cart.getFuel() < 2) || (cart.getFuel() > (FUEL_PER_TICK + 1)))
49
{
50
return;
51
}
52
53
List<Entity> cartsInRange = vehicle.getNearbyEntities(3D, 3D, 3D);
54
55
for(Entity entity : cartsInRange)
56
{
57
if(entity instanceof StorageMinecart)
58
{
59
if(REFILL_ONLY_FROM_TENDER)
60
{
61
if(!isCartTender((StorageMinecart) entity))
62
{
63
continue;
64
}
65
}
66
67
Inventory inventory = ((StorageMinecart) entity).getInventory();
68
69
if(inventory.contains(Material.COAL))
70
{
71
inventory.removeItem(new ItemStack(Material.COAL, 1));
72
cart.setFuel(cart.getFuel() + 3600);
73
return;
74
}
75
76
if(inventory.contains(Material.CHARCOAL))
77
{
78
inventory.removeItem(new ItemStack(Material.CHARCOAL, 1));
79
cart.setFuel(cart.getFuel() + 3600);
80
return;
81
}
82
}
83
}
84
}
85
86
private boolean isCartTender(StorageMinecart cart) {
87
if (cart.getCustomName() == null) {
88
return false;
89
}
90
91
if (cart.getCustomName().equalsIgnoreCase(FUEL_CART_NAME)) {
92
return true;
93
}
94
return false;
95
}
96
}
@@ -0,0 +1,96 @@1
package me.fridtjof.minecarttrains.events;2
3
import me.fridtjof.minecarttrains.managers.LinkageManager;4
import me.fridtjof.minecarttrains.MinecartTrains;5
import org.bukkit.Material;6
import org.bukkit.entity.Entity;7
import org.bukkit.entity.Vehicle;8
import org.bukkit.entity.minecart.PoweredMinecart;9
import org.bukkit.entity.minecart.StorageMinecart;10
import org.bukkit.event.EventHandler;11
import org.bukkit.event.EventPriority;12
import org.bukkit.event.Listener;13
import org.bukkit.event.vehicle.VehicleUpdateEvent;14
import org.bukkit.inventory.Inventory;15
import org.bukkit.inventory.ItemStack;16
17
import java.util.List;18
19
public class OnVehicleUpdateEventLowestPriority implements Listener20
{21
22
static MinecartTrains plugin = MinecartTrains.getInstance();23
LinkageManager linkageManager = new LinkageManager();24
25
private final int FUEL_PER_TICK = plugin.configManager.mainConfig.getConfig().getInt("trains.fuel.consumption_per_tick");26
private final boolean REFILL_ONLY_FROM_TENDER = plugin.configManager.mainConfig.getConfig().getBoolean("trains.fuel.refill_only_from_fuel_cart");27
private final String FUEL_CART_NAME = plugin.configManager.mainConfig.getConfig().getString("trains.fuel.cart_name");28
29
@EventHandler(priority = EventPriority.LOWEST)30
public void OnFuelEmptyEvent(VehicleUpdateEvent event) {31
Vehicle vehicle = event.getVehicle();32
String uniqueId;33
Entity parent;34
35
if (!(vehicle instanceof PoweredMinecart)) {36
return;37
}38
39
PoweredMinecart cart = (PoweredMinecart) vehicle;40
41
//TODO42
//maybe adding for particles43
/*if(cart.getFuel() != 0)44
{45
cart.getWorld().spawnParticle(Particle.CAMPFIRE_SIGNAL_SMOKE, cart.getLocation().add(new Vector(0, 2, 0)), 1);46
}*/47
48
if((cart.getFuel() < 2) || (cart.getFuel() > (FUEL_PER_TICK + 1)))49
{50
return;51
}52
53
List<Entity> cartsInRange = vehicle.getNearbyEntities(3D, 3D, 3D);54
55
for(Entity entity : cartsInRange)56
{57
if(entity instanceof StorageMinecart)58
{59
if(REFILL_ONLY_FROM_TENDER)60
{61
if(!isCartTender((StorageMinecart) entity))62
{63
continue;64
}65
}66
67
Inventory inventory = ((StorageMinecart) entity).getInventory();68
69
if(inventory.contains(Material.COAL))70
{71
inventory.removeItem(new ItemStack(Material.COAL, 1));72
cart.setFuel(cart.getFuel() + 3600);73
return;74
}75
76
if(inventory.contains(Material.CHARCOAL))77
{78
inventory.removeItem(new ItemStack(Material.CHARCOAL, 1));79
cart.setFuel(cart.getFuel() + 3600);80
return;81
}82
}83
}84
}85
86
private boolean isCartTender(StorageMinecart cart) {87
if (cart.getCustomName() == null) {88
return false;89
}90
91
if (cart.getCustomName().equalsIgnoreCase(FUEL_CART_NAME)) {92
return true;93
}94
return false;95
}96
}@@ -0,0 +1,187 @@
1
package me.fridtjof.minecarttrains.managers;
2
3
import me.fridtjof.puddingapi.bukkit.utils.YamlConfig;
4
import org.bukkit.Material;
5
import org.bukkit.plugin.java.JavaPlugin;
6
7
import java.io.File;
8
import java.util.Collections;
9
import java.util.Objects;
10
import java.util.logging.Logger;
11
12
public class ConfigManager
13
{
14
15
JavaPlugin plugin;
16
17
private Logger logger;
18
public YamlConfig mainConfig, physicsConfig, messagesFile;
19
20
public static int mainConfigVersion = 4;
21
public static int physicsConfigVersion = 4;
22
public static String versionStringName = "config_version";
23
24
public ConfigManager(JavaPlugin plugin)
25
{
26
this.plugin = plugin;
27
logger = plugin.getLogger();
28
setupConfigs();
29
checkConfigVersions();
30
//2nd time to overwrite renamed ones
31
setupConfigs();
32
reloadConfigs();
33
}
34
35
private void setupConfigs()
36
{
37
mainConfig = new YamlConfig(plugin.getDataFolder(), "config");
38
physicsConfig = new YamlConfig(plugin.getDataFolder(), "physics");
39
messagesFile = new YamlConfig(plugin.getDataFolder(), "messages");
40
}
41
42
private void checkConfigVersions()
43
{
44
checkConfigVersion(mainConfig, versionStringName, mainConfigVersion);
45
checkConfigVersion(physicsConfig, versionStringName, physicsConfigVersion);
46
}
47
48
//TODO move to PuddingAPI
49
private void checkConfigVersion(YamlConfig config, String versionStringName, int wantedVersion)
50
{
51
if(!config.getConfig().contains(versionStringName))
52
{
53
return;
54
}
55
if(config.getConfig().getInt(versionStringName) == wantedVersion)
56
{
57
return;
58
}
59
60
61
String filePath = config.getFile().getAbsolutePath();
62
63
File renamedFile = new File(filePath + "_backup");
64
65
int backupCount = 0;
66
67
while(renamedFile.exists())
68
{
69
backupCount++;
70
renamedFile = new File(filePath + "_backup_" + backupCount);
71
}
72
73
config.getFile().renameTo(renamedFile);
74
75
logger.warning("The old " + config.getName() + " was replaced by a new version of the default file due to an update");
76
}
77
78
private void reloadConfigs()
79
{
80
loadMainConfig();
81
checkMaterial();
82
loadPhysicsConfig();
83
loadMessagesFile();
84
}
85
86
private void loadMainConfig()
87
{
88
mainConfig.getConfig().options().setHeader(Collections.singletonList("This is the main configuration file"));
89
90
mainConfig.getConfig().addDefault(versionStringName, mainConfigVersion);
91
92
mainConfig.getConfig().addDefault("trains.run_over.entities", true);
93
mainConfig.getConfig().addDefault("trains.run_over.min_velocity", 1.8D);
94
mainConfig.getConfig().addDefault("trains.run_over.damage", 10000);
95
96
mainConfig.getConfig().addDefault("trains.coupling.tool", "IRON_CHAIN");
97
98
mainConfig.getConfig().addDefault("trains.can_get_hit_by_arrows", false);
99
100
mainConfig.getConfig().addDefault("trains.fuel.consumption_per_tick", 1);
101
mainConfig.getConfig().addDefault("trains.fuel.refill_only_from_fuel_cart", true);
102
mainConfig.getConfig().addDefault("trains.fuel.cart_name", "Coal Cart");
103
mainConfig.getConfig().addDefault("trains.fuel.do_hopper_logic", true);
104
105
mainConfig.getConfig().addDefault("tracks.high_speed_tracks.enable", true);
106
mainConfig.getConfig().addDefault("tracks.high_speed_tracks.bed_block", Material.REDSTONE_BLOCK.toString());
107
108
mainConfig.getConfig().options().copyDefaults(true);
109
mainConfig.save();
110
logger.info("Successfully (re)loaded config.yml");
111
}
112
113
private void loadPhysicsConfig()
114
{
115
physicsConfig.getConfig().options().setHeader(Collections.singletonList("This is the physics configuration file - Handle with care! - Default values by @Wallaceman105"));
116
117
physicsConfig.getConfig().addDefault(versionStringName, physicsConfigVersion);
118
119
physicsConfig.getConfig().addDefault("coupling.max_distance", 3.5);
120
121
physicsConfig.getConfig().addDefault("link.distance.max", 9.5);
122
physicsConfig.getConfig().addDefault("link.distance.min", 0.7);
123
124
physicsConfig.getConfig().addDefault("link.low_speed.speed.pull", 1);
125
physicsConfig.getConfig().addDefault("link.low_speed.speed.push", 32);
126
physicsConfig.getConfig().addDefault("link.low_speed.distance.aimed", 1.3);
127
physicsConfig.getConfig().addDefault("link.low_speed.distance.aimed_tolerance", 0.001);
128
129
physicsConfig.getConfig().addDefault("link.high_speed.speed.pull", 4);
130
physicsConfig.getConfig().addDefault("link.high_speed.speed.push", 4);
131
physicsConfig.getConfig().addDefault("link.high_speed.distance.aimed", 1.5);
132
physicsConfig.getConfig().addDefault("link.high_speed.distance.aimed_tolerance", 0.001);
133
134
physicsConfig.getConfig().addDefault("link.high_speed.gate_speed", 1.5);
135
136
physicsConfig.getConfig().addDefault("track.high_speed.max_speed", 4);
137
physicsConfig.getConfig().addDefault("track.high_speed.acceleration", 0.008);
138
139
physicsConfig.getConfig().options().copyDefaults(true);
140
physicsConfig.save();
141
logger.info("Successfully (re)loaded physics.yml");
142
}
143
144
private void loadMessagesFile()
145
{
146
messagesFile.getConfig().options().header("This is the localization file.");;
147
148
messagesFile.getConfig().addDefault("trains.coupling_successful", "Coupling successful!");
149
messagesFile.getConfig().addDefault("trains.coupling_failed_distance", "Coupling failed! - The minecarts are too far apart!");
150
messagesFile.getConfig().addDefault("trains.coupling_failed_self", "Coupling failed! - Can't be coupled with itself!");
151
messagesFile.getConfig().addDefault("trains.coupling_already_coupled_with_itself", "Minecart is coupled with itself! - this shouldn't be possible!");
152
153
messagesFile.getConfig().addDefault("trains.coupling_1-2", "Coupling (1/2) activated for ");
154
messagesFile.getConfig().addDefault("trains.coupling_2-2", "Coupling (2/2) activated for ");
155
156
messagesFile.getConfig().options().copyDefaults(true);
157
messagesFile.save();
158
logger.info("Successfully (re)loaded messages.yml");
159
}
160
161
public void checkMaterial()
162
{
163
//check is Material of tool is valid
164
String toolMaterialConfig = mainConfig.getConfig().getString("trains.coupling.tool");
165
if((toolMaterialConfig == null) || (Material.getMaterial(toolMaterialConfig) == null))
166
{
167
String msg = "Could not resolve coupling tool Material! - Replacing with default!";
168
Material newToolMaterialDefault = Material.STICK;
169
170
// server lost support for the legacy chain naming
171
if(Material.getMaterial("CHAIN") == null)
172
{
173
newToolMaterialDefault = Material.getMaterial("IRON_CHAIN");
174
}
175
176
// server uses legacy naming for the iron chain
177
if(Material.getMaterial("IRON_CHAIN") == null)
178
{
179
newToolMaterialDefault = Material.getMaterial("CHAIN");
180
}
181
182
logger.warning(msg);
183
mainConfig.getConfig().set("trains.coupling.tool", newToolMaterialDefault.toString());
184
mainConfig.save();
185
}
186
}
187
}
@@ -0,0 +1,187 @@1
package me.fridtjof.minecarttrains.managers;2
3
import me.fridtjof.puddingapi.bukkit.utils.YamlConfig;4
import org.bukkit.Material;5
import org.bukkit.plugin.java.JavaPlugin;6
7
import java.io.File;8
import java.util.Collections;9
import java.util.Objects;10
import java.util.logging.Logger;11
12
public class ConfigManager13
{14
15
JavaPlugin plugin;16
17
private Logger logger;18
public YamlConfig mainConfig, physicsConfig, messagesFile;19
20
public static int mainConfigVersion = 4;21
public static int physicsConfigVersion = 4;22
public static String versionStringName = "config_version";23
24
public ConfigManager(JavaPlugin plugin)25
{26
this.plugin = plugin;27
logger = plugin.getLogger();28
setupConfigs();29
checkConfigVersions();30
//2nd time to overwrite renamed ones31
setupConfigs();32
reloadConfigs();33
}34
35
private void setupConfigs()36
{37
mainConfig = new YamlConfig(plugin.getDataFolder(), "config");38
physicsConfig = new YamlConfig(plugin.getDataFolder(), "physics");39
messagesFile = new YamlConfig(plugin.getDataFolder(), "messages");40
}41
42
private void checkConfigVersions()43
{44
checkConfigVersion(mainConfig, versionStringName, mainConfigVersion);45
checkConfigVersion(physicsConfig, versionStringName, physicsConfigVersion);46
}47
48
//TODO move to PuddingAPI49
private void checkConfigVersion(YamlConfig config, String versionStringName, int wantedVersion)50
{51
if(!config.getConfig().contains(versionStringName))52
{53
return;54
}55
if(config.getConfig().getInt(versionStringName) == wantedVersion)56
{57
return;58
}59
60
61
String filePath = config.getFile().getAbsolutePath();62
63
File renamedFile = new File(filePath + "_backup");64
65
int backupCount = 0;66
67
while(renamedFile.exists())68
{69
backupCount++;70
renamedFile = new File(filePath + "_backup_" + backupCount);71
}72
73
config.getFile().renameTo(renamedFile);74
75
logger.warning("The old " + config.getName() + " was replaced by a new version of the default file due to an update");76
}77
78
private void reloadConfigs()79
{80
loadMainConfig();81
checkMaterial();82
loadPhysicsConfig();83
loadMessagesFile();84
}85
86
private void loadMainConfig()87
{88
mainConfig.getConfig().options().setHeader(Collections.singletonList("This is the main configuration file"));89
90
mainConfig.getConfig().addDefault(versionStringName, mainConfigVersion);91
92
mainConfig.getConfig().addDefault("trains.run_over.entities", true);93
mainConfig.getConfig().addDefault("trains.run_over.min_velocity", 1.8D);94
mainConfig.getConfig().addDefault("trains.run_over.damage", 10000);95
96
mainConfig.getConfig().addDefault("trains.coupling.tool", "IRON_CHAIN");97
98
mainConfig.getConfig().addDefault("trains.can_get_hit_by_arrows", false);99
100
mainConfig.getConfig().addDefault("trains.fuel.consumption_per_tick", 1);101
mainConfig.getConfig().addDefault("trains.fuel.refill_only_from_fuel_cart", true);102
mainConfig.getConfig().addDefault("trains.fuel.cart_name", "Coal Cart");103
mainConfig.getConfig().addDefault("trains.fuel.do_hopper_logic", true);104
105
mainConfig.getConfig().addDefault("tracks.high_speed_tracks.enable", true);106
mainConfig.getConfig().addDefault("tracks.high_speed_tracks.bed_block", Material.REDSTONE_BLOCK.toString());107
108
mainConfig.getConfig().options().copyDefaults(true);109
mainConfig.save();110
logger.info("Successfully (re)loaded config.yml");111
}112
113
private void loadPhysicsConfig()114
{115
physicsConfig.getConfig().options().setHeader(Collections.singletonList("This is the physics configuration file - Handle with care! - Default values by @Wallaceman105"));116
117
physicsConfig.getConfig().addDefault(versionStringName, physicsConfigVersion);118
119
physicsConfig.getConfig().addDefault("coupling.max_distance", 3.5);120
121
physicsConfig.getConfig().addDefault("link.distance.max", 9.5);122
physicsConfig.getConfig().addDefault("link.distance.min", 0.7);123
124
physicsConfig.getConfig().addDefault("link.low_speed.speed.pull", 1);125
physicsConfig.getConfig().addDefault("link.low_speed.speed.push", 32);126
physicsConfig.getConfig().addDefault("link.low_speed.distance.aimed", 1.3);127
physicsConfig.getConfig().addDefault("link.low_speed.distance.aimed_tolerance", 0.001);128
129
physicsConfig.getConfig().addDefault("link.high_speed.speed.pull", 4);130
physicsConfig.getConfig().addDefault("link.high_speed.speed.push", 4);131
physicsConfig.getConfig().addDefault("link.high_speed.distance.aimed", 1.5);132
physicsConfig.getConfig().addDefault("link.high_speed.distance.aimed_tolerance", 0.001);133
134
physicsConfig.getConfig().addDefault("link.high_speed.gate_speed", 1.5);135
136
physicsConfig.getConfig().addDefault("track.high_speed.max_speed", 4);137
physicsConfig.getConfig().addDefault("track.high_speed.acceleration", 0.008);138
139
physicsConfig.getConfig().options().copyDefaults(true);140
physicsConfig.save();141
logger.info("Successfully (re)loaded physics.yml");142
}143
144
private void loadMessagesFile()145
{146
messagesFile.getConfig().options().header("This is the localization file.");;147
148
messagesFile.getConfig().addDefault("trains.coupling_successful", "Coupling successful!");149
messagesFile.getConfig().addDefault("trains.coupling_failed_distance", "Coupling failed! - The minecarts are too far apart!");150
messagesFile.getConfig().addDefault("trains.coupling_failed_self", "Coupling failed! - Can't be coupled with itself!");151
messagesFile.getConfig().addDefault("trains.coupling_already_coupled_with_itself", "Minecart is coupled with itself! - this shouldn't be possible!");152
153
messagesFile.getConfig().addDefault("trains.coupling_1-2", "Coupling (1/2) activated for ");154
messagesFile.getConfig().addDefault("trains.coupling_2-2", "Coupling (2/2) activated for ");155
156
messagesFile.getConfig().options().copyDefaults(true);157
messagesFile.save();158
logger.info("Successfully (re)loaded messages.yml");159
}160
161
public void checkMaterial()162
{163
//check is Material of tool is valid164
String toolMaterialConfig = mainConfig.getConfig().getString("trains.coupling.tool");165
if((toolMaterialConfig == null) || (Material.getMaterial(toolMaterialConfig) == null))166
{167
String msg = "Could not resolve coupling tool Material! - Replacing with default!";168
Material newToolMaterialDefault = Material.STICK;169
170
// server lost support for the legacy chain naming171
if(Material.getMaterial("CHAIN") == null)172
{173
newToolMaterialDefault = Material.getMaterial("IRON_CHAIN");174
}175
176
// server uses legacy naming for the iron chain177
if(Material.getMaterial("IRON_CHAIN") == null)178
{179
newToolMaterialDefault = Material.getMaterial("CHAIN");180
}181
182
logger.warning(msg);183
mainConfig.getConfig().set("trains.coupling.tool", newToolMaterialDefault.toString());184
mainConfig.save();185
}186
}187
}@@ -0,0 +1,29 @@
1
package me.fridtjof.minecarttrains.managers;
2
3
import me.fridtjof.minecarttrains.events.*;
4
import org.bukkit.event.Listener;
5
import org.bukkit.plugin.java.JavaPlugin;
6
7
import static org.bukkit.Bukkit.getServer;
8
9
public class EventManager implements Listener
10
{
11
12
public EventManager(JavaPlugin plugin)
13
{
14
registerListeners(plugin);
15
}
16
17
private void registerListeners(JavaPlugin plugin)
18
{
19
getServer().getPluginManager().registerEvents((Listener) new OnPlayerInteractEntityEvent(), plugin);
20
getServer().getPluginManager().registerEvents((Listener) new OnVehicleUpdateEvent(), plugin);
21
getServer().getPluginManager().registerEvents((Listener) new OnVehicleUpdateEventLowestPriority(), plugin);
22
getServer().getPluginManager().registerEvents((Listener) new OnVehicleEntityCollisionEvent(), plugin);
23
getServer().getPluginManager().registerEvents((Listener) new OnProjectileHitEvent(), plugin);
24
getServer().getPluginManager().registerEvents((Listener) new OnVehicleCreateEvent(), plugin);
25
getServer().getPluginManager().registerEvents((Listener) new OnInventoryMoveItemEvent(), plugin);
26
getServer().getPluginManager().registerEvents((Listener) new OnVehicleMoveEvent(), plugin);
27
}
28
29
}
@@ -0,0 +1,29 @@1
package me.fridtjof.minecarttrains.managers;2
3
import me.fridtjof.minecarttrains.events.*;4
import org.bukkit.event.Listener;5
import org.bukkit.plugin.java.JavaPlugin;6
7
import static org.bukkit.Bukkit.getServer;8
9
public class EventManager implements Listener10
{11
12
public EventManager(JavaPlugin plugin)13
{14
registerListeners(plugin);15
}16
17
private void registerListeners(JavaPlugin plugin)18
{19
getServer().getPluginManager().registerEvents((Listener) new OnPlayerInteractEntityEvent(), plugin);20
getServer().getPluginManager().registerEvents((Listener) new OnVehicleUpdateEvent(), plugin);21
getServer().getPluginManager().registerEvents((Listener) new OnVehicleUpdateEventLowestPriority(), plugin);22
getServer().getPluginManager().registerEvents((Listener) new OnVehicleEntityCollisionEvent(), plugin);23
getServer().getPluginManager().registerEvents((Listener) new OnProjectileHitEvent(), plugin);24
getServer().getPluginManager().registerEvents((Listener) new OnVehicleCreateEvent(), plugin);25
getServer().getPluginManager().registerEvents((Listener) new OnInventoryMoveItemEvent(), plugin);26
getServer().getPluginManager().registerEvents((Listener) new OnVehicleMoveEvent(), plugin);27
}28
29
}@@ -0,0 +1,47 @@
1
package me.fridtjof.minecarttrains.managers;
2
3
import me.fridtjof.minecarttrains.MinecartTrains;
4
import org.bukkit.NamespacedKey;
5
import org.bukkit.entity.Minecart;
6
import org.bukkit.persistence.PersistentDataContainer;
7
import org.bukkit.persistence.PersistentDataType;
8
9
import java.util.UUID;
10
11
public class LinkageManager
12
{
13
14
static MinecartTrains plugin = MinecartTrains.getInstance();
15
16
NamespacedKey key = new NamespacedKey(plugin, "coupler");
17
18
public LinkageManager()
19
{
20
21
}
22
23
public void removeLink(Minecart cart)
24
{
25
cart.getPersistentDataContainer().remove(key);
26
}
27
28
public String getLinkString(Minecart cart)
29
{
30
return cart.getPersistentDataContainer().get(key, PersistentDataType.STRING);
31
}
32
33
public UUID getLinkUniqueId(Minecart cart)
34
{
35
return UUID.fromString(getLinkString(cart));
36
}
37
38
public void setLink(Minecart cart, String linkedCartUniqueId)
39
{
40
cart.getPersistentDataContainer().set(key, PersistentDataType.STRING, linkedCartUniqueId);
41
}
42
43
public boolean hasLink(Minecart cart)
44
{
45
return cart.getPersistentDataContainer().has(key, PersistentDataType.STRING);
46
}
47
}
@@ -0,0 +1,47 @@1
package me.fridtjof.minecarttrains.managers;2
3
import me.fridtjof.minecarttrains.MinecartTrains;4
import org.bukkit.NamespacedKey;5
import org.bukkit.entity.Minecart;6
import org.bukkit.persistence.PersistentDataContainer;7
import org.bukkit.persistence.PersistentDataType;8
9
import java.util.UUID;10
11
public class LinkageManager12
{13
14
static MinecartTrains plugin = MinecartTrains.getInstance();15
16
NamespacedKey key = new NamespacedKey(plugin, "coupler");17
18
public LinkageManager()19
{20
21
}22
23
public void removeLink(Minecart cart)24
{25
cart.getPersistentDataContainer().remove(key);26
}27
28
public String getLinkString(Minecart cart)29
{30
return cart.getPersistentDataContainer().get(key, PersistentDataType.STRING);31
}32
33
public UUID getLinkUniqueId(Minecart cart)34
{35
return UUID.fromString(getLinkString(cart));36
}37
38
public void setLink(Minecart cart, String linkedCartUniqueId)39
{40
cart.getPersistentDataContainer().set(key, PersistentDataType.STRING, linkedCartUniqueId);41
}42
43
public boolean hasLink(Minecart cart)44
{45
return cart.getPersistentDataContainer().has(key, PersistentDataType.STRING);46
}47
}@@ -0,0 +1,42 @@
1
package me.fridtjof.minecarttrains.managers;
2
3
import me.fridtjof.minecarttrains.MinecartTrains;
4
import me.fridtjof.puddingapi.bukkit.utils.RecipeMaker;
5
import org.bukkit.Bukkit;
6
import org.bukkit.Material;
7
import org.bukkit.NamespacedKey;
8
import org.bukkit.inventory.ItemStack;
9
import org.bukkit.inventory.ShapedRecipe;
10
import org.bukkit.inventory.ShapelessRecipe;
11
import org.bukkit.inventory.meta.ItemMeta;
12
import org.bukkit.inventory.recipe.CraftingBookCategory;
13
14
public class RecipeManager
15
{
16
17
static MinecartTrains plugin = MinecartTrains.getInstance();
18
19
private final String FUEL_CART_NAME = plugin.configManager.mainConfig.getConfig().getString("trains.fuel.cart_name");
20
21
public RecipeManager()
22
{
23
//Tender recipe
24
ItemStack tenderItemStack = new ItemStack(Material.CHEST_MINECART);
25
ItemMeta tenderItemMeta = tenderItemStack.getItemMeta();
26
tenderItemMeta.setDisplayName(FUEL_CART_NAME);
27
tenderItemStack.setItemMeta(tenderItemMeta);
28
29
NamespacedKey tenderKey = new NamespacedKey(plugin, "fuel_cart");
30
31
ShapelessRecipe tenderRecipe = new ShapelessRecipe(tenderKey, tenderItemStack);
32
33
tenderRecipe.setCategory(CraftingBookCategory.REDSTONE);
34
35
//tenderRecipe.shape("#B#", "#M#");
36
37
tenderRecipe.addIngredient(Material.MINECART);
38
tenderRecipe.addIngredient(Material.COAL_BLOCK);
39
40
Bukkit.addRecipe(tenderRecipe);
41
}
42
}
@@ -0,0 +1,42 @@1
package me.fridtjof.minecarttrains.managers;2
3
import me.fridtjof.minecarttrains.MinecartTrains;4
import me.fridtjof.puddingapi.bukkit.utils.RecipeMaker;5
import org.bukkit.Bukkit;6
import org.bukkit.Material;7
import org.bukkit.NamespacedKey;8
import org.bukkit.inventory.ItemStack;9
import org.bukkit.inventory.ShapedRecipe;10
import org.bukkit.inventory.ShapelessRecipe;11
import org.bukkit.inventory.meta.ItemMeta;12
import org.bukkit.inventory.recipe.CraftingBookCategory;13
14
public class RecipeManager15
{16
17
static MinecartTrains plugin = MinecartTrains.getInstance();18
19
private final String FUEL_CART_NAME = plugin.configManager.mainConfig.getConfig().getString("trains.fuel.cart_name");20
21
public RecipeManager()22
{23
//Tender recipe24
ItemStack tenderItemStack = new ItemStack(Material.CHEST_MINECART);25
ItemMeta tenderItemMeta = tenderItemStack.getItemMeta();26
tenderItemMeta.setDisplayName(FUEL_CART_NAME);27
tenderItemStack.setItemMeta(tenderItemMeta);28
29
NamespacedKey tenderKey = new NamespacedKey(plugin, "fuel_cart");30
31
ShapelessRecipe tenderRecipe = new ShapelessRecipe(tenderKey, tenderItemStack);32
33
tenderRecipe.setCategory(CraftingBookCategory.REDSTONE);34
35
//tenderRecipe.shape("#B#", "#M#");36
37
tenderRecipe.addIngredient(Material.MINECART);38
tenderRecipe.addIngredient(Material.COAL_BLOCK);39
40
Bukkit.addRecipe(tenderRecipe);41
}42
}@@ -0,0 +1,7 @@
1
name: MinecartTrains
2
version: '${project.version}'
3
main: me.fridtjof.minecarttrains.MinecartTrains
4
api-version: '1.21'
5
authors: [ Fridtjof_DE ]
6
website: https://www.fridtjof.me
7
depend: [PuddingAPI]
@@ -0,0 +1,7 @@1
name: MinecartTrains2
version: '${project.version}'3
main: me.fridtjof.minecarttrains.MinecartTrains4
api-version: '1.21'5
authors: [ Fridtjof_DE ]6
website: https://www.fridtjof.me7
depend: [PuddingAPI]