Skip to content

Commit

Permalink
Removed unnecessary IntTimeToString command.
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Baumann committed Apr 8, 2014
1 parent 5bb3ac8 commit 69a73e9
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/com/dre/managerxl/commands/player/CMDTimeBan.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void onExecute(String[] args, CommandSender sender) {
player.setBannedReason(message);
player.setBanned(true);

P.p.msg(sender, P.p.getLanguageReader().get("Cmd_TimeBan_Success", player.getName(), MUtility.getIntTimeToString(time)));
P.p.msg(sender, P.p.getLanguageReader().get("Cmd_TimeBan_Success", player.getName(), MUtility.getLongTimeToString(time)));
} else {
P.p.msg(sender, P.p.getLanguageReader().get("Error_CmdBan_AlreadyBanned", player.getName()));
}
Expand Down
2 changes: 1 addition & 1 deletion src/com/dre/managerxl/listeners/PlayerListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void onPlayerLogin(PlayerLoginEvent event) {
if (player != null) {
if (player.isBanned()) {
if (player.getUntilUnBannedTime() > 0) {
event.disallow(Result.KICK_OTHER, P.p.replaceColors(P.p.getLanguageReader().get("Player_Kick_TimeBan", player.getBannedReason(), MUtility.getIntTimeToString(player.getUntilUnBannedTime()))));
event.disallow(Result.KICK_OTHER, P.p.replaceColors(P.p.getLanguageReader().get("Player_Kick_TimeBan", player.getBannedReason(), MUtility.getLongTimeToString(player.getUntilUnBannedTime()))));
} else {
event.disallow(Result.KICK_OTHER, P.p.replaceColors(P.p.getLanguageReader().get("Player_Kick_Ban", player.getBannedReason())));
}
Expand Down
70 changes: 0 additions & 70 deletions src/com/dre/managerxl/util/MUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,6 @@ public static int parseInt(String string) {
return NumberUtils.toInt(string, 0);
}

public static int getStringTimeToInt(String time) {
int result = 0;
int index = 0;
int lastIndex = 0;

// Days
index = time.indexOf("d");
if (index > lastIndex) {
result += parseInt(time.substring(lastIndex, index)) * 24 * 60 * 60;
}

// Hours
lastIndex = index;
index = time.indexOf("h");
if (index > lastIndex) {
result += parseInt(time.substring(lastIndex + 1, index)) * 60 * 60;
}

// Minutes
lastIndex = index;
index = time.indexOf("m");
if (index > lastIndex) {
result += parseInt(time.substring(lastIndex + 1, index)) * 60;
}

// Seconds
lastIndex = index;
index = time.indexOf("s");
if (index > lastIndex) {
result += parseInt(time.substring(lastIndex + 1, index));
}

return result * 1000; // Seconds to millisecs
}

public static long getStringTimeToLong(String time) {
long result = 0;
int index = 0;
Expand Down Expand Up @@ -100,41 +65,6 @@ public static long getStringTimeToLong(String time) {

return result * 1000; // Seconds to millisecs
}

public static String getIntTimeToString(long l) {
String result = "";

l = l / 1000; // Millisecs to seconds

// Days
int dayTime = 24 * 60 * 60;
if (l >= dayTime) {
result += ((int) (l / dayTime)) + " " + P.p.getLanguageReader().get("Format_Days") + " ";
l = l % dayTime;
}

// Hours
int hourTime = 60 * 60;
if (l >= hourTime) {
result += ((int) (l / hourTime)) + " " + P.p.getLanguageReader().get("Format_Hours") + " ";
l = l % hourTime;
}

// Minute
int minuteTime = 60;
if (l >= minuteTime) {
result += ((int) (l / minuteTime)) + " " + P.p.getLanguageReader().get("Format_Minutes") + " ";
l = l % minuteTime;
}

// Seconds
if (l >= 1) {
result += l + " " + P.p.getLanguageReader().get("Format_Seconds") + " ";
l = l % minuteTime;
}

return result.trim();
}

public static String getLongTimeToString(long l) {
String result = "";
Expand Down

0 comments on commit 69a73e9

Please sign in to comment.