diff --git a/pom.xml b/pom.xml index 4e6ee2b..c4b4598 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ RcRPG.RcRPGMain RcRPG - 1.1.3-MOT + 1.1.4-MOT UTF-8 diff --git a/src/main/java/RcRPG/Events.java b/src/main/java/RcRPG/Events.java index b32b0fb..d6f6e73 100644 --- a/src/main/java/RcRPG/Events.java +++ b/src/main/java/RcRPG/Events.java @@ -512,8 +512,8 @@ public void damageEvent(EntityDamageByEntityEvent event){ } if (damagerIsPlayer) { ((Player) damager).sendMessage(RcRPGMain.getI18n().tr(((Player) damager).getLanguageCode(), "rcrpg.events.life_steal_message", lifeSteal)); + if (hasDisplayDamage) DamageApi.displayAsParticle(new DamageTextDTO(finalDamage, wounded, "damage:ph")); } - if (hasDisplayDamage) DamageApi.displayAsParticle(new DamageTextDTO(finalDamage, wounded, "damage:ph")); } } @@ -533,7 +533,7 @@ public void damageEvent(EntityDamageByEntityEvent event){ Damage.onDamage((Player) damager, wounded); if (crtDamage > 0) { - if (hasDisplayDamage) DamageApi.displayAsParticle(new DamageTextDTO(finalDamage, wounded, "damage:ed")); + if (hasDisplayDamage) DamageApi.displayAsParticle(new DamageTextDTO((int) crtDamage, wounded, "damage:ed")); ((Player) damager).sendMessage(RcRPGMain.getI18n().tr(((Player) damager).getLanguageCode(), "rcrpg.events.critical_damage_message", woundedName, crtDamage)); } @@ -568,7 +568,33 @@ public void toggleSprintEvent(PlayerToggleSprintEvent event) { PlayerAttr attr = PlayerAttr.getPlayerAttr(player); if (attr == null) return; float speedAddition = attr.movementSpeedMultiplier;// 处理移速加成 - //TODO: if (speedAddition > 0) player.sendMovementSpeed(speedAddition); + if (speedAddition <= -1) { + return; + } + + float finalSpeed = Player.DEFAULT_SPEED; + + Effect speedEffect = player.getEffect(Effect.SPEED); + if (speedEffect != null) { + finalSpeed *= (1 + 0.2f * (speedEffect.getAmplifier() + 1)); + } + + Effect slownessEffect = player.getEffect(Effect.SLOWNESS); + if (slownessEffect != null) { + finalSpeed *= (1 - 0.15f * (slownessEffect.getAmplifier() + 1)); + } + + // 处理移速加成 + finalSpeed *= (1 + speedAddition); + +// // 处理冲刺状态的影响 +// if (event.isSprinting()) { +// finalSpeed *= 1.3f; +// } else { +// finalSpeed /= 1.3f; +// } + + player.setMovementSpeed(finalSpeed); } @EventHandler diff --git a/src/main/java/RcRPG/RPG/Armour.java b/src/main/java/RcRPG/RPG/Armour.java index b797b09..47c36c9 100644 --- a/src/main/java/RcRPG/RPG/Armour.java +++ b/src/main/java/RcRPG/RPG/Armour.java @@ -28,7 +28,7 @@ public class Armour extends ItemAttr { /** * -- SETTER -- - * 仅作为属性分类的标识 + * 仅作为属性分类的标识 * * @param label */ @@ -37,7 +37,7 @@ public class Armour extends ItemAttr { /** * -- GETTER -- - * 物品名,替代源label用法 + * 物品名,替代源label用法 * * @return */ @@ -49,13 +49,13 @@ public class Armour extends ItemAttr { private int health; private int damage; - + private int reDamage; private ArrayList effects = new ArrayList<>(); @Getter - private Object attr; + private Map attr; private int stone; @@ -81,15 +81,15 @@ public class Armour extends ItemAttr { private ArrayList stoneList = new ArrayList<>(); private ArrayList loreList = new ArrayList<>(); - - public Armour(String name,Config config){ + + public Armour(String name, Config config) { this.name = name; this.config = config; } - public static Armour loadArmour(String name,Config config){ - try{ - Armour armour = new Armour(name,config); + public static Armour loadArmour(String name, Config config) { + try { + Armour armour = new Armour(name, config); armour.setLabel(config.getString("标签")); armour.setShowName(config.getString("显示名称")); @@ -126,9 +126,9 @@ public static Armour loadArmour(String name,Config config){ armour.setStoneList(stoneList); return armour; - }catch(Exception e){ + } catch (Exception e) { e.printStackTrace(); - RcRPGMain.getInstance().getLogger().error("加载盔甲"+name+"配置文件失败"); + RcRPGMain.getInstance().getLogger().error("加载盔甲" + name + "配置文件失败"); return null; } } @@ -147,7 +147,7 @@ private static ColorRGB loadColorFromConfig(Config config) { private static ArrayList loadEffectsFromConfig(Config config) { ArrayList effects = new ArrayList<>(); if (!config.exists("药水效果")) { - return effects; + return effects; } for (String effect : config.getStringList("药水效果")) { String[] parts = effect.split(":"); @@ -161,44 +161,45 @@ private static ArrayList loadEffectsFromConfig(Config config) { } - public static Config getArmourConfig(String name){ - File file = new File(RcRPGMain.getInstance().getDataFolder()+"/Armour/"+name+".yml"); + public static Config getArmourConfig(String name) { + File file = new File(RcRPGMain.getInstance().getDataFolder() + "/Armour/" + name + ".yml"); Config config; - if(file.exists()){ - config = new Config(file,Config.YAML); - }else{ + if (file.exists()) { + config = new Config(file, Config.YAML); + } else { return null; } return config; } - public static Config addArmourConfig(String name,String id){ - if(getArmourConfig(name) == null){ - RcRPGMain.getInstance().saveResource("Armour/Armour.yml","/Armour/"+name+".yml",false); - Config config = new Config(RcRPGMain.getInstance().getArmourFile()+"/"+name+".yml"); - config.set("物品ID",id); + public static Config addArmourConfig(String name, String id) { + if (getArmourConfig(name) == null) { + RcRPGMain.getInstance().saveResource("Armour/Armour.yml", "/Armour/" + name + ".yml", false); + Config config = new Config(RcRPGMain.getInstance().getArmourFile() + "/" + name + ".yml"); + config.set("物品ID", id); config.save(); return config; } return null; } - public static boolean delArmourConfig(String name){ - if(getArmourConfig(name) != null){ - File file = new File(RcRPGMain.getInstance().getArmourFile(), name+".yml"); + public static boolean delArmourConfig(String name) { + if (getArmourConfig(name) != null) { + File file = new File(RcRPGMain.getInstance().getArmourFile(), name + ".yml"); file.delete(); return true; } return false; } + public static Item getItem(String name, int count) { Armour armour = RcRPGMain.loadArmour.get(name); Item item = armour.getItem(); item.setCount(count); CompoundTag tag = item.hasCompoundTag() ? item.getNamedTag() : new CompoundTag(); - tag.putString("type","armour"); - tag.putString("name",name); - tag.putByte("Unbreakable",1); + tag.putString("type", "armour"); + tag.putString("name", name); + tag.putByte("Unbreakable", 1); if (!armour.getColor().isEmpty()) { tag.putInt("customColor", armour.getColor().getRgb()); @@ -209,8 +210,9 @@ public static Item getItem(String name, int count) { Armour.setArmourLore(item); return item; } - public static boolean giveArmour(Player player, String name, int count){ - if(!RcRPGMain.loadArmour.containsKey(name)) { + + public static boolean giveArmour(Player player, String name, int count) { + if (!RcRPGMain.loadArmour.containsKey(name)) { return false; } Armour armour = RcRPGMain.loadArmour.get(name); @@ -219,72 +221,72 @@ public static boolean giveArmour(Player player, String name, int count){ return false; } player.getInventory().addItem(item); - if(!armour.getMyMessage().isEmpty()){ + if (!armour.getMyMessage().isEmpty()) { String text = armour.getMyMessage(); - if(text.contains("@player")) text = text.replace("@player", player.getName()); - if(text.contains("@item")) text = text.replace("@item", armour.getLabel()); + if (text.contains("@player")) text = text.replace("@player", player.getName()); + if (text.contains("@item")) text = text.replace("@item", armour.getLabel()); player.sendMessage(text); } - if(!armour.getServerMessage().isEmpty()){ + if (!armour.getServerMessage().isEmpty()) { String text = armour.getServerMessage(); - if(text.contains("@player")) text = text.replace("@player", player.getName()); - if(text.contains("@item")) text = text.replace("@item", armour.getLabel()); + if (text.contains("@player")) text = text.replace("@player", player.getName()); + if (text.contains("@item")) text = text.replace("@item", armour.getLabel()); RcRPGMain.getInstance().getServer().broadcastMessage(text); } return true; } - public static boolean isArmour(Item item){ - if(item.getNamedTag() == null) { + public static boolean isArmour(Item item) { + if (item.getNamedTag() == null) { return false; } - if(!item.getNamedTag().contains("type")){ + if (!item.getNamedTag().contains("type")) { return false; } return item.getNamedTag().getString("type").equals("armour"); } - public static LinkedList getStones(Item item){ + public static LinkedList getStones(Item item) { LinkedList list = new LinkedList<>(); if (!isArmour(item) || item.getNamedTag() == null) return list; - ListTag tags = item.getNamedTag().getList("stone",StringTag.class); - for(StringTag tag : tags.getAll()){ + ListTag tags = item.getNamedTag().getList("stone", StringTag.class); + for (StringTag tag : tags.getAll()) { list.add(Handle.getStoneViaName(tag.parseValue())); } Armour armour = RcRPGMain.loadArmour.get(item.getNamedTag().getString("name")); - while(list.size() < armour.getStone()){ + while (list.size() < armour.getStone()) { list.add(null); } return list; } - public static int getStoneSize(Item item){ + public static int getStoneSize(Item item) { LinkedList list = Armour.getStones(item); int i = 0; - for(Stone stone : list){ - if(stone != null) i++; + for (Stone stone : list) { + if (stone != null) i++; } return i; } @Deprecated - public static boolean canInlay(Item item){ - if(Armour.isArmour(item)){ + public static boolean canInlay(Item item) { + if (Armour.isArmour(item)) { Armour armour = RcRPGMain.loadArmour.get(item.getNamedTag().getString("name")); return Armour.getStoneSize(item) < armour.getStone(); - }else{ + } else { return false; } } - public static void setStone(Player player,Item item,LinkedList list){ + public static void setStone(Player player, Item item, LinkedList list) { ListTag stoneList = new ListTag<>("stone"); - for(Stone stone : list){ + for (Stone stone : list) { if (stone == null) { stoneList.add(new StringTag("", "")); continue; } - stoneList.add(new StringTag(stone.getLabel(),stone.getLabel())); + stoneList.add(new StringTag(stone.getName(), stone.getName())); } CompoundTag tag = item.getNamedTag(); tag.putList(stoneList); @@ -292,12 +294,12 @@ public static void setStone(Player player,Item item,LinkedList list){ player.getInventory().setItemInHand(Armour.setArmourLore(item)); } - public static int getStoneHealth(Item item){ - if(Armour.isArmour(item)){ + public static int getStoneHealth(Item item) { + if (Armour.isArmour(item)) { LinkedList list = Armour.getStones(item); int damage = 0; - for(Stone stone : list){ - if(stone == null) continue; + for (Stone stone : list) { + if (stone == null) continue; damage += stone.getItemAttr("血量值"); } return damage; @@ -305,12 +307,12 @@ public static int getStoneHealth(Item item){ return 0; } - public static int getStoneDamage(Item item){ - if(Armour.isArmour(item)){ + public static int getStoneDamage(Item item) { + if (Armour.isArmour(item)) { LinkedList list = Armour.getStones(item); int damage = 0; - for(Stone stone : list){ - if(stone == null) continue; + for (Stone stone : list) { + if (stone == null) continue; damage += stone.getItemAttr("PVE攻击力"); } return damage; @@ -318,12 +320,12 @@ public static int getStoneDamage(Item item){ return 0; } - public static int getStoneReDamage(Item item){ - if(Armour.isArmour(item)){ + public static int getStoneReDamage(Item item) { + if (Armour.isArmour(item)) { LinkedList list = Armour.getStones(item); int damage = 0; - for(Stone stone : list){ - if(stone == null) continue; + for (Stone stone : list) { + if (stone == null) continue; damage += stone.getItemAttr("防御力"); } return damage; @@ -331,18 +333,21 @@ public static int getStoneReDamage(Item item){ return 0; } - public static Item setArmourLore(Item item){ - if(Armour.isArmour(item)){ + public static Item setArmourLore(Item item) { + if (Armour.isArmour(item)) { Armour armour = RcRPGMain.loadArmour.get(item.getNamedTag().getString("name")); ArrayList lore = (ArrayList) armour.getLoreList().clone(); - for(int i = 0;i < lore.size();i++){ + for (int i = 0; i < lore.size(); i++) { String s = lore.get(i); - if(s.contains("@message")) s = s.replace("@message",armour.getMessage()); - if(s.contains("@stoneHealth")) s = s.replace("@stoneHealth",String.valueOf(Armour.getStoneHealth(item))); - if(s.contains("@stoneDamage")) s = s.replace("@stoneDamage",String.valueOf(Armour.getStoneDamage(item))); - if(s.contains("@stoneReDamage")) s = s.replace("@stoneReDamage",String.valueOf(Armour.getStoneReDamage(item))); + if (s.contains("@message")) s = s.replace("@message", armour.getMessage()); + if (s.contains("@stoneHealth")) + s = s.replace("@stoneHealth", String.valueOf(Armour.getStoneHealth(item))); + if (s.contains("@stoneDamage")) + s = s.replace("@stoneDamage", String.valueOf(Armour.getStoneDamage(item))); + if (s.contains("@stoneReDamage")) + s = s.replace("@stoneReDamage", String.valueOf(Armour.getStoneReDamage(item))); s = armour.replaceAttrTemplate(s);// 替换属性的值 - lore.set(i,s); + lore.set(i, s); } item.setLore(lore.toArray(new String[0])); } @@ -353,6 +358,7 @@ public void setAttr(Map attr) { this.attr = attr; setItemAttrConfig(attr); } + @Getter @Setter public static class ColorRGB { diff --git a/src/main/java/RcRPG/RPG/Ornament.java b/src/main/java/RcRPG/RPG/Ornament.java index 58353da..f4fac9c 100644 --- a/src/main/java/RcRPG/RPG/Ornament.java +++ b/src/main/java/RcRPG/RPG/Ornament.java @@ -46,7 +46,7 @@ public class Ornament extends ItemAttr { private int level; @Getter - private Object attr; + private Map attr; private String tipText; diff --git a/src/main/java/RcRPG/RPG/Stone.java b/src/main/java/RcRPG/RPG/Stone.java index b8aa616..546e245 100644 --- a/src/main/java/RcRPG/RPG/Stone.java +++ b/src/main/java/RcRPG/RPG/Stone.java @@ -34,7 +34,7 @@ public class Stone extends ItemAttr { private int reDamage; - private Object attr; + private Map attr; private String tipText; @@ -192,19 +192,18 @@ public static LinkedList getStonesViaType(Player player, String type){ for(int i = 0;i < player.getInventory().getSize();i++){ item = player.getInventory().getItem(i); if(Stone.isStone(item)){ - if(!list.contains(item.getNamedTag().getString("name")) && - RcRPGMain.loadStone.get(item.getNamedTag().getString("name")).getType().equals(type) - ){ - list.add(item.getNamedTag().getString("name")); + String stoneName = item.getNamedTag().getString("name"); + if (!RcRPGMain.loadStone.containsKey(stoneName)) { + continue; + } + if(!list.contains(stoneName) && RcRPGMain.loadStone.get(stoneName).getType().equals(type)){ + list.add(stoneName); } } } return list; } - public Object getAttr() { - return attr; - } public void setAttr(Map attr) { this.attr = attr; setItemAttrConfig(attr); diff --git a/src/main/java/RcRPG/RPG/Weapon.java b/src/main/java/RcRPG/RPG/Weapon.java index 4c9c826..3639a41 100644 --- a/src/main/java/RcRPG/RPG/Weapon.java +++ b/src/main/java/RcRPG/RPG/Weapon.java @@ -48,7 +48,7 @@ public class Weapon extends ItemAttr { private int lightRound;// 属性 - 雷击 - private Object attr; + private Map attr; private int stone; diff --git a/src/main/java/RcRPG/command/Commands.java b/src/main/java/RcRPG/command/Commands.java index 7b9ad50..711d00d 100644 --- a/src/main/java/RcRPG/command/Commands.java +++ b/src/main/java/RcRPG/command/Commands.java @@ -361,6 +361,7 @@ public boolean execute(CommandSender sender, String label, String[] args) { switch (args[1]) { case "help" -> { sender.sendMessage("/rpg exp add [Player] [Exp] 给予玩家经验"); + return true; } case "add" -> { if (args.length < 4) { @@ -370,14 +371,12 @@ public boolean execute(CommandSender sender, String label, String[] args) { Player player = Server.getInstance().getPlayer(args[2]); if (player == null) return false; int expValue = Integer.parseInt(args[3]); - if (sender.isPlayer()) { - if (Level.addExp(player, expValue)) { - sender.sendMessage("给予成功"); - } else { - sender.sendMessage("给予失败"); - } - return true; + if (Level.addExp(player, expValue)) { + if (sender.isPlayer()) sender.sendMessage("给予成功"); + } else { + if (sender.isPlayer()) sender.sendMessage("给予失败"); } + return true; } } sender.sendMessage(TextFormat.RED + "错误的命令,请使用:/rpg help"); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index aa181a4..7c62a06 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: RcRPG main: RcRPG.RcRPGMain -version: 1.1.3 +version: 1.1.4 author: 若尘 authors: ["若尘", "Mcayear"] api: 1.0.8