mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-03 02:55:46 +00: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
5 changed files with 38 additions and 4 deletions
|
@ -320,4 +320,6 @@ public interface ISettings extends IConf {
|
||||||
String getItemDbType();
|
String getItemDbType();
|
||||||
|
|
||||||
boolean isForceEnableRecipe();
|
boolean isForceEnableRecipe();
|
||||||
|
|
||||||
|
boolean allowOldIdSigns();
|
||||||
}
|
}
|
||||||
|
|
|
@ -538,7 +538,8 @@ public class Settings implements net.ess3.api.ISettings {
|
||||||
isCompassTowardsHomePerm = _isCompassTowardsHomePerm();
|
isCompassTowardsHomePerm = _isCompassTowardsHomePerm();
|
||||||
isAllowWorldInBroadcastworld = _isAllowWorldInBroadcastworld();
|
isAllowWorldInBroadcastworld = _isAllowWorldInBroadcastworld();
|
||||||
itemDbType = _getItemDbType();
|
itemDbType = _getItemDbType();
|
||||||
forceEnableRecipe = config.getBoolean("force-enable-recipe", false);
|
forceEnableRecipe = _isForceEnableRecipe();
|
||||||
|
allowOldIdSigns = _allowOldIdSigns();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Material> itemSpawnBl = new ArrayList<Material>();
|
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 forceEnableRecipe; // https://github.com/EssentialsX/Essentials/issues/1397
|
||||||
|
|
||||||
|
private boolean _isForceEnableRecipe() {
|
||||||
|
return config.getBoolean("force-enable-recipe", false);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isForceEnableRecipe() {
|
public boolean isForceEnableRecipe() {
|
||||||
return forceEnableRecipe;
|
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));
|
final int amount = getIntegerPositive(getSignText(sign, amountIndex));
|
||||||
return new Trade(amount, ess);
|
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());
|
final int amount = Math.min(getIntegerPositive(getSignText(sign, amountIndex)), item.getType().getMaxStackSize() * player.getBase().getInventory().getSize());
|
||||||
if (item.getType() == Material.AIR || amount < 1) {
|
if (item.getType() == Material.AIR || amount < 1) {
|
||||||
throw new SignException(tl("moreThanZero"));
|
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 {
|
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 {
|
try {
|
||||||
final ItemStack item = ess.getItemDb().get(itemName);
|
final ItemStack item = ess.getItemDb().get(itemName);
|
||||||
item.setAmount(quantity);
|
item.setAmount(quantity);
|
||||||
|
@ -420,7 +431,7 @@ public class EssentialsSign {
|
||||||
sign.setLine(index, quantity + " exp");
|
sign.setLine(index, quantity + " exp");
|
||||||
return new Trade(quantity, ess);
|
return new Trade(quantity, ess);
|
||||||
} else {
|
} else {
|
||||||
final ItemStack stack = getItemStack(item, quantity, ess);
|
final ItemStack stack = getItemStack(item, quantity, true, ess);
|
||||||
sign.setLine(index, quantity + " " + item);
|
sign.setLine(index, quantity + " " + item);
|
||||||
return new Trade(stack, ess);
|
return new Trade(stack, ess);
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,7 +237,7 @@ public class SignTrade extends EssentialsSign {
|
||||||
return new Trade((amountType == AmountType.COST ? stackamount : amount), ess);
|
return new Trade((amountType == AmountType.COST ? stackamount : amount), ess);
|
||||||
} else {
|
} else {
|
||||||
final int stackamount = getIntegerPositive(split[0]);
|
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]);
|
int amount = getInteger(split[2]);
|
||||||
if (amountType == AmountType.ROUNDED) {
|
if (amountType == AmountType.ROUNDED) {
|
||||||
amount -= amount % stackamount;
|
amount -= amount % stackamount;
|
||||||
|
|
|
@ -322,6 +322,11 @@ 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
|
||||||
|
|
||||||
|
# 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
|
# 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.
|
# 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
|
# For example, if a plugin provides a [kit] sign, and you wish to use theirs instead of
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue