Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Attribute:
- attribute: str
- attribute_name: str
- amount: int
- operation: str
- def __init__(self, attribute, attribute_name, amount, operation):
- self.attribute = attribute
- self.attribute_name = attribute_name
- self.amount = amount
- self.operation = operation
- def toString(self, meta_obj_name, equipmentSlot):
- return f" {meta_obj_name}.addAttributeModifier(Attribute.{self.attribute}, new org.bukkit.attribute.AttributeModifier(UUID.randomUUID(), \"{self.attribute_name}\", {str(self.amount)}, Operation.{self.operation}, EquipmentSlot.{equipmentSlot}));"
- class Enchant:
- level: int
- name: str
- def __init__(self, name, level):
- self.name = name
- self.level = level
- def getName(self):
- return self.name
- def getLevel(self):
- return self.level
- def toString(self, meta_obj_name):
- return f" {meta_obj_name}.addEnchant(Enchantment.{self.name}, {str(self.level)}, true);"
- def save_ability(content):
- file = open(ability_path, 'w+')
- file.write(content)
- file.close()
- print('Ability successfully created')
- def fix(armor_name):
- newarmorname = armor_name.lower().title().replace(" ", "")
- return newarmorname[:1].lower() + newarmorname[1:]
- def exitP():
- input('Done! Press enter to exit.\n')
- exit(0)
- def effect(armor_id, armor_name):
- print('Running: Effects')
- print('''---- POTION EFFECTS ----
- SPEED, SLOW, FAST_DIGGING, SLOW_DIGGING, INCREASE_DAMAGE, HEAL,
- HARM, JUMP, CONFUSION, REGENERATION, DAMAGE_RESISTANCE, FIRE_RESISTANCE,
- WATER_BREATHING, INVISIBILITY, BLINDNESS, NIGHT_VISION, HUNGER,
- WEAKNESS, POISON, WITHER, HEALTH_BOOST, ABSORPTION, SATURATION,
- GLOWING, LEVITATION, LUCK, UNLUCK, SLOW_FALLING, CONDUIT_POWER,
- DOLPHINS_GRACE, BAD_OMEN, HERO_OF_THE_VILLAGE
- ---- POTION EFFECTS ----
- ''')
- potion_effect = input('Potion Effect: ').upper()
- amplifier = int(input('Potion Amplifier (starts with 0, 0 = Level 1): '))
- ability = ''' @ArmorEquip
- @EventHandler
- public void <ana>Armor(ArmorEquipEvent e) {
- try {
- for(String dis : plugin.disabledArmors)
- if(dis.equalsIgnoreCase("{armor_id}"))
- return;
- }catch(Exception ignored) {}
- try {
- Player p = e.getPlayer();
- if(ifWearing(getNew(p, e.getNewArmorPiece()), "{armor_id}")) {
- armorInfo.remove(p.getUniqueId());
- armorInfo.put(p.getUniqueId(), "{armor_id}");
- p.addPotionEffect(new PotionEffect(PotionEffectType.{effect}, Integer.MAX_VALUE, {amplifier}));
- }else if(get(p).equalsIgnoreCase("{armor_id}")) {
- armorInfo.remove(p.getUniqueId());
- p.removePotionEffect(PotionEffectType.{effect});
- }
- }catch(Exception ignored) {}
- }
- '''.replace('<ana>', fix(armor_name)).replace('{effect}', potion_effect).replace('{armor_id}', armor_id).replace(
- '{amplifier}', str(amplifier))
- save_ability(ability)
- exitP()
- def everyXTicks(armor_id, armor_name):
- print('Running: Every X ticks')
- ability = ''' public void {fix(armor_name)}Armor(Player p) {
- try {
- for(String dis : disabledArmors)
- if(dis.equalsIgnoreCase("{armor_id}")) return;
- }catch(Exception ignored) {}
- try {
- if(!ifWearing(p, "{armor_id}")) return;
- // TODO
- }catch(Exception ignored) {}
- }'''.replace("{armor_id}", armor_id).replace("{fix(armor_name)}", fix(armor_name))
- save_ability(ability)
- exitP()
- def armorChange(armor_id, armor_name, item_code):
- print('Running: ArmorChange (enchants/attributes)')
- enchants = []
- attributes = []
- if input("Put enchants (Y/N)? ").lower() == 'y':
- print('''--- ENCHANTS ---
- PROTECTION_ENVIRONMENTAL, PROTECTION_FIRE, PROTECTION_FALL, PROTECTION_EXPLOSIONS,
- PROTECTION_PROJECTILE, OXYGEN, WATER_WORKER, THORNS, DEPTH_STRIDER, BINDING_CURSE,
- DAMAGE_ALL, DAMAGE_UNDEAD, DAMAGE_ARTHROPODS, KNOCKBACK, FIRE_ASPECT, LOOT_BONUS_MOBS,
- SWEEPING_EDGE, DIG_SPEED, SILK_TOUCH, DURABILITY, LOOT_BONUS_BLOCKS, ARROW_DAMAGE,
- ARROW_FIRE, ARROW_INFINITE, LUCK, LURE, LOYALTY, IMPALING, RIPTIDE, CHANNELING,
- MULTISHOT, QUICK_CHARGE, PIERCING, MENDING, VANISHING_CURSE, SOUL_SPEED
- --- ENCHANTS ---''')
- while True:
- name = input('Enchant name: ').upper()
- level = int(input('Enchant level: '))
- enchants.append(Enchant(name, level))
- s = input('Input \'s\' to stop. ').lower()
- if s == 's':
- break
- if input('Put attributes (Y/N)? ').lower() == 'y':
- print('''--- ATTRIBUTES ---
- On 1.15 and below, _ are not in attributes. the letter after the supposed _ is capitalized follow_range -> followRange
- GENERIC_MAX_HEALTH("generic.max_health")
- GENERIC_FOLLOW_RANGE("generic.follow_range")
- GENERIC_KNOCKBACK_RESISTANCE("generic.knockback_resistance")
- GENERIC_MOVEMENT_SPEED("generic.movement_speed")
- GENERIC_FLYING_SPEED("generic.flying_speed")
- GENERIC_ATTACK_DAMAGE("generic.attack_damage")
- GENERIC_ATTACK_KNOCKBACK("generic.attack_knockback")
- GENERIC_ATTACK_SPEED("generic.attack_speed")
- GENERIC_ARMOR("generic.armor")
- GENERIC_ARMOR_TOUGHNESS("generic.armor_toughness")
- GENERIC_LUCK("generic.luck")
- HORSE_JUMP_STRENGTH("horse.jump_strength")
- ZOMBIE_SPAWN_REINFORCEMENTS("zombie.spawn_reinforcements")
- --- ATTRIBUTES ---''')
- while True:
- attribute = input('Attribute (GENERIC_ARMOR): ').upper()
- attribute_name = input('Attribute string name (generic.armor): ')
- operation = input('Operation (ADD_NUMBER): ').upper()
- amount = int(input('Amount: '))
- # attribute, attributename, operation, amount
- attributes.append(Attribute(attribute, attribute_name, amount, operation))
- s = input('Input \'s\' to stop. ').lower()
- if s == 's':
- break
- enchants_str = ""
- attribute_str = ""
- first = None
- for en in enchants:
- if first is None:
- first = "Enchantment." + en.name.upper()
- enchants_str = enchants_str + en.toString("m1") + "\n"
- enchants_str = enchants_str + en.toString("m2") + "\n"
- enchants_str = enchants_str + en.toString("m3") + "\n"
- enchants_str = enchants_str + en.toString("m4") + "\n"
- for attr in attributes:
- if first is None:
- first = "Attribute." + attr.attribute.upper()
- attribute_str = attribute_str + attr.toString("m1", "HEAD") + "\n"
- attribute_str = attribute_str + attr.toString("m2", "CHEST") + "\n"
- attribute_str = attribute_str + attr.toString("m3", "LEGS") + "\n"
- attribute_str = attribute_str + attr.toString("m4", "FEET") + "\n"
- new_item_code = item_code.replace("{MetaAdd}", f'''
- {enchants_str}{attribute_str}''')
- item_code = item_code.replace("{MetaAdd}", "")
- ability = ''' public void {fix(armor_name)}Armor(Player p) {
- try {
- for(String dis : plugin.disabledArmors)
- if(dis.equalsIgnoreCase("{armor_id}")) return;
- if(ifWearing(p, "{armor_id}")) {
- {new_item_code}
- changeArmorInArmorSlot(p, array[0], array[1], array[2], array[3]);
- }else {
- {item_code}
- replaceArmorInInventory(p, "{armor_id}", array, true, {first});
- }
- }catch(Exception ignored) {}
- }'''.replace("{armor_id}", armor_id).replace("{fix(armor_name)}", fix(armor_name)).replace("{new_item_code}",
- new_item_code).replace(
- "{item_code}", item_code).replace("{first}", first)
- save_ability(ability)
- exitP()
- def sneakEvent(armor_id, armor_name):
- print('Running: SneakEvent (PlayerToggleSneakEvent)')
- ability = ''' @EventHandler
- public void {fix(armor_name)}Armor(PlayerToggleSneakEvent e) {
- try {
- for(String dis : disabledArmors)
- if(dis.equalsIgnoreCase("{armor_id}")) return;
- }catch(Exception ignored) {}
- try {
- if(e.isSneaking() && ifWearing(p, "{armor_id}")) {
- // TODO
- }
- }catch(Exception ignored) {}
- }'''.replace("{fix(armor_name)}", fix(armor_name)).replace("{armor_id}", armor_id)
- save_ability(ability)
- exitP()
- def customEvent(armor_id, armor_name):
- print('Running: CustomEvent (BlockBreakEvent)')
- event = input('Event Class Name: ')
- code = input('Code to check if player is wearing (enter BLANK if not possible): ')
- ability = ''' @EventHandler
- public void {fix(armor_name)}Armor({event} e) {
- try {
- for(String dis : plugin.disabledArmors)
- if(dis.equalsIgnoreCase("{armor_id}")) return;
- }catch(Exception ignored) {}
- try {
- <code_check>
- // TODO
- }catch(Exception ignored) {}
- }'''.replace("{armor_id}", armor_id).replace("{fix(armor_name)}", fix(armor_name)).replace("<code_check>",
- code).replace(
- "{event}", event)
- save_ability(ability)
- exitP()
- def main():
- armor_id = input('Armor ID: ').upper()
- armor_name = input('Armor Name (without Helmet...): ')
- armor_lore1 = input('Armor Lore #1 (''no'' to cancel) (ChatColor with ''&''): ')
- armor_lore2 = input('Armor Lore #2 (''no'' to cancel) (ChatColor with ''&''): ')
- slot = int(input('Slot (needed for recipe): '))
- recipe_mat = input('Recipe material (stone): ').upper()
- armor_mat = input('Armor material (netherite): ').upper()
- armor_lore = ""
- if not armor_lore1.lower() == 'no':
- armor_lore = armor_lore1
- if not armor_lore2.lower() == 'no':
- if not armor_lore1.lower() == 'no':
- armor_lore = armor_lore + '\\n'
- armor_lore = armor_lore + armor_lore2
- lang = open(language_path, 'w+')
- lang.write(f'''names: {armor_id}: "{armor_name}"
- lores: {armor_id}: "{armor_lore}"''')
- lang.close()
- print('Versions:')
- print('1 > Effects (strength,etc)')
- print('2 > Every X Ticks (give food level every tick)')
- print('3 > ArmorChange (change when full armor, enchants/attributes')
- print('4 > Sneaking event')
- print('5 > Custom event')
- i = input('Select: ')
- io = int(i)
- print('Making recipe')
- #
- recipe = '''public void {fix(armor_name)}Armor() {
- ItemStack[] array = getArmor(null, {slot});
- ShapedRecipe r1 = new ShapedRecipe(new NamespacedKey(plugin, "{fix(armor_name)}_helmet"), array[0]);
- ShapedRecipe r2 = new ShapedRecipe(new NamespacedKey(plugin, "{fix(armor_name)}_chestplate"), array[1]);
- ShapedRecipe r3 = new ShapedRecipe(new NamespacedKey(plugin, "{fix(armor_name)}_leggings"), array[2]);
- ShapedRecipe r4 = new ShapedRecipe(new NamespacedKey(plugin, "{fix(armor_name)}_boots"), array[3]);
- r1.shape("***", "* *");
- r2.shape("* *", "***", "***");
- r3.shape("***", "* *", "* *");
- r4.shape("* *", "* *");
- r1.setIngredient('*', Material.<recipe_mat>);
- r2.setIngredient('*', Material.<recipe_mat>);
- r3.setIngredient('*', Material.<recipe_mat>);
- r4.setIngredient('*', Material.<recipe_mat>);
- server.addRecipe(r1);
- server.addRecipe(r2);
- server.addRecipe(r3);
- server.addRecipe(r4);
- if(!activeRecipes.contains(r1)) activeRecipes.add(r1);
- if(!activeRecipes.contains(r2)) activeRecipes.add(r2);
- if(!activeRecipes.contains(r3)) activeRecipes.add(r3);
- if(!activeRecipes.contains(r4)) activeRecipes.add(r4);
- }'''.replace("{fix(armor_name)}", fix(armor_name)).replace("<recipe_mat>", recipe_mat).replace("{slot}", str(slot))
- rf = open(recipe_path, 'w+')
- rf.write(recipe)
- rf.close()
- print('Recipe successfully loaded')
- print('Making item')
- # inventoryevents item
- ue = input('Use ''if'' (0) or ''else if'' (1)? ')
- ues = "else if"
- if ue == '0':
- ues = "if"
- item = '''{ues}(slot == {slot}) {
- ItemStack armor1 = new ItemStack(Material.{armor_mat}_HELMET);
- ItemStack armor2 = new ItemStack(Material.{armor_mat}_CHESTPLATE);
- ItemStack armor3 = new ItemStack(Material.{armor_mat}_LEGGINGS);
- ItemStack armor4 = new ItemStack(Material.{armor_mat}_BOOTS);
- {PutMetaHere}
- String id = Method.getArmorIds().get(slot);
- String separator = plugin.lang.getSeparator();
- m1.setDisplayName(plugin.lang.getName(id) + separator + plugin.lang.getHelmet());
- m2.setDisplayName(plugin.lang.getName(id) + separator + plugin.lang.getChestplate());
- m3.setDisplayName(plugin.lang.getName(id) + separator + plugin.lang.getLeggings());
- m4.setDisplayName(plugin.lang.getName(id) + separator + plugin.lang.getBoots());
- List<String> lore = new ArrayList<>();
- lore.add(plugin.lang.getLore(id));
- lore.add(plugin.lang.getAllPieces());
- m1.setLore(lore);
- m2.setLore(lore);
- m3.setLore(lore);
- m4.setLore(lore);
- NamespacedKey key = new NamespacedKey(plugin, plugin.tag);
- {v3}
- m1.getPersistentDataContainer().set(tag, PersistentDataType.STRING, "{armor_id}");
- m2.getPersistentDataContainer().set(tag, PersistentDataType.STRING, "{armor_id}");
- m3.getPersistentDataContainer().set(tag, PersistentDataType.STRING, "{armor_id}");
- m4.getPersistentDataContainer().set(tag, PersistentDataType.STRING, "{armor_id}");
- {ChangeArmorAttribute}
- if(plugin.getConfig().getBoolean("glowing-armor")) m1.addEnchant(Method.GLOWING, 0, true);
- if(plugin.getConfig().getBoolean("glowing-armor")) m2.addEnchant(Method.GLOWING, 0, true);
- if(plugin.getConfig().getBoolean("glowing-armor")) m3.addEnchant(Method.GLOWING, 0, true);
- if(plugin.getConfig().getBoolean("glowing-armor")) m4.addEnchant(Method.GLOWING, 0, true);
- armor1.setItemMeta(m1);
- armor2.setItemMeta(m2);
- armor3.setItemMeta(m3);
- armor4.setItemMeta(m4);
- if(p != null) p.getInventory().addItem(armor1);
- if(p != null) p.getInventory().addItem(armor2);
- if(p != null) p.getInventory().addItem(armor3);
- if(p != null) p.getInventory().addItem(armor4);
- return new ItemStack[] {armor1,armor2,armor3,armor4};
- }
- '''.replace("{armor_id}", armor_id).replace("{armor_mat}", armor_mat).replace("{slot}", str(slot)).replace("{ues}", ues)
- item_code = '''ItemStack[] array = plugin.invevents.getArmor(null, {slot});{MetaAdd}'''.replace("{slot}", str(slot))
- if io == 3:
- item = item.replace("{v3}",
- f'''m1.getPersistentDataContainer().set(new NamespacedKey(plugin, "{fix(armor_name)}Helm"), PersistentDataType.BYTE, (byte) 1);
- m2.getPersistentDataContainer().set(new NamespacedKey(plugin, "{fix(armor_name)}Chest"), PersistentDataType.BYTE, (byte) 1");
- m3.getPersistentDataContainer().set(new NamespacedKey(plugin, "{fix(armor_name)}Legs"), PersistentDataType.BYTE, (byte) 1);
- m4.getPersistentDataContainer().set(new NamespacedKey(plugin, "{fix(armor_name)}Feet"), PersistentDataType.BYTE, (byte) 1);''')
- else:
- item = item.replace("{v3}", "")
- if armor_mat == 'LEATHER':
- colored = input('Leather Color Armor (Y/N)? ').lower()
- if colored == 'y':
- r = input('(Leather-Color) Red (1-255): ')
- g = input('(Leather-Color) Green (1-255): ')
- b = input('(Leather-Color) Blue (1-255): ')
- item = item.replace("{PutMetaHere}", f'''LeatherArmorMeta m1 = (LeatherArmorMeta) armor1.getItemMeta();
- LeatherArmorMeta m2 = (LeatherArmorMeta) armor2.getItemMeta();
- LeatherArmorMeta m3 = (LeatherArmorMeta) armor3.getItemMeta();
- LeatherArmorMeta m4 = (LeatherArmorMeta) armor4.getItemMeta();
- m1.setColor(Color.fromRGB({r},{g},{b}));
- m2.setColor(Color.fromRGB({r},{g},{b}));
- m3.setColor(Color.fromRGB({r},{g},{b}));
- m4.setColor(Color.fromRGB({r},{g},{b}));''')
- else:
- item = item.replace("{PutMetaHere}", '''ItemMeta m1 = armor1.getItemMeta();
- ItemMeta m2 = armor2.getItemMeta();
- ItemMeta m3 = armor3.getItemMeta();
- ItemMeta m4 = armor4.getItemMeta();''')
- # Change armor attribute
- change = input('Change armor attribute (Y/N) ?').lower()
- if change == 'y':
- a1 = input('Helmet armor attribute: ')
- a2 = input('Chestplate armor attribute: ')
- a3 = input('Leggings armor attribute: ')
- a4 = input('Boots armor attribute: ')
- item = item.replace("{ChangeArmorAttribute}", f'''
- m1.removeAttributeModifier(Attribute.GENERIC_ARMOR);
- m2.removeAttributeModifier(Attribute.GENERIC_ARMOR);
- m3.removeAttributeModifier(Attribute.GENERIC_ARMOR);
- m4.removeAttributeModifier(Attribute.GENERIC_ARMOR);
- m1.addAttributeModifier(Attribute.GENERIC_ARMOR, new org.bukkit.attribute.AttributeModifier(UUID.randomUUID(), "generic.armor", {a1}, Operation.ADD_NUMBER, EquipmentSlot.HEAD));
- m2.addAttributeModifier(Attribute.GENERIC_ARMOR, new org.bukkit.attribute.AttributeModifier(UUID.randomUUID(), "generic.armor", {a2}, Operation.ADD_NUMBER, EquipmentSlot.CHEST));
- m3.addAttributeModifier(Attribute.GENERIC_ARMOR, new org.bukkit.attribute.AttributeModifier(UUID.randomUUID(), "generic.armor", {a3}, Operation.ADD_NUMBER, EquipmentSlot.LEGS));
- m4.addAttributeModifier(Attribute.GENERIC_ARMOR, new org.bukkit.attribute.AttributeModifier(UUID.randomUUID(), "generic.armor", {a4}, Operation.ADD_NUMBER, EquipmentSlot.FEET));
- ''')
- else:
- item = item.replace("{ChangeArmorAttribute}", "")
- item_code = item_code.replace("{ChangeArmorAttribute}", "")
- item_file = open(item_path, "w+")
- item_file.write(item)
- item_file.close()
- #
- try:
- if io == 1:
- effect(armor_id, armor_name)
- elif io == 2:
- everyXTicks(armor_id, armor_name)
- elif io == 3:
- armorChange(armor_id, armor_name, item_code)
- elif io == 4:
- sneakEvent(armor_id, armor_name)
- elif io == 5:
- customEvent(armor_id, armor_name)
- else:
- exit(-1)
- except ValueError:
- exit(-1)
- # File paths
- recipe_path = "recipe.txt"
- item_path = "item.txt"
- ability_path = "ability.txt"
- language_path = "language.txt"
- main()
Advertisement
Add Comment
Please, Sign In to add comment