commit c3bce35dc42abb59af57e63fa6982fca53e0b7a9 Author: TheTrouper <93684527+thetrouper@users.noreply.github.com> Date: Thu Mar 28 15:57:36 2024 -0500 Added lots o commands diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b63da45 --- /dev/null +++ b/.gitignore @@ -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 \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/discord.xml b/.idea/discord.xml new file mode 100644 index 0000000..30bab2a --- /dev/null +++ b/.idea/discord.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..2a65317 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,17 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..53589ce --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..2b63946 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..522e9ee --- /dev/null +++ b/build.gradle @@ -0,0 +1,76 @@ +plugins { + id 'java' +} + +group = project.group +version = project.version + +jar { + from { + duplicatesStrategy = DuplicatesStrategy.EXCLUDE + configurations.runtimeClasspath.collect { + it.isDirectory() ? it : zipTree(it) + } + } +} + +repositories { + mavenCentral() + maven { + name = 'spigotmc-repo' + url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' + } + maven { + url = uri("https://repo.papermc.io/repository/maven-public/") + } + maven { + name = 'sonatype' + url = 'https://oss.sonatype.org/content/groups/public/' + } +} + +dependencies { + compileOnly 'io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT' + implementation 'com.google.code.gson:gson:2.10.1' + implementation files("libs/PDK-1.3.4.jar") +} + +def targetJavaVersion = 17 +java { + def javaVersion = JavaVersion.toVersion(targetJavaVersion) + sourceCompatibility = javaVersion + targetCompatibility = javaVersion + toolchain.languageVersion.set(JavaLanguageVersion.of(17)) + if (JavaVersion.current() < javaVersion) { + toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) + } +} + +tasks.withType(JavaCompile).configureEach { + if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { + options.release = targetJavaVersion + } +} + +tasks.register('copyDeps', Copy) { + from configurations.runtimeClasspath + into 'build/deps' + include '*.jar' +} + + +processResources { + def props = [version: version] + inputs.properties props + filteringCharset 'UTF-8' + filesMatching('plugin.yml') { + expand props + } +} + +compileJava.options.encoding("UTF-8") + +tasks.withType(JavaCompile) { + options.encoding = "UTF-8" +} + diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..9317c2b --- /dev/null +++ b/gradle.properties @@ -0,0 +1,8 @@ + +# Plugin +group = 'me.trouper' +version = 0.0.1 + +# Minecraft +mc_version = 1.20.4 + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..249e583 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..2968ed2 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Mar 22 10:18:19 CDT 2024 +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 diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..1b6c787 --- /dev/null +++ b/gradlew @@ -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" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -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 diff --git a/libs/PDK-1.3.4.jar b/libs/PDK-1.3.4.jar new file mode 100644 index 0000000..e949bf1 Binary files /dev/null and b/libs/PDK-1.3.4.jar differ diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..816233a --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'UltraUtils' + diff --git a/src/main/java/functions/Text.java b/src/main/java/functions/Text.java new file mode 100644 index 0000000..9dba901 --- /dev/null +++ b/src/main/java/functions/Text.java @@ -0,0 +1,85 @@ +package functions; + + +import me.trouper.ultrautils.UltraUtils; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class Text { + + public static String regexHighlighter(String input, String regex, String startString, String endString) { + Pattern pattern = Pattern.compile(regex); + + Matcher matcher = pattern.matcher(input); + + StringBuffer result = new StringBuffer(); + + while (matcher.find()) { + matcher.appendReplacement(result, startString + matcher.group() + endString); + } + + matcher.appendTail(result); + + return result.toString(); + } + + public static final char SECTION_SYMBOL = (char)167; + + public static String color(String msg) { + return msg.replace('&', SECTION_SYMBOL); + } + public static String prefix(String text) { + String prefix = UltraUtils.config.prefix; + return color(prefix + text); + } + public static String removeFirstColor(String input) { + if (input.startsWith("\u00a7")) { + if (input.length() > 2) { + return input.substring(2); + } else { + return ""; + } + } else { + return input; + } + } + public static String replaceRepeatingLetters(String input) { + if (input == null || input.isEmpty()) { + return input; + } + + StringBuilder simplifiedText = new StringBuilder(); + char currentChar = input.charAt(0); + int count = 1; + + for (int i = 1; i < input.length(); i++) { + char nextChar = input.charAt(i); + + if (Character.toLowerCase(nextChar) == Character.toLowerCase(currentChar)) { + count++; + } else { + simplifiedText.append(currentChar); + + if (count > 1) { + simplifiedText.append(currentChar); + } + + currentChar = nextChar; + count = 1; + } + } + + simplifiedText.append(currentChar); + + if (count > 1) { + simplifiedText.append(currentChar); + } + + return simplifiedText.toString(); + } + + public static String cleanName(String type) { + return type.replaceAll("_"," ").toLowerCase(); + } +} diff --git a/src/main/java/me/trouper/ultrautils/UltraUtils.java b/src/main/java/me/trouper/ultrautils/UltraUtils.java new file mode 100644 index 0000000..75d7295 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/UltraUtils.java @@ -0,0 +1,95 @@ +package me.trouper.ultrautils; + +import io.github.itzispyder.pdk.PDK; +import io.github.itzispyder.pdk.utils.misc.JsonSerializable; +import me.trouper.ultrautils.commands.UltraUtilsCommand; +import me.trouper.ultrautils.commands.gamemode.*; +import me.trouper.ultrautils.commands.mobility.FlyCommand; +import me.trouper.ultrautils.commands.mobility.SpeedCommand; +import me.trouper.ultrautils.commands.workstations.*; +import me.trouper.ultrautils.data.config.Config; +import org.bukkit.Bukkit; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.File; +import java.util.logging.Logger; + +public final class UltraUtils extends JavaPlugin { + + private static UltraUtils instance; + private static final File configFile = new File("plugins/UltraUtils/main-config.json"); + public static Config config = JsonSerializable.load(configFile, Config.class, new Config()); + public static final Logger log = Bukkit.getLogger(); + + /** + * Plugin startup logic + */ + @Override + public void onEnable() { + + log.info("\n]======------ Pre-load started ------======["); + PDK.init(this); + instance = this; + + loadConfig(); + + startup(); + } + + public void startup() { + log.info("\n]======----- Loading UltraUtils-----======["); + + // Plugin startup logic + log.info("Starting Up! (%s)...".formatted(getDescription().getVersion())); + + + new UltraUtilsCommand().register(); + new GamemodeCommand().register(); + new GMACommand().register(); + new GMCCommand().register(); + new GMSPCommand().register(); + new GMSCommand().register(); + new AnvilCommand().register(); + new CartographyCommand().register(); + new CraftingCommand().register(); + new GrindstoneCommand().register(); + new LoomCommand().register(); + new SmithingCommand().register(); + new StonecutterCommand().register(); + new FlyCommand().register(); + new SpeedCommand().register(); + + // Events + + log.info(""" + Finished! + UltraUtils has loaded. + """); + } + + public void loadConfig() { + log.info("Loading Config..."); + + // Init + config = JsonSerializable.load(configFile, Config.class,new Config()); + + // Save + config.save(); + + } + + + /** + * Plugin shutdown logic + */ + @Override + public void onDisable() { + // Plugin shutdown logic + log.info("UltraUtils has disabled! (%s)".formatted(getDescription().getVersion())); + } + + public static UltraUtils getInstance() { + return instance; + } + +} diff --git a/src/main/java/me/trouper/ultrautils/commands/UltraUtilsCommand.java b/src/main/java/me/trouper/ultrautils/commands/UltraUtilsCommand.java new file mode 100644 index 0000000..b1b1bc6 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/UltraUtilsCommand.java @@ -0,0 +1,37 @@ +package me.trouper.ultrautils.commands; + +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import me.trouper.ultrautils.UltraUtils; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandRegistry(value = "ultrautils", permission = @Permission("ultrautils.admin"), printStackTrace = true) +public class UltraUtilsCommand implements CustomCommand { + + @Override + public void dispatchCommand(CommandSender sender, Args args) { + Player p = (Player) sender; + + switch (args.get(0).toString()) { + case "toggle" -> { + switch (args.get(1).toString()) { + case "debug" -> { + UltraUtils.config.debugMode = !UltraUtils.config.debugMode; + UltraUtils.config.save(); + } + } + } + } + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + b.then(b.arg("toggle") + .then(b.arg("debug")) + ); + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/gamemode/GMACommand.java b/src/main/java/me/trouper/ultrautils/commands/gamemode/GMACommand.java new file mode 100644 index 0000000..3bafb1b --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/gamemode/GMACommand.java @@ -0,0 +1,44 @@ +package me.trouper.ultrautils.commands.gamemode; + +import functions.Text; +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import io.github.itzispyder.pdk.utils.ServerUtils; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +@CommandRegistry(value = "gma",permission = @Permission("ultrautils.gamemode.adventure")) +public class GMACommand implements CustomCommand { + + @Override + public void dispatchCommand(CommandSender commandSender, Args args) { + Player target = Bukkit.getPlayer(args.get(0).toString()); + if (target == null && (commandSender instanceof Player)) target = (Player) commandSender; + if (target == null) { + commandSender.sendMessage(Text.prefix("Only players may execute that command")); + return; + } + if (!commandSender.hasPermission("ultrautils.gamemode")) { + commandSender.sendMessage(Text.prefix("You do not have the root permission to change gamemode.")); + return; + } + GamemodeCommand.setGameMode(commandSender,target,GameMode.ADVENTURE,"ultrautils.gamemode.adventure"); + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + List players = new ArrayList<>(); + for (Player player : ServerUtils.players()) { + players.add(player.getName()); + } + b.then(b.arg(players)); + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/gamemode/GMCCommand.java b/src/main/java/me/trouper/ultrautils/commands/gamemode/GMCCommand.java new file mode 100644 index 0000000..ee33afc --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/gamemode/GMCCommand.java @@ -0,0 +1,43 @@ +package me.trouper.ultrautils.commands.gamemode; + +import functions.Text; +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import io.github.itzispyder.pdk.utils.ServerUtils; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +@CommandRegistry(value = "gmc",permission = @Permission("ultrautils.gamemode.creative")) +public class GMCCommand implements CustomCommand { + + @Override + public void dispatchCommand(CommandSender commandSender, Args args) { + Player target = Bukkit.getPlayer(args.get(0).toString()); + if (target == null && (commandSender instanceof Player)) target = (Player) commandSender; + if (target == null) { + commandSender.sendMessage(Text.prefix("Only players may execute that command")); + return; + } + if (!commandSender.hasPermission("ultrautils.gamemode")) { + commandSender.sendMessage(Text.prefix("You do not have the root permission to change gamemode.")); + return; + } + GamemodeCommand.setGameMode(commandSender,target,GameMode.CREATIVE,"ultrautils.gamemode.creative");} + + @Override + public void dispatchCompletions(CompletionBuilder b) { + List players = new ArrayList<>(); + for (Player player : ServerUtils.players()) { + players.add(player.getName()); + } + b.then(b.arg(players)); + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/gamemode/GMSCommand.java b/src/main/java/me/trouper/ultrautils/commands/gamemode/GMSCommand.java new file mode 100644 index 0000000..02b67d7 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/gamemode/GMSCommand.java @@ -0,0 +1,43 @@ +package me.trouper.ultrautils.commands.gamemode; + +import functions.Text; +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import io.github.itzispyder.pdk.utils.ServerUtils; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +@CommandRegistry(value = "gms",permission = @Permission("ultrautils.gamemode.survival")) +public class GMSCommand implements CustomCommand { + + @Override + public void dispatchCommand(CommandSender commandSender, Args args) { + Player target = Bukkit.getPlayer(args.get(0).toString()); + if (target == null && (commandSender instanceof Player)) target = (Player) commandSender; + if (target == null) { + commandSender.sendMessage(Text.prefix("Only players may execute that command")); + return; + } + if (!commandSender.hasPermission("ultrautils.gamemode")) { + commandSender.sendMessage(Text.prefix("You do not have the root permission to change gamemode.")); + return; + } + GamemodeCommand.setGameMode(commandSender,target,GameMode.SURVIVAL,"ultrautils.gamemode.survival");} + + @Override + public void dispatchCompletions(CompletionBuilder b) { + List players = new ArrayList<>(); + for (Player player : ServerUtils.players()) { + players.add(player.getName()); + } + b.then(b.arg(players)); + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/gamemode/GMSPCommand.java b/src/main/java/me/trouper/ultrautils/commands/gamemode/GMSPCommand.java new file mode 100644 index 0000000..ed53e78 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/gamemode/GMSPCommand.java @@ -0,0 +1,44 @@ +package me.trouper.ultrautils.commands.gamemode; + +import functions.Text; +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import io.github.itzispyder.pdk.utils.ServerUtils; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +@CommandRegistry(value = "gmc",permission = @Permission("ultrautils.gamemode.spectator")) +public class GMSPCommand implements CustomCommand { + + @Override + public void dispatchCommand(CommandSender commandSender, Args args) { + Player target = Bukkit.getPlayer(args.get(0).toString()); + if (target == null && (commandSender instanceof Player)) target = (Player) commandSender; + if (target == null) { + commandSender.sendMessage(Text.prefix("Only players may execute that command")); + return; + } + if (!commandSender.hasPermission("ultrautils.gamemode")) { + commandSender.sendMessage(Text.prefix("You do not have the root permission to change gamemode.")); + return; + } + GamemodeCommand.setGameMode(commandSender,target,GameMode.SPECTATOR,"ultrautils.gamemode.spectator"); + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + List players = new ArrayList<>(); + for (Player player : ServerUtils.players()) { + players.add(player.getName()); + } + b.then(b.arg(players)); + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/gamemode/GamemodeCommand.java b/src/main/java/me/trouper/ultrautils/commands/gamemode/GamemodeCommand.java new file mode 100644 index 0000000..ea8265b --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/gamemode/GamemodeCommand.java @@ -0,0 +1,72 @@ +package me.trouper.ultrautils.commands.gamemode; + +import functions.Text; +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import io.github.itzispyder.pdk.utils.ServerUtils; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.List; + +@CommandRegistry(value = "gamemode", permission = @Permission("ultrautils.gamemode")) +public class GamemodeCommand implements CustomCommand { + + @Override + public void dispatchCommand(CommandSender sender, Args args) { + Player target = Bukkit.getPlayer(args.get(1).toString()); + if (target == null && (sender instanceof Player)) target = (Player) sender; + if (target == null) { + sender.sendMessage(Text.prefix("Only players may execute that command")); + return; + } + switch (args.get(0).toString()) { + case "a","adventure","adv","gma" -> setGameMode(sender,target,GameMode.ADVENTURE, "ultrautils.gamemode.adventure"); + case "c","creative","cre","gmc" -> setGameMode(sender,target,GameMode.CREATIVE,"ultrautils.gamemode.creative"); + case "s","survival","sur","gms" -> setGameMode(sender,target,GameMode.SURVIVAL,"ultrautils.gamemode.survival"); + case "sp","spectator","spec","gmsp" -> setGameMode(sender,target,GameMode.SPECTATOR,"ultrautils.gamemode.spectator"); + } + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + List players = new ArrayList<>(); + for (Player player : ServerUtils.players()) { + players.add(player.getName()); + } + b.then(b.arg("adventure","creative","survival","spectator") + .then(b.arg(players)) + ); + } + + public static void setGameMode(CommandSender user, @Nullable Player target, GameMode gm, String permission) { + if (!user.hasPermission(permission)) { + user.sendMessage(Text.prefix("You lack the permission to swith gamemodes to %c%s&7.")); + return; + } + + if (target == null && user instanceof Player) target = (Player) user; + if (target == null) { + user.sendMessage(Text.prefix("Only players can execute self-effecting commands.")); + return; + } + + if (user.equals(target)) { + target.setGameMode(gm); + user.sendMessage(Text.prefix("Set your gamemode to &a%s&7.".formatted(target.getGameMode().toString().toLowerCase()))); + } else if (user.hasPermission("ultrautils.gamemode.others")) { + target.setGameMode(gm); + user.sendMessage(Text.prefix("Set the gamemode of &e%s&7 to &a%s&7.".formatted(target.getName(),target.getGameMode().toString().toLowerCase()))); + target.sendMessage(Text.prefix("Your gamemode has been set to &a%s&7.".formatted(target.getGameMode().toString().toLowerCase()))); + } else { + user.sendMessage(Text.prefix("You lack the permission to set other player's gamemode.")); + } + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/mobility/FlyCommand.java b/src/main/java/me/trouper/ultrautils/commands/mobility/FlyCommand.java new file mode 100644 index 0000000..f1ef3c4 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/mobility/FlyCommand.java @@ -0,0 +1,51 @@ +package me.trouper.ultrautils.commands.mobility; + +import functions.Text; +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import io.github.itzispyder.pdk.utils.ServerUtils; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +@CommandRegistry(value = "fly", permission = @Permission("ultrautils.flight")) +public class FlyCommand implements CustomCommand { + @Override + public void dispatchCommand(CommandSender sender, Args args) { + Player user = (Player) sender; + Player target = Bukkit.getPlayer(args.get(1).toString()); + if (target == null && (sender instanceof Player)) target = (Player) sender; + if (target == null) { + sender.sendMessage(Text.prefix("Only players may execute that command")); + return; + } + + boolean current = target.getAllowFlight(); + if (user.equals(target)) { + target.setAllowFlight(!current); + sender.sendMessage(Text.prefix("Flight &a%s&7.".formatted(!current ? "&aenabled" : "&cdisabled"))); + } else if (sender.hasPermission("ultrautils.flight.others")) { + target.setAllowFlight(!current); + sender.sendMessage(Text.prefix("&a%s&7 the flight of &e%s&7.".formatted(!current ? "&aenabled" : "&cdisabled",target.getName()))); + target.sendMessage(Text.prefix("Your flight has been &a%s&7.".formatted(!current ? "&aenabled" : "&cdisabled"))); + } else { + sender.sendMessage(Text.prefix("You lack the permission to set other player's flight status.")); + } + + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + List players = new ArrayList<>(); + for (Player player : ServerUtils.players()) { + players.add(player.getName()); + } + b.then(b.arg(players)); + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/mobility/SpeedCommand.java b/src/main/java/me/trouper/ultrautils/commands/mobility/SpeedCommand.java new file mode 100644 index 0000000..5d2ae89 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/mobility/SpeedCommand.java @@ -0,0 +1,96 @@ +package me.trouper.ultrautils.commands.mobility; + +import functions.Text; +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import io.github.itzispyder.pdk.utils.ServerUtils; +import me.trouper.ultrautils.UltraUtils; +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import java.util.ArrayList; +import java.util.List; + +@CommandRegistry(value = "speed", permission = @Permission("ultrautils.speed")) +public class SpeedCommand implements CustomCommand { + @Override + public void dispatchCommand(CommandSender sender, Args args) { + String type = args.get(1).toString(); + float speed = args.get(0).toFloat(); + Player user = (Player) sender; + Player target = Bukkit.getPlayer(args.get(2).toString()); + if (target == null && (sender instanceof Player)) target = (Player) sender; + if (target == null) { + sender.sendMessage(Text.prefix("Only players may execute that command")); + return; + } + + switch (type) { + case "walk" -> { + setWalkSpeed(sender,user,target,speed); + } + case "flight" -> { + setFlySpeed(sender,user,target,speed); + } + default -> { + if (target.isFlying()) { + setFlySpeed(sender,user,target,speed); + return; + } + setWalkSpeed(sender,user,target,speed); + } + } + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + List players = new ArrayList<>(); + for (Player player : ServerUtils.players()) { + players.add(player.getName()); + } + + b.then(b.arg("[]") + .then(b.arg("walk","flight") + .then(b.arg(players)) + ) + ); + } + public static void setFlySpeed(CommandSender sender, Player user, Player target, float speed) { + if (!user.hasPermission("ultrautils.speed.flight")) { + sender.sendMessage("You lack the permission to set walk speed."); + return; + } + if (user.equals(target)) { + target.setFlySpeed(speed); + user.sendMessage(Text.prefix("Set your flight speed to &a%s&7.".formatted(speed))); + } else if (user.hasPermission("ultrautils.speed.fly.others")) { + target.setFlySpeed(speed); + user.sendMessage(Text.prefix("Set the flight speed of &e%s&7 to &a%s&7.".formatted(target.getName(),speed))); + target.sendMessage(Text.prefix("Your flight speed has been set to &a%s&7.".formatted(speed))); + } else { + user.sendMessage(Text.prefix("You lack the permission to set other player's flight speed.")); + } + } + + public static void setWalkSpeed(CommandSender sender, Player user, Player target, float speed) { + if (!user.hasPermission("ultrautils.speed.walk")) { + sender.sendMessage("You lack the permission to set walk speed."); + return; + } + if (user.equals(target)) { + target.setWalkSpeed(speed); + user.sendMessage(Text.prefix("Set your walk speed to &a%s&7.".formatted(speed))); + } else if (user.hasPermission("ultrautils.speed.walk.others")) { + target.setWalkSpeed(speed); + user.sendMessage(Text.prefix("Set the walk speed of &e%s&7 to &a%s&7.".formatted(target.getName(),speed))); + target.sendMessage(Text.prefix("Your walk speed has been set to &a%s&7.".formatted(speed))); + } else { + user.sendMessage(Text.prefix("You lack the permission to set other player's walk speed.")); + } + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/workstations/AnvilCommand.java b/src/main/java/me/trouper/ultrautils/commands/workstations/AnvilCommand.java new file mode 100644 index 0000000..190a7e2 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/workstations/AnvilCommand.java @@ -0,0 +1,23 @@ +package me.trouper.ultrautils.commands.workstations; + +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandRegistry(value = "anvil", permission = @Permission("ultrautils.anvil"),playersOnly = true) +public class AnvilCommand implements CustomCommand { + @Override + public void dispatchCommand(CommandSender sender, Args args) { + Player p = (Player) sender; + p.openAnvil(p.getLocation(),true); + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/workstations/CartographyCommand.java b/src/main/java/me/trouper/ultrautils/commands/workstations/CartographyCommand.java new file mode 100644 index 0000000..3a6c826 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/workstations/CartographyCommand.java @@ -0,0 +1,23 @@ +package me.trouper.ultrautils.commands.workstations; + +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandRegistry(value = "cartography", permission = @Permission("ultrautils.cartography"),playersOnly = true) +public class CartographyCommand implements CustomCommand { + @Override + public void dispatchCommand(CommandSender sender, Args args) { + Player p = (Player) sender; + p.openCartographyTable(p.getLocation(),true); + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/workstations/CraftingCommand.java b/src/main/java/me/trouper/ultrautils/commands/workstations/CraftingCommand.java new file mode 100644 index 0000000..1c33b84 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/workstations/CraftingCommand.java @@ -0,0 +1,23 @@ +package me.trouper.ultrautils.commands.workstations; + +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandRegistry(value = "craft", permission = @Permission("ultrautils.craft"),playersOnly = true) +public class CraftingCommand implements CustomCommand { + @Override + public void dispatchCommand(CommandSender sender, Args args) { + Player p = (Player) sender; + p.openWorkbench(p.getLocation(),true); + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/workstations/GrindstoneCommand.java b/src/main/java/me/trouper/ultrautils/commands/workstations/GrindstoneCommand.java new file mode 100644 index 0000000..941dcfe --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/workstations/GrindstoneCommand.java @@ -0,0 +1,23 @@ +package me.trouper.ultrautils.commands.workstations; + +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandRegistry(value = "grindstone", permission = @Permission("ultrautils.grind"),playersOnly = true) +public class GrindstoneCommand implements CustomCommand { + @Override + public void dispatchCommand(CommandSender sender, Args args) { + Player p = (Player) sender; + p.openGrindstone(p.getLocation(),true); + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/workstations/LoomCommand.java b/src/main/java/me/trouper/ultrautils/commands/workstations/LoomCommand.java new file mode 100644 index 0000000..53c9ec3 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/workstations/LoomCommand.java @@ -0,0 +1,23 @@ +package me.trouper.ultrautils.commands.workstations; + +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandRegistry(value = "smith", permission = @Permission("ultrautils.smith"),playersOnly = true) +public class LoomCommand implements CustomCommand { + @Override + public void dispatchCommand(CommandSender sender, Args args) { + Player p = (Player) sender; + p.openLoom(p.getLocation(),true); + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/workstations/SmithingCommand.java b/src/main/java/me/trouper/ultrautils/commands/workstations/SmithingCommand.java new file mode 100644 index 0000000..a0e9ead --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/workstations/SmithingCommand.java @@ -0,0 +1,23 @@ +package me.trouper.ultrautils.commands.workstations; + +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandRegistry(value = "smith", permission = @Permission("ultrautils.smith"),playersOnly = true) +public class SmithingCommand implements CustomCommand { + @Override + public void dispatchCommand(CommandSender sender, Args args) { + Player p = (Player) sender; + p.openSmithingTable(p.getLocation(),true); + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + + } +} diff --git a/src/main/java/me/trouper/ultrautils/commands/workstations/StonecutterCommand.java b/src/main/java/me/trouper/ultrautils/commands/workstations/StonecutterCommand.java new file mode 100644 index 0000000..d705c7d --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/commands/workstations/StonecutterCommand.java @@ -0,0 +1,23 @@ +package me.trouper.ultrautils.commands.workstations; + +import io.github.itzispyder.pdk.commands.Args; +import io.github.itzispyder.pdk.commands.CommandRegistry; +import io.github.itzispyder.pdk.commands.CustomCommand; +import io.github.itzispyder.pdk.commands.Permission; +import io.github.itzispyder.pdk.commands.completions.CompletionBuilder; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +@CommandRegistry(value = "stonecutter", permission = @Permission("ultrautils.stonecut"),playersOnly = true) +public class StonecutterCommand implements CustomCommand { + @Override + public void dispatchCommand(CommandSender sender, Args args) { + Player p = (Player) sender; + p.openStonecutter(p.getLocation(),true); + } + + @Override + public void dispatchCompletions(CompletionBuilder b) { + + } +} diff --git a/src/main/java/me/trouper/ultrautils/data/Items.java b/src/main/java/me/trouper/ultrautils/data/Items.java new file mode 100644 index 0000000..1f6f2f9 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/data/Items.java @@ -0,0 +1,4 @@ +package me.trouper.ultrautils.data; + +public class Items { +} diff --git a/src/main/java/me/trouper/ultrautils/data/Storage.java b/src/main/java/me/trouper/ultrautils/data/Storage.java new file mode 100644 index 0000000..149a5d4 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/data/Storage.java @@ -0,0 +1,4 @@ +package me.trouper.ultrautils.data; + +public class Storage { +} diff --git a/src/main/java/me/trouper/ultrautils/data/config/Config.java b/src/main/java/me/trouper/ultrautils/data/config/Config.java new file mode 100644 index 0000000..7d84dbc --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/data/config/Config.java @@ -0,0 +1,24 @@ +package me.trouper.ultrautils.data.config; + +import io.github.itzispyder.pdk.utils.misc.JsonSerializable; + +import java.io.File; + +public class Config implements JsonSerializable { + + @Override + public File getFile() { + File file = new File("plugins/UltraUtils/main-config.json"); + file.getParentFile().mkdirs(); + return file; + } + + public String prefix = "&9UltraCore> &7"; + public boolean debugMode = false; + public Plugin plugin = new Plugin(); + + public class Plugin { + public String joinMessage = "&8[&2+&8] &a%s&7 has joined."; + public String leaveMessage = "&8[&4-&8] &c%s&7 has left."; + } +} diff --git a/src/main/java/me/trouper/ultrautils/events/JoinLeaveEvent.java b/src/main/java/me/trouper/ultrautils/events/JoinLeaveEvent.java new file mode 100644 index 0000000..ad3f7e8 --- /dev/null +++ b/src/main/java/me/trouper/ultrautils/events/JoinLeaveEvent.java @@ -0,0 +1,31 @@ +package me.trouper.ultrautils.events; + +import functions.Text; +import io.github.itzispyder.pdk.events.CustomListener; +import me.trouper.ultrautils.UltraUtils; +import me.trouper.ultrautils.data.config.Config; +import net.kyori.adventure.text.Component; +import org.bukkit.event.EventHandler; +import org.bukkit.event.player.PlayerJoinEvent; +import org.bukkit.event.player.PlayerQuitEvent; + +public class JoinLeaveEvent implements CustomListener { + + @EventHandler + public void onJoin(PlayerJoinEvent e) { + if (UltraUtils.config.plugin.joinMessage.isBlank()) { + e.joinMessage(null); + return; + } + e.joinMessage(Component.text(Text.color(UltraUtils.config.plugin.joinMessage))); + } + + @EventHandler + public void onLeave(PlayerQuitEvent e) { + if (UltraUtils.config.plugin.leaveMessage.isBlank()) { + e.quitMessage(null); + return; + } + e.quitMessage(Component.text(Text.color(UltraUtils.config.plugin.leaveMessage))); + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..cf01cb3 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,118 @@ +name: UltraUtils +version: '${version}' +main: me.trouper.ultrautils.UltraUtils +api-version: 1.19 +authors: [ obvWolf ] +description: A Utility plugin for server management and moderation. +website: https://trouper.me/ +permissions: + ultrautils.admin: + default: op + description: Access to the admin command + ultrautils.gamemode: + default: op + description: This permission is required to use ANY gamemode commands. It does not give permission to switch to any gamemodes. + ultrautils.gamemode.adventure: + default: op + description: Allows changing gamemode to adventure + ultrautils.gamemode.creative: + default: op + description: Allows changing gamemode to creative + ultrautils.gamemode.survival: + default: op + description: Allows changing gamemode to survival + ultrautils.gamemode.spectator: + default: op + description: Allows changing gamemode to spectator + ultrautils.gamemode.others: + default: op + description: Allows setting the gamemode of other players + ultrautils.craft: + default: op + description: Access to the portable crafting table + ultrautils.anvil: + default: op + description: Access to the portable anvil + ultrautils.cartography: + default: op + description: Access to the portable cartography table + ultrautils.grindstone: + default: op + description: Access to the portable grindstone + ultrautils.loom: + default: op + description: Access to the portable loom + ultrautils.smithing: + default: op + description: Access to the portable smithing table + ultrautils.stonecutter: + default: op + description: Access to the portable stonecutter + ultrautils.flight: + default: op + description: Enable or disable flight (only the sender) + ultrautils.flight.others: + defualt: op + description: Enable or disable flight for specific players + + +commands: + ultrautils: + description: Admin command for admin things + usage: /ultrautils + permission: ultrautils.admin + aliases: + - uu + gma: + description: Change gamemode to adventure + permission: ultrautils.gamemode.adventure + usage: /gma [] + gmc: + description: Change gamemode to creative + permission: ultrautils.gamemode.creative + usage: /gmc [] + gms: + description: Change gamemode to survival + permission: ultrautils.gamemode.survival + usage: /gms [] + gmsp: + description: Change gamemode to spectator + permission: ultrautils.gamemode.spectator + usage: /gmsp [] + gamemode: + description: Root gamemode changing command. Required for all the other gamemode commands. + permission: ultrautils.gamemode + usage: /gamemode [] + anvil: + permission: ultrautils.anvil + description: a portable anvil + cartography: + permission: ultrautils.cartography + description: a portable cartography table + aliases: + - mapstation + craft: + permission: ultrautils.craft + description: a portable crafting table + aliases: + - workbench + grindstone: + permission: ultrautils.grindstone + description: a portable grindstone + loom: + permission: ultrautils.loom + description: a portable loom + smithingtable: + description: a portable smithing table + permission: ultrautils.smithing + aliases: + - upgradetable + stonecutter: + description: a portable stonecutter + permission: ultrautils.stonecutter + fly: + description: Toggle flight status + permission: ultrautils.flight + usage: /fly [] + aliases: + - flight