diff --git a/pom.xml b/pom.xml
index 447773da..a25e2662 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
io.github.rypofalem.armorstandeditor
armorstandeditor
jar
- 1.21.1-47.2
+ 1.21.4-48
armorstandeditor
https://maven.apache.org
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java
index ef571529..1029fa2e 100644
--- a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java
@@ -81,6 +81,8 @@ public class ArmorStandEditorPlugin extends JavaPlugin {
List> allowedWorldList = null;
boolean allowCustomModelData = false;
Integer customModelDataInt = Integer.MIN_VALUE;
+ double maxScaleValue;
+ double minScaleValue;
//GUI Settings
boolean requireSneaking = false;
@@ -220,6 +222,10 @@ public void onEnable() {
coarseRot = getConfig().getDouble("coarse");
fineRot = getConfig().getDouble("fine");
+ // Scale Values for Size
+ maxScaleValue = getConfig().getDouble("maxScaleValue");
+ minScaleValue = getConfig().getDouble("minScaleValue");
+
//Set Tool to be used in game
toolType = getConfig().getString("tool");
if (toolType != null) {
@@ -580,6 +586,10 @@ public void performReload() {
coarseRot = getConfig().getDouble("coarse");
fineRot = getConfig().getDouble("fine");
+ // Scale Values for Size
+ maxScaleValue = getConfig().getDouble("maxScaleValue");
+ minScaleValue = getConfig().getDouble("minScaleValue");
+
//Set Tool to be used in game
toolType = getConfig().getString("tool");
if (toolType != null) {
@@ -745,4 +755,12 @@ public boolean isDebug() {
public void debugMsgHandler(String msg) {
if (isDebug()) getServer().getLogger().log(Level.WARNING, "[ASE-DEBUG]: {0}", msg);
}
+
+ public double getMinScaleValue() {
+ return minScaleValue;
+ }
+
+ public double getMaxScaleValue() {
+ return maxScaleValue;
+ }
}
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java
index 0c780878..9020e72e 100644
--- a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java
@@ -18,6 +18,7 @@
*/
package io.github.rypofalem.armorstandeditor;
+import io.github.rypofalem.armorstandeditor.menu.SizeMenu;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
@@ -69,6 +70,7 @@ public class PlayerEditor {
int frameTargetIndex = 0;
EquipmentMenu equipMenu;
PresetArmorPosesMenu presetPoseMenu;
+ SizeMenu sizeModificationMenu;
long lastCancelled = 0;
public PlayerEditor(UUID uuid, ArmorStandEditorPlugin plugin) {
@@ -139,7 +141,7 @@ public void editArmorStand(ArmorStand armorStand) {
toggleArms(armorStand);
break;
case SIZE:
- toggleSize(armorStand);
+ chooseSize(armorStand);
break;
case INVISIBLE:
toggleVisible(armorStand);
@@ -225,6 +227,25 @@ private void choosePreset(ArmorStand armorStand) {
presetPoseMenu.openMenu();
}
+ //Size Menu Refactor
+ /* void toggleSize(ArmorStand armorStand) {
+ if (getPlayer().hasPermission("asedit.togglesize")) {
+ armorStand.setSmall(!armorStand.isSmall());
+ } else {
+ sendMessage("nopermoption", "warn", "size");
+ }
+ }
+ */
+ private void chooseSize(ArmorStand armorStand){
+ if(!getPlayer().hasPermission("asedit.togglesize")){
+ sendMessage("nopermoption", "warn", "size");
+ return;
+ } else {
+ sizeModificationMenu = new SizeMenu(this, armorStand);
+ sizeModificationMenu.openMenu();
+ }
+ }
+
public void reverseEditArmorStand(ArmorStand armorStand) {
if (!getPlayer().hasPermission("asedit.basic")) return;
@@ -476,13 +497,6 @@ void toggleItemFrameVisible(ItemFrame itemFrame) {
}
}
- void toggleSize(ArmorStand armorStand) {
- if (getPlayer().hasPermission("asedit.togglesize")) {
- armorStand.setSmall(!armorStand.isSmall());
- } else {
- sendMessage("nopermoption", "warn", "size");
- }
- }
void cycleAxis(int i) {
int index = axis.ordinal();
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java
index 79778a9a..b3234519 100644
--- a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java
@@ -53,6 +53,7 @@ public class PlayerEditorManager implements Listener {
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
+ private ASEHolder sizeMenuHolder = new ASEHolder(); //Inventory Holder that owns the PresetArmorStand Post Menu
double coarseAdj;
double fineAdj;
double coarseMov;
@@ -432,6 +433,17 @@ void onPlayerMenuSelect(InventoryClickEvent e) {
pe.presetPoseMenu.handlePresetPose(itemName, player);
}
}
+
+ if (e.getInventory().getHolder() == sizeMenuHolder){
+ 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.sizeModificationMenu.handleAttributeScaling(itemName,player);
+ }
+ }
}
@@ -472,6 +484,10 @@ public ASEHolder getEquipmentHolder() {
return equipmentHolder;
}
+ public ASEHolder getSizeMenuHolder() {
+ return sizeMenuHolder;
+ }
+
public ASEHolder getPresetHolder() {
return presetHolder;
}
diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/menu/SizeMenu.java b/src/main/java/io/github/rypofalem/armorstandeditor/menu/SizeMenu.java
new file mode 100644
index 00000000..a1a0a2bc
--- /dev/null
+++ b/src/main/java/io/github/rypofalem/armorstandeditor/menu/SizeMenu.java
@@ -0,0 +1,233 @@
+package io.github.rypofalem.armorstandeditor.menu;
+
+import io.github.rypofalem.armorstandeditor.ArmorStandEditorPlugin;
+import io.github.rypofalem.armorstandeditor.PlayerEditor;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.Sound;
+import org.bukkit.attribute.Attribute;
+import org.bukkit.entity.ArmorStand;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.Inventory;
+import org.bukkit.inventory.ItemFlag;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.persistence.PersistentDataType;
+
+import java.util.ArrayList;
+import java.util.Map;
+
+public class SizeMenu extends ASEHolder {
+
+ public ArmorStandEditorPlugin plugin = ArmorStandEditorPlugin.instance();
+ Inventory menuInv;
+ private PlayerEditor pe;
+ private ArmorStand as;
+ static String name = "Size Menu";
+
+ public SizeMenu(PlayerEditor pe, ArmorStand as){
+ this.pe = pe;
+ this.as = as;
+ name = pe.plugin.getLang().getMessage("sizeMenu", "menutitle");
+ menuInv = Bukkit.createInventory(pe.getManager().getSizeMenuHolder(), 27 , name);
+ }
+
+ //PRESET NAMES
+ final String SCALE1 = plugin.getLang().getMessage("scale1").replace("§6","§2§n");
+ final String SCALE2 = plugin.getLang().getMessage("scale2").replace("§6","§2§n");
+ final String SCALE3 = plugin.getLang().getMessage("scale3").replace("§6","§2§n");
+ final String SCALE4 = plugin.getLang().getMessage("scale4").replace("§6","§2§n");
+ final String SCALE5 = plugin.getLang().getMessage("scale5").replace("§6","§2§n");
+ final String SCALE6 = plugin.getLang().getMessage("scale6").replace("§6","§2§n");
+ final String SCALE7 = plugin.getLang().getMessage("scale7").replace("§6","§2§n");
+ final String SCALE8 = plugin.getLang().getMessage("scale8").replace("§6","§2§n");
+ final String SCALE9 = plugin.getLang().getMessage("scale9").replace("§6","§2§n");
+ final String SCALE10 = plugin.getLang().getMessage("scale10").replace("§6","§2§n");
+ final String SCALEPLUS12 = plugin.getLang().getMessage("scaleadd12").replace("§6","§2§n");
+ final String SCALEMINUS12= plugin.getLang().getMessage("scaleremove12").replace("§6","§2§n");
+ final String SCALEPLUS110 = plugin.getLang().getMessage("scaleadd110").replace("§6","§2§n");
+ final String SCALEMINUS110 = plugin.getLang().getMessage("scaleremove110").replace("§6","§2§n");
+
+ //Menu Stuff
+ final String BACKTOMENU = plugin.getLang().getMessage("backtomenu").replace("§6","§2§n");
+ final String RESET = plugin.getLang().getMessage("reset").replace("§6","§2§n");
+
+
+ private void fillInventory(){
+ menuInv.clear();
+ ItemStack blankSlot= createIcon(new ItemStack(Material.BLACK_STAINED_GLASS_PANE, 1), "blankslot");
+ ItemStack base10 = createIcon(new ItemStack(Material.RED_CONCRETE, 1), "scale1");
+ ItemStack base20 = createIcon(new ItemStack(Material.RED_CONCRETE, 2), "scale2");
+ ItemStack base30 = createIcon(new ItemStack(Material.RED_CONCRETE, 3), "scale3");
+ ItemStack base40 = createIcon(new ItemStack(Material.RED_CONCRETE, 4), "scale4");
+ ItemStack base50 = createIcon(new ItemStack(Material.RED_CONCRETE, 5), "scale5");
+ ItemStack base60 = createIcon(new ItemStack(Material.RED_CONCRETE, 6), "scale6");
+ ItemStack base70 = createIcon(new ItemStack(Material.RED_CONCRETE, 7), "scale7");
+ ItemStack base80 = createIcon(new ItemStack(Material.RED_CONCRETE, 8), "scale8");
+ ItemStack base90 = createIcon(new ItemStack(Material.RED_CONCRETE, 9), "scale9");
+ ItemStack base100 = createIcon(new ItemStack(Material.RED_CONCRETE, 10), "scale10");
+ ItemStack add12toBase = createIcon(new ItemStack(Material.ORANGE_CONCRETE, 1), "scaleadd12");
+ ItemStack remove12fromBase = createIcon(new ItemStack(Material.GREEN_CONCRETE ,1), "scaleremove12");
+ ItemStack add110fromBase = createIcon(new ItemStack(Material.ORANGE_CONCRETE ,2), "scaleadd110");
+ ItemStack remove110fromBase = createIcon(new ItemStack(Material.GREEN_CONCRETE ,2), "scaleremove110");
+ ItemStack backToMenu = createIcon(new ItemStack(Material.RED_WOOL, 1), "backtomenu");
+ ItemStack resetIcon = createIcon(new ItemStack(Material.NETHER_STAR, 1), "reset");
+
+ ItemStack[] items = {
+ backToMenu,blankSlot,base10,base20,base30,base40,base50,base60,blankSlot,
+ resetIcon,blankSlot,base70,base80,base90,base100,blankSlot,add12toBase,remove12fromBase,
+ blankSlot,blankSlot,blankSlot,blankSlot,blankSlot,blankSlot,blankSlot,add110fromBase,remove110fromBase
+ };
+
+ menuInv.setContents(items);
+ }
+
+ private ItemStack createIcon(ItemStack icon, String path) {
+ return createIcon(icon, path, null);
+ }
+
+ private ItemStack createIcon(ItemStack icon, String path, String option) {
+ ItemMeta meta = icon.getItemMeta();
+ assert meta != null;
+ meta.getPersistentDataContainer().set(ArmorStandEditorPlugin.instance().getIconKey(), PersistentDataType.STRING, "ase " + option);
+ meta.setDisplayName(getIconName(path, option));
+ ArrayList loreList = new ArrayList<>();
+ loreList.add(getIconDescription(path, option));
+ meta.setLore(loreList);
+ meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
+ icon.setItemMeta(meta);
+ return icon;
+ }
+
+ private String getIconName(String path, String option) {
+ return pe.plugin.getLang().getMessage(path, "iconname", option);
+ }
+
+
+ private String getIconDescription(String path, String option) {
+ return pe.plugin.getLang().getMessage(path + ".description", "icondescription", option);
+ }
+
+
+ public void handleAttributeScaling(String itemName, Player player) {
+ if (itemName == null || player == null) return;
+
+ // Separate maps for positive and negative scaling options
+ Map positiveScaleMap = Map.ofEntries(
+ Map.entry(SCALE1, 1.0),
+ Map.entry(SCALE2, 2.0),
+ Map.entry(SCALE3, 3.0),
+ Map.entry(SCALE4, 4.0),
+ Map.entry(SCALE5, 5.0),
+ Map.entry(SCALE6, 6.0),
+ Map.entry(SCALE7, 7.0),
+ Map.entry(SCALE8, 8.0),
+ Map.entry(SCALE9, 9.0),
+ Map.entry(SCALE10, 10.0),
+ Map.entry(SCALEPLUS12, 0.5),
+ Map.entry(SCALEPLUS110, 0.1)
+ );
+
+ Map negativeScaleMap = Map.ofEntries(
+ Map.entry(SCALEMINUS12, 0.5), // Changed value to negative for decrement
+ Map.entry(SCALEMINUS110, 0.1) // Changed value to negative for decrement
+ );
+
+ if (positiveScaleMap.containsKey(itemName)) {
+ handleScaleChange(player, itemName, positiveScaleMap.get(itemName));
+ } else if (negativeScaleMap.containsKey(itemName)) {
+ handleScaleChange(player, itemName, negativeScaleMap.get(itemName));
+ } else if (itemName.equals(BACKTOMENU)) {
+ handleBackToMenu(player);
+ } else if (itemName.equals(RESET)) {
+ handleReset(player);
+ }
+ }
+
+
+ private void handleScaleChange(Player player, String itemName, double scale) {
+ setArmorStandScale(player, itemName, scale);
+ playChimeSound(player);
+ player.closeInventory();
+ }
+
+ private void handleBackToMenu(Player player) {
+ player.playSound(player.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 1);
+ player.closeInventory();
+ pe.openMenu();
+ }
+
+ private void handleReset(Player player) {
+ setArmorStandScale(player, RESET, 1);
+ playChimeSound(player);
+ player.closeInventory();
+ }
+
+ private void playChimeSound(Player player) {
+ player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_CHIME, 1, 1);
+ }
+
+ private void setArmorStandScale(Player player, String itemName, double scaleValue) {
+
+ double currentScaleValue; double newScaleValue;
+
+ for (Entity theArmorStand : player.getNearbyEntities(1,1,1)){
+ if(theArmorStand instanceof ArmorStand as){
+
+ // Permission Check
+ if (!player.hasPermission("asedit.togglesize")) return;
+
+ // Can be overwritten
+ currentScaleValue = 0;
+
+ // Basically go from 0 to ItemSize
+ if(itemName.equals(SCALE1) || itemName.equals(SCALE2) || itemName.equals(SCALE3)
+ || itemName.equals(SCALE4)|| itemName.equals(SCALE5)|| itemName.equals(SCALE6)
+ || itemName.equals(SCALE7)|| itemName.equals(SCALE8)|| itemName.equals(SCALE9)
+ || itemName.equals(SCALE10)){
+ newScaleValue = currentScaleValue + scaleValue;
+ if(newScaleValue >= plugin.getMaxScaleValue()){
+ pe.plugin.getLang().getMessage("scalemaxwarn","warn");
+ return;
+ } else if(newScaleValue <= plugin.getMinScaleValue()){
+ pe.plugin.getLang().getMessage("scaleminwarn","warn");
+ return;
+ } else {
+ as.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(newScaleValue);
+ }
+ } else if(itemName.equals(SCALEPLUS12) || itemName.equals(SCALEPLUS110)){
+ currentScaleValue = as.getAttribute(Attribute.GENERIC_SCALE).getBaseValue();
+ newScaleValue = currentScaleValue + scaleValue; // Add for increments
+ if(newScaleValue >= plugin.getMaxScaleValue()){
+ pe.plugin.getLang().getMessage("scalemaxwarn", "warn");
+ return;
+ }
+ as.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(newScaleValue);
+ } else if(itemName.equals(SCALEMINUS12) || itemName.equals(SCALEMINUS110)){
+ currentScaleValue = as.getAttribute(Attribute.GENERIC_SCALE).getBaseValue();
+ newScaleValue = currentScaleValue - scaleValue; // Subtract for decrements
+ if(newScaleValue <= plugin.getMinScaleValue()){
+ pe.plugin.getLang().getMessage("scaleminwarn", "warn");
+ return;
+ }
+ as.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(newScaleValue);
+ }else if(itemName.equals(RESET)){
+ newScaleValue = 1;
+ as.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(newScaleValue);
+ }
+
+
+ }
+ }
+
+
+ }
+
+ public void openMenu() {
+ if(pe.getPlayer().hasPermission("asedit.togglesize")){
+ fillInventory();
+ pe.getPlayer().openInventory(menuInv);
+ }
+ }
+}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 22667c12..377ade75 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -3,7 +3,7 @@
#-----------------------------#
#DO NOT CHANGE THIS - CHANGES AUTOMATICALLY PER UPDATE
-version: "1.21.1-47.2"
+version: "1.21.4-48"
#----------- LANGUAGE
#Name of the language file you wish to use
@@ -73,6 +73,11 @@ coarse: 12
#How many rotations to make a full circle in Fine adjustment mode
fine: 120
+# (NEW) Set a server limit on the Size of an ArmorStand
+# NOte this has been changed to take into account the /attribute command version
+minScaleValue: 0.1
+maxScaleValue: 10
+
#Allow the option to toggle invisibility for ItemFrames and ArmorStand
#You can either use this or the below permissions to allow visibility changes
#asedit.togglearmorstandvisibility
diff --git a/src/main/resources/lang/en_US.yml b/src/main/resources/lang/en_US.yml
index 9940fe8a..63ea695f 100644
--- a/src/main/resources/lang/en_US.yml
+++ b/src/main/resources/lang/en_US.yml
@@ -371,3 +371,71 @@ howtopresetmsg:
3. Choose one of the Armor Stand Presets that you want to select.
4. After choosing, your menu will close and your chosen preset will be applied. "
+
+
+#Size Scaling
+sizeMenu:
+ msg: ArmorStand Size (Scaling)
+ description:
+ msg: Set a scale for your ArmorStand [Will Open ANOTHER Menu]
+
+scale1:
+ msg: Scale = 1 (Default)
+ description:
+ msg: Set the Scale Attribute of your ArmorStand to 1 (Default)
+scale2:
+ msg: Scale = 2
+ description:
+ msg: Set the Scale Attribute of your ArmorStand to Scale 2
+scale3:
+ msg: Scale = 3
+ description:
+ msg: Set the Scale Attribute of your ArmorStand to Scale 3
+scale4:
+ msg: Scale = 4
+ description:
+ msg: Set the Scale Attribute of your ArmorStand to Scale 4
+scale5:
+ msg: Scale = 5
+ description:
+ msg: Set the Scale Attribute of your ArmorStand to Scale 5
+scale6:
+ msg: Scale = 6
+ description:
+ msg: Set the Scale Attribute of your ArmorStand to Scale 6
+scale7:
+ msg: Scale = 7
+ description:
+ msg: Set the Scale Attribute of your ArmorStand to Scale 7
+scale8:
+ msg: Scale = 8
+ description:
+ msg: Set the Scale Attribute of your ArmorStand to Scale 8
+scale9:
+ msg: Scale = 9
+ description:
+ msg: Set the Scale Attribute of your ArmorStand to scale 9
+scale10:
+ msg: Scale = 10
+ description:
+ msg: Set the Scale Attribute of your ArmorStand to scale 10
+scaleadd12:
+ msg: Scale + 0.5 (Coarse)
+ description:
+ msg: Add 0.5 to the current Scale of your ArmorStand
+scaleremove12:
+ msg: Scale - 0.5 (Coarse)
+ description:
+ msg: Remove 0.5 to the current Scale of your ArmorStand
+scaleadd110:
+ msg: Scale + 0.1 (Fine)
+ description:
+ msg: Remove 0.5 to the current Scale of your ArmorStand
+scaleremove110:
+ msg: Scale - 0.1 (Fine)
+ description:
+ msg: Remove 0.1 to the current Scale of your ArmorStand
+scalemaxwarn:
+ msg: Please choose a different size, as this against the server maximum scale limits
+scaleminwarn:
+ msg: Please choose a different size, as this against the server minimum scale limits
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index fdf6d196..2f949d7f 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
name: ArmorStandEditor
main: io.github.rypofalem.armorstandeditor.ArmorStandEditorPlugin
-version: 1.21.1-47.2
+version: 1.21.4-48
api-version: "1.17"
folia-supported: true
website: https://www.spigotmc.org/resources/94503/