mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-24 00:15:16 +01:00
Restrictions Update
restrictions.yml has been fixed and now work as it should. 'required tool' message now displays even if a tool is not registered You can now use MMOItems in restrictions.yml, format = 'TYPE?ID' Requires MMOLib 1.3.3.1 (1.3.3 works too, but the 'parent' feature is broken in that case)
This commit is contained in:
parent
6807a5f8f3
commit
55035d2c60
@ -29,7 +29,7 @@ public class CustomBlockMineEvent extends PlayerDataEvent implements Cancellable
|
||||
|
||||
this.block = block;
|
||||
this.info = info;
|
||||
this.drops = (info.getDropTable().areConditionsMet(new ConditionInstance(player.getPlayer())))
|
||||
this.drops = (info.hasDropTable() && info.getDropTable().areConditionsMet(new ConditionInstance(player.getPlayer())))
|
||||
? info.collectDrops(new LootBuilder(player, 0)) : new ArrayList<>();
|
||||
this.experience = info.hasExperience() ? info.getExperience().newInfo() : null;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.Indyuce.mmocore.listener;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -62,13 +64,14 @@ public class BlockListener implements Listener {
|
||||
}
|
||||
|
||||
ItemStack item = player.getInventory().getItemInMainHand();
|
||||
BlockPermissions perms = MMOCore.plugin.restrictionManager.getPermissions(item);
|
||||
if (perms == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!perms.canMine(info.getBlock())) {
|
||||
Set<BlockPermissions> perms = MMOCore.plugin.restrictionManager.getPermissions(item);
|
||||
boolean check = false;
|
||||
for(BlockPermissions perm : perms)
|
||||
if(perm.canMine(info.getBlock())) {
|
||||
check = true;
|
||||
break;
|
||||
}
|
||||
if (!check) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("cannot-break").send(player);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
@ -48,10 +48,11 @@ public class RestrictionManager {
|
||||
// return breakBlackList.contains(s);
|
||||
// }
|
||||
|
||||
public BlockPermissions getPermissions(ItemStack item) {
|
||||
public Set<BlockPermissions> getPermissions(ItemStack item) {
|
||||
Set<BlockPermissions> set = new HashSet<>();
|
||||
for(ItemType type : map.keySet())
|
||||
if(type.matches(item)) map.get(type);
|
||||
return null;
|
||||
if(type.matches(item)) set.add(map.get(type));
|
||||
return set;
|
||||
}
|
||||
|
||||
public class BlockPermissions extends PostLoadObject {
|
||||
@ -59,7 +60,7 @@ public class RestrictionManager {
|
||||
private final ItemType tool;
|
||||
|
||||
private BlockPermissions parent;
|
||||
|
||||
|
||||
public BlockPermissions(ConfigurationSection config) {
|
||||
super(config);
|
||||
|
||||
@ -69,7 +70,7 @@ public class RestrictionManager {
|
||||
@Override
|
||||
protected void whenPostLoaded(ConfigurationSection config) {
|
||||
if (config.contains("parent"))
|
||||
parent = map.get(ItemType.fromString(config.getString("parent", "None")));
|
||||
parent = map.get(ItemType.fromString(config.getString("parent")));
|
||||
for (String key : config.getStringList("can-mine"))
|
||||
mineable.add(MMOCore.plugin.loadManager.loadBlockType(new MMOLineConfig(key)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user