update some baseline stuff
This commit is contained in:
parent
684bb43903
commit
71324e7d8d
48 changed files with 2130 additions and 17 deletions
55
.gitignore
vendored
55
.gitignore
vendored
|
@ -1,21 +1,42 @@
|
|||
.gradle
|
||||
**/build/
|
||||
!src/**/build/
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
|
||||
# Avoid ignore Gradle wrappper properties
|
||||
!gradle-wrapper.properties
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
# Eclipse Gradle plugin generated files
|
||||
# Eclipse Core
|
||||
.project
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
8
.idea/.gitignore
vendored
Normal file
8
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
17
.idea/gradle.xml
Normal file
17
.idea/gradle.xml
Normal 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="externalProjectPath" value="$PROJECT_DIR$" />
|
||||
<option name="gradleHome" value="" />
|
||||
<option name="modules">
|
||||
<set>
|
||||
<option value="$PROJECT_DIR$" />
|
||||
</set>
|
||||
</option>
|
||||
</GradleProjectSettings>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
15
.idea/misc.xml
Normal file
15
.idea/misc.xml
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?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="FrameworkDetectionExcludesConfiguration">
|
||||
<file type="web" url="file://$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="corretto-1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal 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>
|
41
build.gradle
Normal file
41
build.gradle
Normal file
|
@ -0,0 +1,41 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'java-library'
|
||||
}
|
||||
|
||||
allprojects {
|
||||
|
||||
apply plugin: 'java'
|
||||
|
||||
group = 'me.tofaa.entitylib'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
java.targetCompatibility = JavaVersion.VERSION_1_8
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
url = 'https://jitpack.io/'
|
||||
}
|
||||
maven {
|
||||
name = 'papermc'
|
||||
url = 'https://repo.papermc.io/repository/maven-public/'
|
||||
}
|
||||
maven {
|
||||
name = 'codemc-repo'
|
||||
url = 'https://repo.codemc.io/repository/maven-releases/'
|
||||
}
|
||||
maven {
|
||||
url = "https://oss.sonatype.org/content/groups/public/"
|
||||
}
|
||||
maven { url = "https://repo.codemc.org/repository/maven-public/" }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.github.retrooper.packetevents:spigot:2.0.2")
|
||||
}
|
||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
6
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
#Mon Nov 27 02:38:48 TRT 2023
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
234
gradlew
vendored
Normal file
234
gradlew
vendored
Normal 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
89
gradlew.bat
vendored
Normal 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
|
3
settings.gradle
Normal file
3
settings.gradle
Normal file
|
@ -0,0 +1,3 @@
|
|||
rootProject.name = 'EntityLib'
|
||||
include 'test-plugin'
|
||||
|
74
src/main/java/me/tofaa/entitylib/EntityLib.java
Normal file
74
src/main/java/me/tofaa/entitylib/EntityLib.java
Normal file
|
@ -0,0 +1,74 @@
|
|||
package me.tofaa.entitylib;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEventsAPI;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
public final class EntityLib {
|
||||
|
||||
private EntityLib() {}
|
||||
private static final HashMap<Integer, EntityMeta> metadata = new HashMap<>();
|
||||
private static boolean initialized = false;
|
||||
private static PacketEventsAPI<?> packetEvents;
|
||||
private static MetaConverterRegistry metaRegistry;
|
||||
|
||||
public static void init(@NotNull PacketEventsAPI<?> packetEvents) {
|
||||
if (initialized) {
|
||||
throw new IllegalStateException("EntityLib is already initialized");
|
||||
}
|
||||
initialized = true;
|
||||
EntityLib.packetEvents = packetEvents;
|
||||
if (!packetEvents.isInitialized()) {
|
||||
initialized = false;
|
||||
throw new IllegalStateException("PacketEvents is not initialized");
|
||||
}
|
||||
metaRegistry = new MetaConverterRegistry();
|
||||
}
|
||||
|
||||
|
||||
public static @Nullable EntityMeta getMeta(int entityId) {
|
||||
checkInit();
|
||||
return metadata.get(entityId);
|
||||
}
|
||||
|
||||
public static <T extends EntityMeta> @Nullable T getMeta(int entityId, Class<T> metaClass) {
|
||||
checkInit();
|
||||
EntityMeta meta = metadata.get(entityId);
|
||||
if (meta == null) {
|
||||
return null;
|
||||
}
|
||||
if (metaClass.isAssignableFrom(meta.getClass())) {
|
||||
return (T) meta;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static EntityMeta createMeta(int entityId, EntityType entityType) {
|
||||
checkInit();
|
||||
Metadata m = new Metadata(entityId);
|
||||
BiFunction<Integer, Metadata, EntityMeta> function = metaRegistry.get(entityType);
|
||||
if (function == null) {
|
||||
throw new IllegalArgumentException("No meta converter for entity type " + entityType);
|
||||
}
|
||||
EntityMeta meta = function.apply(entityId, m);
|
||||
metadata.put(entityId, meta);
|
||||
return meta;
|
||||
}
|
||||
|
||||
public static PacketEventsAPI<?> getPacketEvents() {
|
||||
checkInit();
|
||||
return packetEvents;
|
||||
}
|
||||
|
||||
private static void checkInit() {
|
||||
if (!initialized) {
|
||||
throw new IllegalStateException("EntityLib is not initialized");
|
||||
}
|
||||
}
|
||||
}
|
47
src/main/java/me/tofaa/entitylib/MetaConverterRegistry.java
Normal file
47
src/main/java/me/tofaa/entitylib/MetaConverterRegistry.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package me.tofaa.entitylib;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityType;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.mobs.*;
|
||||
import me.tofaa.entitylib.meta.projectile.SmallFireballMeta;
|
||||
import me.tofaa.entitylib.meta.projectile.ThrownEggMeta;
|
||||
import me.tofaa.entitylib.meta.projectile.ThrownExpBottleMeta;
|
||||
import me.tofaa.entitylib.meta.projectile.ThrownTridentMeta;
|
||||
import me.tofaa.entitylib.meta.types.PlayerMeta;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
final class MetaConverterRegistry {
|
||||
|
||||
private final Map<EntityType, BiFunction<Integer, Metadata, EntityMeta>> converters = new HashMap<>();
|
||||
|
||||
MetaConverterRegistry() {
|
||||
put(EntityTypes.PLAYER, PlayerMeta::new);
|
||||
put(EntityTypes.THROWN_EXP_BOTTLE, ThrownExpBottleMeta::new);
|
||||
put(EntityTypes.EGG, ThrownEggMeta::new);
|
||||
put(EntityTypes.TRIDENT, ThrownTridentMeta::new);
|
||||
put(EntityTypes.POTION, ThrownTridentMeta::new);
|
||||
put(EntityTypes.SMALL_FIREBALL, SmallFireballMeta::new);
|
||||
put(EntityTypes.PIG, PigMeta::new);
|
||||
put(EntityTypes.COW, CowMeta::new);
|
||||
put(EntityTypes.CHICKEN, ChickenMeta::new);
|
||||
put(EntityTypes.BEE, BeeMeta::new);
|
||||
put(EntityTypes.TURTLE, TurtleMeta::new);
|
||||
put(EntityTypes.DONKEY, DonkeyMeta::new);
|
||||
put(EntityTypes.SHEEP, SheepMeta::new);
|
||||
}
|
||||
|
||||
private void put(EntityType entityType, BiFunction<Integer, Metadata, EntityMeta> function) {
|
||||
converters.put(entityType, function);
|
||||
}
|
||||
|
||||
public @Nullable BiFunction<Integer, Metadata, EntityMeta> get(EntityType entityType) {
|
||||
return converters.get(entityType);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package me.tofaa.entitylib.exception;
|
||||
|
||||
public class InvalidVersionException extends RuntimeException {
|
||||
|
||||
public InvalidVersionException() {
|
||||
}
|
||||
|
||||
public InvalidVersionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public InvalidVersionException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public InvalidVersionException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public InvalidVersionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
}
|
||||
}
|
190
src/main/java/me/tofaa/entitylib/meta/EntityMeta.java
Normal file
190
src/main/java/me/tofaa/entitylib/meta/EntityMeta.java
Normal file
|
@ -0,0 +1,190 @@
|
|||
package me.tofaa.entitylib.meta;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.manager.server.VersionComparison;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
|
||||
import me.tofaa.entitylib.EntityLib;
|
||||
import me.tofaa.entitylib.exception.InvalidVersionException;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
|
||||
public class EntityMeta {
|
||||
|
||||
public static final byte OFFSET = 0;
|
||||
public static final byte MAX_OFFSET = OFFSET + 8;
|
||||
|
||||
private final static byte ON_FIRE_BIT = 0x01;
|
||||
private final static byte CROUCHING_BIT = 0x02;
|
||||
private final static byte SPRINTING_BIT = 0x08;
|
||||
private final static byte SWIMMING_BIT = 0x10;
|
||||
private final static byte INVISIBLE_BIT = 0x20;
|
||||
private final static byte HAS_GLOWING_EFFECT_BIT = 0x40;
|
||||
private final static byte FLYING_WITH_ELYTRA_BIT = (byte) 0x80;
|
||||
|
||||
protected final int entityId;
|
||||
protected final Metadata metadata;
|
||||
|
||||
public EntityMeta(int entityId, Metadata metadata) {
|
||||
this.entityId = entityId;
|
||||
this.metadata = metadata;
|
||||
}
|
||||
|
||||
public boolean isOnFire() {
|
||||
return getMaskBit(OFFSET, ON_FIRE_BIT);
|
||||
}
|
||||
|
||||
public void setOnFire(boolean value) {
|
||||
setMaskBit(OFFSET, ON_FIRE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSneaking() {
|
||||
return getMaskBit(OFFSET, CROUCHING_BIT);
|
||||
}
|
||||
|
||||
public void setSneaking(boolean value) {
|
||||
setMaskBit(OFFSET, CROUCHING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isSprinting() {
|
||||
return getMaskBit(OFFSET, SPRINTING_BIT);
|
||||
}
|
||||
|
||||
public void setSprinting(boolean value) {
|
||||
setMaskBit(OFFSET, SPRINTING_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isInvisible() {
|
||||
return getMaskBit(OFFSET, INVISIBLE_BIT);
|
||||
}
|
||||
|
||||
public void setInvisible(boolean value) {
|
||||
setMaskBit(OFFSET, INVISIBLE_BIT, value);
|
||||
}
|
||||
|
||||
public short getAirTicks() {
|
||||
return this.metadata.getIndex((byte) 1, (short) 300);
|
||||
}
|
||||
|
||||
public void setAirTicks(short value) {
|
||||
this.metadata.setIndex((byte) 1, EntityDataTypes.SHORT, value);
|
||||
}
|
||||
|
||||
public Component getCustomName() {
|
||||
return this.metadata.getIndex((byte) 2, null);
|
||||
}
|
||||
|
||||
public boolean hasGlowingEffect() {
|
||||
return getMaskBit(OFFSET, HAS_GLOWING_EFFECT_BIT);
|
||||
}
|
||||
public boolean isSwimming() {
|
||||
return getMaskBit(OFFSET, SWIMMING_BIT);
|
||||
}
|
||||
|
||||
public void setSwimming(boolean value) {
|
||||
setMaskBit(OFFSET, SWIMMING_BIT, value);
|
||||
}
|
||||
|
||||
public void setHasGlowingEffect(boolean value) {
|
||||
setMaskBit(OFFSET, HAS_GLOWING_EFFECT_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isFlyingWithElytra() {
|
||||
return getMaskBit(OFFSET, FLYING_WITH_ELYTRA_BIT);
|
||||
}
|
||||
|
||||
public void setFlyingWithElytra(boolean value) {
|
||||
setMaskBit(OFFSET, FLYING_WITH_ELYTRA_BIT, value);
|
||||
}
|
||||
|
||||
public void setCustomName(Component value) {
|
||||
this.metadata.setIndex((byte) 2, EntityDataTypes.COMPONENT, GsonComponentSerializer.gson().serialize(value));
|
||||
}
|
||||
|
||||
public boolean isCustomNameVisible() {
|
||||
return this.metadata.getIndex((byte) 3, false);
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean value) {
|
||||
this.metadata.setIndex((byte) 3, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isSilent() {
|
||||
return this.metadata.getIndex((byte) 4, false);
|
||||
}
|
||||
|
||||
public void setSilent(boolean value) {
|
||||
this.metadata.setIndex((byte) 4, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isHasNoGravity() {
|
||||
return this.metadata.getIndex(offset(5), true);
|
||||
}
|
||||
|
||||
public void setHasNoGravity(boolean value) {
|
||||
this.metadata.setIndex(offset(5), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public EntityPose getPose() {
|
||||
return this.metadata.getIndex(offset(6), EntityPose.STANDING);
|
||||
}
|
||||
|
||||
public void setPose(EntityPose value) {
|
||||
this.metadata.setIndex(offset(6), EntityDataTypes.ENTITY_POSE, value);
|
||||
}
|
||||
|
||||
public WrapperPlayServerEntityMetadata createPacket() {
|
||||
return metadata.createPacket();
|
||||
}
|
||||
|
||||
|
||||
protected static void isVersion(ServerVersion version) {
|
||||
if (!EntityLib.getPacketEvents().getServerManager().getVersion().is(VersionComparison.EQUALS, version)) {
|
||||
throw new InvalidVersionException("This method is only available for " + version.name() + " and above.");
|
||||
}
|
||||
}
|
||||
|
||||
protected static void isVersionOlder(ServerVersion version) {
|
||||
if (!EntityLib.getPacketEvents().getServerManager().getVersion().is(VersionComparison.OLDER_THAN, version)) {
|
||||
throw new InvalidVersionException("This method is only available for versions older than " + version.name() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
protected static void isVersionNewer(ServerVersion version) {
|
||||
if (!EntityLib.getPacketEvents().getServerManager().getVersion().is(VersionComparison.NEWER_THAN, version)) {
|
||||
throw new InvalidVersionException("This method is only available for versions newer than " + version.name() + ".");
|
||||
}
|
||||
}
|
||||
|
||||
protected static byte offset(int amount) {
|
||||
return (byte) (OFFSET + amount);
|
||||
}
|
||||
|
||||
protected byte getMask(byte index) {
|
||||
return this.metadata.getIndex(index, (byte) 0);
|
||||
}
|
||||
|
||||
protected void setMask(byte index, byte mask) {
|
||||
this.metadata.setIndex(index, EntityDataTypes.BYTE, mask);
|
||||
}
|
||||
|
||||
protected boolean getMaskBit(byte index, byte bit) {
|
||||
return (getMask(index) & bit) == bit;
|
||||
}
|
||||
|
||||
protected void setMaskBit(int index, byte bit, boolean value) {
|
||||
byte mask = getMask((byte)index);
|
||||
boolean currentValue = (mask & bit) == bit;
|
||||
if (currentValue == value) {
|
||||
return;
|
||||
}
|
||||
if (value) {
|
||||
mask |= bit;
|
||||
} else {
|
||||
mask &= ~bit;
|
||||
}
|
||||
setMask((byte)index, mask);
|
||||
}
|
||||
|
||||
}
|
44
src/main/java/me/tofaa/entitylib/meta/Metadata.java
Normal file
44
src/main/java/me/tofaa/entitylib/meta/Metadata.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package me.tofaa.entitylib.meta;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityData;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class Metadata {
|
||||
|
||||
private final Map<Byte, EntityData> metadataMap = new ConcurrentHashMap<>();
|
||||
private final int entityId;
|
||||
|
||||
public Metadata(int entityId) {
|
||||
this.entityId = entityId;
|
||||
}
|
||||
|
||||
public <T> T getIndex(byte index, @Nullable T defaultValue) {
|
||||
EntityData entityData = metadataMap.get(index);
|
||||
if (entityData == null) return defaultValue;
|
||||
if (entityData.getValue() == null) return defaultValue;
|
||||
return (T) entityData.getValue();
|
||||
}
|
||||
|
||||
public <T> void setIndex(byte index, @NotNull EntityDataType<T> dataType, T value) {
|
||||
EntityData data = new EntityData(index, dataType, value);
|
||||
this.metadataMap.put(index, data);
|
||||
}
|
||||
|
||||
@NotNull List<EntityData> getEntries() {
|
||||
return new ArrayList<>(metadataMap.values());
|
||||
}
|
||||
|
||||
public WrapperPlayServerEntityMetadata createPacket() {
|
||||
return new WrapperPlayServerEntityMetadata(entityId, getEntries());
|
||||
}
|
||||
|
||||
}
|
52
src/main/java/me/tofaa/entitylib/meta/mobs/BeeMeta.java
Normal file
52
src/main/java/me/tofaa/entitylib/meta/mobs/BeeMeta.java
Normal file
|
@ -0,0 +1,52 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class BeeMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private final static byte ANGRY_BIT = 0x02;
|
||||
private final static byte HAS_STUNG_BIT = 0x04;
|
||||
private final static byte HAS_NECTAR_BIT = 0x08;
|
||||
|
||||
public BeeMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isAngry() {
|
||||
return getMaskBit(OFFSET, ANGRY_BIT);
|
||||
}
|
||||
|
||||
public void setAngry(boolean value) {
|
||||
setMaskBit(OFFSET, ANGRY_BIT, value);
|
||||
}
|
||||
|
||||
public boolean hasStung() {
|
||||
return getMaskBit(OFFSET, HAS_STUNG_BIT);
|
||||
}
|
||||
|
||||
public void setHasStung(boolean value) {
|
||||
setMaskBit(OFFSET, HAS_STUNG_BIT, value);
|
||||
}
|
||||
|
||||
public boolean hasNectar() {
|
||||
return getMaskBit(OFFSET, HAS_NECTAR_BIT);
|
||||
}
|
||||
|
||||
public void setHasNectar(boolean value) {
|
||||
setMaskBit(OFFSET, HAS_NECTAR_BIT, value);
|
||||
}
|
||||
|
||||
public int getAngerTicks() {
|
||||
return super.metadata.getIndex(offset(1), 0);
|
||||
}
|
||||
|
||||
public void setAngerTicks(int value) {
|
||||
super.metadata.setIndex(offset(1), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
}
|
14
src/main/java/me/tofaa/entitylib/meta/mobs/ChickenMeta.java
Normal file
14
src/main/java/me/tofaa/entitylib/meta/mobs/ChickenMeta.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class ChickenMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ChickenMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
14
src/main/java/me/tofaa/entitylib/meta/mobs/CowMeta.java
Normal file
14
src/main/java/me/tofaa/entitylib/meta/mobs/CowMeta.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class CowMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public CowMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
14
src/main/java/me/tofaa/entitylib/meta/mobs/DonkeyMeta.java
Normal file
14
src/main/java/me/tofaa/entitylib/meta/mobs/DonkeyMeta.java
Normal file
|
@ -0,0 +1,14 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class DonkeyMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public DonkeyMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
}
|
34
src/main/java/me/tofaa/entitylib/meta/mobs/PigMeta.java
Normal file
34
src/main/java/me/tofaa/entitylib/meta/mobs/PigMeta.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class PigMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public PigMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean hasSaddle() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setHasSaddle(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public int getTimeToBoost() {
|
||||
isVersionNewer(ServerVersion.V_1_16);
|
||||
return super.metadata.getIndex(offset(1), 0);
|
||||
}
|
||||
|
||||
public void setTimeToBoost(int value) {
|
||||
isVersionNewer(ServerVersion.V_1_16);
|
||||
super.metadata.setIndex(offset(1), EntityDataTypes.INT, value);
|
||||
}
|
||||
}
|
43
src/main/java/me/tofaa/entitylib/meta/mobs/SheepMeta.java
Normal file
43
src/main/java/me/tofaa/entitylib/meta/mobs/SheepMeta.java
Normal file
|
@ -0,0 +1,43 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class SheepMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
|
||||
private final static byte COLOR_BITS = 0x0F;
|
||||
private final static byte SHEARED_BIT = 0x10;
|
||||
|
||||
public SheepMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return getMask(OFFSET) & COLOR_BITS;
|
||||
}
|
||||
|
||||
public void setColor(byte color) {
|
||||
byte before = getMask(OFFSET);
|
||||
byte mask = before;
|
||||
mask &= ~COLOR_BITS;
|
||||
mask |= (color & COLOR_BITS);
|
||||
if (mask != before) {
|
||||
setMask(OFFSET, mask);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSheared() {
|
||||
return getMaskBit(OFFSET, SHEARED_BIT);
|
||||
}
|
||||
|
||||
public void setSheared(boolean value) {
|
||||
setMaskBit(OFFSET, SHEARED_BIT, value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
66
src/main/java/me/tofaa/entitylib/meta/mobs/TurtleMeta.java
Normal file
66
src/main/java/me/tofaa/entitylib/meta/mobs/TurtleMeta.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package me.tofaa.entitylib.meta.mobs;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.AgeableMeta;
|
||||
|
||||
public class TurtleMeta extends AgeableMeta {
|
||||
|
||||
public static final byte OFFSET = AgeableMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 6;
|
||||
|
||||
public TurtleMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
|
||||
public Vector3i getHomePosition() {
|
||||
return super.metadata.getIndex(OFFSET, Vector3i.zero());
|
||||
}
|
||||
|
||||
public void setBlockPosition(Vector3i value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BLOCK_POSITION, value);
|
||||
}
|
||||
|
||||
public boolean hasEgg() {
|
||||
return super.metadata.getIndex(offset(1), false);
|
||||
}
|
||||
|
||||
public void setHasEgg(boolean value) {
|
||||
super.metadata.setIndex(offset(1), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isLayingEgg() {
|
||||
return super.metadata.getIndex(offset(2), false);
|
||||
}
|
||||
|
||||
public void setLayingEgg(boolean value) {
|
||||
super.metadata.setIndex(offset(2), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public Vector3i getTravelPosition() {
|
||||
return super.metadata.getIndex(offset(3), Vector3i.zero());
|
||||
}
|
||||
|
||||
public void setTravelPosition(Vector3i value) {
|
||||
super.metadata.setIndex(offset(3), EntityDataTypes.BLOCK_POSITION, value);
|
||||
}
|
||||
|
||||
public boolean isGoingHome() {
|
||||
return super.metadata.getIndex(offset(4), false);
|
||||
}
|
||||
|
||||
public void setGoingHome(boolean value) {
|
||||
super.metadata.setIndex(offset(4), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public boolean isTravelling() {
|
||||
return super.metadata.getIndex(offset(5), false);
|
||||
}
|
||||
|
||||
public void setTravelling(boolean value) {
|
||||
super.metadata.setIndex(offset(4), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||
import me.tofaa.entitylib.meta.types.ProjectileMeta;
|
||||
|
||||
public class ArrowMeta extends BaseArrowMeta implements ProjectileMeta, ObjectData {
|
||||
|
||||
public static final byte OFFSET = BaseArrowMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private int shooterId = -1;
|
||||
|
||||
public ArrowMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return super.metadata.getIndex(OFFSET, -1);
|
||||
}
|
||||
|
||||
public void setColor(int value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getShooter() {
|
||||
return shooterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShooter(int entityId) {
|
||||
this.shooterId = entityId;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return this.shooterId == -1 ? 0 : this.shooterId + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresVelocityPacketAtSpawn() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class BaseArrowMeta extends EntityMeta {
|
||||
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
private final static byte CRITICAL_BIT = 0x01;
|
||||
private final static byte NO_CLIP_BIT = 0x02;
|
||||
|
||||
public BaseArrowMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isCritical() {
|
||||
return getMaskBit(OFFSET, CRITICAL_BIT);
|
||||
}
|
||||
|
||||
public void setCritical(boolean value) {
|
||||
setMaskBit(OFFSET, CRITICAL_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isNoClip() {
|
||||
isVersionNewer(ServerVersion.V_1_9);
|
||||
return getMaskBit(OFFSET, NO_CLIP_BIT);
|
||||
}
|
||||
|
||||
public void setNoClip(boolean value) {
|
||||
isVersionNewer(ServerVersion.V_1_9);
|
||||
setMaskBit(OFFSET, NO_CLIP_BIT, value);
|
||||
}
|
||||
|
||||
public int getPierceLevel() {
|
||||
isVersionNewer(ServerVersion.V_1_14);
|
||||
return super.metadata.getIndex(offset(1), 0);
|
||||
}
|
||||
|
||||
public void setPierceLevel(int value) {
|
||||
isVersionNewer(ServerVersion.V_1_14);
|
||||
super.metadata.setIndex(offset(1), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ItemContainerMeta;
|
||||
|
||||
public class EyeOfEnderMeta extends ItemContainerMeta {
|
||||
|
||||
|
||||
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public static final ItemStack EYE_OF_ENDER = ItemStack.builder().type(ItemTypes.ENDER_EYE).build();
|
||||
|
||||
public EyeOfEnderMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata, EYE_OF_ENDER);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ItemContainerMeta;
|
||||
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||
|
||||
public class ItemEntityMeta extends ItemContainerMeta implements ObjectData {
|
||||
|
||||
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
protected ItemEntityMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresVelocityPacketAtSpawn() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ItemContainerMeta;
|
||||
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||
import me.tofaa.entitylib.meta.types.ProjectileMeta;
|
||||
|
||||
public class LargeFireballMeta extends ItemContainerMeta implements ObjectData, ProjectileMeta {
|
||||
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
private int shooterId = -1;
|
||||
|
||||
public LargeFireballMeta(int entityId, Metadata meta) {
|
||||
super(entityId, meta, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return this.shooterId == -1 ? 0 : this.shooterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresVelocityPacketAtSpawn() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getShooter() {
|
||||
return shooterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShooter(int entityId) {
|
||||
this.shooterId = entityId;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ItemContainerMeta;
|
||||
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||
import me.tofaa.entitylib.meta.types.ProjectileMeta;
|
||||
|
||||
public class SmallFireballMeta extends ItemContainerMeta implements ObjectData, ProjectileMeta {
|
||||
|
||||
|
||||
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public static final ItemStack SMALL_FIREBALL = ItemStack.builder().type(ItemTypes.FIRE_CHARGE).build();
|
||||
|
||||
private int shooterId = -1;
|
||||
|
||||
public SmallFireballMeta(int entityId, Metadata meta) {
|
||||
super(entityId, meta, SMALL_FIREBALL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return this.shooterId == -1 ? 0 : this.shooterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresVelocityPacketAtSpawn() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getShooter() {
|
||||
return shooterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShooter(int entityId) {
|
||||
this.shooterId = entityId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ItemContainerMeta;
|
||||
|
||||
public class SnowballMeta extends ItemContainerMeta {
|
||||
|
||||
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public static final ItemStack SNOWBALL = ItemStack.builder().type(ItemTypes.SNOWBALL).build();
|
||||
|
||||
public SnowballMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata, SNOWBALL);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ObjectData;
|
||||
import me.tofaa.entitylib.meta.types.ProjectileMeta;
|
||||
|
||||
public class SpectralArrowMeta extends BaseArrowMeta implements ProjectileMeta, ObjectData {
|
||||
|
||||
public static final byte OFFSET = BaseArrowMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
private int shooterId = -1;
|
||||
|
||||
public SpectralArrowMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectData() {
|
||||
return this.shooterId == -1 ? 0 : this.shooterId + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresVelocityPacketAtSpawn() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getShooter() {
|
||||
return shooterId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShooter(int entityId) {
|
||||
this.shooterId = entityId;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ItemContainerMeta;
|
||||
|
||||
public class ThrownEggMeta extends ItemContainerMeta {
|
||||
|
||||
|
||||
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
private static final ItemStack EGG = ItemStack.builder().type(ItemTypes.EGG).build();
|
||||
|
||||
public ThrownEggMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata, EGG);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ItemContainerMeta;
|
||||
|
||||
public class ThrownEnderPearlMeta extends ItemContainerMeta {
|
||||
|
||||
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
private static final ItemStack ENDER_PEARL = ItemStack.builder().type(ItemTypes.ENDER_PEARL).build();
|
||||
|
||||
public ThrownEnderPearlMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata, ENDER_PEARL);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import com.github.retrooper.packetevents.protocol.item.type.ItemTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ItemContainerMeta;
|
||||
|
||||
public class ThrownExpBottleMeta extends ItemContainerMeta {
|
||||
|
||||
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
private static final ItemStack EXP_BOTTLE = ItemStack.builder().type(ItemTypes.EXPERIENCE_BOTTLE).build();
|
||||
|
||||
public ThrownExpBottleMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata, EXP_BOTTLE);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import me.tofaa.entitylib.meta.types.ItemContainerMeta;
|
||||
|
||||
public class ThrownPotionMeta extends ItemContainerMeta {
|
||||
|
||||
public static final byte OFFSET = ItemContainerMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 0;
|
||||
|
||||
public ThrownPotionMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata, ItemStack.EMPTY);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package me.tofaa.entitylib.meta.projectile;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class ThrownTridentMeta extends BaseArrowMeta{
|
||||
|
||||
public static final byte OFFSET = BaseArrowMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 2;
|
||||
|
||||
public ThrownTridentMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public int getLoyaltyLevel() {
|
||||
return super.metadata.getIndex(OFFSET, 0);
|
||||
}
|
||||
|
||||
public void setLoyaltyLevel(int value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public boolean isHasEnchantmentGlint() {
|
||||
return super.metadata.getIndex(offset(1), false);
|
||||
}
|
||||
|
||||
public void setHasEnchantmentGlint(boolean value) {
|
||||
super.metadata.setIndex(offset(1), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
}
|
23
src/main/java/me/tofaa/entitylib/meta/types/AgeableMeta.java
Normal file
23
src/main/java/me/tofaa/entitylib/meta/types/AgeableMeta.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package me.tofaa.entitylib.meta.types;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class AgeableMeta extends MobMeta {
|
||||
|
||||
public static final byte OFFSET = MobMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
public AgeableMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return super.metadata.getIndex(OFFSET, false);
|
||||
}
|
||||
|
||||
public void setBaby(boolean value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package me.tofaa.entitylib.meta.types;
|
||||
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.item.ItemStack;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public abstract class ItemContainerMeta extends EntityMeta {
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final ItemStack baseItem;
|
||||
|
||||
protected ItemContainerMeta(int entityId, Metadata metadata, ItemStack baseItem) {
|
||||
super(entityId, metadata);
|
||||
this.baseItem = baseItem;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return super.metadata.getIndex(OFFSET, baseItem);
|
||||
}
|
||||
|
||||
public void setItem(ItemStack value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.ITEMSTACK, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
package me.tofaa.entitylib.meta.types;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.player.HumanoidArm;
|
||||
import com.github.retrooper.packetevents.util.Vector3i;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class LivingEntityMeta extends EntityMeta {
|
||||
public static final byte OFFSET = EntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 7;
|
||||
|
||||
private final static byte IS_HAND_ACTIVE_BIT = 0x01;
|
||||
private final static byte ACTIVE_HAND_BIT = 0x02;
|
||||
private final static byte IS_IN_SPIN_ATTACK_BIT = 0x04;
|
||||
|
||||
public LivingEntityMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
|
||||
public float getHealth() {
|
||||
return super.metadata.getIndex(offset(1), 1F);
|
||||
}
|
||||
|
||||
|
||||
public int getPotionEffectColor() {
|
||||
isVersionNewer(ServerVersion.V_1_9);
|
||||
return super.metadata.getIndex(offset(2), 0);
|
||||
}
|
||||
|
||||
public void setPotionEffectColor(int value) {
|
||||
isVersionNewer(ServerVersion.V_1_9);
|
||||
super.metadata.setIndex(offset(2), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public void setPotionEffectColor(int red, int green, int blue) {
|
||||
isVersionNewer(ServerVersion.V_1_9);
|
||||
setPotionEffectColor(red << 16 + green << 8 + blue);
|
||||
}
|
||||
|
||||
public boolean isPotionEffectAmbient() {
|
||||
isVersionNewer(ServerVersion.V_1_9);
|
||||
return super.metadata.getIndex(offset(3), false);
|
||||
}
|
||||
|
||||
public void setPotionEffectAmbient(boolean value) {
|
||||
isVersionNewer(ServerVersion.V_1_9);
|
||||
super.metadata.setIndex(offset(3), EntityDataTypes.BOOLEAN, value);
|
||||
}
|
||||
|
||||
public int getArrowCount() {
|
||||
isVersionNewer(ServerVersion.V_1_9);
|
||||
return super.metadata.getIndex(offset(4), 0);
|
||||
}
|
||||
|
||||
public void setArrowCount(int value) {
|
||||
isVersionNewer(ServerVersion.V_1_9);
|
||||
super.metadata.setIndex(offset(4), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public void setHealth(float value) {
|
||||
super.metadata.setIndex(offset(1), EntityDataTypes.FLOAT, value);
|
||||
}
|
||||
|
||||
public HumanoidArm getActiveHand() {
|
||||
isVersionNewer(ServerVersion.V_1_9);
|
||||
return getMaskBit(OFFSET, ACTIVE_HAND_BIT) ? HumanoidArm.LEFT : HumanoidArm.RIGHT;
|
||||
}
|
||||
|
||||
public void setActiveHand(HumanoidArm value) {
|
||||
isVersionNewer(ServerVersion.V_1_9);
|
||||
setMaskBit(OFFSET, ACTIVE_HAND_BIT, value == HumanoidArm.LEFT);
|
||||
}
|
||||
|
||||
public boolean isInRiptideSpinAttack() {
|
||||
isVersionNewer(ServerVersion.V_1_13);
|
||||
return getMaskBit(OFFSET, IS_IN_SPIN_ATTACK_BIT);
|
||||
}
|
||||
|
||||
public void setInRiptideSpinAttack(boolean value) {
|
||||
isVersionNewer(ServerVersion.V_1_13);
|
||||
setMaskBit(OFFSET, IS_IN_SPIN_ATTACK_BIT, value);
|
||||
}
|
||||
|
||||
public Optional<Vector3i> getBedPosition() {
|
||||
isVersionNewer(ServerVersion.V_1_14);
|
||||
return super.metadata.getIndex(offset(6), Optional.empty());
|
||||
}
|
||||
|
||||
public void setBedPosition(Vector3i value) {
|
||||
isVersionNewer(ServerVersion.V_1_14);
|
||||
super.metadata.setIndex(offset(6), EntityDataTypes.OPTIONAL_BLOCK_POSITION, value == null ? Optional.empty() : Optional.of(value));
|
||||
}
|
||||
|
||||
public int getBeeStingerCount() {
|
||||
isVersionNewer(ServerVersion.V_1_15);
|
||||
return super.metadata.getIndex(offset(5), 0);
|
||||
}
|
||||
|
||||
public void setBeeStingerCount(int value) {
|
||||
isVersionNewer(ServerVersion.V_1_15);
|
||||
super.metadata.setIndex(offset(5), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public boolean isHandActive() {
|
||||
isVersionNewer(ServerVersion.V_1_15);
|
||||
return getMaskBit(OFFSET, IS_HAND_ACTIVE_BIT);
|
||||
}
|
||||
|
||||
public void setHandActive(boolean value) {
|
||||
isVersionNewer(ServerVersion.V_1_15);
|
||||
setMaskBit(OFFSET, IS_HAND_ACTIVE_BIT, value);
|
||||
}
|
||||
|
||||
}
|
49
src/main/java/me/tofaa/entitylib/meta/types/MobMeta.java
Normal file
49
src/main/java/me/tofaa/entitylib/meta/types/MobMeta.java
Normal file
|
@ -0,0 +1,49 @@
|
|||
package me.tofaa.entitylib.meta.types;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
|
||||
public class MobMeta extends LivingEntityMeta {
|
||||
|
||||
public static final byte OFFSET = LivingEntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte NO_AI_BIT = 0x01;
|
||||
private final static byte IS_LEFT_HANDED_BIT = 0x02;
|
||||
private final static byte IS_AGGRESSIVE_BIT = 0x04;
|
||||
|
||||
|
||||
public MobMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public boolean isNoAi() {
|
||||
return getMaskBit(OFFSET, NO_AI_BIT);
|
||||
}
|
||||
|
||||
public void setNoAi(boolean value) {
|
||||
setMaskBit(OFFSET, NO_AI_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isLeftHanded() {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
return getMaskBit(OFFSET, IS_LEFT_HANDED_BIT);
|
||||
}
|
||||
|
||||
public void setLeftHanded(boolean value) {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
setMaskBit(OFFSET, IS_LEFT_HANDED_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isAggressive() {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_14);
|
||||
return getMaskBit(OFFSET, IS_AGGRESSIVE_BIT);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean value) {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_14);
|
||||
setMaskBit(OFFSET, IS_AGGRESSIVE_BIT, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package me.tofaa.entitylib.meta.types;
|
||||
|
||||
public interface ObjectData {
|
||||
|
||||
int getObjectData();
|
||||
|
||||
boolean requiresVelocityPacketAtSpawn();
|
||||
|
||||
}
|
148
src/main/java/me/tofaa/entitylib/meta/types/PlayerMeta.java
Normal file
148
src/main/java/me/tofaa/entitylib/meta/types/PlayerMeta.java
Normal file
|
@ -0,0 +1,148 @@
|
|||
package me.tofaa.entitylib.meta.types;
|
||||
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes;
|
||||
import com.github.retrooper.packetevents.protocol.nbt.NBTCompound;
|
||||
import me.tofaa.entitylib.EntityLib;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.Metadata;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class PlayerMeta extends LivingEntityMeta {
|
||||
|
||||
public static final byte OFFSET = LivingEntityMeta.MAX_OFFSET;
|
||||
public static final byte MAX_OFFSET = OFFSET + 1;
|
||||
|
||||
private final static byte CAPE_BIT = 0x01;
|
||||
private final static byte JACKET_BIT = 0x02;
|
||||
private final static byte LEFT_SLEEVE_BIT = 0x04;
|
||||
private final static byte RIGHT_SLEEVE_BIT = 0x08;
|
||||
private final static byte LEFT_LEG_BIT = 0x10;
|
||||
private final static byte RIGHT_LEG_BIT = 0x20;
|
||||
private final static byte HAT_BIT = 0x40;
|
||||
|
||||
public PlayerMeta(int entityId, Metadata metadata) {
|
||||
super(entityId, metadata);
|
||||
}
|
||||
|
||||
public float getAdditionalHearts() {
|
||||
return super.metadata.getIndex(OFFSET, 0F);
|
||||
}
|
||||
|
||||
public void setAdditionalHearts(float value) {
|
||||
super.metadata.setIndex(OFFSET, EntityDataTypes.FLOAT, value);
|
||||
}
|
||||
|
||||
public int getScore() {
|
||||
return super.metadata.getIndex(EntityMeta.offset(1), 0);
|
||||
}
|
||||
|
||||
public void setScore(int value) {
|
||||
super.metadata.setIndex(EntityMeta.offset(1), EntityDataTypes.INT, value);
|
||||
}
|
||||
|
||||
public boolean isCapeEnabled() {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
return getMaskBit(EntityMeta.offset(2), CAPE_BIT);
|
||||
}
|
||||
|
||||
public void setCapeEnabled(boolean value) {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
setMaskBit(EntityMeta.offset(2), CAPE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isJacketEnabled() {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
return getMaskBit(EntityMeta.offset(2), JACKET_BIT);
|
||||
}
|
||||
|
||||
public void setJacketEnabled(boolean value) {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
setMaskBit(EntityMeta.offset(2), JACKET_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isLeftSleeveEnabled() {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
return getMaskBit(EntityMeta.offset(2), LEFT_SLEEVE_BIT);
|
||||
}
|
||||
|
||||
public void setLeftSleeveEnabled(boolean value) {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
setMaskBit(EntityMeta.offset(2), LEFT_SLEEVE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRightSleeveEnabled() {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
return getMaskBit(EntityMeta.offset(2), RIGHT_SLEEVE_BIT);
|
||||
}
|
||||
|
||||
public void setRightSleeveEnabled(boolean value) {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
setMaskBit(EntityMeta.offset(2), RIGHT_SLEEVE_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isLeftLegEnabled() {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
return getMaskBit(EntityMeta.offset(2), LEFT_LEG_BIT);
|
||||
}
|
||||
|
||||
public void setLeftLegEnabled(boolean value) {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
setMaskBit(EntityMeta.offset(2), LEFT_LEG_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRightLegEnabled() {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
return getMaskBit(EntityMeta.offset(2), RIGHT_LEG_BIT);
|
||||
}
|
||||
|
||||
public void setRightLegEnabled(boolean value) {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
setMaskBit(EntityMeta.offset(2), RIGHT_LEG_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isHatEnabled() {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
return getMaskBit(EntityMeta.offset(2), HAT_BIT);
|
||||
}
|
||||
|
||||
public void setHatEnabled(boolean value) {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_9);
|
||||
setMaskBit(EntityMeta.offset(2), HAT_BIT, value);
|
||||
}
|
||||
|
||||
public boolean isRightHandMain() {
|
||||
if (EntityLib.getPacketEvents().getServerManager().getVersion().isOlderThan(ServerVersion.V_1_9)) {
|
||||
return true;
|
||||
}
|
||||
return super.metadata.getIndex(EntityMeta.offset(3), (byte) 1) == (byte) 1;
|
||||
}
|
||||
|
||||
public void setRightHandMain(boolean value) {
|
||||
if (EntityLib.getPacketEvents().getServerManager().getVersion().isOlderThan(ServerVersion.V_1_9)) {
|
||||
return;
|
||||
}
|
||||
super.metadata.setIndex(EntityMeta.offset(3), EntityDataTypes.BYTE, (byte) (value ? 1 : 0));
|
||||
}
|
||||
|
||||
public @Nullable NBTCompound getLeftShoulderData() {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_11);
|
||||
return super.metadata.getIndex(EntityMeta.offset(4), null);
|
||||
}
|
||||
|
||||
public void setLeftShoulderData(@Nullable NBTCompound value) {
|
||||
if (value == null) value = new NBTCompound();
|
||||
super.metadata.setIndex(EntityMeta.offset(4), EntityDataTypes.NBT, value);
|
||||
}
|
||||
|
||||
public @Nullable NBTCompound getRightShoulderData() {
|
||||
EntityMeta.isVersionNewer(ServerVersion.V_1_11);
|
||||
return super.metadata.getIndex(EntityMeta.offset(5), null);
|
||||
}
|
||||
|
||||
public void setRightShoulderData(@Nullable NBTCompound value) {
|
||||
if (value == null) value = new NBTCompound();
|
||||
super.metadata.setIndex(EntityMeta.offset(5), EntityDataTypes.NBT, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package me.tofaa.entitylib.meta.types;
|
||||
|
||||
|
||||
public interface ProjectileMeta {
|
||||
|
||||
int getShooter();
|
||||
|
||||
void setShooter(int entityId);
|
||||
|
||||
}
|
42
test-plugin/.gitignore
vendored
Normal file
42
test-plugin/.gitignore
vendored
Normal file
|
@ -0,0 +1,42 @@
|
|||
.gradle
|
||||
build/
|
||||
!gradle/wrapper/gradle-wrapper.jar
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
out/
|
||||
!**/src/main/**/out/
|
||||
!**/src/test/**/out/
|
||||
|
||||
### Eclipse ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
bin/
|
||||
!**/src/main/**/bin/
|
||||
!**/src/test/**/bin/
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
### Mac OS ###
|
||||
.DS_Store
|
30
test-plugin/build.gradle
Normal file
30
test-plugin/build.gradle
Normal file
|
@ -0,0 +1,30 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'com.github.johnrengelman.shadow' version '7.1.2'
|
||||
|
||||
}
|
||||
|
||||
group = 'me.tofaa.peentitymeta'
|
||||
version = '1.0-SNAPSHOT'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = 'papermc'
|
||||
url = 'https://repo.papermc.io/repository/maven-public/'
|
||||
}
|
||||
maven {
|
||||
name = 'codemc-repo'
|
||||
url = 'https://repo.codemc.io/repository/maven-releases/'
|
||||
}
|
||||
maven {
|
||||
url = "https://oss.sonatype.org/content/groups/public/"
|
||||
}
|
||||
maven { url = "https://repo.codemc.org/repository/maven-public/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly('org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT')
|
||||
compileOnly('com.github.retrooper.packetevents:spigot:2.0.2')
|
||||
implementation project(':')
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package me.tofaa.entitylib;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class EntityLibPlugin extends JavaPlugin {
|
||||
|
||||
static EntityLibPlugin instance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
EntityLib.init(PacketEvents.getAPI());
|
||||
getCommand("testapi").setExecutor(new TestCommand());
|
||||
instance = this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package me.tofaa.entitylib;
|
||||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.protocol.entity.type.EntityTypes;
|
||||
import com.github.retrooper.packetevents.util.Vector3d;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnEntity;
|
||||
import me.tofaa.entitylib.meta.EntityMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.PigMeta;
|
||||
import me.tofaa.entitylib.meta.mobs.SheepMeta;
|
||||
import me.tofaa.entitylib.meta.types.PlayerMeta;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class TestCommand implements CommandExecutor {
|
||||
|
||||
private int entityId = -1;
|
||||
private BukkitTask task;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) return false;
|
||||
Player player = (Player) sender;
|
||||
if (entityId == -1) {
|
||||
createEntity(player);
|
||||
}
|
||||
SheepMeta meta = EntityLib.getMeta(entityId, SheepMeta.class);
|
||||
if (task == null || task.isCancelled()) {
|
||||
this.task = Bukkit.getScheduler().runTaskTimer(EntityLibPlugin.instance, () -> {
|
||||
byte randomColor = (byte) (Math.random() * 15);
|
||||
meta.setColor(randomColor);
|
||||
meta.setSheared(!meta.isSheared());
|
||||
WrapperPlayServerEntityMetadata packet = meta.createPacket();
|
||||
packet.getEntityMetadata().forEach(s -> player.sendMessage(s.getValue().toString()));
|
||||
PacketEvents.getAPI().getPlayerManager().getUser(player).sendPacket(packet);
|
||||
player.sendMessage("Color is now " + meta.getColor() + " (" + randomColor + ")");
|
||||
}, 0L, 4L);
|
||||
}
|
||||
else {
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void createEntity(Player player) {
|
||||
entityId = (int) (Math.random() * 99999);
|
||||
Optional<UUID> uuid = Optional.of(UUID.randomUUID());
|
||||
Optional<Vector3d> velocity = Optional.empty();
|
||||
WrapperPlayServerSpawnEntity packet = new WrapperPlayServerSpawnEntity(
|
||||
entityId,
|
||||
uuid,
|
||||
EntityTypes.SHEEP,
|
||||
new Vector3d(player.getLocation().getX(), player.getLocation().getY(), player.getLocation().getZ()),
|
||||
player.getLocation().getPitch(),
|
||||
player.getLocation().getYaw(),
|
||||
90,
|
||||
0,
|
||||
velocity
|
||||
);
|
||||
PacketEvents.getAPI().getPlayerManager().getUser(player).sendPacket(packet);
|
||||
EntityMeta meta = EntityLib.createMeta(entityId, EntityTypes.SHEEP);
|
||||
player.sendMessage("Meta class is " + meta.getClass().getSimpleName());
|
||||
}
|
||||
}
|
9
test-plugin/src/main/resources/plugin.yml
Normal file
9
test-plugin/src/main/resources/plugin.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
name: EntityLibPlugin
|
||||
version: 1.0.0
|
||||
depend:
|
||||
- packetevents
|
||||
main: me.tofaa.entitylib.EntityLibPlugin
|
||||
commands:
|
||||
testapi:
|
||||
description: Test PEEntityMeta API
|
||||
usage: /<command>
|
Loading…
Reference in a new issue