initial commit
This commit is contained in:
118
.gitignore
vendored
Normal file
118
.gitignore
vendored
Normal file
@@ -0,0 +1,118 @@
|
||||
# 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/
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
31
build.gradle
Normal file
31
build.gradle
Normal file
@@ -0,0 +1,31 @@
|
||||
import org.apache.tools.ant.filters.ReplaceTokens
|
||||
|
||||
apply plugin: 'java'
|
||||
|
||||
group = 'net.babamod'
|
||||
version = '0.0.1'
|
||||
|
||||
sourceCompatibility = '1.8'
|
||||
targetCompatibility = '1.8'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = 'spigotmc-repo'
|
||||
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
|
||||
}
|
||||
maven {
|
||||
name = 'sonatype'
|
||||
url = 'https://oss.sonatype.org/content/groups/public/'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly 'org.spigotmc:spigot-api:1.16.3-R0.1-SNAPSHOT'
|
||||
}
|
||||
|
||||
processResources {
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
filter ReplaceTokens, tokens: [version: version]
|
||||
}
|
||||
}
|
||||
0
gradle.properties
Normal file
0
gradle.properties
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Normal file
Binary file not shown.
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
5
gradle/wrapper/gradle-wrapper.properties
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
188
gradlew
vendored
Normal file
188
gradlew
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or 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 UN*X
|
||||
##
|
||||
##############################################################################
|
||||
|
||||
# Attempt to set APP_HOME
|
||||
# Resolve links: $0 may be a link
|
||||
PRG="$0"
|
||||
# Need this for relative symlinks.
|
||||
while [ -h "$PRG" ] ; do
|
||||
ls=`ls -ld "$PRG"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
PRG="$link"
|
||||
else
|
||||
PRG=`dirname "$PRG"`"/$link"
|
||||
fi
|
||||
done
|
||||
SAVED="`pwd`"
|
||||
cd "`dirname \"$PRG\"`/" >/dev/null
|
||||
APP_HOME="`pwd -P`"
|
||||
cd "$SAVED" >/dev/null
|
||||
|
||||
APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
|
||||
warn () {
|
||||
echo "$*"
|
||||
}
|
||||
|
||||
die () {
|
||||
echo
|
||||
echo "$*"
|
||||
echo
|
||||
exit 1
|
||||
}
|
||||
|
||||
# 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
|
||||
;;
|
||||
MINGW* )
|
||||
msys=true
|
||||
;;
|
||||
NONSTOP* )
|
||||
nonstop=true
|
||||
;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
if [ -n "$JAVA_HOME" ] ; then
|
||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
||||
# IBM's JDK on AIX uses strange locations for the executables
|
||||
JAVACMD="$JAVA_HOME/jre/sh/java"
|
||||
else
|
||||
JAVACMD="$JAVA_HOME/bin/java"
|
||||
fi
|
||||
if [ ! -x "$JAVACMD" ] ; then
|
||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
else
|
||||
JAVACMD="java"
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
|
||||
MAX_FD_LIMIT=`ulimit -H -n`
|
||||
if [ $? -eq 0 ] ; then
|
||||
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
|
||||
MAX_FD="$MAX_FD_LIMIT"
|
||||
fi
|
||||
ulimit -n $MAX_FD
|
||||
if [ $? -ne 0 ] ; then
|
||||
warn "Could not set maximum file descriptor limit: $MAX_FD"
|
||||
fi
|
||||
else
|
||||
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 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=$((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
|
||||
fi
|
||||
|
||||
# Escape application args
|
||||
save () {
|
||||
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
|
||||
echo " "
|
||||
}
|
||||
APP_ARGS=$(save "$@")
|
||||
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
|
||||
|
||||
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
|
||||
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
|
||||
cd "$(dirname "$0")"
|
||||
fi
|
||||
|
||||
exec "$JAVACMD" "$@"
|
||||
100
gradlew.bat
vendored
Normal file
100
gradlew.bat
vendored
Normal file
@@ -0,0 +1,100 @@
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
: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 %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
1
settings.gradle
Normal file
1
settings.gradle
Normal file
@@ -0,0 +1 @@
|
||||
rootProject.name = 'mineclass'
|
||||
29
src/main/java/net/babamod/mineclass/Mineclass.java
Normal file
29
src/main/java/net/babamod/mineclass/Mineclass.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package net.babamod.mineclass;
|
||||
|
||||
import net.babamod.mineclass.commands.CommandClass;
|
||||
import net.babamod.mineclass.utils.AppliedStatus;
|
||||
import net.babamod.mineclass.utils.MineClassListeners;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public final class Mineclass extends JavaPlugin implements Listener {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
AppliedStatus.getInstance();
|
||||
new MineClassListeners(this);
|
||||
PluginCommand pluginCommand = this.getCommand("class");
|
||||
if (pluginCommand != null) {
|
||||
pluginCommand.setTabCompleter((sender, command, alias, args) -> Arrays.asList("dwarf", "elf", "fire_dwarf", "naga", "clear", "whoami"));
|
||||
pluginCommand.setExecutor(new CommandClass());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
// Plugin shutdown logic
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package net.babamod.mineclass.classes;
|
||||
|
||||
import net.babamod.mineclass.utils.AppliedStatus;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
public class ClassWrapper {
|
||||
|
||||
public static void reapplyRightClassEffects(Player player, boolean sendReminder) {
|
||||
if (AppliedStatus.getInstance().isDwarf(player.getName()) || DwarfClass.is(player)) {
|
||||
AppliedStatus.getInstance().setDwarf(player.getName(), true);
|
||||
DwarfClass.reapplyEffects(player);
|
||||
if (sendReminder) {
|
||||
player.sendMessage("Reminder : You are a dwarf.");
|
||||
}
|
||||
}
|
||||
if (AppliedStatus.getInstance().isElf(player.getName()) || ElfClass.is(player)) {
|
||||
AppliedStatus.getInstance().setElf(player.getName(), true);
|
||||
ElfClass.reapplyEffects(player);
|
||||
if (sendReminder) {
|
||||
player.sendMessage("Reminder : You are an elf.");
|
||||
}
|
||||
}
|
||||
if (AppliedStatus.getInstance().isFireDwarf(player.getName()) || FireDwarfClass.is(player)) {
|
||||
AppliedStatus.getInstance().setFireDwarf(player.getName(), true);
|
||||
FireDwarfClass.reapplyEffects(player);
|
||||
if (sendReminder) {
|
||||
player.sendMessage("Reminder : You are a fire dwarf.");
|
||||
}
|
||||
}
|
||||
if (AppliedStatus.getInstance().isNaga(player.getName()) || NagaClass.is(player)) {
|
||||
AppliedStatus.getInstance().setNaga(player.getName(), true);
|
||||
NagaClass.reapplyEffects(player);
|
||||
if (sendReminder) {
|
||||
player.sendMessage("Reminder : You are a naga.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void clearAllClassEffects(Player player) {
|
||||
for (PotionEffect activePotionEffect : player.getActivePotionEffects()) {
|
||||
if (activePotionEffect.getDuration() > 32766) {
|
||||
player.removePotionEffect(activePotionEffect.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isItemForbidden(Player player, Material type) {
|
||||
if (AppliedStatus.getInstance().isDwarf(player.getName())) {
|
||||
return DwarfClass.isItemForbidden(type);
|
||||
}
|
||||
if (AppliedStatus.getInstance().isElf(player.getName())) {
|
||||
return ElfClass.isItemForbidden(type);
|
||||
}
|
||||
if (AppliedStatus.getInstance().isFireDwarf(player.getName())) {
|
||||
return FireDwarfClass.isItemForbidden(type);
|
||||
}
|
||||
if (AppliedStatus.getInstance().isNaga(player.getName())) {
|
||||
return NagaClass.isItemForbidden(type);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
78
src/main/java/net/babamod/mineclass/classes/DwarfClass.java
Normal file
78
src/main/java/net/babamod/mineclass/classes/DwarfClass.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package net.babamod.mineclass.classes;
|
||||
|
||||
import net.babamod.mineclass.utils.Pair;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class DwarfClass {
|
||||
|
||||
private static final Set<Material> forbiddenItems = new HashSet<Material>() {{
|
||||
add(Material.DIAMOND_AXE);
|
||||
add(Material.GOLDEN_AXE);
|
||||
add(Material.IRON_AXE);
|
||||
add(Material.NETHERITE_AXE);
|
||||
add(Material.DIAMOND_HOE);
|
||||
add(Material.GOLDEN_HOE);
|
||||
add(Material.IRON_HOE);
|
||||
add(Material.NETHERITE_HOE);
|
||||
add(Material.BOW);
|
||||
add(Material.TRIDENT);
|
||||
}};
|
||||
|
||||
private static final Map<PotionEffectType, Integer> potionEffects = Stream.of(new Object[][]{
|
||||
{PotionEffectType.HEALTH_BOOST, 2},
|
||||
{PotionEffectType.DAMAGE_RESISTANCE, 1},
|
||||
{PotionEffectType.HERO_OF_THE_VILLAGE, 1},
|
||||
{PotionEffectType.FAST_DIGGING, 1},
|
||||
{PotionEffectType.NIGHT_VISION, 1},
|
||||
}).collect(Collectors.toMap(data -> (PotionEffectType) data[0], data -> (Integer) data[1]));
|
||||
|
||||
private static final Map<Material, List<Pair<Enchantment, Integer>>> classEnchantments = Stream.of(
|
||||
new AbstractMap.SimpleEntry<>(Material.NETHERITE_PICKAXE, Arrays.asList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 8),
|
||||
new Pair<>(Enchantment.LOOT_BONUS_BLOCKS, 2)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.DIAMOND_PICKAXE, Arrays.asList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 8),
|
||||
new Pair<>(Enchantment.LOOT_BONUS_BLOCKS, 2)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.IRON_PICKAXE, Arrays.asList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 8),
|
||||
new Pair<>(Enchantment.LOOT_BONUS_BLOCKS, 2)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.GOLDEN_PICKAXE, Arrays.asList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 8),
|
||||
new Pair<>(Enchantment.LOOT_BONUS_BLOCKS, 2)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.STONE_PICKAXE, Arrays.asList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 8),
|
||||
new Pair<>(Enchantment.LOOT_BONUS_BLOCKS, 2)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.WOODEN_PICKAXE, Arrays.asList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 8),
|
||||
new Pair<>(Enchantment.LOOT_BONUS_BLOCKS, 2)
|
||||
))
|
||||
).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
public static boolean is(Player player) {
|
||||
return player.getActivePotionEffects().stream().map(PotionEffect::getType).collect(Collectors.toList()).containsAll(potionEffects.keySet());
|
||||
}
|
||||
|
||||
public static void reapplyEffects(Player player) {
|
||||
potionEffects.forEach((key, value) -> {
|
||||
player.removePotionEffect(key);
|
||||
player.addPotionEffect(new PotionEffect(key, Integer.MAX_VALUE, value - 1, false, false));
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isItemForbidden(Material type) {
|
||||
return forbiddenItems.contains(type);
|
||||
}
|
||||
}
|
||||
61
src/main/java/net/babamod/mineclass/classes/ElfClass.java
Normal file
61
src/main/java/net/babamod/mineclass/classes/ElfClass.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package net.babamod.mineclass.classes;
|
||||
|
||||
import net.babamod.mineclass.utils.Pair;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class ElfClass {
|
||||
|
||||
private static final Set<Material> forbiddenItems = new HashSet<Material>() {{
|
||||
add(Material.DIAMOND_SWORD);
|
||||
add(Material.GOLDEN_SWORD);
|
||||
add(Material.IRON_SWORD);
|
||||
add(Material.NETHERITE_SWORD);
|
||||
add(Material.DIAMOND_PICKAXE);
|
||||
add(Material.GOLDEN_PICKAXE);
|
||||
add(Material.IRON_PICKAXE);
|
||||
add(Material.NETHERITE_PICKAXE);
|
||||
add(Material.DIAMOND_SHOVEL);
|
||||
add(Material.GOLDEN_SHOVEL);
|
||||
add(Material.IRON_SHOVEL);
|
||||
add(Material.NETHERITE_SHOVEL);
|
||||
add(Material.CROSSBOW);
|
||||
add(Material.TRIDENT);
|
||||
}};
|
||||
|
||||
private static final Map<PotionEffectType, Integer> potionEffects = Stream.of(new Object[][]{
|
||||
{PotionEffectType.SPEED, 2},
|
||||
{PotionEffectType.JUMP, 3},
|
||||
{PotionEffectType.LUCK, 1},
|
||||
{PotionEffectType.NIGHT_VISION, 1},
|
||||
}).collect(Collectors.toMap(data -> (PotionEffectType) data[0], data -> (Integer) data[1]));
|
||||
|
||||
private static final Map<Material, List<Pair<Enchantment, Integer>>> classEnchantments = Stream.of(
|
||||
new AbstractMap.SimpleEntry<>(Material.BOW, Arrays.asList(
|
||||
new Pair<>(Enchantment.ARROW_INFINITE, 1),
|
||||
new Pair<>(Enchantment.ARROW_DAMAGE, 8)
|
||||
))
|
||||
).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
public static boolean is(Player player) {
|
||||
return player.getActivePotionEffects().stream().map(PotionEffect::getType).collect(Collectors.toList()).containsAll(potionEffects.keySet());
|
||||
}
|
||||
|
||||
public static void reapplyEffects(Player player) {
|
||||
potionEffects.forEach((key, value) -> {
|
||||
player.removePotionEffect(key);
|
||||
player.addPotionEffect(new PotionEffect(key, Integer.MAX_VALUE, value - 1, false, false));
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isItemForbidden(Material type) {
|
||||
return forbiddenItems.contains(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package net.babamod.mineclass.classes;
|
||||
|
||||
import net.babamod.mineclass.utils.Pair;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class FireDwarfClass {
|
||||
|
||||
private static final Set<Material> forbiddenItems = new HashSet<Material>() {{
|
||||
add(Material.DIAMOND_SWORD);
|
||||
add(Material.GOLDEN_SWORD);
|
||||
add(Material.IRON_SWORD);
|
||||
add(Material.NETHERITE_SWORD);
|
||||
add(Material.DIAMOND_HOE);
|
||||
add(Material.GOLDEN_HOE);
|
||||
add(Material.IRON_HOE);
|
||||
add(Material.NETHERITE_HOE);
|
||||
add(Material.DIAMOND_SHOVEL);
|
||||
add(Material.GOLDEN_SHOVEL);
|
||||
add(Material.IRON_SHOVEL);
|
||||
add(Material.NETHERITE_SHOVEL);
|
||||
add(Material.BOW);
|
||||
add(Material.ARROW);
|
||||
add(Material.TRIDENT);
|
||||
}};
|
||||
|
||||
private static final Map<PotionEffectType, Integer> potionEffects = Stream.of(new Object[][]{
|
||||
{PotionEffectType.FIRE_RESISTANCE, 1},
|
||||
{PotionEffectType.FAST_DIGGING, 1},
|
||||
{PotionEffectType.JUMP, 2},
|
||||
{PotionEffectType.NIGHT_VISION, 1},
|
||||
{PotionEffectType.HEALTH_BOOST, 2},
|
||||
}).collect(Collectors.toMap(data -> (PotionEffectType) data[0], data -> (Integer) data[1]));
|
||||
|
||||
private static final Map<Material, List<Pair<Enchantment, Integer>>> classEnchantment = Stream.of(
|
||||
new AbstractMap.SimpleEntry<>(Material.NETHERITE_AXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.FIRE_ASPECT, 2)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.DIAMOND_AXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.FIRE_ASPECT, 2)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.IRON_AXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.FIRE_ASPECT, 2)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.GOLDEN_AXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.FIRE_ASPECT, 2)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.STONE_AXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.FIRE_ASPECT, 2)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.WOODEN_AXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.FIRE_ASPECT, 2)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.NETHERITE_PICKAXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.DIAMOND_PICKAXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.IRON_PICKAXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.GOLDEN_PICKAXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.STONE_PICKAXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.WOODEN_PICKAXE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DIG_SPEED, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.FLINT_AND_STEEL, new ArrayList<Pair<Enchantment, Integer>>())
|
||||
// See to make infinity working on crossbow
|
||||
// Inventory auto smelt
|
||||
).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
public static boolean is(Player player) {
|
||||
return player.getActivePotionEffects().stream().map(PotionEffect::getType).collect(Collectors.toList()).containsAll(potionEffects.keySet());
|
||||
}
|
||||
|
||||
public static void reapplyEffects(Player player) {
|
||||
potionEffects.forEach((key, value) -> {
|
||||
player.removePotionEffect(key);
|
||||
player.addPotionEffect(new PotionEffect(key, Integer.MAX_VALUE, value - 1, false, false));
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isItemForbidden(Material type) {
|
||||
return forbiddenItems.contains(type);
|
||||
}
|
||||
}
|
||||
82
src/main/java/net/babamod/mineclass/classes/NagaClass.java
Normal file
82
src/main/java/net/babamod/mineclass/classes/NagaClass.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package net.babamod.mineclass.classes;
|
||||
|
||||
import net.babamod.mineclass.utils.Pair;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class NagaClass {
|
||||
|
||||
private static final Set<Material> forbiddenItems = new HashSet<Material>() {{
|
||||
add(Material.DIAMOND_SWORD);
|
||||
add(Material.GOLDEN_SWORD);
|
||||
add(Material.IRON_SWORD);
|
||||
add(Material.NETHERITE_SWORD);
|
||||
add(Material.DIAMOND_AXE);
|
||||
add(Material.GOLDEN_AXE);
|
||||
add(Material.IRON_AXE);
|
||||
add(Material.NETHERITE_AXE);
|
||||
add(Material.CROSSBOW);
|
||||
add(Material.BOW);
|
||||
add(Material.FLINT_AND_STEEL);
|
||||
}};
|
||||
|
||||
private static final Map<PotionEffectType, Integer> potionEffects = Stream.of(new Object[][]{
|
||||
{PotionEffectType.DOLPHINS_GRACE, 1},
|
||||
{PotionEffectType.CONDUIT_POWER, 1},
|
||||
{PotionEffectType.WATER_BREATHING, 1},
|
||||
{PotionEffectType.SLOW, 2},
|
||||
{PotionEffectType.WEAKNESS, 1},
|
||||
}).collect(Collectors.toMap(data -> (PotionEffectType) data[0], data -> (Integer) data[1]));
|
||||
|
||||
private static final Map<Material, List<Pair<Enchantment, Integer>>> classEnchantment = Stream.of(
|
||||
new AbstractMap.SimpleEntry<>(Material.TRIDENT, Arrays.asList(
|
||||
new Pair<>(Enchantment.LOYALTY, 3),
|
||||
new Pair<>(Enchantment.IMPALING, 5),
|
||||
new Pair<>(Enchantment.CHANNELING, 1)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.NETHERITE_HOE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DAMAGE_ALL, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.DIAMOND_HOE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DAMAGE_ALL, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.IRON_HOE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DAMAGE_ALL, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.WOODEN_HOE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DAMAGE_ALL, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.GOLDEN_HOE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DAMAGE_ALL, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.STONE_HOE, Collections.singletonList(
|
||||
new Pair<>(Enchantment.DAMAGE_ALL, 5)
|
||||
)),
|
||||
new AbstractMap.SimpleEntry<>(Material.FISHING_ROD, Arrays.asList(
|
||||
new Pair<>(Enchantment.LUCK, 3),
|
||||
new Pair<>(Enchantment.LURE, 3)
|
||||
))
|
||||
).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||
|
||||
public static boolean is(Player player) {
|
||||
return player.getActivePotionEffects().stream().map(PotionEffect::getType).collect(Collectors.toList()).containsAll(potionEffects.keySet());
|
||||
}
|
||||
|
||||
public static void reapplyEffects(Player player) {
|
||||
potionEffects.forEach((key, value) -> {
|
||||
player.removePotionEffect(key);
|
||||
player.addPotionEffect(new PotionEffect(key, Integer.MAX_VALUE, value - 1, false, false));
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isItemForbidden(Material type) {
|
||||
return forbiddenItems.contains(type);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
package net.babamod.mineclass.commands;
|
||||
|
||||
import net.babamod.mineclass.classes.*;
|
||||
import net.babamod.mineclass.utils.AppliedStatus;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandClass implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage("You need to use this command with one of the suggested arguments.");
|
||||
return false;
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (args[0].equals("dwarf")) {
|
||||
AppliedStatus.getInstance().setElf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setFireDwarf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setNaga(player.getName(), false);
|
||||
AppliedStatus.getInstance().setDwarf(player.getName(), true);
|
||||
ClassWrapper.clearAllClassEffects(player);
|
||||
DwarfClass.reapplyEffects(player);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equals("elf")) {
|
||||
AppliedStatus.getInstance().setDwarf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setFireDwarf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setNaga(player.getName(), false);
|
||||
AppliedStatus.getInstance().setElf(player.getName(), true);
|
||||
ClassWrapper.clearAllClassEffects(player);
|
||||
ElfClass.reapplyEffects(player);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equals("fire_dwarf")) {
|
||||
AppliedStatus.getInstance().setDwarf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setElf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setNaga(player.getName(), false);
|
||||
AppliedStatus.getInstance().setFireDwarf(player.getName(), true);
|
||||
ClassWrapper.clearAllClassEffects(player);
|
||||
FireDwarfClass.reapplyEffects(player);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equals("naga")) {
|
||||
AppliedStatus.getInstance().setDwarf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setElf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setFireDwarf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setNaga(player.getName(), true);
|
||||
ClassWrapper.clearAllClassEffects(player);
|
||||
NagaClass.reapplyEffects(player);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equals("clear")) {
|
||||
AppliedStatus.getInstance().setDwarf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setElf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setFireDwarf(player.getName(), false);
|
||||
AppliedStatus.getInstance().setNaga(player.getName(), false);
|
||||
ClassWrapper.clearAllClassEffects(player);
|
||||
return true;
|
||||
}
|
||||
if (args[0].equals("whoami")) {
|
||||
if (AppliedStatus.getInstance().isDwarf(player.getName())) {
|
||||
player.sendMessage("You are a dwarf.");
|
||||
}
|
||||
if (AppliedStatus.getInstance().isElf(player.getName())) {
|
||||
player.sendMessage("You are an elf.");
|
||||
}
|
||||
if (AppliedStatus.getInstance().isFireDwarf(player.getName())) {
|
||||
player.sendMessage("You are a fire dwarf.");
|
||||
}
|
||||
if (AppliedStatus.getInstance().isNaga(player.getName())) {
|
||||
player.sendMessage("You are a naga.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
102
src/main/java/net/babamod/mineclass/utils/AppliedStatus.java
Normal file
102
src/main/java/net/babamod/mineclass/utils/AppliedStatus.java
Normal file
@@ -0,0 +1,102 @@
|
||||
package net.babamod.mineclass.utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
public class AppliedStatus implements Serializable {
|
||||
/**
|
||||
* Instance unique pré-initialisée
|
||||
*/
|
||||
private static AppliedStatus INSTANCE;
|
||||
private final HashMap<String, Boolean> dwarf;
|
||||
private final HashMap<String, Boolean> elf;
|
||||
private final HashMap<String, Boolean> fireDwarf;
|
||||
private final HashMap<String, Boolean> naga;
|
||||
|
||||
/**
|
||||
* Constructeur privé
|
||||
*/
|
||||
private AppliedStatus() {
|
||||
dwarf = new HashMap<>();
|
||||
elf = new HashMap<>();
|
||||
fireDwarf = new HashMap<>();
|
||||
naga = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Point d'accès pour l'instance unique du singleton
|
||||
*/
|
||||
public static synchronized AppliedStatus getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
INSTANCE = new AppliedStatus();
|
||||
}
|
||||
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void setDwarf(String playerName, boolean dwarf) {
|
||||
this.dwarf.put(playerName, dwarf);
|
||||
}
|
||||
|
||||
public void setElf(String playerName, boolean elf) {
|
||||
this.elf.put(playerName, elf);
|
||||
}
|
||||
|
||||
public void setFireDwarf(String playerName, boolean fireDwarf) {
|
||||
this.fireDwarf.put(playerName, fireDwarf);
|
||||
}
|
||||
|
||||
public void setNaga(String playerName, boolean naga) {
|
||||
this.naga.put(playerName, naga);
|
||||
}
|
||||
|
||||
public boolean isDwarf(String playerName) {
|
||||
return dwarf.getOrDefault(playerName, false);
|
||||
}
|
||||
|
||||
public boolean isElf(String playerName) {
|
||||
return elf.getOrDefault(playerName, false);
|
||||
}
|
||||
|
||||
public boolean isFireDwarf(String playerName) {
|
||||
return fireDwarf.getOrDefault(playerName, false);
|
||||
}
|
||||
|
||||
public boolean isNaga(String playerName) {
|
||||
return naga.getOrDefault(playerName, false);
|
||||
}
|
||||
|
||||
public boolean hasAClass(String playerName) {
|
||||
return dwarf.getOrDefault(playerName, false) ||
|
||||
elf.getOrDefault(playerName, false) ||
|
||||
fireDwarf.getOrDefault(playerName, false) ||
|
||||
naga.getOrDefault(playerName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
AppliedStatus that = (AppliedStatus) o;
|
||||
return Objects.equals(dwarf, that.dwarf) &&
|
||||
Objects.equals(elf, that.elf) &&
|
||||
Objects.equals(fireDwarf, that.fireDwarf) &&
|
||||
Objects.equals(naga, that.naga);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(dwarf, elf, fireDwarf, naga);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AppliedStatus{" +
|
||||
"dwarf=" + dwarf +
|
||||
", elf=" + elf +
|
||||
", fireDwarf=" + fireDwarf +
|
||||
", naga=" + naga +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package net.babamod.mineclass.utils;
|
||||
|
||||
import net.babamod.mineclass.classes.ClassWrapper;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class ApplyClassStatusTask extends BukkitRunnable {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final Player player;
|
||||
|
||||
public ApplyClassStatusTask(JavaPlugin plugin, Player player) {
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
ClassWrapper.reapplyRightClassEffects(player, false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package net.babamod.mineclass.utils;
|
||||
|
||||
import net.babamod.mineclass.Mineclass;
|
||||
import net.babamod.mineclass.classes.ClassWrapper;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class MineClassListeners implements Listener {
|
||||
|
||||
private final Mineclass plugin;
|
||||
|
||||
public MineClassListeners(Mineclass plugin) {
|
||||
this.plugin = plugin;
|
||||
this.plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
ClassWrapper.reapplyRightClassEffects(player, true);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(PlayerItemConsumeEvent event) {
|
||||
if (event.getItem().getType().equals(Material.MILK_BUCKET)) {
|
||||
if (AppliedStatus.getInstance().hasAClass(event.getPlayer().getName())) {
|
||||
new ApplyClassStatusTask(this.plugin, event.getPlayer()).runTaskLater(this.plugin, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(EntityPickupItemEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
if (ClassWrapper.isItemForbidden(player, event.getItem().getItemStack().getType())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
27
src/main/java/net/babamod/mineclass/utils/Pair.java
Normal file
27
src/main/java/net/babamod/mineclass/utils/Pair.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package net.babamod.mineclass.utils;
|
||||
|
||||
public class Pair<F, S> {
|
||||
private F first;
|
||||
private S second;
|
||||
|
||||
public Pair(F first, S second) {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
public F getFirst() {
|
||||
return first;
|
||||
}
|
||||
|
||||
public void setFirst(F first) {
|
||||
this.first = first;
|
||||
}
|
||||
|
||||
public S getSecond() {
|
||||
return second;
|
||||
}
|
||||
|
||||
public void setSecond(S second) {
|
||||
this.second = second;
|
||||
}
|
||||
}
|
||||
9
src/main/resources/plugin.yml
Normal file
9
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,9 @@
|
||||
name: Mineclass
|
||||
version: @version@
|
||||
main: net.babamod.mineclass.Mineclass
|
||||
api-version: 1.16
|
||||
authors: [ Barazok ]
|
||||
commands:
|
||||
class:
|
||||
description: The class choosing command
|
||||
usage: /<command>
|
||||
Reference in New Issue
Block a user