mirror of
https://github.com/SimplexDevelopment/ToolAssist.git
synced 2025-07-04 19:36:41 +00:00
Compare commits
4 Commits
Alpha-1.0-
...
Alpha-1.0-
Author | SHA1 | Date | |
---|---|---|---|
813b710220 | |||
805f765434 | |||
f1989e1bbe | |||
086a310479 |
82
build/resources/main/config.yml
Normal file
82
build/resources/main/config.yml
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
# The overall settings for the plugin itself
|
||||||
|
plugin_settings:
|
||||||
|
|
||||||
|
# The permission required to use the assist feature.
|
||||||
|
permission: "toolassist.activate"
|
||||||
|
|
||||||
|
# How many blocks outwards should be scanned
|
||||||
|
search_radius: 15
|
||||||
|
|
||||||
|
# Whether a user must be sneaking to activate
|
||||||
|
sneak_activation: true
|
||||||
|
|
||||||
|
# Whether to use the respective tool to trigger activation, or to use the groupings listed below.
|
||||||
|
no_config: false
|
||||||
|
|
||||||
|
# The block material that can be targeted by the respective tool grouping
|
||||||
|
tool_settings:
|
||||||
|
|
||||||
|
# Blocks which are affected by pickaxes
|
||||||
|
pickaxe:
|
||||||
|
- COAL_ORE
|
||||||
|
- COPPER_ORE
|
||||||
|
- IRON_ORE
|
||||||
|
- GOLD_ORE
|
||||||
|
- REDSTONE_ORE
|
||||||
|
- LAPIS_LAZULI_ORE
|
||||||
|
- EMERALD_ORE
|
||||||
|
- DIAMOND_ORE
|
||||||
|
- DEEPSLATE_COAL_ORE
|
||||||
|
- DEEPSLATE_IRON_ORE
|
||||||
|
- DEEPSLATE_GOLD_ORE
|
||||||
|
- DEEPSLATE_REDSTONE_ORE
|
||||||
|
- DEEPSLATE_LAPIS_ORE
|
||||||
|
- DEEPSLATE_EMERALD_ORE
|
||||||
|
- DEEPSLATE_DIAMOND_ORE
|
||||||
|
- DEEPSLATE_COPPER_ORE
|
||||||
|
- NETHER_QUARTZ_ORE
|
||||||
|
- NETHER_GOLD_ORE
|
||||||
|
|
||||||
|
# Blocks which are affected by axes
|
||||||
|
axe:
|
||||||
|
- OAK_LOG
|
||||||
|
- DARK_OAK_LOG
|
||||||
|
- BIRCH_LOG
|
||||||
|
- SPRUCE_LOG
|
||||||
|
- JUNGLE_LOG
|
||||||
|
- ACACIA_LOG
|
||||||
|
- STRIPPED_OAK_LOG
|
||||||
|
- STRIPPED_DARK_OAK_LOG
|
||||||
|
- STRIPPED_BIRCH_LOG
|
||||||
|
- STRIPPED_SPRUCE_LOG
|
||||||
|
- STRIPPED_JUNGLE_LOG
|
||||||
|
- STRIPPED_ACACIA_LOG
|
||||||
|
|
||||||
|
# Blocks which are affected by shovels
|
||||||
|
shovel:
|
||||||
|
- SAND
|
||||||
|
- GRAVEL
|
||||||
|
|
||||||
|
# Blocks which are affected by hoes
|
||||||
|
hoe:
|
||||||
|
- WARPED_WART_BLOCK
|
||||||
|
- NETHER_WART_BLOCK
|
||||||
|
- SPONGE
|
||||||
|
- WET_SPONGE
|
||||||
|
|
||||||
|
# Blocks which are affected by swords
|
||||||
|
sword:
|
||||||
|
- COBWEB
|
||||||
|
|
||||||
|
# Blocks which are affected by shears
|
||||||
|
shears:
|
||||||
|
- OAK_LEAVES
|
||||||
|
- DARK_OAK_LEAVES
|
||||||
|
- BIRCH_LEAVES
|
||||||
|
- JUNGLE_LEAVES
|
||||||
|
- ACACIA_LEAVES
|
||||||
|
- SPRUCE_LEAVES
|
||||||
|
- VINE
|
||||||
|
- CAVE_VINES_PLANT
|
||||||
|
- WEEPING_VINES_PLANT
|
||||||
|
- TWISTING_VINES_PLANT
|
6
build/resources/main/plugin.yml
Normal file
6
build/resources/main/plugin.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
name: ToolAssist
|
||||||
|
version: 'v1.0-Alpha'
|
||||||
|
main: io.github.simplex.toolassist.ToolAssist
|
||||||
|
api-version: 1.18
|
||||||
|
authors: [ SimplexDevelopment ]
|
||||||
|
description: A lightweight vein-mining plugin.
|
BIN
build/tmp/compileJava/previous-compilation-data.bin
Normal file
BIN
build/tmp/compileJava/previous-compilation-data.bin
Normal file
Binary file not shown.
2
build/tmp/jar/MANIFEST.MF
Normal file
2
build/tmp/jar/MANIFEST.MF
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
Manifest-Version: 1.0
|
||||||
|
|
@ -1,28 +1,37 @@
|
|||||||
package io.github.simplex.toolassist;
|
package io.github.simplex.toolassist;
|
||||||
|
|
||||||
import io.github.simplex.toolassist.data.Config;
|
import io.github.simplex.toolassist.data.Config;
|
||||||
|
import io.github.simplex.toolassist.play.Command_toolassist;
|
||||||
|
import io.github.simplex.toolassist.play.MineListener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public final class ToolAssist extends JavaPlugin {
|
public final class ToolAssist extends JavaPlugin {
|
||||||
|
|
||||||
private Config config;
|
private Config config;
|
||||||
|
private Command_toolassist command;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Plugin startup logic
|
// Plugin startup logic
|
||||||
getLogger().info("Initializing configuration...");
|
getLogger().info("Initializing configuration...");
|
||||||
this.config = new Config(this);
|
config = new Config(this);
|
||||||
getLogger().info("Initialization complete! Registering listener...");
|
getLogger().info("Configuration loaded! Registering listener...");
|
||||||
new MineListener(this);
|
new MineListener(this);
|
||||||
|
getLogger().info("Listener registered successfully! Loading command...");
|
||||||
|
command = new Command_toolassist(this);
|
||||||
getLogger().info("Initialization complete!");
|
getLogger().info("Initialization complete!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
this.config.osave();
|
getLogger().info("Saving configuration...");
|
||||||
this.config = null;
|
config.osave();
|
||||||
getLogger().info("Goodbye!");
|
config = null;
|
||||||
|
getLogger().info("Configuration saved successfully. Unregistering the command...");
|
||||||
|
command.unregister();
|
||||||
|
command = null;
|
||||||
|
getLogger().info("Termination complete. Goodbye!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -2,6 +2,8 @@ package io.github.simplex.toolassist.data;
|
|||||||
|
|
||||||
import io.github.simplex.toolassist.ToolAssist;
|
import io.github.simplex.toolassist.ToolAssist;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -9,7 +11,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockIdentifier {
|
public class BlockIdentifier {
|
||||||
private final List<Block> blockList = new ArrayList<>();
|
|
||||||
private final ToolAssist plugin;
|
private final ToolAssist plugin;
|
||||||
boolean isValid = false;
|
boolean isValid = false;
|
||||||
|
|
||||||
@ -18,9 +19,9 @@ public class BlockIdentifier {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public List<Block> populateAndRetrieve(Block block, ItemStack requiredItem) {
|
public List<Block> populateAndRetrieve(Block block, ItemStack requiredItem) {
|
||||||
|
List<Block> surroundingBlocks = new ArrayList<>();
|
||||||
Location start = block.getLocation().clone();
|
Location start = block.getLocation().clone();
|
||||||
int radius = plugin.getConfig().getSettings().radius();
|
int radius = plugin.getConfig().getSettings().radius();
|
||||||
List<Block> surroundingBlocks = new ArrayList<>();
|
|
||||||
for (double x = start.getX() - radius; x <= start.getX() + radius; x++) {
|
for (double x = start.getX() - radius; x <= start.getX() + radius; x++) {
|
||||||
for (double y = start.getY() - radius; y <= start.getY() + radius; y++) {
|
for (double y = start.getY() - radius; y <= start.getY() + radius; y++) {
|
||||||
for (double z = start.getZ() - radius; z <= start.getZ() + radius; z++) {
|
for (double z = start.getZ() - radius; z <= start.getZ() + radius; z++) {
|
||||||
@ -31,14 +32,12 @@ public class BlockIdentifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
blockList.addAll(surroundingBlocks);
|
return surroundingBlocks;
|
||||||
|
|
||||||
return blockList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkBlock(Block block, ItemStack targetItem) {
|
public boolean checkBlock(Block block, ItemStack targetItem) {
|
||||||
if (plugin.getConfig().getSettings().noConfig()) {
|
if (plugin.getConfig().getSettings().noConfig()) {
|
||||||
return block.isValidTool(targetItem);
|
return block.isValidTool(targetItem) && all.stream().anyMatch(a -> a.isTagged(block.getType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
checkBlockConfig(block, targetItem);
|
checkBlockConfig(block, targetItem);
|
||||||
@ -74,4 +73,20 @@ public class BlockIdentifier {
|
|||||||
}
|
}
|
||||||
isValid = false;
|
isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Tag<Material>> all = List.of(Tag.COAL_ORES,
|
||||||
|
Tag.COPPER_ORES,
|
||||||
|
Tag.GOLD_ORES,
|
||||||
|
Tag.IRON_ORES,
|
||||||
|
Tag.DIAMOND_ORES,
|
||||||
|
Tag.LAPIS_ORES,
|
||||||
|
Tag.EMERALD_ORES,
|
||||||
|
Tag.REDSTONE_ORES,
|
||||||
|
Tag.SAND,
|
||||||
|
Tag.CAVE_VINES,
|
||||||
|
Tag.WART_BLOCKS,
|
||||||
|
Tag.LOGS,
|
||||||
|
Tag.LOGS_THAT_BURN,
|
||||||
|
Tag.LEAVES,
|
||||||
|
Tag.WARPED_STEMS);
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,9 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.io.IOException;
|
||||||
import java.util.Optional;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -20,45 +20,17 @@ public class Config extends YamlConfiguration {
|
|||||||
|
|
||||||
public Config(ToolAssist plugin) {
|
public Config(ToolAssist plugin) {
|
||||||
this.settings = new Settings(this);
|
this.settings = new Settings(this);
|
||||||
|
|
||||||
String fileName = "config.yml";
|
String fileName = "config.yml";
|
||||||
|
|
||||||
File dataFolder = plugin.getDataFolder();
|
File dataFolder = plugin.getDataFolder();
|
||||||
|
|
||||||
if (!dataFolder.exists()) dataFolder.mkdirs();
|
if (!dataFolder.exists()) dataFolder.mkdirs();
|
||||||
|
|
||||||
cf = new File(dataFolder, fileName);
|
cf = new File(dataFolder, fileName);
|
||||||
|
try {
|
||||||
InputStream stream = plugin.getResource(fileName);
|
if (cf.createNewFile()) {
|
||||||
assert stream != null;
|
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8))) {
|
|
||||||
if (!cf.exists()) {
|
|
||||||
cf.createNewFile();
|
|
||||||
plugin.saveResource(fileName, true);
|
plugin.saveResource(fileName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
oload();
|
|
||||||
|
|
||||||
reader.lines().filter(s -> s.contains(":"))
|
|
||||||
.map(s -> s.split(":")[0])
|
|
||||||
.filter(s -> !super.getValues(true).containsKey(s))
|
|
||||||
.forEach(s -> {
|
|
||||||
plugin.getLogger().severe("Configuration is missing an entry, attempting to replace...");
|
|
||||||
Optional<String> stringStream = reader.lines().filter(c -> c.contains(s)).findFirst();
|
|
||||||
if (stringStream.isEmpty())
|
|
||||||
throw new RuntimeException("Unable to fix your configuration file. Please delete the config.yml in the data folder and restart your server.");
|
|
||||||
String key = stringStream.get().split(":")[0].trim();
|
|
||||||
String value = stringStream.get().split(":")[1].trim();
|
|
||||||
super.addDefault(key, value);
|
|
||||||
osave();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
plugin.getLogger().severe(ex.getMessage());
|
plugin.getLogger().severe(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
oload();
|
oload();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,8 +57,10 @@ public class Config extends YamlConfiguration {
|
|||||||
public static class Settings {
|
public static class Settings {
|
||||||
private final ConfigurationSection plugin_settings;
|
private final ConfigurationSection plugin_settings;
|
||||||
private final ConfigurationSection tool_settings;
|
private final ConfigurationSection tool_settings;
|
||||||
|
private final Config config;
|
||||||
|
|
||||||
public Settings(Config config) {
|
public Settings(Config config) {
|
||||||
|
this.config = config;
|
||||||
this.plugin_settings = config.getConfigurationSection("plugin_settings");
|
this.plugin_settings = config.getConfigurationSection("plugin_settings");
|
||||||
this.tool_settings = config.getConfigurationSection("tool_settings");
|
this.tool_settings = config.getConfigurationSection("tool_settings");
|
||||||
}
|
}
|
||||||
@ -148,5 +122,28 @@ public class Config extends YamlConfiguration {
|
|||||||
.map(Material::matchMaterial)
|
.map(Material::matchMaterial)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void modifyToolEntry(String name, String value, boolean addOrRemove) {
|
||||||
|
List<String> materialList = tool_settings.getStringList(name);
|
||||||
|
|
||||||
|
// This is to use a tertiary statement instead of an if-else.
|
||||||
|
// The respective method will be called and then the result will be set to the ignored boolean, which can be safely ignored.
|
||||||
|
boolean ignored = addOrRemove ? materialList.add(value) : materialList.remove(value);
|
||||||
|
|
||||||
|
tool_settings.set(name, materialList);
|
||||||
|
config.osave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void removeToolEntry(String name, String value) {
|
||||||
|
List<String> materialList = tool_settings.getStringList(name);
|
||||||
|
materialList.remove(value);
|
||||||
|
tool_settings.set(name, materialList);
|
||||||
|
config.osave();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void setPluginEntry(String name, Object value) {
|
||||||
|
plugin_settings.set(name, value);
|
||||||
|
config.osave();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,138 @@
|
|||||||
|
package io.github.simplex.toolassist.play;
|
||||||
|
|
||||||
|
import io.github.simplex.toolassist.ToolAssist;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.PluginIdentifiableCommand;
|
||||||
|
import org.bukkit.command.TabCompleter;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class Command_toolassist extends Command implements PluginIdentifiableCommand, TabCompleter {
|
||||||
|
private final ToolAssist plugin;
|
||||||
|
|
||||||
|
public Command_toolassist(ToolAssist plugin) {
|
||||||
|
super("toolassist");
|
||||||
|
super.setLabel("toolassist");
|
||||||
|
super.setPermission("toolassist.admin");
|
||||||
|
super.setDescription("A way to modify the configuration in game.");
|
||||||
|
super.setUsage("/toolassist <plugin | (tool <add | remove>)> <setting> <value>");
|
||||||
|
super.setAliases(List.of("ta", "miner", "assist", "vm"));
|
||||||
|
super.permissionMessage(Component.empty().content("You must have the toolassist.admin permission to use this command.")
|
||||||
|
.color(TextColor.color(ChatColor.RED.asBungee().getColor().getRGB())));
|
||||||
|
super.register(plugin.getServer().getCommandMap());
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
|
||||||
|
if (args[0].equalsIgnoreCase("plugin")) {
|
||||||
|
if (args.length != 3) return false;
|
||||||
|
|
||||||
|
switch (args[1]) {
|
||||||
|
case "radius" -> {
|
||||||
|
plugin.getConfig().getSettings().setPluginEntry("search_radius", args[2]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "sneak" -> {
|
||||||
|
plugin.getConfig().getSettings().setPluginEntry("sneak_activation", args[2]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "use_config" -> {
|
||||||
|
plugin.getConfig().getSettings().setPluginEntry("no_config", args[2]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "permission" -> {
|
||||||
|
plugin.getConfig().getSettings().setPluginEntry("permission", args[2]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("tools")) {
|
||||||
|
if (args.length != 4) return false;
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("add")) {
|
||||||
|
switch (args[2]) {
|
||||||
|
case "pickaxe", "axe", "sword", "shears", "shovel", "hoe" -> {
|
||||||
|
plugin.getConfig().getSettings().modifyToolEntry(args[2], args[3], true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[1].equalsIgnoreCase("remove")) {
|
||||||
|
switch (args[2]) {
|
||||||
|
case "pickaxe", "axe", "sword", "shears", "shovel", "hoe" -> {
|
||||||
|
plugin.getConfig().getSettings().modifyToolEntry(args[2], args[3], false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default -> {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NotNull ToolAssist getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
|
||||||
|
List<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 1 -> {
|
||||||
|
completions = List.of("tools", "plugin");
|
||||||
|
}
|
||||||
|
case 2 -> {
|
||||||
|
if (args[0].equalsIgnoreCase("tools")) {
|
||||||
|
completions = List.of("add", "remove");
|
||||||
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("plugin")) {
|
||||||
|
completions = List.of("permission", "radius", "sneak", "use_config");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 3 -> {
|
||||||
|
if (args[0].equalsIgnoreCase("tools")) {
|
||||||
|
if (args[1].equalsIgnoreCase("add") || args[1].equalsIgnoreCase("remove")) {
|
||||||
|
completions = Stream.of("pickaxe", "axe", "sword", "shears", "shovel", "hoe").sorted().toList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("plugin")) {
|
||||||
|
if (args[1].equalsIgnoreCase("use_config") || args[1].equalsIgnoreCase("sneak")) {
|
||||||
|
completions = List.of("true", "false");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return completions.stream().filter(p -> p.startsWith(args[args.length - 1])).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unregister() {
|
||||||
|
unregister(plugin.getServer().getCommandMap());
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package io.github.simplex.toolassist;
|
package io.github.simplex.toolassist.play;
|
||||||
|
|
||||||
|
import io.github.simplex.toolassist.ToolAssist;
|
||||||
import io.github.simplex.toolassist.data.BlockIdentifier;
|
import io.github.simplex.toolassist.data.BlockIdentifier;
|
||||||
import io.github.simplex.toolassist.data.Config;
|
import io.github.simplex.toolassist.data.Config;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -24,15 +25,15 @@ public class MineListener implements Listener {
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void activate(BlockBreakEvent event) {
|
public void activate(BlockBreakEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
ItemStack stack = player.getInventory().getItemInMainHand();
|
|
||||||
Block block = event.getBlock();
|
|
||||||
String permission = settings.permission();
|
String permission = settings.permission();
|
||||||
List<Block> blocks = identifier.populateAndRetrieve(block, stack);
|
|
||||||
|
|
||||||
if (!player.hasPermission(permission)) return;
|
if (!player.hasPermission(permission)) return;
|
||||||
|
|
||||||
if (!player.isSneaking() && settings.useSneak()) return;
|
if (!player.isSneaking() && settings.useSneak()) return;
|
||||||
|
|
||||||
|
ItemStack stack = player.getInventory().getItemInMainHand();
|
||||||
|
Block block = event.getBlock();
|
||||||
|
List<Block> blocks = identifier.populateAndRetrieve(block, stack);
|
||||||
|
|
||||||
blocks.forEach(Block::breakNaturally);
|
blocks.forEach(Block::breakNaturally);
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user