Skip to content

Commit

Permalink
Added CXTime command
Browse files Browse the repository at this point in the history
  • Loading branch information
Delocaz committed Mar 28, 2013
1 parent 194ab00 commit b1bf438
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/me/delocaz/cmdx/CmdX.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package me.delocaz.cmdx;

import me.delocaz.cmdx.api.CXAPI;
import me.delocaz.cmdx.commands.CXServer;
import me.delocaz.cmdx.commands.CXTP;
import me.delocaz.cmdx.commands.CXTime;

import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

Expand All @@ -15,6 +18,8 @@ public static CmdX getInstance() {
public void onEnable() {
api = new CXAPI();
getAPI().getCommandManager().registerCommand(new CXTP(), "tp", true);
getAPI().getCommandManager().registerCommand(new CXServer(), "server", false);
getAPI().getCommandManager().registerCommand(new CXTime(), "time", false);
}
public void onDisable() {
getAPI().getPlayerDataManager().save();
Expand Down
41 changes: 41 additions & 0 deletions src/me/delocaz/cmdx/commands/CXTime.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package me.delocaz.cmdx.commands;

import me.delocaz.cmdx.api.CXCommand;

import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class CXTime extends CXCommand {
@Override
public boolean executeCommand(CommandSender cs, String[] args) {
if (args.length == 0) {
cs.sendMessage(getAPI().getLanguageManager().getLang("notEnoughArguments"));
return false;
}
int time = 1000;
switch (args[0]) {
case "night":
time = 13000;
case "noon":
time = 6000;
case "midnight":
time = 18000;
}
if (StringUtils.isNumeric(args[0])) {
time = Integer.parseInt(args[0]);
}
if (cs instanceof Player) {
for (World w : Bukkit.getWorlds()) {
w.setTime(time);
}
} else {
Player p = (Player) cs;
p.getWorld().setTime(time);
}
cs.sendMessage(getAPI().getLanguageManager().getLang("weatherSet", time+""));
return true;
}
}

0 comments on commit b1bf438

Please sign in to comment.