From 4d58a6416fd572a815199cac680eaf316b3a5687 Mon Sep 17 00:00:00 2001 From: matahombres Date: Sun, 10 May 2020 20:54:44 +0200 Subject: [PATCH 1/6] Add HideFlags for item and unbreakable https://minecraft.gamepedia.com/Tutorials/Command_NBT_tags ## HideFlags Add hideflag because when you go put into nbt you need sum the numbers. Adding 1 will hide Enchantments Adding 2 will hide Attributes modifiers Adding 4 will hide Unbreakable Adding 8 will hide CanDestroy Adding 16 will hide CanPlaceOn Adding 32 will hide Others, such as potion effects & shield pattern info So you don't have to continually go to the wiki in case you don't know The unbreakable is not absolutely necessary, but i also added it --- .../java/com/codehusky/huskycrates/crate/virtual/Crate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java b/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java index 3047cf0..156eb8f 100644 --- a/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java +++ b/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java @@ -126,7 +126,7 @@ public Crate(ConfigurationNode node){ }else if(aKeyNode.isVirtual() && !this.free){ throw new ConfigParseError("Non-free crate has no accepted keys!",node.getPath()); } - + if(node.getNode("slots").isVirtual()){ if(!this.injection) { From a5f81ab9881b75658892769e6279b42df48bd34c Mon Sep 17 00:00:00 2001 From: matahombres Date: Sun, 10 May 2020 20:56:24 +0200 Subject: [PATCH 2/6] Add HideFlags and Unbreakable --- .../codehusky/huskycrates/crate/virtual/views/ViewConfig.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/codehusky/huskycrates/crate/virtual/views/ViewConfig.java b/src/main/java/com/codehusky/huskycrates/crate/virtual/views/ViewConfig.java index 50929a1..bf56117 100644 --- a/src/main/java/com/codehusky/huskycrates/crate/virtual/views/ViewConfig.java +++ b/src/main/java/com/codehusky/huskycrates/crate/virtual/views/ViewConfig.java @@ -10,7 +10,7 @@ public ViewConfig(ConfigurationNode node){ if(!node.getNode("borderItem").isVirtual()) this.borderItem = new Item(node.getNode("borderItem")); else - this.borderItem = new Item("&6HuskyCrates", ItemTypes.STAINED_GLASS_PANE,null,1,15,null,null,null); + this.borderItem = new Item("&6HuskyCrates", ItemTypes.STAINED_GLASS_PANE,null,1,15,null,null,null,null,null,null,null,null,null,null); } public Item getBorderItem() { From 00229f0eac2389ef6b3c1a925117c0311717a633 Mon Sep 17 00:00:00 2001 From: matahombres Date: Sun, 10 May 2020 21:04:18 +0200 Subject: [PATCH 3/6] Add HideFlags for item and unbreakable https://minecraft.gamepedia.com/Tutorials/Command_NBT_tags ## HideFlags Add hideflag because when you go put into nbt you need sum the numbers. Adding 1 will hide Enchantments Adding 2 will hide Attributes modifiers Adding 4 will hide Unbreakable Adding 8 will hide CanDestroy Adding 16 will hide CanPlaceOn Adding 32 will hide Others, such as potion effects & shield pattern info So you don't have to continually go to the wiki in case you don't know The unbreakable is not absolutely necessary, but i also added it --- .../huskycrates/crate/virtual/Item.java | 52 ++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/codehusky/huskycrates/crate/virtual/Item.java b/src/main/java/com/codehusky/huskycrates/crate/virtual/Item.java index 8c744be..e39331d 100644 --- a/src/main/java/com/codehusky/huskycrates/crate/virtual/Item.java +++ b/src/main/java/com/codehusky/huskycrates/crate/virtual/Item.java @@ -31,6 +31,14 @@ public class Item { private Integer count; private Integer damage; // or metadata or meta private Integer durability; // amount of durability left on tool, weapon, armor, etc. + private Boolean unbreakable; // never loss durability + private Boolean hideAttributes; //Hide attributes like damage (sword example) + private Boolean hideEnchantments; //Hide enchantments, this is for create effect enchant without showing the enchantment + private Boolean hideUnbreakable; //Hide unbreakable value + //Mainly put for rol/mmorpg servers + private Boolean hideCanDestroy; //For hand items. Example -> Pickaxe only can break stone. + private Boolean hideCanPlace; //For hand items. Example -> ladder only can place into iron_blocks + private Boolean hideMiscellaneous; //JD sponge is down. unknown private List enchantments; private Map nbt; @@ -52,11 +60,18 @@ public static Item fromItemStack(ItemStack stack){ stack.toContainer().getInt(DataQuery.of("UnsafeDamage")).orElse(null), stack.get(Keys.ITEM_DURABILITY).orElse(null), stack.get(Keys.ITEM_ENCHANTMENTS).orElse(null), + stack.get(Keys.UNBREAKABLE).orElse(null), + stack.get(Keys.HIDE_ATTRIBUTES).orElse(null), + stack.get(Keys.HIDE_CAN_DESTROY).orElse(null), + stack.get(Keys.HIDE_CAN_PLACE).orElse(null), + stack.get(Keys.HIDE_ENCHANTMENTS).orElse(null), + stack.get(Keys.HIDE_MISCELLANEOUS).orElse(null), + stack.get(Keys.HIDE_UNBREAKABLE).orElse(null), stack.toContainer().getMap(DataQuery.of("UnsafeData")).orElse(null) ); } //TODO: builder pattern - public Item(String name, ItemType itemType, List lore, Integer count, Integer damage, Integer durability, List enchantments, Map nbt){ + public Item(String name, ItemType itemType, List lore, Integer count, Integer damage, Integer durability, List enchantments, Boolean unbreakable,Boolean hideAttributes, Boolean hideCanDestroy, Boolean hideCanPlace, Boolean hideEnchantments, Boolean hideMiscellaneous, Boolean hideUnbreakable, Map nbt){ this.name = name; if(name != null && name.length() == 0) this.name = null; this.itemType = itemType; @@ -65,6 +80,13 @@ public Item(String name, ItemType itemType, List lore, Integer count, In this.damage = damage; this.durability = durability; this.enchantments = enchantments; + this.unbreakable = unbreakable; + this.hideAttributes= hideAttributes; + this.hideCanDestroy=hideCanDestroy; + this.hideCanPlace=hideCanPlace; + this.hideEnchantments=hideEnchantments; + this.hideMiscellaneous=hideMiscellaneous; + this.hideUnbreakable=hideUnbreakable; this.nbt = nbt; if(this.nbt instanceof ImmutableMap){ this.nbt = Maps.newHashMap(this.nbt); @@ -89,6 +111,13 @@ public Item(ConfigurationNode node){ this.count = node.getNode("count").getInt(1); this.damage = node.getNode("damage").getInt(node.getNode("meta").getInt(node.getNode("metadata").getInt())); this.durability = node.getNode("durability").getInt(); + this.unbreakable=node.getNode("unbreakable").getBoolean(); + this.hideAttributes=node.getNode("hide_attributes").getBoolean(); + this.hideCanDestroy=node.getNode("hide_can_destroy").getBoolean(); + this.hideCanPlace=node.getNode("hide_can_place").getBoolean(); + this.hideEnchantments=node.getNode("hide_enchantments").getBoolean(); + this.hideMiscellaneous=node.getNode("hide_miscellaneous").getBoolean(); + this.hideUnbreakable=node.getNode("hide_unbreakable").getBoolean(); if(!node.getNode("lore").isVirtual()){ try { @@ -140,6 +169,27 @@ public ItemStack toItemStack(){ } if(this.enchantments != null){ stack.offer(Keys.ITEM_ENCHANTMENTS,enchantments); + if(this.hideEnchantments != null){ + stack.offer(Keys.HIDE_ENCHANTMENTS,hideEnchantments); + } + } + if(this.unbreakable != null){ + stack.offer(Keys.UNBREAKABLE,false); + if(this.hideUnbreakable != null){ + stack.offer(Keys.HIDE_UNBREAKABLE,hideUnbreakable); + } + } + if(this.hideAttributes != null){ + stack.offer(Keys.HIDE_ATTRIBUTES,hideUnbreakable); + } + if(this.hideMiscellaneous != null){ + stack.offer(Keys.HIDE_MISCELLANEOUS,hideMiscellaneous); + } + if(this.hideCanDestroy != null){ + stack.offer(Keys.HIDE_CAN_DESTROY,hideCanDestroy); + } + if(this.hideCanPlace != null){ + stack.offer(Keys.HIDE_CAN_PLACE,hideCanPlace); } if(this.nbt != null){ DataContainer container = stack.toContainer(); From 58dc73c5df77e3494f8c535c136ba133367fdeee Mon Sep 17 00:00:00 2001 From: matahombres Date: Sun, 10 May 2020 21:07:09 +0200 Subject: [PATCH 4/6] Add HideFlags and unbreakable --- .../java/com/codehusky/huskycrates/crate/virtual/Crate.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java b/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java index 156eb8f..b600e19 100644 --- a/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java +++ b/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java @@ -121,7 +121,7 @@ public Crate(ConfigurationNode node){ if(!node.getNode("localKey").isVirtual()){ this.localKey = new Key("LOCALKEY_" + this.id, new Item(node.getNode("localKey")),localKeyLaunchesCrate); }else{ - this.localKey = new Key("LOCALKEY_" + this.id, new Item("&8" + this.name + " Key", ItemTypes.NETHER_STAR, null, 1, null, null, null, null),localKeyLaunchesCrate); + this.localKey = new Key("LOCALKEY_" + this.id, new Item("&8" + this.name + " Key", ItemTypes.NETHER_STAR, null, 1, null, null, null, null, null, null, null, null, null, null, null),localKeyLaunchesCrate); } }else if(aKeyNode.isVirtual() && !this.free){ throw new ConfigParseError("Non-free crate has no accepted keys!",node.getPath()); From 595deda0d2e6a7d8c4a4e8ea659630274165251b Mon Sep 17 00:00:00 2001 From: matahombres Date: Sun, 10 May 2020 21:09:36 +0200 Subject: [PATCH 5/6] Add hideflags and unbreakable --- .../codehusky/huskycrates/crate/virtual/views/SpinnerView.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/codehusky/huskycrates/crate/virtual/views/SpinnerView.java b/src/main/java/com/codehusky/huskycrates/crate/virtual/views/SpinnerView.java index 078f62e..6b03faa 100644 --- a/src/main/java/com/codehusky/huskycrates/crate/virtual/views/SpinnerView.java +++ b/src/main/java/com/codehusky/huskycrates/crate/virtual/views/SpinnerView.java @@ -182,7 +182,7 @@ public Config(ConfigurationNode node){ if(!node.getNode("selectorItem").isVirtual()) { this.selectorItem = new Item(node.getNode("selectorItem")); }else{ - this.selectorItem = new Item("&6HuskyCrates", ItemTypes.REDSTONE_TORCH,null,1,null,null,null,null); + this.selectorItem = new Item("&6HuskyCrates", ItemTypes.REDSTONE_TORCH,null,1,null,null,null,null,null,null,null,null,null,null,null); } System.out.println(node.getNode("ticksToSelection").getValue()); this.ticksToSelection = node.getNode("ticksToSelection").getInt(30); From 26a2427c4a8b936418bddfb1e26bc5540b52b27e Mon Sep 17 00:00:00 2001 From: matahombres Date: Sun, 10 May 2020 22:15:57 +0200 Subject: [PATCH 6/6] Add preview text rewardcount/occurrence Add: - previewTextRewardCount -> Text RewardCount - previewTextOccurrence -> Text Occurrence --- .../codehusky/huskycrates/crate/virtual/Crate.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java b/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java index b600e19..ff6f5e9 100644 --- a/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java +++ b/src/main/java/com/codehusky/huskycrates/crate/virtual/Crate.java @@ -37,6 +37,8 @@ public class Crate { private String id; private String name; + private String previewTextOccurrence; + private String previewTextRewardCount; private Hologram hologram; @@ -197,9 +199,11 @@ public Crate(ConfigurationNode node){ } this.previewable = node.getNode("previewable").getBoolean(false); + this.previewTextOccurrence=node.getNode("previewTextOccurrence").getString("Occurrence: "); + this.previewTextRewardCount=node.getNode("previewTextRewardCount").getString("Rewards: "); this.previewShowsRewardCount = node.getNode("previewShowsRewardCount").getBoolean(true); } - public Crate(String id, String name, Hologram hologram, Effect idleEffect, Effect rejectEffect, Effect winEffect, Effect openEffect, List slots, boolean scrambleSlots, boolean free, boolean previewable, boolean previewRewardCount, long cooldownSeconds, boolean useLocalKey, Key localKey, HashMap acceptedKeys, ViewType viewType, ViewConfig viewConfig){ + public Crate(String id, String name, Hologram hologram, Effect idleEffect, Effect rejectEffect, Effect winEffect, Effect openEffect, List slots, boolean scrambleSlots, boolean free, boolean previewable, boolean previewRewardCount, long cooldownSeconds, boolean useLocalKey, Key localKey, HashMap acceptedKeys, ViewType viewType, ViewConfig viewConfig,String previewTextOccurrence,String previewTextRewardCount){ this.id = id; this.name = name; this.hologram = hologram; @@ -225,12 +229,14 @@ public Crate(String id, String name, Hologram hologram, Effect idleEffect, Effec this.acceptedKeys = acceptedKeys; this.viewType = viewType; this.viewConfig = viewConfig; + this.previewTextOccurrence=previewTextOccurrence; + this.previewTextRewardCount=previewTextRewardCount; } public Crate getScrambledCrate() { ArrayList newSlots = new ArrayList<>(slots); Collections.shuffle(newSlots); - return new Crate(id,name,hologram,idleEffect,rejectEffect,winEffect,openEffect,newSlots,scrambleSlots,free,previewable,previewShowsRewardCount,cooldownSeconds,useLocalKey,localKey,acceptedKeys,viewType,viewConfig); + return new Crate(id,name,hologram,idleEffect,rejectEffect,winEffect,openEffect,newSlots,scrambleSlots,free,previewable,previewShowsRewardCount,cooldownSeconds,useLocalKey,localKey,acceptedKeys,viewType,viewConfig,previewTextOccurrence,previewTextRewardCount); } public boolean isScrambled() { return this.scrambleSlots; @@ -482,9 +488,9 @@ public void launchPreview(Player player){ double val = ((double)slots.get(j).getChance()/(double)slotChanceMax)*100; BigDecimal occurance = new BigDecimal(val).setScale(2,BigDecimal.ROUND_HALF_UP); if (previewShowsRewardCount) { - oldLore.add(Text.of(TextStyles.NONE,TextColors.GRAY,"Rewards: " + slots.get(j).getRewards().size())); + oldLore.add(TextSerializers.FORMATTING_CODE.deserialize("&r&7"+previewTextRewardCount+ slots.get(j).getRewards().size())); } - oldLore.add(Text.of(TextStyles.NONE,TextColors.GRAY,"Occurrence: " + ((val < 0.01)?"< 0.01":occurance.toString()) + "%")); + oldLore.add(TextSerializers.FORMATTING_CODE.deserialize("&r&7"+previewTextOccurrence+ ((val < 0.01)?"< 0.01":occurance.toString()) + "%")); builder.addElement(new Element(ItemStack.builder().from(orig).add(Keys.ITEM_LORE,oldLore).build())); } Page built = builder.build("preview");