Skip to content

Commit ba2ed2a

Browse files
authored
Merge pull request #583 from Chronoken/main
Fix name conditions
2 parents 4b0e2ba + d99e68c commit ba2ed2a

2 files changed

Lines changed: 7 additions & 11 deletions

File tree

core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/DisplayNameCondition.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@
55
import org.bukkit.entity.LivingEntity;
66
import com.nisovin.magicspells.util.Util;
77

8-
import net.kyori.adventure.text.Component;
9-
108
import com.nisovin.magicspells.castmodifiers.Condition;
119

1210
public class DisplayNameCondition extends Condition {
1311

14-
private Component displayName;
12+
private String displayName;
1513

1614
@Override
1715
public boolean initialize(String var) {
1816
if (var == null || var.isEmpty()) return false;
19-
displayName = Util.getMiniMessage(var);
17+
displayName = Util.getStringFromComponent(Util.getMiniMessage(var));
2018
return true;
2119
}
2220

@@ -28,7 +26,7 @@ public boolean check(LivingEntity livingEntity) {
2826
@Override
2927
public boolean check(LivingEntity livingEntity, LivingEntity target) {
3028
if (!(target instanceof Player player)) return false;
31-
return player.displayName().equals(displayName);
29+
return Util.getStringFromComponent(player.displayName()).equals(displayName);
3230
}
3331

3432
@Override

core/src/main/java/com/nisovin/magicspells/castmodifiers/conditions/NameCondition.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,18 @@
22

33
import org.bukkit.Location;
44
import org.bukkit.entity.LivingEntity;
5-
import com.nisovin.magicspells.util.Util;
6-
7-
import net.kyori.adventure.text.Component;
85

6+
import com.nisovin.magicspells.util.Util;
97
import com.nisovin.magicspells.castmodifiers.Condition;
108

119
public class NameCondition extends Condition {
1210

13-
private Component name;
11+
private String name;
1412

1513
@Override
1614
public boolean initialize(String var) {
1715
if (var == null || var.isEmpty()) return false;
18-
name = Util.getMiniMessage(var);
16+
name = Util.getPlainString(Util.getMiniMessage(var));
1917
return true;
2018
}
2119

@@ -26,7 +24,7 @@ public boolean check(LivingEntity livingEntity) {
2624

2725
@Override
2826
public boolean check(LivingEntity livingEntity, LivingEntity target) {
29-
return target.name().equals(name);
27+
return Util.getPlainString(target.name()).equals(name);
3028
}
3129

3230
@Override

0 commit comments

Comments
 (0)