Skip to content

Commit

Permalink
feat: 适配 DisplayDamage
Browse files Browse the repository at this point in the history
  • Loading branch information
Mcayear committed Aug 14, 2024
1 parent b34eb61 commit 493eaee
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 14 deletions.
Binary file added lib/DisplayDamage_v1.0.3-clean.jar
Binary file not shown.
10 changes: 9 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>RcRPG.RcRPGMain</groupId>
<artifactId>RcRPG</artifactId>
<version>1.1.0-MOT</version>
<version>1.1.1-MOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -167,6 +167,14 @@
<systemPath>${pom.basedir}/lib/FakeInventories-1.1.5.jar</systemPath>
</dependency>

<dependency>
<groupId>org.sobadfish.displaydamage.PluginMain</groupId>
<artifactId>DisplayDamage</artifactId>
<version>1.0.3</version>
<scope>system</scope>
<systemPath>${pom.basedir}/lib/DisplayDamage_v1.0.3-clean.jar</systemPath>
</dependency>

<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
Expand Down
19 changes: 13 additions & 6 deletions src/main/java/RcRPG/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
import RcRPG.AttrManager.Manager;
import RcRPG.AttrManager.PlayerAttr;
import RcRPG.AttrManager.RcNPCAttr;
import RcRPG.config.MainConfig;
import RcRPG.panel.form.guildForm;
import RcRPG.RPG.*;
import RcRPG.Society.Money;
import RcRPG.Society.Prefix;
import RcRPG.config.MainConfig;
import RcRPG.floatingtext.TextEntity;
import RcRPG.guild.Guild;
import RcRPG.panel.form.guildForm;
import cn.nukkit.Player;
import cn.nukkit.Server;
import cn.nukkit.block.Block;
Expand All @@ -33,27 +33,28 @@
import com.smallaswater.littlemonster.entity.IEntity;
import com.smallaswater.npc.entitys.EntityRsNPC;
import healthapi.PlayerHealth;
import org.sobadfish.displaydamage.DamageApi;
import org.sobadfish.displaydamage.dto.DamageTextDTO;

import java.io.File;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;

import static RcRPG.Handle.getProbabilisticResults;

public class Events implements Listener {

public static LinkedHashMap<Player,String> playerShop = new LinkedHashMap<>();

public static final boolean hasEconomyAPI = Server.getInstance().getPluginManager().getPlugin("EconomyAPI") != null;
public static final boolean hasPlayerPoints = Server.getInstance().getPluginManager().getPlugin("playerPoints") != null;
public static final boolean hasHealthAPI = Server.getInstance().getPluginManager().getPlugin("HealthAPI") != null;
public static final boolean hasRsNPC = Server.getInstance().getPluginManager().getPlugin("RsNPC") != null;
public static final boolean hasLittleMonster = Server.getInstance().getPluginManager().getPlugin("LittleMonster") != null;
public static final boolean hasRcEntity = Server.getInstance().getPluginManager().getPlugin("RcEntity") != null;
public static final boolean hasRcNPC = Server.getInstance().getPluginManager().getPlugin("RcNPC") != null;
public static final boolean hasDisplayDamage = Server.getInstance().getPluginManager().getPlugin("DisplayDamage") != null;

public static final List<String> ProjectileWeapons = Arrays.asList("minecraft:bow", "minecraft:crossbow", "minecraft:trident");

public Events(){
Expand Down Expand Up @@ -512,6 +513,7 @@ 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"));
}
}

Expand All @@ -531,6 +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"));
((Player) damager).sendMessage(RcRPGMain.getI18n().tr(((Player) damager).getLanguageCode(), "rcrpg.events.critical_damage_message", woundedName, crtDamage));
}

Expand All @@ -551,7 +554,11 @@ public void damageEvent(EntityDamageByEntityEvent event){
}

// 伤害 浮空字
TextEntity.send(wounded, "§c-"+finalDamage);
if (hasDisplayDamage) {
DamageApi.displayAsParticle(new DamageTextDTO(finalDamage, wounded, "damage:epd"));
} else {
TextEntity.send(wounded, "§c-" + finalDamage);
}
}
}
@EventHandler
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/RcRPG/RcRPGMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ public void onLoad() {

public void onEnable() {
if (Server.getInstance().getPluginManager().getPlugin("FakeInventories") == null) {
this.getLogger().error("未检测到 FakeInventories 插件,插件无法启动");
throw new RuntimeException("前置插件 FakeInventories 下载地址:https://github.com/JkqzDev/FakeInventories-MOT/releases");
this.getLogger().error(i18n.tr(serverLangCode, "rcrpg.missing.plugin", "FakeInventories", "https://github.com/JkqzDev/FakeInventories-MOT/releases"));
throw new RuntimeException("Missing required plugin FakeInventories!");
}

Entity.registerEntity("TextEntity", TextEntity.class);
Expand Down Expand Up @@ -100,9 +100,9 @@ public void onEnable() {
this.getLogger().warning("未检测到 PlayerPoints 插件,将使用默认的点券核心");
}
if (Server.getInstance().getPluginManager().getPlugin("Tips") != null) {
Api.registerVariables("AyearTipsApi", TipsVariables.class);
Api.registerVariables("RcRPGTipsApi", TipsVariables.class);
}
this.getLogger().info("插件加载成功,作者:若尘");
this.getLogger().info("插件加载成功,作者:若尘、Mcayear");
}

public void init() {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/Ornament/Ornament.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
- 演示套装
个人通知: ''
全服通知: ''
# 生效槽: 1 # 仅放置在饰品背包对应槽位上时生效,-1为不限制,0为第一个槽,1为第二个槽...
生效槽: -1 # 仅放置在饰品背包对应槽位上时生效,-1为不限制,0为第一个槽,1为第二个槽...
2 changes: 2 additions & 0 deletions src/main/resources/language/en_US.lang
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
rcrpg.missing.plugin={%0} plugin not detected, the plugin cannot be started! Download link: {%1}

rcrpg.commands.message.noPermission=§cNo permissions!
rcrpg.commands.message.noTarget=§cNo matching target found.
rcrpg.commands.reloaded=§aConfiguration reload successful!
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/language/zh_CN.lang
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
rcrpg.missing.plugin=未检测到 {%0} 插件,插件无法启动!下载地址:{%1}

rcrpg.commands.message.noPermission=§c权限不足
rcrpg.commands.message.noTarget=§c没有匹配的目标
rcrpg.commands.reloaded=§a配置文件重载成功
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: RcRPG
main: RcRPG.RcRPGMain
version: 1.1.0
version: 1.1.1
author: 若尘
authors: ["若尘", "Mcayear"]
api: 1.0.8
load: POSTWORLD
website: https://github.com/RuoChen688/RcRPG
depend: []
softdepend: ["FakeInventories", "EconomyAPI", "RcNPC", "RsNPC", "PlayerPoint", "LittleMonster", "HealthAPI", "Tips"]
softdepend: ["FakeInventories", "EconomyAPI", "RcNPC", "RsNPC", "PlayerPoint", "LittleMonster", "HealthAPI", "Tips", "DisplayDamage"]
permissions:
rcrpg.command.check:
description: "查询玩家信息"
Expand Down

0 comments on commit 493eaee

Please sign in to comment.