#help-development
1 messages · Page 932 of 1
oh yeah, how do i fix that?
Check if the primary inventory of this event is your custom inventory, regardless of which inventory is clicked.
Inventory primary = event.getInventory();
You might want to think about using a GUI library btw.
The current setup might work for now, but using a lib lets you focus on creating actual content
instead of fiddling with your gui logic.
Hello, when I try to get the foliage color using net.minecraft.world.level.biome.Biome.getFoliageColor, sometimes it returns 0, how can I fix that?
hmm ok, which one do you recommend?
After you got some experience you might want to write your own:
https://www.spigotmc.org/threads/a-modern-approach-to-inventory-guis.594005/
I've used Triumph in the past. It was fine back then.
is it because it's a plain?
Probably
also doing that with Savanna...
ok thanks
🤷
I think a value of 0 means it uses whatever colormap the client has
oh...
is there a way to get the default colormap?
humm okay thanks
So, I have thisjava public static Object getFoliageDefaultColor(Block block){ double AdjTemp = Math.clamp(FallingLeaves.leavesColorImpl.getTemperature(block.getLocation()), 0.0, 1.0); double AdjDownfall = Math.clamp(FallingLeaves.leavesColorImpl.getDownFall(block.getLocation()), 0.0, 1.0 ) * AdjTemp; return null; }
But how can I select the good color from that?
I imported Foliage.png in resources
is InventoryCloseEvent fired when the player leaves before closing the inventory?
Just look at the png and get the color values like described in the wiki
Yes
Ok nice
but how can I pick the good color 😅
What makes a color "good"?
The color associated to my variable
Pinking the good color for a plain not the one for a mangrove if I'm in a plain
Ah, you just write some code to pick the color from the png. Just as described in the wiki.
Okay I'll try to understand
hey is it possible to spawn arrow entity which is attached to specific part on player entity
like when u get shot by skeleton
but I would like to spawn arrow on player
how can i have code run when an object is collected by the garbage collector?
basically the opposite of a constructor?
its deprecated
what do i do instead?
why do you need to do that
i have an object that you can modify at the and you need to call a method to commit the changes and i want to throw an error if you dont commit the changes and the object was collected
cleaner api
but be very careful to not reference the object from your runnable
or it will never be GCd since it's reachable
So I’ve got a project I’m working on, pets system. Issue is that I need the items model’s to be integrated through a pre-existing resource pack, I’ve never worked with them before so I have no idea how to go about this.
Them being resource packs
No
Show the entire code
something like that?```java
public static byte getFoliageDefaultColor(FallingLeaves plugin, Block block) throws IOException {
double AdjTemp = Math.clamp(FallingLeaves.leavesColorImpl.getTemperature(block.getLocation()), 0.0, 1.0);
double AdjDownfall = Math.clamp(FallingLeaves.leavesColorImpl.getDownFall(block.getLocation()), 0.0, 1.0 ) * AdjTemp;
BufferedImage in = ImageIO.read(plugin.getResource("Foliage.png"));
BufferedImage newImage = new BufferedImage(in.getWidth(), in.getHeight(), BufferedImage.TYPE_INT_RGB);
byte[] pixels = ((DataBufferByte) newImage.getRaster().getDataBuffer()).getData();
return pixels[(int) (pixels.length*AdjDownfall)];
}```
?paste
When using hibernate, is there a method to retrieve a value or insert one and return it if not existing alr?
would it be possible to spawn arrow at specific part of body?
my pc lagging with 100k arrows from some reason
does anyone have a tutorial on using Firebase?
Google does have good documentation
Google's documentation on anything always throws me off
They have like 30 steps to authenticate anything for their API (any, not just firebase) and then turns out the doc page I'm reading is deprecated and the new API requires 40 steps, but the API in itself is deprecated and the new auth method requires a different account overall, and then when I finally authenticate, the methods and classes I need are the least documented
Looks like this should work. Btw you should follow java naming conventions.
How do you determine if this works or not?
@lost matrix I edited my code but it returns me -113:```java
public static byte getDefaultFoliageColor(FallingLeaves plugin, Location location) throws IOException {
double AdjTemp = Math.clamp(FallingLeaves.leavesColorImpl.getTemperature(location), 0.0, 1.0);
double AdjDownfall = Math.clamp(FallingLeaves.leavesColorImpl.getDownFall(location), 0.0, 1.0 ) * AdjTemp;
BufferedImage in = ImageIO.read(plugin.getResource("Foliage.png"));
byte[] pixels = ((DataBufferByte) in.getRaster().getDataBuffer()).getData();
return pixels[(byte) (pixels.length*AdjDownfall)];
}```
(in a jungle)
and -1 in a forest
but how can I convert it to a hexadecimal then?
Didnt read the wiki entry
I re-read, and I'm making BufferedImage#getRGB(x, y) but how can I convert the doubles to an int?
multiplying by 256?
it's not permanent
Sure, just map [0.0 - 1.0] to [0 - 255]
if I do ArrayList.set(60, someValue) when the array list is empty rn, does the arraylist size become 60?
Nope
Does it become 1?
Nope it will throw an AIOOBE
im making vaults rn
0-9
List<ItemStack[]>
so the first vault is 0 in the list, 2nd is 1 etc etc
so (int) (AdjTemp*256), (int) (AdjDownfall*256) ?
should I use HashMap instead or
If you want to serialize nulls:
Arrays.asList(new ItemStack[9]);
This creates a List with a fixed size of 9, initially filled with nulls.
@lost matrix java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds!
return new Color(in.getRGB((int) (AdjTemp*256), (int) (AdjDownfall*256)), true);```
Do you know?
Should I remove new Color ?
You tried to get a pixel outside of the image.
humm
but the image is 256x256
and It's clamped so..
Tell me the index of the very first pixel and the index of the very last pixel.
Maybe this helps.
The first pixel is at (0 : 0) and the last is at (255 : 255)
No idea. Depends on how your code looks like rn.
public static int getDefaultFoliageColor(FallingLeaves plugin, Location location) throws IOException {
double AdjTemp = Math.clamp(FallingLeaves.leavesColorImpl.getTemperature(location), 0.0, 1.0);
double AdjDownfall = Math.clamp(FallingLeaves.leavesColorImpl.getDownFall(location), 0.0, 1.0 ) * AdjTemp;
BufferedImage in = ImageIO.read(plugin.getResource("Foliage.png"));
//byte[] pixels = ((DataBufferByte) in.getRaster().getDataBuffer()).getData();
return in.getRGB((int) (AdjTemp*256), (int) (AdjDownfall*256)); //pixels[(int) (pixels.length*AdjDownfall)];
}```
It crashes at the return
(but I didn't tested using 255)
so it's with 256
Whats this for?
-1 (for pixels[0])
95 (for pixels[255*255)
usingjava byte[] pixels = ((DataBufferByte) in.getRaster().getDataBuffer()).getData();
Ah they use the bottom left corner as a base. Ok makes sense.
Yeah now multiply by 255 and check if it works
not working
out of bound
return in.getRGB((int) (AdjTemp*255), (int) (AdjDownfall*255));```
Print out the image dimentions and the coordinates
coordinates?
Honestly this is just some basic debugging.
of what?
The pixels you want to retrieve
wait is it possible to store things in an inventory holder
like
private int index; and then do
inv.getHolder().getIndex();
how can I pass (int) (AdjTemp*255), (int) (AdjDownfall*255) to .indexOf ?
@lost matrix do you know?
Yes
DuckDuckGo. Privacy, Simplified.
Anything. Doesnt matter. There is probably a Facbook group that has covered this. You can probably
find this in old msn messages. This has been solved millions of times for the past 20 years.
Close your eyes and click on a random link. It will most likely spoon you the answer in 5 different colors.
oh okay
@lost matrixjava int[][] pixels = convertTo2DUsingGetRGB(in); // [] x [] y System.out.println(pixels[(int) (AdjTemp*255)][(int) (AdjDownfall*255)]);
Returns me -9395353
Sounds good
Hey, we are planning to include some kind of auto-updater in our plugins!
This means that we have a folder on our root server (e.g. path /home/autoupdater/), in which we pack configs, for example.
The plugins should then check at startup whether they still have the latest version of the config themselves. If this is not the case, the plugins should automatically download the latest version of the config from this folder.
Now we wanted to ask how we can access a directory that is outside the Minecraft server.
Many thanks in advance.
then, how can I convert it to rgb?
By using any of javas File IO like you would normally no.
You’d have to hardcode the path
Or does java let you traverse backwards above the folder the jar is in
if I remove the last digit I get a light green
@lost matrix you're a magician, do you know how can I do? 🥹
public static Color getDefaultFoliageColor(Location location) {
Block block = location.getBlock();
double temperature = block.getTemperature();
double downfall = block.getHumidity();
double adjTemp = Math.clamp(temperature, 0.0, 1.0);
double adjDownfall = Math.clamp(downfall, 0.0, 1.0) * adjTemp;
BufferedImage in = ImageIO.read(plugin.getResource("Foliage.png"));
int xCoord = (int) (adjTemp * (in.getWidth() - 1));
int yCoord = (int) (adjDownfall * (in.getHeight() - 1));
int rgb = in.getRGB(xCoord, yCoord);
return new Color(rgb);
}
why it returns me a blue color 😭
there isn't any blue color so how in the world can it returns a blue color???
Debug it
java.awt.Color coll = LeavesUtil.getDefaultFoliageColor(plugin, location);
System.out.println("r " + coll.getRed());
System.out.println("g " + coll.getBlue());
System.out.println("b " + coll.getGreen());```
yeah, it's named coll
I forgot to put 1234567 after
If i invert blue and green I get a green color
You cant
how do i make movecraft compatible with 1.20.4 version of MC
Make a class + methods to make inventories and guis easier to work with. Specifically, my class had a listener nested in it, and i want to be able to add eventlisteners after the class is instantiated
?gui
So, @lost matrix what should I do ?
It's weird
Debug it
Using the real debugger ?
In 4 years of programmation, I never used a debugger, only print in console...
But I'll try this tomorrow, thanks really much for your help
Im seeing plenty of blue on this png to be honest
boy oh boy thats a lot of work
But, why I get a really blue color?
That's weird
I know I can be disturbing because today I haven't searched really much, but I'm falling asleep since 1 hour already so I'll check that tomorrow
Goodbye 👋
Im no regex expert, but this exception looks very questionable
Yeah that looks fine
Unless “” are part of the key
Or there is some weird Unicode character in there
I found the problem. It was something cursed in there from serializing the key.
Im doing something that should probably not be done
Im... not sure. I started implementing a map view for MongoDB
And since i had a whole abstraction on top of that, i decided to implement it for Files, SQL and PDCs for some reason
But PDC is already a map
Yes, but it has a bunch of serialization and namespacing on its tail
Honestly its just an experiment.
I like the idea of just having a Map representation for the persistence layer.
Imagine all you have to do is
public class PlayerDataManager {
public static final String DB_NAME = "playerdata";
private final Map<UUID, PlayerData> liveMap;
private final MongoMap<UUID, PlayerData> mongoMap;
public PlayerDataManager(Ambrosia<MongoDatabase, MongoMap<?, ?>> ambrosia) {
this.liveMap = new ConcurrentHashMap<>();
this.mongoMap = ambrosia.createMapView(DB_NAME, UUID.class, PlayerData.class);
}
public void loadPlayerData(UUID playerId) {
PlayerData mPlayerData = this.mongoMap.computeIfAbsent(playerId, PlayerData::new);
this.liveMap.put(playerId, mPlayerData);
}
public void savePlayerData(UUID playerId) {
PlayerData playerData = this.liveMap.remove(playerId);
this.mongoMap.fastPut(playerId, playerData);
}
public PlayerData getPlayerData(UUID playerId) {
return this.liveMap.get(playerId);
}
}
To load and save your data
why cant the JVM find the class?
can i not use top level variables inside another plugin?
java.lang.NoClassDefFoundError: me/outspending/invoice/core/InvoiceCoreKt```
trying to use that variable
i've tried shading my dependant plugin, and tried it without
neither worked
is the InvoiceCore plugin loaded properly?
The child plugin should have depend: otherplugin in the plugin.yml
i am doing that
and i tripled checked that the core is being loaded before the child plugin
which it is
NoClassDefFoundError can be caused by an exception in a static initializer block.
Its thrown during classloading and doesnt show up in the logs. The classloader simply discards this class.
Try lazily initializing your fields.
how would i do that?
This looks extremely dangerous
how? I was also thinking that was a bad practice
i just didn't know what else to do
ig could put it as static inside the main class
just initialise it like a normal plugin
spigot class loader will handle plugin loading priority if you set the depend in config
technically the block hasnt changed yet
getBlockData()
for the block that it iwll be changed to
getBlock() returns the current state of the block before its changed
yeah maybe mccoroutine messing it up
let me just try normal and move those variables to static instead
Im using Hibernate and when i delete a field it doesnt delete the column in the database? is there a config setting i need to apply?
why is it a mess tho?
oh yeah this one
im not doing any transctions
im just deleting fiels
fields
in the entity
yes im editing the class
no this is just for when updating values
i dont think it drops columns
i have it set to update, update only adds columns but doesnt drop them
lmfao
XD
I think you chose the last normal gif for "big spoon" XD
lol
that's exactly what i want
it's returning air though
it should be sand?
because it's sand turning into air
(falling sand)
A falling block is an entity. When it lands, it changes an AIR block to whatever it was while falling.
So getBlock() will almost always be AIR for a FallingBlock.
Ah wait
You are speaking about when the Block starts falling?
yea i'm trying to grab it after the first state change
yeee
so uh
my goal is
basically
to keep block gravity but simulate it in a way that doesn't involve any entities
so when a block is falling, the entity doesn't spawn and instead it calculates the first physical block under that block
then removes the block, and replaces it one above the block it found
simulating block gravity
I wonder if the downwards iteration would actually be that much more efficient than entities
everything works except for the replacing of the block
In that case the EntitySpawnEvent might be more suitable
in this case it's just to reduce entity lag
iirc the entityspawnevent doesn't trigger
even if it did, would I be able to get the block state before it's turned into an entity?
You would get the BlockData
Hm, does that event really not trigger for falling blocks?
So wait what’s wrong with the EntityChangeBlockEvent
when the event is triggered, it doesn't capture the original block's data correctly for falling entities
I mean you still have the FallinBlock entity and could your BlockData from it
Cancelling the EntitySpawnEvent might be more efficient if the EntityChangeBlockEvent is fired after already spawning the entity to the world
managed to get it working with EntitySpawnEvent
thank you vm
is it possible to run it all asynchronously? not sure if it's because the server is waiting for the processing or it's just running out of mem (i'm self hosting off of my pc rn so it might be that)
I mean you can run it async but not on a different thread
fair
Also it’s like 3 methods
one to make it work, two to get your pathfinder, three to do the math
Yea not literally one lol
It also loved the randomly fly up a block on walking setting
Custom is also better just was try’s be lazy
i should have read your entire sentence first
I couldn't get it to function at all
anyways, at least you could find a solution that fits you the best
Took a while to get it to work with what I was doing
what took you the longest, just out of interest?
maybe there are things to improve, always glad about feedback
Hey, quick question
Is it possible to give a player an item from another mod via a spigot plugin?
Spigot generally doesnt support mods. What platform are you using?
I am using Mohist 1.20.1
Prepare for the mandatory disclaimer lol
Yeah, I am only using Mohist because I need to use plugins and want to add a mod pack to my Server.. So is there a way to use or rather give a player an item from a different mod?
Look at the Mohist javadocs. They probably have a way.
I ended up... writing a full library for this.
https://www.spigotmc.org/threads/ambrosia-easy-to-use-storage-library-for-mongodb-files-pdc-and-redis.640405/
Im using hibernate and the Auto schema only adds columns is there a setting for also dropping columns?
I doubt that hibernate supports something as risky as auto dropping columns
:(
This. Is lovely
I will be looking into it 🙂
Incredible job haha
Tell me if it works then 👍
Hlo
Hi :)
Hy
DuckDuckGo. Privacy, Simplified.
Item adder essentialx essential x chat footage buzz anticheat world edit world guard multiverse core multiverse inventorys Happy Hyd Eco Pets And Job Bas Yeh Sab
I need this plugins
How to download
Not showing me download option
This is also a question for #help-server
I can't send photo
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
I do verify why I am not verified
It told you what to do in #help-server
Buying nitro before 2018
He give nitro ?
?
To anyone
Olivo you always give free Nitro to people.
Give one the Epic_Mayank as well.
._.
no that's your job 
Why would you even need nitro
to annoy people with huge code blocks instead of using ?paste
Wait you can paste bigger codeblocks with nitro? lmt
well the message limit is higher in general
I think it's twice the normal one
let's test
class ArgumentPath<T : CommandContext>(
val senderArgument: SenderType<*>,
val arguments: List<Pair<String, CommandArgument<*>>>,
val permission: List<Permission> = emptyList(),
private val contextBuilder: (Map<String, Any?>) -> T,
val ownExecutor: CommandContextExecutor<T>? = null,
) {
fun matches(
sender: CommandSender,
args: List<String>,
): Either<PathMatchResult, Pair<Double, List<Message>>> {
val greedyArg = arguments.indexOfFirst { it.second.greedy }
var firstErrorIndex = -1.0
val errors = mutableListOf<Message>()
arguments.indices.forEach { index ->
if (index >= args.size) {
return@forEach
}
val currentArg = currentArgResult.leftOrNull()!!
val parsed = argument.parse(sender, currentArg)
if (parsed == null) {
val error = argument.errorMessage(sender, currentArg)
firstErrorIndex = if (firstErrorIndex == -1.0) index.toDouble() else min(firstErrorIndex, index.toDouble())
errors.add(error)
}
}
if (errors.isNotEmpty()) return Either.Right(firstErrorIndex to errors)
if (greedyArg == -1) {
if (args.size > arguments.sumOf { it.second.length }) {
return Either.Right(
arguments.size.toDouble() to listOf(Basics.messages.tooManyArguments),
)
}
}
if (!senderArgument.requiredType.isInstance(sender)) return Either.Left(PathMatchResult.YES_BUT_NOT_FROM_CONSOLE)
if (!hasPermission(sender)) return Either.Left(PathMatchResult.YES_BUT_NO_PERMISSION)
return Either.Left(PathMatchResult.YES)
}
fun accumulateArguments0(
argIndex: Int,
givenArgs: List<String>,
commandArguments: List<CommandArgument<*>>,
greedyPosition: Int,
): Either<String, Int> {
var myStartIndex = commandArguments.subList(0, argIndex).sumOf { it.length }
val mySupposedLength = commandArguments[argIndex].length
val myEndIndex = myStartIndex + mySupposedLength
var missingArguments = mySupposedLength - (givenArgs.size - myStartIndex)
if (myEndIndex > givenArgs.size) {
return Either.Right(missingArguments) // TODO: Is this correct?
}
val expectedLengthWithoutGreedy = commandArguments.filter { !it.greedy }.sumOf { it.length }
if (greedyPosition == -1 || argIndex < greedyPosition) {
return Either.Left(givenArgs.subList(myStartIndex, myEndIndex).joinToString(" "))
}
val greedyArgumentSize = givenArgs.size - expectedLengthWithoutGreedy
val extraArgs = givenArgs.subList(greedyPosition, greedyPosition + greedyArgumentSize)
if (argIndex == greedyPosition) {
return Either.Left(extraArgs.joinToString(" "))
}
val lengthAfterMe = commandArguments.subList(argIndex + 1, commandArguments.size).sumOf { it.length }
myStartIndex = givenArgs.size - lengthAfterMe - 1
missingArguments = mySupposedLength - (givenArgs.size - myStartIndex)
if (myStartIndex + 1 > givenArgs.size) {
return Either.Right(missingArguments)
}
return Either.Left(givenArgs.subList(myStartIndex, givenArgs.size).joinToString(" "))
}
}
weird, 3950 chars is too much for nitro
but 3306 works
Meh thats half the class at best
the class had 14k chars, I deleted stuff until it fit
thanks for the free code
I thought the limit is 4k chars but apparently its 3500 or sth
I swear Either and Pair are so Pythonesque.
XD
coding at 3am moment
Whats the alternative to pair
Tuple?
should have tagged unions like in rust
What's javafx
for Gui
Ah that
i guess so
i dunno they are kinda good
i just dont like how they nest things up
early return on IsUploadJob
?
?
?1.8
Too old! (Click the link to get the exact time)
im trying to access a file in the plugins folder from a plugin that is not loaded
File dataFile = new File("plugins/SomePlugin/data.yml");
will this work? or should i find the server's directory
Did you add the spigot repository to your pom?
yes
already 8 years old
Wtf is blud talking about 🗣️
i typed "?" and pasted the image and pressed enter but i didnt had perms due to not being verified so the image didnt got posted
Can do File(plugin.dataFolder, "data.yml")
o
as i said, the plugin is not loaded.
in the plugins folder from a plugin that is not loaded
Ah yes my apologies
Well
val pluginsRoot = File(yourPlugin.dataFolder).resolve("../")
if you really need to know the path
resolve might be part of the paths api
Yeah part of NIO, kotlin should have extensions for that though
What do you mean by task? And how would you "execute tasks through the command" when you are in an inventory GUI?
> close UI
> send clickable chat component
> reopen UI on interaction
🧌
i made a similar system for this once, are you still looking for a solution?
reload maven
?
read the room bro
well its hard to tell if its a joke
the only suggestion to a joke is that orc
otherwise it seems like advice on how to make such a thing
Definitely no need to be so rude about it
Hi guys, how can I pass a Date instance on my POST request body? I can't handle it correctly. This is the code: https://paste.md-5.net/qisaxaxore.js
is the format messed up?
Possibly convert to a format, such as dd-MM-YYYYY or whatever you wanna use
?
?
?kick @fallen lily put off the attitude
Done. That felt good.
Alright big man
No need for that thanks
Besides if YOU as the moderating body read the room yourself you would have noticed that the person originally asking for help with their poor approach realised that it didn’t make sense
Shocker, I know right
take a chill pill, victim
That doesn’t imply sending a rude gif to someone who just tried to help, let alone smack me with a “nerd” gif.
“Rude” gif 😭
You don’t see a problem, do you?
No?
Does anyone know how to display this kind of preview using a list of itemstacks while hovering over an item of choice
This "preview" is limited only to the bundle item
Would it be possible to extend / implement from bundle?
Oh, so I can't like adopt it or make the item a bundle but the item that's showing something else
nope, this preview is client side
I don't think I fully understand
But you can use RP to give the bundle a custom texture (via custom_model_data)
You might be able to pull off some hacky resourcepack wizardry
Alright, sad I can't implement the feature. Thanks for helping tho
if I want to create a copy of some world when a player joins the server, teleport him there and then remove it once he leaves the server, would it be overkill if there are 500 players joining in one moment? Ig yes, then the question how would I be able to handle that
placeholderapi exists
I saw Maximvdw managed to make an option to remove red numbers from the scoreboard in the versions 1.20.3 and above. I know you can always use resource pack to modify this but apparently this is not what's happening here.
https://www.spigotmc.org/resources/featherboard.2691/update?update=533980
My question is done anyone knows how this is done?
oh wait, I remember that :D
Good old vanilla shulker box content display datapack
SlimeWorldManager
But ideally you have like 5 servers
And some services and shit to track everything
This is a new vanilla feature
you can try to load balance it, when many ppl join you load all their worlds, but you only allow like 5ms of a tick for world loading so the server doesnt stop
what is it called?
then you put the player in a waiting room and show him some kinda % to make him not leave
do a queue
last updated 5 years ago is it still valid?, oh nvm it has new resource page
AdvancedSlimePaper
ye just noticed it has new pages
alright, how many players would I be able to handle with 1 1.16.5 server ideally if it creates empty world with an island in them, so no real heavy things?
Uh you're looking at an old build for that version
sounds nice, could you elaborate how I can do this?
I'd keep it at 100/server
there was a thread to this by smile but idk the link rn
there was a command as well to it
?workload
?workdistro
i can send u smiles thread
hm, I am making that system for one guy, so I'd say he expects like 1000 players joining at once and he does not want to have more than 1 server, so there is really no way with this system to handle that amount of players on 1 server?
who tf called it workdistro
yes, please
not a bad abbr for workload distribution
its this one
i think
ye
by 1 server do you mean 1 machine or 1 instance
cant you load them async on paper or whatever
instance
because you really really really really really want multiple instances for 1k+
IIRC at akuma we did hold 1500 players on prison but everything was packet-based and the main thread tps wasn't great
yeah you wanna have a cloud for that one
i love your discord profile
Made a prison server using packets? Wow
imagine a skyblock server with only one island for every player but everything is packet based
so they each have "their own"
you have to do A LOT of tracking and emulating but you can do it all off the main thread
And maybe a custom spigot would help
it's really just not realistic
im pretty sure that wynncraft does something similar
Thanks:D u mean the "Zoltus" XD?
I heard hypixel's limbo is packet based although I am not sure how it would look in code, so I wanna ask if I can do the trick with worls creating packet based primarily. So, I load world - teleport player there - he mines 3 blocks from the island he is on and then he is sent to another server, in that way packet based would it increase possible amount of players on 1 server instance?
Let's say you have a single "island-world"
And you know its default state
And you can replicate it with "packet blocks"
Everyone's on the same world but no one can see each other
When a player breaks a block, you listen to the packets sent, track the block and send it as "broken" and replicate all of the logic
You'd need to make a hacked version of every entity in nms so it collides with the right blocks
Simulate water physics, all of that
When the player leaves, they go to another world like usual
When a player rejoins their island, you need to build up the right chunk packets
Basically rewriting all the logic from scratch
ahh I see, that would have been much nicer
The cool part is that you can do all that tracking async
The not so cool part is that you need to rewrite everything from scratch
In theory you can have the island server be on minestom
And maybe just maybe hold a lot more players
But that means writing all your custom logic from scratch because minestom doesn't run your usual bukkit plugins
when having objects that can have an impl of something but dont need to, how do i handle such situations? do i need to spam instanceof's to check if an interface is present?
I have a Data object which can have a onload a onunload or neither or both
Default empty methods that you call regardless?
And if you want to impl them you override
i guess, wouldnt that mean dead code tho?
Isn't dead code just code that isn't linked anywhere
You can make it mandatory to override and just // No-OP it
okay
as long as it gets called its never dead ¯_(ツ)_/¯
Hello, I am trying to get a join message from config but its not working, here is my code:
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player p = e.getPlayer();
e.setJoinMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getInt("join-message").replace("{player}", p.getName())));
}
``` I did it before and it worked now it doesnt
The code in the IDE is errored
okay so red underlines?
yes
and what do they tell you
Let me check
But i sent it here because i dont know
i need to find the erorr
its probably because you are trying to edit a int with a string or something
Oh there is a solve thing it said "Put in String.valueOf" and i clicked on it then it worked
ok
Well, yes and no
I don't think that's right
Do you know what an int is?
its a number from -22M to 22M i think
Is your join messenge a number?
i once saw you can set the value from a specific million to another
Now, do you know what a String is?
Its text
Cool
Like String string = "Hi"
Now, is a message a String or an int?
Its String because a message is usually text
Alright
unless you send someone a message saying "1234"
And what are you trying to fetch from your config?
join-message in config
(Wrapping in String.valueOf is the wrong solution to your problem)
What type is it? String or int?
normally it will be just text of the player name so String but i think its possible to be int if you only put a number like 1
Let's start by clarifying that you can have numerical strings
"123" is a string whose content is just numbers
Now, the final question
Why are you calling getInt and not getString then 
oops
i checked now there is getString not getInt but why if String.valueOf() works
Oh what if it already is a string
It compiles, but it's not the right solution
Then it just returns itself
String.valueOf("hey") -> "hey"
Oh then its not made for this purpose so i should use getString because its made for this purpose
Correct
thanks so much :D
depends on context
one sec
Caused by: java.lang.LinkageError: loader constraint violation for class me.outspending.invoice.mining.pmines.data.PmineDataManager: when selecting overriding method 'java.lang.Object me.outspending.invoice.mining.pmines.data.PmineDataManager.loadData(java.lang.Object, kotlin.coroutines.Continuation)' the class loader 'InvoiceMining.jar' @4c33cb51 of the selected method's type me.outspending.invoice.mining.pmines.data.PmineDataManager, and the class loader 'InvoiceCore.jar' @1a7ae251 for its super type me.outspending.invoice.core.data.DataManager have different Class objects for the type kotlin.coroutines.Continuation used in the signature (me.outspending.invoice.mining.pmines.data.PmineDataManager is in unnamed module of loader 'InvoiceMining.jar' @4c33cb51, parent loader java.net.URLClassLoader @4e515669; me.outspending.invoice.core.data.DataManager is in unnamed module of loader 'InvoiceCore.jar' @1a7ae251, parent loader java.net.URLClassLoader @4e515669)
sob
never had this happen before
Kotlin, so no clue
You could be shading something you should not as it refers to a different loader for the objects.
well both plugins have somewhat the same dependencies cuz it errors if it cannot find the correct dependency
i can send both of my build.gradle
My guess would be that you've loaded the Kotlin library twice
that might be it, but i have too? Or it errors
so Java doesn't know which one the code is refering to
both basically have the same dependencies but if i dont it wont let me use some of the methods
beta version of kotlin 
yeah its always worked fine for me
been using it for a while
99% sure its something to do with mccoroutine cuz of this Class objects for the type kotlin.coroutines.Continuation
i've also tried to compileOnly instead
which didn't work
with the dependencies that are used in Core
How are you loading the Kotlin library
it does it for me? wdym, intellij just adds it to the dependencies then it works fine
once i compile
So you're shading it?
this happens when the same class is loaded by two different classloaders and one of them is passed into a method and is not the same instance of class it was expecting or if its a different version. A class is treated as being different class even if two different classloaders load up the same class.
Code that doesn't exist cannot run so you're providing it somewhere
i ain't specifically shading it but one sec
it seems to do it for me:
decompiled jar ^
Try relocating it
yeah, i figured that out but not sure how to fix it
so you avoid loading it twice under the same namespace
what if i just compileOnly the sdk?
Code that doesn't exist cannot run
invoicemining.jar and invoicecore.jar are both loading the same class
You need to provide it at runtime
sad
I assume you are shading both of those and are those jars yours?
yeah that's the issue
both are implementing the same abstract class but different names?
You're shading Kotlin in both of the jars
ah oki
causing the kotlin classes to be loaded twice
.
So my guess here is correct
if both of those jars are yours, then restructure your projects where you are not doing that
although its coroutine dependent? different Class objects for the type kotlin.coroutines.Continuation
or is it kotlin itself
if they are going to be shaded into a project, it makes no sense to shade anything into those jars
and let the last project do the shading
cuz coroutines are a seperate thing
You're trying to reference the coroutine class but there are two different classes with the same name
ah
So it has no idea what to do
so i have to relocate it somewhere?
backwards, its two classes loading the same class via two different loaders
when this happens, the class is treated as being different
between the two loaders
That's what I meant
so even though you have Object1 loaded, Object1 in the other class is not the same
but the JVM can't distinguish this
not automatically anyways
do something like this?
you don't need to relocate if these jars are being shaded in
don't shade anything into those two jars, the final project which is where you are at, shade everything
well i dont have a final project doe, they are all seperate plugins
just easier to manage
imo
implementation + shadow
like dis?
but then they are double shading the same thing?
its 2 projects so should get different paths
well if the second project is shading the same thing
then one of them doesn't need to shade that one thing
yeah but it's two different plugins so not much you can do about that
if for some reason you need both jars to shade that thing, then instead of relocating, use a filter to exclude from shading then
well you could create a third lib plugin
goal here is not to end up with duplicated classes, which is what relocating will cause to happen
so the best thing to use, is exclusions
well since kotlin has the same path in both plugins
couldn't i just compileOnly kotlin's SDK?
you can target specific artifiacts with exclusions
since they will both point to the same package
Do your plugins depend on eachother?
well the child plugin depends on core
or can they run separate
Then shade kotlin in to core (relocated)
then only include kotlin in teh core
and exclude it from the child
basically what some of us said in the beginning >>
^^
fortunately there is people here who know the error you were getting and how to resolve it 😛
hmm, still doing the same thing
compileOnly(kotlin("stdlib-jdk8"))
just did dat
and all of these are compileOnly because Core already has them:
how can i get this text?
gotta use NMS iirc
I recommend using https://github.com/WesJD/AnvilGUI
honestly pretty goofy that bukkit doesn't allow you to grab that string
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
yet
@y2k
he left
wat
no chance what
ok no fr y2k left
XD
he got sick of cmarco so just left
lmao
Or we can ban marco instead of having half the community leave
block button fr
block button no help
blocking cmarco doesnt stop seeing everyone else still interacting with them causing more stuff
xd
if only we would find anti cmarco guy who would be a total opposite of cmarco
then there would be some action
I think the most opposite of cmarco is cmarco
cmarco is secretly suffering of multiple personality disorder and hasnt had his real personality in 3 years
i miss leguernic
imagine leguernic and cmarco in 1 convo
What is everyones beef with cmarco ?
idk leguernic lol... should have seen their convo yeah
o.o
YOU ARE back
i never left
Hi, quick question, kinda lost on the doc with this one, i'm trying to get the itemstacks from a smithingrecipes, it give you a recipechoice but i'm not sure if i can just cast it to Itemstack or not without causing problems :/
when i'm creating the craft i can just use the .exactchoice / .materialchoice but when i want to retrieve it the .getitemstack is deprecated
Check and cast
maybe older version = lighter :>
Use the build tools
And vulnerable to multiple exploits
HAHAHAHAHAHAHAHAHAHA
Big amount of those exploits have been fixed by forks
Forks don't run 1.8.3 I hope
they run 1.8.8 at the least
Also many vulnerabilities are in the client
is there even spigot for older than 1.8.8
yes
oh
Using the build tools and using spigot instead of spigot-api
i think there is a command in the discord here that tells u not to use 1.8 🤣
forgot what it was
It's ?1.8
ooh ye
I enjoy 1.8 servers too as it has the classy nostalgic feel for me as I started at those times
dont Hypixel which is the most popular mc server write their plugins in 1.8
?1.8
Too old! (Click the link to get the exact time)
ye
Bruv just use 1.8.8 and not 1.8.3
i love it though
it lacks a lot of useful features in the API 2
I added adventure chat apis to 1.8.8 myself and lost the patches
I cant find it and I spent so long adding the patches so awesome time lost
Just use the adapter
I want to backport my plugins to 1.8.8 easier so I'm just adding Audience to the player entity
Rerun BuildTools in a clean folder
What is the directory you run BuildTools from? It's probably not the reason for your error, but try to make sure it only contains alphanumeric characters and no spaces
folders with spaces do work fine
In that case idrk
I'll run bt myself and see if I get the same error
Wouldn't be surprised tbh 1.8 is old
Oh mine's even better lol
right didn't Mojang remove that download
use the gui smh
Yeah mine is from 27.07.2022 it does not have a gui lol
I downloaded latest and the gui is loading rn
This is taking its sweet time
yeah that happens on slow internet
VPN 🥲
oh difflib stuff, im out
What did you change
I got a question how does hypixel skyblocks private island system work, like do hypixel have like 200 different servers for each players private island or is it another system cause I know that whenever traveling from the hub to your private island you get sent into another server
maybe they have 5 players per server and they hide them from each other
wait but I know that each player can set the time for their island
wouldnt that have influence on the other players island aswell?
It's per world
there's Player#setTime or a method called something similar, it only changes the time for the player and if they relog itll be reset to the normal time
ah aight
oh so each player has their own world?
Likely and multiple servers
Yeah it's multiple servers with multiple worlds per server
It's hypixel they get 50k+ players
Whats the best way to save an ItemStack, byte array?
Base64?
wait you can do that?
yes
Depends
this makes things so much easier
Do you want readable or compact
I wont be reading it while its stored
storage compact
i see
Preferably compact over readable as I wont be reading it
well in case you want to use it https://gist.github.com/graywolf336/8153678 this utility class could help
public List<CraftHusk> getZombiesInWorldChunk(World world, int chunkX, int chunkZ) {
List<CraftHusk> list = new ArrayList<>();
for (CraftHusk zombie : zombieMap) {
int chunkXZombie = (int) zombie.getLocation().getX() >> 4;
int chunkZZombie = (int) zombie.getLocation().getZ() >> 4;
if (chunkXZombie == chunkX && chunkZZombie == chunkZ && zombie.getWorld().equals(world)) {
list.add(zombie);
}
}
return list;
}``` the chunkX variable is the value of the PacketPlayOutMapChunk variable "a" and chunkZ is variable "b". zombie is my custom entity entityzombiehusk, but for some reason, when adding it to the array, I cannot track its position and determine whether the player is in the same chunk
PacketPlayOutMapChunk loadChunkPacket = (PacketPlayOutMapChunk) packet;
Field xField = loadChunkPacket.getClass().getDeclaredField("a");
xField.setAccessible(true);
Field zField = loadChunkPacket.getClass().getDeclaredField("b");
zField.setAccessible(true);
int chunkX = xField.getInt(loadChunkPacket);
int chunkZ = zField.getInt(loadChunkPacket);```
hey, im making a custom /enchant command and wondering how i can get the actual vanilla enchantment names, so like minecraft:efficiency instead of Enchantment.DIG_SPEED?
so who am i believing at this point?
getItem might be null
Check if its air
but then again, i dont get it
im pretty sure thats it but i dont entirely know
i need all of them as well for autocomplete
How would I replicate this with a single server tho
thanks
^ rad
^ zbll
I was really asleep, I inverted rgb and done rbg...
Ah missed that msg
You would just have a ton of worlds
And hope for the best
Well try it out ig
how
How what
Take the namespaced key of all enchantments and print them out and see if that's what you mean
Then probably via the registry
I know for a fact that my cheap ahh 5$ a month server would get filled to the brim in matter of seconds
I mean you can also do multiple in the same world
But it isn't gonna make a huge difference
Bukkit.getRegistry(Enchantment::class.java)!!.toList() is this good
ye I could but stills gonna take up server storage
or does this just error
and lag the server
alr will try
There's an iterator() for them, not sure if there's a way to get all of the values just like that
Registry.ENCHANTMENT.toList().map { it.key.key }
You need it.key.value
will the loop keep running? or does it stop on error
btw an idea I had was what If I make a system so that your island gets saved on a database and then a few minutes after you left the game your island will be deleted but still saved, so when you rejoin the island will get placed again
NamespacedKey#key is the plugin iirc
So in the case of enchantments it'll just be "minecraft"
ah ok
sometimes
people can make custom keys that arent there plugin
yeah
unless its a forge/fabric cross over mod and then you can 9 trillion namespaces
Lol
swift_sneak, feather_falling, infinity, flame, impaling, protection, knockback, depth_strider, luck_of_the_sea, silk_touch, loyalty, vanishing_curse, fire_protection, channeling, binding_curse, sweeping, quick_charge, bane_of_arthropods, frost_walker, multishot, projectile_protection, aqua_affinity, soul_speed, looting, smite, piercing, lure, riptide, power, blast_protection, mending, fire_aspect, respiration, thorns, punch, sharpness, efficiency, fortune, unbreaking
woo
can I just say how much I appreciate List#joinToString in kotlin
Yeah that's fine
I just found an article from a hypixel developer he says that 10-30 seconds after you left your base it will be unloaded
yep
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) return true;
Player player = (Player) sender;
if (command.getName().equalsIgnoreCase("flatworld")){
World flatworld = Bukkit.getWorld("flatworld");
player.sendMessage(ChatColor.AQUA + "Cacat!");
player.teleport(new Location(flatworld , 0 , 0 , 0));
}
return true;
}
why doesnt this work
i have my world file name flatworld in my server folder
for some reason its null
You load it with WorldCreator
package testgroup.flatworldhandler;
import org.bukkit.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public final class FlatworldHandler extends JavaPlugin implements CommandExecutor {
World flatWorld;
@Override
public void onLoad() {
flatWorld = new WorldCreator("flatworld").createWorld();
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) return true;
Player player = (Player) sender;
if (command.getName().equalsIgnoreCase("flatworld")){
player.teleport(new Location(flatWorld , 0 , 0 , 0));
player.sendMessage(ChatColor.GREEN + "Welcome to flatworld!");
}
return true;
}
}
what da hell
ava.lang.IllegalArgumentException: location.world
is it faster to create a manager per player when needed and cache the managed data during use for quick access or a manager that accepts the uuid as argument and retrieves the data on every method call (singleton)?
Sounds like you're trying premature optimization again
Bad idea, just go for what makes sense (second option)
no, im not doing that (optimization) , its just that im unsure whether to use one thing or another, cuz i feel like the first option would be kinda good when methods are used in bulk?
Can somebody help me spot concurrent modification in this class? https://paste.md-5.net/avijamupav.java
This is basically a carbon copy of 7smile7's work distro class for evenly distributed workloads that I've written based on my understanding of his code and explanations. When I add 30k+ workloads, it gives me a ConcurrentModificationException at line 65 once but never again, even when I keep readding 30k workloads every now and then.
?
Interestingly, it works just fine, but the exception in the beginning does disturb me a bit
it will still be running
and when i try to connect
okay thanks
can you help me in help-server
i never used bungeeguard / bungeecord, there will probably be some1 helping you in a few minutes
ty
is it possible to add pdc to ItemStack in the config?
and where can I find an example of a serialized item
Why not just make an itemstack with pdc and then serialize it
Bam, you have an example
how can this code be improved so that it can remove NPCs from the tab list in 1.16.5 without the risk that the skin will sometimes disapear ```java
public void showTo(Player player, CraftPlayer npc, int entityID) {
try {
PlayerConnection connection = ((CraftPlayer) player).getHandle().playerConnection;
PacketPlayOutPlayerInfo info = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, npc.getHandle());
connection.sendPacket(info);
PacketPlayOutNamedEntitySpawn packet = new PacketPlayOutNamedEntitySpawn(npc.getHandle());
Field idField = packet.getClass().getDeclaredField("a");
idField.setAccessible(true);
idField.set(packet, entityID);
connection.sendPacket(packet)
player.getServer().getScheduler().scheduleSyncDelayedTask(AngryNPC.plugin, () -> new BukkitRunnable() {
@Override
public void run() {
PacketPlayOutPlayerInfo removePlayers = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, npc.getHandle());
for (Player player : Bukkit.getOnlinePlayers()) {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(removePlayers);
}
}
}.runTaskLater(AngryNPC.plugin, 40));
}```
and what could be the reasons that a custom NMS entity sometimes, if you go far away, appears in a suspended state at the player's position and then disappears when moving somewhere (that is, loading another chunk)?
You’re not really supposed to use the scheduler that way
oh wait nvm, ah you’re currying it
but without using it, when sending the REMOVE_PLAYER packet, the skin will be deleted immediately
is there a better way to do this?
By the way, could you please help me with this problem? custom NMS entity sometimes, if you go far away, appears in a suspended state at the player's position and then disappears when moving somewhere (that is, loading another chunk)? the fact is that I spawn a zombie and replace it with an id for an id npc while the player receives the PacketPlayOutSpawnEntityLiving packet. this way I get an NPC with AI, but if I move away, I sometimes see afterimages of the NPC, it strangely changes its position, maybe I should add handling of the npc unloading event
if (packet instanceof PacketPlayOutSpawnEntityLiving) {
Field idField = packet.getClass().getDeclaredField("c");
idField.setAccessible(true);
int id = idField.getInt(packet);
Field uidField = packet.getClass().getDeclaredField("b");
uidField.setAccessible(true);
UUID uuid = (UUID) uidField.get(packet);
if (id == 34 && fakeZombies.contains(uuid)) {
Field eidField = packet.getClass().getDeclaredField("a");
eidField.setAccessible(true);
int eid = eidField.getInt(packet);
new BukkitRunnable() {
@Override
public void run() {
FakePlayer fakePlayer;
try {
fakePlayer = FakePlayer.create("name", "custom_name", player.getWorld(), player.getLocation());
} catch (IOException e) {
throw new RuntimeException(e);
}
System.out.println("SUMMON");
manager.showTo(player, fakePlayer.getBukkitEntity(), eid);
}
}.runTaskLater(plugin, 1);
return;
}
}```
showTo
Are you using citizens?
no
or is this your own stuff?
own
Hmm alright and what is it that you’re trying to achieve?
Just custom npc nms entities?
also, I am sending packets to the player when loading the chunk ```java
else if (packet instanceof PacketPlayOutMapChunk) {
try {
PacketPlayOutMapChunk loadChunkPacket = (PacketPlayOutMapChunk) packet;
Field xField = loadChunkPacket.getClass().getDeclaredField("a");
xField.setAccessible(true);
Field zField = loadChunkPacket.getClass().getDeclaredField("b");
zField.setAccessible(true);
int chunkX = xField.getInt(loadChunkPacket);
int chunkZ = zField.getInt(loadChunkPacket);
if (!manager.getZombiesInWorldChunk(player.getWorld(), chunkX, chunkZ).isEmpty()) {
new BukkitRunnable() {
@Override
public void run() {
Bukkit.getPluginManager().callEvent(new PlayerChunkLoadEvent(player, chunkX, chunkZ, manager));
}
}.runTaskLater(plugin, 1);
return;
}
} catch(Exception err) {
err.printStackTrace();
}```
yes
Combat NPCs
should I hide npc from the entity when its chunk is being unloaded?

well, I'll replace it with a more reliable logger, but if this one doesn't throw errors, then everything is fine
I have still no idea why you chose to use reflections when you have nms at your disposal in the first place.
You will trash your servers performance like that.
can you say anything about the problem above?
to be honest, I don't understand how to implement what I need without reflection
how do i exclude kotlin in gradle?
compileOnly doesn't work, also tried shadowJar's exclude
decompiled jar ^
When i want to get block and change type chunk needs to be loaded or not?
It needs to be loaded
Are you pulling it transitively from somewhere?
no
i dont think so
my Core has kotlin and is throwing a LinkageError
cuz both jars have kotlin
Show your build file
Couldnt find anything. Try gradle clean before compiling.
If that doesnt work then anaylze your dependency tree.
i think i figured it out, one of my dependencies was shading the kotlin-stdlib
is there something like 'wait' in a BukkitTask?
i want to make the task wait afew ticks if a boolean is true
you can "wait" IF async
?
How about you just dont do anything while the boolean is false?
if(!condition) {
return;
}
Yes they are indeed very different
Take a step back and tell us what you are trying to do
Wait for a certain amount of time or until a condition is met?
wait a certain amount of time
How about BukkitScheduler#runTaskLater(...)?
call getNearbyEntities and get the first one. I think its ordered by distance already.
i don't want by distance, i want just in general
even if the entity is like 10000 blocks away but it's the nearest
In that case you need to get all entities in the same world and check which one has the lowest distanceSq to the player
What are you calling an entity?
as dropped items are entities
as are Players
and mobs
all entities
