Update to new name Raxen
This commit is contained in:
parent
5f548d81db
commit
5761aa5e79
34 changed files with 215 additions and 211 deletions
107
src/main/java/gq/unurled/raxen/commands/admin/NbtCommand.java
Normal file
107
src/main/java/gq/unurled/raxen/commands/admin/NbtCommand.java
Normal file
|
@ -0,0 +1,107 @@
|
|||
package gq.unurled.raxen.commands.admin;
|
||||
|
||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.player.Skills;
|
||||
import gq.unurled.raxen.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.raxen.utils.Skills.updateSkills;
|
||||
import static gq.unurled.raxen.utils.Utils.*;
|
||||
|
||||
public class NbtCommand implements TabExecutor {
|
||||
|
||||
private ProfileManager profileManager;
|
||||
|
||||
public NbtCommand(Raxen 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, Raxen.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.raxen.commands.admin;
|
||||
|
||||
import gq.unurled.raxen.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.raxen.utils.Utils.*;
|
||||
|
||||
public class ReloadCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String msg, @NotNull String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if(!player.hasPermission("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.raxen.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.raxen.utils.Utils.color;
|
||||
import static gq.unurled.raxen.utils.Utils.log;
|
||||
|
||||
public class TestGuiCommand implements TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
if(player.hasPermission("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.raxen.commands.player;
|
||||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.player.Skills;
|
||||
import gq.unurled.raxen.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.raxen.utils.Utils.*;
|
||||
|
||||
public class SkillsCommand implements TabExecutor {
|
||||
|
||||
private ProfileManager profileManager;
|
||||
|
||||
public SkillsCommand(Raxen 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.raxen.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,59 @@
|
|||
package gq.unurled.raxen.commands.player;
|
||||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.manager.ProfileManager;
|
||||
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.bukkit.inventory.Inventory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.*;
|
||||
|
||||
public class StorageCommand implements TabExecutor {
|
||||
|
||||
private ProfileManager profileManager = Raxen.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;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue