3
0
Mirror von https://github.com/St3venAU/ArmorStandTools.git synchronisiert 2024-12-26 03:20:07 +01:00
Dieser Commit ist enthalten in:
Steven 2021-07-18 19:07:23 +08:00
Ursprung 1e7a868862
Commit 0023ddedd1
14 geänderte Dateien mit 134 neuen und 58 gelöschten Zeilen

Datei anzeigen

@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2019 St3venAU
Copyright (c) 2021 St3venAU
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

Datei anzeigen

@ -57,7 +57,8 @@ WorldGuard Integration
Permissions
-----------
- astools.use : Permission for using any of the tools, except for those that have a custom permission below
- astools.use: Permission for using any of the tools, except for those that have a custom permission below
- astools.new: Permission to use "/astools new" command to summon a new armor stand
- astools.clone: Permission to use the clone tool
- astools.head: Permission to use the player head tool (Ability to specify a player head for an armor stand)
- astools.summon: Permission to use the summon tool (Summons an armor stand without requiring the materials)
@ -66,6 +67,7 @@ Permissions
- astools.ascmd.assign.player: Permission to assign a player command to an armor stand
- astools.ascmd.remove: Permission to remove a command from an armor stand
- astools.ascmd.view: Permission to view the command assigned to an armor stand
- astools.ascmd.cooldown: Permission to add a cooldown to commands assigned to an armor stand
- astools.ascmd.execute: Permission to execute a command assigned to an armor stand by (on right click)
- astools.bypass-wg-flag: Permission to bypass the WorldGuard ast flag, allowing the player to use AST even in regions that ast flag is set to deny.

Datei anzeigen

@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.St3venAU.plugins</groupId>
<artifactId>ArmorStandTools</artifactId>
<version>4.0.1</version>
<version>4.0.2</version>
<name>ArmorStandTools</name>
<repositories>

Datei anzeigen

@ -172,9 +172,7 @@ public class AST extends JavaPlugin {
static boolean checkBlockPermission(Player p, Block b) {
if(b == null) return true;
if (PlotSquaredHook.api != null) {
debug("PlotSquaredHook.api: " + PlotSquaredHook.api);
Location l = b.getLocation();
debug("PlotSquaredHook.isPlotWorld(l): " + PlotSquaredHook.isPlotWorld(l));
if(PlotSquaredHook.isPlotWorld(l)) {
Boolean hasPermission = PlotSquaredHook.checkPermission(p, l);
if(hasPermission != null) {
@ -205,17 +203,18 @@ public class AST extends JavaPlugin {
}
static boolean playerHasPermission(Player p, Block b, ArmorStandTool tool) {
debug("tool: " + tool);
if(tool != null) {
debug("en: " + tool.isEnabled());
debug("perm: " + Utils.hasPermissionNode(p, tool.getPermission()));
String permNode = tool == null ? "astools.use" : tool.getPermission();
boolean enabled = tool == null || tool.isEnabled();
boolean hasNode = Utils.hasPermissionNode(p, permNode);
boolean blockPerm = checkBlockPermission(p, b);
if(Config.debug) {
AST.debug("Plr: " + p.getName() + ", Tool: " + tool + ", Tool En: " + enabled + ", Perm: " + permNode + ", Has Perm: " + hasNode + ", Location Perm: " + blockPerm);
}
String permission = tool == null ? "astools.use" : tool.getPermission();
return (tool == null || tool.isEnabled()) && Utils.hasPermissionNode(p, permission) && checkBlockPermission(p, b);
return enabled && hasNode && blockPerm;
}
static void debug(String msg) {
if(!Config.debug) return;
Bukkit.getLogger().log(Level.INFO, "[DEBUG] " + msg);
Bukkit.getLogger().log(Level.INFO, "[AST DEBUG] " + msg);
}
}

Datei anzeigen

@ -3,6 +3,7 @@ package com.gmail.st3venau.plugins.armorstandtools;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
@ -24,12 +25,12 @@ import java.util.UUID;
class ArmorStandGUI implements Listener {
private static final int INV_SLOT_HELMET = 2;
private static final int INV_SLOT_CHEST = 11;
private static final int INV_SLOT_PANTS = 20;
private static final int INV_SLOT_BOOTS = 29;
private static final int INV_SLOT_R_HAND = 10;
private static final int INV_SLOT_L_HAND = 12;
private static final int INV_SLOT_HELMET = 1;
private static final int INV_SLOT_CHEST = 10;
private static final int INV_SLOT_PANTS = 19;
private static final int INV_SLOT_BOOTS = 28;
private static final int INV_SLOT_R_HAND = 9;
private static final int INV_SLOT_L_HAND = 11;
private static final HashSet<Integer> inUse = new HashSet<>();
private static final HashSet<Integer> invSlots = new HashSet<>();
@ -106,10 +107,12 @@ class ArmorStandGUI implements Listener {
event.setCancelled(true);
return;
}
boolean rightClick = event.getClick() == ClickType.RIGHT;
int slot = event.getRawSlot();
if(slot > i.getSize()) return;
Location l = as.getLocation();
if(invSlots.contains(slot)) {
if(AST.checkBlockPermission(p, as.getLocation().getBlock())) {
if(AST.checkBlockPermission(p, l.getBlock())) {
updateArmorStandInventory();
} else {
event.setCancelled(true);
@ -121,7 +124,7 @@ class ArmorStandGUI implements Listener {
if(!(event.getWhoClicked() instanceof Player)) return;
ArmorStandTool t = ArmorStandTool.get(event.getCurrentItem());
if(t == null) return;
if (!AST.playerHasPermission(p, as.getLocation().getBlock(), t)) {
if (!AST.playerHasPermission(p, l.getBlock(), t)) {
p.sendMessage(ChatColor.RED + Config.generalNoPerm);
return;
}
@ -193,6 +196,23 @@ class ArmorStandGUI implements Listener {
AST.pickUpArmorStand(as, p);
Utils.title(p, Config.carrying);
break;
case UP:
case DOWN:
double dist = (t == ArmorStandTool.UP ? 1 : -1) * (rightClick ? 1 : 0.1);
l.add(0, dist,0);
if (!AST.playerHasPermission(p, l.getBlock(), null)) {
p.closeInventory();
p.sendMessage(ChatColor.RED + Config.wgNoPerm);
break;
}
as.setGravity(false);
as.teleport(l);
break;
case ROTATE:
float yaw = l.getYaw() + (rightClick ? -5 : 5);
l.setYaw(yaw);
as.teleport(l);
break;
case GLOW:
boolean glowing = !as.isGlowing();
as.setGlowing(glowing);

Datei anzeigen

@ -16,25 +16,30 @@ import java.util.UUID;
public enum ArmorStandTool {
HEAD ("gui_head", Material.PLAYER_HEAD, 6, "astools.use", false),
BODY ("gui_body", Material.NETHER_BRICKS, 15, "astools.use", false),
RARM ("gui_rarm", Material.REDSTONE_TORCH, 14, "astools.use", true),
LARM ("gui_larm", Material.TORCH, 16, "astools.use", true),
RLEG ("gui_rleg", Material.BLAZE_ROD, 23, "astools.use", true),
LLEG ("gui_lleg", Material.BONE, 25, "astools.use", true),
MOVE ("gui_move", Material.FEATHER, 24, "astools.use", false),
CLONE ("gui_clone", Material.GLOWSTONE_DUST, 33, "astools.clone", false),
SAVE ("gui_save", Material.DIAMOND, 43, "astools.cmdblock",false),
SLOTS ("gui_slots", Material.IRON_HOE, 44, "astools.use", false),
HEAD ("gui_head", Material.PLAYER_HEAD, 7, "astools.use", false),
BODY ("gui_body", Material.NETHER_BRICKS, 16, "astools.use", false),
RARM ("gui_rarm", Material.REDSTONE_TORCH, 15, "astools.use", true),
LARM ("gui_larm", Material.TORCH, 17, "astools.use", true),
RLEG ("gui_rleg", Material.BLAZE_ROD, 24, "astools.use", true),
LLEG ("gui_lleg", Material.BONE, 26, "astools.use", true),
MOVE ("gui_move", Material.FEATHER, 25, "astools.use", false),
CLONE ("gui_clone", Material.GLOWSTONE_DUST, 34, "astools.clone", false),
UP ("gui_moveup", Material.LIGHTNING_ROD, 4, "astools.use", false),
DOWN ("gui_movedown",Material.LEVER, 13, "astools.use", false),
ROTATE ("gui_rotate", Material.ENDER_PEARL, 22, "astools.use", false),
PHEAD ("gui_pHead", Material.PLAYER_HEAD, 36, "astools.head", false),
NAME ("gui_name", Material.NAME_TAG, 45, "astools.use", false),
PHEAD ("gui_pHead", Material.PLAYER_HEAD, 46, "astools.head", false),
INVIS ("gui_invis", Material.GOLD_NUGGET, 47, "astools.use", false),
ARMS ("gui_arms", Material.ARROW, 48, "astools.use", false),
BASE ("gui_base", Material.STONE_SLAB, 49, "astools.use", false),
SIZE ("gui_size", Material.EMERALD, 50, "astools.use", false),
GRAV ("gui_grav", Material.GHAST_TEAR, 51, "astools.use", false),
INVUL ("gui_invul", Material.GLISTERING_MELON_SLICE, 52, "astools.use", false),
GLOW ("gui_glow", Material.GLOWSTONE, 53, "astools.glow", false);
INVIS ("gui_invis", Material.GOLD_NUGGET, 46, "astools.use", false),
ARMS ("gui_arms", Material.ARROW, 47, "astools.use", false),
BASE ("gui_base", Material.STONE_SLAB, 48, "astools.use", false),
SIZE ("gui_size", Material.EMERALD, 49, "astools.use", false),
GRAV ("gui_grav", Material.GHAST_TEAR, 50, "astools.use", false),
INVUL ("gui_invul", Material.GLISTERING_MELON_SLICE, 51, "astools.use", false),
SLOTS ("gui_slots", Material.IRON_HOE, 52, "astools.use", false),
GLOW ("gui_glow", Material.GLOWSTONE, 53, "astools.glow", false),
SAVE ("gui_save", Material.DIAMOND, 44, "astools.cmdblock",false);
private final ItemStack item;
private final String config_id;

Datei anzeigen

@ -1,12 +1,14 @@
package com.gmail.st3venau.plugins.armorstandtools;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
@ -29,7 +31,22 @@ class Commands implements CommandExecutor, TabCompleter {
p.sendMessage(ChatColor.RED + Config.noCommandPerm);
return true;
}
p.sendMessage(ChatColor.AQUA + Config.instructions);
if(args.length > 0 && args[0].equalsIgnoreCase("new")) {
// astools new
if (!Utils.hasPermissionNode(p, "astools.new")) {
p.sendMessage(ChatColor.RED + Config.noCommandPerm);
return true;
}
Location l = Utils.getLocationFacing(p.getLocation());
if(l.getWorld() == null) {
p.sendMessage(ChatColor.RED + Config.error);
return true;
}
ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
AST.pickUpArmorStand(as, p);
Utils.title(p, Config.carrying);
}
p.sendMessage(ChatColor.AQUA + Config.instructions1 + ChatColor.GREEN + " /ast new " + ChatColor.AQUA + Config.instructions2);
return true;
} else if(cmd.equals("ascmd")) {
ArmorStand as = getNearbyArmorStand(p);
@ -111,6 +128,10 @@ class Commands implements CommandExecutor, TabCompleter {
p.sendMessage("\n" + Config.assignCmdError + name);
}
} else if(args.length >= 2 && args[0].equalsIgnoreCase("cooldown")) { //ascmd cooldown <ticks>/remove
if (!Utils.hasPermissionNode(p, "astools.ascmd.cooldown")) {
p.sendMessage(ChatColor.RED + Config.noCommandPerm);
return true;
}
ArmorStandCmd asCmd = new ArmorStandCmd(as);
if(asCmd.getCommand() == null) {
p.sendMessage(Config.closestAS + name + Config.hasNoCmd);

Datei anzeigen

@ -37,9 +37,9 @@ class Config {
ascmdHelp, viewCmd, removeCmd, assignConsole,
assignPlayer, executeCmdError, cmdOnCooldown,
cooldownRemovedFrom, isAnInvalidCooldown,
cooldownSetTo, ticksFor, setCooldown,
removeCooldown, glow, instructions, crouch, click,
finish;
cooldownSetTo, ticksFor, setCooldown, glow,
removeCooldown, instructions1, instructions2,
crouch, click, finish, error;
static void reload(AST main) {
plugin = main;
@ -57,7 +57,7 @@ class Config {
requireCreative = config.getBoolean("requireCreativeForSaveAsCmdBlock");
defaultASCmdCooldownTicks = config.getInt("defaultASCmdCooldownTicks");
ignoreWGForASCmdExecution = config.getBoolean("bypassWorldguardForASCmdExecution");
debug = config.getBoolean("debug", false);
debug = config.getBoolean("showDebugMessages", false);
AST.activeTool.clear();
AST.selectedArmorStand.clear();
@ -159,10 +159,12 @@ class Config {
removeCooldown = languageConfig.getString("removeCooldown");
ticksFor = languageConfig.getString("ticksFor");
glow = languageConfig.getString("glow");
instructions = languageConfig.getString("instructions");
instructions1 = languageConfig.getString("instructions1");
instructions2 = languageConfig.getString("instructions2");
crouch = languageConfig.getString("crouch");
click = languageConfig.getString("click");
finish = languageConfig.getString("finish");
error = languageConfig.getString("error");
}
}

Datei anzeigen

@ -25,6 +25,7 @@ import org.bukkit.metadata.MetadataValue;
import java.util.UUID;
import java.util.regex.Pattern;
@SuppressWarnings("CommentedOutCode")
public class MainListener implements Listener {
private static final Pattern MC_USERNAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_]{3,16}$");
@ -34,9 +35,14 @@ public class MainListener implements Listener {
Player p = event.getPlayer();
if(stopEditing(p, false)) {
event.setCancelled(true);
AST.debug("Interaction cancelled as player is already editing");
}
if(!(event.getRightClicked() instanceof ArmorStand)) return;
ArmorStand as = (ArmorStand) event.getRightClicked();
AST.debug(p.getName() + " right-clicked " + as.getName() + ", Crouching: " + p.isSneaking());
if(event.isCancelled()) {
AST.debug("Interaction with Armor Stand was cancelled by a plugin");
}
if(!event.isCancelled() && ArmorStandGUI.isInUse(as)) {
Utils.title(p, Config.guiInUse);
event.setCancelled(true);
@ -66,9 +72,7 @@ public class MainListener implements Listener {
ArmorStand getCarryingArmorStand(Player p) {
UUID uuid = p.getUniqueId();
return ArmorStandTool.MOVE == AST.activeTool.get(uuid)
? AST.selectedArmorStand.get(uuid)
: null;
return ArmorStandTool.MOVE == AST.activeTool.get(uuid) ? AST.selectedArmorStand.get(uuid) : null;
}
@EventHandler(priority = EventPriority.LOWEST)
@ -247,7 +251,9 @@ public class MainListener implements Listener {
attachment.setPermission("astools.ascmd.remove", true);
attachment.setPermission("astools.ascmd.assign.player", true);
attachment.setPermission("astools.ascmd.assign.console", true);
attachment.setPermission("astools.ascmd.cooldown", true);
attachment.setPermission("astools.ascmd.execute", true);
attachment.setPermission("astools.new", true);
//attachment.setPermission("astools.bypass-wg-flag", true);
}*/

Datei anzeigen

@ -25,24 +25,18 @@ class PlotSquaredHook {
public static Boolean checkPermission(Player p, Location l) {
if(l.getWorld() == null) return null;
com.plotsquared.core.location.Location plotLocation
= com.plotsquared.core.location.Location.at(l.getWorld().getName(), BlockVector3.at(l.getBlockX(), l.getBlockY(), l.getBlockZ()));
com.plotsquared.core.location.Location plotLocation = com.plotsquared.core.location.Location.at(l.getWorld().getName(), BlockVector3.at(l.getBlockX(), l.getBlockY(), l.getBlockZ()));
PlotArea plotArea = plotLocation.getPlotArea();
if(plotArea == null) {
AST.debug("plots.admin.build.road: " + p.hasPermission("plots.admin.build.road"));
return p.hasPermission("plots.admin.build.road");
}
Plot plot = plotArea.getPlot(plotLocation);
PlotPlayer<?> pp = api.wrapPlayer(p.getUniqueId());
if(pp == null) return null;
AST.debug("Plot: " + plot);
if (plot == null) {
AST.debug("plots.admin.build.road: " + pp.hasPermission("plots.admin.build.road"));
return pp.hasPermission("plots.admin.build.road");
}
UUID uuid = pp.getUUID();
AST.debug("plot.isAdded: " + plot.isAdded(uuid));
AST.debug("plots.admin.build.other: " + pp.hasPermission("plots.admin.build.other"));
return plot.isAdded(uuid) || pp.hasPermission("plots.admin.build.other");
}
}

Datei anzeigen

@ -232,6 +232,7 @@ class Utils {
sb.append(",Count:").append(is.getAmount());
}
String itemStackTags = getItemStackTags(is);
@SuppressWarnings("deprecation")
short durability = is.getDurability();
String skullOwner = skullOwner(is);
int n = 0;

Datei anzeigen

@ -31,6 +31,7 @@
#
# Permissions:
# astools.use Permission to using any of the tools, except the ones below that have their own separate permissions (see below)
# astools.new Permission to use "/astools new" command to summon a new armor stand
# astools.clone Permission to use the clone tool (Clones an armor stand without requiring the materials)
# astools.summon Permission to use the summon tool (Summons an armor stand without requiring the materials)
# astools.head Permission to use the player head tool (Ability to specify a player head for an armor stand)
@ -40,6 +41,7 @@
# astools.ascmd.remove Permission to remove a command from an armor stand
# astools.ascmd.view Permission to view the command assigned to an armor stand
# astools.ascmd.execute Permission to execute a command assigned to an armor stand by (on right click)
# astools.ascmd.cooldown Permission to add a cooldown to commands assigned to an armor stand
# astools.bypass-wg-flag Permission to bypass AST's custom worldguard flag (see below for more details)
#
# WorldGuard Integration:
@ -50,6 +52,7 @@
# this permission can use AST in worldguard regions even if the ast flag for that region is set to Deny.
# - The ast worldguard flag is also ignored for players that have op.
#
showDebugMessages: false
integrateWithWorldGuard: true
allowMovingStandsBetweenWorlds: false
requireCreativeForSaveAsCmdBlock: false
@ -68,6 +71,9 @@ enableTool:
gui_pHead: true
gui_invul: true
gui_move: true
gui_moveup: true
gui_movedown: true
gui_rotate: true
gui_glow: true
gui_head: true
gui_body: true

Datei anzeigen

@ -84,19 +84,39 @@ removeCooldown: 'Remove the cooldown for the command'
# New since v3.4.1
glow: 'Glow'
#New since v4.0.0
instructions: 'Crouch + right-click an armor stand to use Armor Stand Tools'
crouch: 'Crouch'
click: 'Click'
finish: 'Finish'
#New since v4.0.2
instructions1: 'Crouch + right-click an armor stand to edit, or use command'
instructions2: 'to summon a new armor stand'
error: 'An error occured. Try again.'
#
#############################
# Tool names & descriptions #
#############################
tool:
gui_move:
name: 'Pick Up (Move/Rotate)'
name: 'Pick Up (Move)'
lore:
- 'Pick up this armor stand to move or rotate it'
- 'Pick up this armor stand to move it'
gui_moveup:
name: 'Move Up'
lore:
- 'Left click: Move up 0.1 block'
- 'Right click: Move up 1 block'
- '(Automatically disables gravity)'
gui_movedown:
name: 'Move Down'
lore:
- 'Left click: Move down 0.1 block'
- 'Right click: Move down 1 block'
- '(Automatically disables gravity)'
gui_rotate:
name: 'Rotate'
lore:
- 'Left click: Rotate clockwise 5°'
- 'Right click: Rotate anti-clockwise 5°'
gui_clone:
name: 'Clone'
lore:

Datei anzeigen

@ -9,7 +9,7 @@ commands:
astools:
description: Provides player instructions on how to use AST
aliases: ast
usage: Usage /astools or /ast
usage: Usage /astools or /ast, /ast new
ascmd:
description: View/Remove/Assign the command assigned to the nearest armor stand
usage: Usage /ascmd view, /ascmd remove, /ascmd assign <player/console> <command>