2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2013-10-16 19:59:39 +00:00
|
|
|
import com.earth2me.essentials.CommandSource;
|
2011-04-05 15:57:54 +00:00
|
|
|
import com.earth2me.essentials.Console;
|
2011-05-15 11:40:46 +00:00
|
|
|
import com.earth2me.essentials.User;
|
2015-10-27 17:34:59 +00:00
|
|
|
import com.earth2me.essentials.messaging.IMessageRecipient;
|
2020-07-06 18:52:51 +00:00
|
|
|
import com.earth2me.essentials.utils.DateUtil;
|
2013-06-08 21:31:19 +00:00
|
|
|
import com.earth2me.essentials.utils.FormatUtil;
|
2011-11-18 17:42:26 +00:00
|
|
|
import org.bukkit.Server;
|
2011-03-19 22:39:51 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
import static com.earth2me.essentials.I18n.tl;
|
|
|
|
|
|
|
|
public class Commandr extends EssentialsCommand {
|
|
|
|
public Commandr() {
|
|
|
|
super("r");
|
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
@Override
|
|
|
|
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
|
|
|
|
if (args.length < 1) {
|
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
String message = getFinalArg(args, 0);
|
2020-10-03 17:46:05 +00:00
|
|
|
final IMessageRecipient messageSender;
|
2015-04-15 04:06:16 +00:00
|
|
|
if (sender.isPlayer()) {
|
2020-10-03 17:46:05 +00:00
|
|
|
final User user = ess.getUser(sender.getPlayer());
|
2017-07-09 14:17:07 +00:00
|
|
|
if (user.isMuted()) {
|
2020-10-03 17:46:05 +00:00
|
|
|
final String dateDiff = user.getMuteTimeout() > 0 ? DateUtil.formatDateDiff(user.getMuteTimeout()) : null;
|
2020-07-06 18:52:51 +00:00
|
|
|
if (dateDiff == null) {
|
|
|
|
throw new Exception(user.hasMuteReason() ? tl("voiceSilencedReason", user.getMuteReason()) : tl("voiceSilenced"));
|
|
|
|
}
|
|
|
|
throw new Exception(user.hasMuteReason() ? tl("voiceSilencedReasonTime", dateDiff, user.getMuteReason()) : tl("voiceSilencedTime", dateDiff));
|
2017-07-09 14:17:07 +00:00
|
|
|
}
|
|
|
|
|
2015-04-15 04:06:16 +00:00
|
|
|
message = FormatUtil.formatMessage(user, "essentials.msg", message);
|
2015-10-27 17:34:59 +00:00
|
|
|
messageSender = user;
|
2015-04-15 04:06:16 +00:00
|
|
|
} else {
|
|
|
|
message = FormatUtil.replaceFormat(message);
|
2015-10-27 17:34:59 +00:00
|
|
|
messageSender = Console.getInstance();
|
2015-04-15 04:06:16 +00:00
|
|
|
}
|
2012-01-16 20:25:36 +00:00
|
|
|
|
2015-10-27 17:34:59 +00:00
|
|
|
final IMessageRecipient target = messageSender.getReplyRecipient();
|
2015-10-30 19:58:30 +00:00
|
|
|
// Check to make sure the sender does have a quick-reply recipient
|
2020-11-09 12:25:16 +00:00
|
|
|
if (target == null || (!ess.getSettings().isReplyToVanished() && sender.isPlayer() && target.isHiddenFrom(sender.getPlayer()))) {
|
|
|
|
messageSender.setReplyRecipient(null);
|
2015-04-15 04:06:16 +00:00
|
|
|
throw new Exception(tl("foreverAlone"));
|
|
|
|
}
|
2015-10-27 17:34:59 +00:00
|
|
|
messageSender.sendMessage(target, message);
|
2015-04-15 04:06:16 +00:00
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|