Skip to content

Commit

Permalink
ファイルが無いときのエラー処理
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamesuta committed Feb 19, 2024
1 parent a44c3bd commit 65fb4cd
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 26 deletions.
27 changes: 1 addition & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.kamesuta</groupId>
<artifactId>SchemUploader</artifactId>
<version>1.5-SNAPSHOT</version>
<version>1.6-SNAPSHOT</version>
<packaging>jar</packaging>

<name>SchemUploader</name>
Expand Down Expand Up @@ -42,26 +42,6 @@
</configuration>
</execution>
</executions>
<configuration>
<relocations>
<relocation>
<pattern>com.squareup.okhttp</pattern>
<shadedPattern>com.kamesuta.schemuploader.lib.com.squareup.okhttp</shadedPattern>
</relocation>
<relocation>
<pattern>org.apache.commons.lang3</pattern>
<shadedPattern>com.kamesuta.schemuploader.lib.org.apache.commons.lang3</shadedPattern>
</relocation>
<relocation>
<pattern>okio</pattern>
<shadedPattern>com.kamesuta.schemuploader.lib.okio</shadedPattern>
</relocation>
<relocation>
<pattern>com.kamesuta.commandlib</pattern>
<shadedPattern>com.kamesuta.schemuploader.lib.commandlib</shadedPattern>
</relocation>
</relocations>
</configuration>
</plugin>
</plugins>
<resources>
Expand Down Expand Up @@ -90,11 +70,6 @@
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp</artifactId>
<version>2.7.5</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/com/kamesuta/schemuploader/CommandListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
sender.sendMessage(plugin.messages.error("error_invalid_folder"));
return true;
}

// Check if the file exists
if (!schemFile.exists()) {
sender.sendMessage(plugin.messages.error("error_not_found", schemFileName));
return true;
}

// Get the name and UUID of the sender
String senderName = sender.getName();
UUID senderUUID = (sender instanceof Player) ? ((Player) sender).getUniqueId() : null;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ prefix: "[SchemUploader] "
error_invalid_folder: "You can only specify locations within the WorldEdit schematic folder"
error_http_status: "HTTP status code: %d"
error_io: "IO error: %s"
error_not_found: "File %s does not exist"
error_not_schematic: "The file is not a schematic file"
error_already_exists: "%s already exists. Please specify -f to overwrite"
error_file_size_exceeded: "File size exceeds maximum limit (%d Bytes)"
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/messages_ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ prefix: "[SchemUploader] "
error_invalid_folder: "WorldEditのschematicフォルダー以外の場所を指定することはできません"
error_http_status: "HTTPステータスコード: %d"
error_io: "IOエラー: %s"
error_not_found: "ファイル %s が存在しません"
error_not_schematic: "ファイルがschematicファイルではありません"
error_already_exists: "%s は既に存在します。上書きする場合は -f を指定してください"
error_file_size_exceeded: "ファイルサイズが大きすぎます (最大 %d Bytes)"
Expand Down

0 comments on commit 65fb4cd

Please sign in to comment.