Make this skript into a plugin
📄
AriseSMP.txt
txt
264 lines
▶
# AriseSMP multiplier and playtime heart system
options:
voucher-name: &6Multiplier Voucher
voucher-value: &eValue: 0.5x Multiplier
voucher-instruction: &7Right-click to claim.
function healthCap(multiplier: number) :: number:
set {_cap} to 10 + ({_multiplier} * 4)
if {_cap} > 20:
set {_cap} to 20
return {_cap}
function checkHealthCap(p: player):
set {_uuid} to uuid of {_p}
if {heartmult::%{_uuid}%} is not set:
set {heartmult::%{_uuid}%} to 1.0
set {_cap} to healthCap({heartmult::%{_uuid}%})
if {_p}'s max health > {_cap}:
set {_p}'s max health to {_cap}
function createVoucher() :: item:
set {_voucher} to clock named "{@voucher-name}" with lore "{@voucher-value}" and "{@voucher-instruction}"
return {_voucher}
on join:
set {_uuid} to uuid of player
if {heartmult::%{_uuid}%} is not set:
set {heartmult::%{_uuid}%} to 1.0
set {hearttimer::%{_uuid}%} to 3600
set player's max health to 10
if {hearttimer::%{_uuid}%} is not set:
set {hearttimer::%{_uuid}%} to 3600
checkHealthCap(player)
every 1 second:
loop all players:
set {_uuid} to uuid of loop-player
if {heartmult::%{_uuid}%} is not set:
set {heartmult::%{_uuid}%} to 1.0
if {hearttimer::%{_uuid}%} is not set:
set {hearttimer::%{_uuid}%} to 3600
checkHealthCap(loop-player)
set {_cap} to healthCap({heartmult::%{_uuid}%})
if loop-player's max health >= {_cap}:
send action bar "&eMAX &7| &6%{heartmult::%{_uuid}%}%x" to loop-player
else:
subtract 1 from {hearttimer::%{_uuid}%}
if {hearttimer::%{_uuid}%} <= 0:
set {hearttimer::%{_uuid}%} to 3600
set {_reward} to 2 * {heartmult::%{_uuid}%}
set {_newHealth} to loop-player's max health + {_reward}
if {_newHealth} > {_cap}:
set loop-player's max health to {_cap}
else:
set loop-player's max health to {_newHealth}
send "&aYou gained hearts from your hourly playtime!" to loop-player
play sound "entity.player.levelup" with volume 1 and pitch 1.2 to loop-player
set {_mins} to ceil({hearttimer::%{_uuid}%} / 60)
send action bar "&a%{_mins}% min &7| &6%{heartmult::%{_uuid}%}%x" to loop-player
on death of player:
set {_victimUuid} to uuid of victim
if attacker is a player:
set {_attackerUuid} to uuid of attacker
if {heartmult::%{_victimUuid}%} <= 0:
send "&cYou got nothing because the victim was at 0x." to attacker
else:
subtract 0.5 from {heartmult::%{_victimUuid}%}
if {heartmult::%{_victimUuid}%} < 0:
set {heartmult::%{_victimUuid}%} to 0
set {hearttimer::%{_victimUuid}%} to 3600
checkHealthCap(victim)
play sound "entity.wither.break_block" with volume 1 and pitch 0.8 to victim
if {heartmult::%{_attackerUuid}%} >= 2.5:
set {_voucher} to createVoucher()
drop {_voucher} at victim's location
send "&eYou are at the maximum multiplier. A 0.5x multiplier voucher dropped on the ground." to attacker
play sound "entity.item.pickup" with volume 1 and pitch 1 to attacker
else:
add 0.5 to {heartmult::%{_attackerUuid}%}
set {hearttimer::%{_attackerUuid}%} to 3600
send "&aYou killed %victim% and gained +0.5x multiplier!" to attacker
play sound "ui.toast.challenge_complete" with volume 0.8 and pitch 1.4 to attacker
else:
if {heartmult::%{_victimUuid}%} > 0:
set {_voucher} to createVoucher()
drop {_voucher} at victim's location
subtract 0.5 from {heartmult::%{_victimUuid}%}
if {heartmult::%{_victimUuid}%} < 0:
set {heartmult::%{_victimUuid}%} to 0
set {hearttimer::%{_victimUuid}%} to 3600
checkHealthCap(victim)
send "&cYou died to natural causes and lost 0.5x multiplier!" to victim
play sound "entity.wither.break_block" with volume 1 and pitch 0.8 to victim
on right click:
if player's tool is a clock:
if name of player's tool is "{@voucher-name}":
if lore of player's tool contains "{@voucher-value}":
cancel event
set {_uuid} to uuid of player
if {heartmult::%{_uuid}%} >= 2.5:
send "&cYour multiplier is already at the 2.5x maximum." to player
stop
remove 1 of player's tool from player's inventory
add 0.5 to {heartmult::%{_uuid}%}
if {heartmult::%{_uuid}%} > 2.5:
set {heartmult::%{_uuid}%} to 2.5
set {hearttimer::%{_uuid}%} to 3600
send "&aYou claimed a 0.5x multiplier voucher!" to player
play sound "entity.player.levelup" with volume 1 and pitch 1.3 to player
command /withdraw :
usage: &cUsage: /withdraw
trigger:
set {_amount} to arg-1 parsed as an integer
if {_amount} is not set:
send "&cPlease specify a valid whole number. Example: /withdraw 2" to player
stop
set {_uuid} to uuid of player
if {_amount} < 1:
send "&cYou must withdraw at least 1 multiplier token!" to player
stop
if {heartmult::%{_uuid}%} <= 0:
send "&cYou have no multiplier to withdraw." to player
stop
set {_valueToDeduct} to {_amount} * 0.5
if {heartmult::%{_uuid}%} - {_valueToDeduct} < 0:
send "&cYou do not have enough multiplier to withdraw that amount!" to player
stop
subtract {_valueToDeduct} from {heartmult::%{_uuid}%}
set {hearttimer::%{_uuid}%} to 3600
checkHealthCap(player)
play sound "block.iron_door.close" with volume 1 and pitch 1.5 to player
set {_voucher} to createVoucher()
loop {_amount} times:
if player can hold {_voucher}:
give 1 of {_voucher} to player's inventory
else:
drop 1 of {_voucher} at player's location
send "&aSuccessfully withdrew %{_amount}% multiplier token(s)!" to player
command /checkmultiplier [] []:
permission: admin.multiplier
permission message: &cYou do not have permission to run this admin command.
usage: &eUsage: /checkmultiplier [set/add/remove] [value]
trigger:
set {_target} to arg-1
set {_targetUuid} to uuid of {_target}
set {_action} to arg-2
set {_value} to arg-3
if {heartmult::%{_targetUuid}%} is not set:
set {heartmult::%{_targetUuid}%} to 1.0
if {hearttimer::%{_targetUuid}%} is not set:
set {hearttimer::%{_targetUuid}%} to 3600
if {_action} is not set:
send "&8========== &6%{_target}%'s Profile &8==========" to player
send "&eMultiplier: &6%{heartmult::%{_targetUuid}%}%x" to player
set {_mins} to ceil({hearttimer::%{_targetUuid}%} / 60)
send "&eTimer left: &6%{_mins}% minute(s)" to player
send "&8=====================================" to player
stop
if {_action} is "set":
if {_value} is not set:
send "&cPlease specify a value to set." to player
stop
if {_value} < 0:
send "&cMultipliers cannot go below 0x!" to player
stop
if {_value} > 2.5:
send "&cMultipliers cannot exceed 2.5x!" to player
stop
set {heartmult::%{_targetUuid}%} to {_value}
set {hearttimer::%{_targetUuid}%} to 3600
checkHealthCap({_target})
send "&aSuccessfully set %{_target}%'s multiplier to %{_value}%x." to player
send "&eAn admin updated your multiplier to %{_value}%x!" to {_target}
stop
if {_action} is "add":
if {_value} is not set:
send "&cPlease specify a value to add." to player
stop
if {_value} <= 0:
send "&cThe amount must be greater than 0." to player
stop
if {heartmult::%{_targetUuid}%} + {_value} > 2.5:
send "&cThis modification would exceed the 2.5x cap!" to player
stop
add {_value} to {heartmult::%{_targetUuid}%}
set {hearttimer::%{_targetUuid}%} to 3600
send "&aAdded %{_value}%x to %{_target}%'s multiplier." to player
send "&eAdded +%{_value}%x to your multiplier!" to {_target}
stop
if {_action} is "remove":
if {_value} is not set:
send "&cPlease specify a value to remove." to player
stop
if {_value} <= 0:
send "&cThe amount must be greater than 0." to player
stop
if {heartmult::%{_targetUuid}%} - {_value} < 0:
send "&cThis modification would drop them below the 0x floor!" to player
stop
subtract {_value} from {heartmult::%{_targetUuid}%}
set {hearttimer::%{_targetUuid}%} to 3600
checkHealthCap({_target})
send "&aRemoved %{_value}%x from %{_target}%'s multiplier." to player
send "&cAn admin removed %{_value}%x from your multiplier!" to {_target}
stop
send "&cInvalid action. Use set, add, or remove." to player
Build the Gradle/Spigot plugin scaffold and resource metadata.
Implement persistent multiplier/timer storage, health caps, hourly rewards, deaths, and vouchers.
Add
/withdrawand/checkmultipliercommands with permissions and validation.Register listeners and the repeating playtime task in the main plugin class.
Created the AriseSMP plugin with:
Persistent multiplier and playtime timer storage in
data.ymlHealth caps based on multiplier
Hourly playtime heart rewards
Player and natural death multiplier handling
Multiplier voucher creation, dropping, withdrawal, and claiming
/withdraw <amount>/checkmultiplier <player> [set|add|remove] [value]Admin permission handling
Configurable voucher messages, timer, reward, and multiplier cap
Registered event listeners and repeating timer task
Gradle build and plugin metadata
package com.arisesmp;
import com.arisesmp.command.MultiplierCommand;
import com.arisesmp.command.WithdrawCommand;
import com.arisesmp.data.MultiplierData;
import com.arisesmp.listener.HeartListener;
import com.arisesmp.manager.HeartManager;
import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
public class AriseSMPPlugin extends JavaPlugin {
private MultiplierData multiplierData;
private HeartManager heartManager;
private BukkitTask heartTask;
@Override
public void onEnable() {
saveDefaultConfig();
this.multiplierData = new MultiplierData(this);
this.heartManager = new HeartManager(this, multiplierData);
Listener listener = new HeartListener(heartManager);
Bukkit.getPluginManager().registerEvents(listener, this);
getCommand("withdraw").setExecutor(new WithdrawCommand(heartManager));
getCommand("checkmultiplier").setExecutor(new MultiplierCommand(heartManager));
this.heartTask = Bukkit.getScheduler().runTaskTimer(this, () -> {
Bukkit.getOnlinePlayers().forEach(heartManager::tickPlayer);
}, 20L, 20L);
}
@Override
public void onDisable() {
if (heartTask != null) {
heartTask.cancel();
}
if (multiplierData != null) {
multiplierData.save();
}
}
}