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
|
||||
|
|
|
@ -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,14 +14,15 @@ 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 static final String prefix =
|
||||
"<aqua>Rx</aqua><light_purple>></light_purple> ";
|
||||
|
||||
@Getter
|
||||
private static String version = "0.5.7";
|
||||
|
||||
private boolean loading = true;
|
||||
private final PluginManager pm = getServer().getPluginManager();
|
||||
|
||||
private static Raxen plugin;
|
||||
|
@ -29,9 +33,11 @@ public final class Raxen extends JavaPlugin {
|
|||
|
||||
private static PlayerConfig playerConfig;
|
||||
|
||||
@Getter private ProtocolManager protocolManager;
|
||||
@Getter
|
||||
private ProtocolManager protocolManager;
|
||||
|
||||
@Getter private Manager manager;
|
||||
@Getter
|
||||
private Manager manager;
|
||||
|
||||
/**
|
||||
* Method when the server launch the plugin.
|
||||
|
@ -40,7 +46,9 @@ public final class Raxen extends JavaPlugin {
|
|||
public void onEnable() {
|
||||
plugin = this;
|
||||
logger = getLogger();
|
||||
version = plugin.getDescription().getVersion();
|
||||
|
||||
version = this.getPluginMeta().getVersion();
|
||||
|
||||
manager = new Manager();
|
||||
manager.set(plugin);
|
||||
|
||||
|
@ -55,9 +63,14 @@ public final class Raxen extends JavaPlugin {
|
|||
registerCommands();
|
||||
registerEvents();
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(colorComp(prefix +"<green>Server Started Successfully!</green>"));
|
||||
Bukkit
|
||||
.getConsoleSender()
|
||||
.sendMessage(
|
||||
colorComp(prefix + "<green>Server Started Successfully!</green>")
|
||||
);
|
||||
|
||||
manager.getListenerManager().getServerPingEvent().setLoading(false);
|
||||
loading = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +79,9 @@ public final class Raxen extends JavaPlugin {
|
|||
private void registerCommands() {
|
||||
manager.getCommandManager().register();
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(colorComp(prefix +"<green>Commands Registered!</green>"));
|
||||
Bukkit
|
||||
.getConsoleSender()
|
||||
.sendMessage(colorComp(prefix + "<green>Commands Registered!</green>"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -75,7 +90,9 @@ public final class Raxen extends JavaPlugin {
|
|||
private void registerEvents() {
|
||||
manager.getListenerManager().register();
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(colorComp(prefix +"<green>Events Registered!</green>"));
|
||||
Bukkit
|
||||
.getConsoleSender()
|
||||
.sendMessage(colorComp(prefix + "<green>Events Registered!</green>"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,12 +100,18 @@ public final class Raxen extends JavaPlugin {
|
|||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (!loading) {
|
||||
manager.getListenerManager().getServerPingEvent().setLoading(true);
|
||||
Reload.kickAll();
|
||||
|
||||
playerConfig.close();
|
||||
}
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(colorComp(prefix +"<red>Server Stopped Successfully!</red>"));
|
||||
Bukkit
|
||||
.getConsoleSender()
|
||||
.sendMessage(
|
||||
colorComp(prefix + "<red>Server Stopped Successfully!</red>")
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,10 +14,6 @@ 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;
|
||||
|
@ -24,11 +23,22 @@ public class RaxenCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String msg, @NotNull String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
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."));
|
||||
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);
|
||||
|
@ -36,17 +46,49 @@ public class RaxenCommand implements TabExecutor {
|
|||
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>---------------------------------------------"));
|
||||
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>---------------------------------------------");
|
||||
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);
|
||||
msgPlayer(player, Raxen.getVersion());
|
||||
}
|
||||
case "hemlp", "?", "h" -> {
|
||||
//print help
|
||||
|
@ -54,46 +96,88 @@ public class RaxenCommand implements TabExecutor {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
log(String.valueOf(args.length));
|
||||
} else {
|
||||
switch (args.length) {
|
||||
case 0 -> {
|
||||
msgSender(sender, Raxen.getPrefix() + "<gold>Printing About Raxen...",
|
||||
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");
|
||||
"<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>---------------------------------------------"));
|
||||
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(StorageManager.getMongodb().getMongoClient().getClusterDescription().toString());
|
||||
sender.sendMessage(StorageManager.getMongodb().getMongoDatabase().getName());
|
||||
sender.sendMessage(StorageManager.getMongodb().getMongoCollection().getNamespace().toString());
|
||||
sender.sendMessage(coloredString("<gold>---------------------------------------------"));
|
||||
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...",
|
||||
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");
|
||||
"<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>---------------------------------------------"));
|
||||
sender.sendMessage(
|
||||
colorComp("<gold>---------------------------------------------")
|
||||
);
|
||||
return true;
|
||||
}
|
||||
case "hemlp", "?", "h" ->
|
||||
//print help
|
||||
case "hemlp", "?", "h" -> //print help
|
||||
debug(main, "print help");
|
||||
}
|
||||
}
|
||||
|
@ -103,22 +187,36 @@ public class RaxenCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
public void msgPl(Player player, Integer in) {
|
||||
switch(in) {
|
||||
switch (in) {
|
||||
case 0:
|
||||
msgPlayer(player, Raxen.getPrefix() + "<gold>Printing About Raxen...",
|
||||
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")
|
||||
"<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>---------------------------------------------");
|
||||
msgPlayer(
|
||||
player,
|
||||
"",
|
||||
"<gold>---------------------------------------------"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
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,13 +17,6 @@ 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 {
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,12 @@ public class CustomModelDataCommand implements TabExecutor {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!(sender instanceof Player)) {
|
||||
errorConsoleSender(sender);
|
||||
return true;
|
||||
|
@ -40,17 +45,26 @@ public class CustomModelDataCommand implements TabExecutor {
|
|||
}
|
||||
ItemStack it = p.getInventory().getItemInMainHand();
|
||||
if (args.length == 0) {
|
||||
p.sendMessage(colorComp("<gold>Usage: /custommodeldata <model-data-value> <item-name></gold>"));
|
||||
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]));
|
||||
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>"));
|
||||
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
|
||||
|
@ -59,8 +73,14 @@ public class CustomModelDataCommand implements TabExecutor {
|
|||
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>"));
|
||||
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;
|
||||
|
@ -77,13 +97,18 @@ public class CustomModelDataCommand implements TabExecutor {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
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<>();
|
||||
List<String> SUB_COMMANDS = new ArrayList<>();
|
||||
|
||||
if (!(isInt(args[0]))) {
|
||||
return Arrays.asList( "§c" + args[0]);
|
||||
return Arrays.asList("§c" + args[0]);
|
||||
}
|
||||
if (args.length == 2) {
|
||||
for (Material mat : Material.values()) {
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
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
|
||||
|
@ -18,8 +18,12 @@ public class EntitiyCommand implements TabExecutor {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -34,7 +38,12 @@ public class EntitiyCommand implements TabExecutor {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
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,10 +13,6 @@ 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;
|
||||
|
@ -27,14 +26,24 @@ public class ItemListCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String msg, @NotNull String[] args) {
|
||||
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."));
|
||||
if (!(player.hasPermission("raxen.itemlist.cmd"))) {
|
||||
msgPlayer(
|
||||
player,
|
||||
colorString(
|
||||
"<red>You'dont have the permission to execute this command."
|
||||
)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
//openGui logic
|
||||
|
@ -43,7 +52,12 @@ public class ItemListCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
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,12 +11,8 @@ 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
|
||||
|
@ -21,7 +21,12 @@ public class ItemTo64Command implements TabExecutor {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
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 {
|
||||
|
@ -42,7 +47,12 @@ public class ItemTo64Command implements TabExecutor {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
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,13 +21,6 @@ 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;
|
||||
|
@ -31,19 +30,30 @@ public class NbtCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
@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!"));
|
||||
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."));
|
||||
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 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();
|
||||
|
@ -76,7 +86,13 @@ public class NbtCommand implements TabExecutor {
|
|||
}
|
||||
// itm.lore(lore);
|
||||
// it.setItemMeta(itm);
|
||||
PlayerManager pm = ((Raxen) Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("Raxen"))).getManager().getPlayerManager();
|
||||
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"));
|
||||
|
@ -86,23 +102,38 @@ public class NbtCommand implements TabExecutor {
|
|||
}
|
||||
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>."));
|
||||
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);
|
||||
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) {
|
||||
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) {
|
||||
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")) {
|
||||
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."));
|
||||
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) {
|
||||
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,15 +24,6 @@ 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;
|
||||
|
@ -36,28 +35,57 @@ public class SpawnEntity implements TabExecutor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
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>"));
|
||||
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]));
|
||||
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);
|
||||
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
|
||||
// livingEntity.getEquipment().set
|
||||
ItemStack helmet = itemFrom64(args[11]);
|
||||
ItemStack chestplate = itemFrom64(args[12]);
|
||||
ItemStack leggins = itemFrom64(args[13]);
|
||||
|
@ -78,7 +106,11 @@ public class SpawnEntity implements TabExecutor {
|
|||
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() + ")");
|
||||
error(
|
||||
"Could not deserialize item from the command EntitySpawn (command launched by " +
|
||||
sender.getName() +
|
||||
")"
|
||||
);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
@ -94,21 +126,45 @@ public class SpawnEntity implements TabExecutor {
|
|||
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>"));
|
||||
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]));
|
||||
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);
|
||||
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
|
||||
// livingEntity.getEquipment().set
|
||||
ItemStack helmet = itemFrom64(args[11]);
|
||||
ItemStack chestplate = itemFrom64(args[12]);
|
||||
ItemStack leggins = itemFrom64(args[13]);
|
||||
|
@ -129,7 +185,11 @@ public class SpawnEntity implements TabExecutor {
|
|||
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() + ")");
|
||||
error(
|
||||
"Could not deserialize item from the command EntitySpawn (command launched by " +
|
||||
sender.getName() +
|
||||
")"
|
||||
);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
|
@ -137,7 +197,12 @@ public class SpawnEntity implements TabExecutor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
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());
|
||||
|
|
|
@ -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,21 +12,23 @@ 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) {
|
||||
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])));
|
||||
if (player.hasPermission("raxen.test.gui.cmd")) {
|
||||
player.openInventory(
|
||||
Bukkit.createInventory(null, 54, colorTextComp(args[0]))
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
log("The console can't execute this Command!");
|
||||
return true;
|
||||
}
|
||||
|
@ -30,7 +36,12 @@ public class TestGuiCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
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,12 +17,6 @@ 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;
|
||||
|
@ -31,17 +30,37 @@ public class ClassCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
@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!");
|
||||
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();
|
||||
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>"));
|
||||
inv =
|
||||
Bukkit.createInventory(
|
||||
null,
|
||||
classes.size(),
|
||||
colorTextComp("<grey>Choose your class</grey>")
|
||||
);
|
||||
}
|
||||
}
|
||||
for (Class clas : classes.values()) {
|
||||
|
@ -52,7 +71,12 @@ public class ClassCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
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,11 +14,6 @@ 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;
|
||||
|
@ -31,7 +30,12 @@ public class MainGuiCommand implements TabExecutor {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
public boolean onCommand(
|
||||
@NotNull CommandSender sender,
|
||||
@NotNull Command command,
|
||||
@NotNull String label,
|
||||
@NotNull String[] args
|
||||
) {
|
||||
if (!(sender instanceof Player)) {
|
||||
errorConsoleSender(sender);
|
||||
return true;
|
||||
|
@ -57,7 +61,12 @@ public class MainGuiCommand implements TabExecutor {
|
|||
* @return
|
||||
*/
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
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,11 +16,6 @@ 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;
|
||||
|
@ -26,9 +25,17 @@ public class SkillsCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
@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!");
|
||||
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;
|
||||
|
@ -36,22 +43,35 @@ public class SkillsCommand implements TabExecutor {
|
|||
switch (args.length) {
|
||||
case 0:
|
||||
//open gui
|
||||
player.sendMessage(colorTextComp("<red>GUI not implemented yet..").append(colorTextComp("<red>Try /skill help.")));
|
||||
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}")));
|
||||
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();
|
||||
PlayerManager pm =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
for (String s : pm.getAttribute().keySet()) {
|
||||
if (s.equalsIgnoreCase(args[0]))
|
||||
switch (args[1]) {
|
||||
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]));
|
||||
pm
|
||||
.getAttribute()
|
||||
.get(s)
|
||||
.remove(player, Integer.parseInt(args[2]));
|
||||
case "set":
|
||||
pm.getAttribute().get(s).set(player, Integer.parseInt(args[2]));
|
||||
}
|
||||
|
@ -62,7 +82,12 @@ public class SkillsCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
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,36 +14,51 @@ 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;
|
||||
|
||||
@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!");
|
||||
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();
|
||||
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();
|
||||
if (playerManager.getRaxenPlayer(player).getStorage() == null) {
|
||||
inv =
|
||||
playerManager
|
||||
.getRaxenPlayer(player)
|
||||
.createStorage()
|
||||
.getEc()
|
||||
.getEc();
|
||||
} else {
|
||||
inv = playerManager.getRaxenPlayer(player).getStorage().getEc().getEc();
|
||||
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."));
|
||||
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();
|
||||
|
@ -51,7 +69,12 @@ public class StorageCommand implements TabExecutor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
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,33 +10,38 @@ 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<>();
|
||||
@Getter
|
||||
private HashMap<String, RaxenEntity> monster = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The Type of the Dungeon
|
||||
*/
|
||||
@Getter private Types types;
|
||||
@Getter
|
||||
private Types types;
|
||||
|
||||
/**
|
||||
* Monster Types
|
||||
*/
|
||||
@Getter private MonsterType monsterType;
|
||||
@Getter
|
||||
private MonsterType monsterType;
|
||||
|
||||
@Getter private Location location;
|
||||
@Getter private Integer radius;
|
||||
@Getter
|
||||
private Location location;
|
||||
|
||||
@Getter
|
||||
private Integer radius;
|
||||
|
||||
public Dungeon(String name, Rank rank, Types types, MonsterType mType) {
|
||||
this.name = name;
|
||||
|
@ -49,7 +57,12 @@ public class Dungeon {
|
|||
*/
|
||||
public void generateGate() {
|
||||
// -281.50 36.00 187.50
|
||||
Location loc = new Location(Bukkit.getWorld("Liberty_City"), -284.0, 45.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);
|
||||
}
|
||||
|
@ -61,6 +74,5 @@ public class Dungeon {
|
|||
Raxen main = (Raxen) Bukkit.getPluginManager().getPlugin("Raxen");
|
||||
main.getManager().getWorldManager().loadWorld(name);
|
||||
monsterType.genMonster(Bukkit.getWorld(name), rank);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
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;
|
||||
|
@ -12,16 +11,13 @@ public class Gate {
|
|||
private Location loc;
|
||||
private Integer portalRadius;
|
||||
|
||||
|
||||
public Gate(String name, Location loc, Integer portalRadius) {
|
||||
this.loc = loc;
|
||||
this.portalRadius = portalRadius;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void teleport() {
|
||||
|
||||
}
|
||||
public void teleport() {}
|
||||
|
||||
public void genGate() {
|
||||
// get which side it's gonna expand with radius
|
||||
|
@ -35,7 +31,7 @@ public class Gate {
|
|||
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) {
|
||||
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);
|
||||
|
@ -59,7 +55,6 @@ public class Gate {
|
|||
*/
|
||||
}
|
||||
|
||||
|
||||
public Location getLoc() {
|
||||
return loc;
|
||||
}
|
||||
|
|
|
@ -12,5 +12,5 @@ public enum Rank {
|
|||
SSS,
|
||||
WORLD,
|
||||
UNBEATABLE,
|
||||
NOT_DEFINED
|
||||
NOT_DEFINED,
|
||||
}
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
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 {
|
||||
|
||||
|
@ -13,7 +12,6 @@ public class Type {
|
|||
public Map<String, RaxenEntity> monster = new HashMap<>();
|
||||
|
||||
public Map<String, LootItem> lootItem = new HashMap<>();
|
||||
|
||||
// public Map<String, > chest
|
||||
|
||||
}
|
||||
|
|
|
@ -16,5 +16,5 @@ public enum Types {
|
|||
CAVES,
|
||||
LABYRINTH,
|
||||
UNDERGROUND_LABYRINTH,
|
||||
FOREST_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,12 +14,10 @@ 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 {;
|
||||
|
||||
public enum type {
|
||||
;
|
||||
|
||||
private Double rate;
|
||||
public String ID;
|
||||
|
@ -30,7 +31,7 @@ public class MonsterType {
|
|||
|
||||
public static @Nullable type getTypeById(String ID) {
|
||||
for (type type : type.values()) {
|
||||
if(type.ID.equals(ID)) {
|
||||
if (type.ID.equals(ID)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
@ -73,22 +74,35 @@ public class MonsterType {
|
|||
if (per >= type.rate) {
|
||||
// spawn entity
|
||||
debug("Spawning Entity " + type.ID);
|
||||
Entity e = world.spawnEntity(new Location(world, x, y, z), EntityType.ARROW);
|
||||
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());
|
||||
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();
|
||||
.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,6 +6,7 @@ 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);
|
||||
}
|
||||
|
|
|
@ -7,8 +7,9 @@ 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),
|
||||
@Getter
|
||||
enum type {
|
||||
ELF(50.0, "ELF", Elf.class),
|
||||
WOLF(50.0, "WOLF", Wolf.class);
|
||||
|
||||
private Double rate;
|
||||
|
|
|
@ -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,9 +12,8 @@ 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) {
|
||||
|
@ -21,7 +21,8 @@ public class EnchantmentWarpper extends Enchantment {
|
|||
this.maxLevel = lvl;
|
||||
}
|
||||
|
||||
@Override @Deprecated
|
||||
@Override
|
||||
@Deprecated
|
||||
public @NotNull String getName() {
|
||||
return null;
|
||||
}
|
||||
|
@ -82,7 +83,10 @@ public class EnchantmentWarpper extends Enchantment {
|
|||
}
|
||||
|
||||
@Override
|
||||
public float getDamageIncrease(int level, @NotNull EntityCategory entityCategory) {
|
||||
public float getDamageIncrease(
|
||||
int level,
|
||||
@NotNull EntityCategory entityCategory
|
||||
) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,8 +12,6 @@ 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 {
|
||||
|
||||
/**
|
||||
|
@ -45,11 +45,30 @@ public class Attribute {
|
|||
* @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);
|
||||
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());
|
||||
debug(
|
||||
name +
|
||||
" not found in Entity: " +
|
||||
entity.getType().toString() +
|
||||
" " +
|
||||
entity.getName() +
|
||||
" " +
|
||||
entity.getUniqueId().toString()
|
||||
);
|
||||
set(entity, 0);
|
||||
return 0;
|
||||
}
|
||||
|
@ -61,7 +80,7 @@ public class Attribute {
|
|||
*/
|
||||
public Integer get(@NotNull ItemStack it) {
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
if (nbti.hasTag(name)){
|
||||
if (nbti.hasTag(name)) {
|
||||
return nbti.getInteger(name);
|
||||
}
|
||||
return 0;
|
||||
|
@ -76,27 +95,43 @@ public class Attribute {
|
|||
EntityEquipment equi = e.getEquipment();
|
||||
Integer attribute = 0;
|
||||
if (equi != null) {
|
||||
if (equi.getItemInMainHand().getType() != Material.AIR && equi.getHelmet() != 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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
if (
|
||||
equi.getBoots().getType() != Material.AIR && equi.getBoots() != null
|
||||
) {
|
||||
ItemStack item = equi.getBoots();
|
||||
attribute = attribute + get(item);
|
||||
}
|
||||
|
@ -110,7 +145,9 @@ public class Attribute {
|
|||
* @param amount the amount you want to set
|
||||
*/
|
||||
public void set(@NotNull Entity entity, @NotNull Integer amount) {
|
||||
entity.getPersistentDataContainer().set(namespacekey, PersistentDataType.INTEGER, amount);
|
||||
entity
|
||||
.getPersistentDataContainer()
|
||||
.set(namespacekey, PersistentDataType.INTEGER, amount);
|
||||
debug("set " + name + " " + amount);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,4 +8,3 @@ public class Defense extends Attribute {
|
|||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,4 +8,3 @@ public class Health extends Attribute {
|
|||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,4 +8,3 @@ public class Luck extends Attribute {
|
|||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,4 +8,3 @@ public class Mana extends Attribute {
|
|||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package me.unurled.raxen.components.entity.Attributes;
|
|||
import org.bukkit.NamespacedKey;
|
||||
|
||||
public class MaxManaBuilder {
|
||||
|
||||
private NamespacedKey namespacekey;
|
||||
private String name;
|
||||
|
||||
|
|
|
@ -8,4 +8,3 @@ public class Strength extends Attribute {
|
|||
super(namespacekey, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@ public class EntityNamespacedKey {
|
|||
itemLuck = new NamespacedKey(main, "ITEM_LUCK");
|
||||
inventory = new NamespacedKey(main, "INVENTORY");
|
||||
storage = new NamespacedKey(main, "STORAGE");
|
||||
|
||||
}
|
||||
|
||||
public final NamespacedKey name;
|
||||
|
@ -45,5 +44,4 @@ public class EntityNamespacedKey {
|
|||
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,8 +10,6 @@ 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;
|
||||
|
@ -20,14 +20,30 @@ public class EntityUtils {
|
|||
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) {
|
||||
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.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);
|
||||
|
@ -35,11 +51,13 @@ public class EntityUtils {
|
|||
}
|
||||
|
||||
public static void updateSkills(@NotNull LivingEntity livingEntity) {
|
||||
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
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);
|
||||
defense = pm.getDefense().get(livingEntity);
|
||||
maxMana = pm.getMaxMana().get(livingEntity);
|
||||
itemDefense= pm.getItemDefense().get(livingEntity);
|
||||
itemDefense = pm.getItemDefense().get(livingEntity);
|
||||
health = pm.getHealth().get(livingEntity);
|
||||
itemHealth = pm.getItemHealth().get(livingEntity);
|
||||
mana = pm.getMana().get(livingEntity);
|
||||
|
@ -51,20 +69,37 @@ public class EntityUtils {
|
|||
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_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));
|
||||
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(),
|
||||
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);
|
||||
"Defense " + (defense + itemDefense),
|
||||
"Strength " + (strength + itemStrength),
|
||||
"Luck " + (luck + itemLuck),
|
||||
"Mana " + (mana + itemMana) + " Max Mana " + maxMana
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,17 +15,31 @@ public abstract class RaxenEntity {
|
|||
|
||||
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) {
|
||||
public RaxenEntity(
|
||||
Raxen main,
|
||||
String name,
|
||||
Integer level,
|
||||
Double health,
|
||||
Double strength
|
||||
) {
|
||||
this.main = main;
|
||||
this.name = name;
|
||||
this.level = level;
|
||||
|
@ -43,7 +57,7 @@ public abstract class RaxenEntity {
|
|||
|
||||
public void register(Entity e) {
|
||||
PersistentDataContainer data = e.getPersistentDataContainer();
|
||||
data.set(new NamespacedKey(main ,"NAME"), PersistentDataType.STRING, name);
|
||||
data.set(new NamespacedKey(main, "NAME"), PersistentDataType.STRING, name);
|
||||
}
|
||||
|
||||
public Double getMaxHealth(Entity e) {
|
||||
|
|
|
@ -1,39 +1,53 @@
|
|||
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 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;
|
||||
|
||||
public Entity(String name, Integer level, Double maxHealth, Double strength, Double defense, Double speed, 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;
|
||||
|
@ -45,7 +59,7 @@ public class Entity {
|
|||
this.uuid = UUID.randomUUID();
|
||||
}
|
||||
|
||||
public void register (Raxen main) {
|
||||
public void register(Raxen main) {
|
||||
main.getManager().getEntityManager().entities.put(name, this);
|
||||
}
|
||||
|
||||
|
@ -55,9 +69,25 @@ public class Entity {
|
|||
|
||||
public String getFullName(Entity e) {
|
||||
if (isHostile) {
|
||||
return colorString(getColorLevel() + "<white>⚔️" + getName() + "<red>" + health + "<white>/<white/>" + maxHealth);
|
||||
return colorString(
|
||||
getColorLevel() +
|
||||
"<white>⚔️" +
|
||||
getName() +
|
||||
"<red>" +
|
||||
health +
|
||||
"<white>/<white/>" +
|
||||
maxHealth
|
||||
);
|
||||
} else {
|
||||
return colorString(getColorLevel() + "<white>❤️" + getName() + "<red>" + health + "<white>/<white/>" + maxHealth);
|
||||
return colorString(
|
||||
getColorLevel() +
|
||||
"<white>❤️" +
|
||||
getName() +
|
||||
"<red>" +
|
||||
health +
|
||||
"<white>/<white/>" +
|
||||
maxHealth
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,17 @@ 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...
|
||||
|
||||
public Humanoid(String name, Integer level, Double maxHealth, Double strength, Double defense, Double speed, boolean isHostile, String skin, UUID 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,9 +9,16 @@ 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) {
|
||||
public Elf(
|
||||
Raxen main,
|
||||
String name,
|
||||
Integer level,
|
||||
Double health,
|
||||
Double strength
|
||||
) {
|
||||
super(main, name, level, health, strength);
|
||||
this.name = name;
|
||||
}
|
||||
|
@ -30,5 +37,4 @@ public class Elf extends RaxenEntity {
|
|||
super(main, "Elf", 10, 120.0, 25.0);
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,10 +9,16 @@ 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) {
|
||||
public Wolf(
|
||||
Raxen main,
|
||||
String name,
|
||||
Integer level,
|
||||
Double health,
|
||||
Double strength
|
||||
) {
|
||||
super(main, name, level, health, strength);
|
||||
this.name = name;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,8 @@ public class Goblin extends Entity {
|
|||
|
||||
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) {
|
||||
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);
|
||||
|
@ -26,6 +27,13 @@ public class Goblin extends Entity {
|
|||
}
|
||||
|
||||
public String getFullName(Entity e) {
|
||||
return "<white>⚔️" + getName() + "<red>" + getHealth() + "<white>/<white/>" + getMaxHealth();
|
||||
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,6 +3,7 @@ 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) {
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
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();
|
||||
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);
|
||||
defense = pm.getDefense().get(player);
|
||||
maxMana = pm.getMaxMana().get(player);
|
||||
itemDefense= pm.getItemDefense().get(player);
|
||||
itemDefense = pm.getItemDefense().get(player);
|
||||
health = pm.getHealth().get(player);
|
||||
itemHealth = pm.getItemHealth().get(player);
|
||||
mana = pm.getMana().get(player);
|
||||
|
@ -27,16 +29,19 @@ public class PlayerUtils {
|
|||
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
|
||||
.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(),
|
||||
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);
|
||||
"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,12 +22,6 @@ 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;
|
||||
|
@ -45,11 +44,45 @@ public class RaxenPlayer {
|
|||
|
||||
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);
|
||||
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) {
|
||||
public void setStorages(
|
||||
org.bukkit.inventory.Inventory inv,
|
||||
org.bukkit.inventory.Inventory ec
|
||||
) {
|
||||
setStorage(ec);
|
||||
setInventory(inv);
|
||||
}
|
||||
|
@ -57,7 +90,11 @@ public class RaxenPlayer {
|
|||
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"));
|
||||
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);
|
||||
|
@ -67,8 +104,15 @@ public class RaxenPlayer {
|
|||
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);
|
||||
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;
|
||||
|
@ -78,9 +122,9 @@ public class RaxenPlayer {
|
|||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
List<String> listInv = new ArrayList<String>();
|
||||
Integer reverse = 0;
|
||||
for(ItemStack it : inv) {
|
||||
for (ItemStack it : inv) {
|
||||
reverse = reverse + 1;
|
||||
if(it != null && it.getType() != Material.AIR) {
|
||||
if (it != null && it.getType() != Material.AIR) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
listInv.add(s);
|
||||
}
|
||||
|
@ -94,8 +138,8 @@ public class RaxenPlayer {
|
|||
PersistentDataContainer data = player.getPersistentDataContainer();
|
||||
List<String> list = new ArrayList<String>();
|
||||
int reverse = 0;
|
||||
for(ItemStack it : ec) {
|
||||
if(it != null) {
|
||||
for (ItemStack it : ec) {
|
||||
if (it != null) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
list.add(s);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
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;
|
||||
|
@ -21,34 +21,54 @@ public class Scoreboard {
|
|||
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"));
|
||||
Objective obj = board.registerNewObjective(
|
||||
"Raxen",
|
||||
Criteria.DUMMY,
|
||||
colorTextComp("<red>Elixium")
|
||||
);
|
||||
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||
Score score = obj.getScore(textCompToString(colorTextComp("<gold>-------------")));
|
||||
Score score = obj.getScore(
|
||||
textCompToString(colorTextComp("<gold>-------------"))
|
||||
);
|
||||
score.setScore(4);
|
||||
Score score1 = obj.getScore(textCompToString(colorTextComp("<aqua>Name:" + player.getName())));
|
||||
Score score1 = obj.getScore(
|
||||
textCompToString(colorTextComp("<aqua>Name:" + player.getName()))
|
||||
);
|
||||
score1.setScore(3);
|
||||
Score score2 = obj.getScore(textCompToString(colorTextComp("<white>Location")));
|
||||
Score score2 = obj.getScore(
|
||||
textCompToString(colorTextComp("<white>Location"))
|
||||
);
|
||||
score2.setScore(2);
|
||||
Score score3 = obj.getScore(textCompToString(colorTextComp("<gold>Coins: <gold>" + vault.getBalanceString(player))));
|
||||
Score score3 = obj.getScore(
|
||||
textCompToString(
|
||||
colorTextComp("<gold>Coins: <gold>" + vault.getBalanceString(player))
|
||||
)
|
||||
);
|
||||
score3.setScore(1);
|
||||
Score score4 = obj.getScore(textCompToString(colorTextComp("<yellow>unurled.me")));
|
||||
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);
|
||||
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())) {
|
||||
|
||||
}
|
||||
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 score = objective.getScore(
|
||||
textCompToString(
|
||||
colorTextComp("<gold>Coins: <gold>" + vault.getBalanceString(player))
|
||||
)
|
||||
);
|
||||
score.setScore(1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,22 @@ public class Attribute {
|
|||
@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) {
|
||||
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;
|
||||
|
|
|
@ -20,11 +20,13 @@ public class Attributes {
|
|||
@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();
|
||||
PlayerManager pm =
|
||||
((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager()
|
||||
.getPlayerManager();
|
||||
Entity e = player;
|
||||
defense= pm.getDefense().get(e);
|
||||
defense = pm.getDefense().get(e);
|
||||
maxMana = pm.getMaxMana().get(e);
|
||||
itemDefense= pm.getItemDefense().get(e);
|
||||
itemDefense = pm.getItemDefense().get(e);
|
||||
health = pm.getHealth().get(e);
|
||||
itemHealth = pm.getItemHealth().get(e);
|
||||
mana = pm.getMana().get(e);
|
||||
|
@ -36,11 +38,44 @@ public class Attributes {
|
|||
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);
|
||||
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();
|
||||
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);
|
||||
|
@ -59,7 +94,13 @@ public class Attributes {
|
|||
}
|
||||
|
||||
public static String[] getNameList() {
|
||||
return new String[]{"Defense", "Health", "Luck", "Mana", "Speed", "Strength"};
|
||||
|
||||
return new String[] {
|
||||
"Defense",
|
||||
"Health",
|
||||
"Luck",
|
||||
"Mana",
|
||||
"Speed",
|
||||
"Strength",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,25 +1,35 @@
|
|||
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;
|
||||
|
||||
public Class(String name, String colorName, String ID, String itemPlaceHolder, 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));
|
||||
|
@ -27,7 +37,13 @@ public class Class {
|
|||
this.max_level = max_level;
|
||||
}
|
||||
|
||||
public Class(String name, String colorName, String ID, ItemStack itemPlaceHolder, Integer max_level) {
|
||||
public Class(
|
||||
String name,
|
||||
String colorName,
|
||||
String ID,
|
||||
ItemStack itemPlaceHolder,
|
||||
Integer max_level
|
||||
) {
|
||||
this.name = name;
|
||||
this.ID = ID;
|
||||
this.placeHolder = itemPlaceHolder;
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
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;
|
||||
|
@ -21,12 +21,15 @@ public class Classes {
|
|||
}
|
||||
|
||||
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;
|
||||
|
|
|
@ -15,13 +15,25 @@ public class Assassin extends Class {
|
|||
ItemStack placeHolder;
|
||||
|
||||
public Assassin() {
|
||||
super("Assassin", "<red>Assassin", "ASSASSIN", new ItemStack(Material.AIR), 100);
|
||||
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) {
|
||||
public Assassin(
|
||||
String name,
|
||||
String colorName,
|
||||
String ID,
|
||||
String itemPlaceHolder,
|
||||
Integer max_level
|
||||
) {
|
||||
super(name, colorName, ID, itemPlaceHolder, max_level);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,11 @@ public class EnderChest {
|
|||
|
||||
@Getter
|
||||
@Setter
|
||||
public Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||
public Inventory ec = Bukkit.createInventory(
|
||||
null,
|
||||
54,
|
||||
Component.text("Ender Chest")
|
||||
);
|
||||
|
||||
public EnderChest(Inventory ec) {
|
||||
this.ec = ec;
|
||||
|
|
|
@ -6,9 +6,13 @@ 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 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,27 +23,57 @@ 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 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 HashMap<String, ItemStack> itlist;
|
||||
|
||||
|
@ -47,9 +83,21 @@ public class ItemListGui implements Listener {
|
|||
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 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();
|
||||
|
||||
|
@ -59,65 +107,88 @@ public class ItemListGui implements Listener {
|
|||
for (Map.Entry<String, ItemStack> entry : itlist.entrySet()) {
|
||||
ItemStack it = entry.getValue();
|
||||
item++;
|
||||
if(item > 44 && item < 91) {
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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(
|
||||
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 {
|
||||
} else {
|
||||
inv.addItem(it);
|
||||
inv.setItem(49, PAGE);
|
||||
inv.setItem(50, NEXT);
|
||||
|
@ -157,19 +228,30 @@ public class ItemListGui implements Listener {
|
|||
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) {
|
||||
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) {
|
||||
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) {
|
||||
String name = textCompToString(pagee.displayName());
|
||||
int page = Integer.parseInt(name.replace("page", ""));
|
||||
switch (page) {
|
||||
case 2:
|
||||
player.openInventory(inv);
|
||||
case 3:
|
||||
|
@ -195,11 +277,11 @@ public class ItemListGui implements Listener {
|
|||
//next
|
||||
ItemStack pagee = einv.getItem(49);
|
||||
if (pagee != null) {
|
||||
String name = ChatColor.stripColor(ChatColor.translateAlternateColorCodes('&',Utils.textCompToString(pagee.displayName())));
|
||||
String name = textCompToString(pagee.displayName());
|
||||
name = name.replace("[", "");
|
||||
name = name.replace("]", "");
|
||||
log(name);
|
||||
Integer page = Integer.parseInt(name.replace("page", ""));
|
||||
int page = Integer.parseInt(name.replace("page", ""));
|
||||
switch (page) {
|
||||
case 1:
|
||||
player.openInventory(inv2);
|
||||
|
|
|
@ -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,16 +12,16 @@ 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," +
|
||||
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," +
|
||||
|
@ -45,18 +49,22 @@ public class MainGui {
|
|||
HashMap<String, ItemStack> list = new HashMap<>();
|
||||
list.put("1", head);
|
||||
list.put("2", bank);
|
||||
list.put("3",ah);
|
||||
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 inventory = stringToGui(inv, gui, list);
|
||||
inventory = fillGreyPane(inventory);
|
||||
return inventory;
|
||||
}
|
||||
|
||||
public static Inventory stringToGui(Inventory inv, String stt, HashMap<String, ItemStack> it) {
|
||||
public static Inventory stringToGui(
|
||||
Inventory inv,
|
||||
String stt,
|
||||
HashMap<String, ItemStack> it
|
||||
) {
|
||||
String[] s = stt.split(",");
|
||||
if (s.length != inv.getContents().length) {
|
||||
return inv;
|
||||
|
|
|
@ -3,10 +3,18 @@ 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) {
|
||||
public Attributes(
|
||||
Integer health,
|
||||
Integer defense,
|
||||
Integer speed,
|
||||
Integer strength,
|
||||
Integer mana,
|
||||
Integer luck
|
||||
) {
|
||||
this.health = health;
|
||||
this.defense = defense;
|
||||
this.speed = speed;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
package me.unurled.raxen.components.items;
|
||||
|
||||
public class CustomModelData {
|
||||
}
|
||||
public class CustomModelData {}
|
||||
|
|
|
@ -11,5 +11,4 @@ public class NBT {
|
|||
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,8 +10,6 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.util.BoundingBox;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ThrowingDagger {
|
||||
|
||||
Player player;
|
||||
|
@ -25,18 +24,23 @@ public class ThrowingDagger {
|
|||
|
||||
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++){
|
||||
|
||||
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)){
|
||||
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++) {
|
||||
// spawn an item in air
|
||||
|
|
|
@ -28,5 +28,4 @@ public abstract class Item {
|
|||
public void registerItem(@NotNull Raxen main) {
|
||||
main.getManager().getItemManager().registerItem(item);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,5 +7,5 @@ public enum ItemTypes {
|
|||
MEDICINE,
|
||||
ARMOR,
|
||||
BLOCKS,
|
||||
MISCELLANEOUS
|
||||
MISCELLANEOUS,
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
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;
|
||||
|
|
|
@ -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,12 +17,8 @@ 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;
|
||||
|
||||
|
|
|
@ -8,8 +8,10 @@ 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) {
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
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;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
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;
|
||||
|
@ -12,7 +11,6 @@ public class LootItem {
|
|||
private double dropRate;
|
||||
private static Random randomiser = new Random();
|
||||
|
||||
|
||||
public LootItem(ItemStack item, double dropRate) {
|
||||
this.item = item;
|
||||
this.dropRate = dropRate;
|
||||
|
|
|
@ -22,10 +22,14 @@ public class ResourcePack {
|
|||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(resourcePackManager.isUseRP()) {
|
||||
player.setResourcePack(config.getString("ressource_pack_url"), config.getString("resource_pack_sha1"));
|
||||
if (resourcePackManager.isUseRP()) {
|
||||
player.setResourcePack(
|
||||
config.getString("ressource_pack_url"),
|
||||
config.getString("resource_pack_sha1")
|
||||
);
|
||||
}
|
||||
}
|
||||
}.runTaskLater(main, 2L);
|
||||
}
|
||||
.runTaskLater(main, 2L);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
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;
|
||||
|
@ -19,7 +19,6 @@ public class Config {
|
|||
@Getter
|
||||
private FileConfiguration config;
|
||||
|
||||
|
||||
public Config(Raxen main) {
|
||||
this.main = main;
|
||||
this.config = main.getConfig();
|
||||
|
@ -43,9 +42,8 @@ public class Config {
|
|||
e.printStackTrace();
|
||||
}
|
||||
debug(main, conf.getString("version"));
|
||||
if(!Raxen.getVersion().equals(config.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,14 +33,6 @@ 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;
|
||||
|
@ -66,24 +65,35 @@ public class PlayerConfig {
|
|||
* @param invstr
|
||||
* @param reverse
|
||||
*/
|
||||
public void saveUsingMongoDB(@NotNull Player player, Attributes attributes, String invstr, Integer 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();
|
||||
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) {
|
||||
if (playerManager.getRaxenPlayer(player).getStorage().getEc() != null) {
|
||||
debug(main, "Saving " + player.getName() + "'s storage!");
|
||||
EnderChest ec = playerManager.getRaxenPlayer(player).getStorage().getEc();
|
||||
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) {
|
||||
for (ItemStack it : ec.getEc()) {
|
||||
if (it != null && it.getType() != Material.AIR) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
list.add(s);
|
||||
}
|
||||
|
@ -93,13 +103,17 @@ public class PlayerConfig {
|
|||
doc.append("ec", ecstr);
|
||||
}
|
||||
}
|
||||
Document playerDoc = mongoCollection.find(Filters.eq("uuid", player.getUniqueId().toString())).first();
|
||||
if(playerDoc == null) {
|
||||
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);
|
||||
} else {
|
||||
mongoCollection.replaceOne(
|
||||
Filters.eq("uuid", player.getUniqueId().toString()),
|
||||
doc
|
||||
);
|
||||
debug(main, "replace one");
|
||||
}
|
||||
}
|
||||
|
@ -111,22 +125,33 @@ public class PlayerConfig {
|
|||
* @param invstr
|
||||
* @param reverse
|
||||
*/
|
||||
public void saveUsingYml(Player player, Attributes attributes, String invstr, Integer 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();
|
||||
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();
|
||||
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()) {
|
||||
for (ItemStack it : ec.getEc()) {
|
||||
reverse += 1;
|
||||
if(it != null) {
|
||||
if (it != null) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
list.add(s);
|
||||
}
|
||||
|
@ -136,7 +161,13 @@ public class PlayerConfig {
|
|||
}
|
||||
}
|
||||
try {
|
||||
config.save(main.getDataFolder() + "/playerInfo/" + player.getUniqueId() + "/" + "playerInfo.yml");
|
||||
config.save(
|
||||
main.getDataFolder() +
|
||||
"/playerInfo/" +
|
||||
player.getUniqueId() +
|
||||
"/" +
|
||||
"playerInfo.yml"
|
||||
);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -147,8 +178,10 @@ public class PlayerConfig {
|
|||
* @param player
|
||||
*/
|
||||
public void loadUsingMongoDB(@NotNull Player player) {
|
||||
Document playerDoc = mongoCollection.find(Filters.eq("uuid", player.getUniqueId().toString())).first();
|
||||
if(playerDoc == null) {
|
||||
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();
|
||||
|
@ -157,23 +190,47 @@ public class PlayerConfig {
|
|||
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) {
|
||||
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);
|
||||
ec =
|
||||
setItemsToInventory(
|
||||
mapItemStackDeserialize(playerDoc.getString("ec")),
|
||||
ec
|
||||
);
|
||||
}
|
||||
playerManager.getRaxenPlayer(player).setStorage(ec);
|
||||
PlayerInventory inv = player.getInventory();
|
||||
inv = setItemsToInventory(listItemStackDeserialize(playerDoc.getString("inv")), inv);
|
||||
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);
|
||||
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);
|
||||
|
@ -186,24 +243,51 @@ public class PlayerConfig {
|
|||
*/
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
@ -218,14 +302,14 @@ public class PlayerConfig {
|
|||
|
||||
List<String> listInv = new ArrayList<String>();
|
||||
Integer reverse = 0;
|
||||
for(ItemStack it : inv) {
|
||||
for (ItemStack it : inv) {
|
||||
reverse = reverse + 1;
|
||||
if(it != null && it.getType() != Material.AIR) {
|
||||
if (it != null && it.getType() != Material.AIR) {
|
||||
String s = Items.itemStackSerialize(it, reverse);
|
||||
listInv.add(s);
|
||||
}
|
||||
}
|
||||
String invstr= Items.itemStackSer(inv);
|
||||
String invstr = Items.itemStackSer(inv);
|
||||
debug(main, "saving...");
|
||||
String storage = sto.getConfig().getString("storage");
|
||||
Integer finalReverse = reverse;
|
||||
|
@ -235,7 +319,8 @@ public class PlayerConfig {
|
|||
public void run() {
|
||||
saveUsingMongoDB(player, attributes, finalInvstr, finalReverse);
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
}
|
||||
.runTaskAsynchronously(main);
|
||||
debug(main, "using mongo");
|
||||
if (storage == "MYSQL" || storage == "YML") {
|
||||
String finalInvstr1 = invstr;
|
||||
|
@ -245,7 +330,8 @@ public class PlayerConfig {
|
|||
public void run() {
|
||||
saveUsingYml(player, attributes, finalInvstr1, finalReverse1);
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
}
|
||||
.runTaskAsynchronously(main);
|
||||
debug(main, "using yml");
|
||||
}
|
||||
|
||||
|
@ -265,7 +351,8 @@ public class PlayerConfig {
|
|||
public void run() {
|
||||
loadUsingMongoDB(player);
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
}
|
||||
.runTaskAsynchronously(main);
|
||||
value = "mongodb";
|
||||
} else {
|
||||
value = "yml";
|
||||
|
@ -278,9 +365,12 @@ public class PlayerConfig {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}.runTaskAsynchronously(main);
|
||||
}
|
||||
debug(main, "Player: " + player.getName() + " data successfully loaded using " + value);
|
||||
.runTaskAsynchronously(main);
|
||||
}
|
||||
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,10 +18,6 @@ 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;
|
||||
|
@ -36,7 +35,10 @@ public class DamageEntity implements Listener {
|
|||
*/
|
||||
@EventHandler
|
||||
public void entityDamageByEntity(EntityDamageByEntityEvent e) {
|
||||
if (!(e.getEntity() instanceof LivingEntity) || !(e.getDamager() instanceof LivingEntity)) {
|
||||
if (
|
||||
!(e.getEntity() instanceof LivingEntity) ||
|
||||
!(e.getDamager() instanceof LivingEntity)
|
||||
) {
|
||||
debug("Not Living Entity, Some block falling shit or block entities");
|
||||
} else {
|
||||
e.setDamage(0);
|
||||
|
@ -48,52 +50,90 @@ public class DamageEntity implements Listener {
|
|||
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());
|
||||
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);
|
||||
PersistentDataContainer data =
|
||||
entityDamager.getPersistentDataContainer();
|
||||
if (
|
||||
data.has(entityNamespacedKey.strength, PersistentDataType.INTEGER)
|
||||
) {
|
||||
strength =
|
||||
data.get(entityNamespacedKey.strength, PersistentDataType.INTEGER);
|
||||
}
|
||||
itemStrength = pm.getItemStrength().getItem((LivingEntity) entityDamager);
|
||||
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);
|
||||
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();
|
||||
PersistentDataContainer data =
|
||||
entityVictim.getPersistentDataContainer();
|
||||
if (data.has(entityNamespacedKey.defense, PersistentDataType.INTEGER)) {
|
||||
defense = data.get(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);
|
||||
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));
|
||||
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);
|
||||
defense = defense / (defense + 100);
|
||||
debug(main, String.valueOf(damage));
|
||||
debug(main, String.valueOf(defense));
|
||||
Integer health_with_defense = health * (1+ (defense/100));
|
||||
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());
|
||||
e.setDamage(
|
||||
Objects
|
||||
.requireNonNull(
|
||||
e
|
||||
.getEntity()
|
||||
.getType()
|
||||
.getDefaultAttributes()
|
||||
.getAttribute(Attribute.GENERIC_MAX_HEALTH)
|
||||
)
|
||||
.getDefaultValue()
|
||||
);
|
||||
} else {
|
||||
debug(main, "Applying damage to entity.");
|
||||
if (defense == 0) {
|
||||
|
@ -102,9 +142,12 @@ public class DamageEntity implements Listener {
|
|||
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);
|
||||
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);
|
||||
playerVictim.setHealth(health.doubleValue() / 5);
|
||||
} else {
|
||||
Entity entityVictim = e.getEntity();
|
||||
pm.getHealth().set(entityVictim, health);
|
||||
|
@ -123,8 +166,6 @@ public class DamageEntity implements Listener {
|
|||
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,8 +13,6 @@ 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;
|
||||
|
@ -35,10 +35,30 @@ public class SpawnEvent implements Listener {
|
|||
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) {
|
||||
} 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);
|
||||
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());
|
||||
}
|
||||
|
|
|
@ -29,41 +29,40 @@ public class ArmorEvent implements Listener {
|
|||
@EventHandler
|
||||
public void ArmorChangeEvent(PlayerArmorChangeEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
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) {
|
||||
if (e.getOldItem() != null && e.getOldItem().getType() != Material.AIR) {
|
||||
ItemStack oldItem = e.getOldItem();
|
||||
NBTItem nbti = new NBTItem(oldItem);
|
||||
if(nbti.hasTag("SPEED")) {
|
||||
if (nbti.hasTag("SPEED")) {
|
||||
pm.getSpeed().remove(entity, nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasTag("HEALTH")) {
|
||||
if (nbti.hasTag("HEALTH")) {
|
||||
pm.getHealth().remove(entity, nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if(nbti.hasTag("DEFENSE")) {
|
||||
if (nbti.hasTag("DEFENSE")) {
|
||||
pm.getDefense().remove(entity, nbti.getInteger("DEFENSE"));
|
||||
|
||||
}
|
||||
if(nbti.hasTag("STRENGTH")) {
|
||||
if (nbti.hasTag("STRENGTH")) {
|
||||
pm.getStrength().remove(entity, nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
}
|
||||
if(e.getNewItem() != null && e.getNewItem().getType() != Material.AIR) {
|
||||
if (e.getNewItem() != null && e.getNewItem().getType() != Material.AIR) {
|
||||
ItemStack newItem = e.getNewItem();
|
||||
NBTItem nbti = new NBTItem(newItem);
|
||||
if(nbti.hasTag("SPEED")) {
|
||||
if (nbti.hasTag("SPEED")) {
|
||||
pm.getSpeed().add(entity, nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasTag("HEALTH")) {
|
||||
if (nbti.hasTag("HEALTH")) {
|
||||
pm.getHealth().add(entity, nbti.getInteger("HEALTH"));
|
||||
|
||||
}
|
||||
if(nbti.hasTag("DEFENSE")) {
|
||||
if (nbti.hasTag("DEFENSE")) {
|
||||
pm.getDefense().add(entity, nbti.getInteger("DEFENSE"));
|
||||
|
||||
}
|
||||
if(nbti.hasTag("STRENGTH")) {
|
||||
if (nbti.hasTag("STRENGTH")) {
|
||||
pm.getStrength().add(entity, nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,8 +11,6 @@ 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;
|
||||
|
@ -24,7 +24,9 @@ public class CloseInventoryEvent implements Listener {
|
|||
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 =
|
||||
((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();
|
||||
// }
|
||||
// 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,10 +18,6 @@ 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;
|
||||
|
@ -34,28 +33,29 @@ public class ItemHandEvent implements Listener {
|
|||
@EventHandler
|
||||
public void ItemHeldEvent(PlayerItemHeldEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
PlayerManager pm = ((Raxen) Bukkit.getPluginManager().getPlugin("Raxen")).getManager().getPlayerManager();
|
||||
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) {
|
||||
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) {
|
||||
|
||||
}
|
||||
} catch (SecurityException | NoSuchMethodException exception) {}
|
||||
if (method != null) {
|
||||
me.unurled.raxen.components.entity.Attributes.Attribute attribute = null;
|
||||
me.unurled.raxen.components.entity.Attributes.Attribute attribute =
|
||||
null;
|
||||
try {
|
||||
attribute = (Attribute) method.invoke(pm, null);
|
||||
} catch (InvocationTargetException | IllegalAccessException exception) {
|
||||
|
||||
}
|
||||
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());
|
||||
|
@ -76,23 +76,22 @@ public class ItemHandEvent implements Listener {
|
|||
pm.getItemStrength().remove(player, nbti.getInteger("STRENGTH"));
|
||||
}*/
|
||||
}
|
||||
if(newItem != null && newItem.getType() != Material.AIR) {
|
||||
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) {
|
||||
|
||||
}
|
||||
} catch (SecurityException | NoSuchMethodException exception) {}
|
||||
if (method != null) {
|
||||
me.unurled.raxen.components.entity.Attributes.Attribute attribute = null;
|
||||
me.unurled.raxen.components.entity.Attributes.Attribute attribute =
|
||||
null;
|
||||
try {
|
||||
attribute = (Attribute) method.invoke(pm, null);
|
||||
} catch (InvocationTargetException | IllegalAccessException exception) {
|
||||
|
||||
}
|
||||
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());
|
||||
|
|
|
@ -23,7 +23,8 @@ public class JoinEvent implements Listener {
|
|||
this.main = main;
|
||||
this.playerConfig = main.getPlayerConfig();
|
||||
this.scoreboard = new Scoreboard(main);
|
||||
this.resourcePack = main.getManager().getResourcePackManager().getResourcePack();
|
||||
this.resourcePack =
|
||||
main.getManager().getResourcePackManager().getResourcePack();
|
||||
this.playerManager = main.getManager().getPlayerManager();
|
||||
}
|
||||
|
||||
|
@ -41,5 +42,4 @@ public class JoinEvent implements Listener {
|
|||
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,8 +10,6 @@ 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;
|
||||
|
@ -19,7 +18,6 @@ public class LeaveEvent implements Listener {
|
|||
public LeaveEvent(Raxen main) {
|
||||
this.playerConfig = main.getPlayerConfig();
|
||||
this.playerManager = main.getManager().getPlayerManager();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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,9 +10,6 @@ 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
|
||||
|
|
|
@ -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();
|
||||
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>");
|
||||
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,11 +10,10 @@ 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;
|
||||
|
|
|
@ -14,27 +14,39 @@ public class Manager {
|
|||
|
||||
@Getter
|
||||
private WorldManager worldManager;
|
||||
|
||||
@Getter
|
||||
private StorageManager storageManager;
|
||||
|
||||
@Getter
|
||||
private PlayerManager playerManager;
|
||||
|
||||
@Getter
|
||||
private ListenerManager listenerManager;
|
||||
|
||||
@Getter
|
||||
private CommandManager commandManager;
|
||||
|
||||
@Getter
|
||||
private ItemManager itemManager;
|
||||
|
||||
@Getter
|
||||
private ResourcePackManager resourcePackManager;
|
||||
|
||||
@Getter
|
||||
private EntityManager entityManager;
|
||||
|
||||
@Getter
|
||||
private LootManager lootManager;
|
||||
|
||||
@Getter
|
||||
private LibsManager libsManager;
|
||||
@Getter private DungeonsManager dungeonsManager;
|
||||
|
||||
@Getter private Multiverse multiverse;
|
||||
@Getter
|
||||
private DungeonsManager dungeonsManager;
|
||||
|
||||
@Getter
|
||||
private Multiverse multiverse;
|
||||
|
||||
/**
|
||||
* Create an instance of all managers.
|
||||
|
|
|
@ -1,5 +1,11 @@
|
|||
package me.unurled.raxen.manager.entity;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
|
@ -9,13 +15,6 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class EntityManager {
|
||||
|
||||
private Raxen main;
|
||||
|
@ -24,7 +23,8 @@ public class EntityManager {
|
|||
@Setter
|
||||
public List<EntityType> list = new ArrayList<>();
|
||||
|
||||
public HashMap<String, me.unurled.raxen.components.entity.other.custom.Entity> entities = new HashMap<>();
|
||||
public HashMap<String, me.unurled.raxen.components.entity.other.custom.Entity> entities =
|
||||
new HashMap<>();
|
||||
|
||||
public HashMap<UUID, Entity> livingEntities = new HashMap<>();
|
||||
|
||||
|
@ -32,9 +32,7 @@ public class EntityManager {
|
|||
this.main = main;
|
||||
}
|
||||
|
||||
public void registerLivingEntities(World world) {
|
||||
|
||||
}
|
||||
public void registerLivingEntities(World world) {}
|
||||
|
||||
/**
|
||||
* used to register entities using fileconfigs but rapidly abandoned
|
||||
|
@ -46,5 +44,4 @@ public class EntityManager {
|
|||
World world = Bukkit.getWorld(file.getString("world"));
|
||||
String name = file.getString("name");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,12 +1,22 @@
|
|||
package me.unurled.raxen.manager.entity;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.items.NBT;
|
||||
import me.unurled.raxen.components.items.custom.Item;
|
||||
import me.unurled.raxen.utils.Utils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
|
@ -16,20 +26,13 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
public class ItemManager {
|
||||
|
||||
private final Raxen main;
|
||||
|
||||
@Getter
|
||||
private HashMap<String, ItemStack> list = new HashMap<>();
|
||||
|
||||
private NBT nbt = new NBT();
|
||||
|
||||
public ItemManager(Raxen main) {
|
||||
|
@ -42,7 +45,8 @@ public class ItemManager {
|
|||
* register manually all item in Raxen
|
||||
*/
|
||||
private void registerItem() {
|
||||
me.unurled.raxen.components.items.custom.List lisst = new me.unurled.raxen.components.items.custom.List(main);
|
||||
me.unurled.raxen.components.items.custom.List lisst =
|
||||
new me.unurled.raxen.components.items.custom.List(main);
|
||||
for (Item items : lisst.getItems()) {
|
||||
registerItem(items.getItem());
|
||||
}
|
||||
|
@ -67,7 +71,7 @@ public class ItemManager {
|
|||
registerItem(customItem);
|
||||
} else if (listFile[i].isDirectory()) {
|
||||
for (int a = 0; a < listFile[i].listFiles().length; a++) {
|
||||
if(listFile[i].listFiles()[a].isFile()) {
|
||||
if (listFile[i].listFiles()[a].isFile()) {
|
||||
FileConfiguration customItem = new YamlConfiguration();
|
||||
try {
|
||||
customItem.load(listFile[i].listFiles()[a]);
|
||||
|
@ -76,9 +80,11 @@ public class ItemManager {
|
|||
}
|
||||
registerItem(customItem);
|
||||
} else if (listFile[i].listFiles()[a].isDirectory()) {
|
||||
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Can't use more than 2 folder to get Items.yml");
|
||||
error(
|
||||
(Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),
|
||||
"Can't use more than 2 folder to get Items.yml"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -91,12 +97,30 @@ public class ItemManager {
|
|||
@Deprecated
|
||||
private void registerItem(@NotNull FileConfiguration file) {
|
||||
debug(main, file.getString("id"));
|
||||
ItemStack it = new ItemStack(Objects.requireNonNull(Material.getMaterial((String) Objects.requireNonNull(file.get("id")))));
|
||||
ItemStack it = new ItemStack(
|
||||
Objects.requireNonNull(
|
||||
Material.getMaterial((String) Objects.requireNonNull(file.get("id")))
|
||||
)
|
||||
);
|
||||
ItemMeta itm = it.getItemMeta();
|
||||
itm.displayName(colorTextComp((String) file.get("name")));
|
||||
List<Component> lore = ((List<String>) Objects.requireNonNull(file.get("lore"))).stream().map(Utils::colorTextComp).collect(Collectors.toList());
|
||||
itm.setCustomModelData(Objects.requireNonNull(file.getConfigurationSection("Pack")).getInt("custom_model_data"));
|
||||
itm.lore(lore);
|
||||
Object lore_obj = file.get("lore");
|
||||
if (lore_obj instanceof List<?> lore) {
|
||||
List<Component> lores = new ArrayList<>();
|
||||
for (Object s : lore) {
|
||||
if (s == null) continue;
|
||||
if (s instanceof String) {
|
||||
TextComponent textComponent = colorTextComp((String) s);
|
||||
lores.add(textComponent);
|
||||
}
|
||||
}
|
||||
itm.lore(lores);
|
||||
}
|
||||
itm.setCustomModelData(
|
||||
Objects
|
||||
.requireNonNull(file.getConfigurationSection("Pack"))
|
||||
.getInt("custom_model_data")
|
||||
);
|
||||
it.setItemMeta(itm);
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
nbti.setInteger(NBT.SPEED, file.getInt("speed"));
|
||||
|
|
|
@ -1,20 +1,18 @@
|
|||
package me.unurled.raxen.manager.entity;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.lootchest.loots.LootItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LootManager {
|
||||
|
||||
private Raxen main;
|
||||
|
||||
@Getter
|
||||
private List<LootItem> lootTable;
|
||||
|
||||
|
||||
public LootManager(Raxen main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package me.unurled.raxen.manager.entity;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.entity.Attributes.*;
|
||||
|
@ -11,20 +15,16 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
public class PlayerManager {
|
||||
|
||||
private final Raxen main;
|
||||
private final HashMap<UUID, BukkitTask> actionBar = new HashMap<>();
|
||||
// TODO: player classes
|
||||
private final HashMap<String, Class> classes = new HashMap<>();
|
||||
@Getter
|
||||
private final HashMap<String, me.unurled.raxen.components.entity.Attributes.Attribute> attribute = new HashMap<>();
|
||||
|
||||
@Getter
|
||||
private final HashMap<String, me.unurled.raxen.components.entity.Attributes.Attribute> attribute =
|
||||
new HashMap<>();
|
||||
|
||||
private Classes classesRegister;
|
||||
|
||||
|
@ -62,12 +62,23 @@ public class PlayerManager {
|
|||
BukkitTask task = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.sendActionBar(colorComp("<red>" + pm.getHealth().get(player) + "/" +
|
||||
pm.getMaxHealth().get(player) + "❤</red> <aqua>" + pm.getMana().get(player) + "/" +
|
||||
pm.getMaxMana().get(player) + "</aqua>"));
|
||||
player.sendActionBar(
|
||||
colorComp(
|
||||
"<red>" +
|
||||
pm.getHealth().get(player) +
|
||||
"/" +
|
||||
pm.getMaxHealth().get(player) +
|
||||
"❤</red> <aqua>" +
|
||||
pm.getMana().get(player) +
|
||||
"/" +
|
||||
pm.getMaxMana().get(player) +
|
||||
"</aqua>"
|
||||
)
|
||||
);
|
||||
}
|
||||
}.runTaskTimerAsynchronously(main, 10, 20);
|
||||
if(actionBar.containsKey(player.getUniqueId())) {
|
||||
}
|
||||
.runTaskTimerAsynchronously(main, 10, 20);
|
||||
if (actionBar.containsKey(player.getUniqueId())) {
|
||||
actionBar.replace(player.getUniqueId(), task);
|
||||
} else {
|
||||
actionBar.put(player.getUniqueId(), task);
|
||||
|
@ -79,17 +90,24 @@ public class PlayerManager {
|
|||
* @param player
|
||||
*/
|
||||
public void unRegisterActionBar(Player player) {
|
||||
if(actionBar.containsKey(player.getUniqueId())) {
|
||||
if (actionBar.containsKey(player.getUniqueId())) {
|
||||
BukkitTask task = actionBar.get(player.getUniqueId());
|
||||
task.cancel();
|
||||
actionBar.remove(player.getUniqueId());
|
||||
} else {
|
||||
debug(colorTextComp("<red>Player " + player.getName() + " didn't have any Action Bar" + player.getUniqueId().toString() + "</red>"));
|
||||
debug(
|
||||
colorTextComp(
|
||||
"<red>Player " +
|
||||
player.getName() +
|
||||
" didn't have any Action Bar" +
|
||||
player.getUniqueId().toString() +
|
||||
"</red>"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public void unRegisterRaxenPlayer(Player player) {
|
||||
}
|
||||
public void unRegisterRaxenPlayer(Player player) {}
|
||||
|
||||
/**
|
||||
* getClasses
|
||||
|
@ -144,7 +162,11 @@ public class PlayerManager {
|
|||
this.mana = new Mana(key.mana, "MANA");
|
||||
attribute.put("MANA", mana);
|
||||
|
||||
this.maxMana = new MaxManaBuilder().setNamespacekey(key.maxMana).setName("MAX_MANA").createMaxMana();
|
||||
this.maxMana =
|
||||
new MaxManaBuilder()
|
||||
.setNamespacekey(key.maxMana)
|
||||
.setName("MAX_MANA")
|
||||
.createMaxMana();
|
||||
attribute.put("MAX_MANA", maxMana);
|
||||
|
||||
this.maxHealth = new MaxHealth(key.maxHealth, "MAX_HEALTH");
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
package me.unurled.raxen.manager.entity;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.utils.libs.MongoDB;
|
||||
|
@ -11,20 +16,16 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
|
||||
public class StorageManager {
|
||||
|
||||
private static Raxen main;
|
||||
|
||||
@Getter
|
||||
private static FileConfiguration config;
|
||||
|
||||
@Getter
|
||||
private static MongoDB mongodb;
|
||||
|
||||
@Getter
|
||||
private static Mysql mysql;
|
||||
|
||||
|
@ -41,11 +42,14 @@ public class StorageManager {
|
|||
String s = (String) config.get("storage");
|
||||
debug(main, s);
|
||||
mongodb = main.getManager().getLibsManager().getMongoDB();
|
||||
if(s.equalsIgnoreCase("MONGODB")) {
|
||||
if (s.equalsIgnoreCase("MONGODB")) {
|
||||
mongodb.connect();
|
||||
debug(main, "'" + s + "'");
|
||||
} else if(s.equalsIgnoreCase("MYSQL")) {
|
||||
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Currently not implemented, switching to YML");
|
||||
} else if (s.equalsIgnoreCase("MYSQL")) {
|
||||
error(
|
||||
(Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),
|
||||
"Currently not implemented, switching to YML"
|
||||
);
|
||||
debug(main, "'" + s + "'");
|
||||
} else {
|
||||
debug(main, "'" + s + "'");
|
||||
|
@ -67,15 +71,21 @@ public class StorageManager {
|
|||
public static @NotNull FileConfiguration createYml(@NotNull Player player) {
|
||||
File customFile;
|
||||
FileConfiguration customConfig;
|
||||
customFile = new File(main.getDataFolder() + "/playerInfo/" + player.getUniqueId(), "/playerInfo.yml");
|
||||
customFile =
|
||||
new File(
|
||||
main.getDataFolder() + "/playerInfo/" + player.getUniqueId(),
|
||||
"/playerInfo.yml"
|
||||
);
|
||||
|
||||
if (!customFile.exists()) {
|
||||
customFile.getParentFile().mkdirs();
|
||||
try {
|
||||
customFile.createNewFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Error in Storage Manager saving new File.");
|
||||
} catch (IOException e) {
|
||||
error(
|
||||
(Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),
|
||||
"Error in Storage Manager saving new File."
|
||||
);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -97,8 +107,8 @@ public class StorageManager {
|
|||
customConfig.set("itemSpeed", 0);
|
||||
customConfig.set("strength", 100);
|
||||
customConfig.set("itemDmg", 0);
|
||||
customConfig.set("inv","");
|
||||
customConfig.set("ec","");
|
||||
customConfig.set("inv", "");
|
||||
customConfig.set("ec", "");
|
||||
try {
|
||||
customConfig.save(customFile);
|
||||
} catch (IOException e) {
|
||||
|
@ -114,16 +124,17 @@ public class StorageManager {
|
|||
* @return a file configuration
|
||||
*/
|
||||
public static @NotNull FileConfiguration createYml(@NotNull File file) {
|
||||
|
||||
FileConfiguration customConfig;
|
||||
|
||||
if (!file.exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
try {
|
||||
file.createNewFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Error in Storage Manager saving new File.");
|
||||
} catch (IOException e) {
|
||||
error(
|
||||
(Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),
|
||||
"Error in Storage Manager saving new File."
|
||||
);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -149,9 +160,11 @@ public class StorageManager {
|
|||
customFile.getParentFile().mkdirs();
|
||||
try {
|
||||
customFile.createNewFile();
|
||||
}
|
||||
catch (IOException e) {
|
||||
error((Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),"Error in Storage Manager saving new File.");
|
||||
} catch (IOException e) {
|
||||
error(
|
||||
(Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),
|
||||
"Error in Storage Manager saving new File."
|
||||
);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,12 +9,13 @@ import me.unurled.raxen.commands.player.MainGuiCommand;
|
|||
import me.unurled.raxen.commands.player.SkillsCommand;
|
||||
import me.unurled.raxen.commands.player.StorageCommand;
|
||||
|
||||
|
||||
public class CommandManager {
|
||||
|
||||
private Raxen main;
|
||||
|
||||
@Getter
|
||||
private ItemListCommand itemListCommand;
|
||||
|
||||
private ReloadCommand reloadComand = new ReloadCommand();
|
||||
private NbtCommand nbtCommand;
|
||||
private TestGuiCommand testGuiCommand = new TestGuiCommand();
|
||||
|
@ -28,8 +29,6 @@ public class CommandManager {
|
|||
private MainGuiCommand mainGuiCommand;
|
||||
private ItemTo64Command itemTo64Command;
|
||||
|
||||
private TestHoloCommand testHoloCommand;
|
||||
|
||||
public CommandManager(Raxen main) {
|
||||
this.main = main;
|
||||
this.itemListCommand = new ItemListCommand(this.main);
|
||||
|
@ -42,7 +41,6 @@ public class CommandManager {
|
|||
this.customModelDataCommand = new CustomModelDataCommand();
|
||||
this.mainGuiCommand = new MainGuiCommand(this.main);
|
||||
this.itemTo64Command = new ItemTo64Command();
|
||||
this.testHoloCommand = new TestHoloCommand(this.main);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +59,6 @@ public class CommandManager {
|
|||
main.getCommand("storage").setExecutor(storageCommand);
|
||||
main.getCommand("storage").setTabCompleter(storageCommand);
|
||||
|
||||
|
||||
main.getCommand("skills").setTabCompleter(skillsCommand);
|
||||
main.getCommand("skills").setExecutor(skillsCommand);
|
||||
|
||||
|
@ -85,8 +82,5 @@ public class CommandManager {
|
|||
|
||||
main.getCommand("itemto64").setTabCompleter(itemTo64Command);
|
||||
main.getCommand("itemto64").setExecutor(itemTo64Command);
|
||||
|
||||
main.getCommand("testholo").setTabCompleter(testHoloCommand);
|
||||
main.getCommand("testholo").setExecutor(testHoloCommand);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package me.unurled.raxen.manager.server;
|
||||
|
||||
import java.util.HashMap;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.dungeons.Dungeon;
|
||||
import me.unurled.raxen.components.dungeons.Gate;
|
||||
import me.unurled.raxen.components.dungeons.types.forest.ForestDungeon;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DungeonsManager {
|
||||
|
||||
private Raxen main;
|
||||
|
@ -35,7 +34,7 @@ public class DungeonsManager {
|
|||
*/
|
||||
}
|
||||
|
||||
public HashMap getGates() {
|
||||
public HashMap<Gate, Location> getGates() {
|
||||
return gates;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package me.unurled.raxen.manager.server;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
public class EnchantmentManager {
|
||||
|
||||
|
|
|
@ -2,27 +2,30 @@ package me.unurled.raxen.manager.server;
|
|||
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.utils.Utils;
|
||||
import me.unurled.raxen.utils.libs.*;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class LibsManager {
|
||||
|
||||
@Getter
|
||||
private final ProtocolManager protocolManager;
|
||||
|
||||
@Getter
|
||||
private final LuckPerm luckPerm;
|
||||
|
||||
@Getter
|
||||
private final Vault vault;
|
||||
|
||||
@Getter
|
||||
private final MongoDB mongoDB;
|
||||
|
||||
@Getter
|
||||
private static Mysql mysql;
|
||||
|
||||
@Getter
|
||||
private PlaceHolderAPI placeHolderAPI;
|
||||
|
||||
@Getter
|
||||
private CitizensApi citizens;
|
||||
@Getter
|
||||
private HolographicDisplay holographicDisplay;
|
||||
|
||||
public LibsManager(Raxen main) {
|
||||
this.luckPerm = new LuckPerm(main);
|
||||
|
@ -32,11 +35,5 @@ public class LibsManager {
|
|||
this.mongoDB = new MongoDB();
|
||||
this.placeHolderAPI = new PlaceHolderAPI(main);
|
||||
this.citizens = new CitizensApi(main);
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
|
||||
Utils.error("*** HolographicDisplays is not installed or not enabled. ***", "*** This plugin will be disabled. ***");
|
||||
main.disable();
|
||||
} else {
|
||||
holographicDisplay = new HolographicDisplay(main);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ public class ListenerManager {
|
|||
|
||||
private final Raxen main;
|
||||
private final PluginManager pm;
|
||||
|
||||
@Getter
|
||||
private ServerPingEvent serverPingEvent;
|
||||
|
||||
|
@ -31,12 +32,18 @@ public class ListenerManager {
|
|||
this.pm.registerEvents(new ItemHandEvent(main), main);
|
||||
this.pm.registerEvents(new Reload(), main);
|
||||
this.pm.registerEvents(new TransactionEvent(main), main);
|
||||
this.pm.registerEvents(main.getManager().getCommandManager().getItemListCommand().getItemListGui(), main);
|
||||
this.pm.registerEvents(
|
||||
main
|
||||
.getManager()
|
||||
.getCommandManager()
|
||||
.getItemListCommand()
|
||||
.getItemListGui(),
|
||||
main
|
||||
);
|
||||
this.pm.registerEvents(new DamageEntity(main), main);
|
||||
this.pm.registerEvents(new SpawnEvent(main), main);
|
||||
this.pm.registerEvents(new ClickBlockEvent(main), main);
|
||||
this.pm.registerEvents(serverPingEvent, main);
|
||||
this.pm.registerEvents(new CloseInventoryEvent(), main);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,13 +19,19 @@ public class ProtocolManager {
|
|||
}
|
||||
|
||||
public void listen() {
|
||||
manager.addPacketListener(new PacketAdapter(main, ListenerPriority.NORMAL, PacketType.Play.Client.BLOCK_DIG) {
|
||||
manager.addPacketListener(
|
||||
new PacketAdapter(
|
||||
main,
|
||||
ListenerPriority.NORMAL,
|
||||
PacketType.Play.Client.BLOCK_DIG
|
||||
) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PacketContainer packet = event.getPacket();
|
||||
// if(player.)
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
package me.unurled.raxen.manager.server;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
|
||||
import java.util.Objects;
|
||||
import lombok.Getter;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.resourcepack.ResourcePack;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.debug;
|
||||
import static me.unurled.raxen.utils.Utils.error;
|
||||
|
||||
public class ResourcePackManager {
|
||||
|
||||
private Raxen main;
|
||||
|
||||
@Getter
|
||||
private ResourcePack resourcePack;
|
||||
|
||||
private FileConfiguration config;
|
||||
|
||||
@Getter
|
||||
private boolean useRP;
|
||||
|
||||
|
@ -31,11 +33,22 @@ public class ResourcePackManager {
|
|||
* Method to enable the ressourcepack
|
||||
*/
|
||||
private void enable() {
|
||||
if(useRP) {
|
||||
if(config.getString("resource_pack_url") == null || Objects.equals(config.getString("rssource_pack_url"), "") ||
|
||||
config.getString("resource_pack_sha1") == null || Objects.equals(config.getString("resource_pack_sha1"), "") ||
|
||||
Objects.equals(config.getString("resource_pack_url"), "https://mc-packs.net/") || Objects.equals(config.getString("resource_pack_sha1"), "sha1hallo")) {
|
||||
error(main, "You must specify an resource_pack_url and resource_pack_sha1!");
|
||||
if (useRP) {
|
||||
if (
|
||||
config.getString("resource_pack_url") == null ||
|
||||
Objects.equals(config.getString("rssource_pack_url"), "") ||
|
||||
config.getString("resource_pack_sha1") == null ||
|
||||
Objects.equals(config.getString("resource_pack_sha1"), "") ||
|
||||
Objects.equals(
|
||||
config.getString("resource_pack_url"),
|
||||
"https://mc-packs.net/"
|
||||
) ||
|
||||
Objects.equals(config.getString("resource_pack_sha1"), "sha1hallo")
|
||||
) {
|
||||
error(
|
||||
main,
|
||||
"You must specify an resource_pack_url and resource_pack_sha1!"
|
||||
);
|
||||
debug(main, "Resource pack not enabled.");
|
||||
useRP = false;
|
||||
} else {
|
||||
|
@ -44,6 +57,5 @@ public class ResourcePackManager {
|
|||
} else {
|
||||
debug(main, "Resource pack not enabled.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package me.unurled.raxen.manager.server;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MVWorldManager;
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseWorld;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static me.unurled.raxen.utils.Utils.*;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import org.bukkit.World;
|
||||
|
||||
public class WorldManager {
|
||||
|
||||
|
@ -64,7 +63,11 @@ public class WorldManager {
|
|||
public void load() {
|
||||
if (!pluginFolder.exists()) {
|
||||
pluginFolder.mkdirs();
|
||||
error("Please put in the folder " + pluginFolder.getAbsolutePath() + " all the needed worlds :");
|
||||
error(
|
||||
"Please put in the folder " +
|
||||
pluginFolder.getAbsolutePath() +
|
||||
" all the needed worlds :"
|
||||
);
|
||||
for (String s : worlds) {
|
||||
error(" - " + s + ",");
|
||||
}
|
||||
|
@ -77,7 +80,7 @@ public class WorldManager {
|
|||
if (worldd.isDirectory()) {
|
||||
worldManager.loadWorld(s);
|
||||
}
|
||||
} else if (world.exists() ) {
|
||||
} else if (world.exists()) {
|
||||
if (world.isDirectory()) {
|
||||
loadWorld(s);
|
||||
} else {
|
||||
|
@ -96,18 +99,40 @@ public class WorldManager {
|
|||
public void loadWorld(String name) {
|
||||
File world = new File(pluginFolder + "/" + name + "/");
|
||||
if (!world.exists() || !world.isDirectory()) {
|
||||
error("Loading world " + name + ". Folder " + world.getAbsolutePath() + " don't exists.");
|
||||
error(
|
||||
"Loading world " +
|
||||
name +
|
||||
". Folder " +
|
||||
world.getAbsolutePath() +
|
||||
" don't exists."
|
||||
);
|
||||
return;
|
||||
}
|
||||
File newWorld = new File(worldFolder + "/" + name);
|
||||
try {
|
||||
log(colorTextComp("<aqua>Copping world " + world.getName() + ".</aqua>"), colorTextComp("<blue>From " + world.getAbsolutePath() + " to " + newWorld.getAbsolutePath() +".</blue>"));
|
||||
log(
|
||||
colorTextComp("<aqua>Copping world " + world.getName() + ".</aqua>"),
|
||||
colorTextComp(
|
||||
"<blue>From " +
|
||||
world.getAbsolutePath() +
|
||||
" to " +
|
||||
newWorld.getAbsolutePath() +
|
||||
".</blue>"
|
||||
)
|
||||
);
|
||||
copyDirectory(world.getAbsolutePath(), newWorld.getAbsolutePath());
|
||||
} catch (IOException e) {
|
||||
error("Error while Loading world " + name + " at coping data.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
worldManager.loadWorld(name);
|
||||
worldManager.addWorld(world.getName(), World.Environment.NORMAL, null, null, false, null);
|
||||
worldManager.addWorld(
|
||||
world.getName(),
|
||||
World.Environment.NORMAL,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package me.unurled.raxen.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import me.unurled.raxen.Raxen;
|
||||
import me.unurled.raxen.components.dungeons.Gate;
|
||||
import me.unurled.raxen.components.dungeons.Rank;
|
||||
|
@ -8,9 +10,6 @@ import org.bukkit.Bukkit;
|
|||
import org.bukkit.Location;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
public class DungeonUtils {
|
||||
|
||||
/**
|
||||
|
@ -60,16 +59,22 @@ public class DungeonUtils {
|
|||
* @return boolean
|
||||
*/
|
||||
public static Boolean isInRange(Location loc) {
|
||||
Raxen main = (Raxen) Bukkit.getServer().getPluginManager().getPlugin("Raxen");
|
||||
HashMap<Gate, Location> gats = main.getManager().getDungeonsManager().getGates();
|
||||
Raxen main = (Raxen) Bukkit
|
||||
.getServer()
|
||||
.getPluginManager()
|
||||
.getPlugin("Raxen");
|
||||
HashMap<Gate, Location> gats = main
|
||||
.getManager()
|
||||
.getDungeonsManager()
|
||||
.getGates();
|
||||
for (Gate g : gats.keySet()) {
|
||||
Double x = g.getLoc().getX();
|
||||
Double y = g.getLoc().getY();
|
||||
Double z = g.getLoc().getZ();
|
||||
Double radius = Double.valueOf(g.getPortalRadius());
|
||||
if (loc.getX() < x+radius && loc.getX() > x-radius) {
|
||||
if (loc.getY() < y+radius && loc.getY() > y-radius) {
|
||||
if (loc.getZ() < z+radius && loc.getZ() > z-radius) {
|
||||
if (loc.getX() < x + radius && loc.getX() > x - radius) {
|
||||
if (loc.getY() < y + radius && loc.getY() > y - radius) {
|
||||
if (loc.getZ() < z + radius && loc.getZ() > z - radius) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -83,16 +88,22 @@ public class DungeonUtils {
|
|||
* @return the gates which is in range
|
||||
*/
|
||||
public static Gate whichIsInRange(Location loc) {
|
||||
Raxen main = (Raxen) Bukkit.getServer().getPluginManager().getPlugin("Raxen");
|
||||
HashMap<Gate, Location> gats = main.getManager().getDungeonsManager().getGates();
|
||||
Raxen main = (Raxen) Bukkit
|
||||
.getServer()
|
||||
.getPluginManager()
|
||||
.getPlugin("Raxen");
|
||||
HashMap<Gate, Location> gats = main
|
||||
.getManager()
|
||||
.getDungeonsManager()
|
||||
.getGates();
|
||||
for (Gate g : gats.keySet()) {
|
||||
Double x = g.getLoc().getX();
|
||||
Double y = g.getLoc().getY();
|
||||
Double z = g.getLoc().getZ();
|
||||
Double radius = Double.valueOf(g.getPortalRadius());
|
||||
if (loc.getX() < x+radius && loc.getX() > x-radius) {
|
||||
if (loc.getY() < y+radius && loc.getY() > y-radius) {
|
||||
if (loc.getZ() < z+radius && loc.getZ() > z-radius) {
|
||||
if (loc.getX() < x + radius && loc.getX() > x - radius) {
|
||||
if (loc.getY() < y + radius && loc.getY() > y - radius) {
|
||||
if (loc.getZ() < z + radius && loc.getZ() > z - radius) {
|
||||
return g;
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue