mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-02-05 11:51:26 +01:00
Fixed Custom Mining priorities.
This commit is contained in:
parent
783782f44f
commit
5c608b8439
@ -37,7 +37,22 @@ public class BlockListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
boolean customMine = MMOCore.plugin.mineManager.isEnabled(player);
|
boolean customMine = MMOCore.plugin.mineManager.isEnabled(player);
|
||||||
ItemStack item = player.getInventory().getItemInMainHand();
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
|
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block.getType());
|
||||||
|
if (info == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (customMine) {
|
if (customMine) {
|
||||||
|
/*
|
||||||
|
* calls the event and listen for cancel & for drops changes... also
|
||||||
|
* allows to apply tool durability & enchants to drops, etc.
|
||||||
|
*/
|
||||||
|
CustomBlockMineEvent called = new CustomBlockMineEvent(PlayerData.get(player), block, info);
|
||||||
|
Bukkit.getPluginManager().callEvent(called);
|
||||||
|
if (called.isCancelled()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
BlockPermissions perms = MMOCore.plugin.restrictionManager.getPermissions(item.getType());
|
BlockPermissions perms = MMOCore.plugin.restrictionManager.getPermissions(item.getType());
|
||||||
if (perms == null) {
|
if (perms == null) {
|
||||||
@ -50,53 +65,39 @@ public class BlockListener implements Listener {
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
BlockInfo info = MMOCore.plugin.mineManager.getInfo(block.getType());
|
|
||||||
if (info == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* calls the event and listen for cancel & for drops changes... also
|
* remove vanilla drops if needed
|
||||||
* allows to apply tool durability & enchants to drops, etc.
|
*/
|
||||||
*/
|
if (!info.hasVanillaDrops()) {
|
||||||
CustomBlockMineEvent called = new CustomBlockMineEvent(PlayerData.get(player), block, info);
|
event.setCancelled(true);
|
||||||
Bukkit.getPluginManager().callEvent(called);
|
event.getBlock().setType(Material.AIR);
|
||||||
if (called.isCancelled()) {
|
}
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* remove vanilla drops if needed
|
* apply triggers, add experience info to the event so the other events
|
||||||
*/
|
* can give exp to other TOOLS and display HOLOGRAMS
|
||||||
if (!info.hasVanillaDrops()) {
|
*/
|
||||||
event.setCancelled(true);
|
if (info.hasTriggers()) {
|
||||||
event.getBlock().setType(Material.AIR);
|
PlayerData playerData = PlayerData.get(player);
|
||||||
}
|
info.getTriggers().forEach(trigger -> {
|
||||||
|
if(!block.hasMetadata("player_placed") && trigger instanceof ExperienceTrigger)
|
||||||
|
trigger.apply(playerData);
|
||||||
|
});
|
||||||
|
if(!block.hasMetadata("player_placed") && info.hasExperience() && MMOCore.plugin.hasHolograms())
|
||||||
|
MMOCore.plugin.hologramSupport.displayIndicator(block.getLocation().add(.5, .5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + called.getGainedExperience().getValue()), player);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* apply triggers, add experience info to the event so the other events
|
* apply drop tables
|
||||||
* can give exp to other TOOLS and display HOLOGRAMS
|
*/
|
||||||
*/
|
if (info.hasDropTable()) {
|
||||||
if (info.hasTriggers()) {
|
Location dropLocation = getSafeDropLocation(block, !info.hasDropTable());
|
||||||
PlayerData playerData = PlayerData.get(player);
|
for (ItemStack drop : called.getDrops())
|
||||||
info.getTriggers().forEach(trigger -> {
|
if (drop.getType() != Material.AIR && drop.getAmount() > 0)
|
||||||
if(!block.hasMetadata("player_placed") && trigger instanceof ExperienceTrigger)
|
block.getWorld().dropItemNaturally(dropLocation, drop);
|
||||||
trigger.apply(playerData);
|
}
|
||||||
});
|
|
||||||
if(!block.hasMetadata("player_placed") && info.hasExperience() && MMOCore.plugin.hasHolograms())
|
|
||||||
MMOCore.plugin.hologramSupport.displayIndicator(block.getLocation().add(.5, .5, .5), MMOCore.plugin.configManager.getSimpleMessage("exp-hologram", "exp", "" + called.getGainedExperience().getValue()), player);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* apply drop tables
|
|
||||||
*/
|
|
||||||
if (info.hasDropTable()) {
|
|
||||||
Location dropLocation = getSafeDropLocation(block, !info.hasDropTable());
|
|
||||||
for (ItemStack drop : called.getDrops())
|
|
||||||
if (drop.getType() != Material.AIR && drop.getAmount() > 0)
|
|
||||||
block.getWorld().dropItemNaturally(dropLocation, drop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user