Skip to content

Commit

Permalink
Added config.yml to store database connection settings. Added a Datab…
Browse files Browse the repository at this point in the history
…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
Relism committed Jan 8, 2024
1 parent a168640 commit 6fc4d0a
Show file tree
Hide file tree
Showing 10 changed files with 823 additions and 19 deletions.
17 changes: 0 additions & 17 deletions .github/workflows/deploy-docs.yml

This file was deleted.

15 changes: 15 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -71,5 +75,16 @@
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.33</version>
</dependency>
</dependencies>
</project>
51 changes: 51 additions & 0 deletions src/main/java/dev/relismdev/playlegendquests/Models/Economy.java
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 src/main/java/dev/relismdev/playlegendquests/Models/Quest.java
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 src/main/java/dev/relismdev/playlegendquests/Playlegendquests.java
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; }
}
Loading

0 comments on commit 6fc4d0a

Please # to comment.