Skip to content

Commit bf60fcd

Browse files
committed
Support spigot
1 parent 96331fe commit bf60fcd

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

src/main/java/com/kamesuta/schemuploader/CommandListener.java

+12-12
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
6161
File schemFile = new File(plugin.schematicFolder, schemFileName);
6262
// Check if the file is included in the directory (to prevent ../ and other path traversal attacks)
6363
if (!schemFile.getParentFile().equals(plugin.schematicFolder)) {
64-
sender.sendMessage(plugin.messages.error("error_invalid_folder"));
64+
sender.spigot().sendMessage(plugin.messages.error("error_invalid_folder"));
6565
return true;
6666
}
6767

6868
// Check if the file exists
6969
if (!schemFile.exists()) {
70-
sender.sendMessage(plugin.messages.error("error_not_found", schemFileName));
70+
sender.spigot().sendMessage(plugin.messages.error("error_not_found", schemFileName));
7171
return true;
7272
}
7373

@@ -77,7 +77,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
7777

7878
// Send a message if it is expected to take some time
7979
BukkitTask task = Bukkit.getScheduler().runTaskLater(plugin, () -> {
80-
sender.sendMessage(plugin.messages.info("upload_progress"));
80+
sender.spigot().sendMessage(plugin.messages.info("upload_progress"));
8181
}, 20);
8282

8383
// Upload the schem file asynchronously
@@ -90,7 +90,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
9090

9191
// Send an error message if the upload fails
9292
if (!result.success) {
93-
sender.sendMessage(plugin.messages.error("upload_failed", result.error));
93+
sender.spigot().sendMessage(plugin.messages.error("upload_failed", result.error));
9494

9595
// Add record to statistics
9696
plugin.statistics.actionCounter.increment(Statistics.ActionCounter.ActionType.UPLOAD_FAILURE);
@@ -99,7 +99,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
9999
}
100100

101101
// Send a message when the upload is complete
102-
sender.sendMessage(new ComponentBuilder()
102+
sender.spigot().sendMessage(new ComponentBuilder()
103103
.append(plugin.messages.success("upload_done", schemFileName))
104104
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(plugin.messages.getMessage("upload_done_open_url"))))
105105
.event(new ClickEvent(ClickEvent.Action.OPEN_URL, result.url))
@@ -146,24 +146,24 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
146146

147147
// Check if the file is included in the directory (to prevent ../ and other path traversal attacks)
148148
if (!schemFile.getParentFile().equals(plugin.schematicFolder)) {
149-
sender.sendMessage(plugin.messages.error("error_invalid_folder"));
149+
sender.spigot().sendMessage(plugin.messages.error("error_invalid_folder"));
150150
return true;
151151
}
152152
// If the file exists and force flag is not set, send an error message
153153
if (!force && schemFile.exists()) {
154-
sender.sendMessage(plugin.messages.error("error_already_exists", schemName + ".schem"));
154+
sender.spigot().sendMessage(plugin.messages.error("error_already_exists", schemName + ".schem"));
155155
return true;
156156
}
157157

158158
// Check the URL prefix if URL restriction is enabled
159159
if (PluginConfig.downloadUrlRestrictionEnabled && !url.startsWith(PluginConfig.downloadUrlPrefix)) {
160-
sender.sendMessage(plugin.messages.error("error_url_prefix"));
160+
sender.spigot().sendMessage(plugin.messages.error("error_url_prefix"));
161161
return true;
162162
}
163163

164164
// Send a message if it is expected to take some time
165165
BukkitTask task = Bukkit.getScheduler().runTaskLater(plugin, () -> {
166-
sender.sendMessage(plugin.messages.info("download_progress"));
166+
sender.spigot().sendMessage(plugin.messages.info("download_progress"));
167167
}, 20);
168168

169169
// Download the schem file asynchronously
@@ -177,9 +177,9 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
177177
// Send an error message if the download fails
178178
if (!result.success) {
179179
if (result.exceededSize) {
180-
sender.sendMessage(plugin.messages.error("error_file_size_exceeded", PluginConfig.downloadMaxSize));
180+
sender.spigot().sendMessage(plugin.messages.error("error_file_size_exceeded", PluginConfig.downloadMaxSize));
181181
} else {
182-
sender.sendMessage(plugin.messages.error("download_failed", result.error));
182+
sender.spigot().sendMessage(plugin.messages.error("download_failed", result.error));
183183
}
184184

185185
// Add record to statistics
@@ -189,7 +189,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
189189
}
190190

191191
// Send a message when the download is complete
192-
sender.sendMessage(new ComponentBuilder()
192+
sender.spigot().sendMessage(new ComponentBuilder()
193193
.append(plugin.messages.success("download_done", schemName + ".schem"))
194194
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(plugin.messages.getMessage("download_done_open_folder"))))
195195
.event(new ClickEvent(ClickEvent.Action.OPEN_URL, url))

0 commit comments

Comments
 (0)