Skip to content

Commit

Permalink
Fix command (#8)
Browse files Browse the repository at this point in the history
* fix: 护甲宝石镶嵌、控制台给予经验

* change: 暂时撤销 DisplayDamage 粒子的生成

* fix: 疾跑加速

* fix: 锻造容器中正确显示提交的素材

* fix: 普通玩家打开饰品背包的权限

* some change.

* dump: 1.1.5
  • Loading branch information
Mcayear authored Sep 1, 2024
1 parent 53df94d commit 42d612a
Show file tree
Hide file tree
Showing 18 changed files with 270 additions and 96 deletions.
7 changes: 4 additions & 3 deletions 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.4-MOT</version>
<version>1.1.5-MOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -30,11 +30,12 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<encoding>UTF-8</encoding>
<useIncrementalCompilation>true</useIncrementalCompilation>
</configuration>
</plugin>

Expand Down Expand Up @@ -83,7 +84,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.24</version>
<version>1.18.26</version>
<scope>compile</scope>
</dependency>

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/RcRPG/AttrManager/AttrComp.java

This file was deleted.

1 change: 0 additions & 1 deletion src/main/java/RcRPG/AttrManager/AttrInterface.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package RcRPG.AttrManager;

public interface AttrInterface {
AttrComp getComp();
boolean checkFloatArray(float[] array);
/**
* 获取指定属性值(随机后)
Expand Down
83 changes: 83 additions & 0 deletions src/main/java/RcRPG/AttrManager/FootageAttr.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package RcRPG.AttrManager;

import RcRPG.RcRPGMain;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class FootageAttr extends Manager {

/**
* 属性结构
* {
* "Main": {
* "攻击力": [1,3]
* }
* }
*/
public Map<String, Map<String, float[]>> myAttr = new HashMap<>();

public void setItemAttrConfig(String id, Map<String, Object> newAttr) {
Map<String, float[]> attrMap = new HashMap<>();
for (Map.Entry<String, Object> entry : newAttr.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof List<?> values) {
float[] floatValue = new float[values.size()];
for (int i = 0; i < values.size(); i++) {
if (values.get(i) instanceof Double) {
floatValue[i] = ((Double) values.get(i)).floatValue();
} else if (values.get(i) instanceof Integer) {
floatValue[i] = ((Integer) values.get(i)).floatValue();
}
}
if (floatValue.length < 2) {
floatValue = new float[]{floatValue[0], floatValue[0]};
}
attrMap.put(key, floatValue);
} else if (value instanceof float[] floatValue) {
if (floatValue.length < 2) {
floatValue = new float[]{floatValue[0], floatValue[0]};
}
attrMap.put(key, floatValue);
} else {
RcRPGMain.getInstance().getLogger().warning(key + "不知道是啥类型");
}
}

Map<String, float[]> mainAttrMap = myAttr.get("Main");
Map<String, float[]> oldAttrMap = deepCopyMap(myAttr.get(id));
myAttr.put(id, attrMap);
// 处理newAttr属性
for (Map.Entry<String, float[]> entry : attrMap.entrySet()) {
String key = entry.getKey();
float[] mainValues = new float[]{0.0f, 0.0f};
if (mainAttrMap.containsKey(key)) {
mainValues = mainAttrMap.get(key);
}
if (mainValues.length < 2) {
mainValues = new float[]{mainValues[0], mainValues[0]};
}

float[] values = attrMap.get(key);
mainValues[0] = mainValues[0] - (oldAttrMap.containsKey(key) ? oldAttrMap.get(key)[0] : 0) + values[0];
mainValues[1] = mainValues[1] - (oldAttrMap.containsKey(key) ? oldAttrMap.get(key)[1] : 0) + values[1];

mainAttrMap.put(key, mainValues);
}

// 副作用回收
// 处理 oldAttr 有但是 newAttr 没有的属性
for (Map.Entry<String, float[]> entry : oldAttrMap.entrySet()) {
String key = entry.getKey();
if (!attrMap.containsKey(key)) {
float[] mainValues = mainAttrMap.get(key);
float[] values = oldAttrMap.get(key);
mainValues[0] = mainValues[0] - values[0];
mainValues[1] = mainValues[1] - values[1];
mainAttrMap.put(key, mainValues);
}
}
}
}
8 changes: 4 additions & 4 deletions src/main/java/RcRPG/AttrManager/ItemAttr.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public float getItemAttr(String attrName) {
/**
* 获取指定属性的原始值
* @param attrName 属性名
* @param index 索引,0为min,1为max。内部可能传入-1
* @param index 索引,0为min,1为max。-1为min-max的随机值
* @return
*/
public float getItemAttr(String attrName, int index) {
Expand All @@ -85,8 +85,8 @@ public float getItemAttr(String attrName, int index) {
}

/**
* 返回 [最小值, 最大值] 的随机值
* @param array
* 返回 min-max 的随机值
* @param array [最小值, 最大值]
* @return
*/
public static float getRandomNum(float[] array) {
Expand All @@ -107,7 +107,7 @@ public static float getRandomNum(float[] array) {
}

public String replaceAttrTemplate(String str) {
Pattern pattern = Pattern.compile("\\{\\{(.*?)\\}\\}");
Pattern pattern = Pattern.compile("\\{\\{(.*?)}}");
Matcher matcher = pattern.matcher(str);
StringBuilder sb = new StringBuilder();

Expand Down
4 changes: 0 additions & 4 deletions src/main/java/RcRPG/AttrManager/Manager.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ public void updateComp() {
movementSpeedMultiplier = getRandomNum(getMovementSpeedMultiplier());
// ...继续更新其他变量的值
}
@Override
public AttrComp getComp() {
return null;
}

/**
* 返回 [最小值, 最大值] 的随机值
Expand Down
28 changes: 7 additions & 21 deletions src/main/java/RcRPG/AttrManager/PlayerAttr.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void update() {
ArrayList<String> beforeLabel = new ArrayList<>(labelList);
labelList.clear();

Map<String, Integer> suitMap = new HashMap<>();// _声明套装Map
Map<String, Integer> suitMap = new HashMap<>();// 声明套装Map

ArrayList<Item> itemList = new ArrayList<>();
// 主手
Expand Down Expand Up @@ -246,33 +246,19 @@ public void checkItemStoneAttr(String mainItemName, LinkedList<Stone> list, Arra
/**
* 属性结构
* {
* "Main": {
* "攻击力": [1,3]
* }
* "Main": {
* "攻击力": [1,3]
* }
* }
*/
public Map<String, Map<String, float[]>> myAttr = new HashMap<>();

public void setItemAttrConfig(String id, Object newAttr) {
public void setItemAttrConfig(String id, Map<String, float[]> newAttr) {
Map<String, float[]> attrMap = new HashMap<>();
Map<String, Object> attr = (Map<String, Object>) newAttr;
for (Map.Entry<String, Object> entry : attr.entrySet()) {
for (Map.Entry<String, float[]> entry : newAttr.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
if (value instanceof List<?> values) {
float[] floatValue = new float[values.size()];
for (int i = 0; i < values.size(); i++) {
if (values.get(i) instanceof Double) {
floatValue[i] = ((Double) values.get(i)).floatValue();
} else if (values.get(i) instanceof Integer) {
floatValue[i] = ((Integer) values.get(i)).floatValue();
}
}
if (floatValue.length < 2) {
floatValue = new float[]{floatValue[0], floatValue[0]};
}
attrMap.put(key, floatValue);
} else if (value instanceof float[] floatValue) {
if (value instanceof float[] floatValue) {
if (floatValue.length < 2) {
floatValue = new float[]{floatValue[0], floatValue[0]};
}
Expand Down
27 changes: 17 additions & 10 deletions src/main/java/RcRPG/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -354,11 +354,15 @@ public void damageEvent(EntityDamageByEntityEvent event){
if (getProbabilisticResults(dodge - DAttr.hitChance)) {
if (woundedIsPlayer) {
wounded.getLevel().addSound(wounded, Sound.valueOf("GAME_PLAYER_ATTACK_NODAMAGE"));
((Player) wounded).sendMessage(RcRPGMain.getI18n().tr(((Player) wounded).getLanguageCode(), "rcrpg.events.dodge_message_you_evaded", damagerName));
if (MainConfig.getEnableDamageMessage().isDodge()) {
((Player) wounded).sendMessage(RcRPGMain.getI18n().tr(((Player) wounded).getLanguageCode(), "rcrpg.events.dodge_message_you_evaded", damagerName));
}
}
if (damagerIsPlayer) {
damager.getLevel().addSound(damager, Sound.valueOf("GAME_PLAYER_ATTACK_NODAMAGE"));
((Player) damager).sendMessage(RcRPGMain.getI18n().tr(((Player) damager).getLanguageCode(), "rcrpg.events.dodge_message_enemy_evaded", woundedName));
if (MainConfig.getEnableDamageMessage().isDodge()) {
((Player) damager).sendMessage(RcRPGMain.getI18n().tr(((Player) damager).getLanguageCode(), "rcrpg.events.dodge_message_enemy_evaded", woundedName));
}
}
event.setCancelled(true);
return;
Expand Down Expand Up @@ -508,7 +512,7 @@ public void damageEvent(EntityDamageByEntityEvent event){
} else {
damager.heal(new EntityRegainHealthEvent(damager, (float) lifeSteal, RegainHealthEnum.LifeSteal.getCode()));
}
if (damagerIsPlayer) {
if (damagerIsPlayer && MainConfig.getEnableDamageMessage().isLifeSteal()) {
((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 @@ -532,7 +536,10 @@ public void damageEvent(EntityDamageByEntityEvent event){

if (crtDamage > 0) {
//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));

if (MainConfig.getEnableDamageMessage().isCriticalDamage()) {
((Player) damager).sendMessage(RcRPGMain.getI18n().tr(((Player) damager).getLanguageCode(), "rcrpg.events.critical_damage_message", woundedName, crtDamage));
}
}

// 击杀提示
Expand Down Expand Up @@ -585,12 +592,12 @@ public void toggleSprintEvent(PlayerToggleSprintEvent event) {
// 处理移速加成
finalSpeed *= (1 + speedAddition);

// // 处理冲刺状态的影响
// if (event.isSprinting()) {
// finalSpeed *= 1.3f;
// } else {
// finalSpeed /= 1.3f;
// }
// 处理冲刺状态的影响
if (event.isSprinting()) {
finalSpeed *= 1.2f;
} else {
finalSpeed /= 1.2f;
}

player.setMovementSpeed(finalSpeed);
}
Expand Down
Loading

0 comments on commit 42d612a

Please sign in to comment.