Commit b63b56c7 authored by Tommy Ang's avatar Tommy Ang 🤣

Implement liquid flow protection

parent 62af90b4
......@@ -9,23 +9,12 @@
import:
org.bukkit.event.player.PlayerInteractEvent
org.bukkit.event.hanging.HangingBreakByEntityEvent
org.bukkit.event.block.BlockFromToEvent
options:
ChunkPrice: 2500
ChunksPerPurchase: 5
command /migrate:
permission: op
trigger:
loop {ptownlist::*}:
if {ptown.%loop-value%.landexpansion} is set:
set {_totalRefund} to 0
loop {ptown.%loop-value%.landexpansion} time:
set {_nextUpgrade} to ({@ChunksPerPurchase} * {@ChunkPrice} * loop-number) * 0.75
add {_nextUpgrade} to {_totalRefund}
message "Total Refund to %{ptown.money::%loop-value%}%: %{_totalRefund}%"
add {_totalRefund} to {ptown.money::%loop-value%}
command /potatotown <text="help"> [<text>]:
aliases: ptown
description: Potato Town
......@@ -176,15 +165,19 @@ command /potatotown <text="help"> [<text>]:
message "Town not found."
stop
set {_boughtTime} to {ptown.%{_town}%.landexpansion}
set {_nextUpgrade} to ({@ChunksPerPurchase} * {@ChunkPrice} * ({_boughtTime} + 1)) * 0.75
set {_nextUpgrade} to "&a%({@ChunksPerPurchase} * {@ChunkPrice} * ({_boughtTime} + 1)) * 0.75%"
if {_boughtTime} is more than 29:
set {_nextUpgrade} to "Max"
set {_nextUpgrade} to "&cMax"
if {ptown.money::%{_town}%} is set:
set {_money} to {ptown.money::%{_town}%}
else:
set {_money} to 0
message "&6--------------------- Potato Town ---------------------"
message "Town: %{_town}%"
message "Desc: %{ptown.%{_town}%.desc}%"
message "Size: %{ptown.%{_town}%.size}%/%{ptown.%{_town}%.maxsize}%"
message "Bank: %{ptown.money::%{_town}%}%" #(+%{ptown.tax.%{_town}%}%)
message "Land Expansion Bought: %{_boughtTime}% (Next Upgrade: %{_nextUpgrade}%)"
message "&6Town: &e%{_town}%"
message "&6Desc: &e%{ptown.%{_town}%.desc}%"
message "&6Size: &e%{ptown.%{_town}%.size}%&e/%{ptown.%{_town}%.maxsize}%"
message "&6Bank: &e%{_money}% &eRammyCoin" #(+%{ptown.tax.%{_town}%}%)
message "&6Land Expansion Bought: &e%{_boughtTime}% &e(Next Upgrade: %{_nextUpgrade}%&e)"
#message "Nation: "
set {_fire} to {ptown.%{_town}%.flag::fire}
if {_fire} is not set:
......@@ -200,7 +193,7 @@ command /potatotown <text="help"> [<text>]:
set {_friendlyfire} to "&aFriendlyFire"
if {_friendlyfire} is "false":
set {_friendlyfire} to "&cFriendlyFire"
message "Flag: %{_fire}% &f| %{_friendlyfire}%"
message "&6Flag: %{_fire}% &f| %{_friendlyfire}%"
set {_prbreak} to {ptown.%{_town}%.prflag::break}
set {_prbuild} to {ptown.%{_town}%.prflag::build}
if {_prbreak} is not set:
......@@ -215,8 +208,8 @@ command /potatotown <text="help"> [<text>]:
set {_prbuild} to "&aBuild"
if {_prbuild} is "false":
set {_prbuild} to "&cBuild"
message "Nation Flag: Build | Break"
message "PR Flag: %{_prbuild}% | %{_prbreak}%"
#message "Nation Flag: Build | Break"
message "&6PR Flag: %{_prbuild}% &f| %{_prbreak}%"
set {_player} to {ptown.%{_town}%.owner}
set {_player} to {_player} parsed as offline player
if {_player} is online:
......@@ -243,8 +236,8 @@ command /potatotown <text="help"> [<text>]:
if {_player3} is offline:
#add "%loop-value%" to {ptown.%{_town}%.infolist::*}
set {_online} to "%{_online}%, %loop-value%"
message "Members: %{_online}%"
message "PRs: %{ptown.%{_town}%.prlist::*}%"
message "&6Members: %{_online}%"
message "&6PRs: &e%{ptown.%{_town}%.prlist::*}%"
clear {ptown.%{_town}%.infolist::*}
stop
if arg 1 is "list":
......@@ -400,13 +393,13 @@ command /potatotown <text="help"> [<text>]:
stop
set {ptown.destroy.confirmation.%player%} to 1
if player's current language is "zh_cn" or "zh_tw":
message "---------------Potato Town---------------"
message "&6--------------------- Potato Town ---------------------"
message "&c您确定要摧毁您的性感小镇?"
message "您可以点击下面的选项,或者您可以使用&b/ptown confirm &9或&b/ptown cancel。" to player
message formatted "<tooltip:点击这将确认操作><cmd:/ptown confirm>[&a确认&f]<r> | <tooltip:点击这将取消操作><cmd:/ptown cancel>[&c取消&f]"
message "&c您有10秒。"
else:
message "---------------Potato Town---------------"
message "&6--------------------- Potato Town ---------------------"
message "&cAre you sure you want to destroy your sexy town?"
message "&9You may click the option below or alternatively you may use &b/ptown confirm &9or &b/ptown cancel." to player
message formatted "<tooltip:Clicking this will confirm your action><cmd:/ptown confirm>[&aConfirm&f]<r> | <tooltip:Clicking this will cancel your action><cmd:/ptown cancel>[&cCancel&f]"
......@@ -437,12 +430,12 @@ command /potatotown <text="help"> [<text>]:
set {ptown.invited.confirmation.%loop-player%} to 1
set {ptown.readytojoin.%loop-player%} to "%{ptown.%player%}%"
if loop-player's current language is "zh_cn" or "zh_tw":
message "--------------Potato Town--------------"
message "&6--------------------- Potato Town ---------------------"
message "%player% 邀请您住进小镇 &b%{_town}%&f." to loop-player
message formatted "<tooltip:点击这个会接受邀请><cmd:/ptown join %{_town}%>[&a接受&f]" to loop-player
message "10秒后超时" to loop-player
else:
message "--------------Potato Town--------------"
message "&6--------------------- Potato Town ---------------------"
message "%player% has sent you an invitation to town &b%{_town}%&f." to loop-player
message formatted "<tooltip:Clicking this will accept the invitation><cmd:/ptown join %{_town}%>[&aAccept&f]" to loop-player
message "Time out in 10 seconds" to loop-player
......@@ -471,13 +464,13 @@ command /potatotown <text="help"> [<text>]:
set {ptown.invited.confirmation.%loop-player%} to 1
set {ptown.readytojoin.%loop-player%} to "%{ptown.%player%}%"
if loop-player's current language is "zh_cn" or "zh_tw":
message "--------------Potato Town--------------"
message "&6--------------------- Potato Town ---------------------"
message "%player% 邀请您住进小镇 &b%{_town}%&f." to loop-player
message "您可以点击下面的选项,或者您可以使用&b/ptown join %{_town}%。" to loop-player
message formatted "<tooltip:点击这个会接受邀请><cmd:/ptown join %{_town}%>[&a接受&f]" to loop-player
message "10秒后超时" to loop-player
else:
message "--------------Potato Town--------------"
message "&6--------------------- Potato Town ---------------------"
message "%player% have sent you an invitation to town &b%{_town}%&f." to loop-player
message "&9You may click the option below or alternatively, you may use &b/ptown join %{_town}%." to loop-player
message formatted "<tooltip:Clicking this will accept the invitation><cmd:/ptown join %{_town}%>[&aAccept&f]" to loop-player
......@@ -686,13 +679,13 @@ command /potatotown <text="help"> [<text>]:
if {ptown.%player%} is set:
set {ptown.leave.confirmation.%player%} to 1
if player's current language is "zh_cn" or "zh_tw":
message "---------------Potato Town---------------"
message "&6--------------------- Potato Town ---------------------"
message "&c您确定要离开您的性感小镇?"
message "您可以点击下面的选项,或者您可以使用&b/ptown confirm &9或&b/ptown cancel。" to player
message formatted "<tooltip:点击这将确认操作><cmd:/ptown confirm>[&a确认&f]<r> | <tooltip:点击这将取消操作><cmd:/ptown cancel>[&c取消&f]"
message "&c您有10秒。"
else:
message "---------------Potato Town---------------"
message "&6--------------------- Potato Town ---------------------"
message "&cAre you sure you want to leave your sexy town?"
message "&9You may click the option below or alternatively you may use &b/ptown confirm &9or &b/ptown cancel." to player
message formatted "<tooltip:Clicking this will confirm your action><cmd:/ptown confirm>[&aConfirm&f]<r> | <tooltip:Clicking this will cancel your action><cmd:/ptown cancel>[&cCancel&f]"
......@@ -1401,6 +1394,8 @@ on HangingBreakByEntityEvent:
message "[&6PTown&f] &4这不是您的小镇!" to {_player}
else:
message "[&6PTown&f] &4This is not your town!" to {_player}
on block damage:
if {ptown.%player%.adminmode} is not set:
......@@ -1695,4 +1690,30 @@ on any movement:
else:
send title "&a%{_ptowncurrentlocation}%" with subtitle "%{ptown.%{_ptowncurrentlocation}%.desc}%" to player for 2 seconds with fade in 10 ticks and fade out 10 ticks
message "[&6PTown&f] You are now entering %{_ptowncurrentlocation}%"
# Liquid Flow Protection #
on BlockFromToEvent:
# Get direction of the flow
set {_direction} to "%event.getFace().getOppositeFace()%"
set {_block} to event.getToBlock()
# Get the origin block
if {_direction} is equal to "SOUTH":
set {_origin} to block 1 south of {_block}
else if {_direction} is equal to "NORTH":
set {_origin} to block 1 north of {_block}
else if {_direction} is equal to "WEST":
set {_origin} to block 1 west of {_block}
else if {_direction} is equal to "EAST":
set {_origin} to block 1 east of {_block}
else if {_direction} is equal to "UP":
set {_origin} to block above {_block}
# Get origin chunk
set {_originChunk} to chunk at {_origin}
# Get destination chunk
set {_destination} to chunk at {_block}
if {ptownlist.chunk::%{_originChunk}%} is not equal to {ptownlist.chunk::%{_destination}%}:
# Allow flow to wilderness
if {ptownlist.chunk::%{_destination}%} is set:
cancel event
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment