#velocity-dev
164 messages ¡ Page 7 of 1
you said nothing about why it's so terrible
read the post I sent.
I can't tell why you're not willing to
because you started this discussion
If you'd prefer I sent it,
Static variables represent global state. That's hard to reason about and hard to test: if I create a new instance of an object, I can reason about its new state within tests. If I use code which is using static variables, it could be in any state - and anything could be modifying it.
I could go on for quite a while, but the bigger concept to think about is that the tighter the scope of something, the easier it is to reason about. We're good at thinking about small things, but it's hard to reason about the state of a million line system if there's no modularity. This applies to all sorts of things, by the way - not just static variables.
answered Aug 11, 2011 at 13:18
Jon Skeet
thx
what does and anything could be modifying it. mean?
the static variable
could be changed
and you have a new state
this is not super important for MC
but it's against best practices
ok, so find me another way to do pass it and i will stop using instances
wdym stop using instances?
and find me another way?
We were just talking about it. Dependency Injection
pass an instance of your plugin to methods
stop using that ""static abuse"" as you call it
show me how to
as zMario did
i think it would break stuff
new TestClass(this)
and inside TestClass accept an instance of your plugin
what stuff would it break?
oh, like that
you're using OOP Java how it was made :p
i'll try
(not now because i need to first finish my plugin)
since is not causing performance or securety issues, i don't care that much
tbh
again, it's probably fine
but it's against best practices
I was just trying to explain what they were doing
you mean "it's not the best way to do it"?
yes, static abuse is not the best way to do it.
ok, i got it
another question, how am i supposed to share variables across the project without having to reinizialize them every time?
shut up
^^^
kyngs is right
I know how wierd dependency injection is as a newbie
but you get used to it
i asked another thing
.
we just answered you
nope
that solves nothing
???
that's static abuse
what?
as you said
???
huh
passing an instance
as a parameter
is fine
I told you not to make a public static variable
that was an instance of your main class
so, it's not fine to pass an instance of a class and it's fine to pass istances of variables?
^^
Why wouldn't it?
it's just when you use static
he said it's static abuse
i'm very confused rn
i think everyone here is
I'm a bit tired so am probably explaining things poorly
I second that
That's technically speaking not static abuse, but singleton. You should avoid that too
ah
well, I misunderstood then
but I was just trying to explain that when that guy a while back passed this, he was doing a fine thing
why wouldn't he?
you don't have to
you can though
if you don't need the data
then you don't need to
ok, now i'm sick of this
so for once, can you exaplain when tf is this so called "static abuse" and when it's not
and what should be the correct behaviour?
correct behavior -> dependency injection
and how tf should do that?
as an argument
yes
THEN SAY SO
that's what I was trying to explain, I'm sorry of I was unclear
it was pretty clear to me...
dude, honestly, fuck off
lol why are you so mad?
On an entirely unrelated note, are there any examples of plugin messaging on velocity
I can't get it working
hm?
that's the wiki website
that isn't related to plugin messaging at all
ik
i sent you the wiki website
okay...?
^
I tried
arena.sendPluginMessage(MinecraftChannelIdentifier.create("trials", "start"), new byte[0]);
if he could, he wouldn't be asking here
and could not recieve anything on the channel minecraft:trials
that won't work, plugin messages must be bound to player
???? Plugin messaging is not on the wiki
ooooh
so
who said anything about the wiki now?
you
.
will that work if a player is connected?
or does that always fail
as long as there is think kind of "helping behaviour" ofc not
if you want to send something, do it like this:
player.getCurrentServer().get().sendPluginMessage(the thing you already have)
cool
make sure to check whether player is connected to some server
you're not gonna tell him "look it for urself" uh?
This message was response to
this message
nope
it literally is lol
nope lmao
or at least that's how I meant it, the fact it was send after your message should indicate that
how you intend something is not always the same as how something is
guys please stop, there's no use in this
well there's one great thing called "common sense", if I send something right after your message I am probably replying to it
Does that thing I sent work?
trying it right now
that "as if he could search it for himself" was not related to the wiki
Optional<Player> arenaPlayer = arena.getPlayersConnected().stream().findFirst();
arenaPlayer.ifPresent(player -> player.getCurrentServer().get()
.sendPluginMessage(MinecraftChannelIdentifier.create("trials", "start"), new byte[0]));
doesn't work unfortunately
still getting nothing
on the other end
since you said to me to look for what i was asking for myself
maybe the issue is the MinecraftChannelIdentifier? I just don't know how to make my own lmao
yup
this.getServer().getMessenger().registerIncomingPluginChannel(this, "minecraft:trials", new PluginChannelListener());
oh that's the issue!
public class PluginChannelListener implements PluginMessageListener {
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
System.out.println("Received message from channel " + channel);
if (!channel.equals("minecraft:trials")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
System.out.println("Received message from subchannel " + subchannel);
if (subchannel.equals("start")) {
Utils.createPlatform(Bukkit.getWorlds().get(0));
new BukkitRunnable() {
@Override
public void run() {
Utils.removePlatform(Bukkit.getWorlds().get(0));
}
}.runTaskLater(PVPTrialsArena.this, 20 * 8);
}
}
}```
what a clown, ghosting me because you know i'm right
MinecraftChannelIdentifier.create("trials", "start") will create channel named "trials:start"
iirc
ah okay
:), I don't usually block people, but I don't think you're worth my time. Are you really that pathetic that you check whether someone has blocked you all the time?
blocked?
[PVPTrialsArena] [STDOUT] Received message from channel trials:start đ
Thank You!
You're welcome
the time of someone that replies with "go look by yourself" when someone asks something is veeery worthy lol
lol
i didn't even know you have blocked me lmao
lmao
How do i get current server of CommandSource object?
You can only get the server of a Player
CommandSource can also be a console, which well, can't be connected to any server
any way to get player from commandsource?
instanceof + cast?
let me try
Is it possible to check if a kick message contains a certain String? The problem is that I don't know how to check for Components correctly :/
(Please ping on answer)
+ event.getPreviousServer().get().getServerInfo().getName() + " â "
+ event.getServer().getServerInfo().getName() + ")";```
Why this String converted into component using Component.text(sendMessage) outputs this weird characters?
its working
because it doesnt know how to handle § i think
how can i replace §
That's not the right way to use components, here is the guide https://docs.adventure.kyori.net/text.html
Make sure you have permission to run the command
That's just bad file encoding - but yes, don't put legacy characters into components, use them properly as per the doc link. You may also want to look at the legacy component serializer or a modern tool like minimessage
Anyone has an answer? '^^
think Component had a search method
or use the serialisers to convert it to plain text depending on needs, etc
sounds like bad design tho - why don't you just send a plugin message or something and make velocity do a kick or whatever it is you're trying to do
is it possible to change server brand from "Paper (Velocity)" to custom text in F3 Debug?
yes but it's not supported in velocity
so its some kind of license?
no
it's just that velocity doesn't natively support removing attribution - neither does paper/etc
youâre free to change it with a plugin or by editing the sourcecode as long as you follow the license for whatever which youâre doing
Just know that changing it will not make the proxy unidentifiable
what version of adventure is velocity-3.0 is using?
4.10.0 currently
thanks
If you have time, could you bump that to 4.10.1?
Am about to turn my phone off for the night, will do before or after lecture tomorrow if thatâs fast enough
Yup, that's fine
Kk
need to decide on when to do a release tbqh
i cant create classes and when i click on browse the project is not showed so i cant select it and so i cant create class files
this isnt really eclipse support
i got said i should move to #paper-dev but ok where should i ask instead?
oof sorry im dumb
idk why the trees are different but it seem to not understand that there is a sourcefolder in the paperweight project
well
the java folder should be a source folder
make sure that you imported the gradle project properly
I can't provide support for eclipse, however
okay thanks
Hello! Sorry, I have more questions on plugin messaging. Is it normal that on first initialisation of Paper and Velocity that no plugin message exchanges go through? If I reconnect a second time, it all works fine though.
Anyone that can help me?
Is it possible to know somebody's client version on login? Aka to send them a specific server that's on a different version?
ah protocolversion i wager
No; Thatâs not normal. Once a client is at or past the ServerPostConnetEvent this should definitely work in any case
Can you inspect the compiled product with Bytecode-viewer and show us how it generates that? Lombok can create unusable bytecode with custom annotation processors
Yea; from the time the connection is past Handshake that info is available https://jd.velocitypowered.com/3.0.0/com/velocitypowered/api/proxy/InboundConnection.html#getProtocolVersion()
đ
What version of the velocity api should I be using? 3.1 or 4.0?
are plugins built with api 3.1 compatible with velocity 3.2.x?
3.1.1 because it's stable
Well Iâm running some inside the server post connect event, and I understand if that doesnât work, but I have some in commands, and that doesnât work on the first connection.
not the proxy its self, the api
4.0 is pre-beta. Any 3.x version is fully upwards compatible to any newer 3.x. If you want to be sure it runs on older 3.x versions too use the 3.0 api
Show your code?
--- This is for registration: ---
Velocity: server.getChannelRegistrar().register(MinecraftChannelIdentifier.create("imdabigboss", "main"));
public void onPluginMessage(PluginMessageEvent event) {
Paper:
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "imdabigboss:main");
this.getServer().getMessenger().registerIncomingPluginChannel(this, "imdabigboss:main", this);
public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
---This is for messaging: ---
Velocity: server.sendPluginMessage(CHANNEL_ID, b.toByteArray()); (public static final ChannelIdentifier CHANNEL_ID = MinecraftChannelIdentifier.create("imdabigboss", "main");)
Paper: player.sendPluginMessage(PLUGIN INSTANCE, "imdabigboss:main", b.toByteArray());
When are you calling the .sendPluginMessage(âŚ)? Again its only guaranteed to work from ServerPostConnectEvent
Also, how are you getting the server?
Is there a PlayerPreprocessCommandEvent in velocity that does provide the whole message?
Or would I use the PlayerChatEvent and check if it starts with /?
just CommandExecuteEvent? chat events aren't fired for commands
that's not what i'm seeing
Ohw, then what's the method called to get the whole message/arguments
getCommand
itâs the whole command without the first slash
Iâm getting the server from the player (if it exists, it warns me if not) and from the event in server post connect event. Iâm calling those functions from a command and in that event.
which version of adventure does velocity 3.1.1 ship with?
4.9.3 iirc
sure, that's 3.1.2-SNAPSHOT tho :p
^
Hey there I have a problem with the CommandExecuteEvent
I am trying to get all commands executed on the proxy but when I go to the server and try for example to execute /foo it does not print anything.
@Subscribe
public void bar(CommandExecuteEvent event){
System.out.println(event.getCommand());
System.out.println(event.getResult());
System.out.println(event.getCommandSource());
}
I have registered the event subscriber and also have this in the same class
@Subscribe
public void foobar(PostLoginEvent event){
Main.instance.server.getEventManager().fire(new CommandExecuteEvent(event.getPlayer(), "/test"));
}
and this fires and also causes the bar event to fore
How I can get all the online players?
in the proxy
to put them in the tab complete
ProxyServer#getAllPlayers
Is that command registered on the proxy?
Also tried executing /velocity
But I would like to catch all the commands that are only registered on the servers not on the proxy
I think your issue is that youâre trying to run a command manually using the event
I am running the commands ingame
thx
ty!
Velocity doesnât have a network control thread
Some of the en/decoding is differently designed
As per events; everything is async; but thereâs a difference between blocking and non-blocking events
Blocking events are annotated @AwaitingEvent to clearly indicate the blocked event flow
Any other events are notify only
Threads are from a thread pool and each event is fired on a future-basis from said pool
Same goes with all internal code
There is a âmainâ context type thread per player but thatâs the only clearly linked thread
To put that into perspective, Velocity will use an ample amount of threads so itâs best run in a threading-friendly environment (multi-core cpu)
^ that especially scale out well with compression
Yes, usually swapped in and out with a lot more executors
But you need to remember that a Java thread doesnât occupy a system thread fully
A single core can manage a lot of low to medium-load Java threads just fine
The alternative is what bungeecord does (or did? not sure) in which case if the thread hangs the proxy essentially chokes or freezes
Does anyone have any idea?
You should not use main singletons, use dependency injection instead
And I think only registered command work
But idk exactly
No, the event is fired regardless of whether the command is actually registered
Is the event fired if you use CommandManager#executeAsync https://jd.velocitypowered.com/3.0.0/com/velocitypowered/api/command/CommandManager.html#executeAsync(com.velocitypowered.api.command.CommandSource,java.lang.String) (instead of firing the event yourself, that's dangerous)
Is there any docs for velocity plugins? Does the docs just end at the couple of website examples/event apis?
the event api seems pretty limited, is there a way to get the input params to the events? For example im trying to get the player once they log in, but have no real clue to get the player as the docs are super limited.
thanks!
How do you do color codes with Components? the usual "&c" doesn't auto translate
Donât
then how to use colors
Using kyori or minimessage
That seems horrible for a configuration to allow people to change colors
How so
<red>Red Text <yellow>Yellow Text makes a lot more sense than &cRed Text &eYellow Text but maybe thatâs me
I'm coming from 1.8 & bungee purely so I only know &
The only difference is you have to know the names of colors
So like instead of 4, think dark red
will take some getting used to
It makes a lot more sense than magic numbers
Random numbers arbitrarily assigned to a color seems more confusing to me
It's just what my entire community is used to
lol yeah, I've been living in the caves of 1.8 spigot and bungeecord for too long now, want to actually progress things along with minecraft
Kyori is the way to go
Never a better time than now đ minimessage is super cool, I recommend pursuing that
Is there a method somewhere in getServer() to get the plugins information, the @Plugin annotation descriptor
IIrc get the class, then get the annotation?
forgot about that
Just using it and reading over the docs this is like 90 times better... why haven't I done this earlier
Is spigot not used anymore? is there something else that has replaced it?
paper
paper is spigot
I mean something like velocity where it has its own base, and isn't built from bukkit/spigot
Paper is becoming less and less spigot every update
They have plans to drop spigot as an upstream
Really the only thing could be fabric but that's still an entirely different thing so
Since it's meant for modding
PaperMC encompasses Paper and Velocity, Velocity is built up itself so it doesnât use bungee chat, instead they use a shared lib which is kyori
Kyori has quite a few different optimizations but in general itâs a lot faster and performant than legacy.
I really enjoy velocity
is ServerResult.denied() the equivalent of event.setCanceled(true)
pretty much, the only difference is that some results have metadata
it's more complex than "cancelled" but it gives us more options
man this is so much nicer than legacy
100% yeah
Does velocity have an offline player?
it doesn't really have that concept
so no
alr I'll just make requests through mojangs api
how do i send a player to a server?
why does this not work
might have done this incorrectly
how to change variables in config toml and save it?
I would think u need to use the snakeyml library, but i could be mistaken
snakeyml is for yml not for toml files
The context.getSource() method returns a CommandSource instance, which can be a player or the console. To perform an action if a player executes the command, you must perform an instanceof check and then cast the CommandSource to a Player
Also, can we see the command registration code? (clarifying 4drian3d's message -- you don't need to manually extract the player's name and do a lookup, a Player is a CommandSource)
Hey, I'm trying to pass through a favicon/server list icon during the ProxyPingEvent.
Need to do it through URL. The docs say to convert the URL to base64 first, so I do. Then I create the favicon with Favicon favIcon = new Favicon(serverIconB64);, but it's showing up as black in the server list. I'm positive that the provided URL is correct, and I can take the serverIconB64 and convert it back to the URL myself and the download works through the browser.
I'm also providing the image myself through a pipe in node.js (res.writeHead to set the Content-Type, Content-Disposition, and Content-Length and then fs.createReadStream.pipe(res)), does it need to be sent in a specific way for Velocity to accept it?
Did I misread ctr the docs for Favicon? It says we can pass through a "Base64 URL", which I assumed meant it can be a remote URL. But all the other helper functions that it suggests say to either pass in a path or a BufferedImage, which leads me to believe that it might not take remote URLs.
Oohh, yeah that makes total sense.
Same issue. Still black. I'm going to try passing the URL and let Java's ImageIO convert it to a BufferedImage, and use that to generate the favicon.
Same issue with creating a FavIcon via BufferedImage. The BufferedImage has the correct image data, but on the server list it's just black.
are you sure it's being put into a 64x64 png when being sent
the size is important
100% sure. I uploaded the same file and loaded it via FavIcon's path loader and it worked fine (and I just double checked the remote file that it's grabbing, it is 64x64). But for some reason the URI nor the BufferedImage -> FavIcon are working.
What does the default fav icon logic look like, is there a way to completely replicate that code with the target uri in place of the file uri
Our default FavIcon usage is pulled from file. So it works fine.
yeah right, but look at the source code of velocity for how it translates it and sends it
because if you can get it into a similar format at a single stage of the process you could just replicate the remaining steps
I'd bet something you're doing from loading the url contents to distributing them is wrong
Ohp, I think something got messed up with my image. It seems fine, but the size is different and I just tried loading the exact image via path and the same thing is happening, black image. Gonna do some more testing with other images to try to track down the issue.
Also, the source of FavIcon is super simple. Just converts the Path to a BufferedImage, then a BufferedImage to a URI. So I think it's very likely something just got messed up with my image during development.
Favicon.create(ImageIO.read(inputstream));
Thatâs what I did in my plugins
Scratch everything I just said. BufferedImages aren't working for me at all.
If I load it using ImageIO.read(inputStream) it works, but loading the file into a BufferedImage using ImageIO.read(new File("/path/to/server-icon.png")); and then create the FavIcon with Favicon.create(bufferedImage) always provides a black image.
Thatâs not surprising,
The image reader chosen is probably not good for the image
Is there anything I can do to go about fixing it, other than downloading the file locally then using an inputStream? That's not really an option.
ImageIO also has a .read(URL)
Yeah, same issue.
I donât have the workings of either in my head atm; There are other ways to encode it as b64, well other than what velocity does
If you use one of those and turn it back, provide that and send it then should work
I already tried encoding it to URI myself and had the same issue.
Is the URI a local resource or a remote resource
It's a data URI, so the image is stored in the URI itself afaik.
And the URI can be written to file successfully?
Yeah. The URI link itself worked fine. Triple checked. Just loading as black.

I just tried uploading a brand new 64x64 png file to imgur and using the direct link as a URL in the ImageIO.read(new URL(url)), still same issue.
I am questioning the flags or channel of the image as URI encoded
If the data didnât amount to a picture it wouldnât display anything except the standard sever icon
Thinking the transparency channel is broken?
Remember the opengl Minecraft clients use doesnât make sense and especially these icons are finicky as hell
I bet 5$ that the icon displays correctly if you check status with a site like https://mcsrvstat.us
It sure does.
What does that mean?
The image is being processed by velocity properly, but not the Minecraft client?
Would that mean that I created the image incorrectly somehow? Or?
No the image is fine
The way itâs rendered is the issue
And thatâs not an issue with how you saved it
Itâs an issue with how velocity re-encoded it
Itâs correct but the client doesnât think so
Finicky as hell
Thatâs the beauty of this with opengl
Probably changing one letter in the address would also have fixed or changed it

I tried deleting the server and re-adding, but I'm wondering if it keeps deleted servers cached until you restart or something.
"beauty" lol. Thank you for the help. I think we can deal with just needing a client restart some of the time, for now at least.
I have no fix for this
Could probably be fixed with a fabric mod to force linear encoding on this
Thatâs also the reason maps sometimes flicker ingame btw
Same issue
Probably, but we can't expect users to install fabric + a mod.
Ahh, interesting. Good to know. Thank you again for the help!
Just as a parting comment
Thereâs a high chance youâre the only one whoâll ever experience this issue here so in a way itâs ironic

What is the proper way to get a player from an on command event?
CommandSource source = event.getCommandSource();
if(!(source instanceof Player)){
// the source is not a player, maybe consolecommandsource
source.sendMessage(Component.text("You are not a Player", NamedTextColor.GRAY));
return;
}
// the source is a player and can be casted to a player
Player player = (Player) source;
player.sendMessage(Component.text("You are a Player", NamedTextColor.GREEN));
If you are trying to make a "/hub" plugin you don't need to put a listener in the CommandExecuteEvent, directly in the brigadier command you can send the player to the hub. You can be guided by a plugin I recently made for the same purpose https://github.com/4drian3d/VLobby/blob/main/src/main/java/me/dreamerzero/vlobby/commands/LobbyCommand.java
Oh okie, so i just cast the source to a player
now that I have a bit more understanding of the velocity api, I went through and cleaned up the code. Please let me know if i did something incorrectly!
A CommandSource can be an instance of a player as well as of the console, so you must always check instanceof to be able to cast a commandsource to a player
There are several methods that return an optional, these methods indicate that the value they contain, will not always exist and can be null, for example, when calling a method server.getServer("lobby"); There is a possibility that either the server is not registered or the server is offline, so you should not call an Optional#get on every method that returns an optional, but you should check if it contains a value with Optional#isPresent or Optional#isEmpty before calling the Optional#get method
To compare the similarity between objects, unless it is a primitive type you should not use a comparator ==, but the #equals method. The == comparator checks if the 2 objects are exactly the same in memory, which, most of the time, does not return true. While the #equals method checks for similarity with implementation specific checks, so it may be more accurate depending on what is required
I'm sure this is a very common question but I can't find an answer, how do I teleport players to a different server from a spigot plugin?
the same way you would do if you were running behind bungee
Inexperienced, how would that be?
bungeecord connect player to another server -> 
Right, thank you
What is the equivalent of TabCompleteEvent for 1.13+ as this works only for 1.12 or bellow according to the docs?
there isn't one, as per the docs
Is there then any way to block auto-completer?
You can remove the commands in the PlayerAvailableCommandsEvent event
do you have any examples on hand?
public void handle(final PlayerAvailableCommandsEvent event) {
if (!event.getPlayer().hasPermission("system.admin")) {
event.getRootNode().getChildren().clear();
}
}```
which is cringe solution that doesn't do anything security wise other than annoy people and reduce accessibility
just create your commands properly in the first place
ez
Would this also clear server side command that are not registered on the proxy?
yes
again, just make your commands properly and then you wouldn't have to do anything of this
Yeah I already have lots of plugins that do not do it properly and I want to implement this to clear the mess
Would there be a way to filter server side commands also. So it will only allow certain commands to be auto completed?
Can the proxy really remove the commands registered by the server that are sent to the player? or even know of their existence?
Heyo,
Just trying to get started on Plugin Messaging within Velocity, does anyone have a good link or way to get started with that?
It works more or less in the same way as on bungeecord basically, https://gist.github.com/Xernium/95c9262c5f70b8791557861bbc09be1b see this as an example
Awesome thank you!
Thereâs a semi-supported way of intercepting packets- See how ViaVersion or Geyser injects by replacing the channel initializer
But itâd be better to know why youâre trying to do this beforehand
How would I send a message to all servers for example? This one only seems to be targeting one receiver
What exactly are you trying to do?
Pretty much sending a plugin message to all servers, so that the other plugins on those servers all update states upon receiving a message
If that makes any sense
You can iterate through the registered servers and send the message to all
But beware that the messaging api only works as long as at least one player is connected to the server thatâs supposed to get the message
Ah I see! Good to know, thanks for the help, think I can go off on my own from here
Hello! Is there a way that I can subscribe to events like interactions, block placements, and stuff like that with Velocity? I'd rather do it network wide, rather than on every server.
well, no
technically, yes, but, well
- velocity doesn't care about that stuff so doesn't decode those packets and just passes them through
- velocity wouldn't know what you interacted with, given that info only exists on the server/client
Ok. So I'll have to do it in a plugin. Just means a bit more organisation for me then. Can't do it the lazy way XD
You're a lot better off using login-plugin-messaging. That wont require a hack and since youre using a client mod you might as well use that
Velocity is one of the only non-modded platforms that has native api support for it (already)
For anyone who wants to play with the bleeding edge.. see the dev/netty-5 branch, where I've made initial progress in moving Velocity to use the very first Netty 5 alpha.
CAUTION: Don't use this branch where you care about the integrity of your server. It's not going to work with plugins that grovel down into the Netty layer to do their work like Geyser or ViaVersion. HAProxy is not currently supported. I have only lightly tested this, and it works insofar as you can authenticate to the proxy - the rest is up to you.
And I am not going to make development builds available, you get to build it yourself.
any way to make aliases with the /server command?
example: /s for /server smp
preferably a plugin (not mycommand), idk how to code
then don't crosspost, especially into the dev channels...
mb
@oblique haven https://pastebin.com/e61vFfuN
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Not entirely sure, looks like the runnable youâre assigning isnât properly interfaced as a command - but thatâs just my initial guess
Canât tell from initial glance though
It looks like it needs to serialize it - I assume something with that command or simple command class has something to do with setting that up
Hum okay I work with someone who use a thread for his plugin. It's required to do a thread for a command ?
Did you need to see my main class ?
In line 33, StringReader::getString is not a valid type, choose one of these three https://github.com/Mojang/brigadier/blob/cf754c4ef654160dca946889c11941634c5db3d5/src/main/java/com/mojang/brigadier/arguments/StringArgumentType.java#L20
Thanks I take a look
Hi
How i can create a .yml config file in velocity plugin
:saD:
Some people prefer Toml as a configuration file, try looking others velocity plugins source code for an example of implementation, both yaml or toml
I can't find anything about yamls that's why I ask for help
if anyone could help me i would appreciate it
But there are any example code?
configurate has a wiki yes
https://github.com/SpongePowered/Configurate
Configurate is a simple configuration library for Java applications that provides a node-based representation of data, able to handle a wide variety of ...
yes but when i see the example i dont know how i can call the config file to use getstring
look
i have this from configurate repo
but i dont know how register and use in other class
Did you look through the wiki
Read this, and go through it, and you should be able to figure it out
If anything we would just be quoting the wiki so
sponge also has a discord
i can register but, how i can do for example
final ConfigurationNode countNode = root.node("messages", "count");
final ConfigurationNode moodNode = root.node("messages", "mood");
final @Nullable String name = root.node("name").getString();
final int count = countNode.getInt(Integer.MIN_VALUE);
final @Nullable Mood mood = moodNode.get(Mood.class);
this
In another class other than the main
well, that's just java
id rec doing something like jetbrains academy before you start developing plugins
I see that however I don't see configurate anywhere in the server file and I just get java.lang.NoClassDefFoundError: org/spongepowered/configurate/serialize/TypeSerializer if I dont shade myself
velocity contains 3.x
Velocity currently includes Configurate 3, not Configurate 4. The Configurate 3 documentation is https://github.com/SpongePowered/Configurate/tree/3.x/configurate-examples
??
Why?
He's a troll, he got removed, dw
did not know that paper is apparently a server host!
Ok. But of all the available channels... why do you say it in the Velocity channel? đ¤
He's banned lol
is there an api event for when a player disconnects? I can only see when the player is kicked.
playerquitevent
perfect thank you guys ;)
My server selector plugin uses the BungeeCord plugin messaging channel to send players to servers. Reportedly, this does not work with Velocity when configured in modern forwarding mode (I know it works in classic mode).
I couldnât find any mention in the documentation about the BungeeCord messaging channel with regards to modern forwarding. Does modern forwarding use the BungeeCord messaging channel, or something else?
Forwarding mode has zero effect on this. But I assume you have the online-mode misconfigured for the online-mode of the proxy; see that it matches in the paper.yml and velocity config
Inconsistent UUIDs will cause this is what Iâm saying
Will check that after eating thx for the answer 
Yeah, that was the issue, tho it doesn't seem to work with Fabric server...
Tried Fabric-Proxy and Fabric-ProxyLite
if you have an issue report it to their github https://github.com/OKTW-Network/FabricProxy-Lite
Thx 
Hello everyone, if I want to modify the tab response sent by the server to players, what events should I monitor? (in BungeeCord, it is "TabCompleteResponseEvent". I'm migrating from bc to velocity, but I can't find the corresponding event. I only found "TabCompleteEvent", but it only supports 1.12.2 and below)
I don't think that velocity exposes that
Oh, I'm making a feature to replace the player list because my plugin has the ability to operate across servers.
If velocity does not have this API, it seems that more complex operations are required. đ
If you just want to remove commands then the PlayerAvailableCommandsEvent is what you want to use
Otherwise actual tab-completes for commands arenât exposed to the api
ok, thank you!
Hi, when is velocity adding 1.18.2 support? My server hosting is Exaroton.
Velocity already supports 1.18.2
grab a build from the downloads page, velocity has supported 1.18.2 for like a month now
If an exception happens in initalizing my plugin, what can I call to mark it as such in Velocity?
e.g. if something critical happens to where my plugin cannot function properly, can I force the Velocity server to shutdown or unload my plugin in response?
Specifically during the initialization stage
you can handle errors properly and shut it down yourself đ
what kind of errors are you seeing which would be critical which you can't catch yourself?
I can catch them just fine, but if the error occurs, the plugin can't function at all afterward
I was looking in the api for a built in shutdown method
then you should shut down the velocity server yourself - velocity has no concept of enabled/disabled
ProxyServer#shutdown
I have a question, so i want to create a config file for my velocity plugin but idk how to create a Configuration file can someone help me?
thanks
Is it possible to track which subdomain is player using to join server?
I want to make something like u join string1.domain.com -> value for your uuid in database is set to "string1", if u join string2.domain.com, value is set to "string2" etc.
Yes, you can get the hostname used off the players connection or something iirc
use the "virtual host" of the address
Player#getVirtualHost()``` this is the method
Is it possible anyway to get proxy bind port in ProxyInitializeEvent?
Well it returns something like this _dc-srv.0b917116b85b._minecraft._tcp.domain.com (code p.getVirtualHost().get().getHostName())
that's because of the types of records probably? I'm not entirely sure
i don't know how that is even possible
Hostname or IP, e.g. localhost or 127.0.0.1, that was used to connect. The Notchian server does not use this information. Note that SRV records are a simple redirect, e.g. if _minecraft._tcp.example.com points to mc.example.org, users connecting to example.com will provide example.org as server address in addition to connecting to it.
Thereâs https://jd.velocitypowered.com/3.0.0/com/velocitypowered/api/event/proxy/ListenerBoundEvent.html
Edit: Use that getAddress().getPort()
~~As for that DNS address from the hostname might be an unresolved address
- Adding onto that the behavior will vary drastically depending on how system DNS is set up~~
Stricken text unrelated got confused in the process of reading the messages
Thereâs also https://jd.velocitypowered.com/3.0.0/com/velocitypowered/api/event/proxy/ListenerCloseEvent.html if you need that for any reason
How do I change the player count which is shown in the server list?
I could find a getPlayerCount() method.
But not a setPlayerCount()
that method iirc was on another object
you'd create a new instance of that other object and set it on the event
You set it on the proxypingevent.
Got it thanks
is there a getDataFolder() in velocity, similar to JavaPlugin#getDataFolder() in paper?
nvm @DataDirectory is something
what about using minimessage in velocity?
Yeah it packages it in
At least it does in the latest dev
ohhh thats why my plugins didn't work yesterday, it wasn't in the stable build yet
Hi, why this dont work?
public class ChatListener {
@Subscribe(order = PostOrder.FIRST)
public void onChat(PlayerChatEvent event) {
final Player player = event.getPlayer();
if (player.hasPermission("pl.rafi67000.velocitycore.chat.premium")) {
String message = event.getMessage();
String replacedMessage = message.replace("test", "testooowawiadomosc");
event.setResult(PlayerChatEvent.ChatResult.message(replacedMessage));
}
}
}
Hi guys do you know how could I remove this useless exception thrown by Velocity when a player tries to connect to an offline server with the /server command:
io.netty.channel.AbstractChannel$AnnotatedConnectException: finishConnect(..) failed: Connection refused: /
Caused by: java.net.ConnectException: finishConnect(..) failed: Connection refused
at io.netty.channel.unix.Errors.newConnectException0(Errors.java:155) ~[velocity.jar:3.0.2-SNAPSHOT (git-effca0da-b70)]
at io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:128) ~[velocity.jar:3.0.2-SNAPSHOT (git-effca0da-b70)]
at io.netty.channel.unix.Socket.finishConnect(Socket.java:312) ~[velocity.jar:3.0.2-SNAPSHOT (git-effca0da-b70)]
at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.doFinishConnect(AbstractEpollChannel.java:710) ~[velocity.jar:3.0.2-SNAPSHOT (git-effca0da-b70)]
at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.finishConnect(AbstractEpollChannel.java:687) ~[velocity.jar:3.0.2-SNAPSHOT (git-effca0da-b70)]
Its much bigger I had to cut it
do you have your firewall set up correctly
Hi, why this dont work?
public class ChatListener {
@Subscribe(order = PostOrder.FIRST)
public void onChat(PlayerChatEvent event) {
final Player player = event.getPlayer();
if (player.hasPermission("pl.rafi67000.velocitycore.chat.premium")) {
String message = event.getMessage();
String replacedMessage = message.replace("test", "testooowawiadomosc");
event.setResult(PlayerChatEvent.ChatResult.message(replacedMessage));
}
}
}
Hi i was wondering about safe way to execute commands for example give user i specify specified rank from my other service on the same server is there any hooks or is the rcon the safest way to go?
rcon is okay but for safe set firewall
I don't know if this woirks, /send?
teleport not server change
I believe he meant change server
is there a velocity plugin github I can look at for brigadier commands? I have a command /party test <player> but the player argument is triggered instead of test literal argument. I want to know what literal is used from inside the player arg executes
that uses simple command
could be a lot easier to write with simple though
I see a lot of plugins using it instead of brigadier
Any way to send a plugin message from a spigot server to another without the server you are sending from and to have player
hi, when my server restarts, an error is thrown in console
[18:40:34] [Netty epoll Worker #1/INFO]: [connected player] mastermc05 (/*ip*:33631) has disconnected: An internal server connection error occurred.
because this is a disconnect, not a kick, my plugin can't detect this, and also i'm not redirected to limbo
I'm using the same configs as on my pc, and when i connect trough my pc it works well, but if from pterodactyl, it has some troubles
Can somebody give me at least a hint what may be wrong?
redis :p
lol
The player argument is an argument node, not a literal node
depends on what the exception is coming from is the issue
like, restarting a server /shouldn't/ cause that
but it happens every time on restart, and most strange, on the same server, but from 2 different proxies (with the same secret), one has error, the remote one doesn't have
and when the error happens, i'm kicked with a delay
i wabt to try rebooting the vds now,when there will be 0 players
is there a way to enable like debug level for more logs on that error?
.
What about it doesnât work
What have you tried
Have you done any debugging at all?
What plugins do you run?
chatregulator litebans luckperms party and friends clans report helpop velocitycore vtools
this dont work, without error etc
What about it doesnât work
What part of it
Does it run
Does it check the permission
replace TEST in message to another text
no
does velocity provide a plugin config?
no, use java utilities for file
Hey, I'm trying to work with plugin messaging with Velocity 3.1.2 but it doesn't seem to be working.
Plugin channels have been registered in both plugin/proxy plugin
@EventHandler
fun on(ev: PlayerJoinEvent) {
val p = ev.player
val baos = ByteArrayOutputStream()
val dos = DataOutputStream(baos)
dos.writeUTF("Test")
p.sendPluginMessage(this, "messagechannel:proxy", baos.toByteArray())
logger.info("sent plugin message to messagechannel:proxy")
}
This is the test code I'm using to quickly send a message
And this is my receiver
@Subscribe
fun onPluginMessageEvent(ev: PluginMessageEvent) {
logger.info("Hit event // ${ev.data}")
}
It seems to be sending the message but the proxy isn't receiving it, any ideas as to why this is happening? Ping me if you know, thank you!
Solution: Wait a few ticks before sending the plugin message.
Also this is how I'm registering the channels on Server/Proxy
Server: server.messenger.registerOutgoingPluginChannel(this, "messagechannel:proxy")
Proxy: proxy.channelRegistrar.register(MinecraftChannelIdentifier.create("messagechannel", "proxy"))
In the first snippet your message actually gets sent to yourpluginname:messagechannel:proxy
Oh does it?
The format is supposed to be
pluginname:channel
To my knowledge, yes
When I tried registering a channel on the server it was throwing an error because the name didn't have a colon in it or something
Are you sure?
Might not have read the error properly, hold on.
java.lang.IllegalArgumentException: Channel must contain : separator (attempted to use proxy)
nah was right
Try to change the name to only "proxy" on the server, and in the mcchanneliden. use "your plugin name", "proxy"
This is on the server?
yeah
Or the proxy?
val pre = ""
server.messenger.registerOutgoingPluginChannel(this, "${pre}proxy")
server
changing pre to messagechannel: stops the error from throwing, colons are required 
Weird, gimme a sec
Thanks in advance.
whats up
Lol not like I helped you much anyway glhf
nah, i would've been googling this and not getting a good solution back
thanks đ
đ
@fading pond is this on a minehut proxy? if so it might have some weird behavior with plugin messaging
so I urge you to test on both if that's the plan
I haven't heard anything conclusive yet - but I think it was listed as a potential issue when we were working on the connection stuff
Nah, for something else
No idea if anything funky happens with MH
also i updated the original message with the lovely solution
As far as I know you can't really prevent ddos attacks with software u will need hardware level mitigation like OVH does. Bot attacks can be mitigated by using plugins such as bot sentry.
I will change the server from a player
./send doesnt work
But nobody can me help đŚ
I WILL THAT I can send a Player to a another SERVER
I have try 2 plugins...... but they doesnt works
Player.createConnectionRequest(RegisteredServer server)
Then .connect(), .connectWithIndication() or even .fireAndForget()
@agile ore
- Don't make proxyserver final as you intend to change it
that's their constructor, they just named the class name lowercase
The moment command is called it will raise an error
Someone who choses API first, before learning Java
hey how do i schedule an async task in velocity
like i do in spigot
is this async by default?
velocity doesn't really have the concept of "sync"
Synchronize thread in Netty boss event loop group and see what will happen
btw how do i evaluate a math operation given in a string form. for.eg. "1+1*5-8". is there some kind of parser?
there are several libraries out there for that type of stuff
If you know functional programming you can check Tagless Final pattern
is this performance heavy?
That is a horrible way of doing what you're trying to do
Can default java run js?
Well, for me the only way of running js was through rhino js
there are like only five operators lmao, just "hardcode" it
But Java doesn't allow true + true + true
Yes, it can
[] + [] + [] >
ow EvalEx looks good
I think that the JS engine was removed in Java 16
*15
Btw I noticed that velocity lacks basic bungeecord commands. If i do a pull request adding all bungee commands will it be accepted?
Most likely not
Yea it's one thing to have them in plugins and another thing to have them natively
Makes life easier for end user
"ideal" situation is that somebody creates something like an essential suite of plugins which implements all the more opinionated stuff
Velocity wants to be lightweight, this seems like bloat to me
it means that we then have to maintain that stuff, and then you end up in the case of like bungee where all the builtin commands haven't progressed anywhere in 5 years

things like /send produce extra verbose stuff which is considered needless to many but there is no configuration options for, etc
Well if you see it that way a simple /server command doesn't need maintenance other than potential bug fixes.
Look, I even needed to disable the integrated /server command
Because I wanted to have special permissions for each server
Custom messages
Etc.
so that's already 1 feature people want which doesnt exist in velocities server command
This sounds interesting

If it were on me, I would remove the /server command
because I have issues overriding it
U can just remove /server permission from default group
And use some other plugin to handle server transfers
yes, but I want to override the command
which is basically impossible with ACF
But y do you need to override that particular command u can make a new command like /s <serverName> and use that every where
I mean, last I saw you can practically use it akin to ACF or close enough
ACF should have a force param for registering commands last I saw
idk, ACF seems more user friendly to me 
Aikar's Command Framework
Well it's everything but new
I am hearing the term for the first time
I just found it on spigot damn it looks good
I see
cloud supports velocity really nicely
you can unregister the server command?
yes kezz I know, but I am used to ACF
And migrating command framework is the last thing I have time for ATM
does velocity-api ship with gson or some other impl?
Yes, gson
Is it possible to open inventory / sign editor for player from proxy or i need to have plugin on each backend and send message to it?
Is there any working ex how do i register proxy cmd?
Does meloncube support papermc?
x post
You would need the backend server to do that, yes. There's a wiki article on the command API https://docs.papermc.io/velocity/developers/command-api
https://github.com/Simplix-Softworks/Cirrus is WIP for velocity. For inventory menus.
I can back this up, I ended up replacing velocities /server with my own so I can prevent people from switching to certain servers.
Invalid ID for plugin FalconClientSpigot.FalconMainVelocity. IDs must start alphabetically, have alphanumeric characters, and can contain dashes or underscores.
``` im getting this error while compiling
a velocity plugin
any fix?
what is your plugin id?
there's your problem
IDs must start alphabetically, have alphanumeric characters, and can contain dashes or underscores.
ow got it
and I don't think you can use numbers but i might be wrong
I think you can
that's not their plugin id
Hey, I have a little problem with ping-delay of 5-6s on the server list of my Minecraft client when pinging a Velocity proxy. Is this a known problem?
is this intended, there's no response and it was opened in January
I'm not talking about kicked people, I'm talking about pinging clients
I wasn't talking about your issue, also that issue you are talking about seems to be just you
what minecraft version are you using
1.16.5
im also changing the motd
on ping event
do i need to do something here?
yes, or you can build the new server ping from the previous ServerPing.Builder builder = event.getPing().asBuilder() then only modify what you want, the rest will be default
only what you want
bascically when u hover over the playercount
this one
what is this called?
@Subscribe
public void onPing(ProxyPingEvent event) {
ServerPing.Builder builder = event.getPing().asBuilder()
.description(description);
event.setPing(builder.build());
}
set the description to a Component
oh sorry
sample players?
so those are player names?
maybe?
thats a cool trick
maybe it's mods, idk
hmm i'll try both
google probably has the answer
Then do not hesitate to chill out a little bit and use Discord's answer feature ^^
idk what to tell you
btw I was interested myself and looked around, found a example here https://github.com/MrUniverse44/PixelMOTD3/blob/master/src/main/java/dev/mruniverse/pixelmotd/velocity/listeners/PingBuilder.java
they are using sample players
{line1}\n{line2}
can I set the motd somehow?
you can use the ServerPingEvent and set the motd there using the ServerPing object
There is no ServerPingEvent in Velocity
thx
We are in Velocity, no bungee or spigot, do not use those characters, to jump to the next line you can use Component.newLine() or in MiniMessage: <br> or <newline>
Any idea why this: audience.pointers().getOrDefault(Identity.UUID, null) returns null on a player?
Or are the pointers different for velocity?
heh
unless im missing something, i dont think this is actually returned anywhere? https://github.com/PaperMC/Velocity/blob/94e8b0df43fa7d59372d62bef1dcff5baa7315fc/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ConnectedPlayer.java#L144
I guess it never was added lmfao
no it definitely was
I'm pushing an PR
im so sorry lmao
i think we spoke about the idea of a type pointer
Cause I'm working on an universal system, so everything breaks for me
I have no way of identifying who is who
i can't quite remember why a type pointer never ended up existing
cus itâs native
it can't really
I mean it could have just an AudienceProvider out of the platform
but stuff is audiences
That way it could be much easier to implement stuff with multi proxies
Cause rn I literally gotta just create own AudienceProvider đ
i mean, yeah
i dont know why - your abstractions should just be returning audience/etc
and in those cases you just return server player or whatever
the audience provider is ideally an implementation detail
the audience itself is the abstraction you should be passing about
I guess I'll just have to use a fork of velocity for now
With FacetPointers added to identify
no - this seems completely wrong
So how else can I identify?
depends on what the xy is here
but i would highly rec making a pr to add a type pointer into adventure if you want
well, yeah
Imma open an PR tho
Imma test first
Ayo works
I forgot that PR updates when I update src lol
im gonna tell you now, velocity and other native implementations should never ever have adventure-platform stuff
Wait what
sorry, typo lol
Well for FacetPointers you do need it
That's where Type comes from
facet pointers is an internal implementation detail
But you cannot get the type in any shape or form
Just 1 month ago I started to make 2 plugins for Paper and Velocity that depend on the player's pointers to check permissions and I just found out that it is not implemented XD (the plugins are not published yet and I have only tested them from console, maybe that's why I didn't realize it)
yes you can, with a PR of a type pointer to adventure api
Well it's time to PR adventure then
why would it break the platforms?
And people wouldn't be happy to update
Cause the Type would be inside adventure itself
itâs internal api that class?
It is
so people shouldnât use that anyway?
Well there's no other way?
adventure-platform implements adventure-api
so adventure-platform's audiences would implement this new type pointer
what
no it's a new thing
again, the entirety of adventure-platform-facet is an implementation detail
I understand that
Iâm not familiar with adventure here but Iâll take a look later. But Kezz does make a good point; you may want to take this to the adventure discord
*kyori
Well the main problem tho was with velocity
Howâs it handled in paper?
And that was the pointers never used lol
I'm sure Paper doesn't return Empty pointers
Who did the ConnectedPlayer I'd like to spank the f out of them đ
?
Well I'm very surprised how I found out about it lmfao, it's pretty crucial thing
I'm not judging no one's perfect, but this is funny tho
@burnt dragon Why didn't you code the stuff for it? on the issue
because i have a full-time job and can't always get around to working on open-source projects in my free time
I see. I'm gonna try to implement such system into adventure itself
yeah go for it! definitely needs doing
Tbh I think having the Type as strings would be the easiest implementation for all the facets & natively
Hey guys I need help.
How can I change the .suggest so that it only shows all possible entries that start with h.
Not everything like screenshot
.startsWith?
for better context:
need more code
i think the way youre supposed to do it is to create separate nodes as subcommands
so then you dont have to manually write any logic to parse the arguments basically
Itâll show what you offer as suggestions.
Besides that thereâs a predicate you can set which has to match for it to display
Predicates are usually used as permission checks but can also be used for that
Can you Show an example Code?
Not currently sorry
I could try that
i have some code for a plugin i made that i could show
That would be useful
Saw it thank you
I wish mojang would soon and once and for all remove the legacy color codes and support components in the motd "player list" đĽ˛
How can I check, if the CommandSource is the console?
instanceof
thanks
Dear Team of velocity,
Is there anywhere a good explanation with examples for Brigadier commands for Velocity?
Because I can´t get the hang of it and I would like to code plugins for velocity with Brigadier command back end.
Or should I just stick to Simple Command?
The github page from Mojang doesn´t help much bcs you guys didn´t code it exactly the same (I think)
I'm using Simple Commands and I learned how to do it with a youtube tutorial from a german youtuber ^^
It would be best to use brigadier commands, since Velocity internally uses brigadier
The mojang "example" uses static imports, which is why it is so incomprehensible at first look
Brigadier is brigadier, for the most part it's gonna work the exact same, maybe some slight differnces towards what you're seeing, etc
any docs planed for to velocity approach?
@opaque escarp you have some sources where I can comprehend the brigadier approach?
like tutorials, docs, explanations, or better examples?
Now I was writing a mini tutorial to explain, but I think I'll do it in a better way
I am german too, which videos did you watch?
thank you for youre service sir! đ
The SimpleCommand works quite similarly to the Bukkit and Bungeecord commands, it simply delivers an "invocation" object with the command arguments and the commandsource
got it thanks
From Coole Pizza
I can send you a link via dm, if you want
You don´t need to already found it đ
after its finished, could you send me a link?
Hello guys, I'm starting using veloctiy API, and I want to create new User object when Player is joining or logging, how can I do it or when is the best option to create user?
is the User object your own thing? if so, then it's up to what you need it to do
is there a kyori-adventure-platform velocity?
velocity supports adventure if that's what you're asking

