mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-08 17:38:20 +01:00
Add setting to enable item ID recognition on signs
Item IDs can now be enabled for existing signs by manually changing a config option, but there is no facility to create new signs with item IDs.
This commit is contained in:
parent
28559dda3a
commit
55074872fe
@ -320,4 +320,6 @@ public interface ISettings extends IConf {
|
||||
String getItemDbType();
|
||||
|
||||
boolean isForceEnableRecipe();
|
||||
|
||||
boolean allowOldIdSigns();
|
||||
}
|
||||
|
@ -538,7 +538,8 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
isCompassTowardsHomePerm = _isCompassTowardsHomePerm();
|
||||
isAllowWorldInBroadcastworld = _isAllowWorldInBroadcastworld();
|
||||
itemDbType = _getItemDbType();
|
||||
forceEnableRecipe = config.getBoolean("force-enable-recipe", false);
|
||||
forceEnableRecipe = _isForceEnableRecipe();
|
||||
allowOldIdSigns = _allowOldIdSigns();
|
||||
}
|
||||
|
||||
private List<Material> itemSpawnBl = new ArrayList<Material>();
|
||||
@ -1482,8 +1483,23 @@ public class Settings implements net.ess3.api.ISettings {
|
||||
|
||||
private boolean forceEnableRecipe; // https://github.com/EssentialsX/Essentials/issues/1397
|
||||
|
||||
private boolean _isForceEnableRecipe() {
|
||||
return config.getBoolean("force-enable-recipe", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isForceEnableRecipe() {
|
||||
return forceEnableRecipe;
|
||||
}
|
||||
|
||||
private boolean allowOldIdSigns;
|
||||
|
||||
private boolean _allowOldIdSigns() {
|
||||
return config.getBoolean("allow-old-id-signs", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowOldIdSigns() {
|
||||
return allowOldIdSigns;
|
||||
}
|
||||
}
|
||||
|
@ -309,7 +309,7 @@ public class EssentialsSign {
|
||||
final int amount = getIntegerPositive(getSignText(sign, amountIndex));
|
||||
return new Trade(amount, ess);
|
||||
}
|
||||
final ItemStack item = getItemStack(itemType, 1, ess);
|
||||
final ItemStack item = getItemStack(itemType, 1, true, ess);
|
||||
final int amount = Math.min(getIntegerPositive(getSignText(sign, amountIndex)), item.getType().getMaxStackSize() * player.getBase().getInventory().getSize());
|
||||
if (item.getType() == Material.AIR || amount < 1) {
|
||||
throw new SignException(tl("moreThanZero"));
|
||||
@ -346,6 +346,17 @@ public class EssentialsSign {
|
||||
}
|
||||
|
||||
protected final ItemStack getItemStack(final String itemName, final int quantity, final IEssentials ess) throws SignException {
|
||||
return getItemStack(itemName, quantity, false, ess);
|
||||
}
|
||||
|
||||
protected final ItemStack getItemStack(final String itemName, final int quantity, final boolean allowId, final IEssentials ess) throws SignException {
|
||||
if (allowId && ess.getSettings().allowOldIdSigns()) {
|
||||
final Material newMaterial = ess.getItemDb().getFromLegacy(itemName);
|
||||
if (newMaterial != null) {
|
||||
return new ItemStack(newMaterial, quantity);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
final ItemStack item = ess.getItemDb().get(itemName);
|
||||
item.setAmount(quantity);
|
||||
@ -420,7 +431,7 @@ public class EssentialsSign {
|
||||
sign.setLine(index, quantity + " exp");
|
||||
return new Trade(quantity, ess);
|
||||
} else {
|
||||
final ItemStack stack = getItemStack(item, quantity, ess);
|
||||
final ItemStack stack = getItemStack(item, quantity, true, ess);
|
||||
sign.setLine(index, quantity + " " + item);
|
||||
return new Trade(stack, ess);
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ public class SignTrade extends EssentialsSign {
|
||||
return new Trade((amountType == AmountType.COST ? stackamount : amount), ess);
|
||||
} else {
|
||||
final int stackamount = getIntegerPositive(split[0]);
|
||||
final ItemStack item = getItemStack(split[1], stackamount, ess);
|
||||
final ItemStack item = getItemStack(split[1], stackamount, true, ess);
|
||||
int amount = getInteger(split[2]);
|
||||
if (amountType == AmountType.ROUNDED) {
|
||||
amount -= amount % stackamount;
|
||||
|
@ -322,6 +322,11 @@ enabledSigns:
|
||||
# Lower numbers will reduce the possibility of lag, but may annoy players.
|
||||
sign-use-per-second: 4
|
||||
|
||||
# Allow item IDs on pre-existing signs on 1.13 and above.
|
||||
# You cannot use item IDs on new signs, but this will allow players to interact with signs that
|
||||
# were placed before 1.13.
|
||||
allow-old-id-signs: false
|
||||
|
||||
# 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
|
||||
|
Loading…
Reference in New Issue
Block a user