Initial commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
.gradle
|
||||
**/build/
|
||||
!src/**/build/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
# Eclipse Gradle plugin generated files
|
||||
# Eclipse Core
|
||||
.project
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
generated
+3
@@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
generated
+1
@@ -0,0 +1 @@
|
||||
mc-srv2-notifyonstart
|
||||
generated
+6
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<bytecodeTargetLevel target="18" />
|
||||
</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
+17
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
||||
<component name="GradleSettings">
|
||||
<option name="linkedExternalProjectsSettings">
|
||||
<GradleProjectSettings>
|
||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
generated
+30
@@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven2" />
|
||||
<option name="name" value="maven2" />
|
||||
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="MavenRepo" />
|
||||
<option name="name" value="MavenRepo" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="maven" />
|
||||
<option name="name" value="maven" />
|
||||
<option name="url" value="https://oss.sonatype.org/content/repositories/snapshots" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
||||
generated
+12
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="EntryPointsManager">
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_18" default="true" project-jdk-name="corretto-18" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module version="4">
|
||||
<component name="FacetManager">
|
||||
<facet type="minecraft" name="Minecraft">
|
||||
<configuration>
|
||||
<autoDetectTypes>
|
||||
<platformType>SPIGOT</platformType>
|
||||
</autoDetectTypes>
|
||||
</configuration>
|
||||
</facet>
|
||||
</component>
|
||||
</module>
|
||||
generated
+124
@@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</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,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
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
|
||||
|
||||
http://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.
|
||||
@@ -0,0 +1,38 @@
|
||||
# spigot-swbhos
|
||||
|
||||
this project is made to just send messages to Discord webhooks when events trigger
|
||||
|
||||
this was just made to remember whatever goofy things we did in a minecraft server, in discord
|
||||
# making webhooks
|
||||
If you already know how, you can skip this step.
|
||||
|
||||
To make a webhook:
|
||||
1. Go to a Discord server.\
|
||||
You can make a new channel or use an existing one.
|
||||
2. Right-click on the channel.
|
||||
3. Click "Edit Channel".
|
||||
4. Click "Integrations" and click "Webhooks".
|
||||
5. Click "New Webhook".
|
||||
6. Give the webhook a name. As an example, we will use `notify` as the webhook name.
|
||||
7. You may change the channel where it is associated/linked to, change the webhook name, and set a picture for the webhook.
|
||||
8. Copy the webhook link.
|
||||
|
||||
|
||||
# using this thing
|
||||
You must get Spigot.\
|
||||
On first run, it will make a directory where Spigot is.\
|
||||
These files will be `NoS/notifyWebhook.json` and `NoS/pubMessageWebhook.json`.
|
||||
|
||||
Of course, put the webhook URL of where the events should be logged in `notifyWebhook.json`
|
||||
|
||||
`pubMessageWebhook.json` is for a command named `/send-message`. This will simply send text to the webhook containing provided text.\
|
||||
Put the webhook link in `url`.
|
||||
|
||||
An example of what the file content should be:
|
||||
```json
|
||||
{
|
||||
"url": "<get the webhook link from earlier and paste"
|
||||
}
|
||||
```
|
||||
|
||||
If you change this value, you have to restart the server to apply changes.
|
||||
@@ -0,0 +1,28 @@
|
||||
plugins {
|
||||
id 'java'
|
||||
}
|
||||
|
||||
group 'cf.sobrooms'
|
||||
version '1.1'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
|
||||
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
|
||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
|
||||
}
|
||||
|
||||
test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
jar {
|
||||
manifest {
|
||||
attributes 'Main-Class': 'cf.sobrooms.Main'
|
||||
}
|
||||
}
|
||||
vendored
BIN
Binary file not shown.
+5
@@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
@@ -0,0 +1,240 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright © 2015-2021 the original authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
||||
# noncompliant, but you have some other compliant shell such as ksh or
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
# * functions;
|
||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||
# * compound commands having a testable exit status, especially «case»;
|
||||
# * various built-in commands including «command», «set», and «ulimit».
|
||||
#
|
||||
# Important for patching:
|
||||
#
|
||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||
#
|
||||
# The "traditional" practice of packing multiple parameters into a
|
||||
# space-separated string is a well documented source of bugs and security
|
||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||
# options in "$@", and eventually passing that to Java.
|
||||
#
|
||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||
# see the in-line comments for details.
|
||||
#
|
||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/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
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# 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"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
} >&2
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
} >&2
|
||||
|
||||
# OS specific support (must be 'true' or 'false').
|
||||
cygwin=false
|
||||
msys=false
|
||||
darwin=false
|
||||
nonstop=false
|
||||
case "$( uname )" in #(
|
||||
CYGWIN* ) cygwin=true ;; #(
|
||||
Darwin* ) darwin=true ;; #(
|
||||
MSYS* | MINGW* ) msys=true ;; #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# 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
|
||||
which java >/dev/null 2>&1 || 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
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command, stacking in reverse order:
|
||||
# * args from the command line
|
||||
# * the main class name
|
||||
# * -classpath
|
||||
# * -D...appname settings
|
||||
# * --module-path (only if needed)
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if "$cygwin" || "$msys" ; then
|
||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||
|
||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||
|
||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||
for arg do
|
||||
if
|
||||
case $arg in #(
|
||||
-*) false ;; # don't mess with options #(
|
||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||
[ -e "$t" ] ;; #(
|
||||
*) false ;;
|
||||
esac
|
||||
then
|
||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||
fi
|
||||
# Roll the args list around exactly as many times as the number of
|
||||
# args, so each arg winds up back in the position where it started, but
|
||||
# possibly modified.
|
||||
#
|
||||
# NB: a `for` loop captures its iteration list before it begins, so
|
||||
# changing the positional parameters here affects neither the number of
|
||||
# iterations, nor the values presented in `arg`.
|
||||
shift # remove old arg
|
||||
set -- "$@" "$arg" # push replacement arg
|
||||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# 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" "$@"
|
||||
@@ -0,0 +1 @@
|
||||
call ./gradlew jar
|
||||
vendored
+91
@@ -0,0 +1,91 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -0,0 +1,2 @@
|
||||
rootProject.name = 'mc-srv2-notifyonstart'
|
||||
|
||||
@@ -0,0 +1,388 @@
|
||||
package cf.sobrooms;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Array;
|
||||
import java.net.URL;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Class used to execute Discord Webhooks with low effort
|
||||
*/
|
||||
public class DiscordWebhook {
|
||||
|
||||
private final String url;
|
||||
private String content;
|
||||
private String username;
|
||||
private String avatarUrl;
|
||||
private boolean tts;
|
||||
private final List<EmbedObject> embeds = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructs a new DiscordWebhook instance
|
||||
*
|
||||
* @param url The webhook_notify URL obtained in Discord
|
||||
*/
|
||||
public DiscordWebhook(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setAvatarUrl(String avatarUrl) {
|
||||
this.avatarUrl = avatarUrl;
|
||||
}
|
||||
|
||||
public void setTts(boolean tts) {
|
||||
this.tts = tts;
|
||||
}
|
||||
|
||||
public void addEmbed(EmbedObject embed) {
|
||||
this.embeds.add(embed);
|
||||
}
|
||||
|
||||
public void execute() throws IOException {
|
||||
if (this.content == null && this.embeds.isEmpty()) {
|
||||
throw new IllegalArgumentException("Set content or add at least one EmbedObject");
|
||||
}
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
json.put("content", this.content);
|
||||
json.put("username", this.username);
|
||||
json.put("avatar_url", this.avatarUrl);
|
||||
json.put("tts", this.tts);
|
||||
|
||||
if (!this.embeds.isEmpty()) {
|
||||
List<JSONObject> embedObjects = new ArrayList<>();
|
||||
|
||||
for (EmbedObject embed : this.embeds) {
|
||||
JSONObject jsonEmbed = new JSONObject();
|
||||
|
||||
jsonEmbed.put("title", embed.getTitle());
|
||||
jsonEmbed.put("description", embed.getDescription());
|
||||
jsonEmbed.put("url", embed.getUrl());
|
||||
|
||||
if (embed.getColor() != null) {
|
||||
Color color = embed.getColor();
|
||||
int rgb = color.getRed();
|
||||
rgb = (rgb << 8) + color.getGreen();
|
||||
rgb = (rgb << 8) + color.getBlue();
|
||||
|
||||
jsonEmbed.put("color", rgb);
|
||||
}
|
||||
|
||||
EmbedObject.Footer footer = embed.getFooter();
|
||||
EmbedObject.Image image = embed.getImage();
|
||||
EmbedObject.Thumbnail thumbnail = embed.getThumbnail();
|
||||
EmbedObject.Author author = embed.getAuthor();
|
||||
List<EmbedObject.Field> fields = embed.getFields();
|
||||
|
||||
if (footer != null) {
|
||||
JSONObject jsonFooter = new JSONObject();
|
||||
|
||||
jsonFooter.put("text", footer.getText());
|
||||
jsonFooter.put("icon_url", footer.getIconUrl());
|
||||
jsonEmbed.put("footer", jsonFooter);
|
||||
}
|
||||
|
||||
if (image != null) {
|
||||
JSONObject jsonImage = new JSONObject();
|
||||
|
||||
jsonImage.put("url", image.getUrl());
|
||||
jsonEmbed.put("image", jsonImage);
|
||||
}
|
||||
|
||||
if (thumbnail != null) {
|
||||
JSONObject jsonThumbnail = new JSONObject();
|
||||
|
||||
jsonThumbnail.put("url", thumbnail.getUrl());
|
||||
jsonEmbed.put("thumbnail", jsonThumbnail);
|
||||
}
|
||||
|
||||
if (author != null) {
|
||||
JSONObject jsonAuthor = new JSONObject();
|
||||
|
||||
jsonAuthor.put("name", author.getName());
|
||||
jsonAuthor.put("url", author.getUrl());
|
||||
jsonAuthor.put("icon_url", author.getIconUrl());
|
||||
jsonEmbed.put("author", jsonAuthor);
|
||||
}
|
||||
|
||||
List<JSONObject> jsonFields = new ArrayList<>();
|
||||
for (EmbedObject.Field field : fields) {
|
||||
JSONObject jsonField = new JSONObject();
|
||||
|
||||
jsonField.put("name", field.getName());
|
||||
jsonField.put("value", field.getValue());
|
||||
jsonField.put("inline", field.isInline());
|
||||
|
||||
jsonFields.add(jsonField);
|
||||
}
|
||||
|
||||
jsonEmbed.put("fields", jsonFields.toArray());
|
||||
embedObjects.add(jsonEmbed);
|
||||
}
|
||||
|
||||
json.put("embeds", embedObjects.toArray());
|
||||
}
|
||||
|
||||
URL url = new URL(this.url);
|
||||
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
||||
connection.addRequestProperty("Content-Type", "application/json");
|
||||
connection.addRequestProperty("User-Agent", "Java-DiscordWebhook-BY-Gelox_");
|
||||
connection.setDoOutput(true);
|
||||
connection.setRequestMethod("POST");
|
||||
|
||||
OutputStream stream = connection.getOutputStream();
|
||||
stream.write(json.toString().getBytes());
|
||||
stream.flush();
|
||||
stream.close();
|
||||
|
||||
connection.getInputStream().close(); //I'm not sure why but it doesn't work without getting the InputStream
|
||||
connection.disconnect();
|
||||
}
|
||||
|
||||
public static class EmbedObject {
|
||||
private String title;
|
||||
private String description;
|
||||
private String url;
|
||||
private Color color;
|
||||
|
||||
private Footer footer;
|
||||
private Thumbnail thumbnail;
|
||||
private Image image;
|
||||
private Author author;
|
||||
private final List<Field> fields = new ArrayList<>();
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public EmbedObject setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public EmbedObject setDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public EmbedObject setUrl(String url) {
|
||||
this.url = url;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
public EmbedObject setColor(Color color) {
|
||||
this.color = color;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Footer getFooter() {
|
||||
return footer;
|
||||
}
|
||||
|
||||
public Thumbnail getThumbnail() {
|
||||
return thumbnail;
|
||||
}
|
||||
|
||||
public EmbedObject setThumbnail(String url) {
|
||||
this.thumbnail = new Thumbnail(url);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Image getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public EmbedObject setImage(String url) {
|
||||
this.image = new Image(url);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public List<Field> getFields() {
|
||||
return fields;
|
||||
}
|
||||
|
||||
public EmbedObject setFooter(String text, String icon) {
|
||||
this.footer = new Footer(text, icon);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmbedObject setAuthor(String name, String url, String icon) {
|
||||
this.author = new Author(name, url, icon);
|
||||
return this;
|
||||
}
|
||||
|
||||
public EmbedObject addField(String name, String value, boolean inline) {
|
||||
this.fields.add(new Field(name, value, inline));
|
||||
return this;
|
||||
}
|
||||
|
||||
private class Footer {
|
||||
private final String text;
|
||||
private final String iconUrl;
|
||||
|
||||
private Footer(String text, String iconUrl) {
|
||||
this.text = text;
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
private String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
private String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
}
|
||||
|
||||
private class Thumbnail {
|
||||
private final String url;
|
||||
|
||||
private Thumbnail(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
private String getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
private class Image {
|
||||
private final String url;
|
||||
|
||||
private Image(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
private String getUrl() {
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
private class Author {
|
||||
private final String name;
|
||||
private final String url;
|
||||
private final String iconUrl;
|
||||
|
||||
private Author(String name, String url, String iconUrl) {
|
||||
this.name = name;
|
||||
this.url = url;
|
||||
this.iconUrl = iconUrl;
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
private String getIconUrl() {
|
||||
return iconUrl;
|
||||
}
|
||||
}
|
||||
|
||||
private class Field {
|
||||
private final String name;
|
||||
private final String value;
|
||||
private final boolean inline;
|
||||
|
||||
private Field(String name, String value, boolean inline) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
this.inline = inline;
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
private String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
private boolean isInline() {
|
||||
return inline;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class JSONObject {
|
||||
|
||||
private final HashMap<String, Object> map = new HashMap<>();
|
||||
|
||||
void put(String key, Object value) {
|
||||
if (value != null) {
|
||||
map.put(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Set<Map.Entry<String, Object>> entrySet = map.entrySet();
|
||||
builder.append("{");
|
||||
|
||||
int i = 0;
|
||||
for (Map.Entry<String, Object> entry : entrySet) {
|
||||
Object val = entry.getValue();
|
||||
builder.append(quote(entry.getKey())).append(":");
|
||||
|
||||
if (val instanceof String) {
|
||||
builder.append(quote(String.valueOf(val)));
|
||||
} else if (val instanceof Integer) {
|
||||
builder.append(Integer.valueOf(String.valueOf(val)));
|
||||
} else if (val instanceof Boolean) {
|
||||
builder.append(val);
|
||||
} else if (val instanceof JSONObject) {
|
||||
builder.append(val);
|
||||
} else if (val.getClass().isArray()) {
|
||||
builder.append("[");
|
||||
int len = Array.getLength(val);
|
||||
for (int j = 0; j < len; j++) {
|
||||
builder.append(Array.get(val, j).toString()).append(j != len - 1 ? "," : "");
|
||||
}
|
||||
builder.append("]");
|
||||
}
|
||||
|
||||
builder.append(++i == entrySet.size() ? "}" : ",");
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private String quote(String string) {
|
||||
return "\"" + string + "\"";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package cf.sobrooms;
|
||||
|
||||
import cf.sobrooms.commands.InfoCommand;
|
||||
import cf.sobrooms.commands.PingCommand;
|
||||
import cf.sobrooms.commands.SendMessageCommand;
|
||||
import cf.sobrooms.commands.SetLoggingModeCommand;
|
||||
import cf.sobrooms.events.enchantment.EnchantItem;
|
||||
import cf.sobrooms.events.enchantment.PrepareItemEnchant;
|
||||
import cf.sobrooms.events.player.*;
|
||||
import cf.sobrooms.events.server.ServerStart;
|
||||
import cf.sobrooms.events.weather.LightningStrike;
|
||||
import cf.sobrooms.events.weather.ThunderChange;
|
||||
import cf.sobrooms.events.weather.WeatherChange;
|
||||
import cf.sobrooms.events.world.WorldInit;
|
||||
import cf.sobrooms.events.world.WorldLoad;
|
||||
import cf.sobrooms.events.world.WorldSave;
|
||||
import cf.sobrooms.events.world.WorldUnload;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
public static File isLoggingConfig;
|
||||
public static File notifyWebhookConfig;
|
||||
public static File pubMessageWebhookConfig;
|
||||
public static String serverAddress = "mc-srv2-singapore.rrryfoo.cf";
|
||||
private static boolean webhooksAreValidUrls;
|
||||
|
||||
public static void main(String... args) {
|
||||
System.out.printf("Initializing using server address: %s...%n", serverAddress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
String loggingDir = "./NoS";
|
||||
File directory = new File(loggingDir);
|
||||
if (!directory.exists()) {
|
||||
if (directory.mkdir()) {
|
||||
System.out.println("Config dir created: " + loggingDir);
|
||||
} else {
|
||||
System.out.println("Failed to create config directory: " + loggingDir);
|
||||
}
|
||||
}
|
||||
isLoggingConfig = new File("./NoS/willLogCommands.bool");
|
||||
notifyWebhookConfig = new File("./NoS/notifyWebhook.json");
|
||||
pubMessageWebhookConfig = new File("./NoS/pubMessageWebhook.json");
|
||||
try {
|
||||
if (isLoggingConfig.createNewFile() || notifyWebhookConfig.createNewFile() || pubMessageWebhookConfig.createNewFile()) {
|
||||
System.out.println("Config created: " + isLoggingConfig.getName());
|
||||
FileWriter notifyWebhookConfigWriter = new FileWriter(notifyWebhookConfig);
|
||||
FileWriter pubMessageWebhookConfigWriter = new FileWriter(pubMessageWebhookConfig);
|
||||
notifyWebhookConfigWriter.write("{\"url\": \"default-ns\"}");
|
||||
pubMessageWebhookConfigWriter.write("{\"url\": \"default-ns\"}");
|
||||
pubMessageWebhookConfigWriter.close();
|
||||
notifyWebhookConfigWriter.close();
|
||||
} else {
|
||||
System.out.println("Created config even while it already exists, skipping step...");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
// post
|
||||
Bukkit.getConsoleSender().sendMessage("Note: This Spigot/Bukkit plugin is highly verbose, so it will log a lot of events...");
|
||||
// register commands
|
||||
try {
|
||||
Objects.requireNonNull(this.getCommand("info")).setExecutor(new InfoCommand());
|
||||
Objects.requireNonNull(this.getCommand("send-message")).setExecutor(new SendMessageCommand());
|
||||
Objects.requireNonNull(this.getCommand("set-logging")).setExecutor(new SetLoggingModeCommand());
|
||||
Objects.requireNonNull(this.getCommand("ping-server")).setExecutor(new PingCommand());
|
||||
} catch (NullPointerException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
// register events
|
||||
ServerStart serverStart = new ServerStart();
|
||||
getServer().getPluginManager().registerEvents(serverStart, this);
|
||||
if (getLoggingConfig().equals("true") && webhooksAreValidUrls)
|
||||
registerEvents();
|
||||
if (webhooksAreValidUrls) {
|
||||
PlayerJoin playerJoin = new PlayerJoin();
|
||||
PlayerQuit playerQuit = new PlayerQuit();
|
||||
getServer().getPluginManager().registerEvents(playerJoin, this);
|
||||
getServer().getPluginManager().registerEvents(playerQuit, this);
|
||||
}
|
||||
|
||||
}
|
||||
public static String getPublicMessageWebhook() {
|
||||
try {
|
||||
BufferedReader brfmsg = new BufferedReader(new FileReader(pubMessageWebhookConfig));
|
||||
JsonParser jsonReader = new JsonParser();
|
||||
JsonElement MsgParse = jsonReader.parse(brfmsg.readLine());
|
||||
String lineMsg = MsgParse.getAsJsonObject().get("url").getAsString();
|
||||
// validate url being url
|
||||
// but this won't validate the url being an actual webhook
|
||||
// i can try but lazy :sob:
|
||||
if (lineMsg.equals("default-ns")) {
|
||||
System.out.printf("Please set the webhook URL in %s and restart the server", pubMessageWebhookConfig.getAbsolutePath());
|
||||
webhooksAreValidUrls = false;
|
||||
return lineMsg;
|
||||
} else if (lineMsg.startsWith("https://") || lineMsg.startsWith("http://")) {
|
||||
return lineMsg;
|
||||
} else {
|
||||
System.out.printf("Please set the webhook URL in %s and restart the server", pubMessageWebhookConfig.getAbsolutePath());
|
||||
webhooksAreValidUrls = false;
|
||||
return lineMsg;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public static String getNotifyWebhook() {
|
||||
try {
|
||||
BufferedReader brfntfy = new BufferedReader(new FileReader(notifyWebhookConfig));
|
||||
JsonParser jsonReader = new JsonParser();
|
||||
JsonElement NtfyParse = jsonReader.parse(brfntfy.readLine());
|
||||
String lineNtfy = NtfyParse.getAsJsonObject().get("url").getAsString();
|
||||
// validate url being url
|
||||
// but this won't validate the url being an actual webhook
|
||||
// i can try but lazy :sob:
|
||||
if (lineNtfy.equals("default-ns")) {
|
||||
System.out.printf("Please set the webhook URL in %s and restart the server", notifyWebhookConfig.getAbsolutePath());
|
||||
webhooksAreValidUrls = false;
|
||||
return lineNtfy;
|
||||
} else if (lineNtfy.startsWith("https://") || lineNtfy.startsWith("http://")) {
|
||||
return lineNtfy;
|
||||
} else {
|
||||
System.out.printf("Please set the webhook URL in %s and restart the server", notifyWebhookConfig.getAbsolutePath());
|
||||
webhooksAreValidUrls = false;
|
||||
return lineNtfy;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public static String getLoggingConfig() {
|
||||
try {
|
||||
File file = new File("./NoS/willLogCommands.bool");
|
||||
BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
if (line.equals("true") || line.equals("false"))
|
||||
return line;
|
||||
else
|
||||
return "Content is not a boolean";
|
||||
}
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred while reading the configuration file.");
|
||||
e.printStackTrace();
|
||||
return "err";
|
||||
}
|
||||
return "err";
|
||||
}
|
||||
public void registerEvents() {
|
||||
PlayerChat playerChat = new PlayerChat();
|
||||
PlayerCommandPreprocess playerCommandPreprocess = new PlayerCommandPreprocess();
|
||||
EnchantItem enchantItemEvent = new EnchantItem();
|
||||
PrepareItemEnchant prepareItemEnchant = new PrepareItemEnchant();
|
||||
PlayerBedEnter playerBedEnter = new PlayerBedEnter();
|
||||
PlayerBedLeave playerBedLeave = new PlayerBedLeave();
|
||||
LightningStrike lightningStrike = new LightningStrike();
|
||||
ThunderChange thunderChange = new ThunderChange();
|
||||
WeatherChange weatherChange = new WeatherChange();
|
||||
WorldInit worldInit = new WorldInit();
|
||||
WorldLoad worldLoad = new WorldLoad();
|
||||
WorldSave worldSave = new WorldSave();
|
||||
WorldUnload worldUnload = new WorldUnload();
|
||||
getServer().getPluginManager().registerEvents(playerChat, this);
|
||||
getServer().getPluginManager().registerEvents(playerCommandPreprocess, this);
|
||||
getServer().getPluginManager().registerEvents(enchantItemEvent, this);
|
||||
getServer().getPluginManager().registerEvents(prepareItemEnchant, this);
|
||||
getServer().getPluginManager().registerEvents(playerBedEnter, this);
|
||||
getServer().getPluginManager().registerEvents(playerBedLeave, this);
|
||||
getServer().getPluginManager().registerEvents(lightningStrike, this);
|
||||
getServer().getPluginManager().registerEvents(thunderChange, this);
|
||||
getServer().getPluginManager().registerEvents(weatherChange, this);
|
||||
getServer().getPluginManager().registerEvents(worldInit, this);
|
||||
getServer().getPluginManager().registerEvents(worldLoad, this);
|
||||
getServer().getPluginManager().registerEvents(worldSave, this);
|
||||
getServer().getPluginManager().registerEvents(worldUnload, this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package cf.sobrooms;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Socket;
|
||||
|
||||
public class ServerUtils {
|
||||
public static int port = 25565;
|
||||
public static String address = "http://mc-srv2-singapore.rrryfoo.cf";
|
||||
public static String address_fallback = Utils.getServerHostPublicIP();
|
||||
public static String webhook_notify = Main.getNotifyWebhook();
|
||||
public static String webhook_messages = Main.getPublicMessageWebhook();
|
||||
|
||||
public static boolean serverIsUp(String serverAddress, Integer serverPort) {
|
||||
/*Socket socket;
|
||||
try {
|
||||
socket = new Socket(address, port);
|
||||
socket.close();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
System.out.println("Server is inactive on default address. Pinging on fallback address (" + address_fallback + ")...");
|
||||
Socket socket2 = new Socket(address_fallback, port);
|
||||
socket2.close();
|
||||
return true;
|
||||
} catch (Exception exception) {
|
||||
System.out.println("Server is inactive on fallback address. No longer pinging...");
|
||||
return false;
|
||||
}
|
||||
}*/
|
||||
try {
|
||||
Server server = Bukkit.getServer();
|
||||
Socket s = new Socket();
|
||||
s.connect(new InetSocketAddress(serverAddress.toString(), Integer.parseInt(serverPort.toString())), 15);
|
||||
s.close();
|
||||
System.out.println("Server is online. Sending message to webhook_notify... (Pinged " + Utils.getServerHostPublicIP() + ":" + server.getPort() + ")");
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
System.out.println("Server is inactive. Pinging fallback address...");
|
||||
try {
|
||||
Server server = Bukkit.getServer();
|
||||
Socket s = new Socket();
|
||||
s.connect(new InetSocketAddress(address_fallback, Integer.parseInt(serverPort.toString())), 15);
|
||||
s.close();
|
||||
} catch (Exception err) {
|
||||
System.out.println("Fallback address is inactive. No longer pinging...");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package cf.sobrooms;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.InetAddress;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
public class Utils {
|
||||
public static String getActivePlayers() {
|
||||
var players = Bukkit.getServer().getOnlinePlayers();
|
||||
String activePlayers;
|
||||
if (players.size() < 1) {
|
||||
activePlayers = "None.";
|
||||
} else {
|
||||
activePlayers = "";
|
||||
int playersCounted = 0;
|
||||
for (Player player : players) {
|
||||
playersCounted++;
|
||||
activePlayers = "%s\n%s) %s".formatted(activePlayers, playersCounted, player.getName());
|
||||
}
|
||||
}
|
||||
return activePlayers;
|
||||
}
|
||||
|
||||
public static String getServerHostPublicIP() {
|
||||
String urlString = "http://myexternalip.com/raw";
|
||||
try {
|
||||
URL url = new URL(urlString);
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()))) {
|
||||
return br.readLine();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String getServerPing(String address) {
|
||||
try {
|
||||
int timeout = 3000;
|
||||
long startTime = System.currentTimeMillis();
|
||||
InetAddress serverAddress = InetAddress.getByName(address);
|
||||
boolean reachable = serverAddress.isReachable(timeout);
|
||||
long endTime = System.currentTimeMillis();
|
||||
long latency = endTime - startTime;
|
||||
if (reachable) {
|
||||
return String.valueOf(latency);
|
||||
} else {
|
||||
return "404svh";
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cf.sobrooms.commands;
|
||||
|
||||
|
||||
import cf.sobrooms.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class InfoCommand implements CommandExecutor {
|
||||
|
||||
// This method is called, when somebody uses our command
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
sender.sendMessage((ChatColor.YELLOW + """
|
||||
Server Info
|
||||
|
||||
""" + ChatColor.WHITE +
|
||||
"""
|
||||
Server name/type: %s
|
||||
Server IP: %s
|
||||
Server Port: %s
|
||||
Server Version: %s
|
||||
Active Players:""" + ChatColor.GOLD +
|
||||
" %s\n" + ChatColor.WHITE + "Plugin made by sobrooms (rrryfoo, AnonCYTO)\n" + ChatColor.MAGIC + ":sob: all day" + ChatColor.WHITE)
|
||||
.formatted(Bukkit.getServer().getName(), Utils.getServerHostPublicIP(), Bukkit.getServer().getPort(), Bukkit.getServer().getVersion(), Utils.getActivePlayers()));
|
||||
|
||||
// If the player (or console) uses our command correct, we can return true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cf.sobrooms.commands;
|
||||
|
||||
import cf.sobrooms.Utils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PingCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
try {
|
||||
String ping_host = Utils.getServerPing(Utils.getServerHostPublicIP());
|
||||
Player player;
|
||||
if (sender instanceof Player) {
|
||||
// Sender is a player
|
||||
player = (Player) sender;
|
||||
} else {
|
||||
// Sender is not a player
|
||||
sender.sendMessage("You must be a player to use this command.");
|
||||
return true;
|
||||
}
|
||||
if (ping_host.equals("404svh")) {
|
||||
sender.sendMessage("Failed to fetch ping.");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.ITALIC + "Server ping: %sms".formatted(ping_host));
|
||||
sender.sendMessage(ChatColor.ITALIC + "Player ping: %sms".formatted(player.getPing()));
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package cf.sobrooms.commands;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class SendMessageCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("Please input a message to send...");
|
||||
return false;
|
||||
} else {
|
||||
sender.sendMessage("Sending public message to discord server...");
|
||||
DiscordWebhook discordWebhook = new DiscordWebhook(ServerUtils.webhook_messages);
|
||||
discordWebhook.setUsername("Public Messages");
|
||||
String message = String.join(" ", args);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject()
|
||||
.setTitle("New public message")
|
||||
.setDescription(message)
|
||||
.setAuthor(sender.getName(), "", "")
|
||||
.setFooter(new Date().toString(), "")
|
||||
.setColor(Color.darkGray);
|
||||
discordWebhook.addEmbed(embedObject);
|
||||
try {
|
||||
discordWebhook.execute();
|
||||
sender.sendMessage("Sent public message.");
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
sender.sendMessage("An error occurred while sending your message...");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cf.sobrooms.commands;
|
||||
|
||||
import cf.sobrooms.Main;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SetLoggingModeCommand implements CommandExecutor {
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args[0].isBlank()) {
|
||||
sender.sendMessage("Please provide a boolean and make sure you only provided one argument. (true/false)");
|
||||
return false;
|
||||
} else {
|
||||
if (args[0].equals("true") || args[0].equals("false")) {
|
||||
try {
|
||||
FileWriter writer = new FileWriter(Main.isLoggingConfig);
|
||||
writer.write(args[0]);
|
||||
writer.close();
|
||||
System.out.println("Wrote to config, closing writer...");
|
||||
sender.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Changes will only apply once the server has restarted.");
|
||||
sender.sendMessage(ChatColor.RED + "" + ChatColor.ITALIC + "Please restart the server manually.");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cf.sobrooms.events.enchantment;
|
||||
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.enchantment.EnchantItemEvent;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class EnchantItem implements Listener {
|
||||
@EventHandler
|
||||
public void onEnchantItem(EnchantItemEvent event) {
|
||||
Player player = event.getEnchanter();
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered EnchantItem event");
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Enchant item").setDescription("A player has enchanted an item...")
|
||||
.addField("Datetime", new Date().toString(), false)
|
||||
.addField("Player name", player.getName(), true)
|
||||
.addField("Enchantment", event.getEnchantsToAdd().toString(), true)
|
||||
.addField("Item name", event.getItem().toString(), true)
|
||||
.addField("Amount", String.valueOf(event.getItem().getAmount()), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package cf.sobrooms.events.enchantment;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.enchantment.PrepareItemEnchantEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class PrepareItemEnchant implements Listener {
|
||||
@EventHandler
|
||||
public void onPrepareItemEnchant(PrepareItemEnchantEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered PrepareItemEnchant event.");
|
||||
Player player = event.getEnchanter();
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Enchantment prepare").setDescription("A player is about to enchant an item...")
|
||||
.addField("Date of preparation", new Date().toString(), false)
|
||||
.addField("Player name", player.getName(), true)
|
||||
.addField("Item to be enchanted", event.getItem().toString(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cf.sobrooms.events.player;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class PlayerBedEnter implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered PlayerBedEnter event.");
|
||||
Player player = event.getPlayer();
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Player slep").setDescription("Player is sleping")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("Player name", player.getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cf.sobrooms.events.player;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerBedLeaveEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class PlayerBedLeave implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerBedLeave(PlayerBedLeaveEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered PlayerBedLeave event.");
|
||||
Player player = event.getPlayer();
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Player no longe slep...").setDescription("Player is no slep")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("Player name", player.getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package cf.sobrooms.events.player;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class PlayerChat implements Listener {
|
||||
public PlayerChat() {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered chat event.");
|
||||
Player player = event.getPlayer();
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("A message was sent").setDescription(String.format("A message sent by %s was sent.", player.getName()))
|
||||
.addField("Date of message", new Date().toString(), false)
|
||||
.addField("Message content", event.getMessage(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package cf.sobrooms.events.player;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class PlayerCommandPreprocess implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("PlayerCommandPreprocess event triggered");
|
||||
Player player = event.getPlayer();
|
||||
String[] command = event.getMessage().split(" "); // get the command name
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Command used").setDescription("A player has used a command.")
|
||||
.addField("Date of usage", new Date().toString(), false)
|
||||
.addField("Player name", player.getName(), false)
|
||||
.addField("Command", command[0], true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cf.sobrooms.events.player;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class PlayerJoin implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered PlayerJoinEvent.");
|
||||
Player player = event.getPlayer();
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("Player join").setDescription("A player has joined the game.")
|
||||
.addField("Date of join", new Date().toString(), false)
|
||||
.addField("Player name", player.getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cf.sobrooms.events.player;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
public class PlayerQuit implements Listener {
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("PlayerQuit event triggered");
|
||||
Player player = event.getPlayer();
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("A player has left the server").setDescription(String.format("A player left the server..", player.getName()))
|
||||
.addField("Date of quit", new Date().toString(), false)
|
||||
.addField("Player name", event.getPlayer().getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package cf.sobrooms.events.server;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.Main;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import cf.sobrooms.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.ServerLoadEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook.EmbedObject;
|
||||
|
||||
public class ServerStart implements Listener {
|
||||
public static int timesCalled = 0;
|
||||
@EventHandler
|
||||
public void onServerStart(ServerLoadEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered ServerLoad event.");
|
||||
if (timesCalled < 1) {
|
||||
Bukkit.getConsoleSender().sendMessage("Checking if server is up on " + ServerUtils.address + " with port " + ServerUtils.port + "...");
|
||||
if (ServerUtils.serverIsUp(Main.serverAddress, 25565)) {
|
||||
System.out.println(ServerUtils.webhook_messages);
|
||||
System.out.println(ServerUtils.webhook_notify);
|
||||
DiscordWebhook notify = new DiscordWebhook(Main.getNotifyWebhook());
|
||||
EmbedObject embedObject = new EmbedObject().setTitle("Server started up successfully").setDescription(String.format("The server at %s:%d has started successfully.", Utils.getServerHostPublicIP(), Bukkit.getServer().getPort()))
|
||||
.addField("Date of start", new Date().toString(), false)
|
||||
.setColor(Color.GREEN);
|
||||
if (Main.getLoggingConfig().equals("false"))
|
||||
embedObject.addField("Extra notes", "The server will not try to log any events.", false);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
timesCalled++;
|
||||
} else {
|
||||
Bukkit.getConsoleSender().sendMessage("OnServerStart was called, but the server is currently offline... This may trigger more than once.");
|
||||
}
|
||||
} else {
|
||||
Bukkit.getConsoleSender().sendMessage("(debug) server start event was called more than 1 time");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package cf.sobrooms.events.weather;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.weather.LightningStrikeEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class LightningStrike implements Listener {
|
||||
@EventHandler
|
||||
public void onLightningStrike(LightningStrikeEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered LightningStrike event.");
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("LightningStrike").setDescription("lightning striked")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("World in which event was triggered in", event.getWorld().getName(), true)
|
||||
.addField("Cause of strike", event.getCause().name(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package cf.sobrooms.events.weather;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.weather.ThunderChangeEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class ThunderChange implements Listener {
|
||||
@EventHandler
|
||||
public void onThunderChange(ThunderChangeEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered ThunderChange event.");
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("ThunderChange").setDescription("Tf is this")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("Occurred in world", event.getWorld().getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cf.sobrooms.events.weather;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class WeatherChange implements Listener {
|
||||
@EventHandler
|
||||
public void onWeatherChange(WeatherChangeEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered WeatherChange event.");
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("WeatherChange").setDescription("Weather was changed")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("Occurred in world", event.getWorld().getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cf.sobrooms.events.world;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldInitEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class WorldInit implements Listener {
|
||||
@EventHandler
|
||||
public void onWorldInit(WorldInitEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered WorldInit event.");
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("WorldInit").setDescription("World initialized")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("World name", event.getWorld().getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cf.sobrooms.events.world;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class WorldLoad implements Listener {
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered WorldLoad event.");
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("WorldLoad").setDescription("World in server was loaded")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("World name", event.getWorld().getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cf.sobrooms.events.world;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldSaveEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class WorldSave implements Listener {
|
||||
@EventHandler
|
||||
public void onWorldSave(WorldSaveEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered WorldSave event.");
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("WorldSave").setDescription("World in the server was saved")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("World name", event.getWorld().getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package cf.sobrooms.events.world;
|
||||
|
||||
import cf.sobrooms.DiscordWebhook;
|
||||
import cf.sobrooms.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
|
||||
public class WorldUnload implements Listener {
|
||||
@EventHandler
|
||||
public void onWorldUnload(WorldUnloadEvent event) {
|
||||
Bukkit.getConsoleSender().sendMessage("Triggered WorldUnload event.");
|
||||
DiscordWebhook notify = new DiscordWebhook(ServerUtils.webhook_notify);
|
||||
DiscordWebhook.EmbedObject embedObject = new DiscordWebhook.EmbedObject().setTitle("WorldUnload").setDescription("A world was unloaded...")
|
||||
.addField("Time", new Date().toString(), false)
|
||||
.addField("World name", event.getWorld().getName(), true)
|
||||
.setColor(Color.BLUE);
|
||||
notify.addEmbed(embedObject);
|
||||
try {
|
||||
notify.execute();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
main: cf.sobrooms.Main
|
||||
version: 1.0.0
|
||||
name: notifyOnStart
|
||||
description: Sends webhook_notify to sobrooms when the server starts successfully
|
||||
api-version: 1.19
|
||||
authors: [rrryfoo, sobrooms]
|
||||
commands:
|
||||
info:
|
||||
description: Shows info about this server.
|
||||
usage: /info
|
||||
send-message:
|
||||
description: Sends a message to the server's main discord server.
|
||||
usage: /send-message <message content>
|
||||
set-logging:
|
||||
description: Toggles event logging in the server, may greatly increase performance and reduce lag.
|
||||
usage: /set-logging <true|false>
|
||||
permission: op
|
||||
ping-server:
|
||||
description: Pings the server...
|
||||
usage: /ping-server
|
||||
Reference in New Issue
Block a user