1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 14:05:25 +01:00

Better blockinfo command with click suggestion option

This commit is contained in:
Zrips 2021-11-26 14:02:57 +02:00
parent 07593ca336
commit 3d4266f80c
2 changed files with 29 additions and 15 deletions

View File

@ -9,6 +9,7 @@ import com.gamingmesh.jobs.commands.Cmd;
import com.gamingmesh.jobs.stuff.Util; import com.gamingmesh.jobs.stuff.Util;
import net.Zrips.CMILib.Items.CMIMaterial; import net.Zrips.CMILib.Items.CMIMaterial;
import net.Zrips.CMILib.RawMessages.RawMessage;
import net.Zrips.CMILib.Version.Version; import net.Zrips.CMILib.Version.Version;
public class blockinfo implements Cmd { public class blockinfo implements Cmd {
@ -27,24 +28,36 @@ public class blockinfo implements Cmd {
} }
Block block = Util.getTargetBlock((Player) sender, 15); Block block = Util.getTargetBlock((Player) sender, 15);
if (block == null || CMIMaterial.isAir(block.getType())) CMIMaterial cmat = CMIMaterial.get(block);
if (block == null || cmat.isAir())
return true; return true;
byte blockData = CMIMaterial.getBlockData(block); short blockData = CMIMaterial.getBlockData(block);
String dataString = blockData == 0 ? "" : "-" + blockData; String dataString = blockData == 0 ? "" : "-" + blockData;
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator")); RawMessage rm = new RawMessage();
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.name", "%blockname%", block.getType().name()));
if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) rm.addText(Jobs.getLanguage().getMessage("general.info.separator") + "\n");
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.id", "%blockid%", block.getType().getId())); rm.addText(Jobs.getLanguage().getMessage("command.blockinfo.output.material", "%blockname%", block.getType().name()) + "\n");
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.data", "%blockdata%", blockData)); rm.addSuggestion(block.getType().name());
if (Version.isCurrentEqualOrLower(Version.v1_13_R2)) {
rm.addText(Jobs.getLanguage().getMessage("command.blockinfo.output.id", "%blockid%", block.getType().getId()) + "\n");
rm.addSuggestion(String.valueOf(block.getType().getId()));
}
if (blockData != 0) {
rm.addText(Jobs.getLanguage().getMessage("command.blockinfo.output.state", "%blockdata%", blockData) + "\n");
rm.addSuggestion(String.valueOf(blockData));
}
if (Version.isCurrentEqualOrHigher(Version.v1_14_R1)) if (Version.isCurrentEqualOrHigher(Version.v1_14_R1))
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.usage", "%first%", "", rm.addText(Jobs.getLanguage().getMessage("command.blockinfo.output.use", "%usage%", block.getType().name() + dataString) + "\n");
"%second%", block.getType().name() + dataString));
else else
sender.sendMessage(Jobs.getLanguage().getMessage("command.blockinfo.output.usage", "%first%", block.getType().getId() + dataString, rm.addText(Jobs.getLanguage().getMessage("command.blockinfo.output.deprecated", "%first%", block.getType().getId() + dataString, "%second%", block.getType().name() + dataString) + "\n");
"%second%", block.getType().name() + dataString)); rm.addSuggestion(block.getType().name() + dataString);
sender.sendMessage(Jobs.getLanguage().getMessage("general.info.separator"));
rm.addText(Jobs.getLanguage().getMessage("general.info.separator"));
rm.show(sender);
return true; return true;
} }

View File

@ -271,10 +271,11 @@ public class LanguageManager {
c.get("command.blockinfo.help.info", "Shows information for the block you are looking at."); c.get("command.blockinfo.help.info", "Shows information for the block you are looking at.");
c.get("command.blockinfo.help.args", ""); c.get("command.blockinfo.help.args", "");
c.get("command.blockinfo.output.name", " &eBlock name: &6%blockname%"); c.get("command.blockinfo.output.material", " &eBlock material: &6%blockname%");
c.get("command.blockinfo.output.id", " &eBlock id: &6%blockid%"); c.get("command.blockinfo.output.id", " &eBlock id: &6%blockid%");
c.get("command.blockinfo.output.data", " &eBlock data: &6%blockdata%"); c.get("command.blockinfo.output.state", " &eBlock sate: &6%blockdata%");
c.get("command.blockinfo.output.usage", " &eUsage: &6%first% &eor &6%second%"); c.get("command.blockinfo.output.deprecated", " &eUsage: &6%first% &eor &6%second%");
c.get("command.blockinfo.output.use", " &eConfig file usage: &6%usage%");
c.get("command.iteminfo.help.info", "Shows information for the item you are holding."); c.get("command.iteminfo.help.info", "Shows information for the item you are holding.");
c.get("command.iteminfo.help.args", ""); c.get("command.iteminfo.help.args", "");