-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added config.yml to store database connection settings. Added a Datab…
…aseWrapper for an abstraction I find easier to work with, along initialization methods. Added a DatabaseInterface on top of the DatabaseWrapper for "error handling". Created an "msg" class for easy message logging, sending, debugging with hexadecimal and vanilla color support, along PlaceholderAPI support. Created an ItemUtils class for serialization/deserialization of ItemStack to store them in the database as Base64 encoded strings.
- Loading branch information
Showing
10 changed files
with
823 additions
and
19 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/dev/relismdev/playlegendquests/Models/Economy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package dev.relismdev.playlegendquests.Models; | ||
|
||
import org.bukkit.OfflinePlayer; | ||
|
||
/** | ||
* Represents an economy profile associated with a player, containing information about their balance. | ||
*/ | ||
public class Economy { | ||
|
||
private static OfflinePlayer player; // The associated player | ||
private static int balance; // The player's balance | ||
|
||
/** | ||
* Constructs an Economy object associated with the specified player and balance. | ||
* | ||
* @param p The OfflinePlayer associated with this economy profile. | ||
* @param balance The balance associated with the player's economy. | ||
*/ | ||
public Economy(OfflinePlayer p, int balance) { | ||
this.player = p; | ||
this.balance = balance; | ||
} | ||
|
||
/** | ||
* Retrieves the OfflinePlayer associated with this economy profile. | ||
* | ||
* @return The OfflinePlayer associated with this economy profile. | ||
*/ | ||
public static OfflinePlayer getPlayer() { | ||
return player; | ||
} | ||
|
||
/** | ||
* Retrieves the balance associated with this player's economy. | ||
* | ||
* @return The balance associated with this player's economy. | ||
*/ | ||
public static int getBalance() { | ||
return balance; | ||
} | ||
|
||
/** | ||
* Sets the balance associated with this player's economy. | ||
* | ||
* @param balance The new balance to set for this player's economy. | ||
*/ | ||
public static void setBalance(int balance) { | ||
Economy.balance = balance; | ||
} | ||
} | ||
|
114 changes: 114 additions & 0 deletions
114
src/main/java/dev/relismdev/playlegendquests/Models/Quest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package dev.relismdev.playlegendquests.Models; | ||
|
||
import org.bukkit.inventory.ItemStack; | ||
|
||
/** | ||
* Represents a quest in the game, encapsulating its unique identifier, name, description, | ||
* reward in coins, and an item rewarded upon completion. | ||
*/ | ||
public class Quest { | ||
|
||
private final String id; // Unique identifier of the quest | ||
private String name; // Name of the quest | ||
private String description; // Description of the quest | ||
private int reward_coins; // Coins rewarded upon completion | ||
private ItemStack reward_item; // Item rewarded upon completion | ||
|
||
/** | ||
* Constructs a Quest object with the specified details. | ||
* | ||
* @param id The unique identifier of the quest. | ||
* @param name The name of the quest. | ||
* @param description The description of the quest. | ||
* @param reward_coins The amount of coins rewarded for completing the quest. | ||
* @param reward_item The ItemStack representing the item rewarded for completing the quest. | ||
*/ | ||
public Quest(String id, String name, String description, int reward_coins, ItemStack reward_item) { | ||
this.id = id; | ||
this.name = name; | ||
this.description = description; | ||
this.reward_coins = reward_coins; | ||
this.reward_item = reward_item; | ||
} | ||
|
||
/** | ||
* Retrieves the unique identifier of the quest. | ||
* | ||
* @return The unique identifier of the quest. | ||
*/ | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
/** | ||
* Retrieves the name of the quest. | ||
* | ||
* @return The name of the quest. | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* Sets the name of the quest. | ||
* | ||
* @param name The new name of the quest. | ||
*/ | ||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
/** | ||
* Retrieves the description of the quest. | ||
* | ||
* @return The description of the quest. | ||
*/ | ||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
/** | ||
* Sets the description of the quest. | ||
* | ||
* @param description The new description of the quest. | ||
*/ | ||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
/** | ||
* Retrieves the amount of coins rewarded for completing the quest. | ||
* | ||
* @return The amount of coins rewarded for completing the quest. | ||
*/ | ||
public int getReward_coins() { | ||
return reward_coins; | ||
} | ||
|
||
/** | ||
* Sets the amount of coins rewarded for completing the quest. | ||
* | ||
* @param reward_coins The new amount of coins rewarded for completing the quest. | ||
*/ | ||
public void setReward_coins(int reward_coins) { | ||
this.reward_coins = reward_coins; | ||
} | ||
|
||
/** | ||
* Retrieves the item rewarded for completing the quest. | ||
* | ||
* @return The ItemStack representing the item rewarded for completing the quest. | ||
*/ | ||
public ItemStack getReward_item() { | ||
return reward_item; | ||
} | ||
|
||
/** | ||
* Sets the item rewarded for completing the quest. | ||
* | ||
* @param reward_item The new ItemStack representing the item rewarded for completing the quest. | ||
*/ | ||
public void setReward_item(ItemStack reward_item) { | ||
this.reward_item = reward_item; | ||
} | ||
} |
14 changes: 12 additions & 2 deletions
14
src/main/java/dev/relismdev/playlegendquests/Playlegendquests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
package dev.relismdev.playlegendquests; | ||
|
||
import dev.relismdev.playlegendquests.storage.DatabaseWrapper; | ||
import dev.relismdev.playlegendquests.utils.DatabaseInterface; | ||
import dev.relismdev.playlegendquests.utils.msg; | ||
import org.bukkit.plugin.Plugin; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public final class Playlegendquests extends JavaPlugin { | ||
|
||
private static Playlegendquests plugin; | ||
|
||
@Override | ||
public void onEnable() { | ||
plugin = this; | ||
saveDefaultConfig(); | ||
DatabaseWrapper.init(); | ||
// Plugin startup logic | ||
|
||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
// Plugin shutdown logic | ||
DatabaseWrapper.disable(); | ||
} | ||
|
||
public static Playlegendquests getPlugin(){ return plugin; } | ||
} |
Oops, something went wrong.