Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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