Add help to storage command.
This commit is contained in:
parent
c8df9e19f5
commit
761d65320f
@ -80,7 +80,7 @@ public final class CreateCommand implements Command {
|
|||||||
ItemStack itemStack = null;
|
ItemStack itemStack = null;
|
||||||
|
|
||||||
// Get the players target block.
|
// Get the players target block.
|
||||||
target = player.getTargetBlock(null, 3).getLocation();
|
target = player.getTargetBlock(null, 5).getLocation();
|
||||||
|
|
||||||
// Check if itemcase already exists here.
|
// Check if itemcase already exists here.
|
||||||
if(ItemCaseCore.instance.getItemcaseManager().isItemcase(target)) {
|
if(ItemCaseCore.instance.getItemcaseManager().isItemcase(target)) {
|
||||||
|
@ -76,7 +76,7 @@ public final class DestroyCommand implements Command {
|
|||||||
ItemcaseManager manager = ItemCaseCore.instance.getItemcaseManager();
|
ItemcaseManager manager = ItemCaseCore.instance.getItemcaseManager();
|
||||||
|
|
||||||
// Get the players target block.
|
// Get the players target block.
|
||||||
target = player.getTargetBlock(null, 3).getLocation();
|
target = player.getTargetBlock(null, 5).getLocation();
|
||||||
|
|
||||||
// Check this target is an itemcase.
|
// Check this target is an itemcase.
|
||||||
if(!manager.isItemcase(target)) {
|
if(!manager.isItemcase(target)) {
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package com.gmail.bleedobsidian.itemcase.commands;
|
package com.gmail.bleedobsidian.itemcase.commands;
|
||||||
|
|
||||||
import com.gmail.bleedobsidian.itemcase.ChatLogger;
|
import com.gmail.bleedobsidian.itemcase.ChatLogger;
|
||||||
import com.gmail.bleedobsidian.itemcase.GenericLogger;
|
|
||||||
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
||||||
@ -52,11 +51,8 @@ public final class ModifyCommand implements Command {
|
|||||||
// Cast sender to player.
|
// Cast sender to player.
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
// Check command params have been given.
|
// Check if player is asking for help.
|
||||||
if(args.length != 3) {
|
if(this.isAskingForHelp(player, label, args)) {
|
||||||
|
|
||||||
// Shop help message.
|
|
||||||
this.showHelp(player, label);
|
|
||||||
|
|
||||||
// Exit.
|
// Exit.
|
||||||
return;
|
return;
|
||||||
@ -79,7 +75,7 @@ public final class ModifyCommand implements Command {
|
|||||||
Location target = null;
|
Location target = null;
|
||||||
|
|
||||||
// Get the players target block.
|
// Get the players target block.
|
||||||
target = player.getTargetBlock(null, 3).getLocation();
|
target = player.getTargetBlock(null, 5).getLocation();
|
||||||
|
|
||||||
// Check if itemcase exists here.
|
// Check if itemcase exists here.
|
||||||
if(!ItemCaseCore.instance.getItemcaseManager().isItemcase(target)) {
|
if(!ItemCaseCore.instance.getItemcaseManager().isItemcase(target)) {
|
||||||
@ -484,6 +480,34 @@ public final class ModifyCommand implements Command {
|
|||||||
chatLogger.message(player, "command.modify.success");
|
chatLogger.message(player, "command.modify.success");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If the command sender is asking for help about this command.
|
||||||
|
*/
|
||||||
|
public boolean isAskingForHelp(Player player, String label, String[] args) {
|
||||||
|
|
||||||
|
// If args length equals 2.
|
||||||
|
if(args.length != 2) {
|
||||||
|
|
||||||
|
// False.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get argument.
|
||||||
|
String argument = args[1];
|
||||||
|
|
||||||
|
// If not equal to help.
|
||||||
|
if(!argument.equalsIgnoreCase("help")) {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show help.
|
||||||
|
this.showHelp(player, label);
|
||||||
|
|
||||||
|
// Return.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show help for main command to given sender.
|
* Show help for main command to given sender.
|
||||||
*
|
*
|
||||||
|
@ -19,6 +19,7 @@ import com.gmail.bleedobsidian.itemcase.ItemCaseCore;
|
|||||||
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
import com.gmail.bleedobsidian.itemcase.Itemcase;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.StorageType;
|
||||||
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
import com.gmail.bleedobsidian.itemcase.Itemcase.Type;
|
||||||
|
import com.gmail.bleedobsidian.itemcase.LanguageTranslator;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -46,12 +47,19 @@ public final class StorageCommand implements Command {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get chat logger.
|
|
||||||
ChatLogger chatLogger = ItemCaseCore.instance.getChatLogger();
|
|
||||||
|
|
||||||
// Cast sender to player.
|
// Cast sender to player.
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
// Check if player is asking for help.
|
||||||
|
if(this.isAskingForHelp(player, label, args)) {
|
||||||
|
|
||||||
|
// Exit.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get chat logger.
|
||||||
|
ChatLogger chatLogger = ItemCaseCore.instance.getChatLogger();
|
||||||
|
|
||||||
// Check if player has permission.
|
// Check if player has permission.
|
||||||
if(!player.hasPermission("itemcase.create")) {
|
if(!player.hasPermission("itemcase.create")) {
|
||||||
|
|
||||||
@ -66,7 +74,7 @@ public final class StorageCommand implements Command {
|
|||||||
Location target = null;
|
Location target = null;
|
||||||
|
|
||||||
// Get the players target block.
|
// Get the players target block.
|
||||||
target = player.getTargetBlock(null, 3).getLocation();
|
target = player.getTargetBlock(null, 5).getLocation();
|
||||||
|
|
||||||
// Check if itemcase exists here.
|
// Check if itemcase exists here.
|
||||||
if(!ItemCaseCore.instance.getItemcaseManager().isItemcase(target)) {
|
if(!ItemCaseCore.instance.getItemcaseManager().isItemcase(target)) {
|
||||||
@ -122,4 +130,44 @@ public final class StorageCommand implements Command {
|
|||||||
// Open itemcase storage to player.
|
// Open itemcase storage to player.
|
||||||
player.openInventory(itemcase.getStorage());
|
player.openInventory(itemcase.getStorage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return If the command sender is asking for help about this command.
|
||||||
|
*/
|
||||||
|
public boolean isAskingForHelp(Player player, String label, String[] args) {
|
||||||
|
|
||||||
|
// If args length equals 2.
|
||||||
|
if(args.length != 2) {
|
||||||
|
|
||||||
|
// False.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get argument.
|
||||||
|
String argument = args[1];
|
||||||
|
|
||||||
|
// If not equal to help.
|
||||||
|
if(!argument.equalsIgnoreCase("help")) {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get chat logger.
|
||||||
|
ChatLogger chatLogger = ItemCaseCore.instance.getChatLogger();
|
||||||
|
|
||||||
|
// Get translator.
|
||||||
|
LanguageTranslator translator = ItemCaseCore.instance.getTranslator();
|
||||||
|
|
||||||
|
// Set placeholder.
|
||||||
|
translator.setPlaceholder("%COMMAND%", "/" + label + " storage");
|
||||||
|
|
||||||
|
// Show command help.
|
||||||
|
chatLogger.message(player, "command.itemcase-help");
|
||||||
|
|
||||||
|
// Show specific help.
|
||||||
|
chatLogger.message(player, "command.storage.help");
|
||||||
|
|
||||||
|
// Return.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,10 @@ command:
|
|||||||
# %COMMAND% = The command usage syntax.
|
# %COMMAND% = The command usage syntax.
|
||||||
itemcase-help: "Usage: %COMMAND%"
|
itemcase-help: "Usage: %COMMAND%"
|
||||||
|
|
||||||
|
# Shown when a user incorrectly uses the main itemcase command.
|
||||||
|
# %LABEL% = The label that was used.
|
||||||
|
command-help: "To view more: /%LABEL% [command] help"
|
||||||
|
|
||||||
# Shown when a user tries to execute a command and they are not an in game
|
# Shown when a user tries to execute a command and they are not an in game
|
||||||
# player.
|
# player.
|
||||||
not-player: "You must be a player to use this command."
|
not-player: "You must be a player to use this command."
|
||||||
@ -50,6 +54,9 @@ command:
|
|||||||
# Messages shown when using the 'create' command.
|
# Messages shown when using the 'create' command.
|
||||||
create:
|
create:
|
||||||
|
|
||||||
|
# Shown to the player when asking for help.
|
||||||
|
help: "Creates a new itemcase with the item in your main hand, at the block you are looking at."
|
||||||
|
|
||||||
# Shown to the player when they try to make an itemcase out of an
|
# Shown to the player when they try to make an itemcase out of an
|
||||||
# invalid block type.
|
# invalid block type.
|
||||||
invalid-type: "This block cannot be used for an ItemCase."
|
invalid-type: "This block cannot be used for an ItemCase."
|
||||||
@ -68,12 +75,18 @@ command:
|
|||||||
# Messages shown when using the 'destroy' command.
|
# Messages shown when using the 'destroy' command.
|
||||||
destroy:
|
destroy:
|
||||||
|
|
||||||
|
# Shown to the player when asking for help.
|
||||||
|
help: "Destroy the itemcase you are looking at permanently."
|
||||||
|
|
||||||
# Shown to the player upon successful deletion.
|
# Shown to the player upon successful deletion.
|
||||||
success: "ItemCase destroyed."
|
success: "ItemCase destroyed."
|
||||||
|
|
||||||
# Messages shwon when using the 'modify' command.
|
# Messages shwon when using the 'modify' command.
|
||||||
modify:
|
modify:
|
||||||
|
|
||||||
|
# Shown to the player when asking for help.
|
||||||
|
help: "Modify a flag of the itemcase you are looking at."
|
||||||
|
|
||||||
# Shown to the player when trying to set the sell price of an ItemCase
|
# Shown to the player when trying to set the sell price of an ItemCase
|
||||||
# that only buys items.
|
# that only buys items.
|
||||||
sell-only: "This ItemCase only sells items."
|
sell-only: "This ItemCase only sells items."
|
||||||
@ -91,6 +104,31 @@ command:
|
|||||||
# Messages shown when using the 'storage' command.
|
# Messages shown when using the 'storage' command.
|
||||||
storage:
|
storage:
|
||||||
|
|
||||||
|
# Shown to the player when asking for help.
|
||||||
|
help: "View the storage of the itemcase you are looking at."
|
||||||
|
|
||||||
# Shown to the player when trying to access the storage of an infinite
|
# Shown to the player when trying to access the storage of an infinite
|
||||||
# itemcase shop.
|
# itemcase shop.
|
||||||
infinite: "This ItemCase has infinite items to buy/sell, therefore has no storage."
|
infinite: "This ItemCase has infinite items to buy/sell, therefore has no storage."
|
||||||
|
|
||||||
|
# Messages shown when ordering.
|
||||||
|
order:
|
||||||
|
|
||||||
|
# Shown when ordering.
|
||||||
|
# %ITEM_NAME% = The item being sold.
|
||||||
|
item: "Item: %ITEM_NAME%"
|
||||||
|
|
||||||
|
# Shown when ordering.
|
||||||
|
# %BUY_PRICE% = The buy price.
|
||||||
|
buy-price: "Buy price: %BUY_PRICE%"
|
||||||
|
|
||||||
|
# Shown when ordering.
|
||||||
|
# %SELL_PRICE% = The sell price.
|
||||||
|
sell-price: "Sell price: %SELL_PRICE%"
|
||||||
|
|
||||||
|
# Shown when ordering.
|
||||||
|
# %AMOUNT% = The amount.
|
||||||
|
amount: "Amount: %AMOUNT%"
|
||||||
|
|
||||||
|
# Shown when ordering.
|
||||||
|
help: "Help: /itemc order help"
|
Loading…
x
Reference in New Issue
Block a user