Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
kr45732 committed Jun 27, 2024
1 parent f9dfc22 commit 97e0e46
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 20 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ If you are stuck or encounter a problem in the steps below, create an issue and
- Same thing as above with JACOB_KEY, you probably won't ever use that endpoint, but you don't want anyone to be able to POST data to it
- Ensure the AUCTION_API_KEY is the same as the ADMIN_API_KEY of your self-hosted rust-query-api
- If you are self-hosted [hste](https://github.com/kr45732/hste), then HASTE_KEY should be the same as the KEY set on there
3. Databases: At the moment, there are two databases instead of a single one. You might be able to combine it into one without needing to modify code by setting both databases to the same URL, but I haven't tested that. Refer to [setup-resources](https://github.com/kr45732/skyblock-plus/tree/master/setup-resources) for schemas and database dumps. You will also need to install the [pg_trgm module](https://www.postgresql.org/docs/current/pgtrgm.html) on your databases.
3. Databases: At the moment, there are two databases instead of a single one. You might be able to combine it into one without needing to modify code by setting both databases to the same URL, but I haven't tested that. Refer to [setup-resources](https://github.com/kr45732/skyblock-plus/tree/master/setup-resources) for schemas and database dumps. You will also need to install the [pg_trgm module](https://www.postgresql.org/docs/current/pgtrgm.html) on your databases. This can be done by executing `CREATE EXTENSION pg_trgm` when connected to your database
- [Server Settings Schema](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/schemas.md#server-settings-schema)
- [Linked Accounts Schema](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/schemas.md#linked-accounts-schema)
- [Leaderboards Schema](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/schemas.md#leaderboards-schema)
Expand All @@ -56,7 +56,11 @@ If you are stuck or encounter a problem in the steps below, create an issue and
- Using the evaluate command run `ev com.skyblockplus.utils.EmojiUpdater.runEmojis(json)` where json is a haste link to the output JSON you got from processAll() above
- Paste the JSON output of runEmojis into the "IdToEmojiMappings.json"
5. Data repository: you will need to make your own clone of the skyblock-plus-data repository so your bot can automatically update it:
- Clone [skyblock-plus-data](https://github.com/kr45732/skyblock-plus-data)
- Fork [skyblock-plus-data](https://github.com/kr45732/skyblock-plus-data)
- Set "DATA_REPO_GITHUB" in DevSettings.properties to point to your repository
- Navigate to "Settings.json" of your repository and edit the following:
- Change "ahApiUrl" to point to your self-hosted rust-query-api
- Change "hasteUrl" to point to your self-hosted hastebin
- Create a new channel in your PRIMARY_GUILD and set "NEU_REPO_UPDATE_CHANNEL_ID" in DevSettings.properties
- Join [Moulberry's Bush](https://discord.gg/moulberry)
- Follow "#item-repo-github" and send it to the channel you just created
Expand Down
5 changes: 4 additions & 1 deletion setup-resources/ExampleDevSettings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ BOT_STATUS_CHANNEL_ID =
# text channel in PRIMARY_GUILD where networth bug reports are logged to
NETWORTH_BUG_REPORT_CHANNEL_ID =

# text channel where
# text channel where NEU-repo updates are forward to (see step 6 in README)
NEU_REPO_UPDATE_CHANNEL_ID =

# GitHub link to your clone of https://github.com/kr45732/skyblock-plus-data formatted as is "username/repo" (e.g. "kr45732/skyblock-plus-data")
DATA_REPO_GITHUB =

# used for prefix commands (mainly dev commands)
# requires message content intent to be enabled to use prefix
# if you don't have the message content intent & want to use prefix commands, then just mention the bot instead of a prefix
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/skyblockplus/utils/ApiHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public static void initialize() {
public static void updateCaches() {
try {
cacheApplyGuildUsers();
leaderboardDatabase.cacheJacob();
leaderboardDatabase.cacheCommandUses();
leaderboardDatabase.cacheAuctionTracker();
leaderboardDatabase.cacheTokens();
Expand All @@ -95,7 +96,7 @@ public static void updateCaches() {
}

public static void initializeConstants() {
JsonElement settings = getJson("https://raw.githubusercontent.com/kr45732/skyblock-plus-data/main/Settings.json");
JsonElement settings = getJson("https://raw.githubusercontent.com/" + DATA_REPO_GITHUB + "/main/Settings.json");
ahApiUrl = higherDepth(settings, "ahApiUrl").getAsString();
mojangApiNum = higherDepth(settings, "mojangApiNum", 0);
allowMojangApi = higherDepth(settings, "allowMojangApi", false);
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/com/skyblockplus/utils/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
import static com.skyblockplus.utils.utils.HttpUtils.getJson;
import static com.skyblockplus.utils.utils.JsonUtils.*;
import static com.skyblockplus.utils.utils.StringUtils.capitalizeString;
import static com.skyblockplus.utils.utils.Utils.getEmoji;
import static com.skyblockplus.utils.utils.Utils.gson;
import static com.skyblockplus.utils.utils.Utils.*;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
Expand Down Expand Up @@ -1395,7 +1394,7 @@ public class Constants {

public static void initialize() {
try {
CONSTANTS = getJson("https://raw.githubusercontent.com/kr45732/skyblock-plus-data/main/Constants.json").getAsJsonObject();
CONSTANTS = getJson("https://raw.githubusercontent.com/" + DATA_REPO_GITHUB + "/main/Constants.json").getAsJsonObject();

Type mapStringString = new TypeToken<Map<String, String>>() {}.getType();
Type listInteger = new TypeToken<List<Integer>>() {}.getType();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/skyblockplus/utils/EmojiUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public static JsonElement getMissing(String... url) {
.getAsJsonObject()
: getJson(url[0])).getAsJsonObject()
.keySet();
Set<String> allItems = getJson("https://raw.githubusercontent.com/kr45732/skyblock-plus-data/main/InternalNameMappings.json")
Set<String> allItems = getJson("https://raw.githubusercontent.com/" + DATA_REPO_GITHUB + "/main/InternalNameMappings.json")
.getAsJsonObject()
.keySet();
allItems.removeIf(processedItemsSet::contains);
Expand All @@ -85,7 +85,7 @@ public static JsonObject processAll() {
}

Collection<JsonElement> sbItems = getSkyblockItemsJson().values();
Set<String> allSbItems = getJson("https://raw.githubusercontent.com/kr45732/skyblock-plus-data/main/InternalNameMappings.json")
Set<String> allSbItems = getJson("https://raw.githubusercontent.com/" + DATA_REPO_GITHUB + "/main/InternalNameMappings.json")
.getAsJsonObject()
.keySet();
Set<String> added = JsonParser
Expand Down
15 changes: 7 additions & 8 deletions src/main/java/com/skyblockplus/utils/utils/JsonUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static com.skyblockplus.utils.Constants.getConstant;
import static com.skyblockplus.utils.utils.HttpUtils.*;
import static com.skyblockplus.utils.utils.StringUtils.nameToId;
import static com.skyblockplus.utils.utils.Utils.DATA_REPO_GITHUB;
import static com.skyblockplus.utils.utils.Utils.executor;

import com.google.gson.JsonArray;
Expand Down Expand Up @@ -99,7 +100,7 @@ public static JsonObject getLowestBinJson() {
public static JsonObject getInternalJsonMappings() {
if (internalJsonMappings == null) {
internalJsonMappings =
getJsonObject("https://raw.githubusercontent.com/kr45732/skyblock-plus-data/main/InternalNameMappings.json");
getJsonObject("https://raw.githubusercontent.com/" + DATA_REPO_GITHUB + "/main/InternalNameMappings.json");
}

return internalJsonMappings;
Expand Down Expand Up @@ -334,7 +335,7 @@ public static JsonObject getMiscJson() {

public static JsonObject getDungeonLootJson() {
if (dungeonLootJson == null) {
dungeonLootJson = getJsonObject("https://raw.githubusercontent.com/kr45732/skyblock-plus-data/main/DungeonLoot.json");
dungeonLootJson = getJsonObject("https://raw.githubusercontent.com/" + DATA_REPO_GITHUB + "/main/DungeonLoot.json");
for (Map.Entry<String, JsonElement> floor : dungeonLootJson.entrySet()) {
for (Map.Entry<String, JsonElement> chest : floor.getValue().getAsJsonObject().entrySet()) {
for (JsonElement item : chest.getValue().getAsJsonArray()) {
Expand All @@ -351,7 +352,7 @@ public static JsonObject getDungeonLootJson() {

public static JsonObject getDragonLootJson() {
if (dragonLootJson == null) {
dragonLootJson = getJsonObject("https://raw.githubusercontent.com/kr45732/skyblock-plus-data/main/DragonLoot.json");
dragonLootJson = getJsonObject("https://raw.githubusercontent.com/" + DATA_REPO_GITHUB + "/main/DragonLoot.json");
}

return dragonLootJson;
Expand Down Expand Up @@ -409,15 +410,15 @@ public static JsonObject getMuseumCategoriesJson() {

public static JsonObject getBitsJson() {
if (bitsJson == null) {
bitsJson = getJsonObject("https://raw.githubusercontent.com/kr45732/skyblock-plus-data/main/BitPrices.json");
bitsJson = getJsonObject("https://raw.githubusercontent.com/" + DATA_REPO_GITHUB + "/main/BitPrices.json");
}

return bitsJson;
}

public static JsonObject getCopperJson() {
if (copperJson == null) {
copperJson = getJsonObject("https://raw.githubusercontent.com/kr45732/skyblock-plus-data/main/CopperPrices.json");
copperJson = getJsonObject("https://raw.githubusercontent.com/" + DATA_REPO_GITHUB + "/main/CopperPrices.json");
}

return copperJson;
Expand Down Expand Up @@ -534,9 +535,7 @@ public static JsonObject getCollectionsJson() {

public static JsonObject getPriceOverrideJson() {
if (priceOverrideJson == null) {
JsonElement splitPriceOverrides = getJson(
"https://raw.githubusercontent.com/kr45732/skyblock-plus-data/main/PriceOverrides.json"
)
JsonElement splitPriceOverrides = getJson("https://raw.githubusercontent.com/" + DATA_REPO_GITHUB + "/main/PriceOverrides.json")
.getAsJsonObject();
priceOverrideJson = higherDepth(splitPriceOverrides, "automatic").getAsJsonObject();
vanillaItems.addAll(priceOverrideJson.keySet());
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/com/skyblockplus/utils/utils/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public class Utils {
public static String ERROR_LOG_CHANNEL_ID = "";
public static String BOT_STATUS_CHANNEL_ID = "";
public static String NEU_REPO_UPDATE_CHANNEL_ID = "";
public static String DATA_REPO_GITHUB = "";
public static TextChannel errorLogChannel;
public static ShardManager jda;
public static Database database;
Expand Down Expand Up @@ -319,6 +320,7 @@ public static void initialize() {
ERROR_LOG_CHANNEL_ID = (String) appProps.get("ERROR_LOG_CHANNEL_ID");
BOT_STATUS_CHANNEL_ID = (String) appProps.get("BOT_STATUS_CHANNEL_ID");
NEU_REPO_UPDATE_CHANNEL_ID = (String) appProps.get("NEU_REPO_UPDATE_CHANNEL_ID");
DATA_REPO_GITHUB = (String) appProps.get("DATA_REPO_GITHUB");
} catch (IOException e) {
HYPIXEL_API_KEY = System.getenv("HYPIXEL_API_KEY");
BOT_TOKEN = System.getenv("BOT_TOKEN");
Expand Down Expand Up @@ -349,6 +351,7 @@ public static void initialize() {
ERROR_LOG_CHANNEL_ID = System.getenv("ERROR_LOG_CHANNEL_ID");
BOT_STATUS_CHANNEL_ID = System.getenv("BOT_STATUS_CHANNEL_ID");
NEU_REPO_UPDATE_CHANNEL_ID = System.getenv("NEU_REPO_UPDATE_CHANNEL_ID");
DATA_REPO_GITHUB = System.getenv("DATA_REPO_GITHUB");
}
}

Expand Down Expand Up @@ -846,7 +849,7 @@ public static void updateDataRepo() {

Git skyblockPlusDataRepo = Git
.cloneRepository()
.setURI("https://github.com/kr45732/skyblock-plus-data.git")
.setURI("https://github.com/" + DATA_REPO_GITHUB + ".git")
.setDirectory(skyblockPlusDir)
.call();

Expand All @@ -868,8 +871,8 @@ public static void updateDataRepo() {
skyblockPlusDataRepo
.commit()
.setAllowEmpty(false)
.setAuthor("kr45632", "[email protected]")
.setCommitter("kr45632", "[email protected]")
.setAuthor("kr45732", "[email protected]")
.setCommitter("kr45732", "[email protected]")
.setMessage("Automatic update (" + neuRepo.log().setMaxCount(1).call().iterator().next().getName() + ")")
.call();
skyblockPlusDataRepo.push().setCredentialsProvider(new UsernamePasswordCredentialsProvider(GITHUB_TOKEN, "")).call();
Expand Down

0 comments on commit 97e0e46

Please sign in to comment.