-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/club/kid7/bannermaker/command/ViewCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package club.kid7.bannermaker.command; | ||
|
||
import club.kid7.bannermaker.BannerMaker; | ||
import club.kid7.bannermaker.util.BannerUtil; | ||
import club.kid7.bannermaker.util.InventoryMenuUtil; | ||
import club.kid7.bannermaker.util.MessageUtil; | ||
import club.kid7.pluginutilities.command.CommandComponent; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
public class ViewCommand extends CommandComponent { | ||
//名稱 | ||
private static final String name = "View"; | ||
//介紹 | ||
private static final String description = "View banner info of the banner command"; | ||
//權限 | ||
private static final String permission = "BannerMaker.view"; | ||
//使用方法 | ||
private static final String usage = "/bm view <bannerString>"; | ||
//僅能由玩家執行 | ||
private static final boolean onlyFromPlayer = true; | ||
|
||
public ViewCommand(BannerMaker bm) { | ||
super(bm, name, description, permission, usage, onlyFromPlayer); | ||
} | ||
|
||
@Override | ||
public boolean executeCommand(CommandSender sender, Command command, String label, String[] args) { | ||
// TODO: 將訊息新增至語系檔 | ||
Player player = (Player) sender; | ||
if (args.length != 1) { | ||
player.sendMessage(MessageUtil.format(true, "&cUsage: " + usage)); | ||
return true; | ||
} | ||
String bannerString = args[0]; | ||
try { | ||
ItemStack banner = BannerUtil.deserialize(bannerString); | ||
//顯示旗幟 | ||
InventoryMenuUtil.showBannerInfo(player, banner); | ||
} catch (Exception e) { | ||
player.sendMessage(MessageUtil.format(true, "&cInvalid banner string")); | ||
return true; | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters