Skip to content

Commit

Permalink
[CORE] ArmorStandEditor 1.21.4-48.1: Fixes (#671)
Browse files Browse the repository at this point in the history
* [CORE] Bump to 1.21.4-48.1

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

* [LANG] Fix an issue with the size menu showing the wrong description when adding Fine Movements

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

* [CORE] Fix Undisclosed Duplicate

Credits to Cullan on the Discord for helping me work this one out

* [CORE] Fix the check for the Size Menu Requirements (Part 1)

* [CORE] Fix the check for the Size Menu Requirements (Part 1.5)

* [CORE] Size menu Fix part 2

* [CORE] Size Menu Part 3 - Fixing Stats Menu

* [CORE] Size Menu - part4

* [CORE] Replace the check on NMS Versioning

More a test to see if what I have in mind will work.

* [CORE] Revert Changes and update getMinecraftVersion routine.

* Revert d3150d1

* [CORE] Fix it like we do for the Startup Checks

* [CORE] Update TownyProtection with a bit better checks and a new permission.

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

* [CORE] Add Debug and Output Message if editing in Wild Fails

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

---------

Signed-off-by: Wolfieheart <[email protected]>
  • Loading branch information
Wolfieheart authored Feb 10, 2025
1 parent 9f140cc commit a362389
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>io.github.rypofalem.armorstandeditor</groupId>
<artifactId>armorstandeditor</artifactId>
<packaging>jar</packaging>
<version>1.21.4-48</version>
<version>1.21.4-48.1</version>
<name>armorstandeditor</name>
<url>https://maven.apache.org</url>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,12 @@ public void onDisable() {
}

public String getNmsVersion() {
return this.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
// return this.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
if (getHasPaper() || getHasFolia()){
return this.getMinecraftVersion();
} else {
return this.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
}
}

public boolean getHasSpigot() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ private void commandStats(Player player) {
leftLegZ = Math.toDegrees(leftLegZ);
leftLegZ = Math.rint(leftLegZ);

if (plugin.getServer().getMinecraftVersion().compareTo("1.21.4") >= 0 || plugin.getNmsVersion().compareTo("v1_21_R3") >= 0) {
if (plugin.getNmsVersion().compareTo("1.21.4") >= 0 || plugin.getNmsVersion().compareTo("v1_21_R3") >= 0) {
sizeAttribute = Objects.requireNonNull(as.getAttribute(Attribute.SCALE)).getBaseValue();
} else {
sizeAttribute = 0;
Expand Down Expand Up @@ -440,7 +440,7 @@ private void commandStats(Player player) {
player.sendMessage(ChatColor.YELLOW + "Coordinates: " + ChatColor.AQUA + " X: " + locationX + " / Y: " + locationY + " / Z: " + locationZ);
player.sendMessage(ChatColor.YELLOW + "Is Visible: " + ChatColor.AQUA + isVisible + ". " + ChatColor.YELLOW + "Arms Visible: " + ChatColor.AQUA + armsVisible + ". " + ChatColor.YELLOW + "Base Plate Visible: " + ChatColor.AQUA + basePlateVisible);
player.sendMessage(ChatColor.YELLOW + "Is Vulnerable: " + ChatColor.AQUA + isVulnerable + ". " + ChatColor.YELLOW + "Affected by Gravity: " + ChatColor.AQUA + hasGravity);
if (plugin.getServer().getMinecraftVersion().compareTo("1.21.4") >= 0 || plugin.getNmsVersion().compareTo("v1_21_R3") >= 0) {
if (plugin.getNmsVersion().compareTo("1.21.4") >= 0 || plugin.getNmsVersion().compareTo("v1_21_R3") >= 0) {
player.sendMessage(ChatColor.YELLOW + "Size: " + ChatColor.AQUA + sizeAttribute + "/" + plugin.getMaxScaleValue() + ". " + ChatColor.YELLOW + "Is Glowing: " + ChatColor.AQUA + isGlowing + ". " + ChatColor.YELLOW + "Is Locked: " + ChatColor.AQUA + isLocked);
} else {
player.sendMessage(ChatColor.YELLOW + "Is Small: " + ChatColor.AQUA + isSmall + ". " + ChatColor.YELLOW + "Is Glowing: " + ChatColor.AQUA + isGlowing + ". " + ChatColor.YELLOW + "Is Locked: " + ChatColor.AQUA + isLocked);
Expand Down Expand Up @@ -578,4 +578,4 @@ private List<String> getAdjOptions() {
return List.of("Coarse", "Fine");
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ private void openEquipment(ArmorStand armorStand) {
if(team != null && !team.hasEntry(armorStandInUseId.toString())){
debug.log("ArmorStand Not on a Team and Player '" + getPlayer().getDisplayName() + "' has triggered to Open the Equipment Menu, Adding to In Use Team");
team.addEntry(armorStandInUseId.toString());
getPlayer().closeInventory();
equipMenu = new EquipmentMenu(this, armorStand);
equipMenu.openMenu();
} else {
Expand All @@ -246,6 +247,7 @@ private void openEquipment(ArmorStand armorStand) {
private void choosePreset(ArmorStand armorStand) {
if (!getPlayer().hasPermission("asedit.basic")) return;
debug.log("Player '" + getPlayer().getDisplayName() + "' has triggered the Preset Poses Menu");
getPlayer().closeInventory();
presetPoseMenu = new PresetArmorPosesMenu(this, armorStand);
presetPoseMenu.openMenu();
}
Expand All @@ -256,9 +258,10 @@ private void chooseSize(ArmorStand armorStand){
sendMessage("nopermoption", "warn", "size");
return;
} else {
if (plugin.getServer().getMinecraftVersion().compareTo("1.21.4") >= 0 || plugin.getNmsVersion().compareTo("v1_21_R3") >= 0) {
if (plugin.getNmsVersion().compareTo("1.21.4") >= 0 || plugin.getNmsVersion().compareTo("v1_21_R3") >= 0) {
//NOTE: New Sizing Menu ONLY WORKS IN 1.21.3 and HIGHER
debug.log("Player '" + getPlayer().getDisplayName() + "' has triggered the AS Attribute Size Menu");
getPlayer().closeInventory();
sizeModificationMenu = new SizeMenu(this, armorStand);
sizeModificationMenu.openMenu();
} else {
Expand Down Expand Up @@ -391,7 +394,7 @@ private void paste(ArmorStand armorStand) {
armorStand.setLeftLegPose(data.leftLegPos);
armorStand.setRightLegPose(data.rightLegPos);

if (plugin.getServer().getMinecraftVersion().compareTo("1.21.4") >= 0 || plugin.getNmsVersion().compareTo("v1_21_R3") >= 0) {
if (plugin.getNmsVersion().compareTo("1.21.4") >= 0 || plugin.getNmsVersion().compareTo("v1_21_R3") >= 0) {
armorStand.getAttribute(Attribute.SCALE).setBaseValue(data.attributeScale);
} else {
armorStand.setSmall(data.size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ArmorStandData {
this.leftLegPos = as.getLeftLegPose();
this.rightLegPos = as.getRightLegPose();
this.size = as.isSmall();
if (plugin.getServer().getMinecraftVersion().compareTo("1.21.4") >= 0 || plugin.getNmsVersion().compareTo("v1_21_R3") >= 0) {
if (plugin.getNmsVersion().compareTo("1.21.4") >= 0 || plugin.getNmsVersion().compareTo("v1_21_R3") >= 0) {
this.attributeScale = as.getAttribute(Attribute.SCALE).getValue();
}
this.basePlate = as.hasBasePlate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,55 @@
package io.github.rypofalem.armorstandeditor.protections;

import com.palmergames.bukkit.towny.TownyAPI;
import com.palmergames.bukkit.towny.event.executors.TownyActionEventExecutor;

import com.palmergames.bukkit.towny.object.Resident;
import com.palmergames.bukkit.towny.object.Town;
import com.palmergames.bukkit.towny.object.TownBlock;
import io.github.rypofalem.armorstandeditor.ArmorStandEditorPlugin;
import io.github.rypofalem.armorstandeditor.Debug;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;

//FIX for https://github.com/Wolfieheart/ArmorStandEditor-Issues/issues/15
public class TownyProtection implements Protection {
private final boolean tEnabled;
private Debug debug;
private ArmorStandEditorPlugin plugin;


public TownyProtection() {
plugin = ArmorStandEditorPlugin.instance();
debug = new Debug(plugin);
tEnabled = Bukkit.getPluginManager().isPluginEnabled("Towny");
}

public boolean checkPermission(Block block, Player player) {
TownyAPI towny;
if (!tEnabled) return true;
if (player.isOp()) return true;
if (player.hasPermission("asedit.ignoreProtection.towny")) return true; //Add Additional Permission

towny = TownyAPI.getInstance();
Location playerLoc = player.getLocation();
Location asLoc = block.getLocation();

if (TownyAPI.getInstance().isWilderness(playerLoc)) return false;
return TownyActionEventExecutor.canDestroy(player, block.getLocation(), Material.ARMOR_STAND);
if(towny.isWilderness(playerLoc) && player.hasPermission("asedit.townyProtection.canEditInWild")){
debug.log(" User is in the Wilderness and Can Edit.");
return true;
} else if(towny.isWilderness(playerLoc) && !player.hasPermission("asedit.townyProtection.canEditInWild")) {
player.sendMessage(plugin.getLang().getMessage("townyNoWildEdit","warn"));
return false;
}

Resident resident = towny.getResident(player);
TownBlock townBlock = towny.getTownBlock(asLoc);
Town town = townBlock.getTownOrNull();

if(resident == null || town == null) return true;
if(townBlock.hasResident(resident) || townBlock.hasTrustedResident(resident)) return true;
return town.hasResident(resident);
}
}

2 changes: 1 addition & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#-----------------------------#

#DO NOT CHANGE THIS - CHANGES AUTOMATICALLY PER UPDATE
version: "1.21.4-48"
version: "1.21.4-48.1"

#----------- LANGUAGE
#Name of the language file you wish to use
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/lang/en_US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ noconsolecom:
msg: Sorry but this command only works from in-game and not from Console!
renamestopped:
msg: Please make sure you have the ability/permission to give your ArmorStand Colored Names.

townyNoWildEdit:
msg: Unable to change this ArmorStand as you are not allowed to edit in the wild.

#menutitle
mainmenutitle:
Expand Down Expand Up @@ -433,7 +434,7 @@ scaleremove12:
scaleadd110:
msg: Scale + 0.1 (Fine)
description:
msg: Remove 0.5 to the current Scale of your ArmorStand
msg: Add 0.1 to the current Scale of your ArmorStand
scaleremove110:
msg: Scale - 0.1 (Fine)
description:
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ArmorStandEditor
main: io.github.rypofalem.armorstandeditor.ArmorStandEditorPlugin
version: 1.21.4-48
version: 1.21.4-48.1
api-version: "1.17"
folia-supported: true
website: https://www.spigotmc.org/resources/94503/
Expand Down Expand Up @@ -124,6 +124,10 @@ permissions:
description: Allows user to ignore ItemAdder/LoneDev Protection Limitations.
default: false

asedit.townyProtection.canEditInWild:
description: Allows for editing in the Wilderness - ONLY use IF you have Towny
default: false

asedit.ignoreProtection.*:
description: Ignore all Protection Limitations
default: op
Expand Down

0 comments on commit a362389

Please sign in to comment.