Compare commits
16
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b54b3f9eaf | ||
|
|
40ded90edf | ||
|
|
19e0760aa2 | ||
|
|
35f34b2b71 | ||
|
|
37f044751c | ||
|
|
e8c73ead90 | ||
|
|
abd5578be4 | ||
|
|
3b4a4660d0 | ||
|
|
b6630b2639 | ||
|
|
a8f24e8d91 | ||
|
|
cb4601dbfe | ||
|
|
645b019f8d | ||
|
|
a40a838e7a | ||
|
|
c144a71d47 | ||
|
|
78b4b5d25a | ||
|
|
82e16ed007 |
Vendored
+20
@@ -0,0 +1,20 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
stages {
|
||||||
|
stage('Gradle') {
|
||||||
|
steps {
|
||||||
|
sh 'bash gradlew shadowJar -x test'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Archive') {
|
||||||
|
steps {
|
||||||
|
archiveArtifacts artifacts: 'build/libs/', followSymlinks: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('discord') {
|
||||||
|
steps {
|
||||||
|
discordSend description: "Build: ${BUILD_NUMBER}", showChangeset: true, result: currentBuild.currentResult, title: currentBuild.fullProjectName, webhookURL: env.discordwebhook
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-12
@@ -1,13 +1,11 @@
|
|||||||
plugins {
|
plugins {
|
||||||
`java`
|
`java`
|
||||||
`maven-publish`
|
`maven-publish`
|
||||||
id("com.github.johnrengelman.shadow") version "7.0.0"
|
id("com.gradleup.shadow") version "9.0.0-beta4"
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
val build = System.getenv("BUILD_NUMBER") ?: "SNAPSHOT"
|
|
||||||
group = "com.alttd.proxydiscordlink"
|
group = "com.alttd.proxydiscordlink"
|
||||||
version = "1.0.0-BETA-$build"
|
|
||||||
description = "A velocity plugin to link Discord and Minecraft accounts."
|
description = "A velocity plugin to link Discord and Minecraft accounts."
|
||||||
|
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
@@ -15,14 +13,14 @@ allprojects {
|
|||||||
|
|
||||||
java {
|
java {
|
||||||
toolchain {
|
toolchain {
|
||||||
languageVersion.set(JavaLanguageVersion.of(16))
|
languageVersion.set(JavaLanguageVersion.of(21))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
withType<JavaCompile> {
|
withType<JavaCompile> {
|
||||||
options.encoding = Charsets.UTF_8.name()
|
options.encoding = Charsets.UTF_8.name()
|
||||||
options.release.set(16)
|
options.release.set(21)
|
||||||
}
|
}
|
||||||
|
|
||||||
withType<Javadoc> {
|
withType<Javadoc> {
|
||||||
@@ -31,6 +29,10 @@ allprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// Minimessage
|
// Minimessage
|
||||||
// implementation("net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT")
|
// implementation("net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT")
|
||||||
@@ -51,17 +53,18 @@ dependencies {
|
|||||||
compileOnly("com.alttd:ShutdownInfo:1.0")
|
compileOnly("com.alttd:ShutdownInfo:1.0")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
implementation("org.aarboard.nextcloud:nextcloud-api:13.1.0") //NextCloud
|
||||||
|
|
||||||
|
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
|
||||||
|
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0")
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
archiveFileName.set("${project.name}-${project.version}.jar")
|
|
||||||
// exclude("net.kyori.adventure")
|
archiveFileName.set("ProxyDiscordLink.jar")
|
||||||
// exclude("net.kyori.examination")
|
|
||||||
minimize {
|
|
||||||
//exclude(dependency("net.kyori:.*:.*"))
|
|
||||||
}
|
|
||||||
listOf(
|
listOf(
|
||||||
// "net.kyori",
|
|
||||||
"net.dv8tion.jda"
|
"net.dv8tion.jda"
|
||||||
).forEach { relocate(it, "${rootProject.group}.lib.$it") }
|
).forEach { relocate(it, "${rootProject.group}.lib.$it") }
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
+3
-1
@@ -1,5 +1,7 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Copyright 2015 the original author or authors.
|
# Copyright © 2015-2021 the original authors.
|
||||||
#
|
#
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
# you may not use this file except in compliance with the License.
|
# you may not use this file except in compliance with the License.
|
||||||
@@ -17,67 +17,99 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
#
|
||||||
## Gradle start up script for UN*X
|
# 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/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
|
# Attempt to set APP_HOME
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
# Resolve links: $0 may be a link
|
||||||
PRG="$0"
|
app_path=$0
|
||||||
# Need this for relative symlinks.
|
|
||||||
while [ -h "$PRG" ] ; do
|
# Need this for daisy-chained symlinks.
|
||||||
ls=`ls -ld "$PRG"`
|
while
|
||||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
||||||
if expr "$link" : '/.*' > /dev/null; then
|
[ -h "$app_path" ]
|
||||||
PRG="$link"
|
do
|
||||||
else
|
ls=$( ls -ld "$app_path" )
|
||||||
PRG=`dirname "$PRG"`"/$link"
|
link=${ls#*' -> '}
|
||||||
fi
|
case $link in #(
|
||||||
|
/*) app_path=$link ;; #(
|
||||||
|
*) app_path=$APP_HOME$link ;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
SAVED="`pwd`"
|
|
||||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
|
||||||
APP_HOME="`pwd -P`"
|
|
||||||
cd "$SAVED" >/dev/null
|
|
||||||
|
|
||||||
APP_NAME="Gradle"
|
# This is normally unused
|
||||||
APP_BASE_NAME=`basename "$0"`
|
# shellcheck disable=SC2034
|
||||||
|
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.
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD=maximum
|
||||||
|
|
||||||
warn () {
|
warn () {
|
||||||
echo "$*"
|
echo "$*"
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
die () {
|
die () {
|
||||||
echo
|
echo
|
||||||
echo "$*"
|
echo "$*"
|
||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
}
|
} >&2
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
# OS specific support (must be 'true' or 'false').
|
||||||
cygwin=false
|
cygwin=false
|
||||||
msys=false
|
msys=false
|
||||||
darwin=false
|
darwin=false
|
||||||
nonstop=false
|
nonstop=false
|
||||||
case "`uname`" in
|
case "$( uname )" in #(
|
||||||
CYGWIN* )
|
CYGWIN* ) cygwin=true ;; #(
|
||||||
cygwin=true
|
Darwin* ) darwin=true ;; #(
|
||||||
;;
|
MSYS* | MINGW* ) msys=true ;; #(
|
||||||
Darwin* )
|
NONSTOP* ) nonstop=true ;;
|
||||||
darwin=true
|
|
||||||
;;
|
|
||||||
MINGW* )
|
|
||||||
msys=true
|
|
||||||
;;
|
|
||||||
NONSTOP* )
|
|
||||||
nonstop=true
|
|
||||||
;;
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||||
@@ -87,9 +119,9 @@ CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|||||||
if [ -n "$JAVA_HOME" ] ; then
|
if [ -n "$JAVA_HOME" ] ; then
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
# IBM's JDK on AIX uses strange locations for the executables
|
||||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
JAVACMD=$JAVA_HOME/jre/sh/java
|
||||||
else
|
else
|
||||||
JAVACMD="$JAVA_HOME/bin/java"
|
JAVACMD=$JAVA_HOME/bin/java
|
||||||
fi
|
fi
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
if [ ! -x "$JAVACMD" ] ; then
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||||
@@ -98,88 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the
|
|||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
JAVACMD="java"
|
JAVACMD=java
|
||||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
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
|
Please set the JAVA_HOME variable in your environment to match the
|
||||||
location of your Java installation."
|
location of your Java installation."
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
# Increase the maximum file descriptors if we can.
|
||||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
MAX_FD_LIMIT=`ulimit -H -n`
|
case $MAX_FD in #(
|
||||||
if [ $? -eq 0 ] ; then
|
max*)
|
||||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
MAX_FD="$MAX_FD_LIMIT"
|
# shellcheck disable=SC3045
|
||||||
fi
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
ulimit -n $MAX_FD
|
warn "Could not query maximum file descriptor limit"
|
||||||
if [ $? -ne 0 ] ; then
|
esac
|
||||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
case $MAX_FD in #(
|
||||||
fi
|
'' | soft) :;; #(
|
||||||
else
|
*)
|
||||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
fi
|
# shellcheck disable=SC3045
|
||||||
fi
|
ulimit -n "$MAX_FD" ||
|
||||||
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
# For Darwin, add options to specify how the application appears in the dock
|
|
||||||
if $darwin; then
|
|
||||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
|
||||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
|
||||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
|
||||||
|
|
||||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
|
||||||
|
|
||||||
# We build the pattern for arguments to be converted via cygpath
|
|
||||||
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
|
|
||||||
SEP=""
|
|
||||||
for dir in $ROOTDIRSRAW ; do
|
|
||||||
ROOTDIRS="$ROOTDIRS$SEP$dir"
|
|
||||||
SEP="|"
|
|
||||||
done
|
|
||||||
OURCYGPATTERN="(^($ROOTDIRS))"
|
|
||||||
# Add a user-defined pattern to the cygpath arguments
|
|
||||||
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
|
|
||||||
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
|
|
||||||
fi
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
i=0
|
|
||||||
for arg in "$@" ; do
|
|
||||||
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
|
||||||
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
|
||||||
else
|
|
||||||
eval `echo args$i`="\"$arg\""
|
|
||||||
fi
|
|
||||||
i=`expr $i + 1`
|
|
||||||
done
|
|
||||||
case $i in
|
|
||||||
0) set -- ;;
|
|
||||||
1) set -- "$args0" ;;
|
|
||||||
2) set -- "$args0" "$args1" ;;
|
|
||||||
3) set -- "$args0" "$args1" "$args2" ;;
|
|
||||||
4) set -- "$args0" "$args1" "$args2" "$args3" ;;
|
|
||||||
5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
|
|
||||||
6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
|
|
||||||
7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
|
|
||||||
8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
|
|
||||||
9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
|
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Escape application args
|
# Collect all arguments for the java command, stacking in reverse order:
|
||||||
save () {
|
# * args from the command line
|
||||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
# * the main class name
|
||||||
echo " "
|
# * -classpath
|
||||||
}
|
# * -D...appname settings
|
||||||
APP_ARGS=`save "$@"`
|
# * --module-path (only if needed)
|
||||||
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
||||||
|
|
||||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
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, 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 \
|
||||||
|
"$@"
|
||||||
|
|
||||||
|
# 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" "$@"
|
exec "$JAVACMD" "$@"
|
||||||
|
|||||||
Vendored
+7
-4
@@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
|
|||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
@@ -51,6 +51,10 @@ public class DiscordLink {
|
|||||||
cache = new Cache();
|
cache = new Cache();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO set up a repeating task that checks if ppl with the link role are really linked
|
||||||
|
//TODO fix unlinking in game not unlinking in discord
|
||||||
|
//TODO fix nitro booster role not being removed in game (set up a command to force check?)
|
||||||
|
//TODO fix &sync
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||||
ALogger.init(logger);
|
ALogger.init(logger);
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
package com.alttd.proxydiscordlink.bot;
|
package com.alttd.proxydiscordlink.bot;
|
||||||
|
|
||||||
import com.alttd.proxydiscordlink.JDAListener;
|
import com.alttd.proxydiscordlink.JDAListener;
|
||||||
import com.alttd.proxydiscordlink.bot.commandManager.CommandManager;
|
import com.alttd.proxydiscordlink.DiscordLink;
|
||||||
import com.alttd.proxydiscordlink.bot.listeners.DiscordRoleListener;
|
import com.alttd.proxydiscordlink.bot.listeners.DiscordRoleListener;
|
||||||
|
import com.alttd.proxydiscordlink.bot.tasks.CheckLinkSync;
|
||||||
import com.alttd.proxydiscordlink.config.BotConfig;
|
import com.alttd.proxydiscordlink.config.BotConfig;
|
||||||
import com.alttd.proxydiscordlink.util.ALogger;
|
import com.alttd.proxydiscordlink.util.ALogger;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
@@ -15,10 +16,12 @@ import net.dv8tion.jda.api.entities.Role;
|
|||||||
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
import net.dv8tion.jda.api.entities.channel.concrete.TextChannel;
|
||||||
import net.dv8tion.jda.api.exceptions.HierarchyException;
|
import net.dv8tion.jda.api.exceptions.HierarchyException;
|
||||||
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
|
import net.dv8tion.jda.api.exceptions.InsufficientPermissionException;
|
||||||
|
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||||
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
import net.dv8tion.jda.api.utils.MemberCachePolicy;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@@ -34,10 +37,15 @@ public class Bot {
|
|||||||
.enableIntents(GatewayIntent.GUILD_MEMBERS)
|
.enableIntents(GatewayIntent.GUILD_MEMBERS)
|
||||||
.build();
|
.build();
|
||||||
jda.setAutoReconnect(true);
|
jda.setAutoReconnect(true);
|
||||||
|
jda.awaitReady();
|
||||||
jda.addEventListener(
|
jda.addEventListener(
|
||||||
new DiscordRoleListener(),
|
new DiscordRoleListener(),
|
||||||
new JDAListener(jda)); //This executes code after jda is done loading
|
new JDAListener(jda));
|
||||||
} catch (Exception e) {
|
DiscordLink.getPlugin().getProxy().getScheduler().buildTask(DiscordLink.getPlugin(), new CheckLinkSync())
|
||||||
|
.delay(120, TimeUnit.SECONDS)
|
||||||
|
.repeat(12, TimeUnit.HOURS)
|
||||||
|
.schedule();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -231,4 +239,20 @@ public class Bot {
|
|||||||
ALogger.warn("Unable to ban " + member.getAsMention() + " : " + member.getId() + " from Discord they might be above me.");
|
ALogger.warn("Unable to ban " + member.getAsMention() + " : " + member.getId() + " from Discord they might be above me.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Member> getMembersWithRole(long guildId, long roleId) {
|
||||||
|
Guild guild = jda.getGuildById(guildId);
|
||||||
|
Role role = jda.getRoleById(roleId);
|
||||||
|
|
||||||
|
if (guild == null) {
|
||||||
|
//TODO error
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (role == null) {
|
||||||
|
//TODO error
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return guild.getMembers().stream().filter(member -> member.getRoles().contains(role)).toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
package com.alttd.proxydiscordlink.bot;
|
|
||||||
|
|
||||||
import com.alttd.proxydiscordlink.bot.commands.*;
|
|
||||||
import net.dv8tion.jda.api.entities.Message;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public abstract class DiscordCommand {
|
|
||||||
|
|
||||||
private static List<DiscordCommand> commands;
|
|
||||||
|
|
||||||
public abstract String getCommand();
|
|
||||||
public abstract String getPermission();// TODO discord and LP permissions
|
|
||||||
public abstract String getDescription();
|
|
||||||
public abstract String getSyntax();
|
|
||||||
public abstract long getChannel();
|
|
||||||
|
|
||||||
public abstract void handleCommand(Message message, String sender, String command, String[] args);
|
|
||||||
|
|
||||||
public static void loadCommands() {
|
|
||||||
commands = new ArrayList<>();
|
|
||||||
|
|
||||||
loadCommand(new DiscordLinkCommand(),
|
|
||||||
new DiscordUnlink(),
|
|
||||||
new DiscordNick(),
|
|
||||||
new DiscordStaffList(),
|
|
||||||
new DiscordServerList()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadCommand(DiscordCommand ... discordCommands) {
|
|
||||||
Collections.addAll(commands, discordCommands);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<DiscordCommand> getCommands() {
|
|
||||||
return commands;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -37,13 +37,6 @@ public class CommandManager extends ListenerAdapter {
|
|||||||
.filter(discordCommand -> discordCommand.getName().equalsIgnoreCase(commandName))
|
.filter(discordCommand -> discordCommand.getName().equalsIgnoreCase(commandName))
|
||||||
.findFirst();
|
.findFirst();
|
||||||
if (first.isEmpty()) {
|
if (first.isEmpty()) {
|
||||||
event.replyEmbeds(new EmbedBuilder()
|
|
||||||
.setTitle("Invalid command")
|
|
||||||
.setDescription("We couldn't find a command called [" + commandName + "], please report this issue to a Teri")
|
|
||||||
.setColor(Color.RED)
|
|
||||||
.build())
|
|
||||||
.setEphemeral(true)
|
|
||||||
.queue();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
first.get().execute(event);
|
first.get().execute(event);
|
||||||
|
|||||||
+5
-5
@@ -28,7 +28,7 @@ public class CommandLink extends DiscordCommand {
|
|||||||
private final CommandData commandData;
|
private final CommandData commandData;
|
||||||
public CommandLink(JDA jda) {
|
public CommandLink(JDA jda) {
|
||||||
commandData = Commands.slash(getName(), "Link your Discord and Altitude Minecraft accounts")
|
commandData = Commands.slash(getName(), "Link your Discord and Altitude Minecraft accounts")
|
||||||
.addOption(OptionType.NUMBER, "code", "The code you got from doing /discord link on Altitude in Minecraft", true)
|
.addOption(OptionType.STRING, "code", "The code you got from doing /discord link on Altitude in Minecraft", true)
|
||||||
.setDefaultPermissions(DefaultMemberPermissions.ENABLED);
|
.setDefaultPermissions(DefaultMemberPermissions.ENABLED);
|
||||||
|
|
||||||
Utilities.registerCommand(jda, commandData);
|
Utilities.registerCommand(jda, commandData);
|
||||||
@@ -47,7 +47,7 @@ public class CommandLink extends DiscordCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID uuid = getUUID(event.getOption("link", OptionMapping::getAsInt));
|
UUID uuid = getUUID(event.getOption("code", OptionMapping::getAsString));
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
Utilities.commandErrAutoRem("This is not a valid link code, please check Minecraft and try again", event);
|
Utilities.commandErrAutoRem("This is not a valid link code, please check Minecraft and try again", event);
|
||||||
return;
|
return;
|
||||||
@@ -127,10 +127,10 @@ public class CommandLink extends DiscordCommand {
|
|||||||
return "No User";
|
return "No User";
|
||||||
}
|
}
|
||||||
|
|
||||||
private UUID getUUID(Integer code) {
|
private UUID getUUID(String code) {
|
||||||
if (code == null)
|
if (code == null || !code.matches("[0-9]{6}"))
|
||||||
return null;
|
return null;
|
||||||
return DiscordLink.getPlugin().getCache().getUUID(String.valueOf(code));
|
return DiscordLink.getPlugin().getCache().getUUID(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
+5
-2
@@ -13,6 +13,7 @@ import net.dv8tion.jda.api.interactions.commands.DefaultMemberPermissions;
|
|||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
import net.dv8tion.jda.api.interactions.commands.build.CommandData;
|
||||||
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
import net.dv8tion.jda.api.interactions.commands.build.Commands;
|
||||||
|
import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@@ -20,8 +21,10 @@ public class CommandNick extends DiscordCommand {
|
|||||||
CommandData commandData;
|
CommandData commandData;
|
||||||
private final HashMap<String, SubOption> subOptionsMap = new HashMap<>();
|
private final HashMap<String, SubOption> subOptionsMap = new HashMap<>();
|
||||||
public CommandNick(JDA jda) {
|
public CommandNick(JDA jda) {
|
||||||
commandData = Commands.slash(getName(), "Create an auction")
|
commandData = Commands.slash(getName(), "Change your nickname to be your mc name/nickname")
|
||||||
.addOption(OptionType.NUMBER, "code", "The code you got from doing /discord link on Altitude in Minecraft", true)
|
.addSubcommands(new SubcommandData("username", "Change your name to your Minecraft username"),
|
||||||
|
new SubcommandData("nickname", "Change your name to your Minecraft nickname")
|
||||||
|
)
|
||||||
.setDefaultPermissions(DefaultMemberPermissions.ENABLED);
|
.setDefaultPermissions(DefaultMemberPermissions.ENABLED);
|
||||||
Utilities.registerSubOptions(subOptionsMap,
|
Utilities.registerSubOptions(subOptionsMap,
|
||||||
new SubCommandUserName(null,this),
|
new SubCommandUserName(null,this),
|
||||||
|
|||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package com.alttd.proxydiscordlink.bot.tasks;
|
||||||
|
|
||||||
|
import com.alttd.proxydiscordlink.DiscordLink;
|
||||||
|
import com.alttd.proxydiscordlink.bot.Bot;
|
||||||
|
import com.alttd.proxydiscordlink.config.BotConfig;
|
||||||
|
import com.alttd.proxydiscordlink.util.ALogger;
|
||||||
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public class CheckLinkSync implements Runnable {
|
||||||
|
|
||||||
|
private final DiscordLink plugin;
|
||||||
|
private final Bot bot;
|
||||||
|
|
||||||
|
public CheckLinkSync() {
|
||||||
|
plugin = DiscordLink.getPlugin();
|
||||||
|
bot = plugin.getBot();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
List<Member> members = bot.getMembersWithRole(BotConfig.DISCORD.GUILD_ID, BotConfig.DISCORD.LINKED_ROLE_ID);
|
||||||
|
HashSet<Long> dbIdSet = plugin.getDatabase().getLinkedUsers();
|
||||||
|
HashSet<Long> membersIdSet = members.stream().map(Member::getIdLong).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
|
//give these people the link role in discord, if they are not in the discord unlink them in game
|
||||||
|
HashSet<Long> noRoleIds = dbIdSet.stream().filter(id -> !membersIdSet.contains(id)).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
|
//remove the linked role from these people
|
||||||
|
HashSet<Long> notInDbIds = membersIdSet.stream().filter(id -> !dbIdSet.contains(id)).collect(Collectors.toCollection(HashSet::new));
|
||||||
|
|
||||||
|
fixNotInDb(members, notInDbIds);
|
||||||
|
fixNoLinkRole(members, noRoleIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fixNotInDb(List<Member> members, Set<Long> notInDbIds) {
|
||||||
|
for (Long id : notInDbIds) {
|
||||||
|
members.stream()
|
||||||
|
.filter(member -> member.getIdLong() == id)
|
||||||
|
.findAny()
|
||||||
|
.ifPresent(member -> {
|
||||||
|
ALogger.info("Removing linked role from user with discord id: [" + id + "] due to them not being in the database.");
|
||||||
|
// bot.removeRole(id, BotConfig.LINKED_ROLE_ID, member.getGuild().getIdLong());
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fixNoLinkRole(List<Member> members, Set<Long> noRoleIds) {
|
||||||
|
for (Long id : noRoleIds) {
|
||||||
|
members.stream()
|
||||||
|
.filter(member -> member.getIdLong() == id)
|
||||||
|
.findAny()
|
||||||
|
.ifPresentOrElse(
|
||||||
|
member -> {
|
||||||
|
ALogger.info("Adding role to user with discord id: [" + id + "] due to them being in the database without having a role in discord.");
|
||||||
|
// bot.addRole(id, BotConfig.LINKED_ROLE_ID, member.getGuild().getIdLong());
|
||||||
|
}, () -> {
|
||||||
|
ALogger.info("Removing user with discord id: [" + id + "] from the database due to them not being in the discord.");
|
||||||
|
// plugin.getDatabase().removeLinkedAccount(id);
|
||||||
|
});
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.alttd.proxydiscordlink.bot.tasks;
|
||||||
|
|
||||||
|
public class CheckNitroSync {
|
||||||
|
|
||||||
|
//TODO copy CheckLinkSync but for nitro
|
||||||
|
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ public class BotConfig {
|
|||||||
public static File CONFIGPATH;
|
public static File CONFIGPATH;
|
||||||
|
|
||||||
public static void init() { // todo setup share for the config
|
public static void init() { // todo setup share for the config
|
||||||
CONFIGPATH = new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "DiscordLink");
|
CONFIGPATH = new File(File.separator + "mnt" + File.separator + "configs" + File.separator + "DiscordLink");
|
||||||
CONFIG_FILE = new File(CONFIGPATH, "bot-config.yml");
|
CONFIG_FILE = new File(CONFIGPATH, "bot-config.yml");
|
||||||
|
|
||||||
configLoader = YAMLConfigurationLoader.builder()
|
configLoader = YAMLConfigurationLoader.builder()
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public final class Config {
|
|||||||
public static File CONFIGPATH;
|
public static File CONFIGPATH;
|
||||||
|
|
||||||
public static void init() { // todo setup share for the config
|
public static void init() { // todo setup share for the config
|
||||||
CONFIGPATH = new File(System.getProperty("user.home") + File.separator + "share" + File.separator + "configs" + File.separator + "DiscordLink");
|
CONFIGPATH = new File(File.separator + "mnt" + File.separator + "configs" + File.separator + "DiscordLink");
|
||||||
CONFIG_FILE = new File(CONFIGPATH, "config.yml");
|
CONFIG_FILE = new File(CONFIGPATH, "config.yml");
|
||||||
|
|
||||||
configLoader = YAMLConfigurationLoader.builder()
|
configLoader = YAMLConfigurationLoader.builder()
|
||||||
@@ -195,6 +195,38 @@ public final class Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class WORDPRESS_DB {
|
||||||
|
public static String DRIVERS = "mysql";
|
||||||
|
public static String IP = "localhost";
|
||||||
|
public static String PORT = "3306";
|
||||||
|
public static String DATABASE_NAME = "wordpress";
|
||||||
|
public static String USERNAME = "root";
|
||||||
|
public static String PASSWORD = "root";
|
||||||
|
|
||||||
|
private static void database() {
|
||||||
|
DRIVERS = getString("database.drivers", DRIVERS);
|
||||||
|
IP = getString("database.ip", IP);
|
||||||
|
PORT = getString("database.port", PORT);
|
||||||
|
DATABASE_NAME = getString("database.database_name", DATABASE_NAME);
|
||||||
|
USERNAME = getString("database.username", USERNAME);
|
||||||
|
PASSWORD = getString("database.password", PASSWORD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class NEXT_CLOUD {
|
||||||
|
public static String ADDRESS = "drive.alttd.com";
|
||||||
|
public static Integer PORT = 443;
|
||||||
|
public static String USERNAME = "root";
|
||||||
|
public static String PASSWORD = "root";
|
||||||
|
|
||||||
|
private static void loadNextCloud() {
|
||||||
|
ADDRESS = getString("next_cloud.address", ADDRESS);
|
||||||
|
PORT = getInt("next_cloud.port", PORT);
|
||||||
|
USERNAME = getString("next_cloud.username", USERNAME);
|
||||||
|
PASSWORD = getString("next_cloud.password", PASSWORD);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class MESSAGES {
|
public static class MESSAGES {
|
||||||
|
|
||||||
public static String ALREADY_LINKED_ACCOUNTS = "<yellow>Your accounts are already linked. You can unlink your accounts by doing <gold>/discord unlink</gold>.</yellow>";
|
public static String ALREADY_LINKED_ACCOUNTS = "<yellow>Your accounts are already linked. You can unlink your accounts by doing <gold>/discord unlink</gold>.</yellow>";
|
||||||
@@ -215,8 +247,8 @@ public final class Config {
|
|||||||
public static String HELP_RELOAD = "<yellow><gold>/discord reload</gold>: Reload the config.</yellow>";
|
public static String HELP_RELOAD = "<yellow><gold>/discord reload</gold>: Reload the config.</yellow>";
|
||||||
public static String HELP_SYNC = "<yellow><gold>/discord sync</gold>: Manually synchronize your roles across Discord and Minecraft.</yellow>";
|
public static String HELP_SYNC = "<yellow><gold>/discord sync</gold>: Manually synchronize your roles across Discord and Minecraft.</yellow>";
|
||||||
public static List<String> DISCORD_MESSAGE = new ArrayList<>(List.of("Invite code here."));
|
public static List<String> DISCORD_MESSAGE = new ArrayList<>(List.of("Invite code here."));
|
||||||
public static String DISCORD_LINK = "<click:run:command:discord link:><yellow>Your Minecraft and Discord accounts aren't linked yet, to link them click this message!</yellow></click>";
|
public static String DISCORD_LINK = "<click:run_command:'/discord link'><yellow>Your Minecraft and Discord accounts aren't linked yet, to link them click this message!</yellow></click>";
|
||||||
public static String GIVE_CODE = "<yellow>Your code is <gold><code></gold>, To link your accounts do <gold>&link <code></gold> in the Discord #link channel.</yellow>";
|
public static String GIVE_CODE = "<yellow>Your code is <gold><code></gold>, To link your accounts do <gold>&link <code></gold> in the Discord #link channel. You can join the Discord here <click:open_url:'https://discord.gg/TGqpzCJ'></click></yellow>";
|
||||||
|
|
||||||
private static void loadMessages() {
|
private static void loadMessages() {
|
||||||
DISCORD_MESSAGE = getList("messages.discord-message", DISCORD_MESSAGE);
|
DISCORD_MESSAGE = getList("messages.discord-message", DISCORD_MESSAGE);
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
package com.alttd.proxydiscordlink.database;
|
package com.alttd.proxydiscordlink.database;
|
||||||
|
|
||||||
import com.alttd.proxydiscordlink.objects.DiscordLinkPlayer;
|
import com.alttd.proxydiscordlink.objects.DiscordLinkPlayer;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class Database {
|
public class Database {
|
||||||
@@ -103,6 +104,19 @@ public class Database {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeRole(UUID uuid, String roleName) {
|
||||||
|
try {
|
||||||
|
String sql = "DELETE FROM account_roles WHERE uuid = ? AND role_name = ?";
|
||||||
|
|
||||||
|
PreparedStatement statement = DatabaseConnection.getConnection().prepareStatement(sql);
|
||||||
|
statement.setString(1, uuid.toString());
|
||||||
|
statement.setString(2, roleName);
|
||||||
|
statement.execute();
|
||||||
|
} catch (SQLException exception) {
|
||||||
|
exception.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean playerIsLinked(UUID uuid) { //TODO maybe this can be using the discord api instead? (or a cache idk)
|
public boolean playerIsLinked(UUID uuid) { //TODO maybe this can be using the discord api instead? (or a cache idk)
|
||||||
try {
|
try {
|
||||||
PreparedStatement statement = DatabaseConnection.getConnection()
|
PreparedStatement statement = DatabaseConnection.getConnection()
|
||||||
@@ -149,7 +163,17 @@ public class Database {
|
|||||||
} catch (SQLException var2) {
|
} catch (SQLException var2) {
|
||||||
var2.printStackTrace();
|
var2.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeLinkedAccount(Long id) {
|
||||||
|
try {
|
||||||
|
PreparedStatement statement = DatabaseConnection.getConnection()
|
||||||
|
.prepareStatement("DELETE FROM linked_accounts WHERE discord_id = ?");
|
||||||
|
statement.setLong(1, id);
|
||||||
|
statement.executeUpdate();
|
||||||
|
} catch (SQLException var2) {
|
||||||
|
var2.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String uuidFromName(String playerName) {
|
public String uuidFromName(String playerName) {
|
||||||
@@ -269,4 +293,20 @@ public class Database {
|
|||||||
exception.printStackTrace();
|
exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HashSet<Long> getLinkedUsers() {
|
||||||
|
String sql = "SELECT discord_id FROM linked_accounts";
|
||||||
|
try {
|
||||||
|
PreparedStatement statement = DatabaseConnection.getConnection().prepareStatement(sql);
|
||||||
|
ResultSet resultSet = statement.executeQuery();
|
||||||
|
HashSet<Long> results = new HashSet<>();
|
||||||
|
while (resultSet.next()) {
|
||||||
|
results.add(resultSet.getLong("discord_id"));
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+60
-17
@@ -3,12 +3,17 @@ package com.alttd.proxydiscordlink.minecraft.listeners;
|
|||||||
import com.alttd.proxydiscordlink.DiscordLink;
|
import com.alttd.proxydiscordlink.DiscordLink;
|
||||||
import com.alttd.proxydiscordlink.config.BotConfig;
|
import com.alttd.proxydiscordlink.config.BotConfig;
|
||||||
import com.alttd.proxydiscordlink.objects.DiscordLinkPlayer;
|
import com.alttd.proxydiscordlink.objects.DiscordLinkPlayer;
|
||||||
|
import com.alttd.proxydiscordlink.util.Evidence;
|
||||||
|
import com.alttd.proxydiscordlink.util.Utilities;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import litebans.api.Entry;
|
import litebans.api.Entry;
|
||||||
import litebans.api.Events;
|
import litebans.api.Events;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
|
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||||
|
import net.luckperms.api.model.user.User;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.time.Instant;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -32,39 +37,77 @@ public class LiteBansBanListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void onBan(Entry entry) {
|
private void onBan(Entry entry) {
|
||||||
if (!entry.isPermanent())
|
if (entry == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String stringUuid = entry.getUuid();
|
String stringUuid = entry.getUuid();
|
||||||
if (stringUuid == null)
|
if (stringUuid == null)
|
||||||
return;
|
return;
|
||||||
UUID uuid = UUID.fromString(stringUuid);
|
UUID uuid = UUID.fromString(stringUuid);
|
||||||
|
|
||||||
|
Optional<Player> player = DiscordLink.getPlugin().getProxy().getPlayer(uuid);
|
||||||
|
String username;
|
||||||
|
|
||||||
|
if (player.isPresent()) {
|
||||||
|
username = player.get().getUsername();
|
||||||
|
} else {
|
||||||
|
User user = Utilities.getLuckPerms().getUserManager().getUser(uuid);
|
||||||
|
if (user == null) {
|
||||||
|
username = uuid.toString();
|
||||||
|
} else {
|
||||||
|
username = user.getUsername();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Evidence evidence = new Evidence();
|
||||||
|
evidence.getNewEvidenceFolder(username).thenAcceptAsync(optionalUrl -> {
|
||||||
|
Optional<MessageEmbed.Field> field = banDiscordUserIfExists(entry, uuid);
|
||||||
|
|
||||||
|
EmbedBuilder banEvidence = new EmbedBuilder()
|
||||||
|
.setColor(entry.isPermanent() ? Color.RED : Color.ORANGE)
|
||||||
|
.setAuthor(username, null, "https://crafatar.com/avatars/" + stringUuid + "?overlay")
|
||||||
|
.addField("Banned by", entry.getExecutorName() == null ? "unknown" : entry.getExecutorName(), true)
|
||||||
|
.addField("Ban duration", getBanDuration(entry), true)
|
||||||
|
.addField("Reason", entry.getReason() == null ? "unknown" : entry.getReason(), true)
|
||||||
|
.setTitle("Auto Discord ban");
|
||||||
|
|
||||||
|
if (optionalUrl.isPresent()) {
|
||||||
|
banEvidence.addField("Evidence", optionalUrl.get(), false);
|
||||||
|
} else {
|
||||||
|
banEvidence.addField("Evidence", "Failed to get url, please make the folder yourself and reply to this post with the link.", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
field.ifPresent(banEvidence::addField);
|
||||||
|
|
||||||
|
DiscordLink.getPlugin().getBot().sendEmbedToDiscord(BotConfig.DISCORD.EVIDENCE_CHANNEL_ID, banEvidence, -1);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getBanDuration(Entry entry) {
|
||||||
|
if (entry.isPermanent())
|
||||||
|
return "Permanent ban";
|
||||||
|
Instant instant = Instant.ofEpochMilli(entry.getDateEnd());
|
||||||
|
return String.format("<t:%d:F>", instant.getEpochSecond());
|
||||||
|
}
|
||||||
|
|
||||||
|
private Optional<MessageEmbed.Field> banDiscordUserIfExists(Entry entry, UUID uuid) {
|
||||||
|
if (!entry.isPermanent())
|
||||||
|
return Optional.empty();
|
||||||
|
|
||||||
DiscordLinkPlayer discordLinkPlayer = DiscordLinkPlayer.getDiscordLinkPlayer(uuid);
|
DiscordLinkPlayer discordLinkPlayer = DiscordLinkPlayer.getDiscordLinkPlayer(uuid);
|
||||||
if (discordLinkPlayer == null || !discordLinkPlayer.isActive())
|
if (discordLinkPlayer == null || !discordLinkPlayer.isActive())
|
||||||
return;
|
return Optional.empty();
|
||||||
discordLinkPlayer.setActive(false);
|
discordLinkPlayer.setActive(false);
|
||||||
|
|
||||||
DiscordLink.getPlugin().getBot().discordBan(BotConfig.DISCORD.GUILD_ID, discordLinkPlayer.getUserId(), "Auto ban due to Minecraft ban");
|
DiscordLink.getPlugin().getBot().discordBan(BotConfig.DISCORD.GUILD_ID, discordLinkPlayer.getUserId(), "Auto ban due to Minecraft ban");
|
||||||
Optional<Player> player = DiscordLink.getPlugin().getProxy().getPlayer(uuid);
|
|
||||||
|
|
||||||
String username = discordLinkPlayer.getUsername();
|
return Optional.of(new MessageEmbed.Field("Auto Discord ban",
|
||||||
if (player.isPresent())
|
|
||||||
username = player.get().getUsername();
|
|
||||||
|
|
||||||
DiscordLink.getPlugin().getBot().sendEmbedToDiscord(BotConfig.DISCORD.EVIDENCE_CHANNEL_ID,
|
|
||||||
new EmbedBuilder()
|
|
||||||
.setColor(Color.RED)
|
|
||||||
.setAuthor(username, null, "https://crafatar.com/avatars/" + stringUuid + "?overlay")
|
|
||||||
.setTitle("Auto Discord ban")
|
|
||||||
.addField("Ban info",
|
|
||||||
"**Discord username**: `" + discordLinkPlayer.getDiscordUsername() + "`" +
|
"**Discord username**: `" + discordLinkPlayer.getDiscordUsername() + "`" +
|
||||||
"\n**Discord id**: `" + discordLinkPlayer.getUserId() + "`" +
|
"\n**Discord id**: `" + discordLinkPlayer.getUserId() + "`" +
|
||||||
"\n**UUID**: `" + stringUuid + "`" +
|
"\n**UUID**: `" + uuid.toString() + "`" +
|
||||||
"\n**Banned by**: `" + entry.getExecutorName() + "`" +
|
"\n**Banned by**: `" + entry.getExecutorName() + "`" +
|
||||||
"\n**For**: ```" + (entry.getReason().length() < 800 ? entry.getReason() : entry.getReason().substring(0, 797) + "...") + "```",
|
"\n**For**: ```" + (entry.getReason().length() < 800 ? entry.getReason() : entry.getReason().substring(0, 797) + "...") + "```",
|
||||||
false),
|
false)
|
||||||
-1);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onUnBan(Entry entry) {
|
private void onUnBan(Entry entry) {
|
||||||
|
|||||||
@@ -3,9 +3,14 @@ package com.alttd.proxydiscordlink.minecraft.listeners;
|
|||||||
import com.alttd.proxydiscordlink.DiscordLink;
|
import com.alttd.proxydiscordlink.DiscordLink;
|
||||||
import com.alttd.proxydiscordlink.config.BotConfig;
|
import com.alttd.proxydiscordlink.config.BotConfig;
|
||||||
import com.alttd.proxydiscordlink.objects.DiscordLinkPlayer;
|
import com.alttd.proxydiscordlink.objects.DiscordLinkPlayer;
|
||||||
|
import com.alttd.proxydiscordlink.util.ALogger;
|
||||||
|
import com.alttd.proxydiscordlink.util.Utilities;
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||||
|
import com.velocitypowered.api.proxy.Player;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class PlayerJoin {
|
public class PlayerJoin {
|
||||||
|
|
||||||
@@ -13,14 +18,16 @@ public class PlayerJoin {
|
|||||||
public void playerConnected(ServerConnectedEvent event) {
|
public void playerConnected(ServerConnectedEvent event) {
|
||||||
if (event.getPreviousServer().isPresent())
|
if (event.getPreviousServer().isPresent())
|
||||||
return;
|
return;
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
DiscordLinkPlayer discordLinkPlayer = DiscordLinkPlayer.getDiscordLinkPlayer(event.getPlayer().getUniqueId());
|
DiscordLinkPlayer discordLinkPlayer = DiscordLinkPlayer.getDiscordLinkPlayer(uuid);
|
||||||
|
|
||||||
if (discordLinkPlayer == null)
|
if (discordLinkPlayer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
boolean sync = false;
|
boolean sync = false;
|
||||||
String username = event.getPlayer().getUsername();
|
String username = player.getUsername();
|
||||||
|
|
||||||
if (!discordLinkPlayer.getUsername().equals(username)) { //Update username if needed
|
if (!discordLinkPlayer.getUsername().equals(username)) { //Update username if needed
|
||||||
discordLinkPlayer.setUsername(username);
|
discordLinkPlayer.setUsername(username);
|
||||||
@@ -39,6 +46,18 @@ public class PlayerJoin {
|
|||||||
DiscordLink.getPlugin().getBot().changeNick(BotConfig.DISCORD.GUILD_ID, discordLinkPlayer.getUserId(), nick);
|
DiscordLink.getPlugin().getBot().changeNick(BotConfig.DISCORD.GUILD_ID, discordLinkPlayer.getUserId(), nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean hasMinecraftNitro = Utilities.hasMinecraftNitro(player);
|
||||||
|
boolean hasDatabaseNitro = Utilities.hasDatabaseNitro(discordLinkPlayer);
|
||||||
|
if (hasMinecraftNitro != hasDatabaseNitro) {
|
||||||
|
if (hasMinecraftNitro) {
|
||||||
|
//Utilities.removeRole(uuid, "nitro"); //TODO add nitro to config
|
||||||
|
ALogger.info("Removing nitro role from [" + player.getUsername() + "] since they shouldn't have it");
|
||||||
|
} else {
|
||||||
|
//Utilities.addRole(uuid, "nitro"); //TODO add nitro to config
|
||||||
|
ALogger.info("Added nitro role to [" + player.getUsername() + "] since they should have it");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (sync) //Sync if needed
|
if (sync) //Sync if needed
|
||||||
DiscordLink.getPlugin().getDatabase().syncPlayer(discordLinkPlayer);
|
DiscordLink.getPlugin().getDatabase().syncPlayer(discordLinkPlayer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,4 +21,8 @@ public class ALogger {
|
|||||||
public static void error(String message) {
|
public static void error(String message) {
|
||||||
logger.error(message);
|
logger.error(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void error(String message, Throwable t) {
|
||||||
|
logger.error(message, t);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,48 @@
|
|||||||
|
package com.alttd.proxydiscordlink.util;
|
||||||
|
|
||||||
|
import com.alttd.proxydiscordlink.config.Config;
|
||||||
|
import org.aarboard.nextcloud.api.NextcloudConnector;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class Evidence {
|
||||||
|
|
||||||
|
public CompletableFuture<Optional<String>> getNewEvidenceFolder(String username) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
NextcloudConnector nextcloudConnector = new NextcloudConnector(
|
||||||
|
Config.NEXT_CLOUD.ADDRESS,
|
||||||
|
true,
|
||||||
|
Config.NEXT_CLOUD.PORT,
|
||||||
|
Config.NEXT_CLOUD.USERNAME,
|
||||||
|
Config.NEXT_CLOUD.PASSWORD
|
||||||
|
);
|
||||||
|
String evidenceFilePath = String.format("/Evidence/%s", username);
|
||||||
|
if (!nextcloudConnector.folderExists(evidenceFilePath)) {
|
||||||
|
nextcloudConnector.createFolder(evidenceFilePath);
|
||||||
|
}
|
||||||
|
String newEvidenceFolderPath = evidenceFilePath + "/" + getCurrentDate();
|
||||||
|
if (!nextcloudConnector.folderExists(newEvidenceFolderPath)) {
|
||||||
|
nextcloudConnector.createFolder(newEvidenceFolderPath);
|
||||||
|
}
|
||||||
|
String id;
|
||||||
|
try {
|
||||||
|
id = nextcloudConnector.getProperties(newEvidenceFolderPath, true).getId();
|
||||||
|
} catch (IOException e) {
|
||||||
|
ALogger.error("Failed to get share link for Next Cloud folder", e);
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return Optional.of("https://drive.alttd.com/f/" + id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String getCurrentDate() {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd_HH_mm");
|
||||||
|
return now.format(formatter);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,6 +5,7 @@ import com.alttd.proxydiscordlink.bot.commandManager.SubOption;
|
|||||||
import com.alttd.proxydiscordlink.bot.objects.DiscordRole;
|
import com.alttd.proxydiscordlink.bot.objects.DiscordRole;
|
||||||
import com.alttd.proxydiscordlink.config.BotConfig;
|
import com.alttd.proxydiscordlink.config.BotConfig;
|
||||||
import com.alttd.proxydiscordlink.config.Config;
|
import com.alttd.proxydiscordlink.config.Config;
|
||||||
|
import com.alttd.proxydiscordlink.objects.DiscordLinkPlayer;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import net.dv8tion.jda.api.EmbedBuilder;
|
import net.dv8tion.jda.api.EmbedBuilder;
|
||||||
@@ -84,6 +85,16 @@ public class Utilities {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasDatabaseNitro(DiscordLinkPlayer player) {
|
||||||
|
List<String> groups = player.getRoles();
|
||||||
|
for (String group : Config.DISCORD_GROUPS) {
|
||||||
|
if (groups.contains(group)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static String getAuthKey() {
|
public static String getAuthKey() {
|
||||||
String randChars = "1234567890";
|
String randChars = "1234567890";
|
||||||
StringBuilder salt = new StringBuilder();
|
StringBuilder salt = new StringBuilder();
|
||||||
@@ -206,4 +217,31 @@ public class Utilities {
|
|||||||
.setEphemeral(true)
|
.setEphemeral(true)
|
||||||
.queue(res -> res.deleteOriginal().queueAfter(5, TimeUnit.SECONDS));
|
.queue(res -> res.deleteOriginal().queueAfter(5, TimeUnit.SECONDS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean removeRole(UUID uuid, String group) {
|
||||||
|
User user = getLuckPerms().getUserManager().getUser(uuid);
|
||||||
|
if (user == null)
|
||||||
|
return false;
|
||||||
|
user.getNodes(NodeType.INHERITANCE)
|
||||||
|
.stream()
|
||||||
|
.filter(inheritanceNode -> inheritanceNode.getGroupName().equalsIgnoreCase(group))
|
||||||
|
.findAny()
|
||||||
|
.ifPresent(node ->
|
||||||
|
getLuckPerms().getUserManager().modifyUser(uuid, result -> result.data().remove(node)));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean addRole(UUID uuid, String group) {
|
||||||
|
User user = getLuckPerms().getUserManager().getUser(uuid);
|
||||||
|
if (user == null)
|
||||||
|
return false;
|
||||||
|
user.getNodes(NodeType.INHERITANCE)
|
||||||
|
.stream()
|
||||||
|
.filter(inheritanceNode -> inheritanceNode.getGroupName().equalsIgnoreCase(group))
|
||||||
|
.findAny()
|
||||||
|
.ifPresent(node ->
|
||||||
|
getLuckPerms().getUserManager().modifyUser(uuid, result -> result.data().add(node)));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package com.alttd.proxydiscordlink.util;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
public class EvidenceTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldReturnEvidenceUrl() {
|
||||||
|
Evidence evidence = new Evidence();
|
||||||
|
Optional<String> evidenceUrl = evidence.getNewEvidenceFolder("akastijn").join();
|
||||||
|
assertTrue(evidenceUrl.isPresent());
|
||||||
|
System.out.println(evidenceUrl.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user