Skip to content

Commit

Permalink
Improved Usages
Browse files Browse the repository at this point in the history
  • Loading branch information
Calcilore committed Mar 27, 2024
1 parent 430ca20 commit b6a9b2f
Show file tree
Hide file tree
Showing 26 changed files with 59 additions and 38 deletions.
3 changes: 2 additions & 1 deletion src/main/java/net/serble/estools/Commands/ClearInv.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import java.util.ArrayList;

public class ClearInv extends MultiPlayerCommand {
private static final String usage = genUsage("/ci <player1> [player2]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

ArrayList<Player> ps = new ArrayList<>();

if (args.length == 0) {
if (isNotPlayer(sender, genUsage("/ci <player1> [player2]")))
if (isNotPlayer(sender, usage))
return true;

ps.add((Player)sender);
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/serble/estools/Commands/EditSign.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.List;

public class EditSign extends CMD {
private static final String usage = genUsage("/editsign <line number> [line]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Expand All @@ -23,7 +24,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return false;

if (args.length < 1) {
s(sender, genUsage("/editsign <line number> [line]"));
s(sender, usage);
return false;
}

Expand All @@ -43,7 +44,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
try {
lineNum = Integer.parseInt(args[0]);
} catch (Exception e) {
s(sender, genUsage("/editsign <line number> [line]"));
s(sender, usage);
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/net/serble/estools/Commands/Eff.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

public class Eff extends MultiPlayerCommand {

public static final String usage = genUsage("/eff <effect> <amplifier> <duration> <players>");
private static final String usage = genUsage("/eff <effect> <amplifier> <duration> <players>");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Expand Down
11 changes: 6 additions & 5 deletions src/main/java/net/serble/estools/Commands/Ench.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@
import net.serble.estools.CMD;

public class Ench extends CMD {
private static final String usage = genUsage("/ench <enchantment> [level] [player]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

if (args.length == 0) {
s(sender, genUsage("/ench <enchantment> [level] [player]"));
s(sender, usage);
return false;
}

Expand All @@ -34,13 +35,13 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
try {
level = Integer.parseInt(args[1]);
} catch (Exception e) {
s(sender, genUsage("/ench <enchantment> [level] [player]"));
s(sender, usage);
return false;
}
}

if (args.length <= 2) {
if (isNotPlayer(sender, genUsage("/ench <enchantment> <level> <player>")))
if (isNotPlayer(sender, usage))
return false;

is = getMainHand(((Player) sender));
Expand All @@ -61,7 +62,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
else
ench = Enchantments.getByName(args[0].toLowerCase());
} catch (IllegalArgumentException e) {
s(sender, genUsage("/ench <enchantment> [level] [player]"));
s(sender, usage);
return true;
}

Expand All @@ -71,7 +72,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
s(sender, "&aEnchantment &6%s&a at level &6%s&a was added!", args[0].toLowerCase(), level);
}
else {
s(sender, genUsage("/ench <enchantment> [level] [player]"));
s(sender, usage);
}
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/serble/estools/Commands/Feed.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import java.util.ArrayList;

public class Feed extends MultiPlayerCommand {
private static final String usage = genUsage("/feed <Player>");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

ArrayList<Player> ps = new ArrayList<>();

if (args.length == 0) {
if (isNotPlayer(sender, genUsage("/feed <Player>")))
if (isNotPlayer(sender, usage))
return false;

ps.add((Player) sender);
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/serble/estools/Commands/Fix.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,15 @@
import net.serble.estools.PlayerCommand;

public class Fix extends PlayerCommand {
private static final String usage = genUsage("/fix [hand/offhand/helmet/chestplate/leggings/boots] [player]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

Player p;

if (args.length < 2) {
if (isNotPlayer(sender, genUsage("/fix <hand/offhand/helmet/chestplate/leggings/boots> <player>")))
if (isNotPlayer(sender, usage))
return false;

p = (Player) sender;
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/serble/estools/Commands/Fly.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import java.util.Objects;

public class Fly extends MultiPlayerCommand {
private static final String usage = genUsage("/fly [Player]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

ArrayList<Player> ps = new ArrayList<>();

if (args.length == 0) {
if (isNotPlayer(sender, genUsage("/fly [Player]")))
if (isNotPlayer(sender, usage))
return false;

ps.add((Player) sender);
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/serble/estools/Commands/FlySpeed.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import java.util.List;

public class FlySpeed extends MultiPlayerCommand {

private static final String usage = genUsage("/flyspeed <speed> [players]");

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/serble/estools/Commands/GetInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
import java.util.Objects;

public class GetInfo extends EntityCommand {
private static final String usage = genUsage("/getinfo <entity>");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

if (args.length == 0) {
s(sender, genUsage("/getinfo <entity>"));
s(sender, usage);
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/serble/estools/Commands/H.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.serble.estools.Give;

public class H extends CMD {
private static final String usage = genUsage("/h <item> [amount]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Expand All @@ -17,7 +18,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return false;

if (args.length == 0) {
s(sender, genUsage("/h <item> [amount]"));
s(sender, usage);
return false;
}

Expand All @@ -29,7 +30,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
try {
amount = Integer.parseInt(args[1]);
} catch(Exception e) {
s(sender, genUsage("/h <item> [amount]"));
s(sender, usage);
return false;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/serble/estools/Commands/Heal.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
import org.bukkit.entity.LivingEntity;

public class Heal extends EntityCommand {
private static final String usage = genUsage("/heal [entity]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

LivingEntity p;

if (args.length == 0) {
if (isNotEntity(sender, genUsage("/heal <entity>")))
if (isNotEntity(sender, usage))
return false;

p = (LivingEntity) sender;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/serble/estools/Commands/I.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.serble.estools.Give;

public class I extends CMD {
private static final String usage = genUsage("/i <item> [amount]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Expand All @@ -17,7 +18,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return false;

if (args.length == 0) {
s(sender, genUsage("/i <item> [amount]"));
s(sender, usage);
return false;
}

Expand All @@ -29,7 +30,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
try {
amount = Integer.parseInt(args[1]);
} catch(Exception e) {
s(sender, genUsage("/i <item> [amount]"));
s(sender, usage);
return false;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/serble/estools/Commands/Invsee.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.bukkit.entity.Player;

public class Invsee extends PlayerCommand {
private static final String usage = genUsage("/invsee <player>");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Expand All @@ -14,7 +15,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
return false;

if (args.length == 0) {
s(sender, genUsage("/invsee <player>"));
s(sender, usage);
return false;
}

Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/serble/estools/Commands/Music.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.List;

public class Music extends CMD {
private static final String usage = genUsage("/music [song]");

public static ArrayList<Sound> musics = new ArrayList<>();

Expand Down Expand Up @@ -43,7 +44,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
if (args[0].equalsIgnoreCase("random")) {
sound = musics.get((int)(Math.random() * musics.size()));
} else {
s(sender, genUsage("/music [song]"));
s(sender, usage);
return true;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/serble/estools/Commands/Potion.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
import java.util.Map;

public class Potion extends EntityCommand {
private static final String usage = genUsage("/potion <potion> [amplifier] [duration] [amount] [drink/splash/lingering] [player]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

if (args.length == 0) {
s(sender, genUsage("/potion <potion> [amplifier] [duration] [amount] [drink/splash/lingering] [player]"));
s(sender, usage);
return false;
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/serble/estools/Commands/Rename.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import net.serble.estools.CMD;

public class Rename extends CMD {

public static final String usage = genUsage("/rename <name>");

@Override
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/serble/estools/Commands/SetHealth.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import org.bukkit.entity.LivingEntity;

public class SetHealth extends EntityCommand {
private static final String usage = genUsage("/sethealth <amount> [entity]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

if (args.length == 0) {
s(sender, genUsage("/sethealth <amount> [entity]"));
s(sender, usage);
}

LivingEntity p;
Expand All @@ -32,7 +33,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
try {
health = Double.parseDouble(args[0]);
} catch (Exception e) {
s(sender, genUsage("/sethealth <amount> [entity]"));
s(sender, usage);
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/serble/estools/Commands/SetHunger.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import org.bukkit.entity.Player;

public class SetHunger extends PlayerCommand {
private static final String usage = genUsage("/sethunger <amount> [entity]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
s(sender, genUsage("/sethunger <amount> [entity]"));
s(sender, usage);
return false;
}

Expand All @@ -33,7 +34,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
try {
hunger = Integer.parseInt(args[0]);
} catch (Exception e) {
s(sender, genUsage("/sethunger <amount> [entity]"));
s(sender, usage);
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/serble/estools/Commands/SetMaxHealth.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
import org.bukkit.entity.LivingEntity;

public class SetMaxHealth extends EntityCommand {
private static final String usage = genUsage("/setmaxhealth <amount> [entity]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

if (args.length == 0) {
s(sender, genUsage("/setmaxhealth <amount> [entity]"));
s(sender, usage);
}

LivingEntity p;
Expand All @@ -20,7 +21,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
try {
health = Double.valueOf(args[0]);
} catch (Exception e) {
s(sender, genUsage("/sethealth <amount> [entity]"));
s(sender, usage);
return false;
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/net/serble/estools/Commands/SetSaturation.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
import org.bukkit.entity.Player;

public class SetSaturation extends PlayerCommand {
private static final String usage = genUsage("/setsaturation <amount> [entity]");

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (args.length == 0) {
s(sender, genUsage("/setsaturation <amount> [entity]"));
s(sender, usage);
return false;
}

Expand All @@ -33,7 +34,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
try {
saturation = Float.parseFloat(args[0]);
} catch (Exception e) {
s(sender, genUsage("/setsaturation <amount> [entity]"));
s(sender, usage);
return false;
}

Expand Down
Loading

0 comments on commit b6a9b2f

Please sign in to comment.