First Commit
This commit is contained in:
commit
ba4641a4b2
32 changed files with 1745 additions and 0 deletions
166
pom.xml
Normal file
166
pom.xml
Normal file
|
@ -0,0 +1,166 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>gq.unurled</groupId>
|
||||
<artifactId>elixium</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Elixium</name>
|
||||
|
||||
<properties>
|
||||
<java.version>1.16</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>maven-snapshots</id>
|
||||
<url>https://repository.apache.org/content/repositories/snapshots/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.3.1-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>de.tr7zw.changeme.nbtapi</pattern>
|
||||
<shadedPattern>de.tr7zw.nbtapi</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc-repo</id>
|
||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
<layout>default</layout>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>dmulloy2-repo</id>
|
||||
<url>https://repo.dmulloy2.net/repository/public/</url>
|
||||
</repository>
|
||||
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>nms</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/api/patched_1.17.1.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.22</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mongodb</groupId>
|
||||
<artifactId>mongodb-driver-sync</artifactId>
|
||||
<version>4.3.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.tr7zw</groupId>
|
||||
<artifactId>nbt-data-api</artifactId>
|
||||
<version>2.8.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>de.tr7zw</groupId>
|
||||
<artifactId>nbt-injector</artifactId>
|
||||
<version>2.8.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.simplix-softworks</groupId>
|
||||
<artifactId>SimplixStorage</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>4.7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>com.github.Th0rgal</groupId>
|
||||
<artifactId>Oraxen</artifactId>
|
||||
<version>1.117.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/api/oraxen-1.117.0.jar</systemPath>
|
||||
</dependency>
|
||||
-->
|
||||
<dependency>
|
||||
<groupId>com.github.lokka30</groupId>
|
||||
<artifactId>LevelledMobs</artifactId>
|
||||
<version>3.2.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.Archy-X</groupId>
|
||||
<artifactId>AureliumSkills</artifactId>
|
||||
<version>Beta1.2.5</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
124
src/main/java/gq/unurled/elixium/Elixium.java
Normal file
124
src/main/java/gq/unurled/elixium/Elixium.java
Normal file
|
@ -0,0 +1,124 @@
|
|||
package gq.unurled.elixium;
|
||||
|
||||
import com.archyx.aureliumskills.api.AureliumAPI;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import gq.unurled.elixium.config.Config;
|
||||
import gq.unurled.elixium.config.PlayerConfig;
|
||||
import gq.unurled.elixium.manager.*;
|
||||
import gq.unurled.elixium.utils.MongoDB;
|
||||
import gq.unurled.elixium.utils.Reload;
|
||||
import io.netty.channel.Channel;
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static gq.unurled.elixium.utils.Utils.msgPlayer;
|
||||
|
||||
public final class Elixium extends JavaPlugin {
|
||||
|
||||
private static final String prefix = ChatColor.AQUA + "Ex" + ChatColor.LIGHT_PURPLE + "> ";
|
||||
private final PluginManager pm = getServer().getPluginManager();
|
||||
|
||||
private static Elixium plugin;
|
||||
|
||||
private static Logger logger;
|
||||
|
||||
private static MongoDB mongoDB;
|
||||
|
||||
private static Config config;
|
||||
|
||||
private static PlayerManager playerManager;
|
||||
private static ProfileManager profileManager;
|
||||
private static PlayerConfig playerConfig;
|
||||
|
||||
private static ListenerManager listenerManager;
|
||||
private static CommandManager commandManager;
|
||||
|
||||
@Getter
|
||||
private ProtocolManager protocolManager;
|
||||
@Getter
|
||||
public AureliumAPI aureliumAPI;
|
||||
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
logger = getLogger();
|
||||
mongoDB = new MongoDB();
|
||||
//config = new Config(this);
|
||||
|
||||
profileManager = new ProfileManager(this);
|
||||
listenerManager = new ListenerManager(this);
|
||||
commandManager = new CommandManager(this);
|
||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
|
||||
playerConfig = new PlayerConfig(this);
|
||||
aureliumAPI = new AureliumAPI();
|
||||
|
||||
registerCommands();
|
||||
registerEvents();
|
||||
|
||||
getServer().getConsoleSender().sendMessage(Component.text(prefix +"§aServer Started Successfully!"));
|
||||
}
|
||||
|
||||
private void registerCommands() {
|
||||
commandManager.register();
|
||||
|
||||
getServer().getConsoleSender().sendMessage(Component.text(prefix +"§aCommands Registered!"));
|
||||
}
|
||||
|
||||
private void registerEvents() {
|
||||
listenerManager.register();
|
||||
|
||||
getServer().getConsoleSender().sendMessage(Component.text(prefix +"§aEvents Registered!"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Reload.kickAll();
|
||||
|
||||
getServer().getConsoleSender().sendMessage(Component.text(prefix +"§cServer Stopped Successfully!"));
|
||||
}
|
||||
|
||||
public static Logger getPluginLogger() {
|
||||
return logger;
|
||||
}
|
||||
|
||||
public PluginManager getPm() {
|
||||
return pm;
|
||||
}
|
||||
|
||||
public static Elixium getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
return prefix;
|
||||
}
|
||||
|
||||
public static ProfileManager getProfileManager() {
|
||||
return profileManager;
|
||||
}
|
||||
|
||||
public static PlayerManager getPlayerManager() {
|
||||
return playerManager;
|
||||
}
|
||||
|
||||
public static MongoDB getMongoDB() {
|
||||
return mongoDB;
|
||||
}
|
||||
|
||||
public static PlayerConfig getPlayerConfig() {
|
||||
return playerConfig;
|
||||
}
|
||||
}
|
107
src/main/java/gq/unurled/elixium/commands/admin/NbtCommand.java
Normal file
107
src/main/java/gq/unurled/elixium/commands/admin/NbtCommand.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
package gq.unurled.elixium.commands.admin;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.components.player.Skills;
|
||||
import gq.unurled.elixium.manager.ProfileManager;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
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 static gq.unurled.elixium.utils.Skills.updateSkills;
|
||||
import static gq.unurled.elixium.utils.Utils.*;
|
||||
|
||||
public class NbtCommand implements TabExecutor {
|
||||
|
||||
private ProfileManager profileManager;
|
||||
|
||||
public NbtCommand(Elixium main) {
|
||||
this.profileManager = main.getProfileManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String msg, @NotNull String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
error(color("&cYou can't execute this command as the Console!"));
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if(player.getInventory().getItemInMainHand().getType() == Material.AIR || player.getInventory().getItemInMainHand() == null) {
|
||||
msgPlayer(player,color("&cYou must hold an Item in hand."));
|
||||
return true;
|
||||
}
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
case 1:
|
||||
msgPlayer(player, color("&cYou must specify an nbt and an int."));
|
||||
break;
|
||||
case 2:
|
||||
log("'"+args[0]+"'", "'"+args[1]+"'");
|
||||
ItemStack it = player.getInventory().getItemInMainHand();
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
int a = 0;
|
||||
if(nbti.hasKey(args[1])) {
|
||||
a = nbti.getInteger(args[1]);
|
||||
}
|
||||
List<Component> lore = new ArrayList<>();
|
||||
ItemMeta itm = it.getItemMeta();
|
||||
lore.add((Component) itm.lore());
|
||||
Boolean yes = false;
|
||||
Boolean ever = false;
|
||||
for(Component ct : lore) {
|
||||
if (ct != null) {
|
||||
if (ct.contains(Component.text("Attributes:"))) {
|
||||
yes = true;
|
||||
ever = true;
|
||||
} else {
|
||||
if (yes) {
|
||||
ct.append(Component.text(color(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a))));
|
||||
yes = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!ever) {
|
||||
lore.add(Component.text(color("&cAttributes:")));
|
||||
lore.add(Component.text(color(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a) )));
|
||||
}
|
||||
itm.lore(lore);
|
||||
it.setItemMeta(itm);
|
||||
Skills skills = profileManager.getPlayerProfile(player.getUniqueId()).getSkils();
|
||||
nbti.setInteger(args[0], Integer.parseInt(args[1]) + a);
|
||||
if(nbti.hasKey("SPEED")) {
|
||||
skills.addSpeed(nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasKey("HEALTH")) {
|
||||
skills.addHealth(nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if(nbti.hasKey("DEFENSE")) {
|
||||
skills.addDefense(nbti.getInteger("DEFENSE"));
|
||||
}
|
||||
if(nbti.hasKey("STRENGTH")) {
|
||||
skills.addStrength(nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
it = nbti.getItem();
|
||||
msgPlayer(player, Elixium.getPrefix() + color("&fYou successfully added the nbt " +attributes(args[0]) + "&fwith " + args[1] + "&f."));
|
||||
updateSkills(player);
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), it);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package gq.unurled.elixium.commands.admin;
|
||||
|
||||
import gq.unurled.elixium.utils.Reload;
|
||||
import org.bukkit.Bukkit;
|
||||
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;
|
||||
|
||||
import static gq.unurled.elixium.utils.Utils.*;
|
||||
|
||||
public class ReloadCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String msg, @NotNull String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if(!player.hasPermission("elixium.reload.cmd")) {
|
||||
player.sendMessage(noPerms());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reload.kickAll();
|
||||
log(color("&cServer stopping!\n Using: /rlpl.\n Please wait a little bit."));
|
||||
Bukkit.getServer().shutdown();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package gq.unurled.elixium.commands.admin;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
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;
|
||||
|
||||
import static gq.unurled.elixium.utils.Utils.color;
|
||||
import static gq.unurled.elixium.utils.Utils.log;
|
||||
|
||||
public class TestGuiCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if(player.hasPermission("elixium.test.gui.cmd")) {
|
||||
player.openInventory(Bukkit.createInventory(null, 54, Component.text(color(args[0]))));
|
||||
}
|
||||
}
|
||||
else {
|
||||
log("The console can't execute this Command!");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package gq.unurled.elixium.commands.player;
|
||||
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.components.player.Skills;
|
||||
import gq.unurled.elixium.manager.ProfileManager;
|
||||
import net.kyori.adventure.text.Component;
|
||||
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;
|
||||
|
||||
import static gq.unurled.elixium.utils.Utils.*;
|
||||
|
||||
public class SkillsCommand implements TabExecutor {
|
||||
|
||||
private ProfileManager profileManager;
|
||||
|
||||
public SkillsCommand(Elixium main) {
|
||||
this.profileManager = main.getProfileManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String msg, @NotNull String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
error("The console can't execute this Command!");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Skills skills = profileManager.getPlayerProfile(player.getUniqueId()).getSkils();
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
//open gui
|
||||
player.sendMessage(Component.text(color("&cGUI not implemented yet..")).append(Component.text(color("&cTry /skill help."))));
|
||||
break;
|
||||
case 1:
|
||||
case 2:
|
||||
player.sendMessage(Component.text(color("&fUse the command like: "))
|
||||
.append(Component.text(color("&f/skill &3{health|defense|speed|strength} {add|set|remove} {amount}"))));
|
||||
break;
|
||||
case 3:
|
||||
switch (args[0]) {
|
||||
case "health":
|
||||
if(args[1].equalsIgnoreCase("add")) {
|
||||
skills.setHealth(skills.getHealth() + Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You were added " + args[2] + " health more!");
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("set")) {
|
||||
skills.setHealth(Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You are set " + args[2] + " health!");
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("remove")) {
|
||||
skills.setHealth(skills.getHealth() - Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You were removeded " + args[2] + " health less!");
|
||||
|
||||
}
|
||||
break;
|
||||
case "defense":
|
||||
if(args[1].equalsIgnoreCase("add")) {
|
||||
skills.setDefense(skills.getDefense() + Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You were added " + args[2] + " defense more!");
|
||||
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("set")) {
|
||||
skills.setDefense(Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You are set " + args[2] + " defense!");
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("remove")) {
|
||||
skills.setDefense(skills.getDefense() - Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You were removed " + args[2] + " defense less!");
|
||||
}
|
||||
break;
|
||||
case "speed":
|
||||
if(args[1].equalsIgnoreCase("add")) {
|
||||
skills.setSpeed(skills.getSpeed() + Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You were added " + args[2] + " speed more!");
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("set")) {
|
||||
skills.setSpeed(Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You are set " + args[2] + " speed!");
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("remove")) {
|
||||
skills.setSpeed(skills.getSpeed() - Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You were removed " + args[2] + " speed less!");
|
||||
}
|
||||
break;
|
||||
case "stregnth":
|
||||
if(args[1].equalsIgnoreCase("add")) {
|
||||
skills.setStrength(skills.getStrength() + Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You were added " + args[2] + " strength more!");
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("set")) {
|
||||
skills.setStrength(Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You are set " + args[2] + " strength!");
|
||||
}
|
||||
if(args[1].equalsIgnoreCase("remove")) {
|
||||
skills.setStrength(skills.getStrength() - Integer.parseInt(args[2]));
|
||||
msgPlayer(player,"You were removed " + args[2] + " strength less!");
|
||||
}
|
||||
break;
|
||||
}
|
||||
gq.unurled.elixium.utils.Skills.updateSkills(player);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package gq.unurled.elixium.commands.player;
|
||||
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.manager.PlayerManager;
|
||||
import gq.unurled.elixium.manager.ProfileManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static gq.unurled.elixium.utils.Utils.*;
|
||||
|
||||
public class StorageCommand implements TabExecutor {
|
||||
|
||||
private ProfileManager profileManager = Elixium.getProfileManager();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(!(sender instanceof Player)) {
|
||||
error("The console can't execute this Command!");
|
||||
return true;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
Inventory inv;
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if(profileManager.getPlayerStorage(player.getUniqueId()) != null) {
|
||||
inv = profileManager.getPlayerStorage(player.getUniqueId()).getEc().getEc();
|
||||
}
|
||||
else {
|
||||
profileManager.createNewStorage(player);
|
||||
inv = profileManager.getPlayerStorage(player.getUniqueId()).getEc().getEc();
|
||||
}
|
||||
player.openInventory(inv);
|
||||
|
||||
break;
|
||||
case 1:
|
||||
Player p = Bukkit.getPlayer(args[0]);
|
||||
if(p == null) {
|
||||
msgPlayer(player, color("&cYou can't open the Storage of an unknown Player."));
|
||||
return true;
|
||||
}
|
||||
inv = profileManager.getPlayerStorage(p.getUniqueId()).getEc().getEc();
|
||||
player.openInventory(inv);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package gq.unurled.elixium.components.player;
|
||||
|
||||
import gq.unurled.elixium.components.player.Storages.EnderChest;
|
||||
import gq.unurled.elixium.components.player.Storages.Inventory;
|
||||
|
||||
public class Inventories {
|
||||
private Inventory inv;
|
||||
|
||||
public Inventories(Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
|
||||
public Inventory getInv() {
|
||||
return inv;
|
||||
}
|
||||
|
||||
public void setInv(Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package gq.unurled.elixium.components.player;
|
||||
|
||||
public class Profile {
|
||||
|
||||
private Skills skils;
|
||||
|
||||
public Profile(Skills skils) {
|
||||
this.skils = skils;
|
||||
}
|
||||
|
||||
public Skills getSkils() {
|
||||
return skils;
|
||||
}
|
||||
|
||||
public void setSkils(Skills skils) {
|
||||
this.skils = skils;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package gq.unurled.elixium.components.player;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class Skills {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int health, defense, speed, strength;
|
||||
|
||||
public Skills(int health, int defense, int speed, int strength) {
|
||||
this.health = health;
|
||||
this.defense = defense;
|
||||
this.speed = speed;
|
||||
this.strength = strength;
|
||||
}
|
||||
|
||||
public void removeSpeed(int i) {
|
||||
this.speed =this.getSpeed() - i;
|
||||
}
|
||||
public void removeHealth(int i) {
|
||||
this.health =this.getHealth() - i;
|
||||
}
|
||||
public void removeDefense(int i) {
|
||||
this.defense =this.getDefense() - i;
|
||||
}
|
||||
public void removeStrength(int i) {
|
||||
this.strength =this.getStrength() - i;
|
||||
}
|
||||
|
||||
public void addSpeed(int i) {
|
||||
this.speed = this.getSpeed() + i;
|
||||
}
|
||||
public void addHealth(int i) {
|
||||
this.health = this.getHealth() + i;
|
||||
}
|
||||
public void addDefense(int i) {
|
||||
this.defense = this.getDefense() + i;
|
||||
}
|
||||
public void addStrength(int i) {
|
||||
this.strength = this.getStrength() + i;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package gq.unurled.elixium.components.player;
|
||||
|
||||
import gq.unurled.elixium.components.player.Storages.EnderChest;
|
||||
|
||||
public class Storage {
|
||||
|
||||
private EnderChest ec;
|
||||
|
||||
public Storage(EnderChest ec) {
|
||||
this.ec = ec;
|
||||
}
|
||||
|
||||
public EnderChest getEc() {
|
||||
return ec;
|
||||
}
|
||||
|
||||
public void setEc(EnderChest ec) {
|
||||
this.ec = ec;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package gq.unurled.elixium.components.player.Storages;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
public class EnderChest {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||
|
||||
public EnderChest(Inventory ec) {
|
||||
this.ec = ec;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package gq.unurled.elixium.components.player.Storages;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
|
||||
public class Inventory {
|
||||
@Getter
|
||||
@Setter
|
||||
public org.bukkit.inventory.Inventory inv = Bukkit.createInventory(null, InventoryType.PLAYER);
|
||||
|
||||
public Inventory(org.bukkit.inventory.Inventory inv) {
|
||||
this.inv = inv;
|
||||
}
|
||||
}
|
30
src/main/java/gq/unurled/elixium/config/Config.java
Normal file
30
src/main/java/gq/unurled/elixium/config/Config.java
Normal file
|
@ -0,0 +1,30 @@
|
|||
package gq.unurled.elixium.config;
|
||||
|
||||
import de.leonhard.storage.Json;
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class Config {
|
||||
private Elixium main;
|
||||
|
||||
private File configFile;
|
||||
|
||||
@Getter
|
||||
private FileConfiguration config;
|
||||
|
||||
|
||||
public Config(Elixium main) {
|
||||
this.main = main;
|
||||
this.config = main.getConfig();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
if (!(new File(main.getDataFolder() + "/config.yml").exists())) {
|
||||
main.saveDefaultConfig();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
120
src/main/java/gq/unurled/elixium/config/PlayerConfig.java
Normal file
120
src/main/java/gq/unurled/elixium/config/PlayerConfig.java
Normal file
|
@ -0,0 +1,120 @@
|
|||
package gq.unurled.elixium.config;
|
||||
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.model.Filters;
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.components.player.Inventories;
|
||||
import gq.unurled.elixium.components.player.Profile;
|
||||
import gq.unurled.elixium.components.player.Skills;
|
||||
import gq.unurled.elixium.components.player.Storage;
|
||||
import gq.unurled.elixium.components.player.Storages.EnderChest;
|
||||
import gq.unurled.elixium.manager.ProfileManager;
|
||||
import gq.unurled.elixium.utils.MongoDB;
|
||||
import gq.unurled.elixium.utils.Utils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bson.Document;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
import static gq.unurled.elixium.utils.Utils.log;
|
||||
|
||||
public class PlayerConfig {
|
||||
|
||||
private Elixium main;
|
||||
private MongoDB mongoDB;
|
||||
private MongoCollection<Document> mongoCollection;
|
||||
private ProfileManager profileManager;
|
||||
|
||||
public PlayerConfig(Elixium main) {
|
||||
this.main = main;
|
||||
this.mongoDB = main.getMongoDB();
|
||||
this.mongoCollection = mongoDB.getMongoCollection();
|
||||
this.profileManager = main.getProfileManager();
|
||||
}
|
||||
|
||||
public void savePlayerConfig(Player player) {
|
||||
Skills skills = profileManager.getPlayerProfile(player.getUniqueId()).getSkils();
|
||||
Inventory inv = player.getInventory();
|
||||
List<String> listInv = new ArrayList<String>();
|
||||
Integer reverse = 0;
|
||||
for(ItemStack it : inv) {
|
||||
reverse = reverse + 1;
|
||||
if(it != null && it.getType() != Material.AIR) {
|
||||
String s = Utils.itemStackSerilize(it, reverse);
|
||||
listInv.add(s);
|
||||
}
|
||||
}
|
||||
String invstr = Utils.listItemStackSerelize(listInv);
|
||||
Document doc = new Document("uuid", player.getUniqueId().toString())
|
||||
.append("name", player.getName())
|
||||
.append("health", skills.getHealth())
|
||||
.append("defense", skills.getDefense())
|
||||
.append("speed", skills.getSpeed())
|
||||
.append("strength", skills.getStrength())
|
||||
.append("inv", invstr);
|
||||
if (profileManager.getPlayerStorage(player.getUniqueId()) != null) {
|
||||
if(profileManager.getPlayerStorage(player.getUniqueId()).getEc() != null) {
|
||||
EnderChest ec = profileManager.getPlayerStorage(player.getUniqueId()).getEc();
|
||||
List<String> list = new ArrayList<String>();
|
||||
reverse = 0;
|
||||
for(ItemStack it : ec.getEc()) {
|
||||
reverse += 1;
|
||||
if(it != null) {
|
||||
String s = Utils.itemStackSerilize(it, reverse);
|
||||
list.add(s);
|
||||
}
|
||||
}
|
||||
String ecstr = Utils.listItemStackSerelize(list);
|
||||
doc.append("ec", ecstr);
|
||||
}
|
||||
}
|
||||
Document playerDoc = mongoCollection.find(Filters.eq("uuid", player.getUniqueId().toString())).first();
|
||||
if(playerDoc == null) {
|
||||
mongoCollection.insertOne(doc);
|
||||
}
|
||||
else {
|
||||
mongoCollection.replaceOne(Filters.eq("uuid", player.getUniqueId().toString()), doc);
|
||||
}
|
||||
log("Player: " + player.getName() + " data successfully saved!");
|
||||
}
|
||||
|
||||
public void loadPlayerConfig(Player player) {
|
||||
Document playerDoc = mongoCollection.find(Filters.eq("uuid", player.getUniqueId().toString())).first();
|
||||
if(playerDoc == null) {
|
||||
profileManager.createNewProfile(player);
|
||||
profileManager.createNewStorage(player);
|
||||
profileManager.createNewInventory(player);
|
||||
return;
|
||||
}
|
||||
Skills skills = new Skills(playerDoc.getInteger("health"), playerDoc.getInteger("defense"), playerDoc.getInteger("speed"), playerDoc.getInteger("strength"));
|
||||
Profile profile = new Profile(skills);
|
||||
profileManager.setPlayerProfile(player.getUniqueId(), profile);
|
||||
Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||
if(playerDoc.getString("ec") != null) {
|
||||
ItemStack[] itList = Utils.listItemStackDeserilize(playerDoc.getString("ec"));
|
||||
ec.addItem(itList);
|
||||
}
|
||||
EnderChest ecc = new EnderChest(ec);
|
||||
Storage storage = new Storage(ecc);
|
||||
profileManager.setPlayerStorage(player.getUniqueId(), storage);
|
||||
Inventory inv = Bukkit.createInventory(player, InventoryType.PLAYER);
|
||||
ItemStack[] itListInv = Utils.listItemStackDeserilize(playerDoc.getString("inv"));
|
||||
inv.addItem(itListInv);
|
||||
player.updateInventory();
|
||||
gq.unurled.elixium.components.player.Storages.Inventory invv = new gq.unurled.elixium.components.player.Storages.Inventory(inv);
|
||||
Inventories invvv = new Inventories(invv);
|
||||
profileManager.setPlayerInventory(player.getUniqueId(), invvv);
|
||||
log("Player: " + player.getName() + " data successfully loaded!");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package gq.unurled.elixium.listener.player;
|
||||
|
||||
import com.destroystokyo.paper.event.player.PlayerArmorChangeEvent;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.components.player.Skills;
|
||||
import gq.unurled.elixium.manager.ProfileManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ArmorEvent implements Listener {
|
||||
|
||||
private ProfileManager profileManager;
|
||||
|
||||
public ArmorEvent(Elixium main) {
|
||||
this.profileManager = main.getProfileManager();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ArmorChangeEvent(PlayerArmorChangeEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
Skills skills = profileManager.getPlayerProfile(player.getUniqueId()).getSkils();
|
||||
if(e.getOldItem() != null && e.getOldItem().getType() != Material.AIR) {
|
||||
ItemStack oldItem = e.getOldItem();
|
||||
NBTItem nbti = new NBTItem(oldItem);
|
||||
if(nbti.hasKey("SPEED")) {
|
||||
skills.removeSpeed(nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasKey("HEALTH")) {
|
||||
skills.removeHealth(nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if(nbti.hasKey("DEFENSE")) {
|
||||
skills.removeDefense(nbti.getInteger("DEFENSE"));
|
||||
}
|
||||
if(nbti.hasKey("STRENGTH")) {
|
||||
skills.removeStrength(nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
}
|
||||
if(e.getNewItem() != null && e.getNewItem().getType() != Material.AIR) {
|
||||
ItemStack newItem = e.getNewItem();
|
||||
NBTItem nbti = new NBTItem(newItem);
|
||||
if(nbti.hasKey("SPEED")) {
|
||||
skills.addSpeed(nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasKey("HEALTH")) {
|
||||
skills.addHealth(nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if(nbti.hasKey("DEFENSE")) {
|
||||
skills.addDefense(nbti.getInteger("DEFENSE"));
|
||||
}
|
||||
if(nbti.hasKey("STRENGTH")) {
|
||||
skills.addStrength(nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
}
|
||||
gq.unurled.elixium.utils.Skills.updateSkills(player);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package gq.unurled.elixium.listener.player;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.components.player.Skills;
|
||||
import gq.unurled.elixium.manager.ProfileManager;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class ItemHandEvent implements Listener {
|
||||
|
||||
private ProfileManager profileManager;
|
||||
|
||||
public ItemHandEvent(Elixium main) {
|
||||
this.profileManager = main.getProfileManager();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ItemHeldEvent(PlayerItemHeldEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
Skills skills = profileManager.getPlayerProfile(player.getUniqueId()).getSkils();
|
||||
ItemStack oldItem = player.getInventory().getItem(e.getPreviousSlot());
|
||||
ItemStack newItem = player.getInventory().getItem(e.getNewSlot());
|
||||
if(oldItem != null && oldItem.getType() != Material.AIR) {
|
||||
NBTItem nbti = new NBTItem(oldItem);
|
||||
if(nbti.hasKey("SPEED")) {
|
||||
skills.removeSpeed(nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasKey("HEALTH")) {
|
||||
skills.removeHealth(nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if(nbti.hasKey("DEFENSE")) {
|
||||
skills.removeDefense(nbti.getInteger("DEFENSE"));
|
||||
}
|
||||
if(nbti.hasKey("STRENGTH")) {
|
||||
skills.removeStrength(nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
}
|
||||
if(newItem != null && newItem.getType() != Material.AIR) {
|
||||
NBTItem nbti = new NBTItem(newItem);
|
||||
if(nbti.hasKey("SPEED")) {
|
||||
skills.addSpeed(nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasKey("HEALTH")) {
|
||||
skills.addHealth(nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if(nbti.hasKey("DEFENSE")) {
|
||||
skills.addDefense(nbti.getInteger("DEFENSE"));
|
||||
}
|
||||
if(nbti.hasKey("STRENGTH")) {
|
||||
skills.addStrength(nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
}
|
||||
gq.unurled.elixium.utils.Skills.updateSkills(player);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package gq.unurled.elixium.listener.player;
|
||||
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.config.PlayerConfig;
|
||||
import gq.unurled.elixium.manager.ProfileManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class JoinEvent implements Listener {
|
||||
|
||||
private Elixium main;
|
||||
private ProfileManager profileManager;
|
||||
private PlayerConfig playerConfig;
|
||||
|
||||
public JoinEvent(Elixium main) {
|
||||
this.main = main;
|
||||
this.profileManager = main.getProfileManager();
|
||||
this.playerConfig = main.getPlayerConfig();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerJoinEvent(PlayerJoinEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
playerConfig.loadPlayerConfig(player);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package gq.unurled.elixium.listener.player;
|
||||
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.config.PlayerConfig;
|
||||
import gq.unurled.elixium.manager.ProfileManager;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class LeaveEvent implements Listener {
|
||||
|
||||
private final PlayerConfig playerConfig;
|
||||
|
||||
public LeaveEvent(Elixium main) {
|
||||
ProfileManager profileManager = main.getProfileManager();
|
||||
this.playerConfig = main.getPlayerConfig();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PlayerLeaveEvent(PlayerQuitEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
playerConfig.savePlayerConfig(player);
|
||||
}
|
||||
}
|
42
src/main/java/gq/unurled/elixium/manager/CommandManager.java
Normal file
42
src/main/java/gq/unurled/elixium/manager/CommandManager.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package gq.unurled.elixium.manager;
|
||||
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.commands.admin.NbtCommand;
|
||||
import gq.unurled.elixium.commands.admin.ReloadCommand;
|
||||
import gq.unurled.elixium.commands.admin.TestGuiCommand;
|
||||
import gq.unurled.elixium.commands.player.SkillsCommand;
|
||||
import gq.unurled.elixium.commands.player.StorageCommand;
|
||||
|
||||
|
||||
public class CommandManager {
|
||||
|
||||
private Elixium main;
|
||||
|
||||
public CommandManager(Elixium main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
public void register() {
|
||||
ReloadCommand reloadComand = new ReloadCommand();
|
||||
main.getCommand("reloadplugin").setExecutor(reloadComand);
|
||||
main.getCommand("reloadplugin").setTabCompleter(reloadComand);
|
||||
|
||||
NbtCommand nbtCommand = new NbtCommand(main);
|
||||
main.getCommand("nbt").setExecutor(nbtCommand);
|
||||
main.getCommand("nbt").setTabCompleter(nbtCommand);
|
||||
|
||||
TestGuiCommand testGuiCommand = new TestGuiCommand();
|
||||
main.getCommand("testgui").setExecutor(testGuiCommand);
|
||||
main.getCommand("testgui").setTabCompleter(testGuiCommand);
|
||||
|
||||
StorageCommand storageCommand = new StorageCommand();
|
||||
main.getCommand("storage").setExecutor(storageCommand);
|
||||
main.getCommand("storage").setTabCompleter(storageCommand);
|
||||
|
||||
|
||||
SkillsCommand skillsCommand = new SkillsCommand(main);
|
||||
main.getCommand("skills").setTabCompleter(skillsCommand);
|
||||
main.getCommand("skills").setExecutor(skillsCommand);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package gq.unurled.elixium.manager;
|
||||
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.listener.player.*;
|
||||
import gq.unurled.elixium.utils.AureliumSkills;
|
||||
import gq.unurled.elixium.utils.Reload;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
public class ListenerManager {
|
||||
|
||||
private final Elixium main;
|
||||
private final PluginManager pm;
|
||||
|
||||
public ListenerManager(Elixium main) {
|
||||
this.main = main;
|
||||
this.pm = main.getPm();
|
||||
}
|
||||
|
||||
public void register() {
|
||||
this.pm.registerEvents(new JoinEvent(main), main);
|
||||
this.pm.registerEvents(new LeaveEvent(main), main);
|
||||
this.pm.registerEvents(new ArmorEvent(main), main);
|
||||
this.pm.registerEvents(new ItemHandEvent(main), main);
|
||||
this.pm.registerEvents(new AureliumSkills(main), main);
|
||||
this.pm.registerEvents(new Reload(), main);
|
||||
}
|
||||
}
|
15
src/main/java/gq/unurled/elixium/manager/PlayerManager.java
Normal file
15
src/main/java/gq/unurled/elixium/manager/PlayerManager.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package gq.unurled.elixium.manager;
|
||||
|
||||
import gq.unurled.elixium.Elixium;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlayerManager {
|
||||
|
||||
private Elixium main;
|
||||
|
||||
public PlayerManager(Elixium main) {
|
||||
this.main = main;
|
||||
}
|
||||
}
|
95
src/main/java/gq/unurled/elixium/manager/ProfileManager.java
Normal file
95
src/main/java/gq/unurled/elixium/manager/ProfileManager.java
Normal file
|
@ -0,0 +1,95 @@
|
|||
package gq.unurled.elixium.manager;
|
||||
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.components.player.Inventories;
|
||||
import gq.unurled.elixium.components.player.Profile;
|
||||
import gq.unurled.elixium.components.player.Skills;
|
||||
import gq.unurled.elixium.components.player.Storage;
|
||||
import gq.unurled.elixium.components.player.Storages.EnderChest;
|
||||
import gq.unurled.elixium.components.player.Storages.Inventory;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static gq.unurled.elixium.utils.Utils.log;
|
||||
|
||||
public class ProfileManager {
|
||||
|
||||
private Elixium main;
|
||||
private Map<UUID, Profile> profiles = new HashMap<>();
|
||||
private Map<UUID, Storage> storages = new HashMap<>();
|
||||
private Map<UUID, Inventories> inventory = new HashMap<>();
|
||||
|
||||
public ProfileManager(Elixium main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
public Profile createNewProfile(Player player) {
|
||||
Skills skills = new Skills( 100, 50, 100, 100);
|
||||
Profile profile = new Profile(skills);
|
||||
profiles.put(player.getUniqueId(), profile);
|
||||
return profile;
|
||||
}
|
||||
|
||||
public Profile getPlayerProfile(UUID uuid) {
|
||||
return profiles.get(uuid);
|
||||
}
|
||||
|
||||
public void setPlayerProfile(UUID uuid, Profile profile) {
|
||||
if(profiles.get(uuid) == null) {
|
||||
profiles.put(uuid, profile);
|
||||
}
|
||||
else {
|
||||
profiles.replace(uuid, profile);
|
||||
}
|
||||
log("Profile Updated!");
|
||||
}
|
||||
|
||||
public Storage createNewStorage(Player player) {
|
||||
EnderChest ec = new EnderChest(Bukkit.createInventory(null, 54, Component.text("Ender Chest")));
|
||||
Storage storage = new Storage(ec);
|
||||
storages.put(player.getUniqueId(), storage);
|
||||
return storage;
|
||||
}
|
||||
|
||||
public Storage getPlayerStorage(UUID uuid) {
|
||||
return storages.get(uuid);
|
||||
}
|
||||
|
||||
public void setPlayerStorage(UUID uuid, Storage storage) {
|
||||
if(storages.get(uuid) == null) {
|
||||
storages.put(uuid, storage);
|
||||
}
|
||||
else {
|
||||
storages.replace(uuid, storage);
|
||||
}
|
||||
log("Storage Updated!");
|
||||
}
|
||||
|
||||
public Inventories createNewInventory(Player player) {
|
||||
Inventory inv = new Inventory(Bukkit.createInventory(null, InventoryType.PLAYER));
|
||||
Inventories inves = new Inventories(inv);
|
||||
inventory.put(player.getUniqueId(), inves);
|
||||
return inves;
|
||||
}
|
||||
|
||||
public Inventories getPlayerInventory(UUID uuid) {
|
||||
return inventory.get(uuid);
|
||||
}
|
||||
|
||||
public void setPlayerInventory(UUID uuid, Inventories inventories) {
|
||||
if(inventory.get(uuid) == null) {
|
||||
inventory.put(uuid, inventories);
|
||||
}
|
||||
else {
|
||||
inventory.replace(uuid, inventories);
|
||||
}
|
||||
log("Inventory Updated!");
|
||||
}
|
||||
|
||||
}
|
53
src/main/java/gq/unurled/elixium/utils/AureliumSkills.java
Normal file
53
src/main/java/gq/unurled/elixium/utils/AureliumSkills.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package gq.unurled.elixium.utils;
|
||||
|
||||
import com.archyx.aureliumskills.api.AureliumAPI;
|
||||
import com.archyx.aureliumskills.api.event.SkillLevelUpEvent;
|
||||
import com.archyx.aureliumskills.skills.Skill;
|
||||
import com.archyx.aureliumskills.skills.SkillRegistry;
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
|
||||
import static gq.unurled.elixium.utils.Utils.log;
|
||||
import static gq.unurled.elixium.utils.Utils.msgPlayer;
|
||||
|
||||
public class AureliumSkills implements Listener {
|
||||
|
||||
private static AureliumAPI aureliumAPI;
|
||||
|
||||
public AureliumSkills(Elixium main) {
|
||||
this.aureliumAPI = main.getAureliumAPI();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void skillLevelUp(SkillLevelUpEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
Skill skill = e.getSkill();
|
||||
Integer level = e.getLevel();
|
||||
switch (skill.name()){
|
||||
case "FARMING":
|
||||
case "FORAGING":
|
||||
case "MINING":
|
||||
case "FISHING":
|
||||
case "EXCAVATION":
|
||||
case "ARCHERY":
|
||||
case "DEFENSE":
|
||||
case "FIGHTING":
|
||||
case "ENDURANCE":
|
||||
case "AGILITY":
|
||||
case "ALCHEMY":
|
||||
case "ENCHANTING":
|
||||
case "SORCERY":
|
||||
case "HEALING":
|
||||
case "FORGING":
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
34
src/main/java/gq/unurled/elixium/utils/MongoDB.java
Normal file
34
src/main/java/gq/unurled/elixium/utils/MongoDB.java
Normal file
|
@ -0,0 +1,34 @@
|
|||
package gq.unurled.elixium.utils;
|
||||
|
||||
import com.mongodb.ConnectionString;
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoClients;
|
||||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.MongoDatabase;
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import lombok.Getter;
|
||||
import org.bson.Document;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public class MongoDB {
|
||||
@Getter
|
||||
private MongoClient mongoClient;
|
||||
@Getter
|
||||
private MongoDatabase mongoDatabase;
|
||||
@Getter
|
||||
private MongoCollection<Document> mongoCollection;
|
||||
|
||||
public MongoDB() {
|
||||
this.connect();
|
||||
}
|
||||
|
||||
public void connect() {
|
||||
ConnectionString connectionString = new ConnectionString("mongodb://localhost:27017");
|
||||
mongoClient = MongoClients.create(connectionString);
|
||||
mongoDatabase = mongoClient.getDatabase("Elixium");
|
||||
mongoCollection = mongoDatabase.getCollection("player");
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "MongoDB connected!");
|
||||
}
|
||||
}
|
55
src/main/java/gq/unurled/elixium/utils/Reload.java
Normal file
55
src/main/java/gq/unurled/elixium/utils/Reload.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
package gq.unurled.elixium.utils;
|
||||
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.config.Config;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static gq.unurled.elixium.utils.Utils.log;
|
||||
|
||||
public class Reload implements Listener {
|
||||
|
||||
private static FileConfiguration config = Elixium.getPlugin().getConfig();
|
||||
private static boolean serverReloading = true;
|
||||
|
||||
public static void kickAll() {
|
||||
for(Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.kick(Component.text(Elixium.getPrefix() + "\n §cServer is Restarting\n §cPlease Wait a few Minutes to reconnect."));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public static void pingList(ServerListPingEvent e) throws IOException {
|
||||
setPingList(e);
|
||||
}
|
||||
|
||||
public static void setPingList(ServerListPingEvent e) throws IOException {
|
||||
if(serverReloading) {
|
||||
List<String> newLines = new ArrayList<>();
|
||||
for(String line : Files.readAllLines(Paths.get("server.properties"), StandardCharsets.UTF_8)) {
|
||||
if(line.contains("motd=")) {
|
||||
newLines.add("motd=" + config.get("motd-reload"));
|
||||
} else {
|
||||
newLines.add(line);
|
||||
}
|
||||
}
|
||||
Files.write(Paths.get("server.properties"), newLines, StandardCharsets.UTF_8);
|
||||
|
||||
e.motd(Component.text((String) config.get("motd-reload")));
|
||||
} else {
|
||||
e.motd(Component.text((String) config.get("motd")));
|
||||
}
|
||||
}
|
||||
}
|
25
src/main/java/gq/unurled/elixium/utils/Skills.java
Normal file
25
src/main/java/gq/unurled/elixium/utils/Skills.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package gq.unurled.elixium.utils;
|
||||
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import static gq.unurled.elixium.utils.Utils.color;
|
||||
import static gq.unurled.elixium.utils.Utils.msgPlayer;
|
||||
|
||||
public class Skills {
|
||||
|
||||
public static void updateSkills(Player player) {
|
||||
gq.unurled.elixium.components.player.Skills skills = Elixium.getProfileManager().getPlayerProfile(player.getUniqueId()).getSkils();
|
||||
int health, defense, speed, strength;
|
||||
health = skills.getHealth();
|
||||
defense = skills.getDefense();
|
||||
speed = skills.getSpeed();
|
||||
strength = skills.getStrength();
|
||||
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20D + health / 100);
|
||||
player.setWalkSpeed((float) (0.0 + (speed / 100) * 0.2));
|
||||
player.setFlySpeed((float) (0.0 + (speed / 100) * 0.2));
|
||||
msgPlayer(player, "Speed " + speed, "Health " + health, "Defense " + defense, "Strength " + strength);
|
||||
}
|
||||
|
||||
}
|
27
src/main/java/gq/unurled/elixium/utils/TabApi.java
Normal file
27
src/main/java/gq/unurled/elixium/utils/TabApi.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package gq.unurled.elixium.utils;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import net.minecraft.server.players.PlayerList;
|
||||
import gq.unurled.elixium.Elixium;
|
||||
|
||||
public class TabApi {
|
||||
|
||||
private ProtocolManager protocolManager;
|
||||
private Elixium main;
|
||||
|
||||
public TabApi(Elixium main) {
|
||||
this.main = main;
|
||||
this.protocolManager = main.getProtocolManager();
|
||||
}
|
||||
|
||||
public void packetListener() {
|
||||
protocolManager.addPacketListener(
|
||||
new PacketAdapter(main, ListenerPriority.NORMAL, PacketType.Play.Server.PLAYER_INFO) {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
}
|
233
src/main/java/gq/unurled/elixium/utils/Utils.java
Normal file
233
src/main/java/gq/unurled/elixium/utils/Utils.java
Normal file
|
@ -0,0 +1,233 @@
|
|||
package gq.unurled.elixium.utils;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import de.tr7zw.changeme.nbtapi.NBTCompound;
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import gq.unurled.elixium.Elixium;
|
||||
import gq.unurled.elixium.commands.admin.NbtCommand;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.checkerframework.checker.units.qual.N;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class Utils {
|
||||
|
||||
private static Logger logger = Elixium.getPluginLogger();
|
||||
|
||||
public static String color(String string) {
|
||||
return ChatColor.translateAlternateColorCodes('&', string);
|
||||
}
|
||||
|
||||
public static String decolor(String string) {
|
||||
return ChatColor.stripColor(color(string));
|
||||
}
|
||||
|
||||
public static void log(String... strings) {
|
||||
for(String string : strings) {
|
||||
logger.info(string);
|
||||
}
|
||||
}
|
||||
|
||||
public static void warn(String... strings) {
|
||||
for(String string : strings) {
|
||||
logger.warning(string);
|
||||
}
|
||||
}
|
||||
|
||||
public static void error(String... strings) {
|
||||
for(String string : strings) {
|
||||
logger.severe(string);
|
||||
}
|
||||
}
|
||||
|
||||
public static void msgPlayer(Player player, String... strings) {
|
||||
for(String string : strings) {
|
||||
player.sendMessage(Component.text(color(string)));
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack createItem(Material material, int amount, boolean glow, boolean unb, String name, String... lore) {
|
||||
ItemStack item = new ItemStack(material, amount);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if(name != null) {
|
||||
itemMeta.displayName(Component.text(color(name)));
|
||||
}
|
||||
if(lore != null) {
|
||||
List<Component> list = new ArrayList<>();
|
||||
for(String string : lore) {
|
||||
list.add(Component.text(color(string)));
|
||||
}
|
||||
itemMeta.lore(list);
|
||||
}
|
||||
if(glow) {
|
||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||
itemMeta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||
}
|
||||
if(unb) {
|
||||
itemMeta.setUnbreakable(true);
|
||||
}
|
||||
item.setItemMeta(itemMeta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static ItemStack editItem(ItemStack item, int amount, List<Component> lore) {
|
||||
if(amount == 0) {
|
||||
amount = 1;
|
||||
}
|
||||
item.setAmount(amount);
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
itemMeta.lore(lore);
|
||||
item.setItemMeta(itemMeta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public static Component noPerms() {
|
||||
return Component.text(color("&cYou don't have the permission to use this feature."));
|
||||
}
|
||||
|
||||
public static Component error() {
|
||||
return Component.text(color("&cAn Error has occurred. Please retry or contact an Admin."));
|
||||
}
|
||||
|
||||
public static String itemStackSerilize(ItemStack it, Integer slot) {
|
||||
Gson gson = new Gson();
|
||||
//String str = gson.toJson(it.serialize());
|
||||
String str = gson.toJson(it.serialize(), new TypeToken<Map>(){}.getType());
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
str = str + "@#NBT#" + nbti.toString();
|
||||
str = str + "@#SLOT#" + slot.toString();
|
||||
return str;
|
||||
}
|
||||
|
||||
public static class itemStackDeserilizeResult {
|
||||
int slot;
|
||||
ItemStack it;
|
||||
|
||||
public itemStackDeserilizeResult(Integer slot, ItemStack it) {
|
||||
this.slot = slot;
|
||||
this.it = it;
|
||||
}
|
||||
}
|
||||
|
||||
public static itemStackDeserilizeResult itemStackDeserilize(String str) {
|
||||
List<String> mapp = Arrays.asList(str.split("@#NBT#"));
|
||||
Gson gson = new Gson();
|
||||
ItemStack it = new ItemStack(Material.AIR);
|
||||
Integer slot = 0;
|
||||
for (String s : mapp) {
|
||||
if(s != null && s.length() > 2) {
|
||||
try {
|
||||
Map<String, Object> map = gson.fromJson(s, new TypeToken<Map<String, Object>>(){}.getType());
|
||||
it = ItemStack.deserialize(map);
|
||||
} catch (Exception e) {
|
||||
List<String> mappp = Arrays.asList(s.split("@#SLOT#"));
|
||||
for (String ss : mappp) {
|
||||
try {
|
||||
if (ss != null && ss.length() > 2) {
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
String strrr = ss;
|
||||
if (strrr.length() > 2) {
|
||||
for (String strr : strrr.split(",")) {
|
||||
if (!strr.equals("{") && !strr.equals("}")) {
|
||||
strr = strr.replace("{", "");
|
||||
strr = strr.replace("}", "");
|
||||
String[] nb = strr.split(":");
|
||||
nbti.setInteger(nb[0], Integer.valueOf(nb[1]));
|
||||
it = nbti.getItem();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Exception ee) {
|
||||
slot = Integer.valueOf(ss);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
itemStackDeserilizeResult itt = new itemStackDeserilizeResult(slot, it);
|
||||
return itt;
|
||||
}
|
||||
|
||||
public static String listItemStackSerelize(List<String> list) {
|
||||
Gson gson = new Gson();
|
||||
String str = "";
|
||||
for(String a : list) {
|
||||
str = str + "@#NEW_ITEM#" + a;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static ItemStack[] listItemStackDeserilize(String str) {
|
||||
Gson gson = new Gson();
|
||||
List<String> map = Arrays.asList(str.split("@#NEW_ITEM#"));
|
||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||
for(String s : map) {
|
||||
ItemStack itt;
|
||||
if(s != null) {
|
||||
itt = itemStackDeserilize(s).it;
|
||||
if (itt != null && itt.getType() != Material.AIR) {
|
||||
items.add(itt);
|
||||
}
|
||||
}
|
||||
}
|
||||
ItemStack[] it = items.toArray(new ItemStack[0]);
|
||||
return it;
|
||||
}
|
||||
|
||||
public static String attributes(String str) {
|
||||
String stt = "";
|
||||
if(str.contains("SPEED")) {
|
||||
stt = "&fSpeed";
|
||||
return stt;
|
||||
}
|
||||
if(str.contains("STRENGTH")) {
|
||||
stt = "&4Strength";
|
||||
return stt;
|
||||
}
|
||||
if(str.contains("HEALTH")) {
|
||||
stt = "&cHealth";
|
||||
return stt;
|
||||
}
|
||||
if(str.contains("DEFENSE")) {
|
||||
stt = "&1Defense";
|
||||
return stt;
|
||||
}
|
||||
else {
|
||||
stt = "None";
|
||||
return stt;
|
||||
}
|
||||
}
|
||||
|
||||
public static NBTItem setAttributes(String str, Integer nb, NBTItem nbti) {
|
||||
log(str);
|
||||
switch (str) {
|
||||
case "SPEED":
|
||||
nbti.setInteger("SPEED", nb);
|
||||
case "STRENGTH":
|
||||
nbti.setInteger("STRENGTH", nb);
|
||||
case "HEALTH":
|
||||
nbti.setInteger("HEALTH", nb);
|
||||
case "DEFENSE":
|
||||
nbti.setInteger("DEFENSE", nb);
|
||||
default:
|
||||
error("Cant set Attributes with an unknown attribute.");
|
||||
}
|
||||
return nbti;
|
||||
}
|
||||
|
||||
}
|
2
src/main/resources/config.yml
Normal file
2
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
motd: "YAY, Super server!"
|
||||
motd-reload: "Server reloading!"
|
0
src/main/resources/players.yml
Normal file
0
src/main/resources/players.yml
Normal file
30
src/main/resources/plugin.yml
Normal file
30
src/main/resources/plugin.yml
Normal file
|
@ -0,0 +1,30 @@
|
|||
name: Elixium
|
||||
version: '${project.version}'
|
||||
main: gq.unurled.elixium.Elixium
|
||||
api-version: 1.17
|
||||
depend: [ProtocolLib]
|
||||
|
||||
commands:
|
||||
reloadplugin:
|
||||
aliases:
|
||||
- rlpl
|
||||
- reloadpl
|
||||
description: reload command that stops the server.
|
||||
skills:
|
||||
aliases:
|
||||
- skill
|
||||
description: skill command.
|
||||
testgui:
|
||||
description: test gui command
|
||||
storage:
|
||||
description: acces player storage
|
||||
nbt:
|
||||
description: nbt command
|
||||
|
||||
permissions:
|
||||
elixium.reload.cmd:
|
||||
description: reload command permission
|
||||
elixium.test.gui.cmd:
|
||||
description: testgui command permission
|
||||
elixium.nbt.cmd:
|
||||
description: nbt command permission
|
Loading…
Reference in a new issue