3
0
Mirror von https://github.com/St3venAU/ArmorStandTools.git synchronisiert 2024-12-26 19:42:41 +01:00
Dieser Commit ist enthalten in:
Steven 2021-07-10 20:38:15 +08:00
Ursprung c7834fdb9e
Commit 42b6b66f63
24 geänderte Dateien mit 967 neuen und 1644 gelöschten Zeilen

1
.gitignore vendored
Datei anzeigen

@ -1,6 +1,7 @@
### Java template ### Java template
target/classes/io/github/archemedes/knockoutplus/corpse/CorpseRegistry.class target/classes/io/github/archemedes/knockoutplus/corpse/CorpseRegistry.class
/.idea /.idea
/libs
# Mobile Tools for Java (J2ME) # Mobile Tools for Java (J2ME)
.mtj.tmp/ .mtj.tmp/

Datei anzeigen

@ -5,11 +5,12 @@ Spigot resource page with plugin download: http://www.spigotmc.org/resources/arm
Inspiration Inspiration
----------- -----------
I wanted to create an armor stand for each kit in my mini-game, and I quickly became frustrated with trying to use commands and numeric values to position the legs, arms, body and head of each armor stand, so I created this plugin which allows you to do all of this with ease. Among other features you can create any pose you wish just by holding right click on the tools and moving your cursor up and down on the armor stand. The plugin can also generate a summon command that will re-create the armor stand at any time. I wanted to create an armor stand for each kit in my mini-game, and I quickly became frustrated with trying to use commands and numeric values to position the legs, arms, body and head of each armor stand, so I created this plugin which allows you to do all of this with ease. Simply couch/sneak while right clicking an armor stand to open the tools. The plugin can also generate a summon command that will re-create the armor stand at any time.
Compatibility Compatibility
------------- -------------
- Armor Stand Tools v3.x.x - Spigot/CraftBukkit 1.13 to 1.16.4 only - Armor Stand Tools v4.x.x - Spigot/CraftBukkit 1.17+
- Armor Stand Tools v3.x.x - Spigot/CraftBukkit 1.13 - 1.16
- Armor Stand Tools v2.4.3 - Spigot/CraftBukkit 1.8, 1.9, 1.10, 1.11, 1.12 (https://www.spigotmc.org/resources/armor-stand-tools.2237/download?version=175162) - Armor Stand Tools v2.4.3 - Spigot/CraftBukkit 1.8, 1.9, 1.10, 1.11, 1.12 (https://www.spigotmc.org/resources/armor-stand-tools.2237/download?version=175162)
Features Features
@ -17,7 +18,7 @@ Features
- Summon armor stands. - Summon armor stands.
- Name armor stands. - Name armor stands.
- Toggle: Gravity, Visibility, Arms, Base, Size, Invulnerability, Equipment Lock. - Toggle: Gravity, Visibility, Arms, Base, Size, Invulnerability, Equipment Lock.
- Manipulate the x/y/z rotations of the Head, Body, Arms and Legs. The value depends on how high up the armor stand's body you click with the tool (i.e. click near the feet is one extreme, near the top of the head is the other extreme). - Manipulate the rotations of the Head, Body, Arms and Legs.
- Full control over armor stand's inventory (armor & items in hands). - Full control over armor stand's inventory (armor & items in hands).
- Pick up and move armor stands. - Pick up and move armor stands.
- Armor stand cloning tool. - Armor stand cloning tool.
@ -35,19 +36,17 @@ Assigning Commands
- When a player with the astools.ascmd.execute permission right clicks on an armor stand, it's command is run. - When a player with the astools.ascmd.execute permission right clicks on an armor stand, it's command is run.
- If a player is crouching when they right click the armor stand, the command will not be run. - If a player is crouching when they right click the armor stand, the command will not be run.
- Warning: Make sure you are careful when assigning console commands. Any player with the astools.ascmd.execute permission will be able to execute the command. - Warning: Make sure you are careful when assigning console commands. Any player with the astools.ascmd.execute permission will be able to execute the command.
- By default any armor stands command will use the cooldown set in config.yml. This can be set on an individual basis using the /ascmd cooldown <ticks> command. - By default, any command assigned to an armor stand will use the default cooldown set in config.yml. This can be set on an individual basis using the /ascmd cooldown <ticks> command.
Commands Commands
-------- --------
- /astools : Give yourself all of the armor stand tools (Note: Clears your inventory)
- /astools reload : Reload the config file
- /ast : Alias for /astools
- /ascmd assign console <command> : Assign a console command to the nearest armor stand (within 4 blocks) - /ascmd assign console <command> : Assign a console command to the nearest armor stand (within 4 blocks)
- /ascmd assign player <command> : Assign a player command to the nearest armor stand - /ascmd assign player <command> : Assign a player command to the nearest armor stand
- /ascmd remove : Remove the command assigned to the nearest armor stand - /ascmd remove : Remove the command assigned to the nearest armor stand
- /ascmd view : View the command assigned to the nearest armor stand - /ascmd view : View the command assigned to the nearest armor stand
- /ascmd cooldown <ticks> : Sets the cooldown (in ticks) for the command on nearest armor stand (Setting this overrides the default cooldown from config.yml) - /ascmd cooldown <ticks> : Sets the cooldown (in ticks) for the command on nearest armor stand (Setting this overrides the default cooldown from config.yml)
- /ascmd cooldown remove : Removes the cooldown for the command on nearest armor stand (Default cooldown set in config.yml will be used) - /ascmd cooldown remove : Removes the cooldown for the command on nearest armor stand (Default cooldown set in config.yml will be used)
- /astools or /ast : Legacy command - instructs player to crouch right-click an armor stand to use AST.
WorldGuard Integration WorldGuard Integration
---------------------- ----------------------
@ -58,9 +57,7 @@ WorldGuard Integration
Permissions Permissions
----------- -----------
- astools.command : Permission for the /astools command - astools.use : Permission for using any of the tools, except for those that have a custom permission below
- astools.reload : Permission to reload the plugin with /astools reload
- astools.use : Permission for using any of the tools
- astools.clone: Permission to use the clone tool - 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.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) - astools.summon: Permission to use the summon tool (Summons an armor stand without requiring the materials)

22
pom.xml
Datei anzeigen

@ -5,15 +5,16 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.St3venAU.plugins</groupId> <groupId>com.gmail.St3venAU.plugins</groupId>
<artifactId>ArmorStandTools</artifactId> <artifactId>ArmorStandTools</artifactId>
<version>3.7.2</version> <version>4.0.0</version>
<name>ArmorStandTools</name> <name>ArmorStandTools</name>
<repositories> <repositories>
<!-- Spigot -->
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<!-- WorldEdit --> <!-- WorldEdit / WorldGuard -->
<repository> <repository>
<id>sk89q-repo</id> <id>sk89q-repo</id>
<url>http://maven.sk89q.com/repo/</url> <url>http://maven.sk89q.com/repo/</url>
@ -26,29 +27,32 @@
</repositories> </repositories>
<dependencies> <dependencies>
<!-- Spigot -->
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId> <artifactId>spigot-api</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version> <version>1.17.1-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- WorldGuard -->
<dependency> <dependency>
<groupId>com.sk89q.worldguard</groupId> <groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId> <artifactId>worldguard-bukkit</artifactId>
<version>7.0.4</version> <version>7.0.6-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- WorldEdit -->
<dependency> <dependency>
<groupId>com.sk89q.worldedit</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-core</artifactId> <artifactId>worldedit-core</artifactId>
<version>7.2.0-SNAPSHOT</version> <version>7.3.0-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- PlotSquared Core API --> <!-- PlotSquared Core API -->
<dependency> <dependency>
<groupId>com.plotsquared</groupId> <groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Core</artifactId> <artifactId>PlotSquared-Core</artifactId>
<version>5.13.3</version> <version>6.0.6-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
@ -68,10 +72,10 @@
<plugins> <plugins>
<plugin> <plugin>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version> <version>3.8.1</version>
<configuration> <configuration>
<source>1.8</source> <source>16</source>
<target>1.8</target> <target>16</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

Datei anzeigen

@ -0,0 +1,218 @@
package com.gmail.st3venau.plugins.armorstandtools;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.HashMap;
import java.util.UUID;
import java.util.logging.Level;
public class AST extends JavaPlugin {
private static Object WG_AST_FLAG;
final static HashMap<UUID, ArmorStandTool> activeTool = new HashMap<>();
final static HashMap<UUID, ArmorStand> selectedArmorStand = new HashMap<>();
static AST plugin;
@SuppressWarnings({"unchecked", "JavaReflectionInvocation", "rawtypes"})
@Override
public void onLoad() {
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) {
try {
// Need to do this with reflection for some reason, otherwise plugin load fails when worldguard is not present, even though this code block is not actually executed unless worldguard is present ???
WG_AST_FLAG = Class.forName("com.sk89q.worldguard.protection.flags.StateFlag").getConstructor(String.class, boolean.class).newInstance("ast", true);
Class worldGuardClass = Class.forName("com.sk89q.worldguard.WorldGuard");
Object worldGuard = worldGuardClass.getMethod("getInstance").invoke(worldGuardClass);
Object flagRegistry = worldGuardClass.getMethod("getFlagRegistry").invoke(worldGuard);
flagRegistry.getClass().getMethod("register", Class.forName("com.sk89q.worldguard.protection.flags.Flag")).invoke(flagRegistry, WG_AST_FLAG);
getLogger().info("Registered custom WorldGuard flag: ast");
} catch (Exception e) {
getLogger().info("Failed to register custom WorldGuard flag");
}
}
}
@Override
public void onEnable() {
plugin = this;
String nmsVersion = getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
if( nmsVersion.startsWith("v1_4") ||
nmsVersion.startsWith("v1_5") ||
nmsVersion.startsWith("v1_6") ||
nmsVersion.startsWith("v1_7") ||
nmsVersion.startsWith("v1_8") ||
nmsVersion.startsWith("v1_9") ||
nmsVersion.startsWith("v1_10") ||
nmsVersion.startsWith("v1_11") ||
nmsVersion.startsWith("v1_12") ||
nmsVersion.startsWith("v1_13") ||
nmsVersion.startsWith("v1_14") ||
nmsVersion.startsWith("v1_15") ||
nmsVersion.startsWith("v1_16")) {
getLogger().warning("This Craftbukkit/Spigot version is not supported. Craftbukkit/Spigot 1.17+ required. Loading plugin failed.");
setEnabled(false);
return;
}
getServer().getPluginManager().registerEvents(new MainListener(), this);
Commands cmds = new Commands();
PluginCommand command = getCommand("astools");
if(command != null) {
command.setExecutor(cmds);
}
command = getCommand("ascmd");
if(command != null) {
command.setExecutor(cmds);
command.setTabCompleter(cmds);
}
Config.reload(this);
new BukkitRunnable() {
@Override
public void run() {
for(UUID uuid : activeTool.keySet()) {
Player p = getServer().getPlayer(uuid);
ArmorStandTool tool = activeTool.get(uuid);
if(p != null && tool != null && p.isOnline() && selectedArmorStand.containsKey(uuid)) {
tool.use(p, selectedArmorStand.get(uuid));
}
}
}
}.runTaskTimer(this, 5L, 5L);
}
@Override
public void onDisable() {
for(UUID uuid : activeTool.keySet()) {
if(ArmorStandTool.MOVE != activeTool.get(uuid)) continue;
ArmorStand as = selectedArmorStand.get(uuid);
if(as != null && !as.isDead()) {
returnArmorStand(as);
selectedArmorStand.remove(uuid);
activeTool.remove(uuid);
}
}
}
static void returnArmorStand(ArmorStand as) {
if(as.hasMetadata("clone")) {
as.remove();
return;
}
if(as.hasMetadata("startLoc")) {
for (MetadataValue metaData : as.getMetadata("startLoc")) {
if (metaData.getOwningPlugin() == plugin) {
Location l = (Location) metaData.value();
if(l != null) {
as.teleport(l);
as.removeMetadata("startLoc", plugin);
return;
}
}
}
}
as.remove();
}
static void pickUpArmorStand(ArmorStand as, Player p) {
UUID uuid = p.getUniqueId();
activeTool.put(uuid, ArmorStandTool.MOVE);
selectedArmorStand.put(uuid, as);
as.setMetadata("startLoc", new FixedMetadataValue(AST.plugin, as.getLocation()));
}
static void setName(Player p, ArmorStand as) {
Block b = findAnAirBlock(p.getLocation());
if(b == null) {
p.sendMessage(ChatColor.RED + Config.noAirError);
return;
}
b.setType(Material.OAK_SIGN);
Utils.openSign(p, b);
b.setMetadata("armorStand", new FixedMetadataValue(AST.plugin, as.getUniqueId()));
b.setMetadata("setName", new FixedMetadataValue(AST.plugin, true));
}
static void setPlayerSkull(Player p, ArmorStand as) {
Block b = findAnAirBlock(p.getLocation());
if(b == null) {
p.sendMessage(ChatColor.RED + Config.noAirError);
return;
}
b.setType(Material.OAK_SIGN);
Utils.openSign(p, b);
b.setMetadata("armorStand", new FixedMetadataValue(AST.plugin, as.getUniqueId()));
b.setMetadata("setSkull", new FixedMetadataValue(AST.plugin, true));
}
private static Block findAnAirBlock(Location l) {
while(l.getY() < 255 && l.getBlock().getType() != Material.AIR) {
l.add(0, 1, 0);
}
return l.getY() < 255 && l.getBlock().getType() == Material.AIR ? l.getBlock() : null;
}
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)) {
return PlotSquaredHook.checkPermission(p, l);
}
}
if(Config.worldGuardPlugin != null) {
if(!Utils.hasPermissionNode(p, "astools.bypass-wg-flag") && !getWorldGuardAstFlag(b.getLocation())) {
return false;
}
return Config.worldGuardPlugin.createProtectionQuery().testBlockBreak(p, b);
}
BlockBreakEvent breakEvent = new BlockBreakEvent(b, p);
Bukkit.getServer().getPluginManager().callEvent(breakEvent);
return !breakEvent.isCancelled();
}
private static boolean getWorldGuardAstFlag(Location l) {
if (l != null && l.getWorld() != null) {
RegionContainer regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionManager regions = regionContainer.get(BukkitAdapter.adapt(l.getWorld()));
if (regions == null) return true;
return regions.getApplicableRegions(BukkitAdapter.asBlockVector(l)).testState(null, (StateFlag) WG_AST_FLAG);
} else {
return false;
}
}
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 permission = tool == null ? "astools.use" : tool.getPermission();
return (tool == null || tool.isEnabled()) && Utils.hasPermissionNode(p, permission) && checkBlockPermission(p, b);
}
static void debug(String msg) {
if(!Config.debug) return;
Bukkit.getLogger().log(Level.INFO, "[DEBUG] " + msg);
}
}

Datei anzeigen

@ -1,4 +1,4 @@
package com.gmail.St3venAU.plugins.ArmorStandTools; package com.gmail.st3venau.plugins.armorstandtools;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -98,7 +98,7 @@ class ArmorStandCmd {
} }
static boolean removeAssignedCommand(ArmorStand as) { static boolean removeAssignedCommand(ArmorStand as) {
List<String> tags = new ArrayList<String>(); List<String> tags = new ArrayList<>();
for(String tag : as.getScoreboardTags()) { for(String tag : as.getScoreboardTags()) {
if(tag.startsWith("ast-cmd-")) { if(tag.startsWith("ast-cmd-")) {
tags.add(tag); tags.add(tag);
@ -116,13 +116,13 @@ class ArmorStandCmd {
cooldownTime = Config.defaultASCmdCooldownTicks; cooldownTime = Config.defaultASCmdCooldownTicks;
} }
if(cooldownTime < 1) return; if(cooldownTime < 1) return;
armorStand.setMetadata("ast-cmd-cooldown", new FixedMetadataValue(Main.plugin, true)); armorStand.setMetadata("ast-cmd-cooldown", new FixedMetadataValue(AST.plugin, true));
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
armorStand.removeMetadata("ast-cmd-cooldown", Main.plugin); armorStand.removeMetadata("ast-cmd-cooldown", AST.plugin);
} }
}.runTaskLater(Main.plugin, cooldownTime); }.runTaskLater(AST.plugin, cooldownTime);
} }
private boolean isOnCooldown() { private boolean isOnCooldown() {
@ -132,7 +132,7 @@ class ArmorStandCmd {
// Positive cooldown: Set cooldown time, Negative cooldown: Remove cooldown time // Positive cooldown: Set cooldown time, Negative cooldown: Remove cooldown time
void setCooldownTime(int cooldown) { void setCooldownTime(int cooldown) {
if(armorStand == null) return; if(armorStand == null) return;
List<String> tags = new ArrayList<String>(); List<String> tags = new ArrayList<>();
for(String tag : armorStand.getScoreboardTags()) { for(String tag : armorStand.getScoreboardTags()) {
if(tag.startsWith("ast-cdn-")) { if(tag.startsWith("ast-cdn-")) {
tags.add(tag); tags.add(tag);

Datei anzeigen

@ -1,4 +1,4 @@
package com.gmail.St3venAU.plugins.ArmorStandTools; package com.gmail.st3venau.plugins.armorstandtools;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -13,10 +13,10 @@ import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent; import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryDragEvent; import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import java.util.HashSet; import java.util.HashSet;
@ -24,15 +24,21 @@ import java.util.UUID;
class ArmorStandGUI implements Listener { class ArmorStandGUI implements Listener {
private static final HashSet<Integer> inUse = new HashSet<Integer>(); private static final int INV_SLOT_HELMET = 2;
private static final HashSet<Integer> invSlots = new HashSet<Integer>(); 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 HashSet<Integer> inUse = new HashSet<>();
private static final HashSet<Integer> invSlots = new HashSet<>();
private static ItemStack filler; private static ItemStack filler;
private Inventory i; private Inventory i;
private ArmorStand as; private ArmorStand as;
private Main plugin;
ArmorStandGUI(Main plugin, ArmorStand as, Player p) { ArmorStandGUI(ArmorStand as, Player p) {
if(isInUse(as)) { if(isInUse(as)) {
p.sendMessage(ChatColor.RED + Config.guiInUse); p.sendMessage(ChatColor.RED + Config.guiInUse);
return; return;
@ -40,17 +46,18 @@ class ArmorStandGUI implements Listener {
if(filler == null) { if(filler == null) {
filler = new ItemStack(Material.BLACK_STAINED_GLASS_PANE, 1); filler = new ItemStack(Material.BLACK_STAINED_GLASS_PANE, 1);
ItemMeta im = filler.getItemMeta(); ItemMeta im = filler.getItemMeta();
im.setDisplayName(" "); if(im != null) {
filler.setItemMeta(im); im.setDisplayName(" ");
invSlots.add(10); filler.setItemMeta(im);
invSlots.add(12); }
invSlots.add(2); invSlots.add(INV_SLOT_HELMET);
invSlots.add(11); invSlots.add(INV_SLOT_CHEST);
invSlots.add(20); invSlots.add(INV_SLOT_PANTS);
invSlots.add(29); invSlots.add(INV_SLOT_BOOTS);
invSlots.add(INV_SLOT_R_HAND);
invSlots.add(INV_SLOT_L_HAND);
} }
this.plugin = plugin; AST.plugin.getServer().getPluginManager().registerEvents(this, AST.plugin);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
this.as = as; this.as = as;
String name = as.getCustomName(); String name = as.getCustomName();
if(name == null) { if(name == null) {
@ -58,21 +65,24 @@ class ArmorStandGUI implements Listener {
} else if(name.length() > 32) { } else if(name.length() > 32) {
name = name.substring(0, 32); name = name.substring(0, 32);
} }
i = Bukkit.createInventory(null, 36, name); i = Bukkit.createInventory(null, 54, name);
for(int slot = 0; slot < i.getSize(); slot++) { for(int slot = 0; slot < i.getSize(); slot++) {
i.setItem(slot, filler); i.setItem(slot, filler);
} }
for(ArmorStandTool tool : ArmorStandTool.values()) { for(ArmorStandTool tool : ArmorStandTool.values()) {
if(tool.isForGui() && tool.isEnabled()) { if(tool.isEnabled()) {
i.setItem(tool.getSlot(), updateLore(tool)); i.setItem(tool.getSlot(), tool.updateLore(as));
} }
} }
i.setItem(10, as.getEquipment().getItemInMainHand()); EntityEquipment entityEquipment = as.getEquipment();
i.setItem(12, as.getEquipment().getItemInOffHand()); if(entityEquipment != null) {
i.setItem(2, as.getHelmet()); i.setItem(INV_SLOT_R_HAND, entityEquipment.getItemInMainHand());
i.setItem(11, as.getChestplate()); i.setItem(INV_SLOT_L_HAND, entityEquipment.getItemInOffHand());
i.setItem(20, as.getLeggings()); i.setItem(INV_SLOT_HELMET, entityEquipment.getHelmet());
i.setItem(29, as.getBoots()); i.setItem(INV_SLOT_CHEST, entityEquipment.getChestplate());
i.setItem(INV_SLOT_PANTS, entityEquipment.getLeggings());
i.setItem(INV_SLOT_BOOTS, entityEquipment.getBoots());
}
inUse.add(as.getEntityId()); inUse.add(as.getEntityId());
p.openInventory(i); p.openInventory(i);
} }
@ -81,43 +91,6 @@ class ArmorStandGUI implements Listener {
return inUse.contains(as.getEntityId()); return inUse.contains(as.getEntityId());
} }
private ItemStack updateLore(ArmorStandTool tool) {
ItemStack item = tool.getItem();
switch (tool) {
case INVIS:
return Utils.setLore(item, ChatColor.AQUA + Config.asVisible + ": " + (as.isVisible() ? (ChatColor.GREEN + Config.isTrue) : (ChatColor.RED + Config.isFalse)));
case SIZE:
return Utils.setLore(item, ChatColor.AQUA + Config.size + ": " + (as.isSmall() ? (ChatColor.BLUE + Config.small) : (ChatColor.GREEN + Config.normal)));
case BASE:
return Utils.setLore(item, ChatColor.AQUA + Config.basePlate + ": " + (as.hasBasePlate() ? (ChatColor.GREEN + Config.isOn) : (ChatColor.RED + Config.isOff)));
case GRAV:
return Utils.setLore(item, ChatColor.AQUA + Config.gravity + ": " + (as.hasGravity() ? (ChatColor.GREEN + Config.isOn) : (ChatColor.RED + Config.isOff)));
case ARMS:
return Utils.setLore(item, ChatColor.AQUA + Config.arms + ": " + (as.hasArms() ? (ChatColor.GREEN + Config.isOn) : (ChatColor.RED + Config.isOff)));
case INVUL:
return Utils.setLore(item, ChatColor.AQUA + Config.invul + ": " + (as.isInvulnerable() ? (ChatColor.GREEN + Config.isOn) : (ChatColor.RED + Config.isOff)));
case SLOTS:
return Utils.setLore(item, ChatColor.AQUA + Config.equip + ": " + (Main.nms.equipmentLocked(as) ? (ChatColor.GREEN + Config.locked) : (ChatColor.RED + Config.unLocked)));
case NAME:
return Utils.setLore(item, ChatColor.AQUA + Config.currently + ": " + (as.getCustomName() == null ? (ChatColor.BLUE + Config.none) : (ChatColor.GREEN + as.getCustomName())));
case PHEAD:
String name = plrHeadName(as);
return Utils.setLore(item, ChatColor.AQUA + Config.currently + ": " + (name == null ? (ChatColor.BLUE + Config.none) : (ChatColor.GREEN + name)));
case GLOW:
return Utils.setLore(item, ChatColor.AQUA + Config.glow + ": " + (as.isGlowing() ? (ChatColor.GREEN + Config.isOn) : (ChatColor.RED + Config.isOff)));
default:
return item;
}
}
private String plrHeadName(ArmorStand as) {
if(as.getHelmet() == null) return null;
if(!(as.getHelmet().getItemMeta() instanceof SkullMeta)) return null;
SkullMeta meta = (SkullMeta) as.getHelmet().getItemMeta();
if(!meta.hasOwner()) return null;
return meta.getOwningPlayer().getName();
}
@EventHandler @EventHandler
public void onInventoryClose(InventoryCloseEvent event) { public void onInventoryClose(InventoryCloseEvent event) {
if(!event.getInventory().equals(i)) return; if(!event.getInventory().equals(i)) return;
@ -127,7 +100,7 @@ class ArmorStandGUI implements Listener {
@EventHandler @EventHandler
public void onInventoryClick(InventoryClickEvent event) { public void onInventoryClick(InventoryClickEvent event) {
if(!event.getInventory().equals(i)) return; if(!event.getInventory().equals(i) || !(event.getWhoClicked() instanceof Player)) return;
Player p = (Player) event.getWhoClicked(); Player p = (Player) event.getWhoClicked();
if(event.getClick() == ClickType.SHIFT_LEFT || event.getClick() == ClickType.SHIFT_RIGHT || event.getClick() == ClickType.NUMBER_KEY) { if(event.getClick() == ClickType.SHIFT_LEFT || event.getClick() == ClickType.SHIFT_RIGHT || event.getClick() == ClickType.NUMBER_KEY) {
event.setCancelled(true); event.setCancelled(true);
@ -136,8 +109,8 @@ class ArmorStandGUI implements Listener {
int slot = event.getRawSlot(); int slot = event.getRawSlot();
if(slot > i.getSize()) return; if(slot > i.getSize()) return;
if(invSlots.contains(slot)) { if(invSlots.contains(slot)) {
if(plugin.checkBlockPermission(p, as.getLocation().getBlock())) { if(AST.checkBlockPermission(p, as.getLocation().getBlock())) {
updateInventory(); updateArmorStandInventory();
} else { } else {
event.setCancelled(true); event.setCancelled(true);
p.sendMessage(ChatColor.RED + Config.wgNoPerm); p.sendMessage(ChatColor.RED + Config.wgNoPerm);
@ -148,76 +121,87 @@ class ArmorStandGUI implements Listener {
if(!(event.getWhoClicked() instanceof Player)) return; if(!(event.getWhoClicked() instanceof Player)) return;
ArmorStandTool t = ArmorStandTool.get(event.getCurrentItem()); ArmorStandTool t = ArmorStandTool.get(event.getCurrentItem());
if(t == null) return; if(t == null) return;
if (!plugin.playerHasPermission(p, as.getLocation().getBlock(), t)) { if (!AST.playerHasPermission(p, as.getLocation().getBlock(), t)) {
p.sendMessage(ChatColor.RED + Config.generalNoPerm); p.sendMessage(ChatColor.RED + Config.generalNoPerm);
return; return;
} }
UUID uuid = p.getUniqueId();
switch (t) { switch (t) {
case HEAD:
case BODY:
case LARM:
case RARM:
case LLEG:
case RLEG:
AST.activeTool.put(uuid, t);
AST.selectedArmorStand.put(uuid, as);
p.closeInventory();
t.showTitle(p);
break;
case INVIS: case INVIS:
as.setVisible(!as.isVisible()); as.setVisible(!as.isVisible());
Utils.actionBarMsg(p, Config.asVisible + ": " + (as.isVisible() ? Config.isTrue : Config.isFalse)); Utils.title(p, Config.asVisible + ": " + (as.isVisible() ? Config.isTrue : Config.isFalse));
break; break;
case CLONE: case CLONE:
p.closeInventory(); p.closeInventory();
plugin.pickUpArmorStand(Main.nms.clone(as), p, true); AST.pickUpArmorStand(Utils.cloneArmorStand(as), p);
Utils.actionBarMsg(p, Config.carrying); Utils.title(p, Config.carrying);
break; break;
case SAVE: case SAVE:
if(Config.requireCreative && p.getGameMode() != GameMode.CREATIVE) { if(Config.requireCreative && p.getGameMode() != GameMode.CREATIVE) {
p.sendMessage(ChatColor.RED + Config.creativeRequired); p.sendMessage(ChatColor.RED + Config.creativeRequired);
} else { } else {
Main.nms.generateCmdBlock(p.getLocation(), as); Utils.generateCmdBlock(p.getLocation(), as);
Utils.actionBarMsg(p, Config.cbCreated); Utils.title(p, Config.cbCreated);
} }
break; break;
case SIZE: case SIZE:
as.setSmall(!as.isSmall()); as.setSmall(!as.isSmall());
Utils.actionBarMsg(p, Config.size + ": " + (as.isSmall() ? Config.small : Config.normal)); Utils.title(p, Config.size + ": " + (as.isSmall() ? Config.small : Config.normal));
break; break;
case BASE: case BASE:
as.setBasePlate(!as.hasBasePlate()); as.setBasePlate(!as.hasBasePlate());
Utils.actionBarMsg(p, Config.basePlate + ": " + (as.hasBasePlate() ? Config.isOn : Config.isOff)); Utils.title(p, Config.basePlate + ": " + (as.hasBasePlate() ? Config.isOn : Config.isOff));
break; break;
case GRAV: case GRAV:
as.setGravity(!as.hasGravity()); as.setGravity(!as.hasGravity());
Utils.actionBarMsg(p, Config.gravity + ": " + (as.hasGravity() ? Config.isOn : Config.isOff)); Utils.title(p, Config.gravity + ": " + (as.hasGravity() ? Config.isOn : Config.isOff));
break; break;
case ARMS: case ARMS:
as.setArms(!as.hasArms()); as.setArms(!as.hasArms());
Utils.actionBarMsg(p, Config.arms + ": " + (as.hasArms() ? Config.isOn : Config.isOff)); Utils.title(p, Config.arms + ": " + (as.hasArms() ? Config.isOn : Config.isOff));
break; break;
case NAME: case NAME:
p.closeInventory(); p.closeInventory();
plugin.setName(p, as); AST.setName(p, as);
break; break;
case PHEAD: case PHEAD:
p.closeInventory(); p.closeInventory();
plugin.setPlayerSkull(p, as); AST.setPlayerSkull(p, as);
break; break;
case INVUL: case INVUL:
Utils.actionBarMsg(p, Config.invul + ": " + (Utils.toggleInvulnerability(as) ? Config.isOn : Config.isOff)); boolean inv = !as.isInvulnerable();
as.setInvulnerable(inv);
Utils.title(p, Config.invul + ": " + (inv ? Config.isOn : Config.isOff));
break; break;
case SLOTS: case SLOTS:
Utils.actionBarMsg(p, Config.equip + ": " + (Main.nms.toggleSlotsDisabled(as) ? Config.locked : Config.unLocked)); Utils.title(p, Config.equip + ": " + (Utils.toggleSlotsDisabled(as) ? Config.locked : Config.unLocked));
break; break;
case MOVE: case MOVE:
p.closeInventory(); p.closeInventory();
UUID uuid = p.getUniqueId(); as.removeMetadata("clone", AST.plugin);
if(plugin.carryingArmorStand.containsKey(uuid)) { AST.pickUpArmorStand(as, p);
plugin.carryingArmorStand.remove(uuid); Utils.title(p, Config.carrying);
Utils.actionBarMsg(p, Config.asDropped);
} else {
plugin.pickUpArmorStand(as, p, false);
Utils.actionBarMsg(p, Config.carrying);
}
break; break;
case GLOW: case GLOW:
Utils.actionBarMsg(p, Config.glow + ": " + (Utils.toggleGlow(as) ? Config.isOn : Config.isOff)); boolean glowing = !as.isGlowing();
as.setGlowing(glowing);
Utils.title(p, Config.glow + ": " + (glowing ? Config.isOn : Config.isOff));
break; break;
default: default:
return; return;
} }
i.setItem(t.getSlot(), updateLore(t)); i.setItem(t.getSlot(), t.updateLore(as));
} }
@EventHandler @EventHandler
@ -236,8 +220,8 @@ class ArmorStandGUI implements Listener {
} }
} }
if(invModified) { if(invModified) {
if(plugin.checkBlockPermission(p, as.getLocation().getBlock())) { if(AST.checkBlockPermission(p, as.getLocation().getBlock())) {
updateInventory(); updateArmorStandInventory();
} else { } else {
event.setCancelled(true); event.setCancelled(true);
p.sendMessage(ChatColor.RED + Config.wgNoPerm); p.sendMessage(ChatColor.RED + Config.wgNoPerm);
@ -245,19 +229,20 @@ class ArmorStandGUI implements Listener {
} }
} }
private void updateInventory() { private void updateArmorStandInventory() {
new BukkitRunnable() { new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
if(as == null || i == null) return; EntityEquipment equipment = as.getEquipment();
as.getEquipment().setItemInMainHand(i.getItem(10)); if(as == null || i == null || equipment == null) return;
as.getEquipment().setItemInOffHand(i.getItem(12)); equipment.setItemInMainHand(i.getItem(INV_SLOT_R_HAND));
as.setHelmet(i.getItem(2)); equipment.setItemInOffHand(i.getItem(INV_SLOT_L_HAND));
as.setChestplate(i.getItem(11)); equipment.setHelmet(i.getItem(INV_SLOT_HELMET));
as.setLeggings(i.getItem(20)); equipment.setChestplate(i.getItem(INV_SLOT_CHEST));
as.setBoots(i.getItem(29)); equipment.setLeggings(i.getItem(INV_SLOT_PANTS));
equipment.setBoots(i.getItem(INV_SLOT_BOOTS));
} }
}.runTaskLater(plugin, 1L); }.runTaskLater(AST.plugin, 1L);
} }
} }

Datei anzeigen

@ -1,84 +1,85 @@
package com.gmail.St3venAU.plugins.ArmorStandTools; package com.gmail.st3venau.plugins.armorstandtools;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.util.EulerAngle;
import java.util.Arrays;
import java.util.UUID;
public enum ArmorStandTool { public enum ArmorStandTool {
HEADX ("headX", Material.JACK_O_LANTERN, (short) 0, 12, false, true, "astools.use"),
HEADY ("headY", Material.JACK_O_LANTERN, (short) 0, 13, false, true, "astools.use"), HEAD ("gui_head", Material.PLAYER_HEAD, 6, "astools.use", false),
HEADZ ("headZ", Material.JACK_O_LANTERN, (short) 0, 14, false, true, "astools.use"), BODY ("gui_body", Material.NETHER_BRICKS, 15, "astools.use", false),
LARMX ("lArmX", Material.TORCH, (short) 0, 27, false, true, "astools.use"), RARM ("gui_rarm", Material.REDSTONE_TORCH, 14, "astools.use", true),
LARMY ("lArmY", Material.TORCH, (short) 0, 28, false, true, "astools.use"), LARM ("gui_larm", Material.TORCH, 16, "astools.use", true),
LARMZ ("lArmZ", Material.TORCH, (short) 0, 29, false, true, "astools.use"), RLEG ("gui_rleg", Material.BLAZE_ROD, 23, "astools.use", true),
RARMX ("rArmX", Material.REDSTONE_TORCH, (short) 0, 30, false, true, "astools.use"), LLEG ("gui_lleg", Material.BONE, 25, "astools.use", true),
RARMY ("rArmY", Material.REDSTONE_TORCH, (short) 0, 31, false, true, "astools.use"), MOVE ("gui_move", Material.FEATHER, 24, "astools.use", false),
RARMZ ("rArmZ", Material.REDSTONE_TORCH, (short) 0, 32, false, true, "astools.use"), CLONE ("gui_clone", Material.GLOWSTONE_DUST, 33, "astools.clone", false),
MOVEX ("moveX", Material.SHEARS, (short) 0, 3, false, true, "astools.use"), SAVE ("gui_save", Material.DIAMOND, 43, "astools.cmdblock",false),
MOVEY ("moveY", Material.SHEARS, (short) 0, 4, false, true, "astools.use"), SLOTS ("gui_slots", Material.IRON_HOE, 44, "astools.use", false),
MOVEZ ("moveZ", Material.SHEARS, (short) 0, 5, false, true, "astools.use"), NAME ("gui_name", Material.NAME_TAG, 45, "astools.use", false),
LLEGX ("lLegX", Material.BONE, (short) 0, 18, false, true, "astools.use"), PHEAD ("gui_pHead", Material.PLAYER_HEAD, 46, "astools.head", false),
LLEGY ("lLegY", Material.BONE, (short) 0, 19, false, true, "astools.use"), INVIS ("gui_invis", Material.GOLD_NUGGET, 47, "astools.use", false),
LLEGZ ("lLegZ", Material.BONE, (short) 0, 20, false, true, "astools.use"), ARMS ("gui_arms", Material.ARROW, 48, "astools.use", false),
RLEGX ("rLegX", Material.BLAZE_ROD, (short) 0, 21, false, true, "astools.use"), BASE ("gui_base", Material.STONE_SLAB, 49, "astools.use", false),
RLEGY ("rLegY", Material.BLAZE_ROD, (short) 0, 22, false, true, "astools.use"), SIZE ("gui_size", Material.EMERALD, 50, "astools.use", false),
RLEGZ ("rLegZ", Material.BLAZE_ROD, (short) 0, 23, false, true, "astools.use"), GRAV ("gui_grav", Material.GHAST_TEAR, 51, "astools.use", false),
BODYX ("bodyX", Material.NETHER_BRICKS, (short) 0, 9, false, true, "astools.use"), INVUL ("gui_invul", Material.GLISTERING_MELON_SLICE, 52, "astools.use", false),
BODYY ("bodyY", Material.NETHER_BRICKS, (short) 0, 10, false, true, "astools.use"), GLOW ("gui_glow", Material.GLOWSTONE, 53, "astools.glow", false);
BODYZ ("bodyZ", Material.NETHER_BRICKS, (short) 0, 11, false, true, "astools.use"),
SUMMON ("summon", Material.ARMOR_STAND, (short) 0, 0, false, true, "astools.summon"),
GUI ("gui", Material.NETHER_STAR, (short) 0, 1, false, true, "astools.use"),
ROTAT ("rotat", Material.MAGMA_CREAM, (short) 0, 2, false, true, "astools.use"),
CLONE ("gui_clone", Material.GLOWSTONE_DUST, (short) 0, 15, true, true, "astools.clone"),
SAVE ("gui_save", Material.DIAMOND, (short) 0, 16, true, true, "astools.cmdblock"),
INVIS ("gui_invis", Material.GOLD_NUGGET, (short) 0, 7, true, true, "astools.use"),
SIZE ("gui_size", Material.EMERALD, (short) 0, 25, true, true, "astools.use"),
BASE ("gui_base", Material.STONE_SLAB, (short) 0, 24, true, true, "astools.use"),
GRAV ("gui_grav", Material.GHAST_TEAR, (short) 0, 32, true, true, "astools.use"),
ARMS ("gui_arms", Material.ARROW, (short) 0, 23, true, true, "astools.use"),
NAME ("gui_name", Material.NAME_TAG, (short) 0, 5, true, true, "astools.use"),
SLOTS ("gui_slots", Material.IRON_HOE, (short) 0, 34, true, true, "astools.use"),
PHEAD ("gui_pHead", Material.PLAYER_HEAD, (short) 3, 6, true, true, "astools.head"),
INVUL ("gui_invul", Material.GLISTERING_MELON_SLICE,(short) 0, 33, true, true, "astools.use"),
MOVE ("gui_move", Material.FEATHER, (short) 0, 14, true, true, "astools.use"),
GLOW ("gui_glow", Material.GLOWSTONE, (short) 0, 8, true, true, "astools.glow");
private final ItemStack item; private final ItemStack item;
private final String id; private final String config_id;
private final int slot; private final int slot;
private boolean enabled; private boolean enabled;
private final boolean forGui;
private final String permission; private final String permission;
private final boolean reverseSneaking;
private String name;
ArmorStandTool(String id, Material m, short data, int slot, boolean forGui, boolean enabled, String permission) { ArmorStandTool(String config_id, Material m, int slot, String permission, boolean reverseSneaking) {
item = new ItemStack(m, 1, data); item = new ItemStack(m);
this.id = id; this.config_id = config_id;
this.slot = slot; this.slot = slot;
this.forGui = forGui; this.enabled = true;
this.enabled = enabled;
this.permission = permission; this.permission = permission;
this.reverseSneaking = reverseSneaking;
} }
ItemStack getItem() { void showTitle(Player p) {
return item; boolean sneaking = p.isSneaking();
ChatColor offColor = ChatColor.WHITE;
ChatColor onColor = ChatColor.YELLOW;
ChatColor divColor = ChatColor.BLACK;
String msg =
(sneaking ? offColor : onColor) +
Config.normal + ": X/" + (reverseSneaking ? "Z" : "Y") +
divColor + " | " +
(sneaking ? onColor : offColor) +
Config.crouch + ": X/" + (reverseSneaking ? "Y" : "Z") +
divColor + " | " +
offColor + Config.click + ": " + Config.finish;
p.sendTitle(" ", msg, 0, 600, 0);
} }
private boolean is(ItemStack is) { private boolean is(ItemStack is) {
return is != null && is.getType() == item.getType() && is.hasItemMeta() && return is != null &&
is.getType() == item.getType() &&
is.getItemMeta() != null &&
is.getItemMeta().hasDisplayName() && is.getItemMeta().hasDisplayName() &&
item.getItemMeta() != null &&
is.getItemMeta().getDisplayName().equals(item.getItemMeta().getDisplayName()); is.getItemMeta().getDisplayName().equals(item.getItemMeta().getDisplayName());
} }
boolean isForGui() {
return forGui;
}
void setEnabled(FileConfiguration config) { void setEnabled(FileConfiguration config) {
enabled = config.getBoolean("enableTool." + id); enabled = config.getBoolean("enableTool." + config_id);
} }
boolean isEnabled() { boolean isEnabled() {
@ -93,41 +94,145 @@ public enum ArmorStandTool {
return slot; return slot;
} }
static void updateTools(FileConfiguration config) { void use(Player p, ArmorStand as) {
for(ArmorStandTool t : values()) { if(as == null || as.isDead()) {
ItemMeta im = t.item.getItemMeta(); UUID uuid = p.getUniqueId();
im.setDisplayName(ChatColor.YELLOW + config.getString("tool." + t.id + ".name")); AST.selectedArmorStand.remove(uuid);
im.setLore(config.getStringList("tool." + t.id + ".lore")); AST.activeTool.remove(uuid);
t.item.setItemMeta(im); return;
}
EulerAngle eulerAngle;
switch (this) {
case MOVE:
as.teleport(Utils.getLocationFacing(p.getLocation()));
Utils.title(p, Config.carrying);
return;
case HEAD:
eulerAngle = as.getHeadPose();
break;
case BODY:
eulerAngle = as.getBodyPose();
break;
case LARM:
eulerAngle = as.getLeftArmPose();
break;
case RARM:
eulerAngle = as.getRightArmPose();
break;
case LLEG:
eulerAngle = as.getLeftLegPose();
break;
case RLEG:
eulerAngle = as.getRightLegPose();
break;
default:
return;
}
eulerAngle = eulerAngle.setX(getPitch(p));
boolean sneaking = reverseSneaking != p.isSneaking();
double yaw = getRelativeYaw(p, as);
eulerAngle = sneaking ? eulerAngle.setZ(yaw) : eulerAngle.setY(yaw);
showTitle(p);
switch (this) {
case HEAD -> as.setHeadPose(eulerAngle);
case BODY -> as.setBodyPose(eulerAngle);
case LARM -> as.setLeftArmPose(eulerAngle);
case RARM -> as.setRightArmPose(eulerAngle);
case LLEG -> as.setLeftLegPose(eulerAngle);
case RLEG -> as.setRightLegPose(eulerAngle);
} }
} }
static void give(Player p) { // Get pitch and format as 0 to 2pi radians
PlayerInventory i = p.getInventory(); // Actual pitch quadrupled for increased sensitivity
for(ArmorStandTool t : values()) { private double getPitch(Player p) {
if(t.enabled && !t.forGui) { double pitch = p.getLocation().getPitch() * 4;
i.setItem(t.slot, t.item); while(pitch < 0) {
} pitch += 360;
} }
while(pitch > 360) {
pitch -= 360;
}
return pitch * Math.PI / 180.0;
}
// Get yaw relative to armor stand facing direction and format as 0 to 2pi radians
// Actual yaw doubled for increased sensitivity, and reversed to create mirror effect
private double getRelativeYaw(Player p, ArmorStand as) {
double difference = p.getLocation().getYaw() - as.getLocation().getYaw();
double yaw = 360.0 - (difference * 2);
while(yaw < 0) {
yaw += 360;
}
while(yaw > 360) {
yaw -= 360;
}
return yaw * Math.PI / 180.0;
}
ItemStack updateLore(ArmorStand as) {
switch (this) {
case INVIS:
return setLore(item, ChatColor.AQUA + Config.asVisible + ": " + (as.isVisible() ? (ChatColor.GREEN + Config.isTrue) : (ChatColor.RED + Config.isFalse)));
case SIZE:
return setLore(item, ChatColor.AQUA + Config.size + ": " + (as.isSmall() ? (ChatColor.BLUE + Config.small) : (ChatColor.GREEN + Config.normal)));
case BASE:
return setLore(item, ChatColor.AQUA + Config.basePlate + ": " + (as.hasBasePlate() ? (ChatColor.GREEN + Config.isOn) : (ChatColor.RED + Config.isOff)));
case GRAV:
return setLore(item, ChatColor.AQUA + Config.gravity + ": " + (as.hasGravity() ? (ChatColor.GREEN + Config.isOn) : (ChatColor.RED + Config.isOff)));
case ARMS:
return setLore(item, ChatColor.AQUA + Config.arms + ": " + (as.hasArms() ? (ChatColor.GREEN + Config.isOn) : (ChatColor.RED + Config.isOff)));
case INVUL:
return setLore(item, ChatColor.AQUA + Config.invul + ": " + (as.isInvulnerable() ? (ChatColor.GREEN + Config.isOn) : (ChatColor.RED + Config.isOff)));
case SLOTS:
return setLore(item, ChatColor.AQUA + Config.equip + ": " + (Utils.hasDisabledSlots(as) ? (ChatColor.GREEN + Config.locked) : (ChatColor.RED + Config.unLocked)));
case NAME:
return setLore(item, ChatColor.AQUA + Config.currently + ": " + (as.getCustomName() == null ? (ChatColor.BLUE + Config.none) : (ChatColor.GREEN + as.getCustomName())));
case PHEAD:
String name = plrHeadName(as);
return setLore(item, ChatColor.AQUA + Config.currently + ": " + (name == null ? (ChatColor.BLUE + Config.none) : (ChatColor.GREEN + name)));
case GLOW:
return setLore(item, ChatColor.AQUA + Config.glow + ": " + (as.isGlowing() ? (ChatColor.GREEN + Config.isOn) : (ChatColor.RED + Config.isOff)));
default:
return item;
}
}
private ItemStack setLore(ItemStack is, String... lore) {
ItemMeta meta = is.getItemMeta();
if(meta != null) {
meta.setLore(Arrays.asList(lore));
is.setItemMeta(meta);
}
return is;
}
private String plrHeadName(ArmorStand as) {
EntityEquipment entityEquipment = as.getEquipment();
if(entityEquipment == null || entityEquipment.getHelmet() == null || !(entityEquipment.getHelmet().getItemMeta() instanceof SkullMeta)) return null;
SkullMeta meta = (SkullMeta) entityEquipment.getHelmet().getItemMeta();
if(meta.getOwningPlayer() == null) return null;
return meta.getOwningPlayer().getName();
} }
static ArmorStandTool get(ItemStack is) { static ArmorStandTool get(ItemStack is) {
if(is == null || !is.hasItemMeta() || !is.getItemMeta().hasDisplayName()) return null; if(is == null || is.getItemMeta() == null || !is.getItemMeta().hasDisplayName()) return null;
for(ArmorStandTool t : values()) { for(ArmorStandTool t : values()) {
if(t.is(is)) return t; if(t.is(is)) return t;
} }
return null; return null;
} }
static ArmorStandTool get(Player p) { static void updateTools(FileConfiguration config) {
return get(p.getInventory().getItemInMainHand()); for(ArmorStandTool t : values()) {
t.name = config.getString("tool." + t.config_id + ".name");
ItemMeta im = t.item.getItemMeta();
if(im != null) {
im.setDisplayName(ChatColor.YELLOW + t.name);
im.setLore(config.getStringList("tool." + t.config_id + ".lore"));
t.item.setItemMeta(im);
}
}
} }
static boolean isTool(ItemStack is) {
return get(is) != null;
}
static boolean isHoldingTool(Player p) {
return isTool(p.getInventory().getItemInMainHand());
}
} }

Datei anzeigen

@ -1,4 +1,4 @@
package com.gmail.St3venAU.plugins.ArmorStandTools; package com.gmail.st3venau.plugins.armorstandtools;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.Command; import org.bukkit.command.Command;
@ -12,52 +12,24 @@ import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID;
class Commands implements CommandExecutor, TabCompleter { class Commands implements CommandExecutor, TabCompleter {
private final Main plugin;
Commands(Main main) {
this.plugin = main;
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) { if (!(sender instanceof Player)) {
plugin.getLogger().warning(Config.notConsole); AST.plugin.getLogger().warning(Config.notConsole);
return false; return false;
} }
String cmd = command.getName().toLowerCase(); String cmd = command.getName().toLowerCase();
Player p = (Player) sender; Player p = (Player) sender;
if(cmd.equals("astools") || cmd.equals("ast")) { if(cmd.equals("astools") || cmd.equals("ast")) {
if (!Utils.hasPermissionNode(p, "astools.command")) { if (!Utils.hasPermissionNode(p, "astools.use")) {
p.sendMessage(ChatColor.RED + Config.noCommandPerm); p.sendMessage(ChatColor.RED + Config.noCommandPerm);
return true; return true;
} }
if (args.length == 0) { p.sendMessage(ChatColor.AQUA + Config.instructions);
UUID uuid = p.getUniqueId(); return true;
if (plugin.savedInventories.containsKey(uuid)) {
plugin.restoreInventory(p);
return true;
} else {
plugin.saveInventoryAndClear(p);
ArmorStandTool.give(p);
p.sendMessage(ChatColor.GREEN + Config.giveMsg1);
p.sendMessage(ChatColor.AQUA + Config.giveMsg2);
return true;
}
}
if (args[0].equalsIgnoreCase("reload")) {
if (Utils.hasPermissionNode(p, "astools.reload")) {
Config.reload();
p.sendMessage(ChatColor.GREEN + Config.conReload);
return true;
} else {
p.sendMessage(ChatColor.RED + Config.noRelPerm);
return true;
}
}
} else if(cmd.equals("ascmd")) { } else if(cmd.equals("ascmd")) {
ArmorStand as = getNearbyArmorStand(p); ArmorStand as = getNearbyArmorStand(p);
if(as == null) { if(as == null) {
@ -124,7 +96,7 @@ class Commands implements CommandExecutor, TabCompleter {
sb.append(args[i]).append(" "); sb.append(args[i]).append(" ");
} }
int startAt = sb.charAt(0) == '/' ? 1 : 0; int startAt = sb.charAt(0) == '/' ? 1 : 0;
String c = sb.toString().substring(startAt, sb.length() - 1); String c = sb.substring(startAt, sb.length() - 1);
if(c.length() == 0) { if(c.length() == 0) {
ascmdHelp(p); ascmdHelp(p);
return true; return true;
@ -146,7 +118,6 @@ class Commands implements CommandExecutor, TabCompleter {
if(args[1].equalsIgnoreCase("remove")) { if(args[1].equalsIgnoreCase("remove")) {
asCmd.setCooldownTime(-1); asCmd.setCooldownTime(-1);
p.sendMessage(Config.cooldownRemovedFrom + " " + Config.closestAS + name); p.sendMessage(Config.cooldownRemovedFrom + " " + Config.closestAS + name);
return true;
} else { } else {
int ticks; int ticks;
try { try {
@ -161,8 +132,8 @@ class Commands implements CommandExecutor, TabCompleter {
} }
asCmd.setCooldownTime(ticks); asCmd.setCooldownTime(ticks);
p.sendMessage(Config.cooldownSetTo + " " + ticks + " " + Config.ticksFor + " " + Config.closestAS + name); p.sendMessage(Config.cooldownSetTo + " " + ticks + " " + Config.ticksFor + " " + Config.closestAS + name);
return true;
} }
return true;
} else { } else {
ascmdHelp(p); ascmdHelp(p);
return true; return true;
@ -198,7 +169,7 @@ class Commands implements CommandExecutor, TabCompleter {
} }
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<>();
String cmd = command.getName().toLowerCase(); String cmd = command.getName().toLowerCase();
String typed = ""; String typed = "";
if (args.length > 0) { if (args.length > 0) {

Datei anzeigen

@ -1,73 +1,111 @@
package com.gmail.St3venAU.plugins.ArmorStandTools; package com.gmail.st3venau.plugins.armorstandtools;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import org.bukkit.Material;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.nio.charset.Charset; import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.logging.Level; import java.util.logging.Level;
class Config { class Config {
private static Main plugin; private static AST plugin;
private static File languageConfigFile; private static File languageConfigFile;
private static FileConfiguration languageConfig; private static FileConfiguration languageConfig;
static WorldGuardPlugin worldGuardPlugin; static WorldGuardPlugin worldGuardPlugin;
static ItemStack helmet, chest, pants, boots, itemInHand, itemInOffHand;
static boolean isVisible = true;
static boolean isSmall = false;
static boolean hasArms = true;
static boolean hasBasePlate = false;
static boolean hasGravity = false;
static String defaultName = "";
static boolean invulnerable = false;
static boolean equipmentLock = false;
static boolean allowMoveWorld = false; static boolean allowMoveWorld = false;
static boolean deactivateOnWorldChange = true;
static boolean debug = false; static boolean debug = false;
static boolean requireCreative = false; static boolean requireCreative = false;
static int defaultASCmdCooldownTicks = 0;
static boolean ignoreWGForASCmdExecution = false; static boolean ignoreWGForASCmdExecution = false;
static int defaultASCmdCooldownTicks = 0;
static final ArrayList<String> deniedCommands = new ArrayList<String>();
static String static String
invReturned, asDropped, asVisible, isTrue, isFalse, asDropped, asVisible, isTrue, isFalse, carrying,
carrying, cbCreated, size, small, normal, basePlate, cbCreated, size, small, normal, basePlate, isOn,
isOn, isOff, gravity, arms, invul, equip, locked, isOff, gravity, arms, invul, equip, locked,
unLocked, notConsole, giveMsg1, giveMsg2, conReload, unLocked, notConsole, noAirError, invalidName,
noRelPerm, noAirError, pleaseWait, appliedHead, wgNoPerm, currently, noCommandPerm, generalNoPerm,
invalidName, wgNoPerm, currently, headFailed, armorStand, none, guiInUse, noASNearBy, closestAS,
noCommandPerm, generalNoPerm, armorStand, none, creativeRequired, hasNoCmd, hasCmd, type, command,
guiInUse, noASNearBy, closestAS, creativeRequired, unassignedCmd, assignedCmdToAS, assignCmdError,
hasNoCmd, hasCmd, type, command, unassignedCmd, ascmdHelp, viewCmd, removeCmd, assignConsole,
assignedCmdToAS, assignCmdError, ascmdHelp, viewCmd, assignPlayer, executeCmdError, cmdOnCooldown,
removeCmd, assignConsole, assignPlayer, executeCmdError, cooldownRemovedFrom, isAnInvalidCooldown,
cmdOnCooldown, cooldownRemovedFrom, isAnInvalidCooldown, cooldownSetTo, ticksFor, setCooldown,
cooldownSetTo, ticksFor, setCooldown, removeCooldown, removeCooldown, glow, instructions, crouch, click,
cmdNotAllowed, glow; finish;
static void reload(Main main) { static void reload(AST main) {
plugin = main; plugin = main;
reload();
}
static void reload() {
reloadMainConfig(); reloadMainConfig();
saveDefaultLanguageConfig(); saveDefaultLanguageConfig();
reloadLanguageConfig(); reloadLanguageConfig();
ArmorStandTool.updateTools(languageConfig); ArmorStandTool.updateTools(languageConfig);
invReturned = languageConfig.getString("invReturned"); }
private static void reloadMainConfig() {
plugin.saveDefaultConfig();
plugin.reloadConfig();
FileConfiguration config = plugin.getConfig();
allowMoveWorld = config.getBoolean("allowMovingStandsBetweenWorlds");
requireCreative = config.getBoolean("requireCreativeForSaveAsCmdBlock");
defaultASCmdCooldownTicks = config.getInt("defaultASCmdCooldownTicks");
ignoreWGForASCmdExecution = config.getBoolean("bypassWorldguardForASCmdExecution");
debug = config.getBoolean("debug", false);
AST.activeTool.clear();
AST.selectedArmorStand.clear();
for(ArmorStandTool tool : ArmorStandTool.values()) {
tool.setEnabled(config);
}
Plugin plotSquared = plugin.getServer().getPluginManager().getPlugin("PlotSquared");
if (plotSquared != null && plotSquared.isEnabled()) {
try {
PlotSquaredHook.init();
plugin.getLogger().log(Level.INFO, "PlotSquared plugin was found. PlotSquared support enabled.");
}
catch (Throwable e) {
e.printStackTrace();
plugin.getLogger().log(Level.WARNING, "PlotSquared plugin was found, but there was an error initializing PlotSquared support.");
}
} else {
plugin.getLogger().log(Level.INFO, "PlotSquared plugin not found. Continuing without PlotSquared support.");
}
Plugin wgp = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
if(wgp instanceof WorldGuardPlugin) {
worldGuardPlugin = (WorldGuardPlugin) wgp;
}
if(config.getBoolean("integrateWithWorldGuard")) {
plugin.getLogger().log(Level.INFO, worldGuardPlugin == null ? "WorldGuard plugin not found. Continuing without WorldGuard support." : "WorldGuard plugin found. WorldGuard support enabled.");
} else if(worldGuardPlugin != null) {
plugin.getLogger().log(Level.WARNING, "WorldGuard plugin was found, but integrateWithWorldGuard is set to false in config.yml. Continuing without WorldGuard support.");
worldGuardPlugin = null;
}
}
private static void saveDefaultLanguageConfig() {
languageConfigFile = new File(plugin.getDataFolder(), "language.yml");
if (!languageConfigFile.exists()) {
plugin.saveResource("language.yml", false);
}
}
private static void reloadLanguageConfig() {
languageConfigFile = new File(plugin.getDataFolder(), "language.yml");
languageConfig = YamlConfiguration.loadConfiguration(languageConfigFile);
InputStream defConfigStream = plugin.getResource("language.yml");
if (defConfigStream != null) {
languageConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, StandardCharsets.UTF_8)));
}
asDropped = languageConfig.getString("asDropped"); asDropped = languageConfig.getString("asDropped");
asVisible = languageConfig.getString("asVisible"); asVisible = languageConfig.getString("asVisible");
isTrue = languageConfig.getString("isTrue"); isTrue = languageConfig.getString("isTrue");
@ -87,18 +125,11 @@ class Config {
locked = languageConfig.getString("locked"); locked = languageConfig.getString("locked");
unLocked = languageConfig.getString("unLocked"); unLocked = languageConfig.getString("unLocked");
notConsole = languageConfig.getString("notConsole"); notConsole = languageConfig.getString("notConsole");
giveMsg1 = languageConfig.getString("giveMsg1");
giveMsg2 = languageConfig.getString("giveMsg2");
conReload = languageConfig.getString("conReload");
noRelPerm = languageConfig.getString("noRelPerm");
noAirError = languageConfig.getString("noAirError"); noAirError = languageConfig.getString("noAirError");
pleaseWait = languageConfig.getString("pleaseWait");
appliedHead = languageConfig.getString("appliedHead");
invalidName = languageConfig.getString("invalidName"); invalidName = languageConfig.getString("invalidName");
wgNoPerm = languageConfig.getString("wgNoPerm"); wgNoPerm = languageConfig.getString("wgNoPerm");
noCommandPerm = languageConfig.getString("noCommandPerm"); noCommandPerm = languageConfig.getString("noCommandPerm");
currently = languageConfig.getString("currently"); currently = languageConfig.getString("currently");
headFailed = languageConfig.getString("headFailed");
generalNoPerm = languageConfig.getString("generalNoPerm"); generalNoPerm = languageConfig.getString("generalNoPerm");
armorStand = languageConfig.getString("armorStand"); armorStand = languageConfig.getString("armorStand");
none = languageConfig.getString("none"); none = languageConfig.getString("none");
@ -125,119 +156,13 @@ class Config {
cooldownSetTo = languageConfig.getString("cooldownSetTo"); cooldownSetTo = languageConfig.getString("cooldownSetTo");
ticksFor = languageConfig.getString("ticksFor"); ticksFor = languageConfig.getString("ticksFor");
setCooldown = languageConfig.getString("setCooldown"); setCooldown = languageConfig.getString("setCooldown");
removeCooldown = languageConfig.getString("removeCooldown");
ticksFor = languageConfig.getString("ticksFor"); ticksFor = languageConfig.getString("ticksFor");
cmdNotAllowed = languageConfig.getString("cmdNotAllowed");
glow = languageConfig.getString("glow"); glow = languageConfig.getString("glow");
} instructions = languageConfig.getString("instructions");
crouch = languageConfig.getString("crouch");
private static void reloadMainConfig() { click = languageConfig.getString("click");
plugin.saveDefaultConfig(); finish = languageConfig.getString("finish");
plugin.reloadConfig();
FileConfiguration config = plugin.getConfig();
helmet = toItemStack(config.getString("helmet"));
chest = toItemStack(config.getString("chest"));
pants = toItemStack(config.getString("pants"));
boots = toItemStack(config.getString("boots"));
itemInHand = toItemStack(config.getString("inHand"));
itemInOffHand = toItemStack(config.getString("inOffHand"));
isVisible = config.getBoolean("isVisible");
isSmall = config.getBoolean("isSmall");
hasArms = config.getBoolean("hasArms");
hasBasePlate = config.getBoolean("hasBasePlate");
hasGravity = config.getBoolean("hasGravity");
defaultName = config.getString("name");
invulnerable = config.getBoolean("invulnerable");
equipmentLock = config.getBoolean("equipmentLock");
allowMoveWorld = config.getBoolean("allowMovingStandsBetweenWorlds");
deactivateOnWorldChange = config.getBoolean("deactivateToolsOnWorldChange");
requireCreative = config.getBoolean("requireCreativeForSaveAsCmdBlock");
defaultASCmdCooldownTicks = config.getInt("defaultASCmdCooldownTicks");
ignoreWGForASCmdExecution = config.getBoolean("bypassWorldguardForASCmdExecution");
debug = config.getBoolean("debug", false);
plugin.carryingArmorStand.clear();
deniedCommands.clear();
for(String deniedCmd : config.getStringList("deniedCommandsWhileUsingTools")) {
deniedCmd = deniedCmd.split(" ")[0].toLowerCase();
while(deniedCmd.length() > 0 && deniedCmd.charAt(0) == '/') {
deniedCmd = deniedCmd.substring(1);
}
if(deniedCmd.length() > 0) {
deniedCommands.add(deniedCmd);
}
}
for(ArmorStandTool tool : ArmorStandTool.values()) {
tool.setEnabled(config);
}
Plugin plotSquared = plugin.getServer().getPluginManager().getPlugin("PlotSquared");
if (plotSquared != null && plotSquared.isEnabled()) {
try {
new PlotSquaredHook(plugin);
plugin.getLogger().log(Level.INFO, "PlotSquared plugin was found. PlotSquared support enabled.");
}
catch (Throwable e) {
e.printStackTrace();
plugin.getLogger().log(Level.WARNING, "PlotSquared plugin was found, but there was an error initializing PlotSquared support.");
}
} else {
plugin.getLogger().log(Level.INFO, "PlotSquared plugin not found. Continuing without PlotSquared support.");
}
Plugin wgp = plugin.getServer().getPluginManager().getPlugin("WorldGuard");
if(wgp != null && wgp instanceof WorldGuardPlugin) {
worldGuardPlugin = (WorldGuardPlugin) wgp;
}
if(config.getBoolean("integrateWithWorldGuard")) {
plugin.getLogger().log(Level.INFO, worldGuardPlugin == null ? "WorldGuard plugin not found. Continuing without WorldGuard support." : "WorldGuard plugin found. WorldGuard support enabled.");
} else if(worldGuardPlugin != null) {
plugin.getLogger().log(Level.WARNING, "WorldGuard plugin was found, but integrateWithWorldGuard is set to false in config.yml. Continuing without WorldGuard support.");
worldGuardPlugin = null;
}
}
private static void reloadLanguageConfig() {
languageConfigFile = new File(plugin.getDataFolder(), "language.yml");
languageConfig = YamlConfiguration.loadConfiguration(languageConfigFile);
InputStream defConfigStream = plugin.getResource("language.yml");
if (defConfigStream != null) {
languageConfig.setDefaults(YamlConfiguration.loadConfiguration(new InputStreamReader(defConfigStream, Charset.forName("UTF-8"))));
}
}
private static void saveDefaultLanguageConfig() {
languageConfigFile = new File(plugin.getDataFolder(), "language.yml");
if (!languageConfigFile.exists()) {
plugin.saveResource("language.yml", false);
}
}
private static ItemStack toItemStack(String s) {
if(s == null || s.length() == 0) {
return new ItemStack(Material.AIR);
}
String[] split = s.split(" ");
if(split.length > 2) {
plugin.getLogger().warning("Error in config.yml: Must use the format: MATERIAL_NAME dataValue. Continuing using AIR instead.");
return new ItemStack(Material.AIR);
}
byte dataValue = (byte) 0;
if(split.length == 2) {
try {
dataValue = Byte.parseByte(split[1]);
} catch (NumberFormatException nfe) {
plugin.getLogger().warning("Error in config.yml: Invalid data value specifed. Continuing using data value 0 instead.");
}
}
Material m;
try {
m = Material.valueOf(split[0].toUpperCase());
} catch(IllegalArgumentException iae) {
plugin.getLogger().warning("Error in config.yml: Invalid material name specifed. Continuing using AIR instead.");
return new ItemStack(Material.AIR);
}
return new ItemStack(m, 1, dataValue);
} }
} }

Datei anzeigen

@ -1,240 +0,0 @@
package com.gmail.St3venAU.plugins.ArmorStandTools;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.RegionContainer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.UUID;
import java.util.logging.Level;
public class Main extends JavaPlugin {
private static final String LATEST_VERSION = "v1_16_R3";
private static Object WG_AST_FLAG;
static NMS nms;
final HashMap<UUID, ArmorStand> carryingArmorStand = new HashMap<UUID, ArmorStand>();
final HashMap<UUID, ItemStack[]> savedInventories = new HashMap<UUID, ItemStack[]>();
static Main plugin;
@SuppressWarnings("unchecked")
@Override
public void onLoad() {
if (getServer().getPluginManager().getPlugin("WorldGuard") != null) {
try {
// Need to do this with reflection for some reason, otherwise plugin load fails when worldguard is not present, even though this code block is not actually executed unless worldguard is present ???
WG_AST_FLAG = Class.forName("com.sk89q.worldguard.protection.flags.StateFlag").getConstructor(String.class, boolean.class).newInstance("ast", true);
Class worldGuardClass = Class.forName("com.sk89q.worldguard.WorldGuard");
Object worldGuard = worldGuardClass.getMethod("getInstance").invoke(worldGuardClass);
Object flagRegistry = worldGuardClass.getMethod("getFlagRegistry").invoke(worldGuard);
flagRegistry.getClass().getMethod("register", Class.forName("com.sk89q.worldguard.protection.flags.Flag")).invoke(flagRegistry, WG_AST_FLAG);
getLogger().info("Registered custom WorldGuard flag: ast");
} catch (Exception e) {
getLogger().info("Failed to register custom WorldGuard flag");
}
}
}
@Override
public void onEnable() {
plugin = this;
if(!loadSpigotVersionSupport()) {
setEnabled(false);
return;
}
getServer().getPluginManager().registerEvents(new MainListener(this), this);
Commands cmds = new Commands(this);
getCommand("astools").setExecutor(cmds);
getCommand("ascmd").setExecutor(cmds);
getCommand("ascmd").setTabCompleter(cmds);
Config.reload(this);
}
@Override
public void onDisable() {
for(ArmorStand as : carryingArmorStand.values()) {
returnArmorStand(as);
}
carryingArmorStand.clear();
Player p;
for(UUID uuid : savedInventories.keySet()) {
p = getServer().getPlayer(uuid);
if(p != null && p.isOnline()) {
restoreInventory(p);
}
}
savedInventories.clear();
}
private boolean loadSpigotVersionSupport() {
String nmsVersion = getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
String usingVersion;
if(nmsVersion.startsWith("v1_4") || nmsVersion.startsWith("v1_5") || nmsVersion.startsWith("v1_6") ||
nmsVersion.startsWith("v1_7") || nmsVersion.startsWith("v1_8") || nmsVersion.startsWith("v1_9") ||
nmsVersion.startsWith("v1_10") || nmsVersion.startsWith("v1_11") || nmsVersion.startsWith("v1_12")) {
getLogger().warning("This Craftbukkit/Spigot version is not supported. Craftbukkit/Spigot 1.13+ required. Loading plugin failed.");
return false;
}
try {
if(NMS.class.isAssignableFrom(Class.forName("com.gmail.St3venAU.plugins.ArmorStandTools.NMS_" + nmsVersion))) {
usingVersion = nmsVersion;
getLogger().info("Loading support for " + usingVersion);
} else {
usingVersion = LATEST_VERSION;
getLogger().warning("Support for " + nmsVersion + " not found, trying " + usingVersion + ". Please check for possible updates to the plugin.");
}
} catch (Exception e) {
usingVersion = LATEST_VERSION;
getLogger().warning("Support for " + nmsVersion + " not found, trying " + usingVersion + ". Please check for possible updates to the plugin.");
}
try {
nms = (NMS) Class.forName("com.gmail.St3venAU.plugins.ArmorStandTools.NMS_" + usingVersion).getConstructor(String.class).newInstance(nmsVersion);
} catch (Exception e) {
e.printStackTrace();
getLogger().warning("An error occurred while attempting to load support for this version of Craftbukkit/Spigot. Loading plugin failed.");
return false;
}
return true;
}
void returnArmorStand(ArmorStand as) {
if(as.hasMetadata("startLoc")) {
for (MetadataValue value : as.getMetadata("startLoc")) {
if (value.getOwningPlugin() == this) {
as.teleport((Location) value.value());
as.removeMetadata("startLoc", this);
return;
}
}
}
as.remove();
}
private void removeAllTools(Player p) {
PlayerInventory i = p.getInventory();
for(ArmorStandTool t : ArmorStandTool.values()) {
i.remove(t.getItem());
}
}
void saveInventoryAndClear(Player p) {
ItemStack[] inv = p.getInventory().getContents().clone();
savedInventories.put(p.getUniqueId(), inv);
p.getInventory().clear();
}
void restoreInventory(Player p) {
removeAllTools(p);
UUID uuid = p.getUniqueId();
ItemStack[] savedInv = savedInventories.get(uuid);
if(savedInv == null) return;
PlayerInventory plrInv = p.getInventory();
ItemStack[] newItems = plrInv.getContents().clone();
plrInv.setContents(savedInv);
savedInventories.remove(uuid);
for(ItemStack i : newItems) {
if(i == null) continue;
HashMap<Integer, ItemStack> couldntFit = plrInv.addItem(i);
for (ItemStack is : couldntFit.values()) {
p.getWorld().dropItem(p.getLocation(), is);
}
}
p.sendMessage(ChatColor.GREEN + Config.invReturned);
}
void pickUpArmorStand(ArmorStand as, Player p, boolean newlySummoned) {
carryingArmorStand.put(p.getUniqueId(), as);
if(newlySummoned) return;
as.setMetadata("startLoc", new FixedMetadataValue(this, as.getLocation()));
}
void setName(Player p, ArmorStand as) {
Block b = Utils.findAnAirBlock(p.getLocation());
if(b == null) {
p.sendMessage(ChatColor.RED + Config.noAirError);
return;
}
b.setType(Material.OAK_SIGN);
nms.openSign(p, b);
b.setMetadata("armorStand", new FixedMetadataValue(this, as.getUniqueId()));
b.setMetadata("setName", new FixedMetadataValue(this, true));
}
void setPlayerSkull(Player p, ArmorStand as) {
Block b = Utils.findAnAirBlock(p.getLocation());
if(b == null) {
p.sendMessage(ChatColor.RED + Config.noAirError);
return;
}
b.setType(Material.OAK_SIGN);
nms.openSign(p, b);
b.setMetadata("armorStand", new FixedMetadataValue(this, as.getUniqueId()));
b.setMetadata("setSkull", new FixedMetadataValue(this, true));
}
boolean checkBlockPermission(Player p, Block b) {
if(b == null) return true;
debug("PlotSquaredHook.api: " + PlotSquaredHook.api);
if (PlotSquaredHook.api != null) {
Location l = b.getLocation();
debug("PlotSquaredHook.isPlotWorld(l): " + PlotSquaredHook.isPlotWorld(l));
if(PlotSquaredHook.isPlotWorld(l)) {
return PlotSquaredHook.checkPermission(p, l);
}
}
if(Config.worldGuardPlugin != null) {
if(!Utils.hasPermissionNode(p, "astools.bypass-wg-flag") && !getWorldGuardAstFlag(b.getLocation())) {
return false;
}
return Config.worldGuardPlugin.createProtectionQuery().testBlockBreak(p, b);
}
BlockBreakEvent breakEvent = new BlockBreakEvent(b, p);
Bukkit.getServer().getPluginManager().callEvent(breakEvent);
return !breakEvent.isCancelled();
}
private boolean getWorldGuardAstFlag(Location l) {
if (l != null) {
RegionContainer regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
RegionManager regions = regionContainer.get(BukkitAdapter.adapt(l.getWorld()));
if (regions == null) return true;
return regions.getApplicableRegions(BukkitAdapter.asBlockVector(l)).testState(null, (StateFlag) WG_AST_FLAG);
} else {
return false;
}
}
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()));
}
return (tool == null || (tool.isEnabled() && Utils.hasPermissionNode(p, tool.getPermission()))) && checkBlockPermission(p, b);
}
void debug(String msg) {
if(Config.debug) {
getLogger().log(Level.INFO, "[DEBUG] " + msg);
}
}
}

Datei anzeigen

@ -1,382 +1,140 @@
package com.gmail.St3venAU.plugins.ArmorStandTools; package com.gmail.st3venau.plugins.armorstandtools;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryDragEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue; import org.bukkit.metadata.MetadataValue;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.Arrays;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.regex.Pattern; import java.util.regex.Pattern;
public class MainListener implements Listener { public class MainListener implements Listener {
private final Pattern MC_USERNAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_]{3,16}$"); private static final Pattern MC_USERNAME_PATTERN = Pattern.compile("^[a-zA-Z0-9_]{3,16}$");
private final Main plugin;
MainListener(Main main) {
this.plugin = main;
}
@EventHandler @EventHandler
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
if(event.getRightClicked() instanceof ArmorStand) { Player p = event.getPlayer();
Player p = event.getPlayer(); if(stopEditing(p, false)) {
ArmorStand as = (ArmorStand) event.getRightClicked(); event.setCancelled(true);
if(!event.isCancelled() && ArmorStandGUI.isInUse(as)) { }
Utils.actionBarMsg(p, Config.guiInUse); if(!(event.getRightClicked() instanceof ArmorStand)) return;
ArmorStand as = (ArmorStand) event.getRightClicked();
if(!event.isCancelled() && ArmorStandGUI.isInUse(as)) {
Utils.title(p, Config.guiInUse);
event.setCancelled(true);
return;
}
if(!event.isCancelled() && p.isSneaking()) {
if (!AST.playerHasPermission(p, as.getLocation().getBlock(), null)) {
p.sendMessage(ChatColor.RED + Config.generalNoPerm);
return;
}
new ArmorStandGUI(as, p);
event.setCancelled(true);
return;
}
if((Config.ignoreWGForASCmdExecution || !event.isCancelled()) && !p.isSneaking()) {
ArmorStandCmd asCmd = new ArmorStandCmd(as);
if (asCmd.getCommand() != null) {
event.setCancelled(true); event.setCancelled(true);
return; if (Utils.hasPermissionNode(p, "astools.ascmd.execute")) {
} if (!asCmd.execute(p)) {
if(!event.isCancelled() && plugin.carryingArmorStand.containsKey(p.getUniqueId())) { p.sendMessage(Config.executeCmdError);
if (plugin.playerHasPermission(p, plugin.carryingArmorStand.get(p.getUniqueId()).getLocation().getBlock(), null)) {
plugin.carryingArmorStand.remove(p.getUniqueId());
Utils.actionBarMsg(p, Config.asDropped);
event.setCancelled(true);
return;
} else {
p.sendMessage(ChatColor.RED + Config.wgNoPerm);
}
}
ArmorStandTool tool = ArmorStandTool.get(p);
if(!event.isCancelled() && tool != null) {
if (!plugin.playerHasPermission(p, as.getLocation().getBlock(), tool)) {
p.sendMessage(ChatColor.RED + Config.generalNoPerm);
event.setCancelled(true);
return;
}
double num = event.getClickedPosition().getY() - 0.05;
if (num < 0) {
num = 0;
} else if (num > 2) {
num = 2;
}
num = 2.0 - num;
double angle = num * Math.PI;
boolean cancel = true;
switch (tool) {
case HEADX:
as.setHeadPose(as.getHeadPose().setX(angle));
break;
case HEADY:
as.setHeadPose(as.getHeadPose().setY(angle));
break;
case HEADZ:
as.setHeadPose(as.getHeadPose().setZ(angle));
break;
case LARMX:
as.setLeftArmPose(as.getLeftArmPose().setX(angle));
break;
case LARMY:
as.setLeftArmPose(as.getLeftArmPose().setY(angle));
break;
case LARMZ:
as.setLeftArmPose(as.getLeftArmPose().setZ(angle));
break;
case RARMX:
as.setRightArmPose(as.getRightArmPose().setX(angle));
break;
case RARMY:
as.setRightArmPose(as.getRightArmPose().setY(angle));
break;
case RARMZ:
as.setRightArmPose(as.getRightArmPose().setZ(angle));
break;
case LLEGX:
as.setLeftLegPose(as.getLeftLegPose().setX(angle));
break;
case LLEGY:
as.setLeftLegPose(as.getLeftLegPose().setY(angle));
break;
case LLEGZ:
as.setLeftLegPose(as.getLeftLegPose().setZ(angle));
break;
case RLEGX:
as.setRightLegPose(as.getRightLegPose().setX(angle));
break;
case RLEGY:
as.setRightLegPose(as.getRightLegPose().setY(angle));
break;
case RLEGZ:
as.setRightLegPose(as.getRightLegPose().setZ(angle));
break;
case BODYX:
as.setBodyPose(as.getBodyPose().setX(angle));
break;
case BODYY:
as.setBodyPose(as.getBodyPose().setY(angle));
break;
case BODYZ:
as.setBodyPose(as.getBodyPose().setZ(angle));
break;
case MOVEX:
as.teleport(as.getLocation().add(0.05 * (p.isSneaking() ? -1 : 1), 0.0, 0.0));
break;
case MOVEY:
as.teleport(as.getLocation().add(0.0, 0.05 * (p.isSneaking() ? -1 : 1), 0.0));
break;
case MOVEZ:
as.teleport(as.getLocation().add(0.0, 0.0, 0.05 * (p.isSneaking() ? -1 : 1)));
break;
case ROTAT:
Location l = as.getLocation();
l.setYaw(((float) num) * 180F);
as.teleport(l);
break;
case GUI:
new ArmorStandGUI(plugin, as, p);
break;
default:
cancel = tool == ArmorStandTool.SUMMON || tool == ArmorStandTool.SAVE || event.isCancelled();
}
event.setCancelled(cancel);
return;
}
if((Config.ignoreWGForASCmdExecution || !event.isCancelled()) && !p.isSneaking()) {
ArmorStandCmd asCmd = new ArmorStandCmd(as);
if (asCmd.getCommand() != null) {
event.setCancelled(true);
if (Utils.hasPermissionNode(p, "astools.ascmd.execute")) {
if (!asCmd.execute(p)) {
p.sendMessage(Config.executeCmdError);
}
} }
} }
} }
} }
} }
@EventHandler ArmorStand getCarryingArmorStand(Player p) {
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { UUID uuid = p.getUniqueId();
if (event.getRightClicked() instanceof ItemFrame && ArmorStandTool.isHoldingTool(event.getPlayer())) { return ArmorStandTool.MOVE == AST.activeTool.get(uuid)
event.setCancelled(true); ? AST.selectedArmorStand.get(uuid)
//noinspection deprecation : null;
event.getPlayer().updateInventory();
}
}
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (ArmorStandTool.isHoldingTool(event.getPlayer())) {
event.setCancelled(true);
}
}
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
Player p = event.getPlayer();
if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) {
ArmorStand as = plugin.carryingArmorStand.get(p.getUniqueId());
if (as == null || as.isDead()) {
plugin.carryingArmorStand.remove(p.getUniqueId());
Utils.actionBarMsg(p, Config.asDropped);
return;
}
as.teleport(Utils.getLocationFacing(event.getTo()));
Utils.actionBarMsg(p, Config.carrying);
}
} }
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void onPlayerTeleport(PlayerTeleportEvent event) { public void onPlayerTeleport(PlayerTeleportEvent event) {
if(event.getTo() == null || event.getFrom().getWorld() == event.getTo().getWorld()) return;
final Player p = event.getPlayer(); final Player p = event.getPlayer();
boolean sameWorld = event.getFrom().getWorld() == event.getTo().getWorld(); final ArmorStand as = getCarryingArmorStand(p);
if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) { if (as == null || as.isDead()) {
UUID uuid = event.getPlayer().getUniqueId(); stopEditing(p,false);
final ArmorStand as = plugin.carryingArmorStand.get(uuid);
if (as == null || as.isDead()) {
plugin.carryingArmorStand.remove(p.getUniqueId());
Utils.actionBarMsg(p, Config.asDropped);
return;
}
if(sameWorld || Config.allowMoveWorld) {
new BukkitRunnable() {
@Override
public void run() {
as.teleport(Utils.getLocationFacing(p.getLocation()));
Utils.actionBarMsg(p, Config.carrying);
}
}.runTaskLater(plugin, 1L);
} else {
plugin.returnArmorStand(plugin.carryingArmorStand.get(uuid));
plugin.carryingArmorStand.remove(uuid);
if (plugin.savedInventories.containsKey(uuid)) {
plugin.restoreInventory(p);
}
}
}
if(Config.deactivateOnWorldChange && !sameWorld && plugin.savedInventories.containsKey(p.getUniqueId())) {
plugin.restoreInventory(p);
}
}
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event) {
final Player p = event.getEntity();
List<ItemStack> drops = event.getDrops();
for(ArmorStandTool t : ArmorStandTool.values()) {
drops.remove(t.getItem());
}
if(p.getWorld().getGameRuleValue("keepInventory").equalsIgnoreCase("true")) return;
if(Bukkit.getServer().getPluginManager().getPermission("essentials.keepinv") != null && Utils.hasPermissionNode(p, "essentials.keepinv", true)) return;
if(plugin.savedInventories.containsKey(p.getUniqueId())) {
drops.addAll(Arrays.asList(plugin.savedInventories.get(p.getUniqueId())));
plugin.savedInventories.remove(p.getUniqueId());
}
}
@EventHandler
public void onCraftItem(CraftItemEvent event) {
if (event.isCancelled()) return;
final Player p = (Player) event.getWhoClicked();
CraftingInventory inventory = event.getInventory();
for(ItemStack is : inventory.getContents()) {
if(ArmorStandTool.isTool(is)) {
event.setCancelled(true);
//noinspection deprecation
p.updateInventory();
return;
}
}
}
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
if (event.isCancelled() || !(event.getWhoClicked() instanceof Player)) return;
final Player p = (Player) event.getWhoClicked();
ItemStack item = event.getCurrentItem();
if(event.getInventory().getHolder() != p && ArmorStandTool.isTool(item)) {
event.setCancelled(true);
//noinspection deprecation
p.updateInventory();
return; return;
} }
if(event.getAction() == InventoryAction.HOTBAR_SWAP || event.getAction() == InventoryAction.HOTBAR_MOVE_AND_READD) { if (!Config.allowMoveWorld) {
if(Utils.hasAnyTools(p)) { AST.returnArmorStand(as);
event.setCancelled(true); stopEditing(p, true);
//noinspection deprecation
p.updateInventory();
}
}
}
@EventHandler
public void onInventoryDrag(InventoryDragEvent event) {
if (event.isCancelled() || !(event.getWhoClicked() instanceof Player)) return;
final Player p = (Player) event.getWhoClicked();
if (event.getInventory().getHolder() != p && Utils.containsItems(event.getNewItems().values())) {
event.setCancelled(true);
//noinspection deprecation
p.updateInventory();
}
}
@EventHandler
public void onPlayerDropItem(final PlayerDropItemEvent event) {
if (ArmorStandTool.isTool(event.getItemDrop().getItemStack())) {
event.getItemDrop().remove();
} }
} }
@EventHandler @EventHandler
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
UUID uuid = event.getPlayer().getUniqueId(); stopEditing(event.getPlayer(), true);
if(plugin.carryingArmorStand.containsKey(uuid)) { }
plugin.returnArmorStand(plugin.carryingArmorStand.get(uuid));
plugin.carryingArmorStand.remove(uuid); boolean stopEditing(Player p, boolean force) {
ArmorStand carrying = getCarryingArmorStand(p);
if(carrying != null && !carrying.isDead()) {
if (AST.playerHasPermission(p, carrying.getLocation().getBlock(), null)) {
Utils.title(p, Config.asDropped);
carrying.removeMetadata("clone", AST.plugin);
} else {
if(force) {
AST.returnArmorStand(carrying);
} else {
p.sendMessage(ChatColor.RED + Config.wgNoPerm);
return true;
}
}
} }
if(plugin.savedInventories.containsKey(uuid)) { UUID uuid = p.getUniqueId();
plugin.restoreInventory(event.getPlayer()); AST.selectedArmorStand.remove(uuid);
boolean editing = AST.activeTool.containsKey(uuid);
if(editing) {
AST.activeTool.remove(uuid);
Utils.title(p, "");
} }
return editing;
} }
@EventHandler @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
final Player p = event.getPlayer(); Player p = event.getPlayer();
if(plugin.carryingArmorStand.containsKey(p.getUniqueId())) { if(stopEditing(p, false)) {
if (plugin.playerHasPermission(p, plugin.carryingArmorStand.get(p.getUniqueId()).getLocation().getBlock(), null)) { event.setCancelled(true);
plugin.carryingArmorStand.remove(p.getUniqueId());
Utils.actionBarMsg(p, Config.asDropped);
p.setMetadata("lastDrop", new FixedMetadataValue(plugin, System.currentTimeMillis()));
event.setCancelled(true);
} else {
p.sendMessage(ChatColor.RED + Config.wgNoPerm);
}
return;
} }
ArmorStandTool tool = ArmorStandTool.get(event.getItem());
if(tool == null) return;
event.setCancelled(true);
Action action = event.getAction();
if(action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) {
Utils.cycleInventory(p);
} else if((action == Action.RIGHT_CLICK_BLOCK || action == Action.RIGHT_CLICK_AIR) && tool == ArmorStandTool.SUMMON) {
if (!plugin.playerHasPermission(p, event.getClickedBlock(), tool)) {
p.sendMessage(ChatColor.RED + Config.generalNoPerm);
return;
}
Location l = Utils.getLocationFacing(p.getLocation());
plugin.pickUpArmorStand(spawnArmorStand(l), p, true);
Utils.actionBarMsg(p, Config.carrying);
}
new BukkitRunnable() {
@Override
public void run() {
//noinspection deprecation
p.updateInventory();
}
}.runTaskLater(plugin, 1L);
} }
@EventHandler @EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if(event.getEntity() instanceof ArmorStand) { if(event.getEntity() instanceof ArmorStand) {
ArmorStand as = (ArmorStand) event.getEntity(); ArmorStand as = (ArmorStand) event.getEntity();
if(event.getDamager() instanceof Player && stopEditing((Player) event.getDamager(), false)) {
event.setCancelled(true);
return;
}
if(ArmorStandGUI.isInUse(as) || as.isInvulnerable()) { if(ArmorStandGUI.isInUse(as) || as.isInvulnerable()) {
event.setCancelled(true); event.setCancelled(true);
} }
if(event.getDamager() instanceof Player && ArmorStandTool.isHoldingTool((Player) event.getDamager())) {
event.setCancelled(true);
if(noCooldown(event.getDamager())) {
Utils.cycleInventory((Player) event.getDamager());
}
}
} }
} }
@ -390,37 +148,6 @@ public class MainListener implements Listener {
} }
} }
private boolean noCooldown(Entity e) {
for(MetadataValue meta : e.getMetadata("lastDrop")) {
if(meta.getOwningPlugin() == plugin) {
return System.currentTimeMillis() - meta.asFloat() > 100;
}
}
return true;
}
private ArmorStand spawnArmorStand(Location l) {
ArmorStand as = (ArmorStand) l.getWorld().spawnEntity(l, EntityType.ARMOR_STAND);
as.setHelmet(Config.helmet);
as.setChestplate(Config.chest);
as.setLeggings(Config.pants);
as.setBoots(Config.boots);
as.getEquipment().setItemInMainHand(Config.itemInHand);
as.getEquipment().setItemInOffHand(Config.itemInOffHand);
as.setVisible(Config.isVisible);
as.setSmall(Config.isSmall);
as.setArms(Config.hasArms);
as.setBasePlate(Config.hasBasePlate);
as.setGravity(Config.hasGravity);
as.setInvulnerable(Config.invulnerable);
if(Config.defaultName.length() > 0) {
as.setCustomName(Config.defaultName);
as.setCustomNameVisible(true);
}
Main.nms.setSlotsDisabled(as, Config.equipmentLock);
return as;
}
@EventHandler @EventHandler
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
Block b = event.getBlock(); Block b = event.getBlock();
@ -431,84 +158,70 @@ public class MainListener implements Listener {
@EventHandler @EventHandler
public void onSignChange(final SignChangeEvent event) { public void onSignChange(final SignChangeEvent event) {
if(event.getBlock().hasMetadata("armorStand")) { final Block b = event.getBlock();
final Block b = event.getBlock(); if(!b.hasMetadata("armorStand")) {
final ArmorStand as = getArmorStand(b); return;
if (as != null) { }
StringBuilder sb = new StringBuilder(); final ArmorStand as = getArmorStand(b);
for (String line : event.getLines()) { if (as != null) {
if (line != null && line.length() > 0) { StringBuilder sb = new StringBuilder();
sb.append(ChatColor.translateAlternateColorCodes('&', line)); for (String line : event.getLines()) {
} if (line != null && line.length() > 0) {
} sb.append(ChatColor.translateAlternateColorCodes('&', line));
String input = sb.toString(); }
if(b.hasMetadata("setName")) { }
if (input.length() > 0) { String input = sb.toString();
as.setCustomName(input); if(b.hasMetadata("setName")) {
as.setCustomNameVisible(true); if (input.length() > 0) {
} else { as.setCustomName(input);
as.setCustomName(""); as.setCustomNameVisible(true);
as.setCustomNameVisible(false); } else {
as.setCustomNameVisible(false); as.setCustomName("");
} as.setCustomNameVisible(false);
} else if(b.hasMetadata("setSkull")) { as.setCustomNameVisible(false);
if(MC_USERNAME_PATTERN.matcher(input).matches()) { }
b.setMetadata("protected", new FixedMetadataValue(plugin, true)); } else if(b.hasMetadata("setSkull")) {
event.getPlayer().sendMessage(ChatColor.GOLD + Config.pleaseWait); if(MC_USERNAME_PATTERN.matcher(input).matches()) {
String cmd = "minecraft:give " + event.getPlayer().getName() + " minecraft:player_head{SkullOwner:\"" + input + "\"} 1"; if(as.getEquipment() != null) {
String current = b.getWorld().getGameRuleValue("sendCommandFeedback"); as.getEquipment().setHelmet(getPlayerHead(input));
b.getWorld().setGameRuleValue("sendCommandFeedback", "false"); }
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), cmd); } else {
b.getWorld().setGameRuleValue("sendCommandFeedback", current); event.getPlayer().sendMessage(ChatColor.RED + input + " " + Config.invalidName);
boolean found = false;
for(int slot : event.getPlayer().getInventory().all(Material.PLAYER_HEAD).keySet()) {
ItemStack skull = event.getPlayer().getInventory().getItem(slot);
SkullMeta sm = (SkullMeta) skull.getItemMeta();
if(sm.hasOwner() && input.equalsIgnoreCase(sm.getOwningPlayer().getName())) {
as.setHelmet(skull);
event.getPlayer().sendMessage(ChatColor.GREEN + Config.appliedHead + ChatColor.GOLD + " " + input);
event.getPlayer().getInventory().setItem(slot, null);
found = true;
break;
}
}
if(!found) {
event.getPlayer().sendMessage(ChatColor.GOLD + Config.headFailed);
}
} else {
event.getPlayer().sendMessage(ChatColor.RED + input + " " + Config.invalidName);
}
} }
} }
event.setCancelled(true);
b.removeMetadata("armorStand", plugin);
b.removeMetadata("setName", plugin);
b.removeMetadata("setSkull", plugin);
b.setType(Material.AIR);
} }
event.setCancelled(true);
b.removeMetadata("armorStand", AST.plugin);
b.removeMetadata("setName", AST.plugin);
b.removeMetadata("setSkull", AST.plugin);
b.setType(Material.AIR);
} }
@EventHandler @SuppressWarnings("deprecation")
public void onPlayerCommand(final PlayerCommandPreprocessEvent event) { private ItemStack getPlayerHead(String playerName) {
Player p = event.getPlayer(); OfflinePlayer offlinePlayer = Bukkit.getServer().getPlayer(playerName);
String cmd = event.getMessage().split(" ")[0].toLowerCase(); if(offlinePlayer == null) {
while(cmd.length() > 0 && cmd.charAt(0) == '/') { offlinePlayer = Bukkit.getOfflinePlayer(playerName);
cmd = cmd.substring(1);
} }
if(cmd.length() > 0 && Config.deniedCommands.contains(cmd) && Utils.hasAnyTools(p)) { final ItemStack item = new ItemStack(Material.PLAYER_HEAD);
event.setCancelled(true); final SkullMeta meta = (SkullMeta) item.getItemMeta();
p.sendMessage(ChatColor.RED + Config.cmdNotAllowed); if(meta == null) {
Bukkit.getLogger().warning("Skull item meta was null");
return item;
} }
meta.setOwningPlayer(offlinePlayer);
item.setItemMeta(meta);
return item;
} }
private ArmorStand getArmorStand(Block b) { private ArmorStand getArmorStand(Block b) {
UUID uuid = null; UUID uuid = null;
for (MetadataValue value : b.getMetadata("armorStand")) { for (MetadataValue value : b.getMetadata("armorStand")) {
if (value.getOwningPlugin() == plugin) { if (value.getOwningPlugin() == AST.plugin) {
uuid = (UUID) value.value(); uuid = (UUID) value.value();
} }
} }
b.removeMetadata("armorStand", plugin); b.removeMetadata("armorStand", AST.plugin);
if (uuid != null) { if (uuid != null) {
for(org.bukkit.entity.Entity e : b.getWorld().getEntities()) { for(org.bukkit.entity.Entity e : b.getWorld().getEntities()) {
if(e instanceof ArmorStand && e.getUniqueId().equals(uuid)) { if(e instanceof ArmorStand && e.getUniqueId().equals(uuid)) {
@ -523,8 +236,7 @@ public class MainListener implements Listener {
/*@EventHandler /*@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player p = event.getPlayer(); Player p = event.getPlayer();
PermissionAttachment attachment = p.addAttachment(plugin); PermissionAttachment attachment = p.addAttachment(AST.plugin);
attachment.setPermission("astools.command", true);
attachment.setPermission("astools.use", true); attachment.setPermission("astools.use", true);
attachment.setPermission("astools.summon", true); attachment.setPermission("astools.summon", true);
attachment.setPermission("astools.clone", true); attachment.setPermission("astools.clone", true);

Datei anzeigen

@ -1,220 +0,0 @@
package com.gmail.St3venAU.plugins.ArmorStandTools;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.CommandBlock;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.scheduler.BukkitRunnable;
import java.lang.reflect.Field;
import java.util.Map;
abstract class NMS {
private final String nmsVersion;
private final String[] disabledSlotsFieldNames;
NMS(String nmsVersion, String... disabledSlotsFieldNames) {
this.nmsVersion = nmsVersion;
this.disabledSlotsFieldNames = disabledSlotsFieldNames;
}
private Class<?> getNMSClass(String nmsClassString) throws ClassNotFoundException {
return Class.forName("net.minecraft.server." + nmsVersion + "." + nmsClassString);
}
private Object getNmsEntity(org.bukkit.entity.Entity entity) {
try {
return entity.getClass().getMethod("getHandle").invoke(entity);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
void openSign(final Player p, final Block b) {
new BukkitRunnable() {
@Override
public void run() {
try {
Object world = b.getWorld().getClass().getMethod("getHandle").invoke(b.getWorld());
Object blockPos = getNMSClass("BlockPosition").getConstructor(int.class, int.class, int.class).newInstance(b.getX(), b.getY(), b.getZ());
Object sign = world.getClass().getMethod("getTileEntity", getNMSClass("BlockPosition")).invoke(world, blockPos);
Object player = p.getClass().getMethod("getHandle").invoke(p);
player.getClass().getMethod("openSign", getNMSClass("TileEntitySign")).invoke(player, sign);
} catch (Exception e) {
e.printStackTrace();
}
}
}.runTaskLater(Main.plugin, 2L);
}
boolean toggleSlotsDisabled(ArmorStand as) {
boolean slotsDisabled = getDisabledSlots(as) == 0;
setSlotsDisabled(as, slotsDisabled);
return slotsDisabled;
}
private Field getDisabledSlotsField(Object nmsEntity) {
if(nmsEntity == null) return null;
for(String field : disabledSlotsFieldNames) {
try {
Field f = nmsEntity.getClass().getDeclaredField(field);
f.setAccessible(true);
return f;
} catch (NoSuchFieldException e) {
}
}
return null;
}
private int getDisabledSlots(ArmorStand as) {
Object nmsEntity = getNmsEntity(as);
if(nmsEntity == null) return 0;
Field f = getDisabledSlotsField(nmsEntity);
if(f == null) return 0;
try {
return (Integer) f.get(nmsEntity);
} catch (IllegalAccessException e) {
e.printStackTrace();
return 0;
}
}
void setSlotsDisabled(ArmorStand as, boolean slotsDisabled) {
Object nmsEntity = getNmsEntity(as);
if (nmsEntity == null) return;
Field f = getDisabledSlotsField(nmsEntity);
try {
f.set(nmsEntity, slotsDisabled ? 0xFFFFFF : 0);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
boolean equipmentLocked(ArmorStand as) {
return getDisabledSlots(as) == 0xFFFFFF;
}
private String getItemStackTags(ItemStack is) {
if(is == null) {
return "";
}
StringBuilder tags = new StringBuilder();
if(is.getItemMeta() != null && is.getItemMeta() instanceof LeatherArmorMeta) {
LeatherArmorMeta armorMeta = (LeatherArmorMeta) is.getItemMeta();
tags.append("display:{color:");
tags.append(armorMeta.getColor().asRGB());
tags.append("}");
}
Map<Enchantment, Integer> enchants = is.getEnchantments();
if(enchants.size() > 0) {
if(tags.length() > 0) {
tags.append(",");
}
tags.append("Enchantments:[");
for(Enchantment e : enchants.keySet()) {
tags.append("{id:");
tags.append(e.getKey().getKey());
tags.append(",lvl:");
tags.append(enchants.get(e));
tags.append("},");
}
tags.setCharAt(tags.length() - 1, ']');
}
return tags.length() == 0 ? "" : ("," + tags.toString());
}
private String skullOwner(ItemStack is) {
if(is == null || is.getItemMeta() == null || !(is.getItemMeta() instanceof SkullMeta)) {
return "";
}
SkullMeta skull = (SkullMeta) is.getItemMeta();
if(skull.hasOwner()) {
return ",SkullOwner:\"" + skull.getOwningPlayer().getName() + "\"";
} else {
return "";
}
}
void generateCmdBlock(Location l, ArmorStand as) {
Block b = l.getBlock();
b.setType(Material.COMMAND_BLOCK);
CommandBlock cb = (CommandBlock) b.getState();
cb.setCommand("summon minecraft:armor_stand " + Utils.twoDec(as.getLocation().getX()) + " " + Utils.twoDec(as.getLocation().getY()) + " " + Utils.twoDec(as.getLocation().getZ()) + " "
+ "{"
+ (as.isVisible() ? "" : "Invisible:1," )
+ (as.hasBasePlate() ? "" : "NoBasePlate:1," )
+ (as.hasGravity() ? "" : "NoGravity:1," )
+ (as.hasArms() ? "ShowArms:1," : "" )
+ (as.isSmall() ? "Small:1," : "" )
+ (as.isInvulnerable() ? "Invulnerable:1," : "" )
+ (as.isGlowing() ? "Glowing:1," : "" )
+ (getDisabledSlots(as) == 0 ? "" : ("DisabledSlots:" + getDisabledSlots(as) + ",") )
+ (as.isCustomNameVisible() ? "CustomNameVisible:1," : "" )
+ (as.getCustomName() == null ? "" : ("CustomName:\"\\\"" + as.getCustomName() + "\\\"\",") )
+ (as.getLocation().getYaw() == 0F ? "" : ("Rotation:[" + Utils.twoDec(as.getLocation().getYaw()) + "f],"))
+ "ArmorItems:["
+ (as.getEquipment() != null && as.getEquipment().getBoots() == null ? "{}," : ("{id:" + as.getEquipment().getBoots().getType().getKey().getKey() + ",Count:" + as.getEquipment().getBoots().getAmount() + ",tag:{Damage:" + as.getEquipment().getBoots().getDurability() + getItemStackTags(as.getEquipment().getBoots()) + "}},"))
+ (as.getEquipment() != null && as.getEquipment().getLeggings() == null ? "{}," : ("{id:" + as.getEquipment().getLeggings().getType().getKey().getKey() + ",Count:" + as.getEquipment().getLeggings().getAmount() + ",tag:{Damage:" + as.getEquipment().getLeggings().getDurability() + getItemStackTags(as.getEquipment().getLeggings()) + "}},"))
+ (as.getEquipment() != null && as.getEquipment().getChestplate() == null ? "{}," : ("{id:" + as.getEquipment().getChestplate().getType().getKey().getKey() + ",Count:" + as.getEquipment().getChestplate().getAmount() + ",tag:{Damage:" + as.getEquipment().getChestplate().getDurability() + getItemStackTags(as.getEquipment().getChestplate()) + "}},"))
+ (as.getEquipment() != null && as.getEquipment().getHelmet() == null ? "{}" : ("{id:" + as.getEquipment().getHelmet().getType().getKey().getKey() + ",Count:" + as.getEquipment().getHelmet().getAmount() + ",tag:{Damage:" + as.getEquipment().getHelmet().getDurability() + getItemStackTags(as.getEquipment().getHelmet()) + skullOwner(as.getEquipment().getHelmet()) + "}}" ))
+ "],"
+ "HandItems:["
+ (as.getEquipment().getItemInMainHand() == null ? "{}," : ("{id:" + as.getEquipment().getItemInMainHand().getType().getKey().getKey() + ",Count:" + as.getEquipment().getItemInMainHand().getAmount() + ",tag:{Damage:" + as.getEquipment().getItemInMainHand().getDurability() + getItemStackTags(as.getEquipment().getItemInMainHand()) + "}},"))
+ (as.getEquipment().getItemInOffHand() == null ? "{}" : ("{id:" + as.getEquipment().getItemInOffHand().getType().getKey().getKey() + ",Count:" + as.getEquipment().getItemInOffHand().getAmount() + ",tag:{Damage:" + as.getEquipment().getItemInOffHand().getDurability() + getItemStackTags(as.getEquipment().getItemInOffHand()) + "}}" ))
+ "],"
+ "Pose:{"
+ "Body:[" + Utils.angle(as.getBodyPose().getX()) + "f," + Utils.angle(as.getBodyPose().getY()) + "f," + Utils.angle(as.getBodyPose().getZ()) + "f],"
+ "Head:[" + Utils.angle(as.getHeadPose().getX()) + "f," + Utils.angle(as.getHeadPose().getY()) + "f," + Utils.angle(as.getHeadPose().getZ()) + "f],"
+ "LeftLeg:[" + Utils.angle(as.getLeftLegPose().getX()) + "f," + Utils.angle(as.getLeftLegPose().getY()) + "f," + Utils.angle(as.getLeftLegPose().getZ()) + "f],"
+ "RightLeg:[" + Utils.angle(as.getRightLegPose().getX()) + "f," + Utils.angle(as.getRightLegPose().getY()) + "f," + Utils.angle(as.getRightLegPose().getZ()) + "f],"
+ "LeftArm:[" + Utils.angle(as.getLeftArmPose().getX()) + "f," + Utils.angle(as.getLeftArmPose().getY()) + "f," + Utils.angle(as.getLeftArmPose().getZ()) + "f],"
+ "RightArm:[" + Utils.angle(as.getRightArmPose().getX()) + "f," + Utils.angle(as.getRightArmPose().getY()) + "f," + Utils.angle(as.getRightArmPose().getZ()) + "f]"
+ "}"
+ "}"
);
cb.update();
}
ArmorStand clone(ArmorStand as) {
ArmorStand clone = (ArmorStand) as.getWorld().spawnEntity(as.getLocation().add(1, 0, 0), EntityType.ARMOR_STAND);
clone.setGravity(as.hasGravity());
clone.getEquipment().setHelmet(as.getEquipment().getHelmet());
clone.getEquipment().setChestplate(as.getEquipment().getChestplate());
clone.getEquipment().setLeggings(as.getEquipment().getLeggings());
clone.getEquipment().setBoots(as.getEquipment().getBoots());
clone.getEquipment().setItemInMainHand(as.getEquipment().getItemInMainHand());
clone.getEquipment().setItemInOffHand(as.getEquipment().getItemInOffHand());
clone.setHeadPose(as.getHeadPose());
clone.setBodyPose(as.getBodyPose());
clone.setLeftArmPose(as.getLeftArmPose());
clone.setRightArmPose(as.getRightArmPose());
clone.setLeftLegPose(as.getLeftLegPose());
clone.setRightLegPose(as.getRightLegPose());
clone.setVisible(as.isVisible());
clone.setBasePlate(as.hasBasePlate());
clone.setArms(as.hasArms());
clone.setCustomName(as.getCustomName());
clone.setCustomNameVisible(as.isCustomNameVisible());
clone.setSmall(as.isSmall());
clone.setInvulnerable(as.isInvulnerable());
clone.setGlowing(as.isGlowing());
setSlotsDisabled(clone, getDisabledSlots(as) == 0xFFFFFF);
ArmorStandCmd asCmd = new ArmorStandCmd(as);
if(asCmd.getCommand() != null) {
asCmd.cloneTo(clone);
}
return clone;
}
}

Datei anzeigen

@ -1,13 +0,0 @@
package com.gmail.St3venAU.plugins.ArmorStandTools;
@SuppressWarnings("unused")
class NMS_v1_13_R1 extends NMS {
public NMS_v1_13_R1(String nmsVersion) {
super(
nmsVersion,
"bH"
);
}
}

Datei anzeigen

@ -1,13 +0,0 @@
package com.gmail.St3venAU.plugins.ArmorStandTools;
@SuppressWarnings("unused")
class NMS_v1_13_R2 extends NMS {
public NMS_v1_13_R2(String nmsVersion) {
super(
nmsVersion,
"bH"
);
}
}

Datei anzeigen

@ -1,13 +0,0 @@
package com.gmail.St3venAU.plugins.ArmorStandTools;
@SuppressWarnings("unused")
class NMS_v1_14_R1 extends NMS {
public NMS_v1_14_R1(String nmsVersion) {
super(
nmsVersion,
"bE"
);
}
}

Datei anzeigen

@ -1,13 +0,0 @@
package com.gmail.St3venAU.plugins.ArmorStandTools;
@SuppressWarnings("unused")
class NMS_v1_15_R1 extends NMS {
public NMS_v1_15_R1(String nmsVersion) {
super(
nmsVersion,
"bB"
);
}
}

Datei anzeigen

@ -1,13 +0,0 @@
package com.gmail.St3venAU.plugins.ArmorStandTools;
@SuppressWarnings("unused")
class NMS_v1_16_R1 extends NMS {
public NMS_v1_16_R1(String nmsVersion) {
super(
nmsVersion,
"bA"
);
}
}

Datei anzeigen

@ -1,13 +0,0 @@
package com.gmail.St3venAU.plugins.ArmorStandTools;
@SuppressWarnings("unused")
class NMS_v1_16_R2 extends NMS {
public NMS_v1_16_R2(String nmsVersion) {
super(
nmsVersion,
"disabledSlots", "bv"
);
}
}

Datei anzeigen

@ -1,13 +0,0 @@
package com.gmail.St3venAU.plugins.ArmorStandTools;
@SuppressWarnings("unused")
class NMS_v1_16_R3 extends NMS {
public NMS_v1_16_R3(String nmsVersion) {
super(
nmsVersion,
"disabledSlots"
);
}
}

Datei anzeigen

@ -1,9 +1,10 @@
package com.gmail.St3venAU.plugins.ArmorStandTools; package com.gmail.st3venau.plugins.armorstandtools;
import com.plotsquared.core.api.PlotAPI; import com.plotsquared.core.PlotAPI;
import com.plotsquared.core.player.PlotPlayer; import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.Plot; import com.plotsquared.core.plot.Plot;
import com.plotsquared.core.plot.PlotArea; import com.plotsquared.core.plot.PlotArea;
import com.sk89q.worldedit.math.BlockVector3;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,38 +12,36 @@ import java.util.UUID;
class PlotSquaredHook { class PlotSquaredHook {
public static PlotAPI api; public static PlotAPI api = null;
private static Main plugin;
public PlotSquaredHook(Main main) { public static void init() {
PlotSquaredHook.api = new PlotAPI(); if(api != null) return;
plugin = main; api = new PlotAPI();
} }
public static boolean isPlotWorld(Location loc) { public static boolean isPlotWorld(Location l) {
return api.getPlotSquared().hasPlotArea(loc.getWorld().getName()); return l.getWorld() != null && api.getPlotSquared().getPlotAreaManager().hasPlotArea(l.getWorld().getName());
} }
public static boolean checkPermission(Player player, Location location) { public static boolean checkPermission(Player p, Location l) {
com.plotsquared.core.location.Location plotLocation = new com.plotsquared.core.location.Location(location.getWorld().getName(), if(l.getWorld() == null) return true;
location.getBlockX(), com.plotsquared.core.location.Location plotLocation
location.getBlockY(), = com.plotsquared.core.location.Location.at(l.getWorld().getName(), BlockVector3.at(l.getBlockX(), l.getBlockY(), l.getBlockZ()));
location.getBlockZ());
PlotArea plotArea = plotLocation.getPlotArea(); PlotArea plotArea = plotLocation.getPlotArea();
if(plotArea == null) { if(plotArea == null) {
plugin.debug("plots.admin.build.road: " + player.hasPermission("plots.admin.build.road")); AST.debug("plots.admin.build.road: " + p.hasPermission("plots.admin.build.road"));
return player.hasPermission("plots.admin.build.road"); return p.hasPermission("plots.admin.build.road");
} }
Plot plot = plotArea.getPlot(plotLocation); Plot plot = plotArea.getPlot(plotLocation);
PlotPlayer pp = PlotPlayer.wrap(player); PlotPlayer<?> pp = api.wrapPlayer(p.getUniqueId());
plugin.debug("Plot: " + plot); AST.debug("Plot: " + plot);
if (plot == null) { if (plot == null) {
plugin.debug("plots.admin.build.road: " + pp.hasPermission("plots.admin.build.road")); AST.debug("plots.admin.build.road: " + pp.hasPermission("plots.admin.build.road"));
return pp.hasPermission("plots.admin.build.road"); return pp.hasPermission("plots.admin.build.road");
} }
UUID uuid = pp.getUUID(); UUID uuid = pp.getUUID();
plugin.debug("plot.isAdded: " + plot.isAdded(uuid)); AST.debug("plot.isAdded: " + plot.isAdded(uuid));
plugin.debug("plots.admin.build.other: " + pp.hasPermission("plots.admin.build.other")); AST.debug("plots.admin.build.other: " + pp.hasPermission("plots.admin.build.other"));
return plot.isAdded(uuid) || pp.hasPermission("plots.admin.build.other"); return plot.isAdded(uuid) || pp.hasPermission("plots.admin.build.other");
} }
} }

Datei anzeigen

@ -1,62 +1,139 @@
package com.gmail.St3venAU.plugins.ArmorStandTools; package com.gmail.st3venau.plugins.armorstandtools;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.CommandBlock;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols; import java.text.DecimalFormatSymbols;
import java.util.Arrays; import java.util.Map;
import java.util.Collection;
class Utils { class Utils {
private static DecimalFormat twoDec; private static DecimalFormat twoDec;
static boolean containsItems(Collection<ItemStack> items) { static void openSign(final Player p, final Block b) {
for(ItemStack i : items) { new BukkitRunnable() {
if(ArmorStandTool.get(i) != null) { @Override
public void run() {
try {
Object world = b.getWorld().getClass().getMethod("getHandle").invoke(b.getWorld());
Object position = Class.forName("net.minecraft.core.BlockPosition").getConstructor(int.class, int.class, int.class).newInstance(b.getX(), b.getY(), b.getZ());
Object sign = world.getClass().getMethod("getTileEntity", Class.forName("net.minecraft.core.BlockPosition")).invoke(world, position);
Object player = p.getClass().getMethod("getHandle").invoke(p);
player.getClass().getMethod("openSign", Class.forName("net.minecraft.world.level.block.entity.TileEntitySign")).invoke(player, sign);
} catch (Exception e) {
e.printStackTrace();
}
}
}.runTaskLater(AST.plugin, 2L);
}
static final EquipmentSlot[] equipmentSlots = {
EquipmentSlot.HAND,
EquipmentSlot.OFF_HAND,
EquipmentSlot.HEAD,
EquipmentSlot.CHEST,
EquipmentSlot.LEGS,
EquipmentSlot.FEET
};
static boolean hasDisabledSlots(ArmorStand as) {
for(EquipmentSlot slot : equipmentSlots) {
if(as.hasEquipmentLock(slot, ArmorStand.LockType.REMOVING_OR_CHANGING)) {
return true; return true;
} }
} }
return false; return false;
} }
static boolean hasPermissionNode(Player player, String perm, boolean ignoreOp) { static void setSlotsDisabled(ArmorStand as, boolean slotsDisabled) {
if (!ignoreOp && ((player == null) || player.isOp())) { if(slotsDisabled) {
for(EquipmentSlot slot : equipmentSlots) {
as.addEquipmentLock(slot, ArmorStand.LockType.REMOVING_OR_CHANGING);
}
} else {
for(EquipmentSlot slot : equipmentSlots) {
as.removeEquipmentLock(slot, ArmorStand.LockType.REMOVING_OR_CHANGING);
}
}
}
static boolean toggleSlotsDisabled(ArmorStand as) {
boolean slotsDisabled = !hasDisabledSlots(as);
setSlotsDisabled(as, slotsDisabled);
return slotsDisabled;
}
static ArmorStand cloneArmorStand(ArmorStand as) {
ArmorStand clone = (ArmorStand) as.getWorld().spawnEntity(as.getLocation().add(1, 0, 0), EntityType.ARMOR_STAND);
EntityEquipment asEquipment = as.getEquipment();
EntityEquipment cloneEquipment = clone.getEquipment();
if(asEquipment != null && cloneEquipment != null) {
cloneEquipment.setHelmet(asEquipment.getHelmet());
cloneEquipment.setChestplate(asEquipment.getChestplate());
cloneEquipment.setLeggings(asEquipment.getLeggings());
cloneEquipment.setBoots(asEquipment.getBoots());
cloneEquipment.setItemInMainHand(asEquipment.getItemInMainHand());
cloneEquipment.setItemInOffHand(asEquipment.getItemInOffHand());
}
clone.setHeadPose(as.getHeadPose());
clone.setBodyPose(as.getBodyPose());
clone.setLeftArmPose(as.getLeftArmPose());
clone.setRightArmPose(as.getRightArmPose());
clone.setLeftLegPose(as.getLeftLegPose());
clone.setRightLegPose(as.getRightLegPose());
clone.setGravity(as.hasGravity());
clone.setVisible(as.isVisible());
clone.setBasePlate(as.hasBasePlate());
clone.setArms(as.hasArms());
clone.setCustomName(as.getCustomName());
clone.setCustomNameVisible(as.isCustomNameVisible());
clone.setSmall(as.isSmall());
clone.setInvulnerable(as.isInvulnerable());
clone.setGlowing(as.isGlowing());
Utils.setSlotsDisabled(clone, Utils.hasDisabledSlots(as));
ArmorStandCmd asCmd = new ArmorStandCmd(as);
if(asCmd.getCommand() != null) {
asCmd.cloneTo(clone);
}
clone.setMetadata("clone", new FixedMetadataValue(AST.plugin, true));
return clone;
}
static boolean hasPermissionNode(Player p, String perm) {
if ((p == null) || p.isOp()) {
return true; return true;
} }
if (player.hasPermission(perm)) { if (p.hasPermission(perm)) {
return true; return true;
} }
final String[] nodes = perm.split("\\."); final String[] nodes = perm.split("\\.");
final StringBuilder n = new StringBuilder(); final StringBuilder n = new StringBuilder();
for (int i = 0; i < (nodes.length - 1); i++) { for (int i = 0; i < (nodes.length - 1); i++) {
n.append(nodes[i]).append("."); n.append(nodes[i]).append(".");
if (player.hasPermission(n + "*")) { if (p.hasPermission(n + "*")) {
return true; return true;
} }
} }
return false; return false;
} }
static boolean hasPermissionNode(Player player, String perm) { static void title(Player p, String msg) {
return hasPermissionNode(player, perm, false); p.sendTitle(" ", msg, 0, 70, 0);
}
static boolean hasAnyTools(Player p) {
for(ItemStack i : p.getInventory()) {
if(ArmorStandTool.isTool(i)) {
return true;
}
}
return false;
} }
static Location getLocationFacing(Location loc) { static Location getLocationFacing(Location loc) {
@ -82,25 +159,85 @@ class Utils {
return l; return l;
} }
static void cycleInventory(Player p) {
Inventory i = p.getInventory(); static private String getItemStackTags(ItemStack is) {
ItemStack temp; if(is == null) {
for (int n = 0; n < 9; n++) { return "";
temp = i.getItem(n);
i.setItem(n, i.getItem(27 + n));
i.setItem(27 + n, i.getItem(18 + n));
i.setItem(18 + n, i.getItem(9 + n));
i.setItem(9 + n, temp);
} }
//noinspection deprecation StringBuilder tags = new StringBuilder();
p.updateInventory(); if(is.getItemMeta() != null && is.getItemMeta() instanceof LeatherArmorMeta) {
LeatherArmorMeta armorMeta = (LeatherArmorMeta) is.getItemMeta();
tags.append("display:{color:");
tags.append(armorMeta.getColor().asRGB());
tags.append("}");
}
Map<Enchantment, Integer> enchants = is.getEnchantments();
if(enchants.size() > 0) {
if(tags.length() > 0) {
tags.append(",");
}
tags.append("Enchantments:[");
for(Enchantment e : enchants.keySet()) {
tags.append("{id:");
tags.append(e.getKey().getKey());
tags.append(",lvl:");
tags.append(enchants.get(e));
tags.append("},");
}
tags.setCharAt(tags.length() - 1, ']');
}
return tags.length() == 0 ? "" : ("," + tags.toString());
} }
static String angle(double d) { static private String skullOwner(ItemStack is) {
return twoDec(d * 180.0 / Math.PI); if(is == null || is.getItemMeta() == null || !(is.getItemMeta() instanceof SkullMeta)) return "";
SkullMeta skull = (SkullMeta) is.getItemMeta();
return skull.getOwningPlayer() == null ? "" : ",SkullOwner:\"" + skull.getOwningPlayer().getName() + "\"";
} }
static String twoDec(double d) { static void generateCmdBlock(Location l, ArmorStand as) {
Block b = l.getBlock();
b.setType(Material.COMMAND_BLOCK);
CommandBlock cb = (CommandBlock) b.getState();
EntityEquipment e = as.getEquipment();
cb.setCommand("summon minecraft:armor_stand " + twoDec(as.getLocation().getX()) + " " + twoDec(as.getLocation().getY()) + " " + twoDec(as.getLocation().getZ()) + " "
+ "{"
+ (as.isVisible() ? "" : "Invisible:1," )
+ (as.hasBasePlate() ? "" : "NoBasePlate:1," )
+ (as.hasGravity() ? "" : "NoGravity:1," )
+ (as.hasArms() ? "ShowArms:1," : "" )
+ (as.isSmall() ? "Small:1," : "" )
+ (as.isInvulnerable() ? "Invulnerable:1," : "" )
+ (as.isGlowing() ? "Glowing:1," : "" )
+ (as.isCustomNameVisible() ? "CustomNameVisible:1," : "" )
+ (as.getCustomName() == null ? "" : ("CustomName:\"\\\"" + as.getCustomName() + "\\\"\",") )
+ (as.getLocation().getYaw() == 0F ? "" : ("Rotation:[" + twoDec(as.getLocation().getYaw()) + "f],"))
+ "ArmorItems:["
+ (e == null || e.getBoots() == null ? "{}," : ("{id:" + e.getBoots().getType().getKey().getKey() + ",Count:" + e.getBoots().getAmount() + ",tag:{Damage:" + e.getBoots().getDurability() + getItemStackTags(e.getBoots()) + "}},"))
+ (e == null || e.getLeggings() == null ? "{}," : ("{id:" + e.getLeggings().getType().getKey().getKey() + ",Count:" + e.getLeggings().getAmount() + ",tag:{Damage:" + e.getLeggings().getDurability() + getItemStackTags(e.getLeggings()) + "}},"))
+ (e == null || e.getChestplate() == null ? "{}," : ("{id:" + e.getChestplate().getType().getKey().getKey() + ",Count:" + e.getChestplate().getAmount() + ",tag:{Damage:" + e.getChestplate().getDurability() + getItemStackTags(e.getChestplate()) + "}},"))
+ (e == null || e.getHelmet() == null ? "{}" : ("{id:" + e.getHelmet().getType().getKey().getKey() + ",Count:" + e.getHelmet().getAmount() + ",tag:{Damage:" + e.getHelmet().getDurability() + getItemStackTags(e.getHelmet()) + skullOwner(e.getHelmet()) + "}}" ))
+ "],"
+ "HandItems:["
+ (e == null ? "{}," : ("{id:" + e.getItemInMainHand().getType().getKey().getKey() + ",Count:" + e.getItemInMainHand().getAmount() + ",tag:{Damage:" + e.getItemInMainHand().getDurability() + getItemStackTags(e.getItemInMainHand()) + "}},"))
+ (e == null ? "{}" : ("{id:" + e.getItemInOffHand().getType().getKey().getKey() + ",Count:" + e.getItemInOffHand().getAmount() + ",tag:{Damage:" + e.getItemInOffHand().getDurability() + getItemStackTags(e.getItemInOffHand()) + "}}" ))
+ "],"
+ "Pose:{"
+ "Body:[" + degrees(as.getBodyPose().getX()) + "f," + degrees(as.getBodyPose().getY()) + "f," + degrees(as.getBodyPose().getZ()) + "f],"
+ "Head:[" + degrees(as.getHeadPose().getX()) + "f," + degrees(as.getHeadPose().getY()) + "f," + degrees(as.getHeadPose().getZ()) + "f],"
+ "LeftLeg:[" + degrees(as.getLeftLegPose().getX()) + "f," + degrees(as.getLeftLegPose().getY()) + "f," + degrees(as.getLeftLegPose().getZ()) + "f],"
+ "RightLeg:[" + degrees(as.getRightLegPose().getX()) + "f," + degrees(as.getRightLegPose().getY()) + "f," + degrees(as.getRightLegPose().getZ()) + "f],"
+ "LeftArm:[" + degrees(as.getLeftArmPose().getX()) + "f," + degrees(as.getLeftArmPose().getY()) + "f," + degrees(as.getLeftArmPose().getZ()) + "f],"
+ "RightArm:[" + degrees(as.getRightArmPose().getX()) + "f," + degrees(as.getRightArmPose().getY()) + "f," + degrees(as.getRightArmPose().getZ()) + "f]"
+ "}"
+ "}"
);
cb.update();
}
private static String twoDec(double d) {
if(twoDec == null) { if(twoDec == null) {
twoDec = new DecimalFormat("0.0#"); twoDec = new DecimalFormat("0.0#");
DecimalFormatSymbols symbols = new DecimalFormatSymbols(); DecimalFormatSymbols symbols = new DecimalFormatSymbols();
@ -110,33 +247,8 @@ class Utils {
return twoDec.format(d); return twoDec.format(d);
} }
static Block findAnAirBlock(Location l) { private static String degrees(double d) {
while(l.getY() < 255 && l.getBlock().getType() != Material.AIR) { return twoDec(d * 180.0 / Math.PI);
l.add(0, 1, 0);
}
return l.getY() < 255 && l.getBlock().getType() == Material.AIR ? l.getBlock() : null;
} }
static ItemStack setLore(ItemStack is, String... lore) {
ItemMeta meta = is.getItemMeta();
meta.setLore(Arrays.asList(lore));
is.setItemMeta(meta);
return is;
}
static boolean toggleInvulnerability(ArmorStand as) {
boolean inv = !as.isInvulnerable();
as.setInvulnerable(inv);
return inv;
}
static void actionBarMsg(Player p, String msg) {
p.sendTitle("", msg, 0, 70, 0);
}
static boolean toggleGlow(ArmorStand as) {
boolean glowing = !as.isGlowing();
as.setGlowing(glowing);
return glowing;
}
} }

Datei anzeigen

@ -4,39 +4,33 @@
# #
# Main Config # Main Config
# #
# File generated by: v3.7.2 # File generated by: v${project.version}
# (If this is not the version you are running, consider deleting this # (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) # config to allow it to be re-created. There may be new config options)
# #
# Features: # Features:
# - Summon armor stands
# - Name armor stands
# - Toggle: Gravity, Visibility, Arms, Base, Size, Invulnerability, Equipment Lock
# - Manipulate the position of the Head, Body, Arms and Legs # - Manipulate the position of the Head, Body, Arms and Legs
# - Full control over armor stand's inventory (armor & items in hands) # - Toggle: Gravity, Visibility, Arms, Base plate, Size, Invulnerability, Equipment Lock, Glow
# - Clone armor stand tool # - Name armor stands
# - Create command block tool: Creates a command block with the command that will summon this # - Full control over armor stand's inventory (armor & items in both hands)
# armor stand in its current state # - Create exact clones of armor stands
# - Player head tool: Set's an armor stand's head to the head of a specified player. # - Create a command block with the command to summon the same armor stand
# - Set's an armor stand's head to the head of a specified player.
# - Support for WorldGuard regions. # - Support for WorldGuard regions.
# - User customizable language config. # - User customizable language config.
# #
# Commands: # Commands:
# /astools Give yourself all of the armor stand tools (Note: Clears your inventory)
# /astools reload Reload the armor stand tools plugin config file
# /ast Alias for the /astools
# /ascmd assign console <command> Assign a console command to the nearest armor stand (within 4 blocks) # /ascmd assign console <command> Assign a console command to the nearest armor stand (within 4 blocks)
# /ascmd assign player <command> Assign a player command to the nearest armor stand # /ascmd assign player <command> Assign a player command to the nearest armor stand
# /ascmd remove Remove the command assigned to the nearest armor stand # /ascmd remove Remove the command assigned to the nearest armor stand
# /ascmd view View the command assigned to the nearest armor stand # /ascmd view View the command assigned to the nearest armor stand
# /ascmd cooldown <ticks> Set the cooldown for the command on nearest armor stand (Setting this overrides the default cooldown from config.yml) # /ascmd cooldown <ticks> Set the cooldown for the command on nearest armor stand (Setting this overrides the default cooldown from config.yml)
# /ascmd cooldown remove Remove the cooldown for the command on nearest armor stand (Default cooldown set in config.yml will be used) # /ascmd cooldown remove Remove the cooldown for the command on nearest armor stand (Default cooldown set in config.yml will be used)
# Note: Commands may include a %player% placeholder, which will get replaced by the executing player's name at time of execution. # /astools or /ast Legacy command - now gives instructions for player to crouch right-click an armor stand
# Note: Armor stand commands may include a %player% placeholder, which will get replaced by the executing player's name at time of execution.
# #
# Permissions: # Permissions:
# astools.command Permission for the /astools command # astools.use Permission to using any of the tools, except the ones below that have their own separate permissions (see below)
# 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) # 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.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) # astools.head Permission to use the player head tool (Ability to specify a player head for an armor stand)
@ -56,60 +50,12 @@
# this permission can use AST in worldguard regions even if the ast flag for that region is set to Deny. # 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. # - The ast worldguard flag is also ignored for players that have op.
# #
# These are the defaults for spawning new armor stands with the /astools (or /ast) armor stand
# The helmet, chest, pants, boots and inHand items are set like this: MATERIAL dataValue
# e.g. To have red wool in the armor stands hand by default: inHand: WOOL 14
#
integrateWithWorldGuard: true integrateWithWorldGuard: true
allowMovingStandsBetweenWorlds: false allowMovingStandsBetweenWorlds: false
deactivateToolsOnWorldChange: true
requireCreativeForSaveAsCmdBlock: false requireCreativeForSaveAsCmdBlock: false
defaultASCmdCooldownTicks: 0 defaultASCmdCooldownTicks: 0
bypassWorldguardForASCmdExecution: false bypassWorldguardForASCmdExecution: false
# Uncomment the section below to deny players access to commands of your choice when they have any AST tools in their inventory
# Add as many command as you wish. Only the first word of each command is needed, anything after the first space is ignored.
#deniedCommandsWhileUsingTools:
# - sell
helmet: AIR 0
chest: AIR 0
pants: AIR 0
boots: AIR 0
inHand: AIR 0
inOffHand: AIR 0
isVisible: true
isSmall: false
hasArms: true
hasBasePlate: false
hasGravity: false
name: ''
invulnerable: false
equipmentLock: false
enableTool: enableTool:
headX: true
headY: true
headZ: true
lArmX: true
lArmY: true
lArmZ: true
rArmX: true
rArmY: true
rArmZ: true
moveX: true
moveY: true
moveZ: true
lLegX: true
lLegY: true
lLegZ: true
rLegX: true
rLegY: true
rLegZ: true
bodyX: true
bodyY: true
bodyZ: true
summon: true
gui: true
rotat: true
gui_clone: true gui_clone: true
gui_save: true gui_save: true
gui_invis: true gui_invis: true
@ -123,3 +69,9 @@ enableTool:
gui_invul: true gui_invul: true
gui_move: true gui_move: true
gui_glow: true gui_glow: true
gui_head: true
gui_body: true
gui_larm: true
gui_rarm: true
gui_lleg: true
gui_rleg: true

Datei anzeigen

@ -4,7 +4,7 @@
# #
# Language Config # Language Config
# #
# File generated by: v3.7.2 # File generated by: v${project.version}
# (If this is not the version you are running, consider deleting this # (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) # config to allow it to be re-created. There may be new config options)
# #
@ -27,7 +27,6 @@
#################### ####################
# General Messages # # General Messages #
#################### ####################
invReturned: 'Inventory contents returned'
asDropped: 'Armor stand dropped' asDropped: 'Armor stand dropped'
asVisible: 'Visible' asVisible: 'Visible'
isTrue: 'True' isTrue: 'True'
@ -49,16 +48,9 @@ locked: 'Locked'
unLocked: 'Un-Locked' unLocked: 'Un-Locked'
currently: 'Currently' currently: 'Currently'
notConsole: 'This command can not be run from console' notConsole: 'This command can not be run from console'
giveMsg1: 'Given armor stand tools. L-click any tool to cycle through tools.'
giveMsg2: 'Run this command again to return your inventory.'
conReload: 'Armor Stand Tools config reloaded'
noRelPerm: 'You do not have permission to reload the plugin'
noAirError: 'Error: Failed to find a near-by air block. Move and try again.' noAirError: 'Error: Failed to find a near-by air block. Move and try again.'
pleaseWait: 'Please wait. this may take a few seconds...'
appliedHead: 'Applied the head of player'
invalidName: 'is not a valid minecraft username' invalidName: 'is not a valid minecraft username'
wgNoPerm: 'No permission to alter an armor stand in this region' wgNoPerm: 'No permission to alter an armor stand in this region'
headFailed: 'Failed to apply the player head. Try again.'
noCommandPerm: 'You do not have permission to use this command' noCommandPerm: 'You do not have permission to use this command'
armorStand: 'Armor Stand' armorStand: 'Armor Stand'
none: 'None' none: 'None'
@ -91,137 +83,20 @@ setCooldown: 'Set the cooldown for the command'
removeCooldown: 'Remove the cooldown for the command' removeCooldown: 'Remove the cooldown for the command'
# New since v3.4.1 # New since v3.4.1
glow: 'Glow' glow: 'Glow'
cmdNotAllowed: 'That command is not allowed while using Armor Stand Tools' #New since v4.0.0
instructions: 'Crouch + right-click an armor stand to use Armor Stand Tools'
crouch: 'Crouch'
click: 'Click'
finish: 'Finish'
# #
############################# #############################
# Tool names & descriptions # # Tool names & descriptions #
############################# #############################
tool: tool:
summon:
name: 'Summon Armor Stand'
lore:
- 'R-Click to summon an armor stand and pick it up'
- 'Any click will drop it'
gui:
name: 'GUI Multi-Tool'
lore:
- 'R-Click armor stand to open a GUI to tweak'
- 'the attributes of the armor stand or change'
- 'its armor and items'
rotat:
name: 'Rotation'
lore:
- 'R-Click armor stand to change its Rotation'
- 'Value depends on how high up the body you click'
headX:
name: 'Head X'
lore:
- 'R-Click armor stand to change Head X Value'
- 'Value depends on how high up the body you click'
headY:
name: 'Head Y'
lore:
- 'R-Click armor stand to change Head Y Value'
- 'Value depends on how high up the body you click'
headZ:
name: 'Head Z'
lore:
- 'R-Click armor stand to change Head Z Value'
- 'Value depends on how high up the body you click'
lArmX:
name: 'Left Arm X'
lore:
- 'R-Click armor stand to change Left Arm X Value'
- 'Value depends on how high up the body you click'
lArmY:
name: 'Left Arm Y'
lore:
- 'R-Click armor stand to change Left Arm Y Value'
- 'Value depends on how high up the body you click'
lArmZ:
name: 'Left Arm Z'
lore:
- 'R-Click armor stand to change Left Arm Z Value'
- 'Value depends on how high up the body you click'
rArmX:
name: 'Right Arm X'
lore:
- 'R-Click armor stand to change Right Arm X Value'
- 'Value depends on how high up the body you click'
rArmY:
name: 'Right Arm Y'
lore:
- 'R-Click armor stand to change Right Arm Y Value'
- 'Value depends on how high up the body you click'
rArmZ:
name: 'Right Arm Z'
lore:
- 'R-Click armor stand to change Right Arm Z Value'
- 'Value depends on how high up the body you click'
moveX:
name: 'Move X'
lore:
- 'R-Click armor stand to move +0.1 X'
- 'Crouch R-Click for -0.1 X'
moveY:
name: 'Move Y'
lore:
- 'R-Click armor stand to move +0.1 Y'
- 'Crouch R-Click for -0.1 Y'
moveZ:
name: 'Move Z'
lore:
- 'R-Click armor stand to move +0.1 Z'
- 'Crouch R-Click for -0.1 Z'
lLegX:
name: 'Left Leg X'
lore:
- 'R-Click armor stand to change Left Leg X'
- 'Value depends on how high up the body you click'
lLegY:
name: 'Left Leg Y'
lore:
- 'R-Click armor stand to change Left Leg Y'
- 'Value depends on how high up the body you click'
lLegZ:
name: 'Left Leg Z'
lore:
- 'R-Click armor stand to change Left Leg Z'
- 'Value depends on how high up the body you click'
rLegX:
name: 'Right Leg X'
lore:
- 'R-Click armor stand to change Right Leg X'
- 'Value depends on how high up the body you click'
rLegY:
name: 'Right Leg Y'
lore:
- 'R-Click armor stand to change Right Leg Y'
- 'Value depends on how high up the body you click'
rLegZ:
name: 'Right Leg Z'
lore:
- 'R-Click armor stand to change Right Leg Z'
- 'Value depends on how high up the body you click'
bodyX:
name: 'Body X'
lore:
- 'R-Click armor stand to change Body X'
- 'Value depends on how high up the body you click'
bodyY:
name: 'Body Y'
lore:
- 'R-Click armor stand to change Body Y'
- 'Value depends on how high up the body you click'
bodyZ:
name: 'Body Z'
lore:
- 'R-Click armor stand to change Body Z'
- 'Value depends on how high up the body you click'
gui_move: gui_move:
name: 'Pick Up (Move)' name: 'Pick Up (Move/Rotate)'
lore: lore:
- 'Pick up this armor stand to move it' - 'Pick up this armor stand to move or rotate it'
gui_clone: gui_clone:
name: 'Clone' name: 'Clone'
lore: lore:
@ -261,3 +136,21 @@ tool:
gui_glow: gui_glow:
name: 'Toggle Glow' name: 'Toggle Glow'
lore: lore:
gui_head:
name: 'Move Head'
lore: 'Change the head position'
gui_body:
name: 'Move Body'
lore: 'Change the body position'
gui_larm:
name: 'Move Left Arm'
lore: 'Change the left arm position'
gui_rarm:
name: 'Move Right Arm'
lore: 'Change the right arm position'
gui_lleg:
name: 'Move Left Leg'
lore: 'Change the left leg position'
gui_rleg:
name: 'Move Right Leg'
lore: 'Change the right leg position'

Datei anzeigen

@ -1,7 +1,7 @@
main: com.gmail.St3venAU.plugins.ArmorStandTools.Main main: com.gmail.st3venau.plugins.armorstandtools.AST
name: ArmorStandTools name: ArmorStandTools
version: ${project.version} version: ${project.version}
api-version: 1.13 api-version: 1.17
author: St3venAU author: St3venAU
description: Armor stand manipulation tools description: Armor stand manipulation tools
softdepend: [WorldGuard, PlotSquared] softdepend: [WorldGuard, PlotSquared]