Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CannonBattle Minigame & GoldRush Minigame & Trainmasters Map #21

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions MINIGAMES.SK/core/_lib/nbt.sk
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# ==============
# nbt.sk
# ==============
# nbt.sk is part of the MINIGAMES.SK library.
# ==============

import:
org.bukkit.Bukkit
org.bukkit.NamespacedKey
org.bukkit.persistence.PersistentDataType
org.bukkit.persistence.PersistentDataContainer

#
# > Function - getnbtvalue
# > Parameters:
# > <item> The item with the nbt value
# > <text> The nbt tag data which is needed
# > Actions:
# > Loads nbt value for the parameter tag and return the value.
function getnbtvalue(item:item,tag:text) :: object:
set {_namespacedKey} to new NamespacedKey(Bukkit.getServer().getPluginManager().getPlugin("Skript"), {_tag})
set {_meta} to {_item}.getItemMeta()
set {_container} to {_meta}.getPersistentDataContainer()
if {_container}.has({_namespacedKey} , PersistentDataType.STRING!):
return {_container}.get({_namespacedKey}, PersistentDataType.STRING!)

#
# > Function - setnbtvalue
# > Parameters:
# > <item> The item to set the nbt value on
# > <text> The tag which should be set
# > <text> The value which should be set
# > Actions:
# > Sets the tag to the value and return the item with the new nbt data.
function setnbtvalue(item:item,tag:text,value:text) :: item:
set {_namespacedKey} to new NamespacedKey(Bukkit.getServer().getPluginManager().getPlugin("Skript"), {_tag})
set {_meta} to {_item}.getItemMeta()
{_meta}.getPersistentDataContainer().set({_namespacedKey}, PersistentDataType.STRING!, {_value})
{_item}.setItemMeta({_meta})
return {_item}
8 changes: 6 additions & 2 deletions MINIGAMES.SK/core/events/mgFixInvisiblePlayers.sk
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
# mgFixInvisiblePlayers.sk is part of the MINIGAMES.SK library.
# ==============

import:
org.bukkit.Bukkit

on join:
wait 1 second
set {_plugin} to Bukkit.getServer().getPluginManager().getPlugin("Skript")
loop all players:
loop-player.showPlayer(player)
player.showPlayer(loop-player)
loop-player.showPlayer({_plugin},player)
player.showPlayer({_plugin},loop-player)
77 changes: 77 additions & 0 deletions MINIGAMES.SK/games/CannonBattle/-init.sk
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@

#
# ==============
# init.sk
# ==============
# init.sk is part of the MINIGAMES.SK library.
# ==============
# > GAME: CannonBattle
# ==============

on load:
wait 1 tick
mgCannonBattleHandler("start")

every 1 second:
feed all players

on quit:
if mgGetTemporaryGameData("playerstatus|%player%") is true:
set {_playersingame} to mgGetTemporaryGameData("playersingame")
remove 1 from {_playersingame}
mgSetTemporaryGameData("playersingame",{_playersingame})
mgSetTemporaryGameData("playerstatus|%player%",false)
mgCheckCannonBattleRoundEnd()

on join:
clear inventory of player
set gamemode of player to spectator
set {_loc} to mgGetTemporaryGameData("respawnloc")
teleport player to {_loc}

on damage:
if victim is a player:
if "%event.getCause()%" is "unknown" or "fall":
cancel event
mgCannonBattleHandleGameDeath(victim)

on death:
if victim is a player:
wait 1 tick
force victim to respawn
wait 1 tick
mgCannonBattleHandleGameDeath(player)

on explosion:
loop all blocks in radius 5 around event-location:
if loop-block is grass block or dirt or sandstone:
add location of loop-block to {_expblocks::*}
add loop-block.getBlockData() to {_expdata::*}
wait 1 tick
loop {_expblocks::*}:
if block at loop-value is air:
chance of 50%:
set {_direction} to direction from event-location to loop-value
set {_e} to (event-locations's world).spawnFallingBlock(loop-value, {_expdata::%loop-index%})
push {_e} {_direction} at speed 1


on respawn:
wait 1 tick
mgCannonBattleHandleGameDeath(player)


on break:
clear drops
if mgGetTemporaryGameData("status") is not "ingame":
cancel event

every 1 tick:
if mgGetTemporaryGameData("status") is "ingame":
loop all players:
set {_loc} to location of loop-player
remove 1 from y-coord of {_loc}
loop blocks in radius 1.2 around {_loc}:
if loop-block is lime concrete:
set {_bloc} to location of loop-block
mgCannonBattleFloor({_bloc})
14 changes: 14 additions & 0 deletions MINIGAMES.SK/games/CannonBattle/config.sk
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# ==============
# config.sk
# ==============
# config.sk is part of the MINIGAMES.SK library.
# ==============

on load:
wait 1 tick
set {_game} to "CannonBattle"
mgSetTranslation("en",{_game},"name","CannonBattle")
mgSetTranslation("en",{_game},"desc","Build TNT Cannons and destory the beacon of the enemy.")
mgSetTranslation("en",{_game},"bossbar_countdown","Prepare yourself...")
mgSetTranslation("en",{_game},"toplist_scoreboard","&7&l<place> | &f<player> &7&l>> &e&l<points>")
Loading