Skip to content

Commit

Permalink
Fix suit effect. (#5)
Browse files Browse the repository at this point in the history
* fix: 配置项中套装列表不生效

* dump: v1.1.2
  • Loading branch information
Mcayear authored Aug 14, 2024
1 parent 493eaee commit c780d38
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 40 deletions.
26 changes: 26 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
changelog:
exclude:
labels:
- ignore-for-release
categories:
- title: '🔥 Breaking Changes'
labels:
- 'refactor'
- 'breaking'
- title: 🏕 Features
labels:
- 'feat'
- 'enhancement'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bug'
- title: '👋 Deprecated'
labels:
- 'deprecation'
- title: 📦 Dependencies
labels:
- dependencies
- title: Other Changes
labels:
- "*"
2 changes: 1 addition & 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.1-MOT</version>
<version>1.1.2-MOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/RcRPG/RPG/Armour.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,11 @@ public static Armour loadArmour(String name,Config config){
armour.setDismantle(config.getString("分解", ""));

if (config.exists("套装")) {
String suitStr = config.getString("套装", "");
List<String> suitList;
if (suitStr.isEmpty()) {
if (config.isList("套装")) {
suitList = config.getStringList("套装");
} else {
suitList = new ArrayList<>(Arrays.asList(suitStr.split(",")));
suitList = new ArrayList<>(Arrays.asList(config.getString("套装", "").split(",")));
}
armour.setSuit(suitList);
}
Expand Down
48 changes: 24 additions & 24 deletions src/main/java/RcRPG/RPG/Level.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,34 +16,34 @@ public Level(){

public static boolean addExp(Player player,int exp){
String name = player.getName();
if(Handle.getPlayerConfig(name) != null){
Config config = Handle.getPlayerConfig(name);
int newExp = config.getInt("经验") + exp;
int level = config.getInt("等级");
int oldLevel = level;
while(newExp >= level * MainConfig.getExpIncrement()){
newExp -= level * MainConfig.getExpIncrement();
level++;
}
config.set("经验",newExp);
String text = MainConfig.getExpGainMessage();
if(!text.isEmpty()){
if(text.contains("@player")) text = text.replace("@player",name);
if(text.contains("@exp")) text = text.replace("@exp",String.valueOf(exp));
player.sendMessage(text);
}
config.save();
addLevel(player,level - oldLevel);
return true;
if(Handle.getPlayerConfig(name) == null) {
return false;
}
Config config = Handle.getPlayerConfig(name);
int newExp = config.getInt("经验", 0) + exp;
int level = config.getInt("等级", 0);
int oldLevel = level;
while(newExp >= level * MainConfig.getExpIncrement()){
newExp -= level * MainConfig.getExpIncrement();
level++;
}
return false;
config.set("经验",newExp);
String text = MainConfig.getExpGainMessage();
if(!text.isEmpty()){
if(text.contains("@player")) text = text.replace("@player",name);
if(text.contains("@exp")) text = text.replace("@exp",String.valueOf(exp));
player.sendMessage(text);
}
config.save();
addLevel(player,level - oldLevel);
return true;
}

public static void addLevel(Player player, int level){
if(level == 0) return;
String name = player.getName();
Config config = Handle.getPlayerConfig(name);
int newLevel = config.getInt("等级") + level;
int newLevel = config.getInt("等级", 0) + level;
if(!MainConfig.getExpGainMessage().isEmpty()){
String text = MainConfig.getExpGainMessage();
if(text.contains("@player")) text = text.replace("@player",name);
Expand All @@ -59,19 +59,19 @@ public static void addLevel(Player player, int level){
public static int getLevel(Player player){
Config config = Handle.getPlayerConfig(player.getName());
if (config == null) return 0;
return config.getInt("等级");
return config.getInt("等级", 0);
}

public static int getExp(Player player){
Config config = Handle.getPlayerConfig(player.getName());
if (config == null) return 0;
return config.getInt("经验");
return config.getInt("经验", 0);
}

public static int getMaxExp(Player player){
Config config = Handle.getPlayerConfig(player.getName());
if (config == null) return 0;
int level = config.getInt("等级");
int level = config.getInt("等级", 0);
return level * MainConfig.getExpIncrement();
}

Expand Down
5 changes: 2 additions & 3 deletions src/main/java/RcRPG/RPG/Ornament.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,11 @@ public static Ornament loadOrnament(String name, Config config) {
ornament.setLoreList(new ArrayList<>(config.getStringList("显示")));

if (config.exists("套装")) {
String suitStr = config.getString("套装", "");
List<String> suitList;
if (suitStr.isEmpty()) {
if (config.isList("套装")) {
suitList = config.getStringList("套装");
} else {
suitList = new ArrayList<>(Arrays.asList(suitStr.split(",")));
suitList = new ArrayList<>(Arrays.asList(config.getString("套装", "").split(",")));
}
ornament.setSuit(suitList);
}
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/RcRPG/RPG/Weapon.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,11 @@ public static Weapon loadWeapon(String name, Config config) {
weapon.setDismantle(config.getString("分解", ""));

if (config.exists("套装")) {
String suitStr = config.getString("套装", "");
List<String> suitList;
if (suitStr.isEmpty()) {
if (config.isList("套装")) {
suitList = config.getStringList("套装");
} else {
suitList = new ArrayList<>(Arrays.asList(suitStr.split(",")));
suitList = new ArrayList<>(Arrays.asList(config.getString("套装", "").split(",")));
}
weapon.setSuit(suitList);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/RcRPG/RcRPGMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void onEnable() {
this.createConfigDir();
init();

if (MainConfig.isPrefixSystemDisabled()) {
if (MainConfig.isExpSystemDisabled()) {
Level.enable = false;
}

Expand Down
11 changes: 7 additions & 4 deletions src/main/java/RcRPG/command/Commands.java
Original file line number Diff line number Diff line change
Expand Up @@ -370,10 +370,13 @@ 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 (Level.addExp(player, expValue)) {
if (sender.isPlayer()) sender.sendMessage("给予成功");
} else {
if (sender.isPlayer()) sender.sendMessage("给予失败");
if (sender.isPlayer()) {
if (Level.addExp(player, expValue)) {
sender.sendMessage("给予成功");
} else {
sender.sendMessage("给予失败");
}
return true;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: RcRPG
main: RcRPG.RcRPGMain
version: 1.1.1
version: 1.1.2
author: 若尘
authors: ["若尘", "Mcayear"]
api: 1.0.8
Expand Down

0 comments on commit c780d38

Please sign in to comment.