initial commit

This commit is contained in:
2022-07-05 10:05:22 +02:00
commit 3f986b424d
56 changed files with 1155 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

Binary file not shown.

View File

@@ -0,0 +1,2 @@
#Mon Jul 04 09:35:38 CEST 2022
gradle.version=7.4

Binary file not shown.

View File

3
.idea/.gitignore generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

6
.idea/compiler.xml generated Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="17" />
</component>
</project>

17
.idea/gradle.xml generated Normal file
View File

@@ -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>

25
.idea/jarRepositories.xml generated Normal file
View File

@@ -0,0 +1,25 @@
<?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="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://jitpack.io" />
</remote-repository>
</component>
</project>

7
.idea/misc.xml generated Normal file
View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

12
.idea/modules/MineNetPvE.main.iml generated Normal file
View File

@@ -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>ADVENTURE</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>

12
.idea/modules/MineNetPvE.test.iml generated Normal file
View File

@@ -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>ADVENTURE</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>

124
.idea/uiDesigner.xml generated Normal file
View File

@@ -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>

28
build.gradle Normal file
View File

@@ -0,0 +1,28 @@
plugins {
id 'java'
id "com.github.johnrengelman.shadow" version "7.1.0"
}
group 'eu.mhsl.minenet'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
implementation 'com.github.Minestom:Minestom:ab5734334c'
}
jar {
manifest {
attributes 'Main-Class': 'eu.mhsl.minenet.minestom.pve.Main',
'Multi-Release': true
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,4 @@
Manifest-Version: 1.0
Main-Class: eu.mhsl.minenet.minestom.pve.Main
Multi-Release: true

View File

@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Class-Path: Main

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

234
gradlew vendored Executable file
View File

@@ -0,0 +1,234 @@
#!/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 \
"$@"
# 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" "$@"

89
gradlew.bat vendored Normal file
View File

@@ -0,0 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

2
settings.gradle Normal file
View File

@@ -0,0 +1,2 @@
rootProject.name = 'MineNetPvE'

View File

@@ -0,0 +1,59 @@
package eu.mhsl.minenet.minestom.pve;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.title.Title;
import net.minestom.server.MinecraftServer;
import net.minestom.server.entity.Entity;
import net.minestom.server.entity.Player;
import net.minestom.server.event.EventNode;
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
import net.minestom.server.event.item.ItemDropEvent;
import net.minestom.server.event.player.*;
import net.minestom.server.event.trait.InstanceEvent;
import net.minestom.server.instance.InstanceContainer;
import eu.mhsl.minenet.minestom.pve.util.FullbrightDimension;
import eu.mhsl.minenet.minestom.pve.util.PaneGenerator;
import net.minestom.server.instance.block.Block;
import net.minestom.server.sound.SoundEvent;
import java.util.UUID;
public final class Lobby extends InstanceContainer {
public static final Lobby INSTANCE = new Lobby();
static {
MinecraftServer.getInstanceManager().registerInstance(INSTANCE);
}
private Lobby() {
super(UUID.randomUUID(), FullbrightDimension.INSTANCE);
setGenerator(new PaneGenerator(Block.GOLD_BLOCK));
setTimeRate(0);
setTime(18000);
EventNode<InstanceEvent> events = eventNode();
events.addListener(AddEntityToInstanceEvent.class, addEntityToInstanceEvent -> {
final Entity entity = addEntityToInstanceEvent.getEntity();
if(!(entity instanceof Player p)) return;
if(p.getInstance() != null) {
p.scheduler().scheduleNextTick(() -> p.sendMessage("BACK TO LOBBY"));
} else {
p.scheduler().scheduleNextTick(() -> p.sendMessage("NEW TO LOBBY"));
//p.playSound(Sound.sound(SoundEvent.MUSIC_END, Sound.Source.MASTER, 1f, 1f));
}
});
events.addListener(ItemDropEvent.class, itemDropEvent -> {
itemDropEvent.setCancelled(true);
});
events.addListener(PlayerBlockBreakEvent.class, playerBlockBreakEvent -> {
playerBlockBreakEvent.setCancelled(true);
});
}
}

View File

@@ -0,0 +1,107 @@
package eu.mhsl.minenet.minestom.pve;
import eu.mhsl.minenet.minestom.pve.command.PlayCommand;
import eu.mhsl.minenet.minestom.pve.command.StopCommand;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minestom.server.MinecraftServer;
import net.minestom.server.adventure.audience.Audiences;
import net.minestom.server.command.CommandManager;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.entity.GameMode;
import net.minestom.server.entity.Player;
import net.minestom.server.entity.PlayerSkin;
import net.minestom.server.event.GlobalEventHandler;
import net.minestom.server.event.player.PlayerChatEvent;
import net.minestom.server.event.player.PlayerLoginEvent;
import net.minestom.server.event.player.PlayerSpawnEvent;
import net.minestom.server.event.server.ServerTickMonitorEvent;
import net.minestom.server.extras.lan.OpenToLAN;
import net.minestom.server.instance.InstanceContainer;
import net.minestom.server.instance.InstanceManager;
import net.minestom.server.instance.block.Block;
import net.minestom.server.monitoring.TickMonitor;
import net.minestom.server.potion.Potion;
import net.minestom.server.potion.PotionEffect;
import net.minestom.server.sound.SoundEvent;
import net.minestom.server.timer.TaskSchedule;
import net.minestom.server.utils.MathUtils;
import net.minestom.server.world.Difficulty;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicReference;
public class Main {
public static void main(String[] args) {
MinecraftServer server = MinecraftServer.init();
CommandManager commands = MinecraftServer.getCommandManager();
InstanceManager instances = MinecraftServer.getInstanceManager();
GlobalEventHandler events = MinecraftServer.getGlobalEventHandler();
MinecraftServer.setBrandName("minenet");
MinecraftServer.setCompressionThreshold(0);
MinecraftServer.setTerminalEnabled(true);
MinecraftServer.setDifficulty(Difficulty.NORMAL);
events.addListener(PlayerLoginEvent.class, playerLoginEvent -> {
final Player p = playerLoginEvent.getPlayer();
playerLoginEvent.setSpawningInstance(Lobby.INSTANCE);
if(!p.getName().toString().equals("MineTec")) p.setReducedDebugScreenInformation(true); //TODO remove condition
p.setRespawnPoint(new Pos(0,5,0));
p.setGameMode(GameMode.CREATIVE);
p.setEnableRespawnScreen(false);
});
events.addListener(PlayerChatEvent.class, chatEvent -> {
chatEvent.setChatFormat((event) -> Component.text(event.getEntity().getUsername())
.append(Component.text(" | ", NamedTextColor.DARK_GRAY)
.append(Component.text(event.getMessage(), NamedTextColor.WHITE))));
});
events.addListener(PlayerSpawnEvent.class, playerSpawnEvent -> {
playerSpawnEvent.getPlayer().addEffect(new Potion(PotionEffect.BLINDNESS, (byte) 1, 30));
});
commands.register(new PlayCommand());
commands.register(new StopCommand());
AtomicReference<TickMonitor> lastTick = new AtomicReference<>();
events.addListener(ServerTickMonitorEvent.class, event -> {
final TickMonitor monitor = event.getTickMonitor();
lastTick.set(monitor);
});
MinecraftServer.getSchedulerManager().scheduleTask(() -> {
Collection<Player> players = MinecraftServer.getConnectionManager().getOnlinePlayers();
if (players.isEmpty()) return;
for(Player p : players) {
p.refreshCommands(); //TODO this is a dumb idea
}
final Runtime runtime = Runtime.getRuntime();
final TickMonitor tickMonitor = lastTick.get();
final long ramUsage = (runtime.totalMemory() - runtime.freeMemory()) / 1024 / 1024;
final Component header = Component.newline()
.append(Component.newline()).append(Component.text("Players: " + players.size()))
.append(Component.newline()).append(Component.newline())
.append(Component.text("RAM: " + ramUsage + " MB", NamedTextColor.GRAY).append(Component.newline())
.append(Component.text("TICK: " + MathUtils.round(tickMonitor.getTickTime(), 2) + "ms", NamedTextColor.GRAY))).append(Component.newline())
.append(Component.text("LOAD: " + MathUtils.round(tickMonitor.getTickTime()*2, 1) + "%", NamedTextColor.GRAY))
.append(Component.newline());
final Component footer = Component.text("");
Audiences.players().sendPlayerListHeaderAndFooter(header, footer);
}, TaskSchedule.tick(20), TaskSchedule.tick(20));
OpenToLAN.open();
server.start("0.0.0.0", 25565);
}
}

View File

@@ -0,0 +1,129 @@
package eu.mhsl.minenet.minestom.pve.arena;
import eu.mhsl.minenet.minestom.pve.Lobby;
import eu.mhsl.minenet.minestom.pve.arena.mob.Zombie;
import eu.mhsl.minenet.minestom.pve.util.FullbrightDimension;
import eu.mhsl.minenet.minestom.pve.util.PaneGenerator;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minestom.server.MinecraftServer;
import net.minestom.server.coordinate.Point;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.coordinate.Vec;
import net.minestom.server.entity.*;
import net.minestom.server.entity.ai.EntityAIGroup;
import net.minestom.server.entity.ai.EntityAIGroupBuilder;
import net.minestom.server.entity.ai.goal.DoNothingGoal;
import net.minestom.server.entity.ai.goal.FollowTargetGoal;
import net.minestom.server.entity.ai.goal.RandomLookAroundGoal;
import net.minestom.server.entity.ai.goal.RandomStrollGoal;
import net.minestom.server.entity.ai.target.ClosestEntityTarget;
import net.minestom.server.entity.damage.DamageType;
import net.minestom.server.event.entity.EntityAttackEvent;
import net.minestom.server.event.entity.EntityDamageEvent;
import net.minestom.server.event.entity.EntityDeathEvent;
import net.minestom.server.event.instance.AddEntityToInstanceEvent;
import net.minestom.server.event.instance.RemoveEntityFromInstanceEvent;
import net.minestom.server.instance.InstanceContainer;
import net.minestom.server.instance.block.Block;
import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material;
import net.minestom.server.potion.Potion;
import net.minestom.server.potion.PotionEffect;
import net.minestom.server.sound.SoundEvent;
import net.minestom.server.timer.Task;
import net.minestom.server.timer.TaskSchedule;
import net.minestom.server.world.DimensionType;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
public class Arena extends InstanceContainer {
private UUID arenaId;
private Task spawner;
private boolean isRunning = false;
public Arena(UUID arenaId) {
super(arenaId, FullbrightDimension.INSTANCE);
this.arenaId = arenaId;
MinecraftServer.getInstanceManager().registerInstance(this);
ArenaManager.add(this);
this.setGenerator(new PaneGenerator(Block.STONE));
eventNode().addListener(AddEntityToInstanceEvent.class, addEntityToInstanceEvent -> {
if(addEntityToInstanceEvent.getEntity() instanceof Player) start();
});
eventNode().addListener(RemoveEntityFromInstanceEvent.class, removeEntityFromInstanceEvent -> {
if(!(removeEntityFromInstanceEvent.getEntity() instanceof Player)) return;
if(this.getPlayers().size() > 1) return;
stop();
});
eventNode().addListener(EntityAttackEvent.class, entityAttackEvent -> {
//Player attacks Mob
if(!(entityAttackEvent.getEntity() instanceof Player)) return;
sendMessage(Component.text("EntityAttackEvent " + System.currentTimeMillis()));
Player attacker = (Player) entityAttackEvent.getEntity();
LivingEntity target = (LivingEntity) entityAttackEvent.getTarget();
target.damage(DamageType.fromPlayer(attacker), 20);
double knockbackX = Math.sin(attacker.getPosition().yaw() * (Math.PI / 180));
double knockbackZ = -Math.cos(attacker.getPosition().yaw() * (Math.PI / 180));
entityAttackEvent.getTarget().takeKnockback(
0.5f,
knockbackX,
knockbackZ
);
scheduler().scheduleNextTick(() -> {
if(target.isDead()) {
target.takeKnockback(
1f,
knockbackX,
knockbackZ
);
} else
target.setVelocity(new Vec(0, 10, 0));
});
});
}
public void stop() {
this.spawner.cancel();
if(this.getPlayers().size() > 1) {
for(Player p : this.getPlayers()) {
p.sendMessage(Component.text("instance stopped"));
p.setInstance(Lobby.INSTANCE);
}
}
MinecraftServer.getSchedulerManager().scheduleNextTick(() -> {
MinecraftServer.getInstanceManager().unregisterInstance(this);
System.out.println("Stopped arena " + arenaId);
});
}
public void start() {
if(isRunning) return;
isRunning = true;
this.spawner = scheduler().scheduleTask(() -> {
if(this.getEntities().size() > 100) return;
new Zombie().setInstance(this, new Pos(0, 5, 0));
}, TaskSchedule.seconds(1), TaskSchedule.seconds(1));
}
}

View File

@@ -0,0 +1,29 @@
package eu.mhsl.minenet.minestom.pve.arena;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicReferenceArray;
public class ArenaManager {
private static List<Arena> ARENAS = new ArrayList<>();
public static void add(@NotNull Arena arena) {
ARENAS.add(arena);
}
public static void remove(@NotNull Arena arena) {
ARENAS.remove(arena);
}
public static List<Arena> get() {
return ARENAS;
}
public static void stopAll() {
for(Arena arena : ARENAS) {
arena.stop();
}
}
}

View File

@@ -0,0 +1,126 @@
package eu.mhsl.minenet.minestom.pve.arena;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.minestom.server.MinecraftServer;
import net.minestom.server.coordinate.Pos;
import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.LivingEntity;
import net.minestom.server.entity.Player;
import net.minestom.server.entity.ai.EntityAIGroupBuilder;
import net.minestom.server.entity.ai.goal.MeleeAttackGoal;
import net.minestom.server.entity.ai.goal.RandomLookAroundGoal;
import net.minestom.server.entity.ai.goal.RandomStrollGoal;
import net.minestom.server.entity.ai.target.ClosestEntityTarget;
import net.minestom.server.entity.damage.DamageType;
import net.minestom.server.event.entity.EntityAttackEvent;
import net.minestom.server.event.entity.EntityDamageEvent;
import net.minestom.server.event.entity.EntityDeathEvent;
import net.minestom.server.event.entity.EntitySpawnEvent;
import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material;
import net.minestom.server.particle.Particle;
import net.minestom.server.particle.ParticleCreator;
import net.minestom.server.potion.Potion;
import net.minestom.server.potion.PotionEffect;
import net.minestom.server.sound.SoundEvent;
import net.minestom.server.timer.TaskSchedule;
import net.minestom.server.utils.time.TimeUnit;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class ArenaMob extends EntityCreature {
public ArenaMob(@NotNull EntityType entityType) {
super(entityType);
setCustomName(generateHealthBar(getMaxHealth(), getHealth()));
setCustomNameVisible(true);
setRemovalAnimationDelay(3500);
addAIGroup(
new EntityAIGroupBuilder()
.addGoalSelector(new MeleeAttackGoal(this, 1.2, 20, TimeUnit.SERVER_TICK))
.addTargetSelector(new ClosestEntityTarget(this, 32, Player.class))
.addGoalSelector(new RandomLookAroundGoal(this, 30))
.addGoalSelector(new RandomStrollGoal(this, 5))
.build()
);
eventNode().addListener(EntitySpawnEvent.class, entitySpawnEvent -> {
Pos position = entitySpawnEvent.getEntity().getPosition();
if(entitySpawnEvent.getEntity() == this) ParticleCreator.createParticlePacket(Particle.FIREWORK,
position.x(),
position.y(),
position.z(),
(float) position.sub(1).x(),
(float) position.sub(1).y(),
(float) position.sub(1).z(),
10);
});
eventNode().addListener(EntityAttackEvent.class, entityAttackEvent -> {
//Mob attacks Player
if(entityAttackEvent.getEntity() instanceof Player) return;
instance.sendMessage(Component.text("EntityAttackEvent " + System.currentTimeMillis()));
entityAttackEvent.getTarget().takeKnockback(
0.2f,
Math.sin(entityAttackEvent.getEntity().getPosition().yaw() * (Math.PI / 180)),
-Math.cos(entityAttackEvent.getEntity().getPosition().yaw() * (Math.PI / 180))
);
((LivingEntity) entityAttackEvent.getTarget()).damage(DamageType.fromEntity(entityAttackEvent.getEntity()), 1);
((EntityCreature) entityAttackEvent.getEntity()).swingMainHand();
});
eventNode().addListener(EntityDamageEvent.class, entityDamageEvent -> {
instance.sendMessage(Component.text("EntityDamageEvent " + System.currentTimeMillis()));
entityDamageEvent.setSound(SoundEvent.BLOCK_AMETHYST_BLOCK_STEP);
setCustomName(generateHealthBar(getMaxHealth(), getHealth()));
lookAt(new Pos(0,0,0));
});
eventNode().addListener(EntityDeathEvent.class, entityDeathEvent -> {
instance.sendMessage(Component.text("EntityDeathEvent " + System.currentTimeMillis()));
setCustomNameVisible(false);
setCustomName(null);
scheduler().scheduleTask(() -> {
teleport(getPosition().sub(0, 0.1, 0));
}, TaskSchedule.seconds(3), TaskSchedule.stop());
});
}
private static final int BLOCK_LENGTH = 6;
private static final List<String> CHARACTERS = List.of(
"", "", "", "",
"", "", "", ""
);
private static final String FULL_BLOCK_CHAR = "";
private static @NotNull Component generateHealthBar(float maxHealth, float currentHealth) {
// Converts the health percentage into a number from 0-{blockLength} -- only 0 if the mob's health is 0
final double charHealth = (currentHealth / maxHealth) * BLOCK_LENGTH;
return Component.text()
.append(Component.text(
FULL_BLOCK_CHAR.repeat((int) Math.floor(charHealth)),
NamedTextColor.DARK_RED
)).append(Component.text(CHARACTERS.get((int) Math.round(
(charHealth - Math.floor(charHealth)) // number from 0-1
* (CHARACTERS.size() - 1) // indexes start at 0
)), NamedTextColor.GOLD))
.build();
}
}

View File

@@ -0,0 +1,19 @@
package eu.mhsl.minenet.minestom.pve.arena.mob;
import eu.mhsl.minenet.minestom.pve.arena.ArenaMob;
import net.minestom.server.entity.EntityCreature;
import net.minestom.server.entity.EntityType;
import net.minestom.server.entity.Player;
import net.minestom.server.item.ItemStack;
import net.minestom.server.item.Material;
import org.jetbrains.annotations.NotNull;
public class Zombie extends ArenaMob {
public Zombie() {
super(EntityType.ZOMBIE);
setItemInHand(Player.Hand.MAIN, ItemStack.builder(Material.TNT).build());
setItemInHand(Player.Hand.OFF, ItemStack.builder(Material.FLINT_AND_STEEL).build());
}
}

View File

@@ -0,0 +1,31 @@
package eu.mhsl.minenet.minestom.pve.command;
import eu.mhsl.minenet.minestom.pve.arena.Arena;
import eu.mhsl.minenet.minestom.pve.arena.ArenaManager;
import eu.mhsl.minenet.minestom.pve.util.CommandConditions;
import kotlin.reflect.jvm.internal.impl.metadata.ProtoBuf;
import kotlin.reflect.jvm.internal.impl.protobuf.MessageLite;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.builder.Command;
import net.minestom.server.command.builder.condition.CommandCondition;
import net.minestom.server.entity.Player;
import net.minestom.server.potion.Potion;
import net.minestom.server.potion.PotionEffect;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public class PlayCommand extends Command {
public PlayCommand() {
super("start");
setCondition(CommandConditions::lobbyOnly);
setDefaultExecutor((sender, context) -> {
if(sender instanceof Player p) {
Arena arena = new Arena(p.getUuid());
p.setInstance(arena);
}
});
}
}

View File

@@ -0,0 +1,22 @@
package eu.mhsl.minenet.minestom.pve.command;
import eu.mhsl.minenet.minestom.pve.Lobby;
import eu.mhsl.minenet.minestom.pve.arena.ArenaManager;
import eu.mhsl.minenet.minestom.pve.util.CommandConditions;
import net.minestom.server.MinecraftServer;
import net.minestom.server.command.builder.Command;
import net.minestom.server.entity.Player;
import org.jetbrains.annotations.NotNull;
public class StopCommand extends Command {
public StopCommand() {
super("stop");
setCondition(CommandConditions::arenaOnly);
setDefaultExecutor(((sender, context) -> {
final Player p = (Player) sender;
p.setInstance(Lobby.INSTANCE);
p.setHealth(p.getMaxHealth());
}));
}
}

View File

@@ -0,0 +1,21 @@
package eu.mhsl.minenet.minestom.pve.util;
import eu.mhsl.minenet.minestom.pve.Lobby;
import net.minestom.server.command.CommandSender;
import net.minestom.server.entity.Player;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.InstanceContainer;
public class CommandConditions {
public static boolean lobbyOnly(CommandSender sender, String arguments) {
if(!(sender instanceof Player p)) return false;
Instance instance = p.getInstance();
return instance == null || instance == Lobby.INSTANCE;
}
public static boolean arenaOnly(CommandSender sender, String arguments) {
if(!(sender instanceof Player p)) return false;
final Instance instance = p.getInstance();
return instance != null && instance != Lobby.INSTANCE;
}
}

View File

@@ -0,0 +1,15 @@
package eu.mhsl.minenet.minestom.pve.util;
import net.minestom.server.MinecraftServer;
import net.minestom.server.utils.NamespaceID;
import net.minestom.server.world.DimensionType;
public class FullbrightDimension {
public static final DimensionType INSTANCE = DimensionType.builder(NamespaceID.from("arena:default"))
.ambientLight(2f)
.build();
static {
MinecraftServer.getDimensionTypeManager().addDimension(INSTANCE);
}
}

View File

@@ -0,0 +1,24 @@
package eu.mhsl.minenet.minestom.pve.util;
import net.minestom.server.instance.block.Block;
import net.minestom.server.instance.generator.GenerationUnit;
import net.minestom.server.instance.generator.Generator;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
public class PaneGenerator implements Generator {
private Block block;
public PaneGenerator(Block block) {
this.block = block;
}
@Override
public void generate(@NotNull GenerationUnit unit) {
unit.modifier().fillHeight(0, 5, block);
}
@Override
public void generateAll(@NotNull Collection<@NotNull GenerationUnit> units) {
Generator.super.generateAll(units);
}
}