Skip to content

Commit 0ae0405

Browse files
committed
Coverted website to using new system for tricks.
1 parent bf97027 commit 0ae0405

4 files changed

Lines changed: 9 additions & 17 deletions

File tree

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ dependencies {
9393

9494
launchtarget("org.mangorage:mangobotlaunchtarget:0.1.8")
9595

96-
plugin('org.mangorage:mangobot:12.0.89')
97-
plugin('org.mangorage:mangobotplugin:12.0.50')
96+
plugin('org.mangorage:mangobot:12.0.96')
97+
plugin('org.mangorage:mangobotplugin:12.0.57')
9898

9999
library('org.eclipse.jetty:jetty-server:11.0.16')
100100
library('org.eclipse.jetty:jetty-servlet:11.0.16')

src/main/java/org/mangorage/mangobotsite/MangoBotSite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void load() {
4141
var pl = PluginManager.getInstance().getPlugin("mangobot").getInstance(MangoBot.class);
4242

4343
ObjectMap objectMap = new ObjectMap();
44-
objectMap.put("trickCommand", pl.getCommandManager().getCommand("trick"));
44+
objectMap.put("trickManager", pl.getTrickManager());
4545
objectMap.put("jda", pl.getJDA());
4646
objectMap.put(WebConstants.FILE_MANAGER, fileUploadManager);
4747
objectMap.put(WebConstants.ENTITY_MANAGER, getEntityManager());

src/main/java/org/mangorage/mangobotsite/website/WebServer.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ public static void startWebServerSafely(ObjectMap objectMap) {
5656
}).start();
5757
}
5858

59-
public static void main(String[] args) {
60-
ObjectMap map = new ObjectMap();
61-
map.put(WebConstants.FILE_MANAGER, new FileUploadManager(Path.of("webpage-root/uploads")));
62-
startWebServerSafely(map);
63-
}
64-
6559
public static void startWebServer(ObjectMap objectMap) throws Exception {
6660
Server server = new Server();
6761

src/main/java/org/mangorage/mangobotsite/website/servlet/TricksServlet.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
import jakarta.servlet.http.HttpServletResponse;
66
import net.dv8tion.jda.api.JDA;
77
import org.mangorage.mangobotplugin.commands.trick.Trick;
8-
import org.mangorage.mangobotplugin.commands.trick.TrickCommand;
9-
import org.mangorage.mangobotsite.website.impl.ObjectMap;
8+
import org.mangorage.mangobotplugin.commands.trick.TrickManager;
109
import org.mangorage.mangobotsite.website.impl.StandardHttpServlet;
1110
import org.mangorage.mangobotsite.website.util.MapBuilder;
12-
import org.mangorage.mangobotsite.website.util.WebConstants;
1311
import java.io.IOException;
1412
import java.time.Instant;
1513
import java.util.Comparator;
@@ -44,7 +42,7 @@ private static long getLong(String value) {
4442
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
4543
// Retrieve shared objects from the servlet context
4644
var map = getObjectMap();
47-
var command = map.get("trickCommand", TrickCommand.class);
45+
var trickManager = map.get("trickManager", TrickManager.class);
4846
var jda = map.get("jda", JDA.class);
4947

5048
resp.setContentType("text/html");
@@ -54,7 +52,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
5452
if (guildId != null) {
5553
try {
5654
long id = Long.parseLong(guildId);
57-
if (command.getTricksForGuild(id).isEmpty()) {
55+
if (trickManager.getTricksForGuild(id).isEmpty()) {
5856
processTemplate(
5957
MapBuilder.of()
6058
.self(this)
@@ -82,7 +80,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
8280
}
8381
}
8482

85-
var trick = guildId != null && trickId != null ? command.getTrick(trickId, Long.parseLong(guildId)) : null;
83+
var trick = guildId != null && trickId != null ? trickManager.getTrickForGuildByName(Long.parseLong(guildId), trickId) : null;
8684

8785
if (trickId != null && guildId != null && trick == null) {
8886
processTemplate(
@@ -110,7 +108,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
110108
if (guildId == null) {
111109
b.put(
112110
"guilds",
113-
command.getGuilds()
111+
trickManager.getAllGuilds()
114112
.stream()
115113
.map(id -> new Guild(id.toString(), getGuild(jda, id)))
116114
.toList()
@@ -119,7 +117,7 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws Se
119117

120118
if (guildId != null) {
121119
b.put("tricks",
122-
command.getTricksForGuild(Long.parseLong(guildId))
120+
trickManager.getTricksForGuild(Long.parseLong(guildId))
123121
.stream()
124122
.sorted(Comparator.comparing(Trick::getTrickID))
125123
.toList()

0 commit comments

Comments
 (0)