Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
5.2 kB
2
Indexable
Never
command /crate [<text>] [<text>]:
	trigger:
		if player does not have permission "crate.use" or "crate.*":
			send "&9Crates&8 - &7Designed by &aSantio71"
			stop
		if arg-1 is not set:
			send "&9/crate create (name) &7&m-&7 Create a new crate"
			send "&9/crate crate (name) &7&m-&7 Get a placeable crate"
			send "&9/crate additem (crate) &7&m-&7 Add your held item into a crate!"
			send "&9/crate removeitem (crate) &7&m-&7 Remove your held item from a crate!"
			send "&9/crate remove (crate) &7&m-&7 Remove a crate!"
			send "&9/crate key (crate) &7&m-&7 Get a key for a crate!"
			send "&9/crate list &7&m-&7 List all crates!"
		else if arg-1 is "create":
			if arg-2 is not set:
				send "&c/crate %arg-1% (name)"
				stop
			if arg-2 contains "&":
				send "&cColored names are not allowed!"
				stop
			if {crates::%arg-2%::exists} is set:
				send "&cThat crate already exists!"
				stop
			add arg-2 to {crates::list::*}
			set {crates::%arg-2%::exists} to true
			send "&8(&a*&8)&7 Created the crate %arg-2%!"
		else if arg-1 is "remove":
			if arg-2 is not set:
				send "&c/crate %arg-1% (name)"
				stop
			if {crates::%arg-2%::exists} is not set:
				send "&cThat crate does not exist!"
				stop
			remove arg-2 from {crates::list::*}
			clear {crates::%arg-2%::*}
			send "&8(&a*&8)&7 Removed crate %arg-2%!"
		else if arg-1 is "list":
			send "&7&m--------"
			loop {crates::list::*}:
				send "&9%loop-value%"
			send "&7&m--------"
		else if arg-1 is "additem" or "addi" or "ai":
			if arg-2 is not set:
				send "&c/crate %arg-1% (name)"
				stop
			if {crates::%arg-2%::exists} is not set:
				send "&cThat crate does not exist!"
				stop
			if "%player's held item%" contains "air":
				send "&cYou cannot add air into the crate!"
				stop
			add player's held item to {crates::%arg-2%::items::*}
			send "&8(&a*&8) &7Added %player's held item% in crate %arg-2%&7!"
		else if arg-1 is "removeitem" or "remitem" or "ri":
			if arg-2 is not set:
				send "&c/crate %arg-1% (name)"
				stop
			if {crates::%arg-2%::exists} is not set:
				send "&cThat crate does not exist!"
				stop
			if "%player's held item%" contains "air":
				send "&cYou cannot take air from the crate!"
				stop
			remove player's held item from {crates::%arg-2%::items::*}
			send "&8(&a*&8) &7Removed %player's held item% in crate %arg-2%&7!"
		else if arg-1 is "key":
			if arg-2 is not set:
				send "&c/crate %arg-1% (name)"
				stop
			if {crates::%arg-2%::exists} is not set:
				send "&cThat crate does not exist!"
				stop
			give 1 nether star named "&d%arg-2% Crate &dKey" to player
			send "&8(&a*&8)&7 Gave a %arg-2%&7 crate key!"
		else if arg-1 is "crate":
			if arg-2 is not set:
				send "&c/crate %arg-1% (name)"
				stop
			if {crates::%arg-2%::exists} is not set:
				send "&cThat crate does not exist!"
				stop
			give 1 end portal frame block named "&d%arg-2%" with lore "&7Place me down!" to player
			send "&8(&a*&8)&7 You gave yourself the %arg-2% crate!"
		else:
			send "&cUnknown argument!"
			send "&7/crate &c&o&n%arg-1%"
			
on place:
	event-block is end portal frame block
	loop {crates::list::*}:
		if name of player's held item is "&d%loop-value%":
			add location of event-block to {crates::locations::%loop-value%::*}
			send "&7Crate added!"

on left click:
	if clicked block is set:
		if block at location of clicked block is end portal frame block:
			loop {crates::list::*}:
				loop {crates::locations::%loop-value%::*}:
					if location of event-block is loop-value-2:
						if player's gamemode is survival:
							cancel event
							open chest with 4 row named "&d%loop-value-1% Crate&7 Prizes" to player
							set {_a} to 0
							loop {crates::%loop-value-1%::items::*}:
								if "%loop-value-3%" contains "air":
									add 1 to {_a}
									remove loop-value-3 from {crates::%loop-value-1%::items::*}
								else:
									format slot {_a} of player with loop-value-3 to close
									add 1 to {_a}
on break:
	event-block is end portal frame block
	loop {crates::list::*}:
		loop {crates::locations::%loop-value%::*}:
			if location of event-block is loop-value-2:
				if player has permission "op":
					remove location of event-block from {crates::locations::%loop-value-1%::*}
					send "&7Crate Removed!"
				else:
					cancel event

on right click:
	event-block is end portal frame block
	loop {crates::list::*}:
		loop {crates::locations::%loop-value%::*}:
			if location of event-block is loop-value-2:
				cancel event
				if name of tool is "&d%loop-value-1% Crate &dKey":
					set {_p} to random object out of {crates::%loop-value-1%::items::*}
					remove nether star named "&d%loop-value-1% Crate &dKey" from player
					give {_p} to player
					send "&8(&a*&8)&7 You were rewarded an item!"
				else:
					cancel event
					if {fling::%player%} is not set:
						set {fling::%player%} to true
						send "&6You need a &d%loop-value-1% Crate &dKey &6for this crate!" to the player
						push the player backwards at speed 0.75
						wait 1 second
						clear {fling::%player%}
Leave a Comment