Commit Graph

59 Commits

Author SHA1 Message Date
Josh Roy
f6cb9ff470
Improve command codestyle (#3337)
Co-authored-by: MD <1917406+md678685@users.noreply.github.com>

Fixes #3579 (async `/skull` command)
Fixes #3336 (improve codestyle of commands)
Partially addresses #3339 (`/spawn` and `/setspawn` are now hidden from tabcomplete)
Closes #3087 (`/paytoggle` is now a loop command)
2020-08-11 19:09:22 +01:00
uf0h
f9de6763d3
Use playerNeverOnServer message where appropriate (#3489)
### Use `playerNeverOnServer` message where it should be used:

### 309e1c470d 
`playerNeverOnServer=\u00a74Player\u00a7c {0} \u00a74was never on this server.` is currently used in the **Commandmail** class at [Line 61](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/Commandmail.java#L61), [Line 116](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/Commandmail.java#L116) and [Line 129](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/Commandmail.java#L129) however is **not called** as PlayerNotFoundException is thrown by `#getPlayer` breaking current execution (below).
```
Commandmail#run() throws Exception {
...
    User u = getPlayer(server, args[1], true, true); // throws PlayerNotFoundException
        if (u == null) {
            throw new Exception(tl("playerNeverOnServer", args[1]));
    } 
...
}
```

Before changes:
![bm](https://user-images.githubusercontent.com/24858857/87236993-6b679180-c3e8-11ea-83a7-002194f5c467.png)
After changes:
![mailafter](https://user-images.githubusercontent.com/24858857/87237060-3576dd00-c3e9-11ea-8020-d5a80a958ca0.png)

--------------------------

**Commandseen** currently throws the default PlayerNotFoundException `playerNotFound` message for players that have not logged on to the server where it would be more appropriate to use the `playerNeverOnServer` message.

```
Commandseen#run throws Exception {
...
    AsyncRunnable#run() {
        User userFromBukkit = ess.getUserMap().getUserFromBukkit(args[0]);  <-- ***
        try {
            if (userFromBukkit != null) {                             <--- ***
                showUserSeen(userFromBukkit);
            } else {
                showUserSeen(getPlayer(server, sender, args, 0)); <--- ***
            }
        } catch (Exception e) {
            ess.showError(sender, e, commandLabel);
        }
    }
    private void showUserSeen(User user) throws Exception {
        if (user == null) {                                    <--- ***
            throw new PlayerNotFoundException();
        }
        showSeenMessage(server, sender, user, showBan, showIp, showLocation);
    }
...
}
```

**`<-- ***`:**
`usersFromBukkit` null check is performed before `#showUserSeen` so there is no need for another null check.
`EssentialsCommand#getPlayer` throws **NotEnoughArguementsException** or **PlayerNotFoundException** after [arg checks](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java#L88) and [player checks](https://github.com/EssentialsX/Essentials/blob/2.x/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java#L103). https://github.com/EssentialsX/Essentials/pull/3489#issuecomment-657138524

Before changes:
![sb](https://user-images.githubusercontent.com/24858857/87237038-e9c43380-c3e8-11ea-8294-8f91e8b6f25d.png)
After changes:
![seenafter](https://user-images.githubusercontent.com/24858857/87237067-53444200-c3e9-11ea-92c5-1784b4dcd739.png)

----------------

### 725128e
Catch more specfic exception `PlayerNotFoundException`.

Before changes:
![banbefore](https://user-images.githubusercontent.com/24858857/87237021-c1d4d000-c3e8-11ea-99e4-eb97b5a5ba6d.png)
After changes:
![afterunban](https://user-images.githubusercontent.com/24858857/87237081-8d154880-c3e9-11ea-9d35-a25b8c105969.png)
2020-08-04 15:30:05 +01:00
Josh Roy
9681933ec2
Add mute expiry time in mute messages (#3329)
Co-authored-by: MD <1917406+md678685@users.noreply.github.com>

Closes #1211.
2020-07-06 19:52:51 +01:00
montlikadani
3f5f9cc717 Fixed when the mail has already cleared (#2063) 2019-04-18 13:18:42 -04:00
md678685
f5c21d1089 Merge branch '2.x' into final_mute_reason_issue#385 2019-03-15 11:52:50 +00:00
triagonal
31b98fb9f3 allow console to use color codes when sending mail (#2435) @triagonal 2019-02-22 14:34:56 +00:00
Johnny Cao
d3c4c2ba6a Fixes #1866 (#1867) 2018-03-20 21:51:16 -07:00
Johnny Cao
fb5ebdb0c2 Fixes #1637: Correctly handle /mail permissions (#1743) @AgentTroll
Fixes #1637

/mail stripped colors from the entire message before as reported by the issue. The desired fix was to only strip the color from the sent message rather than from the entire message format (e.g. prefixes coming before the message itself).

Fixed by formatting only the message before passing it to the localization.

Also had a minor issue with FormatUtil in which it failed to strip ampersand (&)-formatted color codes, which was amended by stripping both VANILLA_*_PATTERN as well as REPLACE_*_PATTERN in FormatUtil#formatString(...). It's not necessary to actualy strip any vanilla (i.e. section-prefixed) color codes since that's already done by FormatUtil#stripFormat(String), but I'd like to keep the changes as non-invasive as possible at the current moment.

Demo: git-Spigot-d20369f-7fc5cd8 (MC: 1.9) (Implementing API version 1.9-R0.1-SNAPSHOT)
https://streamable.com/umyi8

This is my first time contributing so please be gentle :)
2018-01-29 18:01:20 +00:00
CreedTheFreak
f9d81c4302 Merge branch 'mutes385' of https://github.com/delbertina/Essentials into final_mute_reason_issue#385
Testing PR
2017-12-23 21:51:21 -08:00
delbertina
3d33bbc33d Added 8 new messages for "...Reason" versions of mute messages and implemented em. 2017-12-20 00:35:51 -06:00
CreedTheFreak
adf1bc291c Merge branch 'mutes385' of https://github.com/delbertina/Essentials into final_mute_reason_issue#385 2017-12-16 22:27:52 -08:00
delbertina
034ffbd0bc Added space when adding reason to string. 2017-12-17 00:16:06 -06:00
CreedTheFreak
62d5dd3516 Merge remote-tracking branch 'magnarisa/final_mute_reason_issue#385' into final_mute_reason_issue#385
Updated my local repos for testing purposes
2017-12-16 19:43:56 -08:00
delbertina
849b329213 Changed if else blocks to ternary operators. Not sure if way to avoid weird empty string usage. 2017-12-02 20:35:44 -06:00
delbertina
43cbab37f0 Changed muteFormat to muteReason.
Removed space at beginning of muteReason.
2017-11-26 01:32:22 -06:00
Ali 'SupaHam' M
c14d565b56
Support mail chat formatting via essentials.mail base permission. (#1611)
`essentials.mail.url`, `essentials.mail.color`, etc.
2017-10-29 01:16:04 +00:00
CreedTheFreak
f10a766442 fixed some wonky commit thing that happened, thus the following modifications are brought to you by Delbertina. 2017-09-03 19:49:57 -07:00
Ali 'SupaHam' M
bbe0ca9302 Implement tab completion for all commands. (#1282)
List of supported commands:
```
/afk
/balance
/balancetop
/ban
/banip
/bigtree
/book
/broadcastworld
/burn
/clearinventory
/condense
/delhome
/deljail
/delwarp
/eco
/enchant
/enderchest
/essentials
/exp
/ext
/feed
/fireball
/firework
/gamemode
/getpos
/give
/hat
/heal
/help
/helpop
/home
/ignore
/invsee
/item
/itemdb
/jump
/kick
/kill
/kit
/lightning
/list
/mail
/me
/msg
/mute
/near
/nick
/nuke
/pay
/potion
/powertool
/ptime
/pweather
/recipe
/remove
/repair
/sell
/showkit
/skull
/speed
/tempban
/thunder
/time
/togglejail
/tp
/tpa
/tpaall
/tpahere
/tpall
/tphere
/tpo
/tpohere
/tppos
/tree
/warp
/weather
/world
/worth```
2017-06-11 01:17:43 +01:00
drtshock
dde0b20775 Reformat 2015-04-14 23:06:16 -05:00
KHobbits
53a7cd732f Add paging to mail.
Support aliases in rule and baltop output.
2014-08-11 19:03:24 +01:00
KHobbits
4fd026ff99 Add mailFormat TL key. 2014-08-11 18:46:04 +01:00
KHobbits
9d9af25c7f Add local echo of mail being sent on /mail send. 2014-06-05 00:07:27 +01:00
KHobbits
cbaf126a25 Stop using old string player lookup. 2014-05-17 02:47:10 +01:00
KHobbits
9e9409da1e Essentials UUID conversion. 2014-04-13 21:40:15 +01:00
FearFree
5724c0c8df Future Java versions may not support _ as identifier. 2014-03-22 16:08:11 +11:00
Luke Anderson (stuntguy3000)
077074c855 Add missing language pointers 2014-03-09 17:14:09 +00:00
KHobbits
6f85761f7f Extract CommandSender to CommandSource, this should prevent Ess user object leaks. 2013-10-16 21:05:33 +01:00
KHobbits
59b501b2b1 Clean Imports 2013-10-11 03:44:41 +01:00
KHobbits
66eb9202ce Fix mail sendall from console skipping first param 2013-08-13 22:01:13 +01:00
Necrodoom
ab359f678a fix mute message when chatting
deny /mail if muted
2013-07-12 15:22:48 +01:00
KHobbits
09f67c9723 Split util classes. 2013-06-08 22:31:19 +01:00
KHobbits
5225fb22f8 Minor comment updates. 2013-02-03 04:14:23 +00:00
Iaccidentally
4edc39360a Refactor name of ScheduleAsyncDelayedTask to RunTaskAsynchronously 2013-01-31 14:16:09 -05:00
KHobbits
c57332be63 Tell user that /mail sendall succeeded when used in console. 2013-01-06 16:27:20 +00:00
ementalo
bea3583192 Fix mail 2012-10-28 20:00:15 +00:00
KHobbits
48d04216a7 Reduce calls to bukkit getPlayer(); 2012-10-26 21:34:36 +01:00
snowleo
0097f961b4 Prevent massive amount of mails being send.
Added new config: mails-per-minute, default 1000
2012-10-07 22:46:15 +02:00
KHobbits
97eada7dd6 Players should not be able to ignore Console
Also implement chat exempt permission in other commands.
2012-06-16 16:22:51 +01:00
md_5
0559b935e9 Add new command /hat and update translate keys as well as fix colour codes. 2012-05-27 17:24:49 +10:00
KHobbits
0dc1270aed Split colour permissions into 3: color/magic/format 2012-03-22 22:07:13 +00:00
KHobbits
5c19e71858 Sanitize mail for untoward characters.
Prevent a user error from terminating essentials timer task.
2012-02-02 09:26:36 +00:00
KHobbits
1f2c669eca Stripping vanilla colour from /helpop and /mail
Adding support for &k in EssChat
Adding support for colour in /msg and /r - New perm: essentials.msg.color
2012-01-16 20:25:36 +00:00
KHobbits
c0e903c1f3 New permissions: essentials.powertool.append. 2011-12-09 21:42:36 +00:00
snowleo
5b539bf034 Fix /mail sendall, fixes #1209 2011-12-07 11:02:10 +01:00
Khyperia
b49a9ef165 New feature: /mail sendall <message>
Test: #649
2011-12-07 08:53:15 +08:00
snowleo
220d68f375 Switch to the new I18n class and format cleanup of all classes 2011-11-21 02:55:26 +01:00
KHobbits
e5a8cd88f0 Code cleanup continued. 2011-11-18 17:48:49 +00:00
KHobbits
a05f730e76 Little more command cleanup. 2011-11-18 13:48:31 +00:00
snowleo
358456c8ea Cleanup 2011-10-19 14:47:32 +02:00
Tim P
82b225a261 Minor fixes. Basic testing shows all works. 2011-10-18 23:08:06 -04:00