0.0.4: Added custom damage system, little bit of custom entities
⚠ havn't tested at all, probably not working great, gonna make some update on it this week. want to make a better system for custom mobs. optimized imports with idea.
This commit is contained in:
parent
47efef1b71
commit
d943dfadaa
33 changed files with 761 additions and 308 deletions
|
@ -6,7 +6,7 @@ Some RPG thing :
|
||||||
- Raxen must do :
|
- Raxen must do :
|
||||||
- some survival and RPG thing
|
- some survival and RPG thing
|
||||||
- need some sort of action => pve, pvp maybe ?
|
- need some sort of action => pve, pvp maybe ?
|
||||||
- need custom mobs
|
- need custom mobs => some are made => not definitive need more => juste made the damage system and persistentdatacontainer on entities outside of Player, might consider to switch to persistentdatacontainer on player instead of having an hashmap (ProfileManager.java)
|
||||||
- need custom items
|
- need custom items => partialy made => need custom resource pack support
|
||||||
- can use custom texture pack
|
- can use custom texture pack => in making
|
||||||
- protection and logging feature => coreprotect
|
- protection and logging feature => coreprotect
|
|
@ -11,3 +11,6 @@ to use custom texture for items, modify the custom data model => [Example](https
|
||||||
|
|
||||||
for more info contact me.
|
for more info contact me.
|
||||||
@unurled#0149
|
@unurled#0149
|
||||||
|
|
||||||
|
|
||||||
|
custom Items uses custom model data to work => need to update in model/item/item.json [Example](https://github.com/elBukkit/MagicPlugin/wiki/ResourcePack#customizing)
|
24
pom.xml
24
pom.xml
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
<groupId>gq.unurled</groupId>
|
<groupId>gq.unurled</groupId>
|
||||||
<artifactId>raxen</artifactId>
|
<artifactId>raxen</artifactId>
|
||||||
<version>0.0.3</version>
|
<version>0.0.4</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Raxen</name>
|
<name>Raxen</name>
|
||||||
|
@ -66,6 +66,10 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
<repository>
|
<repository>
|
||||||
<id>papermc-repo</id>
|
<id>papermc-repo</id>
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
|
@ -74,10 +78,6 @@
|
||||||
<id>sonatype</id>
|
<id>sonatype</id>
|
||||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||||
</repository>
|
</repository>
|
||||||
<repository>
|
|
||||||
<id>jitpack.io</id>
|
|
||||||
<url>https://jitpack.io</url>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>codemc-repo</id>
|
<id>codemc-repo</id>
|
||||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||||
|
@ -132,12 +132,14 @@
|
||||||
<version>2.9.0-SNAPSHOT</version>
|
<version>2.9.0-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<!--
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.simplix-softworks</groupId>
|
<groupId>com.github.simplix-softworks</groupId>
|
||||||
<artifactId>SimplixStorage</artifactId>
|
<artifactId>SimplixStorage</artifactId>
|
||||||
<version>3.2.3</version>
|
<version>3.2.3</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.comphenix.protocol</groupId>
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
<artifactId>ProtocolLib</artifactId>
|
<artifactId>ProtocolLib</artifactId>
|
||||||
|
@ -153,18 +155,6 @@
|
||||||
<systemPath>${project.basedir}/api/oraxen-1.117.0.jar</systemPath>
|
<systemPath>${project.basedir}/api/oraxen-1.117.0.jar</systemPath>
|
||||||
</dependency>
|
</dependency>
|
||||||
-->
|
-->
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.lokka30</groupId>
|
|
||||||
<artifactId>LevelledMobs</artifactId>
|
|
||||||
<version>3.2.3</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.Archy-X</groupId>
|
|
||||||
<artifactId>AureliumSkills</artifactId>
|
|
||||||
<version>Beta1.2.5</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.luckperms</groupId>
|
<groupId>net.luckperms</groupId>
|
||||||
<artifactId>api</artifactId>
|
<artifactId>api</artifactId>
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
package gq.unurled.raxen;
|
package gq.unurled.raxen;
|
||||||
|
|
||||||
import com.archyx.aureliumskills.api.AureliumAPI;
|
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.ProtocolManager;
|
import com.comphenix.protocol.ProtocolManager;
|
||||||
import gq.unurled.raxen.config.Config;
|
import gq.unurled.raxen.config.Config;
|
||||||
import gq.unurled.raxen.config.PlayerConfig;
|
import gq.unurled.raxen.config.PlayerConfig;
|
||||||
import gq.unurled.raxen.manager.*;
|
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.Reload;
|
import gq.unurled.raxen.utils.Reload;
|
||||||
import gq.unurled.raxen.utils.Vault;
|
import gq.unurled.raxen.utils.Vault;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
@ -22,7 +20,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.3";
|
private static final String version = "0.0.4";
|
||||||
private final PluginManager pm = getServer().getPluginManager();
|
private final PluginManager pm = getServer().getPluginManager();
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -45,12 +43,12 @@ public final class Raxen extends JavaPlugin {
|
||||||
private gq.unurled.raxen.manager.ProtocolManager protoManager;
|
private gq.unurled.raxen.manager.ProtocolManager protoManager;
|
||||||
@Getter
|
@Getter
|
||||||
private ItemManager itemManager;
|
private ItemManager itemManager;
|
||||||
|
@Getter
|
||||||
|
private ResourcePackManager resourcePackManager;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private ProtocolManager protocolManager;
|
private ProtocolManager protocolManager;
|
||||||
@Getter
|
@Getter
|
||||||
public AureliumAPI aureliumAPI;
|
|
||||||
@Getter
|
|
||||||
public LuckPerm luckPerm;
|
public LuckPerm luckPerm;
|
||||||
@Getter
|
@Getter
|
||||||
public Vault vault;
|
public Vault vault;
|
||||||
|
@ -71,9 +69,9 @@ public final class Raxen extends JavaPlugin {
|
||||||
commandManager = new CommandManager(this);
|
commandManager = new CommandManager(this);
|
||||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||||
protoManager = new gq.unurled.raxen.manager.ProtocolManager(this);
|
protoManager = new gq.unurled.raxen.manager.ProtocolManager(this);
|
||||||
|
resourcePackManager = new ResourcePackManager(this);
|
||||||
|
|
||||||
playerConfig = new PlayerConfig(this);
|
playerConfig = new PlayerConfig(this);
|
||||||
aureliumAPI = new AureliumAPI();
|
|
||||||
luckPerm = new LuckPerm(this);
|
luckPerm = new LuckPerm(this);
|
||||||
luckPerm.register();
|
luckPerm.register();
|
||||||
vault = new Vault(this);
|
vault = new Vault(this);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.jetbrains.annotations.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static gq.unurled.raxen.utils.Items.attributes;
|
||||||
import static gq.unurled.raxen.utils.Skills.updateSkills;
|
import static gq.unurled.raxen.utils.Skills.updateSkills;
|
||||||
import static gq.unurled.raxen.utils.Utils.*;
|
import static gq.unurled.raxen.utils.Utils.*;
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,8 @@
|
||||||
package gq.unurled.raxen.components.enchantments.player;
|
package gq.unurled.raxen.components.enchantments.player;
|
||||||
|
|
||||||
import gq.unurled.raxen.components.enchantments.EnchantmentWarpper;
|
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.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
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 class Telekinesis implements Listener {
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package gq.unurled.raxen.components.entity;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
|
||||||
|
public class EntityNamespacedKey {
|
||||||
|
public EntityNamespacedKey(Raxen main) {
|
||||||
|
levelKey = new NamespacedKey(main, "level");
|
||||||
|
strengthKey = new NamespacedKey(main, "strength");
|
||||||
|
healthKey = new NamespacedKey(main, "health");
|
||||||
|
speedKey = new NamespacedKey(main, "speed");
|
||||||
|
defenseKey = new NamespacedKey(main, "defense");
|
||||||
|
}
|
||||||
|
|
||||||
|
public final NamespacedKey levelKey;
|
||||||
|
public final NamespacedKey healthKey;
|
||||||
|
public final NamespacedKey speedKey;
|
||||||
|
public final NamespacedKey defenseKey;
|
||||||
|
public final NamespacedKey strengthKey;
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package gq.unurled.raxen.components.entity;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
|
public class RaxenEntity {
|
||||||
|
|
||||||
|
private final Raxen main;
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private Integer level;
|
||||||
|
private Double health;
|
||||||
|
private Double strength;
|
||||||
|
|
||||||
|
public RaxenEntity(Raxen main, String name, Integer level, Double health, Double strength) {
|
||||||
|
this.main = main;
|
||||||
|
this.name = name;
|
||||||
|
this.level = level;
|
||||||
|
this.health = health;
|
||||||
|
this.strength = strength;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Entity createEntity(EntityType type, String name, Location location) {
|
||||||
|
Entity e = location.getWorld().spawnEntity(location, type);
|
||||||
|
e.setCustomNameVisible(true);
|
||||||
|
e.setCustomName(name);
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(Entity e) {
|
||||||
|
PersistentDataContainer data = e.getPersistentDataContainer();
|
||||||
|
data.set(new NamespacedKey(main ,"NAME"), PersistentDataType.STRING, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,12 +1,10 @@
|
||||||
package gq.unurled.raxen.components.gui;
|
package gq.unurled.raxen.components.gui;
|
||||||
|
|
||||||
import gq.unurled.raxen.Raxen;
|
import gq.unurled.raxen.Raxen;
|
||||||
import gq.unurled.raxen.manager.ItemManager;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
@ -17,7 +15,9 @@ import org.bukkit.inventory.ItemStack;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static gq.unurled.raxen.utils.Utils.*;
|
import static gq.unurled.raxen.utils.Items.*;
|
||||||
|
import static gq.unurled.raxen.utils.Utils.fillGreyPane;
|
||||||
|
import static gq.unurled.raxen.utils.Utils.log;
|
||||||
|
|
||||||
public class ItemListGui implements Listener {
|
public class ItemListGui implements Listener {
|
||||||
|
|
||||||
|
@ -38,6 +38,7 @@ public class ItemListGui implements Listener {
|
||||||
public ItemListGui(Raxen main) {
|
public ItemListGui(Raxen main) {
|
||||||
this.main = main;
|
this.main = main;
|
||||||
this.itlist = this.main.getItemManager().getList();
|
this.itlist = this.main.getItemManager().getList();
|
||||||
|
this.inv = getInventories();
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack PREVIOUS = createItem(Material.ARROW, 1,true, false, "Previous page");
|
private ItemStack PREVIOUS = createItem(Material.ARROW, 1,true, false, "Previous page");
|
||||||
|
@ -46,7 +47,7 @@ public class ItemListGui implements Listener {
|
||||||
private ItemStack CLOSE = closeItem();
|
private ItemStack CLOSE = closeItem();
|
||||||
private ItemStack GREY_PANE = greyPane();
|
private ItemStack GREY_PANE = greyPane();
|
||||||
|
|
||||||
public Inventory getInv() {
|
public Inventory getInventories() {
|
||||||
Integer page = 1;
|
Integer page = 1;
|
||||||
Integer item = -1;
|
Integer item = -1;
|
||||||
for (ItemStack it : itlist) {
|
for (ItemStack it : itlist) {
|
||||||
|
@ -139,6 +140,7 @@ public class ItemListGui implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
page++;
|
page++;
|
||||||
|
inv.setItem(53, CLOSE);
|
||||||
inv = fillGreyPane(inv);
|
inv = fillGreyPane(inv);
|
||||||
}
|
}
|
||||||
return inv;
|
return inv;
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
package gq.unurled.raxen.components.items;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
public class Attributes {
|
||||||
|
@Getter
|
||||||
|
Integer health, speed, defense, strength;
|
||||||
|
|
||||||
|
public Attributes(Integer health, Integer defense, Integer speed, Integer strength) {
|
||||||
|
this.health = health;
|
||||||
|
this.defense = defense;
|
||||||
|
this.speed = speed;
|
||||||
|
this.strength = strength;
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,13 +7,17 @@ public class Skills {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private int health, defense, speed, strength;
|
private int health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemDmg;
|
||||||
|
|
||||||
public Skills(int health, int defense, int speed, int strength) {
|
public Skills(int health, int itemHealth, int defense, int itemDefense, int speed, int itemSpeed, int strength, int itemDmg) {
|
||||||
this.health = health;
|
this.health = health;
|
||||||
|
this.itemHealth = health;
|
||||||
this.defense = defense;
|
this.defense = defense;
|
||||||
|
this.itemDefense = itemDefense;
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
|
this.itemSpeed = speed;
|
||||||
this.strength = strength;
|
this.strength = strength;
|
||||||
|
this.itemDmg = itemDmg;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeSpeed(int i) {
|
public void removeSpeed(int i) {
|
||||||
|
@ -29,6 +33,19 @@ public class Skills {
|
||||||
this.strength =this.getStrength() - i;
|
this.strength =this.getStrength() - i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void removeItemSpeed(int i) {
|
||||||
|
this.itemSpeed =this.getItemSpeed() - i;
|
||||||
|
}
|
||||||
|
public void removeItemHealth(int i) {
|
||||||
|
this.itemHealth =this.getItemHealth() - i;
|
||||||
|
}
|
||||||
|
public void removeItemDefense(int i) {
|
||||||
|
this.itemDefense =this.getItemDefense() - i;
|
||||||
|
}
|
||||||
|
public void removeItemStrength(int i) {
|
||||||
|
this.itemDmg =this.getItemDmg() - i;
|
||||||
|
}
|
||||||
|
|
||||||
public void addSpeed(int i) {
|
public void addSpeed(int i) {
|
||||||
this.speed = this.getSpeed() + i;
|
this.speed = this.getSpeed() + i;
|
||||||
}
|
}
|
||||||
|
@ -41,4 +58,17 @@ public class Skills {
|
||||||
public void addStrength(int i) {
|
public void addStrength(int i) {
|
||||||
this.strength = this.getStrength() + i;
|
this.strength = this.getStrength() + i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void addItemSpeed(int i) {
|
||||||
|
this.itemSpeed = this.getItemSpeed() + i;
|
||||||
|
}
|
||||||
|
public void addItemHealth(int i) {
|
||||||
|
this.itemHealth = this.getItemHealth() + i;
|
||||||
|
}
|
||||||
|
public void addItemDefense(int i) {
|
||||||
|
this.itemDefense = this.getItemDefense() + i;
|
||||||
|
}
|
||||||
|
public void addItemStrength(int i) {
|
||||||
|
this.itemDmg = this.getItemDmg() + i;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
package gq.unurled.raxen.components.resourcepack;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.manager.ResourcePackManager;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class ResourcePack {
|
||||||
|
|
||||||
|
private Raxen main;
|
||||||
|
private FileConfiguration config;
|
||||||
|
private ResourcePackManager resourcePackManager;
|
||||||
|
|
||||||
|
public ResourcePack(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
this.config = main.getConfig();
|
||||||
|
this.resourcePackManager = main.getResourcePackManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void join(Player player) {
|
||||||
|
new BukkitRunnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if(resourcePackManager.isUseRP()) {
|
||||||
|
player.setResourcePack(config.getString("ressource_pack_url"), config.getString("resource_pack_sha1"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskLater(main, 2L);
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,8 +10,8 @@ import gq.unurled.raxen.components.player.Storage;
|
||||||
import gq.unurled.raxen.components.player.Storages.EnderChest;
|
import gq.unurled.raxen.components.player.Storages.EnderChest;
|
||||||
import gq.unurled.raxen.manager.ProfileManager;
|
import gq.unurled.raxen.manager.ProfileManager;
|
||||||
import gq.unurled.raxen.manager.StorageManager;
|
import gq.unurled.raxen.manager.StorageManager;
|
||||||
|
import gq.unurled.raxen.utils.Items;
|
||||||
import gq.unurled.raxen.utils.MongoDB;
|
import gq.unurled.raxen.utils.MongoDB;
|
||||||
import gq.unurled.raxen.utils.Utils;
|
|
||||||
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;
|
||||||
|
@ -50,9 +50,13 @@ public class PlayerConfig {
|
||||||
Document doc = new Document("uuid", player.getUniqueId().toString())
|
Document doc = new Document("uuid", player.getUniqueId().toString())
|
||||||
.append("name", player.getName())
|
.append("name", player.getName())
|
||||||
.append("health", skills.getHealth())
|
.append("health", skills.getHealth())
|
||||||
|
.append("itemHealth", skills.getItemHealth())
|
||||||
.append("defense", skills.getDefense())
|
.append("defense", skills.getDefense())
|
||||||
|
.append("itemDefense", skills.getItemDefense())
|
||||||
.append("speed", skills.getSpeed())
|
.append("speed", skills.getSpeed())
|
||||||
|
.append("itemSpeed", skills.getItemSpeed())
|
||||||
.append("strength", skills.getStrength())
|
.append("strength", skills.getStrength())
|
||||||
|
.append("itemDmg", skills.getItemDmg())
|
||||||
.append("inv", invstr);
|
.append("inv", invstr);
|
||||||
if (profileManager.getPlayerStorage(player.getUniqueId()) != null) {
|
if (profileManager.getPlayerStorage(player.getUniqueId()) != null) {
|
||||||
if(profileManager.getPlayerStorage(player.getUniqueId()).getEc() != null) {
|
if(profileManager.getPlayerStorage(player.getUniqueId()).getEc() != null) {
|
||||||
|
@ -62,11 +66,11 @@ public class PlayerConfig {
|
||||||
for(ItemStack it : ec.getEc()) {
|
for(ItemStack it : ec.getEc()) {
|
||||||
reverse += 1;
|
reverse += 1;
|
||||||
if(it != null) {
|
if(it != null) {
|
||||||
String s = Utils.itemStackSerilize(it, reverse);
|
String s = Items.itemStackSerilize(it, reverse);
|
||||||
list.add(s);
|
list.add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String ecstr = Utils.listItemStackSerelize(list);
|
String ecstr = Items.listItemStackSerelize(list);
|
||||||
doc.append("ec", ecstr);
|
doc.append("ec", ecstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,9 +87,13 @@ public class PlayerConfig {
|
||||||
FileConfiguration config = sto.createYml(player);
|
FileConfiguration config = sto.createYml(player);
|
||||||
config.set("name", player.getName());
|
config.set("name", player.getName());
|
||||||
config.set("health", skills.getHealth());
|
config.set("health", skills.getHealth());
|
||||||
|
config.set("itemHealth", skills.getItemHealth());
|
||||||
config.set("strength", skills.getStrength());
|
config.set("strength", skills.getStrength());
|
||||||
|
config.set("itemDmg", skills.getItemDmg());
|
||||||
config.set("speed", skills.getSpeed());
|
config.set("speed", skills.getSpeed());
|
||||||
|
config.set("itemSpeed", skills.getItemSpeed());
|
||||||
config.set("defense", skills.getDefense());
|
config.set("defense", skills.getDefense());
|
||||||
|
config.set("itemDefense", skills.getItemDefense());
|
||||||
config.set("inv", invstr);
|
config.set("inv", invstr);
|
||||||
if (profileManager.getPlayerStorage(player.getUniqueId()) != null) {
|
if (profileManager.getPlayerStorage(player.getUniqueId()) != null) {
|
||||||
if(profileManager.getPlayerStorage(player.getUniqueId()).getEc() != null) {
|
if(profileManager.getPlayerStorage(player.getUniqueId()).getEc() != null) {
|
||||||
|
@ -95,11 +103,11 @@ public class PlayerConfig {
|
||||||
for(ItemStack it : ec.getEc()) {
|
for(ItemStack it : ec.getEc()) {
|
||||||
reverse += 1;
|
reverse += 1;
|
||||||
if(it != null) {
|
if(it != null) {
|
||||||
String s = Utils.itemStackSerilize(it, reverse);
|
String s = Items.itemStackSerilize(it, reverse);
|
||||||
list.add(s);
|
list.add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String ecstr = Utils.listItemStackSerelize(list);
|
String ecstr = Items.listItemStackSerelize(list);
|
||||||
config.set("ec", ecstr);
|
config.set("ec", ecstr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,20 +126,20 @@ public class PlayerConfig {
|
||||||
profileManager.createNewInventory(player);
|
profileManager.createNewInventory(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Skills skills = new Skills(playerDoc.getInteger("health"), playerDoc.getInteger("defense"), playerDoc.getInteger("speed"), playerDoc.getInteger("strength"));
|
Skills skills = new Skills(playerDoc.getInteger("health"), playerDoc.getInteger("itemHealth"), playerDoc.getInteger("defense"), playerDoc.getInteger("itemDefense"), playerDoc.getInteger("speed"), playerDoc.getInteger("itemSpeed"), playerDoc.getInteger("strength"), playerDoc.getInteger("itemDmg"));
|
||||||
Profile profile = new Profile(skills);
|
Profile profile = new Profile(skills);
|
||||||
|
|
||||||
profileManager.setPlayerProfile(player.getUniqueId(), profile);
|
profileManager.setPlayerProfile(player.getUniqueId(), profile);
|
||||||
Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||||
if(playerDoc.getString("ec") != null) {
|
if(playerDoc.getString("ec") != null) {
|
||||||
ItemStack[] itList = Utils.listItemStackDeserilize(playerDoc.getString("ec"));
|
ItemStack[] itList = Items.listItemStackDeserilize(playerDoc.getString("ec"));
|
||||||
ec.addItem(itList);
|
ec.addItem(itList);
|
||||||
}
|
}
|
||||||
EnderChest ecc = new EnderChest(ec);
|
EnderChest ecc = new EnderChest(ec);
|
||||||
Storage storage = new Storage(ecc);
|
Storage storage = new Storage(ecc);
|
||||||
profileManager.setPlayerStorage(player.getUniqueId(), storage);
|
profileManager.setPlayerStorage(player.getUniqueId(), storage);
|
||||||
Inventory inv = Bukkit.createInventory(player, InventoryType.PLAYER);
|
Inventory inv = Bukkit.createInventory(player, InventoryType.PLAYER);
|
||||||
ItemStack[] itListInv = Utils.listItemStackDeserilize(playerDoc.getString("inv"));
|
ItemStack[] itListInv = Items.listItemStackDeserilize(playerDoc.getString("inv"));
|
||||||
inv.addItem(itListInv);
|
inv.addItem(itListInv);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
gq.unurled.raxen.components.player.Storages.Inventory invv = new gq.unurled.raxen.components.player.Storages.Inventory(inv);
|
gq.unurled.raxen.components.player.Storages.Inventory invv = new gq.unurled.raxen.components.player.Storages.Inventory(inv);
|
||||||
|
@ -141,20 +149,23 @@ public class PlayerConfig {
|
||||||
|
|
||||||
public void loadUsingYml(Player player) throws IOException {
|
public void loadUsingYml(Player player) throws IOException {
|
||||||
FileConfiguration config = sto.createYml(player);
|
FileConfiguration config = sto.createYml(player);
|
||||||
Skills skills = new Skills((Integer) config.get("health"), (Integer) config.get("defense"), (Integer) config.get("speed"), (Integer) config.get("strength"));
|
Skills skills = new Skills(config.getInt("health"), config.getInt("itemHealth"),
|
||||||
|
config.getInt("defense"), config.getInt("itemDefense"),
|
||||||
|
config.getInt("speed"), config.getInt("itemSpeed"),
|
||||||
|
config.getInt("strength"), config.getInt("itemDmg"));
|
||||||
Profile profile = new Profile(skills);
|
Profile profile = new Profile(skills);
|
||||||
profileManager.setPlayerProfile(player.getUniqueId(), profile);
|
profileManager.setPlayerProfile(player.getUniqueId(), profile);
|
||||||
|
|
||||||
Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||||
if((String) config.get("ec") != null) {
|
if((String) config.get("ec") != null) {
|
||||||
ItemStack[] itList = Utils.listItemStackDeserilize((String) config.get("ec"));
|
ItemStack[] itList = Items.listItemStackDeserilize((String) config.get("ec"));
|
||||||
ec.addItem(itList);
|
ec.addItem(itList);
|
||||||
}
|
}
|
||||||
EnderChest ecc = new EnderChest(ec);
|
EnderChest ecc = new EnderChest(ec);
|
||||||
Storage storage = new Storage(ecc);
|
Storage storage = new Storage(ecc);
|
||||||
profileManager.setPlayerStorage(player.getUniqueId(), storage);
|
profileManager.setPlayerStorage(player.getUniqueId(), storage);
|
||||||
Inventory inv = Bukkit.createInventory(player, InventoryType.PLAYER);
|
Inventory inv = Bukkit.createInventory(player, InventoryType.PLAYER);
|
||||||
ItemStack[] itListInv = Utils.listItemStackDeserilize((String) config.getString("inv"));
|
ItemStack[] itListInv = Items.listItemStackDeserilize((String) config.getString("inv"));
|
||||||
inv.addItem(itListInv);
|
inv.addItem(itListInv);
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
gq.unurled.raxen.components.player.Storages.Inventory invv = new gq.unurled.raxen.components.player.Storages.Inventory(inv);
|
gq.unurled.raxen.components.player.Storages.Inventory invv = new gq.unurled.raxen.components.player.Storages.Inventory(inv);
|
||||||
|
@ -170,11 +181,11 @@ public class PlayerConfig {
|
||||||
for(ItemStack it : inv) {
|
for(ItemStack it : inv) {
|
||||||
reverse = reverse + 1;
|
reverse = reverse + 1;
|
||||||
if(it != null && it.getType() != Material.AIR) {
|
if(it != null && it.getType() != Material.AIR) {
|
||||||
String s = Utils.itemStackSerilize(it, reverse);
|
String s = Items.itemStackSerilize(it, reverse);
|
||||||
listInv.add(s);
|
listInv.add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String invstr = Utils.listItemStackSerelize(listInv);
|
String invstr = Items.listItemStackSerelize(listInv);
|
||||||
|
|
||||||
|
|
||||||
Object storage = sto.getConfig().get("storage");
|
Object storage = sto.getConfig().get("storage");
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
package gq.unurled.raxen.listener.entity;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.components.entity.EntityNamespacedKey;
|
||||||
|
import gq.unurled.raxen.components.items.Attributes;
|
||||||
|
import gq.unurled.raxen.components.player.Skills;
|
||||||
|
import gq.unurled.raxen.manager.ProfileManager;
|
||||||
|
import gq.unurled.raxen.utils.Items;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
|
public class DamageEntity implements Listener {
|
||||||
|
private Raxen main;
|
||||||
|
private ProfileManager profileManager;
|
||||||
|
private EntityNamespacedKey entityNamespacedKey;
|
||||||
|
|
||||||
|
public DamageEntity(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
this.profileManager = main.getProfileManager();
|
||||||
|
this.entityNamespacedKey = new EntityNamespacedKey(main);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void entityDamageByEntity(EntityDamageByEntityEvent e) {
|
||||||
|
e.setDamage(0);
|
||||||
|
Integer damage = 1;
|
||||||
|
Integer strength = 0;
|
||||||
|
Integer itemDmg = 0;
|
||||||
|
Integer defense = 0;
|
||||||
|
Integer itemDefense = 0;
|
||||||
|
Integer health = 0;
|
||||||
|
Integer itemHealth = 0;
|
||||||
|
Integer initDamage = 0;
|
||||||
|
if (e.getDamager() instanceof Player) {
|
||||||
|
Player playerDamager = (Player) e.getDamager();
|
||||||
|
Skills skills = profileManager.getPlayerProfile(playerDamager.getUniqueId()).getSkils();
|
||||||
|
strength = skills.getStrength();
|
||||||
|
itemDmg = skills.getItemDmg();
|
||||||
|
} else {
|
||||||
|
Entity entityDamager = e.getDamager();
|
||||||
|
PersistentDataContainer data = entityDamager.getPersistentDataContainer();
|
||||||
|
if (data.has(entityNamespacedKey.strengthKey, PersistentDataType.INTEGER)) {
|
||||||
|
strength = data.get(entityNamespacedKey.strengthKey, PersistentDataType.INTEGER);
|
||||||
|
}
|
||||||
|
Attributes attributes = Items.getNbtFromEntity((LivingEntity) entityDamager);
|
||||||
|
itemDmg = attributes.getStrength();
|
||||||
|
}
|
||||||
|
if (e.getEntity() instanceof Player) {
|
||||||
|
Player playerVictim = (Player) e.getEntity();
|
||||||
|
Skills skills = profileManager.getPlayerProfile(playerVictim.getUniqueId()).getSkils();
|
||||||
|
defense = skills.getDefense();
|
||||||
|
health = skills.getHealth();
|
||||||
|
itemDefense = skills.getItemDefense();
|
||||||
|
itemHealth = skills.getItemHealth();
|
||||||
|
} else {
|
||||||
|
Entity entityVictim = e.getEntity();
|
||||||
|
PersistentDataContainer data = entityVictim.getPersistentDataContainer();
|
||||||
|
if (data.has(entityNamespacedKey.defenseKey, PersistentDataType.INTEGER)) {
|
||||||
|
defense = data.get(entityNamespacedKey.defenseKey, PersistentDataType.INTEGER);
|
||||||
|
}
|
||||||
|
if (data.has(entityNamespacedKey.healthKey, PersistentDataType.INTEGER)) {
|
||||||
|
health = data.get(entityNamespacedKey.healthKey, PersistentDataType.INTEGER);
|
||||||
|
}
|
||||||
|
Attributes attributes = Items.getNbtFromEntity((LivingEntity) entityVictim);
|
||||||
|
itemDefense = attributes.getDefense();
|
||||||
|
itemHealth = attributes.getHealth();
|
||||||
|
}
|
||||||
|
initDamage = (5+ itemDmg) * (1+ (strength/100));
|
||||||
|
damage = initDamage;
|
||||||
|
defense = defense + itemDefense;
|
||||||
|
defense = defense/(defense+100);
|
||||||
|
damage = damage*defense;
|
||||||
|
if (damage >= health) {
|
||||||
|
e.setDamage(e.getEntity().getType().getDefaultAttributes().getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue());
|
||||||
|
} else {
|
||||||
|
health = health - damage;
|
||||||
|
if (e.getEntity() instanceof Player) {
|
||||||
|
Player playerVictim = (Player) e.getEntity();
|
||||||
|
Skills skills = profileManager.getPlayerProfile(playerVictim.getUniqueId()).getSkils();
|
||||||
|
skills.setHealth(health);
|
||||||
|
} else {
|
||||||
|
Entity entityVictim = e.getEntity();
|
||||||
|
PersistentDataContainer data = entityVictim.getPersistentDataContainer();
|
||||||
|
data.set(entityNamespacedKey.healthKey, PersistentDataType.INTEGER, health);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -28,31 +28,31 @@ public class ItemHandEvent implements Listener {
|
||||||
if(oldItem != null && oldItem.getType() != Material.AIR) {
|
if(oldItem != null && oldItem.getType() != Material.AIR) {
|
||||||
NBTItem nbti = new NBTItem(oldItem);
|
NBTItem nbti = new NBTItem(oldItem);
|
||||||
if(nbti.hasKey("SPEED")) {
|
if(nbti.hasKey("SPEED")) {
|
||||||
skills.removeSpeed(nbti.getInteger("SPEED"));
|
skills.removeItemSpeed(nbti.getInteger("SPEED"));
|
||||||
}
|
}
|
||||||
if(nbti.hasKey("HEALTH")) {
|
if(nbti.hasKey("HEALTH")) {
|
||||||
skills.removeHealth(nbti.getInteger("HEALTH"));
|
skills.removeItemHealth(nbti.getInteger("HEALTH"));
|
||||||
}
|
}
|
||||||
if(nbti.hasKey("DEFENSE")) {
|
if(nbti.hasKey("DEFENSE")) {
|
||||||
skills.removeDefense(nbti.getInteger("DEFENSE"));
|
skills.removeItemDefense(nbti.getInteger("DEFENSE"));
|
||||||
}
|
}
|
||||||
if(nbti.hasKey("STRENGTH")) {
|
if(nbti.hasKey("STRENGTH")) {
|
||||||
skills.removeStrength(nbti.getInteger("STRENGTH"));
|
skills.removeItemStrength(nbti.getInteger("STRENGTH"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(newItem != null && newItem.getType() != Material.AIR) {
|
if(newItem != null && newItem.getType() != Material.AIR) {
|
||||||
NBTItem nbti = new NBTItem(newItem);
|
NBTItem nbti = new NBTItem(newItem);
|
||||||
if(nbti.hasKey("SPEED")) {
|
if(nbti.hasKey("SPEED")) {
|
||||||
skills.addSpeed(nbti.getInteger("SPEED"));
|
skills.addItemSpeed(nbti.getInteger("SPEED"));
|
||||||
}
|
}
|
||||||
if(nbti.hasKey("HEALTH")) {
|
if(nbti.hasKey("HEALTH")) {
|
||||||
skills.addHealth(nbti.getInteger("HEALTH"));
|
skills.addItemHealth(nbti.getInteger("HEALTH"));
|
||||||
}
|
}
|
||||||
if(nbti.hasKey("DEFENSE")) {
|
if(nbti.hasKey("DEFENSE")) {
|
||||||
skills.addDefense(nbti.getInteger("DEFENSE"));
|
skills.addItemDefense(nbti.getInteger("DEFENSE"));
|
||||||
}
|
}
|
||||||
if(nbti.hasKey("STRENGTH")) {
|
if(nbti.hasKey("STRENGTH")) {
|
||||||
skills.addStrength(nbti.getInteger("STRENGTH"));
|
skills.addItemStrength(nbti.getInteger("STRENGTH"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gq.unurled.raxen.utils.Skills.updateSkills(player);
|
gq.unurled.raxen.utils.Skills.updateSkills(player);
|
||||||
|
|
|
@ -2,6 +2,7 @@ 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.components.player.Scoreboard;
|
||||||
|
import gq.unurled.raxen.components.resourcepack.ResourcePack;
|
||||||
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;
|
||||||
|
@ -15,12 +16,14 @@ public class JoinEvent implements Listener {
|
||||||
private ProfileManager profileManager;
|
private ProfileManager profileManager;
|
||||||
private PlayerConfig playerConfig;
|
private PlayerConfig playerConfig;
|
||||||
private Scoreboard scoreboard;
|
private Scoreboard scoreboard;
|
||||||
|
private ResourcePack resourcePack;
|
||||||
|
|
||||||
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);
|
this.scoreboard = new Scoreboard(main);
|
||||||
|
this.resourcePack = main.getResourcePackManager().getResourcePack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -28,6 +31,7 @@ public class JoinEvent implements Listener {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
playerConfig.loadPlayerConfig(player);
|
playerConfig.loadPlayerConfig(player);
|
||||||
scoreboard.createScorebord(player);
|
scoreboard.createScorebord(player);
|
||||||
|
resourcePack.join(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
35
src/main/java/gq/unurled/raxen/manager/EntityManager.java
Normal file
35
src/main/java/gq/unurled/raxen/manager/EntityManager.java
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
package gq.unurled.raxen.manager;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class EntityManager {
|
||||||
|
|
||||||
|
private Raxen main;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public List<EntityType> list = new ArrayList<>();
|
||||||
|
|
||||||
|
public EntityManager(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerLivingEntities(World world) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerEntityFromConfig(FileConfiguration config) {
|
||||||
|
World world = Bukkit.getWorld(config.getString("world"));
|
||||||
|
String name = config.getString("name");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -11,14 +11,13 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static gq.unurled.raxen.utils.Items.setLoreFromNBT;
|
||||||
import static gq.unurled.raxen.utils.Utils.*;
|
import static gq.unurled.raxen.utils.Utils.*;
|
||||||
|
|
||||||
public class ItemManager {
|
public class ItemManager {
|
||||||
|
@ -78,7 +77,6 @@ public class ItemManager {
|
||||||
File folder = new File(main.getDataFolder() + "/Items/");
|
File folder = new File(main.getDataFolder() + "/Items/");
|
||||||
File[] listFile = folder.listFiles();
|
File[] listFile = folder.listFiles();
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < listFile.length; i++) {
|
for (int i = 0; i < listFile.length; i++) {
|
||||||
if (listFile[i].isFile()) {
|
if (listFile[i].isFile()) {
|
||||||
FileConfiguration customItem = new YamlConfiguration();
|
FileConfiguration customItem = new YamlConfiguration();
|
||||||
|
@ -116,8 +114,8 @@ public class ItemManager {
|
||||||
for (String str : (List<String>) Objects.requireNonNull(file.get("lore"))) {
|
for (String str : (List<String>) Objects.requireNonNull(file.get("lore"))) {
|
||||||
lore.add(Component.text(color(str)));
|
lore.add(Component.text(color(str)));
|
||||||
}
|
}
|
||||||
|
itm.setCustomModelData(file.getConfigurationSection("Pack").getInt("custom_model_data"));
|
||||||
itm.lore(lore);
|
itm.lore(lore);
|
||||||
itm.setCustomModelData(file.getInt("custom_model_data"));
|
|
||||||
it.setItemMeta(itm);
|
it.setItemMeta(itm);
|
||||||
NBTItem nbti = new NBTItem(it);
|
NBTItem nbti = new NBTItem(it);
|
||||||
nbti.setInteger("SPEED", file.getInt("speed"));
|
nbti.setInteger("SPEED", file.getInt("speed"));
|
||||||
|
@ -127,6 +125,7 @@ public class ItemManager {
|
||||||
nbti.setString("ID", file.getString("customId"));
|
nbti.setString("ID", file.getString("customId"));
|
||||||
nbti.setString("CUSTOM_ABILITY", file.getString("custom_ability"));
|
nbti.setString("CUSTOM_ABILITY", file.getString("custom_ability"));
|
||||||
it = nbti.getItem();
|
it = nbti.getItem();
|
||||||
|
it = setLoreFromNBT(it);
|
||||||
list.add(it);
|
list.add(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package gq.unurled.raxen.manager;
|
package gq.unurled.raxen.manager;
|
||||||
|
|
||||||
import gq.unurled.raxen.Raxen;
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.listener.entity.DamageEntity;
|
||||||
import gq.unurled.raxen.listener.player.*;
|
import gq.unurled.raxen.listener.player.*;
|
||||||
import gq.unurled.raxen.utils.AureliumSkills;
|
|
||||||
import gq.unurled.raxen.utils.Reload;
|
import gq.unurled.raxen.utils.Reload;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ public class ListenerManager {
|
||||||
this.pm.registerEvents(new LeaveEvent(main), main);
|
this.pm.registerEvents(new LeaveEvent(main), main);
|
||||||
this.pm.registerEvents(new ArmorEvent(main), main);
|
this.pm.registerEvents(new ArmorEvent(main), main);
|
||||||
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 Reload(), main);
|
this.pm.registerEvents(new Reload(), main);
|
||||||
this.pm.registerEvents(new TransactionEvent(main), main);
|
this.pm.registerEvents(new TransactionEvent(main), main);
|
||||||
this.pm.registerEvents(main.getCommandManager().getItemListCommand().getItemListGui(), main);
|
this.pm.registerEvents(main.getCommandManager().getItemListCommand().getItemListGui(), main);
|
||||||
|
this.pm.registerEvents(new DamageEntity(main), main);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class ProfileManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Profile createNewProfile(Player player) {
|
public Profile createNewProfile(Player player) {
|
||||||
Skills skills = new Skills( 100, 50, 100, 100);
|
Skills skills = new Skills( 100, 0, 50, 0, 100, 0, 100, 0);
|
||||||
Profile profile = new Profile(skills);
|
Profile profile = new Profile(skills);
|
||||||
profiles.put(player.getUniqueId(), profile);
|
profiles.put(player.getUniqueId(), profile);
|
||||||
return profile;
|
return profile;
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
package gq.unurled.raxen.manager;
|
package gq.unurled.raxen.manager;
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.events.*;
|
import com.comphenix.protocol.events.ListenerPriority;
|
||||||
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import gq.unurled.raxen.Raxen;
|
import gq.unurled.raxen.Raxen;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package gq.unurled.raxen.manager;
|
||||||
|
|
||||||
|
import gq.unurled.raxen.Raxen;
|
||||||
|
import gq.unurled.raxen.components.resourcepack.ResourcePack;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import static gq.unurled.raxen.utils.Utils.error;
|
||||||
|
import static gq.unurled.raxen.utils.Utils.log;
|
||||||
|
|
||||||
|
public class ResourcePackManager {
|
||||||
|
|
||||||
|
private Raxen main;
|
||||||
|
@Getter
|
||||||
|
private ResourcePack resourcePack;
|
||||||
|
private FileConfiguration config;
|
||||||
|
@Getter
|
||||||
|
private boolean useRP;
|
||||||
|
|
||||||
|
public ResourcePackManager(Raxen main) {
|
||||||
|
this.main = main;
|
||||||
|
this.resourcePack = new ResourcePack(main);
|
||||||
|
this.config = main.getConfig();
|
||||||
|
this.useRP = this.config.getBoolean("useResourcePack");
|
||||||
|
enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void enable() {
|
||||||
|
if(useRP) {
|
||||||
|
if(config.getString("resource_pack_url") == null || Objects.equals(config.getString("rssource_pack_url"), "") ||
|
||||||
|
config.getString("resource_pack_sha1") == null || Objects.equals(config.getString("resource_pack_sha1"), "") ||
|
||||||
|
Objects.equals(config.getString("resource_pack_url"), "https://mc-packs.net/") || Objects.equals(config.getString("resource_pack_sha1"), "sha1hallo")) {
|
||||||
|
error("You must specify an resource_pack_url and resource_pack_sha1!");
|
||||||
|
log("Resource pack not enabled.");
|
||||||
|
useRP = false;
|
||||||
|
} else {
|
||||||
|
log("Ressource Pack enabled.");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log("Resource pack not enabled.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.stream.IntStream;
|
|
||||||
|
|
||||||
import static gq.unurled.raxen.utils.Utils.*;
|
import static gq.unurled.raxen.utils.Utils.*;
|
||||||
|
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
package gq.unurled.raxen.utils;
|
|
||||||
|
|
||||||
import com.archyx.aureliumskills.api.AureliumAPI;
|
|
||||||
import com.archyx.aureliumskills.api.event.SkillLevelUpEvent;
|
|
||||||
import com.archyx.aureliumskills.skills.Skill;
|
|
||||||
import gq.unurled.raxen.Raxen;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
public class AureliumSkills implements Listener {
|
|
||||||
|
|
||||||
private static AureliumAPI aureliumAPI;
|
|
||||||
|
|
||||||
public AureliumSkills(Raxen main) {
|
|
||||||
this.aureliumAPI = main.getAureliumAPI();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void skillLevelUp(SkillLevelUpEvent e) {
|
|
||||||
Player p = e.getPlayer();
|
|
||||||
Skill skill = e.getSkill();
|
|
||||||
Integer level = e.getLevel();
|
|
||||||
switch (skill.name()){
|
|
||||||
case "FARMING":
|
|
||||||
case "FORAGING":
|
|
||||||
case "MINING":
|
|
||||||
case "FISHING":
|
|
||||||
case "EXCAVATION":
|
|
||||||
case "ARCHERY":
|
|
||||||
case "DEFENSE":
|
|
||||||
case "FIGHTING":
|
|
||||||
case "ENDURANCE":
|
|
||||||
case "AGILITY":
|
|
||||||
case "ALCHEMY":
|
|
||||||
case "ENCHANTING":
|
|
||||||
case "SORCERY":
|
|
||||||
case "HEALING":
|
|
||||||
case "FORGING":
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
324
src/main/java/gq/unurled/raxen/utils/Items.java
Normal file
324
src/main/java/gq/unurled/raxen/utils/Items.java
Normal file
|
@ -0,0 +1,324 @@
|
||||||
|
package gq.unurled.raxen.utils;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.reflect.TypeToken;
|
||||||
|
import de.tr7zw.changeme.nbtapi.NBTItem;
|
||||||
|
import gq.unurled.raxen.components.items.Attributes;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.inventory.EntityEquipment;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static gq.unurled.raxen.utils.Utils.color;
|
||||||
|
import static gq.unurled.raxen.utils.Utils.error;
|
||||||
|
|
||||||
|
public class Items {
|
||||||
|
|
||||||
|
public static ItemStack createItem(Material material, int amount, boolean glow, boolean unb, String name, String... lore) {
|
||||||
|
ItemStack item = new ItemStack(material, amount);
|
||||||
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if(name != null) {
|
||||||
|
itemMeta.displayName(Component.text(color(name)));
|
||||||
|
}
|
||||||
|
if(lore != null) {
|
||||||
|
List<Component> list = new ArrayList<>();
|
||||||
|
for(String string : lore) {
|
||||||
|
list.add(Component.text(color(string)));
|
||||||
|
}
|
||||||
|
itemMeta.lore(list);
|
||||||
|
}
|
||||||
|
if(glow) {
|
||||||
|
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
|
itemMeta.addEnchant(Enchantment.DURABILITY, 1, true);
|
||||||
|
}
|
||||||
|
if(unb) {
|
||||||
|
itemMeta.setUnbreakable(true);
|
||||||
|
}
|
||||||
|
item.setItemMeta(itemMeta);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack editItem(ItemStack item, String name,int amount, List<Component> lore) {
|
||||||
|
if(amount == 0) {
|
||||||
|
amount = 1;
|
||||||
|
}
|
||||||
|
item.setAmount(amount);
|
||||||
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
if (name != null) {
|
||||||
|
itemMeta.displayName(Component.text(name));
|
||||||
|
}
|
||||||
|
itemMeta.lore(lore);
|
||||||
|
item.setItemMeta(itemMeta);
|
||||||
|
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 String itemStackSerilize(ItemStack it, Integer slot) {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
//String str = gson.toJson(it.serialize());
|
||||||
|
String str = gson.toJson(it.serialize(), new TypeToken<Map>(){}.getType());
|
||||||
|
NBTItem nbti = new NBTItem(it);
|
||||||
|
str = str + "@#NBT#" + nbti.toString();
|
||||||
|
str = str + "@#SLOT#" + slot.toString();
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class itemStackDeserilizeResult {
|
||||||
|
int slot;
|
||||||
|
ItemStack it;
|
||||||
|
|
||||||
|
public itemStackDeserilizeResult(Integer slot, ItemStack it) {
|
||||||
|
this.slot = slot;
|
||||||
|
this.it = it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static itemStackDeserilizeResult itemStackDeserilize(String str) {
|
||||||
|
List<String> mapp = Arrays.asList(str.split("@#NBT#"));
|
||||||
|
Gson gson = new Gson();
|
||||||
|
ItemStack it = new ItemStack(Material.AIR);
|
||||||
|
Integer slot = 0;
|
||||||
|
for (String s : mapp) {
|
||||||
|
if(s != null && s.length() > 2) {
|
||||||
|
try {
|
||||||
|
Map<String, Object> map = gson.fromJson(s, new TypeToken<Map<String, Object>>(){}.getType());
|
||||||
|
it = ItemStack.deserialize(map);
|
||||||
|
} catch (Exception e) {
|
||||||
|
List<String> mappp = Arrays.asList(s.split("@#SLOT#"));
|
||||||
|
for (String ss : mappp) {
|
||||||
|
try {
|
||||||
|
if (ss != null && ss.length() > 2) {
|
||||||
|
NBTItem nbti = new NBTItem(it);
|
||||||
|
String strrr = ss;
|
||||||
|
if (strrr.length() > 2) {
|
||||||
|
for (String strr : strrr.split(",")) {
|
||||||
|
if (!strr.equals("{") && !strr.equals("}")) {
|
||||||
|
strr = strr.replace("{", "");
|
||||||
|
strr = strr.replace("}", "");
|
||||||
|
String[] nb = strr.split(":");
|
||||||
|
nbti.setInteger(nb[0], Integer.valueOf(nb[1]));
|
||||||
|
it = nbti.getItem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ee) {
|
||||||
|
slot = Integer.valueOf(ss);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itemStackDeserilizeResult itt = new itemStackDeserilizeResult(slot, it);
|
||||||
|
return itt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String listItemStackSerelize(List<String> list) {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
String str = "";
|
||||||
|
for(String a : list) {
|
||||||
|
str = str + "@#NEW_ITEM#" + a;
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack[] listItemStackDeserilize(String str) {
|
||||||
|
Gson gson = new Gson();
|
||||||
|
List<String> map = Arrays.asList(str.split("@#NEW_ITEM#"));
|
||||||
|
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
||||||
|
for(String s : map) {
|
||||||
|
ItemStack itt;
|
||||||
|
if(s != null) {
|
||||||
|
itt = itemStackDeserilize(s).it;
|
||||||
|
if (itt != null && itt.getType() != Material.AIR) {
|
||||||
|
items.add(itt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ItemStack[] it = items.toArray(new ItemStack[0]);
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String attributes(String str) {
|
||||||
|
String stt = "";
|
||||||
|
if(str.contains("SPEED")) {
|
||||||
|
stt = "&fSpeed";
|
||||||
|
return stt;
|
||||||
|
}
|
||||||
|
if(str.contains("STRENGTH")) {
|
||||||
|
stt = "&4Strength";
|
||||||
|
return stt;
|
||||||
|
}
|
||||||
|
if(str.contains("HEALTH")) {
|
||||||
|
stt = "&cHealth";
|
||||||
|
return stt;
|
||||||
|
}
|
||||||
|
if(str.contains("DEFENSE")) {
|
||||||
|
stt = "&1Defense";
|
||||||
|
return stt;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
stt = "None";
|
||||||
|
return stt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NBTItem setAttributes(String str, Integer nb, NBTItem nbti) {
|
||||||
|
switch (str) {
|
||||||
|
case "SPEED":
|
||||||
|
nbti.setInteger("SPEED", nb);
|
||||||
|
case "STRENGTH":
|
||||||
|
nbti.setInteger("STRENGTH", nb);
|
||||||
|
case "HEALTH":
|
||||||
|
nbti.setInteger("HEALTH", nb);
|
||||||
|
case "DEFENSE":
|
||||||
|
nbti.setInteger("DEFENSE", nb);
|
||||||
|
default:
|
||||||
|
error("Cant set Attributes with an unknown attribute.");
|
||||||
|
}
|
||||||
|
return nbti;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer getHealth(ItemStack it) {
|
||||||
|
NBTItem nbti = new NBTItem(it);
|
||||||
|
if (nbti.hasKey("HEALTH")){
|
||||||
|
return nbti.getInteger("HEALTH");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
public static Integer getSpeed(ItemStack it) {
|
||||||
|
NBTItem nbti = new NBTItem(it);
|
||||||
|
if (nbti.hasKey("SPEED")){
|
||||||
|
return nbti.getInteger("SPEED");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
public static Integer getDefense(ItemStack it) {
|
||||||
|
NBTItem nbti = new NBTItem(it);
|
||||||
|
if (nbti.hasKey("DEFENSE")){
|
||||||
|
return nbti.getInteger("DEFENSE");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
public static Integer getStrength(ItemStack it) {
|
||||||
|
NBTItem nbti = new NBTItem(it);
|
||||||
|
if (nbti.hasKey("STRENGTH")){
|
||||||
|
return nbti.getInteger("STRENGTH");
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack setLoreFromNBT(ItemStack it) {
|
||||||
|
ItemMeta itm = it.getItemMeta();
|
||||||
|
List<Component> lore = new ArrayList<>();
|
||||||
|
for (Component cp : itm.lore()) {
|
||||||
|
lore.add(cp);
|
||||||
|
}
|
||||||
|
NBTItem nbti = new NBTItem(it);
|
||||||
|
if(nbti.hasKey("SPEED")) {
|
||||||
|
if(lore.size() > 2) {
|
||||||
|
lore.add(2, Component.text(color(attributes("SPEED")) + nbti.getInteger("SPEED")));
|
||||||
|
} else {
|
||||||
|
lore.add(Component.text(color(attributes("SPEED")) + nbti.getInteger("SPEED")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(nbti.hasKey("HEALTH")) {
|
||||||
|
if(lore.size() > 1) {
|
||||||
|
lore.add(1, Component.text(color(attributes("HEALTH")) + nbti.getInteger("HEALTH")));
|
||||||
|
} else {
|
||||||
|
lore.add(Component.text(color(attributes("HEALTH")) + nbti.getInteger("HEALTH")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(nbti.hasKey("DEFENSE")) {
|
||||||
|
if(lore.size() > 3) {
|
||||||
|
lore.add(3, Component.text(color(attributes("DEFENSE")) + nbti.getInteger("DEFENSE")));
|
||||||
|
} else {
|
||||||
|
lore.add(Component.text(color(attributes("DEFENSE")) + nbti.getInteger("DEFENSE")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(nbti.hasKey("STRENGTH")) {
|
||||||
|
if(lore.size() > 3) {
|
||||||
|
lore.add(3, Component.text(color(attributes("STRENGTH")) + nbti.getInteger("STRENGTH")));
|
||||||
|
} else {
|
||||||
|
lore.add(Component.text(color(attributes("STRENGTH")) + nbti.getInteger("STRENGTH")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
itm.lore(lore);
|
||||||
|
it.setItemMeta(itm);
|
||||||
|
return it;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Attributes getNbtFromEntity(LivingEntity e) {
|
||||||
|
EntityEquipment equi = e.getEquipment();
|
||||||
|
Integer health = 0;
|
||||||
|
Integer defense = 0;
|
||||||
|
Integer speed = 0;
|
||||||
|
Integer strength = 0;
|
||||||
|
if (equi != null) {
|
||||||
|
if (equi.getItemInMainHand().getType() != Material.AIR || equi.getItemInMainHand() != null) {
|
||||||
|
ItemStack item = equi.getItemInMainHand();
|
||||||
|
health = health + getHealth(item);
|
||||||
|
defense = defense + getDefense(item);
|
||||||
|
speed = speed + getSpeed(item);
|
||||||
|
strength = strength + getStrength(item);
|
||||||
|
}
|
||||||
|
if (equi.getHelmet().getType() != Material.AIR || equi.getHelmet() != null) {
|
||||||
|
ItemStack item = equi.getHelmet();
|
||||||
|
health = health + getHealth(item);
|
||||||
|
defense = defense + getDefense(item);
|
||||||
|
speed = speed + getSpeed(item);
|
||||||
|
strength = strength + getStrength(item);
|
||||||
|
}
|
||||||
|
if (equi.getChestplate().getType() != Material.AIR || equi.getChestplate() != null) {
|
||||||
|
ItemStack item = equi.getChestplate();
|
||||||
|
health = health + getHealth(item);
|
||||||
|
defense = defense + getDefense(item);
|
||||||
|
speed = speed + getSpeed(item);
|
||||||
|
strength = strength + getStrength(item);
|
||||||
|
}
|
||||||
|
if (equi.getChestplate().getType() != Material.AIR || equi.getChestplate() != null) {
|
||||||
|
ItemStack item = equi.getChestplate();
|
||||||
|
health = health + getHealth(item);
|
||||||
|
defense = defense + getDefense(item);
|
||||||
|
speed = speed + getSpeed(item);
|
||||||
|
strength = strength + getStrength(item);
|
||||||
|
}
|
||||||
|
if (equi.getLeggings().getType() != Material.AIR || equi.getLeggings() != null) {
|
||||||
|
ItemStack item = equi.getLeggings();
|
||||||
|
health = health + getHealth(item);
|
||||||
|
defense = defense + getDefense(item);
|
||||||
|
speed = speed + getSpeed(item);
|
||||||
|
strength = strength + getStrength(item);
|
||||||
|
}
|
||||||
|
if (equi.getBoots().getType() != Material.AIR || equi.getBoots() != null) {
|
||||||
|
ItemStack item = equi.getBoots();
|
||||||
|
health = health + getHealth(item);
|
||||||
|
defense = defense + getDefense(item);
|
||||||
|
speed = speed + getSpeed(item);
|
||||||
|
strength = strength + getStrength(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Attributes attributes = new Attributes(health, defense, speed, strength);
|
||||||
|
return attributes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -5,7 +5,7 @@ import gq.unurled.raxen.config.Config;
|
||||||
import gq.unurled.raxen.manager.StorageManager;
|
import gq.unurled.raxen.manager.StorageManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.sql.*;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
public class Mysql {
|
public class Mysql {
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.server.ServerListPingEvent;
|
import org.bukkit.event.server.ServerListPingEvent;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
|
|
|
@ -10,15 +10,19 @@ public class Skills {
|
||||||
|
|
||||||
public static void updateSkills(Player player) {
|
public static void updateSkills(Player player) {
|
||||||
gq.unurled.raxen.components.player.Skills skills = Raxen.getProfileManager().getPlayerProfile(player.getUniqueId()).getSkils();
|
gq.unurled.raxen.components.player.Skills skills = Raxen.getProfileManager().getPlayerProfile(player.getUniqueId()).getSkils();
|
||||||
int health, defense, speed, strength;
|
int health, itemHealth, defense, itemDefense, speed, itemSpeed, strength, itemDmg;
|
||||||
health = skills.getHealth();
|
health = skills.getHealth();
|
||||||
|
itemHealth = skills.getItemHealth();
|
||||||
defense = skills.getDefense();
|
defense = skills.getDefense();
|
||||||
|
itemDefense = skills.getItemDefense();
|
||||||
speed = skills.getSpeed();
|
speed = skills.getSpeed();
|
||||||
|
itemSpeed = skills.getItemSpeed();
|
||||||
strength = skills.getStrength();
|
strength = skills.getStrength();
|
||||||
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20D + health / 100);
|
itemDmg = skills.getItemDmg();
|
||||||
player.setWalkSpeed((float) (0.0 + (speed / 100) * 0.2));
|
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20D + (health + itemHealth) / 100);
|
||||||
player.setFlySpeed((float) (0.0 + (speed / 100) * 0.2));
|
player.setWalkSpeed((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||||
msgPlayer(player, "Speed " + speed, "Health " + health, "Defense " + defense, "Strength " + strength);
|
player.setFlySpeed((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||||
|
msgPlayer(player, "Speed " + (speed + itemSpeed), "Health " + (health + itemHealth), "Defense " + (defense+itemDefense), "Strength " + (strength+itemDmg));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,13 @@
|
||||||
package gq.unurled.raxen.utils;
|
package gq.unurled.raxen.utils;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
|
||||||
import de.tr7zw.changeme.nbtapi.NBTItem;
|
|
||||||
import gq.unurled.raxen.Raxen;
|
import gq.unurled.raxen.Raxen;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
@ -53,58 +46,12 @@ public class Utils {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack createItem(Material material, int amount, boolean glow, boolean unb, String name, String... lore) {
|
|
||||||
ItemStack item = new ItemStack(material, amount);
|
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
|
||||||
if(name != null) {
|
|
||||||
itemMeta.displayName(Component.text(color(name)));
|
|
||||||
}
|
|
||||||
if(lore != null) {
|
|
||||||
List<Component> list = new ArrayList<>();
|
|
||||||
for(String string : lore) {
|
|
||||||
list.add(Component.text(color(string)));
|
|
||||||
}
|
|
||||||
itemMeta.lore(list);
|
|
||||||
}
|
|
||||||
if(glow) {
|
|
||||||
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
|
||||||
itemMeta.addEnchant(Enchantment.DURABILITY, 1, true);
|
|
||||||
}
|
|
||||||
if(unb) {
|
|
||||||
itemMeta.setUnbreakable(true);
|
|
||||||
}
|
|
||||||
item.setItemMeta(itemMeta);
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack editItem(ItemStack item, String name,int amount, List<Component> lore) {
|
|
||||||
if(amount == 0) {
|
|
||||||
amount = 1;
|
|
||||||
}
|
|
||||||
item.setAmount(amount);
|
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
|
||||||
if (name != null) {
|
|
||||||
itemMeta.displayName(Component.text(name));
|
|
||||||
}
|
|
||||||
itemMeta.lore(lore);
|
|
||||||
item.setItemMeta(itemMeta);
|
|
||||||
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) {
|
public static Inventory fillGreyPane(Inventory inv) {
|
||||||
Integer in = -1;
|
Integer in = -1;
|
||||||
for (ItemStack it : inv) {
|
for (ItemStack it : inv) {
|
||||||
in++;
|
in++;
|
||||||
if (it == null || it.getType() == Material.AIR) {
|
if (it == null || it.getType() == Material.AIR) {
|
||||||
inv.setItem(in, greyPane());
|
inv.setItem(in, Items.greyPane());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return inv;
|
return inv;
|
||||||
|
@ -118,134 +65,6 @@ public class Utils {
|
||||||
return Component.text(color("&cAn Error has occurred. Please retry or contact an Admin."));
|
return Component.text(color("&cAn Error has occurred. Please retry or contact an Admin."));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String itemStackSerilize(ItemStack it, Integer slot) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
//String str = gson.toJson(it.serialize());
|
|
||||||
String str = gson.toJson(it.serialize(), new TypeToken<Map>(){}.getType());
|
|
||||||
NBTItem nbti = new NBTItem(it);
|
|
||||||
str = str + "@#NBT#" + nbti.toString();
|
|
||||||
str = str + "@#SLOT#" + slot.toString();
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class itemStackDeserilizeResult {
|
|
||||||
int slot;
|
|
||||||
ItemStack it;
|
|
||||||
|
|
||||||
public itemStackDeserilizeResult(Integer slot, ItemStack it) {
|
|
||||||
this.slot = slot;
|
|
||||||
this.it = it;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static itemStackDeserilizeResult itemStackDeserilize(String str) {
|
|
||||||
List<String> mapp = Arrays.asList(str.split("@#NBT#"));
|
|
||||||
Gson gson = new Gson();
|
|
||||||
ItemStack it = new ItemStack(Material.AIR);
|
|
||||||
Integer slot = 0;
|
|
||||||
for (String s : mapp) {
|
|
||||||
if(s != null && s.length() > 2) {
|
|
||||||
try {
|
|
||||||
Map<String, Object> map = gson.fromJson(s, new TypeToken<Map<String, Object>>(){}.getType());
|
|
||||||
it = ItemStack.deserialize(map);
|
|
||||||
} catch (Exception e) {
|
|
||||||
List<String> mappp = Arrays.asList(s.split("@#SLOT#"));
|
|
||||||
for (String ss : mappp) {
|
|
||||||
try {
|
|
||||||
if (ss != null && ss.length() > 2) {
|
|
||||||
NBTItem nbti = new NBTItem(it);
|
|
||||||
String strrr = ss;
|
|
||||||
if (strrr.length() > 2) {
|
|
||||||
for (String strr : strrr.split(",")) {
|
|
||||||
if (!strr.equals("{") && !strr.equals("}")) {
|
|
||||||
strr = strr.replace("{", "");
|
|
||||||
strr = strr.replace("}", "");
|
|
||||||
String[] nb = strr.split(":");
|
|
||||||
nbti.setInteger(nb[0], Integer.valueOf(nb[1]));
|
|
||||||
it = nbti.getItem();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception ee) {
|
|
||||||
slot = Integer.valueOf(ss);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
itemStackDeserilizeResult itt = new itemStackDeserilizeResult(slot, it);
|
|
||||||
return itt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String listItemStackSerelize(List<String> list) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
String str = "";
|
|
||||||
for(String a : list) {
|
|
||||||
str = str + "@#NEW_ITEM#" + a;
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ItemStack[] listItemStackDeserilize(String str) {
|
|
||||||
Gson gson = new Gson();
|
|
||||||
List<String> map = Arrays.asList(str.split("@#NEW_ITEM#"));
|
|
||||||
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
|
|
||||||
for(String s : map) {
|
|
||||||
ItemStack itt;
|
|
||||||
if(s != null) {
|
|
||||||
itt = itemStackDeserilize(s).it;
|
|
||||||
if (itt != null && itt.getType() != Material.AIR) {
|
|
||||||
items.add(itt);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ItemStack[] it = items.toArray(new ItemStack[0]);
|
|
||||||
return it;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String attributes(String str) {
|
|
||||||
String stt = "";
|
|
||||||
if(str.contains("SPEED")) {
|
|
||||||
stt = "&fSpeed";
|
|
||||||
return stt;
|
|
||||||
}
|
|
||||||
if(str.contains("STRENGTH")) {
|
|
||||||
stt = "&4Strength";
|
|
||||||
return stt;
|
|
||||||
}
|
|
||||||
if(str.contains("HEALTH")) {
|
|
||||||
stt = "&cHealth";
|
|
||||||
return stt;
|
|
||||||
}
|
|
||||||
if(str.contains("DEFENSE")) {
|
|
||||||
stt = "&1Defense";
|
|
||||||
return stt;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
stt = "None";
|
|
||||||
return stt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NBTItem setAttributes(String str, Integer nb, NBTItem nbti) {
|
|
||||||
log(str);
|
|
||||||
switch (str) {
|
|
||||||
case "SPEED":
|
|
||||||
nbti.setInteger("SPEED", nb);
|
|
||||||
case "STRENGTH":
|
|
||||||
nbti.setInteger("STRENGTH", nb);
|
|
||||||
case "HEALTH":
|
|
||||||
nbti.setInteger("HEALTH", nb);
|
|
||||||
case "DEFENSE":
|
|
||||||
nbti.setInteger("DEFENSE", nb);
|
|
||||||
default:
|
|
||||||
error("Cant set Attributes with an unknown attribute.");
|
|
||||||
}
|
|
||||||
return nbti;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,3 +7,7 @@ storage: "MONGODB" #switch between "MONGODB", "MYSQL"(not implemented), "YML"(cu
|
||||||
username: "Your-username-here"
|
username: "Your-username-here"
|
||||||
password: "Your-password-here"
|
password: "Your-password-here"
|
||||||
url: "url-to-the-server/db_Name"
|
url: "url-to-the-server/db_Name"
|
||||||
|
|
||||||
|
useResourcePack: true
|
||||||
|
resource_pack_url: "https://mc-packs.net/" # recommend to use https://mc-packs.net/ => free ressource pack hoster (will eventualy developp one myself but not atm)
|
||||||
|
resource_pack_sha1: "sha1hallo" # sha1 hash
|
|
@ -8,6 +8,9 @@ strength: 100
|
||||||
custom_ability: "fireball"
|
custom_ability: "fireball"
|
||||||
isGlowing: true
|
isGlowing: true
|
||||||
isUnbreakable: true
|
isUnbreakable: true
|
||||||
custom_model_data: 123
|
Pack:
|
||||||
|
parent: "item/generated"
|
||||||
|
custom_model_data: 123
|
||||||
|
model: "red_wool"
|
||||||
lore:
|
lore:
|
||||||
- '&cSuper lore'
|
- '&cSuper lore'
|
31
src/main/resources/example_mob.yml
Normal file
31
src/main/resources/example_mob.yml
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
world: world
|
||||||
|
display_name: '&fLvl: {level} {name} &c❤{hp}&f/&c❤{hp_max}'
|
||||||
|
name: 'example mob'
|
||||||
|
base_mob: ZOMBIE
|
||||||
|
ID: EXAMPLE_MOB
|
||||||
|
level:
|
||||||
|
1-10:
|
||||||
|
hp_max: 100*{level}
|
||||||
|
speed: 100+({level}/10)
|
||||||
|
strength: 10*{level}
|
||||||
|
defense: 0
|
||||||
|
11-20:
|
||||||
|
hp_max: 200*{level}
|
||||||
|
speed: 100+({level}/10)
|
||||||
|
strength: 10*{level}
|
||||||
|
defense: 0
|
||||||
|
21-30:
|
||||||
|
hp_max: 200*{level}
|
||||||
|
speed: 100+({level}/10)
|
||||||
|
strength: 10*{level}
|
||||||
|
defense: 0
|
||||||
|
31-40:
|
||||||
|
hp_max: 200*{level}
|
||||||
|
speed: 100+({level}/10)
|
||||||
|
strength: 10*{level}
|
||||||
|
defense: 0
|
||||||
|
41-50:
|
||||||
|
hp_max: 200*{level}
|
||||||
|
speed: 100+({level}/10)
|
||||||
|
strength: 10*{level}
|
||||||
|
defense: 0
|
Loading…
Reference in a new issue