Intial commit.

master
kalle 2021-04-12 23:32:11 +02:00
commit 428af21cce
41 changed files with 2433 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.gradle/
.idea/
gradle/
*.iml

32
build.gradle Normal file
View File

@ -0,0 +1,32 @@
apply plugin: 'java'
group = pluginGroup
version = pluginVersion
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenCentral()
maven {
name = 'spigotmc-repo'
url = 'https://hub.spigotmc.org/nexus/content/groups/public/'
}
maven {
name = 'sonatype'
url = 'https://oss.sonatype.org/content/groups/public/'
}
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile 'org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT'
}
import org.apache.tools.ant.filters.ReplaceTokens
processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}

2
gradle.properties Normal file
View File

@ -0,0 +1,2 @@
pluginGroup=nl.dragontamerfred
pluginVersion=1.0

172
gradlew vendored Executable file
View File

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## 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=""
# 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, switch paths to Windows format before running java
if $cygwin ; 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" "$@"

84
gradlew.bat vendored Normal file
View File

@ -0,0 +1,84 @@
@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=
@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

View File

@ -0,0 +1,105 @@
package nl.dragontamerfred.YRPerks.Classes;
import nl.dragontamerfred.YRPerks.SubClasses.SubClassElf;
import nl.dragontamerfred.YRPerks.SubClasses.SubClassHunter;
import nl.dragontamerfred.YRPerks.Types.Classs;
import nl.dragontamerfred.YRPerks.Types.Level;
import nl.dragontamerfred.YRPerks.Types.Perk;
import nl.dragontamerfred.YRPerks.Types.Reward;
import org.bukkit.Material;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class ClassArcher extends Classs {
public ClassArcher() {
this.id = "archer";
this.name = "Archer";
this.material = Material.BOW;
this.damage = 0;
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
LinkedList<Level> levels = new LinkedList<>();
levels.add(new level1());
levels.add(new level2());
levels.add(new level3());
levels.add(new level4());
levels.add(new level5());
this.levels = levels;
this.subClassOne = new SubClassElf();
this.subClassTwo = new SubClassHunter();
}
private class level1 extends Level {
private level1() {
this.name = "Level 1";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("archersAgility");
}
}
private class level2 extends Level {
private level2() {
this.name = "Level 2";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("trustyBow");
}
}
private class level3 extends Level {
private level3() {
this.name = "Level 3";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("blessingOfTheGoddess");
}
}
private class level4 extends Level {
private level4() {
this.name = "Level 4";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("goldenHeart");
}
}
private class level5 extends Level {
private level5() {
this.name = "Level 5";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK_WITH_SUB_CLASS).setPerk("arrowSpawn");
}
}
}

View File

@ -0,0 +1,103 @@
package nl.dragontamerfred.YRPerks.Classes;
import nl.dragontamerfred.YRPerks.SubClasses.SubClassElf;
import nl.dragontamerfred.YRPerks.SubClasses.SubClassHunter;
import nl.dragontamerfred.YRPerks.SubClasses.SubClassNone;
import nl.dragontamerfred.YRPerks.Types.Classs;
import nl.dragontamerfred.YRPerks.Types.Level;
import nl.dragontamerfred.YRPerks.Types.Reward;
import org.bukkit.Material;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class ClassNone extends Classs {
public ClassNone() {
this.id = "none";
this.name = "None";
this.material = Material.BARRIER;
this.damage = 0;
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
LinkedList<Level> levels = new LinkedList<>();
levels.add(new level1());
levels.add(new level2());
levels.add(new level3());
levels.add(new level4());
levels.add(new level5());
this.levels = levels;
this.subClassOne = new SubClassNone();
this.subClassTwo = new SubClassNone();
}
private class level1 extends Level {
private level1() {
this.name = "Level 1";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("none");
}
}
private class level2 extends Level {
private level2() {
this.name = "Level 2";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("none");
}
}
private class level3 extends Level {
private level3() {
this.name = "Level 3";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("none");
}
}
private class level4 extends Level {
private level4() {
this.name = "Level 4";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("none");
}
}
private class level5 extends Level {
private level5() {
this.name = "Level 5";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK_WITH_SUB_CLASS).setPerk("none");
}
}
}

View File

@ -0,0 +1,60 @@
package nl.dragontamerfred.YRPerks.Commands;
import nl.dragontamerfred.YRPerks.GUI.AdminGui;
import nl.dragontamerfred.YRPerks.GUI.MainGui;
import nl.dragontamerfred.YRPerks.Messages;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class CommandPerks implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = ((Player) sender);
if (args.length == 1) {
if (args[0].equalsIgnoreCase("admin")) {
if (player.hasPermission("perks.admin")) {
new AdminGui().open(player, player);
} else {
player.sendMessage(Messages.PREFIX + Messages.NO_PERMISSION);
}
} else if (player.hasPermission("perks.gui.open.others")) {
Player toView = Bukkit.getPlayer(args[0]);
if (toView == null) {
player.sendMessage(Messages.PREFIX + Messages.PLAYER_NOT_FOUND.replaceAll("<PLAYER_NAME>", args[0]));
} else {
new MainGui().open(toView, player);
}
} else {
player.sendMessage(Messages.PREFIX + Messages.NO_PERMISSION);
}
} else if (args.length == 2) {
if (args[0].equalsIgnoreCase("admin")) {
if (player.hasPermission("perks.admin")) {
Player target = Bukkit.getPlayer(args[1]);
if (target != null) {
new AdminGui().open(target, player);
} else {
player.sendMessage(Messages.PREFIX + Messages.PLAYER_NOT_FOUND.replaceAll("<PLAYER_NAME>", args[1]));
}
} else {
player.sendMessage(Messages.PREFIX + Messages.NO_PERMISSION);
}
} else {
player.sendMessage(Messages.PREFIX + Messages.INVALID_USAGE);
}
} else if (player.hasPermission("perks.gui.open")) {
new MainGui().open(player, player);
} else {
player.sendMessage(Messages.PREFIX + Messages.NO_PERMISSION);
}
} else {
sender.sendMessage(Messages.PREFIX + Messages.NOT_A_PLAYER);
}
return true;
}
}

View File

@ -0,0 +1,48 @@
package nl.dragontamerfred.YRPerks;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class Config {
public static String GENERAL_BACK_BUTTON_MATERIAL;
public static short GENERAL_BACK_BUTTON_DAMAGE;
public static String GENERAL_BACK_BUTTON_NAME;
public static String INVENTORY_MAIN_NAME;
public static String INVENTORY_PERKS_NAME;
public static String INVENTORY_ADMIN_NAME;
public static String INVENTORY_CLASSES_NAME;
public static void load(File file) {
try {
if (!file.getParentFile().exists())
file.getParentFile().mkdirs();
if (!file.exists())
Utils.ExportResource("/config.yml", file);
YamlConfiguration config = new YamlConfiguration();
config.load(file);
// Inventories
// General stuff
GENERAL_BACK_BUTTON_MATERIAL = config.getString("inventory.general.back-button.material");
GENERAL_BACK_BUTTON_DAMAGE = (short) config.getInt("inventory.general.back-button.damage");
GENERAL_BACK_BUTTON_NAME = Utils.color(config.getString("inventory.general.back-button.name"));
// Main inv
INVENTORY_MAIN_NAME = Utils.color(config.getString("inventory.main.name"));
// Perks inv
INVENTORY_PERKS_NAME = Utils.color(config.getString("inventory.perks.name"));
// Admin inv
INVENTORY_MAIN_NAME = Utils.color(config.getString("inventory.admin.name"));
// Classes inv
INVENTORY_CLASSES_NAME = Utils.color(config.getString("inventory.classes.name"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,43 @@
package nl.dragontamerfred.YRPerks.Events;
import nl.dragontamerfred.YRPerks.Types.DamageCause;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class KillEvent extends Event {
private static HandlerList handlers = new HandlerList();
private Player killer;
private Player killed;
private DamageCause cause;
public KillEvent(Player killer, Player killed, DamageCause cause) {
this.killer = killer;
this.killed = killed;
this.cause = cause;
}
public Player getKiller() {
return killer;
}
public Player getKilled() {
return killed;
}
public DamageCause getCause() {
return cause;
}
@Override
public HandlerList getHandlers() {
return handlers;
}
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -0,0 +1,160 @@
package nl.dragontamerfred.YRPerks.GUI;
import nl.dragontamerfred.YRPerks.Config;
import nl.dragontamerfred.YRPerks.PerkManager;
import nl.dragontamerfred.YRPerks.Types.ClassData;
import nl.dragontamerfred.YRPerks.Types.Classs;
import nl.dragontamerfred.YRPerks.Types.Level;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
public class AdminGui implements Listener {
public static HashMap<UUID, InventoryView> openInvs = new HashMap<>();
public static HashMap<UUID, UUID> staffViewing = new HashMap<>();
public void open(Player target, Player staff) {
Inventory inv = Bukkit.createInventory(null, 5*9, Config.INVENTORY_ADMIN_NAME);
Classs classs = PerkManager.getSelectedClassForPlayer(target.getUniqueId());
ClassData classData = PerkManager.getClassDataForPlayer(target.getUniqueId(), classs.id);
if (classData == null) {
staff.sendMessage("&cAn error occurred.");
return;
}
ItemStack classItem = new ItemStack(classs.material, 1, classs.damage);
ItemMeta classsMeta = classItem.getItemMeta();
classsMeta.setDisplayName(classs.name);
classsMeta.setLore(classs.description);
classItem.setItemMeta(classsMeta);
ItemStack subClassOneItem = new ItemStack(classs.subClassOne.material, 1, classs.subClassOne.damage);
ItemMeta subClassOneMeta = subClassOneItem.getItemMeta();
subClassOneMeta.setDisplayName(classs.subClassOne.name);
List<String> subClassOneLore = classs.subClassOne.description;
if (classData.subClassOne.unlocked)
subClassOneLore.add("&aUnlocked");
else
subClassOneLore.add("&4Locked");
subClassOneLore.add("&3Click to toggle unlocked status.");
subClassOneMeta.setLore(subClassOneLore);
subClassOneItem.setItemMeta(subClassOneMeta);
ItemStack subClassTwoItem = new ItemStack(classs.subClassTwo.material, 1, classs.subClassTwo.damage);
ItemMeta subClassTwoMeta = subClassTwoItem.getItemMeta();
subClassTwoMeta.setDisplayName(classs.subClassTwo.name);
List<String> subClassTwoLore = classs.subClassTwo.description;
if (classData.subClassTwo.unlocked)
subClassTwoLore.add("&aUnlocked");
else
subClassTwoLore.add("&4Locked");
subClassTwoLore.add("&3Click to toggle unlocked status.");
subClassTwoMeta.setLore(subClassTwoLore);
subClassTwoItem.setItemMeta(subClassTwoMeta);
for (int i=0; i<classs.levels.size(); i++) {
inv.setItem(i+1, getLevelStack(classs.levels.get(i), classData.level<=i+1));
}
for (int i=0; i<classs.subClassOne.levels.size(); i++) {
inv.setItem(i+10, getLevelStack(classs.subClassOne.levels.get(i), classData.subClassOne.level<=i+1));
}
for (int i=0; i<classs.subClassTwo.levels.size(); i++) {
inv.setItem(i+19, getLevelStack(classs.subClassTwo.levels.get(i), classData.subClassTwo.level<=i+1));
}
// 0 1 2 3 4 5 6 7 8
// 9 10 11 12 13 14 15 16 17
// 18 19 20 21 22 23 24 25 26
// 27 28 29 30 31 32 33 34 35
// 36 37 38 39 40 41 42 43 44
// 45 46 47 48 49 50 51 52 53
inv.setItem(0, classItem);
inv.setItem(9, subClassOneItem);
inv.setItem(18, subClassTwoItem);
staffViewing.put(staff.getUniqueId(), target.getUniqueId());
openInvs.put(staff.getUniqueId(), staff.openInventory(inv));
}
private static ItemStack getLevelStack(Level level, boolean unlocked) {
ItemStack levelStack = new ItemStack(Material.STAINED_GLASS_PANE, 1, unlocked ? (short) 14 : (short) 15);
ItemMeta levelMeta = levelStack.getItemMeta();
levelMeta.setDisplayName(level.name);
List<String> lore = level.description;
lore.add("&3Click to set level.");
levelMeta.setLore(lore);
levelStack.setItemMeta(levelMeta);
return levelStack;
}
@EventHandler
public void on(InventoryClickEvent event) {
if (openInvs.get(event.getWhoClicked().getUniqueId()) == event.getView()) {
Player viewer = ((Player) event.getWhoClicked());
Player target = Bukkit.getPlayer(staffViewing.get(viewer.getUniqueId()));
event.setCancelled(true);
Classs classs = PerkManager.getSelectedClassForPlayer(target.getUniqueId());
ClassData cd = PerkManager.getClassDataForPlayer(target.getUniqueId(), classs.id);
switch (event.getSlot()) {
case 0:
PerkManager.setClassUnlockedForPlayer(target.getUniqueId(), classs.id, !cd.unlocked);
break;
case 1:
PerkManager.setClassLevelForPlayer(target.getUniqueId(), classs.id, 1);
break;
case 2:
PerkManager.setClassLevelForPlayer(target.getUniqueId(), classs.id, 2);
break;
case 3:
PerkManager.setClassLevelForPlayer(target.getUniqueId(), classs.id, 3);
break;
case 4:
PerkManager.setClassLevelForPlayer(target.getUniqueId(), classs.id, 4);
break;
case 5:
PerkManager.setClassLevelForPlayer(target.getUniqueId(), classs.id, 5);
break;
case 9:
PerkManager.setSubclassUnlocedForPlayer(target.getUniqueId(), classs.id, 1, cd.subClassOne.unlocked);
break;
case 10:
PerkManager.setSubclassLevelForPlayer(target.getUniqueId(), classs.id, 1, 1);
break;
case 11:
PerkManager.setSubclassLevelForPlayer(target.getUniqueId(), classs.id, 1, 2);
break;
case 12:
PerkManager.setSubclassLevelForPlayer(target.getUniqueId(), classs.id, 1, 3);
break;
case 18:
PerkManager.setSubclassUnlocedForPlayer(target.getUniqueId(), classs.id, 2, cd.subClassTwo.unlocked);
break;
case 19:
PerkManager.setSubclassLevelForPlayer(target.getUniqueId(), classs.id, 2, 1);
break;
case 20:
PerkManager.setSubclassLevelForPlayer(target.getUniqueId(), classs.id, 2, 2);
break;
case 21:
PerkManager.setSubclassLevelForPlayer(target.getUniqueId(), classs.id, 2, 3);
break;
}
}
}
}

View File

@ -0,0 +1,21 @@
package nl.dragontamerfred.YRPerks.GUI;
import nl.dragontamerfred.YRPerks.Config;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import java.util.HashMap;
import java.util.UUID;
public class ClassesGui {
private static HashMap<UUID, InventoryView> openInvs = new HashMap<>();
public void open(Player player) {
Inventory inv = Bukkit.createInventory(null, 5*9, Config.INVENTORY_CLASSES_NAME);
}
}

View File

@ -0,0 +1,170 @@
package nl.dragontamerfred.YRPerks.GUI;
import nl.dragontamerfred.YRPerks.Config;
import nl.dragontamerfred.YRPerks.PerkManager;
import nl.dragontamerfred.YRPerks.Types.ClassData;
import nl.dragontamerfred.YRPerks.Types.Classs;
import nl.dragontamerfred.YRPerks.Types.Level;
import nl.dragontamerfred.YRPerks.Utils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;
public class MainGui implements Listener {
public static HashMap<UUID, InventoryView> openInvs = new HashMap<>();
public static HashMap<UUID, UUID> staffViewing = new HashMap<>();
public void open(Player player, Player toShow) {
Inventory inv = Bukkit.createInventory(null, 3 * 9, Config.INVENTORY_MAIN_NAME);
// Class item
Classs classs = PerkManager.getSelectedClassForPlayer(player.getUniqueId());
ItemStack classItem = new ItemStack(classs.material, 1, classs.damage);
ItemMeta classsMeta = classItem.getItemMeta();
classsMeta.setDisplayName(classs.name);
classsMeta.setLore(classs.description);
classItem.setItemMeta(classsMeta);
// Level 1-8
ClassData data = PerkManager.getClassDataForPlayer(player.getUniqueId(), classs.id);
int level = 1;
int subClass = 0;
LinkedList<Level> levels = classs.levels;
if (data != null) {
level = data.level;
subClass = data.subClass;
}
ItemStack level1 = getLevelStack(levels.get(0), true);
ItemStack level2 = getLevelStack(levels.get(1), level >= 2);
ItemStack level3 = getLevelStack(levels.get(2), level >= 3);
ItemStack level4 = getLevelStack(levels.get(3), level >= 4);
ItemStack level5 = getLevelStack(levels.get(4), level >= 5);
ItemStack level6 = null;
ItemStack level7 = null;
ItemStack level8 = null;
if (subClass >= 1) {
LinkedList<Level> subLevels = subClass == 1 ? classs.subClassOne.levels : classs.subClassTwo.levels;
level6 = getLevelStack(subLevels.get(0), level >= 6);
level7 = getLevelStack(subLevels.get(1), level >= 7);
level8 = getLevelStack(subLevels.get(2), level >= 8);
}
// perks 1-5
ItemStack perk1 = Utils.createPerkItemStack(PerkManager.getPerkById(data == null ? "no-perk" : data.perkOne));
ItemStack perk2 = Utils.createPerkItemStack(PerkManager.getPerkById(data == null ? "no-perk" : data.perkTwo));
ItemStack perk3 = Utils.createPerkItemStack(PerkManager.getPerkById(data == null ? "no-perk" : data.perkThree));
ItemStack perk4 = Utils.createPerkItemStack(PerkManager.getPerkById(data == null ? "no-perk" : data.perkFour));
ItemStack perk5 = Utils.createPerkItemStack(PerkManager.getPerkById(data == null ? "no-perk" : data.perkFive));
// 0 1 2 3 4 5 6 7 8
// 9 10 11 12 13 14 15 16 17
// 18 19 20 21 22 23 24 25 26
// 27 28 29 30 31 32 33 34 35
// 36 37 38 39 40 41 42 43 44
// 45 46 47 48 49 50 51 52 53
// Class item
inv.setItem(4, classItem);
// Level items
inv.setItem(11, level1);
inv.setItem(12, level2);
inv.setItem(13, level3);
inv.setItem(14, level4);
inv.setItem(15, level5);
if (level6 != null)
inv.setItem(21, level6);
if (level7 != null)
inv.setItem(22, level7);
if (level8 != null)
inv.setItem(23, level8);
// Perk items
inv.setItem(38, perk1);
inv.setItem(39, perk2);
inv.setItem(40, perk3);
inv.setItem(41, perk4);
inv.setItem(42, perk5);
toShow.closeInventory();
openInvs.put(toShow.getUniqueId(), toShow.openInventory(inv));
staffViewing.put(toShow.getUniqueId(), player.getUniqueId());
}
private static ItemStack getLevelStack(Level level, boolean unlocked) {
ItemStack levelStack = new ItemStack(Material.STAINED_GLASS_PANE, 1, unlocked ? (short) 14 : (short) 15);
ItemMeta levelMeta = levelStack.getItemMeta();
levelMeta.setDisplayName(level.name);
List<String> lore = level.description;
levelMeta.setLore(lore);
levelStack.setItemMeta(levelMeta);
return levelStack;
}
@EventHandler
public void on(InventoryCloseEvent event) {
if (openInvs.get(event.getPlayer().getUniqueId()) == event.getView()) {
staffViewing.remove(event.getPlayer().getUniqueId());
openInvs.remove(event.getPlayer().getUniqueId());
}
}
@EventHandler
public void on(InventoryClickEvent event) {
if (openInvs.get(event.getWhoClicked().getUniqueId()) == event.getView()) {
Player player = ((Player) event.getWhoClicked());
event.setCancelled(true);
if (staffViewing.getOrDefault(player.getUniqueId(), null) != player.getUniqueId())
return;
switch (event.getSlot()) {
case 4: {
player.sendMessage("This should have opened the class gui.");
//TODO open class change gui
break;
}
case 38: {
player.sendMessage("This should have opened the perk gui.");
new PerkGui().open(player, 1);
break;
}
case 39: {
player.sendMessage("This should have opened the perk gui.");
new PerkGui().open(player, 2);
break;
}
case 40: {
player.sendMessage("This should have opened the perk gui.");
new PerkGui().open(player, 3);
break;
}
case 41: {
player.sendMessage("This should have opened the perk gui.");
new PerkGui().open(player, 4);
break;
}
case 42: {
player.sendMessage("This should have opened the perk gui.");
new PerkGui().open(player, 5);
break;
}
}
}
}
}

View File

@ -0,0 +1,89 @@
package nl.dragontamerfred.YRPerks.GUI;
import nl.dragontamerfred.YRPerks.Config;
import nl.dragontamerfred.YRPerks.PerkManager;
import nl.dragontamerfred.YRPerks.Types.Perk;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.*;
public class PerkGui implements Listener {
private static HashMap<UUID, InventoryView> openInvs = new HashMap<>();
private static HashMap<UUID, Integer> perkSlots = new HashMap<>();
public void open(Player player, int perkSlot) {
Inventory inv = Bukkit.createInventory(null, 3*9, Config.INVENTORY_PERKS_NAME);
perkSlots.put(player.getUniqueId(), perkSlot);
int slot = 0;
for (String perkID : PerkManager.getAllPerksForPlayer(player.getUniqueId())) {
Perk perk = PerkManager.getPerkById(perkID);
ItemStack is = new ItemStack(perk.material, 1, perk.damage);
ItemMeta im = is.getItemMeta();
im.setDisplayName(perk.name);
List<String> lore = perk.description;
lore.add(ChatColor.BLACK + perk.id);
im.setLore(lore);
is.setItemMeta(im);
inv.setItem(slot, is);
slot++;
}
// No perk item
Perk noPerk = PerkManager.getPerkById("none");
ItemStack noPerkItem = new ItemStack(noPerk.material, 1, noPerk.damage);
ItemMeta noPerkMeta = noPerkItem.getItemMeta();
noPerkMeta.setDisplayName(noPerk.name);
List<String> lore = noPerk.description;
lore.add(ChatColor.BLACK + noPerk.id);
noPerkMeta.setLore(lore);
noPerkItem.setItemMeta(noPerkMeta);
inv.setItem(25, noPerkItem);
// Back item
ItemStack backItem = new ItemStack(Material.valueOf(Config.GENERAL_BACK_BUTTON_MATERIAL), 1, Config.GENERAL_BACK_BUTTON_DAMAGE);
ItemMeta backItemMeta = backItem.getItemMeta();
backItemMeta.setDisplayName(Config.GENERAL_BACK_BUTTON_NAME);
backItem.setItemMeta(backItemMeta);
inv.setItem(26, backItem);
player.closeInventory();
openInvs.put(player.getUniqueId(), player.openInventory(inv));
}
@EventHandler
public void on(InventoryClickEvent event) {
if (openInvs.getOrDefault(event.getWhoClicked().getUniqueId(), null) == event.getView()) {
Player player = ((Player) event.getWhoClicked());
event.setCancelled(true);
if (event.getCurrentItem() != null) {
if (event.getCurrentItem().getItemMeta() != null) {
if (Config.GENERAL_BACK_BUTTON_NAME.equals(event.getCurrentItem().getItemMeta().getDisplayName())) {
new MainGui().open(player, player);
} else if (event.getCurrentItem().getItemMeta().hasLore()) {
ItemStack is = event.getCurrentItem();
List<String> lore = is.getItemMeta().getLore();
Perk perk = PerkManager.getPerkById(lore.get(lore.size()-1).replaceAll(ChatColor.BLACK.toString(), ""));
if (perk != null) {
PerkManager.setPerkForSlot(player.getUniqueId(), perkSlots.get(player.getUniqueId()), perk.id);
}
new MainGui().open(player, player);
}
}
}
}
}
}

View File

@ -0,0 +1,52 @@
package nl.dragontamerfred.YRPerks.Listeners;
import nl.dragontamerfred.YRPerks.Events.KillEvent;
import nl.dragontamerfred.YRPerks.Types.DamageCause;
import org.bukkit.Bukkit;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile;
import org.bukkit.entity.Snowball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import java.util.HashMap;
import java.util.UUID;
public class KillListener implements Listener {
private static HashMap<UUID, UUID> lastDamage = new HashMap<>();
private static HashMap<UUID, DamageCause> lastDamageCause = new HashMap<>();
@EventHandler
public void on(EntityDamageByEntityEvent event) {
if (event.getEntity() instanceof Player) {
Player hit = ((Player) event.getEntity());
if (event.getDamager() instanceof Player) {
lastDamage.put(hit.getUniqueId(), event.getDamager().getUniqueId());
lastDamageCause.put(hit.getUniqueId(), DamageCause.PVP);
} else if (event.getDamager() instanceof Projectile) {
if (((Projectile) event.getDamager()).getShooter() instanceof Player) {
lastDamage.put(hit.getUniqueId(), ((Player) ((Projectile) event.getDamager()).getShooter()).getUniqueId());
if (event.getDamager() instanceof Arrow)
lastDamageCause.put(hit.getUniqueId(), DamageCause.ARROW);
else if (event.getDamager() instanceof Snowball)
lastDamageCause.put(hit.getUniqueId(), DamageCause.SNOWBALL);
}
}
}
}
@EventHandler
public void on(PlayerDeathEvent event) {
Player killed = event.getEntity();
if (lastDamage.containsKey(killed.getUniqueId())) {
Player killer = Bukkit.getPlayer(lastDamage.get(killed.getUniqueId()));
Bukkit.getServer().getPluginManager().callEvent(new KillEvent(killer, killed, lastDamageCause.getOrDefault(killed.getUniqueId(), DamageCause.MISC)));
lastDamage.remove(killed.getUniqueId());
lastDamageCause.remove(killed.getUniqueId());
}
}
}

View File

@ -0,0 +1,34 @@
package nl.dragontamerfred.YRPerks;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class Messages {
public static String PREFIX;
public static String NOT_A_PLAYER;
public static String NO_PERMISSION;
public static String PLAYER_NOT_FOUND;
public static String INVALID_USAGE;
public static void load(File file) {
try {
if (!file.getParentFile().exists())
file.getParentFile().mkdirs();
if (!file.exists())
Utils.ExportResource("/messages.yml", file);
YamlConfiguration config = new YamlConfiguration();
config.load(file);
PREFIX = Utils.color(config.getString("prefix"));
NOT_A_PLAYER = Utils.color(config.getString("not-a-player"));
NO_PERMISSION = Utils.color(config.getString("no-permission"));
PLAYER_NOT_FOUND = Utils.color(config.getString("player-not-found"));
INVALID_USAGE = Utils.color(config.getString("invalid-usage"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,418 @@
package nl.dragontamerfred.YRPerks;
import com.google.gson.Gson;
import nl.dragontamerfred.YRPerks.Types.ClassData;
import nl.dragontamerfred.YRPerks.Types.Classs;
import nl.dragontamerfred.YRPerks.Types.Perk;
import nl.dragontamerfred.YRPerks.Types.SubClassData;
import java.io.File;
import java.sql.*;
import java.util.*;
public class PerkManager {
private static HashMap<String, Classs> classes = new HashMap<>();
private static HashMap<String, Perk> perks = new HashMap<>();
private static String url;
public static void registerClass(Classs classs) {
classes.put(classs.id, classs);
YRPerks.logger.info("Registered class: " + classs.id);
}
public static void registerPerk(Perk perk) {
perks.put(perk.id, perk);
YRPerks.plugin.getServer().getPluginManager().registerEvents(perk, YRPerks.plugin);
YRPerks.logger.info("Registered perk: " + perk.id);
}
/*
selectedClass: uuid (U)| selectedClass
unlockedClasses: uuid | unlockedClass
classData: uuid | class | classData
*/
public static boolean playerHasPerkSelected(UUID uuid, String perk) {
ClassData cd = getClassDataForPlayer(uuid, getSelectedClassForPlayer(uuid).id);
return cd != null && cd.hasPerk(perk);
}
public static void setClassUnlockedForPlayer(UUID uuid, String classID, boolean unlocked) {
if (unlocked)
unlockClassForPlayer(uuid, classID);
else
lockClassForPlayer(uuid, classID);
}
public static void setSubclassUnlocedForPlayer(UUID uuid, String classID, int subclassID, boolean unlocked) {
ClassData cd = getClassDataForPlayer(uuid, classID);
if (subclassID == 1)
cd.subClassOne.unlocked = unlocked;
else
cd.subClassTwo.unlocked = unlocked;
setClassDataForPlayer(uuid, classID, cd);
}
public static void lockClassForPlayer(UUID uuid, String classID) {
try {
Class.forName("org.sqlite.JDBC");
try (Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement()) {
stmt.execute("DELETE * FROM selectedClass WHERE uuid='" + uuid + "' AND unlockedClass='" + classID + "'");
} catch (SQLException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static boolean isClassUnlockedForPlayer(UUID uuid, String classID) {
try {
Class.forName("org.sqlite.JDBC");
try (Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement()) {
ResultSet result = stmt.executeQuery("SELECT * FROM unlockedClasses WHERE uuid='" + uuid + "'");
while (result.next()) {
if (result.getString("unlockedClass").equals(classID))
return true;
}
} catch (SQLException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/*
selectedClass: uuid (U)| selectedClass
unlockedClasses: uuid | unlockedClass
classData: uuid | class | classData
*/
public static void setPerkForSlot(UUID uuid, int slot, String perk) {
// Save it to the database
Classs classs = getSelectedClassForPlayer(uuid);
ClassData cd = getClassDataForPlayer(uuid, classs.id);
if (cd == null) {
cd = new ClassData(
classs.id,
1,
0,
new SubClassData(
false,
0
),
new SubClassData(
false,
0
),
"none",
"none",
"none",
"none",
"none");
}
cd.setPerkBySlot(slot, perk);
setClassDataForPlayer(uuid, classs.id, cd);
}
public static Set<String> getAllPerks() {
return perks.keySet();
}
public static List<String> getAllPerksForPlayer(UUID uuid) {
ClassData cd = getClassDataForPlayer(uuid, getSelectedClassForPlayer(uuid).id);
LinkedList<String> up = new LinkedList<>();
if (cd != null) {
Classs c = classes.get(cd.id);
for (int i = 0; i <= cd.level; i++)
up.add(c.levels.get(i).reward.perk);
if (cd.subClass == 1)
for (int i = 1; i <= cd.subClassOne.level; i++)
up.add(c.subClassOne.levels.get(i).reward.perk);
else if (cd.subClass == 2)
for (int i = 1; i <= cd.subClassTwo.level; i++)
up.add(c.subClassTwo.levels.get(i).reward.perk);
}
return up;
}
public static Perk getPerkById(String perkID) {
return perks.getOrDefault(perkID, perks.get("none"));
}
public static void init(File dbFile) {
try {
Class.forName("org.sqlite.JDBC");
url = "jdbc:sqlite:" + dbFile.getAbsolutePath();
if (!dbFile.getParentFile().exists())
dbFile.getParentFile().mkdirs();
if (!dbFile.exists()) {
createTable();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/*
selectedClass: uuid (U)| selectedClass
unlockedClasses: uuid | unlockedClass
classData: uuid | class | classData
*/
public static void createTable() {
try {
Class.forName("org.sqlite.JDBC");
try (Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement()) {
// SQL statement for creating a new table
stmt.execute("CREATE TABLE IF NOT EXISTS selectedClass (\n"
+ " uuid TEXT PRIMARY KEY,\n"
+ " selectedClass TEXT NOT NULL \n"
+ ");");
stmt.execute("CREATE TABLE IF NOT EXISTS unlockedClasses (\n"
+ " uuid TEXT NOT NULL,\n"
+ " unlockedClass TEXT NOT NULL \n"
+ ");");
stmt.execute("CREATE TABLE IF NOT EXISTS classData (\n"
+ " uuid TEXT NOT NULL,\n"
+ " class TEXT NOT NULL,\n"
+ " classData TEXT NOT NULL \n"
+ ");");
} catch (SQLException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/*
selectedClass: uuid (U)| class
unlockedClasses: uuid | class
classData: uuid | class | classData
*/
public static Classs getSelectedClassForPlayer(UUID uuid) {
try {
Class.forName("org.sqlite.JDBC");
try (Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement()) {
ResultSet result = stmt.executeQuery("SELECT * FROM selectedClass WHERE uuid='" + uuid + "'");
result.next();
return classes.getOrDefault(result.getString("class"), classes.get("none"));
} catch (SQLException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return classes.get("none");
}
public static void setSelectedClassForPlayer(UUID uuid, String classID) {
try {
Class.forName("org.sqlite.JDBC");
try (Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement()) {
stmt.execute("DELETE * FROM selectedClass WHERE uuid='" + uuid + "'");
stmt.execute("INSERT INTO selectedClass ('" + uuid + "','" + classID + "')");
}
} catch (Exception e) {
e.printStackTrace();
}
ClassData cd = getClassDataForPlayer(uuid, classID);
}
public static void setClassDataForPlayer(UUID uuid, String classID, ClassData cd) {
classData d = new classData(
cd.id,
cd.level,
cd.subClass,
new subClassData(
cd.subClassOne.unlocked,
cd.subClassOne.level
),
new subClassData(
cd.subClassTwo.unlocked,
cd.subClassTwo.level
),
new selectedPerks(
cd.perkOne,
cd.perkTwo,
cd.perkThree,
cd.perkFour,
cd.perkFive
)
);
try {
Class.forName("org.sqlite.JDBC");
try (Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement()) {
Gson gson = new Gson();
stmt.execute("DELETE * FROM classData WHERE uuid='" + uuid + "' AND class='" + classID + "'");
stmt.execute("INSERT INTO classData ( '" + uuid + "', '"
+ classID +"', '"
+ gson.toJson(d, classData.class) + "')");
} catch (SQLException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static void unlockClassForPlayer(UUID uuid, String classID) {
try {
Class.forName("org.sqlite.JDBC");
try (Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement()) {
stmt.execute("INSERT INTO unlockedClasses ( ' " + uuid + " ', ' " + classID + " ' )");
} catch (SQLException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
}
/*
selectedClass: uuid (U)| class
unlockedClasses: uuid | class
classData: uuid | class | classData
*/
public static void setClassLevelForPlayer(UUID uuid, String classID, int level) {
setClassDataForPlayer(uuid, classID, getClassDataForPlayer(uuid, classID).setLevel(level));
}
public static void setSubclassLevelForPlayer(UUID uuid, String classID, int subClassID, int level) {
ClassData cd = getClassDataForPlayer(uuid, classID);
if (subClassID==1)
cd.subClassOne.level = level;
else
cd.subClassTwo.level = level;
setClassDataForPlayer(uuid, classID, cd);
}
/**
* Get the class data for a specific class.
* @param uuid The UUID of the player
* @param classID the id of the class
* @return a {@link ClassData} object if there is data found, null if no data was found.
*/
public static ClassData getClassDataForPlayer(UUID uuid, String classID) {
try {
Class.forName("org.sqlite.JDBC");
try (Connection conn = DriverManager.getConnection(url);
Statement stmt = conn.createStatement()) {
ResultSet result = stmt.executeQuery("SELECT * FROM classData WHERE uuid='" + uuid + "' AND class='" + classID+ "'");
if (result.next()) {
Gson gson = new Gson();
classData cd = gson.fromJson(result.getString("classData"), classData.class);
selectedPerks sp = cd.selectedPerks;
return new ClassData(
cd.id,
cd.level,
cd.subClass,
new SubClassData(cd.subClassOne.unlocked, cd.subClassOne.level),
new SubClassData(cd.subClassTwo.unlocked, cd.subClassTwo.level),
sp.one,
sp.two,
sp.three,
sp.four,
sp.five
);
} else {
return new ClassData(
classID,
1,
0,
new SubClassData(
false,
0
),
new SubClassData(
false,
0
),
"none",
"none",
"none",
"none",
"none"
);
}
} catch (SQLException e) {
e.printStackTrace();
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
static class classData {
// The id of the class
public String id;
// The level that the class is at
public int level;
// The subClass that was chosen 0=none, 1=first, 2=second
public int subClass;
// The first subClass's data.
public subClassData subClassOne;
// The second subClass's data.
public subClassData subClassTwo;
// The selected perks
public selectedPerks selectedPerks;
public classData(String id, int level, int subClass, subClassData subClassOne, subClassData subClassTwo, selectedPerks selectedPerks) {
this.id = id;
this.level = level;
this.subClass = subClass;
this.subClassOne = subClassOne;
this.subClassTwo = subClassTwo;
this.selectedPerks = selectedPerks;
}
}
static class subClassData {
public boolean unlocked;
public int level;
public subClassData(boolean unlocked, int level) {
this.unlocked = unlocked;
this.level = level;
}
}
static class selectedPerks {
public String one;
public String two;
public String three;
public String four;
public String five;
public selectedPerks(String one, String two, String three, String four, String five) {
this.one = one;
this.two = two;
this.three = three;
this.four = four;
this.five = five;
}
}
}

View File

@ -0,0 +1,58 @@
package nl.dragontamerfred.YRPerks;
import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File;
public class PerkSettings {
// archersAgility
public static int ARCHERS_AGILITY_DURATION;
public static int ARCHERS_AGILITY_AMPLIFIER;
// trustyBow
public static int TRUSTY_BOW_DAMAGE;
// blessingOfTheGoddess
public static int BLESSING_OF_THE_GODDESS_CHANCE;
public static int BLESSING_OF_THE_GODDESS_MAX_LEVEL;
// goldedHeart
public static int GOLDEN_HEART_CHANCE;
public static int GOLDEN_HEART_MAX_HEARTS;
// arrowSpawn
public static int ARROW_SPAWN_AMOUNT;
public static void load(File file) {
try {
if (!file.getParentFile().exists())
file.getParentFile().mkdirs();
if (!file.exists())
Utils.ExportResource("/perks.yml", file);
YamlConfiguration config = new YamlConfiguration();
config.load(file);
// archersAgility
ARCHERS_AGILITY_DURATION = config.getInt("archersAgility.duration");
ARCHERS_AGILITY_AMPLIFIER = config.getInt("archersAgility.amplifier");
// trustyBow
TRUSTY_BOW_DAMAGE = config.getInt("trustyBow.damage");
// blessingOfTheGoddess
BLESSING_OF_THE_GODDESS_CHANCE = config.getInt("blessingOfTheGoddess.chance");
BLESSING_OF_THE_GODDESS_MAX_LEVEL = config.getInt("blessingOfTheGoddess.max-level");
// goldenHeart
GOLDEN_HEART_CHANCE = config.getInt("goldenHeart.chance");
GOLDEN_HEART_MAX_HEARTS = config.getInt("goldenHeart.max-hearts");
//arrowSpawn
ARROW_SPAWN_AMOUNT = config.getInt("arrowSpawn.amount");
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,42 @@
package nl.dragontamerfred.YRPerks.Perks;
import nl.dragontamerfred.YRPerks.Events.KillEvent;
import nl.dragontamerfred.YRPerks.PerkManager;
import nl.dragontamerfred.YRPerks.PerkSettings;
import nl.dragontamerfred.YRPerks.Types.Perk;
import nl.dragontamerfred.YRPerks.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.List;
public class PerkArchersAgility extends Perk implements Listener {
public PerkArchersAgility() {
this.id = "archersAgility";
this.name = "Archers Agility";
this.material = Material.FEATHER;
this.damage = 0;
List<String> description = new ArrayList<>();
description.add("Get speed for");
description.add("a short time");
description.add("to back up and");
description.add("engage from");
description.add("a distance.");
this.description = Utils.color(description);
}
@EventHandler
public void on(KillEvent event) {
Player killer = event.getKiller();
if (PerkManager.playerHasPerkSelected(killer.getUniqueId(), id)) {
killer.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, PerkSettings.ARCHERS_AGILITY_DURATION,PerkSettings.ARCHERS_AGILITY_AMPLIFIER,false,false));
}
}
}

View File

@ -0,0 +1,40 @@
package nl.dragontamerfred.YRPerks.Perks;
import nl.dragontamerfred.YRPerks.Events.KillEvent;
import nl.dragontamerfred.YRPerks.PerkManager;
import nl.dragontamerfred.YRPerks.PerkSettings;
import nl.dragontamerfred.YRPerks.Types.Perk;
import nl.dragontamerfred.YRPerks.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
public class PerkArrowSpawn extends Perk implements Listener {
public PerkArrowSpawn() {
this.id = "arrowSpawn";
this.name = "Arrow Spawn";
this.material = Material.ARROW;
this.damage = 0;
List<String> description = new ArrayList<>();
description.add("After every kill");
description.add("you'll be granted");
description.add("a few arrows to");
description.add("continue your");
description.add("rampage.");
this.description = Utils.color(description);
}
@EventHandler
public void on(KillEvent event) {
Player killer = event.getKiller();
if (PerkManager.playerHasPerkSelected(killer.getUniqueId(), id)) {
killer.getInventory().addItem(new ItemStack(Material.ARROW, PerkSettings.ARROW_SPAWN_AMOUNT));
}
}
}

View File

@ -0,0 +1,55 @@
package nl.dragontamerfred.YRPerks.Perks;
import nl.dragontamerfred.YRPerks.Events.KillEvent;
import nl.dragontamerfred.YRPerks.PerkManager;
import nl.dragontamerfred.YRPerks.PerkSettings;
import nl.dragontamerfred.YRPerks.Types.DamageCause;
import nl.dragontamerfred.YRPerks.Types.Perk;
import nl.dragontamerfred.YRPerks.Utils;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class PerkBlessingOfTheGoddess extends Perk implements Listener {
public PerkBlessingOfTheGoddess() {
this.id = "blessingOfTheGoddess";
this.name = "Blessing Of The Goddess";
this.material = Material.ENCHANTED_BOOK;
this.damage = 0;
List<String> description = new ArrayList<>();
description.add("The godess of");
description.add("the hunt might");
description.add("bless you by");
description.add("enchanting");
description.add("your bow...");
this.description = Utils.color(description);
}
@EventHandler
public void on(KillEvent event) {
Player killer = event.getKiller();
if (PerkManager.playerHasPerkSelected(killer.getUniqueId(), id)) {
if (event.getCause() == DamageCause.ARROW) {
Random rand = new Random();
if (rand.nextInt(100) <= PerkSettings.BLESSING_OF_THE_GODDESS_CHANCE) {
for (ItemStack is : killer.getInventory().getContents()) {
if (is.getType() == Material.BOW) {
int level = is.getEnchantmentLevel(Enchantment.ARROW_DAMAGE);
if (level < PerkSettings.BLESSING_OF_THE_GODDESS_MAX_LEVEL)
is.addEnchantment(Enchantment.ARROW_DAMAGE, level+1);
break;
}
}
}
}
}
}
}

View File

@ -0,0 +1,44 @@
package nl.dragontamerfred.YRPerks.Perks;
import nl.dragontamerfred.YRPerks.Events.KillEvent;
import nl.dragontamerfred.YRPerks.PerkManager;
import nl.dragontamerfred.YRPerks.PerkSettings;
import nl.dragontamerfred.YRPerks.Types.Perk;
import nl.dragontamerfred.YRPerks.Utils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class PerkGoldenHeart extends Perk implements Listener {
public PerkGoldenHeart() {
this.id = "goldenHeart";
this.name = "Golden Heart";
this.material = Material.GOLDEN_APPLE;
this.damage = 0;
List<String> description = new ArrayList<>();
description.add("You can feel");
description.add("yourself getting");
description.add("stronger every");
description.add("time you defeat");
description.add("an opponent.");
this.description = Utils.color(description);
}
@EventHandler
public void on(KillEvent event) {
Player killer = event.getKiller();
if (PerkManager.playerHasPerkSelected(killer.getUniqueId(), id)) {
Random rand = new Random();
if (rand.nextInt(100) <= PerkSettings.GOLDEN_HEART_CHANCE) {
if (((killer.getMaxHealth() - 20) / 2) < PerkSettings.GOLDEN_HEART_MAX_HEARTS)
killer.setMaxHealth(killer.getMaxHealth() + 2.0);
}
}
}
}

View File

@ -0,0 +1,25 @@
package nl.dragontamerfred.YRPerks.Perks;
import nl.dragontamerfred.YRPerks.Types.Perk;
import nl.dragontamerfred.YRPerks.Utils;
import org.bukkit.Material;
import org.bukkit.event.Listener;
import java.util.ArrayList;
import java.util.List;
public class PerkNone extends Perk implements Listener {
public PerkNone() {
this.id = "none";
this.name = "None";
this.material = Material.BARRIER;
this.damage = 0;
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = Utils.color(description);
}
}

View File

@ -0,0 +1,28 @@
package nl.dragontamerfred.YRPerks.Perks;
import nl.dragontamerfred.YRPerks.Types.Perk;
import nl.dragontamerfred.YRPerks.Utils;
import org.bukkit.Material;
import org.bukkit.event.Listener;
import java.util.ArrayList;
import java.util.List;
public class PerkTrustyBow extends Perk implements Listener {
public PerkTrustyBow() {
this.id = "trustBow";
this.name = "Trusty Bow";
this.material = Material.BOW;
this.damage = 379;
List<String> description = new ArrayList<>();
description.add("Although it's");
description.add("almost broken,");
description.add("your old trusty");
description.add("bow is still");
description.add("worth it.");
this.description = Utils.color(description);
}
//TODO Add the item to the loadout when the loadout plugin is done.
}

View File

@ -0,0 +1,70 @@
package nl.dragontamerfred.YRPerks.SubClasses;
import nl.dragontamerfred.YRPerks.Types.Level;
import nl.dragontamerfred.YRPerks.Types.Reward;
import nl.dragontamerfred.YRPerks.Types.SubClasss;
import org.bukkit.Material;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class SubClassElf extends SubClasss {
public SubClassElf() {
this.id = "elf";
this.name = "Elf";
this.material = Material.BARRIER;
this.damage = 0;
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
LinkedList<Level> levels = new LinkedList<>();
levels.add(new level1());
levels.add(new level2());
levels.add(new level3());
this.levels = levels;
}
private class level1 extends Level {
private level1() {
this.name = "Level 1";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("elfJump");
}
}
private class level2 extends Level {
private level2() {
this.name = "Level 2";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("barrage");
}
}
private class level3 extends Level {
private level3() {
this.name = "Level 3";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("none");
}
}
}

View File

@ -0,0 +1,70 @@
package nl.dragontamerfred.YRPerks.SubClasses;
import nl.dragontamerfred.YRPerks.Types.Level;
import nl.dragontamerfred.YRPerks.Types.Reward;
import nl.dragontamerfred.YRPerks.Types.SubClasss;
import org.bukkit.Material;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class SubClassHunter extends SubClasss {
public SubClassHunter() {
this.id = "elf";
this.name = "Elf";
this.material = Material.BARRIER;
this.damage = 0;
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
LinkedList<Level> levels = new LinkedList<>();
levels.add(new level1());
levels.add(new level2());
levels.add(new level3());
this.levels = levels;
}
private class level1 extends Level {
private level1() {
this.name = "Level 1";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("packSummoner");
}
}
private class level2 extends Level {
private level2() {
this.name = "Level 2";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("grapplingHook");
}
}
private class level3 extends Level {
private level3() {
this.name = "Level 3";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("none");
}
}
}

View File

@ -0,0 +1,70 @@
package nl.dragontamerfred.YRPerks.SubClasses;
import nl.dragontamerfred.YRPerks.Types.Level;
import nl.dragontamerfred.YRPerks.Types.Reward;
import nl.dragontamerfred.YRPerks.Types.SubClasss;
import org.bukkit.Material;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
public class SubClassNone extends SubClasss {
public SubClassNone() {
this.id = "none";
this.name = "None";
this.material = Material.BARRIER;
this.damage = 0;
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
LinkedList<Level> levels = new LinkedList<>();
levels.add(new level1());
levels.add(new level2());
levels.add(new level3());
this.levels = levels;
}
private class level1 extends Level {
private level1() {
this.name = "Level 1";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("none");
}
}
private class level2 extends Level {
private level2() {
this.name = "Level 2";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("none");
}
}
private class level3 extends Level {
private level3() {
this.name = "Level 3";
List<String> description = new ArrayList<>();
description.add("This is");
description.add("something");
description.add("jharmen has");
description.add("to do.");
this.description = description;
this.reward = new Reward(Reward.Type.PERK).setPerk("none");
}
}
}

View File

@ -0,0 +1,67 @@
package nl.dragontamerfred.YRPerks.Types;
public class ClassData {
public String id;
public int level;
public int subClass;
public SubClassData subClassOne;
public SubClassData subClassTwo;
public String perkOne;
public String perkTwo;
public String perkThree;
public String perkFour;
public String perkFive;
public ClassData(String id, int level, int subClass, SubClassData subClassOne, SubClassData subClassTwo, String perkOne, String perkTwo, String perkThree, String perkFour, String perkFive) {
this.id = id;
this.level = level;
this.subClass = subClass;
this.subClassOne = subClassOne;
this.subClassTwo = subClassTwo;
this.perkOne = perkOne;
this.perkTwo = perkTwo;
this.perkThree = perkThree;
this.perkFour = perkFour;
this.perkFive = perkFive;
}
public void setPerkBySlot(int slot, String perk) {
switch (slot) {
case 1:
perkOne = perk;
break;
case 2:
perkTwo = perk;
break;
case 3:
perkThree = perk;
break;
case 4:
perkFour = perk;
break;
case 5:
perkFive = perk;
break;
}
}
public boolean hasPerk(String perk) {
if (perk.equals(perkOne))
return true;
else if (perk.equals(perkTwo))
return true;
else if (perk.equals(perkThree))
return true;
else if (perk.equals(perkFour))
return true;
else if (perk.equals(perkFive))
return true;
return false;
}
public ClassData setLevel(int level) {
this.level = level;
return this;
}
}

View File

@ -0,0 +1,19 @@
package nl.dragontamerfred.YRPerks.Types;
import org.bukkit.Material;
import java.util.LinkedList;
import java.util.List;
public class Classs {
public String id;
public String name;
public Material material;
public Short damage;
public List<String> description;
public LinkedList<Level> levels;
public SubClasss subClassOne;
public SubClasss subClassTwo;
}

View File

@ -0,0 +1,8 @@
package nl.dragontamerfred.YRPerks.Types;
public enum DamageCause {
PVP,
ARROW,
SNOWBALL,
MISC;
}

View File

@ -0,0 +1,10 @@
package nl.dragontamerfred.YRPerks.Types;
import java.util.List;
public class Level {
public String name;
public List<String> description;
public Reward reward;
}

View File

@ -0,0 +1,23 @@
package nl.dragontamerfred.YRPerks.Types;
import org.bukkit.Material;
import org.bukkit.event.Listener;
import java.util.List;
import java.util.UUID;
/**
* Every class extending this class should also implement {@link Listener}.
* If this is not the case it might cause issues at runtime.
*/
public class Perk implements Listener {
public String id;
public String name;
public Material material;
public Short damage;
public List<String> description;
public void resetCooldown(UUID uuid) {}
}

View File

@ -0,0 +1,22 @@
package nl.dragontamerfred.YRPerks.Types;
public class Reward {
public String perk;
public Type type;
public Reward(Type type) {
this.type = type;
}
public Reward setPerk(String perk) {
this.perk = perk;
return this;
}
public enum Type {
PERK,
SUB_ClASSS,
PERK_WITH_SUB_CLASS
}
}

View File

@ -0,0 +1,11 @@
package nl.dragontamerfred.YRPerks.Types;
public class SubClassData {
public boolean unlocked;
public int level;
public SubClassData(boolean unlocked, int level) {
this.unlocked = unlocked;
this.level = level;
}
}

View File

@ -0,0 +1,16 @@
package nl.dragontamerfred.YRPerks.Types;
import org.bukkit.Material;
import java.util.LinkedList;
import java.util.List;
public class SubClasss {
public String id;
public String name;
public Material material;
public Short damage;
public List<String> description;
public LinkedList<Level> levels;
}

View File

@ -0,0 +1,57 @@
package nl.dragontamerfred.YRPerks;
import nl.dragontamerfred.YRPerks.Types.Perk;
import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import javax.rmi.CORBA.Util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;
public class Utils {
public static ItemStack createPerkItemStack(Perk perk) {
ItemStack perkStack = new ItemStack(perk.material, 1, perk.damage);
ItemMeta perkMeta = perkStack.getItemMeta();
perkMeta.setDisplayName(perk.name);
List<String> lore = perk.description;
lore.add(ChatColor.BLACK + perk.id);
perkMeta.setLore(lore);
perkStack.setItemMeta(perkMeta);
return perkStack;
}
public static void ExportResource(String resourceName, File output) {
try (InputStream stream = Util.class.getResourceAsStream(resourceName); OutputStream resStreamOut = new FileOutputStream(output)) {
if (stream == null) {
throw new Exception("Cannot get resource \"" + resourceName + "\" from Jar file.");
}
int readBytes;
byte[] buffer = new byte[4096];
while ((readBytes = stream.read(buffer)) > 0) {
resStreamOut.write(buffer, 0, readBytes);
}
} catch (Exception ex) {
YRPerks.logger.severe("Could not copy defaults from jar! The plugin wont work without these!");
}
}
public static String color(String s) {
return ChatColor.translateAlternateColorCodes('&', s);
}
public static List<String> color(List<String> ls) {
List<String> r = new ArrayList<>();
for (String s : ls) {
r.add(color(s));
}
return r;
}
}

View File

@ -0,0 +1,62 @@
package nl.dragontamerfred.YRPerks;
import nl.dragontamerfred.YRPerks.Classes.ClassArcher;
import nl.dragontamerfred.YRPerks.Classes.ClassNone;
import nl.dragontamerfred.YRPerks.Commands.CommandPerks;
import nl.dragontamerfred.YRPerks.GUI.AdminGui;
import nl.dragontamerfred.YRPerks.GUI.MainGui;
import nl.dragontamerfred.YRPerks.GUI.PerkGui;
import nl.dragontamerfred.YRPerks.Perks.*;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.logging.Logger;
public final class YRPerks extends JavaPlugin {
public static YRPerks plugin;
public static Logger logger = Logger.getLogger("minecraft");
@Override
public void onEnable() {
plugin = this;
PerkManager.init(new File(getDataFolder(), "playerData.db"));
// Load config, messages and perk config files
logger.info("Loading config");
Config.load(new File(getDataFolder(), "config.yml"));
logger.info("Loading messages");
Messages.load(new File(getDataFolder(), "messages.yml"));
logger.info("Loading perk settings");
PerkSettings.load(new File(getDataFolder(), "perks.yml"));
// Register listeners
getServer().getPluginManager().registerEvents(new MainGui(), this);
getServer().getPluginManager().registerEvents(new PerkGui(), this);
getServer().getPluginManager().registerEvents(new AdminGui(), this);
// Register commands
getCommand("perks").setExecutor(new CommandPerks());
// Register classes
logger.info("Loading classes");
PerkManager.registerClass(new ClassNone());
PerkManager.registerClass(new ClassArcher());
// Register perks
logger.info("Loading perks");
PerkManager.registerPerk(new PerkNone());
// Archer perks
PerkManager.registerPerk(new PerkArchersAgility());
PerkManager.registerPerk(new PerkTrustyBow());
PerkManager.registerPerk(new PerkBlessingOfTheGoddess());
PerkManager.registerPerk(new PerkGoldenHeart());
PerkManager.registerPerk(new PerkArrowSpawn());
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}

View File

@ -0,0 +1,14 @@
inventory:
general:
back-button:
material: "ARROW"
damage: 0
name: "&cBack"
main:
name: "Class selection"
perks:
name: "Select perk"
classes:
name: "Select class"
admin:
name: "Admin controls"

View File

@ -0,0 +1,5 @@
prefix: "&7[&4Perks&7] &r"
not-a-player: "&cYou are not a player."
no-permission: "&cYou do not have the required permission to use this command."
player-not-found: "&cPlayer not found by the name of &f<PLAYER_NAME>&c."
invalid-usage: "&cInvalid usage."

View File

@ -0,0 +1,14 @@
archersAgility:
duration: 60 # In game ticks (seconds*20).
amplifier: 0 # Starts at 0.
trustyBow:
damage: 379 # The durability lost on the bow added to the loadout.
blessingOfTheGoddess:
chance: 20 # Chance out of one hundred that the perk will activate.
max-level: 5 # The max level of power you can obtain from this perk.
goldenHeart:
chance: 50 # Chance out of one hundred that the perk will activate.
max-hearts: 10 # The highest amount of extra hearts you can have at once using this perk.
arrowSpawn:
amount: 5 # The amount of arrows you get per kill.

View File

@ -0,0 +1,6 @@
name: YR-Perks
version: @version@
main: nl.dragontamerfred.YRPerks.YRPerks
authors: [dragontamerfred]
commands:
perks: