0.0.3: Custom item with ItemManager.java and little bit of Vault/EssentialsX econnomy handling
- create item with yml files. - preparing for CustomModelData and custom ressource pack handeling (somewhat like oraxen hosting rp) - error with Scoreboard.java need to search how to update a score.
This commit is contained in:
parent
f60f12921e
commit
3e5a9c5e2e
25 changed files with 870 additions and 23 deletions
12
FUTURE.md
Normal file
12
FUTURE.md
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# Future for Raxen
|
||||||
|
#### to wich direction i want Raxen to go ?
|
||||||
|
Some RPG thing :
|
||||||
|
- Hypixel has Skyblock
|
||||||
|
- Wyncraft has Quests
|
||||||
|
- Raxen must do :
|
||||||
|
- some survival and RPG thing
|
||||||
|
- need some sort of action => pve, pvp maybe ?
|
||||||
|
- need custom mobs
|
||||||
|
- need custom items
|
||||||
|
- can use custom texture pack
|
||||||
|
- protection and logging feature => coreprotect
|
|
@ -7,5 +7,7 @@ Minecraft Plugin that do multiple stuff.
|
||||||
|
|
||||||
no build and no running info atm.
|
no build and no running info atm.
|
||||||
|
|
||||||
|
to use custom texture for items, modify the custom data model => [Example](https://www.youtube.com/watch?v=XGxn_Mb8VzI)
|
||||||
|
|
||||||
for more info contact me.
|
for more info contact me.
|
||||||
@unurled#0149
|
@unurled#0149
|
||||||
|
|
20
pom.xml
20
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>gq.unurled</groupId>
|
<groupId>gq.unurled</groupId>
|
||||||
<artifactId>raxen</artifactId>
|
<artifactId>raxen</artifactId>
|
||||||
<version>0.0.2</version>
|
<version>0.0.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Raxen</name>
|
<name>Raxen</name>
|
||||||
|
@ -87,6 +87,10 @@
|
||||||
<id>dmulloy2-repo</id>
|
<id>dmulloy2-repo</id>
|
||||||
<url>https://repo.dmulloy2.net/repository/public/</url>
|
<url>https://repo.dmulloy2.net/repository/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>essentials-releases</id>
|
||||||
|
<url>https://repo.essentialsx.net/releases/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
|
@ -102,7 +106,7 @@
|
||||||
<artifactId>nms</artifactId>
|
<artifactId>nms</artifactId>
|
||||||
<version>4.7.0</version>
|
<version>4.7.0</version>
|
||||||
<scope>system</scope>
|
<scope>system</scope>
|
||||||
<systemPath>${project.basedir}/api/patched_1.17.1.jar</systemPath>
|
<systemPath>${project.basedir}/api/paper-1.18.1.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
|
@ -167,6 +171,18 @@
|
||||||
<version>5.3</version>
|
<version>5.3</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.MilkBowl</groupId>
|
||||||
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.essentialsx</groupId>
|
||||||
|
<artifactId>EssentialsX</artifactId>
|
||||||
|
<version>2.19.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -9,6 +9,7 @@ import gq.unurled.raxen.manager.*;
|
||||||
import gq.unurled.raxen.utils.LuckPerm;
|
import gq.unurled.raxen.utils.LuckPerm;
|
||||||
import gq.unurled.raxen.utils.MongoDB;
|
import gq.unurled.raxen.utils.MongoDB;
|
||||||
import gq.unurled.raxen.utils.Reload;
|
import gq.unurled.raxen.utils.Reload;
|
||||||
|
import gq.unurled.raxen.utils.Vault;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
@ -21,7 +22,7 @@ public final class Raxen extends JavaPlugin {
|
||||||
|
|
||||||
private static final String prefix = ChatColor.AQUA + "Rx" + ChatColor.LIGHT_PURPLE + "> ";
|
private static final String prefix = ChatColor.AQUA + "Rx" + ChatColor.LIGHT_PURPLE + "> ";
|
||||||
@Getter
|
@Getter
|
||||||
private static final String version = "0.0.2";
|
private static final String version = "0.0.3";
|
||||||
private final PluginManager pm = getServer().getPluginManager();
|
private final PluginManager pm = getServer().getPluginManager();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -38,7 +39,12 @@ public final class Raxen extends JavaPlugin {
|
||||||
private static PlayerConfig playerConfig;
|
private static PlayerConfig playerConfig;
|
||||||
|
|
||||||
private static ListenerManager listenerManager;
|
private static ListenerManager listenerManager;
|
||||||
|
@Getter
|
||||||
private static CommandManager commandManager;
|
private static CommandManager commandManager;
|
||||||
|
@Getter
|
||||||
|
private gq.unurled.raxen.manager.ProtocolManager protoManager;
|
||||||
|
@Getter
|
||||||
|
private ItemManager itemManager;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private ProtocolManager protocolManager;
|
private ProtocolManager protocolManager;
|
||||||
|
@ -46,25 +52,33 @@ public final class Raxen extends JavaPlugin {
|
||||||
public AureliumAPI aureliumAPI;
|
public AureliumAPI aureliumAPI;
|
||||||
@Getter
|
@Getter
|
||||||
public LuckPerm luckPerm;
|
public LuckPerm luckPerm;
|
||||||
|
@Getter
|
||||||
|
public Vault vault;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
plugin = this;
|
plugin = this;
|
||||||
logger = getLogger();
|
logger = getLogger();
|
||||||
|
|
||||||
|
//Config and storage sruff
|
||||||
config = new Config(this);
|
config = new Config(this);
|
||||||
storageManager = new StorageManager(this);
|
storageManager = new StorageManager(this);
|
||||||
//config = new Config(this);
|
|
||||||
|
|
||||||
|
//Managers
|
||||||
|
itemManager = new ItemManager(this);
|
||||||
profileManager = new ProfileManager(this);
|
profileManager = new ProfileManager(this);
|
||||||
listenerManager = new ListenerManager(this);
|
listenerManager = new ListenerManager(this);
|
||||||
commandManager = new CommandManager(this);
|
commandManager = new CommandManager(this);
|
||||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
|
protoManager = new gq.unurled.raxen.manager.ProtocolManager(this);
|
||||||
|
|
||||||
playerConfig = new PlayerConfig(this);
|
playerConfig = new PlayerConfig(this);
|
||||||
aureliumAPI = new AureliumAPI();
|
aureliumAPI = new AureliumAPI();
|
||||||
luckPerm = new LuckPerm(this);
|
luckPerm = new LuckPerm(this);
|
||||||
luckPerm.register();
|
luckPerm.register();
|
||||||
|
vault = new Vault(this);
|
||||||
|
|
||||||
|
//register Commands and Events
|
||||||
registerCommands();
|
registerCommands();
|
||||||
registerEvents();
|
registerEvents();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package gq.unurled.raxen.commands;
|
package gq.unurled.raxen.commands;
|
||||||
|
|
||||||
import gq.unurled.raxen.Raxen;
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.manager.StorageManager;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
@ -42,14 +43,57 @@ public class RaxenCommand implements TabExecutor {
|
||||||
case "MONGODB":
|
case "MONGODB":
|
||||||
case "MONGO":
|
case "MONGO":
|
||||||
//print info about connection
|
//print info about connection
|
||||||
|
msgPlayer(player, Raxen.getPrefix() + color("&6--------------------------------"),color("&cMONGO DB"));
|
||||||
|
msgPlayer(player, StorageManager.getMongo().getMongoClient().getClusterDescription().toString());
|
||||||
|
msgPlayer(player, StorageManager.getMongo().getMongoDatabase().getName());
|
||||||
|
msgPlayer(player, StorageManager.getMongo().getMongoCollection().getNamespace().toString());
|
||||||
case "v":
|
case "v":
|
||||||
case "version":
|
case "version":
|
||||||
case "ver":
|
case "ver":
|
||||||
//print case 0?
|
msgPl(player, 0);
|
||||||
case "hemlp":
|
case "hemlp":
|
||||||
case "?":
|
case "?":
|
||||||
case "h":
|
case "h":
|
||||||
//print plugin help
|
//print help
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
switch (args.length) {
|
||||||
|
case 0:
|
||||||
|
sender.sendMessage(Raxen.getPrefix() + color("&6Printing About Raxen..."),
|
||||||
|
color("&6---------------------------------------------"),
|
||||||
|
color("&3 Raxen "),
|
||||||
|
color("&3 - Version: " + Raxen.getVersion()),
|
||||||
|
color("&3 - Author: &l&cU&6n&eu&2r&al&be&3d&r"));
|
||||||
|
TextComponent txt = Component.text(color("&3 - Website: https://unurled.gq"));
|
||||||
|
sender.sendMessage(txt);
|
||||||
|
case 1:
|
||||||
|
switch (args[0]) {
|
||||||
|
case "mongodb":
|
||||||
|
case "mongo":
|
||||||
|
case "MONGODB":
|
||||||
|
case "MONGO":
|
||||||
|
//print info about connection
|
||||||
|
sender.sendMessage( Raxen.getPrefix() + color("&6--------------------------------"),color("&cMONGO DB"));
|
||||||
|
sender.sendMessage( StorageManager.getMongo().getMongoClient().getClusterDescription().toString());
|
||||||
|
sender.sendMessage( StorageManager.getMongo().getMongoDatabase().getName());
|
||||||
|
sender.sendMessage( StorageManager.getMongo().getMongoCollection().getNamespace().toString());
|
||||||
|
case "v":
|
||||||
|
case "version":
|
||||||
|
case "ver":
|
||||||
|
sender.sendMessage(Raxen.getPrefix() + color("&6Printing About Raxen..."),
|
||||||
|
color("&6---------------------------------------------"),
|
||||||
|
color("&3 Raxen "),
|
||||||
|
color("&3 - Version: " + Raxen.getVersion()),
|
||||||
|
color("&3 - Author: &l&cU&6n&eu&2r&al&be&3d&r"));
|
||||||
|
txt = Component.text(color("&3 - Website: https://unurled.gq"));
|
||||||
|
sender.sendMessage(txt);
|
||||||
|
sender.sendMessage(color("&6---------------------------------------------"));
|
||||||
|
case "hemlp":
|
||||||
|
case "?":
|
||||||
|
case "h":
|
||||||
|
//print help
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,8 +109,8 @@ public class RaxenCommand implements TabExecutor {
|
||||||
color("&3 - Version: " + Raxen.getVersion()),
|
color("&3 - Version: " + Raxen.getVersion()),
|
||||||
color("&3 - Author: &l&cU&6n&eu&2r&al&be&3d&r"),
|
color("&3 - Author: &l&cU&6n&eu&2r&al&be&3d&r"),
|
||||||
color("&3 - Website: https://unurled.gq"));
|
color("&3 - Website: https://unurled.gq"));
|
||||||
TextComponent txt = Component.text(color("&3 - Website: https://unurled.gq"));
|
TextComponent txt = Component.text(color("&3 - Website: https://unurled.gq"))
|
||||||
txt.clickEvent(ClickEvent.openUrl("https://unurled.gq"));
|
.clickEvent(ClickEvent.openUrl("https://unurled.gq"));
|
||||||
player.sendMessage(txt);
|
player.sendMessage(txt);
|
||||||
msgPlayer(player, "", color("&6---------------------------------------------"));
|
msgPlayer(player, "", color("&6---------------------------------------------"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package gq.unurled.raxen.commands.admin;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.components.gui.ItemListGui;
|
||||||
|
import lombok.Getter;
|
||||||
|
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 ItemListCommand implements TabExecutor {
|
||||||
|
|
||||||
|
private Raxen main;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private ItemListGui itemListGui;
|
||||||
|
|
||||||
|
public ItemListCommand(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
this.itemListGui = new ItemListGui(this.main);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String msg, @NotNull String[] args) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
log("Console can't execute this command atm.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if(!(player.hasPermission("raxen.itemlist.cmd"))) {
|
||||||
|
msgPlayer(player, color("&cYou'dont have the permission to execute this command."));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//openGui logic
|
||||||
|
player.openInventory(itemListGui.getInv());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
package gq.unurled.raxen.components.enchantments;
|
||||||
|
|
||||||
|
import io.papermc.paper.enchantments.EnchantmentRarity;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.enchantments.EnchantmentTarget;
|
||||||
|
import org.bukkit.entity.EntityCategory;
|
||||||
|
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 String name;
|
||||||
|
private final int maxLevel;
|
||||||
|
|
||||||
|
public EnchantmentWarpper(String nameSpace, String name, int lvl) {
|
||||||
|
super(NamespacedKey.minecraft(nameSpace));
|
||||||
|
this.name = name;
|
||||||
|
this.maxLevel = lvl;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxLevel() {
|
||||||
|
return maxLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getStartLevel() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull EnchantmentTarget getItemTarget() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTreasure() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCursed() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean conflictsWith(@NotNull Enchantment other) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canEnchantItem(@NotNull ItemStack item) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Component displayName(int level) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isTradeable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isDiscoverable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull EnchantmentRarity getRarity() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getDamageIncrease(int level, @NotNull EntityCategory entityCategory) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull Set<EquipmentSlot> getActiveSlots() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull String translationKey() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package gq.unurled.raxen.components.enchantments.player;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.components.enchantments.EnchantmentWarpper;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Container;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class Telekinesis implements Listener {
|
||||||
|
|
||||||
|
public static final Enchantment TELEKINESIS = new EnchantmentWarpper("telekinesis", "telekinesis", 1);
|
||||||
|
}
|
218
src/main/java/gq/unurled/raxen/components/gui/ItemListGui.java
Normal file
218
src/main/java/gq/unurled/raxen/components/gui/ItemListGui.java
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
package gq.unurled.raxen.components.gui;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.manager.ItemManager;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static gq.unurled.raxen.utils.Utils.*;
|
||||||
|
|
||||||
|
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 List<ItemStack> itlist;
|
||||||
|
|
||||||
|
public ItemListGui(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
this.itlist = this.main.getItemManager().getList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ItemStack PREVIOUS = createItem(Material.ARROW, 1,true, false, "Previous page");
|
||||||
|
private ItemStack NEXT = createItem(Material.ARROW, 1,true, false, "Next page");
|
||||||
|
private ItemStack PAGE = createItem(Material.PAPER, 1,true, false, "Page");
|
||||||
|
private ItemStack CLOSE = closeItem();
|
||||||
|
private ItemStack GREY_PANE = greyPane();
|
||||||
|
|
||||||
|
public Inventory getInv() {
|
||||||
|
Integer page = 1;
|
||||||
|
Integer item = -1;
|
||||||
|
for (ItemStack it : itlist) {
|
||||||
|
item++;
|
||||||
|
if(item > 44 && item < 91) {
|
||||||
|
inv2.addItem(it);
|
||||||
|
inv2.setItem(48, PREVIOUS);
|
||||||
|
inv2.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||||
|
inv2.setItem(53, CLOSE);
|
||||||
|
inv2 = fillGreyPane(inv2);
|
||||||
|
}
|
||||||
|
if (item > 90 && item < 136) {
|
||||||
|
inv3.setItem(48, PREVIOUS);
|
||||||
|
inv3.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||||
|
inv3.setItem(53, CLOSE);
|
||||||
|
inv3 = fillGreyPane(inv3);
|
||||||
|
}
|
||||||
|
if (item > 135 && item < 181) {
|
||||||
|
inv4.addItem(it);
|
||||||
|
inv4.setItem(48, PREVIOUS);
|
||||||
|
inv4.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||||
|
inv4.setItem(53, CLOSE);
|
||||||
|
inv4 = fillGreyPane(inv4);
|
||||||
|
}
|
||||||
|
if (item > 180 && item < 226) {
|
||||||
|
inv5.addItem(it);
|
||||||
|
inv5.setItem(48, PREVIOUS);
|
||||||
|
inv5.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||||
|
inv5.setItem(53, CLOSE);
|
||||||
|
inv5 = fillGreyPane(inv5);
|
||||||
|
}
|
||||||
|
if (item > 225 && item < 271) {
|
||||||
|
inv6.addItem(it);
|
||||||
|
inv6.setItem(48, PREVIOUS);
|
||||||
|
inv6.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||||
|
inv6.setItem(53, CLOSE);
|
||||||
|
inv6 = fillGreyPane(inv6);
|
||||||
|
}
|
||||||
|
if (item > 270 && item < 316) {
|
||||||
|
inv7.addItem(it);
|
||||||
|
inv7.setItem(48, PREVIOUS);
|
||||||
|
inv7.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||||
|
inv7.setItem(53, CLOSE);
|
||||||
|
inv7 = fillGreyPane(inv7);
|
||||||
|
}
|
||||||
|
if (item > 315 && item < 361) {
|
||||||
|
inv8.addItem(it);
|
||||||
|
inv8.setItem(48, PREVIOUS);
|
||||||
|
inv8.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||||
|
inv8.setItem(53, CLOSE);
|
||||||
|
inv8 = fillGreyPane(inv8);
|
||||||
|
}
|
||||||
|
if (item > 360 && item < 406) {
|
||||||
|
inv9.addItem(it);
|
||||||
|
inv9.setItem(48, PREVIOUS);
|
||||||
|
inv9.setItem(49, editItem(PAGE, "page" + page,1, new ArrayList<Component>()));
|
||||||
|
inv9.setItem(53, CLOSE);
|
||||||
|
inv9 = fillGreyPane(inv9);
|
||||||
|
}
|
||||||
|
if (item > 405) {
|
||||||
|
log("Too many item to render.");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inv.addItem(it);
|
||||||
|
inv.setItem(49, PAGE);
|
||||||
|
inv.setItem(50, NEXT);
|
||||||
|
}
|
||||||
|
if (item > 44) {
|
||||||
|
inv.setItem(50, NEXT);
|
||||||
|
if (item > 90) {
|
||||||
|
inv2.setItem(50, NEXT);
|
||||||
|
if (item > 135) {
|
||||||
|
inv3.setItem(50, NEXT);
|
||||||
|
if (item > 180) {
|
||||||
|
inv4.setItem(50, NEXT);
|
||||||
|
if (item > 225) {
|
||||||
|
inv5.setItem(50, NEXT);
|
||||||
|
if (item > 270) {
|
||||||
|
inv6.setItem(50, NEXT);
|
||||||
|
if (item > 315) {
|
||||||
|
inv7.setItem(50, NEXT);
|
||||||
|
if (item > 360) {
|
||||||
|
inv8.setItem(50, NEXT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
page++;
|
||||||
|
inv = fillGreyPane(inv);
|
||||||
|
}
|
||||||
|
return inv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void clickInventory(InventoryClickEvent e) {
|
||||||
|
Player player = (Player) e.getWhoClicked();
|
||||||
|
Inventory einv = e.getClickedInventory();
|
||||||
|
if (einv == inv || einv == inv2 || einv == inv3 ||
|
||||||
|
einv == inv4 || einv == inv5 || einv == inv6 ||
|
||||||
|
einv == inv7 || einv == inv8 || einv == inv9) {
|
||||||
|
if(e.getCurrentItem() != null && e.getCurrentItem().getType() != Material.AIR) {
|
||||||
|
Integer slot = e.getSlot();
|
||||||
|
ItemStack clicked;
|
||||||
|
if (slot ==48) {
|
||||||
|
//previous
|
||||||
|
if (e.getCurrentItem() != GREY_PANE) {
|
||||||
|
ItemStack pagee = einv.getItem(49);
|
||||||
|
Integer page = Integer.parseInt(pagee.displayName().toString().replace("page", ""));
|
||||||
|
switch(page) {
|
||||||
|
case 2:
|
||||||
|
player.openInventory(inv);
|
||||||
|
case 3:
|
||||||
|
player.openInventory(inv2);
|
||||||
|
case 4:
|
||||||
|
player.openInventory(inv3);
|
||||||
|
case 5:
|
||||||
|
player.openInventory(inv4);
|
||||||
|
case 6:
|
||||||
|
player.openInventory(inv5);
|
||||||
|
case 7:
|
||||||
|
player.openInventory(inv6);
|
||||||
|
case 8:
|
||||||
|
player.openInventory(inv7);
|
||||||
|
case 9:
|
||||||
|
player.openInventory(inv8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (slot == 49) {
|
||||||
|
//page
|
||||||
|
return;
|
||||||
|
} else if (slot == 50) {
|
||||||
|
//next
|
||||||
|
ItemStack pagee = einv.getItem(49);
|
||||||
|
Integer page = Integer.parseInt(pagee.displayName().toString().replace("page", ""));
|
||||||
|
switch(page) {
|
||||||
|
case 1:
|
||||||
|
player.openInventory(inv2);
|
||||||
|
case 2:
|
||||||
|
player.openInventory(inv3);
|
||||||
|
case 3:
|
||||||
|
player.openInventory(inv4);
|
||||||
|
case 4:
|
||||||
|
player.openInventory(inv5);
|
||||||
|
case 5:
|
||||||
|
player.openInventory(inv6);
|
||||||
|
case 6:
|
||||||
|
player.openInventory(inv7);
|
||||||
|
case 7:
|
||||||
|
player.openInventory(inv8);
|
||||||
|
case 8:
|
||||||
|
player.openInventory(inv9);
|
||||||
|
}
|
||||||
|
} else if (slot == 53) {
|
||||||
|
//close
|
||||||
|
player.closeInventory();
|
||||||
|
} else {
|
||||||
|
//if (player.getInventory().firstEmpty() == -1) {
|
||||||
|
//add to stash
|
||||||
|
//}
|
||||||
|
player.getInventory().addItem(e.getCurrentItem());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
package gq.unurled.raxen.components.items;
|
||||||
|
|
||||||
|
public class CustomModelData {
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package gq.unurled.raxen.components.player;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.utils.Vault;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
import org.bukkit.scoreboard.Score;
|
||||||
|
import org.bukkit.scoreboard.ScoreboardManager;
|
||||||
|
|
||||||
|
import static gq.unurled.raxen.utils.Utils.color;
|
||||||
|
import static gq.unurled.raxen.utils.Utils.log;
|
||||||
|
|
||||||
|
public class Scoreboard {
|
||||||
|
|
||||||
|
private Raxen main;
|
||||||
|
private Vault vault;
|
||||||
|
|
||||||
|
public Scoreboard(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
this.vault = main.getVault();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createScorebord(Player player) {
|
||||||
|
ScoreboardManager manager = Bukkit.getScoreboardManager();
|
||||||
|
org.bukkit.scoreboard.Scoreboard board = manager.getNewScoreboard();
|
||||||
|
Objective obj = board.registerNewObjective("Raxen","dummy", Component.text(color("&cElixium")));
|
||||||
|
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
Score score = obj.getScore(color("&6-------------"));
|
||||||
|
score.setScore(4);
|
||||||
|
Score score1 = obj.getScore(color("&bName:" + player.getName()));
|
||||||
|
score1.setScore(3);
|
||||||
|
Score score2 = obj.getScore(color("&fLocation"));
|
||||||
|
score2.setScore(2);
|
||||||
|
Score score3 = obj.getScore(color("&6Coins: &6" + vault.getBalanceString(player)));
|
||||||
|
score3.setScore(1);
|
||||||
|
Score score4 = obj.getScore(color("&eunurled.gq"));
|
||||||
|
score4.setScore(0);
|
||||||
|
player.setScoreboard(board);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateScoreboardTransaction(Player player) {
|
||||||
|
if(player != null) {
|
||||||
|
Objective objective = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
|
||||||
|
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
|
||||||
|
log(String.valueOf(player.getScoreboard().getEntries()));
|
||||||
|
for (String str : player.getScoreboard().getEntries()) {
|
||||||
|
if(str.contains(player.getName())) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
player.getScoreboard().resetScores("Coins");
|
||||||
|
Score score = objective.getScore(color("&6Coins: &6" + vault.getBalanceString(player)));
|
||||||
|
score.setScore(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -178,10 +178,10 @@ public class PlayerConfig {
|
||||||
|
|
||||||
|
|
||||||
Object storage = sto.getConfig().get("storage");
|
Object storage = sto.getConfig().get("storage");
|
||||||
if ("MONGODB".equals(storage)) {
|
if (storage == "MONGODB") {
|
||||||
saveUsingMongoDB(player, skills, invstr, reverse);
|
saveUsingMongoDB(player, skills, invstr, reverse);
|
||||||
saveUsingMongoDB(player, skills, invstr, reverse);
|
saveUsingMongoDB(player, skills, invstr, reverse);
|
||||||
} else if ("MYSQL".equals(storage) || "YML".equals(storage)) {
|
} else if (storage == "MYSQL" || storage == "YML") {
|
||||||
saveUsingYml(player, skills, invstr, reverse);
|
saveUsingYml(player, skills, invstr, reverse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package gq.unurled.raxen.listener.player;
|
||||||
|
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
public class EnchantmentManager {
|
||||||
|
public static void registerEnchantment(Enchantment enchantment) {
|
||||||
|
boolean registered = true;
|
||||||
|
try {
|
||||||
|
Field f = Enchantment.class.getDeclaredField("acceptingNew");
|
||||||
|
f.setAccessible(true);
|
||||||
|
f.set(null, true);
|
||||||
|
Enchantment.registerEnchantment(enchantment);
|
||||||
|
} catch (Exception e) {
|
||||||
|
registered = false;
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package gq.unurled.raxen.listener.player;
|
package gq.unurled.raxen.listener.player;
|
||||||
|
|
||||||
import gq.unurled.raxen.Raxen;
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.components.player.Scoreboard;
|
||||||
import gq.unurled.raxen.config.PlayerConfig;
|
import gq.unurled.raxen.config.PlayerConfig;
|
||||||
import gq.unurled.raxen.manager.ProfileManager;
|
import gq.unurled.raxen.manager.ProfileManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -13,17 +14,20 @@ public class JoinEvent implements Listener {
|
||||||
private Raxen main;
|
private Raxen main;
|
||||||
private ProfileManager profileManager;
|
private ProfileManager profileManager;
|
||||||
private PlayerConfig playerConfig;
|
private PlayerConfig playerConfig;
|
||||||
|
private Scoreboard scoreboard;
|
||||||
|
|
||||||
public JoinEvent(Raxen main) {
|
public JoinEvent(Raxen main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
this.profileManager = main.getProfileManager();
|
this.profileManager = main.getProfileManager();
|
||||||
this.playerConfig = main.getPlayerConfig();
|
this.playerConfig = main.getPlayerConfig();
|
||||||
|
this.scoreboard = new Scoreboard(main);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void PlayerJoinEvent(PlayerJoinEvent e) {
|
public void PlayerJoinEvent(PlayerJoinEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
playerConfig.loadPlayerConfig(player);
|
playerConfig.loadPlayerConfig(player);
|
||||||
|
scoreboard.createScorebord(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
package gq.unurled.raxen.listener.player;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.components.player.Scoreboard;
|
||||||
|
import gq.unurled.raxen.utils.Vault;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public class TransactionEvent implements Listener {
|
||||||
|
|
||||||
|
private Raxen main;
|
||||||
|
private Scoreboard scoreboard;
|
||||||
|
private Vault vault;
|
||||||
|
|
||||||
|
public TransactionEvent(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
this.scoreboard = new Scoreboard(main);
|
||||||
|
this.vault = main.getVault();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void transaction(net.essentialsx.api.v2.events.TransactionEvent e) {
|
||||||
|
Player player = Bukkit.getPlayer(e.getTarget().getName());
|
||||||
|
Player source = e.getRequester().getPlayer();
|
||||||
|
scoreboard.updateScoreboardTransaction(player);
|
||||||
|
scoreboard.updateScoreboardTransaction(source);
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,46 +2,54 @@ package gq.unurled.raxen.manager;
|
||||||
|
|
||||||
import gq.unurled.raxen.Raxen;
|
import gq.unurled.raxen.Raxen;
|
||||||
import gq.unurled.raxen.commands.RaxenCommand;
|
import gq.unurled.raxen.commands.RaxenCommand;
|
||||||
|
import gq.unurled.raxen.commands.admin.ItemListCommand;
|
||||||
import gq.unurled.raxen.commands.admin.NbtCommand;
|
import gq.unurled.raxen.commands.admin.NbtCommand;
|
||||||
import gq.unurled.raxen.commands.admin.ReloadCommand;
|
import gq.unurled.raxen.commands.admin.ReloadCommand;
|
||||||
import gq.unurled.raxen.commands.admin.TestGuiCommand;
|
import gq.unurled.raxen.commands.admin.TestGuiCommand;
|
||||||
import gq.unurled.raxen.commands.player.SkillsCommand;
|
import gq.unurled.raxen.commands.player.SkillsCommand;
|
||||||
import gq.unurled.raxen.commands.player.StorageCommand;
|
import gq.unurled.raxen.commands.player.StorageCommand;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
|
||||||
public class CommandManager {
|
public class CommandManager {
|
||||||
|
|
||||||
private Raxen main;
|
private Raxen main;
|
||||||
|
@Getter
|
||||||
|
private ItemListCommand itemListCommand;
|
||||||
|
private ReloadCommand reloadComand = new ReloadCommand();
|
||||||
|
private NbtCommand nbtCommand = new NbtCommand(main);
|
||||||
|
private TestGuiCommand testGuiCommand = new TestGuiCommand();
|
||||||
|
private StorageCommand storageCommand = new StorageCommand();
|
||||||
|
private SkillsCommand skillsCommand = new SkillsCommand(main);
|
||||||
|
private RaxenCommand raxenCommand = new RaxenCommand(main);
|
||||||
|
|
||||||
public CommandManager(Raxen main) {
|
public CommandManager(Raxen main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
|
this.itemListCommand = new ItemListCommand(this.main);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
ReloadCommand reloadComand = new ReloadCommand();
|
|
||||||
main.getCommand("reloadplugin").setExecutor(reloadComand);
|
main.getCommand("reloadplugin").setExecutor(reloadComand);
|
||||||
main.getCommand("reloadplugin").setTabCompleter(reloadComand);
|
main.getCommand("reloadplugin").setTabCompleter(reloadComand);
|
||||||
|
|
||||||
NbtCommand nbtCommand = new NbtCommand(main);
|
|
||||||
main.getCommand("nbt").setExecutor(nbtCommand);
|
main.getCommand("nbt").setExecutor(nbtCommand);
|
||||||
main.getCommand("nbt").setTabCompleter(nbtCommand);
|
main.getCommand("nbt").setTabCompleter(nbtCommand);
|
||||||
|
|
||||||
TestGuiCommand testGuiCommand = new TestGuiCommand();
|
|
||||||
main.getCommand("testgui").setExecutor(testGuiCommand);
|
main.getCommand("testgui").setExecutor(testGuiCommand);
|
||||||
main.getCommand("testgui").setTabCompleter(testGuiCommand);
|
main.getCommand("testgui").setTabCompleter(testGuiCommand);
|
||||||
|
|
||||||
StorageCommand storageCommand = new StorageCommand();
|
|
||||||
main.getCommand("storage").setExecutor(storageCommand);
|
main.getCommand("storage").setExecutor(storageCommand);
|
||||||
main.getCommand("storage").setTabCompleter(storageCommand);
|
main.getCommand("storage").setTabCompleter(storageCommand);
|
||||||
|
|
||||||
|
|
||||||
SkillsCommand skillsCommand = new SkillsCommand(main);
|
|
||||||
main.getCommand("skills").setTabCompleter(skillsCommand);
|
main.getCommand("skills").setTabCompleter(skillsCommand);
|
||||||
main.getCommand("skills").setExecutor(skillsCommand);
|
main.getCommand("skills").setExecutor(skillsCommand);
|
||||||
|
|
||||||
RaxenCommand raxenCommand = new RaxenCommand(main);
|
|
||||||
main.getCommand("raxen").setTabCompleter(raxenCommand);
|
main.getCommand("raxen").setTabCompleter(raxenCommand);
|
||||||
main.getCommand("raxen").setExecutor(raxenCommand);
|
main.getCommand("raxen").setExecutor(raxenCommand);
|
||||||
|
|
||||||
|
main.getCommand("itemlist").setExecutor(itemListCommand);
|
||||||
|
main.getCommand("itemlist").setTabCompleter(itemListCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
132
src/main/java/gq/unurled/raxen/manager/ItemManager.java
Normal file
132
src/main/java/gq/unurled/raxen/manager/ItemManager.java
Normal file
|
@ -0,0 +1,132 @@
|
||||||
|
package gq.unurled.raxen.manager;
|
||||||
|
|
||||||
|
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static gq.unurled.raxen.utils.Utils.*;
|
||||||
|
|
||||||
|
public class ItemManager {
|
||||||
|
|
||||||
|
private final Raxen main;
|
||||||
|
@Getter
|
||||||
|
private List<ItemStack> list = new ArrayList<>();
|
||||||
|
|
||||||
|
public ItemManager(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
register();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void example() {
|
||||||
|
File customFile;
|
||||||
|
FileConfiguration customConfig;
|
||||||
|
customFile = new File(main.getDataFolder() + "/Items/", "/example.yml");
|
||||||
|
|
||||||
|
if (!customFile.exists()) {
|
||||||
|
customFile.getParentFile().mkdirs();
|
||||||
|
try {
|
||||||
|
customFile.createNewFile();
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
error("Error in Item Manager saving new File.");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
customConfig = new YamlConfiguration();
|
||||||
|
try {
|
||||||
|
customConfig.load(customFile);
|
||||||
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
lore.add("&csuper lore wahou");
|
||||||
|
if (customConfig.get("name") == null) {
|
||||||
|
customConfig.set("id", "minecraft_id_of_item");
|
||||||
|
customConfig.set("customId", "id_of_item_used_to_identify_it");
|
||||||
|
customConfig.set("name", "&cName of the Item");
|
||||||
|
customConfig.set("health", 100);
|
||||||
|
customConfig.set("defense", 50);
|
||||||
|
customConfig.set("speed", 100);
|
||||||
|
customConfig.set("strength", 100);
|
||||||
|
customConfig.set("custom_ability","fireball");
|
||||||
|
customConfig.set("custom_model_data", 123);
|
||||||
|
customConfig.set("lore",lore);
|
||||||
|
try {
|
||||||
|
customConfig.save(customFile);
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void register() {
|
||||||
|
File folder = new File(main.getDataFolder() + "/Items/");
|
||||||
|
File[] listFile = folder.listFiles();
|
||||||
|
|
||||||
|
|
||||||
|
for (int i = 0; i < listFile.length; i++) {
|
||||||
|
if (listFile[i].isFile()) {
|
||||||
|
FileConfiguration customItem = new YamlConfiguration();
|
||||||
|
try {
|
||||||
|
customItem.load(listFile[i]);
|
||||||
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
registerItem(customItem);
|
||||||
|
} else if (listFile[i].isDirectory()) {
|
||||||
|
for (int a = 0; a < listFile[i].listFiles().length; a++) {
|
||||||
|
if(listFile[i].listFiles()[a].isFile()) {
|
||||||
|
FileConfiguration customItem = new YamlConfiguration();
|
||||||
|
try {
|
||||||
|
customItem.load(listFile[i].listFiles()[a]);
|
||||||
|
} catch (IOException | InvalidConfigurationException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
registerItem(customItem);
|
||||||
|
} else if (listFile[i].listFiles()[a].isDirectory()) {
|
||||||
|
error("Cann't use more than 2 folder to get Items.yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerItem(FileConfiguration file) {
|
||||||
|
log((String) file.get("id"));
|
||||||
|
ItemStack it = new ItemStack(Material.getMaterial((String) file.get("id")));
|
||||||
|
ItemMeta itm = it.getItemMeta();
|
||||||
|
itm.displayName(Component.text(color((String) file.get("name"))));
|
||||||
|
List<Component> lore = new ArrayList<>();
|
||||||
|
for (String str : (List<String>) Objects.requireNonNull(file.get("lore"))) {
|
||||||
|
lore.add(Component.text(color(str)));
|
||||||
|
}
|
||||||
|
itm.lore(lore);
|
||||||
|
itm.setCustomModelData(file.getInt("custom_model_data"));
|
||||||
|
it.setItemMeta(itm);
|
||||||
|
NBTItem nbti = new NBTItem(it);
|
||||||
|
nbti.setInteger("SPEED", file.getInt("speed"));
|
||||||
|
nbti.setInteger("HEALTH", file.getInt("health"));
|
||||||
|
nbti.setInteger("DEFENSE", file.getInt("defense"));
|
||||||
|
nbti.setInteger("STRENGTH", file.getInt("strength"));
|
||||||
|
nbti.setString("ID", file.getString("customId"));
|
||||||
|
nbti.setString("CUSTOM_ABILITY", file.getString("custom_ability"));
|
||||||
|
it = nbti.getItem();
|
||||||
|
list.add(it);
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,5 +23,7 @@ public class ListenerManager {
|
||||||
this.pm.registerEvents(new ItemHandEvent(main), main);
|
this.pm.registerEvents(new ItemHandEvent(main), main);
|
||||||
this.pm.registerEvents(new AureliumSkills(main), main);
|
this.pm.registerEvents(new AureliumSkills(main), main);
|
||||||
this.pm.registerEvents(new Reload(), main);
|
this.pm.registerEvents(new Reload(), main);
|
||||||
|
this.pm.registerEvents(new TransactionEvent(main), main);
|
||||||
|
this.pm.registerEvents(main.getCommandManager().getItemListCommand().getItemListGui(), main);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
27
src/main/java/gq/unurled/raxen/manager/ProtocolManager.java
Normal file
27
src/main/java/gq/unurled/raxen/manager/ProtocolManager.java
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
package gq.unurled.raxen.manager;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.events.*;
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ProtocolManager {
|
||||||
|
private final Raxen main;
|
||||||
|
private com.comphenix.protocol.ProtocolManager manager;
|
||||||
|
|
||||||
|
public ProtocolManager(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
this.manager = main.getProtocolManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void listen() {
|
||||||
|
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.)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,7 +57,6 @@ public class StorageManager {
|
||||||
public static FileConfiguration createYml(Player player) {
|
public static FileConfiguration createYml(Player player) {
|
||||||
File customFile;
|
File customFile;
|
||||||
FileConfiguration customConfig;
|
FileConfiguration customConfig;
|
||||||
log(main.getDataFolder() + "/playerInfo/" + player.getUniqueId() + "/playerInfo.yml");
|
|
||||||
customFile = new File(main.getDataFolder() + "/playerInfo/" + player.getUniqueId(), "/playerInfo.yml");
|
customFile = new File(main.getDataFolder() + "/playerInfo/" + player.getUniqueId(), "/playerInfo.yml");
|
||||||
|
|
||||||
if (!customFile.exists()) {
|
if (!customFile.exists()) {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
@ -18,7 +19,7 @@ import java.util.logging.Logger;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
private static Logger logger = Raxen.getPluginLogger();
|
private static final Logger logger = Raxen.getPluginLogger();
|
||||||
|
|
||||||
public static String color(String string) {
|
public static String color(String string) {
|
||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
|
@ -76,17 +77,39 @@ public class Utils {
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack editItem(ItemStack item, int amount, List<Component> lore) {
|
public static ItemStack editItem(ItemStack item, String name,int amount, List<Component> lore) {
|
||||||
if(amount == 0) {
|
if(amount == 0) {
|
||||||
amount = 1;
|
amount = 1;
|
||||||
}
|
}
|
||||||
item.setAmount(amount);
|
item.setAmount(amount);
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (name != null) {
|
||||||
|
itemMeta.displayName(Component.text(name));
|
||||||
|
}
|
||||||
itemMeta.lore(lore);
|
itemMeta.lore(lore);
|
||||||
item.setItemMeta(itemMeta);
|
item.setItemMeta(itemMeta);
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ItemStack closeItem () {
|
||||||
|
return createItem(Material.BARRIER, 1, false, false, color("&cCLOSE"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack greyPane() {
|
||||||
|
return createItem(Material.GRAY_STAINED_GLASS_PANE, 1, false, true, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Inventory fillGreyPane(Inventory inv) {
|
||||||
|
Integer in = -1;
|
||||||
|
for (ItemStack it : inv) {
|
||||||
|
in++;
|
||||||
|
if (it == null || it.getType() == Material.AIR) {
|
||||||
|
inv.setItem(in, greyPane());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return inv;
|
||||||
|
}
|
||||||
|
|
||||||
public static Component noPerms() {
|
public static Component noPerms() {
|
||||||
return Component.text(color("&cYou don't have the permission to use this feature."));
|
return Component.text(color("&cYou don't have the permission to use this feature."));
|
||||||
}
|
}
|
||||||
|
|
47
src/main/java/gq/unurled/raxen/utils/Vault.java
Normal file
47
src/main/java/gq/unurled/raxen/utils/Vault.java
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
package gq.unurled.raxen.utils;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
|
import static gq.unurled.raxen.utils.Utils.error;
|
||||||
|
|
||||||
|
public class Vault {
|
||||||
|
@Getter
|
||||||
|
private Economy econ = null;
|
||||||
|
//econ.depositPlayer(player,amount)
|
||||||
|
//econ.withdrawPlayer(player,amount)
|
||||||
|
//econ.getBalance(player);
|
||||||
|
|
||||||
|
|
||||||
|
private static Raxen main;
|
||||||
|
|
||||||
|
public Vault(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
setupEconomy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupEconomy() {
|
||||||
|
if (main.getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||||
|
error("Need to install plugin Vault. (https://github.com/milkbowl/Vault)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
RegisteredServiceProvider<Economy> rsp = main.getServer().getServicesManager().getRegistration(Economy.class);
|
||||||
|
if (rsp == null) {
|
||||||
|
error("Some bug happend in the initialisation of Vault and Raxen.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
econ = rsp.getProvider();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBalanceString(Player player) {
|
||||||
|
double bal = econ.getBalance(player);
|
||||||
|
DecimalFormat format = new DecimalFormat("#,###.00");
|
||||||
|
return format.format(bal);
|
||||||
|
}
|
||||||
|
}
|
13
src/main/resources/example_item.yml
Normal file
13
src/main/resources/example_item.yml
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
id: "RED_WOOL"
|
||||||
|
customId: "BEST_NEW_ITEM"
|
||||||
|
name: "best Item name ever"
|
||||||
|
health: 100
|
||||||
|
defense: 50
|
||||||
|
speed: 100
|
||||||
|
strength: 100
|
||||||
|
custom_ability: "fireball"
|
||||||
|
isGlowing: true
|
||||||
|
isUnbreakable: true
|
||||||
|
custom_model_data: 123
|
||||||
|
lore:
|
||||||
|
- '&cSuper lore'
|
|
@ -1,7 +1,7 @@
|
||||||
name: Raxen
|
name: Raxen
|
||||||
version: '${project.version}'
|
version: '${project.version}'
|
||||||
main: gq.unurled.raxen.Raxen
|
main: gq.unurled.raxen.Raxen
|
||||||
api-version: 1.17
|
api-version: 1.18
|
||||||
depend: [ProtocolLib]
|
depend: [ProtocolLib]
|
||||||
softdepend: [AureliumSkills, LuckPerms]
|
softdepend: [AureliumSkills, LuckPerms]
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@ commands:
|
||||||
description: nbt command
|
description: nbt command
|
||||||
raxen:
|
raxen:
|
||||||
description: raxen main command
|
description: raxen main command
|
||||||
|
itemlist:
|
||||||
|
aliases: itl
|
||||||
|
description: Open ItemList menu
|
||||||
|
usage: /itemlist
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
raxen.reload.cmd:
|
raxen.reload.cmd:
|
||||||
|
@ -31,6 +35,7 @@ permissions:
|
||||||
description: testgui command permission
|
description: testgui command permission
|
||||||
raxen.nbt.cmd:
|
raxen.nbt.cmd:
|
||||||
description: nbt command permission
|
description: nbt command permission
|
||||||
permission:
|
|
||||||
raxen.raxen.cmd:
|
raxen.raxen.cmd:
|
||||||
description: raxen command permssion
|
description: raxen command permssion
|
||||||
|
raxen.itemlist.cmd:
|
||||||
|
description: itemlist command permission
|
Loading…
Reference in a new issue