Skip to content

Commit 49e3db6

Browse files
ChewJRoymdcfe
authored andcommitted
Add /warpinfo command (EssentialsX#3820)
Co-authored-by: Josh Roy <10731363+JRoy@users.noreply.github.com> Co-authored-by: MD <1917406+mdcfe@users.noreply.github.com>
1 parent 6eb64ce commit 49e3db6

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package com.earth2me.essentials.commands;
2+
3+
import com.earth2me.essentials.CommandSource;
4+
import org.bukkit.Location;
5+
import org.bukkit.Server;
6+
7+
import java.util.ArrayList;
8+
import java.util.Collections;
9+
import java.util.List;
10+
11+
import static com.earth2me.essentials.I18n.tl;
12+
13+
public class Commandwarpinfo extends EssentialsCommand {
14+
15+
public Commandwarpinfo() {
16+
super("warpinfo");
17+
}
18+
19+
@Override
20+
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
21+
if (args.length == 0) {
22+
throw new NotEnoughArgumentsException();
23+
}
24+
final String name = args[0];
25+
final Location loc = ess.getWarps().getWarp(name);
26+
sender.sendMessage(tl("warpInfo", name));
27+
sender.sendMessage(tl("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
28+
}
29+
30+
@Override
31+
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
32+
if (args.length == 1) {
33+
if (ess.getSettings().getPerWarpPermission() && sender.isPlayer()) {
34+
final List<String> list = new ArrayList<>();
35+
for (String curWarp : ess.getWarps().getList()) {
36+
if (sender.isAuthorized("essentials.warps." + curWarp, ess)) {
37+
list.add(curWarp);
38+
}
39+
}
40+
return list;
41+
}
42+
return new ArrayList<>(ess.getWarps().getList());
43+
} else {
44+
return Collections.emptyList();
45+
}
46+
}
47+
}

Essentials/src/main/resources/messages.properties

+3
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,9 @@ walking=walking
933933
warpCommandDescription=List all warps or warp to the specified location.
934934
warpCommandUsage=/<command> <pagenumber|warp> [player]
935935
warpDeleteError=\u00a74Problem deleting the warp file.
936+
warpInfo=\u00a76Information for warp\u00a7c {0}\u00a76:
937+
warpinfoCommandDescription=Finds location information for a specified warp.
938+
warpinfoCommandUsage=/<command> <warp>
936939
warpingTo=\u00a76Warping to\u00a7c {0}\u00a76.
937940
warpList={0}
938941
warpListPermission=\u00a74You do not have permission to list warps.

Essentials/src/main/resources/plugin.yml

+4
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,10 @@ commands:
568568
description: List all warps or warp to the specified location.
569569
usage: /<command> <pagenumber|warp> [player]
570570
aliases: [ewarp,warps,ewarps]
571+
warpinfo:
572+
description: Finds location information for a specified warp.
573+
usage: /<command> <warp>
574+
aliases: [ewarpinfo]
571575
weather:
572576
description: Sets the weather.
573577
usage: /<command> <storm/sun> [duration]

0 commit comments

Comments
 (0)