Merge pull request 'Woodpeck' (#15) from unurled/Raxen:plugin into plugin
Reviewed-on: #15
This commit is contained in:
commit
6ec6113351
16 changed files with 299 additions and 67 deletions
16
build.gradle
16
build.gradle
|
@ -72,8 +72,8 @@ dependencies {
|
||||||
|
|
||||||
implementation 'redis.clients:jedis:4.3.1'
|
implementation 'redis.clients:jedis:4.3.1'
|
||||||
|
|
||||||
compileOnly 'io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT'
|
compileOnly 'io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT'
|
||||||
implementation 'de.tr7zw:item-nbt-api-plugin:2.11.2'
|
implementation 'de.tr7zw:item-nbt-api-plugin:2.11.3'
|
||||||
// compileOnly 'de.tr7zw:item-nbt-api:2.11.2'
|
// compileOnly 'de.tr7zw:item-nbt-api:2.11.2'
|
||||||
compileOnly 'com.comphenix.protocol:ProtocolLib:5.0.0'
|
compileOnly 'com.comphenix.protocol:ProtocolLib:5.0.0'
|
||||||
compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1'
|
compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1'
|
||||||
|
@ -81,12 +81,12 @@ dependencies {
|
||||||
compileOnly 'com.sk89q.worldedit:worldedit-core:7.2.14'
|
compileOnly 'com.sk89q.worldedit:worldedit-core:7.2.14'
|
||||||
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.14'
|
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.14'
|
||||||
compileOnly 'me.clip:placeholderapi:2.11.3'
|
compileOnly 'me.clip:placeholderapi:2.11.3'
|
||||||
compileOnly('net.citizensnpcs:citizens-main:2.0.31-SNAPSHOT') {
|
compileOnly('net.citizensnpcs:citizens-main:2.0.32-SNAPSHOT') {
|
||||||
exclude group: '*', module: '*'
|
exclude group: '*', module: '*'
|
||||||
}
|
}
|
||||||
compileOnly 'com.onarandombox.multiversecore:Multiverse-Core:4.3.1'
|
compileOnly 'com.onarandombox.multiversecore:Multiverse-Core:4.3.1'
|
||||||
implementation 'com.github.decentsoftware-eu:decentholograms:2.8.1'
|
implementation 'com.github.decentsoftware-eu:decentholograms:2.8.2'
|
||||||
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19.4-R0.1-SNAPSHOT")
|
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.20-R0.1-SNAPSHOT")
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'me.unurled'
|
group = 'me.unurled'
|
||||||
|
@ -116,12 +116,12 @@ tasks {
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
dependencies {
|
dependencies {
|
||||||
include dependency('de.tr7zw:item-nbt-api-plugin:2.11.2')
|
include dependency('de.tr7zw:item-nbt-api-plugin:2.11.3')
|
||||||
include dependency('de.tr7zw:item-nbt-api:2.11.2')
|
include dependency('de.tr7zw:item-nbt-api:2.11.3')
|
||||||
include dependency('org.mongodb:mongodb-driver-sync:4.9.1')
|
include dependency('org.mongodb:mongodb-driver-sync:4.9.1')
|
||||||
include dependency('org.mongodb:bson:4.9.1')
|
include dependency('org.mongodb:bson:4.9.1')
|
||||||
include dependency('org.mongodb:mongodb-driver-core:4.9.1')
|
include dependency('org.mongodb:mongodb-driver-core:4.9.1')
|
||||||
include dependency('com.github.decentsoftware-eu:decentholograms:2.8.1')
|
include dependency('com.github.decentsoftware-eu:decentholograms:2.8.2')
|
||||||
include dependency('org.apache.httpcomponents:httpclient:4.5.13')
|
include dependency('org.apache.httpcomponents:httpclient:4.5.13')
|
||||||
include dependency('org.apache.httpcomponents:httpmime:4.5.13')
|
include dependency('org.apache.httpcomponents:httpmime:4.5.13')
|
||||||
include dependency('redis.clients:jedis:4.3.1')
|
include dependency('redis.clients:jedis:4.3.1')
|
||||||
|
|
44
docs/data_save/Redis.md
Normal file
44
docs/data_save/Redis.md
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
# Redis storage data structure
|
||||||
|
|
||||||
|
## Player data
|
||||||
|
|
||||||
|
- key type : string (json)
|
||||||
|
- key name : uuid
|
||||||
|
|
||||||
|
| Field | Type | Description |
|
||||||
|
|-------------|---------|---------------------------------|
|
||||||
|
| uuid | string | player uuid |
|
||||||
|
| name | string | player name |
|
||||||
|
| ip | string | player ip |
|
||||||
|
| first_join | string | player first join time |
|
||||||
|
| last_join | string | player last join time |
|
||||||
|
| play_time | double | player play time |
|
||||||
|
| last_loc | string | player last location |
|
||||||
|
| inventory | string | player inventory hash |
|
||||||
|
| enderchest | string | player enderchests hash |
|
||||||
|
| health | double | player health |
|
||||||
|
| defense | double | player defense |
|
||||||
|
| strength | double | player strength |
|
||||||
|
| speed | double | player speed |
|
||||||
|
| luck | double | player luck |
|
||||||
|
| mana | double | player mana |
|
||||||
|
| exp | double | player exp until the next level |
|
||||||
|
| level | integer | player level |
|
||||||
|
| money | double | player money |
|
||||||
|
| kills | integer | player kills |
|
||||||
|
| deaths | integer | player deaths |
|
||||||
|
| collections | string | player collections hash |
|
||||||
|
|
||||||
|
## Config data
|
||||||
|
|
||||||
|
- key type : Hash
|
||||||
|
- key name : config_${server_name}
|
||||||
|
|
||||||
|
| Field | Type | Description |
|
||||||
|
|----------------|---------|--------------------------|
|
||||||
|
| server_name | string | server name |
|
||||||
|
| server_motd | string | server motd |
|
||||||
|
| server_address | string | server address |
|
||||||
|
| server_port | integer | server port |
|
||||||
|
| days | integer | days the server was open |
|
||||||
|
| online | integer | online players |
|
|
@ -6,13 +6,25 @@ import static me.unurled.raxen.utils.Utils.log;
|
||||||
|
|
||||||
import me.unurled.raxen.Raxen;
|
import me.unurled.raxen.Raxen;
|
||||||
import me.unurled.raxen.manager.entity.PlayerManager;
|
import me.unurled.raxen.manager.entity.PlayerManager;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
public class PlayerUtils {
|
public class PlayerUtils {
|
||||||
|
|
||||||
|
public static void updateItemStats(Raxen main, Player player) {
|
||||||
|
PlayerManager pm = main.getManager().getPlayerManager();
|
||||||
|
PlayerInventory i = player.getInventory();
|
||||||
|
ItemStack it;
|
||||||
|
if (i.getItemInMainHand().getType() != Material.AIR) {
|
||||||
|
it = i.getItemInMainHand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void updateSkills(Raxen main, Player player) {
|
public static void updateSkills(Raxen main, Player player) {
|
||||||
PlayerManager pm = main.getManager().getPlayerManager();
|
PlayerManager pm = main.getManager().getPlayerManager();
|
||||||
int maxHealth, health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck, itemLuck;
|
int maxHealth, health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck, itemLuck;
|
||||||
|
|
|
@ -600,4 +600,8 @@ public class RaxenPlayer {
|
||||||
p.setExp((float) (((double) xp) / ((double) getXpForNextLevel())));
|
p.setExp((float) (((double) xp) / ((double) getXpForNextLevel())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public double getMoney() {
|
||||||
|
return main.getManager().getLibsManager().getVault().getEcon().getBalance(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,27 @@ public class Attributes {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setAttributes(
|
public static void setAttributes(Raxen main, Player player,
|
||||||
|
int maxHealth,
|
||||||
|
int health,
|
||||||
|
int itemHealth,
|
||||||
|
int defense,
|
||||||
|
int itemDefense,
|
||||||
|
int speed,
|
||||||
|
int itemSpeed,
|
||||||
|
int strength,
|
||||||
|
int itemStrength,
|
||||||
|
int maxMana,
|
||||||
|
int mana,
|
||||||
|
int itemMana,
|
||||||
|
int luck,
|
||||||
|
int itemLuck) {
|
||||||
|
new Attributes(main).setAttributes(player, maxHealth, health, itemHealth, defense,
|
||||||
|
itemDefense, speed, itemSpeed, strength, itemStrength, maxMana, mana, itemMana, luck,
|
||||||
|
itemLuck);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttributes(
|
||||||
Player player,
|
Player player,
|
||||||
int maxHealth,
|
int maxHealth,
|
||||||
int health,
|
int health,
|
||||||
|
@ -94,7 +114,7 @@ public class Attributes {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String[] getNameList() {
|
public static String[] getNameList() {
|
||||||
return new String[] {
|
return new String[]{
|
||||||
"Defense",
|
"Defense",
|
||||||
"Health",
|
"Health",
|
||||||
"Luck",
|
"Luck",
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
package me.unurled.raxen.components.items;
|
package me.unurled.raxen.components.items;
|
||||||
|
|
||||||
public class NBTNames {
|
public enum NBTNames {
|
||||||
|
|
||||||
public static String HEALTH = "HEALTH";
|
|
||||||
public static String SPEED = "SPEED";
|
HEALTH,
|
||||||
public static String STRENGTH = "STRENGTH";
|
SPEED,
|
||||||
public static String DEFENSE = "DEFENSE";
|
DEFENSE,
|
||||||
public static String LUCK = "LUCK";
|
STRENGTH,
|
||||||
public static String MANA = "MANA";
|
LUCK,
|
||||||
public static String ID = "ID";
|
MANA,
|
||||||
public static String CUSTOM_ABILITY = "CUSTOM_ABILITY";
|
ID,
|
||||||
public static String DROP_RATE = "DROP_RATE";
|
CUSTOM_ABILITY,
|
||||||
public static String ITEM_CLASS = "ITEM_CLASS";
|
DROP_RATE,
|
||||||
public static String ITEM_TYPE = "ITEM_TYPE";
|
ITEM_CLASS,
|
||||||
|
ITEM_TYPE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,10 +45,10 @@ public class CombatKnife extends Item {
|
||||||
NBT.modify(
|
NBT.modify(
|
||||||
item,
|
item,
|
||||||
nbt -> {
|
nbt -> {
|
||||||
nbt.setString(NBTNames.ID, ID);
|
nbt.setString(NBTNames.ID.name(), ID);
|
||||||
nbt.setString(NBTNames.ITEM_TYPE, ITEM_TYPES.toString());
|
nbt.setString(NBTNames.ITEM_TYPE.name(), ITEM_TYPES.toString());
|
||||||
nbt.setString(NBTNames.ITEM_CLASS, ITEM_CLASS.toString());
|
nbt.setString(NBTNames.ITEM_CLASS.name(), ITEM_CLASS.toString());
|
||||||
nbt.setInteger(NBTNames.STRENGTH, 20);
|
nbt.setInteger(NBTNames.STRENGTH.name(), 20);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return item;
|
return item;
|
||||||
|
|
|
@ -40,11 +40,11 @@ public class Dagger extends Item {
|
||||||
itm.lore(lore);
|
itm.lore(lore);
|
||||||
item.setItemMeta(itm);
|
item.setItemMeta(itm);
|
||||||
NBTItem nbti = new NBTItem(item);
|
NBTItem nbti = new NBTItem(item);
|
||||||
nbti.setString(NBTNames.ID, ID);
|
nbti.setString(NBTNames.ID.name(), ID);
|
||||||
nbti.setInteger(NBTNames.SPEED, 100);
|
nbti.setInteger(NBTNames.SPEED.name(), 100);
|
||||||
nbti.setInteger(NBTNames.STRENGTH, 50);
|
nbti.setInteger(NBTNames.STRENGTH.name(), 50);
|
||||||
nbti.setString(NBTNames.CUSTOM_ABILITY, "throwing_dager");
|
nbti.setString(NBTNames.CUSTOM_ABILITY.name(), "throwing_dager");
|
||||||
nbti.setDouble(NBTNames.DROP_RATE, 50.0);
|
nbti.setDouble(NBTNames.DROP_RATE.name(), 50.0);
|
||||||
item = nbti.getItem();
|
item = nbti.getItem();
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,8 +28,8 @@ public class CustomLoot {
|
||||||
|
|
||||||
public Double getDrop_rate() {
|
public Double getDrop_rate() {
|
||||||
NBTItem nbti = new NBTItem(item);
|
NBTItem nbti = new NBTItem(item);
|
||||||
if (nbti.hasTag(NBTNames.DROP_RATE)) {
|
if (nbti.hasTag(NBTNames.DROP_RATE.name())) {
|
||||||
return nbti.getDouble(NBTNames.DROP_RATE);
|
return nbti.getDouble(NBTNames.DROP_RATE.name());
|
||||||
}
|
}
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,16 @@ import static me.unurled.raxen.utils.Items.mapItemStackDeserialize;
|
||||||
import static me.unurled.raxen.utils.Items.setItemsToInventory;
|
import static me.unurled.raxen.utils.Items.setItemsToInventory;
|
||||||
import static me.unurled.raxen.utils.Utils.debug;
|
import static me.unurled.raxen.utils.Utils.debug;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.mongodb.client.MongoCollection;
|
import com.mongodb.client.MongoCollection;
|
||||||
import com.mongodb.client.model.Filters;
|
import com.mongodb.client.model.Filters;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import me.unurled.raxen.Raxen;
|
import me.unurled.raxen.Raxen;
|
||||||
import me.unurled.raxen.components.entity.Attributes.Attribute;
|
import me.unurled.raxen.components.entity.Attributes.Attribute;
|
||||||
import me.unurled.raxen.components.entity.player.Inventories;
|
import me.unurled.raxen.components.entity.player.Inventories;
|
||||||
|
@ -23,6 +27,7 @@ import me.unurled.raxen.manager.entity.PlayerManager;
|
||||||
import me.unurled.raxen.manager.entity.StorageManager;
|
import me.unurled.raxen.manager.entity.StorageManager;
|
||||||
import me.unurled.raxen.utils.Items;
|
import me.unurled.raxen.utils.Items;
|
||||||
import me.unurled.raxen.utils.libs.MongoDB;
|
import me.unurled.raxen.utils.libs.MongoDB;
|
||||||
|
import me.unurled.raxen.utils.libs.Redis;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -39,6 +44,7 @@ import org.jetbrains.annotations.NotNull;
|
||||||
public class PlayerConfig {
|
public class PlayerConfig {
|
||||||
|
|
||||||
private static Raxen main;
|
private static Raxen main;
|
||||||
|
private Redis redis;
|
||||||
private MongoDB mongoDB;
|
private MongoDB mongoDB;
|
||||||
private MongoCollection<Document> mongoCollection;
|
private MongoCollection<Document> mongoCollection;
|
||||||
private static PlayerManager playerManager;
|
private static PlayerManager playerManager;
|
||||||
|
@ -50,6 +56,7 @@ public class PlayerConfig {
|
||||||
sto = main.getManager().getStorageManager();
|
sto = main.getManager().getStorageManager();
|
||||||
this.mongoDB = main.getManager().getLibsManager().getMongoDB();
|
this.mongoDB = main.getManager().getLibsManager().getMongoDB();
|
||||||
this.mongoCollection = mongoDB.getMongoCollection();
|
this.mongoCollection = mongoDB.getMongoCollection();
|
||||||
|
this.redis = main.getManager().getLibsManager().getRedis();
|
||||||
playerManager = main.getManager().getPlayerManager();
|
playerManager = main.getManager().getPlayerManager();
|
||||||
this.attributes = new Attributes(main);
|
this.attributes = new Attributes(main);
|
||||||
}
|
}
|
||||||
|
@ -61,6 +68,63 @@ public class PlayerConfig {
|
||||||
mongoDB.close();
|
mongoDB.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* save player data to redis
|
||||||
|
*/
|
||||||
|
public void saveUsingRedis(Player p, Attributes attributes, String invStr) {
|
||||||
|
Map<String, String> hash = new HashMap<>();
|
||||||
|
hash.put("uuid", p.getUniqueId().toString());
|
||||||
|
hash.put("name", p.getName());
|
||||||
|
|
||||||
|
hash.put("last_join", String.valueOf(System.currentTimeMillis()));
|
||||||
|
// hash.put("play_time", String.valueOf(playerManager.getPlayTime(p)));
|
||||||
|
hash.put("location", p.getLocation().toString());
|
||||||
|
|
||||||
|
hash.put("inv", invStr);
|
||||||
|
if (playerManager.getRaxenPlayer(p).getStorage() != null) {
|
||||||
|
if (
|
||||||
|
playerManager.getRaxenPlayer(p).getStorage().getEc() !=
|
||||||
|
null
|
||||||
|
) {
|
||||||
|
EnderChest ec = playerManager
|
||||||
|
.getRaxenPlayer(p)
|
||||||
|
.getStorage()
|
||||||
|
.getEc();
|
||||||
|
List<String> list = new ArrayList<String>();
|
||||||
|
int reverse = 0;
|
||||||
|
for (ItemStack it : ec.getEc()) {
|
||||||
|
if (it != null && it.getType() != Material.AIR) {
|
||||||
|
String s = Items.itemStackSerialize(it, reverse);
|
||||||
|
list.add(s);
|
||||||
|
}
|
||||||
|
reverse += 1;
|
||||||
|
}
|
||||||
|
String ecstr = Items.listItemStackSerialize(list);
|
||||||
|
hash.put("enderchest", ecstr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
HashMap<String, Attribute> attribute = main
|
||||||
|
.getManager()
|
||||||
|
.getPlayerManager()
|
||||||
|
.getAttribute();
|
||||||
|
for (String s : attribute.keySet()) {
|
||||||
|
if (s.contains("ITEM") || s.contains("MAX")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
hash.put(s, attribute.get(s).get(p).toString());
|
||||||
|
}
|
||||||
|
hash.put("level", String.valueOf(playerManager.getRaxenPlayer(p).getLevel()));
|
||||||
|
hash.put("exp", String.valueOf(playerManager.getRaxenPlayer(p).getXpForNextLevel()));
|
||||||
|
hash.put("kills", String.valueOf(playerManager.getRaxenPlayer(p).getMobKills()));
|
||||||
|
hash.put("deaths", String.valueOf(playerManager.getRaxenPlayer(p).getDeaths()));
|
||||||
|
hash.put("money", String.valueOf(playerManager.getRaxenPlayer(p).getMoney()));
|
||||||
|
// TODO: Save Collections
|
||||||
|
|
||||||
|
Gson gson = new GsonBuilder().create();
|
||||||
|
String json = gson.toJson(hash);
|
||||||
|
redis.getJedis().set(p.getUniqueId().toString(), json);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* save players stuff to mongo db
|
* save players stuff to mongo db
|
||||||
*
|
*
|
||||||
|
@ -184,6 +248,81 @@ public class PlayerConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* load player stuff from redis
|
||||||
|
*
|
||||||
|
* @param p player
|
||||||
|
*/
|
||||||
|
public void loadUsingRedis(Player p) {
|
||||||
|
String json = redis.getJedis().get(p.getUniqueId().toString());
|
||||||
|
Gson gson = new Gson();
|
||||||
|
TypeToken<HashMap<String, String>> typeToken = new TypeToken<HashMap<String, String>>() {
|
||||||
|
};
|
||||||
|
HashMap<String, String> hashMap = gson.fromJson(json, typeToken.getType());
|
||||||
|
if (hashMap == null) {
|
||||||
|
playerManager.getRaxenPlayer(p).createNewAttribute();
|
||||||
|
playerManager.getRaxenPlayer(p).createStorage();
|
||||||
|
playerManager.getRaxenPlayer(p).createInventory();
|
||||||
|
PlayerUtils.updateSkills(main, p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int maxHealth = 0, health = 0, itemHealth = 0, defense = 0, itemDefense = 0, speed = 0, itemSpeed = 0, strength = 0, itemStrength = 0, maxMana = 0, mana = 0, itemMana = 0, luck = 0, itemLuck = 0;
|
||||||
|
try {
|
||||||
|
health = Integer.parseInt(hashMap.get("HEALTH"));
|
||||||
|
defense = Integer.parseInt(hashMap.get("DEFENSE"));
|
||||||
|
speed = Integer.parseInt(hashMap.get("SPEED"));
|
||||||
|
strength = Integer.parseInt(hashMap.get("STRENGTH"));
|
||||||
|
mana = Integer.parseInt(hashMap.get("MANA"));
|
||||||
|
luck = Integer.parseInt(hashMap.get("LUCK"));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
}
|
||||||
|
Attributes.setAttributes(main, p,
|
||||||
|
maxHealth,
|
||||||
|
health,
|
||||||
|
itemHealth,
|
||||||
|
defense,
|
||||||
|
itemDefense,
|
||||||
|
speed,
|
||||||
|
itemSpeed,
|
||||||
|
strength,
|
||||||
|
itemStrength,
|
||||||
|
maxMana,
|
||||||
|
mana,
|
||||||
|
itemMana,
|
||||||
|
luck,
|
||||||
|
itemLuck
|
||||||
|
);
|
||||||
|
Inventory ec = Bukkit.createInventory(
|
||||||
|
null,
|
||||||
|
54,
|
||||||
|
Component.text("Ender Chest")
|
||||||
|
);
|
||||||
|
if (hashMap.get("enderchest") != null) {
|
||||||
|
ec =
|
||||||
|
setItemsToInventory(
|
||||||
|
mapItemStackDeserialize(hashMap.get("enderchest")),
|
||||||
|
ec
|
||||||
|
);
|
||||||
|
}
|
||||||
|
playerManager.getRaxenPlayer(p).setStorage(ec);
|
||||||
|
PlayerInventory inv = p.getInventory();
|
||||||
|
inv =
|
||||||
|
setItemsToInventory(
|
||||||
|
listItemStackDeserialize(hashMap.get("inventory")),
|
||||||
|
inv
|
||||||
|
);
|
||||||
|
p.getInventory().setContents(inv.getContents());
|
||||||
|
p.updateInventory();
|
||||||
|
me.unurled.raxen.components.entity.player.storages.Inventory invv =
|
||||||
|
new me.unurled.raxen.components.entity.player.storages.Inventory(
|
||||||
|
inv
|
||||||
|
);
|
||||||
|
Inventories invvv = new Inventories(invv);
|
||||||
|
playerManager.getRaxenPlayer(p).setInventory(inv);
|
||||||
|
PlayerUtils.updateSkills(main, p);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* load player stuff from mongo db
|
* load player stuff from mongo db
|
||||||
*
|
*
|
||||||
|
|
|
@ -24,6 +24,7 @@ public class ArmorEvent implements Listener {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* when player changes armor, calculates new stats for player and setting it
|
* when player changes armor, calculates new stats for player and setting it
|
||||||
|
*
|
||||||
* @param e
|
* @param e
|
||||||
*/
|
*/
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
package me.unurled.raxen.manager.entity;
|
package me.unurled.raxen.manager.entity;
|
||||||
|
|
||||||
|
import static me.unurled.raxen.components.items.NBTNames.CUSTOM_ABILITY;
|
||||||
|
import static me.unurled.raxen.components.items.NBTNames.DEFENSE;
|
||||||
|
import static me.unurled.raxen.components.items.NBTNames.DROP_RATE;
|
||||||
|
import static me.unurled.raxen.components.items.NBTNames.HEALTH;
|
||||||
|
import static me.unurled.raxen.components.items.NBTNames.ID;
|
||||||
|
import static me.unurled.raxen.components.items.NBTNames.SPEED;
|
||||||
|
import static me.unurled.raxen.components.items.NBTNames.STRENGTH;
|
||||||
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
import static me.unurled.raxen.utils.Utils.colorTextComp;
|
||||||
import static me.unurled.raxen.utils.Utils.debug;
|
import static me.unurled.raxen.utils.Utils.debug;
|
||||||
import static me.unurled.raxen.utils.Utils.error;
|
import static me.unurled.raxen.utils.Utils.error;
|
||||||
|
@ -15,7 +22,6 @@ import java.util.Objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.unurled.raxen.Raxen;
|
import me.unurled.raxen.Raxen;
|
||||||
import me.unurled.raxen.components.items.ItemBuilder;
|
import me.unurled.raxen.components.items.ItemBuilder;
|
||||||
import me.unurled.raxen.components.items.NBTNames;
|
|
||||||
import me.unurled.raxen.components.items.custom.Item;
|
import me.unurled.raxen.components.items.custom.Item;
|
||||||
import me.unurled.raxen.config.ItemConfig;
|
import me.unurled.raxen.config.ItemConfig;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
@ -36,7 +42,6 @@ public class ItemManager {
|
||||||
@Getter
|
@Getter
|
||||||
private HashMap<String, ItemStack> list = new HashMap<>();
|
private HashMap<String, ItemStack> list = new HashMap<>();
|
||||||
|
|
||||||
private NBTNames nbt = new NBTNames();
|
|
||||||
private ItemConfig itemConfig;
|
private ItemConfig itemConfig;
|
||||||
private String[] items;
|
private String[] items;
|
||||||
private Map<File, Map<String, ItemBuilder>> map;
|
private Map<File, Map<String, ItemBuilder>> map;
|
||||||
|
@ -145,16 +150,16 @@ public class ItemManager {
|
||||||
);
|
);
|
||||||
it.setItemMeta(itm);
|
it.setItemMeta(itm);
|
||||||
NBTItem nbti = new NBTItem(it);
|
NBTItem nbti = new NBTItem(it);
|
||||||
nbti.setInteger(NBTNames.SPEED, file.getInt("speed"));
|
nbti.setInteger(SPEED.name(), file.getInt("speed"));
|
||||||
nbti.setInteger(NBTNames.HEALTH, file.getInt("health"));
|
nbti.setInteger(HEALTH.name(), file.getInt("health"));
|
||||||
nbti.setInteger(NBTNames.DEFENSE, file.getInt("defense"));
|
nbti.setInteger(DEFENSE.name(), file.getInt("defense"));
|
||||||
nbti.setInteger(NBTNames.STRENGTH, file.getInt("strength"));
|
nbti.setInteger(STRENGTH.name(), file.getInt("strength"));
|
||||||
nbti.setString(NBTNames.ID, file.getString("customId"));
|
nbti.setString(ID.name(), file.getString("customId"));
|
||||||
nbti.setString(
|
nbti.setString(
|
||||||
NBTNames.CUSTOM_ABILITY,
|
CUSTOM_ABILITY.name(),
|
||||||
file.getString("custom_ability")
|
file.getString("custom_ability")
|
||||||
);
|
);
|
||||||
nbti.setDouble(NBTNames.DROP_RATE, file.getDouble("drop_rate"));
|
nbti.setDouble(DROP_RATE.name(), file.getDouble("drop_rate"));
|
||||||
it = nbti.getItem();
|
it = nbti.getItem();
|
||||||
//it = setLoreFromNBT(it); deprecated
|
//it = setLoreFromNBT(it); deprecated
|
||||||
list.put(file.getString("customId"), it);
|
list.put(file.getString("customId"), it);
|
||||||
|
|
|
@ -6,6 +6,7 @@ import me.unurled.raxen.utils.libs.CitizensApi;
|
||||||
import me.unurled.raxen.utils.libs.MongoDB;
|
import me.unurled.raxen.utils.libs.MongoDB;
|
||||||
import me.unurled.raxen.utils.libs.Mysql;
|
import me.unurled.raxen.utils.libs.Mysql;
|
||||||
import me.unurled.raxen.utils.libs.PlaceHolderAPI;
|
import me.unurled.raxen.utils.libs.PlaceHolderAPI;
|
||||||
|
import me.unurled.raxen.utils.libs.Redis;
|
||||||
import me.unurled.raxen.utils.libs.Vault;
|
import me.unurled.raxen.utils.libs.Vault;
|
||||||
|
|
||||||
public class LibsManager {
|
public class LibsManager {
|
||||||
|
@ -22,6 +23,9 @@ public class LibsManager {
|
||||||
@Getter
|
@Getter
|
||||||
private static Mysql mysql;
|
private static Mysql mysql;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Redis redis;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private PlaceHolderAPI placeHolderAPI;
|
private PlaceHolderAPI placeHolderAPI;
|
||||||
|
|
||||||
|
@ -35,5 +39,6 @@ public class LibsManager {
|
||||||
this.mongoDB = new MongoDB();
|
this.mongoDB = new MongoDB();
|
||||||
this.placeHolderAPI = new PlaceHolderAPI(main);
|
this.placeHolderAPI = new PlaceHolderAPI(main);
|
||||||
this.citizens = new CitizensApi(main);
|
this.citizens = new CitizensApi(main);
|
||||||
|
this.redis = new Redis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -549,17 +549,17 @@ public class Items {
|
||||||
) {
|
) {
|
||||||
switch (str) {
|
switch (str) {
|
||||||
case "SPEED":
|
case "SPEED":
|
||||||
nbti.setInteger(NBTNames.SPEED, nb);
|
nbti.setInteger(NBTNames.SPEED.name(), nb);
|
||||||
case "STRENGTH":
|
case "STRENGTH":
|
||||||
nbti.setInteger(NBTNames.STRENGTH, nb);
|
nbti.setInteger(NBTNames.STRENGTH.name(), nb);
|
||||||
case "HEALTH":
|
case "HEALTH":
|
||||||
nbti.setInteger(NBTNames.HEALTH, nb);
|
nbti.setInteger(NBTNames.HEALTH.name(), nb);
|
||||||
case "DEFENSE":
|
case "DEFENSE":
|
||||||
nbti.setInteger(NBTNames.DEFENSE, nb);
|
nbti.setInteger(NBTNames.DEFENSE.name(), nb);
|
||||||
case "LUCK":
|
case "LUCK":
|
||||||
nbti.setInteger(NBTNames.LUCK, nb);
|
nbti.setInteger(NBTNames.LUCK.name(), nb);
|
||||||
case "MANA":
|
case "MANA":
|
||||||
nbti.setInteger(NBTNames.MANA, nb);
|
nbti.setInteger(NBTNames.MANA.name(), nb);
|
||||||
default:
|
default:
|
||||||
error(
|
error(
|
||||||
(Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),
|
(Raxen) Bukkit.getPluginManager().getPlugin("Raxen"),
|
||||||
|
@ -583,99 +583,99 @@ public class Items {
|
||||||
lore.add(cp);
|
lore.add(cp);
|
||||||
}
|
}
|
||||||
NBTItem nbti = new NBTItem(it);
|
NBTItem nbti = new NBTItem(it);
|
||||||
if (nbti.hasTag(NBTNames.SPEED)) {
|
if (nbti.hasTag(NBTNames.SPEED.name())) {
|
||||||
if (lore.size() > 2) {
|
if (lore.size() > 2) {
|
||||||
lore.add(
|
lore.add(
|
||||||
2,
|
2,
|
||||||
colorComp(attributes("SPEED"))
|
colorComp(attributes("SPEED"))
|
||||||
.append(Component.text(nbti.getInteger(NBTNames.SPEED)))
|
.append(Component.text(nbti.getInteger(NBTNames.SPEED.name())))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
lore.add(
|
lore.add(
|
||||||
colorComp(attributes("SPEED"))
|
colorComp(attributes("SPEED"))
|
||||||
.append(Component.text(nbti.getInteger(NBTNames.SPEED)))
|
.append(Component.text(nbti.getInteger(NBTNames.SPEED.name())))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nbti.hasTag(NBTNames.HEALTH)) {
|
if (nbti.hasTag(NBTNames.HEALTH.name())) {
|
||||||
if (lore.size() > 1) {
|
if (lore.size() > 1) {
|
||||||
lore.add(
|
lore.add(
|
||||||
1,
|
1,
|
||||||
colorComp(attributes("HEALTH"))
|
colorComp(attributes("HEALTH"))
|
||||||
.append(
|
.append(
|
||||||
Component.text(nbti.getInteger(NBTNames.HEALTH))
|
Component.text(nbti.getInteger(NBTNames.HEALTH.name()))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
lore.add(
|
lore.add(
|
||||||
colorComp(attributes("HEALTH"))
|
colorComp(attributes("HEALTH"))
|
||||||
.append(
|
.append(
|
||||||
Component.text(nbti.getInteger(NBTNames.HEALTH))
|
Component.text(nbti.getInteger(NBTNames.HEALTH.name()))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nbti.hasTag(NBTNames.DEFENSE)) {
|
if (nbti.hasTag(NBTNames.DEFENSE.name())) {
|
||||||
if (lore.size() > 3) {
|
if (lore.size() > 3) {
|
||||||
lore.add(
|
lore.add(
|
||||||
3,
|
3,
|
||||||
colorComp(attributes("DEFENSE"))
|
colorComp(attributes("DEFENSE"))
|
||||||
.append(
|
.append(
|
||||||
Component.text(nbti.getInteger(NBTNames.DEFENSE))
|
Component.text(nbti.getInteger(NBTNames.DEFENSE.name()))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
lore.add(
|
lore.add(
|
||||||
colorComp(attributes("DEFENSE"))
|
colorComp(attributes("DEFENSE"))
|
||||||
.append(
|
.append(
|
||||||
Component.text(nbti.getInteger(NBTNames.DEFENSE))
|
Component.text(nbti.getInteger(NBTNames.DEFENSE.name()))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nbti.hasTag(NBTNames.STRENGTH)) {
|
if (nbti.hasTag(NBTNames.STRENGTH.name())) {
|
||||||
if (lore.size() > 3) {
|
if (lore.size() > 3) {
|
||||||
lore.add(
|
lore.add(
|
||||||
3,
|
3,
|
||||||
colorComp(attributes("STRENGTH"))
|
colorComp(attributes("STRENGTH"))
|
||||||
.append(
|
.append(
|
||||||
Component.text(nbti.getInteger(NBTNames.STRENGTH))
|
Component.text(nbti.getInteger(NBTNames.STRENGTH.name()))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
lore.add(
|
lore.add(
|
||||||
colorComp(attributes("STRENGTH"))
|
colorComp(attributes("STRENGTH"))
|
||||||
.append(
|
.append(
|
||||||
Component.text(nbti.getInteger(NBTNames.STRENGTH))
|
Component.text(nbti.getInteger(NBTNames.STRENGTH.name()))
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nbti.hasTag(NBTNames.MANA)) {
|
if (nbti.hasTag(NBTNames.MANA.name())) {
|
||||||
if (lore.size() > 3) {
|
if (lore.size() > 3) {
|
||||||
lore.add(
|
lore.add(
|
||||||
3,
|
3,
|
||||||
colorComp(attributes("MANA"))
|
colorComp(attributes("MANA"))
|
||||||
.append(Component.text(nbti.getInteger(NBTNames.MANA)))
|
.append(Component.text(nbti.getInteger(NBTNames.MANA.name())))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
lore.add(
|
lore.add(
|
||||||
colorComp(attributes("MANA"))
|
colorComp(attributes("MANA"))
|
||||||
.append(Component.text(nbti.getInteger(NBTNames.MANA)))
|
.append(Component.text(nbti.getInteger(NBTNames.MANA.name())))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nbti.hasTag(NBTNames.LUCK)) {
|
if (nbti.hasTag(NBTNames.LUCK.name())) {
|
||||||
if (lore.size() > 3) {
|
if (lore.size() > 3) {
|
||||||
lore.add(
|
lore.add(
|
||||||
3,
|
3,
|
||||||
colorComp(attributes("LUCK"))
|
colorComp(attributes("LUCK"))
|
||||||
.append(Component.text(nbti.getInteger(NBTNames.LUCK)))
|
.append(Component.text(nbti.getInteger(NBTNames.LUCK.name())))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
lore.add(
|
lore.add(
|
||||||
colorComp(attributes("LUCK"))
|
colorComp(attributes("LUCK"))
|
||||||
.append(Component.text(nbti.getInteger(NBTNames.LUCK)))
|
.append(Component.text(nbti.getInteger(NBTNames.LUCK.name())))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
package me.unurled.raxen.utils.libs;
|
package me.unurled.raxen.utils.libs;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import redis.clients.jedis.JedisPooled;
|
import redis.clients.jedis.JedisPooled;
|
||||||
|
|
||||||
public class Redis {
|
public class Redis {
|
||||||
|
|
||||||
|
@Getter
|
||||||
JedisPooled jedis;
|
JedisPooled jedis;
|
||||||
|
|
||||||
public Redis() {
|
public Redis() {
|
||||||
|
|
|
@ -46,7 +46,6 @@ public class Vault {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
econ = rsp.getProvider();
|
econ = rsp.getProvider();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getBalanceString(Player player) {
|
public String getBalanceString(Player player) {
|
||||||
|
|
Loading…
Reference in a new issue