Mirror von
https://github.com/St3venAU/ArmorStandTools.git
synchronisiert 2024-12-27 12:00:07 +01:00
Commit
8c88cc02ac
@ -1,18 +1,23 @@
|
||||
package com.gmail.St3venAU.plugins.ArmorStandTools;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
|
||||
class Config {
|
||||
|
||||
private static Main plugin;
|
||||
@ -37,6 +42,7 @@ class Config {
|
||||
static boolean requireCreative = false;
|
||||
static int defaultASCmdCooldownTicks = 0;
|
||||
static boolean ignoreWGForASCmdExecution = false;
|
||||
static List<String> commandsBlocked = new ArrayList<String>();
|
||||
|
||||
static String
|
||||
invReturned, asDropped, asVisible, isTrue, isFalse,
|
||||
@ -51,7 +57,7 @@ class Config {
|
||||
assignedCmdToAS, assignCmdError, ascmdHelp, viewCmd,
|
||||
removeCmd, assignConsole, assignPlayer, executeCmdError,
|
||||
cmdOnCooldown, cooldownRemovedFrom, isAnInvalidCooldown,
|
||||
cooldownSetTo, ticksFor, setCooldown, removeCooldown;
|
||||
cooldownSetTo, ticksFor, setCooldown, removeCooldown, commandBlocked;
|
||||
|
||||
static void reload(Main main) {
|
||||
plugin = main;
|
||||
@ -122,6 +128,7 @@ class Config {
|
||||
ticksFor = languageConfig.getString("ticksFor");
|
||||
setCooldown = languageConfig.getString("setCooldown");
|
||||
ticksFor = languageConfig.getString("ticksFor");
|
||||
commandBlocked = languageConfig.getString("commandBlocked");
|
||||
}
|
||||
|
||||
private static void reloadMainConfig() {
|
||||
@ -150,6 +157,20 @@ class Config {
|
||||
debug = config.getBoolean("debug", false);
|
||||
plugin.carryingArmorStand.clear();
|
||||
|
||||
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||
for (String blocked : config.getStringList("commandBlocked")) {
|
||||
for (Plugin plugin : plugin.getServer().getPluginManager().getPlugins()) {
|
||||
command: for (Command command : PluginCommandYamlParser.parse(plugin)) {
|
||||
if (command.getAliases().contains(blocked)) {
|
||||
commandsBlocked.addAll(command.getAliases());
|
||||
break command;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
commandsBlocked.add(blocked);
|
||||
}});
|
||||
|
||||
for(ArmorStandTool tool : ArmorStandTool.values()) {
|
||||
tool.setEnabled(config);
|
||||
}
|
||||
|
@ -52,6 +52,23 @@ public class MainListener implements Listener {
|
||||
this.plugin = main;
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onCommandProcess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (!plugin.carryingArmorStand.containsKey(player.getUniqueId()))
|
||||
return;
|
||||
|
||||
String command = event.getMessage().split(" ")[0].toLowerCase();
|
||||
for (String block : Config.commandsBlocked) {
|
||||
if (!command.contains(block))
|
||||
continue;
|
||||
|
||||
player.sendMessage(ChatColor.RED + Config.commandBlocked);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
|
||||
if(event.getRightClicked() instanceof ArmorStand) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Main Config
|
||||
#
|
||||
# File generated by: v3.4.0
|
||||
# File generated by: v3.5.0
|
||||
# (If this is not the version you are running, consider deleting this
|
||||
# config to allow it to be re-created. There may be new config options)
|
||||
#
|
||||
@ -20,6 +20,7 @@
|
||||
# - Player head tool: Set's an armor stand's head to the head of a specified player.
|
||||
# - Support for WorldGuard regions.
|
||||
# - User customizable language config.
|
||||
# - Block commands while player are using AST.
|
||||
#
|
||||
# Commands:
|
||||
# /astools Give yourself all of the armor stand tools (Note: Clears your inventory)
|
||||
@ -35,6 +36,7 @@
|
||||
#
|
||||
# Permissions:
|
||||
# astools.command Permission for the /astools command
|
||||
# astools.bypass Permission for the bypass blocked commands
|
||||
# astools.reload Permission to reload the plugin with /astools reload
|
||||
# astools.use Permission for using any of the tools (except the ones below that have their own separate permissions)
|
||||
# astools.clone Permission to use the clone tool (Clones an armor stand without requiring the materials)
|
||||
@ -107,4 +109,7 @@ enableTool:
|
||||
gui_slots: true
|
||||
gui_pHead: true
|
||||
gui_invul: true
|
||||
gui_move: true
|
||||
gui_move: true
|
||||
commandBlocked:
|
||||
- ehat
|
||||
- hat
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# Language Config
|
||||
#
|
||||
# File generated by: v3.4.0
|
||||
# File generated by: v3.5.0
|
||||
# (If this is not the version you are running, consider deleting this
|
||||
# config to allow it to be re-created. There may be new config options)
|
||||
#
|
||||
@ -89,6 +89,8 @@ cooldownSetTo: 'Cooldown set to'
|
||||
ticksFor: 'ticks for'
|
||||
setCooldown: 'Set the cooldown for the command'
|
||||
removeCooldown: 'Remove the cooldown for the command'
|
||||
# New since v3.4.0
|
||||
commandBlocked: 'You cannot use this command while you are using AST'
|
||||
#
|
||||
#############################
|
||||
# Tool names & descriptions #
|
||||
@ -254,4 +256,4 @@ tool:
|
||||
lore:
|
||||
gui_invul:
|
||||
name: 'Toggle Invulnerability'
|
||||
lore:
|
||||
lore:
|
||||
|
@ -1,7 +1,7 @@
|
||||
main: com.gmail.St3venAU.plugins.ArmorStandTools.Main
|
||||
name: ArmorStandTools
|
||||
version: 3.4.0
|
||||
api-version: 1.13
|
||||
version: 3.5.0
|
||||
api-version: 1.14
|
||||
author: St3venAU
|
||||
description: Armor stand manipulation tools
|
||||
softdepend: [WorldGuard, PlotSquared]
|
||||
@ -12,4 +12,4 @@ commands:
|
||||
usage: Usage /astools or /astools reload
|
||||
ascmd:
|
||||
description: View/Remove/Assign the command assigned to the nearest armor stand
|
||||
usage: Usage /ascmd view, /ascmd remove, /ascmd assign <player/console> <command>
|
||||
usage: Usage /ascmd view, /ascmd remove, /ascmd assign <player/console> <command>
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren