First ever plugin I made (/Welcome)
This commit is contained in:
44
README.md
44
README.md
@@ -1,22 +1,22 @@
|
|||||||
# ExamplePluginTemplate
|
# ExamplePluginTemplate
|
||||||
An example plugin template for beginners!
|
An example plugin template for beginners!
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|
||||||
Trying to create your first plugin? Use this template to get started easily!
|
Trying to create your first plugin? Use this template to get started easily!
|
||||||
|
|
||||||
- Comments to guide you
|
- Comments to guide you
|
||||||
- Made some example classes
|
- Made some example classes
|
||||||
- Added some useful utils
|
- Added some useful utils
|
||||||
|
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
|
|
||||||
Download this template -\> Load it into your IDE or development environment. [Check out IntelliJ](https://www.jetbrains.com/idea/download/?fromIDE=#section=windows) -\> Get Creative!
|
Download this template -\> Load it into your IDE or development environment. [Check out IntelliJ](https://www.jetbrains.com/idea/download/?fromIDE=#section=windows) -\> Get Creative!
|
||||||
|
|
||||||
- To build your jar file simply go into the terminal and run `./gradlew build`
|
- To build your jar file simply go into the terminal and run `./gradlew build`
|
||||||
- Your finished jar should appear in `build/libs`!
|
- Your finished jar should appear in `build/libs`!
|
||||||
|
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|
||||||
Have a nice day, happy coding!
|
Have a nice day, happy coding!
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'io.github.itzispyder'
|
group = 'io.github.itzispyder'
|
||||||
version = '(YourPluginVersion)'
|
version = ''
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
10
gradle/wrapper/gradle-wrapper.properties
vendored
10
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
468
gradlew
vendored
468
gradlew
vendored
@@ -1,234 +1,234 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright © 2015-2021 the original authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
# You may obtain a copy of the License at
|
# You may obtain a copy of the License at
|
||||||
#
|
#
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
# https://www.apache.org/licenses/LICENSE-2.0
|
||||||
#
|
#
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
#
|
#
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
# Gradle start up script for POSIX generated by Gradle.
|
||||||
#
|
#
|
||||||
# Important for running:
|
# Important for running:
|
||||||
#
|
#
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
# (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
|
# 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
|
# bash, then to run this script, type that shell name before the whole
|
||||||
# command line, like:
|
# command line, like:
|
||||||
#
|
#
|
||||||
# ksh Gradle
|
# ksh Gradle
|
||||||
#
|
#
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
# Busybox and similar reduced shells will NOT work, because this script
|
||||||
# requires all of these POSIX shell features:
|
# requires all of these POSIX shell features:
|
||||||
# * functions;
|
# * functions;
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
# * compound commands having a testable exit status, especially «case»;
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
# * various built-in commands including «command», «set», and «ulimit».
|
||||||
#
|
#
|
||||||
# Important for patching:
|
# Important for patching:
|
||||||
#
|
#
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
# by Bash, Ksh, etc; in particular arrays are avoided.
|
||||||
#
|
#
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
# The "traditional" practice of packing multiple parameters into a
|
||||||
# space-separated string is a well documented source of bugs and security
|
# space-separated string is a well documented source of bugs and security
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
# problems, so this is (mostly) avoided, by progressively accumulating
|
||||||
# options in "$@", and eventually passing that to Java.
|
# options in "$@", and eventually passing that to Java.
|
||||||
#
|
#
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
||||||
# see the in-line comments for details.
|
# see the in-line comments for details.
|
||||||
#
|
#
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
# There are tweaks for specific operating systems such as AIX, CygWin,
|
||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (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
|
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
app_path=$0
|
app_path=$0
|
||||||
|
|
||||||
# Need this for daisy-chained symlinks.
|
# Need this for daisy-chained symlinks.
|
||||||
while
|
while
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
[ -h "$app_path" ]
|
[ -h "$app_path" ]
|
||||||
do
|
do
|
||||||
ls=$( ls -ld "$app_path" )
|
ls=$( ls -ld "$app_path" )
|
||||||
link=${ls#*' -> '}
|
link=${ls#*' -> '}
|
||||||
case $link in #(
|
case $link in #(
|
||||||
/*) app_path=$link ;; #(
|
/*) app_path=$link ;; #(
|
||||||
*) app_path=$APP_HOME$link ;;
|
*) app_path=$APP_HOME$link ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
APP_NAME="Gradle"
|
||||||
APP_BASE_NAME=${0##*/}
|
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.
|
# 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"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
} >&2
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
} >&2
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "$( uname )" in #(
|
case "$( uname )" in #(
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
Darwin* ) darwin=true ;; #(
|
Darwin* ) darwin=true ;; #(
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD=java
|
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.
|
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
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
# * args from the command line
|
# * args from the command line
|
||||||
# * the main class name
|
# * the main class name
|
||||||
# * -classpath
|
# * -classpath
|
||||||
# * -D...appname settings
|
# * -D...appname settings
|
||||||
# * --module-path (only if needed)
|
# * --module-path (only if needed)
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
if "$cygwin" || "$msys" ; then
|
if "$cygwin" || "$msys" ; then
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
||||||
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
for arg do
|
for arg do
|
||||||
if
|
if
|
||||||
case $arg in #(
|
case $arg in #(
|
||||||
-*) false ;; # don't mess with options #(
|
-*) false ;; # don't mess with options #(
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
||||||
[ -e "$t" ] ;; #(
|
[ -e "$t" ] ;; #(
|
||||||
*) false ;;
|
*) false ;;
|
||||||
esac
|
esac
|
||||||
then
|
then
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
arg=$( cygpath --path --ignore --mixed "$arg" )
|
||||||
fi
|
fi
|
||||||
# Roll the args list around exactly as many times as the number of
|
# 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
|
# args, so each arg winds up back in the position where it started, but
|
||||||
# possibly modified.
|
# possibly modified.
|
||||||
#
|
#
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
# NB: a `for` loop captures its iteration list before it begins, so
|
||||||
# changing the positional parameters here affects neither the number of
|
# changing the positional parameters here affects neither the number of
|
||||||
# iterations, nor the values presented in `arg`.
|
# iterations, nor the values presented in `arg`.
|
||||||
shift # remove old arg
|
shift # remove old arg
|
||||||
set -- "$@" "$arg" # push replacement arg
|
set -- "$@" "$arg" # push replacement arg
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Collect all arguments for the java command;
|
# Collect all arguments for the java command;
|
||||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||||
# shell script including quotes and variable substitutions, so put them in
|
# shell script including quotes and variable substitutions, so put them in
|
||||||
# double quotes to make sure that they get re-expanded; and
|
# double quotes to make sure that they get re-expanded; and
|
||||||
# * put everything else in single quotes, so that it's not re-expanded.
|
# * put everything else in single quotes, so that it's not re-expanded.
|
||||||
|
|
||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
-classpath "$CLASSPATH" \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
org.gradle.wrapper.GradleWrapperMain \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
#
|
#
|
||||||
# In Bash we could simply go:
|
# In Bash we could simply go:
|
||||||
#
|
#
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
||||||
# set -- "${ARGS[@]}" "$@"
|
# set -- "${ARGS[@]}" "$@"
|
||||||
#
|
#
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
# 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
|
# 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
|
# character that might be a shell metacharacter, then use eval to reverse
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
# that process (while maintaining the separation between arguments), and wrap
|
||||||
# the whole thing up as a single "set" statement.
|
# the whole thing up as a single "set" statement.
|
||||||
#
|
#
|
||||||
# This will of course break if any of these variables contains a newline or
|
# This will of course break if any of these variables contains a newline or
|
||||||
# an unmatched quote.
|
# an unmatched quote.
|
||||||
#
|
#
|
||||||
|
|
||||||
eval "set -- $(
|
eval "set -- $(
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
||||||
xargs -n1 |
|
xargs -n1 |
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
||||||
tr '\n' ' '
|
tr '\n' ' '
|
||||||
)" '"$@"'
|
)" '"$@"'
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
rootProject.name = 'ExamplePlugin'
|
rootProject.name = 'ExamplePlugin'
|
||||||
|
|||||||
@@ -1,66 +1,67 @@
|
|||||||
/**
|
/**
|
||||||
* This file is for tutorial purposes made by ImproperIssues. Distribute if you want :)
|
* This file is for tutorial purposes made by ImproperIssues. Distribute if you want :)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package io.github.itzispyder.exampleplugin;
|
package io.github.itzispyder.exampleplugin;
|
||||||
|
|
||||||
import io.github.itzispyder.exampleplugin.commands.CommandExample;
|
import io.github.itzispyder.exampleplugin.commands.CommandExample;
|
||||||
import io.github.itzispyder.exampleplugin.data.Config;
|
import io.github.itzispyder.exampleplugin.data.Config;
|
||||||
import io.github.itzispyder.exampleplugin.events.ExampleEvent;
|
import io.github.itzispyder.exampleplugin.events.ExampleEvent;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is your main class, you register everything important here.
|
* This is your main class, you register everything important here.
|
||||||
*
|
*
|
||||||
* To build the jar, go to terminal and run "./gradlew build"
|
* To build the jar, go to terminal and run "./gradlew build"
|
||||||
*/
|
*/
|
||||||
public final class ExamplePlugin extends JavaPlugin {
|
public final class ExamplePlugin extends JavaPlugin {
|
||||||
|
|
||||||
public static final PluginManager manager = Bukkit.getPluginManager();
|
public static final PluginManager manager = Bukkit.getPluginManager();
|
||||||
public static String starter = "";
|
public static String starter = "";
|
||||||
public static final Logger log = Bukkit.getLogger();
|
public static final Logger log = Bukkit.getLogger();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin startup logic
|
* Plugin startup logic
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Plugin startup logic
|
// Files
|
||||||
log.info("Example plugin has loaded! (" + getDescription().getVersion() + ")");
|
getConfig().options().copyDefaults();
|
||||||
starter = Config.Plugin.getPrefix() + " ";
|
saveDefaultConfig();
|
||||||
|
// Plugin startup logic
|
||||||
// Files
|
log.info("Example plugin has loaded! (" + getDescription().getVersion() + ")");
|
||||||
getConfig().options().copyDefaults();
|
starter = Config.Plugin.getPrefix() + " ";
|
||||||
saveDefaultConfig();
|
|
||||||
|
|
||||||
// Commands -> BE SURE TO REGISTER ANY NEW COMMANDS IN PLUGIN.YML (src/main/java/resources/plugin.yml)!
|
|
||||||
getCommand("example").setExecutor(new CommandExample());
|
// Commands -> BE SURE TO REGISTER ANY NEW COMMANDS IN PLUGIN.YML (src/main/java/resources/plugin.yml)!
|
||||||
getCommand("example").setTabCompleter(new CommandExample.Tabs());
|
getCommand("welcome").setExecutor(new CommandExample());
|
||||||
|
getCommand("welcome").setTabCompleter(new CommandExample.Tabs());
|
||||||
// Events
|
|
||||||
manager.registerEvents(new ExampleEvent(),this);
|
// Events
|
||||||
|
manager.registerEvents(new ExampleEvent(),this);
|
||||||
}
|
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Plugin shutdown logic
|
/**
|
||||||
*/
|
* Plugin shutdown logic
|
||||||
@Override
|
*/
|
||||||
public void onDisable() {
|
@Override
|
||||||
// Plugin shutdown logic
|
public void onDisable() {
|
||||||
log.info("Example plugin has disabled! (" + getDescription().getVersion() + ")");
|
// Plugin shutdown logic
|
||||||
}
|
log.info("Example plugin has disabled! (" + getDescription().getVersion() + ")");
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Returns an instance of this plugin
|
/**
|
||||||
* @return an instance of this plugin
|
* Returns an instance of this plugin
|
||||||
*/
|
* @return an instance of this plugin
|
||||||
public static Plugin getInstance() {
|
*/
|
||||||
return manager.getPlugin("ExamplePlugin");
|
public static Plugin getInstance() {
|
||||||
}
|
return manager.getPlugin("SlashWelcome");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,11 +4,15 @@
|
|||||||
|
|
||||||
package io.github.itzispyder.exampleplugin.commands;
|
package io.github.itzispyder.exampleplugin.commands;
|
||||||
|
|
||||||
|
import io.github.itzispyder.exampleplugin.ExamplePlugin;
|
||||||
import io.github.itzispyder.exampleplugin.exceptions.CmdExHandler;
|
import io.github.itzispyder.exampleplugin.exceptions.CmdExHandler;
|
||||||
|
import io.github.itzispyder.exampleplugin.server.util.ServerUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabCompleter;
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -21,7 +25,15 @@ public class CommandExample implements CommandExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
try {
|
try {
|
||||||
sender.sendMessage("You've execute an example command!");
|
Player P = (Player) sender;
|
||||||
|
Player W = Bukkit.getPlayer(args[0]);
|
||||||
|
for (int i = 0; i < 1; i++) {
|
||||||
|
P.chat("§bWelcome " + W.getName() + "!");
|
||||||
|
Bukkit.getScheduler().scheduleSyncDelayedTask(ExamplePlugin.getInstance(),() -> {
|
||||||
|
P.chat("§bDo /daily for a key and /kit for some free gear!");
|
||||||
|
}, 20);
|
||||||
|
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
CmdExHandler handler = new CmdExHandler(ex,command);
|
CmdExHandler handler = new CmdExHandler(ex,command);
|
||||||
@@ -39,7 +51,7 @@ public class CommandExample implements CommandExecutor {
|
|||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1 -> list.add("test");
|
case 1 -> list.addAll(ServerUtils.listPlayers());
|
||||||
}
|
}
|
||||||
list.removeIf(s -> !s.toLowerCase().contains(args[args.length - 1].toLowerCase()));
|
list.removeIf(s -> !s.toLowerCase().contains(args[args.length - 1].toLowerCase()));
|
||||||
return list;
|
return list;
|
||||||
|
|||||||
@@ -1,17 +1,16 @@
|
|||||||
name: ExamplePlugin
|
name: SlashWelcome
|
||||||
version: '${version}'
|
version: '${version}'
|
||||||
main: io.github.itzispyder.exampleplugin.ExamplePlugin
|
main: io.github.itzispyder.exampleplugin.ExamplePlugin
|
||||||
api-version: 1.17
|
api-version: 1.17
|
||||||
authors: [ YourNameHere ]
|
authors: [ TheTrouper ]
|
||||||
description: An example plugin template for Spigot/Paper.
|
description: An example plugin template for Spigot/Paper.
|
||||||
website: https://ItziSpyder.github.io/
|
website: https://ItziSpyder.github.io/
|
||||||
permissions:
|
permissions:
|
||||||
example.commands:
|
example.commands:
|
||||||
description: An example permission
|
description: An example permission
|
||||||
default: op
|
default: op
|
||||||
commands:
|
commands:
|
||||||
example:
|
welcome:
|
||||||
description: An example command.
|
description: An example command.
|
||||||
usage: /example
|
usage: /example
|
||||||
permission: example.commands
|
|
||||||
permission-message: You do not have permission!
|
permission-message: You do not have permission!
|
||||||
Reference in New Issue
Block a user