From 00c96d42c508698b0e075bf91bcb5835b4be6fb0 Mon Sep 17 00:00:00 2001 From: Aaron Duran <57845320+duranaaron@users.noreply.github.com> Date: Tue, 30 Jan 2024 17:49:32 +0100 Subject: [PATCH] Revert "Phones feature" --- build.gradle.kts | 8 +- configuration/feather.toml | 7 - configuration/feather_de.toml | 47 +++++ configuration/feather_fr.toml | 47 +++++ configuration/feather_nl.toml | 47 +++++ configuration/messages_de.toml | 76 ++++++++ configuration/messages_de_de.toml | 76 ++++++++ configuration/messages_de_fr.toml | 76 ++++++++ configuration/messages_de_nl.toml | 76 ++++++++ configuration/messages_fr.toml | 76 ++++++++ configuration/messages_fr_de.toml | 76 ++++++++ configuration/messages_fr_fr.toml | 76 ++++++++ configuration/messages_fr_nl.toml | 76 ++++++++ configuration/messages_nl.toml | 76 ++++++++ configuration/messages_nl_de.toml | 76 ++++++++ configuration/messages_nl_fr.toml | 76 ++++++++ configuration/messages_nl_nl.toml | 76 ++++++++ src/main/java/cc/ddev/feather/Server.java | 15 +- .../ddev/feather/api/banking/BankUtils.java | 2 +- .../cc/ddev/feather/api/config/Config.java | 10 -- .../feather/api/economy/EconomyManager.java | 17 +- .../cc/ddev/feather/api/objects/Phone.java | 67 ------- .../feather/api/objects/PhoneContact.java | 28 --- .../feather/api/objects/PhoneMessage.java | 68 ------- .../ddev/feather/api/phone/PhoneManager.java | 169 ------------------ .../api/phone/PhoneMessageManager.java | 4 - .../feather/api/playerdata/PlayerManager.java | 7 +- .../feather/api/sidebar/SidebarManager.java | 5 +- .../subcommands/EconomySetCommand.java | 9 +- .../feather/command/essential/OpCommand.java | 12 +- .../feather/command/phone/PhoneCommand.java | 15 -- .../phone/subcommands/PhoneGetCommand.java | 4 - .../subcommands/PhoneSetCreditCommand.java | 4 - .../ddev/feather/database/StormDatabase.java | 3 - .../database/models/PhoneContactsModel.java | 19 -- .../database/models/PhoneMessagesModel.java | 25 --- .../feather/database/models/PhoneModel.java | 24 --- .../listener/player/PlayerChatListener.java | 10 +- .../player/PlayerDisconnectListener.java | 11 +- .../player/PlayerInteractListener.java | 16 -- .../listener/player/PlayerLoginListener.java | 1 - .../listener/player/PlayerSpawnListener.java | 47 ++--- .../cc/ddev/feather/phone/PhoneInventory.java | 4 - .../cc/ddev/feather/world/WorldManager.java | 9 +- 44 files changed, 1133 insertions(+), 540 deletions(-) create mode 100644 configuration/feather_de.toml create mode 100644 configuration/feather_fr.toml create mode 100644 configuration/feather_nl.toml create mode 100644 configuration/messages_de.toml create mode 100644 configuration/messages_de_de.toml create mode 100644 configuration/messages_de_fr.toml create mode 100644 configuration/messages_de_nl.toml create mode 100644 configuration/messages_fr.toml create mode 100644 configuration/messages_fr_de.toml create mode 100644 configuration/messages_fr_fr.toml create mode 100644 configuration/messages_fr_nl.toml create mode 100644 configuration/messages_nl.toml create mode 100644 configuration/messages_nl_de.toml create mode 100644 configuration/messages_nl_fr.toml create mode 100644 configuration/messages_nl_nl.toml delete mode 100644 src/main/java/cc/ddev/feather/api/objects/Phone.java delete mode 100644 src/main/java/cc/ddev/feather/api/objects/PhoneContact.java delete mode 100644 src/main/java/cc/ddev/feather/api/objects/PhoneMessage.java delete mode 100644 src/main/java/cc/ddev/feather/api/phone/PhoneManager.java delete mode 100644 src/main/java/cc/ddev/feather/api/phone/PhoneMessageManager.java delete mode 100644 src/main/java/cc/ddev/feather/command/phone/PhoneCommand.java delete mode 100644 src/main/java/cc/ddev/feather/command/phone/subcommands/PhoneGetCommand.java delete mode 100644 src/main/java/cc/ddev/feather/command/phone/subcommands/PhoneSetCreditCommand.java delete mode 100644 src/main/java/cc/ddev/feather/database/models/PhoneContactsModel.java delete mode 100644 src/main/java/cc/ddev/feather/database/models/PhoneMessagesModel.java delete mode 100644 src/main/java/cc/ddev/feather/database/models/PhoneModel.java delete mode 100644 src/main/java/cc/ddev/feather/listener/player/PlayerInteractListener.java delete mode 100644 src/main/java/cc/ddev/feather/phone/PhoneInventory.java diff --git a/build.gradle.kts b/build.gradle.kts index cf617c0..d03d6c5 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,7 +16,7 @@ repositories { } dependencies { - implementation("dev.hollowcube:minestom-ce:002dcc2745") + implementation("dev.hollowcube:minestom-ce:cf4a2d134e") implementation("com.github.DuranDevelopment:instanceguard:1c50091bc9") { exclude(group = "dev.hollowcube", module = "minestom-ce") } @@ -31,10 +31,10 @@ dependencies { } */ - implementation("com.zaxxer:HikariCP:5.1.0") + implementation("com.zaxxer:HikariCP:5.0.1") implementation("com.github.simplix-softworks:simplixstorage:3.2.7") - implementation("net.kyori:adventure-text-minimessage:4.15.0") - implementation("com.github.Mindgamesnl:storm:e1f961b480") + implementation("net.kyori:adventure-text-minimessage:4.14.0") + implementation("com.github.Mindgamesnl:storm:prod125") implementation("mysql:mysql-connector-java:8.0.33") /* Adding drivers for MySQL and SQLite */ implementation("org.xerial:sqlite-jdbc:3.45.0.0") compileOnly("junit:junit:4.13.2") diff --git a/configuration/feather.toml b/configuration/feather.toml index 9cc5429..8b6ed44 100644 --- a/configuration/feather.toml +++ b/configuration/feather.toml @@ -57,10 +57,3 @@ starting_balance = 1000 days = 30 [plots.calculate] price_formula = ' * 32' - -[phone] - default_credit = 0.0 - message_costs = 2.0 - items = [ - 'minecraft:blaze_powder' - ] diff --git a/configuration/feather_de.toml b/configuration/feather_de.toml new file mode 100644 index 0000000..3049bb5 --- /dev/null +++ b/configuration/feather_de.toml @@ -0,0 +1,47 @@ +messages = { } + +[server] +max_players = 100 +description = "A Feather Server" +host = "0.0.0.0" +port = 25_565 +online_mode = true + +[database] +type = "mysql" +username = "root" +password = "" +database = "feather" +host = "127.0.0.1" +port = 3_306 + +[spawn] +spawn_on_join = true +send_join_message = true +world = "demo" +x = "7.5" +y = -24 +z = "-3.5" + +[player.default] +prefix = "Wanderer" +prefix_color = "" +level = 1 +city_color = "" +chat_color = "" + +[chat] +format = " : " +enabled = true + + [chat.radius] + enabled = true + radius = 100 + MessageWhenNobodyInRange = false + +[sidebar] +enabled = true +title = "" + +[economy] +starting_balance = 1_000 diff --git a/configuration/feather_fr.toml b/configuration/feather_fr.toml new file mode 100644 index 0000000..3049bb5 --- /dev/null +++ b/configuration/feather_fr.toml @@ -0,0 +1,47 @@ +messages = { } + +[server] +max_players = 100 +description = "A Feather Server" +host = "0.0.0.0" +port = 25_565 +online_mode = true + +[database] +type = "mysql" +username = "root" +password = "" +database = "feather" +host = "127.0.0.1" +port = 3_306 + +[spawn] +spawn_on_join = true +send_join_message = true +world = "demo" +x = "7.5" +y = -24 +z = "-3.5" + +[player.default] +prefix = "Wanderer" +prefix_color = "" +level = 1 +city_color = "" +chat_color = "" + +[chat] +format = " : " +enabled = true + + [chat.radius] + enabled = true + radius = 100 + MessageWhenNobodyInRange = false + +[sidebar] +enabled = true +title = "" + +[economy] +starting_balance = 1_000 diff --git a/configuration/feather_nl.toml b/configuration/feather_nl.toml new file mode 100644 index 0000000..3049bb5 --- /dev/null +++ b/configuration/feather_nl.toml @@ -0,0 +1,47 @@ +messages = { } + +[server] +max_players = 100 +description = "A Feather Server" +host = "0.0.0.0" +port = 25_565 +online_mode = true + +[database] +type = "mysql" +username = "root" +password = "" +database = "feather" +host = "127.0.0.1" +port = 3_306 + +[spawn] +spawn_on_join = true +send_join_message = true +world = "demo" +x = "7.5" +y = -24 +z = "-3.5" + +[player.default] +prefix = "Wanderer" +prefix_color = "" +level = 1 +city_color = "" +chat_color = "" + +[chat] +format = " : " +enabled = true + + [chat.radius] + enabled = true + radius = 100 + MessageWhenNobodyInRange = false + +[sidebar] +enabled = true +title = "" + +[economy] +starting_balance = 1_000 diff --git a/configuration/messages_de.toml b/configuration/messages_de.toml new file mode 100644 index 0000000..1caed40 --- /dev/null +++ b/configuration/messages_de.toml @@ -0,0 +1,76 @@ +language = "en" +invalid_arguments = "You provided invalid arguments for this command." +invalid_username = "That username is invalid." +not_online = "That player is not online." +no_permission = "You don't have permission to use this command." +fly_on = "Fly mode has been enabled!" +fly_off = "Fly mode has been disabled!" + +[join] +enabled = true +message = " joined the game" + +[leave] +enabled = true +message = " left the game" + +[join_title] +title = "Welcome to" +subtitle = "" + +[mtworldcmd.add] +success = "Succesfully enabled Feather in this world!" + +[banking] +frozen = "This account is frozen, you can no longer withdraw or deposit money!" + + [banking.selector] + title = "Select the account type:" + + [banking.selector.account] + title = "Select the account:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Government" + savings = "Savings" + private = "Private" + business = "Business" + no_business_accounts = "You don't have any Business accounts!" + no_savings_accounts = "You don't have any Savings accounts!" + + [banking.menu] + title = "Total value: " + item_lore = "This piece of money has a %newline%value of ." + + [banking.money] + lore = "Official Minetopia banknote!" + insufficient_balance = "There is not enough money in this account" + is_fake_money = "You have counterfeit money with you! We are currently unable to accept money!" + + [banking.money.withdraw] + inventory_full = "You can't withdraw money when your inventory is full!" + private = "You have withdrawn from 's account" + savings = "You have withdrawn from 's savings account" + business = "You have withdrawn from 's business account" + government = "You have withdrawn from 's government account" + + [banking.money.deposit] + private = "You have deposited to 's account" + savings = "You have deposited to 's savings account" + business = "You have deposited to 's business account" + government = "You have deposited to 's government account" + + [banking.nobankingpermission] + deposit = "You only have withdrawal rights for the account ! Unfortunately you cannot deposit money." + +[bankaccountcmd] +id_does_not_exist = "There is no bankaccount with this ID." +invalid_bankpermission = "ERROR: Invalid bankpermission, valid permissions are ." + + [bankaccountcmd.adduser] + success = "Successfully added player to this bankaccount." + already_added = "The player has already been added to this bankaccount." + +[atm] +require_card = "You need to hold a debit card in your hand!" diff --git a/configuration/messages_de_de.toml b/configuration/messages_de_de.toml new file mode 100644 index 0000000..1083d5c --- /dev/null +++ b/configuration/messages_de_de.toml @@ -0,0 +1,76 @@ +language = "en" +invalid_arguments = "You provided invalid arguments for this command." +invalid_username = "That username is invalid." +not_online = "That player is not online." +no_permission = "You don't have permission to use this command." +fly_on = "Fly mode has been enabled!" +fly_off = "Fly mode has been disabled!" + +[join] +enabled = true +message = "&7 joined the game" + +[leave] +enabled = true +message = "&7 left the game" + +[join_title] +title = "Welcome to" +subtitle = "" + +[mtworldcmd.add] +success = "Succesfully enabled Feather in this world!" + +[banking] +frozen = "This account is frozen, you can no longer withdraw or deposit money!" + + [banking.selector] + title = "Select the account type:" + + [banking.selector.account] + title = "Select the account:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Government" + savings = "Savings" + private = "Private" + business = "Business" + no_business_accounts = "You don't have any Business accounts!" + no_savings_accounts = "You don't have any Savings accounts!" + + [banking.menu] + title = "Total value: " + item_lore = "This piece of money has a %newline%value of ." + + [banking.money] + lore = "Official Minetopia banknote!" + insufficient_balance = "There is not enough money in this account" + is_fake_money = "You have counterfeit money with you! We are currently unable to accept money!" + + [banking.money.withdraw] + inventory_full = "You can't withdraw money when your inventory is full!" + private = "You have withdrawn from 's account" + savings = "You have withdrawn from 's savings account" + business = "You have withdrawn from 's business account" + government = "You have withdrawn from 's government account" + + [banking.money.deposit] + private = "You have deposited to 's account" + savings = "You have deposited to 's savings account" + business = "You have deposited to 's business account" + government = "You have deposited to 's government account" + + [banking.nobankingpermission] + deposit = "You only have withdrawal rights for the account ! Unfortunately you cannot deposit money." + +[bankaccountcmd] +id_does_not_exist = "There is no bankaccount with this ID." +invalid_bankpermission = "ERROR: Invalid bankpermission, valid permissions are ." + + [bankaccountcmd.adduser] + success = "Successfully added player to this bankaccount." + already_added = "The player has already been added to this bankaccount." + +[atm] +require_card = "You need to hold a debit card in your hand!" diff --git a/configuration/messages_de_fr.toml b/configuration/messages_de_fr.toml new file mode 100644 index 0000000..1083d5c --- /dev/null +++ b/configuration/messages_de_fr.toml @@ -0,0 +1,76 @@ +language = "en" +invalid_arguments = "You provided invalid arguments for this command." +invalid_username = "That username is invalid." +not_online = "That player is not online." +no_permission = "You don't have permission to use this command." +fly_on = "Fly mode has been enabled!" +fly_off = "Fly mode has been disabled!" + +[join] +enabled = true +message = "&7 joined the game" + +[leave] +enabled = true +message = "&7 left the game" + +[join_title] +title = "Welcome to" +subtitle = "" + +[mtworldcmd.add] +success = "Succesfully enabled Feather in this world!" + +[banking] +frozen = "This account is frozen, you can no longer withdraw or deposit money!" + + [banking.selector] + title = "Select the account type:" + + [banking.selector.account] + title = "Select the account:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Government" + savings = "Savings" + private = "Private" + business = "Business" + no_business_accounts = "You don't have any Business accounts!" + no_savings_accounts = "You don't have any Savings accounts!" + + [banking.menu] + title = "Total value: " + item_lore = "This piece of money has a %newline%value of ." + + [banking.money] + lore = "Official Minetopia banknote!" + insufficient_balance = "There is not enough money in this account" + is_fake_money = "You have counterfeit money with you! We are currently unable to accept money!" + + [banking.money.withdraw] + inventory_full = "You can't withdraw money when your inventory is full!" + private = "You have withdrawn from 's account" + savings = "You have withdrawn from 's savings account" + business = "You have withdrawn from 's business account" + government = "You have withdrawn from 's government account" + + [banking.money.deposit] + private = "You have deposited to 's account" + savings = "You have deposited to 's savings account" + business = "You have deposited to 's business account" + government = "You have deposited to 's government account" + + [banking.nobankingpermission] + deposit = "You only have withdrawal rights for the account ! Unfortunately you cannot deposit money." + +[bankaccountcmd] +id_does_not_exist = "There is no bankaccount with this ID." +invalid_bankpermission = "ERROR: Invalid bankpermission, valid permissions are ." + + [bankaccountcmd.adduser] + success = "Successfully added player to this bankaccount." + already_added = "The player has already been added to this bankaccount." + +[atm] +require_card = "You need to hold a debit card in your hand!" diff --git a/configuration/messages_de_nl.toml b/configuration/messages_de_nl.toml new file mode 100644 index 0000000..2b35322 --- /dev/null +++ b/configuration/messages_de_nl.toml @@ -0,0 +1,76 @@ +language = "nl" +invalid_arguments = "Je hebt ongeldige argumenten opgegeven voor dit commando." +invalid_username = "Deze gebruikersnaam is ongeldig." +not_online = "Deze speler is niet online." +no_permission = "Je hebt geen permissie om dit commando te gebruiken." +fly_on = "Vliegmodus is ingeschakeld!" +fly_off = "Vliegmodus is uitgeschakeld!" + +[join] +enabled = true +message = "&7 is de server binnengekomen" + +[leave] +enabled = true +message = "&7 heeft de server verlaten" + +[join_title] +title = "Welkom in" +subtitle = "" + +[mtworldcmd.add] +success = "Feather is succesvol aangezet in deze wereld!" + +[banking] +frozen = "Deze rekening is bevroren, je kan geen geld meer opnemen of storten!" + + [banking.selector] + title = "Selecteer het type rekening:" + + [banking.selector.account] + title = "Selecteer de rekening:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Overheid" + savings = "Sparen" + private = "Privé" + business = "Bedrijf" + no_business_accounts = "Je hebt geen Bedrijfsrekeningen!" + no_savings_accounts = "Je hebt geen Spaar rekeningen!" + + [banking.menu] + title = "Totale waarde: " + item_lore = "Dit geldstuk heeft een %newline%waarde van ." + + [banking.money] + lore = "Officieel Minetopia bankbiljet!" + insufficient_balance = "Er staat niet genoeg geld op deze rekening" + is_fake_money = "Je hebt vervalste geld bij je! We kunnen op dit moment geen geld accepteren!" + + [banking.money.withdraw] + inventory_full = "Je kan geen geld opnemen wanneer je inventory vol is!" + private = "Je hebt opgenomen van 's rekening" + savings = "Je hebt opgenomen van 's spaarrekening" + business = "Je hebt opgenomen van 's bedrijfsrekening" + government = "Je hebt opgenomen van 's overheidsrekening" + + [banking.money.deposit] + private = "Je hebt gestort op 's rekening" + savings = "Je hebt gestort op 's spaarrekening" + business = "Je hebt gestort op 's bedrijfsrekening" + government = "Je hebt gestort op 's overheidsrekening" + + [banking.nobankingpermission] + deposit = "Je hebt alleen opnamerechten voor de rekening ! Je kunt helaas geen geld storten." + +[bankaccountcmd] +id_does_not_exist = "Er is geen bankrekening met dit ID." +invalid_bankpermission = "FOUT: Ongeldige bankpermissie, geldige rechten zijn ." + + [bankaccountcmd.adduser] + success = "Speler is succesvol toegevoegd aan deze bankrekening." + already_added = "Speler is al toegevoegd aan deze bankrekening." + +[atm] +require_card = "Je moet een bankpas in je hand houden!" diff --git a/configuration/messages_fr.toml b/configuration/messages_fr.toml new file mode 100644 index 0000000..1caed40 --- /dev/null +++ b/configuration/messages_fr.toml @@ -0,0 +1,76 @@ +language = "en" +invalid_arguments = "You provided invalid arguments for this command." +invalid_username = "That username is invalid." +not_online = "That player is not online." +no_permission = "You don't have permission to use this command." +fly_on = "Fly mode has been enabled!" +fly_off = "Fly mode has been disabled!" + +[join] +enabled = true +message = " joined the game" + +[leave] +enabled = true +message = " left the game" + +[join_title] +title = "Welcome to" +subtitle = "" + +[mtworldcmd.add] +success = "Succesfully enabled Feather in this world!" + +[banking] +frozen = "This account is frozen, you can no longer withdraw or deposit money!" + + [banking.selector] + title = "Select the account type:" + + [banking.selector.account] + title = "Select the account:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Government" + savings = "Savings" + private = "Private" + business = "Business" + no_business_accounts = "You don't have any Business accounts!" + no_savings_accounts = "You don't have any Savings accounts!" + + [banking.menu] + title = "Total value: " + item_lore = "This piece of money has a %newline%value of ." + + [banking.money] + lore = "Official Minetopia banknote!" + insufficient_balance = "There is not enough money in this account" + is_fake_money = "You have counterfeit money with you! We are currently unable to accept money!" + + [banking.money.withdraw] + inventory_full = "You can't withdraw money when your inventory is full!" + private = "You have withdrawn from 's account" + savings = "You have withdrawn from 's savings account" + business = "You have withdrawn from 's business account" + government = "You have withdrawn from 's government account" + + [banking.money.deposit] + private = "You have deposited to 's account" + savings = "You have deposited to 's savings account" + business = "You have deposited to 's business account" + government = "You have deposited to 's government account" + + [banking.nobankingpermission] + deposit = "You only have withdrawal rights for the account ! Unfortunately you cannot deposit money." + +[bankaccountcmd] +id_does_not_exist = "There is no bankaccount with this ID." +invalid_bankpermission = "ERROR: Invalid bankpermission, valid permissions are ." + + [bankaccountcmd.adduser] + success = "Successfully added player to this bankaccount." + already_added = "The player has already been added to this bankaccount." + +[atm] +require_card = "You need to hold a debit card in your hand!" diff --git a/configuration/messages_fr_de.toml b/configuration/messages_fr_de.toml new file mode 100644 index 0000000..1083d5c --- /dev/null +++ b/configuration/messages_fr_de.toml @@ -0,0 +1,76 @@ +language = "en" +invalid_arguments = "You provided invalid arguments for this command." +invalid_username = "That username is invalid." +not_online = "That player is not online." +no_permission = "You don't have permission to use this command." +fly_on = "Fly mode has been enabled!" +fly_off = "Fly mode has been disabled!" + +[join] +enabled = true +message = "&7 joined the game" + +[leave] +enabled = true +message = "&7 left the game" + +[join_title] +title = "Welcome to" +subtitle = "" + +[mtworldcmd.add] +success = "Succesfully enabled Feather in this world!" + +[banking] +frozen = "This account is frozen, you can no longer withdraw or deposit money!" + + [banking.selector] + title = "Select the account type:" + + [banking.selector.account] + title = "Select the account:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Government" + savings = "Savings" + private = "Private" + business = "Business" + no_business_accounts = "You don't have any Business accounts!" + no_savings_accounts = "You don't have any Savings accounts!" + + [banking.menu] + title = "Total value: " + item_lore = "This piece of money has a %newline%value of ." + + [banking.money] + lore = "Official Minetopia banknote!" + insufficient_balance = "There is not enough money in this account" + is_fake_money = "You have counterfeit money with you! We are currently unable to accept money!" + + [banking.money.withdraw] + inventory_full = "You can't withdraw money when your inventory is full!" + private = "You have withdrawn from 's account" + savings = "You have withdrawn from 's savings account" + business = "You have withdrawn from 's business account" + government = "You have withdrawn from 's government account" + + [banking.money.deposit] + private = "You have deposited to 's account" + savings = "You have deposited to 's savings account" + business = "You have deposited to 's business account" + government = "You have deposited to 's government account" + + [banking.nobankingpermission] + deposit = "You only have withdrawal rights for the account ! Unfortunately you cannot deposit money." + +[bankaccountcmd] +id_does_not_exist = "There is no bankaccount with this ID." +invalid_bankpermission = "ERROR: Invalid bankpermission, valid permissions are ." + + [bankaccountcmd.adduser] + success = "Successfully added player to this bankaccount." + already_added = "The player has already been added to this bankaccount." + +[atm] +require_card = "You need to hold a debit card in your hand!" diff --git a/configuration/messages_fr_fr.toml b/configuration/messages_fr_fr.toml new file mode 100644 index 0000000..1083d5c --- /dev/null +++ b/configuration/messages_fr_fr.toml @@ -0,0 +1,76 @@ +language = "en" +invalid_arguments = "You provided invalid arguments for this command." +invalid_username = "That username is invalid." +not_online = "That player is not online." +no_permission = "You don't have permission to use this command." +fly_on = "Fly mode has been enabled!" +fly_off = "Fly mode has been disabled!" + +[join] +enabled = true +message = "&7 joined the game" + +[leave] +enabled = true +message = "&7 left the game" + +[join_title] +title = "Welcome to" +subtitle = "" + +[mtworldcmd.add] +success = "Succesfully enabled Feather in this world!" + +[banking] +frozen = "This account is frozen, you can no longer withdraw or deposit money!" + + [banking.selector] + title = "Select the account type:" + + [banking.selector.account] + title = "Select the account:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Government" + savings = "Savings" + private = "Private" + business = "Business" + no_business_accounts = "You don't have any Business accounts!" + no_savings_accounts = "You don't have any Savings accounts!" + + [banking.menu] + title = "Total value: " + item_lore = "This piece of money has a %newline%value of ." + + [banking.money] + lore = "Official Minetopia banknote!" + insufficient_balance = "There is not enough money in this account" + is_fake_money = "You have counterfeit money with you! We are currently unable to accept money!" + + [banking.money.withdraw] + inventory_full = "You can't withdraw money when your inventory is full!" + private = "You have withdrawn from 's account" + savings = "You have withdrawn from 's savings account" + business = "You have withdrawn from 's business account" + government = "You have withdrawn from 's government account" + + [banking.money.deposit] + private = "You have deposited to 's account" + savings = "You have deposited to 's savings account" + business = "You have deposited to 's business account" + government = "You have deposited to 's government account" + + [banking.nobankingpermission] + deposit = "You only have withdrawal rights for the account ! Unfortunately you cannot deposit money." + +[bankaccountcmd] +id_does_not_exist = "There is no bankaccount with this ID." +invalid_bankpermission = "ERROR: Invalid bankpermission, valid permissions are ." + + [bankaccountcmd.adduser] + success = "Successfully added player to this bankaccount." + already_added = "The player has already been added to this bankaccount." + +[atm] +require_card = "You need to hold a debit card in your hand!" diff --git a/configuration/messages_fr_nl.toml b/configuration/messages_fr_nl.toml new file mode 100644 index 0000000..c726588 --- /dev/null +++ b/configuration/messages_fr_nl.toml @@ -0,0 +1,76 @@ +language = "nl" +invalid_arguments = "Je hebt ongeldige argumenten opgegeven voor dit commando." +invalid_username = "Deze gebruikersnaam is ongeldig." +not_online = "Deze speler is niet online." +no_permission = "Je hebt geen toestemming om dit commando te gebruiken." +fly_on = "Vliegmodus is ingeschakeld!" +fly_off = "Vliegmodus is uitgeschakeld!" + +[join] +enabled = true +message = "&7 heeft het spel toegetreden" + +[leave] +enabled = true +message = "&7 heeft het spel verlaten" + +[join_title] +title = "Welkom in" +subtitle = "" + +[mtworldcmd.add] +success = "Feather is succesvol aangezet in deze wereld!" + +[banking] +frozen = "Dit account is bevroren, je kan geen geld meer opnemen of storten!" + + [banking.selector] + title = "Selecteer het type rekening:" + + [banking.selector.account] + title = "Selecteer de rekening:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Overheid" + savings = "Sparen" + private = "Privé" + business = "Bedrijf" + no_business_accounts = "Je hebt geen Bedrijfsrekeningen!" + no_savings_accounts = "Je hebt geen Spaar rekeningen!" + + [banking.menu] + title = "Totale waarde: " + item_lore = "Dit geldstuk heeft een %newline%waarde van ." + + [banking.money] + lore = "Officieel Minetopia bankbiljet!" + insufficient_balance = "Er staat niet genoeg geld op deze rekening" + is_fake_money = "Je hebt vervalste geld bij je! We kunnen op dit moment geen geld accepteren!" + + [banking.money.withdraw] + inventory_full = "Je kan geen geld opnemen wanneer je inventory vol is!" + private = "Je hebt opgenomen van 's rekening" + savings = "Je hebt opgenomen van 's spaarrekening" + business = "Je hebt opgenomen van 's bedrijfsrekening" + government = "Je hebt opgenomen van 's overheidsrekening" + + [banking.money.deposit] + private = "Je hebt gestort op 's rekening" + savings = "Je hebt gestort op 's spaarrekening" + business = "Je hebt gestort op 's bedrijfsrekening" + government = "Je hebt gestort op 's overheidsrekening" + + [banking.nobankingpermission] + deposit = "Je hebt alleen opnamerechten voor de rekening ! Je kunt helaas geen geld storten." + +[bankaccountcmd] +id_does_not_exist = "Er is geen bankrekening met dit ID." +invalid_bankpermission = "FOUT: Ongeldige bankpermissie, geldige rechten zijn ." + + [bankaccountcmd.adduser] + success = "Speler is succesvol toegevoegd aan deze bankrekening." + already_added = "Speler is al toegevoegd aan deze bankrekening." + +[atm] +require_card = "Je moet een bankpas in je hand houden!" diff --git a/configuration/messages_nl.toml b/configuration/messages_nl.toml new file mode 100644 index 0000000..e2fc65d --- /dev/null +++ b/configuration/messages_nl.toml @@ -0,0 +1,76 @@ +language = "nl" +invalid_arguments = "Je hebt ongeldige argumenten opgegeven voor dit commando." +invalid_username = "Deze gebruikersnaam is ongeldig." +not_online = "Deze speler is niet online." +no_permission = "Je hebt geen toestemming om dit commando te gebruiken." +fly_on = "Vliegmodus is ingeschakeld!" +fly_off = "Vliegmodus is uitgeschakeld!" + +[join] +enabled = true +message = " joined the game" + +[leave] +enabled = true +message = " left the game" + +[join_title] +title = "Welkom bij" +subtitle = "" + +[mtworldcmd.add] +success = "Feather is succesvol aangezet in deze wereld." + +[banking] +frozen = "Dit account is bevroren, je kan geen geld meer opnemen of storten!" + + [banking.selector] + title = "Selecteer het rekeningtype:" + + [banking.selector.account] + title = "Selecteer de rekening:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Overheid" + savings = "Spaargeld" + private = "Privé" + business = "Zakelijk" + no_business_accounts = "Je hebt geen Zakelijke rekeningen!" + no_savings_accounts = "Je hebt geen Spaar rekeningen!" + + [banking.menu] + title = "Totale waarde: " + item_lore = "Dit geldstuk heeft een %newline%waarde van ." + + [banking.money] + lore = "Officieel Minetopia bankbiljet!" + insufficient_balance = "Er staat niet genoeg geld op deze rekening" + is_fake_money = "Je hebt vals geld bij je! We kunnen op dit moment geen geld accepteren!" + + [banking.money.withdraw] + inventory_full = "Je kan geen geld opnemen wanneer je inventaris vol is!" + private = "Je hebt opgenomen van 's rekening" + savings = "Je hebt opgenomen van 's spaarrekening" + business = "Je hebt opgenomen van 's zakelijke rekening" + government = "Je hebt opgenomen van 's overheid rekening" + + [banking.money.deposit] + private = "Je hebt overgemaakt naar 's rekening" + savings = "Je hebt overgemaakt naar 's spaarrekening" + business = "Je hebt overgemaakt naar 's zakelijke rekening" + government = "Je hebt overgemaakt naar 's overheid rekening" + + [banking.nobankingpermission] + deposit = "Je hebt alleen opnamerechten voor de rekening ! Je kunt helaas geen geld storten." + +[bankaccountcmd] +id_does_not_exist = "Er is geen bankrekening met dit ID." +invalid_bankpermission = "FOUT: Ongeldige bankmachtiging, geldige machtigingen zijn ." + + [bankaccountcmd.adduser] + success = "Speler is succesvol toegevoegd aan deze bankrekening." + already_added = "Speler is al toegevoegd aan deze bankrekening." + +[atm] +require_card = "Je moet een bankpas in je hand houden!" diff --git a/configuration/messages_nl_de.toml b/configuration/messages_nl_de.toml new file mode 100644 index 0000000..b92e4fc --- /dev/null +++ b/configuration/messages_nl_de.toml @@ -0,0 +1,76 @@ +language = "nl" +invalid_arguments = "Je hebt ongeldige argumenten opgegeven voor dit commando." +invalid_username = "Deze gebruikersnaam is ongeldig." +not_online = "Deze speler is niet online." +no_permission = "Je hebt geen toestemming om dit commando te gebruiken." +fly_on = "Vliegmodus is ingeschakeld!" +fly_off = "Vliegmodus is uitgeschakeld!" + +[join] +enabled = true +message = "&7 heeft het spel toegetreden" + +[leave] +enabled = true +message = "&7 heeft het spel verlaten" + +[join_title] +title = "Welkom bij" +subtitle = "" + +[mtworldcmd.add] +success = "Feather is succesvol aangezet in deze wereld." + +[banking] +frozen = "Dit account is bevroren, je kan geen geld meer opnemen of storten!" + + [banking.selector] + title = "Selecteer het rekeningtype:" + + [banking.selector.account] + title = "Selecteer de rekening:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Overheid" + savings = "Spaargeld" + private = "Privé" + business = "Zakelijk" + no_business_accounts = "Je hebt geen Zakelijke rekeningen!" + no_savings_accounts = "Je hebt geen Spaar rekeningen!" + + [banking.menu] + title = "Totale waarde: " + item_lore = "Dit geldstuk heeft een %newline%waarde van ." + + [banking.money] + lore = "Officieel Minetopia bankbiljet!" + insufficient_balance = "Er staat niet genoeg geld op deze rekening" + is_fake_money = "Je hebt vals geld bij je! We kunnen op dit moment geen geld accepteren!" + + [banking.money.withdraw] + inventory_full = "Je kan geen geld opnemen wanneer je inventaris vol is!" + private = "Je hebt opgenomen van 's rekening" + savings = "Je hebt opgenomen van 's spaarrekening" + business = "Je hebt opgenomen van 's zakelijke rekening" + government = "Je hebt opgenomen van 's overheid rekening" + + [banking.money.deposit] + private = "Je hebt overgemaakt naar 's rekening" + savings = "Je hebt overgemaakt naar 's spaarrekening" + business = "Je hebt overgemaakt naar 's zakelijke rekening" + government = "Je hebt overgemaakt naar 's overheid rekening" + + [banking.nobankingpermission] + deposit = "Je hebt alleen opnamerechten voor de rekening ! Je kunt helaas geen geld storten." + +[bankaccountcmd] +id_does_not_exist = "Er is geen bankrekening met dit ID." +invalid_bankpermission = "FOUT: Ongeldige bankmachtiging, geldige machtigingen zijn ." + + [bankaccountcmd.adduser] + success = "Speler is succesvol toegevoegd aan deze bankrekening." + already_added = "Speler is al toegevoegd aan deze bankrekening." + +[atm] +require_card = "Je moet een bankpas in je hand houden!" diff --git a/configuration/messages_nl_fr.toml b/configuration/messages_nl_fr.toml new file mode 100644 index 0000000..b92e4fc --- /dev/null +++ b/configuration/messages_nl_fr.toml @@ -0,0 +1,76 @@ +language = "nl" +invalid_arguments = "Je hebt ongeldige argumenten opgegeven voor dit commando." +invalid_username = "Deze gebruikersnaam is ongeldig." +not_online = "Deze speler is niet online." +no_permission = "Je hebt geen toestemming om dit commando te gebruiken." +fly_on = "Vliegmodus is ingeschakeld!" +fly_off = "Vliegmodus is uitgeschakeld!" + +[join] +enabled = true +message = "&7 heeft het spel toegetreden" + +[leave] +enabled = true +message = "&7 heeft het spel verlaten" + +[join_title] +title = "Welkom bij" +subtitle = "" + +[mtworldcmd.add] +success = "Feather is succesvol aangezet in deze wereld." + +[banking] +frozen = "Dit account is bevroren, je kan geen geld meer opnemen of storten!" + + [banking.selector] + title = "Selecteer het rekeningtype:" + + [banking.selector.account] + title = "Selecteer de rekening:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Overheid" + savings = "Spaargeld" + private = "Privé" + business = "Zakelijk" + no_business_accounts = "Je hebt geen Zakelijke rekeningen!" + no_savings_accounts = "Je hebt geen Spaar rekeningen!" + + [banking.menu] + title = "Totale waarde: " + item_lore = "Dit geldstuk heeft een %newline%waarde van ." + + [banking.money] + lore = "Officieel Minetopia bankbiljet!" + insufficient_balance = "Er staat niet genoeg geld op deze rekening" + is_fake_money = "Je hebt vals geld bij je! We kunnen op dit moment geen geld accepteren!" + + [banking.money.withdraw] + inventory_full = "Je kan geen geld opnemen wanneer je inventaris vol is!" + private = "Je hebt opgenomen van 's rekening" + savings = "Je hebt opgenomen van 's spaarrekening" + business = "Je hebt opgenomen van 's zakelijke rekening" + government = "Je hebt opgenomen van 's overheid rekening" + + [banking.money.deposit] + private = "Je hebt overgemaakt naar 's rekening" + savings = "Je hebt overgemaakt naar 's spaarrekening" + business = "Je hebt overgemaakt naar 's zakelijke rekening" + government = "Je hebt overgemaakt naar 's overheid rekening" + + [banking.nobankingpermission] + deposit = "Je hebt alleen opnamerechten voor de rekening ! Je kunt helaas geen geld storten." + +[bankaccountcmd] +id_does_not_exist = "Er is geen bankrekening met dit ID." +invalid_bankpermission = "FOUT: Ongeldige bankmachtiging, geldige machtigingen zijn ." + + [bankaccountcmd.adduser] + success = "Speler is succesvol toegevoegd aan deze bankrekening." + already_added = "Speler is al toegevoegd aan deze bankrekening." + +[atm] +require_card = "Je moet een bankpas in je hand houden!" diff --git a/configuration/messages_nl_nl.toml b/configuration/messages_nl_nl.toml new file mode 100644 index 0000000..7cfb3de --- /dev/null +++ b/configuration/messages_nl_nl.toml @@ -0,0 +1,76 @@ +language = "nl" +invalid_arguments = "Je hebt ongeldige argumenten opgegeven voor dit commando." +invalid_username = "Deze gebruikersnaam is ongeldig." +not_online = "Deze speler is niet online." +no_permission = "Je hebt geen toestemming om dit commando te gebruiken." +fly_on = "Vliegmodus is ingeschakeld!" +fly_off = "Vliegmodus is uitgeschakeld!" + +[join] +enabled = true +message = "&7 heeft het spel toegetreden" + +[leave] +enabled = true +message = "&7 heeft het spel verlaten" + +[join_title] +title = "Welkom bij" +subtitle = "" + +[mtworldcmd.add] +success = "Feather is succesvol aangezet in deze wereld." + +[banking] +frozen = "Dit account is bevroren, je kan geen geld meer opnemen of storten!" + + [banking.selector] + title = "Selecteer het rekeningtype:" + + [banking.selector.account] + title = "Selecteer de rekening:" + lore = "(ID: )" + + [banking.selector.accounttype] + government = "Overheid" + savings = "Spaargeld" + private = "Privé" + business = "Zakelijk" + no_business_accounts = "Je hebt geen Zakelijke rekeningen!" + no_savings_accounts = "Je hebt geen Spaar rekeningen!" + + [banking.menu] + title = "Totale waarde: " + item_lore = "Dit geldstuk heeft een %newline%waarde van ." + + [banking.money] + lore = "Officieel Minetopia bankbiljet!" + insufficient_balance = "Er staat niet genoeg geld op deze rekening" + is_fake_money = "Je hebt vals geld bij je! We kunnen op dit moment geen geld accepteren!" + + [banking.money.withdraw] + inventory_full = "Je kan geen geld opnemen wanneer je inventaris vol is!" + private = "Je hebt opgenomen van 's rekening" + savings = "Je hebt opgenomen van 's spaarrekening" + business = "Je hebt opgenomen van 's zakelijke rekening" + government = "Je hebt opgenomen van 's overheid's rekening" + + [banking.money.deposit] + private = "Je hebt overgemaakt naar 's rekening" + savings = "Je hebt overgemaakt naar 's spaarrekening" + business = "Je hebt overgemaakt naar 's zakelijke rekening" + government = "Je hebt overgemaakt naar 's overheid rekening" + + [banking.nobankingpermission] + deposit = "Je hebt alleen opnamerechten voor de rekening ! Je kunt helaas geen geld storten." + +[bankaccountcmd] +id_does_not_exist = "Er is geen bankrekening met dit ID." +invalid_bankpermission = "FOUT: Ongeldige bankmachtiging, geldige machtigingen zijn ." + + [bankaccountcmd.adduser] + success = "Speler is succesvol toegevoegd aan deze bankrekening." + already_added = "Speler is al toegevoegd aan deze bankrekening." + +[atm] +require_card = "Je moet een bankpas in je hand houden!" diff --git a/src/main/java/cc/ddev/feather/Server.java b/src/main/java/cc/ddev/feather/Server.java index 6ef185c..c1e9f17 100644 --- a/src/main/java/cc/ddev/feather/Server.java +++ b/src/main/java/cc/ddev/feather/Server.java @@ -29,7 +29,6 @@ import cc.ddev.feather.world.blockhandlers.RegisterHandlers; import cc.ddev.instanceguard.flag.FlagValue; import lombok.Getter; -import net.kyori.adventure.text.Component; import net.minestom.server.MinecraftServer; import net.minestom.server.entity.Player; import net.minestom.server.extras.MojangAuth; @@ -86,11 +85,7 @@ public static void main(String[] args) { // Set the ChunkGenerator instanceContainer.setGenerator(unit -> unit.modifier().fillHeight(0, 40, Block.GRASS_BLOCK)); - } else { - // Load the world - instanceContainer = WorldManager.loadWorld(WorldManager.getInstance().getWorldsDirectory() + File.separator + Config.Spawn.WORLD); } - // Sets online-mode if (Config.Server.ONLINE_MODE) { MojangAuth.init(); @@ -118,7 +113,9 @@ public static void main(String[] args) { new PlayerBlockBreakListener().register(); new PlayerItemDropListener().register(); new PlayerItemPickupListener().register(); - new PlayerInteractListener().register(); + + // Start the server from config values + minecraftServer.start(Config.Server.SERVER_HOST, Config.Server.SERVER_PORT); // Register commands MinecraftServer.getCommandManager().register(new TestCommand()); @@ -133,9 +130,6 @@ public static void main(String[] args) { MinecraftServer.getCommandManager().register(new PlotCommand()); MinecraftServer.getCommandManager().register(new PlotInfoCommand()); - // Start the server from config values - minecraftServer.start(Config.Server.SERVER_HOST, Config.Server.SERVER_PORT); - for (Player player : MinecraftServer.getConnectionManager().getOnlinePlayers()) { API.getPlayerManager().getPlayerModel(player); } @@ -146,6 +140,9 @@ public static void main(String[] args) { API.getInstanceGuard().getFlagManager().registerCustomFlag("feather-description", new FlagValue<>("")); API.getInstanceGuard().getFlagManager().registerCustomFlag("feather-plotlevels", new FlagValue<>("")); + // Load the world + WorldManager.getInstance().loadWorld(WorldManager.getInstance().getWorldsDirectory() + File.separator + Config.Spawn.WORLD); + SidebarRefreshTask.registerTask(); SaveWorldTask.registerTask(); ShutdownTask.registerTask(); diff --git a/src/main/java/cc/ddev/feather/api/banking/BankUtils.java b/src/main/java/cc/ddev/feather/api/banking/BankUtils.java index 3518893..740d981 100644 --- a/src/main/java/cc/ddev/feather/api/banking/BankUtils.java +++ b/src/main/java/cc/ddev/feather/api/banking/BankUtils.java @@ -89,7 +89,7 @@ public void toDatabase() throws Exception { bankAccountModel.setName(bank.getName()); bankAccountModel.setFrozen(bank.isFrozen()); bankAccountModel.setType(bank.getType().name()); - StormDatabase.getInstance().saveStormModel(bankAccountModel); + StormDatabase.getInstance().getStorm().save(bankAccountModel); } } diff --git a/src/main/java/cc/ddev/feather/api/config/Config.java b/src/main/java/cc/ddev/feather/api/config/Config.java index a9f9018..1d5d95d 100644 --- a/src/main/java/cc/ddev/feather/api/config/Config.java +++ b/src/main/java/cc/ddev/feather/api/config/Config.java @@ -9,8 +9,6 @@ import net.minestom.server.item.ItemStack; import net.minestom.server.item.Material; -import java.util.List; - @Getter public class Config { @@ -90,12 +88,4 @@ public static class Plot { public static String CALCULATE_PRICEFORMULA = getFeatherConfig().getString("plot.calculate.price_formula"); } - - public static class Phone { - public static double DEFAULT_CREDIT = getFeatherConfig().getDouble("phone.default_credit"); - - public static double MESSAGE_COSTS = getFeatherConfig().getDouble("phone.message_costs"); - - public static List ITEMS = getFeatherConfig().getStringList("phone.items"); - } } \ No newline at end of file diff --git a/src/main/java/cc/ddev/feather/api/economy/EconomyManager.java b/src/main/java/cc/ddev/feather/api/economy/EconomyManager.java index d924f53..b88fe97 100644 --- a/src/main/java/cc/ddev/feather/api/economy/EconomyManager.java +++ b/src/main/java/cc/ddev/feather/api/economy/EconomyManager.java @@ -1,6 +1,5 @@ package cc.ddev.feather.api.economy; -import cc.ddev.feather.api.API; import cc.ddev.feather.database.StormDatabase; import cc.ddev.feather.database.models.PlayerModel; import cc.ddev.feather.player.PlayerProfile; @@ -19,28 +18,36 @@ public static EconomyManager getInstance() { } public void removeBalance(Player player, double amount) { - PlayerModel playerModel = API.getPlayerManager().getPlayerModel(player); + PlayerProfile playerProfile = PlayerWrapper.getPlayerProfile(player); + if (playerProfile == null) throw new NullPointerException("PlayerProfile is null"); + PlayerModel playerModel = playerProfile.getPlayerModel(); playerModel.setBalance(playerModel.getBalance() - amount); StormDatabase.getInstance().saveStormModel(playerModel); } public void addBalance(Player player, double amount) { - PlayerModel playerModel = API.getPlayerManager().getPlayerModel(player); + PlayerProfile playerProfile = PlayerWrapper.getPlayerProfile(player); + if (playerProfile == null) throw new NullPointerException("PlayerProfile is null"); + PlayerModel playerModel = playerProfile.getPlayerModel(); playerModel.setBalance(playerModel.getBalance() + amount); StormDatabase.getInstance().saveStormModel(playerModel); } public void setBalance(Player player, double amount) { - PlayerModel playerModel = API.getPlayerManager().getPlayerModel(player); + PlayerProfile playerProfile = PlayerWrapper.getPlayerProfile(player); + if (playerProfile == null) throw new NullPointerException("PlayerProfile is null"); + PlayerModel playerModel = playerProfile.getPlayerModel(); playerModel.setBalance(amount); StormDatabase.getInstance().saveStormModel(playerModel); } public double getBalance(Player player) { - PlayerModel playerModel = API.getPlayerManager().getPlayerModel(player); + PlayerProfile playerProfile = PlayerWrapper.getPlayerProfile(player); + if (playerProfile == null) throw new NullPointerException("PlayerProfile is null"); + PlayerModel playerModel = playerProfile.getPlayerModel(); return playerModel.getBalance(); } diff --git a/src/main/java/cc/ddev/feather/api/objects/Phone.java b/src/main/java/cc/ddev/feather/api/objects/Phone.java deleted file mode 100644 index 61776c8..0000000 --- a/src/main/java/cc/ddev/feather/api/objects/Phone.java +++ /dev/null @@ -1,67 +0,0 @@ -package cc.ddev.feather.api.objects; - -import cc.ddev.feather.database.StormDatabase; -import cc.ddev.feather.database.models.BankAccountModel; -import cc.ddev.feather.database.models.PhoneModel; -import com.craftmend.storm.api.enums.Where; - -import java.util.Collection; -import java.util.UUID; - -public class Phone { - private int phonenumber; - private double credit; - private UUID owner; - - public Phone(int phonenumber, double credit, UUID owner) { - this.phonenumber = phonenumber; - this.credit = credit; - this.owner = owner; - } - - public int getPhoneNumber() { - return this.phonenumber; - } - - public double getCredit() { - return this.credit; - } - - public void setCredit(double newCredit) { - this.credit = newCredit; - try { - Collection phoneModels = - StormDatabase.getInstance().getStorm().buildQuery(PhoneModel.class) - .where("phone_number", Where.EQUAL, this.phonenumber) - .limit(1) - .execute() - .join(); - PhoneModel phoneModel = phoneModels.iterator().next(); - phoneModel.setCredit(newCredit); - StormDatabase.getInstance().saveStormModel(phoneModel); - } catch (Exception e) { - e.printStackTrace(); - } - } - - public UUID getOwner() { - return this.owner; - } - - public void setOwner(UUID owner) { - this.owner = owner; - try { - Collection phoneModels = - StormDatabase.getInstance().getStorm().buildQuery(PhoneModel.class) - .where("phone_number", Where.EQUAL, this.phonenumber) - .limit(1) - .execute() - .join(); - PhoneModel phoneModel = phoneModels.iterator().next(); - phoneModel.setOwner(owner); - StormDatabase.getInstance().saveStormModel(phoneModel); - } catch (Exception e) { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/src/main/java/cc/ddev/feather/api/objects/PhoneContact.java b/src/main/java/cc/ddev/feather/api/objects/PhoneContact.java deleted file mode 100644 index 4346994..0000000 --- a/src/main/java/cc/ddev/feather/api/objects/PhoneContact.java +++ /dev/null @@ -1,28 +0,0 @@ -package cc.ddev.feather.api.objects; - - -import java.util.UUID; - -public class PhoneContact { - private long rowId; - private int phoneNumber; - private UUID uuid; - - public PhoneContact(long rowId, int phoneNumber, UUID uuid) { - this.rowId = rowId; - this.phoneNumber = phoneNumber; - this.uuid = uuid; - } - - public long getRowId() { - return this.rowId; - } - - public int getPhoneNumber() { - return this.phoneNumber; - } - - public UUID getOwnerUUID() { - return this.uuid; - } -} \ No newline at end of file diff --git a/src/main/java/cc/ddev/feather/api/objects/PhoneMessage.java b/src/main/java/cc/ddev/feather/api/objects/PhoneMessage.java deleted file mode 100644 index 36a6a4d..0000000 --- a/src/main/java/cc/ddev/feather/api/objects/PhoneMessage.java +++ /dev/null @@ -1,68 +0,0 @@ -package cc.ddev.feather.api.objects; - -import cc.ddev.feather.database.StormDatabase; -import cc.ddev.feather.database.models.PhoneMessagesModel; -import cc.ddev.feather.database.models.PhoneModel; -import com.craftmend.storm.api.enums.Where; - -import java.util.Collection; -import java.util.UUID; - -public class PhoneMessage { - private long id; - private int phoneNumberSender; - private int phoneNumberReceiver; - private UUID sender; - private String message; - private boolean read; - - public PhoneMessage(long id, int phoneNumberSender, UUID sender, int phoneNumberReceiver, String message, boolean read) { - this.id = id; - this.phoneNumberReceiver = phoneNumberReceiver; - this.sender = sender; - this.phoneNumberSender = phoneNumberSender; - this.message = message; - this.read = read; - } - - public long getId() { - return this.id; - } - - public int getPhoneNumberSender() { - return this.phoneNumberSender; - } - - public UUID getSenderUUID() { - return this.sender; - } - - public int getPhoneNumberReceiver() { - return this.phoneNumberReceiver; - } - - public String getMessage() { - return this.message; - } - - public boolean isRead() { - return this.read; - } - - public void setRead(boolean read) { - this.read = read; - try { - Collection phoneMessagesModels = - StormDatabase.getInstance().getStorm().buildQuery(PhoneMessagesModel.class) - .where("id", Where.EQUAL, this.getId()) - .limit(1) - .execute() - .join(); - PhoneMessagesModel phoneMessagesModel = phoneMessagesModels.iterator().next(); - phoneMessagesModel.setMessageRead(read); - StormDatabase.getInstance().saveStormModel(phoneMessagesModel); - } catch (Exception e) { - e.printStackTrace(); - } - } -} \ No newline at end of file diff --git a/src/main/java/cc/ddev/feather/api/phone/PhoneManager.java b/src/main/java/cc/ddev/feather/api/phone/PhoneManager.java deleted file mode 100644 index ff126b3..0000000 --- a/src/main/java/cc/ddev/feather/api/phone/PhoneManager.java +++ /dev/null @@ -1,169 +0,0 @@ -package cc.ddev.feather.api.phone; - -import cc.ddev.feather.api.config.Config; -import cc.ddev.feather.api.objects.Phone; -import cc.ddev.feather.api.objects.PhoneContact; -import cc.ddev.feather.database.StormDatabase; -import cc.ddev.feather.database.models.PhoneContactsModel; -import cc.ddev.feather.database.models.PhoneModel; -import com.craftmend.storm.api.enums.Where; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - -public class PhoneManager { - private static PhoneManager instance; - - public static PhoneManager getInstance() { - if (instance == null) { - instance = new PhoneManager(); - } - return instance; - } - - public CompletableFuture getPhone(int phonenumber) { - return CompletableFuture.supplyAsync(() -> { - try { - Collection phoneModels = - StormDatabase.getInstance().getStorm().buildQuery(PhoneModel.class) - .where("phone_number", Where.EQUAL, phonenumber) - .limit(1) - .execute() - .join(); - PhoneModel phoneModel = phoneModels.iterator().next(); - - double credit = phoneModel.getCredit(); - UUID owner = phoneModel.getOwner(); - - return new Phone(phonenumber, credit, owner); - } catch (Exception e) { - e.printStackTrace(); - } - return null; - }); - } - - public CompletableFuture createNewPhone(int phoneNumber, UUID owner) { - return CompletableFuture.supplyAsync(() -> { - Phone phone; - try { - PhoneModel phoneModel = new PhoneModel(); - phoneModel.setPhoneNumber(phoneNumber); - phoneModel.setCredit(Config.Phone.DEFAULT_CREDIT); - phoneModel.setOwner(owner); - StormDatabase.getInstance().saveStormModel(phoneModel); - } catch (Exception e) { - e.printStackTrace(); - } - - phone = new Phone(phoneNumber, Config.Phone.DEFAULT_CREDIT, owner); - return phone; - }); - } - - public CompletableFuture> getAllPhones() { - return CompletableFuture.supplyAsync(() -> { - ArrayList phones = new ArrayList<>(); - - try { - Collection phoneModels = - StormDatabase.getInstance().getStorm().buildQuery(PhoneModel.class) - .execute() - .join(); - for (PhoneModel phoneModel : phoneModels) { - phones.add(new Phone(phoneModel.getPhoneNumber(), phoneModel.getCredit(), phoneModel.getOwner())); - } - return phones; - } catch (Exception e) { - e.printStackTrace(); - } - return phones; - }); - } - - public CompletableFuture> getAllContacts(int phonenumber) { - return CompletableFuture.supplyAsync(() -> { - ArrayList contacts = new ArrayList<>(); - - try { - Collection phoneContactsModels = - StormDatabase.getInstance().getStorm().buildQuery(PhoneContactsModel.class) - .execute() - .join(); - for (PhoneContactsModel phoneContactsModel : phoneContactsModels) { - contacts.add(new PhoneContact(phoneContactsModel.getId(), phoneContactsModel.getContactPhoneNumber(), getPhone(phonenumber).get().getOwner())); - } - return contacts; - } catch (Exception e) { - e.printStackTrace(); - } - return contacts; - }); - } - - public CompletableFuture addContact(int phonenumber, int newContact) { - return CompletableFuture.supplyAsync(() -> { - try { - PhoneContactsModel phoneContactsModel = new PhoneContactsModel(); - phoneContactsModel.setPhoneNumber(phonenumber); - phoneContactsModel.setContactPhoneNumber(newContact); - - StormDatabase.getInstance().saveStormModel(phoneContactsModel); - return 1; - } catch (Exception e) { - e.printStackTrace(); - return 0; - } - }); - } - - public CompletableFuture removeContact(int phonenumber, int contact) { - return CompletableFuture.supplyAsync(() -> { - try { - Collection phoneContactsModels = - StormDatabase.getInstance().getStorm().buildQuery(PhoneContactsModel.class) - .where("phone_number", Where.EQUAL, phonenumber) - .where("contact_phone_number", Where.EQUAL, contact) - .limit(1) - .execute() - .join(); - PhoneContactsModel phoneContactsModel = phoneContactsModels.iterator().next(); - StormDatabase.getInstance().getStorm().delete(phoneContactsModel); - return 1; - } catch (Exception e) { - e.printStackTrace(); - return 0; - } - }); - } - - public int getRandomPhoneNumber() { - int number = 10000000 + (int) (Math.random() * 9.0E7); - if (String.valueOf(number).startsWith("06")) { - return this.getRandomPhoneNumber(); - } - return number; - } - - public boolean isAvailable(int phonenumber) { - boolean available = false; - try { - Collection phoneModels = - StormDatabase.getInstance().getStorm().buildQuery(PhoneModel.class) - .where("phone_number", Where.EQUAL, phonenumber) - .limit(1) - .execute() - .join(); - if (phoneModels.isEmpty()) { - available = true; - } - return available; - } catch (Exception e) { - e.printStackTrace(); - } - return available; - } -} \ No newline at end of file diff --git a/src/main/java/cc/ddev/feather/api/phone/PhoneMessageManager.java b/src/main/java/cc/ddev/feather/api/phone/PhoneMessageManager.java deleted file mode 100644 index 009e80d..0000000 --- a/src/main/java/cc/ddev/feather/api/phone/PhoneMessageManager.java +++ /dev/null @@ -1,4 +0,0 @@ -package cc.ddev.feather.api.phone; - -public class PhoneMessageManager { -} diff --git a/src/main/java/cc/ddev/feather/api/playerdata/PlayerManager.java b/src/main/java/cc/ddev/feather/api/playerdata/PlayerManager.java index c4dcbf4..6267907 100644 --- a/src/main/java/cc/ddev/feather/api/playerdata/PlayerManager.java +++ b/src/main/java/cc/ddev/feather/api/playerdata/PlayerManager.java @@ -1,11 +1,15 @@ package cc.ddev.feather.api.playerdata; +import cc.ddev.feather.api.API; +import cc.ddev.feather.api.config.Config; +import cc.ddev.feather.api.economy.EconomyManager; import cc.ddev.feather.database.StormDatabase; import cc.ddev.feather.database.models.PlayerModel; import cc.ddev.feather.logger.Log; import cc.ddev.feather.player.PlayerProfile; import cc.ddev.feather.player.PlayerWrapper; import cc.ddev.feather.world.WorldManager; +import net.minestom.server.MinecraftServer; import net.minestom.server.coordinate.Point; import net.minestom.server.coordinate.Pos; import net.minestom.server.entity.Player; @@ -98,8 +102,9 @@ public Pos getLastLocation(Player player) { double z = Double.parseDouble(rawPosition[2].replace("z=", "")); float yaw = Float.parseFloat(rawPosition[3].replace("yaw=", "")); float pitch = Float.parseFloat(rawPosition[4].replace("pitch=", "").replace("]", "")); + Pos pos = new Pos(x, y, z, yaw, pitch); - return new Pos(x, y, z, yaw, pitch); + return pos; } return null; } diff --git a/src/main/java/cc/ddev/feather/api/sidebar/SidebarManager.java b/src/main/java/cc/ddev/feather/api/sidebar/SidebarManager.java index 5202065..b4d529a 100644 --- a/src/main/java/cc/ddev/feather/api/sidebar/SidebarManager.java +++ b/src/main/java/cc/ddev/feather/api/sidebar/SidebarManager.java @@ -1,6 +1,5 @@ package cc.ddev.feather.api.sidebar; -import cc.ddev.feather.api.API; import cc.ddev.feather.api.config.Config; import cc.ddev.feather.database.models.PlayerModel; import cc.ddev.feather.placeholders.Placeholders; @@ -23,7 +22,9 @@ public static void buildSidebar(Player player) { Component titleComponent = Component.text(Placeholders.parse(player, Config.Sidebar.TITLE).toUpperCase()); Sidebar sidebar = new Sidebar(titleComponent); - PlayerModel playerModel = API.getPlayerManager().getPlayerModel(player); + PlayerProfile playerProfile = PlayerWrapper.getPlayerProfile(player); + if (playerProfile == null) return; + PlayerModel playerModel = playerProfile.getPlayerModel(); Double balance = playerModel.getBalance(); Component balanceComponent = balance == 0 ? Component.text("0") : Component.text(balance); diff --git a/src/main/java/cc/ddev/feather/command/economy/subcommands/EconomySetCommand.java b/src/main/java/cc/ddev/feather/command/economy/subcommands/EconomySetCommand.java index 415704d..e8e53e1 100644 --- a/src/main/java/cc/ddev/feather/command/economy/subcommands/EconomySetCommand.java +++ b/src/main/java/cc/ddev/feather/command/economy/subcommands/EconomySetCommand.java @@ -1,6 +1,5 @@ package cc.ddev.feather.command.economy.subcommands; -import cc.ddev.feather.api.API; import cc.ddev.feather.database.StormDatabase; import cc.ddev.feather.database.models.PlayerModel; import cc.ddev.feather.player.PlayerProfile; @@ -33,14 +32,12 @@ public EconomySetCommand() { return; } - PlayerModel playerModel = API.getPlayerManager().getPlayerModel(player); + PlayerProfile playerProfile = PlayerWrapper.getPlayerProfile(target); + PlayerModel playerModel = playerProfile.getPlayerModel(); playerModel.setBalance(context.get("amount")); - StormDatabase.getInstance().saveStormModel(playerModel); SidebarManager.refreshSidebar(player); - sender.sendMessage(Component.text("Set ") - .append(Component.text(target.getUsername()) - .append(Component.text("'s balance to ").append(Component.text(playerModel.getBalance()))))); + sender.sendMessage(Component.text("Set ").append(playerProfile.getUsername()).append(Component.text("'s balance to ").append(Component.text(playerModel.getBalance())))); }, playerArgument, amountArgument); } } diff --git a/src/main/java/cc/ddev/feather/command/essential/OpCommand.java b/src/main/java/cc/ddev/feather/command/essential/OpCommand.java index e6c84e0..3486758 100644 --- a/src/main/java/cc/ddev/feather/command/essential/OpCommand.java +++ b/src/main/java/cc/ddev/feather/command/essential/OpCommand.java @@ -1,6 +1,5 @@ package cc.ddev.feather.command.essential; -import cc.ddev.feather.api.API; import cc.ddev.feather.database.StormDatabase; import cc.ddev.feather.database.models.PlayerModel; import cc.ddev.feather.player.PlayerProfile; @@ -53,7 +52,7 @@ public OpCommand() { * notifies them (and the sender) in the chat. */ private void executeOthers(CommandSender sender, List entities) { - if (entities.isEmpty()) { + if (entities.size() == 0) { //If there are no players that could be modified, display an error message if (sender instanceof Player) sender.sendMessage(Component.translatable("argument.entity.notfound.player", NamedTextColor.RED)); @@ -65,11 +64,11 @@ private void executeOthers(CommandSender sender, List entities) { //executeSelf to display one message instead of two executeSelf((Player) sender); } else { - PlayerModel playerModel = API.getPlayerManager().getPlayerModel(player); - playerModel.setIsOperator(true); + PlayerProfile playerProfile = PlayerWrapper.getPlayerProfile(player); + PlayerModel playerModel = playerProfile.getPlayerModel(); + playerModel.setIsOperator(true); StormDatabase.getInstance().saveStormModel(playerModel); - player.setPermissionLevel(4); Component playerName = player.getDisplayName() == null ? player.getName() : player.getDisplayName(); @@ -94,7 +93,8 @@ private void executeOthers(CommandSender sender, List entities) { * notifies them in the chat. */ private void executeSelf(Player sender) { - PlayerModel playerModel = API.getPlayerManager().getPlayerModel(sender); + PlayerProfile playerProfile = PlayerWrapper.getPlayerProfile(sender); + PlayerModel playerModel = playerProfile.getPlayerModel(); playerModel.setIsOperator(true); StormDatabase.getInstance().saveStormModel(playerModel); sender.setPermissionLevel(4); diff --git a/src/main/java/cc/ddev/feather/command/phone/PhoneCommand.java b/src/main/java/cc/ddev/feather/command/phone/PhoneCommand.java deleted file mode 100644 index 850b5c7..0000000 --- a/src/main/java/cc/ddev/feather/command/phone/PhoneCommand.java +++ /dev/null @@ -1,15 +0,0 @@ -package cc.ddev.feather.command.phone; - -import cc.ddev.feather.command.mtworld.subcommands.*; -import net.minestom.server.command.builder.Command; - -public class PhoneCommand extends Command { - public PhoneCommand() { - super("phone"); - addSubcommand(new MTWorldAddCommand()); - addSubcommand(new MTWorldRemoveCommand()); - - setDefaultExecutor((sender, context) -> sender.sendMessage("Usage: /phone ")); - } - -} diff --git a/src/main/java/cc/ddev/feather/command/phone/subcommands/PhoneGetCommand.java b/src/main/java/cc/ddev/feather/command/phone/subcommands/PhoneGetCommand.java deleted file mode 100644 index fd56b37..0000000 --- a/src/main/java/cc/ddev/feather/command/phone/subcommands/PhoneGetCommand.java +++ /dev/null @@ -1,4 +0,0 @@ -package cc.ddev.feather.command.phone.subcommands; - -public class PhoneGetCommand { -} diff --git a/src/main/java/cc/ddev/feather/command/phone/subcommands/PhoneSetCreditCommand.java b/src/main/java/cc/ddev/feather/command/phone/subcommands/PhoneSetCreditCommand.java deleted file mode 100644 index 4478927..0000000 --- a/src/main/java/cc/ddev/feather/command/phone/subcommands/PhoneSetCreditCommand.java +++ /dev/null @@ -1,4 +0,0 @@ -package cc.ddev.feather.command.phone.subcommands; - -public class PhoneSetCreditCommand { -} diff --git a/src/main/java/cc/ddev/feather/database/StormDatabase.java b/src/main/java/cc/ddev/feather/database/StormDatabase.java index 615f570..fa2620e 100644 --- a/src/main/java/cc/ddev/feather/database/StormDatabase.java +++ b/src/main/java/cc/ddev/feather/database/StormDatabase.java @@ -62,9 +62,6 @@ public void init() throws SQLException, ClassNotFoundException { storm.registerModel(new PlayerModel()); storm.registerModel(new BankAccountUserModel()); storm.registerModel(new BankAccountModel()); - storm.registerModel(new PhoneModel()); - storm.registerModel(new PhoneContactsModel()); - storm.registerModel(new PhoneMessagesModel()); storm.runMigrations(); Log.getLogger().info("Successfully connected to the database."); diff --git a/src/main/java/cc/ddev/feather/database/models/PhoneContactsModel.java b/src/main/java/cc/ddev/feather/database/models/PhoneContactsModel.java deleted file mode 100644 index b35a999..0000000 --- a/src/main/java/cc/ddev/feather/database/models/PhoneContactsModel.java +++ /dev/null @@ -1,19 +0,0 @@ -package cc.ddev.feather.database.models; - -import com.craftmend.storm.api.StormModel; -import com.craftmend.storm.api.markers.Column; -import com.craftmend.storm.api.markers.Table; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@EqualsAndHashCode(callSuper = false) -@Table(name = "phonecontacts") -public class PhoneContactsModel extends StormModel { - - @Column(name = "phone_number") - private Integer phoneNumber; - - @Column(name = "contact_phone_number") - private Integer contactPhoneNumber; -} diff --git a/src/main/java/cc/ddev/feather/database/models/PhoneMessagesModel.java b/src/main/java/cc/ddev/feather/database/models/PhoneMessagesModel.java deleted file mode 100644 index 3c2d075..0000000 --- a/src/main/java/cc/ddev/feather/database/models/PhoneMessagesModel.java +++ /dev/null @@ -1,25 +0,0 @@ -package cc.ddev.feather.database.models; - -import com.craftmend.storm.api.StormModel; -import com.craftmend.storm.api.markers.Column; -import com.craftmend.storm.api.markers.Table; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@Data -@EqualsAndHashCode(callSuper = false) -@Table(name = "phonemessages") -public class PhoneMessagesModel extends StormModel { - - @Column(name = "sender") - private Integer senderPhoneNumber; - - @Column(name = "receiver") - private Integer receiverPhoneNumber; - - @Column(name = "message") - private String message; - - @Column(name = "message_read") - private Boolean messageRead; -} diff --git a/src/main/java/cc/ddev/feather/database/models/PhoneModel.java b/src/main/java/cc/ddev/feather/database/models/PhoneModel.java deleted file mode 100644 index e51a8b0..0000000 --- a/src/main/java/cc/ddev/feather/database/models/PhoneModel.java +++ /dev/null @@ -1,24 +0,0 @@ -package cc.ddev.feather.database.models; - -import com.craftmend.storm.api.StormModel; -import com.craftmend.storm.api.markers.Column; -import com.craftmend.storm.api.markers.Table; -import lombok.Data; -import lombok.EqualsAndHashCode; - -import java.util.UUID; - -@Data -@EqualsAndHashCode(callSuper = false) -@Table(name = "phones") -public class PhoneModel extends StormModel { - - @Column(name = "phone_number") - private Integer phoneNumber; - - @Column - private Double credit; - - @Column - private UUID owner; -} diff --git a/src/main/java/cc/ddev/feather/listener/player/PlayerChatListener.java b/src/main/java/cc/ddev/feather/listener/player/PlayerChatListener.java index 3089629..b7d82c4 100644 --- a/src/main/java/cc/ddev/feather/listener/player/PlayerChatListener.java +++ b/src/main/java/cc/ddev/feather/listener/player/PlayerChatListener.java @@ -1,6 +1,5 @@ package cc.ddev.feather.listener.player; -import cc.ddev.feather.api.API; import cc.ddev.feather.api.config.Config; import cc.ddev.feather.database.models.PlayerModel; import cc.ddev.feather.listener.handler.Listen; @@ -9,15 +8,16 @@ import cc.ddev.feather.player.PlayerWrapper; import cc.ddev.feather.utils.ChatUtils; import net.kyori.adventure.text.Component; -import net.minestom.server.entity.Player; import net.minestom.server.event.player.PlayerChatEvent; public class PlayerChatListener implements Listener { @Listen public void onPlayerChat(PlayerChatEvent event) { - Player player = event.getPlayer(); - PlayerModel playerModel = API.getPlayerManager().getPlayerModel(player); + PlayerProfile playerProfile = PlayerWrapper.getPlayerProfile(event.getPlayer()); + if (playerProfile == null) return; + PlayerModel playerModel = playerProfile.getPlayerModel(); + if (playerModel == null) return; Component chatFormatComponent = ChatUtils.translateMiniMessage( Config.Chat.FORMAT @@ -27,7 +27,7 @@ public void onPlayerChat(PlayerChatEvent event) { .replace("", playerModel.getLevelcolor()) .replace("", playerModel.getLevelcolor()) .replace("", playerModel.getLevelcolor()) - .replace("", player.getUsername()) + .replace("", event.getPlayer().getUsername()) .replace("", event.getMessage()) ); diff --git a/src/main/java/cc/ddev/feather/listener/player/PlayerDisconnectListener.java b/src/main/java/cc/ddev/feather/listener/player/PlayerDisconnectListener.java index e4ef377..bc1a464 100644 --- a/src/main/java/cc/ddev/feather/listener/player/PlayerDisconnectListener.java +++ b/src/main/java/cc/ddev/feather/listener/player/PlayerDisconnectListener.java @@ -1,6 +1,5 @@ package cc.ddev.feather.listener.player; -import cc.ddev.feather.api.API; import cc.ddev.feather.api.config.Messages; import cc.ddev.feather.database.StormDatabase; import cc.ddev.feather.database.models.PlayerModel; @@ -19,15 +18,17 @@ public class PlayerDisconnectListener implements Listener { @Listen public void onPlayerDisconnect(PlayerDisconnectEvent event) { final Player player = event.getPlayer(); + PlayerProfile playerProfile = PlayerWrapper.getPlayerProfile(player); + if (playerProfile == null) { + Log.getLogger().warn("Player " + player.getUsername() + " with UUID " + player.getUuid() + " has no player profile!"); + return; + } // Save player model - PlayerModel playerModel = API.getPlayerManager().getPlayerModel(player); - + PlayerModel playerModel = playerProfile.getPlayerModel(); playerModel.setLastLocation(player.getPosition().toString()); playerModel.setUsername(player.getUsername()); - player.setRespawnPoint(player.getPosition()); - StormDatabase.getInstance().saveStormModel(playerModel); Log.getLogger().info("Saved player " + player.getUsername() + " with UUID " + player.getUuid()); diff --git a/src/main/java/cc/ddev/feather/listener/player/PlayerInteractListener.java b/src/main/java/cc/ddev/feather/listener/player/PlayerInteractListener.java deleted file mode 100644 index da0be8b..0000000 --- a/src/main/java/cc/ddev/feather/listener/player/PlayerInteractListener.java +++ /dev/null @@ -1,16 +0,0 @@ -package cc.ddev.feather.listener.player; - -import cc.ddev.feather.api.phone.PhoneManager; -import cc.ddev.feather.listener.handler.Listen; -import cc.ddev.feather.listener.handler.Listener; -import net.minestom.server.event.player.PlayerUseItemEvent; - -public class PlayerInteractListener implements Listener { - - @Listen - public void onPlayerInteract(PlayerUseItemEvent event) { - PhoneManager.getInstance().createNewPhone(1, event.getPlayer().getUuid()); - PhoneManager.getInstance().getPhone(1); - - } -} diff --git a/src/main/java/cc/ddev/feather/listener/player/PlayerLoginListener.java b/src/main/java/cc/ddev/feather/listener/player/PlayerLoginListener.java index babac45..8fd0d82 100644 --- a/src/main/java/cc/ddev/feather/listener/player/PlayerLoginListener.java +++ b/src/main/java/cc/ddev/feather/listener/player/PlayerLoginListener.java @@ -46,7 +46,6 @@ public void onPlayerLogin(AsyncPlayerConfigurationEvent event) { event.setSpawningInstance(Server.getInstanceContainer()); } - // Set the player's respawn point PlayerModel playerModel = API.getPlayerManager().getPlayerModel(player); if (API.getPlayerManager().getLastLocation(player) == null) { player.setRespawnPoint(Config.Spawn.COORDS); diff --git a/src/main/java/cc/ddev/feather/listener/player/PlayerSpawnListener.java b/src/main/java/cc/ddev/feather/listener/player/PlayerSpawnListener.java index 57ac619..3c4caf4 100644 --- a/src/main/java/cc/ddev/feather/listener/player/PlayerSpawnListener.java +++ b/src/main/java/cc/ddev/feather/listener/player/PlayerSpawnListener.java @@ -1,13 +1,11 @@ package cc.ddev.feather.listener.player; -import cc.ddev.feather.api.API; import cc.ddev.feather.api.config.Config; import cc.ddev.feather.api.config.Messages; import cc.ddev.feather.database.StormDatabase; import cc.ddev.feather.database.models.PlayerModel; import cc.ddev.feather.listener.handler.Listen; import cc.ddev.feather.listener.handler.Listener; -import cc.ddev.feather.logger.Log; import cc.ddev.feather.placeholders.Placeholders; import cc.ddev.feather.player.PlayerProfile; import cc.ddev.feather.player.PlayerWrapper; @@ -33,33 +31,40 @@ public void onPlayerSpawn(PlayerSpawnEvent event) { // Check if player is in an MTWorld if (WorldManager.getInstance().isMTWorld(WorldManager.getInstance().getInstanceName(player.getInstance()))) { + PlayerProfile playerProfile = PlayerWrapper.getPlayerProfile(player); + if (playerProfile == null) { + player.kick("Failed to load player profile!"); + return; + } - PlayerModel playerModel = API.getPlayerManager().getPlayerModel(player); + PlayerModel playerModel = playerProfile.getPlayerModel(); + if (playerModel == null) { + player.kick("Failed to load player model!"); + return; + } // Update username if it has changed playerModel.setUsername(player.getUsername()); StormDatabase.getInstance().saveStormModel(playerModel); -// // Set the spawn position -// if (playerModel.getLastLocation() != null) { -// // Extract X, Y and Z from the position string -// String[] rawPosition = playerModel.getLastLocation().split(","); -// double x = Double.parseDouble(rawPosition[0].replace("Pos[x=", "")); -// double y = Double.parseDouble(rawPosition[1].replace("y=", "")); -// double z = Double.parseDouble(rawPosition[2].replace("z=", "")); -// float yaw = Float.parseFloat(rawPosition[3].replace("yaw=", "")); -// float pitch = Float.parseFloat(rawPosition[4].replace("pitch=", "").replace("]", "")); -// Pos pos = new Pos(x, y, z, yaw, pitch); -// -// player.setRespawnPoint(pos); -// player.teleport(pos); -// } else { -// player.setRespawnPoint(Config.Spawn.COORDS); -// player.teleport(Config.Spawn.COORDS); -// } + // Set the spawn position + if (playerModel.getLastLocation() != null) { + // Extract X, Y and Z from the position string + String[] rawPosition = playerModel.getLastLocation().split(","); + double x = Double.parseDouble(rawPosition[0].replace("Pos[x=", "")); + double y = Double.parseDouble(rawPosition[1].replace("y=", "")); + double z = Double.parseDouble(rawPosition[2].replace("z=", "")); + float yaw = Float.parseFloat(rawPosition[3].replace("yaw=", "")); + float pitch = Float.parseFloat(rawPosition[4].replace("pitch=", "").replace("]", "")); + Pos pos = new Pos(x, y, z, yaw, pitch); + player.setRespawnPoint(pos); + player.teleport(pos); + } else { + player.setRespawnPoint(Config.Spawn.COORDS); + player.teleport(Config.Spawn.COORDS); + } - //player.teleport(new Pos(7.5, 300, -3.5)); if (playerModel.getIsOperator()) { player.setPermissionLevel(4); diff --git a/src/main/java/cc/ddev/feather/phone/PhoneInventory.java b/src/main/java/cc/ddev/feather/phone/PhoneInventory.java deleted file mode 100644 index 1dc9021..0000000 --- a/src/main/java/cc/ddev/feather/phone/PhoneInventory.java +++ /dev/null @@ -1,4 +0,0 @@ -package cc.ddev.feather.phone; - -public class PhoneInventory { -} diff --git a/src/main/java/cc/ddev/feather/world/WorldManager.java b/src/main/java/cc/ddev/feather/world/WorldManager.java index ec01d5d..493e94e 100644 --- a/src/main/java/cc/ddev/feather/world/WorldManager.java +++ b/src/main/java/cc/ddev/feather/world/WorldManager.java @@ -10,14 +10,11 @@ import net.minestom.server.instance.Instance; import net.minestom.server.instance.InstanceContainer; import net.minestom.server.tag.Tag; -import net.minestom.server.timer.TaskSchedule; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.File; -import java.time.Duration; import java.util.Collection; -import java.util.concurrent.TimeUnit; public class WorldManager { @@ -48,13 +45,11 @@ public void saveWorlds() { } } - public static InstanceContainer loadWorld(String loadPath) { + public InstanceContainer loadWorld(String loadPath) { InstanceContainer instanceContainer = MinecraftServer.getInstanceManager().createInstanceContainer(); instanceContainer.setChunkLoader(new AnvilLoader(loadPath)); - String worldName = new File(loadPath).getName(); - getInstance().setInstanceName(instanceContainer, worldName); - + setInstanceName(instanceContainer, worldName); Log.getLogger().info("Loaded world \"" + worldName + "\" (UUID: " + instanceContainer.getUniqueId() + ")" + "!"); return instanceContainer;