Skip to content

Commit

Permalink
Implement timbru31#82
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuarezl committed Jan 31, 2019
1 parent 33f4038 commit b216b99
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.HashMap;
import java.util.Random;
import java.util.stream.Collectors;

import org.bukkit.ChatColor;
import org.bukkit.GameMode;
Expand All @@ -15,6 +16,7 @@
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.permissions.PermissionAttachmentInfo;

import de.dustplanet.silkspawners.SilkSpawners;
import de.dustplanet.silkspawners.events.SilkSpawnersSpawnerBreakEvent;
Expand Down Expand Up @@ -115,7 +117,23 @@ public void onBlockBreak(BlockBreakEvent event) {
if (plugin.mobs.contains("creatures." + entityID + ".silkDropChance")) {
dropChance = plugin.mobs.getInt("creatures." + entityID + ".silkDropChance", 100);
} else {
dropChance = plugin.config.getInt("silkDropChance", 100);
for (String perm : player.getEffectivePermissions().stream().map(PermissionAttachmentInfo::getPermission).collect(Collectors.toList())) {
if (perm.startsWith("silkspawners.dropchance.")) {
try {
dropChance = Integer.parseInt(perm.split("silkspawners.dropchance.")[1]);
if (dropChance > 0) {
break;
}
} catch (NumberFormatException ignore) {
}
}
}
if (dropChance > 100) {
dropChance = 100;
}
if (dropChance <= 0) {
dropChance = plugin.config.getInt("silkDropChance", 100);
}
}

if (randomNumber < dropChance) {
Expand Down

0 comments on commit b216b99

Please sign in to comment.