Skip to content

Commit a890709

Browse files
committed
add custom help command
1 parent becd093 commit a890709

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/main/java/org/geysermc/globallinkserver/GlobalLinkServer.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class GlobalLinkServer extends JavaPlugin implements Listener {
5050
.append(Component.text("`/link`", NamedTextColor.GREEN))
5151
.append(Component.text(" command to link your accounts.", NamedTextColor.AQUA));
5252

53-
public final static Component UNLINK_INSTRUCTIONS = Component.text("To unlink, use ").color(NamedTextColor.AQUA)
53+
public final static Component UNLINK_INSTRUCTIONS = Component.text("You are currently linked. To unlink, use ").color(NamedTextColor.AQUA)
5454
.append(Component.text("`/unlink`", NamedTextColor.RED))
5555
.append(Component.text("."));
5656

@@ -152,6 +152,10 @@ public void onCommands(PlayerCommandSendEvent event) {
152152
continue;
153153
}
154154

155+
if (command.contains("help")) {
156+
continue;
157+
}
158+
155159
toRemove.add(command);
156160
}
157161

@@ -161,7 +165,8 @@ public void onCommands(PlayerCommandSendEvent event) {
161165

162166
@EventHandler
163167
public void preCommand(PlayerCommandPreprocessEvent event) {
164-
if (event.getPlayer().isOp()) {
168+
Player player = event.getPlayer();
169+
if (player.isOp()) {
165170
return;
166171
}
167172

@@ -170,6 +175,15 @@ public void preCommand(PlayerCommandPreprocessEvent event) {
170175
command = command.substring(1);
171176
}
172177

178+
if (command.equalsIgnoreCase("help")) {
179+
event.setCancelled(true);
180+
if (Utils.isLinked(player)) {
181+
player.sendMessage(UNLINK_INSTRUCTIONS);
182+
} else {
183+
player.sendMessage(LINK_INSTRUCTIONS);
184+
}
185+
}
186+
173187
if (!permittedCommands.contains(command)) {
174188
event.setCancelled(true);
175189
}

0 commit comments

Comments
 (0)