#help-development
1 messages · Page 496 of 1
it violates the OOP idea if a command takes the main instance and then register itself through that
because as I can see the playercount is still -1
no because one day you'll publish this horrendous code on github and I'll have a heart attack
this is private code for my private server
you still call getUTF() twice
why do you keep calling that twice
call it ONCE to get the channel, then call getInt() to get the count
how can I get the server?
using readUTF()
so whats the order
getUTF() for the server, then using getInt() for the count, I guess
ah so replace readUTF with get
pretty sure this is all documented
it doesnt send the name of the server
it is, I sent it above
you send the name, it responds with PlayerCount then the int
its pretty clearly written on the doc
oh
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
sorry
it DOES send the name of the server
String server = in.readUTF(); // Name of server, as given in the arguments
int playercount = in.readInt();
String server = in.readUTF(); // Name of server, as given in the arguments
int playercount = in.readInt();
it DOES NOT send "PlayerCount"
clearly does send the player count
sorry that I didn't put quotes around clearly the message type
so the channel ?
😕 give me a minute here
if (subchannel.equals("PlayerCount")) { if (in.readUTF().equals("survival")) { serverSelector.survivalPlayerCount = in.readInt(); } }
^
so there isno channel?
no he's actually right though
bungeecord is the subchannel
"BungeeCord" is the channel
oh
"PlayerCount" is the sub channel
my bad
its okay this is a mess
@Override public void onPluginMessageReceived(String channel, Player player, byte[] message) { if (!channel.equals("BungeeCord")) { return; } ByteArrayDataInput in = ByteStreams.newDataInput(message); String subchannel = in.readUTF(); if (subchannel.equals("SomeSubChannel")) { // Use the code sample in the 'Response' sections below to read // the data. } }
this is from the docs
change it to this please
@Override
public void onPluginMessageReceived(String channel,Player player,byte[] message) {
System.out.println(channel);
if (! channel.equals("BungeeCord")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
String server = in.readUTF();
String count = in.readInt();
System.out.println(subchannel);
System.out.println(server);
System.out.println(count);
if (subchannel.equals("PlayerCount")) {
if (server.equals("survival")) {
serverSelector.survivalPlayerCount = count;
}
}
}
because something is wrong here, but pretty sure the code is working
illsend you the result when it compiles
but you also call getInt() once too many now, don't you?
yes, better now
np
if u already ran its okay Ethan
i fucking hate myself for using the "gson" field in the interface, but there's no better way D: why can't interfaces have private fields
interface fields are special
I cant remember the exact reason but they aren't treated regularly
what in the world even is this for
try {
Bukkit.getScheduler().scheduleSyncRepeatingTask(this,() -> {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("PlayerCount");
out.writeUTF("survival");
},20L,300L);
} catch (Exception a) {
Bukkit.getConsoleSender().sendMessage("Error with scheduler, (IS BUNGEE OFFLINE??)");
}
that does literally nothing
like literally nothing
bungeecord messaging channel only works with a player
o lol
a Player has to send it
because plugin messages are just sent as packets to the player's connection, which is intercepted by the proxy and never sent to the client
which is why at least 1 player has to be online to exchange info with the proxy, and also the channel messaging system's fatal flaw
that's why your code doesn't work btw
ngl I have no idea why u had any hopes for that to work
you just create a new stream
it doesnt' go anywhere
💀 like literally is eaten by the GC right after
whenever a player opensthe gui they willsend the request
yes
that's how it's meant to be done
very revolutionary
while you're at it fix the constructor problem
guys is there an alternative for new MyPlugin()
what
wtf
how does an even worse thing come along
PlayerDataAPI > Bungee messaging 🥲
https://github.com/mfnalex/PlayerDataAPI
alex send ur blog
what dis do
?di @flint carbon
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
sorry for quoting an older message but ur already online
allow to send messages between spigot<>spigot and spigot<>bungee
without a player?
but i use dit to access the config
yes, through redis
what the heck is dit
used it
alrill tr it
I only know git and diff, but no dit
should I remove everything?
val databaseConfig = plugin.config.getConfigurationSection("database")!!```
(this is kotlin)
do not call MyPlugin()
instance?
have you read my blog post?
which method did you choose? Static getter, or dependency injection?
reading it rigth now
oki
alex do I have to upload a plugin tomy server?
should just be something shaded as a lib
I doubt alex would make it an actual plugin
PlayerDataAPI actually is both a bungee and spigot plugin
or what are you talking about
but it requires both, a mysql and a redis connection
it wasn't meant for the public, I only wrote this like yesterday
ja I never heard of PlayerDataAPI so was just guessing it was a library
but sure, feel free to use it if it helps you
I have a mysql, my server runs on ubuntu
is the instance meant to be read-only?
wdym
its meant to be made by the PluginClassLoader
yes
so you are never meant to call the constructor
are you talking about whether to make "instance", when using a static getter, to be a "var" or "val"?
mm this is a very weird approach
since you're using kotlin, you cannot even use a static getter without black magic called companion objects
and you're restricting yourself to mysql
kotlin is a bit behind java, so in your case, just go for DI
I'm using spark to debug
does kotlin even support static init blocks?
But some plugins aren't being displayed
where can I download the jar file alex?
Says it didn't show up on the profile but it's literaelly working in the background
yes
tf does that q even mean lol
init {
}
though im curious, what does java have that kotlin lacks
static fields and methods
verbosity
companion object {
init {
...
}
}
Yeah this is definitely not how I'd do stuff
the redundancy of needing to shade kotlin-commons
or kotlinstd or whats it called
or stdlib
an init inside of a companion object will function the exact same as a static init
whatever its called
java also features the superiority of thinking that the type is more important than the name of something
companion object is the same as static inner class
or very similar
private lateinit var instance: Plugin
fun getInstance(): Plugin{
return instance
}
}```
Alex I can see you having a bunch of problems in the future with the way you're running your impl
that'd mean that in kotlin you couldnt even access private members of a class in your "static init block"
elaborate pls
For one you're hardcoding yourself into mysql
Everywhere
example?
if you wanted to one day add support for mongo you'd be fucked
and would have to rewrite a bunch of stuff
I despise mongodb very much
people use firebase with minecraft?
Anything that's not straight up mysql
does he not abstract data from the database impl?
what even is Seaweed or firebase
no
seaweed is self-hosted s3
SeaweedFS is a kewl file storage system
firebase is amazon's thing
oh eah
u mean google?
I never understood the advantages of nosql
whatever
and I probably never will
NoSQL doesn't stick to a table, you can insert whatever you want
not having another table for every list
i think mongo is easier with json
Mongo is basically json
you guys gotta understand, I'm a fucking lawyer and not someone who studied IT stuff lol
but actually bson
is it like binary json or something
I have an IT degree and I'm still an idiot but people like options
I personally despise sql at work
because writing queries takes brain power
but why would I NOT want to have one table per thing?
and with mongo I can just insert it all in a Map<String, Object> and automatically serialize it
wait @tender shard why were you saying i needed an init
I mean... relational stuff is good, sanitized stuff
I never said that
ANYWAYS
I only said kotlin doesn't support it
but it does
kotlin allows you to use weird companion objects to recreate something that, in the end, behaves similar to java's actual static features
or if you want to pull one from my books
but it's not the same
abstract away the packet system so you can implement RabbitMQ in the future
does init exist in java?
or raw sockets depending on whoever
but yeah have you ever seen someone saying "oh, I need a bit of data. thank god I am using RetardDB instead of mySQL?" because I haven't
i'm learning java as i create these minecraft plugins because i don't really know java 😆
Hypixel uses mongo and seaweedfs
since i'm used to kotlin
Half my customers ask for mongo
alex stop making bad claims
as a second option
you're killing me
hypixel also uses 1.8/1.7, that's not a valid argument
I've had a client DM me asking for S3 support
their backend code is not for 1.8
yeah it's even older
they just support it
their backend is 1.7.10 ported to 1.8
it's 1.7
oh
Mongo is probably the best for publically released stuff
what the fuck
since anyone can start using it for free
yeah and now imagine using that as "standard"
good luck
Their technical debt is too high to actually port shit
mongodb is already shit because of the name they used, like wtf
i like using this for mysql tho
"mongo" is a german insult word against disabled people, and the dude who invented it was german, soooo... very questionable name.
if that's legit your only argument
alex do you use kotlin?
only when I have to contribute on projects that already use kotlin
I try to avoid kotlin
I don't like it for a few reasons
do you know if hashmaps are often used?
it is kinda, yes. I never said mongodb is bad
for minecraft with kotlin*
hashmaps are used whenever you wanna map one object's hashcode to another object
so yes, very often
just make an interface and like 19 impls
so like
<Player,JSONObject>
ew using players as keys
pull request an alternative then please. I'd even pay for that
do not use Players as keys, they are throw-away objects
how much 
Because I'd honestly do your entire system different
keeping all the data on redis, automatically juggling it
pull data to an in-memory cache and register it to receive packets
keeping everything on redis? all data is lost on restart
Redis and any instance the player might be on
With some autosaving to your backend database
Redis has less latency but it's also volatile
UUID better?
And if you're using SSL it becomes single-threaded iirc
how much time do you think, would you need, to do everything like you wanted it to be, by still only using mysql and a general DB abstraction layer, and redis?
whats your situation
I don't mean "tomorrow" or "tuesday", I mean, how many hours would it be
10? 20? 3?
(roughly ofc 😄 )
yeah 3-4 hours ish
I have a core system, which does a lot of stuff. And the core itself is actually barely taking resources in the timings report. But, I was able to point down that some features are causing network lag on the players, but 0 impact on the server
To rewrite this clunky system
I'd give you 50€ for the entire rewrite
so whats the problom?
Sometimes, players will straight up get disconnected, while the server is perfectly responsive. Yes, packets are used on the core a lot
not enough?
I'm trying to figure out how I can see exactly where the "dos" is coming from
that'd double my net worth but like
LMFAO
it isn't compelling enough
lmfao
to actually pull your code
it's not worth more than 50€ to me, so well, decide for yourself
iwill do control a + backspace for 50$
I'll do my best to copypaste existing code for 50€
you really like these flowers
yo google tryna hang out?
so you're out, or still thinking about it? idk, which price would you start to think about it, otherwise?
Alex if it ain’t broken don’t fix it
Let's see
but I wanna see what a "better solution" would be
and if I could get a "propery solution" that's future proof and'd work with other storage systems too, why not
yeah anyway, I'll first of all put some nasty smoke into my breathing organs
what is a java.io.EOFException
End of file
Network performance issues
FancyFuture lol
It's a completablefuture but fancy
how so
can u paste that FancyFuture I’m curious how it’s Fancy
Isnt that exactly the same, except instead of using mysql code, theres another layer inbetween?
it handles exceptions automatically, has a slightly better thread pool that doesn't crash when it runs out of threads
That's for redis
I mean that’s called a database abstraction layer
And how do you store random unseriazable objects?
Redis can store that automatically
What is the purpose of redis? Is it used just for data transport between different parts of a network
Redis is data transport but also a central cache
or for key value caching Y2K
Yes and no. It cannot store a bukkit player
I mean why would you store a player and not their UUID
I'm assuming key value caching for an entire network vs on a per project basis
Correct
So that you can sendMessage on survical seever while player is on creative server, eg
like if you have any horizontally scaled system, you can cache on the app and at the network (redis)
For a bukkit player? Won‘t properly work at all
then just fuckin serialize it to nbt
and push the nbt through
Sure I can make a serializer thing
type adapter type deal
Good luck in serializing a connection that uses internal IPs only that one spigot server hae access to
I decided to make my iPhone naked a few days ago and I already have like 100 micro scratches on my screen lmfao
Your system can't handle it either ;)
idk how people can do this
That is true, so i wonder how would yours be better
Because we don't store a fucking bukkit player in redis, we just write whatever we need?
idk earlier you sent a screenshot that implied you can just store any "object" and it'll just work
and you said "redis handles that automatically"
You'd never be in a use-case scenario where you'd need to store a bukkit player and read it on bungee
typically objects don’t have weird shit in it like Spigot objects do
most POJOs don’t contain non-serializable data like a connected socket connection
I wouldn't call a connection "weird shit" tbh
Just apply some common sense
sure, but that’s obviously not data transferable
and you'll have basically everything
is there a way to check if the server is currently shutting down
onDisable gets called
okay nevermind then
yes, but what you'd need that for?
i want to skip my on enable method if the server.shutdown has already been called
just return at the beginning
^
requires NMS, of course
ah
thanks
it'll probably just be easier to add a method to the other plugin that might shut down the server during enable to check if it did that
that didn't make sense but
why the heck would a plugin shutdown a server o0
whatever
only /stop is supposed to do that
too tired
and SIGTERM etc
my plugin shuts down the server on startup if a certain condition isn't met
its just for my own personal usage
nothing public
but I'd like my other plugin to not go through the startup process
if the first one decided to shut it down
then add an API method or sth
that's what I'm gonna do
try {
new Thread(System::gc).run();
} catch (Exception ignored) {
System.exit(0);
}
async garbage collector
use Unsafe.putAddress(0,0 instead of System.exit
could at least do .start() :p
yeah pretty pointless
nah its genious
that way some fucking idiot faces an exception and quits
but if he knows what he's doing
he'll have access
https://nms.screamingsandals.org/1.18.2/net/minecraft/data/worldgen/biome/Biomes.html
does anyone know how/what BiomeRegistry changed to in 1.19?
private var instance: MyPlugin = MyPlugin() // i think this line is causing the error?
fun getInstance(): MyPlugin {
return instance
}
}```
```[00:30:16] [Server thread/ERROR]: Could not load 'plugins\plugin.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!```
Anyone know how to avoid this
yes stop initializing your plugin yourself
didnt we cover this already
MyPlugin is already created by the PluginClassLoader, which also loads the classes in your jar
i got it
https://github.com/Itzdlg/STRoulette/blob/master/src/main/kotlin/me/schooltests/stroulette/RoulettePlugin.kt if u need an example of a Kotlin plugin
though I will admit Spigot & Kotlin is such a PITA to work with
and of course I've broken probably 180 design principles with that code
now I just DI everything w/ Java 😈
man kotlin always manages to look so cursed
val prefix = ChatColor.translateAlternateColorCodes('&', "&8[&e&lChaos&6&lRoulette&8]&7") the fact this is outside the class makes me go bonkers
oh don't worry
not just you
i used kotlin there because I was lazy and needed to develop quickly
cursed solutions were just possible with kotlin
went through a kotlin phase the right back to the good old java
out of those 4
1 isnt mine (the fork)
and hte last 2 are incomplete
kinda funny
I finish like nothing
same here
but no, I actually develop with both. For example, I'm writing a website backend in Kotlin atm
though I wrote a plugin for someone not too long ago with Java
https://github.com/orgs/Y2K-Media-Creations/repositories 😭 the project graveyard
yep
lmfao I don't even write a readme, why would I populate the GH description
only nerds do that shit
no comment on this https://github.com/Y2K-Media-Creations/simpleconfigs
wrote out an entire readme
for myself
cuz who tf else in their right mind would use my code
erm I actually wrote an entire readme for someone elses project
but not my own
@remote swallow do u still update betteritemconfig
sadly not
i havent touched it in like 2 motnhs
i had to update it for one of my plugins but i didnt commit it
please commit a proper ItemStack Type Adapter for my config lib 🙏
oh though wait nvm I have to fix something with that library first
I just get sucked into a billion projects
I have a problem
I said I'll focus on one project at a time and it got me to this
4 projects
rookie numbers
I have 36 projects
and this is just the stuff I've put in my damn app
80% never will see the light of day
is it json or yaml
If I want to get the index 0 I just do packet.getWatchableCollectionModifier().read(0);
But doing packet.getWatchableCollectionModifier().read(21); says out of bounds even tho that's the index for the glow color
merge this https://github.com/The-Epic/BetterItemConfig
Ebic halp
wat
here
packets are above my level
UnfriendlyHateBuffer
are you sure it isn't 20
The index in website says 21
But now that I look at it
It might be only for the new display entities
well just keep in mind that while although some packets have an index
it doesn't always mean they have to be present
Fair
so always worth checking if its an optional data
Is there no wiki.vg
For older versions?
Why would index 20
Return that
What am I even accessing lmao
1.17.1
Ok but hold on
It seems like the glow color
Has to do with the scoreboard team
Thank you
its probably in the metadata
metadata is an optional thing btw that can be set later
so you can end up getting a metadata packet that has nothing in it
also keep in mind, that if you are using protocolLib
wiki.vg and protocollib will at times not line up
because protocollib will change the structure to make it easier sometimes
Oh
Ok that makes sense
It's a bit hard this
So far I've been able to make a specific player glow for another specific player only
But the color thing is turning out to be weird
lol
you just want one player to see another player glow? do they need to see eachother?
Nono I done that part perfectly
Just the color setting of the glow
I think I need to do the scoreboard part by packets too
also index 20 is the height. I was just merely questioning earlier if you were certain you had the right index or not, not that I was serious in using index 20
why? it's all in the API
yes
But it's not working using scoreboard
one sec
but also I believe setting glow too
Still white
Not only for specific players
Glow applies to everyone
I need just given player to see the glow
glow applies to who is set to be able to see it
Well, doesn't hurt that have learned to mess with packets
may come in handy in the future 😛
?paste
well, lets see what ElgarL comes up for you
Which is why the Player#setGlowing() goes on the player
they are pretty good 🙂
This adds all Mobs to a group which glows a changing colour
Yes but
All players can see the mobs glow
I only want X player to see the mobs glow
It's the huge difference
Same here
Cant connect the player to another bungee server using p.sendPluginMessage(plugin, "bungeecord:main", b.toByteArray());, no error messages.
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("Connect");
out.writeUTF(server);
p.sendPluginMessage(plugin, "bungeecord:main", b.toByteArray());
out.close();
b.close();
} catch (IOException e) {
plugin.getLogger().info(e.getMessage());
}
you are correct, it seems glow is server wide. but colour can be controlled using teams
so in thoery you could enable the glow using packets
The bungeecord channel is just "BungeeCord"
https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/
but color using Teams
I think they added separators after 1.12
coz the "BungeeCord" just goes straight to error
If you can;t see the glow you are likely using shaders
ah
Ok I fixed that part
I think
Changing players glow effect
Color isn't that easy
It works perfectly on mobs
Just not players
you add players by name not UUID
mobs by UUID.toString, Players by name
since mobs don't really have names, their uuid is their name
wait nvm it still works, thx
you could just use teams to control colors and enable glow via packets
Yeah
Doing that
And it's working correctly
So if I want a team for each color
Do I literally do that?
yes
in that example it cycles the colors using a runnable
teams are permanent once created
Is performance bad if I create too many teams?
just use the color as the team name
Is it not a better idea to just do the color using packets too?
It's part of the metadata
upto you, if you go packets for colors too you just have more non API code to keep updated
Well, I would like some assistance figuring it out
Because I wasn't able to
?paste
why b |= 0b01000000;?
I was doing 0x40 before
which should be correct
0x means hexadecimal fyi
ok
0b means binary
Yeah it's the same value
so yes either would work because they are just different formats to specify the same thing
yep, just seemed odd when teh wiki uses hex to use binary
I compared to some examples I found on forums
b |= 0b01000000; or b |= (byte) 0x40;
i'm 99% sure this doesn't apply to players
So I think the only way is indeed using scoreboards
I see nothign in meta to set the color
Yeah I thought so
But then
Packet scoreboards are needed
Because what if 2 different players select the same target
And select different colors
always good to learn 🙂
if(!config.getStringList("whitelisted").contains(player.getUniqueId())) {
Bukkit.broadcastMessage("Whitelist");
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cNot whitelisted"));
return;
}
whitelisted:
- "cb321240-3f44-454e-9963-3f9476b981a6"
Even if i add myself in this whitelisted section i cannot use the command and im so confused why
even if the uuid is the same
Last question
How can I create a new metadata packet completely
To not have to wait for the listener to receive one
If I want to enable/disable it
I need help with this https://hub.spigotmc.org/javadocs/spigot/org/bukkit/conversations/Conversation.html
you need the entity UUID at minimum, and then you would just send a metadata packet
put everything you want in the metadata
player.getUniqueId().toString()
Not able to receive pluginMessage sent on one of the Bungeeserver to another. No errors, there is nothing wrong with the code
This is really the problem just this line will fix my life
Yup but
Wait nvm
1 sec
Using protocolLib
How do I access the index 0 byte types
no, it is definite "BungeeCord"
ya i got it thx
but this
?paste
it is a bitmask
so you will get a byte, and each of those bits means something
with PL isn;t it getBytes().get(0) or something. No idea as I've never used it.
it isnt going to appear on the server without bungee code
It is connected with bungee, i have a code to connect a player to the other server and it works perfectly fine
the only way that it will get to another server is if you wrap it in a Forward https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#forward
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
yes, because BungeeCord channelk is handled by bungeecord
mymclobby:rip is not
bungee isnt going to do anything with it
Cant i register it and send thorugh the registered channel?
sure, but it will be received by bungee
Is it possible to force an Optifine CEM to do specific animations in a Spigot Server?
not another server on the network which seems to be what you want
oh
as you may notice there is 8 items. there is 8bits in a single byte
Yup
so. you would check if there is a 1 in position that corresponds to what you are looking for
thx, ill try it
this is called bitmasking
well you either set it to 1 or 0
Interesting, alright, thanks a lot Elgarl and frost, I need sleep
I need help with the Conversation API, I trying to get user input. I tried Anvil APIs but I heard that needs nms which I refuse to learn for many reasons
Well yeah, bits only 1 or 0
as the index above shows, position 4 is not used
which is good, because you can now split at that position without worry of what is there as well 😛
in the meaning slot
says its unused was previously used for riding
but now it doesn't have a use
at least for now
also, there are some positions that can't be set at the same time
like crouching and swimming
both of those can't be set at the same time because it isn't possible to crouch and swim
I’ll figure that out when I get a error or something doesn’t work xd
Conversation API Help
I point that out, because if you are good with bitshifting, its a simple 1 line check to check both those at the same time 😛
that is why they are equal distance in binary away from each other
the best way to handle it all is constants then &
The thread has been made, I asked a question multiple times and I don't know if any of you got me blocked. But I know rushing it is not a way to get it which I not. Without proper tutorials on the internet on how to use the APIs, I have no choice but to ask who has messed with the APIs like for my case, the Conversation API
LSB = right to left meaning for that index, the top is at the right, and then goes left. MSB = left to right(top would be at the furthest left)
reason I point that out
now that you know how bitmasking works
you can turn that byte into an integer 🙂
if you add the byte value up, you can use integers to refer to what is or is not set lol
with a single byte, the integer only ranges from 0-255
I followed that and I seeEnter waypoint name: nullThen I have to rejoin to use commands
null?
The prompt must have ran at start. Not allowing me to do anything
at start? you mean during login?
No, I mean when I run the conv.begin() like when I click "Add Waypoint" from my GUI, I don't know if I using the API wrong
conversation api is easy
I've never used teh conversation API, not many have
I have a plugin you can look at for example
I have 🙂
handy 🙂
I was going to tell him he'd likely have to wait for frost
err not frost, choco 🙂
Thanks, that is useful for my purposes. I see what I did wrong

you are welcome
yeah Choco knows the conversation api too
How do I get the user input using this? Is it acceptValidatedInput?
it is set in the context
if you noticed, the two classes actually contain a bunch of inner classes
the context is a global variable that can be accessed from all the inner classes and all the inner classes are setting data in this context
it is also how you can share input from one to the other if need be
each class has a prompt that accepts input, the type of prompt dictates the type of input it is expecting
so, in my plugin, you can see that all the inner classes are chained together 🙂
to go from one to the other, you can however make it go backwards too as its just calling the relevant inner class
I see, how do I end the conversation
there are two ways to end it
so that line there is important
if at anytime the player types /quit
the conversation ends
the other way, is if you make it to the last prompt
this is the inner class that ends everything
if they make it that far
Thanks
but, the first link I showed you can make it anything you want, it doesn't have to be /quit
you could do, end
essentially it is just a string that should be unique if you want to end it early
how can I add someone a permission on command for example
do i need to use pex or luckperms api or can i do it with spigot
Just add permission: <permission> below the comma d in plugin.yml
i used command as an example, it's not actually going to be a command which adds it
If you mean you want to grant one like a permissions plugin would, you'd use Permissible#addAttachment like Olivo said
you can use Vault to interface with a permissions plugin, but those permissions plugins all depend on the Spigot API and do pretty much the same thing as well
Hi, Ive tried to use the following library in my plugin, I'm using gradle and added the repo and dependency, but for some reason when my server the plugin crashes with a 'ClassNotFoundException' error for the 'InventoryAPI'. https://github.com/hamza-cskn/obliviate-invs/tree/master/core
You probably need to shadow the library or whatever TF gradle calls it
can anyone elaborate how to fix this using playerarmanimation? https://hub.spigotmc.org/jira/browse/SPIGOT-7073/ - i want to filter arm animation but i couldnt
~~class org.bukkit.craftbukkit.v1_19_R3.block.CraftBlockState cannot be cast to class org.bukkit.block.TileState (org.bukkit.craftbukkit.v1_19_R3.block.CraftBlockState and org.bukkit.block.TileState are in unnamed module of loader java.net.URLClassLoader @46ee7fe8)
Normally NoteBlock have a TileState ???
public void GenNoteBlock(Block block, Instrument instrument, int octave, Note.Tone tone) {
block.setType(Material.NOTE_BLOCK, false);
try {
NoteBlock nblock = (NoteBlock) block.getBlockData();
nblock.setInstrument(instrument);
nblock.setNote(Note.flat(octave, tone));
TileState tileState = (TileState) block.getState();
PersistentDataContainer container = tileState.getPersistentDataContainer();
container.set(new NamespacedKey(this, "instru"), PersistentDataType.STRING, instrument.toString());
container.set(new NamespacedKey(this, "octave"), PersistentDataType.INTEGER, octave);
container.set(new NamespacedKey(this, "tone"), PersistentDataType.STRING, tone.toString());
block.setBlockData(nblock);
getLogger().info(block.getX() + " " + block.getY() + " " + block.getZ());
} catch (Exception err) {
getLogger().info(err.getMessage());
}
}```~~
okay it's blockstate https://www.spigotmc.org/threads/blockdata-is-not-an-instance-of-tilestate.570731/
no
You can create custom persistent data types on your own, or use one of the many libraries available which have implemented those which match your needs. Learn about more persistent data types here: https://www.spigotmc.org/threads/more-persistent-data-types-collections-maps-and-arrays-for-pdc.520677/
Spigot 1.14.4 (for the server) and Spigot 1.19.4 (for the plugin)
and I want to be crosscompatible from 1.14 to 1.19.4
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
That's what I'm using
so farthest you can go back is 1.16.3

okay thanks
you could do 1.14 but you'd have to manage your own PDC store somewhere
so, in 1.14-1.16.3 I need to store in a config.yml (or a database, something like that) and in 1.16.3+ I need to use CustomBlockData ?
no
(updated)
NoteBlocks look like they never had PDC so you would need to store data elsewhere.
okay 👍
CustomBlockData only works back as far a 1.16.5 as it stores in the chunk PDC
okayyy
No need to register something ?java PersistentDataContainer customBlockData = new CustomBlockData(block, this); customBlockData.set(new NamespacedKey(this, "instru"), PersistentDataType.STRING, instrument.toString()); customBlockData.set(new NamespacedKey(this, "octave"), PersistentDataType.INTEGER, octave); customBlockData.set(new NamespacedKey(this, "tone"), PersistentDataType.STRING, tone.toString());
Silly question, why do you need to store a NoteBlock data in a PDC?
because I generate noteblock as an ore, I give him a texture of ore, but when I break the block below, the noteblock change
so I need to store datas who aren't changed to reset the noteblock to the ore
Example :
Instrument = bell
note = 0
When you break the block below :
Instrument = harp
note = 0
why not simply in the BlockBreakEvent check if teh block above is a Noteblock, if it is read it's settings and reset them 1 tick after the event has finished?
no need for storing any data then
maybe it's the easiest 😅
what do I need to use ?
literally call a runTask in the BlockBreakEvent to restore the settings
so in BlockBreakEvent java if (event.getBlock().getRelative(BlockFace.UP).getType() == Material.NOTEBLOCK) {
and ?
inside that you run a new task
so I get the noteblock and after one tick I set it to the datas ?
I made this java Block noteblock = event.getBlock().getRelative(BlockFace.UP); if (noteblock.getType() == Material.NOTE_BLOCK){ NoteBlock nb = (NoteBlock) noteblock.getBlockData(); Bukkit.getScheduler().runTask(this, () -> { noteblock.setBlockData(nb); }); }
yep, clone the BlockData so you know it won;t be changed
okay 👍
I think it's working
I'll try
Does anyone know why when I edit the name in WrappedGameProfile (PLAYER_INFO), it doesn't change in the tab? I need to use different packet or something?
How do i send a action bar message?
Bukkit.spigot().sendMessage(...
How to change player's view? use location's pitch and yaw?
is it possible to send custom packet to a player?
i mean
with another id and structure
i wanna make plugin that sends clear chat packet and fabric mod that listens to it and clears chat on client
just send a few hundred empty lines lol
bad solution
yes
but i haven't found anything about server side
maybe protocollib can do something...
yes
in your plugin.yml you should have main: org.onjoinx.weloinx.WeloinX
does anyone know a way to set players prefix in bungecoord? because i believe the method i used in spigot doesnt work here
i already have
what is yoiur main class
the error says you don't Caused by: java.lang.ClassNotFoundException: org.onjoinx.weloinx.WeloinX
"java.lang.ClassNotFoundException: org.onjoinx.weloinx.WeloinX" you sure you spelled it correctly
It's because your main JavaPlugin class is different
yea
did u refractor something?
red error on the class?
no
looks like a big red ? on the class to me
MessageDigest md = MessageDigest.getInstance("SHA-256");
String text = "Text to hash, cryptographically.";
byte[] digest = md.digest();
String hex = String.format("%064x", new BigInteger(1, digest));
Hi, i used this code, but for checking if the password are matching?
what are you trying to do
you have an out folder which means you built using artifacts not maven
just trying to hash a password and then check it again
yea
build with maven
from a chat msg or what
how?
from a chat message
learn maven
What is wrong with this? it can't understand player.getMessage and its not broadcasting the message its just sending a normale message
@EventHandler
public void OnChat(PlayerChatEvent e){
Player player = e.getPlayer();
Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "A" + ChatColor.DARK_GRAY + "]" + " " + ChatColor.GRAY + player.getDisplayName() + player.getMessage());
}
}
there is a blue m sign on top left
click install there
package
install basically does the same lol
yyea
No it adds it to your local maven
both work
it does build it, but it also installs to your local maven and clutters up multiple build versions
.
only install if you are going to depend on the plugin in another
cast it to the appropriate meta class
What is wrong with this? it can't understand player.getMessage and its not broadcasting the message its just sending a normale message
@EventHandler
public void OnChat(PlayerChatEvent e){
Player player = e.getPlayer();
Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "A" + ChatColor.DARK_GRAY + "]" + " " + ChatColor.GRAY + player.getDisplayName() + player.getMessage());
}
}```
player.getMessage?
e.getMessage()
e.getMessage()
bonk
Code: https://paste.md-5.net/marixapiza.java
Error: Cannot resolve method 'setLodestoneTracked' in 'ItemMeta':70
Cannot resolve method 'setLod' in 'ItemMeta':71
💀
What does it say 'org.bukkit.player.PlayerChatEvent' is deprecated in my Problems section?
At public void OnChat(PlayerChatEvent e){
Because it's deprecated as fourteenbrush already mentioned
declaration: package: org.bukkit.inventory.meta, interface: CompassMeta
So can i do anything to get the warning away?
@quaint mantle
Okay thx
Hello, how can I change the texture of a block without texture pack ?
I think it's possible with protocolLib
to change the texture of an existing block
by a new texture
You need a resource pack
If you just want to disguise it as another block you don’t
But if you want a brand new texture you need a resource pack
okay thanks
But still when im sending a message in the chat its not sending what i want, its just sending the normal message
Yes, i want to change so when you chat its broadcasting my custom message
declaration: package: org.bukkit.event.player, class: AsyncPlayerChatEvent
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
Of what you changed.
@EventHandler
public void OnChat(AsyncPlayerChatEvent e){
Player player = e.getPlayer();
Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "A" + ChatColor.DARK_GRAY + "]" + " " + ChatColor.GRAY + player.getDisplayName() + e.getMessage());
}
}```
And where do you register it
Sry i forgot that part...
Im sorry, but now its broadcasting my message and the normal one, how do i disable the normal one?
learnspigot
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
actually it's the only proper way i see rn
can't he just set new format ?
cuz format is cringe
if i understood what he wants
?
you're cringe
it uses regex of String.format() method
and what is cringe about it
so if you missed a % sign or just typo'd in placeholder the thing just gonna crash
just dont miss % lmao
Don't typo.
instead of working
you literally have two placeholders
but with %yourTypoPlaceholder%
i mean if you are making a chat manager
and it's for others to use
you probably can check the string on having typos and remove the crashing elements
Sanitize the input then.
i'm not the only one who prefers cancelling the asyncchat and broadcasting with own formatting
Not very easy to interface with your plugin then.
slower bot more comfortable(less code)
idk never made an api for my plugins related to chat
I don't want to use your api.
my last public plugin was like in 2019
I want to use the event to interface with your plugin should there be a need to.
So i have this:
@EventHandler
public void OnChat(AsyncPlayerChatEvent e){
Player player = e.getPlayer();
Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "A" + ChatColor.DARK_GRAY + "]" + " " + ChatColor.GRAY + player.getDisplayName() + e.getMessage());
}
}```
And how do i cancel the normal chat message?
I told you.
e.setCancelled()
learnjava
or
e.setFormat(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "A" + ChatColor.DARK_GRAY + "]" + " " + ChatColor.GRAY + player.getDisplayName() + e.getMessage());```
and remove broadcast
tf
At all
ez
Can't wait till a player types some weird syntax
oh true
Someone get Bobby tables
You should use the format arguments not their name or message.
why does this throw an error?:
fileConfiguration.set("tablist.footer", Constants.DEFAULT_FOOTER);
fileConfiguration is a YAMLConfiguration and Constants.DEFAULT_FOOTER is an arraylist of strings
what error
If i am setting the e.setCancelled(); just above my broadcast its says 'setCancelled(boolean)' in 'org.bukkit.event.player.AsyncPlayerChatEvent' cannot be applied to '()' in my problems section
ExceptionInInitialiserError, but if i replace Constants.DEFAULT_FOOTER with 0 it doesnt error
in your case you need true
can you show FULL error
e.setFormat(ChatColor.DARK_GRAY + "[" + ChatColor.GREEN + "A" + ChatColor.DARK_GRAY + "]" + " " + ChatColor.GRAY + "%s%s");
?paste
