mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-28 16:32:09 +00:00
Add the option to disable disabled-sign name protection. (#699)
This allows EssentialsX users to use other plugins that provide signs such as [Kit] and not have EssentialsX interfere with the final sign name.
This commit is contained in:
parent
19f6510840
commit
c9f1b0fdc5
4 changed files with 45 additions and 1 deletions
|
@ -263,4 +263,6 @@ public interface ISettings extends IConf {
|
||||||
boolean isNpcsInBalanceRanking();
|
boolean isNpcsInBalanceRanking();
|
||||||
|
|
||||||
NumberFormat getCurrencyFormat();
|
NumberFormat getCurrencyFormat();
|
||||||
|
|
||||||
|
List<EssentialsSign> getUnprotectedSignNames();
|
||||||
}
|
}
|
||||||
|
|
|
@ -549,6 +549,7 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
commandCooldowns = _getCommandCooldowns();
|
commandCooldowns = _getCommandCooldowns();
|
||||||
npcsInBalanceRanking = _isNpcsInBalanceRanking();
|
npcsInBalanceRanking = _isNpcsInBalanceRanking();
|
||||||
currencyFormat = _getCurrencyFormat();
|
currencyFormat = _getCurrencyFormat();
|
||||||
|
unprotectedSigns = _getUnprotectedSign();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
||||||
|
@ -1328,4 +1329,29 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
public NumberFormat getCurrencyFormat() {
|
public NumberFormat getCurrencyFormat() {
|
||||||
return this.currencyFormat;
|
return this.currencyFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<EssentialsSign> unprotectedSigns = Collections.emptyList();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<EssentialsSign> getUnprotectedSignNames() {
|
||||||
|
return this.unprotectedSigns;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<EssentialsSign> _getUnprotectedSign() {
|
||||||
|
List<EssentialsSign> newSigns = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String signName : config.getStringList("unprotected-sign-names")) {
|
||||||
|
signName = signName.trim().toUpperCase(Locale.ENGLISH);
|
||||||
|
if (signName.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
newSigns.add(Signs.valueOf(signName).getSign());
|
||||||
|
} catch (Exception ex) {
|
||||||
|
logger.log(Level.SEVERE, tl("unknownItemInList", signName, "unprotected-sign-names"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newSigns;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,11 +91,18 @@ public class SignBlockListener implements Listener {
|
||||||
//We loop through all sign types here to prevent clashes with preexisting signs later
|
//We loop through all sign types here to prevent clashes with preexisting signs later
|
||||||
for (Signs signs : Signs.values()) {
|
for (Signs signs : Signs.values()) {
|
||||||
final EssentialsSign sign = signs.getSign();
|
final EssentialsSign sign = signs.getSign();
|
||||||
// If the top line contains any of the success name (excluding colors), just remove all colours from the first line.
|
// If the top sign line contains any of the success name (excluding colors), just remove all colours from the first line.
|
||||||
// This is to ensure we are only modifying possible Essentials Sign and not just removing colors from the first line of all signs.
|
// This is to ensure we are only modifying possible Essentials Sign and not just removing colors from the first line of all signs.
|
||||||
// Top line and sign#getSuccessName() are both lowercased since contains is case-sensitive.
|
// Top line and sign#getSuccessName() are both lowercased since contains is case-sensitive.
|
||||||
String lSuccessName = ChatColor.stripColor(sign.getSuccessName().toLowerCase());
|
String lSuccessName = ChatColor.stripColor(sign.getSuccessName().toLowerCase());
|
||||||
if (lColorlessTopLine.contains(lSuccessName)) {
|
if (lColorlessTopLine.contains(lSuccessName)) {
|
||||||
|
|
||||||
|
// If this sign is not enabled and it has been requested to not protect it's name (when disabled), then do not protect the name.
|
||||||
|
// By lower-casing it and stripping colours.
|
||||||
|
if (!ess.getSettings().enabledSigns().contains(sign)
|
||||||
|
&& ess.getSettings().getUnprotectedSignNames().contains(sign)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
event.setLine(0, lColorlessTopLine);
|
event.setLine(0, lColorlessTopLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,6 +325,15 @@ enabledSigns:
|
||||||
# Lower numbers will reduce the possibility of lag, but may annoy players.
|
# Lower numbers will reduce the possibility of lag, but may annoy players.
|
||||||
sign-use-per-second: 4
|
sign-use-per-second: 4
|
||||||
|
|
||||||
|
# List of sign names Essentials should not protect. This feature is especially useful when
|
||||||
|
# another plugin provides a sign that EssentialsX provides, but Essentials overrides.
|
||||||
|
# For example, if a plugin provides a [kit] sign, and you wish to use theirs instead of
|
||||||
|
# Essentials's, then simply add kit below and Essentials will not protect it.
|
||||||
|
#
|
||||||
|
# See https://github.com/drtshock/Essentials/pull/699 for more information.
|
||||||
|
unprotected-sign-names:
|
||||||
|
#- kit
|
||||||
|
|
||||||
# Backup runs a batch/bash command while saving is disabled.
|
# Backup runs a batch/bash command while saving is disabled.
|
||||||
backup:
|
backup:
|
||||||
# Interval in minutes.
|
# Interval in minutes.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue