#help-development
1 messages ยท Page 221 of 1
I thought of adding a player to an arraylist when they join but Idk if there is a better way to do it
i personally find it easier to have the server run inside intellij unless it's not possible
that probably is, just seeing if i can make it not need me to copy the stuff into ij
Well, Imma go read the documentation, I'll be back then
c;
gl :)
?
it's not exactly checking it
it's so it will make sense when G and B are used as return types in the abstract class
I mean i understand generics, but no that complicated
its a builder so it returns itself
oh ok
but itself is B (when extended)
sorry i didnt know hard generics, i just know simple ones
Ok, so according to what I just read, the hashmap (for creating a homes plugin) should receive the player name as key, and the home as value?
Oh
Why not name?
I know UUID is an identifier but I thought I could use name
Ohhh
lets say morice_0 switches their name to Conclure in minecraft
now they would have access to my homes
also storing the player as the key isn't great because the object changes if the player relogs
Ohhh alright
Then player should be the value?
Technically speaking if it's in a Map it won't matter because maps are based on hashCode() and equals(), which check the UUID
but ye
Uuid the value
oh? i've had the problem in the past
whats the best way to let a plugin work with bungee & spigot? should i make a module for each or smthn
maybe that was an offline server
They won't == each other, but they will equals() each other
Yes
must have been using an offline server then
well, you mean like getting a specific player?
Hmmm, I guess... because a home must be only a player's
well you'd want some commands for this to work
What would be the best way to get a specific string a stringlist
Yes, but are the hasmap key and value alright?
explain?
This is my home class
eg i have 5 different strings on a string list in config (getting from #getStringList) and i wanna try and pick a random one out of the list so would need to get a specific one
random number between 0 and the length of the list exclusive?
okay
Yeah for most part it Player is doable, unless you'd have to access the player extremely early like in async prelogin
Also, you are losting resources
Because you are using* a big object for no need
that objects in memory anyway
Yeah but having it as key in map is even more mem
na
the Player is alr in memory
sure if you use the map past a single player's session, then you might have it filled with old player objects
only a reference to that memory is stored in the hashmap
just realised that its hash is never stored :P so what i said was wrong
Can I reference things in the config.yml of a dependency in my plugin?
what?
yes but you probably shouldn't
in a HashMap?
you mean calling other plugin config, from yours?
Yes
creppy, I mean a HashMap does store both hash and a reference to the K instance
records bruh
or did you mean something else?
no i meant that. I need sleep. My brain worked, then doubted itself
lol yeah nw
No, need to call it as homeLocation, location would be just fine
hi conclure
hello
hai
bruh
ye
my train of thought was the reference to player is held and it calculates the hashcode of each on a get call
but thats no longer O(1)
i rlly miss you
i was right the first time lol
oh well im here right now
what happen to you?
nothing really
it happens to the best of us :,]
u didnt used to be so inactive
well, we have a lot of others who help people in these channels, dont we?
yeah but you are diff from all others
but yes, I havent coded much in the spigot api lately
I mainly understand when some ppl helo me
I have some of them which i umderstamd better or explain better
thats nice :)
sometimes, but I am used to enterprise terminology which confuses a great set of people here as ive come to understand it, but im glad ive been able to help u, maybe we could move this convo to #general speaking of which
https://gyazo.com/4a96102c95f9eb3a7f927f4c6c5998ef do i have to stop this with packets?
int entityId = player.getEntityId();
PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(entityId);
EntityCreature creature = null;
WorldServer ws = ((CraftWorld) player.getWorld()).getHandle();
PacketPlayOutSpawnEntity spawnPacket = new PacketPlayOutSpawnEntity(creature); // creature is not null, i just removed the logic that selected what creature the player should be disguised as.
try {
// c field
Field entityIdField = spawnPacket.getClass().getDeclaredField("c");
entityIdField.setAccessible(true);
entityIdField.set(spawnPacket, entityId);
} catch (NoSuchFieldException | IllegalAccessException e) {
e.printStackTrace();
}
Bukkit.getLogger().info("A little bit of magic for these dumb ass packets!");
Bukkit.getLogger().info("Player Entity Id = " + entityId);
Bukkit.getLogger().info("Spawn Packet Entity Id = " + spawnPacket.b());
for(Player onlinePlayer : Bukkit.getOnlinePlayers()) {
CraftPlayer craftPlayer = (CraftPlayer) onlinePlayer;
EntityPlayer entityPlayer = craftPlayer.getHandle();
entityPlayer.b.a(destroyPacket);
entityPlayer.b.a(spawnPacket);
}
```Could someone tell me why this doesn't work? The Spawn Packet Entity Id is being set to the Player's Entity Id. (ver. 1.19.2)
One of the issues is just me not being able to move after these packets are sent and when I go into third person person my skin / disguise just isn't present. (while in first person I can see my hands)
I am experiencing a bit of lag when trying to use the Random like 100k times at once
It is for a reward system
the player can open all of his keys at once
yes
hmm so, well have you tried SplittableRandom
nop
idk if its any faster, (usually used with parallel streams and stuff) but iirc its quite fast
hm
but like
I use things like Collections.shuffle
and SplittableRandom does not extends Random
so I cant use it there
if you aren't using every item in the list, collections.shuffle is quite an expensive call
Well I am
then nevermind
wizardly
you could shuffle the collection in another thread
ofc it complicates things
For some reason essentials.getUser(Player).getNick(false, false) is returning them with suffix and prefix even tho it has the 2 false's, im so confused why
like collection thread safety
anyway here
splittable is 3-4 times as fast
compared to normal
score is in nano seconds per operation
.5 in error (for splittable)
is there any need for a while true there? seems like a lot of iteration
it is to be sure that there will be a reward
alr, maybe try to copy paste the shuffle method
but with a splittable random
and if thats still not enough, maybe use another thread to do it
couldn't you scale the chances so that only 1 random call needs to be made?
its too late for me to think how
its just a weighted random
yea that too
its taking so long because you may have small chances
there is absolutely no need to iterate more than once to get the correct reward
i have always used a treemap in the past to save iterating each time
Whats the point in adding <?>?
Just a question
Wanting to dive into ? And T
because the type passed doesnt matter Id assume in this case
generics
This beginner Java tutorial describes fundamentals of programming in the Java programming language
I mean
CrateReward<?> is a supertype of CrateReward<A> and CrateReward<B> which is probably why they return a term of that type
the generic for the CrateReward is to specify the reward type
is there a way to get the plugin version specified in the plugin.yml
ty
can be retrieved through Plugin
yes
yo
just remembered
the getRandomReward
is called 1m times
because the player can open all of his keys at once
so even if I use the weight thing
it will be called 1m times
I think it is possible
yeah, just pool the threads tho
(I assume a cached thread pool would be fine here [maybe with a max size configured on ur own tho])
uh
I was thinking that you call necessary getRandomReward calls in CFs
CF.supplyAsync(() -> {
...
}, pool)
nha
cuz that there isnt async at all
no but like completedFuture() is the issue
because it just takes a value a returns a dummy future that wraps the value
hmm well, you could use whenCompleteAsync
but arent there parts that you wanna do sync?
like the inventory stuff
only this needs to be sync
yeah guess you can send that to the bukkit scheduler then
anyway you dont need to use the future before
from what it looks like
the future is for the animation stuff
so when the animation ends
future.complete()
alr
cool
moved it to async
and it is very fun
seeing this literally every time
1 million rewards ๐คก
yes
ah damn
that might be hard then
I mean either way, 1mill rewards are a lot to process
yes
I am talking with the client about it now
he said that a play may have 100k keys
imagine a server with 30 players and each player opening all of their keys at once
yeah
there are certain tricks you could use
lets say the rewards vary from the command
/hello dodo
and
diamond
you could simply map the rewards to the amount of times they've been drawn
and for commands, you might just wanna limit it, lets say they unlock a permission, that should only happen once
imagine sending 1 million messages
oh boy
the client will need to think better then
I was thinking something like
100 keys
or 50
but he is thinking about 100k ๐
d
.
for money, count that to and execute the pay function only once
wow
the problem is that the command can be literally anything
and i dont want to write something to read what the command is
I have a /crate items too
to see your items
because well... 100k is a lot to expect
imagine having 100k items
actually, nvm
I think the only way would be writing a helper method
^
It is still sending the messages lol
๐ฅฒ
o.o
Ayo this probably sounds sketchy asf
but how can I like
Copy all fields from an instance of the super class
to the parent object that I'm inheriting
Like a
public class B extends A {
public B(A original) {
// copy all original values to super object
}
}
Trying to use unsafe but it no worky

prolly the best code of 2022
Lol
xd
check if the sender is an instanceof Player before casting lol

Don't you learn java by experimenting with it?
https://www.codecademy.com/learn/learn-java yes and no
Ok, why no?
dont experiment with spigot
id say learn the foundation of java, experiment with that, and then apply to spigot
The only really issue is that you should check if the sender is of type Player before you try casting something to Player.
Alr, I fixed it ty c;
Otherwise you'll get errors if something like console uses the command.
Hmmm, I think a bit different, I mean, I know some things about java
and make sure args.length > 0 before trying to grab args[0]
and now I want to start implementing it to spigot
Oh, so in this case I should use a conditional if the sender isn't a player right?
?paste
Combine the ifs. I assume you're using java 8? If not then java 17 allows for variable declaration in the if as well
Guys, a question, I'm new using hashmaps, how could I get the UUID of the user in the hasmap to verify if it's the same than the sender's
Alr
^ containsKey() would be the best way
Like this? c;
yes
Looks good
what's the point of the for loop there
It loops through all the items in the map
You should never be looping over a map.
They didn't add the rest of the logic when they sent that screenshot so can't say why they need it or not
i'm assuming they were doing originally that to check if the map contains a key
Without the rest of the logic hard to say
It looks like they're using it as a list
Can someone please help me Iโm trying to use redis bungee but it just keeps saying pinging?
free java lessons
stop it please
Anyone?
problem you are most likely encountering is invoking a new random instance that many times
you really don't need a new random instance
instead make a random instance, and then just call Random.nextInt()
I was using ThreadLocalRandom.current()
only time you really need a new random instance is if you need something close to true randomness
threadlocal doesn't do anything if you are already on the main thread. It is used if you have multiple threads and want those threads to create the random instance from their thread and not the main thread
so creating a random instance outside of your code so those code blocks can get an instance and then re-use that instance. It should help alleviate some lag ๐
Doubt anyone's going to help since you removed the creature logic. At least put a null check and include that after testing it to be true
It just set based on the players kit and it would be a specific mob with their given world.
It should of disguised me into a creeper.
That's fine, but I'm saying most won't take your word for it. Add if (creature==null) return; before your comment, test it, then ask again with the new code. That is, if you're not willing to share in entirety
im having a trouble with using hashmaps, this usually doesn't happen to me i made a hashmap in main class and when i try to use it in another class it doesn't register here is another screen shot
do i need to import an API for hashmaps?
make a public method that returns the hashmap
public HashMap<String, Integer> getKillstreak() {
return killstreak;
}
then you should be able to access it more easily via DI
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
it still doesn't allow me to resolve the method in a player event's class
because you are not using di
if you don't know how to do basic java programming then you probably shouldn't be making plugins
ok il use that
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
register Event class

uh you quoted it out
Hey, how can I make custom world generation? I want to replace all the world generation with my own.
is there a way to view packets per second on client
??
Hey, how can I translate 1.16 NMS to 1.19 NMS?
You rewrite the code
Isn't there like a website that helps you do that?
Screamingsandals can help with mappings
your project is an addon to spigot so its not the Main minecraft class
rename it to SomethingPlugin
dude how did you not delete your eyes
ugh right Army guy. you've seen worse
What's DedicatedServer#getCustomRegistery from 1.17 in 1.19?
Why do you need it
Agree
People mustnt be coding with spigot nor bungeecord api without java knowledge
i am dan
im not a dev but why do ppl buy the src to a plugin if java decompilers exist? can java decompilers be inaccurate or smth?
it can be really inaccurate
try to decompile some plugin and the compile it again
i mean not necessarily inaccurate
but harder to understaind
obfuscation
yeah this too
Some idiot developers use tools
to scramble the code
it's reversible but a pain in the ass
isnt that good tho
nope
to stop leakers
it won't stop leakers
also piracy has a weird stance
no piracy = easier distribution = easier word of mouth advertising
piracy = harder to manipulate, still easy to distribute if it doesn't have DRM
all code eventually gets cracked
But on one side, I guess it's easier to pay 100$ for source code than pay some developer like me 30$/hour for 8 hours of work
Compilers do some black magic and some stuff can be considered irreversible, multiple sourcecodes could end up being compiled to the same bytecode
i think you mean based
i'd die before i willingly let skids like the people in this discord use my code for free
i don't think most people that write decent code would like to work for free
it doesnt stop em
with a bit of work
naming variables etc
it can be understood somehow what does what
not saying its not a pain in the ass
but doable
anyone that has the knowledge to reverse and remap a well obfuscated program will be able to rewrite said program faster
it's doable but no one would bother because rewriting it is faster
So write your own code using just upper and lower case letters and numbers
Its what I do with my libraries
๐
Is there a way to check if a pressure plate is pressed outside of the PlayerInteractEvent (so just checking the current state)
Hi, anyone know how I can set to run a command (from console) in a HoverClick event?
Example:
if(player.hasPermission("hi.hi)) {
TextComponent msg = new TextComponent("Hi");
msg.setClickEvent(Here the console makes the command /hi, for example);
player.spigot().sendMessage(msg);
}
you can make a command that just redirects to console
so like
/runconsole plugins
would just get all args and call dispatchEvent
So, make another command and run that?
ye
Mh ok, now I try, thanks
Could someone link me a tutorial about reading server packets answer from a Socket?
no โค๏ธ
google java example client server
Its more spigot related
sockets are not spigot
No
I mean im simumsti ga cmient
I need to emulate a server real connection
๐ฌ
Simumsti ga cmient
If you wont help please dont crรญtice
I just need to read spigot sever packets responses
Because i have already done the handshake and login packet. And the client joins the sever but before 1m aprox its get auto disconnected
Yeah but when?
I need to read sever responses first
But packets formarts are really weird
And i when i sout the DataOutputStream I just get random numbers displays
If not I wouldnt e asking
you can;t sysout the stream. you need to read it per byte
wiki.vg will tell you what teh format of each packet is
eg, the ping packet has a single content, a Long https://wiki.vg/Protocol#Ping_Request
And Where ezplI show to read it
Its just said that packet id and the fields it has, nothing readingrelated
๐ค
I use data input stream?
yes
And how i know its the correct packet response
If the protocol says the packet contains a Long you readLong
Ok
And for packet identifier
Because im sout the data input stream and display random numbers
I've not looked to see but I'd guess teh ID is an Int or a Long
Because the display numbers are from 0 to 223
And also negativos
I really co fjse
I really understand having a simple example about reading
There is a section on data types
it even has example code on reading each type
I just need a example about reading the packets from socket stream
So i convert the stream I to an InputStreamBytdArray
no, just readBytes
Not joking dont really understand
The wiki doesnt help a lot to me
I mainly a visual perdรณn
I dont understand without specific and clarify example
Please give a hand doing a simple packet reading example
Its not so diff for you that undrtstand
๐ฌ
hello when a player joins the game he gets a custom message which status he or she as.
But i want that the message is send after the Join Message "... joined the game" because atm its send before this message could someone help me please?
kinda rude
what he's trying to say is the minecraft protocol is designed like fucking unstructured aids and is there a full example of actually parsing the packet
I have seen checkers web games with a better protocol
Yeah in other words the wiki its a mess
MC protocol is only bad because of its Bigendianness
So how i can read packets responses ๐ค
Use the scheduler to delay by one tick
Ie Bukkit.getScheduler().runTaskLater(...)
I think if mojang provided a json serializer for the packets it would be quite nice
thanks
if I use Bukkit#getPlayer, does it return null for offline players and names that don't exist?
yes
That would be Horrible bloat
ok thanks that's what I need
Why its not rude. Im just saying in a good way
but it would finally be readable and not a blob of weird data
maybe its just broken english then
just cause its json doesnt make it readable
a protocol should be efficient and small, not readable
I meanwhydontjustsendcodeinsteadofmakingpeoplewhodontunderstandlostingtheirtime
json makes it very readable
you can literally just do packet['id'] and you get the packet ID and then you know what to read
mojang should use protobuf
Just sping poof aboutreadi a packet because both of us lost our tkme
I do not like the idea of using binary for structured data
I will try using Netty so because java default things really shity
๐คก
Sorry if sound rude but would you help or not?
if i want to make a plugin for 1.8, what SDK do i use in intellij?
So them we dont lost our time
java 8
?1.8
Too old! (Click the link to get the exact time)
^
Sorry but it's the only way I find to get myself understood
:x
bruh Player z
Ye
Is this a good way to get information from a hash map?
(Imma delete the picture later)
IntelliJ only lets u choose mc version between 1.12-1.19. Which 1 for 1.8?
do i just choose 1.12
Thank you c;
im using the minecraft development addon
lmao
well 1.8.9 isnt in the repo
yeah
redirection would be noice
understandable
who has
I mean he is really new
Because if he is not using maven
If not using maven neither gradle its really weird
meow
hi zack
just here to solve some easy problems
Hi maow!
i'm kinda boredom
ngl ๐ฆ
eh that sounds like work
just here to solve problems
๐ค
Can't lie System and Logic is fun to me
hi, i have a problem, i have a main class and another class named HelloCommand.java, i created a new command but i dont know how to register command i was read some docs but still cant understand
can anyone help me?
i will read this thanks
I just tried my plugin in-game and this is the message that shoud list the name of the homes the user has
Use the home name instead of the home instance
Hmmm but should I create a variable that gets the name of the home?
Because I'm using a hashmap so Idk
This line gets me the home instance
According to the UUID, but how can I access the attributes of the home instance
oh thanks it seems worked i will try rnow
I'll assume your home class has a name field, so you'd just use a getName() or something similar (assuming you have created such a method)
Yes
what api-version do i set in my plugin yml for a 1.8 plugin
you don't
y not?
api-version isn't in the plugin.yml spec for <1.13
ohh ok
homeList.get() will give you a home instance, so now all you have to do is call getHomeName on top of that
not sure what zacken is trying to say?
Done, thank you c;
I don't understand this :c
No, the name, because it was sending me the instance
So what I want to show the users is the home name
Hmmm no
No
Did you figure it out Shadow?
There is a method to do a command on HoverClickEvent from console without create another command?
why this is gives error
I think it's because of the ""
It's asumming it's text
Not enchanment instance
Idk, maybe I'm wrong
looks like a ?learnjava moment
you need to pass an Enchantment to the addUnsafeEnchantment method
I'm not getting mad, just suggesting that you get a good understanding of java before moving on to spigot
any sample
What I told you
Instead of Unbreaking
Enchantment.(here comes the enchantments available)
c;
anyone?
could you rephrase the question?
Guys :c I tried this, and it's working nicely but, for example, If I create many homes, when I list them (with a command) it only shows me the last one I created
you are only saving one home per player
:0
the hashmap relates a uuid -> Home
you can either use a list of homes as the value in the map, or create your own user data class which contains a list of homes
When I click on the text (made with TextComponent) I want the console made a command (without create a new command contenent Bukkit.getServer().getConsoleServer() etc).
Is it possible?
yes, assuming you mean ArrayList<T>
although convention says that you should just use the type List<T>. There's no need to expose the actual implementation of the collection, just knowing that it's a list is sufficient enough to use
Seeing people use notnull annotations in java makes me happy
if you have that mentality maybe you should switch to kotlin ;)

Oh, I'll use this and then I'll share it with you c;
@dim bronze Is the question ok?
You want to run a command that doesn't exist?
Yeah, I think morice answered it nicely though
but it needs to be executed when the text is clicked, which would require a command to be run
No, for example: /kit nameofkit nick
but executed by console
Oh
I think you'll probably have to add another command that does basically the same thing but only Console can run
Or add another argument telling the command that console is running it
The more important question is why does the console have to run it?
I assume to bypass cooldowns
If you are giving players the permission to use the command through text, surely they should just have permission to run the command?
I have to do this with LP, like a contract system, so I made /contract crepppy hi.hi and console when you click on the text add u group hi.hi
yeah, but in every case I have to pass it on clickevent
because it happen when u click on the text
Like so? c;
so there is a method or I have to create a second command and pass it?
mh ok
Like this c;?
Alright c;
Ty c;
I removed the UUID from this class because I'm already giving one in the hashmap
Is it ok like that?
Oh didn't read, alr! ๐
Alr! c;
In this case, it asks me for a list of homes, but I don't have one in the beginning
probably want to have a method PlayerHomeData::addHome(Home)
not much sense to both have a constructor param and that method
there is if it's being serialised
my playerdata is just setup with an ::addHome method and im calling that one instead of creating a collection and then passing it in
recently switched to mongo now smh
doesnt
it has its uses for relational data
but most of the time when making plugins you're dealing with data that is better modelled by a document
that with relations
doesnt it also perform better in terms of performance when you have a big database?
in one that's fucked up
mongo is going to be a lot slower at 'table joins'.
dont want to try that and dont need it anyways
and because all of the information is generally stored in one document rather than multiple because joins don't fit the mongo workflow, you tend to get larger packets sent to the user
of course, this is why graphql is fitted nicely for querying mongo databases
Thank you c;
i swear people have been arguing about sql and mongo for a week in this channel now
both have their benefits and downsides
what is a mongo
I only know about mangos
Only reason I like mongo more is the java drivers lmao so much easier for my brain
working on a sql api rn for myself though lol
i was working on a reflective gson alike sql api and i gave up
too difficult to handle normal level transactions
that combined with annotations was driving me crazy
Me again c;
I register the commands like this, but it looks like it's not getting the second command
The first one is working nicely
any error?
please ensure me PlayerHomeData is not a player specific thing
you probably want to go for player specific home data
so you would end up with a Map<UUID, PlayerHomeData>, assuming PlayerHomeData has a Map<String, Home> or smth internally. PS an UUID is just an identifier to get a player from
cuz now all the homes are stuffed together ig and there no way to distinguate between players
is dintinguate even a word idk
uh well why having homedata twice
my first plugin had a Player field shared in a base command class lol, another player executing and stuff broke
Oh, I forgot to check for player UUID
Hahaha, this is my first time using hashmaps and creating a plugin that contains many information for specific players
we learnt arraylists today in college smh
me just speedrunning all exercices
they using an arraylist in a place where a hashmap is better but anyways
Time for a break
we havent learnt yet so cant use it lmao
Better?
Now it checks for player UUID
@last temple
Could I send you a friend request?
Anyone has any idea on how to override the existing /msg command /
what am i looking at
What are you trying to do ?
have you tested it?
Would you mind if you could help me in DMs?
make sure ur plugin is enabling after the other plugin and simply insert ur command into the command map and it should be overriden
Oh, just to check if the uuid of a player is in the hashmap
So they get the information about their homes
@untold patio new to java ?
fair point.
Kinda new to java but completely noobie in spigot commands and that
thats not proper english.
I don't mean it in a bad way but learning the java basics is kinda needed to get started with the Spigot API.
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
So I amn't English people.
@fervent prawn where are you from ?
Belarus
No, no, I didn't assume it in a bad way, just telling you the truth, and yeah, I see it's the same but I get a bit confused on spigot commands and Bukkit instances
I'd recommend watching some GHG videos on youtube, would clear a lot of questions about anything you have, he also explains stuff as he goes thru with creating things.
It's perfect for beginners and you'll learn quite a bit from it as you go thru his videos, but remember, don't rush and try to learn things slowly.
Spigot ain't bungee though.
It would be so nice for me, could you please send me the channel link?
https://www.youtube.com/c/GHG_TUTORIALS
There you go mate, hope it helps!
Thank you so much c;
Hi if I use zstd to make a yaml file or a sqlite file for making it lighter can that be a good idea?
Not true, indian tutorials are something different.
spigot tutorials only learnt me to abuse things
I mean it's better than just looking at stuff and not understanding anything.
He has to start somewhere and learn somehow.
๐ฎ
and not even talking about Unsafe or Runtime class
I didn't say that he's the best.
i learnt all my shitty code from codedred
Coz maybe I haven't watched much of spigot tutorials and that the only one I know ?
Smh, none of yall every watch thenewboston?
no
๐ข
looking thro gh repositories is far more useful in my eyes
Make them hold different data. Or make them execute different commands.
Would anyone help me on overriding the existing /msg command?
It used to work with just a regular CommandExecutor before, but not anymore.
CommandPreProcessEvent?
dont plugin command basically override vanilla commands?
For the most part yea.
i saw essentials doing it, and the only way to call the vanilla one was calling /minecraft:give
they will override /msg, but /minecraft:msg is there
Makes sense though
Wait, wdym not anymore?
Well it wont override the existing command.
I mean the /minecraft:msg will still be there as you said.
But it used to working with just a CommandExecutor class before, but it doesn't work anymore.
You registered the command and defined it in the plugin.yml?
Do you have any other plugins installed that have a /msg command?
hello guys, can someone help me with loottable?
i want to create loottable with 6 items
each of the items having different drop chance
Please follow the name conventions, must be in english
Hi mate, really sorry for being rude this morning
I just realize how much rude i was
I just was a stressed because i couldnt find any real example about reading server packet reponses from mc protocol
Is there a way to check if a pressure plate is pressed outside of the PlayerInteractEvent (so just checking the current state)
yo you have an input stream?
Im using plain Socket from java.net
And yes i have an input and output from Socket
gotta get encryption and compression sorted, and then you can check https://wiki.vg for the packet formats
compression is not required
if you just make sure to send the server to disable compression
I mean i have done basic steps, Hadshake and Login, so my fake client got conneted to sever but after 1m aprox get disocnnected
Many ppl told me im missing keep alive packets
Just to clarify im not doing a boot java program for shuting down proxys nor severs
aight
You know i will troll the sever
๐
By emulating a real connection
Which just connect to each sever a fake client and stays connected for ever
Let me open the project
i made a framework for server and client networking
Since when does Discord let you use underlines?
Well, I am learning and my native language is spanish thatโs why most of my methodsโ names are in spanish
just need to reimplement the protocol network codec to match the minecraft protocol format
Oh ok, its okay not problem with that if you work alone
Yeah i dont understand how the packages are done
Mainly the conversions
Yeah sorry
wdym by conversions
Since they introduced markdown. It's been here for a while.
__Your underlined text__
Because they are not normal strings nor numbers nor java types
They are all binary and i need to decode them, etc
icic
Yeah i did that
But when i sout data input stream getByte() to get the packet id
I guess because it's mostly hidden I've just not realized underlines were even possible, nor have I had any compelling reason to try it lol
I mainly gt numbers randoms output
I said before you don't sysout
Fair, everyone uses bold and italic for good reason. Not many things need to be underlined I guess.
You readByte to get the packet info, however many bytes is required to read the packet type
its most likely not random
I would understand better with a simple example about reading a packets
But let me send what i have for now
a Packet is not readable as a single unit. it's not like a string
So we dont talk in air
That why i mainly get confuse or having problems
each packet you have to break up into it's constituent parts
You know, now that I think about it, what really needs to be underlined? Besides links and the occasional heading, what else requires it?
Just to talk all in same channel
DataInputStream in = new DataInputStream(socket.getInputStream());
// read packets
while (socket.isOpen()) {
// read packet type
byte type = in.readByte();
// switch type
switch (type) {
case 69 /* hello world or something */ -> {
// read utf string
String str = in.readUTF();
System.out.println("Received 69: " + str);
}
default -> continue;
}
}
``` @sterile token
you need to read more data based on the type
I need to decode that in.readUTF() right?
You are getting there. you just have to break up the packet more once you know what type it is
idk how the minecraft protocol works exactly
might have to handle encryption
Sure, but I believe it's enabled for all online mode servers
Elgarl
I did
Oh ok
pretty sure teh keep alive isn;t a varInt though
I need to liste for ping packet push and answer it on the fake client
how can I get the owner if for example the entity is an arrow / trident in EntityDamageByEntityEvent
What should i first decode? I have setup the DataInputStream
Yep client bound keep alive is a Long https://wiki.vg/Protocol#Keep_Alive_.28clientbound.29
Anyone here from germany that uses Vodafone and knows how to IP Forward ?
I'm having issues with my IP not being forwarded
None programming questions #help-server
For the keep alive read teh packet description I linked.
The server send it to the client at intervals, you need to reply with the same packet payload
0x20 -> Should be convert into int right?
its a Byte
thats just a hexadecimal representation of 20
ok
Hello everyone again, I have a small question. How can I set a speed of particles? I have a code like this and Intellij doesn't show me anything related to speed in this function?
attacked.getWorld().spawnParticle(Particle.SMOKE_NORMAL, attacked.getLocation(), 50, 0.25, 0.25, 0.25);
Have you try checking their docs?
yes i have, but as i remember there weren't anything about speed
i also checked some youtube videos
oh ok
?
arrow.getShooter()?
if you have arrow object
like Arrow arrow = ...
How can I find out whether a potion is a splash potion or drinkable potion (1.8)
For itemstacks ^
ok but still then I need a trident and stuff
Sorry for pinging, but something like this?
yes
maybe you can try with the trident?
be sure to send that long back to the server as your keep alive packet
let me try
Would you recommend me then moving into Netty?
I've not used netty
Ok i ask because is what bungee and spigot use for NET
I guess it all depends on how my protocol you are looking to implement
if it's just a little then stick with java sockets
yes you can)
its a TCP connection so very simple
ok thx
I mean let me explain you my idea and you told me if its small or something really big. I mainly trying to emulate fake connections for using Pluging Messaging Channel without players
It won;t work I'm afraid.
the server will not take any action on a PMC message if no players are online
That why im asking about protcol haha
I will literally emulate fake connections which are real clients
I thought you were just trying to create a fake connection to do something like monitoring.
Oh no, i mean im trying to make it for PMC (Plugin Messaging Channel, just to short it)
oh I see
you are creating a fake client connection to force PMC to be active
nice idea
Yeah
Does someone know why I'm getting this error when I'll try to cast BlockData to Powerable
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_19_R1.block.impl.CraftPressurePlateWeighted cannot be cast to class org.bukkit.block.data.Powerable (org.bukkit.craftbukkit.v1_19_R1.block.impl.CraftPressurePlateWeighted and org.bukkit.block.data.Powerable are in unnamed module of loader java.net.URLClassLoader @25f38edc)
public static void check(Player p, BlockData data) {
Powerable plate = (Powerable) data;
}
I see no problem in the code.
That why im being really ass-hol with the protocol
BlockData
in that case just stick with java sockets
Hehe
nope blockdata i see
you pretty much only need to connect and keep alive
declaration: package: org.bukkit.block.data, interface: Powerable
I dont need another packet for the PMC?
I thought i need something else for them working
Mainly a packet
are you wanting to send a PMC message to the server from your fake client?
What are you passing into data?
It's pressure plate
Data is from a PlayerInteractEvent
Its a pressureplate that gets pressed
Mainly create a simple lib which goes on proxy and spigot, so via proxy check if the sever counter is 0, connect a fake player if not just trigger the data sending/arriving
But how can I check if it is pressed or not?
Client FakeClient has been connected to ....
Keep alive: -4012685007291559508
Keep alive: 5667363623437616032
Keep alive: -8285215939478023833
Keep alive: 8126511915762176
Keep alive: -2376493228367933081
Keep alive: 2161727821172533093
Keep alive: -2664723604519644825
Keep alive: 15998686113536
Keep alive: 4539628424424154981
Keep alive: 6012716073026322447
Keep alive: 8797284204544
Keep alive: -6627891276605681305
Keep alive: 19755289338112
Keep alive: 8092422760333824
Keep alive: -4610560118520409753
Keep alive: 8058342194840064
Keep alive: -6844064058719465113
Keep alive: -6411718494491897497
Keep alive: 6012716073026322447
Keep alive: 8797284204544
Keep alive: -6051430524302257817
Keep alive: -8934297235772796569
Keep alive: 13942470524672
Keep alive: -1440025980851580569
Keep alive: -4610278643543699097
Keep alive: -6339660900453969561
Keep alive: -3627120685966346102
Keep alive: -6716586487775150045
Keep alive: 8026184208948808119
Keep alive: -1850490519057384017
Keep alive: 7591839249313026556
Keep alive: 2025017085546653857
Thats my sever output Elgar
If I were you I'd just do it as a plugin on each server that connects a fake client via localhost
there is probably pplate data or something ยฏ_(ใ)_/ยฏ
By having that single client always connected it will keep PMC active
yeah better idea
Atleast happen what should
I put it the keepAlive() method on a while and finally timed out because i never answer it
yes, you are being disconnected because you are not responding to the keep alive packet
Just this
Elegar i just write the long as a long back to sever right?
so sending the packet id + sever reponse right?
yes
[20:08:03 INFO]: FakeClient lost connection: Internal Exception: io.netty.handler.codec.DecoderException: Badly compressed packet - size of 20 is below server threshold of 256
Hahaha
I need to serialize it i suppouse?
you open one connection to the server over TCP
Yeah
then just listen for data
does 20 means keepalive?
0x20 is keep alive packet id
๐
0x indicates it's a Hex value
ye ik that
so 0x20 = 32 decimal
oh ye right i forgot how to make conversions
only learnt a month ago and i already forgot smh
Elegarl
In confused to send the packet back and what you tell me about "you should be using a single stream"
is this netty that youre using?
what are you making?
Emulating a real mc client connection which connects to sever and stay afk for ever until sever goes down
nice nice
doesnt that require a whole protocol impl?
nope
Just some packets
i dont know any of this so dont really know
Because it wont do anything
lgarl could you help me again?
I didnt understand hat you mean
just login, keep-alive and ping
It looks like you are using a single stream so thats fine
ok so what i need to change?
but I'm not sure how you are calling your keep alive
are you just repeatedly calling it once you have sent the login?
so just continuously responding with 0x20 and then sending the read long back
arent you blocking your socket with that?
put code behind that keepalive and youll see (ig it blocks)