Skip to content

Commit

Permalink
Fixed commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamierocks committed Oct 12, 2014
1 parent 0397a2c commit f5fb998
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<name>PlayTimeLimiter</name>
<url>https://github.com/UnoModding/Canary-PlayTimeLimiter</url>
<description>PlayTimeLimiter is a CanaryMod plugin for Minecraft servers to only allow players to limit the amount of time players spent on your server.</description>
<version>0.2-dev</version>
<version>0.2</version>
<inceptionYear>2014</inceptionYear>

<repositories>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ public void checkCommand(MessageReceiver caller, String[] args) {
parent = "playtime",
description = "add subcommand",
permissions = { "playtimelimiter.playtime.add" },
toolTip = "/playtime add [seconds]",
toolTip = "/playtime add <player> <seconds>",
version = 2)
public void addCommand(MessageReceiver caller, String[] args) {
if (!plugin.hasStarted()) {
caller.message(TextFormat.RED + "Playtime hasn't started yet!");
} else {
try {
plugin.removePlayTime(Canary.getServer().getPlayer(args[0]).getUUIDString(),
Integer.parseInt(args[0]));
plugin.addPlayTime(Canary.getServer().getPlayer(args[0]).getUUIDString(),
Integer.parseInt(args[1]));
caller.message(TextFormat.GREEN + "Added " + Integer.parseInt(args[1])
+ " seconds of playtime from " + args[0]);
} catch (NumberFormatException e) {
Expand All @@ -133,7 +133,7 @@ public void addCommand(MessageReceiver caller, String[] args) {
parent = "playtime",
description = "remove subcommand",
permissions = { "playtimelimiter.playtime.remove" },
toolTip = "/playtime remove [seconds]",
toolTip = "/playtime remove <player> <seconds>",
version = 2)
public void removeCommand(MessageReceiver caller, String[] args) {
if (!plugin.hasStarted()) {
Expand All @@ -147,9 +147,6 @@ public void removeCommand(MessageReceiver caller, String[] args) {
} catch (NumberFormatException e) {
e.printStackTrace();
caller.message(TextFormat.RED + "Invalid number of seconds given!");
} catch (UnknownPlayerException e) {
e.printStackTrace();
caller.message(TextFormat.RED + e.getMessage());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,19 @@ public int getTimeAllowedInSeconds(String uuid) {
return secondsAllowed;
}

public void addPlayTime(String uuid, int seconds) {
public void addPlayTime(String uuid, int seconds) throws UnknownPlayerException {
if (this.timePlayed.containsKey(uuid)) {
this.timePlayed.put(uuid, this.timePlayed.get(uuid) + seconds);
this.timePlayed.put(uuid, this.timePlayed.get(uuid) - seconds);
} else {
this.timePlayed.put(uuid, seconds);
throw new UnknownPlayerException(uuid);
}
}

public void removePlayTime(String uuid, int seconds) throws UnknownPlayerException {
public void removePlayTime(String uuid, int seconds) {
if (this.timePlayed.containsKey(uuid)) {
this.timePlayed.put(uuid, this.timePlayed.get(uuid) - seconds);
this.timePlayed.put(uuid, this.timePlayed.get(uuid) + seconds);
} else {
throw new UnknownPlayerException(uuid);
this.timePlayed.put(uuid, seconds);
}
}

Expand Down

0 comments on commit f5fb998

Please sign in to comment.