Made soft touch

This commit is contained in:
Auxilor 2021-08-09 00:29:01 +01:00
parent 62b7df59c4
commit 3c1d7f88d6
6 changed files with 117 additions and 0 deletions

View File

@ -0,0 +1,7 @@
group 'com.willfp'
version '1.0.0'
description = 'Soft Touch Extension'
shadowJar {
archiveFileName = project.getDescription() + " v" + project.version + ".jar"
}

View File

@ -0,0 +1,51 @@
package com.willfp.ecoenchants.softtouch;
import com.willfp.eco.core.drops.DropQueue;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.jetbrains.annotations.NotNull;
public class SoftTouch extends EcoEnchant {
public SoftTouch() {
super("soft_touch", EnchantmentType.NORMAL);
}
@Override
public void onBlockBreak(@NotNull final Player player,
@NotNull final Block block,
final int level,
@NotNull final BlockBreakEvent event) {
if (!EnchantmentUtils.passedChance(this, level)) {
return;
}
if (!(block.getState() instanceof CreatureSpawner spawner)) {
return;
}
EntityType type = spawner.getSpawnedType();
event.setDropItems(false);
event.setExpToDrop(0);
ItemStack itemStack = new ItemStack(Material.SPAWNER);
BlockStateMeta meta = (BlockStateMeta) itemStack.getItemMeta();
assert meta != null;
meta.setBlockState(spawner);
itemStack.setItemMeta(meta);
new DropQueue(player)
.addItem(itemStack)
.push();
}
}

View File

@ -0,0 +1,24 @@
package com.willfp.ecoenchants.softtouch;
import com.willfp.eco.core.EcoPlugin;
import com.willfp.eco.core.extensions.Extension;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import org.jetbrains.annotations.NotNull;
public class SoftTouchMain extends Extension {
public static final EcoEnchant SOFT_TOUCH = new SoftTouch();
public SoftTouchMain(@NotNull final EcoPlugin plugin) {
super(plugin);
}
@Override
public void onEnable() {
// Handled by super
}
@Override
public void onDisable() {
// Handled by super
}
}

View File

@ -0,0 +1,30 @@
#
# Soft Touch EcoEnchant
#
name: "Soft Touch"
description: '&a%value%%&r chance to drop a spawner when you mine it.'
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: legendary
general-config:
targets:
- pickaxe
grindstoneable: true
disabled-in-worlds: [ ]
conflicts:
- silk_touch
maximum-level: 5
config:
chance-per-level: 10
spawner-name:
- "&a%type%&f Spawner"
spawner-lore:
- "&a%type%&f Spawner"
- "&fCan be placed anywhere in the world"

View File

@ -0,0 +1,4 @@
name: Soft Touch
main: com.willfp.ecoenchants.softtouch.SoftTouchMain
version: ${projectVersion}
author: Auxilor

View File

@ -22,6 +22,7 @@ include ':eco-extensions:intimidation'
include ':eco-extensions:precision' include ':eco-extensions:precision'
include ':eco-extensions:rainbow' include ':eco-extensions:rainbow'
include ':eco-extensions:sprint-artifacts' include ':eco-extensions:sprint-artifacts'
include ':eco-extensions:softtouch'
include ':eco-extensions:summoning' include ':eco-extensions:summoning'
include ':eco-extensions:transmission' include ':eco-extensions:transmission'
include ':eco-extensions:xray' include ':eco-extensions:xray'