-
Notifications
You must be signed in to change notification settings - Fork 4
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
Showing
10 changed files
with
140 additions
and
103 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
25 changes: 14 additions & 11 deletions
25
src/main/java/de/strifel/VTools/commands/CommandBroadcast.java
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 |
---|---|---|
@@ -1,42 +1,45 @@ | ||
package de.strifel.VTools.commands; | ||
|
||
import com.velocitypowered.api.command.Command; | ||
import com.velocitypowered.api.command.CommandSource; | ||
import com.velocitypowered.api.command.SimpleCommand; | ||
import com.velocitypowered.api.proxy.Player; | ||
import com.velocitypowered.api.proxy.ProxyServer; | ||
import net.kyori.text.TextComponent; | ||
import net.kyori.text.format.TextColor; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import net.kyori.adventure.text.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class CommandBroadcast implements Command { | ||
import static de.strifel.VTools.VTools.COLOR_RED; | ||
|
||
public class CommandBroadcast implements SimpleCommand { | ||
private final ProxyServer server; | ||
|
||
public CommandBroadcast(ProxyServer server) { | ||
this.server = server; | ||
} | ||
|
||
@Override | ||
public void execute(CommandSource commandSource, @NonNull String[] strings) { | ||
public void execute(SimpleCommand.Invocation invocation) { | ||
CommandSource commandSource = invocation.source(); | ||
String[] strings = invocation.arguments(); | ||
|
||
if (strings.length > 0) { | ||
String message = String.join(" ", strings).replace("&", "§"); | ||
for (Player player : server.getAllPlayers()) { | ||
player.sendMessage(TextComponent.of(message)); | ||
player.sendMessage(Component.text(message)); | ||
} | ||
} else { | ||
commandSource.sendMessage(TextComponent.of("Usage: /broadcast <message>").color(TextColor.RED)); | ||
commandSource.sendMessage(Component.text("Usage: /broadcast <message>").color(COLOR_RED)); | ||
} | ||
} | ||
|
||
@Override | ||
public List<String> suggest(CommandSource source, @NonNull String[] currentArgs) { | ||
public List<String> suggest(SimpleCommand.Invocation invocation) { | ||
return new ArrayList<String>(); | ||
} | ||
|
||
@Override | ||
public boolean hasPermission(CommandSource source, @NonNull String[] args) { | ||
return source.hasPermission("vtools.broadcast"); | ||
public boolean hasPermission(SimpleCommand.Invocation invocation) { | ||
return invocation.source().hasPermission("vtools.broadcast"); | ||
} | ||
} |
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
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
Oops, something went wrong.