1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00
This commit is contained in:
Florian CUNY 2017-10-13 20:46:28 +02:00
parent cc79e62f34
commit 657fd4d112
2 changed files with 21 additions and 3 deletions

View File

@ -56,6 +56,7 @@ public class SlimefunItem {
private Object[] values;
private Research research;
private boolean ghost, replacing, enchantable, disenchantable;
private boolean requirePermissionToUse;
private Set<ItemHandler> itemhandlers;
private URID urid;
private boolean ticking = false;
@ -140,6 +141,7 @@ public class SlimefunItem {
this.replacing = false;
this.enchantable = true;
this.disenchantable = true;
this.requirePermissionToUse = false;
itemhandlers = new HashSet<ItemHandler>();
urid = URID.nextURID(this, false);
@ -158,6 +160,7 @@ public class SlimefunItem {
this.replacing = false;
this.enchantable = true;
this.disenchantable = true;
this.requirePermissionToUse = false;
itemhandlers = new HashSet<ItemHandler>();
urid = URID.nextURID(this, false);
@ -176,6 +179,7 @@ public class SlimefunItem {
this.replacing = false;
this.enchantable = true;
this.disenchantable = true;
this.requirePermissionToUse = false;
itemhandlers = new HashSet<ItemHandler>();
urid = URID.nextURID(this, false);
@ -194,6 +198,7 @@ public class SlimefunItem {
this.replacing = false;
this.enchantable = true;
this.disenchantable = true;
this.requirePermissionToUse = false;
itemhandlers = new HashSet<ItemHandler>();
urid = URID.nextURID(this, false);
@ -212,6 +217,7 @@ public class SlimefunItem {
this.replacing = false;
this.enchantable = true;
this.disenchantable = true;
this.requirePermissionToUse = false;
itemhandlers = new HashSet<ItemHandler>();
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-disenchanting", this.disenchantable);
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) {
for (int i = 0; i < this.keys.length; 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.enchantable = SlimefunStartup.getItemCfg().getBoolean(this.id + ".allow-enchanting");
this.disenchantable = SlimefunStartup.getItemCfg().getBoolean(this.id + ".allow-disenchanting");
this.requirePermissionToUse = SlimefunStartup.getItemCfg().getBoolean(this.id + ".require-permission-to-use");
items.add(this);
if (slimefun) vanilla++;
map_id.put(this.getID(), this.getURID());
@ -414,6 +422,16 @@ public class SlimefunItem {
public boolean isDisenchantable() {
return disenchantable;
}
/**
* doc needed here
* @return
*
* @since 4.1.11
*/
public boolean requirePermissionToUse() {
return requirePermissionToUse;
}
public void setReplacing(boolean replacing) {
this.replacing = replacing;

View File

@ -185,7 +185,7 @@ public class Slimefun {
public static boolean hasPermission(Player p, SlimefunItem item, boolean message) {
if (item == null) 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 {
if (message) Messages.local.sendTranslation(p, "messages.no-permission", true);
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 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 sfItem the item to check, not null