mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Added requirePermissionToUse field (https://github.com/TheBusyBiscuit/Slimefun4/issues/410)
This commit is contained in:
parent
cc79e62f34
commit
657fd4d112
@ -56,6 +56,7 @@ public class SlimefunItem {
|
|||||||
private Object[] values;
|
private Object[] values;
|
||||||
private Research research;
|
private Research research;
|
||||||
private boolean ghost, replacing, enchantable, disenchantable;
|
private boolean ghost, replacing, enchantable, disenchantable;
|
||||||
|
private boolean requirePermissionToUse;
|
||||||
private Set<ItemHandler> itemhandlers;
|
private Set<ItemHandler> itemhandlers;
|
||||||
private URID urid;
|
private URID urid;
|
||||||
private boolean ticking = false;
|
private boolean ticking = false;
|
||||||
@ -140,6 +141,7 @@ public class SlimefunItem {
|
|||||||
this.replacing = false;
|
this.replacing = false;
|
||||||
this.enchantable = true;
|
this.enchantable = true;
|
||||||
this.disenchantable = true;
|
this.disenchantable = true;
|
||||||
|
this.requirePermissionToUse = false;
|
||||||
itemhandlers = new HashSet<ItemHandler>();
|
itemhandlers = new HashSet<ItemHandler>();
|
||||||
|
|
||||||
urid = URID.nextURID(this, false);
|
urid = URID.nextURID(this, false);
|
||||||
@ -158,6 +160,7 @@ public class SlimefunItem {
|
|||||||
this.replacing = false;
|
this.replacing = false;
|
||||||
this.enchantable = true;
|
this.enchantable = true;
|
||||||
this.disenchantable = true;
|
this.disenchantable = true;
|
||||||
|
this.requirePermissionToUse = false;
|
||||||
itemhandlers = new HashSet<ItemHandler>();
|
itemhandlers = new HashSet<ItemHandler>();
|
||||||
|
|
||||||
urid = URID.nextURID(this, false);
|
urid = URID.nextURID(this, false);
|
||||||
@ -176,6 +179,7 @@ public class SlimefunItem {
|
|||||||
this.replacing = false;
|
this.replacing = false;
|
||||||
this.enchantable = true;
|
this.enchantable = true;
|
||||||
this.disenchantable = true;
|
this.disenchantable = true;
|
||||||
|
this.requirePermissionToUse = false;
|
||||||
itemhandlers = new HashSet<ItemHandler>();
|
itemhandlers = new HashSet<ItemHandler>();
|
||||||
|
|
||||||
urid = URID.nextURID(this, false);
|
urid = URID.nextURID(this, false);
|
||||||
@ -194,6 +198,7 @@ public class SlimefunItem {
|
|||||||
this.replacing = false;
|
this.replacing = false;
|
||||||
this.enchantable = true;
|
this.enchantable = true;
|
||||||
this.disenchantable = true;
|
this.disenchantable = true;
|
||||||
|
this.requirePermissionToUse = false;
|
||||||
itemhandlers = new HashSet<ItemHandler>();
|
itemhandlers = new HashSet<ItemHandler>();
|
||||||
|
|
||||||
urid = URID.nextURID(this, false);
|
urid = URID.nextURID(this, false);
|
||||||
@ -212,6 +217,7 @@ public class SlimefunItem {
|
|||||||
this.replacing = false;
|
this.replacing = false;
|
||||||
this.enchantable = true;
|
this.enchantable = true;
|
||||||
this.disenchantable = true;
|
this.disenchantable = true;
|
||||||
|
this.requirePermissionToUse = false;
|
||||||
itemhandlers = new HashSet<ItemHandler>();
|
itemhandlers = new HashSet<ItemHandler>();
|
||||||
|
|
||||||
urid = URID.nextURID(this, false);
|
urid = URID.nextURID(this, false);
|
||||||
@ -232,6 +238,7 @@ public class SlimefunItem {
|
|||||||
SlimefunStartup.getItemCfg().setDefaultValue(this.id + ".allow-enchanting", this.enchantable);
|
SlimefunStartup.getItemCfg().setDefaultValue(this.id + ".allow-enchanting", this.enchantable);
|
||||||
SlimefunStartup.getItemCfg().setDefaultValue(this.id + ".allow-disenchanting", this.disenchantable);
|
SlimefunStartup.getItemCfg().setDefaultValue(this.id + ".allow-disenchanting", this.disenchantable);
|
||||||
SlimefunStartup.getItemCfg().setDefaultValue(this.id + ".required-permission", "");
|
SlimefunStartup.getItemCfg().setDefaultValue(this.id + ".required-permission", "");
|
||||||
|
SlimefunStartup.getItemCfg().setDefaultValue(this.id + ".require-permission-to-use", this.requirePermissionToUse);
|
||||||
if (this.keys != null && this.values != null) {
|
if (this.keys != null && this.values != null) {
|
||||||
for (int i = 0; i < this.keys.length; i++) {
|
for (int i = 0; i < this.keys.length; i++) {
|
||||||
SlimefunStartup.getItemCfg().setDefaultValue(this.id + "." + this.keys[i], this.values[i]);
|
SlimefunStartup.getItemCfg().setDefaultValue(this.id + "." + this.keys[i], this.values[i]);
|
||||||
@ -256,6 +263,7 @@ public class SlimefunItem {
|
|||||||
this.replacing = SlimefunStartup.getItemCfg().getBoolean(this.id + ".can-be-used-in-workbenches");
|
this.replacing = SlimefunStartup.getItemCfg().getBoolean(this.id + ".can-be-used-in-workbenches");
|
||||||
this.enchantable = SlimefunStartup.getItemCfg().getBoolean(this.id + ".allow-enchanting");
|
this.enchantable = SlimefunStartup.getItemCfg().getBoolean(this.id + ".allow-enchanting");
|
||||||
this.disenchantable = SlimefunStartup.getItemCfg().getBoolean(this.id + ".allow-disenchanting");
|
this.disenchantable = SlimefunStartup.getItemCfg().getBoolean(this.id + ".allow-disenchanting");
|
||||||
|
this.requirePermissionToUse = SlimefunStartup.getItemCfg().getBoolean(this.id + ".require-permission-to-use");
|
||||||
items.add(this);
|
items.add(this);
|
||||||
if (slimefun) vanilla++;
|
if (slimefun) vanilla++;
|
||||||
map_id.put(this.getID(), this.getURID());
|
map_id.put(this.getID(), this.getURID());
|
||||||
@ -415,6 +423,16 @@ public class SlimefunItem {
|
|||||||
return disenchantable;
|
return disenchantable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* doc needed here
|
||||||
|
* @return
|
||||||
|
*
|
||||||
|
* @since 4.1.11
|
||||||
|
*/
|
||||||
|
public boolean requirePermissionToUse() {
|
||||||
|
return requirePermissionToUse;
|
||||||
|
}
|
||||||
|
|
||||||
public void setReplacing(boolean replacing) {
|
public void setReplacing(boolean replacing) {
|
||||||
this.replacing = replacing;
|
this.replacing = replacing;
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,7 @@ public class Slimefun {
|
|||||||
public static boolean hasPermission(Player p, SlimefunItem item, boolean message) {
|
public static boolean hasPermission(Player p, SlimefunItem item, boolean message) {
|
||||||
if (item == null) return true;
|
if (item == null) return true;
|
||||||
else if (SlimefunStartup.getItemCfg().getString(item.getID() + ".required-permission").equalsIgnoreCase("")) return true;
|
else if (SlimefunStartup.getItemCfg().getString(item.getID() + ".required-permission").equalsIgnoreCase("")) return true;
|
||||||
else if (p.hasPermission(SlimefunStartup.getItemCfg().getString(item.getID()) + ".required-permission")) return true;
|
else if (item.requirePermissionToUse() && p.hasPermission(SlimefunStartup.getItemCfg().getString(item.getID()) + ".required-permission")) return true;
|
||||||
else {
|
else {
|
||||||
if (message) Messages.local.sendTranslation(p, "messages.no-permission", true);
|
if (message) Messages.local.sendTranslation(p, "messages.no-permission", true);
|
||||||
return false;
|
return false;
|
||||||
@ -193,7 +193,7 @@ public class Slimefun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this item is enabled in the world of this player.
|
* Checks if this item is enabled in the world this player is in.
|
||||||
*
|
*
|
||||||
* @param p the player to get the world he is in, not null
|
* @param p the player to get the world he is in, not null
|
||||||
* @param item the item to check, not null
|
* @param item the item to check, not null
|
||||||
@ -224,7 +224,7 @@ public class Slimefun {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this item is enabled in the world of this player.
|
* Checks if this item is enabled in the world this player is in.
|
||||||
*
|
*
|
||||||
* @param p the player to get the world he is in, not null
|
* @param p the player to get the world he is in, not null
|
||||||
* @param sfItem the item to check, not null
|
* @param sfItem the item to check, not null
|
||||||
|
Loading…
Reference in New Issue
Block a user