-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0c8aba1
commit 70c5c7b
Showing
6 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.vcmi.commands; | ||
import com.vcmi.Message; | ||
import com.vcmi.VCMI; | ||
import com.vcmi.config.Lang; | ||
import com.velocitypowered.api.command.CommandSource; | ||
import com.velocitypowered.api.command.SimpleCommand; | ||
import com.velocitypowered.api.plugin.PluginContainer; | ||
import java.util.Collection; | ||
import java.util.stream.Collectors; | ||
|
||
public class PluginsCommand implements SimpleCommand { | ||
@Override | ||
public void execute(Invocation invocation) { | ||
CommandSource source = invocation.source(); | ||
String[] args = invocation.arguments(); | ||
if (!hasPermission(invocation)) { | ||
source.sendMessage(Lang.no_perms.get()); | ||
return; | ||
} | ||
Collection<PluginContainer> plugins = VCMI.server.getPluginManager().getPlugins(); | ||
|
||
if (args.length == 1 && args[0].equals("-v")) { | ||
String pluginList = plugins.stream() | ||
.map(plugin -> "&6"+plugin.getDescription().getName().orElse("Unknown") + " &7" + plugin.getDescription().getVersion().orElse("Unknown")) | ||
.collect(Collectors.joining(", ")); | ||
source.sendMessage(Message.convert("&aPlugins: " + pluginList)); | ||
return; | ||
} | ||
String pluginList = plugins.stream() | ||
.map(plugin -> "&6"+plugin.getDescription().getName().orElse("Unknown")) | ||
.collect(java.util.stream.Collectors.joining(", ")); | ||
source.sendMessage(Message.convert("&aPlugins: &6" + pluginList)); | ||
} | ||
|
||
@Override | ||
public boolean hasPermission(final Invocation invocation) { | ||
return invocation.source().hasPermission("vcmi.plugins"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters