Last active
February 10, 2022 19:01
-
-
Save 4drian3d/074c5ab77b16a12b690da46831e2c5ba to your computer and use it in GitHub Desktop.
ProtocolizeAudiences example on Velocity
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
private final ProxyServer proxy; | |
public ProtocolizeCommand(ProxyServer proxy){ | |
this.proxy = proxy; | |
} | |
@Override | |
public void execute(Invocation invocation) { | |
CommandSource source = invocation.source(); | |
String[] args = invocation.arguments(); | |
if(args.length < 1){ | |
// Send to self | |
if(source instanceof Player){ | |
ProtocolizeAudience pAudience = ProtocolizeAudience.audience(source); | |
pAudience.playSound(Sound.ENTITY_CREEPER_PRIMED, SoundCategory.AMBIENT, 10, 10); | |
source.sendMessage(Component.text("Sound AutoSended")); | |
} else { | |
source.sendMessage(Component.text("Ignored")); | |
} | |
} else { | |
switch(args[0]){ | |
//Send to a server | |
case "server": | |
if(source instanceof Player){ | |
Player player = (Player)source; | |
RegisteredServer server = player.getCurrentServer().get().getServer(); | |
ProtocolizeAudience serverAudience = ProtocolizeAudience.audience(server); | |
serverAudience.playSound(Sound.ENTITY_CREEPER_PRIMED, SoundCategory.AMBIENT, 10, 10); | |
source.sendMessage(Component.text("Sound Sended to Server")); | |
} else { | |
source.sendMessage(Component.text("You are not a Player")); | |
} | |
break; | |
//Send to all players | |
case "all": case "proxy": | |
ProtocolizeAudience proxyAudience = ProtocolizeAudience.audience(proxy); | |
proxyAudience.playSound(Sound.ENTITY_CREEPER_PRIMED, SoundCategory.AMBIENT, 10, 10); | |
source.sendMessage(Component.text("Sound Sended to Proxy")); | |
break; | |
default: | |
ProtocolizeAudience defaultAudience = ProtocolizeAudience.audience(proxy); | |
defaultAudience.playSound(Sound.ENTITY_CREEPER_PRIMED, SoundCategory.AMBIENT, 10, 10); | |
source.sendMessage(Component.text("Sound Sended to Proxy")); | |
break; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment