Skip to content

Commit

Permalink
Merge pull request #583 from Chronoken/main
Browse files Browse the repository at this point in the history
Fix name conditions
  • Loading branch information
Chronoken authored Apr 30, 2022
2 parents 4b0e2ba + d99e68c commit ba2ed2a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@
import org.bukkit.entity.LivingEntity;
import com.nisovin.magicspells.util.Util;

import net.kyori.adventure.text.Component;

import com.nisovin.magicspells.castmodifiers.Condition;

public class DisplayNameCondition extends Condition {

private Component displayName;
private String displayName;

@Override
public boolean initialize(String var) {
if (var == null || var.isEmpty()) return false;
displayName = Util.getMiniMessage(var);
displayName = Util.getStringFromComponent(Util.getMiniMessage(var));
return true;
}

Expand All @@ -28,7 +26,7 @@ public boolean check(LivingEntity livingEntity) {
@Override
public boolean check(LivingEntity livingEntity, LivingEntity target) {
if (!(target instanceof Player player)) return false;
return player.displayName().equals(displayName);
return Util.getStringFromComponent(player.displayName()).equals(displayName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,18 @@

import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import com.nisovin.magicspells.util.Util;

import net.kyori.adventure.text.Component;

import com.nisovin.magicspells.util.Util;
import com.nisovin.magicspells.castmodifiers.Condition;

public class NameCondition extends Condition {

private Component name;
private String name;

@Override
public boolean initialize(String var) {
if (var == null || var.isEmpty()) return false;
name = Util.getMiniMessage(var);
name = Util.getPlainString(Util.getMiniMessage(var));
return true;
}

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

@Override
public boolean check(LivingEntity livingEntity, LivingEntity target) {
return target.name().equals(name);
return Util.getPlainString(target.name()).equals(name);
}

@Override
Expand Down

0 comments on commit ba2ed2a

Please sign in to comment.