Skip to content

Commit

Permalink
more improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
kr45732 committed Jun 27, 2024
1 parent 9f77d5f commit 06948c1
Show file tree
Hide file tree
Showing 6 changed files with 167 additions and 242 deletions.
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ If you are stuck or encounter a problem in the steps below, create an issue and
- 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.
- Server settings: should be automatically generated by Spring on first startup
- Server settings: I highly suggest to let Spring automatically generate it on the first startup
- Linked accounts
- Leaderboards: there are 4 leaderboards (all_lb, ironman_lb, stranded_lb, and selected_lb) with identical schemas. The first 3 are self-explanatory. The last one is a cache that stores players' last played profile for automatic nickname updates, automatic roles claim, etc
- Caching: there is `guild` (used for tracking guilds for "/serverlb"), `json_cache` (used to cache json responses from the Hypixel API), and `json_storage` (persistent cache)
- Leaderboards
- Caching
4. Emojis: At the moment, there are around 90 custom emoji servers. To create your own:
- Make "IdToEmojiMappings.json" an empty JSON object
- Create and add the bot to 90 servers with the name "Skyblock Plus - Emoji Server xx" (xx is the server number starting at 1)
Expand All @@ -55,13 +55,17 @@ 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.processAll()`
- 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. Hardcoded constants you will need to change:
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)
- Create a new channel in your PRIMARY_GUILD
6. Hardcoded constants you will need to change:
- You will need to update all emoji maps in the Constants.json from [skyblock-plus-data](https://github.com/kr45732/skyblock-plus-data/blob/main/Constants.json) with your own emojis
- Create 2 messages in a channel to be used for the scuffed event system. Update the assignment of messageId in `com.skyblockplus.features.event.EventHandler` on L46. Update the channel on L57
- Create 2 messages in a channel to be used for the scuffed event system (they will be constantly edited, so they must not be deleted). These messages Update the assignment of messageId in `com.skyblockplus.features.event.EventHandler` on L46. Update the channel on L57
- More will be added as I find/remember them
6. Running the bot:
7. Running the bot:
- Build using gradle or gradlew: `gradle build` to create a jar at "build/libs/SkyblockPlus-0.0.1.jar"
- Run the jar using Java 17 (example using systemctl to run it in the background [here](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/skyblock-plus.service))
- Register slash commands using the `d-slash` prefix command

## Bug reports
Feel free to make an issue or report the bug using the support server linked below.
Expand Down
2 changes: 1 addition & 1 deletion setup-resources/ExampleDevSettings.properties
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ JACOB_KEY =
# Hypixel API key from https://developer.hypixel.net/
HYPIXEL_API_KEY =

# Key (ADMIN_API_KEY) to access my rust-query-api (https://github.com/kr45732/rust-query-api)
# key (ADMIN_API_KEY) to access your self-hosted https://github.com/kr45732/rust-query-api (this is NOT your Hypixel API key)
# you will have to self-host this as it is used for many things related to auctions such as price calculations, auction flipper, etc
AUCTION_API_KEY =

Expand Down
67 changes: 22 additions & 45 deletions setup-resources/leaderboard-cache-dump.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
--
-- PostgreSQL database dump
--

-- Dumped from database version 14.4


--
-- Name: all_lb; Type: TABLE; Schema: public; Owner: postgres
-- Name: all_lb; Type: TABLE; Schema: public
--

CREATE TABLE public.all_lb (
Expand Down Expand Up @@ -1049,10 +1045,8 @@ CREATE TABLE public.all_lb (
);


ALTER TABLE public.all_lb OWNER TO postgres;

--
-- Name: guild; Type: TABLE; Schema: public; Owner: postgres
-- Name: guild; Type: TABLE; Schema: public
--

CREATE TABLE public.guild (
Expand All @@ -1064,10 +1058,8 @@ CREATE TABLE public.guild (
);


ALTER TABLE public.guild OWNER TO postgres;

--
-- Name: ironman_lb; Type: TABLE; Schema: public; Owner: postgres
-- Name: ironman_lb; Type: TABLE; Schema: public
--

CREATE TABLE public.ironman_lb (
Expand Down Expand Up @@ -2110,10 +2102,8 @@ CREATE TABLE public.ironman_lb (
);


ALTER TABLE public.ironman_lb OWNER TO postgres;

--
-- Name: json_cache; Type: TABLE; Schema: public; Owner: postgres
-- Name: json_cache; Type: TABLE; Schema: public
--

CREATE TABLE public.json_cache (
Expand All @@ -2123,10 +2113,8 @@ CREATE TABLE public.json_cache (
);


ALTER TABLE public.json_cache OWNER TO postgres;

--
-- Name: json_storage; Type: TABLE; Schema: public; Owner: postgres
-- Name: json_storage; Type: TABLE; Schema: public
--

CREATE TABLE public.json_storage (
Expand All @@ -2135,10 +2123,8 @@ CREATE TABLE public.json_storage (
);


ALTER TABLE public.json_storage OWNER TO postgres;

--
-- Name: selected_lb; Type: TABLE; Schema: public; Owner: postgres
-- Name: selected_lb; Type: TABLE; Schema: public
--

CREATE TABLE public.selected_lb (
Expand Down Expand Up @@ -3181,10 +3167,8 @@ CREATE TABLE public.selected_lb (
);


ALTER TABLE public.selected_lb OWNER TO postgres;

--
-- Name: stranded_lb; Type: TABLE; Schema: public; Owner: postgres
-- Name: stranded_lb; Type: TABLE; Schema: public
--

CREATE TABLE public.stranded_lb (
Expand Down Expand Up @@ -4227,113 +4211,106 @@ CREATE TABLE public.stranded_lb (
);


ALTER TABLE public.stranded_lb OWNER TO postgres;

--
-- Name: all_lb all_lb_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
-- Name: all_lb all_lb_pkey; Type: CONSTRAINT; Schema: public
--

ALTER TABLE ONLY public.all_lb
ADD CONSTRAINT all_lb_pkey PRIMARY KEY (uuid);


--
-- Name: guild guild_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
-- Name: guild guild_pkey; Type: CONSTRAINT; Schema: public
--

ALTER TABLE ONLY public.guild
ADD CONSTRAINT guild_pkey PRIMARY KEY (guild_id);


--
-- Name: ironman_lb ironman_lb_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
-- Name: ironman_lb ironman_lb_pkey; Type: CONSTRAINT; Schema: public
--

ALTER TABLE ONLY public.ironman_lb
ADD CONSTRAINT ironman_lb_pkey PRIMARY KEY (uuid);


--
-- Name: json_cache json_cache_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
-- Name: json_cache json_cache_pkey; Type: CONSTRAINT; Schema: public
--

ALTER TABLE ONLY public.json_cache
ADD CONSTRAINT json_cache_pkey PRIMARY KEY (id);


--
-- Name: json_storage json_storage_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
-- Name: json_storage json_storage_pkey; Type: CONSTRAINT; Schema: public
--

ALTER TABLE ONLY public.json_storage
ADD CONSTRAINT json_storage_pkey PRIMARY KEY (id);


--
-- Name: selected_lb selected_lb_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
-- Name: selected_lb selected_lb_pkey; Type: CONSTRAINT; Schema: public
--

ALTER TABLE ONLY public.selected_lb
ADD CONSTRAINT selected_lb_pkey PRIMARY KEY (uuid);


--
-- Name: stranded_lb stranded_lb_pkey; Type: CONSTRAINT; Schema: public; Owner: postgres
-- Name: stranded_lb stranded_lb_pkey; Type: CONSTRAINT; Schema: public
--

ALTER TABLE ONLY public.stranded_lb
ADD CONSTRAINT stranded_lb_pkey PRIMARY KEY (uuid);


--
-- Name: all_lb_networth_idx; Type: INDEX; Schema: public; Owner: postgres
-- Name: all_lb_networth_idx; Type: INDEX; Schema: public
--

CREATE INDEX all_lb_networth_idx ON public.all_lb USING btree (networth);


--
-- Name: all_lb_username_idx; Type: INDEX; Schema: public; Owner: postgres
-- Name: all_lb_username_idx; Type: INDEX; Schema: public
--

CREATE INDEX all_lb_username_idx ON public.all_lb USING gist (username public.gist_trgm_ops);


--
-- Name: ironman_lb_networth_idx; Type: INDEX; Schema: public; Owner: postgres
-- Name: ironman_lb_networth_idx; Type: INDEX; Schema: public
--

CREATE INDEX ironman_lb_networth_idx ON public.ironman_lb USING btree (networth);


--
-- Name: selected_lb_networth_idx; Type: INDEX; Schema: public; Owner: postgres
-- Name: selected_lb_networth_idx; Type: INDEX; Schema: public
--

CREATE INDEX selected_lb_networth_idx ON public.selected_lb USING btree (networth);


--
-- Name: selected_lb_username_idx; Type: INDEX; Schema: public; Owner: postgres
-- Name: selected_lb_username_idx; Type: INDEX; Schema: public
--

CREATE INDEX selected_lb_username_idx ON public.selected_lb USING gist (username public.gist_trgm_ops);


--
-- Name: stranded_lb_networth_idx; Type: INDEX; Schema: public; Owner: postgres
-- Name: stranded_lb_networth_idx; Type: INDEX; Schema: public
--

CREATE INDEX stranded_lb_networth_idx ON public.stranded_lb USING btree (networth);


--
-- Name: stranded_lb_username_idx; Type: INDEX; Schema: public; Owner: postgres
-- Name: stranded_lb_username_idx; Type: INDEX; Schema: public
--

CREATE INDEX stranded_lb_username_idx ON public.stranded_lb USING gist (username public.gist_trgm_ops);


--
-- PostgreSQL database dump complete
--
CREATE INDEX stranded_lb_username_idx ON public.stranded_lb USING gist (username public.gist_trgm_ops);
73 changes: 73 additions & 0 deletions setup-resources/linked-accounts-dump.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
-- Dumped from database version 14.1


--
-- Name: linked_account; Type: TABLE; Schema: public
--

CREATE TABLE public.linked_account (
id integer NOT NULL,
last_updated bigint,
discord character varying(255),
username character varying(255),
uuid character varying(255)
);


--
-- Name: linked_account_id_seq; Type: SEQUENCE; Schema: public
--

CREATE SEQUENCE public.linked_account_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;


--
-- Name: linked_account_id_seq; Type: SEQUENCE OWNED BY; Schema: public
--

ALTER SEQUENCE public.linked_account_id_seq OWNED BY public.linked_account.id;


--
-- Name: linked_account id; Type: DEFAULT; Schema: public
--

ALTER TABLE ONLY public.linked_account ALTER COLUMN id SET DEFAULT nextval('public.linked_account_id_seq'::regclass);


--
-- Name: linked_account linked_account_discord_key; Type: CONSTRAINT; Schema: public
--

ALTER TABLE ONLY public.linked_account
ADD CONSTRAINT linked_account_discord_key UNIQUE (discord);


--
-- Name: linked_account linked_account_pkey; Type: CONSTRAINT; Schema: public
--

ALTER TABLE ONLY public.linked_account
ADD CONSTRAINT linked_account_pkey PRIMARY KEY (id);


--
-- Name: linked_account linked_account_username_key; Type: CONSTRAINT; Schema: public
--

ALTER TABLE ONLY public.linked_account
ADD CONSTRAINT linked_account_username_key UNIQUE (username);


--
-- Name: linked_account linked_account_uuid_key; Type: CONSTRAINT; Schema: public
--

ALTER TABLE ONLY public.linked_account
ADD CONSTRAINT linked_account_uuid_key UNIQUE (uuid);
15 changes: 9 additions & 6 deletions setup-resources/schemas.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
If you're really lazy or completely stuck you might be able to just copy and paste SQL from the database dumps. I haven't tested this so no guarantee it will work. [server-settings-linked-accounts-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/server-settings-linked-accounts-dump.sql) has the SQL for server settings and linked accounts. [leaderboard-cache-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/leaderboard-cache-dump.sql) has the SQL for leaderboards and caching.
If you're really lazy or completely stuck you might be able to just copy and paste SQL from the database dumps. I haven't tested this so no guarantee it will work. [server-settings-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/server-settings-dump.sql) has the SQL for server settings. [linked-accounts-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/linked-accounts-dump.sql) has the SQL for linked accounts. [leaderboard-cache-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/leaderboard-cache-dump.sql) has the SQL for leaderboards and caching.


# Server settings schemas
Should be automatically created on first startup by Spring. If you need to manually create it, try using [server-settings-linked-accounts-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/server-settings-linked-accounts-dump.sql).
# Server Settings Schema
I highly suggest to let Spring automatically create this on first startup. Only as a backup, try using [server-settings-dump.sql](https://github.com/kr45732/skyblock-plus/blob/master/setup-resources/server-settings-dump.sql) to manually create it.

# Linked accounts schema
# Linked Accounts Schema
```postgresql
Table "public.linked_account"
Column | Type | Collation | Nullable | Default
Expand All @@ -21,8 +21,8 @@ Indexes:
"linked_account_uuid_key" UNIQUE CONSTRAINT, btree (uuid)
```

# Leaderboards schema
All four leaderboards (all_lb, ironman_lb, stranded_lb, and selected_lb) have the same schema, just different table names.
# Leaderboards Schema
There are 4 leaderboards (all_lb, ironman_lb, stranded_lb, and selected_lb) with identical schemas. The first 3 are self-explanatory. The last one is a cache that stores players' last played profile for automatic nickname updates, automatic roles claim, etc
```postgresql
Table "public.all_lb"
Column | Type | Collation | Nullable | Default
Expand Down Expand Up @@ -1071,6 +1071,7 @@ Indexes:

# Cache Schemas
### guild
Used for tracking guilds for "/serverlb" command
```postgresql
Table "public.guild"
Column | Type | Collation | Nullable | Default
Expand All @@ -1085,6 +1086,7 @@ Indexes:
```

### json_cache
Used to cache JSON responses from the Hypixel API
```postgresql
Table "public.json_cache"
Column | Type | Collation | Nullable | Default
Expand All @@ -1097,6 +1099,7 @@ Indexes:
```

### json_storage
Persistent cache for features like auction tracker, dungeon parties, etc
```postgresql
Table "public.json_storage"
Column | Type | Collation | Nullable | Default
Expand Down
Loading

0 comments on commit 06948c1

Please sign in to comment.