PermissionWrapper WIP

This commit is contained in:
nossr50 2019-06-18 18:07:06 -07:00
parent 29670cd66f
commit c0685bd1eb
5 changed files with 74 additions and 75 deletions

View File

@ -12,6 +12,29 @@ Version 2.2.0
Parties no longer have a cap, you can level them forever for bragging rights Parties no longer have a cap, you can level them forever for bragging rights
You can now specify multiple repair-items for an item (such as specifying that a wooden sword can be repaired by all types of planks) You can now specify multiple repair-items for an item (such as specifying that a wooden sword can be repaired by all types of planks)
Repair no longer consumes materials with item lore, players are informed that they cannot repair with that material if its the only matching repair material in their inventory Repair no longer consumes materials with item lore, players are informed that they cannot repair with that material if its the only matching repair material in their inventory
Removed the following Repair/Salvage permissions
mcmmo.ability.repair.stonerepair
mcmmo.ability.repair.stringrepair
mcmmo.ability.repair.toolrepair
mcmmo.ability.repair.woodrepair
mcmmo.ability.repair.armorrepair
mcmmo.ability.repair.diamondrepair
mcmmo.ability.repair.goldrepair
mcmmo.ability.repair.ironrepair
mcmmo.ability.repair.leatherrepair
mcmmo.ability.repair.othermaterialrepair
mcmmo.ability.repair.otherrepair
mcmmo.ability.salvage.armorsalvage
mcmmo.ability.salvage.diamondsalvage
mcmmo.ability.salvage.goldsalvage
mcmmo.ability.salvage.ironsalvage
mcmmo.ability.salvage.leathersalvage
mcmmo.ability.salvage.othermaterialsalvage
mcmmo.ability.salvage.othersalvage
mcmmo.ability.salvage.stonesalvage
mcmmo.ability.salvage.stringsalvage
mcmmo.ability.salvage.toolsalvage
mcmmo.ability.salvage.woodsalvage
Added new locale string - Repair.NoBasicRepairMatsFound Added new locale string - Repair.NoBasicRepairMatsFound
Simplified the config entries for Repairables in the Repair config Simplified the config entries for Repairables in the Repair config
Repairables in the repair config now use their internal registry key names instead of Bukkit material names Repairables in the repair config now use their internal registry key names instead of Bukkit material names

View File

@ -0,0 +1,32 @@
package com.gmail.nossr50.datatypes.permissions;
import java.util.Objects;
public class PermissionWrapper {
private String permissionAddress;
public PermissionWrapper(String permissionAddress) {
this.permissionAddress = permissionAddress;
}
public String getPermissionAddress() {
return permissionAddress;
}
public void setPermissionAddress(String permissionAddress) {
this.permissionAddress = permissionAddress;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof PermissionWrapper)) return false;
PermissionWrapper that = (PermissionWrapper) o;
return getPermissionAddress().equals(that.getPermissionAddress());
}
@Override
public int hashCode() {
return Objects.hash(getPermissionAddress());
}
}

View File

@ -69,15 +69,15 @@ public class RepairManager extends SkillManager {
} }
// Permissions checks on material and item types // Permissions checks on material and item types
if (!Permissions.repairMaterialType(player, repairable.getRepairItemMaterialCategory())) { // if (!Permissions.repairMaterialType(player, repairable.getRepairItemMaterialCategory())) {
mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission"); // mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission");
return; // return;
} // }
//
if (!Permissions.repairItemType(player, repairable.getRepairItemType())) { // if (!Permissions.repairItemType(player, repairable.getRepairItemType())) {
mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission"); // mcMMO.getNotificationManager().sendPlayerInformation(player, NotificationType.NO_PERMISSION, "mcMMO.NoPermission");
return; // return;
} // }
int skillLevel = getSkillLevel(); int skillLevel = getSkillLevel();
int minimumRepairableLevel = repairable.getMinimumLevel(); int minimumRepairableLevel = repairable.getMinimumLevel();

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.skills.repair.repairables; package com.gmail.nossr50.skills.repair.repairables;
import com.gmail.nossr50.datatypes.permissions.PermissionWrapper;
import com.gmail.nossr50.skills.repair.RepairTransaction; import com.gmail.nossr50.skills.repair.RepairTransaction;
import com.gmail.nossr50.util.nbt.RawNBT; import com.gmail.nossr50.util.nbt.RawNBT;
import org.bukkit.Material; import org.bukkit.Material;
@ -13,6 +14,7 @@ public class Repairable {
private int baseXP; private int baseXP;
private RawNBT rawNBT; private RawNBT rawNBT;
private int repairCount; private int repairCount;
private PermissionWrapper permissionWrapper;
public Repairable(Material itemMaterial, RepairTransaction repairTransaction, int minimumLevel, int repairCount, int baseXP, RawNBT rawNBT) { public Repairable(Material itemMaterial, RepairTransaction repairTransaction, int minimumLevel, int repairCount, int baseXP, RawNBT rawNBT) {
this(itemMaterial.getKey().getKey(), repairTransaction, minimumLevel, repairCount, baseXP, false, rawNBT); this(itemMaterial.getKey().getKey(), repairTransaction, minimumLevel, repairCount, baseXP, false, rawNBT);
@ -34,6 +36,14 @@ public class Repairable {
this.rawNBT = rawNBT; this.rawNBT = rawNBT;
} }
public PermissionWrapper getPermissionWrapper() {
return permissionWrapper;
}
public void setPermissionWrapper(PermissionWrapper permissionWrapper) {
this.permissionWrapper = permissionWrapper;
}
public RawNBT getRawNBT() { public RawNBT getRawNBT() {
return rawNBT; return rawNBT;
} }

View File

@ -445,47 +445,14 @@ permissions:
description: Allows access to all Repair abilities description: Allows access to all Repair abilities
children: children:
mcmmo.ability.repair.arcaneforging: true mcmmo.ability.repair.arcaneforging: true
mcmmo.ability.repair.armorrepair: true
mcmmo.ability.repair.diamondrepair: true
mcmmo.ability.repair.goldrepair: true
mcmmo.ability.repair.ironrepair: true
mcmmo.ability.repair.leatherrepair: true
mcmmo.ability.repair.othermaterialrepair: true
mcmmo.ability.repair.otherrepair: true
mcmmo.ability.repair.repairbonus: true mcmmo.ability.repair.repairbonus: true
mcmmo.ability.repair.repairmastery: true mcmmo.ability.repair.repairmastery: true
mcmmo.ability.repair.stonerepair: true
mcmmo.ability.repair.stringrepair: true
mcmmo.ability.repair.toolrepair: true
mcmmo.ability.repair.woodrepair: true
mcmmo.ability.repair.arcaneforging: mcmmo.ability.repair.arcaneforging:
description: Allows access to the Arcane Forging ability description: Allows access to the Arcane Forging ability
mcmmo.ability.repair.armorrepair:
description: Allows ability to repair armor
mcmmo.ability.repair.diamondrepair:
description: Allows ability to repair Diamond tools & armor
mcmmo.ability.repair.goldrepair:
description: Allows ability to repair Gold tools & armor
mcmmo.ability.repair.ironrepair:
description: Allows ability to repair Iron tools & armor
mcmmo.ability.repair.leatherrepair:
description: Allows ability to repair Leather armor
mcmmo.ability.repair.othermaterialrepair:
description: Allows ability to repair items of material type OTHER
mcmmo.ability.repair.otherrepair:
description: Allows ability to repair items of type OTHER
mcmmo.ability.repair.superrepair: mcmmo.ability.repair.superrepair:
description: Allows access to Super Repair bonus description: Allows access to Super Repair bonus
mcmmo.ability.repair.repairmastery: mcmmo.ability.repair.repairmastery:
description: Allows access to Repair Mastery description: Allows access to Repair Mastery
mcmmo.ability.repair.stonerepair:
description: Allows ability to repair Stone tools
mcmmo.ability.repair.stringrepair:
description: Allows ability to repair Bow and Fishing rod
mcmmo.ability.repair.toolrepair:
description: Allows ability to repair tools
mcmmo.ability.repair.woodrepair:
description: Allows ability to repair Wood tools
mcmmo.ability.salvage.*: mcmmo.ability.salvage.*:
default: false default: false
description: Allows access to all Salvage abilities description: Allows access to all Salvage abilities
@ -496,43 +463,10 @@ permissions:
children: children:
mcmmo.ability.salvage.advancedsalvage: true mcmmo.ability.salvage.advancedsalvage: true
mcmmo.ability.salvage.arcanesalvage: true mcmmo.ability.salvage.arcanesalvage: true
mcmmo.ability.salvage.armorsalvage: true
mcmmo.ability.salvage.diamondsalvage: true
mcmmo.ability.salvage.goldsalvage: true
mcmmo.ability.salvage.ironsalvage: true
mcmmo.ability.salvage.leathersalvage: true
mcmmo.ability.salvage.othermaterialsalvage: true
mcmmo.ability.salvage.othersalvage: true
mcmmo.ability.salvage.stonesalvage: true
mcmmo.ability.salvage.stringsalvage: true
mcmmo.ability.salvage.toolsalvage: true
mcmmo.ability.salvage.woodsalvage: true
mcmmo.ability.salvage.advancedsalvage: mcmmo.ability.salvage.advancedsalvage:
description: Allows access to the Advanced Salvage ability description: Allows access to the Advanced Salvage ability
mcmmo.ability.salvage.arcanesalvage: mcmmo.ability.salvage.arcanesalvage:
description: Allows access to the Arcane Salvage ability description: Allows access to the Arcane Salvage ability
mcmmo.ability.salvage.armorsalvage:
description: Allows ability to salvage armor
mcmmo.ability.salvage.diamondsalvage:
description: Allows ability to salvage Diamond tools & armor
mcmmo.ability.salvage.goldsalvage:
description: Allows ability to salvage Gold tools & armor
mcmmo.ability.salvage.ironsalvage:
description: Allows ability to salvage Iron tools & armor
mcmmo.ability.salvage.leathersalvage:
description: Allows ability to salvage Leather armor
mcmmo.ability.salvage.othermaterialsalvage:
description: Allows ability to salvage items of material type OTHER
mcmmo.ability.salvage.othersalvage:
description: Allows ability to salvage items of type OTHER
mcmmo.ability.salvage.stonesalvage:
description: Allows ability to salvage Stone tools
mcmmo.ability.salvage.stringsalvage:
description: Allows ability to salvage Bow and Fishing rod
mcmmo.ability.salvage.toolsalvage:
description: Allows ability to salvage tools
mcmmo.ability.salvage.woodsalvage:
description: Allows ability to salvage Wood tools
mcmmo.ability.smelting.*: mcmmo.ability.smelting.*:
default: false default: false
description: Allows access to all Smelting abilities description: Allows access to all Smelting abilities