Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- options:
- ENCHANT_NAME: "Efficiency", "Fortune", "Laser", "Speed", "Haste", "Wisdom", "Night Vision", and "Jump"
- function reloadConfig():
- unload yaml "config"
- load yml "plugins/Skript/scripts/special tools/config.yml"
- set {_exists} to skript-yml value "Rarities" from "config"
- if {_exists} isn't set:
- set file contents of "plugins/Skript/scripts/special tools/config.yml" to file contents of "plugins/Skript/scripts/special tools/DO NOT EDIT.txt"
- unload yaml "config"
- load yml "plugins/Skript/scripts/special tools/config.yml"
- function loadConfig() :: objects:
- return all yml nodes of "config"
- function loadRarities() :: objects:
- set {_data} to yaml value "Rarities" from "config"
- set {_names::*} to split "%{_data}%" at "{"
- loop {_names::*}:
- set {_names2::*} to split loop-value at "}, "
- loop {_names2::*}:
- set {_name} to subtext of loop-value-2 from characters 1 to (length of (loop-value-2) - 1)
- if yaml value "Rarities.%{_name}%" from "config" is set:
- add {_name} to {_ret::*}
- return {_ret::*}
- on load:
- reloadConfig()
- function pickRarity() :: text:
- set {_rarities::*} to loadRarities()
- set {_total} to 0
- loop {_rarities::*}:
- set {_val} to yaml value "Rarities.%loop-value%.chance" from "config"
- set {_total} to {_total} + {_val}
- set {_random} to random number between 0 and {_total}
- loop {_rarities::*}:
- set {_val} to yaml value "Rarities.%loop-value%.chance" from "config"
- subtract {_val} from {_random}
- if {_random} <= 0:
- return loop-value
- function isSpecialTool(item: item) :: boolean:
- set {_tag} to tag "specialTool_Level" of nbt of {_item}
- if {_tag} is set:
- return true
- return false
- function getEnchantId(name: text) :: integer:
- # Fortune: Vanilla enchant
- if {_name} is "fortune":
- return 35
- # Efficiency: Vanilla enchant
- if {_name} is "efficiency":
- return 32
- # Laser: Shoots eggs out of tool when right clicked. Breaks blocks.
- if {_name} is "laser":
- return 80
- # Explosive: Creates an explosion when a block is mined.
- #if {_name} is "explosive":
- # return 81
- # Haste: Gives haste when tool is held.
- if {_name} is "haste":
- return 82
- # Speed: Gives speed when tool is held.
- if {_name} is "speed":
- return 83
- # Jump: Gives jump boost when tool is held.
- if {_name} is "jump":
- return 84
- if {_name} is "wisdom":
- return 85
- if {_name} is "night vision":
- return 86
- return 0
- function addEnchant(item: item, name: text, level: text = "+1") :: item:
- set {_id} to getEnchantId({_name})
- set {_nbt} to nbt of {_item}
- set {_ench} to tag "specialTool_Ench" of {_nbt}
- set {_found} to 0
- set {_add} to 0
- set {_lvl} to {_level} parsed as number
- if {_level} starts with "+":
- set {_add} to 1
- set {_lvl} to (subtext of {_level} from characters 2 to (length of {_level})) parsed as number
- set {_loop::*} to contents of {_ench}
- loop {_loop::*}:
- set {_cont} to {_ench} index (loop-index parsed as number)
- set {_curID} to tag "id" of loop-value
- if {_curID} = {_id}:
- set {_level} to tag "lvl" of loop-value
- if {_add} is 1:
- add {_lvl} to {_level}
- else:
- set {_level} to {_lvl}
- set tag "lvl" of loop-value to {_level}
- set {_found} to 1
- if {_found} is 0:
- set {_id} to join "%{_id}%" and "s"
- set {_lvl} to join "%{_lvl}%" and "s"
- set {_text} to subtext of "%{_ench}%" from characters 1 to (length of "%{_ench}%" - 1)
- if {_text} is "<none":
- set {_text} to "["
- else:
- set {_text} to "%{_text}%,"
- set {_ench} to "%{_text}%{lvl:%{_lvl}%,id:%{_id}%}]"
- delete tag "specialTool_Ench" of {_nbt}
- set {_nbt} to subtext of "%{_nbt}%" from characters 1 to (length of "%{_nbt}%" - 1)
- set {_item} to {_item} with custom nbt "%{_nbt}%,specialTool_Ench:%{_ench}%}"
- return {_item}
- function getEnchantLevel(item: item, name: text) :: number:
- set {_id} to getEnchantId({_name})
- set {_nbt} to nbt of {_item}
- set {_ench} to tag "specialTool_Ench" of {_nbt}
- set {_found} to 0
- set {_loop::*} to contents of {_ench}
- loop {_loop::*}:
- set {_cont} to {_ench} index (loop-index parsed as number)
- set {_curID} to tag "id" of loop-value
- if {_curID} = {_id}:
- set {_level} to tag "lvl" of loop-value
- return {_level}
- return 0
- function generateSpecialTool(it: item type) :: item:
- set {_rarity} to pickRarity()
- set {_xpMult} to yaml value "Rarities.%{_rarity}%.xpMult" from "config"
- if "%{_it}%" contains "pickaxe":
- set {_names} to yaml value "Rarities.%{_rarity}%.pickaxeNames" from "config"
- else if "%{_it}%" contains "axe":
- set {_names} to yaml value "Rarities.%{_rarity}%.axeNames" from "config"
- else:
- set {_names} to yaml value "Rarities.%{_rarity}%.shovelNames" from "config"
- set {_names} to "%{_names}%"
- set {_names::*} to split {_names} at ", "
- set {_names::1} to subtext of {_names::1} from characters 2 to (length of {_names::1})
- set {_len} to size of {_names::*}
- set {_names::%{_len}%} to subtext of {_names::%{_len}%} from characters 1 to (length of {_names::%{_len}%} - 1)
- set {_name} to random element out of {_names::*}
- set {_item} to 1 of {_it} with custom nbt "{specialTool_Rarity:""%{_rarity}%"",specialTool_Level:1,specialTool_XPToNext:%{_xpMult}%,specialTool_LevelXP:%{_xpMult}%,specialTool_Name:""%colored {_name}%"",HideFlags:5,Unbreakable:1}"
- set {_item} to doLore({_item})
- set name of {_item} to "%colored {_name}% &7[&e0&7/&e%{_xpMult}% &7XP]"
- return {_item}
- function getEnchantColor(enchant: text) :: text:
- set {_name} to {_enchant}
- replace all " " in {_name} with " "
- set {_name} to {_name} converted to lowercase
- set {_val} to yaml value "EnchantNames.%{_name}%" from "config"
- return colored "%{_val}%"
- function getXPBar(item: item, length: number) :: text:
- set {_level} to tag "specialTool_Level" of nbt of {_item}
- set {_toNext} to tag "specialTool_XPToNext" of nbt of {_item}
- set {_currentLevelXP} to tag "specialTool_LevelXP" of nbt of {_item}
- set {_toNext} to {_currentLevelXP} - {_toNext}
- set {_tempToNext} to {_toNext}
- set {_bar} to "[&a"
- set {_switch} to true
- loop {_length} times:
- subtract {_currentLevelXP} / {_length} from {_tempToNext}
- if {_tempToNext} < 0:
- if {_switch} is true:
- set {_switch} to false
- set {_bar} to "%{_bar}%&c"
- set {_bar} to "%{_bar}%|"
- set {_bar} to "%{_bar}%&7]"
- return "&7Level &a%{_level}% &8||&7 %{_bar}% &e%{_toNext}%&7/&e%{_currentLevelXP}%&7 XP"
- function doLore(item: item) :: item:
- set {_rarity} to tag "specialTool_Rarity" of nbt of {_item}
- set {_rarityName} to yaml value "Rarities.%{_rarity}%.name" from "config"
- set {_toNext} to tag "specialTool_XPToNext" of nbt of {_item}
- set {_currentLevelXP} to tag "specialTool_LevelXP" of nbt of {_item}
- set {_toNext} to {_currentLevelXP} - {_toNext}
- set {_name} to tag "specialTool_Name" of nbt of {_item}
- clear {_item}'s lore
- add "&7Special Tool &8||&7 Rarity: %colored {_rarityName}%" to {_item}'s lore
- add getXPBar({_item}, 10) to {_item}'s lore
- set {_enchs::*} to {@ENCHANT_NAME}
- if getEnchantLevel({_item}, "efficiency") > 0:
- set {_level} to getEnchantLevel({_item}, "efficiency")
- enchant {_item} with "efficiency %{_level}%" parsed as enchantment type
- if getEnchantLevel({_item}, "fortune") > 0:
- set {_level} to getEnchantLevel({_item}, "fortune")
- enchant {_item} with "fortune %{_level}%" parsed as enchantment type
- loop {_enchs::*}:
- if getEnchantLevel({_item}, loop-value) > 0:
- add "%getEnchantColor(loop-value)% %getEnchantLevel({_item}, loop-value)%" to {_item}'s lore
- set name of {_item} to "%{_name}% &7[&e%{_toNext}%&7/&e%{_currentLevelXP}%&7 XP]"
- return {_item}
- function levelUpSpecialTool(item: item, player: player, count: number) :: item:
- set {_rarity} to tag "specialTool_Rarity" of nbt of {_item}
- set {_xpMult} to yaml value "Rarities.%{_rarity}%.xpMult" from "config"
- set {_xpCap} to yaml value "Rarities.%{_rarity}%.xpCap" from "config"
- set {_enchChance} to yaml value "Rarities.%{_rarity}%.enchChance" from "config"
- set {_enchChanceCap} to yaml value "Rarities.%{_rarity}%.enchChanceCap" from "config"
- set {_level} to tag "specialTool_Level" of nbt of {_item}
- set {_toNext} to tag "specialTool_XPToNext" of nbt of {_item}
- set {_currentLevelXP} to tag "specialTool_LevelXP" of nbt of {_item}
- set {_name} to tag "specialTool_Name" of nbt of {_item}
- loop {_count} times:
- subtract 1 from {_toNext}
- if {_toNext} <= 0:
- add 1 to {_level}
- set {_toNext} to {_level} * {_xpMult}
- if {_toNext} > {_xpCap}:
- set {_toNext} to {_xpCap}
- set {_currentLevelXP} to {_toNext}
- play sound "ENTITY_PLAYER_LEVELUP" to {_player} with volume 0.5 and pitch 1
- send "&7-------------------------" to {_player}
- send "&aYou leveled up your %{_name}%&a!" to {_player}
- send "&7Level &a%{_level}% &8|| &e%{_toNext}% &7XP to level &a%{_level} + 1%&7." to {_player}
- set {_ec} to {_enchChance} * {_level}
- if {_ec} > {_enchChanceCap}:
- set {_ec} to {_enchChanceCap}
- chance of {_ec}:
- set {_enchs::*} to {@ENCHANT_NAME}
- set {_ench} to random element out of {_enchs::*}
- set {_path} to "Rarities.%{_rarity}%.maxLevels.%{_ench} converted to lowercase%"
- set {_maxLevel} to yaml value {_path} from "config"
- if getEnchantLevel({_item}, {_ench}) >= {_maxLevel}:
- send "&eMaxed enchantment lost! &8||&7 Enchantment: %getEnchantColor({_ench})% &8|| &7This enchantment didn't upgrade, because it has already been maxed out." to {_player}
- else:
- set {_item} to addEnchant({_item}, {_ench})
- send "&aEnchantment obtained! &8||&7 Enchantment: %getEnchantColor({_ench})% &7[Now level %getEnchantLevel({_item}, {_ench})%]" to {_player}
- send "&7-------------------------" to {_player}
- set {_nbt} to nbt of {_item}
- set tag "specialTool_Level" of {_nbt} to {_level}
- set tag "specialTool_XPToNext" of {_nbt} to {_toNext}
- set tag "specialTool_LevelXP" of {_nbt} to {_currentLevelXP}
- set {_item} to {_item} with custom nbt "%{_nbt}%"
- set {_lored} to doLore({_item})
- return {_lored}
- command /specialtools [<text>] [<text>] [<text>]:
- permission: specialtools.use
- aliases: /st, /specialtool
- permission message: &6No Permission &8|| &eYou don't have permission to do this. (&fspecialtools.use&e)
- trigger:
- if arg 1 is not set:
- send "&6/specialtools give <player> <item type> &8||&f Gives <player> a special tool of type <item type>. &8||&e Permission Node: specialtools.give"
- send "&6/specialtools reload &8||&f Reload the Special Tools config file. &8||&e Permission Node: specialtools.reload"
- send "&6/specialtools ench <enchantment> [level] &8||&f Enchant the special tool you're holding with the enchantment <enchantment> with level [level]. If [level] is omitted, the command will add a level of <enchantment>. &8||&e Permission Node: specialtools.ench"
- send "&6/specialtools rarity <rarity> &8||&f Set the rarity of the special tool you are holding to <rarity>. &8||&e Permission Node: specialtools.setrarity"
- send "&6/specialtools xp <amount> &8||&f Adds <amount> XP to the tool you're holding. &8||&e Permission Node: specialtools.xp"
- else if arg 1 is "give":
- if sender has permission "specialtools.give":
- if arg 2 is set:
- if arg 2 parsed as player is set:
- if arg 3 is set:
- if arg 3 parsed as item type is set:
- give (arg 2 parsed as player) generateSpecialTool(arg 3 parsed as item type)
- send "&2Success! &8|| &a%arg 2 parsed as player% has recieved their Special Tool of type %arg 3%!" to sender
- send "&2You have recieved a special tool of type %arg 3%." to (arg 2 parsed as player)
- else:
- send "&4Failure &8|| &cThe item type argument (arg 3) wasn't found. Make sure you typed it correctly, and that you used spaces instead of underscores (diamond pickaxe instead of diamond_pickaxe)."
- else:
- send "&4Failure &8|| &cThe item type argument (arg 3) wasn't specified. Make sure to specify a type of item (such as diamond pickaxe). Don't forget to use spaces instead of underscores."
- else:
- send "&4Failure &8|| &cThat player (arg 2) wasn't found online. Make sure you typed the player's name correctly, and that they're online."
- else:
- send "&4Failure &8|| &cYou didn't specify a player (arg 2)! Make sure to specify an online player to give a special tool to. Capitalization doesn't matter."
- else:
- send "&6No Permission &8|| &eYou don't have permission to do this. (&fspecialtools.give&e)"
- else if arg 1 is "reload":
- if sender has permission "specialtools.reload":
- reloadConfig()
- send "&2Success! &8|| &aConfig reloaded."
- else:
- send "&6No Permission &8|| &eYou don't have permission to do this. (&fspecialtools.reload&e)"
- else if arg 1 is "ench":
- if sender has permission "specialtools.ench":
- if arg 2 is set:
- set {_lvl} to "+1"
- if arg 3 is set:
- set {_lvl} to arg 3
- set player's tool to addEnchant(player's tool, arg 2, {_lvl})
- set player's tool to doLore(player's tool)
- else:
- send "&4Failure &8|| &cYou didn't specify an enchant (arg 2)! Please specify an enchantment, such as efficiency."
- else:
- send "&6No Permission &8|| &eYou don't have permission to do this. (&fspecialtools.ench&e)"
- else if arg 1 is "rarity":
- if sender has permission "specialtools.setrarity":
- set {_rarities::*} to loadRarities()
- if arg 2 is set:
- if {_rarities::*} contains arg 2:
- set {_nbt} to nbt of player's tool
- set tag "specialTool_Rarity" of {_nbt} to arg 2
- set player's tool to player's tool with custom nbt "%{_nbt}%"
- set player's tool to doLore(player's tool)
- send "&2Success! &8|| &aRarity set to %arg 2%."
- else:
- send "&4Failure &8|| &cThat rarity wasn't found in your config file (arg 2). Make sure you spelled it correctly!"
- else:
- send "&4Failure &8|| &cYou didn't specify a rarity (arg 2)! Choose a rarity from your config file, and put it as the second argument to the command."
- else:
- send "&6No Permission &8|| &eYou don't have permission to do this. (&fspecialtools.setrarity&e)"
- else if arg 1 is "xp":
- if sender has permission "specialtools.xp":
- if arg 2 is set:
- if arg 2 parsed as number is set:
- set player's tool to levelUpSpecialTool(player's tool, player, arg 2 parsed as number)
- set player's tool to doLore(player's tool)
- else:
- send "&4Failure &8|| &cThat's not a valid number! Make sure you didn't put any extra characters in there."
- else:
- send "&4Failure &8|| &cYou didn't specify an amount of XP (arg 2)! Put an amount of XP as your second argument."
- else:
- send "&6No Permission &8|| &eYou don't have permission to do this. (&fspecialtools.xp&e)"
- else:
- send "&4Failure &8|| &cThat subcommand wasn't recognized! Try using /st for all subcommands."
- on break:
- player's tool is a pickaxe or a shovel or an axe:
- if isSpecialTool(player's tool) is true:
- set {_name} to "%block%" converted to lowercase
- replace all " " in {_name} with "_"
- set {_exp} to yaml value "ExpPerBlock.%{_name}%" from "config"
- if {_exp} isn't set:
- set {_exp} to 1
- chance of getEnchantLevel(player's tool, "wisdom") * 0.2:
- set {_exp} to {_exp} * 2
- set player's tool to levelUpSpecialTool(player's tool, player, {_exp})
- on hotbar switch:
- if player's tool is a pickaxe or an axe or an axe:
- if isSpecialTool(player's tool) is false:
- set player's tool to generateSpecialTool(type of player's tool)
- # Laser
- on right click:
- getEnchantLevel(player's tool, "laser") > 0:
- shoot an egg from the player with speed 1.25
- on projectile hit:
- projectile is an egg
- set {_tag} to tag "ownerName" of nbt of projectile
- tag "ownerName" of nbt of projectile is set
- wait 1 tick
- set {_block} to the block at location 0.1 in front of the projectile
- if {_block} is air:
- set {_block} to the block at location 0.1 behind the projectile
- set {_player} to "%{_tag}%" parsed as player
- {_player} can build at location
- set {_tag} to tag "ownerName" of nbt of projectile
- {_block} isn't bedrock
- set {_drops::*} to drops of {_block}
- loop {_drops::*}:
- set {_drop} to loop-value
- drop {_drop} at location of {_block}
- set block at location of {_block} to air
- if isSpecialTool({_player}'s tool) is true:
- set {_name} to "%{_block}%" converted to lowercase
- replace all " " in {_name} with "_"
- set {_exp} to yaml value "ExpPerBlock.%{_name}%" from "config"
- if {_exp} isn't set:
- set {_exp} to 1
- chance of getEnchantLevel({_player}'s tool, "wisdom") * 0.2:
- set {_exp} to {_exp} * 2
- set {_player}'s tool to levelUpSpecialTool({_player}'s tool, {_player}, {_exp})
- wait 1 tick
- if distance between last spawned chicken and event-location is less than 20:
- delete the last spawned chicken
- # Explosive
- #on break:
- # getEnchantLevel(player's tool, "explosive") > 0:
- # set {_h} to health of player
- # create an explosion with force getEnchantLevel(player's tool, "explosive") * 3
- # set player's health to {_h}
- # Haste
- every second:
- loop all players:
- if getEnchantLevel(loop-player's tool, "haste") > 0:
- apply haste getEnchantLevel(loop-player's tool, "haste") to loop-player for 1 second
- # Speed
- every second:
- loop all players:
- if getEnchantLevel(loop-player's tool, "speed") > 0:
- apply speed getEnchantLevel(loop-player's tool, "speed") to loop-player for 1 second
- # Jump
- every second:
- loop all players:
- if getEnchantLevel(loop-player's tool, "jump") > 0:
- apply jump boost getEnchantLevel(loop-player's tool, "jump") to loop-player for 1 second
- # NV
- every second:
- loop all players:
- if getEnchantLevel(loop-player's tool, "night vision") > 0:
- apply night vision getEnchantLevel(loop-player's tool, "night vision") to loop-player for 10 seconds
- else:
- remove night vision from loop-player
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement