Initial commit

This commit is contained in:
SKBotNL committed 2025-05-26 21:26:44 +02:00
commit 3036628fc7
30 files changed
+1512

No files matched your search

+119
View File
@@ -0,0 +1,119 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
.gradle
build/
# Ignore Gradle GUI config
gradle-app.setting
# Cache of project
.gradletasknamecache
**/build/
# Common working directory
run/
runs/
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar
+6
View File
@@ -0,0 +1,6 @@
[submodule "libs/DiamondBank-OG"]
path = libs/DiamondBank-OG
url = https://github.com/true-og/DiamondBank-OG
[submodule "libs/Utilities-OG"]
path = libs/Utilities-OG
url = https://github.com/true-og/Utilities-OG
+24
View File
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <https://unlicense.org>
+57
View File
@@ -0,0 +1,57 @@
# Quests-OG
Quests plugin for TrueOG
## Requirements for Each Home
### One home
Free
### Two homes
- 100 diamonds
- 24 hours played
- 10k blocks travelled
- 50 levels
- 10 Duels wins
### Three homes
- 250 diamonds
- 5 days played
- 50k blocks travelled
- Beaconator advancement
- 100 levels
- 20 Duels wins
### Four homes
- 1000 diamonds
- 10 days played
- 200k blocks travelled
- A Furious Cocktail advancement
- Serious Dedication advancement
- 150 levels
- Have been killed by a villager
- Have died to death.fell.accident.water
- 50 Duels wins
### Five homes
- 2500 diamonds
- 15 days played
- 5000k blocks travelled on pig
- 1000k blocks travelled on strider
- Kill 50 dolphins
- Kill 50 zoglins
- The Cutest Predator advancement
- Two by Two advancement
- A Complete Catalogue advancement
- Monsters Hunted advancement
- Have died to fell while climbing
- Have died to magma block while fighting zoglin
- 200 levels
- 2000 fish caught
- 150 Duels wins
### Six Homes
- 5000 diamonds
- 30 days played
- 10000k blocks walked on water
- 10000k blocks walked underwater
- All 13 music discs
- Has died to "left the confines of this world while fighting Ender Dragon"
- All advancements
- 1500 blocks of obsidian mined
- 5 dragon eggs
- 250 levels
- 300 Duels wins
+2
View File
@@ -0,0 +1,2 @@
# Fetch all submodule content.
git submodule update --force --recursive --init --remote
+75
View File
@@ -0,0 +1,75 @@
plugins {
kotlin("jvm") version "2.1.21"
id("com.gradleup.shadow") version "8.3.5"
id("xyz.jpenilla.run-paper") version "2.3.1"
}
group = "net.trueog"
version = "1.0"
val apiVersion = "1.19"
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/") {
name = "papermc-repo"
}
maven("https://oss.sonatype.org/content/groups/public/") {
name = "sonatype"
}
maven {
url = uri("https://jitpack.io")
}
}
dependencies {
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
compileOnly("net.luckperms:api:5.4")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
implementation("io.lettuce:lettuce-core:6.6.0.RELEASE")
compileOnly("com.github.Realizedd.Duels:duels-api:3.5.1")
compileOnly(project(":libs:Utilities-OG"))
compileOnly(project(":libs:DiamondBank-OG"))
}
tasks {
runServer {
// Configure the Minecraft version for our task.
// This is the only required configuration besides applying the plugin.
// Your plugin's jar (or shadowJar if present) will be used automatically.
minecraftVersion("1.19")
}
}
val targetJavaVersion = 17
kotlin {
jvmToolchain(targetJavaVersion)
}
tasks.build {
dependsOn("shadowJar")
}
tasks.jar {
archiveClassifier.set("part")
}
tasks.shadowJar {
archiveClassifier.set("")
minimize()
}
tasks.processResources {
val props = mapOf(
"version" to version,
"apiVersion" to apiVersion
)
inputs.properties(props)
filteringCharset = "UTF-8"
filesMatching("plugin.yml") {
expand(props)
}
}
View File
Whitespace-only changes.
Binary file not shown.
+7
View File
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Vendored Executable
+249
View File
@@ -0,0 +1,249 @@
#!/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/HEAD/platforms/jvm/plugins-application/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
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
# 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
if ! command -v java >/dev/null 2>&1
then
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
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
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
# 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"'
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
Vendored
+92
View File
@@ -0,0 +1,92 @@
@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=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
Submodule libs/DiamondBank-OG added at 2c5d1ab576.
+1
Submodule libs/Utilities-OG added at 15576576ab.
+13
View File
@@ -0,0 +1,13 @@
rootProject.name = "Quests-OG"
val process = ProcessBuilder("sh", "bootstrap.sh")
.directory(rootDir)
.start()
val exitValue = process.waitFor()
if (exitValue != 0) {
throw GradleException("bootstrap.sh failed with exit code $exitValue")
}
include("libs:Utilities-OG")
include("libs:DiamondBank-OG")
@@ -0,0 +1,37 @@
package net.trueog.questsOG
import net.trueog.questsOG.progression.HomesProgression
import org.bukkit.command.Command
import org.bukkit.command.CommandExecutor
import org.bukkit.command.CommandSender
import org.bukkit.entity.Player
class ClaimQuest : CommandExecutor {
override fun onCommand(
sender: CommandSender,
command: Command,
label: String,
args: Array<out String>?
): Boolean {
if (sender !is Player) {
sender.sendMessage("You can only execute this command as a player.")
return true
}
val nextQuest = HomesProgression.getNextQuest(sender)
if (nextQuest == null) {
sender.sendMessage("You cannot progress any further")
return true
}
if (nextQuest.isEligible(sender)) {
nextQuest.consumeQuestItems(sender)
nextQuest.reward(sender)
sender.sendMessage("Claimed quest!")
} else {
sender.sendMessage("You are not eligible to claim the quest")
sender.sendMessage(nextQuest.unmetRequirements(sender))
}
return true
}
}
@@ -0,0 +1,26 @@
package net.trueog.questsOG
import org.bukkit.configuration.file.YamlConfiguration
import java.io.File
class Config {
lateinit var redisUrl: String
fun load(): Boolean {
val file = File(QuestsOG.plugin.dataFolder, "config.yml")
if (!file.exists()) {
QuestsOG.plugin.saveDefaultConfig()
}
val config = YamlConfiguration.loadConfiguration(file)
config.save(file)
try {
redisUrl = config.get("redisUrl") as String
} catch (_: Exception) {
QuestsOG.plugin.logger.severe("Failed to parse config option \"redisUrl\" as a string")
return true
}
return false
}
}
@@ -0,0 +1,37 @@
package net.trueog.questsOG
import kotlinx.coroutines.DelicateCoroutinesApi
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
import org.bukkit.event.entity.PlayerDeathEvent
class Events : Listener {
@OptIn(DelicateCoroutinesApi::class)
@EventHandler
fun onPlayerDeath(event: PlayerDeathEvent) {
if (!event.deathMessage().toString().contains("death.fell.accident.water")) {
QuestsOG.redis.setValue("questsog:${event.player.uniqueId}:deaths:fellAccidentWater", "true")
return
}
if (event.deathMessage().toString().contains("fell while climbing")) {
QuestsOG.redis.setValue("questsog:${event.player.uniqueId}:deaths:fellWhileClimbing", "true")
return
}
if (event.deathMessage().toString().contains("walked into the danger zone due to Zoglin")) {
QuestsOG.redis.setValue(
"questsog:${event.player.uniqueId}:deaths:diedToMagmaBlockWhileFightingZoglin",
"true"
)
return
}
if (event.deathMessage().toString().contains("left the confines of this world while fighting Ender Dragon")) {
QuestsOG.redis.setValue(
"questsog:${event.player.uniqueId}:deaths:leftConfinesOfWorldWhileFightingEnderDragon",
"true"
)
}
}
}
@@ -0,0 +1,35 @@
package net.trueog.questsOG
import org.bukkit.entity.Player
class QuestsManager {
// enum class HomesLevel(val permission: String) {
// TWO("essentials.sethome.multiple.homes-2"),
// THREE("essentials.sethome.multiple.homes-3"),
// FOUR("essentials.sethome.multiple.homes-4"),
// FIVE("essentials.sethome.multiple.homes-5"),
// SIX("essentials.sethome.multiple.homes-6")
// }
val homesLevels = hashMapOf(
"essentials.sethome.multiple.homes-2" to 2,
"essentials.sethome.multiple.homes-3" to 3,
"essentials.sethome.multiple.homes-4" to 4,
"essentials.sethome.multiple.homes-5" to 5,
"essentials.sethome.multiple.homes-6" to 6
)
fun getCurrentAmountOfHomes(player: Player): Int {
val permission = player.effectivePermissions.single { homesLevels.contains(it.permission) }
if (permission == null) {
return 1
}
val homesLevel = homesLevels[permission.permission]!!
return homesLevel
}
fun isEligibleForNextHomesLevel(player: Player) {
val currentAmountOfHomes = getCurrentAmountOfHomes(player)
}
}
@@ -0,0 +1,63 @@
package net.trueog.questsOG
import me.realized.duels.api.Duels
import net.luckperms.api.LuckPerms
import net.trueog.diamondbankog.DiamondBankAPI
import org.bukkit.Bukkit
import org.bukkit.plugin.java.JavaPlugin
class QuestsOG : JavaPlugin() {
companion object {
lateinit var plugin: QuestsOG
lateinit var config: Config
lateinit var redis: Redis
lateinit var diamondBankAPI: DiamondBankAPI
lateinit var luckPerms: LuckPerms
lateinit var duels: Duels
}
override fun onEnable() {
plugin = this
Companion.config = Config()
if (Companion.config.load()) {
Bukkit.getPluginManager().disablePlugin(this)
return
}
redis = Redis()
val diamondBankAPIProvider =
server.servicesManager.getRegistration<DiamondBankAPI>(DiamondBankAPI::class.java)
if (diamondBankAPIProvider == null) {
logger.severe("DiamondBank-OG API is null")
Bukkit.getPluginManager().disablePlugin(this)
return
}
diamondBankAPI = diamondBankAPIProvider.provider
val luckPermsProvider = Bukkit.getServicesManager().getRegistration(LuckPerms::class.java)
if (luckPermsProvider == null) {
this.logger.severe("Luckperms API is null, quitting....")
Bukkit.getPluginManager().disablePlugin(this)
return
}
luckPerms = luckPermsProvider.provider
val duels = Bukkit.getServer().pluginManager.getPlugin("Duels")
if (duels == null) {
this.logger.severe("Duels API is null, quitting....")
Bukkit.getPluginManager().disablePlugin(this)
return
}
Companion.duels = duels as Duels
this.server.pluginManager.registerEvents(Events(), this)
getCommand("claimquest")?.setExecutor(ClaimQuest())
}
override fun onDisable() {
// Plugin shutdown logic
}
}
@@ -0,0 +1,19 @@
package net.trueog.questsOG
import io.lettuce.core.RedisClient
class Redis {
private val redisClient: RedisClient = RedisClient.create(QuestsOG.config.redisUrl)
fun getValue(key: String): String? {
val connection = redisClient.connect()
val commands = connection.sync()
return commands.get(key)
}
fun setValue(key: String, value: String): String? {
val connection = redisClient.connect()
val commands = connection.sync()
return commands.set(key, value)
}
}
@@ -0,0 +1,20 @@
package net.trueog.questsOG.progression
import net.trueog.questsOG.quests.*
import org.bukkit.entity.Player
object HomesProgression : Progression {
override val quests = arrayOf(HomesTwo(), HomesThree(), HomesFour(), HomesFive(), HomesSix())
override fun getNextQuest(player: Player): Quest? {
val homePermission =
player.effectivePermissions.singleOrNull { permission -> permission.permission.startsWith("essentials.sethome.multiple.homes-") }
val nextQuestIndex = homePermission?.permission?.takeLast(1)?.toInt()?.minus(1) ?: 0
if (nextQuestIndex + 1 > quests.size) {
return null
}
return quests[nextQuestIndex]
}
}
@@ -0,0 +1,10 @@
package net.trueog.questsOG.progression
import net.trueog.questsOG.quests.Quest
import org.bukkit.entity.Player
interface Progression {
val quests: Array<Quest>
fun getNextQuest(player: Player): Quest?
}
@@ -0,0 +1,140 @@
package net.trueog.questsOG.quests
import net.luckperms.api.node.types.PermissionNode
import net.trueog.questsOG.QuestsOG
import org.bukkit.Bukkit
import org.bukkit.Statistic
import org.bukkit.entity.EntityType
import org.bukkit.entity.Player
class HomesFive : Quest {
private data class Requirements(
val playerTotalBalance: Int,
val ticksPlayed: Int,
val pigOneCm: Int,
val striderOneCm: Int,
val dolphinKills: Int,
val zoglinKills: Int,
val hasCutestPredator: Boolean,
val hasTwoByTwo: Boolean,
val hasCompleteCatalogue: Boolean,
val hasMonstersHunted: Boolean,
val hasDiedToFellWhileClimbing: Boolean,
val hasDiedToMagmaBlockWhileFightingZoglin: Boolean,
val levels: Int,
val fishCaught: Int,
val duelsWins: Int
)
private val cutestPredatorAdvancement = Bukkit.getServer().advancementIterator().asSequence()
.single { advancement -> advancement.key.toString() == "minecraft:husbandry/axolotl_in_a_bucket" }
private val twoByTwoAdvancement = Bukkit.getServer().advancementIterator().asSequence()
.single { advancement -> advancement.key.toString() == "minecraft:husbandry/bred_all_animals" }
private val completeCatalogueAdvancement = Bukkit.getServer().advancementIterator().asSequence()
.single { advancement -> advancement.key.toString() == "minecraft:husbandry/complete_catalogue" }
private val monstersHuntedAdvancement = Bukkit.getServer().advancementIterator().asSequence()
.single { advancement -> advancement.key.toString() == "minecraft:adventure/kill_all_mobs" }
private fun getRequirements(player: Player): Requirements {
val playerTotalBalanceFuture = QuestsOG.diamondBankAPI.getPlayerTotalBalance(player.uniqueId)
val playerTotalBalance = playerTotalBalanceFuture.get()
val ticksPlayed = player.getStatistic(Statistic.PLAY_ONE_MINUTE)
val pigOneCm = player.getStatistic(Statistic.PIG_ONE_CM)
val striderOneCm = player.getStatistic(Statistic.STRIDER_ONE_CM)
val dolphinKills = player.getStatistic(Statistic.KILL_ENTITY, EntityType.DOLPHIN)
val zoglinKills = player.getStatistic(Statistic.KILL_ENTITY, EntityType.ZOGLIN)
val hasCutestPredator = player.getAdvancementProgress(cutestPredatorAdvancement).isDone
val hasTwoByTwo = player.getAdvancementProgress(twoByTwoAdvancement).isDone
val hasCompleteCatalogue = player.getAdvancementProgress(completeCatalogueAdvancement).isDone
val hasMonstersHunted = player.getAdvancementProgress(monstersHuntedAdvancement).isDone
val hasDiedToFellWhileClimbing =
QuestsOG.redis.getValue("questsog:${player.uniqueId}:deaths:fellWhileClimbing") == "true"
val hasDiedToMagmaBlockWhileFightingZoglin =
QuestsOG.redis.getValue("questsog:${player.uniqueId}:deaths:diedToMagmaBlockWhileFightingZoglin") == "true"
val fishCaught = player.getStatistic(Statistic.FISH_CAUGHT)
val duelsWins = QuestsOG.duels.userManager.get(player.uniqueId)?.wins ?: 0
return Requirements(
playerTotalBalance,
ticksPlayed,
pigOneCm,
striderOneCm,
dolphinKills,
zoglinKills,
hasCutestPredator,
hasTwoByTwo,
hasCompleteCatalogue,
hasMonstersHunted,
hasDiedToFellWhileClimbing,
hasDiedToMagmaBlockWhileFightingZoglin,
player.level,
fishCaught,
duelsWins
)
}
override fun isEligible(player: Player): Boolean {
val requirements = getRequirements(player)
return requirements.playerTotalBalance >= 2500 &&
requirements.ticksPlayed / 20.0 / 60.0 / 60.0 / 24.0 >= 15 &&
requirements.pigOneCm / 100000.0 >= 5 &&
requirements.striderOneCm / 100000.0 >= 1 &&
requirements.dolphinKills >= 50 &&
requirements.zoglinKills >= 50 &&
requirements.hasCutestPredator &&
requirements.hasTwoByTwo &&
requirements.hasCompleteCatalogue &&
requirements.hasMonstersHunted &&
requirements.hasDiedToFellWhileClimbing &&
requirements.hasDiedToMagmaBlockWhileFightingZoglin &&
requirements.levels >= 200 &&
requirements.fishCaught >= 2000 &&
requirements.duelsWins >= 150
}
override fun consumeQuestItems(player: Player): Boolean {
val withdrawFuture = QuestsOG.diamondBankAPI.withdrawFromPlayer(player.uniqueId, 2500)
val error = withdrawFuture.get()
if (error) {
return true
}
player.level -= 200
return false
}
override fun reward(player: Player) {
val homesFourNode = PermissionNode.builder("essentials.sethome.multiple.homes-4").build()
val homesFiveNode = PermissionNode.builder("essentials.sethome.multiple.homes-5").build()
QuestsOG.luckPerms.userManager.modifyUser(player.uniqueId) { user ->
user.data().remove(homesFourNode)
user.data().add(homesFiveNode)
}
}
override fun unmetRequirements(player: Player): String {
val requirements = getRequirements(player)
return "Total Balance: ${requirements.playerTotalBalance}/1000 | Ticks Played: ${requirements.ticksPlayed}/25920000 " +
"| Cm Travelled on Pig: ${requirements.pigOneCm}/500000 | Cm Travelled on Strider: ${requirements.striderOneCm}/ 100000" +
"| Dolphins killed: ${requirements.dolphinKills}/50 | Zoglins killed: ${requirements.zoglinKills}/50 | The Cutest Predator: ${requirements.hasCutestPredator} " +
"| Two by Two: ${requirements.hasTwoByTwo} | Complete Catalogue: ${requirements.hasCompleteCatalogue} | Monsters Hunted: ${requirements.hasMonstersHunted} " +
"| Died to Fell While Climbing ${requirements.hasDiedToFellWhileClimbing} | Died to Magna Block While Fighting Zoglin: ${requirements.hasDiedToMagmaBlockWhileFightingZoglin} " +
"| Levels: ${requirements.levels}/200 | Fish Caught: ${requirements.fishCaught}/2000 | Duels Wins: ${requirements.duelsWins}"
}
}
@@ -0,0 +1,122 @@
package net.trueog.questsOG.quests
import net.luckperms.api.node.types.PermissionNode
import net.trueog.questsOG.QuestsOG
import org.bukkit.Bukkit
import org.bukkit.Statistic
import org.bukkit.entity.EntityType
import org.bukkit.entity.Player
class HomesFour : Quest {
private data class Requirements(
val playerTotalBalance: Int,
val ticksPlayed: Int,
val totalCm: Int,
val hasFuriousCocktail: Boolean,
val hasSeriousDedication: Boolean,
val levels: Int,
val hasBeenKilledByVillager: Boolean,
val hasDiedToFellAccidentWater: Boolean,
val duelsWins: Int
)
private val furiousCocktailAdvancement = Bukkit.getServer().advancementIterator().asSequence()
.single { it.key.toString() == "minecraft:nether/all_potions" }
private val seriousDedicationAdvancement = Bukkit.getServer().advancementIterator().asSequence()
.single { it.key.toString() == "minecraft:husbandry/obtain_netherite_hoe" }
private fun getRequirements(player: Player): Requirements {
val playerTotalBalanceFuture = QuestsOG.diamondBankAPI.getPlayerTotalBalance(player.uniqueId)
val playerTotalBalance = playerTotalBalanceFuture.get()
val ticksPlayed = player.getStatistic(Statistic.PLAY_ONE_MINUTE)
val walkOneCm = player.getStatistic(Statistic.WALK_ONE_CM)
val walkOnWaterOneCm = player.getStatistic(Statistic.WALK_ON_WATER_ONE_CM)
val climbOneCm = player.getStatistic(Statistic.CLIMB_ONE_CM)
// val flyOneCm = player.getStatistic(Statistic.FLY_ONE_CM)
val walkUnderWaterOneCm = player.getStatistic(Statistic.WALK_UNDER_WATER_ONE_CM)
val minecartOneCm = player.getStatistic(Statistic.MINECART_ONE_CM)
val boatOneCm = player.getStatistic(Statistic.BOAT_ONE_CM)
val pigOneCm = player.getStatistic(Statistic.PIG_ONE_CM)
val horseOneCm = player.getStatistic(Statistic.HORSE_ONE_CM)
val sprintOneCm = player.getStatistic(Statistic.SPRINT_ONE_CM)
val crouchOneCm = player.getStatistic(Statistic.CROUCH_ONE_CM)
val aviateOneCm = player.getStatistic(Statistic.AVIATE_ONE_CM)
val swimOneCm = player.getStatistic(Statistic.SWIM_ONE_CM)
val striderOneCm = player.getStatistic(Statistic.STRIDER_ONE_CM)
val totalCm =
walkOneCm + walkOnWaterOneCm + climbOneCm + walkUnderWaterOneCm + minecartOneCm + boatOneCm + pigOneCm + horseOneCm + sprintOneCm + crouchOneCm + aviateOneCm + swimOneCm + striderOneCm
val furiousCocktailAdvancementProgress = player.getAdvancementProgress(furiousCocktailAdvancement)
val seriousDedicationAdvancementProgress = player.getAdvancementProgress(seriousDedicationAdvancement)
val hasBeenKilledByVillager = player.getStatistic(Statistic.ENTITY_KILLED_BY, EntityType.VILLAGER) > 0
val hasDiedToFellAccidentWater =
QuestsOG.redis.getValue("questsog:${player.uniqueId}:deaths:fellAccidentWater") == "true"
val duelsWins = QuestsOG.duels.userManager.get(player.uniqueId)?.wins ?: 0
// TODO: Check if player has a villager head
// val hasVillagerHead = player.inventory.any { isVillagerHead(it) }
return Requirements(
playerTotalBalance,
ticksPlayed,
totalCm,
furiousCocktailAdvancementProgress.isDone,
seriousDedicationAdvancementProgress.isDone,
player.level,
hasBeenKilledByVillager,
hasDiedToFellAccidentWater,
duelsWins
)
}
override fun isEligible(player: Player): Boolean {
val requirements = getRequirements(player)
return requirements.playerTotalBalance >= 1000 &&
requirements.ticksPlayed / 20.0 / 60.0 / 60.0 / 24.0 >= 10 &&
requirements.totalCm / 100.0 >= 200000 &&
requirements.hasFuriousCocktail &&
requirements.hasSeriousDedication &&
requirements.levels >= 150 &&
requirements.hasBeenKilledByVillager &&
requirements.hasDiedToFellAccidentWater &&
requirements.duelsWins >= 50
}
override fun consumeQuestItems(player: Player): Boolean {
val withdrawFuture = QuestsOG.diamondBankAPI.withdrawFromPlayer(player.uniqueId, 1000)
val error = withdrawFuture.get()
if (error) {
return true
}
player.level -= 150
return false
}
override fun reward(player: Player) {
val homesThreeNode = PermissionNode.builder("essentials.sethome.multiple.homes-3").build()
val homesFourNode = PermissionNode.builder("essentials.sethome.multiple.homes-4").build()
QuestsOG.luckPerms.userManager.modifyUser(player.uniqueId) { user ->
user.data().remove(homesThreeNode)
user.data().add(homesFourNode)
}
}
override fun unmetRequirements(player: Player): String {
val requirements = getRequirements(player)
return "Total Balance: ${requirements.playerTotalBalance}/1000 | Ticks Played: ${requirements.ticksPlayed}/17280000 " +
"| Total Cm Travelled: ${requirements.totalCm}/20000000 | A Furious Cocktail: ${requirements.hasFuriousCocktail} " +
"| Serious Dedication: ${requirements.hasSeriousDedication} | Levels: ${requirements.levels}/150 | Killed by villager: ${requirements.hasBeenKilledByVillager} " +
"| Died to death.fell.accident.water: ${requirements.hasDiedToFellAccidentWater} | Duels Wins: ${requirements.duelsWins}/50"
}
}
@@ -0,0 +1,156 @@
package net.trueog.questsOG.quests
import net.luckperms.api.node.types.PermissionNode
import net.trueog.questsOG.QuestsOG
import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.Statistic
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
class HomesSix : Quest {
private data class Requirements(
val playerTotalBalance: Int,
val ticksPlayed: Int,
val walkOnWaterOneCm: Int,
val walkUnderWaterOneCm: Int,
val stoneLikePickedUp: Int,
val discs: Int,
val hasLeftConfinesOfWorldWhileFightingEnderDragon: Boolean,
val finishedAdvancements: Int,
val obsidianMined: Int,
val dragonEggs: Int,
val levels: Int,
val duelsWins: Int
)
private val cutestPredatorAdvancement = Bukkit.getServer().advancementIterator().asSequence()
.single { it.key.toString() == "minecraft:husbandry/axolotl_in_a_bucket" }
private val twoByTwoAdvancement = Bukkit.getServer().advancementIterator().asSequence()
.single { it.key.toString() == "minecraft:husbandry/bred_all_animals" }
private val completeCatalogueAdvancement = Bukkit.getServer().advancementIterator().asSequence()
.single { it.key.toString() == "minecraft:husbandry/complete_catalogue" }
private val monstersHuntedAdvancement = Bukkit.getServer().advancementIterator().asSequence()
.single { it.key.toString() == "minecraft:adventure/kill_all_mobs" }
private val neededDiscs = setOf(
Material.MUSIC_DISC_13,
Material.MUSIC_DISC_CAT,
Material.MUSIC_DISC_BLOCKS,
Material.MUSIC_DISC_CHIRP,
Material.MUSIC_DISC_FAR,
Material.MUSIC_DISC_MALL,
Material.MUSIC_DISC_MELLOHI,
Material.MUSIC_DISC_STAL,
Material.MUSIC_DISC_STRAD,
Material.MUSIC_DISC_WARD,
Material.MUSIC_DISC_11,
Material.MUSIC_DISC_WAIT,
Material.MUSIC_DISC_5
)
private fun getRequirements(player: Player): Requirements {
val playerTotalBalanceFuture = QuestsOG.diamondBankAPI.getPlayerTotalBalance(player.uniqueId)
val playerTotalBalance = playerTotalBalanceFuture.get()
val ticksPlayed = player.getStatistic(Statistic.PLAY_ONE_MINUTE)
val walkOnWaterOneCm = player.getStatistic(Statistic.WALK_ON_WATER_ONE_CM)
val walkUnderWaterOneCm = player.getStatistic(Statistic.WALK_UNDER_WATER_ONE_CM)
val stoneMined = player.getStatistic(Statistic.MINE_BLOCK, Material.STONE)
val cobblestoneMined = player.getStatistic(Statistic.MINE_BLOCK, Material.COBBLESTONE)
val stoneLikeMined = stoneMined + cobblestoneMined
val discs = player.inventory
.filterNotNull()
.filter { it.type in neededDiscs }
val hasLeftConfinesOfWorldWhileFightingEnderDragon =
QuestsOG.redis.getValue("questsog:${player.uniqueId}:deaths:leftConfinesOfWorldWhileFightingEnderDragon") == "true"
val finishedAdvancements = Bukkit.getServer().advancementIterator().asSequence().filterNotNull()
.filter { player.getAdvancementProgress(it).isDone }
val obsidianMined = player.getStatistic(Statistic.MINE_BLOCK, Material.OBSIDIAN)
val dragonEggs = player.inventory.filterNotNull().count { it.type == Material.DRAGON_EGG }
val duelsWins = QuestsOG.duels.userManager.get(player.uniqueId)?.wins ?: 0
return Requirements(
playerTotalBalance,
ticksPlayed,
walkOnWaterOneCm,
walkUnderWaterOneCm,
stoneLikeMined,
discs.size,
hasLeftConfinesOfWorldWhileFightingEnderDragon,
finishedAdvancements.count(),
obsidianMined,
dragonEggs,
player.level,
duelsWins
)
}
override fun isEligible(player: Player): Boolean {
val requirements = getRequirements(player)
return requirements.playerTotalBalance >= 5000 &&
requirements.ticksPlayed / 20.0 / 60.0 / 60.0 / 24.0 >= 30 &&
requirements.walkOnWaterOneCm / 100000.0 >= 10 &&
requirements.walkUnderWaterOneCm / 100000.0 >= 10 &&
requirements.discs >= 13 &&
requirements.hasLeftConfinesOfWorldWhileFightingEnderDragon &&
requirements.finishedAdvancements >= 1179 &&
requirements.obsidianMined >= 1500 &&
requirements.dragonEggs >= 5 &&
requirements.levels >= 250 &&
requirements.duelsWins >= 300
}
override fun consumeQuestItems(player: Player): Boolean {
val withdrawFuture = QuestsOG.diamondBankAPI.withdrawFromPlayer(player.uniqueId, 5000)
val error = withdrawFuture.get()
if (error) {
return true
}
player.level -= 250
val removed = mutableSetOf<Material>()
for (itemStack in player.inventory.filterNotNull()) {
if (itemStack.type in neededDiscs && itemStack.type !in removed) {
itemStack.amount -= 1
removed += itemStack.type
}
}
player.inventory.removeItem(ItemStack(Material.DRAGON_EGG, 5))
return false
}
override fun reward(player: Player) {
val homesFiveNode = PermissionNode.builder("essentials.sethome.multiple.homes-5").build()
val homesSixNode = PermissionNode.builder("essentials.sethome.multiple.homes-6").build()
QuestsOG.luckPerms.userManager.modifyUser(player.uniqueId) { user ->
user.data().remove(homesFiveNode)
user.data().add(homesSixNode)
}
}
override fun unmetRequirements(player: Player): String {
val requirements = getRequirements(player)
return "Total Balance: ${requirements.playerTotalBalance}/1000 | Ticks Played: ${requirements.ticksPlayed}/51840000 " +
"| Cm Walked on Water: ${requirements.walkOnWaterOneCm}/1000000 | Cm Walked under Water: ${requirements.walkUnderWaterOneCm}/1000000 " +
"| Music Discs: ${requirements.discs}/13 | Left Confines of World While Fighting Ender Dragon: ${requirements.hasLeftConfinesOfWorldWhileFightingEnderDragon}/200 " +
"| Finished Advancements: ${requirements.finishedAdvancements}/1179 | Obsidian Mined: ${requirements.obsidianMined}/1500 | Dragon Eggs: ${requirements.dragonEggs}/5 " +
"| Levels: ${requirements.levels}/250 | Duels Wins: ${requirements.duelsWins}/300"
}
}
@@ -0,0 +1,97 @@
package net.trueog.questsOG.quests
import net.luckperms.api.node.types.PermissionNode
import net.trueog.questsOG.QuestsOG
import org.bukkit.Bukkit
import org.bukkit.Statistic
import org.bukkit.entity.Player
class HomesThree : Quest {
private data class Requirements(
val playerTotalBalance: Int,
val ticksPlayed: Int,
val totalCm: Int,
val hasBeaconator: Boolean,
val levels: Int,
val duelsWins: Int
)
private val beaconatorAdvancement = Bukkit.getServer().advancementIterator().asSequence()
.single { it.key.toString() == "minecraft:nether/create_full_beacon" }
private fun getRequirements(player: Player): Requirements {
val playerTotalBalanceFuture = QuestsOG.diamondBankAPI.getPlayerTotalBalance(player.uniqueId)
val playerTotalBalance = playerTotalBalanceFuture.get()
val ticksPlayed = player.getStatistic(Statistic.PLAY_ONE_MINUTE)
val walkOneCm = player.getStatistic(Statistic.WALK_ONE_CM)
val walkOnWaterOneCm = player.getStatistic(Statistic.WALK_ON_WATER_ONE_CM)
val climbOneCm = player.getStatistic(Statistic.CLIMB_ONE_CM)
// val flyOneCm = player.getStatistic(Statistic.FLY_ONE_CM)
val walkUnderWaterOneCm = player.getStatistic(Statistic.WALK_UNDER_WATER_ONE_CM)
val minecartOneCm = player.getStatistic(Statistic.MINECART_ONE_CM)
val boatOneCm = player.getStatistic(Statistic.BOAT_ONE_CM)
val pigOneCm = player.getStatistic(Statistic.PIG_ONE_CM)
val horseOneCm = player.getStatistic(Statistic.HORSE_ONE_CM)
val sprintOneCm = player.getStatistic(Statistic.SPRINT_ONE_CM)
val crouchOneCm = player.getStatistic(Statistic.CROUCH_ONE_CM)
val aviateOneCm = player.getStatistic(Statistic.AVIATE_ONE_CM)
val swimOneCm = player.getStatistic(Statistic.SWIM_ONE_CM)
val striderOneCm = player.getStatistic(Statistic.STRIDER_ONE_CM)
val totalCm =
walkOneCm + walkOnWaterOneCm + climbOneCm + walkUnderWaterOneCm + minecartOneCm + boatOneCm + pigOneCm + horseOneCm + sprintOneCm + crouchOneCm + aviateOneCm + swimOneCm + striderOneCm
val advancementProgress = player.getAdvancementProgress(beaconatorAdvancement)
val duelsWins = QuestsOG.duels.userManager.get(player.uniqueId)?.wins ?: 0
return Requirements(
playerTotalBalance,
ticksPlayed,
totalCm,
advancementProgress.isDone,
player.level,
duelsWins
)
}
override fun isEligible(player: Player): Boolean {
val requirements = getRequirements(player)
return requirements.playerTotalBalance >= 250 &&
requirements.ticksPlayed / 20.0 / 60.0 / 60.0 / 24.0 >= 5 &&
requirements.totalCm / 100.0 >= 50000 && // 100k?
requirements.hasBeaconator &&
requirements.levels >= 100 &&
requirements.duelsWins >= 20
}
override fun consumeQuestItems(player: Player): Boolean {
val withdrawFuture = QuestsOG.diamondBankAPI.withdrawFromPlayer(player.uniqueId, 250)
val error = withdrawFuture.get()
if (error) {
return true
}
player.level -= 100
return false
}
override fun reward(player: Player) {
val homesTwoNode = PermissionNode.builder("essentials.sethome.multiple.homes-2").build()
val homesThreeNode = PermissionNode.builder("essentials.sethome.multiple.homes-3").build()
QuestsOG.luckPerms.userManager.modifyUser(player.uniqueId) { user ->
user.data().remove(homesTwoNode)
user.data().add(homesThreeNode)
}
}
override fun unmetRequirements(player: Player): String {
val requirements = getRequirements(player)
return "Total Balance: ${requirements.playerTotalBalance}/250 | Ticks Played: ${requirements.ticksPlayed}/8640000 | Total Cm Travelled: ${requirements.totalCm}/5000000 | Beaconator: ${requirements.hasBeaconator} | Levels: ${requirements.levels}/100"
}
}
@@ -0,0 +1,79 @@
package net.trueog.questsOG.quests
import net.luckperms.api.node.types.PermissionNode
import net.trueog.questsOG.QuestsOG
import org.bukkit.Statistic
import org.bukkit.entity.Player
class HomesTwo : Quest {
private data class Requirements(
val playerTotalBalance: Int,
val ticksPlayed: Int,
val totalCm: Int,
val levels: Int,
val duelsWins: Int
)
private fun getRequirements(player: Player): Requirements {
val playerTotalBalanceFuture = QuestsOG.diamondBankAPI.getPlayerTotalBalance(player.uniqueId)
val playerTotalBalance = playerTotalBalanceFuture.get()
val ticksPlayed = player.getStatistic(Statistic.PLAY_ONE_MINUTE)
val walkOneCm = player.getStatistic(Statistic.WALK_ONE_CM)
val walkOnWaterOneCm = player.getStatistic(Statistic.WALK_ON_WATER_ONE_CM)
val climbOneCm = player.getStatistic(Statistic.CLIMB_ONE_CM)
// val flyOneCm = player.getStatistic(Statistic.FLY_ONE_CM)
val walkUnderWaterOneCm = player.getStatistic(Statistic.WALK_UNDER_WATER_ONE_CM)
val minecartOneCm = player.getStatistic(Statistic.MINECART_ONE_CM)
val boatOneCm = player.getStatistic(Statistic.BOAT_ONE_CM)
val pigOneCm = player.getStatistic(Statistic.PIG_ONE_CM)
val horseOneCm = player.getStatistic(Statistic.HORSE_ONE_CM)
val sprintOneCm = player.getStatistic(Statistic.SPRINT_ONE_CM)
val crouchOneCm = player.getStatistic(Statistic.CROUCH_ONE_CM)
val aviateOneCm = player.getStatistic(Statistic.AVIATE_ONE_CM)
val swimOneCm = player.getStatistic(Statistic.SWIM_ONE_CM)
val striderOneCm = player.getStatistic(Statistic.STRIDER_ONE_CM)
val totalCm =
walkOneCm + walkOnWaterOneCm + climbOneCm + walkUnderWaterOneCm + minecartOneCm + boatOneCm + pigOneCm + horseOneCm + sprintOneCm + crouchOneCm + aviateOneCm + swimOneCm + striderOneCm
val duelsWins = QuestsOG.duels.userManager.get(player.uniqueId)?.wins ?: 0
return Requirements(playerTotalBalance, ticksPlayed, totalCm, player.level, duelsWins)
}
override fun isEligible(player: Player): Boolean {
val requirements = getRequirements(player)
return requirements.playerTotalBalance >= 100 &&
requirements.ticksPlayed / 20.0 / 60.0 / 60.0 >= 24 &&
requirements.totalCm / 100.0 >= 10000 &&
requirements.levels >= 50 &&
requirements.duelsWins >= 10
}
override fun consumeQuestItems(player: Player): Boolean {
val withdrawFuture = QuestsOG.diamondBankAPI.withdrawFromPlayer(player.uniqueId, 100)
val error = withdrawFuture.get()
player.level -= 100
return error
}
override fun reward(player: Player) {
val homesOneNode = PermissionNode.builder("essentials.sethome.multiple.homes-1").build()
val homesTwoNode = PermissionNode.builder("essentials.sethome.multiple.homes-2").build()
QuestsOG.luckPerms.userManager.modifyUser(player.uniqueId) { user ->
user.data().remove(homesOneNode)
user.data().add(homesTwoNode)
}
}
override fun unmetRequirements(player: Player): String {
val requirements = getRequirements(player)
return "Total Balance: ${requirements.playerTotalBalance}/100 | Ticks Played: ${requirements.ticksPlayed}/1728000 | Total Cm Travelled: ${requirements.totalCm}/1000000"
}
}
@@ -0,0 +1,13 @@
package net.trueog.questsOG.quests
import org.bukkit.entity.Player
interface Quest {
fun isEligible(player: Player): Boolean
fun consumeQuestItems(player: Player): Boolean
fun reward(player: Player)
fun unmetRequirements(player: Player): String
}
+1
View File
@@ -0,0 +1 @@
redisUrl: redis://127.0.0.1:6379/0
+11
View File
@@ -0,0 +1,11 @@
name: Quests-OG
version: '${version}'
main: net.trueog.questsOG.QuestsOG
api-version: '${apiVersion}'
depend:
- DiamondBank-OG
- Utilities-OG
commands:
claimquest:
description: Claims a quest, duh
usage: /claimquest