summaryrefslogtreecommitdiff
path: root/src/main/java/jp/plusplus/fbs/command/CommandGetBook.java
diff options
context:
space:
mode:
authorBenjamin Culkin <scorpress@gmail.com>2024-08-24 08:16:37 -0400
committerBenjamin Culkin <scorpress@gmail.com>2024-08-24 08:16:37 -0400
commit70c1354a4a96698758a88c032866288f79de6f5a (patch)
treeeca51294e84b90a4cb3230bc2c7900469e784184 /src/main/java/jp/plusplus/fbs/command/CommandGetBook.java
Initial commitHEADtrunk
Diffstat (limited to 'src/main/java/jp/plusplus/fbs/command/CommandGetBook.java')
-rw-r--r--src/main/java/jp/plusplus/fbs/command/CommandGetBook.java49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/main/java/jp/plusplus/fbs/command/CommandGetBook.java b/src/main/java/jp/plusplus/fbs/command/CommandGetBook.java
new file mode 100644
index 0000000..e45875d
--- /dev/null
+++ b/src/main/java/jp/plusplus/fbs/command/CommandGetBook.java
@@ -0,0 +1,49 @@
+package jp.plusplus.fbs.command;
+
+import jp.plusplus.fbs.Registry;
+import jp.plusplus.fbs.api.FBSEntityPropertiesAPI;
+import net.minecraft.command.CommandBase;
+import net.minecraft.command.CommandException;
+import net.minecraft.command.ICommandSender;
+import net.minecraft.command.WrongUsageException;
+import net.minecraft.entity.item.EntityItem;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.ItemStack;
+import net.minecraft.world.World;
+
+/**
+ * Created by plusplus_F on 2016/03/01.
+ */
+public class CommandGetBook extends CommandBase {
+ @Override
+ public String getCommandName() {
+ return "givebook";
+ }
+
+ @Override
+ public String getCommandUsage(ICommandSender p_71518_1_) {
+ return "commands.fbs.getbook.usage";
+ }
+
+ @Override
+ public void processCommand(ICommandSender p_71515_1_, String[] p_71515_2_) {
+ if (p_71515_2_.length >= 2) {
+ World w = p_71515_1_.getEntityWorld();
+ EntityPlayer ep = w.getPlayerEntityByName(p_71515_2_[0]);
+ if (ep == null) new CommandException("commands.generic.player.notFound", new Object[1]);
+
+ String name=p_71515_2_[1];
+ ItemStack itemStack= Registry.GetBookItemStack(name);
+ if(itemStack==null){
+ new CommandException("commands.fbs.getbook.notFound", new Object[1]);
+ }
+
+ EntityItem entityitem = ep.dropPlayerItemWithRandomChoice(itemStack, false);
+ entityitem.delayBeforeCanPickup = 0;
+ entityitem.func_145797_a(ep.getCommandSenderName());
+ func_152373_a(p_71515_1_, this, "commands.give.success", new Object[] {itemStack.func_151000_E(), 1, ep.getCommandSenderName()});
+ } else {
+ throw new WrongUsageException("commands.fbs.getbook.usage", new Object[0]);
+ }
+ }
+}