45 lines
1.4 KiB
Java
45 lines
1.4 KiB
Java
package ca.thetechrobo.rltime;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import org.bukkit.NamespacedKey;
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.persistence.PersistentDataType;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
public class Set24HourTime extends Setter {
|
|
|
|
public Set24HourTime(JavaPlugin pl) {
|
|
this.pl = pl;
|
|
}
|
|
|
|
@Override
|
|
protected VerificationStatus set(@NotNull String[] args, @NotNull Player p) {
|
|
if (args.length != 1) {
|
|
return new VerificationStatus(false, "Incorrect amount of arguments (expected 1)");
|
|
}
|
|
String setTo = args[0].toLowerCase();
|
|
if (setTo.equals("true") || setTo.equals("false")) {
|
|
} else {
|
|
return new VerificationStatus(false, "Invalid argument (must be 'true' or 'false')");
|
|
}
|
|
p.getPersistentDataContainer().set(new NamespacedKey(this.pl, "24HourTime"), PersistentDataType.STRING, setTo);
|
|
if (setTo.equals("true")) {
|
|
return new VerificationStatus(true, "Successfully changed to 24-hour time!");
|
|
}
|
|
return new VerificationStatus(true, "Successfully changed to 12-hour time!");
|
|
}
|
|
|
|
@Override
|
|
public ArrayList<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
|
ArrayList<String> list = new ArrayList<String>();
|
|
list.add("true");
|
|
list.add("false");
|
|
return list;
|
|
}
|
|
|
|
}
|