0.4.3: change in Damage system => it's working !, Attributes, ...
need some testin and also make damage by block event
This commit is contained in:
parent
5f5e4fa87c
commit
bc12dcc70a
25 changed files with 182 additions and 120 deletions
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>gq.unurled</groupId>
|
||||
<artifactId>raxen</artifactId>
|
||||
<version>0.4.2</version>
|
||||
<version>0.4.3</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Raxen</name>
|
||||
|
|
|
@ -20,7 +20,7 @@ public final class Raxen extends JavaPlugin {
|
|||
|
||||
private static final String prefix = ChatColor.AQUA + "Rx" + ChatColor.LIGHT_PURPLE + "> ";
|
||||
@Getter
|
||||
private static final String version = "0.4.2";
|
||||
private static final String version = "0.4.3";
|
||||
private final PluginManager pm = getServer().getPluginManager();
|
||||
|
||||
@Getter
|
||||
|
|
|
@ -2,7 +2,6 @@ package gq.unurled.raxen.commands;
|
|||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.manager.StorageManager;
|
||||
import gq.unurled.raxen.utils.Utils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
|
@ -71,7 +70,6 @@ public class RaxenCommand implements TabExecutor {
|
|||
return true;
|
||||
}
|
||||
case 1 -> {
|
||||
log("hello");
|
||||
switch (args[0]) {
|
||||
case "mongodb", "mongo", "MONGODB", "MONGO" -> {
|
||||
//print info about connection
|
||||
|
@ -96,7 +94,7 @@ public class RaxenCommand implements TabExecutor {
|
|||
}
|
||||
case "hemlp", "?", "h" ->
|
||||
//print help
|
||||
log("why tf?");
|
||||
debug(main, "print help");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.bukkit.command.TabExecutor;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
@ -25,8 +24,8 @@ import static gq.unurled.raxen.utils.Utils.*;
|
|||
|
||||
public class NbtCommand implements TabExecutor {
|
||||
|
||||
private Raxen main;
|
||||
private ProfileManager profileManager;
|
||||
private final Raxen main;
|
||||
private final ProfileManager profileManager;
|
||||
|
||||
public NbtCommand(Raxen main) {
|
||||
this.main = main;
|
||||
|
@ -45,16 +44,13 @@ public class NbtCommand implements TabExecutor {
|
|||
return true;
|
||||
}
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
case 1:
|
||||
msgPlayer(player, color("&cYou must specify an nbt and an int."));
|
||||
break;
|
||||
case 2:
|
||||
log("'"+args[0]+"'", "'"+args[1]+"'");
|
||||
case 0, 1 -> msgPlayer(player, color("&cYou must specify an nbt and an int."));
|
||||
case 2 -> {
|
||||
debug(main, "'" + args[0] + "'", "'" + args[1] + "'");
|
||||
ItemStack it = player.getInventory().getItemInMainHand();
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
int a = 0;
|
||||
if(nbti.hasKey(args[1])) {
|
||||
if (nbti.hasKey(args[1])) {
|
||||
a = nbti.getInteger(args[1]);
|
||||
}
|
||||
List<Component> lore = new ArrayList<>();
|
||||
|
@ -62,7 +58,7 @@ public class NbtCommand implements TabExecutor {
|
|||
lore.add((Component) itm.lore());
|
||||
Boolean yes = false;
|
||||
Boolean ever = false;
|
||||
for(Component ct : lore) {
|
||||
for (Component ct : lore) {
|
||||
if (ct != null) {
|
||||
if (ct.contains(Component.text("Attributes:"))) {
|
||||
yes = true;
|
||||
|
@ -75,31 +71,32 @@ public class NbtCommand implements TabExecutor {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(!ever) {
|
||||
if (!ever) {
|
||||
lore.add(Component.text(color("&cAttributes:")));
|
||||
lore.add(Component.text(color(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a) )));
|
||||
lore.add(Component.text(color(attributes(args[0]) + ": " + (Integer.parseInt(args[1]) + a))));
|
||||
}
|
||||
itm.lore(lore);
|
||||
it.setItemMeta(itm);
|
||||
Attributes attributes = new Attributes(main);
|
||||
nbti.setInteger(args[0], Integer.parseInt(args[1]) + a);
|
||||
if(nbti.hasKey("SPEED")) {
|
||||
if (nbti.hasKey("SPEED")) {
|
||||
attributes.addSpeed(player, nbti.getInteger("SPEED"));
|
||||
}
|
||||
if(nbti.hasKey("HEALTH")) {
|
||||
if (nbti.hasKey("HEALTH")) {
|
||||
attributes.addHealth(player, nbti.getInteger("HEALTH"));
|
||||
}
|
||||
if(nbti.hasKey("DEFENSE")) {
|
||||
if (nbti.hasKey("DEFENSE")) {
|
||||
attributes.addDefense(player, nbti.getInteger("DEFENSE"));
|
||||
}
|
||||
if(nbti.hasKey("STRENGTH")) {
|
||||
if (nbti.hasKey("STRENGTH")) {
|
||||
attributes.addStrength(player, nbti.getInteger("STRENGTH"));
|
||||
}
|
||||
it = nbti.getItem();
|
||||
msgPlayer(player, Raxen.getPrefix() + color("&fYou successfully added the nbt " +attributes(args[0]) + "&fwith " + args[1] + "&f."));
|
||||
msgPlayer(player, Raxen.getPrefix() + color("&fYou successfully added the nbt " + attributes(args[0]) + "&fwith " + args[1] + "&f."));
|
||||
updateSkills(main, player);
|
||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), it);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,13 +8,11 @@ import org.bukkit.command.TabExecutor;
|
|||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static gq.unurled.raxen.components.entity.Entity.setNameSpacedKeys;
|
||||
import static gq.unurled.raxen.utils.Utils.*;
|
||||
|
@ -32,11 +30,11 @@ public class SpawnEntity implements TabExecutor {
|
|||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
log("&cConsole can't execute this command!");
|
||||
log(color("&cConsole can't execute this command!"));
|
||||
return false;
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
if (player.hasPermission("raxen.entityspawn.cmd")) {
|
||||
if (!player.hasPermission("raxen.entityspawn.cmd")) {
|
||||
player.sendMessage(noPerms());
|
||||
return false;
|
||||
}
|
||||
|
@ -49,6 +47,10 @@ public class SpawnEntity implements TabExecutor {
|
|||
|
||||
@Override
|
||||
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||
return null;
|
||||
List<String> list = new ArrayList<>();
|
||||
for (EntityType type : EntityType.values()) {
|
||||
list.add(type.name());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ package gq.unurled.raxen.components.entity;
|
|||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.player.Attributes.Attribute;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
public class Attributes {
|
||||
|
||||
|
|
|
@ -6,8 +6,7 @@ import org.bukkit.entity.LivingEntity;
|
|||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.log;
|
||||
import static gq.unurled.raxen.utils.Utils.msgPlayer;
|
||||
import static gq.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class Entity {
|
||||
|
||||
|
@ -15,7 +14,7 @@ public class Entity {
|
|||
private static EntityNamespacedKey namespacedKey;
|
||||
|
||||
public Entity(Raxen main) {
|
||||
main = main;
|
||||
this.main = main;
|
||||
namespacedKey = new EntityNamespacedKey(main);
|
||||
}
|
||||
|
||||
|
@ -26,7 +25,7 @@ public class Entity {
|
|||
data.set(namespacedKey.speedKey, PersistentDataType.INTEGER, speed);
|
||||
data.set(namespacedKey.itemSpeedKey, PersistentDataType.INTEGER, itemSpeed);
|
||||
data.set(namespacedKey.defenseKey, PersistentDataType.INTEGER, defense);
|
||||
data.set(namespacedKey.itemDefenseKey, PersistentDataType.INTEGER, defense);
|
||||
data.set(namespacedKey.itemDefenseKey, PersistentDataType.INTEGER, itemDefense);
|
||||
data.set(namespacedKey.strengthKey, PersistentDataType.INTEGER, strength);
|
||||
data.set(namespacedKey.itemStrengthKey, PersistentDataType.INTEGER, itemDmg);
|
||||
data.set(namespacedKey.nameKey, PersistentDataType.STRING, name);
|
||||
|
@ -59,10 +58,14 @@ public class Entity {
|
|||
itemSpeed = attributes.getItemSpeed(e);
|
||||
strength = attributes.getStrength(e);
|
||||
itemDmg = attributes.getItemStrength(e);
|
||||
livingEntity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).setBaseValue(20D + (health + itemHealth) / 100);
|
||||
if (livingEntity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_FLYING_SPEED) != null) {
|
||||
livingEntity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_FLYING_SPEED).setBaseValue((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||
}
|
||||
if (livingEntity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MOVEMENT_SPEED) != null) {
|
||||
livingEntity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue((float) (0.0 + ((speed + itemSpeed) / 100) * 0.2));
|
||||
log("Speed " + (speed + itemSpeed), "Health " + (health + itemHealth), "Defense " + (defense+itemDefense), "Strength " + (strength+itemDmg));
|
||||
}
|
||||
livingEntity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH).setBaseValue(20D + (health + itemHealth) / 100);
|
||||
debug(main, "Speed " + (speed + itemSpeed), "Health " + (health + itemHealth), "Defense " + (defense+itemDefense), "Strength " + (strength+itemDmg));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import gq.unurled.raxen.Raxen;
|
|||
import org.bukkit.NamespacedKey;
|
||||
|
||||
public class EntityNamespacedKey {
|
||||
|
||||
public EntityNamespacedKey(Raxen main) {
|
||||
nameKey = new NamespacedKey(main, "name");
|
||||
levelKey = new NamespacedKey(main, "level");
|
||||
|
|
|
@ -1,9 +1,4 @@
|
|||
package gq.unurled.raxen.components.entity.spawn;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
public class Eggs {
|
||||
}
|
||||
|
|
10
src/main/java/gq/unurled/raxen/components/items/NBT.java
Normal file
10
src/main/java/gq/unurled/raxen/components/items/NBT.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package gq.unurled.raxen.components.items;
|
||||
|
||||
public class NBT {
|
||||
|
||||
public static String HEALTH = "HEALTH";
|
||||
public static String SPEED = "SPEED";
|
||||
public static String STRENGTH = "STRENGTH";
|
||||
public static String DEFENSE = "DEFENSE";
|
||||
|
||||
}
|
|
@ -2,8 +2,6 @@ package gq.unurled.raxen.components.player.Attributes;
|
|||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.entity.EntityNamespacedKey;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.bukkit.scoreboard.Score;
|
|||
import org.bukkit.scoreboard.ScoreboardManager;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.color;
|
||||
import static gq.unurled.raxen.utils.Utils.log;
|
||||
import static gq.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class Scoreboard {
|
||||
|
||||
|
@ -45,7 +45,7 @@ public class Scoreboard {
|
|||
if(player != null) {
|
||||
Objective objective = player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
|
||||
player.getScoreboard().getObjective(DisplaySlot.SIDEBAR);
|
||||
log(String.valueOf(player.getScoreboard().getEntries()));
|
||||
debug(main, String.valueOf(player.getScoreboard().getEntries()));
|
||||
for (String str : player.getScoreboard().getEntries()) {
|
||||
if(str.contains(player.getName())) {
|
||||
|
||||
|
|
|
@ -7,10 +7,9 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.log;
|
||||
import static gq.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class Config {
|
||||
private Raxen main;
|
||||
|
@ -34,13 +33,13 @@ public class Config {
|
|||
main.saveDefaultConfig();
|
||||
}
|
||||
FileConfiguration conf = new YamlConfiguration();
|
||||
log(config.getString("version"));
|
||||
debug(main, config.getString("version"));
|
||||
try {
|
||||
conf.load(configFile);
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
log(conf.getString("version"));
|
||||
debug(main, conf.getString("version"));
|
||||
if(!Raxen.getVersion().equals(config.getString("version"))){
|
||||
main.saveResource("config.yml", true);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package gq.unurled.raxen.config;
|
|||
import com.mongodb.client.MongoCollection;
|
||||
import com.mongodb.client.model.Filters;
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.player.Attributes.Attribute;
|
||||
import gq.unurled.raxen.components.player.Attributes.Attributes;
|
||||
import gq.unurled.raxen.components.player.Inventories;
|
||||
import gq.unurled.raxen.components.player.Storage;
|
||||
|
@ -26,7 +25,7 @@ import java.io.IOException;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.log;
|
||||
import static gq.unurled.raxen.utils.Utils.debug;
|
||||
import static gq.unurled.raxen.utils.Utils.warn;
|
||||
|
||||
public class PlayerConfig {
|
||||
|
@ -36,6 +35,7 @@ public class PlayerConfig {
|
|||
private MongoCollection<Document> mongoCollection;
|
||||
private static ProfileManager profileManager;
|
||||
private static StorageManager sto;
|
||||
private Attributes attributes;
|
||||
|
||||
public PlayerConfig(Raxen main) {
|
||||
PlayerConfig.main = main;
|
||||
|
@ -43,6 +43,7 @@ public class PlayerConfig {
|
|||
this.mongoDB = StorageManager.getMongo();
|
||||
this.mongoCollection = mongoDB.getMongoCollection();
|
||||
profileManager = Raxen.getProfileManager();
|
||||
this.attributes = new Attributes(main);
|
||||
}
|
||||
|
||||
public void close() {
|
||||
|
@ -80,11 +81,11 @@ public class PlayerConfig {
|
|||
Document playerDoc = mongoCollection.find(Filters.eq("uuid", player.getUniqueId().toString())).first();
|
||||
if(playerDoc == null) {
|
||||
mongoCollection.insertOne(doc);
|
||||
log("insert one");
|
||||
debug(main, "insert one");
|
||||
}
|
||||
else {
|
||||
mongoCollection.replaceOne(Filters.eq("uuid", player.getUniqueId().toString()), doc);
|
||||
log("replace one");
|
||||
debug(main, "replace one");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,13 +127,14 @@ public class PlayerConfig {
|
|||
public void loadUsingMongoDB(Player player) {
|
||||
Document playerDoc = mongoCollection.find(Filters.eq("uuid", player.getUniqueId().toString())).first();
|
||||
if(playerDoc == null) {
|
||||
log("something went wrong");
|
||||
debug(main, "Intiatilising Data for Player: " + player.getName());
|
||||
profileManager.createNewProfile(player);
|
||||
profileManager.createNewStorage(player);
|
||||
profileManager.createNewInventory(player);
|
||||
return;
|
||||
}
|
||||
Attributes.setAttributes(player, playerDoc.getInteger("health"), playerDoc.getInteger("itemHealth"), playerDoc.getInteger("defense"),
|
||||
debug(main, "Loading " + player.getName() + "'s data!");
|
||||
attributes.setAttributes(player, playerDoc.getInteger("health"), playerDoc.getInteger("itemHealth"), playerDoc.getInteger("defense"),
|
||||
playerDoc.getInteger("itemDefense"), playerDoc.getInteger("speed"), playerDoc.getInteger("itemSpeed"),
|
||||
playerDoc.getInteger("strength"), playerDoc.getInteger("itemDmg"));
|
||||
|
||||
|
@ -155,11 +157,10 @@ public class PlayerConfig {
|
|||
|
||||
public void loadUsingYml(Player player) throws IOException {
|
||||
FileConfiguration config = sto.createYml(player);
|
||||
Attributes.setAttributes(player, config.getInt("health"), config.getInt("itemHealth"),
|
||||
attributes.setAttributes(player, config.getInt("health"), config.getInt("itemHealth"),
|
||||
config.getInt("defense"), config.getInt("itemDefense"),
|
||||
config.getInt("speed"), config.getInt("itemSpeed"),
|
||||
config.getInt("strength"), config.getInt("itemDmg"));
|
||||
|
||||
Inventory ec = Bukkit.createInventory(null, 54, Component.text("Ender Chest"));
|
||||
if((String) config.get("ec") != null) {
|
||||
ItemStack[] itList = Items.listItemStackDeserilize((String) config.get("ec"));
|
||||
|
@ -190,16 +191,16 @@ public class PlayerConfig {
|
|||
}
|
||||
}
|
||||
String invstr = Items.listItemStackSerelize(listInv);
|
||||
log("saving...");
|
||||
debug(main, "saving...");
|
||||
String storage = sto.getConfig().getString("storage");
|
||||
saveUsingMongoDB(player, attributes, invstr, reverse);
|
||||
log("using mongo");
|
||||
debug(main, "using mongo");
|
||||
if (storage == "MYSQL" || storage == "YML") {
|
||||
saveUsingYml(player, attributes, invstr, reverse);
|
||||
log("using yml");
|
||||
debug(main, "using yml");
|
||||
}
|
||||
|
||||
log("Player: " + player.getName() + " data successfully saved!");
|
||||
debug(main, "Player: " + player.getName() + " data successfully saved!");
|
||||
}
|
||||
|
||||
public void loadPlayerConfig(Player player) {
|
||||
|
@ -219,7 +220,7 @@ public class PlayerConfig {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
log("Player: " + player.getName() + " data successfully loaded using " + value);
|
||||
debug(main, "Player: " + player.getName() + " data successfully loaded using " + value);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,11 +11,12 @@ 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.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.log;
|
||||
import static gq.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class DamageEntity implements Listener {
|
||||
private Raxen main;
|
||||
|
@ -39,7 +40,7 @@ public class DamageEntity implements Listener {
|
|||
Integer health = 0;
|
||||
Integer itemHealth = 0;
|
||||
Integer initDamage = 0;
|
||||
log(e.getEntity().getName(), e.getEntity().getType().toString(), e.getDamager().getType().toString(), e.getDamager().getName());
|
||||
debug(main, e.getEntity().getName(), e.getEntity().getType().toString(), e.getDamager().getType().toString(), e.getDamager().getName());
|
||||
if (e.getDamager() instanceof Player) {
|
||||
Player playerDamager = (Player) e.getDamager();
|
||||
gq.unurled.raxen.components.player.Attributes.Attributes attributes = new gq.unurled.raxen.components.player.Attributes.Attributes(main);
|
||||
|
@ -74,21 +75,28 @@ public class DamageEntity implements Listener {
|
|||
itemDefense = attributes.getDefense();
|
||||
itemHealth = attributes.getHealth();
|
||||
}
|
||||
debug(main, initDamage.toString(), itemDefense.toString(), strength.toString());
|
||||
initDamage = (5+ itemDmg) * (1+ (strength/100));
|
||||
damage = initDamage;
|
||||
defense = defense + itemDefense;
|
||||
log(String.valueOf(damage));
|
||||
debug(main, String.valueOf(damage));
|
||||
defense = defense/(defense+100);
|
||||
log(String.valueOf(damage));
|
||||
log(String.valueOf(defense));
|
||||
debug(main, String.valueOf(damage));
|
||||
debug(main, String.valueOf(defense));
|
||||
Integer health_with_defense = health * (1+ (defense/100));
|
||||
log(String.valueOf(damage));
|
||||
log(String.valueOf(health));
|
||||
log(String.valueOf(health_with_defense));
|
||||
debug(main, String.valueOf(damage));
|
||||
debug(main, String.valueOf(health));
|
||||
debug(main, String.valueOf(health_with_defense));
|
||||
if (damage >= health_with_defense) {
|
||||
debug(main, "Killed entity normally.");
|
||||
e.setDamage(e.getEntity().getType().getDefaultAttributes().getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue());
|
||||
} else {
|
||||
debug(main, "Applying damage to entity.");
|
||||
if (defense == 0) {
|
||||
health = health_with_defense - damage;
|
||||
} else {
|
||||
health = health_with_defense - health - damage;
|
||||
}
|
||||
if (e.getEntity() instanceof Player) {
|
||||
Player playerVictim = (Player) e.getEntity();
|
||||
gq.unurled.raxen.components.player.Attributes.Attributes attributes = new gq.unurled.raxen.components.player.Attributes.Attributes(main);
|
||||
|
@ -98,6 +106,18 @@ public class DamageEntity implements Listener {
|
|||
PersistentDataContainer data = entityVictim.getPersistentDataContainer();
|
||||
data.set(entityNamespacedKey.healthKey, PersistentDataType.INTEGER, health);
|
||||
}
|
||||
debug(main, health.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void entityDamageByBlock(EntityDamageByBlockEvent e) {
|
||||
e.setDamage(0);
|
||||
if (e.getEntity() instanceof Player) {
|
||||
Player player = (Player) e.getEntity();
|
||||
gq.unurled.raxen.components.player.Attributes.Attributes attributes = new gq.unurled.raxen.components.player.Attributes.Attributes(main);
|
||||
Integer health = attributes.getHealth(player);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,24 +1,41 @@
|
|||
package gq.unurled.raxen.listener.entity;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.entity.Entity;
|
||||
import gq.unurled.raxen.components.entity.EntityNamespacedKey;
|
||||
import org.bukkit.entity.EntityType;
|
||||
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.EntitySpawnEvent;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import static gq.unurled.raxen.components.entity.Entity.updateSkills;
|
||||
import static gq.unurled.raxen.utils.Utils.log;
|
||||
import static gq.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class SpawnEvent implements Listener {
|
||||
|
||||
private Raxen main;
|
||||
private gq.unurled.raxen.components.entity.Entity entity;
|
||||
private EntityNamespacedKey namespacedKey;
|
||||
|
||||
public SpawnEvent(Raxen main) {
|
||||
this.main = main;
|
||||
this.entity = new Entity(main);
|
||||
this.namespacedKey = new EntityNamespacedKey(main);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void Spawn(EntitySpawnEvent e) {
|
||||
if (e.getEntity() instanceof Player) {
|
||||
//player stuff dont want to talk about it;
|
||||
log("Player: " + ((Player) e.getEntity()).getName());
|
||||
} else {
|
||||
log(e.getEntity().getName());
|
||||
updateSkills((LivingEntity) e.getEntity());
|
||||
debug(main, "Player: " + ((Player) e.getEntity()).getName());
|
||||
} else if (e.getEntity().getType() != EntityType.DROPPED_ITEM) {
|
||||
debug(main, e.getEntity().getName());
|
||||
if (!e.getEntity().getPersistentDataContainer().has(namespacedKey.nameKey, PersistentDataType.STRING)) {
|
||||
entity.setNameSpacedKeys(e.getEntity(), e.getEntityType().name(), 1, 10, 0, 50, 0, 100, 0, 100, 0);
|
||||
}
|
||||
entity.updateSkills((LivingEntity) e.getEntity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,7 @@ package gq.unurled.raxen.manager;
|
|||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.commands.RaxenCommand;
|
||||
import gq.unurled.raxen.commands.admin.ItemListCommand;
|
||||
import gq.unurled.raxen.commands.admin.NbtCommand;
|
||||
import gq.unurled.raxen.commands.admin.ReloadCommand;
|
||||
import gq.unurled.raxen.commands.admin.TestGuiCommand;
|
||||
import gq.unurled.raxen.commands.admin.*;
|
||||
import gq.unurled.raxen.commands.player.SkillsCommand;
|
||||
import gq.unurled.raxen.commands.player.StorageCommand;
|
||||
import lombok.Getter;
|
||||
|
@ -17,15 +14,18 @@ public class CommandManager {
|
|||
@Getter
|
||||
private ItemListCommand itemListCommand;
|
||||
private ReloadCommand reloadComand = new ReloadCommand();
|
||||
private NbtCommand nbtCommand = new NbtCommand(main);
|
||||
private NbtCommand nbtCommand;
|
||||
private TestGuiCommand testGuiCommand = new TestGuiCommand();
|
||||
private StorageCommand storageCommand = new StorageCommand();
|
||||
private SkillsCommand skillsCommand = new SkillsCommand(main);
|
||||
private RaxenCommand raxenCommand = new RaxenCommand(main);
|
||||
private SpawnEntity entityspawn;
|
||||
|
||||
public CommandManager(Raxen main) {
|
||||
this.main = main;
|
||||
this.itemListCommand = new ItemListCommand(this.main);
|
||||
this.nbtCommand = new NbtCommand(this.main);
|
||||
this.entityspawn = new SpawnEntity(this.main);
|
||||
}
|
||||
|
||||
public void register() {
|
||||
|
@ -50,6 +50,9 @@ public class CommandManager {
|
|||
|
||||
main.getCommand("itemlist").setExecutor(itemListCommand);
|
||||
main.getCommand("itemlist").setTabCompleter(itemListCommand);
|
||||
|
||||
main.getCommand("entityspawn").setTabCompleter(entityspawn);
|
||||
main.getCommand("entityspawn").setExecutor(entityspawn);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ public class ItemManager {
|
|||
}
|
||||
|
||||
private void registerItem(FileConfiguration file) {
|
||||
log((String) file.get("id"));
|
||||
debug(main, (String) file.get("id"));
|
||||
ItemStack it = new ItemStack(Material.getMaterial((String) file.get("id")));
|
||||
ItemMeta itm = it.getItemMeta();
|
||||
itm.displayName(Component.text(color((String) file.get("name"))));
|
||||
|
|
|
@ -2,6 +2,7 @@ package gq.unurled.raxen.manager;
|
|||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.listener.entity.DamageEntity;
|
||||
import gq.unurled.raxen.listener.entity.SpawnEvent;
|
||||
import gq.unurled.raxen.listener.player.*;
|
||||
import gq.unurled.raxen.utils.Reload;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
@ -25,5 +26,6 @@ public class ListenerManager {
|
|||
this.pm.registerEvents(new TransactionEvent(main), main);
|
||||
this.pm.registerEvents(main.getCommandManager().getItemListCommand().getItemListGui(), main);
|
||||
this.pm.registerEvents(new DamageEntity(main), main);
|
||||
this.pm.registerEvents(new SpawnEvent(main), main);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package gq.unurled.raxen.manager;
|
|||
|
||||
import gq.unurled.raxen.Raxen;
|
||||
import gq.unurled.raxen.components.entity.EntityNamespacedKey;
|
||||
import gq.unurled.raxen.components.player.Attributes.Attribute;
|
||||
import gq.unurled.raxen.components.player.Attributes.Attributes;
|
||||
import gq.unurled.raxen.components.player.Inventories;
|
||||
import gq.unurled.raxen.components.player.Storage;
|
||||
|
@ -16,7 +17,7 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.log;
|
||||
import static gq.unurled.raxen.utils.Utils.debug;
|
||||
|
||||
public class ProfileManager {
|
||||
|
||||
|
@ -24,14 +25,17 @@ public class ProfileManager {
|
|||
private EntityNamespacedKey namespacedKey;
|
||||
private Map<UUID, Storage> storages = new HashMap<>();
|
||||
private Map<UUID, Inventories> inventory = new HashMap<>();
|
||||
private Attributes attributes;
|
||||
|
||||
public ProfileManager(Raxen main) {
|
||||
this.main = main;
|
||||
this.namespacedKey = new EntityNamespacedKey(main);
|
||||
this.attributes = new Attributes(main);
|
||||
}
|
||||
|
||||
public void createNewProfile(Player player) {
|
||||
Attributes.setAttributes(player, 100,0,50,0,100,0,100,0);
|
||||
public Attribute createNewProfile(Player player) {
|
||||
attributes.setAttributes(player, 100,0,50,0,100,0,100,0);
|
||||
return new Attribute(100,0,50,0,100,0,100,0);
|
||||
}
|
||||
|
||||
public Storage createNewStorage(Player player) {
|
||||
|
@ -52,7 +56,7 @@ public class ProfileManager {
|
|||
else {
|
||||
storages.replace(uuid, storage);
|
||||
}
|
||||
log("Storage Updated!");
|
||||
debug(main, "Storage Updated!");
|
||||
}
|
||||
|
||||
public Inventories createNewInventory(Player player) {
|
||||
|
@ -73,7 +77,7 @@ public class ProfileManager {
|
|||
else {
|
||||
inventory.replace(uuid, inventories);
|
||||
}
|
||||
log("Inventory Updated!");
|
||||
debug(main, "Inventory Updated!");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,8 +7,8 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
import static gq.unurled.raxen.utils.Utils.debug;
|
||||
import static gq.unurled.raxen.utils.Utils.error;
|
||||
import static gq.unurled.raxen.utils.Utils.log;
|
||||
|
||||
public class ResourcePackManager {
|
||||
|
||||
|
@ -33,13 +33,13 @@ public class ResourcePackManager {
|
|||
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.");
|
||||
debug(main, "Resource pack not enabled.");
|
||||
useRP = false;
|
||||
} else {
|
||||
log("Ressource Pack enabled.");
|
||||
debug(main, "Ressource Pack enabled.");
|
||||
}
|
||||
} else {
|
||||
log("Resource pack not enabled.");
|
||||
debug(main, "Resource pack not enabled.");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public class StorageManager {
|
|||
|
||||
public static void connect() {
|
||||
String s = (String) config.get("storage");
|
||||
log(s);
|
||||
debug(main, s);
|
||||
if(s.equalsIgnoreCase("MONGODB")) {
|
||||
mongo.connect();
|
||||
warn("'" + s + "'");
|
||||
|
|
|
@ -4,6 +4,7 @@ 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 gq.unurled.raxen.components.items.NBT;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
@ -185,13 +186,13 @@ public class Items {
|
|||
public static NBTItem setAttributes(String str, Integer nb, NBTItem nbti) {
|
||||
switch (str) {
|
||||
case "SPEED":
|
||||
nbti.setInteger("SPEED", nb);
|
||||
nbti.setInteger(NBT.SPEED, nb);
|
||||
case "STRENGTH":
|
||||
nbti.setInteger("STRENGTH", nb);
|
||||
nbti.setInteger(NBT.STRENGTH, nb);
|
||||
case "HEALTH":
|
||||
nbti.setInteger("HEALTH", nb);
|
||||
nbti.setInteger(NBT.HEALTH, nb);
|
||||
case "DEFENSE":
|
||||
nbti.setInteger("DEFENSE", nb);
|
||||
nbti.setInteger(NBT.DEFENSE, nb);
|
||||
default:
|
||||
error("Cant set Attributes with an unknown attribute.");
|
||||
}
|
||||
|
@ -200,29 +201,29 @@ public class Items {
|
|||
|
||||
public static Integer getHealth(ItemStack it) {
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
if (nbti.hasKey("HEALTH")){
|
||||
return nbti.getInteger("HEALTH");
|
||||
if (nbti.hasKey(NBT.HEALTH)){
|
||||
return nbti.getInteger(NBT.HEALTH);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public static Integer getSpeed(ItemStack it) {
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
if (nbti.hasKey("SPEED")){
|
||||
return nbti.getInteger("SPEED");
|
||||
if (nbti.hasKey(NBT.SPEED)){
|
||||
return nbti.getInteger(NBT.SPEED);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public static Integer getDefense(ItemStack it) {
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
if (nbti.hasKey("DEFENSE")){
|
||||
return nbti.getInteger("DEFENSE");
|
||||
if (nbti.hasKey(NBT.DEFENSE)){
|
||||
return nbti.getInteger(NBT.DEFENSE);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public static Integer getStrength(ItemStack it) {
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
if (nbti.hasKey("STRENGTH")){
|
||||
return nbti.getInteger("STRENGTH");
|
||||
if (nbti.hasKey(NBT.STRENGTH)){
|
||||
return nbti.getInteger(NBT.STRENGTH);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -234,32 +235,32 @@ public class Items {
|
|||
lore.add(cp);
|
||||
}
|
||||
NBTItem nbti = new NBTItem(it);
|
||||
if(nbti.hasKey("SPEED")) {
|
||||
if(nbti.hasKey(NBT.SPEED)) {
|
||||
if(lore.size() > 2) {
|
||||
lore.add(2, Component.text(color(attributes("SPEED")) + nbti.getInteger("SPEED")));
|
||||
lore.add(2, Component.text(color(attributes("SPEED")) + nbti.getInteger(NBT.SPEED)));
|
||||
} else {
|
||||
lore.add(Component.text(color(attributes("SPEED")) + nbti.getInteger("SPEED")));
|
||||
lore.add(Component.text(color(attributes("SPEED")) + nbti.getInteger(NBT.SPEED)));
|
||||
}
|
||||
}
|
||||
if(nbti.hasKey("HEALTH")) {
|
||||
if(nbti.hasKey(NBT.HEALTH)) {
|
||||
if(lore.size() > 1) {
|
||||
lore.add(1, Component.text(color(attributes("HEALTH")) + nbti.getInteger("HEALTH")));
|
||||
lore.add(1, Component.text(color(attributes("HEALTH")) + nbti.getInteger(NBT.HEALTH)));
|
||||
} else {
|
||||
lore.add(Component.text(color(attributes("HEALTH")) + nbti.getInteger("HEALTH")));
|
||||
lore.add(Component.text(color(attributes("HEALTH")) + nbti.getInteger(NBT.HEALTH)));
|
||||
}
|
||||
}
|
||||
if(nbti.hasKey("DEFENSE")) {
|
||||
if(nbti.hasKey(NBT.DEFENSE)) {
|
||||
if(lore.size() > 3) {
|
||||
lore.add(3, Component.text(color(attributes("DEFENSE")) + nbti.getInteger("DEFENSE")));
|
||||
lore.add(3, Component.text(color(attributes("DEFENSE")) + nbti.getInteger(NBT.DEFENSE)));
|
||||
} else {
|
||||
lore.add(Component.text(color(attributes("DEFENSE")) + nbti.getInteger("DEFENSE")));
|
||||
lore.add(Component.text(color(attributes("DEFENSE")) + nbti.getInteger(NBT.DEFENSE)));
|
||||
}
|
||||
}
|
||||
if(nbti.hasKey("STRENGTH")) {
|
||||
if(nbti.hasKey(NBT.STRENGTH)) {
|
||||
if(lore.size() > 3) {
|
||||
lore.add(3, Component.text(color(attributes("STRENGTH")) + nbti.getInteger("STRENGTH")));
|
||||
lore.add(3, Component.text(color(attributes("STRENGTH")) + nbti.getInteger(NBT.STRENGTH)));
|
||||
} else {
|
||||
lore.add(Component.text(color(attributes("STRENGTH")) + nbti.getInteger("STRENGTH")));
|
||||
lore.add(Component.text(color(attributes("STRENGTH")) + nbti.getInteger(NBT.STRENGTH)));
|
||||
}
|
||||
}
|
||||
itm.lore(lore);
|
||||
|
|
|
@ -4,6 +4,7 @@ import gq.unurled.raxen.Raxen;
|
|||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
@ -22,6 +23,15 @@ public class Utils {
|
|||
return ChatColor.stripColor(color(string));
|
||||
}
|
||||
|
||||
public static void debug(Raxen main, String... strings) {
|
||||
FileConfiguration config = main.getConfig();
|
||||
if(config.getBoolean("debug")) {
|
||||
for(String string : strings) {
|
||||
logger.info(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void log(String... strings) {
|
||||
for(String string : strings) {
|
||||
logger.info(string);
|
||||
|
|
|
@ -11,3 +11,4 @@ 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
|
||||
debug: true
|
Loading…
Reference in a new issue