mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-12 15:07:22 +01:00
Cache the name for getDisguisePerm
This commit is contained in:
parent
beb3fec8ab
commit
73eacb41f6
@ -361,15 +361,17 @@ public class DisguiseParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static DisguisePerm getDisguisePerm(String name) {
|
public static DisguisePerm getDisguisePerm(String name) {
|
||||||
|
name = name.replaceAll("[ |_]", "").toLowerCase();
|
||||||
|
|
||||||
for (DisguisePerm perm : getDisguisePerms()) {
|
for (DisguisePerm perm : getDisguisePerms()) {
|
||||||
if (!perm.toReadable().replaceAll("[ |_]", "").equalsIgnoreCase(name.replaceAll("[ |_]", ""))) {
|
if (!perm.getRegexedName().equals(name)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
return perm;
|
return perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.equalsIgnoreCase("p")) {
|
if (name.equals("p")) {
|
||||||
return getDisguisePerm(DisguiseType.PLAYER.toReadable());
|
return getDisguisePerm(DisguiseType.PLAYER.toReadable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.utilities.parser;
|
package me.libraryaddict.disguise.utilities.parser;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -12,14 +13,23 @@ import java.util.Objects;
|
|||||||
public class DisguisePerm {
|
public class DisguisePerm {
|
||||||
private final DisguiseType disguiseType;
|
private final DisguiseType disguiseType;
|
||||||
private String permName;
|
private String permName;
|
||||||
|
@Getter
|
||||||
|
private String regexedName;
|
||||||
private boolean customDisguise;
|
private boolean customDisguise;
|
||||||
|
|
||||||
|
private DisguisePerm() {
|
||||||
|
regexedName = toReadable().replaceAll("[ |_]", "").toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
public DisguisePerm(DisguiseType disguiseType) {
|
public DisguisePerm(DisguiseType disguiseType) {
|
||||||
|
this();
|
||||||
|
|
||||||
this.disguiseType = disguiseType;
|
this.disguiseType = disguiseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DisguisePerm(DisguiseType disguiseType, String disguisePerm) {
|
public DisguisePerm(DisguiseType disguiseType, String disguisePerm) {
|
||||||
this.disguiseType = disguiseType;
|
this(disguiseType);
|
||||||
|
|
||||||
permName = disguisePerm;
|
permName = disguisePerm;
|
||||||
customDisguise = true;
|
customDisguise = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user