mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-11-29 21:55:38 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b480b992f | ||
|
|
5a0bb98789 | ||
|
|
9633837c0c | ||
|
|
41aae90916 | ||
|
|
0dd8610bb3 | ||
|
|
3c2837dac7 | ||
|
|
24f9c4fa45 | ||
|
|
baf210f369 | ||
|
|
a331466d9e | ||
|
|
4fb7099c0f | ||
|
|
89dbac9974 | ||
|
|
dc03b5157f | ||
|
|
4e2d737f9d | ||
|
|
16c92b075d | ||
|
|
6a26617c83 | ||
|
|
1a63807a7c | ||
|
|
9dce8155bd | ||
|
|
b0ce56d5c1 | ||
|
|
3c32ea5035 | ||
|
|
99e6a2b0e5 | ||
|
|
619f423574 | ||
|
|
f39660471d | ||
|
|
21cd397781 | ||
|
|
d5212e8e5c | ||
|
|
0f219ce5f6 | ||
|
|
24e981fc9e | ||
|
|
b3ba585f01 | ||
|
|
fde361b0fb | ||
|
|
fce93b87c8 | ||
|
|
b26ff81a1e | ||
|
|
5f2c3c533f | ||
|
|
89eacecf45 | ||
|
|
3317024e2d | ||
|
|
03514e4f57 | ||
|
|
b39148b53e | ||
|
|
288fbba036 | ||
|
|
9c230811b4 | ||
|
|
b17b363971 | ||
|
|
0661068e8f | ||
|
|
ec7e3fc5af | ||
|
|
23e738aa59 | ||
|
|
758d777439 | ||
|
|
38f91a0266 | ||
|
|
a0559985d8 | ||
|
|
48d0611194 | ||
|
|
bd60ff8325 | ||
|
|
c6c293348b | ||
|
|
5291ebced4 | ||
|
|
d2ee401e5d | ||
|
|
cf4560be24 | ||
|
|
58a020dfd4 | ||
|
|
b10e9bddf5 | ||
|
|
f788ae5df7 | ||
|
|
61c3a4adfc | ||
|
|
c059edeb4e | ||
|
|
27a6b07845 | ||
|
|
df0208d9e6 | ||
|
|
62e9b55e92 | ||
|
|
4df2a8e3f0 | ||
|
|
4aeda035f4 | ||
|
|
aee503525e | ||
|
|
83533cef46 | ||
|
|
fcbd9f983c | ||
|
|
fa15c03c6d | ||
|
|
5d5700b61d | ||
|
|
2f21f670e0 | ||
|
|
e33988d103 | ||
|
|
e7a8aa226c | ||
|
|
881c2a8d0e | ||
|
|
f9e0406143 | ||
|
|
232546aeab | ||
|
|
68e4836359 | ||
|
|
b71f4a2ab0 | ||
|
|
872cf09c6a | ||
|
|
a76e65b18f | ||
|
|
d2e2124fbe | ||
|
|
c99d3ab302 | ||
|
|
9d1d818d30 | ||
|
|
d7f216e441 | ||
|
|
127ec9eb42 | ||
|
|
346f1eb0de | ||
|
|
cee0a22f55 | ||
|
|
422db19bdb | ||
|
|
06258b3a0c | ||
|
|
dc08bcad37 | ||
|
|
28be25d2e6 | ||
|
|
c1c09466b4 | ||
|
|
c0149e36d1 | ||
|
|
a7c9a37481 | ||
|
|
8bd1e92381 | ||
|
|
7cb0524f24 | ||
|
|
a8a0b210be | ||
|
|
229f4c5664 | ||
|
|
37e19521a4 | ||
|
|
799b49569e | ||
|
|
c522270815 | ||
|
|
e92153bb81 | ||
|
|
25ee0ce1e4 | ||
|
|
b9ae2a3bf7 | ||
|
|
3a1d335753 | ||
|
|
668312461f | ||
|
|
18e2278ebd | ||
|
|
1fd50ab7fa | ||
|
|
6d43ecc249 | ||
|
|
7eadb4eccd | ||
|
|
59ab5966c4 | ||
|
|
697eed1616 | ||
|
|
ffbe6f72a8 | ||
|
|
124778fd4b | ||
|
|
e690e1006c | ||
|
|
2075f57443 | ||
|
|
2e50641297 | ||
|
|
3a5b5bdbbc | ||
|
|
122e8e7df0 | ||
|
|
23288717ab | ||
|
|
639a2b0eaa | ||
|
|
f60f5c4a15 | ||
|
|
572e09989c | ||
|
|
ad4f35bb4c | ||
|
|
e655f831d3 | ||
|
|
a140a2d12e | ||
|
|
8f61177250 | ||
|
|
ab87e748f9 | ||
|
|
ca45444dd5 | ||
|
|
ac2f59d14d | ||
|
|
ee887d5081 | ||
|
|
0a637e0c8f | ||
|
|
3344fc6e2e | ||
|
|
0aed4d7d7a | ||
|
|
831fda8607 | ||
|
|
c6f77b0ac3 | ||
|
|
e75576a488 | ||
|
|
0b264d7aaf | ||
|
|
fda85555fc | ||
|
|
6c77eb0405 | ||
|
|
86dee2fc1c | ||
|
|
0e3d337f03 | ||
|
|
ab0bee81fb | ||
|
|
43d7ab7b82 | ||
|
|
166abfcae8 | ||
|
|
9585f64ab7 | ||
|
|
648f4431d7 | ||
|
|
2a812961e1 | ||
|
|
e5741ffac1 | ||
|
|
b295cc2d0f | ||
|
|
6eeb079ced | ||
|
|
5e08befb6b | ||
|
|
088e0a4c02 | ||
|
|
2a7819cf09 | ||
|
|
2f48ffea12 | ||
|
|
2604709b53 | ||
|
|
210c69ed07 | ||
|
|
d571a1654e | ||
|
|
0b31c50a29 | ||
|
|
bca181e8ec | ||
|
|
7c85c53eb1 | ||
|
|
47ff57eeb6 | ||
|
|
ebd52989bf | ||
|
|
21040143c7 | ||
|
|
2d49c8003f |
@@ -0,0 +1,12 @@
|
||||
#
|
||||
# https://help.github.com/articles/dealing-with-line-endings/
|
||||
#
|
||||
# Linux start script should use lf
|
||||
/gradlew text eol=lf
|
||||
|
||||
# These are Windows script files and should use crlf
|
||||
*.bat text eol=crlf
|
||||
|
||||
# Binary files should be left untouched
|
||||
*.jar binary
|
||||
|
||||
+20
-1
@@ -1 +1,20 @@
|
||||
.git
|
||||
# Ignore Gradle project-specific cache directory
|
||||
.gradle
|
||||
|
||||
# Ignore Gradle build output directory
|
||||
build
|
||||
|
||||
# Ignore Kotlin plugin data
|
||||
.kotlin
|
||||
|
||||
# Ignore the bin folder vscode keeps creating
|
||||
bin
|
||||
|
||||
# proxies
|
||||
proxies.txt
|
||||
|
||||
# ignore the config
|
||||
config.yml
|
||||
|
||||
# ignore chat attestation
|
||||
chatattestation
|
||||
|
||||
Generated
+3
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
Generated
+1
@@ -0,0 +1 @@
|
||||
NitoriBot
|
||||
Generated
+9
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
||||
Generated
+5
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default copy" />
|
||||
</state>
|
||||
</component>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="25" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
<option name="description" value="" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+16
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="AutoCloseableResource" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="METHOD_MATCHER_CONFIG" value="java.util.Formatter,format,java.io.Writer,append,com.google.common.base.Preconditions,checkNotNull,org.hibernate.Session,close,java.io.PrintWriter,printf,java.io.PrintStream,printf,java.lang.foreign.Arena,ofAuto,java.lang.foreign.Arena,global,java.net.http.HttpClient.Builder,build,java.lang.ClassLoader,getResourceAsStream" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
||||
Generated
+27
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="JsonSchemaMappingsProjectConfiguration">
|
||||
<state>
|
||||
<map>
|
||||
<entry key="No JSON schema">
|
||||
<value>
|
||||
<SchemaInfo>
|
||||
<option name="ignoredFile" value="true" />
|
||||
<option name="name" value="No JSON schema" />
|
||||
<option name="relativePathToSchema" value="" />
|
||||
<option name="applicationDefined" value="true" />
|
||||
<option name="patterns">
|
||||
<list>
|
||||
<Item>
|
||||
<option name="path" value="file://$PROJECT_DIR$/src/main/resources/info.json" />
|
||||
</Item>
|
||||
</list>
|
||||
</option>
|
||||
<option name="isIgnoredFile" value="true" />
|
||||
</SchemaInfo>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</state>
|
||||
</component>
|
||||
</project>
|
||||
Generated
+7
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="KotlinJpsPluginSettings">
|
||||
<option name="externalSystemId" value="Gradle" />
|
||||
<option name="version" value="2.3.10" />
|
||||
</component>
|
||||
</project>
|
||||
Generated
+8
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_25" default="true" project-jdk-name="25 (3)" project-jdk-type="JavaSDK" />
|
||||
</project>
|
||||
Generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published
|
||||
by the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
@@ -0,0 +1,85 @@
|
||||
import java.time.LocalDateTime
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.ZoneId
|
||||
import java.time.ZonedDateTime
|
||||
|
||||
version = "v9.0.0-alpha"
|
||||
group = "nitoribot"
|
||||
description = "NitoriBot"
|
||||
plugins {
|
||||
kotlin("jvm") version "2.3.10"
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(25)
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://repo.opencollab.dev/maven-releases/")
|
||||
maven("https://repo.opencollab.dev/maven-snapshots/")
|
||||
maven("https://jitpack.io/")
|
||||
maven("https://repo.opencollab.dev/main/")
|
||||
maven("https://maven.maxhenkel.de/repository/public/")
|
||||
maven("https://central.sonatype.com/repository/maven-snapshots")
|
||||
maven("https://code.chipmunk.land/api/packages/kaboomstandardsorganization/maven/")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.geysermc.mcprotocollib:protocol:26.3-SNAPSHOT")
|
||||
implementation("ch.qos.logback:logback-classic:1.6.6")
|
||||
implementation("org.slf4j:slf4j-api:2.0.20")
|
||||
implementation("org.yaml:snakeyaml:2.7")
|
||||
implementation("net.kyori:adventure-text-serializer-ansi:5.2.0")
|
||||
implementation("net.kyori:adventure-text-serializer-plain:5.2.0")
|
||||
implementation("net.kyori:adventure-text-serializer-legacy:5.2.0")
|
||||
implementation("net.kyori:adventure-text-serializer-gson:5.2.0")
|
||||
implementation("net.kyori:adventure-text-minimessage:5.2.0")
|
||||
implementation("net.lenni0451:LambdaEvents:2.4.2")
|
||||
implementation("org.jline:jline:4.4.7")
|
||||
implementation("com.github.oshi:oshi-core:7.7.1")
|
||||
implementation("net.kyori:adventure-nbt:5.2.0")
|
||||
implementation("org.bouncycastle:bcprov-jdk18on:1.84")
|
||||
implementation("net.jodah:expiringmap:0.5.11")
|
||||
implementation("org.apache.commons:commons-compress:1.28.0")
|
||||
implementation("io.github.wasabithumb:jtoml-configurate:1.5.1")
|
||||
implementation("com.github.luben:zstd-jni:1.5.6-9")
|
||||
implementation("land.chipmunk.code.kaboomstandardsorganization.messaginglib:mcprotocollib:3.1.2")
|
||||
implementation("com.google.guava:guava:33.6.0-jre")
|
||||
implementation("net.dv8tion:JDA:6.7.0")
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
val timeZone = ZoneId.of("America/Chicago");
|
||||
val zoneDate = ZonedDateTime.now(timeZone);
|
||||
val dateTimeFormatter = DateTimeFormatter.ofPattern("MMMM dd, yyyy hh:mm:ss a")
|
||||
val dateTimeInfo = zoneDate.toLocalDateTime();
|
||||
|
||||
manifest {
|
||||
attributes["Main-Class"] = "land.chipmunk.parker2991.nitoribot.nightofnights.Main"
|
||||
attributes("Build-Time" to dateTimeFormatter.format(dateTimeInfo))
|
||||
attributes("Enable-Native-Access" to "ALL-UNNAMED")
|
||||
}
|
||||
|
||||
archiveClassifier.set("all")
|
||||
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
|
||||
from(sourceSets.main.get().output)
|
||||
|
||||
dependsOn(configurations.runtimeClasspath)
|
||||
|
||||
from(
|
||||
{
|
||||
exclude("META-INF/*.SF")
|
||||
exclude("META-INF/*.RSA")
|
||||
exclude("META-INF/*.DSA")
|
||||
configurations.runtimeClasspath.get().filter {
|
||||
it.name.endsWith("jar")
|
||||
}.map {
|
||||
zipTree(it)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<code_scheme name="Default copy" version="173">
|
||||
<JavaCodeStyleSettings>
|
||||
<option name="DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION" value="true" />
|
||||
<option name="ANNOTATION_PARAMETER_WRAP" value="5" />
|
||||
<option name="ENUM_FIELD_ANNOTATION_WRAP" value="5" />
|
||||
<option name="NEW_LINE_AFTER_LPAREN_IN_ANNOTATION" value="true" />
|
||||
<option name="RPAREN_ON_NEW_LINE_IN_ANNOTATION" value="true" />
|
||||
<option name="RECORD_COMPONENTS_WRAP" value="5" />
|
||||
<option name="NEW_LINE_AFTER_LPAREN_IN_RECORD_HEADER" value="true" />
|
||||
<option name="RPAREN_ON_NEW_LINE_IN_RECORD_HEADER" value="true" />
|
||||
<option name="DECONSTRUCTION_LIST_WRAP" value="5" />
|
||||
<option name="SPACE_BEFORE_DECONSTRUCTION_LIST" value="true" />
|
||||
<option name="MULTI_CATCH_TYPES_WRAP" value="5" />
|
||||
<option name="ALIGN_TYPES_IN_MULTI_CATCH" value="false" />
|
||||
</JavaCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="KEEP_LINE_BREAKS" value="false" />
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
<option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
|
||||
<option name="ALIGN_MULTILINE_RESOURCES" value="false" />
|
||||
<option name="ALIGN_MULTILINE_FOR" value="false" />
|
||||
<option name="SPACE_BEFORE_METHOD_PARENTHESES" value="true" />
|
||||
<option name="CALL_PARAMETERS_WRAP" value="5" />
|
||||
<option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="METHOD_PARAMETERS_WRAP" value="5" />
|
||||
<option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="RESOURCE_LIST_LPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="RESOURCE_LIST_RPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="METHOD_CALL_CHAIN_WRAP" value="5" />
|
||||
<option name="TERNARY_OPERATION_WRAP" value="5" />
|
||||
<option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" />
|
||||
<option name="ARRAY_INITIALIZER_WRAP" value="5" />
|
||||
<option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
|
||||
<option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
|
||||
<option name="SWITCH_EXPRESSIONS_WRAP" value="5" />
|
||||
<option name="CLASS_ANNOTATION_WRAP" value="5" />
|
||||
<option name="FIELD_ANNOTATION_WRAP" value="5" />
|
||||
<option name="PARAMETER_ANNOTATION_WRAP" value="5" />
|
||||
<option name="VARIABLE_ANNOTATION_WRAP" value="5" />
|
||||
<option name="ENUM_CONSTANTS_WRAP" value="5" />
|
||||
<option name="WRAP_ON_TYPING" value="0" />
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="kotlin">
|
||||
<indentOptions>
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="4" />
|
||||
</indentOptions>
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
@@ -0,0 +1 @@
|
||||
java -jar build/libs/NitoriBot-v9.0.0-all.jar
|
||||
@@ -0,0 +1 @@
|
||||
sh ./framework/keepalive.sh
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
echo "starting reset process at $HOME/keepalive"
|
||||
|
||||
dtach -n $HOME/keepalive sh ./framework/reset.sh
|
||||
|
||||
while true; do
|
||||
sh ./framework/bot.sh
|
||||
sleep 5
|
||||
done
|
||||
@@ -0,0 +1,4 @@
|
||||
while true; do
|
||||
sleep 24h
|
||||
pkill -f "java"
|
||||
done
|
||||
@@ -0,0 +1,5 @@
|
||||
# This file was generated by the Gradle 'init' task.
|
||||
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
|
||||
|
||||
org.gradle.configuration-cache=true
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
# This file was generated by the Gradle 'init' task.
|
||||
# https://docs.gradle.org/current/userguide/version_catalogs.html#sec::toml-dependencies-format
|
||||
Vendored
BIN
Binary file not shown.
+9
@@ -0,0 +1,9 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.9.0-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,248 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# gradlew start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh gradlew
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
|
||||
# Resolve links: $0 may be a link
|
||||
app_path=$0
|
||||
|
||||
# Need this for daisy-chained symlinks.
|
||||
while
|
||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||
[ -h "$app_path" ]
|
||||
do
|
||||
ls=$( ls -ld "$app_path" )
|
||||
link=${ls#*' -> '}
|
||||
case $link in #(
|
||||
/*) app_path=$link ;; #(
|
||||
*) app_path=$APP_HOME$link ;;
|
||||
esac
|
||||
done
|
||||
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||
else
|
||||
JAVACMD=$JAVA_HOME/bin/java
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
#
|
||||
# In Bash we could simply go:
|
||||
#
|
||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||
# set -- "${ARGS[@]}" "$@"
|
||||
#
|
||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
||||
# character that might be a shell metacharacter, then use eval to reverse
|
||||
# that process (while maintaining the separation between arguments), and wrap
|
||||
# the whole thing up as a single "set" statement.
|
||||
#
|
||||
# This will of course break if any of these variables contains a newline or
|
||||
# an unmatched quote.
|
||||
#
|
||||
|
||||
eval "set -- $(
|
||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||
xargs -n1 |
|
||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||
tr '\n' ' '
|
||||
)" '"$@"'
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
Vendored
+112
@@ -0,0 +1,112 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem gradlew startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||
setlocal EnableExtensions
|
||||
|
||||
@rem Catch executions from older scripts and ensure they exit cleanly.
|
||||
@rem This can be removed once we can be reasonably confident that few people
|
||||
@rem will be migrating directly to this new wrapper.
|
||||
goto afterSafetyNet
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
goto exitWithErrorLevel
|
||||
:afterSafetyNet
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
1>&2 echo.
|
||||
1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
1>&2 echo.
|
||||
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
|
||||
1>&2 echo location of your Java installation.
|
||||
|
||||
"%COMSPEC%" /c exit 1
|
||||
goto exitWithErrorLevel
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
1>&2 echo.
|
||||
1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
1>&2 echo.
|
||||
1>&2 echo Please set the JAVA_HOME variable in your environment to match the
|
||||
1>&2 echo location of your Java installation.
|
||||
|
||||
"%COMSPEC%" /c exit 1
|
||||
goto exitWithErrorLevel
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
|
||||
|
||||
@rem Execute gradlew
|
||||
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||
@rem which allows us to clear the local environment before executing the java command
|
||||
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel
|
||||
|
||||
@rem This label must not be changed. We rely on old scripts being able to jump to this point.
|
||||
:exitWithErrorLevel
|
||||
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||
@@ -1,731 +0,0 @@
|
||||
const mineflayer = require('mineflayer')
|
||||
let symbol = require('illegal-symbols')
|
||||
var server = 'sus.shhnowisnottheti.me'
|
||||
//NMxigAU6dR1KfgaQkKz87L
|
||||
const readline = require('readline')
|
||||
let chunk = ('prismarine-chunk')
|
||||
const protocol = ('minecraft-protocol')
|
||||
let auth = ('mineflayer-auto-auth')
|
||||
let bcraw = ('prismarine=chat')
|
||||
|
||||
|
||||
let rl = readline.createInterface({ input: process.stdin, output: process.stdout })
|
||||
|
||||
|
||||
const randomstring = require('randomstring');
|
||||
const bot = mineflayer.createBot({
|
||||
host: server,
|
||||
port: 25565,
|
||||
username: randomstring.generate(8),
|
||||
version: 1.17,
|
||||
auth: 'mineflayer-auto-auth'
|
||||
})
|
||||
|
||||
var sleep = t => new Promise(a => setTimeout(a, t)),
|
||||
sendChat = async function(m) { bot.chat(m.slice(0, 256)); await sleep(300); }
|
||||
|
||||
function between(min, max) {
|
||||
return Math.floor(
|
||||
Math.random() * (max - min) + min
|
||||
)
|
||||
}
|
||||
|
||||
//variables
|
||||
var prefix = '&8&l[&b&lFNFBoyfriendBot&8&l]&8&l[&a&lConsole&8&l]&8&l[&4&lParker2991&8&l]';
|
||||
var consoleprefix = 'bcraw &8&l[&b&lFNFBoyfriendBot&8&l]&8&l[&a&lConsole&8&l]&8&l[&4&lParker2991&8&l]';
|
||||
|
||||
function randomchar() {
|
||||
const crypto = require("crypto");
|
||||
var hash = crypto.createHash("md5");
|
||||
var randomBytes = crypto.randomBytes(16);
|
||||
hash.update(randomBytes);
|
||||
var hashi = hash.digest(Math.round(Math.random()) ? "hex" : "Base64");
|
||||
|
||||
return hashi.substring(0, 16);
|
||||
}
|
||||
|
||||
function runInCore(cmd) {
|
||||
bot._client.write('update_command_block', {location: {x:between(Math.floor(bot.entity.position.x) + 1, Math.floor(bot.entity.position.x) - 15), y:between(0, 3), z:between(Math.floor(bot.entity.position.z) + 1, Math.floor(bot.entity.position.z) - 15)}, command: cmd, mode: 1, flags: 0b100});
|
||||
}
|
||||
bot.on('login', async () => { // time in ms
|
||||
console.log(`logged in as ${bot.username}`)
|
||||
//change the coords if bot has problems
|
||||
//await sendChat('/tp '+require('randomstring').generate({length:5,charset:'1234567890'})+' 5 '+require('randomstring').generate({length:6,charset:'1234567890'}))
|
||||
|
||||
await sendChat('/world 3')
|
||||
await sendChat('/tptoggle parker2991')
|
||||
await sendChat('/tp parker2991')
|
||||
await sendChat('/tptoggle parker2991')
|
||||
await sendChat('/tptoggle')
|
||||
await sendChat('/online')
|
||||
await sendChat('/v on')
|
||||
await sendChat('/console ')
|
||||
await sendChat('/username')
|
||||
await sendChat('/c')
|
||||
|
||||
await sendChat('/gmc')
|
||||
await sendChat('/minecraft:reload')
|
||||
await sendChat('/night')
|
||||
await sendChat('/gamerule doMobSpawning false')
|
||||
await sendChat('/de')
|
||||
await sendChat('/online')
|
||||
await sendChat('/cspy on')
|
||||
await sendChat('/prefix &4[BOT/CONSOLE]')
|
||||
await sendChat('/sudo parker2991 prefix &8&l[&4&lOwner of the &b&lFNFBoyfriend&4&lbot&8&l]')
|
||||
await sendChat('/sudo spimtheoctoling prefix &8&l[&&lOwner of the VeemoBot&8&l]')
|
||||
await sendChat(`/fill ${Math.floor(bot.entity.position.x)} 0 ${Math.floor(bot.entity.position.z)} ${Math.floor(bot.entity.position.x) - 15} 50 ${Math.floor(bot.entity.position.z - 15)} command_block replace`)
|
||||
|
||||
runInCore ('bcraw ' + prefix + '&b&lOwner &4&lis &4&lParker2991')
|
||||
runInCore ('bcraw ' + prefix + '
|
||||
|
||||
runInCore ('bcraw ' + prefix + '&a&l Version &a&l2.0 RELEASE')
|
||||
|
||||
runInCore ('bcraw ' + prefix + 'full bot release &8&l1/26/23 &8&l1:47am &8&lCentral &8<ime')
|
||||
|
||||
|
||||
runInCore ('bcraw ' + prefix + 'Boffy:im jesus i dont fucking know')
|
||||
|
||||
})
|
||||
const cmd = require('mineflayer-cmd').plugin
|
||||
|
||||
cmd.allowConsoleInput = false // Optional config argument
|
||||
bot.loadPlugin(cmd)
|
||||
//nuke command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'nuke':
|
||||
setInterval(function() { runInCore('essentials:ekill *'), 1 })
|
||||
setInterval(function() { runInCore('nuke'), 1 })
|
||||
setInterval(function() { runInCore('eco give * 1000'), 1 })
|
||||
setInterval(function() { runInCore('day'), 1 })
|
||||
setInterval(function() { runInCore('night'), 1 })
|
||||
setInterval(function() { runInCore('clear @a'), 1 })
|
||||
setInterval(function() { runInCore('summon fireball 115 62 -5'), 1 })
|
||||
setInterval(function() { runInCore('bcraw ' + prefix + 'WELCOME TO HELL'), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
//fakekick command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'fakekick':
|
||||
runInCore('msg ' + args + ' @e @e @e @e @e @e @e @e @e')
|
||||
runInCore('bcraw &8&l[&b&m&lFNFBoyfriendbot&8&l] ' + args + ' has been kicked!')
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
//gmc command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'gmc':
|
||||
runInCore('sudo + botusername gmc')
|
||||
runInCore('bcraw &4DOWN IN OHIO!')
|
||||
break
|
||||
}
|
||||
|
||||
})
|
||||
//deop command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'deop':
|
||||
setInterval(function() { runInCore('sudo + playerusername deop @s[type=player]'), 1 })
|
||||
}
|
||||
})
|
||||
//kaboom command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
switch (command) {
|
||||
|
||||
case 'kaboom':
|
||||
setInterval(function() { runInCore('sudo * kaboom'), 8})
|
||||
runInCore('bcraw have fun =)')
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
})
|
||||
//BOOM command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
|
||||
|
||||
switch (command) {
|
||||
|
||||
case 'BOOM':
|
||||
runInCore('sudo * /fast')
|
||||
runInCore('sudo * god')
|
||||
runInCore('sudo * gms')
|
||||
runInCore('sudo * /sphere tnt 75')
|
||||
runInCore('sudo * kaboom')
|
||||
runInCore('BOOM GOES THE DINOMITE')
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
})
|
||||
//kick command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
|
||||
case 'kick':
|
||||
runInCore ('/console @e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e@e')
|
||||
runInCore('bcraw &8&l[&b&m&lBoyfriendbot]&8 ' + args + ' has been kicked!')
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
})
|
||||
//greeting command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'greeting':
|
||||
|
||||
runInCore('bcraw &eAyunami2000 Joined the game')
|
||||
|
||||
break
|
||||
}
|
||||
})
|
||||
//fakeban commnad
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'fakeban':
|
||||
runInCore('msg ' + args + ' @e @e @e @e @e @e @e @e @e')
|
||||
runInCore('bcraw &4&l&mConsole Has Perm Banned ' + args + 'For 22 Days And 14 Hours')
|
||||
|
||||
break
|
||||
}
|
||||
})
|
||||
//thor commnad
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'thor':
|
||||
runInCore('essentials:smite *' + args)
|
||||
runInCore('bcraw ' + prefix + '&4&lI AM ZEUS')
|
||||
break
|
||||
}
|
||||
})
|
||||
//OHHAIL console
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'OHHAIL':
|
||||
runInCore('sudo * c: OH HAIL FIRE MOTHER FUCKER' + args.join(' '))
|
||||
break
|
||||
}
|
||||
})
|
||||
//servercrash command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'servercrash':
|
||||
setInterval(function() { runInCore('essentials:sudo * kick @e[type=player] @e @e @e'), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
//explode command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'explode':
|
||||
setInterval(function() { runInCore('minecraft:execute unless entity @e[name= run ] at ' + args + ' run summon minecraft:tnt'), 1 })
|
||||
|
||||
|
||||
|
||||
break
|
||||
}
|
||||
})
|
||||
//trol command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'trol':
|
||||
setInterval(function() { runInCore('essentials:smite ' + args), 1 })
|
||||
setInterval(function() { runInCore('clear ' + args), 1 })
|
||||
setInterval(function() { runInCore('effect give ' + args + ' nausea'), 1 })
|
||||
setInterval(function() { runInCore('effect give ' + args + ' poison'), 1 })
|
||||
runInCore('gms ' + args)
|
||||
setInterval(function() { runInCore('spawnentity pig 10 ' + args), 1 })
|
||||
setInterval(function() { runInCore('spawnentity tntminecart 10 ' + args), 1 })
|
||||
setInterval(function() { runInCore('spawnentity zombie 10 ' + args), 1 })
|
||||
setInterval(function() { runInCore('kaboom ' + args), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
//cloop command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'cloop':
|
||||
|
||||
setInterval(function() { runInCore(args.join(' ')), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
//altcrash command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'altcrash':
|
||||
setInterval(function() { runInCore('sudo * execute at @a run give @a diamond_hoe 64'), 1 })
|
||||
setInterval(function() { runInCore('bcraw ' + prefix + '&8&l Have fun with hoes =) '), 1 })
|
||||
runInCore
|
||||
break
|
||||
}
|
||||
})
|
||||
//Myhead command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'MyHead':
|
||||
runInCore('give @a minecraft:player_head{SkullOwner:Parker2991}')
|
||||
break
|
||||
}
|
||||
})
|
||||
//MYLEG! command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'MYLEG':
|
||||
runInCore('bcraw ' + prefix + '&a&lMY LEG!!!')
|
||||
runInCore('give @a bone 64')
|
||||
break
|
||||
}
|
||||
})
|
||||
//KFCFINGERLICKINGOOD command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'KFC':
|
||||
runInCore('give @a cooked_chicken 64')
|
||||
runInCore('bcraw ' + prefix + 'KFC FINGER LICKIN GOOD')
|
||||
break
|
||||
}
|
||||
})
|
||||
//GODSWORD!! command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'GODSWORD':
|
||||
runInCore('give @a diamond_sword')
|
||||
runInCore('sudo * enchantall')
|
||||
runInCore('bcraw ' + prefix + 'GOD SWORD!!!!!!!!!!!!!!!!!')
|
||||
break
|
||||
}
|
||||
})
|
||||
//technoblade command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'technoblade':
|
||||
runInCore('sudo * summon pig')
|
||||
runInCore('bcraw ' + prefix + 'Rest in peace technoblade we will always love and remember what you have done for youtube technoblade if you can here me i love your youtube channel')
|
||||
break
|
||||
}
|
||||
})
|
||||
//DREAMSTANALERT command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'DREAMSTANALERT':
|
||||
runInCore('bcraw ' + prefix + 'OH HELL NO DREAM STAN ALERT')
|
||||
runInCore('kick @e[type=player] @e @e @e')
|
||||
break
|
||||
}
|
||||
})
|
||||
// command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case '':
|
||||
runInCore('')
|
||||
break
|
||||
}
|
||||
})
|
||||
// command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case '':
|
||||
runInCore('')
|
||||
break
|
||||
}
|
||||
})
|
||||
//test command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'test':
|
||||
|
||||
|
||||
setInterval(function() { runInCore('minecraft:execute unless entity @s[name= run ] at ' + args + ' run summon minecraft:iron_golem'), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
//soundbreaker
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'soundbreaker':
|
||||
|
||||
|
||||
setInterval(function() { runInCore('sudo * execute at @a run playsound minecraft:entity.wolf.hurt master @a ~ ~ ~ 10000 1.5 1 '), 1 })
|
||||
setInterval(function() { runInCore('sudo * execute at @a run playsound minecraft:entity.cat.hurt master @a ~ ~ ~ 10000 1.5 1 '), 1 })
|
||||
setInterval(function() { runInCore('sudo * execute at @a run playsound minecraft:entity.wolf.hurt master @a ~ ~ ~ 10000 1 1 '), 1 })
|
||||
setInterval(function() { runInCore('sudo * execute at @a run playsound minecraft:entity.cat.hurt master @a ~ ~ ~ 10000 1 1 '), 1 })
|
||||
setInterval(function() { runInCore('sudo * execute at @a run playsound minecraft:entity.cat.hiss master @a ~ ~ ~ 10000 1.5 1 '), 1 })
|
||||
setInterval(function() { runInCore('sudo * execute at @a run playsound minecraft:entity.cat.hiss master @a ~ ~ ~ 10000 1 1 '), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
//entityspam
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'entityspam':
|
||||
setInterval(function() { runInCore('sudo * summon fireball '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon ender_dragon '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon zombie '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon creeper'), 1 })
|
||||
setInterval(function() { runInCore('sudo * blaze'), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon horse '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon spider '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon fireball '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon ender_dragon '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon zombie '), 1 })
|
||||
setInterval(function() { runInCore('sudo * ummon creeper '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon blazed '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon horse '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon spider '), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
//tp command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'tp':
|
||||
runInCore('essentials:sudo * tp ' + args)
|
||||
break
|
||||
}
|
||||
})
|
||||
//gms command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'gms':
|
||||
setInterval(function() { runInCore('sudo * gms ' + args), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
//stop command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'stop':
|
||||
runInCore('bcraw ' + prefix + 'STOPPING SERVER.....')
|
||||
setInterval(function() { runInCore('execute unless entity @s[name= run ] run stop'), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
//tntspam command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'tntspam':
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt'), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt '), 1 })
|
||||
setInterval(function() { runInCore('sudo * summon tnt'), 1 })
|
||||
|
||||
break
|
||||
}
|
||||
})
|
||||
//prefix command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'prefix':
|
||||
runInCore('sudo * prefix ' + args)
|
||||
break
|
||||
}
|
||||
})
|
||||
//annoy command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'annoy':
|
||||
setInterval(function() { runInCore('sudo * WHYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY' + ''), 1 })
|
||||
setInterval(function() { runInCore('sudo * playsound minecraft:entity.cat.hurt master @a ~ ~ ~ 10000 1.5 1' + ''), 1 })
|
||||
|
||||
break
|
||||
}
|
||||
})
|
||||
//freeze command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'freeze':
|
||||
setInterval(function() { runInCore('tp ' + args + ' ' + args), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
//troll command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'troll':
|
||||
setInterval(function() { runInCore('day'), 1 })
|
||||
setInterval(function() { runInCore('night'), 1 })
|
||||
setInterval(function() { runInCore('clear @a'), 1 })
|
||||
setInterval(function() { runInCore('effect give @a nausea'), 1 })
|
||||
setInterval(function() { runInCore('effect give @a slowness'), 1 })
|
||||
setInterval(function() { runInCore('give @a bedrock'), 1 })
|
||||
setInterval(function() { runInCore('give @a sand'), 1 })
|
||||
setInterval(function() { runInCore('give @a dirt'), 1 })
|
||||
setInterval(function() { runInCore('give @a diamond'), 1 })
|
||||
setInterval(function() { runInCore('give @a tnt'), 1 })
|
||||
setInterval(function() { runInCore('give @a crafting_table'), 1 })
|
||||
setInterval(function() { runInCore('give @a diamond_block'), 1 })
|
||||
setInterval(function() { runInCore('smite *'), 1 })
|
||||
setInterval(function() { runInCore('essentials:smite ' + args), 1 })
|
||||
setInterval(function() { runInCore('clear ' + args), 1 })
|
||||
setInterval(function() { runInCore('effect give ' + args + ' nausea'), 1 })
|
||||
setInterval(function() { runInCore('effect give ' + args + ' poison'), 1 })
|
||||
runInCore('gms ' + args)
|
||||
setInterval(function() { runInCore('spawnentity pig 10 ' + args), 1 })
|
||||
setInterval(function() { runInCore('spawnentity tntminecart 10 ' + args), 1 })
|
||||
setInterval(function() { runInCore('spawnentity zombie 10 ' + args), 1 })
|
||||
setInterval(function() { runInCore('kaboom ' + args), 1 })
|
||||
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
//icu command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'icu':
|
||||
setInterval(function() { runInCore('tp ' + args + ' Parker2991'), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
//say command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
|
||||
switch (command) {
|
||||
case 'say':
|
||||
runInCore('bcraw ' + prefix + args.join(' '))
|
||||
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
//deop command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'serverdeop':
|
||||
setInterval(function() { runInCore('sudo * deop @e[type=player] ' + args), 1 })
|
||||
setInterval(function() { runInCore('op @s[type=player] ' + args), 1 })
|
||||
setInterval(function() { runInCore('op parker2991 ' + args), 1 })
|
||||
break
|
||||
}
|
||||
})
|
||||
//sudo command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'sudo':
|
||||
runInCore('sudo ' + args.join(' '))
|
||||
|
||||
break
|
||||
}
|
||||
})
|
||||
//tpe command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'tpe':
|
||||
runInCore('execute unless entity @s[name= run ] run tp @e[type=!player] ' + args)
|
||||
|
||||
break
|
||||
}
|
||||
})
|
||||
|
||||
//sudoall command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'sudoall':
|
||||
runInCore('essentials:sudo * ' + args.join(' '))
|
||||
console.log("succesfully execute sudo command " + args)
|
||||
break
|
||||
}
|
||||
})
|
||||
//selfdestruct command
|
||||
rl.on('line', (line) => {
|
||||
let args = line.split(' ')
|
||||
let command = args.shift()
|
||||
|
||||
switch (command) {
|
||||
case 'selfdestruct':
|
||||
|
||||
setInterval(function() { runInCore('day'), 1 })
|
||||
setInterval(function() { runInCore('night'), 1 })
|
||||
setInterval(function() { runInCore('clear @a'), 1 })
|
||||
setInterval(function() { runInCore('effect give @a nausea'), 1 })
|
||||
setInterval(function() { runInCore('effect give @a slowness'), 1 })
|
||||
setInterval(function() { runInCore('give @a bedrock'), 1 })
|
||||
setInterval(function() { runInCore('give @a sand'), 1 })
|
||||
setInterval(function() { runInCore('give @a dirt'), 1 })
|
||||
setInterval(function() { runInCore('give @a diamond'), 1 })
|
||||
setInterval(function() { runInCore('give @a tnt'), 1 })
|
||||
setInterval(function() { runInCore('give @a crafting_table'), 1 })
|
||||
setInterval(function() { runInCore('give @a diamond_block'), 1 })
|
||||
setInterval(function() { runInCore('smite *'), 1 })
|
||||
setInterval(function() { runInCore('kaboom'), 1 })
|
||||
setInterval(function() { runInCore('essentials:ekill *'), 1 })
|
||||
setInterval(function() { runInCore('nuke'), 1 })
|
||||
setInterval(function() { runInCore('eco give * 1000'), 1 })
|
||||
setInterval(function() { runInCore('day'), 1 })
|
||||
setInterval(function() { runInCore('night'), 1 })
|
||||
setInterval(function() { runInCore('clear @a'), 1 })
|
||||
setInterval(function() { runInCore('summon fireball 115 62 -5'), 1 })
|
||||
setInterval(function() { runInCore('sudo * /fast'), 1 })
|
||||
setInterval(function() { runInCore('sudo * gms'), 1 })
|
||||
setInterval(function() { runInCore('sudo * /sphere tnt 75'), 1 })
|
||||
setInterval(function() { runInCore('sudo * kaboom'), 1 })
|
||||
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bot.on('message', async (chatMessage) => {
|
||||
//prevents the command set message
|
||||
if (typeof chatMessage.translate === 'string' && chatMessage.translate.startsWith('advMode.')) return
|
||||
console.log(chatMessage.toAnsi())
|
||||
})
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* This file was generated by the Gradle 'init' task.
|
||||
*
|
||||
* The settings file is used to specify which projects to include in your build.
|
||||
* For more detailed information on multi-project builds, please refer to https://docs.gradle.org/9.4.0/userguide/multi_project_builds.html in the Gradle documentation.
|
||||
*/
|
||||
|
||||
rootProject.name = "NitoriBot"
|
||||
@@ -0,0 +1,162 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights;
|
||||
|
||||
import land.chipmunk.code.kaboomstandardsorganization.messaginglib.mcprotocollib.*;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.boot.GetProxiesList;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.modules.*;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.lenni0451.lambdaevents.EventHandler;
|
||||
import org.geysermc.mcprotocollib.network.Session;
|
||||
import org.geysermc.mcprotocollib.network.event.session.DisconnectedEvent;
|
||||
import org.geysermc.mcprotocollib.network.event.session.DisconnectingEvent;
|
||||
import org.geysermc.mcprotocollib.network.event.session.PacketErrorEvent;
|
||||
import org.geysermc.mcprotocollib.network.factory.ClientNetworkSessionFactory;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.ServerboundPlayerLoadedPacket;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.login.clientbound.ClientboundLoginFinishedPacket;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public @NullMarked class Client extends NitoriBot {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Client.class);
|
||||
|
||||
public Client (
|
||||
Config.Options options,
|
||||
List<NitoriBot> bots,
|
||||
Config config
|
||||
) throws Exception {
|
||||
this.options = options;
|
||||
this.bots = bots;
|
||||
this.config = config;
|
||||
this.modules = List.of(
|
||||
this.discord = new DiscordModule(this),
|
||||
this.chat = new ChatModule(this),
|
||||
new SelfcareModule(this),
|
||||
this.position = new PositionModule(this),
|
||||
this.core = new CommandCoreModule(this),
|
||||
this.registry = new RegistryModule(this),
|
||||
this.players = new PlayerListModule(this),
|
||||
new LoggingModule(this),
|
||||
new ChatCommandHandlerModule(this),
|
||||
this.commandManager = new CommandManagerModule(this),
|
||||
new TextDisplayModule(this),
|
||||
this.mcServer = new MCServerModule(this),
|
||||
new CommandSpyModule(this),
|
||||
this.world = new WorldModule(this),
|
||||
this.tabComplete = new TabCompleteModule(this),
|
||||
this.extrasMessaging = new ExtrasMessagingModule(this),
|
||||
this.validation = new ValidationModule(this)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnecting (
|
||||
DisconnectingEvent event
|
||||
) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetSent (
|
||||
Session session,
|
||||
Packet packet
|
||||
) {
|
||||
for (Listener listener : listenerManager.listeners) {
|
||||
listener.packetSent();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetError (
|
||||
PacketErrorEvent error
|
||||
) {
|
||||
error.setSuppress(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packetReceived (
|
||||
Session session,
|
||||
Packet packet
|
||||
) {
|
||||
try {
|
||||
if (packet instanceof ClientboundLoginPacket)
|
||||
this.session.send(ServerboundPlayerLoadedPacket.INSTANCE);
|
||||
|
||||
for (Listener listener : listenerManager.listeners) {
|
||||
listener.packetReceived(packet);
|
||||
}
|
||||
|
||||
switch (packet) {
|
||||
case ClientboundLoginFinishedPacket p -> getProfile(p);
|
||||
case ClientboundLoginPacket p -> getEntityId(p);
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
} catch (Exception _) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void getProfile (
|
||||
ClientboundLoginFinishedPacket packet
|
||||
) {
|
||||
profile = packet.getProfile();
|
||||
|
||||
loggedIn = true;
|
||||
}
|
||||
|
||||
private void getEntityId (
|
||||
ClientboundLoginPacket packet
|
||||
) {
|
||||
entityId = packet.getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnected (
|
||||
DisconnectedEvent event
|
||||
) {
|
||||
listenerManager.clearListener();
|
||||
loggedIn = false;
|
||||
|
||||
Component host = Component
|
||||
.text(String.format(
|
||||
"[%s:%s] ",
|
||||
options.host,
|
||||
options.port
|
||||
))
|
||||
.color(NamedTextColor.BLUE);
|
||||
Component reason = Component
|
||||
.empty()
|
||||
.append(host)
|
||||
.append(event.getReason());
|
||||
|
||||
logger.reconnect(ComponentUtil.componentToAnsi(reason));
|
||||
|
||||
scheduler.schedule(
|
||||
() -> {
|
||||
try {
|
||||
connect();
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(
|
||||
"{}",
|
||||
NitoriBot.class,
|
||||
e
|
||||
);
|
||||
}
|
||||
},
|
||||
options.reconnectDelay,
|
||||
TimeUnit.MILLISECONDS
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Config {
|
||||
public final Colors colors = new Colors();
|
||||
public final Core core = new Core();
|
||||
public final Console console = new Console();
|
||||
public final Options[] bots = new Options[]{};
|
||||
public List<String> prefixes;
|
||||
public final Keys keys = new Keys();
|
||||
public final Discord discord = new Discord();
|
||||
|
||||
public static class DiscordRoles {
|
||||
public String trusted;
|
||||
public String admin;
|
||||
public String owner;
|
||||
}
|
||||
|
||||
public static class Discord {
|
||||
public String token;
|
||||
public boolean enabled;
|
||||
public String prefix;
|
||||
public String invite;
|
||||
public final DiscordRoles roles = new DiscordRoles();
|
||||
}
|
||||
|
||||
public static class Keys {
|
||||
public String trusted;
|
||||
public String admin;
|
||||
public String owner;
|
||||
}
|
||||
|
||||
public static class Core {
|
||||
public boolean itemRefill;
|
||||
public final Area area = new Area();
|
||||
public String coreName;
|
||||
}
|
||||
|
||||
public static class Area {
|
||||
public final Position start = new Position();
|
||||
public final Position end = new Position();
|
||||
}
|
||||
|
||||
public static class Position {
|
||||
public int x;
|
||||
public int y;
|
||||
public int z;
|
||||
}
|
||||
|
||||
public static class CommandColors {
|
||||
public String primary;
|
||||
public String secondary;
|
||||
public String tertiary;
|
||||
}
|
||||
|
||||
public static class HelpCommandColors {
|
||||
public String Public;
|
||||
public String trusted;
|
||||
public String admin;
|
||||
public String owner;
|
||||
public String console;
|
||||
}
|
||||
|
||||
public static class Console {
|
||||
public String prefix;
|
||||
}
|
||||
|
||||
public static class Colors {
|
||||
public final CommandColors commands = new CommandColors();
|
||||
public final HelpCommandColors help = new HelpCommandColors();
|
||||
public String integer;
|
||||
}
|
||||
|
||||
public static class Options {
|
||||
public String host;
|
||||
public int port;
|
||||
public boolean useProxy;
|
||||
public String serverName;
|
||||
public boolean isPrivate;
|
||||
public String username;
|
||||
public String discordChannelId;
|
||||
public int reconnectDelay;
|
||||
public int selfcareInterval;
|
||||
public String mode;
|
||||
public boolean useMiniMessage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.boot.GetBotBuildInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.boot.GetRepoInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.boot.LoadConfig;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.console.CreateConsole;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.blocks.BlockRegistries;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.BotBuildInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.RepoCommitInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.discord.MessageLogger;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
public class Main {
|
||||
private static final Gson GSON = new Gson();
|
||||
public static final ExecutorService executorService = Executors.newSingleThreadExecutor();
|
||||
public static final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
|
||||
public static final List<NitoriBot> Bots = new ArrayList<>();
|
||||
public static RepoCommitInfo repoCommitInfo = null;
|
||||
public static BotBuildInfo botBuildInfo = null;
|
||||
public static CreateConsole console;
|
||||
public Config config;
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Main.class);
|
||||
public static final List<BlockRegistries> blocks = new ArrayList<>();
|
||||
|
||||
public static JDA discordClient;
|
||||
|
||||
static {
|
||||
final List<BlockRegistries> registries = new ArrayList<>();
|
||||
final List<BlockRegistries> blockRegistries = new ArrayList<>();
|
||||
final Reader blockRegistryReader = new InputStreamReader(Main.class.getResourceAsStream("/blocks" + ".json"));
|
||||
final Reader registriesReader = new InputStreamReader(Main.class.getResourceAsStream("/registries" + ".json"));
|
||||
final Map<?, ?> map = GSON.fromJson(
|
||||
blockRegistryReader,
|
||||
Map.class
|
||||
);
|
||||
|
||||
for (Map.Entry<?, ?> entry : map.entrySet()) {
|
||||
String json = GSON.toJson(entry.getValue());
|
||||
final BlockRegistries parsed = GSON.fromJson(
|
||||
json,
|
||||
BlockRegistries.class
|
||||
);
|
||||
parsed.block = entry
|
||||
.getKey()
|
||||
.toString();
|
||||
registries.add(parsed);
|
||||
}
|
||||
final JsonElement parseRegistries = JsonParser.parseReader(registriesReader);
|
||||
final JsonElement itemArray = parseRegistries
|
||||
.getAsJsonObject()
|
||||
.get("minecraft:item")
|
||||
.getAsJsonObject()
|
||||
.get("entries");
|
||||
final JsonElement blockArray = parseRegistries
|
||||
.getAsJsonObject()
|
||||
.get("minecraft:block")
|
||||
.getAsJsonObject()
|
||||
.get("entries");
|
||||
final Map<?, ?> blockEntrySet = GSON.fromJson(
|
||||
blockArray,
|
||||
Map.class
|
||||
);
|
||||
final Map<?, ?> itemEntrySet = GSON.fromJson(
|
||||
itemArray,
|
||||
Map.class
|
||||
);
|
||||
|
||||
for (Map.Entry<?, ?> entry : blockEntrySet.entrySet()) {
|
||||
String key = entry
|
||||
.getKey()
|
||||
.toString();
|
||||
for (BlockRegistries block : registries) {
|
||||
final Pattern pattern = Pattern.compile("\\{protocol_id=(\\d+(?:\\.\\d+)?)\\}");
|
||||
final Matcher matcher = pattern.matcher(entry
|
||||
.getValue()
|
||||
.toString());
|
||||
if (matcher.find()) {
|
||||
if (block.block.equals(key)) {
|
||||
block.blockId = (int) Float.parseFloat(matcher.group(1));
|
||||
blockRegistries.add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<?, ?> entry : itemEntrySet.entrySet()) {
|
||||
final String key = entry
|
||||
.getKey()
|
||||
.toString();
|
||||
for (BlockRegistries block : blockRegistries) {
|
||||
final Pattern pattern = Pattern.compile("\\{protocol_id=(\\d+(?:\\.\\d+)?)\\}");
|
||||
final Matcher matcher = pattern.matcher(entry
|
||||
.getValue()
|
||||
.toString());
|
||||
|
||||
if (matcher.find()) {
|
||||
if (block.block.equals(key)) {
|
||||
block.itemId = (int) Float.parseFloat(matcher.group(1));
|
||||
blocks.add(block);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void main () {
|
||||
try {
|
||||
botBuildInfo = new GetBotBuildInfo().getBuildInfo();
|
||||
System.out.println("Starting NitoriBot " + ComponentUtil.componentToAnsi(GsonComponentSerializer
|
||||
.gson()
|
||||
.deserialize(botBuildInfo.buildstring.codename.toString())));
|
||||
config = new LoadConfig().loadConfig();
|
||||
Config.Options[] bots = config.bots;
|
||||
console = new CreateConsole();
|
||||
repoCommitInfo = new GetRepoInfo().getRepoInfo();
|
||||
|
||||
if (config.discord.enabled) {
|
||||
JDABuilder builder = JDABuilder.createDefault(config.discord.token);
|
||||
builder.enableIntents(
|
||||
GatewayIntent.MESSAGE_CONTENT,
|
||||
GatewayIntent.DIRECT_MESSAGES,
|
||||
GatewayIntent.GUILD_MEMBERS
|
||||
);
|
||||
|
||||
discordClient = builder.build();
|
||||
discordClient.addEventListener(new MessageLogger(discordClient));
|
||||
discordClient.awaitReady();
|
||||
}
|
||||
|
||||
for (Config.Options options : bots) {
|
||||
final NitoriBot bot = new Client(
|
||||
options,
|
||||
Bots,
|
||||
config
|
||||
);
|
||||
Bots.add(bot);
|
||||
bot.connect();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(
|
||||
"{}",
|
||||
Main.class,
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights;
|
||||
|
||||
import jdk.jshell.JShell;
|
||||
import land.chipmunk.code.kaboomstandardsorganization.messaginglib.mcprotocollib.Injector;
|
||||
import land.chipmunk.code.kaboomstandardsorganization.messaginglib.mcprotocollib.MCProtocolLibMessagingEntrypoint;
|
||||
import land.chipmunk.code.kaboomstandardsorganization.messaginglib.mcprotocollib.MCProtocolLibMessenger;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.boot.GetProxiesList;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.ChatAttestation;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.console.logger.LoggerManager;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.BotBuildInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.RepoCommitInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.ListenerManager;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.modules.*;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.lenni0451.lambdaevents.AHandler;
|
||||
import net.lenni0451.lambdaevents.EventHandler;
|
||||
import net.lenni0451.lambdaevents.IGenerator;
|
||||
import net.lenni0451.lambdaevents.LambdaManager;
|
||||
import net.lenni0451.lambdaevents.generator.LambdaMetaFactoryGenerator;
|
||||
import net.lenni0451.lambdaevents.generator.ReflectionGenerator;
|
||||
import org.geysermc.mcprotocollib.auth.GameProfile;
|
||||
import org.geysermc.mcprotocollib.network.event.session.SessionAdapter;
|
||||
import org.geysermc.mcprotocollib.network.factory.ClientNetworkSessionFactory;
|
||||
import org.geysermc.mcprotocollib.network.netty.DefaultPacketHandlerExecutor;
|
||||
import org.geysermc.mcprotocollib.network.session.ClientNetworkSession;
|
||||
import org.geysermc.mcprotocollib.protocol.MinecraftProtocol;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
public class NitoriBot extends SessionAdapter implements MCProtocolLibMessagingEntrypoint {
|
||||
public final LoggerManager logger = new LoggerManager();
|
||||
public final ListenerManager listenerManager = new ListenerManager();
|
||||
public final ScheduledExecutorService scheduler = Main.scheduler;
|
||||
public final BotBuildInfo botBuildInfo = Main.botBuildInfo;
|
||||
public final RepoCommitInfo repoCommitInfo = Main.repoCommitInfo;
|
||||
public Config config;
|
||||
public Config.Options options;
|
||||
public List<NitoriBot> bots;
|
||||
public ChatModule chat;
|
||||
public PositionModule position;
|
||||
public CommandCoreModule core;
|
||||
public PlayerListModule players;
|
||||
public RegistryModule registry;
|
||||
public ValidationModule validation;
|
||||
public boolean loggedIn = false;
|
||||
public int entityId;
|
||||
public ClientNetworkSession session;
|
||||
public GameProfile profile;
|
||||
public CommandManagerModule commandManager;
|
||||
public MCServerModule mcServer;
|
||||
public WorldModule world;
|
||||
public TabCompleteModule tabComplete;
|
||||
public ExtrasMessagingModule extrasMessaging;
|
||||
public List<?> modules;
|
||||
public DiscordModule discord;
|
||||
public final Map<Object, JShell> evalStorage = new HashMap<>();
|
||||
|
||||
public void addServer (String host, int port, String discordChannelId, String username, boolean useProxy) {
|
||||
// this function is here for shits and giggles
|
||||
Config.Options botOptions = new Config.Options();
|
||||
botOptions.host = host;
|
||||
botOptions.port = port;
|
||||
botOptions.username = username;
|
||||
botOptions.discordChannelId = discordChannelId;
|
||||
botOptions.isPrivate = false;
|
||||
botOptions.reconnectDelay = 6000;
|
||||
botOptions.serverName = "test";
|
||||
botOptions.useProxy = useProxy;
|
||||
botOptions.useMiniMessage = false;
|
||||
|
||||
try {
|
||||
NitoriBot client = new Client(
|
||||
botOptions,
|
||||
bots,
|
||||
config
|
||||
);
|
||||
|
||||
// Main.Bots.add(client);
|
||||
|
||||
client.connect();
|
||||
} catch (Exception ignore) {}
|
||||
|
||||
}
|
||||
//public final ChatAttestation chatAttestation = new ChatAttestation();
|
||||
|
||||
public void connect () throws IOException {
|
||||
final MinecraftProtocol protocol = new MinecraftProtocol(options.username);
|
||||
|
||||
if (options.useProxy)
|
||||
session = ClientNetworkSessionFactory
|
||||
.factory()
|
||||
.setAddress(
|
||||
options.host,
|
||||
options.port
|
||||
)
|
||||
.setProxy(new GetProxiesList().randomProxyIp())
|
||||
.setProtocol(protocol)
|
||||
.create();
|
||||
|
||||
else
|
||||
session = ClientNetworkSessionFactory
|
||||
.factory()
|
||||
.setAddress(
|
||||
options.host,
|
||||
options.port
|
||||
)
|
||||
.setProtocol(protocol)
|
||||
.create();
|
||||
Injector.inject(
|
||||
session,
|
||||
this
|
||||
);
|
||||
ChatAttestation.inject(session);
|
||||
session.addListener(this);
|
||||
session.connect(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegistrationAvailable (MCProtocolLibMessenger messenger) {
|
||||
// stub
|
||||
}
|
||||
|
||||
public NitoriBot () {
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.boot;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.Main;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.BotBuildInfo;
|
||||
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.Objects;
|
||||
|
||||
public class GetBotBuildInfo {
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
public BotBuildInfo getBuildInfo () {
|
||||
Reader reader = new InputStreamReader(Objects.requireNonNull(Main.class.getResourceAsStream("/info.json")));
|
||||
|
||||
return GSON.fromJson(
|
||||
reader,
|
||||
BotBuildInfo.class
|
||||
);
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.boot;
|
||||
|
||||
import org.geysermc.mcprotocollib.network.ProxyInfo;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class GetProxiesList {
|
||||
public ProxyInfo randomProxyIp () throws IOException {
|
||||
Path proxiesPath = Paths.get("proxies.txt");
|
||||
|
||||
int countLines = Math.round(Files
|
||||
.lines(proxiesPath)
|
||||
.count());
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
int randomIndex = random.nextInt(countLines);
|
||||
|
||||
List<String> lines = Files
|
||||
.lines(proxiesPath)
|
||||
.toList();
|
||||
|
||||
String[] ip = lines
|
||||
.stream()
|
||||
.skip(randomIndex)
|
||||
.findAny()
|
||||
.get()
|
||||
.split(":");
|
||||
|
||||
InetSocketAddress address = new InetSocketAddress(
|
||||
ip[0],
|
||||
Integer.parseInt(ip[1])
|
||||
);
|
||||
|
||||
return new ProxyInfo(
|
||||
ProxyInfo.Type.SOCKS5,
|
||||
address
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.boot;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.RepoCommitInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.time.Duration;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
public class GetRepoInfo {
|
||||
private static final Gson GSON = new Gson();
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GetRepoInfo.class);
|
||||
|
||||
public RepoCommitInfo getRepoInfo () {
|
||||
final String repo = "https://code.chipmunk.land/api/v1/repos/Parker2991/NitoriBot/commits?sha=main";
|
||||
HttpClient client = HttpClient
|
||||
.newBuilder()
|
||||
.followRedirects(HttpClient.Redirect.NORMAL)
|
||||
.connectTimeout(Duration.ofSeconds(20))
|
||||
.build();
|
||||
|
||||
HttpRequest request = HttpRequest
|
||||
.newBuilder()
|
||||
.uri(URI.create(repo))
|
||||
.timeout(Duration.ofMillis(20))
|
||||
.header(
|
||||
"accept",
|
||||
"application/json"
|
||||
)
|
||||
.build();
|
||||
|
||||
RepoCommitInfo info = null;
|
||||
try {
|
||||
HttpResponse<String> response = client.send(
|
||||
request,
|
||||
HttpResponse.BodyHandlers.ofString()
|
||||
);
|
||||
JsonElement json = JsonParser.parseString(response.body());
|
||||
|
||||
info = GSON.fromJson(
|
||||
json
|
||||
.getAsJsonArray()
|
||||
.get(0),
|
||||
RepoCommitInfo.class
|
||||
);
|
||||
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(
|
||||
"{}",
|
||||
GetRepoInfo.class,
|
||||
e
|
||||
);
|
||||
ZoneId timezone = ZoneId.of("America/Chicago");
|
||||
String zoneDate = String.valueOf(ZonedDateTime.now(timezone));
|
||||
//ce.printStackTrace(System.err);
|
||||
info = new RepoCommitInfo();
|
||||
info.created = zoneDate;
|
||||
info.commits = 0;
|
||||
info.sha = "N/A";
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.boot;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.Config;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.Main;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.yaml.snakeyaml.LoaderOptions;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import org.yaml.snakeyaml.constructor.Constructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class LoadConfig {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoadConfig.class);
|
||||
|
||||
public Config loadConfig () throws IOException {
|
||||
final Constructor yamlConfig = new Constructor(
|
||||
Config.class,
|
||||
new LoaderOptions()
|
||||
);
|
||||
final Yaml yaml = new Yaml(yamlConfig);
|
||||
final Path configPath = Path.of("config.yml");
|
||||
if (!Files.exists(configPath)) {
|
||||
LOGGER.info("config not found making config now");
|
||||
|
||||
InputStream defaultConfig = Main.class
|
||||
.getClassLoader()
|
||||
.getResourceAsStream("default_config.yml");
|
||||
Files.copy(
|
||||
defaultConfig,
|
||||
configPath
|
||||
);
|
||||
}
|
||||
|
||||
InputStream configFile = Files.newInputStream(configPath);
|
||||
|
||||
return yaml.load(configFile);
|
||||
}
|
||||
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import land.chipmunk.code.kaboomstandardsorganization.messaginglib.mcprotocollib.Injector;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.Main;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.crypto.SigningManager;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util.SigningResult;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util.Util;
|
||||
import org.geysermc.mcprotocollib.network.ClientSession;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.UUID;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.crypto.SigningManager.createHash;
|
||||
|
||||
public class ChatAttestation {
|
||||
private static final UUID NIL_UUID = UUID.fromString("00000000-0000-0000-0000-000000000000");
|
||||
|
||||
public static SigningResult getSigningStatus (
|
||||
String message,
|
||||
UUID senderUuid,
|
||||
String senderNick
|
||||
) {
|
||||
final byte[] pyl;
|
||||
final var wrapped = new SigningManager.WrappedByteArray(createHash(message.getBytes(StandardCharsets.UTF_8)));
|
||||
final ByteBuf payload;
|
||||
payload = senderUuid == NIL_UUID ?
|
||||
MessagingEntrypointImpl.RECENT_PAYLOADS.remove(wrapped) :
|
||||
MessagingEntrypointImpl.ATTRIBUTED_PAYLOADS
|
||||
.getOrDefault(
|
||||
senderUuid,
|
||||
Collections.emptyMap()
|
||||
)
|
||||
.remove(wrapped);
|
||||
|
||||
if (payload == null) {
|
||||
pyl = null;
|
||||
} else {
|
||||
try {
|
||||
pyl = new byte[payload.readableBytes()];
|
||||
payload.readBytes(pyl);
|
||||
} finally {
|
||||
if (senderUuid != NIL_UUID)
|
||||
MessagingEntrypointImpl.RECENT_PAYLOADS.remove(wrapped);
|
||||
payload.release();
|
||||
}
|
||||
}
|
||||
return Signing.getSigningStatus(
|
||||
senderNick,
|
||||
message,
|
||||
pyl
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public static MessagingEntrypointImpl inject (ClientSession clientNetworkSession) {
|
||||
MessagingEntrypointImpl messagingEntrypointImpl = new MessagingEntrypointImpl();
|
||||
Injector.inject(
|
||||
clientNetworkSession,
|
||||
messagingEntrypointImpl
|
||||
);
|
||||
return messagingEntrypointImpl;
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public record KeyManifest(@SerializedName("key_to_claims") Map<String, Set<String>> keyToClaims) {
|
||||
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.crypto.SigningManager;
|
||||
import land.chipmunk.code.kaboomstandardsorganization.messaginglib.mcprotocollib.*;
|
||||
/*import dev.pthepro777.messaging_lib.MCProtocolLibMessagingEntrypoint;
|
||||
import dev.pthepro777.messaging_lib.MCProtocolLibMessenger;
|
||||
import dev.pthepro777.messaging_lib.MCProtocolLibPayloadReceiver;*/
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.jodah.expiringmap.ExpirationPolicy;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public final class MessagingEntrypointImpl implements MCProtocolLibMessagingEntrypoint, MCProtocolLibPayloadReceiver {
|
||||
public static final String CHANNEL_NAME = "chat-attestation/v1:stream";
|
||||
public final Map<StreamCacheKey, ByteBuf> PAYLOAD_MAP = ExpiringMap
|
||||
.builder()
|
||||
.maxSize(1024)
|
||||
.expiration(
|
||||
1,
|
||||
TimeUnit.MINUTES
|
||||
)
|
||||
.build();
|
||||
public static final Map<SigningManager.WrappedByteArray, ByteBuf> RECENT_PAYLOADS = ExpiringMap
|
||||
.builder()
|
||||
.maxSize(1024)
|
||||
.expiration(
|
||||
1,
|
||||
TimeUnit.MINUTES
|
||||
)
|
||||
.asyncExpirationListener(MessagingEntrypointImpl::onExpire)
|
||||
.build();
|
||||
public static final Map<UUID, Map<SigningManager.WrappedByteArray, ByteBuf>> ATTRIBUTED_PAYLOADS = ExpiringMap
|
||||
.builder()
|
||||
.maxSize(256)
|
||||
.expiration(
|
||||
5,
|
||||
TimeUnit.MINUTES
|
||||
)
|
||||
.expirationPolicy(ExpirationPolicy.ACCESSED)
|
||||
.build();
|
||||
public static volatile MCProtocolLibMessenger MESSENGER_INSTANCE;
|
||||
|
||||
public static void onExpire (
|
||||
SigningManager.WrappedByteArray byteArray,
|
||||
ByteBuf buf
|
||||
) {
|
||||
buf.release();
|
||||
}
|
||||
|
||||
|
||||
private static Map<SigningManager.WrappedByteArray, ByteBuf> getAttributionMap (UUID sender) {
|
||||
return ATTRIBUTED_PAYLOADS.computeIfAbsent(
|
||||
sender,
|
||||
_ -> ExpiringMap
|
||||
.builder()
|
||||
.maxSize(16)
|
||||
.expiration(
|
||||
1,
|
||||
TimeUnit.MINUTES
|
||||
)
|
||||
.asyncExpirationListener(MessagingEntrypointImpl::onExpire)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRegistrationAvailable (@NotNull MCProtocolLibMessenger messenger) {
|
||||
MESSENGER_INSTANCE = messenger;
|
||||
|
||||
MESSENGER_INSTANCE.receivePayloads(
|
||||
CHANNEL_NAME,
|
||||
this
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeregister () {
|
||||
MESSENGER_INSTANCE = null;
|
||||
PAYLOAD_MAP.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceivePayload (
|
||||
@NotNull String channelName,
|
||||
@NotNull UUID sender,
|
||||
@NotNull ByteBuf payload
|
||||
) {
|
||||
final byte[] contentHash = new byte[16];
|
||||
payload.readBytes(contentHash);
|
||||
|
||||
final var wrapper = new SigningManager.WrappedByteArray(contentHash);
|
||||
RECENT_PAYLOADS.put(
|
||||
wrapper,
|
||||
payload.copy()
|
||||
);
|
||||
getAttributionMap(sender).put(
|
||||
wrapper,
|
||||
payload.copy()
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: This won't work very well with vanished players.
|
||||
public record StreamCacheKey(
|
||||
SigningManager.WrappedByteArray contentHash,
|
||||
UUID sender
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.crypto.Payload.withAdditionalData;
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util.Constants.LOGGER;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.DataInputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Collection;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.crypto.Payload;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.crypto.SigningManager;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.enums.SigningStatus;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util.SigningResult;
|
||||
|
||||
|
||||
public class Signing {
|
||||
public static SigningResult getSigningStatus (
|
||||
String nick,
|
||||
String msg,
|
||||
byte[] pyl
|
||||
) {
|
||||
if (pyl == null) {
|
||||
return SigningResult.of(SigningManager.INSTANCE.doesNickRequireSignature(nick) ?
|
||||
SigningStatus.NEEDS_SIGNATURE :
|
||||
SigningStatus.NO_PAYLOAD);
|
||||
}
|
||||
|
||||
final Payload decodedPayload;
|
||||
try {
|
||||
decodedPayload = Payload.read(
|
||||
msg.getBytes(StandardCharsets.UTF_8),
|
||||
new DataInputStream(new ByteArrayInputStream(pyl))
|
||||
);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error(
|
||||
"{}",
|
||||
Signing.class,
|
||||
e
|
||||
);
|
||||
return SigningResult.of(SigningStatus.NO_PAYLOAD);
|
||||
}
|
||||
|
||||
final var response = SigningManager.INSTANCE.verifyClaim(
|
||||
withAdditionalData(
|
||||
decodedPayload.msg(),
|
||||
decodedPayload.nonce(),
|
||||
decodedPayload.exp()
|
||||
),
|
||||
decodedPayload.signature(),
|
||||
decodedPayload.key(),
|
||||
decodedPayload.exp()
|
||||
);
|
||||
|
||||
return switch (response) {
|
||||
case SigningManager.Response.InvalidSignature __ -> SigningResult.of(SigningStatus.INVALID_SIGNATURE);
|
||||
case SigningManager.Response.NoSuchKey __ -> SigningResult.of(SigningStatus.NO_SUCH_KEY);
|
||||
case SigningManager.Response.ReusedSignature __ -> SigningResult.of(SigningStatus.REUSED_SIGNATURE);
|
||||
case SigningManager.Response.SignatureValid valid -> {
|
||||
final boolean authenticated = valid
|
||||
.key()
|
||||
.manifestUrlToClaims()
|
||||
.values()
|
||||
.stream()
|
||||
.flatMap(Collection::stream)
|
||||
.anyMatch(claim -> claim.equalsIgnoreCase(nick));
|
||||
|
||||
final String encodedKey = Base64
|
||||
.getEncoder()
|
||||
.encodeToString(valid
|
||||
.key()
|
||||
.bc()
|
||||
.getEncoded());
|
||||
|
||||
yield new SigningResult(
|
||||
authenticated ?
|
||||
SigningStatus.VERIFIED :
|
||||
SigningStatus.VALID_UNVERIFIED,
|
||||
encodedKey
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.config;
|
||||
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ConfigSerializable public final class Configuration {
|
||||
private static final String DEFAULT_MANIFEST = "https://optmstc.dev/key-manifest-v1.json";
|
||||
|
||||
public volatile List<String> keyManifestUrls = List.of(DEFAULT_MANIFEST);
|
||||
|
||||
public volatile boolean toggleForSelf = true;
|
||||
public volatile boolean forceFallback = false;
|
||||
public volatile boolean disableFallback = true;
|
||||
public volatile boolean forceCompress = false;
|
||||
public volatile boolean ignoreCspyLike = true;
|
||||
public volatile int chatMsgTrunc = 2048;
|
||||
public volatile int maxCompressedPayload = this.chatMsgTrunc * 4;
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.config;
|
||||
|
||||
import io.github.wasabithumb.jtoml.configurate.TomlConfigurationLoader;
|
||||
import org.spongepowered.configurate.CommentedConfigurationNode;
|
||||
import org.spongepowered.configurate.ConfigurateException;
|
||||
import org.spongepowered.configurate.loader.HeaderMode;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util.Constants.storageDir;
|
||||
|
||||
|
||||
public final class ConfigurationManager {
|
||||
public static final ConfigurationManager INSTANCE = new ConfigurationManager();
|
||||
public final Configuration config;
|
||||
private final CommentedConfigurationNode node;
|
||||
private final TomlConfigurationLoader loader;
|
||||
|
||||
private ConfigurationManager () {
|
||||
try {
|
||||
this.loader = TomlConfigurationLoader
|
||||
.builder()
|
||||
.defaultOptions(opts -> opts.shouldCopyDefaults(true))
|
||||
.headerMode(HeaderMode.PRESERVE)
|
||||
.path(storageDir.resolve("chatattestation" + ".toml"))
|
||||
.build();
|
||||
|
||||
this.node = this.loader.load();
|
||||
this.config = Objects.requireNonNull(this.node.get(Configuration.class));
|
||||
save();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(
|
||||
"Configuration error",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public void save () {
|
||||
try {
|
||||
this.node.set(
|
||||
Configuration.class,
|
||||
this.config
|
||||
);
|
||||
this.loader.save(this.node);
|
||||
} catch (ConfigurateException e) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to save config",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+147
@@ -0,0 +1,147 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.crypto;
|
||||
|
||||
import com.google.common.primitives.Longs;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.config.ConfigurationManager;
|
||||
import org.apache.commons.compress.compressors.zstandard.ZstdCompressorInputStream;
|
||||
import org.apache.commons.compress.compressors.zstandard.ZstdCompressorOutputStream;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.crypto.SigningManager.PERIOD;
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util.Constants.LOGGER;
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util.Constants.MESSAGE_LIMIT;
|
||||
|
||||
public record Payload(
|
||||
byte[] msg,
|
||||
byte[] signature,
|
||||
byte[] key,
|
||||
byte[] nonce,
|
||||
long exp,
|
||||
boolean compressedMsg
|
||||
) {
|
||||
private static final int ORIGINAL_MSG_BUDGET = (MESSAGE_LIMIT - 4) - 64 - 16 - 8 - 2 - 1; // 64 for signature size, 16 for key hash, 8 for exp, 2 for nonce, 1 for payload header
|
||||
|
||||
public static Payload read (
|
||||
byte[] msg,
|
||||
DataInputStream input
|
||||
) throws IOException {
|
||||
final int replacementMsgBytes = input.readUnsignedByte();
|
||||
final boolean isCompressed = replacementMsgBytes != 0;
|
||||
if (isCompressed) {
|
||||
msg = new byte[replacementMsgBytes];
|
||||
input.readFully(msg);
|
||||
}
|
||||
final byte[] signature = new byte[64];
|
||||
input.readFully(signature);
|
||||
final byte[] keyHash = new byte[16];
|
||||
input.readFully(keyHash);
|
||||
final byte[] nonce = new byte[2];
|
||||
input.readFully(nonce);
|
||||
return new Payload(
|
||||
msg,
|
||||
signature,
|
||||
keyHash,
|
||||
nonce,
|
||||
input.readLong(),
|
||||
isCompressed
|
||||
);
|
||||
}
|
||||
|
||||
public static byte[] withAdditionalData (
|
||||
byte[] msg,
|
||||
byte[] nonce,
|
||||
long exp
|
||||
) {
|
||||
final byte[] msgWithNonceAndExp = new byte[msg.length + 2 + 8];
|
||||
System.arraycopy(
|
||||
nonce,
|
||||
0,
|
||||
msgWithNonceAndExp,
|
||||
0,
|
||||
2
|
||||
);
|
||||
System.arraycopy(
|
||||
Longs.toByteArray(exp),
|
||||
0,
|
||||
msgWithNonceAndExp,
|
||||
2,
|
||||
8
|
||||
);
|
||||
System.arraycopy(
|
||||
msg,
|
||||
0,
|
||||
msgWithNonceAndExp,
|
||||
2 + 8,
|
||||
msg.length
|
||||
);
|
||||
return msgWithNonceAndExp;
|
||||
}
|
||||
|
||||
public static boolean write (
|
||||
byte[] msg,
|
||||
DataOutput output
|
||||
) throws IOException {
|
||||
final boolean compressed = msg.length > ORIGINAL_MSG_BUDGET || ConfigurationManager.INSTANCE.config.forceCompress;
|
||||
|
||||
if (compressed) {
|
||||
final var out = new ByteArrayOutputStream();
|
||||
final var cmp = new ZstdCompressorOutputStream(out);
|
||||
cmp.write(msg);
|
||||
cmp.flush();
|
||||
cmp.close();
|
||||
msg = out.toByteArray();
|
||||
}
|
||||
|
||||
output.writeByte(compressed ?
|
||||
msg.length :
|
||||
0);
|
||||
if (compressed)
|
||||
output.write(msg);
|
||||
final byte[] nonce = new byte[2];
|
||||
ThreadLocalRandom
|
||||
.current()
|
||||
.nextBytes(nonce);
|
||||
final long exp = System.currentTimeMillis() + PERIOD;
|
||||
msg = withAdditionalData(
|
||||
msg,
|
||||
nonce,
|
||||
exp
|
||||
);
|
||||
final var signature = SigningManager.INSTANCE.createSignature(msg);
|
||||
output.write(signature);
|
||||
output.write(SigningManager.INSTANCE.selfHash);
|
||||
output.write(nonce);
|
||||
output.writeLong(exp);
|
||||
return compressed;
|
||||
}
|
||||
|
||||
public String getReplacementMsg () throws IOException {
|
||||
if (!this.compressedMsg)
|
||||
return new String(
|
||||
this.msg,
|
||||
StandardCharsets.UTF_8
|
||||
);
|
||||
@SuppressWarnings("resource")
|
||||
final var in = new ZstdCompressorInputStream(new ByteArrayInputStream(this.msg));
|
||||
final var out = new ByteArrayOutputStream();
|
||||
|
||||
final byte[] buf = new byte[8192];
|
||||
int read;
|
||||
while ((read = in.read(buf)) != -1) {
|
||||
if (out.size() >= ConfigurationManager.INSTANCE.config.maxCompressedPayload)
|
||||
return new String(
|
||||
this.msg,
|
||||
StandardCharsets.UTF_8
|
||||
);
|
||||
|
||||
out.write(
|
||||
buf,
|
||||
0,
|
||||
read
|
||||
);
|
||||
}
|
||||
return out.toString(StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
+455
@@ -0,0 +1,455 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.crypto;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.KeyManifest;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.config.ConfigurationManager;
|
||||
import net.jodah.expiringmap.ExpiringMap;
|
||||
import org.bouncycastle.crypto.params.Ed25519PrivateKeyParameters;
|
||||
import org.bouncycastle.crypto.params.Ed25519PublicKeyParameters;
|
||||
import org.bouncycastle.crypto.util.PrivateKeyFactory;
|
||||
import org.bouncycastle.crypto.util.PrivateKeyInfoFactory;
|
||||
import org.bouncycastle.math.ec.rfc8032.Ed25519;
|
||||
import org.jetbrains.annotations.Unmodifiable;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.net.URI;
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.time.Duration;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.locks.StampedLock;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util.Constants.*;
|
||||
|
||||
public final class SigningManager {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger(SigningManager.class);
|
||||
public static final SigningManager INSTANCE = new SigningManager();
|
||||
public static final long PERIOD = 10_000L;
|
||||
public final byte[] selfHash;
|
||||
private final ExecutorService requestExecutor = Executors.newCachedThreadPool();
|
||||
private final StampedLock lock = new StampedLock();
|
||||
private final Map<String, KeyManifest> manifests;
|
||||
private final Set<String> nicks = new HashSet<>();
|
||||
private final Map<WrappedByteArray, LoadedKey> hashToKey = new HashMap<>();
|
||||
private final Map<Long, Set<WrappedByteArray>> usedSignatureMap = ExpiringMap
|
||||
.builder()
|
||||
.expiration(
|
||||
PERIOD,
|
||||
TimeUnit.MILLISECONDS
|
||||
)
|
||||
.build();
|
||||
private final Ed25519PrivateKeyParameters selfKey;
|
||||
private final Path cachePath;
|
||||
|
||||
public SigningManager () {
|
||||
this.cachePath = storageDir
|
||||
.resolve("data")
|
||||
.resolve("chatattestation-cache.json");
|
||||
|
||||
final var cacheParent = this.cachePath.getParent();
|
||||
final boolean orphan = Files.notExists(cacheParent);
|
||||
|
||||
try {
|
||||
if (orphan) {
|
||||
LOGGER.info("Creating Chat Attestation folder");
|
||||
Files.createDirectories(cacheParent);
|
||||
}
|
||||
|
||||
if (orphan || Files.notExists(this.cachePath)) {
|
||||
this.manifests = new HashMap<>();
|
||||
} else {
|
||||
this.manifests = GSON.fromJson(
|
||||
Files.newBufferedReader(this.cachePath),
|
||||
new TypeToken<>() {
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(
|
||||
"Failed to initialize cache",
|
||||
e
|
||||
);
|
||||
}
|
||||
|
||||
final var legacyKeyPath = storageDir.resolve("chatattestation.key");
|
||||
final var keyPath = storageDir.resolve("chatattestation.priv.key");
|
||||
|
||||
if (Files.exists(legacyKeyPath)) {
|
||||
try {
|
||||
Files.move(
|
||||
legacyKeyPath,
|
||||
keyPath
|
||||
);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Failed to rename legacy key path");
|
||||
}
|
||||
}
|
||||
|
||||
if (Files.notExists(keyPath)) {
|
||||
try {
|
||||
this.selfKey = new Ed25519PrivateKeyParameters(SecureRandom.getInstanceStrong());
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalArgumentException(
|
||||
"JVM does not provide strong secure random impl",
|
||||
e
|
||||
);
|
||||
}
|
||||
|
||||
this.savePrivateKey(keyPath);
|
||||
} else {
|
||||
final byte[] keyData;
|
||||
|
||||
try {
|
||||
keyData = Files.readAllBytes(keyPath);
|
||||
} catch (IOException e) {
|
||||
throw new UncheckedIOException(
|
||||
"Failed to load stored private key",
|
||||
e
|
||||
);
|
||||
}
|
||||
if (keyData.length == 32) {
|
||||
this.selfKey = new Ed25519PrivateKeyParameters(keyData);
|
||||
this.savePrivateKey(keyPath);
|
||||
} else {
|
||||
final var extractedData = Base64
|
||||
.getDecoder()
|
||||
.decode(new String(
|
||||
keyData,
|
||||
StandardCharsets.UTF_8
|
||||
)
|
||||
.lines()
|
||||
.filter(l -> !l.startsWith("-"))
|
||||
.map(String::trim)
|
||||
.collect(Collectors.joining()));
|
||||
|
||||
try {
|
||||
this.selfKey = (Ed25519PrivateKeyParameters) PrivateKeyFactory.createKey(extractedData);
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException(
|
||||
"Invalid private key",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
/* LOGGER.info(
|
||||
"Encoded public key: {}",
|
||||
Base64.getEncoder().encodeToString(this.selfKey.generatePublicKey().getEncoded())
|
||||
);*/
|
||||
}
|
||||
|
||||
final var encodedPublicKey = this.selfKey
|
||||
.generatePublicKey()
|
||||
.getEncoded();
|
||||
this.selfHash = createHash(encodedPublicKey);
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
final var scheduler = Executors.newSingleThreadScheduledExecutor(DAEMON_THREAD_FACTORY);
|
||||
scheduler.scheduleAtFixedRate(
|
||||
this::refetchKeys,
|
||||
0,
|
||||
1,
|
||||
TimeUnit.MINUTES
|
||||
);
|
||||
}
|
||||
|
||||
public static void init () {
|
||||
|
||||
}
|
||||
|
||||
public static byte[] createHash (byte[] input) {
|
||||
final MessageDigest messageDigest;
|
||||
try {
|
||||
messageDigest = MessageDigest.getInstance("SHA3-224");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new IllegalStateException(
|
||||
"JVM does not have SHA3-224 support",
|
||||
e
|
||||
);
|
||||
}
|
||||
|
||||
return Arrays.copyOfRange(
|
||||
messageDigest.digest(input),
|
||||
0,
|
||||
16
|
||||
);
|
||||
}
|
||||
|
||||
private static long getCurrentPeriod () {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private void savePrivateKey (Path keyPath) {
|
||||
try (final var out = Files.newBufferedWriter(keyPath)) {
|
||||
out.write("-----BEGIN PRIVATE KEY-----\n");
|
||||
|
||||
final var encoded = Base64
|
||||
.getEncoder()
|
||||
.encodeToString(PrivateKeyInfoFactory
|
||||
.createPrivateKeyInfo(this.selfKey)
|
||||
.getEncoded());
|
||||
out.write(encoded);
|
||||
out.write("\n-----END PRIVATE KEY-----");
|
||||
out.flush();
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException(
|
||||
"Failed to save private key",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private CompletableFuture<KeyManifest> refetchManifest (String url) {
|
||||
return CompletableFuture.supplyAsync(
|
||||
() -> {
|
||||
try (
|
||||
final var client = HttpClient
|
||||
.newBuilder()
|
||||
.connectTimeout(Duration.ofSeconds(30))
|
||||
.build()
|
||||
) {
|
||||
final var request = client.send(
|
||||
HttpRequest
|
||||
.newBuilder(URI.create(url))
|
||||
.GET()
|
||||
.build(),
|
||||
HttpResponse.BodyHandlers.ofString()
|
||||
);
|
||||
|
||||
return GSON.fromJson(
|
||||
request.body(),
|
||||
KeyManifest.class
|
||||
);
|
||||
} catch (Exception e) {
|
||||
throw new CompletionException(
|
||||
"Failed to fetch manifest",
|
||||
e
|
||||
);
|
||||
}
|
||||
},
|
||||
this.requestExecutor
|
||||
);
|
||||
}
|
||||
|
||||
public void refetchKeys () {
|
||||
final var futures = ConfigurationManager.INSTANCE.config.keyManifestUrls
|
||||
.stream()
|
||||
.collect(Collectors.toMap(
|
||||
url -> url,
|
||||
this::refetchManifest
|
||||
));
|
||||
|
||||
for (final var futureEntry : futures.entrySet()) {
|
||||
final String manifest = futureEntry.getKey();
|
||||
|
||||
try {
|
||||
this.manifests.put(
|
||||
manifest,
|
||||
futureEntry
|
||||
.getValue()
|
||||
.join()
|
||||
);
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn(
|
||||
"Fetching {} failed, cache will be used if present",
|
||||
manifest,
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
try (final var writer = Files.newBufferedWriter(this.cachePath)) {
|
||||
GSON.toJson(
|
||||
this.manifests,
|
||||
writer
|
||||
);
|
||||
writer.flush();
|
||||
} catch (IOException e) {
|
||||
LOGGER.warn(
|
||||
"Failed to save manifest cache",
|
||||
e
|
||||
);
|
||||
}
|
||||
|
||||
this.reloadKeys();
|
||||
}
|
||||
|
||||
private void reloadKeys () {
|
||||
final long writeLock = this.lock.writeLock();
|
||||
|
||||
try {
|
||||
this.hashToKey.clear();
|
||||
this.nicks.clear();
|
||||
|
||||
for (final var entry : this.manifests.entrySet()) {
|
||||
final var manifestUrl = entry.getKey();
|
||||
|
||||
for (final var keyToClaim : entry
|
||||
.getValue()
|
||||
.keyToClaims()
|
||||
.entrySet()) {
|
||||
final var rawKey = Base64
|
||||
.getDecoder()
|
||||
.decode(keyToClaim.getKey());
|
||||
final var loadedKey = this.hashToKey.computeIfAbsent(
|
||||
new WrappedByteArray(createHash(rawKey)),
|
||||
k -> new LoadedKey(
|
||||
new Ed25519PublicKeyParameters(rawKey),
|
||||
new HashMap<>()
|
||||
)
|
||||
);
|
||||
|
||||
final var keyClaims = keyToClaim.getValue();
|
||||
final var claims = loadedKey.manifestUrlToClaims.computeIfAbsent(
|
||||
manifestUrl,
|
||||
k -> new HashSet<>()
|
||||
);
|
||||
claims.addAll(keyClaims);
|
||||
|
||||
for (final var claim : keyClaims)
|
||||
this.nicks.add(claim.toLowerCase());
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
this.lock.unlockWrite(writeLock);
|
||||
}
|
||||
}
|
||||
|
||||
public Response verifyClaim (
|
||||
byte[] msg,
|
||||
byte[] sig,
|
||||
byte[] key,
|
||||
long exp
|
||||
) {
|
||||
if (System.currentTimeMillis() > exp)
|
||||
return Response.ReusedSignature.INSTANCE;
|
||||
|
||||
final long readLock = this.lock.readLock();
|
||||
|
||||
try {
|
||||
final var usedSignatures = this.usedSignatureMap.computeIfAbsent(
|
||||
getCurrentPeriod(),
|
||||
k -> new HashSet<>()
|
||||
);
|
||||
final var wrappedSig = new WrappedByteArray(sig);
|
||||
if (usedSignatures.contains(wrappedSig))
|
||||
return Response.ReusedSignature.INSTANCE;
|
||||
final var wrappedKey = new WrappedByteArray(key);
|
||||
final var loadedKey = this.hashToKey.get(wrappedKey);
|
||||
if (loadedKey == null)
|
||||
return Response.NoSuchKey.INSTANCE;
|
||||
|
||||
if (!loadedKey.bc.verify(
|
||||
Ed25519.Algorithm.Ed25519,
|
||||
null,
|
||||
msg,
|
||||
0,
|
||||
msg.length,
|
||||
sig,
|
||||
0
|
||||
))
|
||||
return Response.InvalidSignature.INSTANCE;
|
||||
|
||||
usedSignatures.add(wrappedSig);
|
||||
return new Response.SignatureValid(loadedKey);
|
||||
} finally {
|
||||
this.lock.unlockRead(readLock);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean doesNickRequireSignature (String nick) {
|
||||
return this.nicks.contains(nick.toLowerCase());
|
||||
}
|
||||
|
||||
public byte[] createSignature (byte[] msg) {
|
||||
final byte[] signature = new byte[64];
|
||||
this.selfKey.sign(
|
||||
Ed25519.Algorithm.Ed25519,
|
||||
null,
|
||||
msg,
|
||||
0,
|
||||
msg.length,
|
||||
signature,
|
||||
0
|
||||
);
|
||||
return signature;
|
||||
}
|
||||
|
||||
public sealed interface Response {
|
||||
final class NoSuchKey implements Response {
|
||||
public static final NoSuchKey INSTANCE = new NoSuchKey();
|
||||
|
||||
private NoSuchKey () {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
final class InvalidSignature implements Response {
|
||||
public static final InvalidSignature INSTANCE = new InvalidSignature();
|
||||
|
||||
private InvalidSignature () {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
final class ReusedSignature implements Response {
|
||||
public static final ReusedSignature INSTANCE = new ReusedSignature();
|
||||
|
||||
private ReusedSignature () {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
record SignatureValid(LoadedKey key) implements Response {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static final class WrappedByteArray {
|
||||
private final byte[] arr;
|
||||
|
||||
public WrappedByteArray (byte @Unmodifiable [] arr) {
|
||||
this.arr = arr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString () {
|
||||
return HexFormat
|
||||
.of()
|
||||
.formatHex(this.arr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode () {
|
||||
return Arrays.hashCode(this.arr);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals (Object obj) {
|
||||
return obj instanceof final WrappedByteArray wrappedByteArray && Arrays.equals(
|
||||
wrappedByteArray.arr,
|
||||
this.arr
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public record LoadedKey(
|
||||
Ed25519PublicKeyParameters bc,
|
||||
Map<String, Set<String>> manifestUrlToClaims
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.enums;
|
||||
|
||||
public enum SigningStatus {
|
||||
NO_PAYLOAD,
|
||||
NEEDS_SIGNATURE,
|
||||
INVALID_SIGNATURE,
|
||||
NO_SUCH_KEY,
|
||||
REUSED_SIGNATURE,
|
||||
VERIFIED, // authenticated via manifest
|
||||
VALID_UNVERIFIED // valid sig, but key not authorized for nick
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util;
|
||||
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public final class ChatEncoding {
|
||||
public static final int[] ENCODING;
|
||||
public static final int[] DECODING;
|
||||
|
||||
static {
|
||||
ENCODING = IntStream
|
||||
.concat(
|
||||
IntStream.range(
|
||||
0x21,
|
||||
0x7E
|
||||
),
|
||||
IntStream.range(
|
||||
0xA1,
|
||||
0x010000
|
||||
)
|
||||
)
|
||||
.filter(c -> c != '&' && c != '§')
|
||||
.limit(256)
|
||||
.toArray();
|
||||
|
||||
final int max = Arrays
|
||||
.stream(ENCODING)
|
||||
.max()
|
||||
.orElseThrow();
|
||||
DECODING = new int[max + 1];
|
||||
Arrays.fill(
|
||||
DECODING,
|
||||
-1
|
||||
);
|
||||
|
||||
for (int i = 0; i < ENCODING.length; i++) {
|
||||
DECODING[ENCODING[i]] = i;
|
||||
}
|
||||
}
|
||||
|
||||
public static String encode (byte[] input) {
|
||||
final var builder = new StringBuilder(input.length);
|
||||
|
||||
for (final byte b : input) {
|
||||
builder.appendCodePoint(ENCODING[(int) b & 0xFF]);
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static byte @Nullable [] decode (String input) {
|
||||
final var out = new ByteArrayOutputStream();
|
||||
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
final var ch = input.codePointAt(i);
|
||||
if (ch < 0 || ch >= DECODING.length)
|
||||
return null;
|
||||
final int b = DECODING[ch];
|
||||
if (b == -1)
|
||||
return null;
|
||||
out.write(b);
|
||||
}
|
||||
|
||||
return out.toByteArray();
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class Constants {
|
||||
public static final Logger LOGGER = LoggerFactory.getLogger("chatattestation");
|
||||
public static final Gson GSON = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
public static final Pattern SIGNED_MESSAGE_PATTERN = Pattern.compile("\\$\\$(.*)\\$\\$(.*)$");
|
||||
public static final ThreadFactory DAEMON_THREAD_FACTORY = r -> {
|
||||
final var t = new Thread(r);
|
||||
t.setDaemon(true);
|
||||
return t;
|
||||
};
|
||||
public static final int MESSAGE_LIMIT = 256;
|
||||
public static final ExecutorService SIGN_EXECUTOR = Executors.newSingleThreadExecutor();
|
||||
public static final Path storageDir = Path.of("chatattestation");
|
||||
|
||||
private Constants () {
|
||||
|
||||
}
|
||||
}
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util;
|
||||
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public final class ListeningList<T> implements List<T> {
|
||||
private final Consumer<T> listener;
|
||||
private final List<T> handle;
|
||||
|
||||
public ListeningList (
|
||||
Consumer<T> listener,
|
||||
List<T> handle
|
||||
) {
|
||||
this.listener = listener;
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int size () {
|
||||
return this.handle.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty () {
|
||||
return this.handle.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains (Object o) {
|
||||
return this.handle.contains(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterator<T> iterator () {
|
||||
return this.handle.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Object @NonNull [] toArray () {
|
||||
return this.handle.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull <T1> T1 @NonNull [] toArray (@NonNull T1 @NonNull [] a) {
|
||||
return this.handle.toArray(a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add (T t) {
|
||||
this.listener.accept(t);
|
||||
return this.handle.add(t);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove (Object o) {
|
||||
return this.handle.remove(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll (@NonNull Collection<?> c) {
|
||||
//noinspection SlowListContainsAll
|
||||
return this.handle.containsAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll (@NonNull Collection<? extends T> c) {
|
||||
c.forEach(this.listener);
|
||||
return this.handle.addAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll (
|
||||
int index,
|
||||
@NonNull Collection<? extends T> c
|
||||
) {
|
||||
c.forEach(this.listener);
|
||||
return this.handle.addAll(
|
||||
index,
|
||||
c
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll (@NonNull Collection<?> c) {
|
||||
return this.handle.removeAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll (@NonNull Collection<?> c) {
|
||||
return this.handle.retainAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear () {
|
||||
this.handle.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public T get (int index) {
|
||||
return this.handle.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T set (
|
||||
int index,
|
||||
T element
|
||||
) {
|
||||
this.listener.accept(element);
|
||||
return this.handle.set(
|
||||
index,
|
||||
element
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add (
|
||||
int index,
|
||||
T element
|
||||
) {
|
||||
this.listener.accept(element);
|
||||
this.handle.add(
|
||||
index,
|
||||
element
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public T remove (int index) {
|
||||
return this.handle.remove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf (Object o) {
|
||||
return this.handle.indexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf (Object o) {
|
||||
return this.handle.lastIndexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ListIterator<T> listIterator () {
|
||||
return this.handle.listIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ListIterator<T> listIterator (int index) {
|
||||
return this.handle.listIterator(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull List<T> subList (
|
||||
int fromIndex,
|
||||
int toIndex
|
||||
) {
|
||||
return this.handle.subList(
|
||||
fromIndex,
|
||||
toIndex
|
||||
);
|
||||
}
|
||||
}
|
||||
+119
@@ -0,0 +1,119 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.Normalizer;
|
||||
import java.util.Arrays;
|
||||
import java.util.HexFormat;
|
||||
import java.util.Objects;
|
||||
|
||||
public final class NormalizationUtil {
|
||||
private static final int[] CONFUSABLES;
|
||||
|
||||
static {
|
||||
int[] confusables = new int[0];
|
||||
final String read;
|
||||
final var resourceStream = Objects.requireNonNull(NormalizationUtil.class
|
||||
.getClassLoader()
|
||||
.getResourceAsStream("confusables.txt"));
|
||||
|
||||
try {
|
||||
read = new String(
|
||||
resourceStream.readAllBytes(),
|
||||
StandardCharsets.UTF_8
|
||||
);
|
||||
resourceStream.close();
|
||||
} catch (IOException e) {
|
||||
throw new IllegalArgumentException(
|
||||
"Failed to read confusables list",
|
||||
e
|
||||
);
|
||||
}
|
||||
|
||||
final var hexFormat = HexFormat.of();
|
||||
final var lines = read
|
||||
.lines()
|
||||
.iterator();
|
||||
while (lines.hasNext()) {
|
||||
var line = lines.next();
|
||||
if (line.startsWith("#"))
|
||||
continue;
|
||||
final var split = line.split(";");
|
||||
if (split.length < 2)
|
||||
continue;
|
||||
final int confusable = intFromByteArrayWithPadding(hexFormat.parseHex(padHex(split[0].trim())));
|
||||
if (confusable <= 127)
|
||||
continue;
|
||||
final var replacement = split[1].trim();
|
||||
if (replacement.split(" ").length != 1)
|
||||
continue;
|
||||
final int replacementCodepoint = intFromByteArrayWithPadding(hexFormat.parseHex(padHex(replacement)));
|
||||
if (replacementCodepoint > 127)
|
||||
continue;
|
||||
if (confusables.length <= confusable) {
|
||||
int[] newConfusables = new int[confusable + 1];
|
||||
Arrays.fill(
|
||||
newConfusables,
|
||||
Integer.MIN_VALUE
|
||||
);
|
||||
System.arraycopy(
|
||||
confusables,
|
||||
0,
|
||||
newConfusables,
|
||||
0,
|
||||
confusables.length
|
||||
);
|
||||
confusables = newConfusables;
|
||||
}
|
||||
|
||||
confusables[confusable] = replacementCodepoint;
|
||||
}
|
||||
|
||||
CONFUSABLES = confusables;
|
||||
}
|
||||
|
||||
private static String padHex (String input) {
|
||||
if (input.length() % 2 != 0)
|
||||
return "0" + input;
|
||||
return input;
|
||||
}
|
||||
|
||||
|
||||
private static int intFromByteArrayWithPadding (byte[] buf) {
|
||||
if (buf.length != 4) {
|
||||
final byte[] intermediate = new byte[4];
|
||||
System.arraycopy(
|
||||
buf,
|
||||
0,
|
||||
intermediate,
|
||||
4 - buf.length,
|
||||
buf.length
|
||||
);
|
||||
buf = intermediate;
|
||||
}
|
||||
|
||||
return Ints.fromByteArray(buf);
|
||||
}
|
||||
|
||||
public static String normalizeString (String input) {
|
||||
input = Normalizer.normalize(
|
||||
input,
|
||||
Normalizer.Form.NFKC
|
||||
);
|
||||
final var output = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < input.length(); i++) {
|
||||
final int codepoint = input.codePointAt(i);
|
||||
final int replacement;
|
||||
if (CONFUSABLES.length <= codepoint || (replacement = CONFUSABLES[codepoint]) == Integer.MIN_VALUE)
|
||||
output.appendCodePoint(codepoint);
|
||||
else {
|
||||
output.appendCodePoint(replacement);
|
||||
}
|
||||
}
|
||||
|
||||
return output.toString();
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.enums.SigningStatus;
|
||||
|
||||
public record SigningResult(
|
||||
SigningStatus status,
|
||||
String encodedKey
|
||||
) {
|
||||
public static SigningResult of (SigningStatus status) {
|
||||
return new SigningResult(
|
||||
status,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.util;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.chatattestation.config.ConfigurationManager;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class Util {
|
||||
private static final Pattern EXTRACTOR = Pattern.compile("^<?([^:<>]*)[>:] (.*)$");
|
||||
private static final Pattern CHIPMUNK_EXTRACTOR = Pattern.compile("^\\[.*] ([^›]*) › (.*)$");
|
||||
|
||||
private Util () {
|
||||
|
||||
}
|
||||
|
||||
public static @Nullable String extractDisguisedContent (String fullMsg) {
|
||||
final var matcher = EXTRACTOR.matcher(fullMsg);
|
||||
return matcher.matches() ?
|
||||
matcher.group(2) :
|
||||
null;
|
||||
}
|
||||
|
||||
public static @Nullable SystemExtraction extractSystemContent (String msg) {
|
||||
final var chipmunkMatcher = CHIPMUNK_EXTRACTOR.matcher(msg);
|
||||
if (chipmunkMatcher.matches()) {
|
||||
return new SystemExtraction(
|
||||
chipmunkMatcher.group(1),
|
||||
chipmunkMatcher.group(2)
|
||||
);
|
||||
} else {
|
||||
final var regularExtractor = EXTRACTOR.matcher(msg);
|
||||
if (!regularExtractor.matches())
|
||||
return null;
|
||||
// TODO: Handle spaces in names.
|
||||
final var sender = regularExtractor
|
||||
.group(1)
|
||||
.split(" ");
|
||||
if (sender.length == 1 && ConfigurationManager.INSTANCE.config.ignoreCspyLike)
|
||||
return null;
|
||||
return new SystemExtraction(
|
||||
sender[sender.length - 1],
|
||||
regularExtractor.group(2)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public record SystemExtraction(
|
||||
String sender,
|
||||
String content
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.chatparsers;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ChatType;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ParseChatData;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.PlayerMessageData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class KaboomChatParser implements ParseChatData {
|
||||
private static final Component SEPERATOR_COLON = Component.text(":");
|
||||
private static final Component SEPERATOR_COLON_RACCOON = Component.text("§f:"); // https://github.com/raccoonserver/extras/commit/315f704075db2f00e3e1bfbf55f858469c22880f
|
||||
private static final Component SEPERATOR_SPACE = Component.space();
|
||||
private final NitoriBot bot;
|
||||
|
||||
public KaboomChatParser (NitoriBot bot) {
|
||||
this.bot = bot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerMessageData parse (
|
||||
ChatType chatType,
|
||||
Component message
|
||||
) {
|
||||
if (message instanceof TextComponent)
|
||||
return parse(
|
||||
chatType,
|
||||
(TextComponent) message
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
public PlayerMessageData parse (
|
||||
ChatType chatType,
|
||||
TextComponent message
|
||||
) {
|
||||
List<Component> children = message.children();
|
||||
|
||||
if (!message
|
||||
.content()
|
||||
.isEmpty() || !message
|
||||
.style()
|
||||
.isEmpty() || children.size() < 3)
|
||||
return null;
|
||||
|
||||
final Component prefix = children.getFirst();
|
||||
Component displayName = Component.empty();
|
||||
Component contents = Component.empty();
|
||||
|
||||
if (isSeperatorAt(
|
||||
children,
|
||||
1
|
||||
)) { // Missing/blank display name
|
||||
if (children.size() > 3)
|
||||
contents = children.get(3);
|
||||
} else if (isSeperatorAt(
|
||||
children,
|
||||
2
|
||||
)) {
|
||||
displayName = children.get(1);
|
||||
if (children.size() > 4)
|
||||
contents = children.get(4);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
PlayerProfileData sender = bot.players.getDisplayName(Component
|
||||
.empty()
|
||||
.append(prefix)
|
||||
.append(displayName));
|
||||
return new PlayerMessageData(
|
||||
sender,
|
||||
contents,
|
||||
chatType,
|
||||
displayName
|
||||
);
|
||||
}
|
||||
|
||||
private boolean isSeperatorAt (
|
||||
List<Component> children,
|
||||
int start
|
||||
) {
|
||||
return (
|
||||
children
|
||||
.get(start)
|
||||
.equals(SEPERATOR_COLON) || children
|
||||
.get(start)
|
||||
.equals(SEPERATOR_COLON_RACCOON)
|
||||
) && children
|
||||
.get(start + 1)
|
||||
.equals(SEPERATOR_SPACE);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.command;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
|
||||
public record CommandContext(
|
||||
NitoriBot bot,
|
||||
String[] args,
|
||||
CommandSource source
|
||||
) {
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.command;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class CommandError extends Exception {
|
||||
public final Component message;
|
||||
|
||||
public CommandError (Component message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Component message () {
|
||||
return message;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.command;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CommandInfo {
|
||||
CommandTrustLevels getTrustLevel ();
|
||||
|
||||
List<String> getAliases ();
|
||||
|
||||
String getDescription ();
|
||||
|
||||
List<String> getUsages ();
|
||||
|
||||
Component execute (CommandContext context) throws CommandError;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.command;
|
||||
|
||||
public enum CommandMessageSource {
|
||||
DISCORD,
|
||||
CONSOLE,
|
||||
INGAME
|
||||
}
|
||||
+56
@@ -0,0 +1,56 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.command;
|
||||
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ChatType;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ParsedChatType;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.componentToAnsi;
|
||||
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public record CommandSource(
|
||||
PlayerProfileData sender,
|
||||
MessageReceivedEvent discordEvent,
|
||||
CommandMessageSource source,
|
||||
ChatType chatType,
|
||||
ParsedChatType parsedChatType
|
||||
) {
|
||||
public void sendFeedback (
|
||||
NitoriBot bot,
|
||||
Component component
|
||||
) {
|
||||
switch (source) {
|
||||
case CommandMessageSource.INGAME -> {
|
||||
final String selector = String.format(
|
||||
"@p[nbt={UUID:uuid(\"%s\")}]",
|
||||
sender.uuid
|
||||
);
|
||||
|
||||
if (parsedChatType() == ParsedChatType.COMMANDSPY)
|
||||
bot.chat.tellraw(
|
||||
selector,
|
||||
component
|
||||
);
|
||||
else
|
||||
bot.chat.tellraw(
|
||||
"@a",
|
||||
component
|
||||
);
|
||||
}
|
||||
case CommandMessageSource.DISCORD -> {
|
||||
final String message = "```ansi\n" + componentToAnsi(component) + "\n```";
|
||||
discordEvent
|
||||
.getMessage()
|
||||
.reply(message)
|
||||
.queue();
|
||||
}
|
||||
case CommandMessageSource.CONSOLE -> {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.command;
|
||||
|
||||
public enum CommandTrustLevels {
|
||||
PUBLIC(0),
|
||||
TRUSTED(1),
|
||||
ADMIN(2),
|
||||
OWNER(3),
|
||||
CONSOLE(4),
|
||||
DISABLED(-1);
|
||||
|
||||
private final int level;
|
||||
|
||||
private CommandTrustLevels (int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int level () {
|
||||
return level;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private final int level;
|
||||
|
||||
private Level(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int level() {
|
||||
return level;
|
||||
}
|
||||
*/
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class CoreCommand implements CommandInfo {
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"core",
|
||||
"cb",
|
||||
"corerun"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "run commands in the bots core";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of("<command>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) {
|
||||
NitoriBot bot = context.bot();
|
||||
CommandSource source = context.source();
|
||||
String message = String.join(
|
||||
" ",
|
||||
context.args()
|
||||
);
|
||||
|
||||
|
||||
if (message.contains("@username") || message.contains("@uuid")) {
|
||||
for (PlayerProfileData player : bot.players.list) {
|
||||
|
||||
bot.core
|
||||
.runTrackedWithPacket(message
|
||||
.replaceAll(
|
||||
"\\s+@username",
|
||||
" " + player.profile.getName()
|
||||
)
|
||||
.replaceAll(
|
||||
"\\s+@uuid",
|
||||
" " + player.profile.getIdAsString()
|
||||
))
|
||||
.thenAccept(reply -> {
|
||||
if (reply == null)
|
||||
return;
|
||||
source.sendFeedback(
|
||||
bot,
|
||||
reply
|
||||
);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
bot.core
|
||||
.runTrackedWithPacket(message)
|
||||
.thenAccept(reply -> {
|
||||
if (reply == null)
|
||||
return;
|
||||
source.sendFeedback(
|
||||
bot,
|
||||
reply
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EchoCommand implements CommandInfo {
|
||||
public EchoCommand () {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"echo",
|
||||
"say"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "make the bot say something";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of("<message>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) {
|
||||
NitoriBot bot = context.bot();
|
||||
String args = String.join(
|
||||
" ",
|
||||
context.args()
|
||||
);
|
||||
if (args.startsWith("/")) {
|
||||
bot.chat.command(args.substring("/".length()));
|
||||
} else {
|
||||
bot.chat.message(args);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+214
@@ -0,0 +1,214 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.JoinConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
|
||||
|
||||
public class HelpCommand implements CommandInfo {
|
||||
public HelpCommand () {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"help",
|
||||
"hell",
|
||||
"?",
|
||||
"heko",
|
||||
"cmds",
|
||||
"commands"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "see the list of commands the bot has";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of("<command>");
|
||||
}
|
||||
|
||||
public Component getCommands (NitoriBot bot) {
|
||||
List<Component> Public = new ArrayList<>();
|
||||
List<Component> Trusted = new ArrayList<>();
|
||||
List<Component> Admin = new ArrayList<>();
|
||||
List<Component> Owner = new ArrayList<>();
|
||||
|
||||
for (CommandInfo commands : bot.commandManager.commands) {
|
||||
switch (commands.getTrustLevel()) {
|
||||
case CommandTrustLevels.PUBLIC -> Public.add(Component
|
||||
.text(commands
|
||||
.getAliases()
|
||||
.getFirst() + " ")
|
||||
.color(convertColorString(bot.config.colors.help.Public)));
|
||||
case CommandTrustLevels.TRUSTED -> Trusted.add(Component
|
||||
.text(commands
|
||||
.getAliases()
|
||||
.getFirst() + " ")
|
||||
.color(convertColorString(bot.config.colors.help.trusted)));
|
||||
case CommandTrustLevels.ADMIN -> Admin.add(Component.text(commands
|
||||
.getAliases()
|
||||
.getFirst() + " ").color(convertColorString(bot.config.colors.help.admin)));
|
||||
case CommandTrustLevels.OWNER -> Owner.add(Component
|
||||
.text(commands
|
||||
.getAliases()
|
||||
.getFirst() + " ")
|
||||
.color(convertColorString(bot.config.colors.help.owner)));
|
||||
default -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Component
|
||||
.empty()
|
||||
.append(Public)
|
||||
.append(Component.text("\n"))
|
||||
.append(Trusted)
|
||||
.append(Component.text("\n"))
|
||||
.append(Owner);
|
||||
}
|
||||
|
||||
private Component getUsages (
|
||||
NitoriBot bot,
|
||||
List<String> usages
|
||||
) {
|
||||
Component component = null;
|
||||
if (usages == null)
|
||||
component = Component
|
||||
.empty()
|
||||
.append(Component
|
||||
.text("N/A")
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)));
|
||||
|
||||
else
|
||||
component = Component
|
||||
.empty()
|
||||
.append(Component
|
||||
.text(usages.toString())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)))
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
|
||||
return component;
|
||||
}
|
||||
|
||||
private Component getCommand (
|
||||
NitoriBot bot,
|
||||
String[] command
|
||||
) {
|
||||
Component component = null;
|
||||
|
||||
for (CommandInfo commands : bot.commandManager.commands) {
|
||||
for (String aliases : commands.getAliases()) {
|
||||
if (aliases.equals(command[0]))
|
||||
component = Component
|
||||
.translatable(
|
||||
"%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
|
||||
Component
|
||||
.text("Command")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(commands
|
||||
.getAliases()
|
||||
.getFirst())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Aliases")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(commands
|
||||
.getAliases()
|
||||
.toString())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Description")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(commands.getDescription())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Trust Level")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(commands
|
||||
.getTrustLevel()
|
||||
.toString())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Usages")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
getUsages(
|
||||
bot,
|
||||
commands.getUsages()
|
||||
)
|
||||
)
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
}
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) {
|
||||
NitoriBot bot = context.bot();
|
||||
String[] args = context.args();
|
||||
CommandSource source = context.source();
|
||||
|
||||
if (args.length != 0) {
|
||||
// source.sendFeedback(bot, getCommand(bot, args));
|
||||
return getCommand(
|
||||
bot,
|
||||
args
|
||||
);
|
||||
}
|
||||
|
||||
Component helpLayout = Component.translatable(
|
||||
"%s: (%s) (%s | %s | %s | %s) ›\n",
|
||||
Component
|
||||
.text("Commands")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(String.valueOf(bot.commandManager.commands.size()))
|
||||
.color(convertColorString(bot.config.colors.integer)),
|
||||
Component
|
||||
.text("Public")
|
||||
.color(convertColorString(bot.config.colors.help.Public)),
|
||||
Component
|
||||
.text("Trusted")
|
||||
.color(convertColorString(bot.config.colors.help.trusted)),
|
||||
Component
|
||||
.text("Admin")
|
||||
.color(convertColorString(bot.config.colors.help.admin)),
|
||||
Component
|
||||
.text("Owner")
|
||||
.color(convertColorString(bot.config.colors.help.owner))
|
||||
);
|
||||
|
||||
Component component = Component
|
||||
.empty()
|
||||
.append(helpLayout)
|
||||
.append(Component.join(
|
||||
JoinConfiguration.separator(Component.space()),
|
||||
getCommands(bot)
|
||||
))
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
+417
@@ -0,0 +1,417 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandError;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.BotBuildInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring.RepoCommitInfo;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.FormatTimeUtil.format;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import oshi.hardware.CentralProcessor;
|
||||
import oshi.hardware.HardwareAbstractionLayer;
|
||||
import oshi.spi.SystemInfoFactory;
|
||||
import oshi.spi.SystemInfoProvider;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.Manifest;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
|
||||
|
||||
public class InfoCommand implements CommandInfo {
|
||||
private final Enumeration<URL> resources = InfoCommand.class
|
||||
.getClassLoader()
|
||||
.getResources("META-INF/MANIFEST.MF");
|
||||
private final Manifest manifest = new Manifest(resources
|
||||
.nextElement()
|
||||
.openStream());
|
||||
private final Attributes attributes = manifest.getMainAttributes();
|
||||
private final String buildTime = attributes.getValue("Build-Time");
|
||||
private final String classPath = attributes.getValue("Main-Class");
|
||||
|
||||
public InfoCommand () throws IOException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"info",
|
||||
"information"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "see the bots info";
|
||||
}
|
||||
|
||||
public List<String> getUsages () {
|
||||
return List.of(
|
||||
"version",
|
||||
"loaded",
|
||||
"server",
|
||||
"about",
|
||||
"config",
|
||||
"credits",
|
||||
"contributors",
|
||||
"uptime"
|
||||
);
|
||||
}
|
||||
|
||||
private final SystemInfoProvider si = SystemInfoFactory.create();
|
||||
|
||||
private final long totalMemory = si
|
||||
.getHardware()
|
||||
.getMemory()
|
||||
.getTotal() / 1024 / 1024;
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandError {
|
||||
var bot = context.bot();
|
||||
|
||||
final BotBuildInfo info = bot.botBuildInfo;
|
||||
|
||||
var args = context.args();
|
||||
|
||||
Component component = null;
|
||||
|
||||
GsonComponentSerializer gson = GsonComponentSerializer.gson();
|
||||
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "discord" -> component = Component
|
||||
.empty()
|
||||
.append(Component.text("The discord invite is "))
|
||||
.append(Component
|
||||
.text(bot.config.discord.invite)
|
||||
.hoverEvent(HoverEvent.showText(Component
|
||||
.text("click here to join the discord server")
|
||||
.color(convertColorString(bot.config.colors.commands.primary))))
|
||||
.clickEvent(ClickEvent.openUrl(bot.config.discord.invite)))
|
||||
.color(convertColorString(bot.config.colors.commands.primary));
|
||||
|
||||
case "uptime" -> {
|
||||
final long uptime = ManagementFactory
|
||||
.getRuntimeMXBean()
|
||||
.getUptime() / 1000L;
|
||||
component = Component
|
||||
.text(format(uptime))
|
||||
.color(convertColorString(bot.config.colors.commands.primary));
|
||||
}
|
||||
|
||||
case "credits",
|
||||
"contributors" -> {
|
||||
List<Component> infoComponent = new ArrayList<>();
|
||||
|
||||
for (BotBuildInfo.Contributors contributors : bot.botBuildInfo.contributors) {
|
||||
infoComponent.add(Component
|
||||
.empty()
|
||||
.append(Component.translatable(
|
||||
"%s - %s",
|
||||
Component
|
||||
.text(contributors.name)
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(contributors.reason)
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
))
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary))
|
||||
.append(Component.newline()));
|
||||
}
|
||||
|
||||
component = Component
|
||||
.empty()
|
||||
.append(Component.translatable(
|
||||
"%s - %s",
|
||||
Component
|
||||
.text(bot.botBuildInfo.owner)
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text("Owner")
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
))
|
||||
.append(Component.newline())
|
||||
.append(infoComponent)
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
}
|
||||
|
||||
case "usage" -> {
|
||||
final Runtime runtime = Runtime.getRuntime();
|
||||
final long heapUsage = ManagementFactory
|
||||
.getMemoryMXBean()
|
||||
.getHeapMemoryUsage()
|
||||
.getUsed() / 1024 / 1024;
|
||||
final long heapMax = ManagementFactory
|
||||
.getMemoryMXBean()
|
||||
.getHeapMemoryUsage()
|
||||
.getMax() / 1024 / 1024;
|
||||
final long freeJVMMemory = runtime.freeMemory() / 1024 / 1024;
|
||||
final long maxJVMMemory = runtime.maxMemory() / 1024 / 1024;
|
||||
final long allocatedJVMMemory = runtime.totalMemory() / 1024 / 1024;
|
||||
final long usedJVMMemory = allocatedJVMMemory - freeJVMMemory;
|
||||
|
||||
component = Component
|
||||
.empty()
|
||||
.append(Component
|
||||
.text("Memory Usage: ")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)))
|
||||
.append(Component.translatable(
|
||||
"%s MB / %s MB",
|
||||
Component
|
||||
.text(usedJVMMemory)
|
||||
.color(convertColorString(bot.config.colors.integer)),
|
||||
Component
|
||||
.text(maxJVMMemory)
|
||||
.color(convertColorString(bot.config.colors.integer))
|
||||
))
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
}
|
||||
|
||||
case "config" -> component = Component
|
||||
.empty()
|
||||
.append(Component.translatable(
|
||||
"%s: %s:%s",
|
||||
Component
|
||||
.text("Server")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(bot.options.host)
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text(bot.options.port)
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
))
|
||||
.append(Component.newline())
|
||||
.append(Component.translatable(
|
||||
"%s: %s",
|
||||
Component
|
||||
.text("Server Name")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(bot.options.serverName)
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
))
|
||||
.append(Component.newline())
|
||||
.append(Component.translatable(
|
||||
"%s: %s",
|
||||
Component
|
||||
.text("Minecraft Username")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(bot.options.username)
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
))
|
||||
.append(Component.newline())
|
||||
.append(Component.translatable(
|
||||
"%s: %s",
|
||||
Component
|
||||
.text("Server Count")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(bot.bots.size())
|
||||
.color(convertColorString(bot.config.colors.integer))
|
||||
))
|
||||
.append(Component.newline())
|
||||
.append(Component.translatable(
|
||||
"%s: %s",
|
||||
Component
|
||||
.text("Prefixes")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(bot.config.prefixes.toString())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
))
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
|
||||
|
||||
case "loaded" -> component = Component.translatable(
|
||||
"%s: %s\n%s: %s\n%s: %s",
|
||||
Component
|
||||
.text("Modules")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(bot.modules.size())
|
||||
.color(convertColorString(bot.config.colors.integer)),
|
||||
Component
|
||||
.text("Commands")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(bot.commandManager.commands.size())
|
||||
.color(convertColorString(bot.config.colors.integer)),
|
||||
Component
|
||||
.text("Chat Parsers")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(bot.chat.chatParsers.size())
|
||||
.color(convertColorString(bot.config.colors.integer))
|
||||
);
|
||||
|
||||
case "version" -> {
|
||||
RepoCommitInfo repoCommitInfo = bot.repoCommitInfo;
|
||||
|
||||
ZonedDateTime dateTime = ZonedDateTime.parse(repoCommitInfo.created);
|
||||
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("MMMM dd, yyyy hh:mm:ss a");
|
||||
|
||||
component = Component
|
||||
.translatable(
|
||||
"%s-%s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
|
||||
gson.deserialize(info.buildstring.botName.toString()),
|
||||
// Component.text(info.buildstring.version).color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
gson.deserialize(info.buildstring.codename.toString()),
|
||||
Component
|
||||
.text("Build")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(info.buildstring.build)
|
||||
.color(convertColorString(bot.config.colors.integer)),
|
||||
Component
|
||||
.text("Commit")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(repoCommitInfo.sha)
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Version release Date")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(dateTime.format(dateTimeFormatter))
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Initial Bot Release")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(info.buildstring.initialBotRelease)
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Jar Compile Date")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(buildTime)
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Main Class Path")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(classPath)
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
)
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
}
|
||||
|
||||
case "server" -> {
|
||||
try {
|
||||
final String osInfo = si
|
||||
.getOperatingSystem()
|
||||
.toString();
|
||||
final HardwareAbstractionLayer hardware = si.getHardware();
|
||||
final CentralProcessor cpuInfo = hardware.getProcessor();
|
||||
final String cpuName = cpuInfo
|
||||
.getProcessorIdentifier()
|
||||
.getName();
|
||||
final int cpuCores = cpuInfo.getPhysicalProcessorCount();
|
||||
final int processes = si
|
||||
.getOperatingSystem()
|
||||
.getProcessCount();
|
||||
|
||||
component = Component
|
||||
.translatable(
|
||||
"%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
|
||||
Component
|
||||
.text("Hostname")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(InetAddress
|
||||
.getLocalHost()
|
||||
.getHostName())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Username")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(System.getProperty("user.name"))
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Directory")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(System.getProperty("user.dir"))
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("CPU Arch")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(System.getProperty("os.arch"))
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("OS")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(osInfo)
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("CPU")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(cpuName)
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("CPU Cores")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(cpuCores)
|
||||
.color(convertColorString(bot.config.colors.integer)),
|
||||
Component
|
||||
.text("Processes")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(processes)
|
||||
.color(convertColorString(bot.config.colors.integer)),
|
||||
Component
|
||||
.text("Java Version")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(System.getProperty("java.version"))
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Total Memory")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(totalMemory + " MB")
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
)
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
case "about" -> component = Component
|
||||
.text(info.about)
|
||||
.color(convertColorString(bot.config.colors.commands.primary));
|
||||
|
||||
default -> throw new CommandError(Component.text("Unknown Argument"));
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.JoinConfiguration;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
|
||||
|
||||
public class ListCommand implements CommandInfo {
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"list",
|
||||
"pl",
|
||||
"playerlist"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "see the list of players";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) {
|
||||
NitoriBot bot = context.bot();
|
||||
CommandSource source = context.source();
|
||||
Component component = null;
|
||||
Component playerComponent = null;
|
||||
List<Component> playersComponent = new ArrayList<>();
|
||||
|
||||
playerComponent = Component
|
||||
.translatable(
|
||||
"%s: (%s)\n",
|
||||
Component
|
||||
.text("Players")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(bot.players.list.size())
|
||||
.color(convertColorString(bot.config.colors.integer))
|
||||
)
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
|
||||
|
||||
for (PlayerProfileData player : bot.players.list) {
|
||||
//TranslatableComponent displayName = (TranslatableComponent) player.displayName();
|
||||
playersComponent.add(Component
|
||||
.translatable(
|
||||
"%s › %s",
|
||||
player.displayName.color(NamedTextColor.WHITE),
|
||||
Component
|
||||
.text(player.uuid.toString())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
)
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary)));
|
||||
}
|
||||
|
||||
component = Component
|
||||
.empty()
|
||||
.append(playerComponent)
|
||||
.append(Component.join(
|
||||
JoinConfiguration.newlines(),
|
||||
playersComponent
|
||||
));
|
||||
|
||||
return Component
|
||||
.empty()
|
||||
.append(component);
|
||||
}
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PingServerData;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class MCServerCommand implements CommandInfo {
|
||||
public MCServerCommand () {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of("mcserver");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "ping minecraft servers";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of("<ip>:<port>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) {
|
||||
var bot = context.bot();
|
||||
var source = context.source();
|
||||
String args = String.join(
|
||||
" ",
|
||||
context.args()
|
||||
);
|
||||
Component component = null;
|
||||
|
||||
var ip = args.split(":");
|
||||
|
||||
List<PingServerData> infoList = bot.mcServer.pingServer(ip);
|
||||
|
||||
PingServerData info = infoList.getFirst();
|
||||
|
||||
component = Component
|
||||
.empty()
|
||||
.append(Component.translatable(
|
||||
"%s: %s:%s\n",
|
||||
Component
|
||||
.text("Server Ip")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(ip[0])
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text(ip[1])
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
))
|
||||
.append(Component.translatable(
|
||||
"%s: %s/%s\n",
|
||||
Component
|
||||
.text("Players")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(info.playersOnline())
|
||||
.color(convertColorString(bot.config.colors.integer)),
|
||||
Component
|
||||
.text(info.maxPlayers())
|
||||
.color(convertColorString(bot.config.colors.integer))
|
||||
))
|
||||
.append(Component.translatable(
|
||||
"%s: %s\n",
|
||||
Component
|
||||
.text("Server Version")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(info.versionName())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
))
|
||||
.append(Component.translatable(
|
||||
"%s: %s\n",
|
||||
Component
|
||||
.text("Protocol Version")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(info.protocolVersion())
|
||||
.color(convertColorString(bot.config.colors.integer))
|
||||
))
|
||||
.append(Component.translatable(
|
||||
"%s: \n%s",
|
||||
Component
|
||||
.text("Description")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
info.description()
|
||||
))
|
||||
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
+97
@@ -0,0 +1,97 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.*;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NetmsgCommand implements CommandInfo {
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"netmsg",
|
||||
"networkmessage"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "send a message to the servers the bot is connected to";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of("<message>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandError {
|
||||
final NitoriBot bot = context.bot();
|
||||
final String message = String
|
||||
.join(
|
||||
" ",
|
||||
context.args()
|
||||
)
|
||||
.replaceAll(
|
||||
".*nigger.*",
|
||||
"I love faggots, I love the gays"
|
||||
)
|
||||
.replaceAll(
|
||||
".*skid.*",
|
||||
"im a no life retarded piece of shit!"
|
||||
)
|
||||
.replaceAll(
|
||||
".*meow.*",
|
||||
":3"
|
||||
);
|
||||
final CommandSource source = context.source();
|
||||
|
||||
for (NitoriBot eachBot : bot.bots) {
|
||||
Component component = null;
|
||||
if (eachBot.options.isPrivate)
|
||||
component = Component
|
||||
.translatable(
|
||||
"[%s] %s › %s",
|
||||
Component
|
||||
.text(eachBot.options.serverName)
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
source.sender().displayName,
|
||||
Component.text(message)
|
||||
)
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
|
||||
else
|
||||
component = Component
|
||||
.translatable(
|
||||
"[%s:%s] %s › %s",
|
||||
Component
|
||||
.text(bot.options.host)
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(bot.options.port)
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
source.sender().displayName,
|
||||
Component.text(message)
|
||||
)
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
|
||||
eachBot.chat.tellraw(
|
||||
"@a",
|
||||
component
|
||||
);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
|
||||
|
||||
public class PlayerInfoCommand implements CommandInfo {
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"playerinfo",
|
||||
"getplayer"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "get the info of a player";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of(
|
||||
"<username>",
|
||||
"<uuid>"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) {
|
||||
NitoriBot bot = context.bot();
|
||||
String[] args = context.args();
|
||||
CommandSource source = context.source();
|
||||
Component component = null;
|
||||
|
||||
for (PlayerProfileData player : bot.players.list) {
|
||||
if (player.profile
|
||||
.getName()
|
||||
.equals(args[0]))
|
||||
component = Component
|
||||
.translatable(
|
||||
"%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s",
|
||||
Component
|
||||
.text("Player")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
player.displayName,
|
||||
Component
|
||||
.text("UUID")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(player.uuid.toString())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Position")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(player.position.toString())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("Latency")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(player.latency + "ms")
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text("GameMode")
|
||||
.color(convertColorString(bot.config.colors.commands.primary)),
|
||||
Component
|
||||
.text(player.gameMode.toString())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary))
|
||||
)
|
||||
.color(convertColorString(bot.config.colors.commands.tertiary));
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandSource;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
|
||||
|
||||
public class RCCommand implements CommandInfo {
|
||||
public RCCommand () {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"rc",
|
||||
"refillcore"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "refill the bots core";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) {
|
||||
NitoriBot bot = context.bot();
|
||||
CommandSource source = context.source();
|
||||
|
||||
bot.core.move();
|
||||
|
||||
return Component
|
||||
.text("Refilling core")
|
||||
.color(convertColorString(bot.config.colors.commands.primary));
|
||||
}
|
||||
}
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.BetweenUtil.between;
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RTPCommand implements CommandInfo {
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"rtp",
|
||||
"tpr",
|
||||
"randomteleport"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "teleport to a random location";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandError {
|
||||
final NitoriBot bot = context.bot();
|
||||
final CommandSource source = context.source();
|
||||
final double posX = between(
|
||||
-1_000_000,
|
||||
1_000_000
|
||||
);
|
||||
final double posY = between(
|
||||
-1_000_000,
|
||||
1_000_000
|
||||
);
|
||||
final double posZ = between(
|
||||
-1_000_000,
|
||||
1_000_000
|
||||
);
|
||||
|
||||
bot.core.run(String.format(
|
||||
"essentials:tp %s %s %s %s",
|
||||
source.sender().profile.getName(),
|
||||
posX,
|
||||
posY,
|
||||
posZ
|
||||
));
|
||||
|
||||
final Component component = Component
|
||||
.translatable(
|
||||
"teleporting %s to %s %s %s",
|
||||
Component
|
||||
.text(source.sender().profile.getName())
|
||||
.color(convertColorString(bot.config.colors.commands.secondary)),
|
||||
Component
|
||||
.text(posX)
|
||||
.color(convertColorString(bot.config.colors.integer)),
|
||||
Component
|
||||
.text(posY)
|
||||
.color(convertColorString(bot.config.colors.integer)),
|
||||
Component
|
||||
.text(posZ)
|
||||
.color(convertColorString(bot.config.colors.integer))
|
||||
)
|
||||
.color(convertColorString(bot.config.colors.commands.primary));
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
/*
|
||||
const x = between(-1_000_000, 1_000_000);
|
||||
const y = 100;
|
||||
const z = between(-1_000_000, 1_000_000);
|
||||
*/
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.Public;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/*
|
||||
Adventure Minimessage is very fucking weird.....
|
||||
the fact it uses an HTML style with strings instead of components is very weird
|
||||
it also makes the JSON so fucking big especially with gradients
|
||||
this does remind me of how i did component.push shit in the JS build of my bot aka v8.0.0-Reignite
|
||||
*/
|
||||
public class TestCommand implements CommandInfo {
|
||||
private static final MiniMessage MINI_MESSAGE = MiniMessage.miniMessage();
|
||||
|
||||
public TestCommand () {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.PUBLIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of("test");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "test cmd";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) {
|
||||
var bot = context.bot();
|
||||
String[] args = context.args();
|
||||
|
||||
var source = context.source();
|
||||
|
||||
Component component = Component.text(
|
||||
bot.registry.getBlockRegistry(
|
||||
String.join(
|
||||
" ",
|
||||
args
|
||||
)
|
||||
).toString()
|
||||
);
|
||||
return component;
|
||||
|
||||
// bot.world.getBlock(Vector3i.from(Integer.parseInt(args[0]), Integer.parseInt(args[1]), Integer.parseInt(args[2])));
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.admin;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandError;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class NetcmdCommand implements CommandInfo {
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.ADMIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of("netcmd");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "run a command within the bot on another server";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandError {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.owner;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.*;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class KillCommand implements CommandInfo {
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.OWNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"kill",
|
||||
"kys",
|
||||
"stop"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "kills the bot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandError {
|
||||
NitoriBot bot = context.bot();
|
||||
CommandSource source = context.source();
|
||||
|
||||
source.sendFeedback(
|
||||
bot,
|
||||
Component
|
||||
.text("Killing Bot Process")
|
||||
.color(convertColorString(bot.config.colors.commands.primary))
|
||||
);
|
||||
|
||||
System.exit(1);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+157
@@ -0,0 +1,157 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.owner;
|
||||
|
||||
import jdk.jshell.*;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.Main;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.*;
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class ServerEvalCommand implements CommandInfo {
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.OWNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"servereval",
|
||||
"se"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "eval code unisolated";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of("<code>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandError {
|
||||
final NitoriBot bot = context.bot();
|
||||
final CommandSource source = context.source();
|
||||
Component component = null;
|
||||
final String args = String.join(
|
||||
" ",
|
||||
context.args()
|
||||
);
|
||||
|
||||
final JShell jShell = JShell
|
||||
.builder()
|
||||
.executionEngine("local")
|
||||
.build();
|
||||
|
||||
var ee = new ArrayList<>();
|
||||
|
||||
final int idx = ee.indexOf(bot);
|
||||
|
||||
if (bot.evalStorage.isEmpty()) {
|
||||
bot.evalStorage.put(
|
||||
"servereval",
|
||||
jShell
|
||||
);
|
||||
var shell = bot.evalStorage.get("servereval");
|
||||
|
||||
shell.eval("import land.chipmunk.parker2991.nitoribot.nightofnights.Main; ");
|
||||
shell.eval("import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot; ");
|
||||
shell.eval("import net.kyori.adventure.text.Component; ");
|
||||
|
||||
shell.eval("final NitoriBot bot = Main.Bots.get(" + idx + "); ");
|
||||
}
|
||||
|
||||
var shell = bot.evalStorage.get("servereval");
|
||||
|
||||
if (args.equalsIgnoreCase("reset")) {
|
||||
bot.evalStorage.clear();
|
||||
component =
|
||||
Component.text("Resetting the eval").color(convertColorString(bot.config.colors.commands.primary));
|
||||
} else {
|
||||
|
||||
List<SnippetEvent> events = shell.eval(args);
|
||||
|
||||
for (SnippetEvent event : events) {
|
||||
final Snippet.Status status = event.status();
|
||||
|
||||
switch (event.status()) {
|
||||
case VALID -> {
|
||||
String value = event.value();
|
||||
JShellException exception = event.exception();
|
||||
|
||||
if (exception != null) {
|
||||
if (exception instanceof EvalException eval) {
|
||||
|
||||
try {
|
||||
if (eval.getCause() != null) {
|
||||
component = Component.text(
|
||||
exception.getCause().getLocalizedMessage()
|
||||
).color(NamedTextColor.RED);
|
||||
} else {
|
||||
component = Component.text(
|
||||
exception.getMessage()
|
||||
).color(NamedTextColor.RED);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
component =
|
||||
Component.text(eval.toString()).color(convertColorString(bot.config.colors.commands.primary));
|
||||
}
|
||||
}
|
||||
} else if (value == null) {
|
||||
component =
|
||||
Component.text("Ran successfully").color(convertColorString(bot.config.colors.commands.primary));
|
||||
} else {
|
||||
component =
|
||||
Component.text(value).color(convertColorString(bot.config.colors.commands.primary));
|
||||
|
||||
}
|
||||
bot.evalStorage.put(
|
||||
args,
|
||||
shell
|
||||
);
|
||||
}
|
||||
case REJECTED -> {
|
||||
shell
|
||||
.diagnostics(event.snippet())
|
||||
.forEach(diagnostic -> {
|
||||
String msg = diagnostic.getMessage(Locale.US);
|
||||
source.sendFeedback(
|
||||
bot,
|
||||
Component
|
||||
.text(msg.split("\n")[0])
|
||||
.color(NamedTextColor.RED)
|
||||
.hoverEvent(Component
|
||||
.text(msg)
|
||||
.color(NamedTextColor.RED))
|
||||
);
|
||||
});
|
||||
}
|
||||
case OVERWRITTEN -> {
|
||||
component = Component.translatable(
|
||||
"Value %s overridden",
|
||||
Component.text(event.snippet().source())
|
||||
).color(convertColorString(bot.config.colors.commands.primary));
|
||||
}
|
||||
case DROPPED -> {
|
||||
component =
|
||||
Component.text("Explicitly dropped").color(convertColorString(bot.config.colors.commands.primary));
|
||||
}
|
||||
default -> {
|
||||
component =
|
||||
Component.translatable("Status %s", Component.text(event.status().toString())).color(convertColorString(bot.config.colors.commands.primary));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.trusted;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandContext;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandInfo;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ReconnectCommand implements CommandInfo {
|
||||
public ReconnectCommand () {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.TRUSTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"reconnect",
|
||||
"end"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "reconnect the bot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) {
|
||||
NitoriBot bot = context.bot();
|
||||
|
||||
bot.session.disconnect("Reconnect Command");
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.commands.trusted;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.*;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
|
||||
|
||||
import static land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil.convertColorString;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ValidateCommand implements CommandInfo {
|
||||
@Override
|
||||
public CommandTrustLevels getTrustLevel () {
|
||||
return CommandTrustLevels.TRUSTED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAliases () {
|
||||
return List.of(
|
||||
"validate",
|
||||
"val"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription () {
|
||||
return "validate within the bot";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUsages () {
|
||||
return List.of("<hash>");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component execute (CommandContext context) throws CommandError {
|
||||
NitoriBot bot = context.bot();
|
||||
CommandSource source = context.source();
|
||||
PlayerProfileData player = source.sender();
|
||||
Component component = null;
|
||||
|
||||
if (source
|
||||
.source()
|
||||
.equals(CommandMessageSource.DISCORD))
|
||||
throw new CommandError(Component
|
||||
.text("this command is meant to be ran in game!")
|
||||
.color(NamedTextColor.RED));
|
||||
else {
|
||||
if (!player.alreadyValidated) {
|
||||
switch (player.trustLevel) {
|
||||
case CommandTrustLevels.TRUSTED -> component = Component
|
||||
.text("Validated as Trusted")
|
||||
.color(convertColorString(bot.config.colors.help.trusted));
|
||||
|
||||
case CommandTrustLevels.ADMIN -> component = Component
|
||||
.text("Validated as Admin")
|
||||
.color(convertColorString(bot.config.colors.help.admin));
|
||||
case CommandTrustLevels.OWNER -> component = Component
|
||||
.text("Validated as Owner")
|
||||
.color(convertColorString(bot.config.colors.help.owner));
|
||||
}
|
||||
|
||||
player.alreadyValidated = true;
|
||||
} else {
|
||||
component = Component
|
||||
.translatable(
|
||||
"Already validated as %s",
|
||||
Component.text(player.trustLevel.toString())
|
||||
)
|
||||
.color(convertColorString(bot.config.colors.commands.primary));
|
||||
}
|
||||
}
|
||||
|
||||
return component;
|
||||
}
|
||||
}
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.console;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.Main;
|
||||
import org.jline.reader.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CreateConsole implements Completer {
|
||||
private static final List<NitoriBot> servers = Main.Bots;
|
||||
public LineReader reader;
|
||||
public final String server = "all";
|
||||
|
||||
@Override
|
||||
public void complete (
|
||||
LineReader reader,
|
||||
ParsedLine line,
|
||||
List<Candidate> candidates
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
private void handleLine (String line) {
|
||||
for (NitoriBot bot : servers) {
|
||||
if (line.equals(bot.config.console.prefix + "kill"))
|
||||
System.exit(0);
|
||||
bot.chat.send(line);
|
||||
}
|
||||
}
|
||||
|
||||
public CreateConsole () {
|
||||
this.reader = LineReaderBuilder
|
||||
.builder()
|
||||
.completer(this)
|
||||
.build();
|
||||
|
||||
JlineAppender.setLineReader(reader);
|
||||
|
||||
Main.executorService.submit(
|
||||
() -> {
|
||||
while (true) {
|
||||
try {
|
||||
String line;
|
||||
|
||||
line = reader.readLine(String.format(
|
||||
"[%s] > ",
|
||||
this.server
|
||||
));
|
||||
|
||||
handleLine(line);
|
||||
} catch (Exception _) {
|
||||
}
|
||||
}
|
||||
},
|
||||
"Console Thread"
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.console;
|
||||
|
||||
import ch.qos.logback.classic.encoder.PatternLayoutEncoder;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.AppenderBase;
|
||||
import org.jline.reader.LineReader;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class JlineAppender extends AppenderBase<ILoggingEvent> {
|
||||
private static LineReader reader;
|
||||
private PatternLayoutEncoder encoder;
|
||||
//private PatternLayoutEncoder encoder = new PatternLayoutEncoder();
|
||||
|
||||
public static void setLineReader (@Nullable LineReader lineReader) {
|
||||
reader = lineReader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start () {
|
||||
super.start();
|
||||
encoder.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop () {
|
||||
encoder.stop();
|
||||
super.stop();
|
||||
}
|
||||
|
||||
|
||||
public void setEncoder (PatternLayoutEncoder encoder) {
|
||||
this.encoder = encoder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void append (ILoggingEvent event) {
|
||||
PatternLayoutEncoder enc = encoder;
|
||||
String message = new String(
|
||||
enc.encode(event),
|
||||
StandardCharsets.UTF_8
|
||||
).stripTrailing();
|
||||
|
||||
if (reader != null) {
|
||||
reader.printAbove(message);
|
||||
} else {
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.console.logger;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.util.ComponentUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.slf4j.*;
|
||||
|
||||
public class LoggerManager {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoggerManager.class);
|
||||
|
||||
public String convertComponentToAnsi (Component component) {
|
||||
return ComponentUtil.componentToAnsi(component);
|
||||
}
|
||||
|
||||
private String getLoggerType (LoggerType logType) {
|
||||
return switch (logType) {
|
||||
case LoggerType.COMMAND -> convertComponentToAnsi(Component
|
||||
.text("COMMAND")
|
||||
.color(NamedTextColor.YELLOW));
|
||||
case LoggerType.LOG -> convertComponentToAnsi(Component
|
||||
.text("LOG")
|
||||
.color(NamedTextColor.GOLD));
|
||||
case LoggerType.RECONNECT -> convertComponentToAnsi(Component
|
||||
.text("RECONNECT")
|
||||
.color(NamedTextColor.AQUA));
|
||||
};
|
||||
}
|
||||
|
||||
public void log (String message) {
|
||||
MDC.putCloseable(
|
||||
"customLevel",
|
||||
getLoggerType(LoggerType.LOG)
|
||||
);
|
||||
LOGGER.info(message);
|
||||
}
|
||||
|
||||
public void command (String message) {
|
||||
MDC.putCloseable(
|
||||
"customLevel",
|
||||
getLoggerType(LoggerType.COMMAND)
|
||||
);
|
||||
LOGGER.info(message);
|
||||
}
|
||||
|
||||
public void reconnect (String message) {
|
||||
MDC.putCloseable(
|
||||
"customLevel",
|
||||
getLoggerType(LoggerType.RECONNECT)
|
||||
);
|
||||
LOGGER.info(message);
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.console.logger;
|
||||
|
||||
public enum LoggerType {
|
||||
LOG,
|
||||
COMMAND,
|
||||
RECONNECT,
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data;
|
||||
|
||||
import org.cloudburstmc.math.vector.Vector3i;
|
||||
|
||||
public record CommandCoreAreaData(
|
||||
Vector3i start,
|
||||
Vector3i end
|
||||
) {
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public record PingServerData(
|
||||
//String ip,
|
||||
//int port,
|
||||
String versionName,
|
||||
long protocolVersion,
|
||||
int playersOnline,
|
||||
int maxPlayers,
|
||||
Component description
|
||||
//long latency
|
||||
) {
|
||||
public void latency (long pingTime) {
|
||||
System.out.println(versionName);
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data;
|
||||
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.command.CommandTrustLevels;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.cloudburstmc.math.vector.Vector3d;
|
||||
import org.geysermc.mcprotocollib.auth.GameProfile;
|
||||
import org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerProfileData {
|
||||
public UUID uuid;
|
||||
public String entityUUID;
|
||||
public GameProfile profile;
|
||||
public boolean listed;
|
||||
public int latency;
|
||||
public GameMode gameMode;
|
||||
public Component displayName;
|
||||
public boolean showHat;
|
||||
public int listOrder;
|
||||
public Vector3d position;
|
||||
public String dimension;
|
||||
public int entityId;
|
||||
public CommandTrustLevels trustLevel = CommandTrustLevels.PUBLIC;
|
||||
public boolean alreadyValidated = false;
|
||||
|
||||
public PlayerProfileData (
|
||||
final UUID uuid,
|
||||
final String entityUUID,
|
||||
final GameProfile profile,
|
||||
final boolean listed,
|
||||
final int latency,
|
||||
final GameMode gameMode,
|
||||
final Component displayName,
|
||||
final boolean showHat,
|
||||
final int listOrder,
|
||||
final Vector3d position,
|
||||
final String dimension,
|
||||
final int entityId
|
||||
) {
|
||||
this.uuid = uuid;
|
||||
this.entityUUID = entityUUID;
|
||||
this.profile = profile;
|
||||
this.listed = listed;
|
||||
this.latency = latency;
|
||||
this.gameMode = gameMode;
|
||||
this.displayName = displayName;
|
||||
this.showHat = showHat;
|
||||
this.listOrder = listOrder;
|
||||
this.position = position;
|
||||
this.dimension = dimension;
|
||||
this.entityId = entityId;
|
||||
}
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.blocks;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockRegistries {
|
||||
public String block;
|
||||
public final STATES[] states = new STATES[]{};
|
||||
public int blockId;
|
||||
public int itemId;
|
||||
|
||||
public static final class STATES {
|
||||
public int id;
|
||||
}
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BotBuildInfo {
|
||||
public String about;
|
||||
public final BuildInfo buildstring = new BuildInfo();
|
||||
public String owner;
|
||||
public Contributors[] contributors = new Contributors[]{};
|
||||
|
||||
public static class BuildInfo {
|
||||
public List<JsonObject> botName;
|
||||
public String version;
|
||||
public List<JsonObject> codename;
|
||||
public String build;
|
||||
public String versionReleaseDate;
|
||||
public String initialBotRelease;
|
||||
}
|
||||
|
||||
public static class Contributors {
|
||||
public String name;
|
||||
public String reason;
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.buildstring;
|
||||
|
||||
public class RepoCommitInfo {
|
||||
public String sha;
|
||||
|
||||
public String created;
|
||||
|
||||
public int commits;
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.chat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChatTranslationsData {
|
||||
public static class Narration {
|
||||
public String translation_key;
|
||||
public List<String> parameters = new ArrayList<>();
|
||||
}
|
||||
|
||||
public static class Chat {
|
||||
public String translation_key;
|
||||
public List<String> parameters = new ArrayList<>();
|
||||
public Narration narration = new Narration();
|
||||
}
|
||||
|
||||
public final Chat chat = new Chat();
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.chat;
|
||||
|
||||
public enum ChatType {
|
||||
PLAYER,
|
||||
SYSTEM,
|
||||
DISGUISED
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.chat;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public interface ParseChatData {
|
||||
PlayerMessageData parse (
|
||||
ChatType chatType,
|
||||
Component message
|
||||
);
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.chat;
|
||||
|
||||
public enum ParsedChatType {
|
||||
COMMANDSPY,
|
||||
NORMAL
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.chat;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public record PlayerMessageData(
|
||||
PlayerProfileData sender,
|
||||
Component contents,
|
||||
ChatType chatType,
|
||||
Component senderName
|
||||
) {
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.world;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public record BlockData(
|
||||
String block,
|
||||
int id,
|
||||
List<Integer> stateIds
|
||||
) {
|
||||
public void stateIds (List<Integer> stateIds) {
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.world;
|
||||
|
||||
public record ChunkData(
|
||||
ChunkPosData chunkPos,
|
||||
byte[] data,
|
||||
int maxHeight,
|
||||
int minY
|
||||
) {
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.world;
|
||||
|
||||
public record ChunkPosData(
|
||||
int x,
|
||||
int z
|
||||
) {
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.data.world;
|
||||
|
||||
public class DimensionData {
|
||||
public int min_y;
|
||||
public int height;
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.discord;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.Main;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.NitoriBot;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.Listener;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.listeners.ListenerManager;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
public class MessageLogger extends ListenerAdapter {
|
||||
private JDA client;
|
||||
|
||||
@Override
|
||||
public void onMessageReceived (MessageReceivedEvent event) {
|
||||
if (event
|
||||
.getAuthor()
|
||||
.getId()
|
||||
.equals(client
|
||||
.getSelfUser()
|
||||
.getId()))
|
||||
return;
|
||||
|
||||
for (NitoriBot bot : Main.Bots) {
|
||||
if (event
|
||||
.getChannel()
|
||||
.getId()
|
||||
.equals(bot.options.discordChannelId)) {
|
||||
for (Listener listener : bot.listenerManager.listeners) {
|
||||
listener.discordMessageReceived(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public MessageLogger (JDA client) {
|
||||
this.client = client;
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package land.chipmunk.parker2991.nitoribot.nightofnights.listeners;
|
||||
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.ChatType;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.PlayerProfileData;
|
||||
import land.chipmunk.parker2991.nitoribot.nightofnights.data.chat.PlayerMessageData;
|
||||
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.geysermc.mcprotocollib.network.packet.Packet;
|
||||
import org.geysermc.mcprotocollib.protocol.packet.ingame.clientbound.level.ClientboundTagQueryPacket;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Listener {
|
||||
default void packetSent () {
|
||||
}
|
||||
|
||||
default void extrasMessagingReceived (
|
||||
String channel,
|
||||
UUID uuid,
|
||||
String message
|
||||
) {
|
||||
}
|
||||
|
||||
default void packetReceived (Packet packet) {
|
||||
}
|
||||
|
||||
default void chatMessageReceived (
|
||||
ChatType chatType,
|
||||
Component message
|
||||
) {
|
||||
}
|
||||
|
||||
default void parsedMessage (PlayerMessageData data) {
|
||||
}
|
||||
|
||||
default void botMoved () {
|
||||
}
|
||||
|
||||
default void commandSpyReceived (
|
||||
PlayerProfileData player,
|
||||
String command
|
||||
) {
|
||||
}
|
||||
|
||||
default void discordMessageReceived (
|
||||
MessageReceivedEvent event
|
||||
) {
|
||||
}
|
||||
|
||||
default void systemChatReceived (Component message) {
|
||||
}
|
||||
|
||||
default void tabCompleteReceived (ClientboundTagQueryPacket packet) {
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user