Skip to content

Commit

Permalink
[CORE] ArmorStandEditor v1.20.40-45 (#386)
Browse files Browse the repository at this point in the history
* [CORE] Bump to 1.20.4

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Fix an issue in BentoBoxProtection when using AOneBlock

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Version Bump -45

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Initial Implementation - Preset Poses (NEW in 1.20.4-45)

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Fix UI Issue where Cursor defailts to hanging over Gravity.

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Resize and Add More Presets.

- Also Update all the language Files to match.

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Fix Copy Paste Error + Fix for Sand being auto clicked in UI

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Lay the ground work for ASE 1.x.x-46

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Lay the ground work for ASE 1.x.x-46

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Final Patches for ASE 1.20.4-45

Signed-off-by: Wolfieheart <[email protected]>

* Revert "[CORE] Final Patches for ASE 1.20.4-45"

This reverts commit c761a71.

* [CORE] Final Patches for ASE 1.20.4-45

Signed-off-by: Wolfieheart <[email protected]>

* Update dependency com.github.angeschossen:LandsAPI to v6.42.8 (#396)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update dependency org.apache.maven.plugins:maven-compiler-plugin to v3.12.0 (#395)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Bump actions/upload-artifact from 3.1.3 to 4.0.0 (#393)

Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.3 to 4.0.0.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@v3.1.3...v4.0.0)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump com.palmergames.bukkit.towny:towny from 0.100.0.8 to 0.100.0.9 (#392)

Bumps [com.palmergames.bukkit.towny:towny](https://github.com/TownyAdvanced/Towny) from 0.100.0.8 to 0.100.0.9.
- [Release notes](https://github.com/TownyAdvanced/Towny/releases)
- [Commits](TownyAdvanced/Towny@0.100.0.8...0.100.0.9)

---
updated-dependencies:
- dependency-name: com.palmergames.bukkit.towny:towny
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump org.openrewrite.maven:rewrite-maven-plugin from 5.15.4 to 5.16.0 (#391)

Bumps [org.openrewrite.maven:rewrite-maven-plugin](https://github.com/openrewrite/rewrite-maven-plugin) from 5.15.4 to 5.16.0.
- [Release notes](https://github.com/openrewrite/rewrite-maven-plugin/releases)
- [Commits](openrewrite/rewrite-maven-plugin@v5.15.4...v5.16.0)

---
updated-dependencies:
- dependency-name: org.openrewrite.maven:rewrite-maven-plugin
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* [CORE] Bump to 1.20.4

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Fix an issue in BentoBoxProtection when using AOneBlock

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Version Bump -45

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Initial Implementation - Preset Poses (NEW in 1.20.4-45)

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Fix UI Issue where Cursor defailts to hanging over Gravity.

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Resize and Add More Presets.

- Also Update all the language Files to match.

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Fix Copy Paste Error + Fix for Sand being auto clicked in UI

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Lay the ground work for ASE 1.x.x-46

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Lay the ground work for ASE 1.x.x-46

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Final Patches for ASE 1.20.4-45

Signed-off-by: Wolfieheart <[email protected]>

* Revert "[CORE] Final Patches for ASE 1.20.4-45"

This reverts commit c761a71.

* [CORE] Final Patches for ASE 1.20.4-45

Signed-off-by: Wolfieheart <[email protected]>

---------

Signed-off-by: Wolfieheart <[email protected]>
Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 22, 2023
1 parent 2227d3b commit 7b2ee3b
Show file tree
Hide file tree
Showing 26 changed files with 1,589 additions and 121 deletions.
4 changes: 2 additions & 2 deletions API-Example-Plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.rypofalem.apiexample</groupId>
<artifactId>armorstandeditor-apitest</artifactId>
<packaging>jar</packaging>
<version>1.20.1-43.2</version>
<name>armorstandeditor-apitest</name>
<url>http://maven.apache.org</url>
<url>s://maven.apache.org</url>

<properties>
<java.version>17</java.version>
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.rypofalem.armorstandeditor</groupId>
<artifactId>armorstandeditor</artifactId>
<packaging>jar</packaging>
<version>1.20.2-44.1</version>
<version>1.20.4-45</version>
<name>armorstandeditor</name>
<url>http://maven.apache.org</url>
<url>https://maven.apache.org</url>

<properties>
<java.version>17</java.version>
Expand Down Expand Up @@ -106,7 +106,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.2-R0.1-SNAPSHOT</version>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
*
* IMPORTANT: You are not allowed to modify this class, except changing the package.
*
* Unallowed modifications include but are not limited to:
* Disallowed modifications include but are not limited to:
* - Remove the option for users to opt-out
* - Change the frequency for data submission
* - Obfuscate the code (every obfucator should allow you to make an exception for specific files)
* - Obfuscate the code (every obfuscator should allow you to make an exception for specific files)
* - Reformat the code (if you use a linter, add an exception)
*
* Violations will result in a ban of your plugin and account from bStats.
*/
package io.github.rypofalem.armorstandeditor;

import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
Expand Down Expand Up @@ -877,4 +878,4 @@ public String toString() {
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package io.github.rypofalem.armorstandeditor;

import io.github.rypofalem.armorstandeditor.menu.PresetArmorPosesMenu;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;

Expand Down Expand Up @@ -65,6 +66,7 @@ public class PlayerEditor {
int targetIndex = 0;
int frameTargetIndex = 0;
EquipmentMenu equipMenu;
PresetArmorPosesMenu presetPoseMenu;
long lastCancelled = 0;

public PlayerEditor(UUID uuid, ArmorStandEditorPlugin plugin) {
Expand Down Expand Up @@ -109,7 +111,7 @@ public void setCopySlot(byte slot) {
}

public void editArmorStand(ArmorStand armorStand) {
if (getPlayer().hasPermission("asedit.basic")) {
if (getPlayer().hasPermission("asedit.basic")) {

armorStand = attemptTarget(armorStand);
switch (eMode) {
Expand Down Expand Up @@ -173,6 +175,9 @@ public void editArmorStand(ArmorStand armorStand) {
case GLOWING:
toggleGlowing(armorStand);
break;
case PRESET:
choosePreset(armorStand);
break;
case NONE:
default:
sendMessage("nomode", null);
Expand Down Expand Up @@ -212,6 +217,12 @@ private void openEquipment(ArmorStand armorStand) {
equipMenu.open();
}

private void choosePreset(ArmorStand armorStand){
if (!getPlayer().hasPermission("asedit.basic")) return;
presetPoseMenu = new PresetArmorPosesMenu(this, armorStand);
presetPoseMenu.openMenu();
}

public void reverseEditArmorStand(ArmorStand armorStand) {
if (!getPlayer().hasPermission("asedit.basic")) return;

Expand Down Expand Up @@ -518,6 +529,7 @@ private EulerAngle subEulerAngle(EulerAngle angle) {
return angle;
}


public void setTarget(ArrayList<ArmorStand> armorStands) {
if (armorStands == null || armorStands.isEmpty()) {
target = null;
Expand Down Expand Up @@ -594,6 +606,7 @@ public void setFrameTarget(ArrayList<ItemFrame> itemFrames) {
}



ArmorStand attemptTarget(ArmorStand armorStand) {
if (target == null
|| !target.isValid()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.bukkit.event.player.*;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.util.Vector;

Expand All @@ -53,6 +52,7 @@ public class PlayerEditorManager implements Listener {
private HashMap<UUID, PlayerEditor> players;
private ASEHolder menuHolder = new ASEHolder(); //Inventory holder that owns the main ase menu inventories for the plugin
private ASEHolder equipmentHolder = new ASEHolder(); //Inventory holder that owns the equipment menu
private ASEHolder presetHolder = new ASEHolder(); //Inventory Holder that owns the PresetArmorStand Post Menu
double coarseAdj;
double fineAdj;
double coarseMov;
Expand Down Expand Up @@ -416,8 +416,21 @@ void onPlayerMenuSelect(InventoryClickEvent e) {
e.setCancelled(true);
}
}

if (e.getInventory().getHolder() == presetHolder){
e.setCancelled(true);
ItemStack item = e.getCurrentItem();
if(item != null && item.hasItemMeta()){
Player player = (Player) e.getWhoClicked();
String itemName = item.getItemMeta().getDisplayName();
PlayerEditor pe = players.get(player.getUniqueId());
pe.presetPoseMenu.handlePresetPose(itemName, player);
}
}
}



@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
void onPlayerMenuClose(InventoryCloseEvent e) {
if (e.getInventory().getHolder() == null) return;
Expand Down Expand Up @@ -455,10 +468,16 @@ public ASEHolder getEquipmentHolder() {
return equipmentHolder;
}

public ASEHolder getPresetHolder() {
return presetHolder;
}

long getTime() {
return counter.ticks;
}



class TickCounter implements Runnable {
long ticks = 0; //I am optimistic

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package io.github.rypofalem.armorstandeditor.menu;

import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;
import java.util.UUID;
import java.util.function.Function;
import java.util.stream.Collectors;


/*
* Currently not used but groundwork is now being laid for later
*/
public interface ItemFactory {
static ItemFactory getInstance() {
return new ItemFactory() {};
}

default ItemStack createItem(ConfigurationSection section, Inventory inventory, Function<ItemStack, ItemStack> function) {
ItemStack itemStack = createItem(section, (Function<String, String>) null, null);
if (itemStack == null || section == null) return itemStack;

int slot = section.getInt("slot", -1);
if (slot != -1 && inventory != null) inventory.setItem(slot, function == null ? itemStack : function.apply(itemStack));
return itemStack;
}

default ItemStack createItem(ConfigurationSection section, Function<String, String> nameReplacements, Function<List<String>, List<String>> loreReplacements) {
if (section == null) return null; // If the section is null, return null.

String upper = section.getString( "material");
if (upper == null) return null;

Material material = Material.getMaterial(loreReplacements == null ? upper.toUpperCase() : nameReplacements.apply(upper)); // Get the material from the config.
if (material == null || material == Material.AIR) return null; // If the material is null or air, return null.
if (material == getSkullMaterial() && (section.getString("owner") != null || section.getString("texture") != null)) // If the material is a skull and the owner or texture is set, create a skull.
return createSkull(section, nameReplacements, loreReplacements);

ItemStack itemStack = new ItemStack(material, section.getInt("amount", 1), (short) section.getInt("data")); // Create the item stack.
return addBaseItemMeta(itemStack, itemStack.getItemMeta(), section, nameReplacements, loreReplacements); // Add the base item meta.
}

default ItemStack createSkull(ConfigurationSection section, Function<String, String> nameReplacements, Function<List<String>, List<String>> loreReplacements) {
if (section == null) return null;

ItemStack itemStack = new ItemStack(getSkullMaterial(), section.getInt("amount", 1), (short) section.getInt("data")); // Create the item stack.
return addBaseItemMeta(itemStack, applyBasicSkull(itemStack, section, nameReplacements), section, nameReplacements, loreReplacements); // Add the base item meta.
}

default SkullMeta applyBasicSkull(ItemStack itemStack, ConfigurationSection section, Function<String, String> nameReplacements) {
SkullMeta im = (SkullMeta) itemStack.getItemMeta(); // Get the item meta.
String owner = section.getString( "owner"); // Get the owner from the config.
if (owner == null) im.setOwner(nameReplacements == null ? owner : nameReplacements.apply(owner)); // If the owner is not empty, set the owner.

String texture = section.getString("texture"); // Get the texture from the config.
if (texture == null) {
GameProfile profile = new GameProfile(UUID.randomUUID(), null); // Create a new game profile.
profile.getProperties().put("textures", new Property("textures", texture)); // Set the texture.

try {
Field profileField = im.getClass().getDeclaredField("profile"); // Get the profile field.
profileField.setAccessible(true); // Set the field to accessible.
profileField.set(im, profile); // Set the profile.
} catch (Exception e) {
e.printStackTrace();
}
}
return im; // Return the item meta.
}

default ItemStack addBaseItemMeta(ItemStack itemStack, ItemMeta im, ConfigurationSection section, Function<String, String> nameReplacements, Function<List<String>, List<String>> loreReplacements) {
if (section == null || itemStack.getAmount() <= 0) return null; // If the section is null or the amount is 0, return null.

String name = ChatColor.translateAlternateColorCodes('&', section.getString("name")); // Get the name from the config.
im.setDisplayName((nameReplacements == null || name == null ? name : nameReplacements.apply(name))); // Set the display name.

List<String> lore = section.getStringList("lore"); // Get the lore from the config.
im.setLore((loreReplacements == null ? lore : loreReplacements.apply(lore).stream().flatMap(x -> Arrays.stream(x.split("\n"))).toList()).stream().map(x -> ChatColor.translateAlternateColorCodes('&', x)).collect(Collectors.toList())); // Set the lore.

if (section.getBoolean("glowing")) { // If the item is glowing,
im.addEnchant(Enchantment.DURABILITY, 1, true); // Add the durability enchantment.
try {
im.addItemFlags(ItemFlag.HIDE_ENCHANTS); // Add the hide enchants flag.
} catch (NoClassDefFoundError ignored) {
}
}
try {
section.getStringList("item-flags").forEach(x -> im.addItemFlags(ItemFlag.valueOf(x))); // Add the item flags.
} catch (NoClassDefFoundError ignored) {
}
try {
section.getStringList("enchantments").forEach(x -> im.addEnchant(Enchantment.getByName(x.split(":")[0].toUpperCase()), Integer.parseInt(x.split(":")[1]), true)); // Add the enchantments.
} catch (NoClassDefFoundError ignored) {
}
try {
int customModelData = section.getInt("custom-model-data", -1); // Get the custom model data.
if (customModelData != -1) im.setCustomModelData(customModelData); // Set the custom model data.
} catch (Throwable ignored) {}

if (im instanceof PotionMeta) {
try {
PotionEffect effect = new PotionEffect(PotionEffectType.getByName(section.getString("effect")), section.getInt("duration"), section.getInt("amplifier"));
((PotionMeta) im).addCustomEffect(effect, true);
} catch (Throwable ignored) {}
}
itemStack.setItemMeta(im); // Set the item meta.
return itemStack; // Return the item stack.
}

default Material getSkullMaterial() {
Material icon = Material.getMaterial("PLAYER_HEAD"); // Get the player head material.
if (icon == null) return Material.getMaterial("SKULL_ITEM"); // If the player head material is null, get the skull item material.
return icon;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ private void fillInventory() {
ItemStack help;
ItemStack itemFrameVisible;
ItemStack blankSlot;
ItemStack presetItem = null;

//Variables that need to be Initialized
ItemStack place = null;
Expand Down Expand Up @@ -134,6 +135,8 @@ private void fillInventory() {
showArms = createIcon(new ItemStack(Material.STICK),
"showarms", "mode showarms");

presetItem = createIcon(new ItemStack(Material.BOOKSHELF), "presetmenu", "mode preset");

//Praise Start - Sikatsu and cowgod, Nicely spotted this being broken
if (pe.getPlayer().hasPermission("asedit.togglearmorstandvisibility") ||
pe.plugin.getArmorStandVisibility()) {
Expand Down Expand Up @@ -236,16 +239,17 @@ private void fillInventory() {

help = createIcon(new ItemStack(Material.NETHER_STAR), "helpgui", "help");

ItemStack[] items ={

ItemStack[] items = {
blankSlot, blankSlot, blankSlot, xAxis, yAxis, zAxis, blankSlot, blankSlot, help,
copy, paste, blankSlot, playerHead, headPos, reset, blankSlot, itemFrameVisible, glowing,
slot1, slot2, blankSlot, rightArmPos, bodyPos, leftArmPos, blankSlot, rotate, place,
slot3, slot4, blankSlot, rightLegPos, equipment, leftLegPos, blankSlot, coarseAdj, fineAdj,
blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot,
blankSlot, showArms, visibility, size, gravity, plate, toggleVulnerabilty, disableSlots, blankSlot
presetItem, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, disableSlots,
blankSlot, showArms, visibility, size, blankSlot, plate, toggleVulnerabilty, gravity, blankSlot
};


menuInv.setContents(items);
}

Expand Down
Loading

0 comments on commit 7b2ee3b

Please sign in to comment.