0.5.7 some cool bug fixes and code prettier
This commit is contained in:
parent
7b11d86487
commit
8a11e28c8b
132 changed files with 6360 additions and 5227 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
# User-specific stuff
|
||||
server/
|
||||
.idea/
|
||||
.vscode/
|
||||
.settings/
|
||||
|
|
34
build.gradle
34
build.gradle
|
@ -1,8 +1,8 @@
|
|||
plugins {
|
||||
id 'java'
|
||||
id 'maven-publish'
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
id "io.papermc.paperweight.userdev" version "1.3.9"
|
||||
id "com.github.johnrengelman.shadow" version "8.1.1"
|
||||
id "io.papermc.paperweight.userdev" version "1.5.4"
|
||||
}
|
||||
|
||||
apply plugin: "java"
|
||||
|
@ -62,8 +62,9 @@ dependencies {
|
|||
implementation 'org.mongodb:bson:4.7.2'
|
||||
implementation 'org.mongodb:mongodb-driver-core:4.7.2'
|
||||
|
||||
implementation 'de.tr7zw:item-nbt-api-plugin:2.11.1'
|
||||
compileOnly 'io.papermc.paper:paper-api:1.19.3-R0.1-SNAPSHOT'
|
||||
compileOnly 'io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT'
|
||||
implementation 'de.tr7zw:item-nbt-api-plugin:2.11.2'
|
||||
// compileOnly 'de.tr7zw:item-nbt-api:2.11.2'
|
||||
compileOnly 'com.comphenix.protocol:ProtocolLib:4.8.0'
|
||||
compileOnly 'net.luckperms:api:5.4'
|
||||
compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1'
|
||||
|
@ -71,17 +72,17 @@ dependencies {
|
|||
//compileOnly 'com.fastasyncworldedit:FastAsyncWorldEdit-Core:2.3.0'
|
||||
//compileOnly 'com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit:2.3.0'
|
||||
compileOnly 'me.clip:placeholderapi:2.11.2'
|
||||
compileOnly('net.citizensnpcs:citizens-main:2.0.30-SNAPSHOT') {
|
||||
compileOnly('net.citizensnpcs:citizens-main:2.0.31-SNAPSHOT') {
|
||||
exclude group: '*', module: '*'
|
||||
}
|
||||
compileOnly 'com.onarandombox.multiversecore:Multiverse-Core:4.3.1'
|
||||
compileOnly 'me.filoghost.holographicdisplays:holographicdisplays-api:3.0.0'
|
||||
compileOnly fileTree(dir: 'libs', include: '*.jar')
|
||||
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19.3-R0.1-SNAPSHOT")
|
||||
// compileOnly 'me.filoghost.holographicdisplays:holographicdisplays-api:3.0.1'
|
||||
// compileOnly fileTree(dir: 'libs', include: '*.jar')
|
||||
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19.4-R0.1-SNAPSHOT")
|
||||
}
|
||||
|
||||
group = 'me.unurled'
|
||||
version = '0.5.6'
|
||||
version = '0.5.7'
|
||||
description = 'Raxen'
|
||||
|
||||
java {
|
||||
|
@ -100,31 +101,34 @@ publishing {
|
|||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = 'UTF-8'
|
||||
options.release = 17
|
||||
options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation"]
|
||||
|
||||
}
|
||||
|
||||
tasks {
|
||||
assemble {
|
||||
dependsOn(reobfJar)
|
||||
}
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
dependencies {
|
||||
include dependency('de.tr7zw:item-nbt-api-plugin:2.11.1')
|
||||
include dependency('de.tr7zw:item-nbt-api-plugin:2.11.2')
|
||||
include dependency('de.tr7zw:item-nbt-api:2.11.2')
|
||||
include dependency('org.mongodb:mongodb-driver-sync:4.7.2')
|
||||
include dependency('org.mongodb:bson:4.7.2')
|
||||
include dependency('org.mongodb:mongodb-driver-core:4.7.2')
|
||||
}
|
||||
relocate("de.tr7zw.changeme", "me.unurled.libs.de.tr7zw")
|
||||
relocate("de.tr7zw", "me.unurled.libs.de.tr7zw")
|
||||
relocate("com.mongodb", 'me.unurled.libs.com.mongodb')
|
||||
relocate("org.bson", 'me.unurled.libs.org.bson')
|
||||
processResources {
|
||||
expand version: project.version
|
||||
}
|
||||
minimize()
|
||||
}
|
||||
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation"]
|
||||
}
|
||||
|
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,4 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
6
gradlew
vendored
Normal file → Executable file
6
gradlew
vendored
Normal file → Executable file
|
@ -205,6 +205,12 @@ set -- \
|
|||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
|
14
gradlew.bat
vendored
14
gradlew.bat
vendored
|
@ -14,7 +14,7 @@
|
|||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
|
@ -25,7 +25,7 @@
|
|||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
@ -75,13 +75,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
|
@ -7,4 +7,4 @@ pluginManagement {
|
|||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'raxen'
|
||||
rootProject.name = 'raxen'
|
|
@ -1,7 +1,10 @@
|
|||
package me.unurled.raxen;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorComp;
|
||||
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.config.Config;
|
||||
import me.unurled.raxen.config.PlayerConfig;
|
||||
|
@ -11,135 +14,155 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorComp;
|
||||
|
||||
public final class Raxen extends JavaPlugin {
|
||||
|
||||
private static final String prefix = "<aqua>Rx</aqua><light_purple>></light_purple> ";
|
||||
@Getter private static String version = "0.5.6";
|
||||
private final PluginManager pm = getServer().getPluginManager();
|
||||
private static final String prefix =
|
||||
"<aqua>Rx</aqua><light_purple>></light_purple> ";
|
||||
|
||||
private static Raxen plugin;
|
||||
@Getter
|
||||
private static String version = "0.5.7";
|
||||
|
||||
private static Logger logger;
|
||||
private boolean loading = true;
|
||||
private final PluginManager pm = getServer().getPluginManager();
|
||||
|
||||
private static Config config;
|
||||
private static Raxen plugin;
|
||||
|
||||
private static PlayerConfig playerConfig;
|
||||
private static Logger logger;
|
||||
|
||||
@Getter private ProtocolManager protocolManager;
|
||||
private static Config config;
|
||||
|
||||
@Getter private Manager manager;
|
||||
private static PlayerConfig playerConfig;
|
||||
|
||||
/**
|
||||
* Method when the server launch the plugin.
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
logger = getLogger();
|
||||
version = plugin.getDescription().getVersion();
|
||||
manager = new Manager();
|
||||
manager.set(plugin);
|
||||
@Getter
|
||||
private ProtocolManager protocolManager;
|
||||
|
||||
// Config
|
||||
config = new Config(plugin);
|
||||
@Getter
|
||||
private Manager manager;
|
||||
|
||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
/**
|
||||
* Method when the server launch the plugin.
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
logger = getLogger();
|
||||
|
||||
playerConfig = new PlayerConfig(plugin);
|
||||
version = this.getPluginMeta().getVersion();
|
||||
|
||||
//register Commands and Events
|
||||
registerCommands();
|
||||
registerEvents();
|
||||
manager = new Manager();
|
||||
manager.set(plugin);
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(colorComp(prefix +"<green>Server Started Successfully!</green>"));
|
||||
// Config
|
||||
config = new Config(plugin);
|
||||
|
||||
manager.getListenerManager().getServerPingEvent().setLoading(false);
|
||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
|
||||
playerConfig = new PlayerConfig(plugin);
|
||||
|
||||
//register Commands and Events
|
||||
registerCommands();
|
||||
registerEvents();
|
||||
|
||||
Bukkit
|
||||
.getConsoleSender()
|
||||
.sendMessage(
|
||||
colorComp(prefix + "<green>Server Started Successfully!</green>")
|
||||
);
|
||||
|
||||
manager.getListenerManager().getServerPingEvent().setLoading(false);
|
||||
loading = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* register the command in the command manager class.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
manager.getCommandManager().register();
|
||||
|
||||
Bukkit
|
||||
.getConsoleSender()
|
||||
.sendMessage(colorComp(prefix + "<green>Commands Registered!</green>"));
|
||||
}
|
||||
|
||||
/**
|
||||
* register the events in the event manager class.
|
||||
*/
|
||||
private void registerEvents() {
|
||||
manager.getListenerManager().register();
|
||||
|
||||
Bukkit
|
||||
.getConsoleSender()
|
||||
.sendMessage(colorComp(prefix + "<green>Events Registered!</green>"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method when the server stops the plugin.
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (!loading) {
|
||||
manager.getListenerManager().getServerPingEvent().setLoading(true);
|
||||
Reload.kickAll();
|
||||
|
||||
playerConfig.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* register the command in the command manager class.
|
||||
*/
|
||||
private void registerCommands() {
|
||||
manager.getCommandManager().register();
|
||||
Bukkit
|
||||
.getConsoleSender()
|
||||
.sendMessage(
|
||||
colorComp(prefix + "<red>Server Stopped Successfully!</red>")
|
||||
);
|
||||
}
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(colorComp(prefix +"<green>Commands Registered!</green>"));
|
||||
}
|
||||
/**
|
||||
* getter for the logger
|
||||
* @return the plugin logger
|
||||
*/
|
||||
public Logger getPluginLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* register the events in the event manager class.
|
||||
*/
|
||||
private void registerEvents() {
|
||||
manager.getListenerManager().register();
|
||||
/**
|
||||
* getter for the bukkit's plugin manager
|
||||
* @return plugin manager
|
||||
*/
|
||||
public PluginManager getPm() {
|
||||
return pm;
|
||||
}
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(colorComp(prefix +"<green>Events Registered!</green>"));
|
||||
}
|
||||
/**
|
||||
* return the instance which is launched.
|
||||
* @return main instance
|
||||
*/
|
||||
public Raxen getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method when the server stops the plugin.
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
manager.getListenerManager().getServerPingEvent().setLoading(true);
|
||||
Reload.kickAll();
|
||||
/**
|
||||
* getter for the raxen prefix
|
||||
* @return string prefix
|
||||
*/
|
||||
public static String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
playerConfig.close();
|
||||
/**
|
||||
* getter for the yml's player configs.
|
||||
* @return player config instance
|
||||
*/
|
||||
public PlayerConfig getPlayerConfig() {
|
||||
return playerConfig;
|
||||
}
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(colorComp(prefix +"<red>Server Stopped Successfully!</red>"));
|
||||
}
|
||||
/**
|
||||
* getter for an instance of the config utility class
|
||||
* @return raxen's config
|
||||
*/
|
||||
public Config getConf() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for the logger
|
||||
* @return the plugin logger
|
||||
*/
|
||||
public Logger getPluginLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for the bukkit's plugin manager
|
||||
* @return plugin manager
|
||||
*/
|
||||
public PluginManager getPm() {
|
||||
return pm;
|
||||
}
|
||||
|
||||
/**
|
||||
* return the instance which is launched.
|
||||
* @return main instance
|
||||
*/
|
||||
public Raxen getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for the raxen prefix
|
||||
* @return string prefix
|
||||
*/
|
||||
public static String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for the yml's player configs.
|
||||
* @return player config instance
|
||||
*/
|
||||
public PlayerConfig getPlayerConfig() {
|
||||
return playerConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter for an instance of the config utility class
|
||||
* @return raxen's config
|
||||
*/
|
||||
public Config getConf() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
this.setEnabled(false);
|
||||
}
|
||||
public void disable() {
|
||||
this.setEnabled(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package me.unurled.raxen.commands;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import java.util.List;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.manager.entity.StorageManager;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
|
@ -11,114 +14,209 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
public class RaxenCommand implements TabExecutor {
|
||||
|
||||
private Raxen main;
|
||||
private Raxen main;
|
||||
|
||||
public RaxenCommand(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
public RaxenCommand(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String msg, @NotNull String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if(!(player.hasPermission("raxen."))) {
|
||||
msgPlayer(player, coloredString(Raxen.getPrefix()) + colorTextComp("<red>You can't execute this command. Insufficient permission."));
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command cmd,
|
||||
@NotNull String msg,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (!(player.hasPermission("raxen."))) {
|
||||
msgPlayer(
|
||||
player,
|
||||
coloredString(Raxen.getPrefix()) +
|
||||
colorTextComp(
|
||||
"<red>You can't execute this command. Insufficient permission."
|
||||
)
|
||||
);
|
||||
}
|
||||
switch (args.length) {
|
||||
case 0 -> msgPl(player, 0);
|
||||
case 1 -> {
|
||||
switch (args[0]) {
|
||||
case "mongodb", "mongo", "MONGODB", "MONGO" -> {
|
||||
//print info about connection
|
||||
sender.sendMessage(
|
||||
stringToComp(
|
||||
Raxen.getPrefix() +
|
||||
colorTextComp(
|
||||
"<gold>Printing About Raxen's MongoDB connection..."
|
||||
)
|
||||
)
|
||||
);
|
||||
msgPlayer(
|
||||
player,
|
||||
coloredString(Raxen.getPrefix()) +
|
||||
colorTextComp(
|
||||
"<gold>---------------------------------------------"
|
||||
)
|
||||
);
|
||||
msgPlayer(player, colorTextComp("<red>MONGO DB<white>"));
|
||||
msgPlayer(
|
||||
player,
|
||||
StorageManager
|
||||
.getMongodb()
|
||||
.getMongoClient()
|
||||
.getClusterDescription()
|
||||
.toString()
|
||||
);
|
||||
msgPlayer(
|
||||
player,
|
||||
StorageManager.getMongodb().getMongoDatabase().getName()
|
||||
);
|
||||
msgPlayer(
|
||||
player,
|
||||
StorageManager
|
||||
.getMongodb()
|
||||
.getMongoCollection()
|
||||
.getNamespace()
|
||||
.toString()
|
||||
);
|
||||
msgPlayer(
|
||||
player,
|
||||
"<gold>---------------------------------------------"
|
||||
);
|
||||
}
|
||||
switch (args.length) {
|
||||
case 0 -> msgPl(player, 0);
|
||||
case 1 -> {
|
||||
switch (args[0]) {
|
||||
case "mongodb", "mongo", "MONGODB", "MONGO" -> {
|
||||
//print info about connection
|
||||
sender.sendMessage(coloredString(Raxen.getPrefix()) + colorTextComp("<gold>Printing About Raxen's MongoDB connection..."));
|
||||
msgPlayer(player, coloredString(Raxen.getPrefix()) +
|
||||
colorTextComp("<gold>---------------------------------------------"));
|
||||
msgPlayer(player, colorTextComp("<red>MONGO DB<white>"));
|
||||
msgPlayer(player, StorageManager.getMongodb().getMongoClient().getClusterDescription().toString());
|
||||
msgPlayer(player, StorageManager.getMongodb().getMongoDatabase().getName());
|
||||
msgPlayer(player, StorageManager.getMongodb().getMongoCollection().getNamespace().toString());
|
||||
msgPlayer(player, "<gold>---------------------------------------------");
|
||||
}
|
||||
case "v", "version", "ver" -> {
|
||||
msgPl(player, 0);
|
||||
}
|
||||
case "hemlp", "?", "h" -> {
|
||||
//print help
|
||||
}
|
||||
}
|
||||
}
|
||||
case "v", "version", "ver" -> {
|
||||
msgPlayer(player, Raxen.getVersion());
|
||||
}
|
||||
}
|
||||
else {
|
||||
log(String.valueOf(args.length));
|
||||
switch (args.length) {
|
||||
case 0 -> {
|
||||
msgSender(sender, Raxen.getPrefix() + "<gold>Printing About Raxen...",
|
||||
"<gold>---------------------------------------------",
|
||||
"<dark_aqua> Raxen ",
|
||||
"<dark_aqua> - Version: " + Raxen.getVersion(),
|
||||
"<dark_aqua> - Author: <b><red>U<gold>n<yellow>u<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>");
|
||||
TextComponent txt = colorTextComp("<dark_aqua> - Website: https://unurled.me");
|
||||
sender.sendMessage(txt);
|
||||
sender.sendMessage(coloredString("<gold>---------------------------------------------"));
|
||||
return true;
|
||||
}
|
||||
case 1 -> {
|
||||
switch (args[0]) {
|
||||
case "mongodb", "mongo", "MONGODB", "MONGO" -> {
|
||||
//print info about connection
|
||||
msgSender(sender, Raxen.getPrefix() + "<gold>Printing About Raxen's MongoDB connection...",
|
||||
"<gold>---------------------------------------------" + "<red>MONGO DB");
|
||||
sender.sendMessage(StorageManager.getMongodb().getMongoClient().getClusterDescription().toString());
|
||||
sender.sendMessage(StorageManager.getMongodb().getMongoDatabase().getName());
|
||||
sender.sendMessage(StorageManager.getMongodb().getMongoCollection().getNamespace().toString());
|
||||
sender.sendMessage(coloredString("<gold>---------------------------------------------"));
|
||||
return true;
|
||||
}
|
||||
case "v", "version", "ver" -> {
|
||||
msgSender(sender, Raxen.getPrefix() + "<gold>Printing About Raxen...",
|
||||
"<gold>---------------------------------------------",
|
||||
"<dark_aqua> Raxen ",
|
||||
"<dark_aqua> - Version: " + Raxen.getVersion(),
|
||||
"<dark_aqua> - Author: <b><red>U<gold>n&eu<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>");
|
||||
TextComponent txt=colorTextComp("<dark_aqua> - Website: https://unurled.me");
|
||||
sender.sendMessage(txt);
|
||||
sender.sendMessage(coloredString("<gold>---------------------------------------------"));
|
||||
return true;
|
||||
}
|
||||
case "hemlp", "?", "h" ->
|
||||
//print help
|
||||
debug(main, "print help");
|
||||
}
|
||||
}
|
||||
case "hemlp", "?", "h" -> {
|
||||
//print help
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void msgPl(Player player, Integer in) {
|
||||
switch(in) {
|
||||
case 0:
|
||||
msgPlayer(player, Raxen.getPrefix() + "<gold>Printing About Raxen...",
|
||||
"<gold>---------------------------------------------",
|
||||
"<dark_aqua> Raxen ",
|
||||
"<dark_aqua> - Version: " + Raxen.getVersion(),
|
||||
"<dark_aqua> - Author: <b><red>U<gold>n&eu<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>");
|
||||
TextComponent txt = (TextComponent) colorComp("<dark_aqua> - Website: https://unurled.me")
|
||||
.clickEvent(ClickEvent.openUrl("https://unurled.me"));
|
||||
player.sendMessage(txt);
|
||||
msgPlayer(player, "", "<gold>---------------------------------------------");
|
||||
}
|
||||
} else {
|
||||
switch (args.length) {
|
||||
case 0 -> {
|
||||
msgSender(
|
||||
sender,
|
||||
Raxen.getPrefix() + "<gold>Printing About Raxen...",
|
||||
"<gold>---------------------------------------------",
|
||||
"<dark_aqua> Raxen ",
|
||||
"<dark_aqua> - Version: " + Raxen.getVersion(),
|
||||
"<dark_aqua> - Author: <b><red>U<gold>n<yellow>u<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>"
|
||||
);
|
||||
TextComponent txt = colorTextComp(
|
||||
"<dark_aqua> - Website: https://unurled.me"
|
||||
);
|
||||
sender.sendMessage(txt);
|
||||
sender.sendMessage(
|
||||
colorComp("<gold>---------------------------------------------")
|
||||
);
|
||||
return true;
|
||||
}
|
||||
case 1 -> {
|
||||
switch (args[0]) {
|
||||
case "mongodb", "mongo", "MONGODB", "MONGO" -> {
|
||||
//print info about connection
|
||||
msgSender(
|
||||
sender,
|
||||
Raxen.getPrefix() +
|
||||
"<gold>Printing About Raxen's MongoDB connection...",
|
||||
"<gold>---------------------------------------------" +
|
||||
"<red>MONGO DB"
|
||||
);
|
||||
sender.sendMessage(
|
||||
stringToComp(
|
||||
StorageManager
|
||||
.getMongodb()
|
||||
.getMongoClient()
|
||||
.getClusterDescription()
|
||||
.toString()
|
||||
)
|
||||
);
|
||||
sender.sendMessage(
|
||||
stringToComp(
|
||||
StorageManager.getMongodb().getMongoDatabase().getName()
|
||||
)
|
||||
);
|
||||
sender.sendMessage(
|
||||
stringToComp(
|
||||
StorageManager
|
||||
.getMongodb()
|
||||
.getMongoCollection()
|
||||
.getNamespace()
|
||||
.toString()
|
||||
)
|
||||
);
|
||||
sender.sendMessage(
|
||||
stringToComp(
|
||||
coloredString(
|
||||
"<gold>---------------------------------------------"
|
||||
)
|
||||
)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
case "v", "version", "ver" -> {
|
||||
msgSender(
|
||||
sender,
|
||||
Raxen.getPrefix() + "<gold>Printing About Raxen...",
|
||||
"<gold>---------------------------------------------",
|
||||
"<dark_aqua> Raxen ",
|
||||
"<dark_aqua> - Version: " + Raxen.getVersion(),
|
||||
"<dark_aqua> - Author: <b><red>U<gold>n&eu<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>"
|
||||
);
|
||||
TextComponent txt = colorTextComp(
|
||||
"<dark_aqua> - Website: https://unurled.me"
|
||||
);
|
||||
sender.sendMessage(txt);
|
||||
sender.sendMessage(
|
||||
colorComp("<gold>---------------------------------------------")
|
||||
);
|
||||
return true;
|
||||
}
|
||||
case "hemlp", "?", "h" -> //print help
|
||||
debug(main, "print help");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
public void msgPl(Player player, Integer in) {
|
||||
switch (in) {
|
||||
case 0:
|
||||
msgPlayer(
|
||||
player,
|
||||
Raxen.getPrefix() + "<gold>Printing About Raxen...",
|
||||
"<gold>---------------------------------------------",
|
||||
"<dark_aqua> Raxen ",
|
||||
"<dark_aqua> - Version: " + Raxen.getVersion(),
|
||||
"<dark_aqua> - Author: <b><red>U<gold>n&eu<dark_green>r<green>l<aqua>e<dark_aqua>d<reset>"
|
||||
);
|
||||
TextComponent txt = (TextComponent) colorComp(
|
||||
"<dark_aqua> - Website: https://unurled.me"
|
||||
)
|
||||
.clickEvent(ClickEvent.openUrl("https://unurled.me"));
|
||||
player.sendMessage(txt);
|
||||
msgPlayer(
|
||||
player,
|
||||
"",
|
||||
"<gold>---------------------------------------------"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import static me.unurled.raxen.utils.Items.customModelData;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -10,88 +17,106 @@ import org.bukkit.util.StringUtil;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Items.customModelData;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
public class CustomModelDataCommand implements TabExecutor {
|
||||
|
||||
/**
|
||||
* change custom model data of an item
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
errorConsoleSender(sender);
|
||||
return true;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (!(p.hasPermission("raxen.custommodeldata.cmd"))) {
|
||||
p.sendMessage(noPerms());
|
||||
return true;
|
||||
}
|
||||
ItemStack it = p.getInventory().getItemInMainHand();
|
||||
if (args.length == 0) {
|
||||
p.sendMessage(colorComp("<gold>Usage: /custommodeldata <model-data-value> <item-name></gold>"));
|
||||
return true;
|
||||
}
|
||||
if (!(isInt(args[0]))) {
|
||||
Material material = Material.getMaterial(args[1]);
|
||||
if (material != null) {
|
||||
it = customModelData(new ItemStack(material), Integer.parseInt(args[0]));
|
||||
p.getInventory().setItemInMainHand(it);
|
||||
p.updateInventory();
|
||||
} else {
|
||||
p.sendMessage(colorComp("<red>Please specify a valid Item Name or a valid Integer.</red>"));
|
||||
}
|
||||
} else {
|
||||
if (it != null && it.getType() != Material.AIR) { // check if player has an item in hand
|
||||
// has item in hand applying the custom model data
|
||||
it = customModelData(it, Integer.parseInt(args[0]));
|
||||
p.getInventory().setItemInMainHand(it);
|
||||
p.updateInventory();
|
||||
} else {
|
||||
p.sendMessage(colorComp("<red>Get an item in hand please or specify an item</red>"));
|
||||
p.sendMessage(colorComp("<gold>Usage: /custommodeldata <model-data-value> <item-name></gold>"));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
/**
|
||||
* change custom model data of an item
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!(sender instanceof Player)) {
|
||||
errorConsoleSender(sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside of a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
final List<String> completions = new ArrayList<>();
|
||||
|
||||
List<String> SUB_COMMANDS= new ArrayList<>();
|
||||
|
||||
if (!(isInt(args[0]))) {
|
||||
return Arrays.asList( "§c" + args[0]);
|
||||
}
|
||||
if (args.length == 2) {
|
||||
for (Material mat : Material.values()) {
|
||||
SUB_COMMANDS.add(mat.name());
|
||||
}
|
||||
StringUtil.copyPartialMatches(args[1], SUB_COMMANDS, completions);
|
||||
Collections.sort(completions);
|
||||
}
|
||||
return completions;
|
||||
Player p = (Player) sender;
|
||||
if (!(p.hasPermission("raxen.custommodeldata.cmd"))) {
|
||||
p.sendMessage(noPerms());
|
||||
return true;
|
||||
}
|
||||
ItemStack it = p.getInventory().getItemInMainHand();
|
||||
if (args.length == 0) {
|
||||
p.sendMessage(
|
||||
colorComp(
|
||||
"<gold>Usage: /custommodeldata <model-data-value> <item-name></gold>"
|
||||
)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
if (!(isInt(args[0]))) {
|
||||
Material material = Material.getMaterial(args[1]);
|
||||
if (material != null) {
|
||||
it =
|
||||
customModelData(new ItemStack(material), Integer.parseInt(args[0]));
|
||||
p.getInventory().setItemInMainHand(it);
|
||||
p.updateInventory();
|
||||
} else {
|
||||
p.sendMessage(
|
||||
colorComp(
|
||||
"<red>Please specify a valid Item Name or a valid Integer.</red>"
|
||||
)
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (it != null && it.getType() != Material.AIR) { // check if player has an item in hand
|
||||
// has item in hand applying the custom model data
|
||||
it = customModelData(it, Integer.parseInt(args[0]));
|
||||
p.getInventory().setItemInMainHand(it);
|
||||
p.updateInventory();
|
||||
} else {
|
||||
p.sendMessage(
|
||||
colorComp("<red>Get an item in hand please or specify an item</red>")
|
||||
);
|
||||
p.sendMessage(
|
||||
colorComp(
|
||||
"<gold>Usage: /custommodeldata <model-data-value> <item-name></gold>"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside of a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
final List<String> completions = new ArrayList<>();
|
||||
|
||||
List<String> SUB_COMMANDS = new ArrayList<>();
|
||||
|
||||
if (!(isInt(args[0]))) {
|
||||
return Arrays.asList("§c" + args[0]);
|
||||
}
|
||||
if (args.length == 2) {
|
||||
for (Material mat : Material.values()) {
|
||||
SUB_COMMANDS.add(mat.name());
|
||||
}
|
||||
StringUtil.copyPartialMatches(args[1], SUB_COMMANDS, completions);
|
||||
Collections.sort(completions);
|
||||
}
|
||||
return completions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,40 +1,49 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class EntitiyCommand implements TabExecutor {
|
||||
/**
|
||||
* Get the egg spawn of a custom entity :)
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Get the egg spawn of a custom entity :)
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.gui.ItemListGui;
|
||||
|
@ -10,40 +13,51 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
public class ItemListCommand implements TabExecutor {
|
||||
|
||||
private Raxen main;
|
||||
private Raxen main;
|
||||
|
||||
@Getter
|
||||
private ItemListGui itemListGui;
|
||||
@Getter
|
||||
private ItemListGui itemListGui;
|
||||
|
||||
public ItemListCommand(Raxen main) {
|
||||
this.main = main;
|
||||
this.itemListGui = new ItemListGui(this.main);
|
||||
public ItemListCommand(Raxen main) {
|
||||
this.main = main;
|
||||
this.itemListGui = new ItemListGui(this.main);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command cmd,
|
||||
@NotNull String msg,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!(sender instanceof Player)) {
|
||||
log("Console can't execute this command atm.");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String msg, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
log("Console can't execute this command atm.");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if(!(player.hasPermission("raxen.itemlist.cmd"))) {
|
||||
msgPlayer(player, colorString("<red>You'dont have the permission to execute this command."));
|
||||
return true;
|
||||
}
|
||||
//openGui logic
|
||||
player.openInventory(itemListGui.getInv());
|
||||
return false;
|
||||
Player player = (Player) sender;
|
||||
if (!(player.hasPermission("raxen.itemlist.cmd"))) {
|
||||
msgPlayer(
|
||||
player,
|
||||
colorString(
|
||||
"<red>You'dont have the permission to execute this command."
|
||||
)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
//openGui logic
|
||||
player.openInventory(itemListGui.getInv());
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import static me.unurled.raxen.utils.Items.itemTo64;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
|
@ -7,42 +11,48 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
import static me.unurled.raxen.utils.Items.itemTo64;
|
||||
|
||||
public class ItemTo64Command implements TabExecutor {
|
||||
/**
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player p) {
|
||||
msgPlayer(p, itemTo64(p.getInventory().getItemInMainHand()));
|
||||
} else {
|
||||
errorConsoleSender(sender);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside of a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return null;
|
||||
/**
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (sender instanceof Player p) {
|
||||
msgPlayer(p, itemTo64(p.getInventory().getItemInMainHand()));
|
||||
} else {
|
||||
errorConsoleSender(sender);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside of a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import static me.unurled.raxen.components.entity.player.PlayerUtils.updateSkills;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.manager.entity.PlayerManager;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -15,94 +21,119 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static me.unurled.raxen.components.entity.player.PlayerUtils.updateSkills;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
public class NbtCommand implements TabExecutor {
|
||||
|
||||
private final Raxen main;
|
||||
private final Raxen main;
|
||||
|
||||
public NbtCommand(Raxen main) {
|
||||
this.main = main;
|
||||
public NbtCommand(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command cmd,
|
||||
@NotNull String msg,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!(sender instanceof Player player)) {
|
||||
error(
|
||||
(Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),
|
||||
colorString("<red>You can't execute this command as the Console!")
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String msg, @NotNull String[] args) {
|
||||
if(!(sender instanceof Player player)) {
|
||||
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),colorString("<red>You can't execute this command as the Console!"));
|
||||
return true;
|
||||
if (player.getInventory().getItemInMainHand().getType() == Material.AIR) {
|
||||
msgPlayer(player, colorTextComp("<red>You must hold an Item in hand."));
|
||||
return true;
|
||||
} else {
|
||||
player.getInventory().getItemInMainHand();
|
||||
}
|
||||
switch (args.length) {
|
||||
case 0, 1 -> msgPlayer(
|
||||
player,
|
||||
colorTextComp("<red>You must specify an nbt and an int.")
|
||||
);
|
||||
case 2 -> {
|
||||
debug("'" + args[0] + "'", "'" + args[1] + "'");
|
||||
ItemStack it = player.getInventory().getItemInMainHand();
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
int a = 0;
|
||||
if (nbti.hasTag(args[0])) {
|
||||
a = nbti.getInteger(args[0]);
|
||||
}
|
||||
if(player.getInventory().getItemInMainHand().getType() == Material.AIR) {
|
||||
msgPlayer(player,colorTextComp("<red>You must hold an Item in hand."));
|
||||
return true;
|
||||
} else {
|
||||
player.getInventory().getItemInMainHand();
|
||||
}
|
||||
switch (args.length) {
|
||||
case 0, 1 -> msgPlayer(player, colorTextComp("<red>You must specify an nbt and an int."));
|
||||
case 2 -> {
|
||||
debug("'" + args[0] + "'", "'" + args[1] + "'");
|
||||
ItemStack it = player.getInventory().getItemInMainHand();
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
int a = 0;
|
||||
if (nbti.hasTag(args[0])) {
|
||||
a = nbti.getInteger(args[0]);
|
||||
}
|
||||
List<Component> lore = new ArrayList<>();
|
||||
// ItemMeta itm = it.getItemMeta();
|
||||
// lore.add((Component) itm.lore());
|
||||
boolean yes = false;
|
||||
boolean ever = false;
|
||||
for (Component ct : lore) {
|
||||
if (ct != null) {
|
||||
if (ct.contains(Component.text("Attributes:"))) {
|
||||
yes = true;
|
||||
ever = true;
|
||||
} else {
|
||||
if (yes) {
|
||||
//ct.append(Component.text(colorString(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a)))); deprecated
|
||||
yes = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!ever) {
|
||||
lore.add(colorTextComp("<red>Attributes:"));
|
||||
//lore.add(colorTextComp(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a))); deprecated
|
||||
}
|
||||
// itm.lore(lore);
|
||||
// it.setItemMeta(itm);
|
||||
PlayerManager pm = ((Raxen) Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("Raxen"))).getManager().getPlayerManager();
|
||||
nbti.setInteger(args[0], Integer.parseInt(args[1]) + a);
|
||||
if (nbti.hasTag("SPEED")) {
|
||||
pm.getSpeed().add(player, nbti.getInteger("SPEED"));
|
||||
}
|
||||
if (nbti.hasTag("HEALTH")) {
|
||||
pm.getHealth().add(player, nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if (nbti.hasTag("DEFENSE")) {
|
||||
pm.getDefense().add(player, nbti.getInteger("DEFENSE"));
|
||||
|
||||
}
|
||||
if (nbti.hasTag("STRENGTH")) {
|
||||
pm.getStrength().add(player, nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
it = nbti.getItem();
|
||||
msgPlayer(player, colorTextComp(Raxen.getPrefix() + "<white>You successfully added the nbt " + /*attributes(args[0])*/ args[0] + "<white>with " + args[1] + "<white>."));
|
||||
updateSkills(main, player);
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), it);
|
||||
List<Component> lore = new ArrayList<>();
|
||||
// ItemMeta itm = it.getItemMeta();
|
||||
// lore.add((Component) itm.lore());
|
||||
boolean yes = false;
|
||||
boolean ever = false;
|
||||
for (Component ct : lore) {
|
||||
if (ct != null) {
|
||||
if (ct.contains(Component.text("Attributes:"))) {
|
||||
yes = true;
|
||||
ever = true;
|
||||
} else {
|
||||
if (yes) {
|
||||
//ct.append(Component.text(colorString(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a)))); deprecated
|
||||
yes = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
if (!ever) {
|
||||
lore.add(colorTextComp("<red>Attributes:"));
|
||||
//lore.add(colorTextComp(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a))); deprecated
|
||||
}
|
||||
// itm.lore(lore);
|
||||
// it.setItemMeta(itm);
|
||||
PlayerManager pm =
|
||||
(
|
||||
(Raxen) Objects.requireNonNull(
|
||||
Bukkit.getPluginManager().getPlugin("Raxen")
|
||||
)
|
||||
).getManager()
|
||||
.getPlayerManager();
|
||||
nbti.setInteger(args[0], Integer.parseInt(args[1]) + a);
|
||||
if (nbti.hasTag("SPEED")) {
|
||||
pm.getSpeed().add(player, nbti.getInteger("SPEED"));
|
||||
}
|
||||
if (nbti.hasTag("HEALTH")) {
|
||||
pm.getHealth().add(player, nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if (nbti.hasTag("DEFENSE")) {
|
||||
pm.getDefense().add(player, nbti.getInteger("DEFENSE"));
|
||||
}
|
||||
if (nbti.hasTag("STRENGTH")) {
|
||||
pm.getStrength().add(player, nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
it = nbti.getItem();
|
||||
msgPlayer(
|
||||
player,
|
||||
colorTextComp(
|
||||
Raxen.getPrefix() +
|
||||
"<white>You successfully added the nbt " +
|
||||
/*attributes(args[0])*/args[0] +
|
||||
"<white>with " +
|
||||
args[1] +
|
||||
"<white>."
|
||||
)
|
||||
);
|
||||
updateSkills(main, player);
|
||||
player
|
||||
.getInventory()
|
||||
.setItem(player.getInventory().getHeldItemSlot(), it);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import java.util.List;
|
||||
import me.unurled.raxen.utils.Reload;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -9,28 +12,39 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
public class ReloadCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String msg, @NotNull String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if(!player.hasPermission("raxen.reload.cmd")) {
|
||||
player.sendMessage(noPerms());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reload.kickAll();
|
||||
log(colorString("<red>Server stopping!\n Using: /rlpl.\n Please wait a little bit."));
|
||||
Bukkit.getServer().shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String msg,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (!player.hasPermission("raxen.reload.cmd")) {
|
||||
player.sendMessage(noPerms());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reload.kickAll();
|
||||
log(
|
||||
colorString(
|
||||
"<red>Server stopping!\n Using: /rlpl.\n Please wait a little bit."
|
||||
)
|
||||
);
|
||||
Bukkit.getServer().shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import static me.unurled.raxen.components.entity.other.EntityUtils.setNameSpacedKeys;
|
||||
import static me.unurled.raxen.utils.Items.itemFrom64;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.other.EntityNamespacedKey;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -16,132 +24,189 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static me.unurled.raxen.components.entity.other.EntityUtils.setNameSpacedKeys;
|
||||
import static me.unurled.raxen.utils.Items.itemFrom64;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
public class SpawnEntity implements TabExecutor {
|
||||
|
||||
private Raxen main;
|
||||
private EntityNamespacedKey namespacedKey;
|
||||
private Raxen main;
|
||||
private EntityNamespacedKey namespacedKey;
|
||||
|
||||
public SpawnEntity(Raxen main) {
|
||||
this.main = main;
|
||||
this.namespacedKey = new EntityNamespacedKey(main);
|
||||
public SpawnEntity(Raxen main) {
|
||||
this.main = main;
|
||||
this.namespacedKey = new EntityNamespacedKey(main);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!(sender instanceof Player)) {
|
||||
log(colorTextComp("<red>Console can't execute this command!"));
|
||||
try { // /entityspawn ZOMBIE "&cHello folks" x:0 y:0 z:0 level health defense speed strength itemStackBinary64: helmet, chestplate, leggings, boots, main-hand, off-hand
|
||||
if (validateArgs(args, 16)) {
|
||||
args = setNullInArgs(args);
|
||||
} else {
|
||||
log(
|
||||
colorTextComp(
|
||||
"<red>Please use null if you don't want some parameters in the command.</red>"
|
||||
)
|
||||
);
|
||||
log(
|
||||
colorTextComp(
|
||||
"<red>Follow this command: /entityspawn TYPE \"name\" x y z level health defense speed strength " +
|
||||
"helmet(itemStackBinary64) chestplate(itemStackBinary64) leggings(itemStackBinary64) boots(itemStackBinary64) main-hand(itemStackBinary64) off-hand(itemStackBinary64)</red>"
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityType types = EntityType.valueOf(args[0]);
|
||||
Location loc = new Location(
|
||||
Bukkit.getWorld("world"),
|
||||
Double.parseDouble(args[2]),
|
||||
Double.parseDouble(args[3]),
|
||||
Double.parseDouble(args[4])
|
||||
);
|
||||
Entity e = loc.getWorld().spawnEntity(loc, types, false);
|
||||
setNameSpacedKeys(
|
||||
e,
|
||||
getStringFromArg(args),
|
||||
Integer.parseInt(args[6]),
|
||||
Integer.parseInt(args[7]),
|
||||
0,
|
||||
Integer.parseInt(args[8]),
|
||||
0,
|
||||
Integer.parseInt(args[9]),
|
||||
0,
|
||||
Integer.parseInt(args[10]),
|
||||
0
|
||||
);
|
||||
e.customName(colorTextComp(getStringFromArg(args)));
|
||||
e.setCustomNameVisible(true);
|
||||
if (e instanceof LivingEntity livingEntity) {
|
||||
// livingEntity.getEquipment().set
|
||||
ItemStack helmet = itemFrom64(args[11]);
|
||||
ItemStack chestplate = itemFrom64(args[12]);
|
||||
ItemStack leggins = itemFrom64(args[13]);
|
||||
ItemStack boots = itemFrom64(args[14]);
|
||||
ItemStack mainhand = itemFrom64(args[15]);
|
||||
ItemStack offhand = itemFrom64(args[14]);
|
||||
EntityEquipment equip = livingEntity.getEquipment();
|
||||
equip.setHelmet(helmet);
|
||||
equip.setChestplate(chestplate);
|
||||
equip.setLeggings(leggins);
|
||||
equip.setBoots(boots);
|
||||
equip.setItemInMainHand(mainhand);
|
||||
equip.setItemInOffHand(offhand);
|
||||
}
|
||||
|
||||
System.out.println(e.getName());
|
||||
} catch (IllegalArgumentException e) {
|
||||
error("Something happened near the SpawnEntity command.");
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
error(
|
||||
"Could not deserialize item from the command EntitySpawn (command launched by " +
|
||||
sender.getName() +
|
||||
")"
|
||||
);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
log(colorTextComp("<red>Console can't execute this command!"));
|
||||
try { // /entityspawn ZOMBIE "&cHello folks" x:0 y:0 z:0 level health defense speed strength itemStackBinary64: helmet, chestplate, leggings, boots, main-hand, off-hand
|
||||
if (validateArgs(args, 16)) {
|
||||
args = setNullInArgs(args);
|
||||
} else {
|
||||
log(colorTextComp("<red>Please use null if you don't want some parameters in the command.</red>"));
|
||||
log(colorTextComp("<red>Follow this command: /entityspawn TYPE \"name\" x y z level health defense speed strength " +
|
||||
"helmet(itemStackBinary64) chestplate(itemStackBinary64) leggings(itemStackBinary64) boots(itemStackBinary64) main-hand(itemStackBinary64) off-hand(itemStackBinary64)</red>"));
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityType types = EntityType.valueOf(args[0]);
|
||||
Location loc = new Location(Bukkit.getWorld("world"), Double.parseDouble(args[2]), Double.parseDouble(args[3]), Double.parseDouble(args[4]));
|
||||
Entity e = loc.getWorld().spawnEntity(loc, types, false);
|
||||
setNameSpacedKeys(e, getStringFromArg(args), Integer.parseInt(args[6]), Integer.parseInt(args[7]),0,
|
||||
Integer.parseInt(args[8]),0, Integer.parseInt(args[9]),0, Integer.parseInt(args[10]),0);
|
||||
e.customName(colorTextComp(getStringFromArg(args)));
|
||||
e.setCustomNameVisible(true);
|
||||
if (e instanceof LivingEntity livingEntity) {
|
||||
// livingEntity.getEquipment().set
|
||||
ItemStack helmet = itemFrom64(args[11]);
|
||||
ItemStack chestplate = itemFrom64(args[12]);
|
||||
ItemStack leggins = itemFrom64(args[13]);
|
||||
ItemStack boots = itemFrom64(args[14]);
|
||||
ItemStack mainhand = itemFrom64(args[15]);
|
||||
ItemStack offhand = itemFrom64(args[14]);
|
||||
EntityEquipment equip = livingEntity.getEquipment();
|
||||
equip.setHelmet(helmet);
|
||||
equip.setChestplate(chestplate);
|
||||
equip.setLeggings(leggins);
|
||||
equip.setBoots(boots);
|
||||
equip.setItemInMainHand(mainhand);
|
||||
equip.setItemInOffHand(offhand);
|
||||
}
|
||||
|
||||
System.out.println(e.getName());
|
||||
} catch (IllegalArgumentException e) {
|
||||
error("Something happened near the SpawnEntity command.");
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
error("Could not deserialize item from the command EntitySpawn (command launched by " + sender.getName() + ")");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
for (String arg : args) {
|
||||
log(arg);
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if (!player.hasPermission("raxen.entityspawn.cmd")) {
|
||||
player.sendMessage(noPerms());
|
||||
return false;
|
||||
}
|
||||
try { // /entityspawn ZOMBIE "&cHello folks" x:0 y:0 z:0 level health defense speed strength itemStackBinary64: helmet, chestplate, leggings, boots, main-hand, off-hand
|
||||
if (validateArgs(args, 16)) {
|
||||
args = setNullInArgs(args);
|
||||
} else {
|
||||
log(colorTextComp("<red>Please use null if you don't want some parameters in the command.</red>"));
|
||||
log(colorTextComp("<red>Follow this command: /entityspawn TYPE \"name\" x y z level health defense speed strength " +
|
||||
"helmet(itemStackBinary64) chestplate(itemStackBinary64) leggings(itemStackBinary64) boots(itemStackBinary64) main-hand(itemStackBinary64) off-hand(itemStackBinary64)</red>"));
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityType types = EntityType.valueOf(args[0]);
|
||||
Location loc = new Location(Bukkit.getWorld("world"), Double.parseDouble(args[2]), Double.parseDouble(args[3]), Double.parseDouble(args[4]));
|
||||
Entity e = loc.getWorld().spawnEntity(loc, types, false);
|
||||
setNameSpacedKeys(e, getStringFromArg(args), Integer.parseInt(args[6]), Integer.parseInt(args[7]),0,
|
||||
Integer.parseInt(args[8]),0, Integer.parseInt(args[9]),0, Integer.parseInt(args[10]),0);
|
||||
e.customName(colorTextComp(getStringFromArg(args)));
|
||||
e.setCustomNameVisible(true);
|
||||
if (e instanceof LivingEntity livingEntity) {
|
||||
// livingEntity.getEquipment().set
|
||||
ItemStack helmet = itemFrom64(args[11]);
|
||||
ItemStack chestplate = itemFrom64(args[12]);
|
||||
ItemStack leggins = itemFrom64(args[13]);
|
||||
ItemStack boots = itemFrom64(args[14]);
|
||||
ItemStack mainhand = itemFrom64(args[15]);
|
||||
ItemStack offhand = itemFrom64(args[14]);
|
||||
EntityEquipment equip = livingEntity.getEquipment();
|
||||
equip.setHelmet(helmet);
|
||||
equip.setChestplate(chestplate);
|
||||
equip.setLeggings(leggins);
|
||||
equip.setBoots(boots);
|
||||
equip.setItemInMainHand(mainhand);
|
||||
equip.setItemInOffHand(offhand);
|
||||
}
|
||||
|
||||
System.out.println(e.getName());
|
||||
} catch (IllegalArgumentException e) {
|
||||
error("Something happened near the SpawnEntity command.");
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
error("Could not deserialize item from the command EntitySpawn (command launched by " + sender.getName() + ")");
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
for (String arg : args) {
|
||||
log(arg);
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if (!player.hasPermission("raxen.entityspawn.cmd")) {
|
||||
player.sendMessage(noPerms());
|
||||
return false;
|
||||
}
|
||||
try { // /entityspawn ZOMBIE "&cHello folks" x:0 y:0 z:0 level health defense speed strength itemStackBinary64: helmet, chestplate, leggings, boots, main-hand, off-hand
|
||||
if (validateArgs(args, 16)) {
|
||||
args = setNullInArgs(args);
|
||||
} else {
|
||||
log(
|
||||
colorTextComp(
|
||||
"<red>Please use null if you don't want some parameters in the command.</red>"
|
||||
)
|
||||
);
|
||||
log(
|
||||
colorTextComp(
|
||||
"<red>Follow this command: /entityspawn TYPE \"name\" x y z level health defense speed strength " +
|
||||
"helmet(itemStackBinary64) chestplate(itemStackBinary64) leggings(itemStackBinary64) boots(itemStackBinary64) main-hand(itemStackBinary64) off-hand(itemStackBinary64)</red>"
|
||||
)
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
EntityType types = EntityType.valueOf(args[0]);
|
||||
Location loc = new Location(
|
||||
Bukkit.getWorld("world"),
|
||||
Double.parseDouble(args[2]),
|
||||
Double.parseDouble(args[3]),
|
||||
Double.parseDouble(args[4])
|
||||
);
|
||||
Entity e = loc.getWorld().spawnEntity(loc, types, false);
|
||||
setNameSpacedKeys(
|
||||
e,
|
||||
getStringFromArg(args),
|
||||
Integer.parseInt(args[6]),
|
||||
Integer.parseInt(args[7]),
|
||||
0,
|
||||
Integer.parseInt(args[8]),
|
||||
0,
|
||||
Integer.parseInt(args[9]),
|
||||
0,
|
||||
Integer.parseInt(args[10]),
|
||||
0
|
||||
);
|
||||
e.customName(colorTextComp(getStringFromArg(args)));
|
||||
e.setCustomNameVisible(true);
|
||||
if (e instanceof LivingEntity livingEntity) {
|
||||
// livingEntity.getEquipment().set
|
||||
ItemStack helmet = itemFrom64(args[11]);
|
||||
ItemStack chestplate = itemFrom64(args[12]);
|
||||
ItemStack leggins = itemFrom64(args[13]);
|
||||
ItemStack boots = itemFrom64(args[14]);
|
||||
ItemStack mainhand = itemFrom64(args[15]);
|
||||
ItemStack offhand = itemFrom64(args[14]);
|
||||
EntityEquipment equip = livingEntity.getEquipment();
|
||||
equip.setHelmet(helmet);
|
||||
equip.setChestplate(chestplate);
|
||||
equip.setLeggings(leggins);
|
||||
equip.setBoots(boots);
|
||||
equip.setItemInMainHand(mainhand);
|
||||
equip.setItemInOffHand(offhand);
|
||||
}
|
||||
|
||||
System.out.println(e.getName());
|
||||
} catch (IllegalArgumentException e) {
|
||||
error("Something happened near the SpawnEntity command.");
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
error(
|
||||
"Could not deserialize item from the command EntitySpawn (command launched by " +
|
||||
sender.getName() +
|
||||
")"
|
||||
);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (EntityType types : EntityType.values()) {
|
||||
list.add(types.name());
|
||||
}
|
||||
return list;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
List<String> list = new ArrayList<>();
|
||||
for (EntityType types : EntityType.values()) {
|
||||
list.add(types.name());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
import static me.unurled.raxen.utils.Utils.log;
|
||||
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -8,29 +12,36 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
import static me.unurled.raxen.utils.Utils.log;
|
||||
|
||||
public class TestGuiCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if(player.hasPermission("raxen.test.gui.cmd")) {
|
||||
player.openInventory(Bukkit.createInventory(null, 54, colorTextComp(args[0])));
|
||||
}
|
||||
}
|
||||
else {
|
||||
log("The console can't execute this Command!");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if (player.hasPermission("raxen.test.gui.cmd")) {
|
||||
player.openInventory(
|
||||
Bukkit.createInventory(null, 54, colorTextComp(args[0]))
|
||||
);
|
||||
}
|
||||
} else {
|
||||
log("The console can't execute this Command!");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
package me.unurled.raxen.commands.admin;
|
||||
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.utils.Utils;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TestHoloCommand implements TabExecutor {
|
||||
|
||||
private Raxen main;
|
||||
|
||||
public TestHoloCommand(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (sender instanceof Player player) {
|
||||
if (player.hasPermission("raxen.testholo.cmd")) {
|
||||
// spawn a hologram
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("text")) {
|
||||
main.getManager().getLibsManager().getHolographicDisplay().createHologram("test holo", player.getLocation().add(0.0, 2.0, 0.0));
|
||||
} else if (args[0].equalsIgnoreCase("item")) {
|
||||
main.getManager().getLibsManager().getHolographicDisplay().createHologram(player.getInventory().getItemInMainHand(), player.getLocation().add(0.0, 2.0, 0.0));
|
||||
}
|
||||
} else {
|
||||
Utils.msgPlayer(player, "You need to use the correct syntax :", "/" + label + " [text | item]");
|
||||
}
|
||||
} else {
|
||||
Utils.msgPlayer(player, (TextComponent) Utils.noPerms());
|
||||
}
|
||||
} else {
|
||||
Utils.errorConsoleSender(sender);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside of a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,10 @@
|
|||
package me.unurled.raxen.commands.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.player.classes.Class;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -12,47 +17,66 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
|
||||
public class ClassCommand implements TabExecutor {
|
||||
|
||||
private Raxen main;
|
||||
private Raxen main;
|
||||
|
||||
/**
|
||||
* the Command to choose the class
|
||||
* @param main
|
||||
*/
|
||||
public ClassCommand(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
/**
|
||||
* the Command to choose the class
|
||||
* @param main
|
||||
*/
|
||||
public ClassCommand(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"The console can't execute this Command!");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Inventory inv = Bukkit.createInventory(null, 9, colorTextComp("<grey>Choose your class</grey>"));
|
||||
HashMap<String, Class> classes = main.getManager().getPlayerManager().getClasses();
|
||||
if (classes.size() > 10) {
|
||||
if (classes.size() > 55) {
|
||||
inv = Bukkit.createInventory(null, classes.size(), colorTextComp("<grey>Choose your class</grey>"));
|
||||
}
|
||||
}
|
||||
for (Class clas : classes.values()) {
|
||||
ItemStack item = clas.getPlaceHolder();
|
||||
inv.addItem(item);
|
||||
}
|
||||
return false;
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!(sender instanceof Player)) {
|
||||
error(
|
||||
(Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),
|
||||
"The console can't execute this Command!"
|
||||
);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Inventory inv = Bukkit.createInventory(
|
||||
null,
|
||||
9,
|
||||
colorTextComp("<grey>Choose your class</grey>")
|
||||
);
|
||||
HashMap<String, Class> classes = main
|
||||
.getManager()
|
||||
.getPlayerManager()
|
||||
.getClasses();
|
||||
if (classes.size() > 10) {
|
||||
if (classes.size() > 55) {
|
||||
inv =
|
||||
Bukkit.createInventory(
|
||||
null,
|
||||
classes.size(),
|
||||
colorTextComp("<grey>Choose your class</grey>")
|
||||
);
|
||||
}
|
||||
}
|
||||
for (Class clas : classes.values()) {
|
||||
ItemStack item = clas.getPlaceHolder();
|
||||
inv.addItem(item);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package me.unurled.raxen.commands.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.errorConsoleSender;
|
||||
import static me.unurled.raxen.utils.Utils.noPerms;
|
||||
|
||||
import java.util.List;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.gui.MainGui;
|
||||
import org.bukkit.command.Command;
|
||||
|
@ -10,54 +14,59 @@ import org.bukkit.inventory.Inventory;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.errorConsoleSender;
|
||||
import static me.unurled.raxen.utils.Utils.noPerms;
|
||||
|
||||
public class MainGuiCommand implements TabExecutor {
|
||||
|
||||
private Raxen main;
|
||||
private Raxen main;
|
||||
|
||||
public MainGuiCommand(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
public MainGuiCommand(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
errorConsoleSender(sender);
|
||||
return true;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (!(p.hasPermission("raxen.maingui.cmd"))) {
|
||||
sender.sendMessage(noPerms());
|
||||
return true;
|
||||
}
|
||||
Inventory inv = MainGui.build(p);
|
||||
p.openInventory(inv);
|
||||
return true;
|
||||
/**
|
||||
* @param sender Source of the command
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args Passed command arguments
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!(sender instanceof Player)) {
|
||||
errorConsoleSender(sender);
|
||||
return true;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (!(p.hasPermission("raxen.maingui.cmd"))) {
|
||||
sender.sendMessage(noPerms());
|
||||
return true;
|
||||
}
|
||||
Inventory inv = MainGui.build(p);
|
||||
p.openInventory(inv);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside of a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* @param sender Source of the command. For players tab-completing a
|
||||
* command inside of a command block, this will be the player, not
|
||||
* the command block.
|
||||
* @param command Command which was executed
|
||||
* @param label Alias of the command which was used
|
||||
* @param args The arguments passed to the command, including final
|
||||
* partial argument to be completed
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package me.unurled.raxen.commands.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
|
||||
import java.util.List;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.player.PlayerUtils;
|
||||
import me.unurled.raxen.components.entity.player.attributes.Attributes;
|
||||
|
@ -12,57 +16,78 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
|
||||
public class SkillsCommand implements TabExecutor {
|
||||
|
||||
private Raxen main;
|
||||
private Raxen main;
|
||||
|
||||
public SkillsCommand(Raxen main) {
|
||||
this.main = main;
|
||||
public SkillsCommand(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String msg,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!(sender instanceof Player)) {
|
||||
error(
|
||||
(Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),
|
||||
"The console can't execute this Command!"
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String msg, @NotNull String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"The console can't execute this Command!");
|
||||
return true;
|
||||
Player player = (Player) sender;
|
||||
Attributes attributes = new Attributes(main);
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
//open gui
|
||||
player.sendMessage(
|
||||
colorTextComp("<red>GUI not implemented yet..")
|
||||
.append(colorTextComp("<red>Try /skill help."))
|
||||
);
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
player.sendMessage(
|
||||
colorTextComp("<white>Use the command like: ")
|
||||
.append(
|
||||
colorTextComp(
|
||||
"<white>/skill <dark_aqua>{health|defense|speed|strength} {add|set|remove} {amount}"
|
||||
)
|
||||
)
|
||||
);
|
||||
break;
|
||||
case 3:
|
||||
PlayerManager pm =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
for (String s : pm.getAttribute().keySet()) {
|
||||
if (s.equalsIgnoreCase(args[0])) switch (args[1]) {
|
||||
case "add":
|
||||
pm.getAttribute().get(s).add(player, Integer.parseInt(args[2]));
|
||||
case "remove":
|
||||
pm
|
||||
.getAttribute()
|
||||
.get(s)
|
||||
.remove(player, Integer.parseInt(args[2]));
|
||||
case "set":
|
||||
pm.getAttribute().get(s).set(player, Integer.parseInt(args[2]));
|
||||
}
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Attributes attributes = new Attributes(main);
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
//open gui
|
||||
player.sendMessage(colorTextComp("<red>GUI not implemented yet..").append(colorTextComp("<red>Try /skill help.")));
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
player.sendMessage(colorTextComp("<white>Use the command like: ")
|
||||
.append(colorTextComp("<white>/skill <dark_aqua>{health|defense|speed|strength} {add|set|remove} {amount}")));
|
||||
break;
|
||||
case 3:
|
||||
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
for (String s : pm.getAttribute().keySet()) {
|
||||
if (s.equalsIgnoreCase(args[0]))
|
||||
switch (args[1]) {
|
||||
case "add":
|
||||
pm.getAttribute().get(s).add(player, Integer.parseInt(args[2]));
|
||||
case "remove":
|
||||
pm.getAttribute().get(s).remove(player, Integer.parseInt(args[2]));
|
||||
case "set":
|
||||
pm.getAttribute().get(s).set(player, Integer.parseInt(args[2]));
|
||||
}
|
||||
}
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
}
|
||||
return false;
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package me.unurled.raxen.commands.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import java.util.List;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.manager.entity.PlayerManager;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -11,47 +14,67 @@ import org.bukkit.inventory.Inventory;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
public class StorageCommand implements TabExecutor {
|
||||
|
||||
private PlayerManager playerManager;
|
||||
private PlayerManager playerManager;
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"The console can't execute this Command!");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Inventory inv;
|
||||
playerManager = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if(playerManager.getRaxenPlayer(player).getStorage() == null) {
|
||||
inv = playerManager.getRaxenPlayer(player).createStorage().getEc().getEc();
|
||||
} else {
|
||||
inv = playerManager.getRaxenPlayer(player).getStorage().getEc().getEc();
|
||||
}
|
||||
player.openInventory(inv);
|
||||
break;
|
||||
case 1:
|
||||
Player p = Bukkit.getPlayer(args[0]);
|
||||
if(p == null) {
|
||||
msgPlayer(player, colorString("<red>You can't open the Storage of an unknown Player."));
|
||||
return true;
|
||||
}
|
||||
inv = playerManager.getRaxenPlayer(player).getStorage().getEc().getEc();
|
||||
player.openInventory(inv);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@Override
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!(sender instanceof Player)) {
|
||||
error(
|
||||
(Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),
|
||||
"The console can't execute this Command!"
|
||||
);
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Inventory inv;
|
||||
playerManager =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (playerManager.getRaxenPlayer(player).getStorage() == null) {
|
||||
inv =
|
||||
playerManager
|
||||
.getRaxenPlayer(player)
|
||||
.createStorage()
|
||||
.getEc()
|
||||
.getEc();
|
||||
} else {
|
||||
inv =
|
||||
playerManager.getRaxenPlayer(player).getStorage().getEc().getEc();
|
||||
}
|
||||
player.openInventory(inv);
|
||||
break;
|
||||
case 1:
|
||||
Player p = Bukkit.getPlayer(args[0]);
|
||||
if (p == null) {
|
||||
msgPlayer(
|
||||
player,
|
||||
colorString("<red>You can't open the Storage of an unknown Player.")
|
||||
);
|
||||
return true;
|
||||
}
|
||||
inv = playerManager.getRaxenPlayer(player).getStorage().getEc().getEc();
|
||||
player.openInventory(inv);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String alias,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package me.unurled.raxen.components.dungeons;
|
||||
|
||||
import static me.unurled.raxen.utils.DungeonUtils.getRadiusFromRank;
|
||||
|
||||
import java.util.HashMap;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.dungeons.types.MonsterType;
|
||||
|
@ -7,60 +10,69 @@ import me.unurled.raxen.components.entity.other.RaxenEntity;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static me.unurled.raxen.utils.DungeonUtils.getRadiusFromRank;
|
||||
|
||||
public class Dungeon {
|
||||
|
||||
@Getter private String name;
|
||||
@Getter
|
||||
private String name;
|
||||
|
||||
@Getter private Rank rank;
|
||||
@Getter
|
||||
private Rank rank;
|
||||
|
||||
@Getter private Gate gate;
|
||||
@Getter
|
||||
private Gate gate;
|
||||
|
||||
//String, RaxenEntity
|
||||
@Getter private HashMap<String, RaxenEntity> monster = new HashMap<>();
|
||||
//String, RaxenEntity
|
||||
@Getter
|
||||
private HashMap<String, RaxenEntity> monster = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The Type of the Dungeon
|
||||
*/
|
||||
@Getter private Types types;
|
||||
/**
|
||||
* The Type of the Dungeon
|
||||
*/
|
||||
@Getter
|
||||
private Types types;
|
||||
|
||||
/**
|
||||
* Monster Types
|
||||
*/
|
||||
@Getter private MonsterType monsterType;
|
||||
/**
|
||||
* Monster Types
|
||||
*/
|
||||
@Getter
|
||||
private MonsterType monsterType;
|
||||
|
||||
@Getter private Location location;
|
||||
@Getter private Integer radius;
|
||||
@Getter
|
||||
private Location location;
|
||||
|
||||
public Dungeon(String name, Rank rank, Types types, MonsterType mType) {
|
||||
this.name = name;
|
||||
this.rank = rank;
|
||||
this.types = types;
|
||||
this.monsterType = mType;
|
||||
generateGate();
|
||||
}
|
||||
@Getter
|
||||
private Integer radius;
|
||||
|
||||
/**
|
||||
* Generate the Gate and make it available to players in the world.
|
||||
* //TODO: Place the gate at a random place.
|
||||
*/
|
||||
public void generateGate() {
|
||||
// -281.50 36.00 187.50
|
||||
Location loc = new Location(Bukkit.getWorld("Liberty_City"), -284.0, 45.00, 187.50);
|
||||
Integer radius = getRadiusFromRank(this.rank);
|
||||
this.gate = new Gate(name, loc, radius);
|
||||
}
|
||||
public Dungeon(String name, Rank rank, Types types, MonsterType mType) {
|
||||
this.name = name;
|
||||
this.rank = rank;
|
||||
this.types = types;
|
||||
this.monsterType = mType;
|
||||
generateGate();
|
||||
}
|
||||
|
||||
/**
|
||||
* //TODO: Terrain Generation of the inside of the Dungeons
|
||||
*/
|
||||
public void generate() {
|
||||
Raxen main = (Raxen) Bukkit.getPluginManager().getPlugin("Raxen");
|
||||
main.getManager().getWorldManager().loadWorld(name);
|
||||
monsterType.genMonster(Bukkit.getWorld(name), rank);
|
||||
/**
|
||||
* Generate the Gate and make it available to players in the world.
|
||||
* //TODO: Place the gate at a random place.
|
||||
*/
|
||||
public void generateGate() {
|
||||
// -281.50 36.00 187.50
|
||||
Location loc = new Location(
|
||||
Bukkit.getWorld("Liberty_City"),
|
||||
-284.0,
|
||||
45.00,
|
||||
187.50
|
||||
);
|
||||
Integer radius = getRadiusFromRank(this.rank);
|
||||
this.gate = new Gate(name, loc, radius);
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* //TODO: Terrain Generation of the inside of the Dungeons
|
||||
*/
|
||||
public void generate() {
|
||||
Raxen main = (Raxen) Bukkit.getPluginManager().getPlugin("Raxen");
|
||||
main.getManager().getWorldManager().loadWorld(name);
|
||||
monsterType.genMonster(Bukkit.getWorld(name), rank);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,48 +1,44 @@
|
|||
package me.unurled.raxen.components.dungeons;
|
||||
|
||||
import java.util.Random;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class Gate {
|
||||
|
||||
private String name;
|
||||
private String name;
|
||||
|
||||
private Location loc;
|
||||
private Integer portalRadius;
|
||||
private Location loc;
|
||||
private Integer portalRadius;
|
||||
|
||||
public Gate(String name, Location loc, Integer portalRadius) {
|
||||
this.loc = loc;
|
||||
this.portalRadius = portalRadius;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Gate(String name, Location loc, Integer portalRadius) {
|
||||
this.loc = loc;
|
||||
this.portalRadius = portalRadius;
|
||||
this.name = name;
|
||||
public void teleport() {}
|
||||
|
||||
public void genGate() {
|
||||
// get which side it's gonna expand with radius
|
||||
Random r = new Random();
|
||||
Boolean xExpend = false;
|
||||
if (r.nextInt(2) == 0) {
|
||||
xExpend = true;
|
||||
}
|
||||
|
||||
public void teleport() {
|
||||
|
||||
// place blocks
|
||||
for (double i = 0; i <= Math.PI; i += Math.PI / portalRadius) {
|
||||
double radius = Math.sin(i);
|
||||
double y = Math.cos(i);
|
||||
for (double a = 0; a < Math.PI * 2; a += Math.PI / portalRadius) {
|
||||
double x = Math.cos(a) * radius;
|
||||
double z = Math.sin(a) * radius;
|
||||
Location locc = new Location(loc.getWorld(), x, y, z);
|
||||
loc.getBlock().setType(Material.NETHER_PORTAL);
|
||||
}
|
||||
}
|
||||
|
||||
public void genGate() {
|
||||
// get which side it's gonna expand with radius
|
||||
Random r = new Random();
|
||||
Boolean xExpend = false;
|
||||
if (r.nextInt(2) == 0) {
|
||||
xExpend = true;
|
||||
}
|
||||
|
||||
// place blocks
|
||||
for (double i = 0; i <= Math.PI; i += Math.PI / portalRadius) {
|
||||
double radius = Math.sin(i);
|
||||
double y = Math.cos(i);
|
||||
for (double a = 0; a < Math.PI * 2; a+= Math.PI / portalRadius) {
|
||||
double x = Math.cos(a) * radius;
|
||||
double z = Math.sin(a) * radius;
|
||||
Location locc = new Location(loc.getWorld(), x, y, z);
|
||||
loc.getBlock().setType(Material.NETHER_PORTAL);
|
||||
}
|
||||
}
|
||||
/*
|
||||
/*
|
||||
for (int n=0; n<portalRadius ; n++) {
|
||||
Double x = loc.getX();
|
||||
Double y = loc.getY();
|
||||
|
@ -57,18 +53,17 @@ public class Gate {
|
|||
}
|
||||
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLoc() {
|
||||
return loc;
|
||||
}
|
||||
|
||||
public Location getLoc() {
|
||||
return loc;
|
||||
}
|
||||
public Integer getPortalRadius() {
|
||||
return portalRadius;
|
||||
}
|
||||
|
||||
public Integer getPortalRadius() {
|
||||
return portalRadius;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package me.unurled.raxen.components.dungeons;
|
||||
|
||||
public enum Rank {
|
||||
F,
|
||||
E,
|
||||
D,
|
||||
C,
|
||||
B,
|
||||
A,
|
||||
S,
|
||||
SS,
|
||||
SSS,
|
||||
WORLD,
|
||||
UNBEATABLE,
|
||||
NOT_DEFINED
|
||||
F,
|
||||
E,
|
||||
D,
|
||||
C,
|
||||
B,
|
||||
A,
|
||||
S,
|
||||
SS,
|
||||
SSS,
|
||||
WORLD,
|
||||
UNBEATABLE,
|
||||
NOT_DEFINED,
|
||||
}
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
package me.unurled.raxen.components.dungeons;
|
||||
|
||||
import me.unurled.raxen.components.entity.other.RaxenEntity;
|
||||
import me.unurled.raxen.components.lootchest.loots.LootItem;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import me.unurled.raxen.components.entity.other.RaxenEntity;
|
||||
import me.unurled.raxen.components.lootchest.loots.LootItem;
|
||||
|
||||
public class Type {
|
||||
|
||||
public String name;
|
||||
public String name;
|
||||
|
||||
public Map<String, RaxenEntity> monster = new HashMap<>();
|
||||
public Map<String, RaxenEntity> monster = new HashMap<>();
|
||||
|
||||
public Map<String, LootItem> lootItem = new HashMap<>();
|
||||
|
||||
// public Map<String, > chest
|
||||
public Map<String, LootItem> lootItem = new HashMap<>();
|
||||
// public Map<String, > chest
|
||||
|
||||
}
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
package me.unurled.raxen.components.dungeons;
|
||||
|
||||
public enum Types {
|
||||
JUNGLE,
|
||||
TROPICAL_JUNGLE,
|
||||
PLAINS,
|
||||
GRAVES,
|
||||
CASTLE,
|
||||
ABANDONED_CASTLE,
|
||||
FIELD,
|
||||
ICE_FOREST,
|
||||
FOREST,
|
||||
VOLCANO,
|
||||
MOUNTAINS,
|
||||
HIGH_MOUNTAINS,
|
||||
CAVES,
|
||||
LABYRINTH,
|
||||
UNDERGROUND_LABYRINTH,
|
||||
FOREST_LABYRINTH
|
||||
JUNGLE,
|
||||
TROPICAL_JUNGLE,
|
||||
PLAINS,
|
||||
GRAVES,
|
||||
CASTLE,
|
||||
ABANDONED_CASTLE,
|
||||
FIELD,
|
||||
ICE_FOREST,
|
||||
FOREST,
|
||||
VOLCANO,
|
||||
MOUNTAINS,
|
||||
HIGH_MOUNTAINS,
|
||||
CAVES,
|
||||
LABYRINTH,
|
||||
UNDERGROUND_LABYRINTH,
|
||||
FOREST_LABYRINTH,
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package me.unurled.raxen.components.dungeons.types;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import java.util.Random;
|
||||
import me.unurled.raxen.components.dungeons.Rank;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
@ -11,84 +14,95 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class MonsterType {
|
||||
public enum type {;
|
||||
|
||||
private Double rate;
|
||||
public String ID;
|
||||
public Class clazz;
|
||||
public enum type {
|
||||
;
|
||||
|
||||
type(Double rate, String ID, Class clazz) {
|
||||
this.rate = rate;
|
||||
this.ID = ID;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
private Double rate;
|
||||
public String ID;
|
||||
public Class clazz;
|
||||
|
||||
public static @Nullable type getTypeById(String ID) {
|
||||
for (type type : type.values()) {
|
||||
if(type.ID.equals(ID)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Double getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(Double rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public void setID(String ID) {
|
||||
this.ID = ID;
|
||||
}
|
||||
|
||||
public Class getClazz() {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public void getClazz(Class clazz) {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
type(Double rate, String ID, Class clazz) {
|
||||
this.rate = rate;
|
||||
this.ID = ID;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public void genMonster(World world, Rank rank) {
|
||||
Double x = 0.0;
|
||||
Double y = 100.0;
|
||||
Double z = 0.0;
|
||||
for (type type : type.values()) {
|
||||
type.name();
|
||||
Random r = new Random();
|
||||
int per = r.nextInt(100);
|
||||
if (per >= type.rate) {
|
||||
// spawn entity
|
||||
debug("Spawning Entity " + type.ID);
|
||||
Entity e = world.spawnEntity(new Location(world, x, y, z), EntityType.ARROW);
|
||||
// e = ((RaxenEntity) type.getClazz()).createEntity();
|
||||
e.setInvulnerable(true);
|
||||
BukkitTask task = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Location loc = new Location(e.getWorld(), e.getLocation().getX(), e.getLocation().getY()-1, e.getLocation().getZ());
|
||||
if (loc.getBlock().getType() != Material.AIR) {
|
||||
e.setInvulnerable(false);
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}.runTaskTimerAsynchronously(Bukkit.getPluginManager().getPlugin("Raxen"), 0L, 20L);
|
||||
}
|
||||
x = 5.0 + ( 50.0 - 5.0 ) * r.nextDouble();
|
||||
z = 5.0 + ( 50.0 - 5.0 ) * r.nextDouble();
|
||||
public static @Nullable type getTypeById(String ID) {
|
||||
for (type type : type.values()) {
|
||||
if (type.ID.equals(ID)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Double getRate() {
|
||||
return rate;
|
||||
}
|
||||
|
||||
public void setRate(Double rate) {
|
||||
this.rate = rate;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public void setID(String ID) {
|
||||
this.ID = ID;
|
||||
}
|
||||
|
||||
public Class getClazz() {
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public void getClazz(Class clazz) {
|
||||
this.clazz = clazz;
|
||||
}
|
||||
}
|
||||
|
||||
public void genMonster(World world, Rank rank) {
|
||||
Double x = 0.0;
|
||||
Double y = 100.0;
|
||||
Double z = 0.0;
|
||||
for (type type : type.values()) {
|
||||
type.name();
|
||||
Random r = new Random();
|
||||
int per = r.nextInt(100);
|
||||
if (per >= type.rate) {
|
||||
// spawn entity
|
||||
debug("Spawning Entity " + type.ID);
|
||||
Entity e = world.spawnEntity(
|
||||
new Location(world, x, y, z),
|
||||
EntityType.ARROW
|
||||
);
|
||||
// e = ((RaxenEntity) type.getClazz()).createEntity();
|
||||
e.setInvulnerable(true);
|
||||
BukkitTask task = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Location loc = new Location(
|
||||
e.getWorld(),
|
||||
e.getLocation().getX(),
|
||||
e.getLocation().getY() - 1,
|
||||
e.getLocation().getZ()
|
||||
);
|
||||
if (loc.getBlock().getType() != Material.AIR) {
|
||||
e.setInvulnerable(false);
|
||||
this.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
.runTaskTimerAsynchronously(
|
||||
Bukkit.getPluginManager().getPlugin("Raxen"),
|
||||
0L,
|
||||
20L
|
||||
);
|
||||
}
|
||||
x = 5.0 + (50.0 - 5.0) * r.nextDouble();
|
||||
z = 5.0 + (50.0 - 5.0) * r.nextDouble();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,12 @@ import me.unurled.raxen.components.dungeons.Types;
|
|||
import me.unurled.raxen.components.dungeons.types.MonsterType;
|
||||
|
||||
public class ForestDungeon extends Dungeon {
|
||||
public ForestDungeon(String name, Rank rank, Types types, MonsterType mType) {
|
||||
super(name, rank, types, mType);
|
||||
}
|
||||
|
||||
public ForestDungeon() {
|
||||
super("Forest", Rank.E, Types.FOREST, new ForestMonster());
|
||||
}
|
||||
public ForestDungeon(String name, Rank rank, Types types, MonsterType mType) {
|
||||
super(name, rank, types, mType);
|
||||
}
|
||||
|
||||
public ForestDungeon() {
|
||||
super("Forest", Rank.E, Types.FOREST, new ForestMonster());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,18 +7,19 @@ import me.unurled.raxen.components.entity.other.custom.dungeon.forest.Wolf;
|
|||
|
||||
public class ForestMonster extends MonsterType {
|
||||
|
||||
@Getter enum type {
|
||||
ELF(50.0 ,"ELF", Elf.class),
|
||||
WOLF(50.0, "WOLF", Wolf.class);
|
||||
@Getter
|
||||
enum type {
|
||||
ELF(50.0, "ELF", Elf.class),
|
||||
WOLF(50.0, "WOLF", Wolf.class);
|
||||
|
||||
private Double rate;
|
||||
public String ID;
|
||||
public Class clazz;
|
||||
private Double rate;
|
||||
public String ID;
|
||||
public Class clazz;
|
||||
|
||||
type(Double rate, String ID, Class clazz) {
|
||||
this.rate = rate;
|
||||
this.ID = ID;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
type(Double rate, String ID, Class clazz) {
|
||||
this.rate = rate;
|
||||
this.ID = ID;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package me.unurled.raxen.components.enchantments;
|
||||
|
||||
import io.papermc.paper.enchantments.EnchantmentRarity;
|
||||
import java.util.Set;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.NamespacedKey;
|
||||
|
@ -11,93 +12,96 @@ import org.bukkit.inventory.EquipmentSlot;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public class EnchantmentWarpper extends Enchantment {
|
||||
private final int maxLevel;
|
||||
|
||||
public EnchantmentWarpper(String nameSpace, String name, int lvl) {
|
||||
super(NamespacedKey.minecraft(nameSpace));
|
||||
this.maxLevel = lvl;
|
||||
}
|
||||
private final int maxLevel;
|
||||
|
||||
@Override @Deprecated
|
||||
public @NotNull String getName() {
|
||||
return null;
|
||||
}
|
||||
public EnchantmentWarpper(String nameSpace, String name, int lvl) {
|
||||
super(NamespacedKey.minecraft(nameSpace));
|
||||
this.maxLevel = lvl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
@Override
|
||||
@Deprecated
|
||||
public @NotNull String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartLevel() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getMaxLevel() {
|
||||
return maxLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EnchantmentTarget getItemTarget() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public int getStartLevel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTreasure() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public @NotNull EnchantmentTarget getItemTarget() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCursed() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isTreasure() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conflictsWith(@NotNull Enchantment other) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isCursed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canEnchantItem(@NotNull ItemStack item) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean conflictsWith(@NotNull Enchantment other) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Component displayName(int level) {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean canEnchantItem(@NotNull ItemStack item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTradeable() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public @NotNull Component displayName(int level) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDiscoverable() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean isTradeable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull EnchantmentRarity getRarity() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public boolean isDiscoverable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDamageIncrease(int level, @NotNull EntityCategory entityCategory) {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public @NotNull EnchantmentRarity getRarity() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<EquipmentSlot> getActiveSlots() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public float getDamageIncrease(
|
||||
int level,
|
||||
@NotNull EntityCategory entityCategory
|
||||
) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String translationKey() {
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public @NotNull Set<EquipmentSlot> getActiveSlots() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Key key() {
|
||||
return super.key();
|
||||
}
|
||||
@Override
|
||||
public @NotNull String translationKey() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Key key() {
|
||||
return super.key();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,5 +6,9 @@ import org.bukkit.event.Listener;
|
|||
|
||||
public class Telekinesis implements Listener {
|
||||
|
||||
public static final Enchantment TELEKINESIS = new EnchantmentWarpper("telekinesis", "telekinesis", 1);
|
||||
public static final Enchantment TELEKINESIS = new EnchantmentWarpper(
|
||||
"telekinesis",
|
||||
"telekinesis",
|
||||
1
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package me.unurled.raxen.components.entity.Attributes;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
|
@ -10,125 +12,160 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class Attribute {
|
||||
|
||||
/**
|
||||
* The NamespaceKey register for the PersistentDataContainer.
|
||||
* static NamespacedKey namespacekey = namespacedKey.TYPE;
|
||||
*/
|
||||
public NamespacedKey namespacekey;
|
||||
/**
|
||||
* The NamespaceKey register for the PersistentDataContainer.
|
||||
* static NamespacedKey namespacekey = namespacedKey.TYPE;
|
||||
*/
|
||||
public NamespacedKey namespacekey;
|
||||
|
||||
/**
|
||||
* The name of the attribute
|
||||
* static String name = "null";
|
||||
*/
|
||||
public String name;
|
||||
/**
|
||||
* The name of the attribute
|
||||
* static String name = "null";
|
||||
*/
|
||||
public String name;
|
||||
|
||||
public Attribute(NamespacedKey namespacekey, String name) {
|
||||
this.namespacekey = namespacekey;
|
||||
this.name = name;
|
||||
public Attribute(NamespacedKey namespacekey, String name) {
|
||||
this.namespacekey = namespacekey;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* gives the name uppercased
|
||||
* @return the name in uppercase
|
||||
*/
|
||||
public String nameUppercase() {
|
||||
return name.toUpperCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* get how many the Entity has Attributed
|
||||
* @param entity a living entity
|
||||
* @return the amount of attribute
|
||||
*/
|
||||
public Integer get(@NotNull Entity entity) {
|
||||
if (
|
||||
entity
|
||||
.getPersistentDataContainer()
|
||||
.has(namespacekey, PersistentDataType.INTEGER)
|
||||
) {
|
||||
debug(
|
||||
" attribute gett" +
|
||||
entity
|
||||
.getPersistentDataContainer()
|
||||
.get(namespacekey, PersistentDataType.INTEGER)
|
||||
);
|
||||
return entity
|
||||
.getPersistentDataContainer()
|
||||
.get(namespacekey, PersistentDataType.INTEGER);
|
||||
}
|
||||
debug(
|
||||
name +
|
||||
" not found in Entity: " +
|
||||
entity.getType().toString() +
|
||||
" " +
|
||||
entity.getName() +
|
||||
" " +
|
||||
entity.getUniqueId().toString()
|
||||
);
|
||||
set(entity, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* gives the name uppercased
|
||||
* @return the name in uppercase
|
||||
*/
|
||||
public String nameUppercase() {
|
||||
return name.toUpperCase();
|
||||
/**
|
||||
* get how many the Entity has Attributed
|
||||
* @param it an ItemStack
|
||||
* @return the amount of attribute
|
||||
*/
|
||||
public Integer get(@NotNull ItemStack it) {
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
if (nbti.hasTag(name)) {
|
||||
return nbti.getInteger(name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get how many the Entity has Attributed
|
||||
* @param entity a living entity
|
||||
* @return the amount of attribute
|
||||
*/
|
||||
public Integer get(@NotNull Entity entity) {
|
||||
if (entity.getPersistentDataContainer().has(namespacekey, PersistentDataType.INTEGER)) {
|
||||
debug(" attribute gett" + entity.getPersistentDataContainer().get(namespacekey, PersistentDataType.INTEGER));
|
||||
return entity.getPersistentDataContainer().get(namespacekey, PersistentDataType.INTEGER);
|
||||
}
|
||||
debug(name + " not found in Entity: " + entity.getType().toString() + " " + entity.getName() + " " + entity.getUniqueId().toString());
|
||||
set(entity, 0);
|
||||
return 0;
|
||||
/**
|
||||
* Get the amount of attribute on the item
|
||||
* @param e a LivingEntity
|
||||
* @return an amount of attribute on the item
|
||||
*/
|
||||
public Integer getItem(@NotNull LivingEntity e) {
|
||||
EntityEquipment equi = e.getEquipment();
|
||||
Integer attribute = 0;
|
||||
if (equi != null) {
|
||||
if (
|
||||
equi.getItemInMainHand().getType() != Material.AIR &&
|
||||
equi.getHelmet() != null
|
||||
) {
|
||||
ItemStack item = equi.getItemInMainHand();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
if (
|
||||
equi.getHelmet().getType() != Material.AIR && equi.getHelmet() != null
|
||||
) {
|
||||
ItemStack item = equi.getHelmet();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
if (
|
||||
equi.getChestplate().getType() != Material.AIR &&
|
||||
equi.getChestplate() != null
|
||||
) {
|
||||
ItemStack item = equi.getChestplate();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
if (
|
||||
equi.getChestplate().getType() != Material.AIR &&
|
||||
equi.getChestplate() != null
|
||||
) {
|
||||
ItemStack item = equi.getChestplate();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
if (
|
||||
equi.getLeggings().getType() != Material.AIR &&
|
||||
equi.getLeggings() != null
|
||||
) {
|
||||
ItemStack item = equi.getLeggings();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
if (
|
||||
equi.getBoots().getType() != Material.AIR && equi.getBoots() != null
|
||||
) {
|
||||
ItemStack item = equi.getBoots();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
}
|
||||
return attribute;
|
||||
}
|
||||
|
||||
/**
|
||||
* get how many the Entity has Attributed
|
||||
* @param it an ItemStack
|
||||
* @return the amount of attribute
|
||||
*/
|
||||
public Integer get(@NotNull ItemStack it) {
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
if (nbti.hasTag(name)){
|
||||
return nbti.getInteger(name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* set amount to the entity's attribute
|
||||
* @param entity a living entity
|
||||
* @param amount the amount you want to set
|
||||
*/
|
||||
public void set(@NotNull Entity entity, @NotNull Integer amount) {
|
||||
entity
|
||||
.getPersistentDataContainer()
|
||||
.set(namespacekey, PersistentDataType.INTEGER, amount);
|
||||
debug("set " + name + " " + amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the amount of attribute on the item
|
||||
* @param e a LivingEntity
|
||||
* @return an amount of attribute on the item
|
||||
*/
|
||||
public Integer getItem(@NotNull LivingEntity e) {
|
||||
EntityEquipment equi = e.getEquipment();
|
||||
Integer attribute = 0;
|
||||
if (equi != null) {
|
||||
if (equi.getItemInMainHand().getType() != Material.AIR && equi.getHelmet() != null) {
|
||||
ItemStack item = equi.getItemInMainHand();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
if (equi.getHelmet().getType() != Material.AIR && equi.getHelmet() != null) {
|
||||
ItemStack item = equi.getHelmet();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
if (equi.getChestplate().getType() != Material.AIR && equi.getChestplate() != null) {
|
||||
ItemStack item = equi.getChestplate();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
if (equi.getChestplate().getType() != Material.AIR && equi.getChestplate() != null) {
|
||||
ItemStack item = equi.getChestplate();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
if (equi.getLeggings().getType() != Material.AIR && equi.getLeggings() != null) {
|
||||
ItemStack item = equi.getLeggings();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
if (equi.getBoots().getType() != Material.AIR && equi.getBoots() != null) {
|
||||
ItemStack item = equi.getBoots();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
}
|
||||
return attribute;
|
||||
}
|
||||
/**
|
||||
* add amount to the entity's attribute
|
||||
* @param entity a living entity
|
||||
* @param amount the amount you want to set
|
||||
*/
|
||||
public void add(@NotNull Entity entity, @NotNull Integer amount) {
|
||||
set(entity, get(entity) + amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* set amount to the entity's attribute
|
||||
* @param entity a living entity
|
||||
* @param amount the amount you want to set
|
||||
*/
|
||||
public void set(@NotNull Entity entity, @NotNull Integer amount) {
|
||||
entity.getPersistentDataContainer().set(namespacekey, PersistentDataType.INTEGER, amount);
|
||||
debug("set " + name + " " + amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* add amount to the entity's attribute
|
||||
* @param entity a living entity
|
||||
* @param amount the amount you want to set
|
||||
*/
|
||||
public void add(@NotNull Entity entity, @NotNull Integer amount) {
|
||||
set(entity, get(entity) + amount);
|
||||
}
|
||||
|
||||
/**
|
||||
* remove amount to the entity's attribute
|
||||
* @param entity a living entity
|
||||
* @param amount the amount you want to set
|
||||
*/
|
||||
public void remove(@NotNull Entity entity, @NotNull Integer amount) {
|
||||
set(entity, get(entity) - amount);
|
||||
}
|
||||
/**
|
||||
* remove amount to the entity's attribute
|
||||
* @param entity a living entity
|
||||
* @param amount the amount you want to set
|
||||
*/
|
||||
public void remove(@NotNull Entity entity, @NotNull Integer amount) {
|
||||
set(entity, get(entity) - amount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class Defense extends Attribute {
|
||||
|
||||
public Defense(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public Defense(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class Health extends Attribute {
|
||||
|
||||
public Health(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public Health(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class ItemDefense extends Attribute {
|
||||
|
||||
public ItemDefense(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public ItemDefense(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class ItemHealth extends Attribute {
|
||||
|
||||
public ItemHealth(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public ItemHealth(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class ItemLuck extends Attribute {
|
||||
|
||||
public ItemLuck(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public ItemLuck(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class ItemMana extends Attribute {
|
||||
|
||||
public ItemMana(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public ItemMana(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class ItemSpeed extends Attribute {
|
||||
|
||||
public ItemSpeed(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public ItemSpeed(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class ItemStrength extends Attribute {
|
||||
|
||||
public ItemStrength(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public ItemStrength(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class Luck extends Attribute {
|
||||
|
||||
public Luck(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public Luck(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class Mana extends Attribute {
|
||||
|
||||
public Mana(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public Mana(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class MaxHealth extends Attribute {
|
||||
|
||||
public MaxHealth(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public MaxHealth(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class MaxMana extends Attribute {
|
||||
|
||||
public MaxMana(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public MaxMana(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,20 +3,21 @@ package me.unurled.raxen.components.entity.Attributes;
|
|||
import org.bukkit.NamespacedKey;
|
||||
|
||||
public class MaxManaBuilder {
|
||||
private NamespacedKey namespacekey;
|
||||
private String name;
|
||||
|
||||
public MaxManaBuilder setNamespacekey(NamespacedKey namespacekey) {
|
||||
this.namespacekey = namespacekey;
|
||||
return this;
|
||||
}
|
||||
private NamespacedKey namespacekey;
|
||||
private String name;
|
||||
|
||||
public MaxManaBuilder setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
public MaxManaBuilder setNamespacekey(NamespacedKey namespacekey) {
|
||||
this.namespacekey = namespacekey;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MaxMana createMaxMana() {
|
||||
return new MaxMana(namespacekey, name);
|
||||
}
|
||||
}
|
||||
public MaxManaBuilder setName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MaxMana createMaxMana() {
|
||||
return new MaxMana(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class Speed extends Attribute {
|
||||
|
||||
public Speed(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public Speed(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,8 +4,7 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class Strength extends Attribute {
|
||||
|
||||
public Strength(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
public Strength(NamespacedKey namespacekey, String name) {
|
||||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,45 +5,43 @@ import org.bukkit.NamespacedKey;
|
|||
|
||||
public class EntityNamespacedKey {
|
||||
|
||||
public EntityNamespacedKey(Raxen main) {
|
||||
name = new NamespacedKey(main, "NAME");
|
||||
level = new NamespacedKey(main, "LEVEL");
|
||||
maxHealth = new NamespacedKey(main, "MAX_HEALTH");
|
||||
health = new NamespacedKey(main, "HEALTH");
|
||||
itemHealth = new NamespacedKey(main, "ITEM_HEALTH");
|
||||
speed = new NamespacedKey(main, "SPEED");
|
||||
itemSpeed = new NamespacedKey(main, "ITEM_SPEED");
|
||||
defense = new NamespacedKey(main, "DEFENSE");
|
||||
itemDefense = new NamespacedKey(main, "ITEM_DEFENSE");
|
||||
strength = new NamespacedKey(main, "STRENGTH");
|
||||
itemStrength = new NamespacedKey(main, "ITEM_STRENGTH");
|
||||
maxMana = new NamespacedKey(main, "MAX_MANA");
|
||||
mana = new NamespacedKey(main, "MANA");
|
||||
itemMana = new NamespacedKey(main, "ITEM_MANA");
|
||||
luck = new NamespacedKey(main, "LUCK");
|
||||
itemLuck = new NamespacedKey(main, "ITEM_LUCK");
|
||||
inventory = new NamespacedKey(main, "INVENTORY");
|
||||
storage = new NamespacedKey(main, "STORAGE");
|
||||
|
||||
}
|
||||
|
||||
public final NamespacedKey name;
|
||||
public final NamespacedKey level;
|
||||
public final NamespacedKey maxHealth;
|
||||
public final NamespacedKey health;
|
||||
public final NamespacedKey itemHealth;
|
||||
public final NamespacedKey speed;
|
||||
public final NamespacedKey itemSpeed;
|
||||
public final NamespacedKey defense;
|
||||
public final NamespacedKey itemDefense;
|
||||
public final NamespacedKey strength;
|
||||
public final NamespacedKey itemStrength;
|
||||
public final NamespacedKey maxMana;
|
||||
public final NamespacedKey mana;
|
||||
public final NamespacedKey itemMana;
|
||||
public final NamespacedKey luck;
|
||||
public final NamespacedKey itemLuck;
|
||||
public final NamespacedKey inventory;
|
||||
public final NamespacedKey storage;
|
||||
public EntityNamespacedKey(Raxen main) {
|
||||
name = new NamespacedKey(main, "NAME");
|
||||
level = new NamespacedKey(main, "LEVEL");
|
||||
maxHealth = new NamespacedKey(main, "MAX_HEALTH");
|
||||
health = new NamespacedKey(main, "HEALTH");
|
||||
itemHealth = new NamespacedKey(main, "ITEM_HEALTH");
|
||||
speed = new NamespacedKey(main, "SPEED");
|
||||
itemSpeed = new NamespacedKey(main, "ITEM_SPEED");
|
||||
defense = new NamespacedKey(main, "DEFENSE");
|
||||
itemDefense = new NamespacedKey(main, "ITEM_DEFENSE");
|
||||
strength = new NamespacedKey(main, "STRENGTH");
|
||||
itemStrength = new NamespacedKey(main, "ITEM_STRENGTH");
|
||||
maxMana = new NamespacedKey(main, "MAX_MANA");
|
||||
mana = new NamespacedKey(main, "MANA");
|
||||
itemMana = new NamespacedKey(main, "ITEM_MANA");
|
||||
luck = new NamespacedKey(main, "LUCK");
|
||||
itemLuck = new NamespacedKey(main, "ITEM_LUCK");
|
||||
inventory = new NamespacedKey(main, "INVENTORY");
|
||||
storage = new NamespacedKey(main, "STORAGE");
|
||||
}
|
||||
|
||||
public final NamespacedKey name;
|
||||
public final NamespacedKey level;
|
||||
public final NamespacedKey maxHealth;
|
||||
public final NamespacedKey health;
|
||||
public final NamespacedKey itemHealth;
|
||||
public final NamespacedKey speed;
|
||||
public final NamespacedKey itemSpeed;
|
||||
public final NamespacedKey defense;
|
||||
public final NamespacedKey itemDefense;
|
||||
public final NamespacedKey strength;
|
||||
public final NamespacedKey itemStrength;
|
||||
public final NamespacedKey maxMana;
|
||||
public final NamespacedKey mana;
|
||||
public final NamespacedKey itemMana;
|
||||
public final NamespacedKey luck;
|
||||
public final NamespacedKey itemLuck;
|
||||
public final NamespacedKey inventory;
|
||||
public final NamespacedKey storage;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package me.unurled.raxen.components.entity.other;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.manager.entity.PlayerManager;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -8,63 +10,96 @@ import org.bukkit.persistence.PersistentDataContainer;
|
|||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class EntityUtils {
|
||||
|
||||
private static Raxen main;
|
||||
private static EntityNamespacedKey namespacedKey;
|
||||
private static Raxen main;
|
||||
private static EntityNamespacedKey namespacedKey;
|
||||
|
||||
public EntityUtils(Raxen main) {
|
||||
this.main = main;
|
||||
namespacedKey = new EntityNamespacedKey(main);
|
||||
public EntityUtils(Raxen main) {
|
||||
this.main = main;
|
||||
namespacedKey = new EntityNamespacedKey(main);
|
||||
}
|
||||
|
||||
public static void setNameSpacedKeys(
|
||||
org.bukkit.entity.@NotNull Entity e,
|
||||
String name,
|
||||
Integer level,
|
||||
int health,
|
||||
int itemHealth,
|
||||
int defense,
|
||||
int itemDefense,
|
||||
int speed,
|
||||
int itemSpeed,
|
||||
int strength,
|
||||
int itemDmg
|
||||
) {
|
||||
PersistentDataContainer data = e.getPersistentDataContainer();
|
||||
data.set(namespacedKey.health, PersistentDataType.INTEGER, health);
|
||||
data.set(namespacedKey.itemHealth, PersistentDataType.INTEGER, itemHealth);
|
||||
data.set(namespacedKey.speed, PersistentDataType.INTEGER, speed);
|
||||
data.set(namespacedKey.itemSpeed, PersistentDataType.INTEGER, itemSpeed);
|
||||
data.set(namespacedKey.defense, PersistentDataType.INTEGER, defense);
|
||||
data.set(
|
||||
namespacedKey.itemDefense,
|
||||
PersistentDataType.INTEGER,
|
||||
itemDefense
|
||||
);
|
||||
data.set(namespacedKey.strength, PersistentDataType.INTEGER, strength);
|
||||
data.set(namespacedKey.itemStrength, PersistentDataType.INTEGER, itemDmg);
|
||||
data.set(namespacedKey.name, PersistentDataType.STRING, name);
|
||||
data.set(namespacedKey.level, PersistentDataType.INTEGER, level);
|
||||
}
|
||||
|
||||
public static void updateSkills(@NotNull LivingEntity livingEntity) {
|
||||
PlayerManager pm =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
int maxHealth, health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck, itemLuck;
|
||||
defense = pm.getDefense().get(livingEntity);
|
||||
maxMana = pm.getMaxMana().get(livingEntity);
|
||||
itemDefense = pm.getItemDefense().get(livingEntity);
|
||||
health = pm.getHealth().get(livingEntity);
|
||||
itemHealth = pm.getItemHealth().get(livingEntity);
|
||||
mana = pm.getMana().get(livingEntity);
|
||||
speed = pm.getSpeed().get(livingEntity);
|
||||
itemLuck = pm.getItemLuck().get(livingEntity);
|
||||
strength = pm.getStrength().get(livingEntity);
|
||||
luck = pm.getLuck().get(livingEntity);
|
||||
maxHealth = pm.getMaxHealth().get(livingEntity);
|
||||
itemStrength = pm.getItemStrength().get(livingEntity);
|
||||
itemSpeed = pm.getItemSpeed().get(livingEntity);
|
||||
itemMana = pm.getItemMana().get(livingEntity);
|
||||
if (
|
||||
livingEntity.getAttribute(
|
||||
org.bukkit.attribute.Attribute.GENERIC_FLYING_SPEED
|
||||
) !=
|
||||
null
|
||||
) {
|
||||
livingEntity
|
||||
.getAttribute(org.bukkit.attribute.Attribute.GENERIC_FLYING_SPEED)
|
||||
.setBaseValue((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||
}
|
||||
|
||||
public static void setNameSpacedKeys(org.bukkit.entity.@NotNull Entity e, String name, Integer level, int health, int itemHealth, int defense, int itemDefense, int speed, int itemSpeed, int strength, int itemDmg) {
|
||||
PersistentDataContainer data = e.getPersistentDataContainer();
|
||||
data.set(namespacedKey.health, PersistentDataType.INTEGER, health);
|
||||
data.set(namespacedKey.itemHealth, PersistentDataType.INTEGER, itemHealth);
|
||||
data.set(namespacedKey.speed, PersistentDataType.INTEGER, speed);
|
||||
data.set(namespacedKey.itemSpeed, PersistentDataType.INTEGER, itemSpeed);
|
||||
data.set(namespacedKey.defense, PersistentDataType.INTEGER, defense);
|
||||
data.set(namespacedKey.itemDefense, PersistentDataType.INTEGER, itemDefense);
|
||||
data.set(namespacedKey.strength, PersistentDataType.INTEGER, strength);
|
||||
data.set(namespacedKey.itemStrength, PersistentDataType.INTEGER, itemDmg);
|
||||
data.set(namespacedKey.name, PersistentDataType.STRING, name);
|
||||
data.set(namespacedKey.level, PersistentDataType.INTEGER, level);
|
||||
if (
|
||||
livingEntity.getAttribute(
|
||||
org.bukkit.attribute.Attribute.GENERIC_MOVEMENT_SPEED
|
||||
) !=
|
||||
null
|
||||
) {
|
||||
livingEntity
|
||||
.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MOVEMENT_SPEED)
|
||||
.setBaseValue((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||
}
|
||||
|
||||
public static void updateSkills(@NotNull LivingEntity livingEntity) {
|
||||
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
int maxHealth, health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck, itemLuck;
|
||||
defense= pm.getDefense().get(livingEntity);
|
||||
maxMana = pm.getMaxMana().get(livingEntity);
|
||||
itemDefense= pm.getItemDefense().get(livingEntity);
|
||||
health = pm.getHealth().get(livingEntity);
|
||||
itemHealth = pm.getItemHealth().get(livingEntity);
|
||||
mana = pm.getMana().get(livingEntity);
|
||||
speed = pm.getSpeed().get(livingEntity);
|
||||
itemLuck = pm.getItemLuck().get(livingEntity);
|
||||
strength = pm.getStrength().get(livingEntity);
|
||||
luck = pm.getLuck().get(livingEntity);
|
||||
maxHealth = pm.getMaxHealth().get(livingEntity);
|
||||
itemStrength = pm.getItemStrength().get(livingEntity);
|
||||
itemSpeed = pm.getItemSpeed().get(livingEntity);
|
||||
itemMana = pm.getItemMana().get(livingEntity);
|
||||
if (livingEntity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_FLYING_SPEED) != null) {
|
||||
livingEntity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_FLYING_SPEED).setBaseValue((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||
}
|
||||
if (livingEntity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MOVEMENT_SPEED) != null) {
|
||||
livingEntity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||
}
|
||||
livingEntity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).setBaseValue(20D + (health + itemHealth) / 100);
|
||||
debug("Entity " + livingEntity.getType().name(),
|
||||
"Speed " + (speed + itemSpeed),
|
||||
"Health " + (health + itemHealth) + " Max Health " + maxHealth,
|
||||
"Defense " + (defense+itemDefense),
|
||||
"Strength " + (strength+itemStrength),
|
||||
"Luck " + (luck+itemLuck),
|
||||
"Mana " + (mana + itemMana) + " Max Mana " + maxMana);
|
||||
}
|
||||
|
||||
livingEntity
|
||||
.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH)
|
||||
.setBaseValue(20D + (health + itemHealth) / 100);
|
||||
debug(
|
||||
"Entity " + livingEntity.getType().name(),
|
||||
"Speed " + (speed + itemSpeed),
|
||||
"Health " + (health + itemHealth) + " Max Health " + maxHealth,
|
||||
"Defense " + (defense + itemDefense),
|
||||
"Strength " + (strength + itemStrength),
|
||||
"Luck " + (luck + itemLuck),
|
||||
"Mana " + (mana + itemMana) + " Max Mana " + maxMana
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,44 +13,58 @@ import org.bukkit.persistence.PersistentDataType;
|
|||
|
||||
public abstract class RaxenEntity {
|
||||
|
||||
private final Raxen main;
|
||||
private final Raxen main;
|
||||
|
||||
@Getter private final String name;
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
@Getter private Integer level;
|
||||
@Getter
|
||||
private Integer level;
|
||||
|
||||
@Getter @Setter private Double health;
|
||||
@Getter
|
||||
@Setter
|
||||
private Double health;
|
||||
|
||||
@Getter @Setter private Double strength;
|
||||
@Getter
|
||||
@Setter
|
||||
private Double strength;
|
||||
|
||||
@Getter @Setter Boolean isAlive = false;
|
||||
@Getter
|
||||
@Setter
|
||||
Boolean isAlive = false;
|
||||
|
||||
public RaxenEntity(Raxen main, String name, Integer level, Double health, Double strength) {
|
||||
this.main = main;
|
||||
this.name = name;
|
||||
this.level = level;
|
||||
this.health = health;
|
||||
this.strength = strength;
|
||||
}
|
||||
public RaxenEntity(
|
||||
Raxen main,
|
||||
String name,
|
||||
Integer level,
|
||||
Double health,
|
||||
Double strength
|
||||
) {
|
||||
this.main = main;
|
||||
this.name = name;
|
||||
this.level = level;
|
||||
this.health = health;
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
public Entity createEntity(EntityType types, String name, Location location) {
|
||||
Entity e = location.getWorld().spawnEntity(location, types);
|
||||
e.setCustomNameVisible(true);
|
||||
e.customName(Component.text(name));
|
||||
public Entity createEntity(EntityType types, String name, Location location) {
|
||||
Entity e = location.getWorld().spawnEntity(location, types);
|
||||
e.setCustomNameVisible(true);
|
||||
e.customName(Component.text(name));
|
||||
|
||||
return e;
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
public void register(Entity e) {
|
||||
PersistentDataContainer data = e.getPersistentDataContainer();
|
||||
data.set(new NamespacedKey(main ,"NAME"), PersistentDataType.STRING, name);
|
||||
}
|
||||
public void register(Entity e) {
|
||||
PersistentDataContainer data = e.getPersistentDataContainer();
|
||||
data.set(new NamespacedKey(main, "NAME"), PersistentDataType.STRING, name);
|
||||
}
|
||||
|
||||
public Double getMaxHealth(Entity e) {
|
||||
PersistentDataContainer data = e.getPersistentDataContainer();
|
||||
EntityNamespacedKey key = new EntityNamespacedKey(main);
|
||||
return data.get(key.maxHealth, PersistentDataType.DOUBLE);
|
||||
}
|
||||
public Double getMaxHealth(Entity e) {
|
||||
PersistentDataContainer data = e.getPersistentDataContainer();
|
||||
EntityNamespacedKey key = new EntityNamespacedKey(main);
|
||||
return data.get(key.maxHealth, PersistentDataType.DOUBLE);
|
||||
}
|
||||
|
||||
public abstract Entity createEntity(Location location);
|
||||
public abstract Entity createEntity(Location location);
|
||||
}
|
||||
|
|
|
@ -1,73 +1,103 @@
|
|||
package me.unurled.raxen.components.entity.other.custom;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorString;
|
||||
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorString;
|
||||
|
||||
public class Entity {
|
||||
|
||||
private java.util.UUID uuid;
|
||||
private java.util.UUID uuid;
|
||||
|
||||
private final String name;
|
||||
@Getter
|
||||
private Integer level;
|
||||
@Setter
|
||||
private Double health;
|
||||
@Getter
|
||||
@Setter
|
||||
private Double strength;
|
||||
@Getter
|
||||
@Setter
|
||||
private Double defense;
|
||||
@Getter
|
||||
@Setter
|
||||
private Double speed;
|
||||
@Getter
|
||||
@Setter
|
||||
private Double maxHealth;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean isHostile;
|
||||
private final String name;
|
||||
|
||||
public Entity(String name, Integer level, Double maxHealth, Double strength, Double defense, Double speed, boolean isHostile) {
|
||||
this.name = name;
|
||||
this.level = level;
|
||||
this.health = maxHealth;
|
||||
this.strength = strength;
|
||||
this.defense = defense;
|
||||
this.speed = speed;
|
||||
this.maxHealth = maxHealth;
|
||||
this.isHostile = isHostile;
|
||||
this.uuid = UUID.randomUUID();
|
||||
@Getter
|
||||
private Integer level;
|
||||
|
||||
@Setter
|
||||
private Double health;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Double strength;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Double defense;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Double speed;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Double maxHealth;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean isHostile;
|
||||
|
||||
public Entity(
|
||||
String name,
|
||||
Integer level,
|
||||
Double maxHealth,
|
||||
Double strength,
|
||||
Double defense,
|
||||
Double speed,
|
||||
boolean isHostile
|
||||
) {
|
||||
this.name = name;
|
||||
this.level = level;
|
||||
this.health = maxHealth;
|
||||
this.strength = strength;
|
||||
this.defense = defense;
|
||||
this.speed = speed;
|
||||
this.maxHealth = maxHealth;
|
||||
this.isHostile = isHostile;
|
||||
this.uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
public void register(Raxen main) {
|
||||
main.getManager().getEntityManager().entities.put(name, this);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "<white>" + name;
|
||||
}
|
||||
|
||||
public String getFullName(Entity e) {
|
||||
if (isHostile) {
|
||||
return colorString(
|
||||
getColorLevel() +
|
||||
"<white>⚔️" +
|
||||
getName() +
|
||||
"<red>" +
|
||||
health +
|
||||
"<white>/<white/>" +
|
||||
maxHealth
|
||||
);
|
||||
} else {
|
||||
return colorString(
|
||||
getColorLevel() +
|
||||
"<white>❤️" +
|
||||
getName() +
|
||||
"<red>" +
|
||||
health +
|
||||
"<white>/<white/>" +
|
||||
maxHealth
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public void register (Raxen main) {
|
||||
main.getManager().getEntityManager().entities.put(name, this);
|
||||
}
|
||||
public String getColorLevel() {
|
||||
return level.toString();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "<white>" + name;
|
||||
}
|
||||
public Double getHealth() {
|
||||
Double health = 0.0;
|
||||
|
||||
public String getFullName(Entity e) {
|
||||
if (isHostile) {
|
||||
return colorString(getColorLevel() + "<white>⚔️" + getName() + "<red>" + health + "<white>/<white/>" + maxHealth);
|
||||
} else {
|
||||
return colorString(getColorLevel() + "<white>❤️" + getName() + "<red>" + health + "<white>/<white/>" + maxHealth);
|
||||
}
|
||||
}
|
||||
|
||||
public String getColorLevel() {
|
||||
return level.toString();
|
||||
}
|
||||
|
||||
public Double getHealth() {
|
||||
Double health = 0.0;
|
||||
|
||||
return health;
|
||||
}
|
||||
return health;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,12 +4,22 @@ import java.util.UUID;
|
|||
|
||||
public class Humanoid extends Entity {
|
||||
|
||||
private String skin; // used to get the path to the skin
|
||||
private UUID skinUuid; // used to get the player skin (if i do it this way...
|
||||
private String skin; // used to get the path to the skin
|
||||
private UUID skinUuid; // used to get the player skin (if i do it this way...
|
||||
|
||||
public Humanoid(String name, Integer level, Double maxHealth, Double strength, Double defense, Double speed, boolean isHostile, String skin, UUID skinUuid) {
|
||||
super(name, level, maxHealth, strength, defense, speed, isHostile);
|
||||
this.skin = skin;
|
||||
this.skinUuid = skinUuid;
|
||||
}
|
||||
public Humanoid(
|
||||
String name,
|
||||
Integer level,
|
||||
Double maxHealth,
|
||||
Double strength,
|
||||
Double defense,
|
||||
Double speed,
|
||||
boolean isHostile,
|
||||
String skin,
|
||||
UUID skinUuid
|
||||
) {
|
||||
super(name, level, maxHealth, strength, defense, speed, isHostile);
|
||||
this.skin = skin;
|
||||
this.skinUuid = skinUuid;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,26 +9,32 @@ import org.bukkit.entity.EntityType;
|
|||
|
||||
public class Elf extends RaxenEntity {
|
||||
|
||||
@Getter private final String name;
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
public Elf(Raxen main, String name, Integer level, Double health, Double strength) {
|
||||
super(main, name, level, health, strength);
|
||||
this.name = name;
|
||||
}
|
||||
public Elf(
|
||||
Raxen main,
|
||||
String name,
|
||||
Integer level,
|
||||
Double health,
|
||||
Double strength
|
||||
) {
|
||||
super(main, name, level, health, strength);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity(Location location) {
|
||||
return super.createEntity(EntityType.PLAYER, name, location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Elf Default values
|
||||
* @param main the main instance
|
||||
* @param name
|
||||
*/
|
||||
public Elf(Raxen main, String name) {
|
||||
super(main, "Elf", 10, 120.0, 25.0);
|
||||
this.name = name;
|
||||
}
|
||||
@Override
|
||||
public Entity createEntity(Location location) {
|
||||
return super.createEntity(EntityType.PLAYER, name, location);
|
||||
}
|
||||
|
||||
/**
|
||||
* Elf Default values
|
||||
* @param main the main instance
|
||||
* @param name
|
||||
*/
|
||||
public Elf(Raxen main, String name) {
|
||||
super(main, "Elf", 10, 120.0, 25.0);
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,21 +9,27 @@ import org.bukkit.entity.EntityType;
|
|||
|
||||
public class Wolf extends RaxenEntity {
|
||||
|
||||
@Getter private final String name;
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
public Wolf(
|
||||
Raxen main,
|
||||
String name,
|
||||
Integer level,
|
||||
Double health,
|
||||
Double strength
|
||||
) {
|
||||
super(main, name, level, health, strength);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Wolf(Raxen main, String name, Integer level, Double health, Double strength) {
|
||||
super(main, name, level, health, strength);
|
||||
this.name = name;
|
||||
}
|
||||
public Wolf(Raxen main) {
|
||||
super(main, "Wolf", 5, 100.0, 20.0);
|
||||
this.name = "Wolf";
|
||||
}
|
||||
|
||||
public Wolf(Raxen main) {
|
||||
super(main, "Wolf", 5, 100.0, 20.0);
|
||||
this.name = "Wolf";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity(Location location) {
|
||||
return super.createEntity(EntityType.WOLF, name, location);
|
||||
}
|
||||
@Override
|
||||
public Entity createEntity(Location location) {
|
||||
return super.createEntity(EntityType.WOLF, name, location);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,24 +8,32 @@ import org.bukkit.entity.EntityType;
|
|||
|
||||
public class Goblin extends Entity {
|
||||
|
||||
RaxenEntity goblin;
|
||||
RaxenEntity goblin;
|
||||
|
||||
public Goblin(Raxen main) {
|
||||
super("Goblin", 1, 100.0, 10.0, 0.0, 50.0, true);
|
||||
this.goblin = new RaxenEntity(main, "Goblin", 1, 100.0, 10.0) {
|
||||
@Override
|
||||
public org.bukkit.entity.Entity createEntity(Location location) {
|
||||
return super.createEntity(EntityType.PLAYER, "Goblin", location);
|
||||
}
|
||||
};
|
||||
register(main);
|
||||
}
|
||||
public Goblin(Raxen main) {
|
||||
super("Goblin", 1, 100.0, 10.0, 0.0, 50.0, true);
|
||||
this.goblin =
|
||||
new RaxenEntity(main, "Goblin", 1, 100.0, 10.0) {
|
||||
@Override
|
||||
public org.bukkit.entity.Entity createEntity(Location location) {
|
||||
return super.createEntity(EntityType.PLAYER, "Goblin", location);
|
||||
}
|
||||
};
|
||||
register(main);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "<white>" + goblin.getName();
|
||||
}
|
||||
public String getName() {
|
||||
return "<white>" + goblin.getName();
|
||||
}
|
||||
|
||||
public String getFullName(Entity e) {
|
||||
return "<white>⚔️" + getName() + "<red>" + getHealth() + "<white>/<white/>" + getMaxHealth();
|
||||
}
|
||||
public String getFullName(Entity e) {
|
||||
return (
|
||||
"<white>⚔️" +
|
||||
getName() +
|
||||
"<red>" +
|
||||
getHealth() +
|
||||
"<white>/<white/>" +
|
||||
getMaxHealth()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
package me.unurled.raxen.components.entity.other.spawn;
|
||||
|
||||
public class Eggs {
|
||||
}
|
||||
public class Eggs {}
|
||||
|
|
|
@ -3,17 +3,18 @@ package me.unurled.raxen.components.entity.player;
|
|||
import me.unurled.raxen.components.entity.player.storages.Inventory;
|
||||
|
||||
public class Inventories {
|
||||
private Inventory inv;
|
||||
|
||||
public Inventories(Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
private Inventory inv;
|
||||
|
||||
public Inventory getInv() {
|
||||
return inv;
|
||||
}
|
||||
public Inventories(Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
|
||||
public void setInv(Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
public Inventory getInv() {
|
||||
return inv;
|
||||
}
|
||||
|
||||
public void setInv(Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,42 +1,47 @@
|
|||
package me.unurled.raxen.components.entity.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.manager.entity.PlayerManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class PlayerUtils {
|
||||
|
||||
public static void updateSkills(Raxen main, Player player) {
|
||||
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
int maxHealth, health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck, itemLuck;
|
||||
defense= pm.getDefense().get(player);
|
||||
maxMana = pm.getMaxMana().get(player);
|
||||
itemDefense= pm.getItemDefense().get(player);
|
||||
health = pm.getHealth().get(player);
|
||||
itemHealth = pm.getItemHealth().get(player);
|
||||
mana = pm.getMana().get(player);
|
||||
speed = pm.getSpeed().get(player);
|
||||
itemLuck = pm.getItemLuck().get(player);
|
||||
strength = pm.getStrength().get(player);
|
||||
luck = pm.getLuck().get(player);
|
||||
maxHealth = pm.getMaxHealth().get(player);
|
||||
itemStrength = pm.getItemStrength().get(player);
|
||||
itemSpeed = pm.getItemSpeed().get(player);
|
||||
itemMana = pm.getItemMana().get(player);
|
||||
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20D + (health + itemHealth) / 100);
|
||||
player.setWalkSpeed((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||
player.setFlySpeed((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||
debug("Player " + player.getName(),
|
||||
"Speed " + (speed + itemSpeed),
|
||||
"Health " + (health + itemHealth) + " Max Health " + maxHealth,
|
||||
"Defense " + (defense+itemDefense),
|
||||
"Strength " + (strength+itemStrength),
|
||||
"Luck " + (luck+itemLuck),
|
||||
"Mana " + (mana + itemMana) + " Max Mana " + maxMana);
|
||||
}
|
||||
|
||||
public static void updateSkills(Raxen main, Player player) {
|
||||
PlayerManager pm =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
int maxHealth, health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck, itemLuck;
|
||||
defense = pm.getDefense().get(player);
|
||||
maxMana = pm.getMaxMana().get(player);
|
||||
itemDefense = pm.getItemDefense().get(player);
|
||||
health = pm.getHealth().get(player);
|
||||
itemHealth = pm.getItemHealth().get(player);
|
||||
mana = pm.getMana().get(player);
|
||||
speed = pm.getSpeed().get(player);
|
||||
itemLuck = pm.getItemLuck().get(player);
|
||||
strength = pm.getStrength().get(player);
|
||||
luck = pm.getLuck().get(player);
|
||||
maxHealth = pm.getMaxHealth().get(player);
|
||||
itemStrength = pm.getItemStrength().get(player);
|
||||
itemSpeed = pm.getItemSpeed().get(player);
|
||||
itemMana = pm.getItemMana().get(player);
|
||||
player
|
||||
.getAttribute(Attribute.GENERIC_MAX_HEALTH)
|
||||
.setBaseValue(20D + (health + itemHealth) / 100);
|
||||
player.setWalkSpeed((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||
player.setFlySpeed((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||
debug(
|
||||
"Player " + player.getName(),
|
||||
"Speed " + (speed + itemSpeed),
|
||||
"Health " + (health + itemHealth) + " Max Health " + maxHealth,
|
||||
"Defense " + (defense + itemDefense),
|
||||
"Strength " + (strength + itemStrength),
|
||||
"Luck " + (luck + itemLuck),
|
||||
"Mana " + (mana + itemMana) + " Max Mana " + maxMana
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package me.unurled.raxen.components.entity.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Items.setItemsToInventory;
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.other.EntityNamespacedKey;
|
||||
import me.unurled.raxen.components.entity.player.attributes.Attribute;
|
||||
|
@ -17,114 +22,153 @@ import org.bukkit.inventory.PlayerInventory;
|
|||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Items.setItemsToInventory;
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class RaxenPlayer {
|
||||
|
||||
private final Raxen main;
|
||||
private final Player player;
|
||||
private final EntityNamespacedKey namespacedKey;
|
||||
private final Raxen main;
|
||||
private final Player player;
|
||||
private final EntityNamespacedKey namespacedKey;
|
||||
|
||||
private Boolean isRaxenPlayer;
|
||||
private Boolean isRaxenPlayer;
|
||||
|
||||
private Attribute attribute;
|
||||
private Attribute attribute;
|
||||
|
||||
private Storage storages;
|
||||
private Inventories inventory;
|
||||
private Storage storages;
|
||||
private Inventories inventory;
|
||||
|
||||
public RaxenPlayer(Raxen main, Player player) {
|
||||
this.main = main;
|
||||
this.player = player;
|
||||
this.namespacedKey = new EntityNamespacedKey(main);
|
||||
this.isRaxenPlayer = true;
|
||||
public RaxenPlayer(Raxen main, Player player) {
|
||||
this.main = main;
|
||||
this.player = player;
|
||||
this.namespacedKey = new EntityNamespacedKey(main);
|
||||
this.isRaxenPlayer = true;
|
||||
}
|
||||
|
||||
public Attribute createNewAttribute() {
|
||||
debug(main, "Created new Attribute");
|
||||
EntityAttributes.setAttributes(
|
||||
player,
|
||||
100,
|
||||
100,
|
||||
0,
|
||||
50,
|
||||
0,
|
||||
100,
|
||||
0,
|
||||
100,
|
||||
0,
|
||||
100,
|
||||
100,
|
||||
0,
|
||||
10,
|
||||
0
|
||||
);
|
||||
return new Attribute(
|
||||
100,
|
||||
100,
|
||||
0,
|
||||
50,
|
||||
0,
|
||||
100,
|
||||
0,
|
||||
100,
|
||||
0,
|
||||
100,
|
||||
100,
|
||||
0,
|
||||
10,
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
public void setStorages(
|
||||
org.bukkit.inventory.Inventory inv,
|
||||
org.bukkit.inventory.Inventory ec
|
||||
) {
|
||||
setStorage(ec);
|
||||
setInventory(inv);
|
||||
}
|
||||
|
||||
public Storage getStorage() {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
String store = data.get(namespacedKey.storage, PersistentDataType.STRING);
|
||||
org.bukkit.inventory.Inventory ec = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Ender Chest")
|
||||
);
|
||||
ec = setItemsToInventory(Items.mapItemStackDeserialize(store), ec);
|
||||
EnderChest ecc = new EnderChest(ec);
|
||||
Storage storage = new Storage(ecc);
|
||||
return storage;
|
||||
}
|
||||
|
||||
public Inventories getInventory() {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
String inv = data.get(namespacedKey.inventory, PersistentDataType.STRING);
|
||||
org.bukkit.inventory.Inventory invv = Bukkit.createInventory(
|
||||
player,
|
||||
InventoryType.PLAYER
|
||||
);
|
||||
invv =
|
||||
setItemsToInventory(
|
||||
Items.listItemStackDeserialize(inv),
|
||||
(PlayerInventory) invv
|
||||
);
|
||||
Inventory invvv = new Inventory(invv);
|
||||
Inventories invvvv = new Inventories(invvv);
|
||||
return invvvv;
|
||||
}
|
||||
|
||||
public void setInventory(org.bukkit.inventory.Inventory inv) {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
List<String> listInv = new ArrayList<String>();
|
||||
Integer reverse = 0;
|
||||
for (ItemStack it : inv) {
|
||||
reverse = reverse + 1;
|
||||
if (it != null && it.getType() != Material.AIR) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
listInv.add(s);
|
||||
}
|
||||
}
|
||||
String invv = Items.listItemStackSerialize(listInv);
|
||||
this.inventory = new Inventories(new Inventory(inv));
|
||||
data.set(namespacedKey.inventory, PersistentDataType.STRING, invv);
|
||||
}
|
||||
|
||||
public Attribute createNewAttribute() {
|
||||
debug(main, "Created new Attribute");
|
||||
EntityAttributes.setAttributes(player, 100, 100,0,50,0,100,0,100,0, 100, 100, 0, 10, 0);
|
||||
return new Attribute(100,100,0,50,0,100,0,100,0, 100, 100, 0, 10, 0);
|
||||
public void setStorage(org.bukkit.inventory.Inventory ec) {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
List<String> list = new ArrayList<String>();
|
||||
int reverse = 0;
|
||||
for (ItemStack it : ec) {
|
||||
if (it != null) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
list.add(s);
|
||||
}
|
||||
reverse += 1;
|
||||
}
|
||||
String store = Items.listItemStackSerialize(list);
|
||||
this.storages = new Storage(new EnderChest(ec));
|
||||
data.set(namespacedKey.storage, PersistentDataType.STRING, store);
|
||||
}
|
||||
|
||||
public void setStorages(org.bukkit.inventory.Inventory inv, org.bukkit.inventory.Inventory ec) {
|
||||
setStorage(ec);
|
||||
setInventory(inv);
|
||||
}
|
||||
public Storage createStorage() {
|
||||
setStorage(Bukkit.createInventory(null, 54, Component.text("Ender Chest")));
|
||||
return getStorage();
|
||||
}
|
||||
|
||||
public Storage getStorage() {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
String store = data.get(namespacedKey.storage, PersistentDataType.STRING);
|
||||
org.bukkit.inventory.Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||
ec = setItemsToInventory(Items.mapItemStackDeserialize(store), ec);
|
||||
EnderChest ecc = new EnderChest(ec);
|
||||
Storage storage = new Storage(ecc);
|
||||
return storage;
|
||||
}
|
||||
public Inventories createInventory() {
|
||||
setInventory(Bukkit.createInventory(null, InventoryType.PLAYER));
|
||||
return getInventory();
|
||||
}
|
||||
|
||||
public Inventories getInventory() {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
String inv = data.get(namespacedKey.inventory, PersistentDataType.STRING);
|
||||
org.bukkit.inventory.Inventory invv = Bukkit.createInventory(player, InventoryType.PLAYER);
|
||||
invv = setItemsToInventory(Items.listItemStackDeserialize(inv), (PlayerInventory) invv);
|
||||
Inventory invvv = new Inventory(invv);
|
||||
Inventories invvvv = new Inventories(invvv);
|
||||
return invvvv;
|
||||
}
|
||||
public Boolean isRaxenPlayer() {
|
||||
return isRaxenPlayer;
|
||||
}
|
||||
|
||||
public void setInventory(org.bukkit.inventory.Inventory inv) {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
List<String> listInv = new ArrayList<String>();
|
||||
Integer reverse = 0;
|
||||
for(ItemStack it : inv) {
|
||||
reverse = reverse + 1;
|
||||
if(it != null && it.getType() != Material.AIR) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
listInv.add(s);
|
||||
}
|
||||
}
|
||||
String invv = Items.listItemStackSerialize(listInv);
|
||||
this.inventory = new Inventories(new Inventory(inv));
|
||||
data.set(namespacedKey.inventory, PersistentDataType.STRING, invv);
|
||||
}
|
||||
public void isRaxenPlayer(boolean player) {
|
||||
isRaxenPlayer = player;
|
||||
}
|
||||
|
||||
public void setStorage(org.bukkit.inventory.Inventory ec) {
|
||||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
List<String> list = new ArrayList<String>();
|
||||
int reverse = 0;
|
||||
for(ItemStack it : ec) {
|
||||
if(it != null) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
list.add(s);
|
||||
}
|
||||
reverse += 1;
|
||||
}
|
||||
String store = Items.listItemStackSerialize(list);
|
||||
this.storages = new Storage(new EnderChest(ec));
|
||||
data.set(namespacedKey.storage, PersistentDataType.STRING, store);
|
||||
}
|
||||
|
||||
public Storage createStorage() {
|
||||
setStorage(Bukkit.createInventory(null, 54, Component.text("Ender Chest")));
|
||||
return getStorage();
|
||||
}
|
||||
|
||||
public Inventories createInventory() {
|
||||
setInventory(Bukkit.createInventory(null, InventoryType.PLAYER));
|
||||
return getInventory();
|
||||
}
|
||||
|
||||
public Boolean isRaxenPlayer() {
|
||||
return isRaxenPlayer;
|
||||
}
|
||||
|
||||
public void isRaxenPlayer(boolean player) {
|
||||
isRaxenPlayer = player;
|
||||
}
|
||||
|
||||
public Attribute getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
public Attribute getAttribute() {
|
||||
return attribute;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,55 +1,75 @@
|
|||
package me.unurled.raxen.components.entity.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.utils.libs.Vault;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scoreboard.*;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
public class Scoreboard {
|
||||
|
||||
private Raxen main;
|
||||
private Vault vault;
|
||||
private Raxen main;
|
||||
private Vault vault;
|
||||
|
||||
public Scoreboard(Raxen main) {
|
||||
this.main = main;
|
||||
this.vault = main.getManager().getLibsManager().getVault();
|
||||
}
|
||||
|
||||
public void createScorebord(Player player) {
|
||||
ScoreboardManager manager = Bukkit.getScoreboardManager();
|
||||
org.bukkit.scoreboard.Scoreboard board = manager.getNewScoreboard();
|
||||
Objective obj = board.registerNewObjective("Raxen", "dummy", colorTextComp("<red>Elixium"));
|
||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
Score score = obj.getScore(textCompToString(colorTextComp("<gold>-------------")));
|
||||
score.setScore(4);
|
||||
Score score1 = obj.getScore(textCompToString(colorTextComp("<aqua>Name:" + player.getName())));
|
||||
score1.setScore(3);
|
||||
Score score2 = obj.getScore(textCompToString(colorTextComp("<white>Location")));
|
||||
score2.setScore(2);
|
||||
Score score3 = obj.getScore(textCompToString(colorTextComp("<gold>Coins: <gold>" + vault.getBalanceString(player))));
|
||||
score3.setScore(1);
|
||||
Score score4 = obj.getScore(textCompToString(colorTextComp("<yellow>unurled.me")));
|
||||
score4.setScore(0);
|
||||
player.setScoreboard(board);
|
||||
}
|
||||
|
||||
public void updateScoreboardTransaction(Player player) {
|
||||
if(player != null) {
|
||||
Objective objective = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
|
||||
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
|
||||
debug(main, String.valueOf(player.getScoreboard().getEntries()));
|
||||
for (String str : player.getScoreboard().getEntries()) {
|
||||
if(str.contains(player.getName())) {
|
||||
|
||||
}
|
||||
}
|
||||
player.getScoreboard().resetScores("Coins");
|
||||
assert objective != null;
|
||||
Score score = objective.getScore(textCompToString(colorTextComp("<gold>Coins: <gold>" + vault.getBalanceString(player))));
|
||||
score.setScore(1);
|
||||
}
|
||||
public Scoreboard(Raxen main) {
|
||||
this.main = main;
|
||||
this.vault = main.getManager().getLibsManager().getVault();
|
||||
}
|
||||
|
||||
public void createScorebord(Player player) {
|
||||
ScoreboardManager manager = Bukkit.getScoreboardManager();
|
||||
org.bukkit.scoreboard.Scoreboard board = manager.getNewScoreboard();
|
||||
Objective obj = board.registerNewObjective(
|
||||
"Raxen",
|
||||
Criteria.DUMMY,
|
||||
colorTextComp("<red>Elixium")
|
||||
);
|
||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
Score score = obj.getScore(
|
||||
textCompToString(colorTextComp("<gold>-------------"))
|
||||
);
|
||||
score.setScore(4);
|
||||
Score score1 = obj.getScore(
|
||||
textCompToString(colorTextComp("<aqua>Name:" + player.getName()))
|
||||
);
|
||||
score1.setScore(3);
|
||||
Score score2 = obj.getScore(
|
||||
textCompToString(colorTextComp("<white>Location"))
|
||||
);
|
||||
score2.setScore(2);
|
||||
Score score3 = obj.getScore(
|
||||
textCompToString(
|
||||
colorTextComp("<gold>Coins: <gold>" + vault.getBalanceString(player))
|
||||
)
|
||||
);
|
||||
score3.setScore(1);
|
||||
Score score4 = obj.getScore(
|
||||
textCompToString(colorTextComp("<yellow>unurled.me"))
|
||||
);
|
||||
score4.setScore(0);
|
||||
player.setScoreboard(board);
|
||||
}
|
||||
|
||||
public void updateScoreboardTransaction(Player player) {
|
||||
if (player != null) {
|
||||
Objective objective = player
|
||||
.getScoreboard()
|
||||
.getObjective(DisplaySlot.SIDEBAR);
|
||||
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
|
||||
debug(main, String.valueOf(player.getScoreboard().getEntries()));
|
||||
for (String str : player.getScoreboard().getEntries()) {
|
||||
if (str.contains(player.getName())) {}
|
||||
}
|
||||
player.getScoreboard().resetScores("Coins");
|
||||
assert objective != null;
|
||||
Score score = objective.getScore(
|
||||
textCompToString(
|
||||
colorTextComp("<gold>Coins: <gold>" + vault.getBalanceString(player))
|
||||
)
|
||||
);
|
||||
score.setScore(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,17 +4,17 @@ import me.unurled.raxen.components.entity.player.storages.EnderChest;
|
|||
|
||||
public class Storage {
|
||||
|
||||
private EnderChest ec;
|
||||
private EnderChest ec;
|
||||
|
||||
public Storage(EnderChest ec) {
|
||||
this.ec = ec;
|
||||
}
|
||||
public Storage(EnderChest ec) {
|
||||
this.ec = ec;
|
||||
}
|
||||
|
||||
public EnderChest getEc() {
|
||||
return ec;
|
||||
}
|
||||
public EnderChest getEc() {
|
||||
return ec;
|
||||
}
|
||||
|
||||
public void setEc(EnderChest ec) {
|
||||
this.ec = ec;
|
||||
}
|
||||
public void setEc(EnderChest ec) {
|
||||
this.ec = ec;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,24 +5,39 @@ import lombok.Setter;
|
|||
|
||||
public class Attribute {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int maxHealth, health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck, itemLuck;
|
||||
@Getter
|
||||
@Setter
|
||||
private int maxHealth, health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck, itemLuck;
|
||||
|
||||
public Attribute(int maxHealth, int health, int itemHealth, int defense, int itemDefense, int speed, int itemSpeed, int strength, int itemStrength, int maxMana, int mana, int itemMana, int luck, int itemLuck) {
|
||||
this.maxHealth = maxHealth;
|
||||
this.health = health;
|
||||
this.itemHealth = itemHealth;
|
||||
this.defense = defense;
|
||||
this.itemDefense = itemDefense;
|
||||
this.speed = speed;
|
||||
this.itemSpeed = itemSpeed;
|
||||
this.strength = strength;
|
||||
this.itemStrength = itemStrength;
|
||||
this.maxHealth = maxMana;
|
||||
this.mana = mana;
|
||||
this.itemMana = itemMana;
|
||||
this.luck = luck;
|
||||
this.itemLuck = itemLuck;
|
||||
}
|
||||
public Attribute(
|
||||
int maxHealth,
|
||||
int health,
|
||||
int itemHealth,
|
||||
int defense,
|
||||
int itemDefense,
|
||||
int speed,
|
||||
int itemSpeed,
|
||||
int strength,
|
||||
int itemStrength,
|
||||
int maxMana,
|
||||
int mana,
|
||||
int itemMana,
|
||||
int luck,
|
||||
int itemLuck
|
||||
) {
|
||||
this.maxHealth = maxHealth;
|
||||
this.health = health;
|
||||
this.itemHealth = itemHealth;
|
||||
this.defense = defense;
|
||||
this.itemDefense = itemDefense;
|
||||
this.speed = speed;
|
||||
this.itemSpeed = itemSpeed;
|
||||
this.strength = strength;
|
||||
this.itemStrength = itemStrength;
|
||||
this.maxHealth = maxMana;
|
||||
this.mana = mana;
|
||||
this.itemMana = itemMana;
|
||||
this.luck = luck;
|
||||
this.itemLuck = itemLuck;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,55 +11,96 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
public class Attributes {
|
||||
|
||||
private static EntityNamespacedKey namespacedKey;
|
||||
private static EntityNamespacedKey namespacedKey;
|
||||
|
||||
public Attributes(Raxen main) {
|
||||
namespacedKey = new EntityNamespacedKey(main);
|
||||
}
|
||||
public Attributes(Raxen main) {
|
||||
namespacedKey = new EntityNamespacedKey(main);
|
||||
}
|
||||
|
||||
@Contract("_ -> new")
|
||||
public static @NotNull Attribute getAttribute(Player player) {
|
||||
int maxHealth, health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck, itemLuck;
|
||||
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
Entity e = player;
|
||||
defense= pm.getDefense().get(e);
|
||||
maxMana = pm.getMaxMana().get(e);
|
||||
itemDefense= pm.getItemDefense().get(e);
|
||||
health = pm.getHealth().get(e);
|
||||
itemHealth = pm.getItemHealth().get(e);
|
||||
mana = pm.getMana().get(e);
|
||||
speed = pm.getSpeed().get(e);
|
||||
itemLuck = pm.getItemLuck().get(e);
|
||||
strength = pm.getStrength().get(e);
|
||||
luck = pm.getLuck().get(e);
|
||||
maxHealth = pm.getMaxHealth().get(e);
|
||||
itemStrength = pm.getItemStrength().get(e);
|
||||
itemSpeed = pm.getItemSpeed().get(e);
|
||||
itemMana = pm.getItemMana().get(e);
|
||||
return new Attribute(maxHealth, health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck, itemLuck);
|
||||
}
|
||||
@Contract("_ -> new")
|
||||
public static @NotNull Attribute getAttribute(Player player) {
|
||||
int maxHealth, health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck, itemLuck;
|
||||
PlayerManager pm =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
Entity e = player;
|
||||
defense = pm.getDefense().get(e);
|
||||
maxMana = pm.getMaxMana().get(e);
|
||||
itemDefense = pm.getItemDefense().get(e);
|
||||
health = pm.getHealth().get(e);
|
||||
itemHealth = pm.getItemHealth().get(e);
|
||||
mana = pm.getMana().get(e);
|
||||
speed = pm.getSpeed().get(e);
|
||||
itemLuck = pm.getItemLuck().get(e);
|
||||
strength = pm.getStrength().get(e);
|
||||
luck = pm.getLuck().get(e);
|
||||
maxHealth = pm.getMaxHealth().get(e);
|
||||
itemStrength = pm.getItemStrength().get(e);
|
||||
itemSpeed = pm.getItemSpeed().get(e);
|
||||
itemMana = pm.getItemMana().get(e);
|
||||
return new Attribute(
|
||||
maxHealth,
|
||||
health,
|
||||
itemHealth,
|
||||
defense,
|
||||
itemDefense,
|
||||
speed,
|
||||
itemSpeed,
|
||||
strength,
|
||||
itemStrength,
|
||||
maxMana,
|
||||
mana,
|
||||
itemMana,
|
||||
luck,
|
||||
itemLuck
|
||||
);
|
||||
}
|
||||
|
||||
public static void setAttributes(Player player, int maxHealth, int health, int itemHealth, int defense, int itemDefense, int speed, int itemSpeed, int strength, int itemStrength, int maxMana, int mana, int itemMana, int luck, int itemLuck) {
|
||||
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
Entity e = player;
|
||||
pm.getDefense().set(e, defense);
|
||||
pm.getMaxMana().set(e, maxMana);
|
||||
pm.getItemDefense().set(e, itemDefense);
|
||||
pm.getHealth().set(e, health);
|
||||
pm.getItemHealth().set(e, itemHealth);
|
||||
pm.getMana().set(e, mana);
|
||||
pm.getSpeed().set(e, speed);
|
||||
pm.getItemLuck().set(e, itemLuck);
|
||||
pm.getStrength().set(e, strength);
|
||||
pm.getLuck().set(e, luck);
|
||||
pm.getMaxHealth().set(e, maxHealth);
|
||||
pm.getItemStrength().set(e, itemStrength);
|
||||
pm.getItemSpeed().set(e, itemSpeed);
|
||||
pm.getItemMana().set(e, itemMana);
|
||||
}
|
||||
public static void setAttributes(
|
||||
Player player,
|
||||
int maxHealth,
|
||||
int health,
|
||||
int itemHealth,
|
||||
int defense,
|
||||
int itemDefense,
|
||||
int speed,
|
||||
int itemSpeed,
|
||||
int strength,
|
||||
int itemStrength,
|
||||
int maxMana,
|
||||
int mana,
|
||||
int itemMana,
|
||||
int luck,
|
||||
int itemLuck
|
||||
) {
|
||||
PlayerManager pm =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
Entity e = player;
|
||||
pm.getDefense().set(e, defense);
|
||||
pm.getMaxMana().set(e, maxMana);
|
||||
pm.getItemDefense().set(e, itemDefense);
|
||||
pm.getHealth().set(e, health);
|
||||
pm.getItemHealth().set(e, itemHealth);
|
||||
pm.getMana().set(e, mana);
|
||||
pm.getSpeed().set(e, speed);
|
||||
pm.getItemLuck().set(e, itemLuck);
|
||||
pm.getStrength().set(e, strength);
|
||||
pm.getLuck().set(e, luck);
|
||||
pm.getMaxHealth().set(e, maxHealth);
|
||||
pm.getItemStrength().set(e, itemStrength);
|
||||
pm.getItemSpeed().set(e, itemSpeed);
|
||||
pm.getItemMana().set(e, itemMana);
|
||||
}
|
||||
|
||||
public static String[] getNameList() {
|
||||
return new String[]{"Defense", "Health", "Luck", "Mana", "Speed", "Strength"};
|
||||
|
||||
}
|
||||
public static String[] getNameList() {
|
||||
return new String[] {
|
||||
"Defense",
|
||||
"Health",
|
||||
"Luck",
|
||||
"Mana",
|
||||
"Speed",
|
||||
"Strength",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,37 +1,53 @@
|
|||
package me.unurled.raxen.components.entity.player.classes;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
|
||||
public class Class {
|
||||
|
||||
@Getter
|
||||
String name;
|
||||
@Getter
|
||||
String colorName;
|
||||
@Getter
|
||||
String ID;
|
||||
@Getter
|
||||
ItemStack placeHolder;
|
||||
@Getter
|
||||
Integer max_level;
|
||||
@Getter
|
||||
String name;
|
||||
|
||||
public Class(String name, String colorName, String ID, String itemPlaceHolder, Integer max_level) {
|
||||
this.name = name;
|
||||
this.ID = ID;
|
||||
this.placeHolder = new ItemStack(Material.getMaterial(itemPlaceHolder));
|
||||
this.placeHolder.getItemMeta().displayName(colorTextComp(colorName));
|
||||
this.max_level = max_level;
|
||||
}
|
||||
@Getter
|
||||
String colorName;
|
||||
|
||||
public Class(String name, String colorName, String ID, ItemStack itemPlaceHolder, Integer max_level) {
|
||||
this.name = name;
|
||||
this.ID = ID;
|
||||
this.placeHolder = itemPlaceHolder;
|
||||
this.placeHolder.getItemMeta().displayName(colorTextComp(colorName));
|
||||
this.max_level = max_level;
|
||||
}
|
||||
@Getter
|
||||
String ID;
|
||||
|
||||
@Getter
|
||||
ItemStack placeHolder;
|
||||
|
||||
@Getter
|
||||
Integer max_level;
|
||||
|
||||
public Class(
|
||||
String name,
|
||||
String colorName,
|
||||
String ID,
|
||||
String itemPlaceHolder,
|
||||
Integer max_level
|
||||
) {
|
||||
this.name = name;
|
||||
this.ID = ID;
|
||||
this.placeHolder = new ItemStack(Material.getMaterial(itemPlaceHolder));
|
||||
this.placeHolder.getItemMeta().displayName(colorTextComp(colorName));
|
||||
this.max_level = max_level;
|
||||
}
|
||||
|
||||
public Class(
|
||||
String name,
|
||||
String colorName,
|
||||
String ID,
|
||||
ItemStack itemPlaceHolder,
|
||||
Integer max_level
|
||||
) {
|
||||
this.name = name;
|
||||
this.ID = ID;
|
||||
this.placeHolder = itemPlaceHolder;
|
||||
this.placeHolder.getItemMeta().displayName(colorTextComp(colorName));
|
||||
this.max_level = max_level;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,40 +1,43 @@
|
|||
package me.unurled.raxen.components.entity.player.classes;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.player.classes.list.Assassin;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class Classes {
|
||||
|
||||
private final Raxen main;
|
||||
private final Raxen main;
|
||||
|
||||
public Classes(Raxen main) {
|
||||
this.main = main;
|
||||
register();
|
||||
}
|
||||
public Classes(Raxen main) {
|
||||
this.main = main;
|
||||
register();
|
||||
}
|
||||
|
||||
public void register() {
|
||||
registerClass(new Assassin());
|
||||
}
|
||||
public void register() {
|
||||
registerClass(new Assassin());
|
||||
}
|
||||
|
||||
public class resultClass {
|
||||
@Getter
|
||||
@Setter
|
||||
public Class clas;
|
||||
@Getter
|
||||
@Setter
|
||||
public String id;
|
||||
public resultClass(Class clas, String id) {
|
||||
this.clas = clas;
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
public class resultClass {
|
||||
|
||||
public void registerClass(Class clas) {
|
||||
debug(clas.getID());
|
||||
main.getManager().getPlayerManager().addClasses(clas, clas.getID());
|
||||
@Getter
|
||||
@Setter
|
||||
public Class clas;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public String id;
|
||||
|
||||
public resultClass(Class clas, String id) {
|
||||
this.clas = clas;
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
public void registerClass(Class clas) {
|
||||
debug(clas.getID());
|
||||
main.getManager().getPlayerManager().addClasses(clas, clas.getID());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,21 +7,33 @@ import org.bukkit.inventory.ItemStack;
|
|||
|
||||
public class Assassin extends Class {
|
||||
|
||||
String ID = "ASSASSIN";
|
||||
String name = "Assassin";
|
||||
String colorName = "<red>Assassin";
|
||||
Integer max_level = 100;
|
||||
String ID = "ASSASSIN";
|
||||
String name = "Assassin";
|
||||
String colorName = "<red>Assassin";
|
||||
Integer max_level = 100;
|
||||
|
||||
ItemStack placeHolder;
|
||||
ItemStack placeHolder;
|
||||
|
||||
public Assassin() {
|
||||
super("Assassin", "<red>Assassin", "ASSASSIN", new ItemStack(Material.AIR), 100);
|
||||
Dagger dagger = new Dagger();
|
||||
dagger.buildItem();
|
||||
placeHolder = dagger.getItem();
|
||||
}
|
||||
public Assassin() {
|
||||
super(
|
||||
"Assassin",
|
||||
"<red>Assassin",
|
||||
"ASSASSIN",
|
||||
new ItemStack(Material.AIR),
|
||||
100
|
||||
);
|
||||
Dagger dagger = new Dagger();
|
||||
dagger.buildItem();
|
||||
placeHolder = dagger.getItem();
|
||||
}
|
||||
|
||||
public Assassin(String name, String colorName, String ID, String itemPlaceHolder, Integer max_level) {
|
||||
super(name, colorName, ID, itemPlaceHolder, max_level);
|
||||
}
|
||||
public Assassin(
|
||||
String name,
|
||||
String colorName,
|
||||
String ID,
|
||||
String itemPlaceHolder,
|
||||
Integer max_level
|
||||
) {
|
||||
super(name, colorName, ID, itemPlaceHolder, max_level);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,15 @@ import org.bukkit.inventory.Inventory;
|
|||
|
||||
public class EnderChest {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||
@Getter
|
||||
@Setter
|
||||
public Inventory ec = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Ender Chest")
|
||||
);
|
||||
|
||||
public EnderChest(Inventory ec) {
|
||||
this.ec = ec;
|
||||
}
|
||||
public EnderChest(Inventory ec) {
|
||||
this.ec = ec;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,11 +6,15 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.event.inventory.InventoryType;
|
||||
|
||||
public class Inventory {
|
||||
@Getter
|
||||
@Setter
|
||||
public org.bukkit.inventory.Inventory inv = Bukkit.createInventory(null, InventoryType.PLAYER);
|
||||
|
||||
public Inventory(org.bukkit.inventory.Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
@Getter
|
||||
@Setter
|
||||
public org.bukkit.inventory.Inventory inv = Bukkit.createInventory(
|
||||
null,
|
||||
InventoryType.PLAYER
|
||||
);
|
||||
|
||||
public Inventory(org.bukkit.inventory.Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package me.unurled.raxen.components.gui;
|
||||
|
||||
import static me.unurled.raxen.utils.Items.*;
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.player.PlayerUtils;
|
||||
|
@ -17,219 +23,295 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
|||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static me.unurled.raxen.utils.Items.*;
|
||||
import static me.unurled.raxen.utils.Utils.fillGreyPane;
|
||||
import static me.unurled.raxen.utils.Utils.log;
|
||||
|
||||
public class ItemListGui implements Listener {
|
||||
|
||||
private Raxen main;
|
||||
@Getter
|
||||
private Inventory inv = Bukkit.createInventory(null, 54, Component.text("Item List"));
|
||||
private Inventory inv2 = Bukkit.createInventory(null, 54, Component.text("Item List"));
|
||||
private Inventory inv3 = Bukkit.createInventory(null, 54, Component.text("Item List"));
|
||||
private Inventory inv4 = Bukkit.createInventory(null, 54, Component.text("Item List"));
|
||||
private Inventory inv5 = Bukkit.createInventory(null, 54, Component.text("Item List"));
|
||||
private Inventory inv6 = Bukkit.createInventory(null, 54, Component.text("Item List"));
|
||||
private Inventory inv7 = Bukkit.createInventory(null, 54, Component.text("Item List"));
|
||||
private Inventory inv8 = Bukkit.createInventory(null, 54, Component.text("Item List"));
|
||||
private Inventory inv9 = Bukkit.createInventory(null, 54, Component.text("Item List"));
|
||||
private Raxen main;
|
||||
|
||||
private HashMap<String, ItemStack> itlist;
|
||||
@Getter
|
||||
private Inventory inv = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Item List")
|
||||
);
|
||||
|
||||
public ItemListGui(Raxen main) {
|
||||
this.main = main;
|
||||
this.itlist = this.main.getManager().getItemManager().getList();
|
||||
this.inv = getInventories();
|
||||
}
|
||||
private Inventory inv2 = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Item List")
|
||||
);
|
||||
private Inventory inv3 = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Item List")
|
||||
);
|
||||
private Inventory inv4 = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Item List")
|
||||
);
|
||||
private Inventory inv5 = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Item List")
|
||||
);
|
||||
private Inventory inv6 = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Item List")
|
||||
);
|
||||
private Inventory inv7 = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Item List")
|
||||
);
|
||||
private Inventory inv8 = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Item List")
|
||||
);
|
||||
private Inventory inv9 = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Item List")
|
||||
);
|
||||
|
||||
private ItemStack PREVIOUS = createItem(Material.ARROW, 1,true, false, "Previous page");
|
||||
private ItemStack NEXT = createItem(Material.ARROW, 1,true, false, "Next page");
|
||||
private ItemStack PAGE = createItem(Material.PAPER, 1,true, false, "Page");
|
||||
private ItemStack CLOSE = closeItem();
|
||||
private ItemStack GREY_PANE = greyPane();
|
||||
private HashMap<String, ItemStack> itlist;
|
||||
|
||||
public Inventory getInventories() {
|
||||
Integer page = 1;
|
||||
Integer item = -1;
|
||||
for (Map.Entry<String, ItemStack> entry : itlist.entrySet()) {
|
||||
ItemStack it = entry.getValue();
|
||||
item++;
|
||||
if(item > 44 && item < 91) {
|
||||
inv2.addItem(it);
|
||||
inv2.setItem(48, PREVIOUS);
|
||||
inv2.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||
inv2.setItem(53, CLOSE);
|
||||
inv2 = fillGreyPane(inv2);
|
||||
}
|
||||
if (item > 90 && item < 136) {
|
||||
inv3.setItem(48, PREVIOUS);
|
||||
inv3.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||
inv3.setItem(53, CLOSE);
|
||||
inv3 = fillGreyPane(inv3);
|
||||
}
|
||||
if (item > 135 && item < 181) {
|
||||
inv4.addItem(it);
|
||||
inv4.setItem(48, PREVIOUS);
|
||||
inv4.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||
inv4.setItem(53, CLOSE);
|
||||
inv4 = fillGreyPane(inv4);
|
||||
}
|
||||
if (item > 180 && item < 226) {
|
||||
inv5.addItem(it);
|
||||
inv5.setItem(48, PREVIOUS);
|
||||
inv5.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||
inv5.setItem(53, CLOSE);
|
||||
inv5 = fillGreyPane(inv5);
|
||||
}
|
||||
if (item > 225 && item < 271) {
|
||||
inv6.addItem(it);
|
||||
inv6.setItem(48, PREVIOUS);
|
||||
inv6.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||
inv6.setItem(53, CLOSE);
|
||||
inv6 = fillGreyPane(inv6);
|
||||
}
|
||||
if (item > 270 && item < 316) {
|
||||
inv7.addItem(it);
|
||||
inv7.setItem(48, PREVIOUS);
|
||||
inv7.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||
inv7.setItem(53, CLOSE);
|
||||
inv7 = fillGreyPane(inv7);
|
||||
}
|
||||
if (item > 315 && item < 361) {
|
||||
inv8.addItem(it);
|
||||
inv8.setItem(48, PREVIOUS);
|
||||
inv8.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||
inv8.setItem(53, CLOSE);
|
||||
inv8 = fillGreyPane(inv8);
|
||||
}
|
||||
if (item > 360 && item < 406) {
|
||||
inv9.addItem(it);
|
||||
inv9.setItem(48, PREVIOUS);
|
||||
inv9.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||
inv9.setItem(53, CLOSE);
|
||||
inv9 = fillGreyPane(inv9);
|
||||
}
|
||||
if (item > 405) {
|
||||
log("Too many item to render.");
|
||||
}
|
||||
else {
|
||||
inv.addItem(it);
|
||||
inv.setItem(49, PAGE);
|
||||
inv.setItem(50, NEXT);
|
||||
}
|
||||
if (item > 44) {
|
||||
inv.setItem(50, NEXT);
|
||||
if (item > 90) {
|
||||
inv2.setItem(50, NEXT);
|
||||
if (item > 135) {
|
||||
inv3.setItem(50, NEXT);
|
||||
if (item > 180) {
|
||||
inv4.setItem(50, NEXT);
|
||||
if (item > 225) {
|
||||
inv5.setItem(50, NEXT);
|
||||
if (item > 270) {
|
||||
inv6.setItem(50, NEXT);
|
||||
if (item > 315) {
|
||||
inv7.setItem(50, NEXT);
|
||||
if (item > 360) {
|
||||
inv8.setItem(50, NEXT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public ItemListGui(Raxen main) {
|
||||
this.main = main;
|
||||
this.itlist = this.main.getManager().getItemManager().getList();
|
||||
this.inv = getInventories();
|
||||
}
|
||||
|
||||
private ItemStack PREVIOUS = createItem(
|
||||
Material.ARROW,
|
||||
1,
|
||||
true,
|
||||
false,
|
||||
"Previous page"
|
||||
);
|
||||
private ItemStack NEXT = createItem(
|
||||
Material.ARROW,
|
||||
1,
|
||||
true,
|
||||
false,
|
||||
"Next page"
|
||||
);
|
||||
private ItemStack PAGE = createItem(Material.PAPER, 1, true, false, "Page");
|
||||
private ItemStack CLOSE = closeItem();
|
||||
private ItemStack GREY_PANE = greyPane();
|
||||
|
||||
public Inventory getInventories() {
|
||||
Integer page = 1;
|
||||
Integer item = -1;
|
||||
for (Map.Entry<String, ItemStack> entry : itlist.entrySet()) {
|
||||
ItemStack it = entry.getValue();
|
||||
item++;
|
||||
if (item > 44 && item < 91) {
|
||||
inv2.addItem(it);
|
||||
inv2.setItem(48, PREVIOUS);
|
||||
inv2.setItem(
|
||||
49,
|
||||
editItem(PAGE, "page" + page, 1, new ArrayList<Component>())
|
||||
);
|
||||
inv2.setItem(53, CLOSE);
|
||||
inv2 = fillGreyPane(inv2);
|
||||
}
|
||||
if (item > 90 && item < 136) {
|
||||
inv3.setItem(48, PREVIOUS);
|
||||
inv3.setItem(
|
||||
49,
|
||||
editItem(PAGE, "page" + page, 1, new ArrayList<Component>())
|
||||
);
|
||||
inv3.setItem(53, CLOSE);
|
||||
inv3 = fillGreyPane(inv3);
|
||||
}
|
||||
if (item > 135 && item < 181) {
|
||||
inv4.addItem(it);
|
||||
inv4.setItem(48, PREVIOUS);
|
||||
inv4.setItem(
|
||||
49,
|
||||
editItem(PAGE, "page" + page, 1, new ArrayList<Component>())
|
||||
);
|
||||
inv4.setItem(53, CLOSE);
|
||||
inv4 = fillGreyPane(inv4);
|
||||
}
|
||||
if (item > 180 && item < 226) {
|
||||
inv5.addItem(it);
|
||||
inv5.setItem(48, PREVIOUS);
|
||||
inv5.setItem(
|
||||
49,
|
||||
editItem(PAGE, "page" + page, 1, new ArrayList<Component>())
|
||||
);
|
||||
inv5.setItem(53, CLOSE);
|
||||
inv5 = fillGreyPane(inv5);
|
||||
}
|
||||
if (item > 225 && item < 271) {
|
||||
inv6.addItem(it);
|
||||
inv6.setItem(48, PREVIOUS);
|
||||
inv6.setItem(
|
||||
49,
|
||||
editItem(PAGE, "page" + page, 1, new ArrayList<Component>())
|
||||
);
|
||||
inv6.setItem(53, CLOSE);
|
||||
inv6 = fillGreyPane(inv6);
|
||||
}
|
||||
if (item > 270 && item < 316) {
|
||||
inv7.addItem(it);
|
||||
inv7.setItem(48, PREVIOUS);
|
||||
inv7.setItem(
|
||||
49,
|
||||
editItem(PAGE, "page" + page, 1, new ArrayList<Component>())
|
||||
);
|
||||
inv7.setItem(53, CLOSE);
|
||||
inv7 = fillGreyPane(inv7);
|
||||
}
|
||||
if (item > 315 && item < 361) {
|
||||
inv8.addItem(it);
|
||||
inv8.setItem(48, PREVIOUS);
|
||||
inv8.setItem(
|
||||
49,
|
||||
editItem(PAGE, "page" + page, 1, new ArrayList<Component>())
|
||||
);
|
||||
inv8.setItem(53, CLOSE);
|
||||
inv8 = fillGreyPane(inv8);
|
||||
}
|
||||
if (item > 360 && item < 406) {
|
||||
inv9.addItem(it);
|
||||
inv9.setItem(48, PREVIOUS);
|
||||
inv9.setItem(
|
||||
49,
|
||||
editItem(PAGE, "page" + page, 1, new ArrayList<Component>())
|
||||
);
|
||||
inv9.setItem(53, CLOSE);
|
||||
inv9 = fillGreyPane(inv9);
|
||||
}
|
||||
if (item > 405) {
|
||||
log("Too many item to render.");
|
||||
} else {
|
||||
inv.addItem(it);
|
||||
inv.setItem(49, PAGE);
|
||||
inv.setItem(50, NEXT);
|
||||
}
|
||||
if (item > 44) {
|
||||
inv.setItem(50, NEXT);
|
||||
if (item > 90) {
|
||||
inv2.setItem(50, NEXT);
|
||||
if (item > 135) {
|
||||
inv3.setItem(50, NEXT);
|
||||
if (item > 180) {
|
||||
inv4.setItem(50, NEXT);
|
||||
if (item > 225) {
|
||||
inv5.setItem(50, NEXT);
|
||||
if (item > 270) {
|
||||
inv6.setItem(50, NEXT);
|
||||
if (item > 315) {
|
||||
inv7.setItem(50, NEXT);
|
||||
if (item > 360) {
|
||||
inv8.setItem(50, NEXT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
page++;
|
||||
inv.setItem(53, CLOSE);
|
||||
inv = fillGreyPane(inv);
|
||||
}
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
page++;
|
||||
inv.setItem(53, CLOSE);
|
||||
inv = fillGreyPane(inv);
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void clickInventory(InventoryClickEvent e) {
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
Inventory einv = e.getClickedInventory();
|
||||
if (einv == inv || einv == inv2 || einv == inv3 ||
|
||||
einv == inv4 || einv == inv5 || einv == inv6 ||
|
||||
einv == inv7 || einv == inv8 || einv == inv9) {
|
||||
if(e.getCurrentItem() != null && e.getCurrentItem().getType() != Material.AIR) {
|
||||
Integer slot = e.getSlot();
|
||||
ItemStack clicked;
|
||||
if (slot ==48) {
|
||||
//previous
|
||||
if (e.getCurrentItem() != GREY_PANE) {
|
||||
ItemStack pagee = einv.getItem(49);
|
||||
String name = ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&',Utils.textCompToString(pagee.displayName())));
|
||||
Integer page = Integer.parseInt(name.toString().replace("page", ""));
|
||||
switch(page) {
|
||||
case 2:
|
||||
player.openInventory(inv);
|
||||
case 3:
|
||||
player.openInventory(inv2);
|
||||
case 4:
|
||||
player.openInventory(inv3);
|
||||
case 5:
|
||||
player.openInventory(inv4);
|
||||
case 6:
|
||||
player.openInventory(inv5);
|
||||
case 7:
|
||||
player.openInventory(inv6);
|
||||
case 8:
|
||||
player.openInventory(inv7);
|
||||
case 9:
|
||||
player.openInventory(inv8);
|
||||
}
|
||||
}
|
||||
} else if (slot == 49) {
|
||||
//page
|
||||
return;
|
||||
} else if (slot == 50) {
|
||||
//next
|
||||
ItemStack pagee = einv.getItem(49);
|
||||
if (pagee != null) {
|
||||
String name = ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&',Utils.textCompToString(pagee.displayName())));
|
||||
name = name.replace("[", "");
|
||||
name = name.replace("]", "");
|
||||
log(name);
|
||||
Integer page = Integer.parseInt(name.replace("page", ""));
|
||||
switch (page) {
|
||||
case 1:
|
||||
player.openInventory(inv2);
|
||||
case 2:
|
||||
player.openInventory(inv3);
|
||||
case 3:
|
||||
player.openInventory(inv4);
|
||||
case 4:
|
||||
player.openInventory(inv5);
|
||||
case 5:
|
||||
player.openInventory(inv6);
|
||||
case 6:
|
||||
player.openInventory(inv7);
|
||||
case 7:
|
||||
player.openInventory(inv8);
|
||||
case 8:
|
||||
player.openInventory(inv9);
|
||||
}
|
||||
}
|
||||
} else if (slot == 53) {
|
||||
//close
|
||||
player.closeInventory();
|
||||
} else {
|
||||
//if (player.getInventory().firstEmpty() == -1) {
|
||||
//add to stash
|
||||
//}
|
||||
player.getInventory().addItem(e.getCurrentItem());
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
}
|
||||
@EventHandler
|
||||
public void clickInventory(InventoryClickEvent e) {
|
||||
Player player = (Player) e.getWhoClicked();
|
||||
Inventory einv = e.getClickedInventory();
|
||||
if (
|
||||
einv == inv ||
|
||||
einv == inv2 ||
|
||||
einv == inv3 ||
|
||||
einv == inv4 ||
|
||||
einv == inv5 ||
|
||||
einv == inv6 ||
|
||||
einv == inv7 ||
|
||||
einv == inv8 ||
|
||||
einv == inv9
|
||||
) {
|
||||
if (
|
||||
e.getCurrentItem() != null &&
|
||||
e.getCurrentItem().getType() != Material.AIR
|
||||
) {
|
||||
Integer slot = e.getSlot();
|
||||
ItemStack clicked;
|
||||
if (slot == 48) {
|
||||
//previous
|
||||
if (e.getCurrentItem() != GREY_PANE) {
|
||||
ItemStack pagee = einv.getItem(49);
|
||||
String name = textCompToString(pagee.displayName());
|
||||
int page = Integer.parseInt(name.replace("page", ""));
|
||||
switch (page) {
|
||||
case 2:
|
||||
player.openInventory(inv);
|
||||
case 3:
|
||||
player.openInventory(inv2);
|
||||
case 4:
|
||||
player.openInventory(inv3);
|
||||
case 5:
|
||||
player.openInventory(inv4);
|
||||
case 6:
|
||||
player.openInventory(inv5);
|
||||
case 7:
|
||||
player.openInventory(inv6);
|
||||
case 8:
|
||||
player.openInventory(inv7);
|
||||
case 9:
|
||||
player.openInventory(inv8);
|
||||
}
|
||||
}
|
||||
} else if (slot == 49) {
|
||||
//page
|
||||
return;
|
||||
} else if (slot == 50) {
|
||||
//next
|
||||
ItemStack pagee = einv.getItem(49);
|
||||
if (pagee != null) {
|
||||
String name = textCompToString(pagee.displayName());
|
||||
name = name.replace("[", "");
|
||||
name = name.replace("]", "");
|
||||
log(name);
|
||||
int page = Integer.parseInt(name.replace("page", ""));
|
||||
switch (page) {
|
||||
case 1:
|
||||
player.openInventory(inv2);
|
||||
case 2:
|
||||
player.openInventory(inv3);
|
||||
case 3:
|
||||
player.openInventory(inv4);
|
||||
case 4:
|
||||
player.openInventory(inv5);
|
||||
case 5:
|
||||
player.openInventory(inv6);
|
||||
case 6:
|
||||
player.openInventory(inv7);
|
||||
case 7:
|
||||
player.openInventory(inv8);
|
||||
case 8:
|
||||
player.openInventory(inv9);
|
||||
}
|
||||
}
|
||||
} else if (slot == 53) {
|
||||
//close
|
||||
player.closeInventory();
|
||||
} else {
|
||||
//if (player.getInventory().firstEmpty() == -1) {
|
||||
//add to stash
|
||||
//}
|
||||
player.getInventory().addItem(e.getCurrentItem());
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package me.unurled.raxen.components.gui;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorComp;
|
||||
import static me.unurled.raxen.utils.Utils.fillGreyPane;
|
||||
|
||||
import java.util.HashMap;
|
||||
import me.unurled.raxen.utils.Items;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -8,64 +12,68 @@ import org.bukkit.inventory.Inventory;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorComp;
|
||||
import static me.unurled.raxen.utils.Utils.fillGreyPane;
|
||||
|
||||
public class MainGui {
|
||||
|
||||
public static Inventory build(Player p) {
|
||||
Inventory inv = Bukkit.createInventory(null, 54, colorComp("<dark_grey>Raxen</dark_grey>"));
|
||||
String gui = "0,7,0,0,0,8,9,0,10," +
|
||||
"0,0,0,0,0,0,0,0,0," +
|
||||
"0,0,0,0,0,0,0,0,0," +
|
||||
"0,2,3,0,0,0,0,4,0," +
|
||||
"0,0,0,0,1,0,0,0,0," +
|
||||
"0,0,0,0,0,0,0,0,0";
|
||||
// 1 player Head
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta headm = (SkullMeta) head.getItemMeta();
|
||||
headm.setOwningPlayer(p.getPlayer());
|
||||
headm.displayName(colorComp("<green></green>"));
|
||||
// 2 bank
|
||||
ItemStack bank = new ItemStack(Material.GOLD_INGOT);
|
||||
// 3 ah
|
||||
ItemStack ah = new ItemStack(Material.GOLD_INGOT);
|
||||
// 4 skill tree
|
||||
ItemStack sk_tree = new ItemStack(Material.OAK_SAPLING);
|
||||
// 7 teleport
|
||||
ItemStack tp = new ItemStack(Material.ENDER_PEARL);
|
||||
// 8 select character
|
||||
ItemStack sel_char = new ItemStack(Material.SNOWBALL);
|
||||
// 9 Settings
|
||||
ItemStack sett = new ItemStack(Material.MAGMA_CREAM);
|
||||
// 10 barrier block close
|
||||
public static Inventory build(Player p) {
|
||||
Inventory inv = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
colorComp("<dark_grey>Raxen</dark_grey>")
|
||||
);
|
||||
String gui =
|
||||
"0,7,0,0,0,8,9,0,10," +
|
||||
"0,0,0,0,0,0,0,0,0," +
|
||||
"0,0,0,0,0,0,0,0,0," +
|
||||
"0,2,3,0,0,0,0,4,0," +
|
||||
"0,0,0,0,1,0,0,0,0," +
|
||||
"0,0,0,0,0,0,0,0,0";
|
||||
// 1 player Head
|
||||
ItemStack head = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta headm = (SkullMeta) head.getItemMeta();
|
||||
headm.setOwningPlayer(p.getPlayer());
|
||||
headm.displayName(colorComp("<green></green>"));
|
||||
// 2 bank
|
||||
ItemStack bank = new ItemStack(Material.GOLD_INGOT);
|
||||
// 3 ah
|
||||
ItemStack ah = new ItemStack(Material.GOLD_INGOT);
|
||||
// 4 skill tree
|
||||
ItemStack sk_tree = new ItemStack(Material.OAK_SAPLING);
|
||||
// 7 teleport
|
||||
ItemStack tp = new ItemStack(Material.ENDER_PEARL);
|
||||
// 8 select character
|
||||
ItemStack sel_char = new ItemStack(Material.SNOWBALL);
|
||||
// 9 Settings
|
||||
ItemStack sett = new ItemStack(Material.MAGMA_CREAM);
|
||||
// 10 barrier block close
|
||||
|
||||
HashMap<String, ItemStack> list = new HashMap<>();
|
||||
list.put("1", head);
|
||||
list.put("2", bank);
|
||||
list.put("3",ah);
|
||||
list.put("4", sk_tree);
|
||||
list.put("7", tp);
|
||||
list.put("8", sel_char);
|
||||
list.put("9", sett);
|
||||
list.put("10", Items.closeItem());
|
||||
Inventory inventory = stringToGui(inv, gui,list);
|
||||
inventory = fillGreyPane(inventory);
|
||||
return inventory;
|
||||
}
|
||||
HashMap<String, ItemStack> list = new HashMap<>();
|
||||
list.put("1", head);
|
||||
list.put("2", bank);
|
||||
list.put("3", ah);
|
||||
list.put("4", sk_tree);
|
||||
list.put("7", tp);
|
||||
list.put("8", sel_char);
|
||||
list.put("9", sett);
|
||||
list.put("10", Items.closeItem());
|
||||
Inventory inventory = stringToGui(inv, gui, list);
|
||||
inventory = fillGreyPane(inventory);
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public static Inventory stringToGui(Inventory inv, String stt, HashMap<String, ItemStack> it) {
|
||||
String[] s = stt.split(",");
|
||||
if (s.length != inv.getContents().length) {
|
||||
return inv;
|
||||
}
|
||||
Integer i = 0;
|
||||
for (String st : s) {
|
||||
inv.setItem(i, it.get(st));
|
||||
i++;
|
||||
}
|
||||
return inv;
|
||||
public static Inventory stringToGui(
|
||||
Inventory inv,
|
||||
String stt,
|
||||
HashMap<String, ItemStack> it
|
||||
) {
|
||||
String[] s = stt.split(",");
|
||||
if (s.length != inv.getContents().length) {
|
||||
return inv;
|
||||
}
|
||||
Integer i = 0;
|
||||
for (String st : s) {
|
||||
inv.setItem(i, it.get(st));
|
||||
i++;
|
||||
}
|
||||
return inv;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,21 @@ package me.unurled.raxen.components.items;
|
|||
import lombok.Getter;
|
||||
|
||||
public class Attributes {
|
||||
@Getter
|
||||
Integer health, speed, defense, strength;
|
||||
|
||||
public Attributes(Integer health, Integer defense, Integer speed, Integer strength, Integer mana, Integer luck) {
|
||||
this.health = health;
|
||||
this.defense = defense;
|
||||
this.speed = speed;
|
||||
this.strength = strength;
|
||||
}
|
||||
@Getter
|
||||
Integer health, speed, defense, strength;
|
||||
|
||||
public Attributes(
|
||||
Integer health,
|
||||
Integer defense,
|
||||
Integer speed,
|
||||
Integer strength,
|
||||
Integer mana,
|
||||
Integer luck
|
||||
) {
|
||||
this.health = health;
|
||||
this.defense = defense;
|
||||
this.speed = speed;
|
||||
this.strength = strength;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
package me.unurled.raxen.components.items;
|
||||
|
||||
public class CustomModelData {
|
||||
}
|
||||
public class CustomModelData {}
|
||||
|
|
|
@ -2,14 +2,13 @@ package me.unurled.raxen.components.items;
|
|||
|
||||
public class NBT {
|
||||
|
||||
public static String HEALTH = "HEALTH";
|
||||
public static String SPEED = "SPEED";
|
||||
public static String STRENGTH = "STRENGTH";
|
||||
public static String DEFENSE = "DEFENSE";
|
||||
public static String LUCK = "LUCK";
|
||||
public static String MANA = "MANA";
|
||||
public static String ID = "ID";
|
||||
public static String CUSTOM_ABILITY = "CUSTOM_ABILITY";
|
||||
public static String DROP_RATE = "DROP_RATE";
|
||||
|
||||
public static String HEALTH = "HEALTH";
|
||||
public static String SPEED = "SPEED";
|
||||
public static String STRENGTH = "STRENGTH";
|
||||
public static String DEFENSE = "DEFENSE";
|
||||
public static String LUCK = "LUCK";
|
||||
public static String MANA = "MANA";
|
||||
public static String ID = "ID";
|
||||
public static String CUSTOM_ABILITY = "CUSTOM_ABILITY";
|
||||
public static String DROP_RATE = "DROP_RATE";
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package me.unurled.raxen.components.items.abilities.weapon;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import me.unurled.raxen.utils.RayTrace;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
@ -9,39 +10,42 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ThrowingDagger {
|
||||
|
||||
Player player;
|
||||
ItemStack item;
|
||||
Location start;
|
||||
Player player;
|
||||
ItemStack item;
|
||||
Location start;
|
||||
|
||||
public ThrowingDagger(Player p) {
|
||||
this.player = p;
|
||||
this.item = p.getActiveItem();
|
||||
this.start = p.getLocation();
|
||||
public ThrowingDagger(Player p) {
|
||||
this.player = p;
|
||||
this.item = p.getActiveItem();
|
||||
this.start = p.getLocation();
|
||||
}
|
||||
|
||||
public void throwDagger() {
|
||||
// ability throw a dagger in the direction the player is looking, max 20 blocks
|
||||
RayTrace rayTrace = new RayTrace(
|
||||
player.getEyeLocation().toVector(),
|
||||
player.getEyeLocation().getDirection()
|
||||
);
|
||||
ArrayList<Vector> positions = rayTrace.traverse(10, 0.01);
|
||||
for (int i = 0; i < positions.size(); i++) {
|
||||
Location position = positions.get(i).toLocation(player.getWorld());
|
||||
Block block = player.getWorld().getBlockAt(position);
|
||||
|
||||
if (
|
||||
block != null &&
|
||||
block.getType() != Material.AIR &&
|
||||
rayTrace.intersects(BoundingBox.of(block), 10, 0.01)
|
||||
) {
|
||||
player.sendMessage(block.getType().toString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void throwDagger() {
|
||||
// ability throw a dagger in the direction the player is looking, max 20 blocks
|
||||
RayTrace rayTrace = new RayTrace(player.getEyeLocation().toVector(),player.getEyeLocation().getDirection());
|
||||
ArrayList<Vector> positions = rayTrace.traverse(10,0.01);
|
||||
for(int i = 0; i < positions.size();i++){
|
||||
|
||||
Location position = positions.get(i).toLocation(player.getWorld());
|
||||
Block block = player.getWorld().getBlockAt(position);
|
||||
|
||||
if(block != null && block.getType() != Material.AIR && rayTrace.intersects(BoundingBox.of(block),10,0.01)){
|
||||
player.sendMessage(block.getType().toString());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
/*for (int i = 0 ; i < 20 ; i++) {
|
||||
/*for (int i = 0 ; i < 20 ; i++) {
|
||||
// spawn an item in air
|
||||
// dispawn the last one
|
||||
// repeat
|
||||
}*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,26 +7,25 @@ import org.jetbrains.annotations.NotNull;
|
|||
|
||||
public abstract class Item {
|
||||
|
||||
@Getter
|
||||
ItemStack item;
|
||||
@Getter
|
||||
ItemStack item;
|
||||
|
||||
String NAME;
|
||||
String ID;
|
||||
String NAME;
|
||||
String ID;
|
||||
|
||||
ItemClass ITEM_CLASS;
|
||||
ItemTypes ITEM_TYPES;
|
||||
ItemClass ITEM_CLASS;
|
||||
ItemTypes ITEM_TYPES;
|
||||
|
||||
protected Item() {
|
||||
this.item = buildItem();
|
||||
}
|
||||
protected Item() {
|
||||
this.item = buildItem();
|
||||
}
|
||||
|
||||
public abstract ItemStack buildItem();
|
||||
|
||||
/**
|
||||
* need item to be set before calling this method.
|
||||
*/
|
||||
public void registerItem(@NotNull Raxen main) {
|
||||
main.getManager().getItemManager().registerItem(item);
|
||||
}
|
||||
public abstract ItemStack buildItem();
|
||||
|
||||
/**
|
||||
* need item to be set before calling this method.
|
||||
*/
|
||||
public void registerItem(@NotNull Raxen main) {
|
||||
main.getManager().getItemManager().registerItem(item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
package me.unurled.raxen.components.items.custom;
|
||||
|
||||
public enum ItemClass {
|
||||
F,
|
||||
E,
|
||||
D,
|
||||
C,
|
||||
B,
|
||||
A,
|
||||
S,
|
||||
SS,
|
||||
SSS,
|
||||
MYTHIC,
|
||||
UNIC,
|
||||
GOD,
|
||||
F,
|
||||
E,
|
||||
D,
|
||||
C,
|
||||
B,
|
||||
A,
|
||||
S,
|
||||
SS,
|
||||
SSS,
|
||||
MYTHIC,
|
||||
UNIC,
|
||||
GOD,
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package me.unurled.raxen.components.items.custom;
|
||||
|
||||
public enum ItemTypes {
|
||||
WEAPON,
|
||||
BOW,
|
||||
TOOLS,
|
||||
MEDICINE,
|
||||
ARMOR,
|
||||
BLOCKS,
|
||||
MISCELLANEOUS
|
||||
WEAPON,
|
||||
BOW,
|
||||
TOOLS,
|
||||
MEDICINE,
|
||||
ARMOR,
|
||||
BLOCKS,
|
||||
MISCELLANEOUS,
|
||||
}
|
||||
|
|
|
@ -1,26 +1,25 @@
|
|||
package me.unurled.raxen.components.items.custom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.items.custom.weapon.Dagger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class List {
|
||||
|
||||
private static Raxen main;
|
||||
private static Raxen main;
|
||||
|
||||
@Getter
|
||||
private java.util.List<Item> items;
|
||||
@Getter
|
||||
private java.util.List<Item> items;
|
||||
|
||||
public List(Raxen main) {
|
||||
this.main = main;
|
||||
this.items = new ArrayList<>();
|
||||
build();
|
||||
}
|
||||
public List(Raxen main) {
|
||||
this.main = main;
|
||||
this.items = new ArrayList<>();
|
||||
build();
|
||||
}
|
||||
|
||||
public void build() {
|
||||
// weapons
|
||||
items.add(new Dagger());
|
||||
}
|
||||
public void build() {
|
||||
// weapons
|
||||
items.add(new Dagger());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package me.unurled.raxen.components.items.custom.weapon;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.components.items.NBT;
|
||||
import me.unurled.raxen.components.items.custom.Item;
|
||||
|
@ -13,39 +17,35 @@ import org.bukkit.inventory.ItemFlag;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
|
||||
public class Dagger extends Item {
|
||||
@Getter
|
||||
ItemStack item;
|
||||
|
||||
String NAME = "Dager";
|
||||
String ID = "DAGER";
|
||||
@Getter
|
||||
ItemStack item;
|
||||
|
||||
ItemClass ITEM_CLASS = ItemClass.F;
|
||||
ItemTypes ITEM_TYPES = ItemTypes.WEAPON;
|
||||
String NAME = "Dager";
|
||||
String ID = "DAGER";
|
||||
|
||||
public ItemStack buildItem() {
|
||||
item = new ItemStack(Material.IRON_SWORD);
|
||||
ItemMeta itm = item.getItemMeta();
|
||||
itm.displayName(colorTextComp("<aqua>" + this.NAME));
|
||||
itm.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
|
||||
itm.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS);
|
||||
itm.setUnbreakable(true);
|
||||
List<Component> lore = new ArrayList<>();
|
||||
lore.add(Component.text("hallooo"));
|
||||
itm.lore(lore);
|
||||
item.setItemMeta(itm);
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
nbti.setString(NBT.ID, ID);
|
||||
nbti.setInteger(NBT.SPEED, 100);
|
||||
nbti.setInteger(NBT.STRENGTH, 50);
|
||||
nbti.setString(NBT.CUSTOM_ABILITY, "throwing_dager");
|
||||
nbti.setDouble(NBT.DROP_RATE, 50.0);
|
||||
item = nbti.getItem();
|
||||
return item;
|
||||
}
|
||||
ItemClass ITEM_CLASS = ItemClass.F;
|
||||
ItemTypes ITEM_TYPES = ItemTypes.WEAPON;
|
||||
|
||||
public ItemStack buildItem() {
|
||||
item = new ItemStack(Material.IRON_SWORD);
|
||||
ItemMeta itm = item.getItemMeta();
|
||||
itm.displayName(colorTextComp("<aqua>" + this.NAME));
|
||||
itm.addEnchant(Enchantment.PROTECTION_ENVIRONMENTAL, 1, false);
|
||||
itm.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS);
|
||||
itm.setUnbreakable(true);
|
||||
List<Component> lore = new ArrayList<>();
|
||||
lore.add(Component.text("hallooo"));
|
||||
itm.lore(lore);
|
||||
item.setItemMeta(itm);
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
nbti.setString(NBT.ID, ID);
|
||||
nbti.setInteger(NBT.SPEED, 100);
|
||||
nbti.setInteger(NBT.STRENGTH, 50);
|
||||
nbti.setString(NBT.CUSTOM_ABILITY, "throwing_dager");
|
||||
nbti.setDouble(NBT.DROP_RATE, 50.0);
|
||||
item = nbti.getItem();
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,17 +8,19 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class GUI {
|
||||
@Getter
|
||||
private static Inventory inv = Bukkit.createInventory(null, 54);
|
||||
private static PlayerManager playerManager;
|
||||
|
||||
public GUI(Raxen main) {
|
||||
this.playerManager = main.getManager().getPlayerManager();
|
||||
}
|
||||
@Getter
|
||||
private static Inventory inv = Bukkit.createInventory(null, 54);
|
||||
|
||||
public static Inventory addItems(Player player) {
|
||||
Integer luck = playerManager.getLuck().get(player);
|
||||
private static PlayerManager playerManager;
|
||||
|
||||
return inv;
|
||||
}
|
||||
public GUI(Raxen main) {
|
||||
this.playerManager = main.getManager().getPlayerManager();
|
||||
}
|
||||
|
||||
public static Inventory addItems(Player player) {
|
||||
Integer luck = playerManager.getLuck().get(player);
|
||||
|
||||
return inv;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,43 +1,42 @@
|
|||
package me.unurled.raxen.components.lootchest.loots;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import java.util.HashMap;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.items.NBT;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class CustomLoot {
|
||||
|
||||
private Raxen main;
|
||||
private Raxen main;
|
||||
|
||||
public HashMap<String, ItemStack> itlist;
|
||||
public HashMap<String, ItemStack> itlist;
|
||||
|
||||
public ItemStack item;
|
||||
public Double drop_rate;
|
||||
public LootItem lootItem;
|
||||
public String ID;
|
||||
public ItemStack item;
|
||||
public Double drop_rate;
|
||||
public LootItem lootItem;
|
||||
public String ID;
|
||||
|
||||
public LootItem getLootItem() {
|
||||
return new LootItem(registerItem(), drop_rate);
|
||||
public LootItem getLootItem() {
|
||||
return new LootItem(registerItem(), drop_rate);
|
||||
}
|
||||
|
||||
public ItemStack registerItem() {
|
||||
return itlist.get(ID);
|
||||
}
|
||||
|
||||
public Double getDrop_rate() {
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
if (nbti.hasTag(NBT.DROP_RATE)) {
|
||||
return nbti.getDouble(NBT.DROP_RATE);
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
public ItemStack registerItem() {
|
||||
return itlist.get(ID);
|
||||
}
|
||||
|
||||
public Double getDrop_rate() {
|
||||
NBTItem nbti = new NBTItem(item);
|
||||
if (nbti.hasTag(NBT.DROP_RATE)) {
|
||||
return nbti.getDouble(NBT.DROP_RATE);
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
public void tryDropLoot(Location location) {
|
||||
for (LootItem item : main.getManager().getLootManager().getLootTable()) {
|
||||
item.tryDropItem(location);
|
||||
}
|
||||
public void tryDropLoot(Location location) {
|
||||
for (LootItem item : main.getManager().getLootManager().getLootTable()) {
|
||||
item.tryDropItem(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,27 @@
|
|||
package me.unurled.raxen.components.lootchest.loots;
|
||||
|
||||
import java.util.Random;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class LootItem {
|
||||
|
||||
private ItemStack item;
|
||||
private int min = 1, max = 1;
|
||||
private double dropRate;
|
||||
private static Random randomiser = new Random();
|
||||
private ItemStack item;
|
||||
private int min = 1, max = 1;
|
||||
private double dropRate;
|
||||
private static Random randomiser = new Random();
|
||||
|
||||
public LootItem(ItemStack item, double dropRate) {
|
||||
this.item = item;
|
||||
this.dropRate = dropRate;
|
||||
}
|
||||
|
||||
public LootItem(ItemStack item, double dropRate) {
|
||||
this.item = item;
|
||||
this.dropRate = dropRate;
|
||||
}
|
||||
|
||||
public void tryDropItem(Location loc) {
|
||||
if (Math.random() * 101 > dropRate) return;
|
||||
int amount = randomiser.nextInt(max - min + 1) + min;
|
||||
if (amount == 0) return;
|
||||
ItemStack item = this.item.clone();
|
||||
item.setAmount(amount);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
public void tryDropItem(Location loc) {
|
||||
if (Math.random() * 101 > dropRate) return;
|
||||
int amount = randomiser.nextInt(max - min + 1) + min;
|
||||
if (amount == 0) return;
|
||||
ItemStack item = this.item.clone();
|
||||
item.setAmount(amount);
|
||||
loc.getWorld().dropItemNaturally(loc, item);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,11 +5,11 @@ import me.unurled.raxen.components.lootchest.loots.CustomLoot;
|
|||
|
||||
public class TestSword extends CustomLoot {
|
||||
|
||||
public TestSword(Raxen main) {
|
||||
this.itlist = main.getManager().getItemManager().getList();
|
||||
this.ID = "BEST_NEW_ITEM";
|
||||
this.drop_rate = getDrop_rate();
|
||||
this.item = registerItem();
|
||||
this.lootItem = getLootItem();
|
||||
}
|
||||
public TestSword(Raxen main) {
|
||||
this.itlist = main.getManager().getItemManager().getList();
|
||||
this.ID = "BEST_NEW_ITEM";
|
||||
this.drop_rate = getDrop_rate();
|
||||
this.item = registerItem();
|
||||
this.lootItem = getLootItem();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,24 +8,28 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||
|
||||
public class ResourcePack {
|
||||
|
||||
private Raxen main;
|
||||
private FileConfiguration config;
|
||||
private ResourcePackManager resourcePackManager;
|
||||
private Raxen main;
|
||||
private FileConfiguration config;
|
||||
private ResourcePackManager resourcePackManager;
|
||||
|
||||
public ResourcePack(Raxen main, ResourcePackManager manager) {
|
||||
this.main = main;
|
||||
this.config = main.getConfig();
|
||||
this.resourcePackManager = manager;
|
||||
}
|
||||
public ResourcePack(Raxen main, ResourcePackManager manager) {
|
||||
this.main = main;
|
||||
this.config = main.getConfig();
|
||||
this.resourcePackManager = manager;
|
||||
}
|
||||
|
||||
public void join(Player player) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(resourcePackManager.isUseRP()) {
|
||||
player.setResourcePack(config.getString("ressource_pack_url"), config.getString("resource_pack_sha1"));
|
||||
}
|
||||
}
|
||||
}.runTaskLater(main, 2L);
|
||||
public void join(Player player) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (resourcePackManager.isUseRP()) {
|
||||
player.setResourcePack(
|
||||
config.getString("ressource_pack_url"),
|
||||
config.getString("resource_pack_sha1")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
.runTaskLater(main, 2L);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,51 +1,49 @@
|
|||
package me.unurled.raxen.config;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class Config {
|
||||
private Raxen main;
|
||||
|
||||
private File configFile;
|
||||
private Raxen main;
|
||||
|
||||
@Getter
|
||||
private FileConfiguration config;
|
||||
private File configFile;
|
||||
|
||||
@Getter
|
||||
private FileConfiguration config;
|
||||
|
||||
public Config(Raxen main) {
|
||||
this.main = main;
|
||||
this.config = main.getConfig();
|
||||
this.init();
|
||||
public Config(Raxen main) {
|
||||
this.main = main;
|
||||
this.config = main.getConfig();
|
||||
this.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* init method, saves config and everything
|
||||
*/
|
||||
public void init() {
|
||||
FileConfiguration config = main.getConfig();
|
||||
File configFile = new File(main.getDataFolder() + "/config.yml");
|
||||
if (!(configFile.exists())) {
|
||||
main.saveDefaultConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* init method, saves config and everything
|
||||
*/
|
||||
public void init() {
|
||||
FileConfiguration config = main.getConfig();
|
||||
File configFile = new File(main.getDataFolder() + "/config.yml");
|
||||
if (!(configFile.exists())) {
|
||||
main.saveDefaultConfig();
|
||||
}
|
||||
FileConfiguration conf = new YamlConfiguration();
|
||||
debug(main, config.getString("version"));
|
||||
try {
|
||||
conf.load(configFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
debug(main, conf.getString("version"));
|
||||
if(!Raxen.getVersion().equals(config.getString("version"))){
|
||||
main.saveResource("config.yml", true);
|
||||
}
|
||||
FileConfiguration conf = new YamlConfiguration();
|
||||
debug(main, config.getString("version"));
|
||||
try {
|
||||
conf.load(configFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
debug(main, conf.getString("version"));
|
||||
if (!Raxen.getVersion().equals(config.getString("version"))) {
|
||||
main.saveResource("config.yml", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
package me.unurled.raxen.config;
|
||||
|
||||
import static me.unurled.raxen.utils.Items.*;
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.model.Filters;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.Attributes.Attribute;
|
||||
import me.unurled.raxen.components.entity.player.Inventories;
|
||||
|
@ -26,261 +33,344 @@ import org.bukkit.inventory.PlayerInventory;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static me.unurled.raxen.utils.Items.*;
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class PlayerConfig {
|
||||
|
||||
private static Raxen main;
|
||||
private MongoDB mongoDB;
|
||||
private MongoCollection<Document> mongoCollection;
|
||||
private static PlayerManager playerManager;
|
||||
private static StorageManager sto;
|
||||
private Attributes attributes;
|
||||
private static Raxen main;
|
||||
private MongoDB mongoDB;
|
||||
private MongoCollection<Document> mongoCollection;
|
||||
private static PlayerManager playerManager;
|
||||
private static StorageManager sto;
|
||||
private Attributes attributes;
|
||||
|
||||
public PlayerConfig(Raxen main) {
|
||||
this.main = main;
|
||||
sto = main.getManager().getStorageManager();
|
||||
this.mongoDB = main.getManager().getLibsManager().getMongoDB();
|
||||
this.mongoCollection = mongoDB.getMongoCollection();
|
||||
playerManager = main.getManager().getPlayerManager();
|
||||
this.attributes = new Attributes(main);
|
||||
public PlayerConfig(Raxen main) {
|
||||
this.main = main;
|
||||
sto = main.getManager().getStorageManager();
|
||||
this.mongoDB = main.getManager().getLibsManager().getMongoDB();
|
||||
this.mongoCollection = mongoDB.getMongoCollection();
|
||||
playerManager = main.getManager().getPlayerManager();
|
||||
this.attributes = new Attributes(main);
|
||||
}
|
||||
|
||||
/**
|
||||
* closes mongo connection
|
||||
*/
|
||||
public void close() {
|
||||
mongoDB.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* save players stuff to mongo db
|
||||
* @param player
|
||||
* @param attributes
|
||||
* @param invstr
|
||||
* @param reverse
|
||||
*/
|
||||
public void saveUsingMongoDB(
|
||||
@NotNull Player player,
|
||||
Attributes attributes,
|
||||
String invstr,
|
||||
Integer reverse
|
||||
) {
|
||||
debug(main, "Saving " + player.getName() + "'s data!");
|
||||
Document doc = new Document("uuid", player.getUniqueId().toString())
|
||||
.append("name", player.getName())
|
||||
.append("inv", invstr);
|
||||
HashMap<String, Attribute> attribute = main
|
||||
.getManager()
|
||||
.getPlayerManager()
|
||||
.getAttribute();
|
||||
for (String s : attribute.keySet()) {
|
||||
debug("saving " + s);
|
||||
doc.append(s, attribute.get(s).get(player));
|
||||
}
|
||||
if (playerManager.getRaxenPlayer(player).getStorage() != null) {
|
||||
if (playerManager.getRaxenPlayer(player).getStorage().getEc() != null) {
|
||||
debug(main, "Saving " + player.getName() + "'s storage!");
|
||||
EnderChest ec = playerManager
|
||||
.getRaxenPlayer(player)
|
||||
.getStorage()
|
||||
.getEc();
|
||||
List<String> list = new ArrayList<String>();
|
||||
reverse = 0;
|
||||
for (ItemStack it : ec.getEc()) {
|
||||
if (it != null && it.getType() != Material.AIR) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
list.add(s);
|
||||
}
|
||||
reverse += 1;
|
||||
}
|
||||
String ecstr = Items.listItemStackSerialize(list);
|
||||
doc.append("ec", ecstr);
|
||||
}
|
||||
}
|
||||
Document playerDoc = mongoCollection
|
||||
.find(Filters.eq("uuid", player.getUniqueId().toString()))
|
||||
.first();
|
||||
if (playerDoc == null) {
|
||||
mongoCollection.insertOne(doc);
|
||||
debug(main, "insert one");
|
||||
} else {
|
||||
mongoCollection.replaceOne(
|
||||
Filters.eq("uuid", player.getUniqueId().toString()),
|
||||
doc
|
||||
);
|
||||
debug(main, "replace one");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* save players stuff to yml
|
||||
* @param player
|
||||
* @param attributes
|
||||
* @param invstr
|
||||
* @param reverse
|
||||
*/
|
||||
public void saveUsingYml(
|
||||
Player player,
|
||||
Attributes attributes,
|
||||
String invstr,
|
||||
Integer reverse
|
||||
) {
|
||||
FileConfiguration config = sto.createYml(player);
|
||||
config.set("name", player.getName());
|
||||
HashMap<String, Attribute> attribute = main
|
||||
.getManager()
|
||||
.getPlayerManager()
|
||||
.getAttribute();
|
||||
for (String s : attribute.keySet()) {
|
||||
config.set(s, attribute.get(s).get(player));
|
||||
}
|
||||
config.set("inv", invstr);
|
||||
if (playerManager.getRaxenPlayer(player).getStorage() != null) {
|
||||
if (playerManager.getRaxenPlayer(player).getStorage().getEc() != null) {
|
||||
EnderChest ec = playerManager
|
||||
.getRaxenPlayer(player)
|
||||
.getStorage()
|
||||
.getEc();
|
||||
List<String> list = new ArrayList<String>();
|
||||
reverse = 0;
|
||||
for (ItemStack it : ec.getEc()) {
|
||||
reverse += 1;
|
||||
if (it != null) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
String ecstr = Items.listItemStackSerialize(list);
|
||||
config.set("ec", ecstr);
|
||||
}
|
||||
}
|
||||
try {
|
||||
config.save(
|
||||
main.getDataFolder() +
|
||||
"/playerInfo/" +
|
||||
player.getUniqueId() +
|
||||
"/" +
|
||||
"playerInfo.yml"
|
||||
);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* load player stuff from mongo db
|
||||
* @param player
|
||||
*/
|
||||
public void loadUsingMongoDB(@NotNull Player player) {
|
||||
Document playerDoc = mongoCollection
|
||||
.find(Filters.eq("uuid", player.getUniqueId().toString()))
|
||||
.first();
|
||||
if (playerDoc == null) {
|
||||
debug(main, "Intiatilising Data for Player: " + player.getName());
|
||||
playerManager.getRaxenPlayer(player).createNewAttribute();
|
||||
playerManager.getRaxenPlayer(player).createStorage();
|
||||
playerManager.getRaxenPlayer(player).createInventory();
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
return;
|
||||
}
|
||||
debug(main, "Loading " + player.getName() + "'s data!");
|
||||
attributes.setAttributes(
|
||||
player,
|
||||
playerDoc.getInteger("MAX_HEALTH"),
|
||||
playerDoc.getInteger("HEALTH"),
|
||||
playerDoc.getInteger("ITEM_HEALTH"),
|
||||
playerDoc.getInteger("DEFENSE"),
|
||||
playerDoc.getInteger("ITEM_DEFENSE"),
|
||||
playerDoc.getInteger("SPEED"),
|
||||
playerDoc.getInteger("ITEM_SPEED"),
|
||||
playerDoc.getInteger("STRENGTH"),
|
||||
playerDoc.getInteger("ITEM_STRENGTH"),
|
||||
playerDoc.getInteger("MAX_MANA"),
|
||||
playerDoc.getInteger("MANA"),
|
||||
playerDoc.getInteger("ITEM_MANA"),
|
||||
playerDoc.getInteger("LUCK"),
|
||||
playerDoc.getInteger("ITEM_LUCK")
|
||||
);
|
||||
Inventory ec = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Ender Chest")
|
||||
);
|
||||
if (playerDoc.getString("ec") != null) {
|
||||
debug(main, "Loading " + player.getName() + "'s storage.");
|
||||
ec =
|
||||
setItemsToInventory(
|
||||
mapItemStackDeserialize(playerDoc.getString("ec")),
|
||||
ec
|
||||
);
|
||||
}
|
||||
playerManager.getRaxenPlayer(player).setStorage(ec);
|
||||
PlayerInventory inv = player.getInventory();
|
||||
inv =
|
||||
setItemsToInventory(
|
||||
listItemStackDeserialize(playerDoc.getString("inv")),
|
||||
inv
|
||||
);
|
||||
player.getInventory().setContents(inv.getContents());
|
||||
player.updateInventory();
|
||||
me.unurled.raxen.components.entity.player.storages.Inventory invv =
|
||||
new me.unurled.raxen.components.entity.player.storages.Inventory(inv);
|
||||
Inventories invvv = new Inventories(invv);
|
||||
playerManager.getRaxenPlayer(player).setInventory(inv);
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* load player stuff from yml
|
||||
* @param player
|
||||
* @throws IOException
|
||||
*/
|
||||
public void loadUsingYml(Player player) throws IOException {
|
||||
FileConfiguration config = sto.createYml(player);
|
||||
attributes.setAttributes(
|
||||
player,
|
||||
config.getInt("maxHealth"),
|
||||
config.getInt("health"),
|
||||
config.getInt("itemHealth"),
|
||||
config.getInt("defense"),
|
||||
config.getInt("itemDefense"),
|
||||
config.getInt("speed"),
|
||||
config.getInt("itemSpeed"),
|
||||
config.getInt("strength"),
|
||||
config.getInt("itemStrength"),
|
||||
config.getInt("maxMana"),
|
||||
config.getInt("mana"),
|
||||
config.getInt("itemMana"),
|
||||
config.getInt("luck"),
|
||||
config.getInt("itemLuck")
|
||||
);
|
||||
Inventory ec = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Ender Chest")
|
||||
);
|
||||
if ((String) config.get("ec") != null) {
|
||||
ec =
|
||||
setItemsToInventory(
|
||||
mapItemStackDeserialize((String) config.get("ec")),
|
||||
ec
|
||||
);
|
||||
}
|
||||
EnderChest ecc = new EnderChest(ec);
|
||||
Storage storage = new Storage(ecc);
|
||||
playerManager.getRaxenPlayer(player).setStorage(ec);
|
||||
PlayerInventory inv = (PlayerInventory) Bukkit.createInventory(
|
||||
player,
|
||||
InventoryType.PLAYER
|
||||
);
|
||||
inv =
|
||||
setItemsToInventory(
|
||||
listItemStackDeserialize((String) config.getString("inv")),
|
||||
inv
|
||||
);
|
||||
player.getInventory().setContents(inv.getContents());
|
||||
player.updateInventory();
|
||||
me.unurled.raxen.components.entity.player.storages.Inventory invv =
|
||||
new me.unurled.raxen.components.entity.player.storages.Inventory(inv);
|
||||
Inventories invvv = new Inventories(invv);
|
||||
playerManager.getRaxenPlayer(player).setInventory(inv);
|
||||
}
|
||||
|
||||
/**
|
||||
* saves player stuff
|
||||
* @param player
|
||||
*/
|
||||
public void savePlayerConfig(@NotNull Player player) {
|
||||
Attributes attributes = new Attributes(main);
|
||||
PlayerInventory inv = player.getInventory();
|
||||
|
||||
List<String> listInv = new ArrayList<String>();
|
||||
Integer reverse = 0;
|
||||
for (ItemStack it : inv) {
|
||||
reverse = reverse + 1;
|
||||
if (it != null && it.getType() != Material.AIR) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
listInv.add(s);
|
||||
}
|
||||
}
|
||||
String invstr = Items.itemStackSer(inv);
|
||||
debug(main, "saving...");
|
||||
String storage = sto.getConfig().getString("storage");
|
||||
Integer finalReverse = reverse;
|
||||
String finalInvstr = invstr;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
saveUsingMongoDB(player, attributes, finalInvstr, finalReverse);
|
||||
}
|
||||
}
|
||||
.runTaskAsynchronously(main);
|
||||
debug(main, "using mongo");
|
||||
if (storage == "MYSQL" || storage == "YML") {
|
||||
String finalInvstr1 = invstr;
|
||||
Integer finalReverse1 = reverse;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
saveUsingYml(player, attributes, finalInvstr1, finalReverse1);
|
||||
}
|
||||
}
|
||||
.runTaskAsynchronously(main);
|
||||
debug(main, "using yml");
|
||||
}
|
||||
|
||||
/**
|
||||
* closes mongo connection
|
||||
*/
|
||||
public void close() {
|
||||
mongoDB.close();
|
||||
}
|
||||
debug(main, "Player: " + player.getName() + " data successfully saved!");
|
||||
}
|
||||
|
||||
/**
|
||||
* save players stuff to mongo db
|
||||
* @param player
|
||||
* @param attributes
|
||||
* @param invstr
|
||||
* @param reverse
|
||||
*/
|
||||
public void saveUsingMongoDB(@NotNull Player player, Attributes attributes, String invstr, Integer reverse) {
|
||||
debug(main, "Saving " + player.getName() + "'s data!");
|
||||
Document doc = new Document("uuid", player.getUniqueId().toString())
|
||||
.append("name", player.getName())
|
||||
.append("inv", invstr);
|
||||
HashMap<String, Attribute> attribute = main.getManager().getPlayerManager().getAttribute();
|
||||
for (String s : attribute.keySet()) {
|
||||
debug("saving " + s);
|
||||
doc.append(s, attribute.get(s).get(player));
|
||||
/**
|
||||
* load player stuff
|
||||
* @param player
|
||||
*/
|
||||
public void loadPlayerConfig(Player player) {
|
||||
String st = StorageManager.getConfig().getString("storage");
|
||||
String value = "";
|
||||
if (st.equals("MONGODB")) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadUsingMongoDB(player);
|
||||
}
|
||||
if (playerManager.getRaxenPlayer(player).getStorage() != null) {
|
||||
if(playerManager.getRaxenPlayer(player).getStorage().getEc() != null) {
|
||||
debug(main, "Saving " + player.getName() + "'s storage!");
|
||||
EnderChest ec = playerManager.getRaxenPlayer(player).getStorage().getEc();
|
||||
List<String> list = new ArrayList<String>();
|
||||
reverse = 0;
|
||||
for(ItemStack it : ec.getEc()) {
|
||||
if(it != null && it.getType() != Material.AIR) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
list.add(s);
|
||||
}
|
||||
reverse += 1;
|
||||
}
|
||||
String ecstr = Items.listItemStackSerialize(list);
|
||||
doc.append("ec", ecstr);
|
||||
}
|
||||
}
|
||||
Document playerDoc = mongoCollection.find(Filters.eq("uuid", player.getUniqueId().toString())).first();
|
||||
if(playerDoc == null) {
|
||||
mongoCollection.insertOne(doc);
|
||||
debug(main, "insert one");
|
||||
}
|
||||
else {
|
||||
mongoCollection.replaceOne(Filters.eq("uuid", player.getUniqueId().toString()), doc);
|
||||
debug(main, "replace one");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* save players stuff to yml
|
||||
* @param player
|
||||
* @param attributes
|
||||
* @param invstr
|
||||
* @param reverse
|
||||
*/
|
||||
public void saveUsingYml(Player player, Attributes attributes, String invstr, Integer reverse) {
|
||||
FileConfiguration config = sto.createYml(player);
|
||||
config.set("name", player.getName());
|
||||
HashMap<String, Attribute> attribute = main.getManager().getPlayerManager().getAttribute();
|
||||
for (String s : attribute.keySet()) {
|
||||
config.set(s, attribute.get(s).get(player));
|
||||
}
|
||||
config.set("inv", invstr);
|
||||
if (playerManager.getRaxenPlayer(player).getStorage() != null) {
|
||||
if(playerManager.getRaxenPlayer(player).getStorage().getEc() != null) {
|
||||
EnderChest ec = playerManager.getRaxenPlayer(player).getStorage().getEc();
|
||||
List<String> list = new ArrayList<String>();
|
||||
reverse = 0;
|
||||
for(ItemStack it : ec.getEc()) {
|
||||
reverse += 1;
|
||||
if(it != null) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
String ecstr = Items.listItemStackSerialize(list);
|
||||
config.set("ec", ecstr);
|
||||
}
|
||||
}
|
||||
try {
|
||||
config.save(main.getDataFolder() + "/playerInfo/" + player.getUniqueId() + "/" + "playerInfo.yml");
|
||||
} catch (IOException e) {
|
||||
}
|
||||
.runTaskAsynchronously(main);
|
||||
value = "mongodb";
|
||||
} else {
|
||||
value = "yml";
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
loadUsingYml(player);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
.runTaskAsynchronously(main);
|
||||
}
|
||||
|
||||
/**
|
||||
* load player stuff from mongo db
|
||||
* @param player
|
||||
*/
|
||||
public void loadUsingMongoDB(@NotNull Player player) {
|
||||
Document playerDoc = mongoCollection.find(Filters.eq("uuid", player.getUniqueId().toString())).first();
|
||||
if(playerDoc == null) {
|
||||
debug(main, "Intiatilising Data for Player: " + player.getName());
|
||||
playerManager.getRaxenPlayer(player).createNewAttribute();
|
||||
playerManager.getRaxenPlayer(player).createStorage();
|
||||
playerManager.getRaxenPlayer(player).createInventory();
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
return;
|
||||
}
|
||||
debug(main, "Loading " + player.getName() + "'s data!");
|
||||
attributes.setAttributes(player, playerDoc.getInteger("MAX_HEALTH"), playerDoc.getInteger("HEALTH"), playerDoc.getInteger("ITEM_HEALTH"),
|
||||
playerDoc.getInteger("DEFENSE"), playerDoc.getInteger("ITEM_DEFENSE"),
|
||||
playerDoc.getInteger("SPEED"), playerDoc.getInteger("ITEM_SPEED"),
|
||||
playerDoc.getInteger("STRENGTH"), playerDoc.getInteger("ITEM_STRENGTH"),
|
||||
playerDoc.getInteger("MAX_MANA"), playerDoc.getInteger("MANA"), playerDoc.getInteger("ITEM_MANA"),
|
||||
playerDoc.getInteger("LUCK"), playerDoc.getInteger("ITEM_LUCK"));
|
||||
Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||
if(playerDoc.getString("ec") != null) {
|
||||
debug(main, "Loading " + player.getName() + "'s storage.");
|
||||
ec = setItemsToInventory(mapItemStackDeserialize(playerDoc.getString("ec")), ec);
|
||||
}
|
||||
playerManager.getRaxenPlayer(player).setStorage(ec);
|
||||
PlayerInventory inv = player.getInventory();
|
||||
inv = setItemsToInventory(listItemStackDeserialize(playerDoc.getString("inv")), inv);
|
||||
player.getInventory().setContents(inv.getContents());
|
||||
player.updateInventory();
|
||||
me.unurled.raxen.components.entity.player.storages.Inventory invv = new me.unurled.raxen.components.entity.player.storages.Inventory(inv);
|
||||
Inventories invvv = new Inventories(invv);
|
||||
playerManager.getRaxenPlayer(player).setInventory(inv);
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
}
|
||||
|
||||
/**
|
||||
* load player stuff from yml
|
||||
* @param player
|
||||
* @throws IOException
|
||||
*/
|
||||
public void loadUsingYml(Player player) throws IOException {
|
||||
FileConfiguration config = sto.createYml(player);
|
||||
attributes.setAttributes(player, config.getInt("maxHealth"), config.getInt("health"), config.getInt("itemHealth"),
|
||||
config.getInt("defense"), config.getInt("itemDefense"),
|
||||
config.getInt("speed"), config.getInt("itemSpeed"),
|
||||
config.getInt("strength"), config.getInt("itemStrength"),
|
||||
config.getInt("maxMana"), config.getInt("mana"), config.getInt("itemMana"),
|
||||
config.getInt("luck"), config.getInt("itemLuck"));
|
||||
Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||
if((String) config.get("ec") != null) {
|
||||
ec = setItemsToInventory(mapItemStackDeserialize((String) config.get("ec")), ec);
|
||||
}
|
||||
EnderChest ecc = new EnderChest(ec);
|
||||
Storage storage = new Storage(ecc);
|
||||
playerManager.getRaxenPlayer(player).setStorage(ec);
|
||||
PlayerInventory inv = (PlayerInventory) Bukkit.createInventory(player, InventoryType.PLAYER);
|
||||
inv = setItemsToInventory(listItemStackDeserialize((String) config.getString("inv")), inv);
|
||||
player.getInventory().setContents(inv.getContents());
|
||||
player.updateInventory();
|
||||
me.unurled.raxen.components.entity.player.storages.Inventory invv = new me.unurled.raxen.components.entity.player.storages.Inventory(inv);
|
||||
Inventories invvv = new Inventories(invv);
|
||||
playerManager.getRaxenPlayer(player).setInventory(inv);
|
||||
}
|
||||
|
||||
/**
|
||||
* saves player stuff
|
||||
* @param player
|
||||
*/
|
||||
public void savePlayerConfig(@NotNull Player player) {
|
||||
Attributes attributes = new Attributes(main);
|
||||
PlayerInventory inv = player.getInventory();
|
||||
|
||||
List<String> listInv = new ArrayList<String>();
|
||||
Integer reverse = 0;
|
||||
for(ItemStack it : inv) {
|
||||
reverse = reverse + 1;
|
||||
if(it != null && it.getType() != Material.AIR) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
listInv.add(s);
|
||||
}
|
||||
}
|
||||
String invstr= Items.itemStackSer(inv);
|
||||
debug(main, "saving...");
|
||||
String storage = sto.getConfig().getString("storage");
|
||||
Integer finalReverse = reverse;
|
||||
String finalInvstr = invstr;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
saveUsingMongoDB(player, attributes, finalInvstr, finalReverse);
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
debug(main, "using mongo");
|
||||
if (storage == "MYSQL" || storage == "YML") {
|
||||
String finalInvstr1 = invstr;
|
||||
Integer finalReverse1 = reverse;
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
saveUsingYml(player, attributes, finalInvstr1, finalReverse1);
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
debug(main, "using yml");
|
||||
}
|
||||
|
||||
debug(main, "Player: " + player.getName() + " data successfully saved!");
|
||||
}
|
||||
|
||||
/**
|
||||
* load player stuff
|
||||
* @param player
|
||||
*/
|
||||
public void loadPlayerConfig(Player player) {
|
||||
String st = StorageManager.getConfig().getString("storage");
|
||||
String value = "";
|
||||
if (st.equals("MONGODB")) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
loadUsingMongoDB(player);
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
value = "mongodb";
|
||||
} else {
|
||||
value = "yml";
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
loadUsingYml(player);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
}
|
||||
debug(main, "Player: " + player.getName() + " data successfully loaded using " + value);
|
||||
}
|
||||
|
||||
debug(
|
||||
main,
|
||||
"Player: " + player.getName() + " data successfully loaded using " + value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package me.unurled.raxen.listener.entity;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import java.util.Objects;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.other.EntityNamespacedKey;
|
||||
import me.unurled.raxen.manager.entity.PlayerManager;
|
||||
|
@ -15,116 +18,154 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
|||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class DamageEntity implements Listener {
|
||||
|
||||
private Raxen main;
|
||||
private EntityNamespacedKey entityNamespacedKey;
|
||||
private Raxen main;
|
||||
private EntityNamespacedKey entityNamespacedKey;
|
||||
|
||||
public DamageEntity(Raxen main) {
|
||||
this.main = main;
|
||||
this.entityNamespacedKey = new EntityNamespacedKey(main);
|
||||
}
|
||||
public DamageEntity(Raxen main) {
|
||||
this.main = main;
|
||||
this.entityNamespacedKey = new EntityNamespacedKey(main);
|
||||
}
|
||||
|
||||
/**
|
||||
* fired when an entity is damaged by another entity
|
||||
* calculates the damage and apply it to the entity
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void entityDamageByEntity(EntityDamageByEntityEvent e) {
|
||||
if (!(e.getEntity() instanceof LivingEntity) || !(e.getDamager() instanceof LivingEntity)) {
|
||||
debug("Not Living Entity, Some block falling shit or block entities");
|
||||
/**
|
||||
* fired when an entity is damaged by another entity
|
||||
* calculates the damage and apply it to the entity
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void entityDamageByEntity(EntityDamageByEntityEvent e) {
|
||||
if (
|
||||
!(e.getEntity() instanceof LivingEntity) ||
|
||||
!(e.getDamager() instanceof LivingEntity)
|
||||
) {
|
||||
debug("Not Living Entity, Some block falling shit or block entities");
|
||||
} else {
|
||||
e.setDamage(0);
|
||||
Integer damage = 1;
|
||||
Integer strength = 0;
|
||||
Integer itemStrength = 0;
|
||||
Integer defense = 0;
|
||||
Integer itemDefense = 0;
|
||||
Integer health = 0;
|
||||
Integer itemHealth = 0;
|
||||
Integer initDamage = 0;
|
||||
PlayerManager pm =
|
||||
(
|
||||
(Raxen) Objects.requireNonNull(
|
||||
Bukkit.getPluginManager().getPlugin("Raxen")
|
||||
)
|
||||
).getManager()
|
||||
.getPlayerManager();
|
||||
debug(
|
||||
main,
|
||||
e.getEntity().getName(),
|
||||
e.getEntity().getType().toString(),
|
||||
e.getDamager().getType().toString(),
|
||||
e.getDamager().getName()
|
||||
);
|
||||
if (e.getDamager() instanceof Player playerDamager) {
|
||||
strength = pm.getStrength().get(playerDamager);
|
||||
itemStrength = pm.getItemStrength().get(playerDamager);
|
||||
} else {
|
||||
Entity entityDamager = e.getDamager();
|
||||
PersistentDataContainer data =
|
||||
entityDamager.getPersistentDataContainer();
|
||||
if (
|
||||
data.has(entityNamespacedKey.strength, PersistentDataType.INTEGER)
|
||||
) {
|
||||
strength =
|
||||
data.get(entityNamespacedKey.strength, PersistentDataType.INTEGER);
|
||||
}
|
||||
itemStrength =
|
||||
pm.getItemStrength().getItem((LivingEntity) entityDamager);
|
||||
}
|
||||
if (e.getEntity() instanceof Player playerVictim) {
|
||||
me.unurled.raxen.components.entity.player.attributes.Attributes attributes =
|
||||
new me.unurled.raxen.components.entity.player.attributes.Attributes(
|
||||
main
|
||||
);
|
||||
defense = pm.getDefense().get(playerVictim);
|
||||
health = pm.getHealth().get(playerVictim);
|
||||
itemDefense = pm.getItemDefense().get(playerVictim);
|
||||
itemHealth = pm.getItemHealth().get(playerVictim);
|
||||
} else {
|
||||
Entity entityVictim = e.getEntity();
|
||||
PersistentDataContainer data =
|
||||
entityVictim.getPersistentDataContainer();
|
||||
if (data.has(entityNamespacedKey.defense, PersistentDataType.INTEGER)) {
|
||||
defense =
|
||||
data.get(entityNamespacedKey.defense, PersistentDataType.INTEGER);
|
||||
}
|
||||
if (data.has(entityNamespacedKey.health, PersistentDataType.INTEGER)) {
|
||||
health =
|
||||
data.get(entityNamespacedKey.health, PersistentDataType.INTEGER);
|
||||
}
|
||||
itemDefense = pm.getItemDefense().getItem((LivingEntity) entityVictim);
|
||||
itemHealth = pm.getItemHealth().getItem((LivingEntity) entityVictim);
|
||||
}
|
||||
debug(
|
||||
main,
|
||||
initDamage.toString(),
|
||||
itemDefense.toString(),
|
||||
strength.toString()
|
||||
);
|
||||
initDamage = (5 + itemStrength) * (1 + (strength / 100));
|
||||
damage = initDamage;
|
||||
defense = defense + itemDefense;
|
||||
debug(main, String.valueOf(damage));
|
||||
defense = defense / (defense + 100);
|
||||
debug(main, String.valueOf(damage));
|
||||
debug(main, String.valueOf(defense));
|
||||
Integer health_with_defense = health * (1 + (defense / 100));
|
||||
debug(main, String.valueOf(damage));
|
||||
debug(main, String.valueOf(health));
|
||||
debug(main, String.valueOf(health_with_defense));
|
||||
if (damage >= health_with_defense) {
|
||||
debug(main, "Killed entity normally.");
|
||||
e.setDamage(
|
||||
Objects
|
||||
.requireNonNull(
|
||||
e
|
||||
.getEntity()
|
||||
.getType()
|
||||
.getDefaultAttributes()
|
||||
.getAttribute(Attribute.GENERIC_MAX_HEALTH)
|
||||
)
|
||||
.getDefaultValue()
|
||||
);
|
||||
} else {
|
||||
debug(main, "Applying damage to entity.");
|
||||
if (defense == 0) {
|
||||
health = health_with_defense - damage;
|
||||
} else {
|
||||
e.setDamage(0);
|
||||
Integer damage = 1;
|
||||
Integer strength = 0;
|
||||
Integer itemStrength = 0;
|
||||
Integer defense = 0;
|
||||
Integer itemDefense = 0;
|
||||
Integer health = 0;
|
||||
Integer itemHealth = 0;
|
||||
Integer initDamage = 0;
|
||||
PlayerManager pm = ((Raxen) Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("Raxen"))).getManager().getPlayerManager();
|
||||
debug(main, e.getEntity().getName(), e.getEntity().getType().toString(), e.getDamager().getType().toString(), e.getDamager().getName());
|
||||
if (e.getDamager() instanceof Player playerDamager) {
|
||||
strength = pm.getStrength().get(playerDamager);
|
||||
itemStrength = pm.getItemStrength().get(playerDamager);
|
||||
} else {
|
||||
Entity entityDamager = e.getDamager();
|
||||
PersistentDataContainer data = entityDamager.getPersistentDataContainer();
|
||||
if (data.has(entityNamespacedKey.strength, PersistentDataType.INTEGER)) {
|
||||
strength = data.get(entityNamespacedKey.strength, PersistentDataType.INTEGER);
|
||||
}
|
||||
itemStrength = pm.getItemStrength().getItem((LivingEntity) entityDamager);
|
||||
}
|
||||
if (e.getEntity() instanceof Player playerVictim) {
|
||||
me.unurled.raxen.components.entity.player.attributes.Attributes attributes = new me.unurled.raxen.components.entity.player.attributes.Attributes(main);
|
||||
defense = pm.getDefense().get(playerVictim);
|
||||
health = pm.getHealth().get(playerVictim);
|
||||
itemDefense = pm.getItemDefense().get(playerVictim);
|
||||
itemHealth = pm.getItemHealth().get(playerVictim);
|
||||
} else {
|
||||
Entity entityVictim = e.getEntity();
|
||||
PersistentDataContainer data = entityVictim.getPersistentDataContainer();
|
||||
if (data.has(entityNamespacedKey.defense, PersistentDataType.INTEGER)) {
|
||||
defense = data.get(entityNamespacedKey.defense, PersistentDataType.INTEGER);
|
||||
}
|
||||
if (data.has(entityNamespacedKey.health, PersistentDataType.INTEGER)) {
|
||||
health = data.get(entityNamespacedKey.health, PersistentDataType.INTEGER);
|
||||
}
|
||||
itemDefense = pm.getItemDefense().getItem((LivingEntity) entityVictim);
|
||||
itemHealth = pm.getItemHealth().getItem((LivingEntity) entityVictim);
|
||||
}
|
||||
debug(main, initDamage.toString(), itemDefense.toString(), strength.toString());
|
||||
initDamage = (5+ itemStrength) * (1+ (strength/100));
|
||||
damage = initDamage;
|
||||
defense = defense + itemDefense;
|
||||
debug(main, String.valueOf(damage));
|
||||
defense = defense/(defense+100);
|
||||
debug(main, String.valueOf(damage));
|
||||
debug(main, String.valueOf(defense));
|
||||
Integer health_with_defense = health * (1+ (defense/100));
|
||||
debug(main, String.valueOf(damage));
|
||||
debug(main, String.valueOf(health));
|
||||
debug(main, String.valueOf(health_with_defense));
|
||||
if (damage >= health_with_defense) {
|
||||
debug(main, "Killed entity normally.");
|
||||
e.setDamage(Objects.requireNonNull(e.getEntity().getType().getDefaultAttributes().getAttribute(Attribute.GENERIC_MAX_HEALTH)).getDefaultValue());
|
||||
} else {
|
||||
debug(main, "Applying damage to entity.");
|
||||
if (defense == 0) {
|
||||
health = health_with_defense - damage;
|
||||
} else {
|
||||
health = health_with_defense - health - damage;
|
||||
}
|
||||
if (e.getEntity() instanceof Player playerVictim) {
|
||||
me.unurled.raxen.components.entity.player.attributes.Attributes attributes = new me.unurled.raxen.components.entity.player.attributes.Attributes(main);
|
||||
pm.getHealth().set(playerVictim, health);
|
||||
playerVictim.setHealth(health.doubleValue()/5);
|
||||
} else {
|
||||
Entity entityVictim = e.getEntity();
|
||||
pm.getHealth().set(entityVictim, health);
|
||||
}
|
||||
debug(main, health.toString());
|
||||
}
|
||||
health = health_with_defense - health - damage;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* damage made by blocks on entity
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void entityDamageByBlock(EntityDamageByBlockEvent e) {
|
||||
e.setDamage(0);
|
||||
if (e.getEntity() instanceof Player) {
|
||||
Player player = (Player) e.getEntity();
|
||||
|
||||
|
||||
if (e.getEntity() instanceof Player playerVictim) {
|
||||
me.unurled.raxen.components.entity.player.attributes.Attributes attributes =
|
||||
new me.unurled.raxen.components.entity.player.attributes.Attributes(
|
||||
main
|
||||
);
|
||||
pm.getHealth().set(playerVictim, health);
|
||||
playerVictim.setHealth(health.doubleValue() / 5);
|
||||
} else {
|
||||
Entity entityVictim = e.getEntity();
|
||||
pm.getHealth().set(entityVictim, health);
|
||||
}
|
||||
debug(main, health.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* damage made by blocks on entity
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void entityDamageByBlock(EntityDamageByBlockEvent e) {
|
||||
e.setDamage(0);
|
||||
if (e.getEntity() instanceof Player) {
|
||||
Player player = (Player) e.getEntity();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package me.unurled.raxen.listener.entity;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.other.EntityNamespacedKey;
|
||||
import me.unurled.raxen.components.entity.other.EntityUtils;
|
||||
|
@ -11,36 +13,54 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class SpawnEvent implements Listener {
|
||||
|
||||
private Raxen main;
|
||||
private EntityUtils entityUtils;
|
||||
private EntityNamespacedKey namespacedKey;
|
||||
private Raxen main;
|
||||
private EntityUtils entityUtils;
|
||||
private EntityNamespacedKey namespacedKey;
|
||||
|
||||
public SpawnEvent(Raxen main) {
|
||||
this.main = main;
|
||||
this.entityUtils = new EntityUtils(main);
|
||||
this.namespacedKey = new EntityNamespacedKey(main);
|
||||
}
|
||||
public SpawnEvent(Raxen main) {
|
||||
this.main = main;
|
||||
this.entityUtils = new EntityUtils(main);
|
||||
this.namespacedKey = new EntityNamespacedKey(main);
|
||||
}
|
||||
|
||||
/**
|
||||
* when a new entity spawns
|
||||
* adds all persistent data container
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void Spawn(EntitySpawnEvent e) {
|
||||
if (e.getEntity() instanceof Player) {
|
||||
//player stuff dont want to talk about it; already doing it in player join event
|
||||
debug(main, "Player: " + ((Player) e.getEntity()).getName());
|
||||
} else if (e.getEntity().getType() != EntityType.DROPPED_ITEM && e.getEntity().getType() != EntityType.FALLING_BLOCK) {
|
||||
debug(main, e.getEntity().getName());
|
||||
if (!e.getEntity().getPersistentDataContainer().has(namespacedKey.name, PersistentDataType.STRING)) {
|
||||
entityUtils.setNameSpacedKeys(e.getEntity(), e.getEntityType().name(), 1, 10, 0, 50, 0, 100, 0, 100, 0);
|
||||
}
|
||||
entityUtils.updateSkills((LivingEntity) e.getEntity());
|
||||
}
|
||||
/**
|
||||
* when a new entity spawns
|
||||
* adds all persistent data container
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void Spawn(EntitySpawnEvent e) {
|
||||
if (e.getEntity() instanceof Player) {
|
||||
//player stuff dont want to talk about it; already doing it in player join event
|
||||
debug(main, "Player: " + ((Player) e.getEntity()).getName());
|
||||
} else if (
|
||||
e.getEntity().getType() != EntityType.DROPPED_ITEM &&
|
||||
e.getEntity().getType() != EntityType.FALLING_BLOCK
|
||||
) {
|
||||
debug(main, e.getEntity().getName());
|
||||
if (
|
||||
!e
|
||||
.getEntity()
|
||||
.getPersistentDataContainer()
|
||||
.has(namespacedKey.name, PersistentDataType.STRING)
|
||||
) {
|
||||
entityUtils.setNameSpacedKeys(
|
||||
e.getEntity(),
|
||||
e.getEntityType().name(),
|
||||
1,
|
||||
10,
|
||||
0,
|
||||
50,
|
||||
0,
|
||||
100,
|
||||
0,
|
||||
100,
|
||||
0
|
||||
);
|
||||
}
|
||||
entityUtils.updateSkills((LivingEntity) e.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,57 +16,56 @@ import org.bukkit.inventory.ItemStack;
|
|||
|
||||
public class ArmorEvent implements Listener {
|
||||
|
||||
private Raxen main;
|
||||
private Raxen main;
|
||||
|
||||
public ArmorEvent(Raxen main) {
|
||||
this.main = main;
|
||||
public ArmorEvent(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
/**
|
||||
* when player changes armor, calculates new stats for player and setting it
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void ArmorChangeEvent(PlayerArmorChangeEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
PlayerManager pm =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
Entity entity = player;
|
||||
Attributes attributes = new Attributes(main);
|
||||
if (e.getOldItem() != null && e.getOldItem().getType() != Material.AIR) {
|
||||
ItemStack oldItem = e.getOldItem();
|
||||
NBTItem nbti = new NBTItem(oldItem);
|
||||
if (nbti.hasTag("SPEED")) {
|
||||
pm.getSpeed().remove(entity, nbti.getInteger("SPEED"));
|
||||
}
|
||||
if (nbti.hasTag("HEALTH")) {
|
||||
pm.getHealth().remove(entity, nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if (nbti.hasTag("DEFENSE")) {
|
||||
pm.getDefense().remove(entity, nbti.getInteger("DEFENSE"));
|
||||
}
|
||||
if (nbti.hasTag("STRENGTH")) {
|
||||
pm.getStrength().remove(entity, nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* when player changes armor, calculates new stats for player and setting it
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void ArmorChangeEvent(PlayerArmorChangeEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
Entity entity = player;
|
||||
Attributes attributes = new Attributes(main);
|
||||
if(e.getOldItem() != null && e.getOldItem().getType() != Material.AIR) {
|
||||
ItemStack oldItem = e.getOldItem();
|
||||
NBTItem nbti = new NBTItem(oldItem);
|
||||
if(nbti.hasTag("SPEED")) {
|
||||
pm.getSpeed().remove(entity, nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasTag("HEALTH")) {
|
||||
pm.getHealth().remove(entity, nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if(nbti.hasTag("DEFENSE")) {
|
||||
pm.getDefense().remove(entity, nbti.getInteger("DEFENSE"));
|
||||
|
||||
}
|
||||
if(nbti.hasTag("STRENGTH")) {
|
||||
pm.getStrength().remove(entity, nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
}
|
||||
if(e.getNewItem() != null && e.getNewItem().getType() != Material.AIR) {
|
||||
ItemStack newItem = e.getNewItem();
|
||||
NBTItem nbti = new NBTItem(newItem);
|
||||
if(nbti.hasTag("SPEED")) {
|
||||
pm.getSpeed().add(entity, nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasTag("HEALTH")) {
|
||||
pm.getHealth().add(entity, nbti.getInteger("HEALTH"));
|
||||
|
||||
}
|
||||
if(nbti.hasTag("DEFENSE")) {
|
||||
pm.getDefense().add(entity, nbti.getInteger("DEFENSE"));
|
||||
|
||||
}
|
||||
if(nbti.hasTag("STRENGTH")) {
|
||||
pm.getStrength().add(entity, nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
}
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
if (e.getNewItem() != null && e.getNewItem().getType() != Material.AIR) {
|
||||
ItemStack newItem = e.getNewItem();
|
||||
NBTItem nbti = new NBTItem(newItem);
|
||||
if (nbti.hasTag("SPEED")) {
|
||||
pm.getSpeed().add(entity, nbti.getInteger("SPEED"));
|
||||
}
|
||||
if (nbti.hasTag("HEALTH")) {
|
||||
pm.getHealth().add(entity, nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if (nbti.hasTag("DEFENSE")) {
|
||||
pm.getDefense().add(entity, nbti.getInteger("DEFENSE"));
|
||||
}
|
||||
if (nbti.hasTag("STRENGTH")) {
|
||||
pm.getStrength().add(entity, nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
}
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,31 +13,31 @@ import org.bukkit.inventory.Inventory;
|
|||
|
||||
public class ClickBlockEvent implements Listener {
|
||||
|
||||
private Raxen main;
|
||||
private GUI gui;
|
||||
private Raxen main;
|
||||
private GUI gui;
|
||||
|
||||
public ClickBlockEvent(Raxen main) {
|
||||
this.main = main;
|
||||
this.gui = new GUI(main);
|
||||
}
|
||||
public ClickBlockEvent(Raxen main) {
|
||||
this.main = main;
|
||||
this.gui = new GUI(main);
|
||||
}
|
||||
|
||||
/**
|
||||
* use with guis
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void ClickEvent(PlayerInteractEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
Block block = e.getClickedBlock();
|
||||
Action action = e.getAction();
|
||||
if (action.isRightClick()) {
|
||||
if (block != null) {
|
||||
if (block.getType() == Material.CHEST) {
|
||||
player.closeInventory();
|
||||
Inventory inv = gui.addItems(player);
|
||||
player.openInventory(inv);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* use with guis
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void ClickEvent(PlayerInteractEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
Block block = e.getClickedBlock();
|
||||
Action action = e.getAction();
|
||||
if (action.isRightClick()) {
|
||||
if (block != null) {
|
||||
if (block.getType() == Material.CHEST) {
|
||||
player.closeInventory();
|
||||
Inventory inv = gui.addItems(player);
|
||||
player.openInventory(inv);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package me.unurled.raxen.listener.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.log;
|
||||
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.manager.entity.PlayerManager;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
@ -9,24 +11,24 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.log;
|
||||
|
||||
public class CloseInventoryEvent implements Listener {
|
||||
|
||||
private PlayerManager playerManager;
|
||||
private PlayerManager playerManager;
|
||||
|
||||
/**
|
||||
* save enderchest/storage when player close
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void InventoryCloseEvent(InventoryCloseEvent e) {
|
||||
Player player = (Player) e.getPlayer();
|
||||
Component title = e.getView().title();
|
||||
if (title.toString().contains("Ender Chest")) {
|
||||
playerManager = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
playerManager.getRaxenPlayer(player).setStorage(e.getInventory());
|
||||
}
|
||||
log(player.getName() + " " + title.toString());
|
||||
/**
|
||||
* save enderchest/storage when player close
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void InventoryCloseEvent(InventoryCloseEvent e) {
|
||||
Player player = (Player) e.getPlayer();
|
||||
Component title = e.getView().title();
|
||||
if (title.toString().contains("Ender Chest")) {
|
||||
playerManager =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
playerManager.getRaxenPlayer(player).setStorage(e.getInventory());
|
||||
}
|
||||
log(player.getName() + " " + title.toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,12 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class InteractEvent implements Listener {
|
||||
@EventHandler
|
||||
public void PlayerInteractEvent(PlayerInteractEvent e) {
|
||||
// Player p = e.getPlayer();
|
||||
// if (e.hasItem()) {
|
||||
// ItemStack i = e.getItem();
|
||||
// }
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerInteractEvent(PlayerInteractEvent e) {
|
||||
// Player p = e.getPlayer();
|
||||
// if (e.hasItem()) {
|
||||
// ItemStack i = e.getItem();
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package me.unurled.raxen.listener.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.Attributes.Attribute;
|
||||
import me.unurled.raxen.components.entity.player.PlayerUtils;
|
||||
|
@ -15,55 +18,52 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class ItemHandEvent implements Listener {
|
||||
|
||||
private Raxen main;
|
||||
private Raxen main;
|
||||
|
||||
public ItemHandEvent(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
public ItemHandEvent(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
/**
|
||||
* when player have something in hand, change and add new stats
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void ItemHeldEvent(PlayerItemHeldEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
Entity entity = player;
|
||||
Attributes attributes = new Attributes(main);
|
||||
ItemStack oldItem = player.getInventory().getItem(e.getPreviousSlot());
|
||||
ItemStack newItem = player.getInventory().getItem(e.getNewSlot());
|
||||
if(oldItem != null && oldItem.getType() != Material.AIR) {
|
||||
NBTItem nbti = new NBTItem(oldItem);
|
||||
for (String s : Attributes.getNameList()) {
|
||||
if (nbti.hasTag(s.toUpperCase())) {
|
||||
java.lang.reflect.Method method = null;
|
||||
try {
|
||||
method = pm.getClass().getMethod("getItem" + s);
|
||||
} catch (SecurityException | NoSuchMethodException exception) {
|
||||
|
||||
}
|
||||
if (method != null) {
|
||||
me.unurled.raxen.components.entity.Attributes.Attribute attribute = null;
|
||||
try {
|
||||
attribute = (Attribute) method.invoke(pm, null);
|
||||
} catch (InvocationTargetException | IllegalAccessException exception) {
|
||||
|
||||
}
|
||||
if (attribute != null) {
|
||||
attribute.remove(player, nbti.getInteger(s.toUpperCase()));
|
||||
debug("removed " + s + " for player " + player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* when player have something in hand, change and add new stats
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void ItemHeldEvent(PlayerItemHeldEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
PlayerManager pm =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
Entity entity = player;
|
||||
Attributes attributes = new Attributes(main);
|
||||
ItemStack oldItem = player.getInventory().getItem(e.getPreviousSlot());
|
||||
ItemStack newItem = player.getInventory().getItem(e.getNewSlot());
|
||||
if (oldItem != null && oldItem.getType() != Material.AIR) {
|
||||
NBTItem nbti = new NBTItem(oldItem);
|
||||
for (String s : Attributes.getNameList()) {
|
||||
if (nbti.hasTag(s.toUpperCase())) {
|
||||
java.lang.reflect.Method method = null;
|
||||
try {
|
||||
method = pm.getClass().getMethod("getItem" + s);
|
||||
} catch (SecurityException | NoSuchMethodException exception) {}
|
||||
if (method != null) {
|
||||
me.unurled.raxen.components.entity.Attributes.Attribute attribute =
|
||||
null;
|
||||
try {
|
||||
attribute = (Attribute) method.invoke(pm, (Object) null);
|
||||
} catch (
|
||||
InvocationTargetException | IllegalAccessException ignored
|
||||
) {}
|
||||
if (attribute != null) {
|
||||
attribute.remove(player, nbti.getInteger(s.toUpperCase()));
|
||||
debug("removed " + s + " for player " + player.getName());
|
||||
}
|
||||
/*if(nbti.hasTag("SPEED")) {
|
||||
}
|
||||
}
|
||||
}
|
||||
/*if(nbti.hasTag("SPEED")) {
|
||||
pm.getItemSpeed().remove(player, nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasTag("HEALTH")) {
|
||||
|
@ -75,32 +75,31 @@ public class ItemHandEvent implements Listener {
|
|||
if(nbti.hasTag("STRENGTH")) {
|
||||
pm.getItemStrength().remove(player, nbti.getInteger("STRENGTH"));
|
||||
}*/
|
||||
}
|
||||
if(newItem != null && newItem.getType() != Material.AIR) {
|
||||
NBTItem nbti = new NBTItem(newItem);
|
||||
for (String s : Attributes.getNameList()) {
|
||||
if (nbti.hasTag(s.toUpperCase())) {
|
||||
java.lang.reflect.Method method = null;
|
||||
try {
|
||||
method = pm.getClass().getMethod("getItem" + s);
|
||||
} catch (SecurityException | NoSuchMethodException exception) {
|
||||
|
||||
}
|
||||
if (method != null) {
|
||||
me.unurled.raxen.components.entity.Attributes.Attribute attribute = null;
|
||||
try {
|
||||
attribute = (Attribute) method.invoke(pm, null);
|
||||
} catch (InvocationTargetException | IllegalAccessException exception) {
|
||||
|
||||
}
|
||||
if (attribute != null) {
|
||||
attribute.add(player, nbti.getInteger(s.toUpperCase()));
|
||||
debug("add " + s + " for player " + player.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (newItem != null && newItem.getType() != Material.AIR) {
|
||||
NBTItem nbti = new NBTItem(newItem);
|
||||
for (String s : Attributes.getNameList()) {
|
||||
if (nbti.hasTag(s.toUpperCase())) {
|
||||
java.lang.reflect.Method method = null;
|
||||
try {
|
||||
method = pm.getClass().getMethod("getItem" + s);
|
||||
} catch (SecurityException | NoSuchMethodException exception) {}
|
||||
if (method != null) {
|
||||
me.unurled.raxen.components.entity.Attributes.Attribute attribute =
|
||||
null;
|
||||
try {
|
||||
attribute = (Attribute) method.invoke(pm, (Object) null);
|
||||
} catch (
|
||||
InvocationTargetException | IllegalAccessException ignored
|
||||
) {}
|
||||
if (attribute != null) {
|
||||
attribute.add(player, nbti.getInteger(s.toUpperCase()));
|
||||
debug("add " + s + " for player " + player.getName());
|
||||
}
|
||||
/* if(nbti.hasTag("SPEED")) {
|
||||
}
|
||||
}
|
||||
}
|
||||
/* if(nbti.hasTag("SPEED")) {
|
||||
pm.getItemSpeed().add(player, nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasTag("HEALTH")) {
|
||||
|
@ -114,7 +113,7 @@ public class ItemHandEvent implements Listener {
|
|||
if(nbti.hasTag("STRENGTH")) {
|
||||
pm.getItemStrength().add(player, nbti.getInteger("STRENGTH"));
|
||||
}*/
|
||||
}
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
}
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,33 +13,33 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
|||
|
||||
public class JoinEvent implements Listener {
|
||||
|
||||
private Raxen main;
|
||||
private PlayerConfig playerConfig;
|
||||
private Scoreboard scoreboard;
|
||||
private ResourcePack resourcePack;
|
||||
private PlayerManager playerManager;
|
||||
private Raxen main;
|
||||
private PlayerConfig playerConfig;
|
||||
private Scoreboard scoreboard;
|
||||
private ResourcePack resourcePack;
|
||||
private PlayerManager playerManager;
|
||||
|
||||
public JoinEvent(Raxen main) {
|
||||
this.main = main;
|
||||
this.playerConfig = main.getPlayerConfig();
|
||||
this.scoreboard = new Scoreboard(main);
|
||||
this.resourcePack = main.getManager().getResourcePackManager().getResourcePack();
|
||||
this.playerManager = main.getManager().getPlayerManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* when player joins, load from config all stats
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void PlayerJoinEvent(PlayerJoinEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
playerConfig.loadPlayerConfig(player);
|
||||
scoreboard.createScorebord(player);
|
||||
resourcePack.join(player);
|
||||
playerManager.getRaxenPlayer(player).isRaxenPlayer(true);
|
||||
playerManager.registerActionBar(player);
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
}
|
||||
public JoinEvent(Raxen main) {
|
||||
this.main = main;
|
||||
this.playerConfig = main.getPlayerConfig();
|
||||
this.scoreboard = new Scoreboard(main);
|
||||
this.resourcePack =
|
||||
main.getManager().getResourcePackManager().getResourcePack();
|
||||
this.playerManager = main.getManager().getPlayerManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* when player joins, load from config all stats
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void PlayerJoinEvent(PlayerJoinEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
playerConfig.loadPlayerConfig(player);
|
||||
scoreboard.createScorebord(player);
|
||||
resourcePack.join(player);
|
||||
playerManager.getRaxenPlayer(player).isRaxenPlayer(true);
|
||||
playerManager.registerActionBar(player);
|
||||
PlayerUtils.updateSkills(main, player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package me.unurled.raxen.listener.player;
|
||||
|
||||
import java.io.IOException;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.player.PlayerUtils;
|
||||
import me.unurled.raxen.config.PlayerConfig;
|
||||
|
@ -9,29 +10,26 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class LeaveEvent implements Listener {
|
||||
|
||||
private final PlayerConfig playerConfig;
|
||||
private PlayerManager playerManager;
|
||||
private final PlayerConfig playerConfig;
|
||||
private PlayerManager playerManager;
|
||||
|
||||
public LeaveEvent(Raxen main) {
|
||||
this.playerConfig = main.getPlayerConfig();
|
||||
this.playerManager = main.getManager().getPlayerManager();
|
||||
public LeaveEvent(Raxen main) {
|
||||
this.playerConfig = main.getPlayerConfig();
|
||||
this.playerManager = main.getManager().getPlayerManager();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* when player leaves, saves everything
|
||||
* @param e
|
||||
* @throws IOException
|
||||
*/
|
||||
@EventHandler
|
||||
public void PlayerLeaveEvent(PlayerQuitEvent e) throws IOException {
|
||||
Player player = e.getPlayer();
|
||||
playerConfig.savePlayerConfig(player);
|
||||
playerManager.getRaxenPlayer(player).isRaxenPlayer(false);
|
||||
playerManager.unRegisterActionBar(player);
|
||||
}
|
||||
/**
|
||||
* when player leaves, saves everything
|
||||
* @param e
|
||||
* @throws IOException
|
||||
*/
|
||||
@EventHandler
|
||||
public void PlayerLeaveEvent(PlayerQuitEvent e) throws IOException {
|
||||
Player player = e.getPlayer();
|
||||
playerConfig.savePlayerConfig(player);
|
||||
playerManager.getRaxenPlayer(player).isRaxenPlayer(false);
|
||||
playerManager.unRegisterActionBar(player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package me.unurled.raxen.listener.player;
|
||||
|
||||
import static me.unurled.raxen.utils.DungeonUtils.isInRange;
|
||||
import static me.unurled.raxen.utils.DungeonUtils.whichIsInRange;
|
||||
|
||||
import me.unurled.raxen.components.dungeons.Gate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -7,21 +10,18 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityPortalEnterEvent;
|
||||
|
||||
import static me.unurled.raxen.utils.DungeonUtils.isInRange;
|
||||
import static me.unurled.raxen.utils.DungeonUtils.whichIsInRange;
|
||||
|
||||
public class PortalEvent implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void PortalE(EntityPortalEnterEvent e) {
|
||||
if (e.getEntity() instanceof Player) {
|
||||
Player p = (Player) e.getEntity();
|
||||
Location loc = e.getLocation();
|
||||
// if loc is in range
|
||||
if (isInRange(loc)) {
|
||||
Gate g = whichIsInRange(loc);
|
||||
//g.t
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void PortalE(EntityPortalEnterEvent e) {
|
||||
if (e.getEntity() instanceof Player) {
|
||||
Player p = (Player) e.getEntity();
|
||||
Location loc = e.getLocation();
|
||||
// if loc is in range
|
||||
if (isInRange(loc)) {
|
||||
Gate g = whichIsInRange(loc);
|
||||
//g.t
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package me.unurled.raxen.listener.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.msgPlayer;
|
||||
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.manager.entity.PlayerManager;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -8,14 +10,18 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.msgPlayer;
|
||||
|
||||
public class RespawnEvent implements Listener {
|
||||
@EventHandler
|
||||
public void PlayerRespawnEvent(PlayerRespawnEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
pm.getHealth().set(p, pm.getMaxHealth().get(p));
|
||||
msgPlayer(p, "<red>You have been killed. You lost something deep in you...</red>");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerRespawnEvent(PlayerRespawnEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
PlayerManager pm =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
pm.getHealth().set(p, pm.getMaxHealth().get(p));
|
||||
msgPlayer(
|
||||
p,
|
||||
"<red>You have been killed. You lost something deep in you...</red>"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package me.unurled.raxen.listener.player;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
|
@ -8,33 +10,32 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||
|
||||
public class ServerPingEvent implements Listener {
|
||||
|
||||
private Raxen main;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean loading = false;
|
||||
private Raxen main;
|
||||
|
||||
public ServerPingEvent(Raxen main) {
|
||||
this.main = main;
|
||||
this.loading = true;
|
||||
}
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean loading = false;
|
||||
|
||||
/**
|
||||
* set the motd
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void ServerListPingEvent(ServerListPingEvent e) {
|
||||
FileConfiguration config = this.main.getConfig();
|
||||
String motd = config.getString("motd");
|
||||
String motdReload = config.getString("motd-reload");
|
||||
if (loading) {
|
||||
e.motd(colorTextComp(motdReload));
|
||||
} else {
|
||||
e.motd(colorTextComp(motd));
|
||||
}
|
||||
public ServerPingEvent(Raxen main) {
|
||||
this.main = main;
|
||||
this.loading = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the motd
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void ServerListPingEvent(ServerListPingEvent e) {
|
||||
FileConfiguration config = this.main.getConfig();
|
||||
String motd = config.getString("motd");
|
||||
String motdReload = config.getString("motd-reload");
|
||||
if (loading) {
|
||||
e.motd(colorTextComp(motdReload));
|
||||
} else {
|
||||
e.motd(colorTextComp(motd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,25 +10,25 @@ import org.bukkit.event.Listener;
|
|||
|
||||
public class TransactionEvent implements Listener {
|
||||
|
||||
private Raxen main;
|
||||
private Scoreboard scoreboard;
|
||||
private Vault vault;
|
||||
private Raxen main;
|
||||
private Scoreboard scoreboard;
|
||||
private Vault vault;
|
||||
|
||||
public TransactionEvent(Raxen main) {
|
||||
this.main = main;
|
||||
this.scoreboard = new Scoreboard(main);
|
||||
this.vault = main.getManager().getLibsManager().getVault();
|
||||
}
|
||||
public TransactionEvent(Raxen main) {
|
||||
this.main = main;
|
||||
this.scoreboard = new Scoreboard(main);
|
||||
this.vault = main.getManager().getLibsManager().getVault();
|
||||
}
|
||||
|
||||
/**
|
||||
* set scoreboard when money changes
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void transaction(net.essentialsx.api.v2.events.TransactionEvent e) {
|
||||
Player player = Bukkit.getPlayer(e.getTarget().getName());
|
||||
Player source = e.getRequester().getPlayer();
|
||||
scoreboard.updateScoreboardTransaction(player);
|
||||
scoreboard.updateScoreboardTransaction(source);
|
||||
}
|
||||
/**
|
||||
* set scoreboard when money changes
|
||||
* @param e
|
||||
*/
|
||||
@EventHandler
|
||||
public void transaction(net.essentialsx.api.v2.events.TransactionEvent e) {
|
||||
Player player = Bukkit.getPlayer(e.getTarget().getName());
|
||||
Player source = e.getRequester().getPlayer();
|
||||
scoreboard.updateScoreboardTransaction(player);
|
||||
scoreboard.updateScoreboardTransaction(source);
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue