@@ -56,15 +56,17 @@ public String getCommandUsage(ICommandSender sender)
5656 @ Override
5757 public void processCommand (ICommandSender sender , String [] args )
5858 {
59- if (!"give" .equals (args [0 ]) && !"add" .equals (args [0 ]) && !"remove" .equals (args [0 ]))
60- throw new CommandNotFoundException ("commans .potion.notFound" );
59+ if (args . length == 0 || !"give" .equals (args [0 ]) && !"add" .equals (args [0 ]) && !"remove" .equals (args [0 ]))
60+ throw new CommandNotFoundException ("commands .potion.notFound" );
6161
6262 int index = 1 ;
6363 int id = this .getPotionID (args [index ]);
6464
6565 if (id == -1 )
6666 {
67- sender = sender .getEntityWorld ().getPlayerEntityByName (args [index ]);
67+ ICommandSender sender1 = sender .getEntityWorld ().getPlayerEntityByName (args [index ]);
68+ if (sender1 != null )
69+ sender = sender1 ;
6870
6971 index ++;
7072 id = this .getPotionID (args [index ]);
@@ -85,16 +87,16 @@ public void processCommand(ICommandSender sender, String[] args)
8587 {
8688 duration = 1 ;
8789 }
88- else if (args .length >= 2 )
90+ else if (args .length >= index + 1 )
8991 {
9092 duration = parseIntBounded (sender , args [index + 1 ], 0 , 1000000 ) * 20 ;
9193 }
9294
93- if (args .length >= 3 )
95+ if (args .length >= index + 2 )
9496 {
9597 amplifier = parseIntBounded (sender , args [index + 2 ], 1 , 256 ) - 1 ;
9698 }
97- if (args .length >= 4 )
99+ if (args .length >= index + 3 )
98100 {
99101 splash = Boolean .parseBoolean (args [index + 3 ]);
100102 }
@@ -119,17 +121,17 @@ else if (args.length >= 2)
119121 notifyAdmins (sender , "commands.potion.give.success" , potioneffect .getEffectName (), id , duration , amplifier , name );
120122 }
121123 }
122- else if ("remove " .equals (args [0 ]))
124+ else if ("add " .equals (args [0 ]))
123125 {
124126 ItemStack stack = player .getHeldItem ();
125- potionType .remove (stack );
127+ potionType .apply (stack );
126128
127129 notifyAdmins (sender , "command.potion.remove.success" , potioneffect .getEffectName (), id , duration , amplifier , name );
128130 }
129- else if ("add " .equals (args [0 ]))
131+ else if ("remove " .equals (args [0 ]))
130132 {
131133 ItemStack stack = player .getHeldItem ();
132- potionType .apply (stack );
134+ potionType .remove (stack );
133135
134136 notifyAdmins (sender , "command.potion.remove.success" , potioneffect .getEffectName (), id , duration , amplifier , name );
135137 }
0 commit comments