Skip to content

Commit

Permalink
[CORE] Add in Custom Item Name Support - Closes #118 (#122)
Browse files Browse the repository at this point in the history
* [CORE] Add in Functionality for Custom Names

* [CORE] Bump to 1.19.2-37.3

* [CORE] Bump to 1.19.2-37.3

* [CORE] Bump PlotSquared to 6.9.4

* [CORE] Optimize Imports

* [CORE] Fix Bugs in Implementation Part 1 - Objests.RequireNonNull

* [CORE] Fix Bug in Checking String Comparison

* [CORE] Fix Build Compliation due to incorrect variable

* [CORE] Bump to 1.19.2-38 - After Debug Fixes.

Signed-off-by: Wolfieheart <xmakeitrain94@gmail.com>

Signed-off-by: Wolfieheart <xmakeitrain94@gmail.com>
  • Loading branch information
Wolfieheart authored Sep 12, 2022
1 parent 22ccc01 commit f023285
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 10 deletions.
6 changes: 3 additions & 3 deletions 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.19.2-37.2</version>
<version>1.19.2-37.3</version>
<name>armorstandeditor</name>
<url>http://maven.apache.org</url>

Expand Down Expand Up @@ -90,14 +90,14 @@
<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Core</artifactId>
<version>6.9.3</version>
<version>6.9.4</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.plotsquared</groupId>
<artifactId>PlotSquared-Bukkit</artifactId>
<version>6.9.3</version>
<version>6.9.4</version>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@
package io.github.rypofalem.armorstandeditor;

import io.github.rypofalem.armorstandeditor.language.Language;

import com.jeff_media.updatechecker.*;

import io.github.rypofalem.armorstandeditor.Metrics.*;

import org.bukkit.Bukkit;
Expand Down Expand Up @@ -71,11 +69,14 @@ public class ArmorStandEditorPlugin extends JavaPlugin{

int editToolData = Integer.MIN_VALUE;
boolean requireSneaking = false;
boolean requireToolName = false;
String editToolName = null;
boolean requireToolLore = false;
String editToolLore = null;
boolean allowCustomModelData = false;
Integer customModelDataInt = Integer.MIN_VALUE;


boolean debug = false; //weather or not to broadcast messages via print(String message)
double coarseRot;
double fineRot;
Expand Down Expand Up @@ -192,6 +193,13 @@ public void onEnable(){
//ArmorStandVisibility Node
armorStandVisibility = getConfig().getBoolean("armorStandVisibility", true);

//Do we require a custom tool name?
requireToolName = getConfig().getBoolean("requireToolName", false);
if(requireToolName){
editToolName = getConfig().getString("toolName", null);
if(editToolName != null) editToolName = ChatColor.translateAlternateColorCodes('&', editToolName);
}

//Is there NBT Required for the tool
requireToolData = getConfig().getBoolean("requireToolData", false);

Expand Down Expand Up @@ -370,14 +378,24 @@ public boolean isEditTool(ItemStack itemStk){
}
}

if(requireToolName && editToolName != null){
if(!itemStk.hasItemMeta()) { return false; }

//Get the name of the Edit Tool - If Null, return false
String itemName = Objects.requireNonNull(itemStk.getItemMeta()).getDisplayName();

//If the name of the Edit Tool is not the Name specified in Config then Return false
if(!itemName.equals(editToolName)) { return false; }

}

if(requireToolLore && editToolLore != null){

//If the ItemStack does not have Metadata then we return false
if(!itemStk.hasItemMeta()) { return false; }

//Get the lore of the Item and if it is null - Return False
List<String> itemLore = Objects.requireNonNull(itemStk.getItemMeta()).getLore(); //Ignore warnings this gives. Will be fixed in the future
if (itemLore == null){ return false; }
List<String> itemLore = Objects.requireNonNull(itemStk.getItemMeta()).getLore();

//If the Item does not have Lore - Return False
boolean hasTheItemLore = itemStk.getItemMeta().hasLore();
Expand Down Expand Up @@ -467,6 +485,10 @@ private void getMetrics(){
//ArmorStandInvis Config
metrics.addCustomChart(new SimplePie("itemframe_invisibility_used", () -> getConfig().getString("invisibleItemFrames")));

//TODO: Add tracking to see who is using Custom Naming in BStats - AKA Remove this soon TM
//metrics.addCustomChart(new SimplePie("custom_toolname_enabled", () -> getConfig().getString("requireToolName")));


}

public NamespacedKey getIconKey() {
Expand Down
10 changes: 8 additions & 2 deletions 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.19.2-37.2"
version: "1.19.2-38"

#----------- LANGUAGE
#Name of the language file you wish to use
Expand All @@ -25,12 +25,18 @@ tool: FLINT
requireToolData: false
toolData: 0

#(Optional) data that the plugin looks for to identify the name of the Edit Tool. Useful for Public Servers that do not want
#normal use of Flint to be impacted.
requireToolName: false
toolName: Example Name here

#(Optional) The first "Lore" entry that the plugin looks for to identify the edit tool.
requireToolLore: false
toolLore: Let's get dangerous

#(Optional) Allow the use of CustomModelData - NOTE: This looks at the editTool set by Config
#and at the Int set here to know what to set.

#Also please if you are using this, ensure that you also give people the ability asedit.give in
#order to allow them to change their edit
#tool for the right Custom Model Data
Expand Down Expand Up @@ -62,4 +68,4 @@ requireSneaking: false

#(Optional) Glowing Item Frames Support for Item Frames in 1.17 - WILL NOT WORK IN 1.16 OR LOWER AND 1.17.1 OR HIGHER
#If true, players can make itemFrames glow by right-clicking with a Glow Ink Sac
glowingItemFrame: true
glowingItemFrame: true
2 changes: 1 addition & 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.19.2-37.2
version: 1.19.2-38
api-version: "1.13"
website: https://www.spigotmc.org/resources/94503/
author: Wolfstorm
Expand Down

0 comments on commit f023285

Please sign in to comment.