import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import net.risingworld.api.Plugin;
import net.risingworld.api.Server;
import net.risingworld.api.Timer;
import net.risingworld.api.World;
import net.risingworld.api.assets.AssetBundle;
import net.risingworld.api.assets.PrefabAsset;
import net.risingworld.api.assets.SoundAsset;
import net.risingworld.api.database.Database;
import net.risingworld.api.events.EventMethod;
import net.risingworld.api.events.Listener;
import net.risingworld.api.events.player.PlayerCommandEvent;
import net.risingworld.api.events.player.PlayerConnectEvent;
import net.risingworld.api.events.player.ui.PlayerUIElementClickEvent;
import net.risingworld.api.objects.Player;
import net.risingworld.api.ui.UIElement;
import net.risingworld.api.ui.UILabel;
import net.risingworld.api.utils.Layer;
import net.risingworld.api.worldelements.Prefab;
public class Boost extends Plugin implements Listener {
public Database database;
System.out.println("-- BOOST ENABLED --");
database = getSQLiteConnection(getPath() + "/database.db");
registerEventListener(this);
database.execute("CREATE TABLE IF NOT EXISTS `Boosts` (`ID` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `BoostType` VARCHAR(64), `BoostTimeInterval` INTEGER, `BoostAmount` INTEGER);");
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Healing'")) {
System.out.println("looking At Boost Settings");
System.out.println("Updating Boost Settings");
database.executeUpdate("INSERT INTO `Boosts` (BoostType, BoostTimeInterval, BoostAmount) VALUES ('Healing','3600','100');");
database.executeUpdate("INSERT INTO `Boosts` (BoostType, BoostTimeInterval, BoostAmount) VALUES ('Thirst','2700','100');");
database.executeUpdate("INSERT INTO `Boosts` (BoostType, BoostTimeInterval, BoostAmount) VALUES ('Hunger','2100','100');");
database.executeUpdate("INSERT INTO `Boosts` (BoostType, BoostTimeInterval, BoostAmount) VALUES ('Stamina','1800','100');");
System.out.println("Boost Settings Looks Ok ");
} catch (SQLException ex) {
Logger.getLogger(Boost.class.getName()).log(Level.SEVERE, null, ex);
public void onDisable() {
System.out.println("-- BOOST DISABLED --");
if(database != null) database.close();
public void onPlayerConnect(PlayerConnectEvent event) throws SQLException {
Player player = event.getPlayer();
float HealingTimeInterval = 0;
float ThirstTimeInterval = 0;
float HungerTimeInterval = 0;
float StaminaTimeInterval = 0;
UIElement MainPanel = new UIElement();
player.addUIElement(MainPanel);
MainPanel.setSize(1000, 400, false);
MainPanel.setPosition(25, 25, true);
MainPanel.setBorderColor(999);
MainPanel.setBackgroundColor(12222);
MainPanel.setVisible(false);
player.setAttribute("MainPanel", MainPanel);
player.setAttribute("MainPanelID", MainPanel.getID());
UILabel exitbutton = new UILabel();
exitbutton.setClickable(true);
exitbutton.isClickable();
exitbutton.setFontColor(50,999,999,50);
exitbutton.setRichTextEnabled(true);
exitbutton.setFontSize(20);
exitbutton.setText(" X ");
exitbutton.setBorderColor(999);
exitbutton.setPosition(950, 5, false);
MainPanel.addChild(exitbutton);
player.setAttribute("exitbutton", exitbutton);
player.setAttribute("exitbuttonID", exitbutton.getID());
UILabel HealingHeadding = new UILabel();
HealingHeadding.setClickable(true);
HealingHeadding.setText("Healing Interval");
HealingHeadding.setPosition(5, 50, false);
MainPanel.addChild(HealingHeadding);
player.setAttribute("HealingHeadding", HealingHeadding);
player.setAttribute("HealingHeaddingID", HealingHeadding.getID());
UILabel ThirstHeadding = new UILabel();
ThirstHeadding.setClickable(true);
ThirstHeadding.setText("Thirst Interval");
ThirstHeadding.setPosition(5, 100, false);
MainPanel.addChild(ThirstHeadding);
player.setAttribute("ThirstHeadding", ThirstHeadding);
player.setAttribute("ThirstHeaddingID", ThirstHeadding.getID());
UILabel HungerHeadding = new UILabel();
HungerHeadding.setClickable(true);
HungerHeadding.setText("Hunger Interval");
HungerHeadding.setPosition(5, 150, false);
MainPanel.addChild(HungerHeadding);
player.setAttribute("HungerHeadding", HungerHeadding);
player.setAttribute("HungerHeaddingID", HungerHeadding.getID());
UILabel StaminaHeadding = new UILabel();
StaminaHeadding.setClickable(true);
StaminaHeadding.setText("Stamina Interval");
StaminaHeadding.setPosition(5, 200, false);
MainPanel.addChild(StaminaHeadding);
player.setAttribute("StaminaHeadding", StaminaHeadding);
player.setAttribute("StaminaHeaddingID", StaminaHeadding.getID());
UILabel HealingPlusButton = new UILabel();
HealingPlusButton.setClickable(true);
HealingPlusButton.setText(" + ");
HealingPlusButton.setBackgroundColor(999);
HealingPlusButton.setPosition(160, 50, false);
MainPanel.addChild(HealingPlusButton);
player.setAttribute("HealingPlusButton", HealingPlusButton);
player.setAttribute("HealingPlusButtonID", HealingPlusButton.getID());
UILabel ThirstPlusButton = new UILabel();
ThirstPlusButton.setClickable(true);
ThirstPlusButton.setText(" + ");
ThirstPlusButton.setBackgroundColor(999);
ThirstPlusButton.setPosition(160, 100, false);
MainPanel.addChild(ThirstPlusButton);
player.setAttribute("ThirstPlusButton", ThirstPlusButton);
player.setAttribute("ThirstPlusButtonID", ThirstPlusButton.getID());
UILabel HungerPlusButton = new UILabel();
HungerPlusButton.setClickable(true);
HungerPlusButton.setText(" + ");
HungerPlusButton.setBackgroundColor(999);
HungerPlusButton.setPosition(160, 150, false);
MainPanel.addChild(HungerPlusButton);
player.setAttribute("HungerPlusButton", HungerPlusButton);
player.setAttribute("HungerPlusButtonID", HungerPlusButton.getID());
UILabel StaminaPlusButton = new UILabel();
StaminaPlusButton.setClickable(true);
StaminaPlusButton.setText(" + ");
StaminaPlusButton.setBackgroundColor(999);
StaminaPlusButton.setPosition(160, 200, false);
MainPanel.addChild(StaminaPlusButton);
player.setAttribute("StaminaPlusButton", StaminaPlusButton);
player.setAttribute("StaminaPlusButtonID", StaminaPlusButton.getID());
// HealingAmountMinusButton
UILabel HealingAmountMinusButton = new UILabel();
HealingAmountMinusButton.setClickable(true);
HealingAmountMinusButton.setText(" - ");
HealingAmountMinusButton.setBackgroundColor(999);
HealingAmountMinusButton.setPosition(650, 50, false);
MainPanel.addChild(HealingAmountMinusButton);
player.setAttribute("HealingAmountMinusButton", HealingAmountMinusButton);
player.setAttribute("HealingAmountMinusButtonID", HealingAmountMinusButton.getID());
// ThirstAmountMinusButton
UILabel ThirstAmountMinusButton = new UILabel();
ThirstAmountMinusButton.setClickable(true);
ThirstAmountMinusButton.setText(" - ");
ThirstAmountMinusButton.setBackgroundColor(999);
ThirstAmountMinusButton.setPosition(650, 100, false);
MainPanel.addChild(ThirstAmountMinusButton);
player.setAttribute("ThirstAmountMinusButton", ThirstAmountMinusButton);
player.setAttribute("ThirstAmountMinusButtonID", ThirstAmountMinusButton.getID());
// HungerAmountMinusButton
UILabel HungerAmountMinusButton = new UILabel();
HungerAmountMinusButton.setClickable(true);
HungerAmountMinusButton.setText(" - ");
HungerAmountMinusButton.setBackgroundColor(999);
HungerAmountMinusButton.setPosition(650, 150, false);
MainPanel.addChild(HungerAmountMinusButton);
player.setAttribute("HungerAmountMinusButton", HungerAmountMinusButton);
player.setAttribute("HungerAmountMinusButtonID", HungerAmountMinusButton.getID());
// StaminaAmountMinusButton
UILabel StaminaAmountMinusButton = new UILabel();
StaminaAmountMinusButton.setClickable(true);
StaminaAmountMinusButton.setText(" - ");
StaminaAmountMinusButton.setBackgroundColor(999);
StaminaAmountMinusButton.setPosition(650, 200, false);
MainPanel.addChild(StaminaAmountMinusButton);
player.setAttribute("StaminaAmountMinusButton", StaminaAmountMinusButton);
player.setAttribute("StaminaAmountMinusButtonID", StaminaAmountMinusButton.getID());
UILabel HealingAmountPlusButton = new UILabel();
HealingAmountPlusButton.setClickable(true);
HealingAmountPlusButton.setText(" + ");
HealingAmountPlusButton.setBackgroundColor(999);
HealingAmountPlusButton.setPosition(515, 50, false);
MainPanel.addChild(HealingAmountPlusButton);
player.setAttribute("HealingAmountPlusButton", HealingAmountPlusButton);
player.setAttribute("HealingAmountPlusButtonID", HealingAmountPlusButton.getID());
UILabel ThirstAmountPlusButton = new UILabel();
ThirstAmountPlusButton.setClickable(true);
ThirstAmountPlusButton.setText(" + ");
ThirstAmountPlusButton.setBackgroundColor(999);
ThirstAmountPlusButton.setPosition(515, 100, false);
MainPanel.addChild(ThirstAmountPlusButton);
player.setAttribute("ThirstAmountPlusButton", ThirstAmountPlusButton);
player.setAttribute("ThirstAmountPlusButtonID", ThirstAmountPlusButton.getID());
UILabel HungerAmountPlusButton = new UILabel();
HungerAmountPlusButton.setClickable(true);
HungerAmountPlusButton.setText(" + ");
HungerAmountPlusButton.setBackgroundColor(999);
HungerAmountPlusButton.setPosition(515, 150, false);
MainPanel.addChild(HungerAmountPlusButton);
player.setAttribute("HungerAmountPlusButton", HungerAmountPlusButton);
player.setAttribute("HungerAmountPlusButtonID", HungerAmountPlusButton.getID());
UILabel StaminaAmountPlusButton = new UILabel();
StaminaAmountPlusButton.setClickable(true);
StaminaAmountPlusButton.setText(" + ");
StaminaAmountPlusButton.setBackgroundColor(999);
StaminaAmountPlusButton.setPosition(515, 200, false);
MainPanel.addChild(StaminaAmountPlusButton);
player.setAttribute("StaminaAmountPlusButton", StaminaAmountPlusButton);
player.setAttribute("StaminaAmountPlusButtonID", StaminaAmountPlusButton.getID());
UILabel HealingAmountHeadding = new UILabel();
HealingAmountHeadding.setClickable(true);
HealingAmountHeadding.setText("Healing Amount");
HealingAmountHeadding.setPosition(375, 50, false);
MainPanel.addChild(HealingAmountHeadding);
player.setAttribute("HealingAmountHeadding", HealingAmountHeadding);
player.setAttribute("HealingAmountHeaddingID", HealingAmountHeadding.getID());
UILabel ThirstAmountHeadding = new UILabel();
ThirstAmountHeadding.setClickable(true);
ThirstAmountHeadding.setText("Thirst Amount");
ThirstAmountHeadding.setPosition(375, 100, false);
MainPanel.addChild(ThirstAmountHeadding);
player.setAttribute("ThirstAmountHeadding", ThirstAmountHeadding);
player.setAttribute("ThirstAmountHeaddingID", ThirstAmountHeadding.getID());
UILabel HungerAmountHeadding = new UILabel();
HungerAmountHeadding.setClickable(true);
HungerAmountHeadding.setText("Hunger Amount");
HungerAmountHeadding.setPosition(375, 150, false);
MainPanel.addChild(HungerAmountHeadding);
player.setAttribute("HungerAmountHeadding", HungerAmountHeadding);
player.setAttribute("HungerAmountHeaddingID", HungerAmountHeadding.getID());
UILabel StaminaAmountHeadding = new UILabel();
StaminaAmountHeadding.setClickable(true);
StaminaAmountHeadding.setText("Stamina Amount");
StaminaAmountHeadding.setPosition(375, 200, false);
MainPanel.addChild(StaminaAmountHeadding);
player.setAttribute("StaminaAmountHeadding", StaminaAmountHeadding);
player.setAttribute("StaminaAmountHeaddingID", StaminaAmountHeadding.getID());
UILabel HealingMinusButton = new UILabel();
HealingMinusButton.setClickable(true);
HealingMinusButton.setText(" - ");
HealingMinusButton.setBackgroundColor(999);
HealingMinusButton.setPosition(275, 50, false);
MainPanel.addChild(HealingMinusButton);
player.setAttribute("HealingMinusButton", HealingMinusButton);
player.setAttribute("HealingMinusButtonID", HealingMinusButton.getID());
UILabel ThirstMinusButton = new UILabel();
ThirstMinusButton.setClickable(true);
ThirstMinusButton.setText(" - ");
ThirstMinusButton.setBackgroundColor(999);
ThirstMinusButton.setPosition(275, 100, false);
MainPanel.addChild(ThirstMinusButton);
player.setAttribute("ThirstMinusButton", ThirstMinusButton);
player.setAttribute("ThirstMinusButtonID", ThirstMinusButton.getID());
UILabel HungerMinusButton = new UILabel();
HungerMinusButton.setClickable(true);
HungerMinusButton.setText(" - ");
HungerMinusButton.setBackgroundColor(999);
HungerMinusButton.setPosition(275, 150, false);
MainPanel.addChild(HungerMinusButton);
player.setAttribute("HungerMinusButton", HungerMinusButton);
player.setAttribute("HungerMinusButtonID", HungerMinusButton.getID());
UILabel StaminaMinusButton = new UILabel();
StaminaMinusButton.setClickable(true);
StaminaMinusButton.setText(" - ");
StaminaMinusButton.setBackgroundColor(999);
StaminaMinusButton.setPosition(275, 200, false);
MainPanel.addChild(StaminaMinusButton);
player.setAttribute("StaminaMinusButton", StaminaMinusButton);
player.setAttribute("StaminaMinusButtonID", StaminaMinusButton.getID());
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Healing'")) {
int HealingBoostInterval = result.getInt("BoostTimeInterval")/60;
player.setAttribute("HealingBoostInterval", HealingBoostInterval);
UILabel HealingInterval = new UILabel();
HealingInterval.setClickable(true);
HealingInterval.setText("" + player.getAttribute("HealingBoostInterval") + "");
HealingInterval.setPosition(175, 50, false);
MainPanel.addChild(HealingInterval);
player.setAttribute("HealingIntervalID", HealingInterval.getID());
player.setAttribute("HealingInterval", HealingInterval);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Thirst'")) {
int ThirstBoostInterval = result.getInt("BoostTimeInterval")/60;
player.setAttribute("ThirstBoostInterval", ThirstBoostInterval);
UILabel ThirstInterval = new UILabel();
ThirstInterval.setClickable(true);
ThirstInterval.setText("" + player.getAttribute("ThirstBoostInterval") + "");
ThirstInterval.setPosition(175, 100, false);
MainPanel.addChild(ThirstInterval);
player.setAttribute("ThirstIntervalID", ThirstInterval.getID());
player.setAttribute("ThirstInterval", ThirstInterval);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Hunger'")) {
int HungerBoostInterval = result.getInt("BoostTimeInterval")/60;
player.setAttribute("HungerBoostInterval", HungerBoostInterval);
UILabel HungerInterval = new UILabel();
HungerInterval.setClickable(true);
HungerInterval.setText("" + player.getAttribute("HungerBoostInterval") + "");
HungerInterval.setPosition(175, 150, false);
MainPanel.addChild(HungerInterval);
player.setAttribute("HungerIntervalID", HungerInterval.getID());
player.setAttribute("HungerInterval", HungerInterval);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Stamina'")) {
int StaminaBoostInterval = result.getInt("BoostTimeInterval")/60;
player.setAttribute("StaminaBoostInterval", StaminaBoostInterval);
UILabel StaminaInterval = new UILabel();
StaminaInterval.setClickable(true);
StaminaInterval.setText("" + player.getAttribute("StaminaBoostInterval") + "");
StaminaInterval.setPosition(175, 200, false);
MainPanel.addChild(StaminaInterval);
player.setAttribute("StaminaIntervalID", StaminaInterval.getID());
player.setAttribute("StaminaInterval", StaminaInterval);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Healing'")) {
int HealingBoostAmount = result.getInt("BoostAmount");
player.setAttribute("HealingBoostAmount", HealingBoostAmount);
UILabel HealingAmount = new UILabel();
HealingAmount.setClickable(true);
HealingAmount.setText("" + player.getAttribute("HealingBoostAmount") + "");
HealingAmount.setPosition(530, 50, false);
MainPanel.addChild(HealingAmount);
player.setAttribute("HealingAmountID", HealingAmount.getID());
player.setAttribute("HealingAmount", HealingAmount);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Thirst'")) {
int ThirstBoostAmount = result.getInt("BoostAmount");
player.setAttribute("ThirstBoostAmount", ThirstBoostAmount);
UILabel ThirstAmount = new UILabel();
ThirstAmount.setClickable(true);
ThirstAmount.setText("" + player.getAttribute("ThirstBoostAmount") + "");
ThirstAmount.setPosition(530, 100, false);
MainPanel.addChild(ThirstAmount);
player.setAttribute("ThirstAmountID", ThirstAmount.getID());
player.setAttribute("ThirstAmount", ThirstAmount);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Hunger'")) {
int HungerBoostAmount = result.getInt("BoostAmount");
player.setAttribute("HungerBoostAmount", HungerBoostAmount);
UILabel HungerAmount = new UILabel();
HungerAmount.setClickable(true);
HungerAmount.setText("" + player.getAttribute("HungerBoostAmount") + "");
HungerAmount.setPosition(530, 150, false);
MainPanel.addChild(HungerAmount);
player.setAttribute("HungerAmountID", HungerAmount.getID());
player.setAttribute("HungerAmount", HungerAmount);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Stamina'")) {
int StaminaBoostAmount = result.getInt("BoostAmount");
player.setAttribute("StaminaBoostAmount", StaminaBoostAmount);
UILabel StaminaAmount = new UILabel();
StaminaAmount.setClickable(true);
StaminaAmount.setText("" + player.getAttribute("StaminaBoostAmount") + "");
StaminaAmount.setPosition(530, 200, false);
MainPanel.addChild(StaminaAmount);
player.setAttribute("StaminaAmountID", StaminaAmount.getID());
player.setAttribute("StaminaAmount", StaminaAmount);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Healing'")) {
HealingTimeInterval = result.getInt("BoostTimeInterval");
Timer HealingTimer = new Timer(HealingTimeInterval, 0.0F, 100, null);
Runnable HealingTimerTask = () -> {
SoundAsset swooshsoundfile = SoundAsset.loadFromFile(getPath() + "/assets/1.wav");
player.playSound(swooshsoundfile);
AssetBundle bundle = AssetBundle.loadFromFile(getPath() + "/assets/charactereffects.bundle");
PrefabAsset asset = PrefabAsset.loadFromAssetBundle(bundle, "Healing.prefab");
Prefab Healing = new Prefab(asset);
Healing.setLayer(Layer.DEFAULT);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Healing'")) {
player.setHealth(result.getInt("BoostAmount"));
} catch (SQLException ex) {
Logger.getLogger(Boost.class.getName()).log(Level.SEVERE, null, ex);
Healing.moveToLocalPosition(player.getPosition(), 1000);
player.addGameObject(Healing);
// update players location so the effect can follow
Timer UpdateLocation = new Timer(0.05F, 0.0F, 199, null);
Runnable UpdateLocationTask = () -> {
Healing.moveToLocalPosition(player.getPosition(), 1000);
UpdateLocation.setTask(UpdateLocationTask);
// ----------------------------------------------------
// remove the Healing effect after 10sec
Timer RemoveHealing = new Timer(10.0F, 0.0F, 0, null);
Runnable RemoveHealingTask = () -> {
player.removeGameObject(Healing);
RemoveHealing.setTask(RemoveHealingTask);
// ------------------------------------------------
player.sendYellMessage("Healing Boost", 5, true);
HealingTimer.setTask(HealingTimerTask);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Thirst'")) {
ThirstTimeInterval = result.getInt("BoostTimeInterval");
Timer ThirstTimer = new Timer(ThirstTimeInterval, 0.0F, 100, null);
Runnable ThirstTimerTask = () -> {
SoundAsset soundfile = SoundAsset.loadFromFile(getPath() + "/assets/2.wav");
player.playSound(soundfile);
AssetBundle bundle = AssetBundle.loadFromFile(getPath() + "/assets/charactereffects.bundle");
PrefabAsset asset = PrefabAsset.loadFromAssetBundle(bundle, "Thirst.prefab");
Prefab Thirst = new Prefab(asset);
Thirst.setLayer(Layer.DEFAULT);
Thirst.moveToLocalPosition(player.getPosition(), 1000);
Timer timer5sec = new Timer(0.05F, 0.0F, 199, null);
Runnable timerTask5sec = () -> {
Thirst.moveToLocalPosition(player.getPosition(), 1000);
timer5sec.setTask(timerTask5sec);
player.addGameObject(Thirst);
Timer timer10sec = new Timer(10.0F, 0.0F, 0, null);
Runnable timerTask10sec = () -> {
player.removeGameObject(Thirst);
timer10sec.setTask(timerTask10sec);
player.sendYellMessage("Thirst Boost", 5, true);
ThirstTimer.setTask(ThirstTimerTask);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Hunger'")) {
HungerTimeInterval = result.getInt("BoostTimeInterval");
Timer HungerTimer = new Timer(HungerTimeInterval, 0.0F, 100, null);
Runnable HungerTimerTask = () -> {
SoundAsset soundfile = SoundAsset.loadFromFile(getPath() + "/assets/3.wav");
player.playSound(soundfile);
AssetBundle bundle = AssetBundle.loadFromFile(getPath() + "/assets/charactereffects.bundle");
PrefabAsset asset = PrefabAsset.loadFromAssetBundle(bundle, "Hunger.prefab");
Prefab Hunger = new Prefab(asset);
Hunger.setLayer(Layer.DEFAULT);
Hunger.moveToLocalPosition(player.getPosition(), 1000);
Timer timer5sec = new Timer(0.05F, 0.0F, 199, null);
Runnable timerTask5sec = () -> {
Hunger.moveToLocalPosition(player.getPosition(), 1000);
timer5sec.setTask(timerTask5sec);
player.addGameObject(Hunger);
Timer timer10sec = new Timer(10.0F, 0.0F, 0, null);
Runnable timerTask10sec = () -> {
player.removeGameObject(Hunger);
timer10sec.setTask(timerTask10sec);
player.sendYellMessage("Hunger Boost", 5, true);
HungerTimer.setTask(HungerTimerTask);
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Stamina'")) {
StaminaTimeInterval = result.getInt("BoostTimeInterval");
Timer StaminaTimer = new Timer(StaminaTimeInterval, 0.0F, 100, null);
Runnable StaminaTimerTask = () -> {
SoundAsset soundfile = SoundAsset.loadFromFile(getPath() + "/assets/4.wav");
player.playSound(soundfile);
AssetBundle bundle = AssetBundle.loadFromFile(getPath() + "/assets/charactereffects.bundle");
PrefabAsset asset = PrefabAsset.loadFromAssetBundle(bundle, "Stamina.prefab");
Prefab Stamina = new Prefab(asset);
Stamina.setLayer(Layer.DEFAULT);
Stamina.moveToLocalPosition(player.getPosition(), 1000);
Timer timer5sec = new Timer(0.05F, 0.0F, 199, null);
Runnable timerTask5sec = () -> {
Stamina.moveToLocalPosition(player.getPosition(), 1000);
timer5sec.setTask(timerTask5sec);
player.addGameObject(Stamina);
Timer timer10sec = new Timer(10.0F, 0.0F, 0, null);
Runnable timerTask10sec = () -> {
player.removeGameObject(Stamina);
timer10sec.setTask(timerTask10sec);
player.sendYellMessage("Stamina Boost", 5, true);
StaminaTimer.setTask(StaminaTimerTask);
public void onPlayerCommandEvent(PlayerCommandEvent evt) throws SQLException {
String[] cmd = evt.getCommand().split(" ");
Player player = evt.getPlayer();
String StaminaPlusButtonID = null;
if (cmd[0].equalsIgnoreCase("/Boost")) {
// let the player use the mouse
player.setMouseCursorVisible(true);
UIElement MainPanel = (UIElement) player.getAttribute("MainPanel");
MainPanel.setVisible(true);
public void onPlayerUIEClick(PlayerUIElementClickEvent evt) throws SQLException {
Player player = evt.getPlayer();
if (player.getAttribute("exitbuttonID") == null){return;}
UILabel buttons = (UILabel) evt.getUIElement();
int ButtonIDs = buttons.getID();
int exitbuttonID = (int) player.getAttribute("exitbuttonID");
int HealingPlusButtonID = (int) player.getAttribute("HealingPlusButtonID");
int ThirstPlusButtonID = (int) player.getAttribute("ThirstPlusButtonID");
int HungerPlusButtonID = (int) player.getAttribute("HungerPlusButtonID");
int StaminaPlusButtonID = (int) player.getAttribute("StaminaPlusButtonID");
int HealingMinusButtonID = (int) player.getAttribute("HealingMinusButtonID");
int ThirstMinusButtonID = (int) player.getAttribute("ThirstMinusButtonID");
int HungerMinusButtonID = (int) player.getAttribute("HungerMinusButtonID");
int StaminaMinusButtonID = (int) player.getAttribute("StaminaMinusButtonID");
int HealingAmountPlusButtonID = (int) player.getAttribute("HealingAmountPlusButtonID");
int ThirstAmountPlusButtonID = (int) player.getAttribute("ThirstAmountPlusButtonID");
int HungerAmountPlusButtonID = (int) player.getAttribute("HungerAmountPlusButtonID");
int StaminaAmountPlusButtonID = (int) player.getAttribute("StaminaAmountPlusButtonID");
int HealingAmountMinusButtonID = (int) player.getAttribute("HealingAmountMinusButtonID");
int ThirstAmountMinusButtonID = (int) player.getAttribute("ThirstAmountMinusButtonID");
int HungerAmountMinusButtonID = (int) player.getAttribute("HungerAmountMinusButtonID");
int StaminaAmountMinusButtonID = (int) player.getAttribute("StaminaAmountMinusButtonID");
UILabel HealingInterval = (UILabel) player.getAttribute("HealingInterval");
UILabel ThirstInterval = (UILabel) player.getAttribute("ThirstInterval");
UILabel HungerInterval = (UILabel) player.getAttribute("HungerInterval");
UILabel StaminaInterval = (UILabel) player.getAttribute("StaminaInterval");
UILabel HealingAmount = (UILabel) player.getAttribute("HealingAmount");
UILabel ThirstAmount = (UILabel) player.getAttribute("ThirstAmount");
UILabel HungerAmount = (UILabel) player.getAttribute("HungerAmount");
UILabel StaminaAmount = (UILabel) player.getAttribute("StaminaAmount");
UIElement MainPanel = (UIElement) player.getAttribute("MainPanel");
// exit button close the main menu
if (ButtonIDs == exitbuttonID)
player.setMouseCursorVisible(false);
MainPanel.setVisible(false);
if (ButtonIDs == HealingPlusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Healing'")) {
int HealingBoostInterval = result.getInt("BoostTimeInterval");
HealingBoostInterval = HealingBoostInterval +60;
database.executeUpdate("UPDATE Boosts SET BoostTimeInterval = '" + HealingBoostInterval + "' WHERE BoostType = 'Healing'");
player.setAttribute("HealingBoostInterval", HealingBoostInterval);
HealingInterval.setText("" + HealingBoostInterval /60 + "");
if (ButtonIDs == ThirstPlusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Thirst'")) {
int ThirstTimeInterval = result.getInt("BoostTimeInterval");
ThirstTimeInterval = ThirstTimeInterval +60;
database.executeUpdate("UPDATE Boosts SET BoostTimeInterval = '" + ThirstTimeInterval + "' WHERE BoostType = 'Thirst'");
player.setAttribute("ThirstInterval", ThirstInterval);
ThirstInterval.setText("" + ThirstTimeInterval /60 + "");
if (ButtonIDs == HungerPlusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Hunger'")) {
int HungerTimeInterval = result.getInt("BoostTimeInterval");
HungerTimeInterval = HungerTimeInterval +60;
database.executeUpdate("UPDATE Boosts SET BoostTimeInterval = '" + HungerTimeInterval + "' WHERE BoostType = 'Hunger'");
player.setAttribute("HungerTimeInterval", HungerTimeInterval);
HungerInterval.setText("" + HungerTimeInterval /60 + "");
if (ButtonIDs == StaminaPlusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Stamina'")) {
int StaminaTimeInterval = result.getInt("BoostTimeInterval");
StaminaTimeInterval = StaminaTimeInterval +60;
database.executeUpdate("UPDATE Boosts SET BoostTimeInterval = '" + StaminaTimeInterval + "' WHERE BoostType = 'Stamina'");
player.setAttribute("StaminaTimeInterval", StaminaTimeInterval);
StaminaInterval.setText("" + StaminaTimeInterval /60 + "");
if (ButtonIDs == HealingMinusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Healing'")) {
int HealingTimeInterval = result.getInt("BoostTimeInterval");
HealingTimeInterval = HealingTimeInterval -60;
database.executeUpdate("UPDATE Boosts SET BoostTimeInterval = '" + HealingTimeInterval + "' WHERE BoostType = 'Healing'");
player.setAttribute("HealingTimeInterval", HealingTimeInterval);
HealingInterval.setText("" + HealingTimeInterval /60 + "");
if (ButtonIDs == ThirstMinusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Thirst'")) {
int ThirstTimeInterval = result.getInt("BoostTimeInterval");
ThirstTimeInterval = ThirstTimeInterval -60;
database.executeUpdate("UPDATE Boosts SET BoostTimeInterval = '" + ThirstTimeInterval + "' WHERE BoostType = 'Thirst'");
player.setAttribute("ThirstTimeInterval", ThirstTimeInterval);
ThirstInterval.setText("" + ThirstTimeInterval /60 + "");
if (ButtonIDs == HungerMinusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Hunger'")) {
int HungerTimeInterval = result.getInt("BoostTimeInterval");
HungerTimeInterval = HungerTimeInterval -60;
database.executeUpdate("UPDATE Boosts SET BoostTimeInterval = '" + HungerTimeInterval + "' WHERE BoostType = 'Hunger'");
player.setAttribute("HungerTimeInterval", HungerTimeInterval);
HungerInterval.setText("" + HungerTimeInterval /60 + "");
if (ButtonIDs == StaminaMinusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Stamina'")) {
int StaminaTimeInterval = result.getInt("BoostTimeInterval");
StaminaTimeInterval = StaminaTimeInterval -60;
database.executeUpdate("UPDATE Boosts SET BoostTimeInterval = '" + StaminaTimeInterval + "' WHERE BoostType = 'Stamina'");
player.setAttribute("StaminaTimeInterval", StaminaTimeInterval);
StaminaInterval.setText("" + StaminaTimeInterval /60 + "");
if (ButtonIDs == HealingAmountPlusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Healing'")) {
int HealingBoostAmount = result.getInt("BoostAmount");
HealingBoostAmount = HealingBoostAmount +1;
database.executeUpdate("UPDATE Boosts SET BoostAmount = '" + HealingBoostAmount + "' WHERE BoostType = 'Healing'");
player.setAttribute("StaminaBoostAmount", HealingBoostAmount);
HealingAmount.setText("" + HealingBoostAmount + "");
if (ButtonIDs == ThirstAmountPlusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Thirst'")) {
int ThirstBoostAmount = result.getInt("BoostAmount");
ThirstBoostAmount = ThirstBoostAmount +1;
database.executeUpdate("UPDATE Boosts SET BoostAmount = '" + ThirstBoostAmount + "' WHERE BoostType = 'Thirst'");
player.setAttribute("ThirstBoostAmount", ThirstBoostAmount);
ThirstAmount.setText("" + ThirstBoostAmount + "");
if (ButtonIDs == HungerAmountPlusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Hunger'")) {
int HungerBoostAmount = result.getInt("BoostAmount");
HungerBoostAmount = HungerBoostAmount +1;
database.executeUpdate("UPDATE Boosts SET BoostAmount = '" + HungerBoostAmount + "' WHERE BoostType = 'Hunger'");
player.setAttribute("HungerBoostAmount", HungerBoostAmount);
HungerAmount.setText("" + HungerBoostAmount + "");
if (ButtonIDs == StaminaAmountPlusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Stamina'")) {
int StaminaBoostAmount = result.getInt("BoostAmount");
StaminaBoostAmount = StaminaBoostAmount +1;
database.executeUpdate("UPDATE Boosts SET BoostAmount = '" + StaminaBoostAmount + "' WHERE BoostType = 'Stamina'");
player.setAttribute("StaminaBoostAmount", StaminaBoostAmount);
StaminaAmount.setText("" + StaminaBoostAmount + "");
if (ButtonIDs == HealingAmountMinusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Healing'")) {
int HealingBoostAmount = result.getInt("BoostAmount");
HealingBoostAmount = HealingBoostAmount -1;
database.executeUpdate("UPDATE Boosts SET BoostAmount = '" + HealingBoostAmount + "' WHERE BoostType = 'Healing'");
player.setAttribute("StaminaBoostAmount", HealingBoostAmount);
HealingAmount.setText("" + HealingBoostAmount + "");
if (ButtonIDs == ThirstAmountMinusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Thirst'")) {
int ThirstBoostAmount = result.getInt("BoostAmount");
ThirstBoostAmount = ThirstBoostAmount -1;
database.executeUpdate("UPDATE Boosts SET BoostAmount = '" + ThirstBoostAmount + "' WHERE BoostType = 'Thirst'");
player.setAttribute("ThirstBoostAmount", ThirstBoostAmount);
ThirstAmount.setText("" + ThirstBoostAmount + "");
if (ButtonIDs == HungerAmountMinusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Hunger'")) {
int HungerBoostAmount = result.getInt("BoostAmount");
HungerBoostAmount = HungerBoostAmount -1;
database.executeUpdate("UPDATE Boosts SET BoostAmount = '" + HungerBoostAmount + "' WHERE BoostType = 'Hunger'");
player.setAttribute("HungerBoostAmount", HungerBoostAmount);
HungerAmount.setText("" + HungerBoostAmount + "");
if (ButtonIDs == StaminaAmountMinusButtonID)
try ( ResultSet result = database.executeQuery("SELECT * FROM `Boosts` WHERE `BoostType` = 'Stamina'")) {
int StaminaBoostAmount = result.getInt("BoostAmount");
StaminaBoostAmount = StaminaBoostAmount -1;
database.executeUpdate("UPDATE Boosts SET BoostAmount = '" + StaminaBoostAmount + "' WHERE BoostType = 'Stamina'");
player.setAttribute("StaminaBoostAmount", StaminaBoostAmount);
StaminaAmount.setText("" + StaminaBoostAmount + "");