forked from Upstream/CommandPanels
3.21.3.2
This commit is contained in:
parent
6c390a98f2
commit
6f2a39d613
@ -1,4 +1,4 @@
|
|||||||
version: 3.21.3.1
|
version: 3.21.3.2
|
||||||
main: me.rockyhawk.commandpanels.CommandPanels
|
main: me.rockyhawk.commandpanels.CommandPanels
|
||||||
name: CommandPanels
|
name: CommandPanels
|
||||||
author: RockyHawk
|
author: RockyHawk
|
||||||
|
@ -335,8 +335,8 @@ public class CommandPanels extends JavaPlugin{
|
|||||||
assert renamedMeta != null;
|
assert renamedMeta != null;
|
||||||
//hiding attributes will add an NBT tag
|
//hiding attributes will add an NBT tag
|
||||||
if(hideAttributes) {
|
if(hideAttributes) {
|
||||||
renamedMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
|
||||||
renamedMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
renamedMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
|
renamedMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||||
//HIDE_ADDITIONAL_TOOLTIP was added into 1.20.5 api
|
//HIDE_ADDITIONAL_TOOLTIP was added into 1.20.5 api
|
||||||
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_21) ||
|
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_21) ||
|
||||||
(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20) && legacy.MINOR_VERSION >= 5)){
|
(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20) && legacy.MINOR_VERSION >= 5)){
|
||||||
@ -355,6 +355,10 @@ public class CommandPanels extends JavaPlugin{
|
|||||||
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_17)){
|
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_17)){
|
||||||
renamedMeta.addItemFlags(ItemFlag.HIDE_DYE);
|
renamedMeta.addItemFlags(ItemFlag.HIDE_DYE);
|
||||||
}
|
}
|
||||||
|
//setAttributeModifiers was added into 1.14 api
|
||||||
|
if(legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_14)){
|
||||||
|
renamedMeta.setAttributeModifiers(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (customName != null) {
|
if (customName != null) {
|
||||||
renamedMeta.setDisplayName(customName);
|
renamedMeta.setDisplayName(customName);
|
||||||
|
@ -20,33 +20,24 @@ public class HasSections {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String hasSection(Panel panel, PanelPosition position, ConfigurationSection cf, Player p) {
|
public String hasSection(Panel panel, PanelPosition position, ConfigurationSection cf, Player p) {
|
||||||
for (int count = 0; cf.getKeys(false).size() > count; count++) {
|
for (String setName : cf.getKeys(false)) {
|
||||||
String setName;
|
if (!cf.isConfigurationSection(setName)) continue;
|
||||||
if(cf.isSet("has" + count)) {
|
|
||||||
setName = "has" + count;
|
ConfigurationSection currentSection = cf.getConfigurationSection(setName);
|
||||||
}else{
|
int numberOfConditions = currentSection.getKeys(false).size();
|
||||||
|
|
||||||
|
Boolean currentBlockResult = null; // This will store the result of the current block (a set of conditions combined by AND or OR).
|
||||||
|
String previousOperator = "AND"; // Default logical operator to start with.
|
||||||
|
|
||||||
|
for (int a = 0; a < numberOfConditions; a++) {
|
||||||
|
if (!currentSection.isSet("value" + a) || !currentSection.isSet("compare" + a)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean endProcess = true;
|
String value = ChatColor.stripColor(plugin.tex.placeholders(panel, position, p, currentSection.getString("value" + a)));
|
||||||
//loop through possible values and compares for hypothetical and operators
|
String compare = ChatColor.stripColor(plugin.tex.placeholders(panel, position, p, currentSection.getString("compare" + a)));
|
||||||
for (int a = 0; cf.getConfigurationSection(setName).getKeys(false).size() > a; a++) {
|
|
||||||
if(cf.isSet(setName + ".value" + a) && cf.isSet(setName + ".compare" + a)){
|
|
||||||
//ensure the endProcess variable has been reset for another operation
|
|
||||||
endProcess = true;
|
|
||||||
//get the values of this statement
|
|
||||||
String value;
|
|
||||||
String compare;
|
|
||||||
try {
|
|
||||||
value = ChatColor.stripColor(plugin.tex.placeholders(panel, position, p, cf.getString(setName + ".value" + a)));
|
|
||||||
compare = ChatColor.stripColor(plugin.tex.placeholders(panel, position, p, cf.getString(setName + ".compare" + a)));
|
|
||||||
}catch (Exception e) {
|
|
||||||
//if errors getting text return
|
|
||||||
plugin.debug(e,p);
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
String operator = "AND";
|
String operator = "AND"; // Default operator for the current condition.
|
||||||
if (compare.endsWith(" OR")) {
|
if (compare.endsWith(" OR")) {
|
||||||
compare = compare.substring(0, compare.length() - 3);
|
compare = compare.substring(0, compare.length() - 3);
|
||||||
operator = "OR";
|
operator = "OR";
|
||||||
@ -54,39 +45,40 @@ public class HasSections {
|
|||||||
compare = compare.substring(0, compare.length() - 4);
|
compare = compare.substring(0, compare.length() - 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
//list of values with the or operator
|
|
||||||
HashSet<String> values = doOperators(new HashSet<>(Collections.singletonList(value)));
|
HashSet<String> values = doOperators(new HashSet<>(Collections.singletonList(value)));
|
||||||
//go through all values with the or operator
|
boolean localResult = false; // This tracks the result of the current condition.
|
||||||
for (String val : values) {
|
for (String val : values) {
|
||||||
if (hasProcess(setName, val, compare, p)) {
|
if (hasProcess(setName, val, compare, p)) {
|
||||||
endProcess = false;
|
localResult = true;
|
||||||
//if it is true and it is OR, there is no need to check the next value in the line
|
|
||||||
if(operator.equals("OR")){
|
|
||||||
a++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(endProcess){
|
|
||||||
//check if the operator link between the next value/compare is OR
|
|
||||||
if(operator.equals("OR")){
|
|
||||||
//I can just continue because the algorithm already assumes the last sequence was true
|
|
||||||
endProcess = false;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (currentBlockResult == null) {
|
||||||
|
// Initialize the result of the block with the result of the first condition.
|
||||||
|
currentBlockResult = localResult;
|
||||||
|
} else {
|
||||||
|
// Combine the result of the current condition with the block result based on the previous operator.
|
||||||
|
if (previousOperator.equals("AND")) {
|
||||||
|
currentBlockResult = currentBlockResult && localResult;
|
||||||
|
} else if (previousOperator.equals("OR")) {
|
||||||
|
currentBlockResult = currentBlockResult || localResult;
|
||||||
}
|
}
|
||||||
//if the has section is false move to the next has section
|
|
||||||
if(endProcess){
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
//proceed if none of the values were false
|
|
||||||
return "." + setName + hasSection(panel, position, cf.getConfigurationSection(setName), p);
|
previousOperator = operator; // Update the operator for the next condition.
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentBlockResult != null && currentBlockResult) {
|
||||||
|
// If the result of this section is true, check nested sections.
|
||||||
|
return "." + setName + hasSection(panel, position, currentSection, p);
|
||||||
|
}
|
||||||
|
// If the result is false, continue to the next 'has' section.
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private HashSet<String> doOperators(HashSet<String> value){
|
private HashSet<String> doOperators(HashSet<String> value){
|
||||||
for(String val : value){
|
for(String val : value){
|
||||||
if(val.contains(" OR ")){
|
if(val.contains(" OR ")){
|
||||||
|
@ -315,8 +315,7 @@ public class ItemCreation {
|
|||||||
ItemMeta unbreak = s.getItemMeta();
|
ItemMeta unbreak = s.getItemMeta();
|
||||||
unbreak.setUnbreakable(true);
|
unbreak.setUnbreakable(true);
|
||||||
s.setItemMeta(unbreak);
|
s.setItemMeta(unbreak);
|
||||||
}
|
}else {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Damageable itemDamage = (Damageable) s.getItemMeta();
|
Damageable itemDamage = (Damageable) s.getItemMeta();
|
||||||
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.placeholders(panel, position, p, itemSection.getString("damage")))));
|
itemDamage.setDamage(Integer.parseInt(Objects.requireNonNull(plugin.tex.placeholders(panel, position, p, itemSection.getString("damage")))));
|
||||||
@ -327,6 +326,7 @@ public class ItemCreation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// 1.20 Trim Feature for Player Armor
|
// 1.20 Trim Feature for Player Armor
|
||||||
if(plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20) && itemSection.contains("trim")){
|
if(plugin.legacy.MAJOR_VERSION.greaterThanOrEqualTo(MinecraftVersions.v1_20) && itemSection.contains("trim")){
|
||||||
// trim: <Material> <Pattern>
|
// trim: <Material> <Pattern>
|
||||||
|
Loading…
Reference in New Issue
Block a user