#help-development
1 messages · Page 1067 of 1
I will certainly look into it! I appreciate yall giving me places to start.
yeah sure!
i am calling an event when my plugin is being disabled (onDisable()) but my listener does not listen it. Do the listeners stop listening when the plugin is being disabled?
yes, you can;t raise events on dsiable
just add disable methods in whatever classes need them and call from onDisable
not spigot related, java. curious if this is a good way to do this. Making a auto broadcast system.
current = 0;
}
sendAll(getMessages().get(current));
current++;```
pretty much just keeping count of the last one and adding 1 after its sent. resets at the stringlist.size()
You could replace the if statement with a %=
current++;
current %= messages.size()
sendAll(messages.get(current))
.size()
whoops dont mind me, baby crawling on me
% operator is taking the rest in the Euclidian division.
a = b * q + r
This is the Euclidian division of a by b.
a / b = q
a % b = r
So you need to divide current by a given int
But why does it reset it when it reaches the max limit?
or does java just do that by default?
What do you mean?
I have to go to the operand page of my java bible every so often haha
Let's say current = a and messages' size = b
a will be always lower or equals to b
So it will always be:
-
a = b * 0 + r => r = a (so a %= b will not change a)
-
a = b * 1 + r => r = 0 (so a %= b will make a = 0) [because a == b]
rolyn out here mathing
I want people to understand what they do
that's fair and I can say that I certainly appreciate it
You helped me with the overlay stuff
great!
too complex explanation. Its just modulo/remainder
Yeah but explain modulo to someone that never heard of modulo without using the word modulo
Idk I feel math should be explained for what it is and why
true
That's a lot of modulo
%%%
And sorry for being in the math religion, it feels like a religious group I cannot get out of
Hey math is great
@EventHandler
private void onInventoryChanged(InventoryMoveItemEvent event){
Bukkit.getLogger().info("real");
if (!(event.getSource().getHolder() instanceof Player)) {
Bukkit.getLogger().info("realest shiz ever bro!");
return;
}
if (event.getItem().getItemMeta().getPersistentDataContainer().has(keys.getRegistered()) || event.getItem().getItemMeta().getPersistentDataContainer().has(keys.getPreviousEnchantLevel())) {
Bukkit.getLogger().info("wat");
if (event.getSource() != event.getDestination()) {
Bukkit.getLogger().info("Shoulda cancelles!");
event.setCancelled(true);
}
}
}
When moving an item from players inventory to chest nothing get printed to console.
But other event listeners in the same class work
Try to put a hopper on top of a chest to check if you get at least the log "real"
Alright ill check
That works. with real and realest shiz ever bro!
Then that's maybe not the event you are wanting ahah
Yea realised
What do you want to achieve? Avoid players to put items in a specific inventory ?
Yea
kinda
A player gets given an item that they should be able to move around in their inventory
but not be able to place in other inventories
In InventoryClickEvent (https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryClickEvent.html) there is a method InventoryClickEvent#getAction that returns the action performed
In the actions possible (https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/inventory/InventoryAction.html), you have MOVE_TO_ANOTHER_INVENTORY
maybe you'd like to cancel it
I'll look into it thanks :)
Make sure to listen to inventory drag event as well
it's done boys
https://github.com/MagmaGuy/ResourcePackManager getting a public release next week
automerges resource packs and autohosts them
0 input or configuration required
Not everyone is super familiar with long division, which is such a shame
modulo is just kind of the remainder of any division no?
the way I usually explain it is that its like a loop
and your starting number is the amount of steps you take
i mean there is a rigorous mathematical definition that involves equivalence classes and binary relations sort of
but eh, who cares about that
I only know Math#floorDiv
is there an invulnerability state change event
I'm trying to make a while loop so it plays the sound/particle but obv with how it's currently written itll only trigger if the player is already flying, not while they are flying
The only thing I can think of is making another listener for a PlayerMoveEvent and checking the conditions there, but surely that's inefficient/may be done in a better way? Otherwise I can try that lol
?scheduling
You might want to use some Bukkit Schedulers. Those are timed loops.
You can run a tasks that play a sound to every players that are flying
Please see the above link. Feel free to ask for anything else
alr, ty
MoveEvent is irregular and will spam players of sound and particles. While loops are just code blocking (the code will stop while the loop is not stopped)
how possible is making this method
updateScoreboard(Player player, Function<List<Player>, List<Player>)
which basically orders the players in the tablist based on the Function parameter
The fk is function
its a java function
(x) -> return y;
so how possible is it
I thought smth like HashMap<Object, Object>
You might be able to make a type
And then have the function return it
well it is possible to sort players in tab list, but idk how to di it
it may require packets
it could just be updateScoreboard(Player player, List<Player>) since the 1st one in the Function is just Bukkit.getOnlinePlayers()
but like ,idk why you are using a Function though
^
i didnt think it through
use a comparable instead
comparable is designed for sorting
there are methods like TreeMap or Arrays.sort that take comparable objects for their sort
i use Arrays sort for a lot of things due to this property
and treemap too where aplicable
it doesn't really matter what i use
the main issue is how to apply the sorting, i think it's player info packet or something
you can achive sorting with a bifunction, not sure how you'd sort it with a function
once again
i dont care how it's sorted
i only need to know hwo to apply the sorted players into tab
well, in that case a function can do it
😭
for the third time
i dont care how its sorted
i want to apply the sorted players into tab
using packets
idc if i use function, bifunction, list or anything
i didn't say anything this time
i'm not sure how tab sorting works, i assume there are docs on spigot
it's A-Z i think
if not what i know is that you can use scoreboard teams
well, in that case isn't stright forward
?
i think minecraft does this sorting by default
yea u think u need to use teams to sort it in the order u want given a list
Which can also be done w mere packets if one wants to
but a z sorting doesn't require anything as far as i know
unless minecraft takes a list of sorted players for the order in that case we're back at comparable
ye it doesn’t, but they wanted the same order as the list passed as argument, or did I get that wrong?
no, he said a z
where?
ah, nvm, i missread it
then yeah, teams are the way
but i remember seeing people doing elaborate tabs that weren't with players anymore
or rather mostly were with stats
oh yea
if you can append entries to the tab or remove them, then you can use color codes to achieve any order you want for your order
https://paste.md-5.net/aviyaciqad.java this is from chat gpt
I wanted to add after the res var is created
basically if(AlixFastUnsafeEpoll.reject(res, addr) return -1;
is this correct?
how would i use teams with packets
why does minecraft always make stuff hard to change
and there isnt a single good thread talking about this
@dawn flower
https://wiki.vg/Protocol
i know about that
Basically your plugin would need to keep track of what teams data you are sending
I hate protocollib ngl
And bytebuf is nicer imo cuz you can use the protocol wiki
Since it's actually documented
Though it might break version to version
But i like it still
public static void updateTabList(Player player, Player... players) {
ProtocolManager manager = Tab.getProtocolManager();
for (int i = 0; i < players.length; i++) {
Player otherPlayer = players[i];
PacketContainer packet = manager.createPacket(PacketType.Play.Server.SCOREBOARD_TEAM);
packet.getStrings().write(0, String.valueOf(i));
packet.getBytes().write(0, (byte) 3);
packet.getIntegers().write(0, 1);
packet.getStrings().write(1, otherPlayer.getName());
manager.sendServerPacket(player, packet);
}
}```
like this?
Protocol lib breaks version to version anyways
With libs like packet events and mojang mappings being easily available, it makes plib pretty useless
Hey guys
Looks about right
What's that?
It basically removes you from tab list
But it doesn't remove you as a whole like REMOVE_PLAYER
I can only use it in versions like 1.19.4
Can you show what all the enum values are in 1.19.4 and 1.18?@keen charm
I'll show it as soon as I get on my PC
hi, i'm trying to spawn in loop some mobs, and i have issues with the spawning: some times it spawn correctly 50 mobs and other times it doesnt spawn them all is there a way to check if the world.spawnentity() works correcly?
Isnt there a method for that in ServerPlayer
For unlisting?
Yeah
Wait there is? 😭
Not sure about 1.18 but I use it in 1.21
I had to manually modify the entry values using Reflection lmao
what are you doing?
well transforming
Can we see your code
trying to add this one line of coding of mine
into that Socket#accept method
For Paper you just had to apply patches and build
Theres an option to dl jdocs on bt iirc
I can view it directly in my ide, pretty sure I just selected that
why are you reflecting sockets?
that is of lesser importance
I'll download Paper sources and only look up for Spigot codes there then
?xy
it's not
hold on a sec
There are probably 2 solutions for my case
and this is one of them
can't do the second cuz I can't code in cpp
anyhow
what can I do about the Verifier?
for (int n = 0; n < SpawnCount; n++) {
while(true) {
int randx = new Random().nextInt(xdif)+minx;
location.setX(randx);
location.setZ(y);
int randz = new Random().nextInt(zdif)+minz;
location.setZ(randz);
if(location.getBlock().getType().equals(Material.AIR)) break;
}
world.spawnEntity(location, mob);
}
the for loop loops the correst amount of times
I'm retransforming the Socket class with a different a bit bytecode
but the verifier just tells me "nuh-uh"
What's alixunsafeepoll line 23?
Are you trying to get the next clear block?
Theres a method for that which doesnt require a while true loop
ehm yes since the area where i spawn mobs have building and i dont want them to spawn into the block
but if the blocks air i should be alrg? no?
i can try that
You should definitely have a safety exit from the while loop
Or just dont use a while true loop
They are dangerous
how did you manage to avoid the Verifier
@young knoll ?
if you can tell me the method i'm willing to use it
if theres a way easier to do smth ill do it
Is that the entire stacktrace?
Nvm I was wrong theres only getHighestBlock
I think that means you mangled something with your asm
oh so the bytecode is invalid?
i mean bruh
Yea usually
There is getHighestBlockY
it's not that bytecode modification is disallowed by the vm?
Or I mean like wrong method signature for example
this is from the gpt friend
does any1 know how to help me out?
Hey
What function did you mention?
Generate random x and z then use gethighestblocky
i dont want mobs to spawn on top of buildings
lol
Also 1.21 & 1.18.2
Im not home rn so cant check but it’s smth like hideFromTablist or some shit
There definitely is an inbuilt method for it tho
#help-server please
mb
Np
Sorry I'm on mobile and too lazy to go on my computer hence how slow I am
You mean ServerPlayer or smth else?
Do you want to hide the player entierly or just tab list?
Just tab list
Please go to #help-server
If that's not your plugin
Hey
If we modify PlayerTextures does the changes apply to GameProfile?
And if we modify GameProfile does the changes apply to PlayerTextures?
I'm trying to make a stats system with ORM Lite using HashMap based on modes and the stat type. So, I create a custom persister to convert hashmap to sql object, since SQL and ORM Lite doesn't support hash maps directly. now I except hashmap instantiates and loads itself, however it ends up hashmap being null and if I try to instantiate it manually, the statistics of the player gets reset obviously.
Account: https://pastes.dev/jfzKB00Up8
AccountStats: https://pastes.dev/ABYQAZDRME
Custom Persister: https://pastes.dev/Z7O10zCfMg
?paste
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
method ScoreboardUtils#updateTabList called with (MissingReports (CraftPlayer), [MissingReports, Lightning9308] (CraftPlayer[])) threw a FieldAccessException: Field index 0 is out of bounds for length 0
public static void updateTabList(Player player, Player... players) {
ProtocolManager manager = Tab.getProtocolManager();
for (int i = 0; i < players.length; i++) {
Player otherPlayer = players[i];
PacketContainer packet = manager.createPacket(PacketType.Play.Server.SCOREBOARD_TEAM);
packet.getStrings().write(0, String.valueOf(i));
packet.getBytes().write(0, (byte) 3);
packet.getIntegers().write(0, 1);
packet.getStrings().write(1, otherPlayer.getName());
manager.sendServerPacket(player, packet);
}
}```
according to wiki.vg it shouldnt do that
bound might be going negative
what bound
ah wait mb
packet.getBytes().write(0, (byte) 3);
packet.getStrings().write(0, String.valueOf(i));
it's one of these thats doing it
and im guessign the 1st one
yeah ppl from Recaf helped me out on that
the problem is that it doesn't find my class now
ah yes
p.getvehicle
Thank you
on interactevent
The netty CL is the root/system CL for reference
?
understandable
use packet events
how does that make a difference
Player cookies can be spoofed right?
also icba to change every code with protocollib
like every packet
hmm but still
I'm using respawn packet and although I don't provide any location, the players gets respawned in their previous position. How does that happen?
how do I have it find my class?
Hmm guess were using redis
Is this a spigot plugin?
yep
jwt them :thinksmart:
my code kinda works, but minecraft hates me so it didnt reorder the tab
the prefix "5" is just for debugging
i tried with 1 instead of 5 but still
and i tried with A
Hey
I'm trying to change a player's skin while they are on a vehicle (aka riding a mob such as a horse)
can someone please help me? i've been trying to do this for like 4 hours now
prob more
I do ServerPlayer#stopRiding(); store the vehicle (aka the entity), and then do ServerPlayer#startRiding(Entity); but it doesn't work
It drops me from the mob, I can't ride it for a few seconds and then after some time I can ride it
Why do you use nms for that
Isn't that in the api
does minecraft take player's latency into account for tablist sorting
no
How do I ride a Entity object then
Hacky fix try adding your jar to the classpath with your startup args https://stackoverflow.com/questions/6409510/how-to-run-a-java-class-with-a-jar-in-the-classpath
goddamn it
tablist is sorted:
spectators are put last
then sorted by teams alphanumerically
then sorted by profile name alphanumerically
oh gosh I can't find it in the API, how did that happen
yes it is
i didnt try having a team
Entity#addPassenger(); it is
But well, never use NMS when you can use the API
There is a problem with it tho
When I use it it adds me as a passenger
But I can't ride it and I'm not even on the passenger seat of the entity
But when I do shift I get off it successfully and then I can ride it again
what happens if i "add an entity" to a non existant team
cuz it doesnt seem to be doing anything
other than existing
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
#bot-commands
how do i create a team that barely exists? i dont want it changing prefix, name, color or anything
hey
any idea, why the statment starting on line 21 is not working?
to be specific the line 27 - stand.setGlowing(true). if i put here stand.setArms(true) or stand.setBasePlate(true) everything is working just fine
no console errors
nothnig
it should not create the armorstand when i use the shroomlight
it should have behavior as the stick and stone_slab
everyhting is okey, if i change the stand.setglow(true) to something else
hi, i'm trying to spawn in loop some mobs, and i have issues with the spawning: some times it spawn correctly 50 mobs and other times it doesnt spawn them all is there a way to check if the world.spawnentity() works correcly?
heres the code: ```java
for (int n = 0; n < SpawnCount; n++) {
while(true) {
int randx = new Random().nextInt(xdif)+minx;
location.setX(randx);
location.setZ(y);
int randz = new Random().nextInt(zdif)+minz;
location.setZ(randz);
if(location.getBlock().getType().equals(Material.AIR)) break;
}
world.spawnEntity(location, mob);
}
i'm 100% sure the for loops goes the correct amount of time
setZ(y) probably isn't helping, depending on where you're testing
fuck me
maybe thats why
😂
i mean thats a correction but still i dont get the spawn i need
please dont create a new random generator every iteration
you have no single clue how heavy generating that object is
oh dammit youre even making two of them
ahyigadhjiuagdbad
Doesn't it fetch a truly random value from the atmospheric whatever for the seed?
truly random things dont exist in computer land
unless youre using /dev/urandom
not entirely sure about that one
They do, fetched from some atmospheric shit value for usage in the seed of pseudorandom
i mean i can change it but i dont think that will solve the problem
But instead of calling new Random each time use ThreadLocalRandom.current()
It will make your plugin quite a bit more optimized
yes but rn i dont reallt care
i just need it to work
ill have room for improvement later on
for now i just need it to work
That's how you end up rewriting your plugin after finishing it
ok
do you know how to help me or you just want to come here and teach me how to do stuff?
I do both, I'm looking at your original msg rn
?paste
https://paste.md-5.net/hujefaqefi.java
[HyroCore] Task #2 for HyroCore v${project.version} generated an exception paper-lobby-1 | java.lang.IllegalArgumentException: An objective of name 'sidebar' already exists
How can I fix this?
The exception suggests you might be trying to make an objective (scoreboard) named 'sidebar' when it already exists
But it seems because of the repeating task, its the same objective
and if set the objetives as an private val doesn't show idk
I looked at the docs for static class and it showed up using a companion
thanks for the suggestion
just register the objective once
okey
how do i change the color in a fake team packet in protocollib?
?
this is so annoying
Not expert at all, but
Hey, could you check it when you are home? I couldn't find it
yep shall check now
i looked at that for the past 7 hours
it makes no sense
because getIntegers is like 1 length
What "get integers"
Can you show how you construct the packet ?
maybe I'm tripping but i can't see it in my code anymore. It might be in ClientInformation
ill send my code, my npcs don't show up in tab
Hastebin is a free web-based pastebin service for storing and sharing text and code snippets with anyone. Get started now.
it's a varint enum
there is no enum related to color in packetwrappers
and doing Packet#getIntegers says it has a length of 1
plib moment
ong bro
i need to rethink my life choices
is there another one
Oh really ?
How so.
retro gonna kill me for this one 🔥
wiki.vg tells you about the byte stream format on the wire, protocollib is just a fancy reflection accessor for the java packet class, those two can differ by a huge margin
^
so im supposed to guess or what
😮
i mean it’s still helpful when it comes to understanding the meaning of the data
go look at the java class of the packet if you are working with plib
but some of the types must not be taken literally
there are class packets?
all packets are classes
nms yea
im talking abt plib
.-.
i dont like incosistencies in my code
plib uses a different structure
ugh
Yes, a seperate project called PacketWrapper, yet I doubt they’re actively maintained
and function on all versions
they told you to open the nms class
the nms class has an optional of Parameter.class
and look at its impl
and protocollib needs a "converter" to get the optional modifiers
you can run a scientific study on this, or you can just accept defeat
and trust in another library
i cant just use protocollib in half of my project and packetevents in another half
and replace all the old code? no thank you
plib users aren't sane
it's way better to use tho lmao
bro everyone told me to use plib
it's just a class
it’s okay guys
what class
im not offended
i have alot of classes that use plib
I mean I use plib... but a method to automatically listen to packets very easily
possible bad design of your project if you have thaat much to change now
but i think you’re exaggerating
Convert to packetevents :P
it's gonna take at least 2 days to convert old code to pe
I spent a whole day converting my project to Spigot from Paper
omg they promise
spigot -> paper is nothing
Promise<Conclube>
Like from 11 am to 4 am
purple you nerd
lmfao
then you're likely doing somethng wrong
My bad, Paper to spigot
I’m not affiliated with that entity but we are not liable of any damages
paper -> spigot is nothing
it might cause on your server.
me when components:
If that’s nothing for you, then PLIB -> PE shouldn’t be such a cumbersome conversion for you
I replaced Player#setPlayerProfile() with remove player, add player, respawn packet
Turned the project into a multimodule gradle project
Yeah it's nothing
it removes about 130% of headaches lol
anyways
and is so much faster
how do u even use pe
Anyway, if you insist on using PLIB sure, just we made the competitor for a reason, it’s not just some knockoff
First time you do it, always painful
There’s guides and such on the GitHub
Gotta open your ear
And a discord server
you create an instance of a packet class and send it
what packet are u even dealing with again
team
ok
why tf do you need packets for that
each player has their own scoreboard
?
yes
WHY DIDNT U TELL ME
who
always check api first kekw
bro who do u think u are
maybe a skill issue
dawg
real
agreed
you sound like an evil villain
except that it literally is
i'm dumb
Yes
yes
did u just call me dumb
jk i am dumb
Yep
anyways im gonna go cry in the corner for the 7 hours wasted or something
you just ```java
var board = Bukkit.getScoreboardManager().getNewScoreboard();
board.registerNewTeam(...)
player.setScoreboard(board);
kek
hehe
no wonder you find it simple
evil "var"
everyone knows making scoreboards is the spigot final boss
make it val
Hey, can someone check my code? https://pastes.dev/Z64AYylHwL
Its about armorstand but the problem is on the line 124 with the glowing... if i put there something else like arms or baseplate, everyhting is working fine, any idea why?
Hi, if I run the following code
try {
Object onlinePlayers = Bukkit.getOnlinePlayers();
Method sizeMethod = onlinePlayers.getClass().getMethod("size");
int count = (int)sizeMethod.invoke(onlinePlayers);
System.out.println("Size:" + count);
} catch (Exception ex) {
ex.printStackTrace();
}
I receive a IllegalAccessException error. Any idea on how I could fix this?
java.lang.IllegalAccessException: class MyClass cannot access a member of class java.util.Collections$UnmodifiableCollection (in module java.base) with modifiers "public"
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:394)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:714)
at java.base/java.lang.reflect.Method.invoke(Method.java:571)
at MyPlugin.jar//MyClass.MyMethod(MyClass.java:0)
at org.bukkit.craftbukkit.scheduler.CraftTask.run(CraftTask.java:101)
at org.bukkit.craftbukkit.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:482)
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1699)
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:467)
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1571)
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1231)
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:323)
at java.base/java.lang.Thread.run(Thread.java:1583)
What are you trying to do?
Getting the number of online players..?
Yea, or just in general the size of a collection
Then why don't you just call Bukkit.getOnlinePlayers().size(); ?
Average chatgpt bandage fix xd
Because the .size is not called in java but rather translated from something else
you know you can cast it right?
wdym
I would have to add more hardcode
Like I added the ability to call java methods from non java
well it would be the same amount of code
And I would then have to check if its a colleciton etc
All I’m saying is to use Collection.class.getMethod(…)
But im obj.getClass()
and then thats that
what the fuck
i would then have to Collection.class.isAssignableFrom(obj.getClass()) and then Collection.class.getMethod ...
why does the problem even exist in the first place? why can i call it in normal java but not with reflect?
Or Collection.class.isInstance() just?
bec its not java code im executing
you think im that stupid
Hey there, can anyone help with why I'm getting this error? I recently switched from 1.20.2 to 1.20.6, and besides some minor tweaks, I didn't change much since 1.20.6 didn't have code-breaking changes, yet I get this error for the teams packet. Any reason why? https://pastebin.com/HxskBffB
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
idk? your class is called MyClass inside of MyPlugin and that's pretty interesting already
bec i renamed them?
I assume they’re writing some other language and want to at runtime “transpile” and map to java reflection objects
ye
like skript but less shit
atleast trying to
🙂
and i dont want to add a getCollectionSizeBecauseFun function
Generally for most languages you should start with an AST for your target
Then build your parser
the language is not the problem. the interaction with java -_-
even in differen plugin the setGlow is not working
I do think they’re past the AST phase
Yea well I mean, the best thing you can do is to just like, use reflection on interfaces if possible
Esp like Set, Map, List, Collection yk
So only way to fix it is to add some sort of hotfix!?
how do u clear a Team object
team.unregister(); if you mean that
well, no, that won't work
why
you need to unregsiter the team on the scoreboard
don't ask me why
it just doesn't
public static void updateTabList(Player player, Map<Player, Integer> players) {
Scoreboard scoreboard = player.getScoreboard();
for (Map.Entry<Player, Integer> entry : players.entrySet()) {
String index = entry.getValue().toString();
Team team = scoreboard.getTeam(index);
if (team != null)
team.unregister();
team = scoreboard.registerNewTeam(index);
team.addPlayer(entry.getKey());
}
}```
is this how you do it?
doing team.unregister() just leaves them on /team and stuff for some reason
just do board.unregister it works
wait if i register a team in a player's scoreboard it shows in /team?
yeah
Making minecraft less shit and better for developers? ❌🖕
Adding wolf armor no one asked for? ✅ 😊
Ignoring performance improvements, better item stack improvements, and movement towards more data driven registries 💪👍
for some reason i feel like the issue is unregistering on the team object itself
board.getTeam(...).unregister() works
spigot moment
team.unregister() doesn't
for me at least
whats the point behind data driven registries?
Adding custom things to the game from the server.
And having the client understand it
Instead of using packet hacks and whatever else we do to jank shit together
Tbh a world without client side mods is an ideal world
Tho using registries you can only go so far
Stuff like JEI and some of the client menu improvements would have to stay there as client side mods
or the ability for the server to do anything on the clients end. like custom gui or whatever
I mean
fun
You could try to get the method from the super class recursively
What’s with the attitude?
:(
not fun
when you do things, there are stupid errors you are wasting your time on than the actual thing
oh you are creating folders recursively?? oh yea the folder doesnt exist so i cant create a folder inside that. you msut restart your computer to fix it. but have fun before trying that
Wouldn't it be nicer to work with if the buttons were togglable instead of always having to say that it's glowing or not glowing?
I mean most of programming is bug fixing. I hope you derive some satisfaction out of that
i know but so often the bug fixing is not even fixing what you done but rather some weird bug that is hard to reproduce, only happens to you or so, makes no sense
like that one
thats an easier one
error is not telling me to restart my fking pc
its fun when the production server crashes, because a list full of integers suddenly gets a string from the database
because at runtime its just a list of objects
have fun figuring that out
It doesnt matter now, i have tried to create command that summon armorstand with setGlow(true) AND still not glowing… using 1.20.1
There is so much staff i want to add - the togglable is good idea
type erasure is a nightmare
Sorry, but I havn't done any spigot for quite some time. I'll have a quick look at the code though
You have to restart PC if folder creation failed because parent doesn't exist ?
Thx, but as i said, event basic command that only summon armorstand with setGlowing(true) is not glowing
yeah thats odd lol
@zealous osprey this is not working too.. idk if they have change something with the setGlowing?... - all other is working fine - purpur block on head, etc
Correct. What its meant to do and normally does is: create folder1 then folder1/folder2 but what it did (maybe) create folder1 (which did nothing idk) then create folder1/folder2 and then say that folder2 cant be created because folder1 doesnt exist. This is just wasting time and not fun. Or the oh you want to call the method? Yea it needs to be on that line for some reason. The 1 single byte cant be different in the final .class file because else i wont work
- Split up the code, it's all just one huge function. It's hard to know what I'm looking at
- Imo, don't use
InventoryClickEventto figure out which inventory/menu the user has open. Give the player some kind of state when they open or close the menu - I think the issue lies in line 99:
if (event.getInventory().contains(Material.STICK)) {that's false I believe, since the confirmation menu doesn't have a stick in it.
Ahh, nvm, I just understood what you are doing there, very weird. Log what stand is in line 132.
i will try to improve it, thx, the stick is for different menu - arms - under this IF statement is else if that is checking the BEACON for glowing - line 118
try:
player.getWorld().spawnEntity(player.getLocation(), EntityType.ARMOR_STAND, (stand) -> {
stand.setGlowing(true);
});
What are u talking about
Lines in code have no meaning lol
Or I misunderstood u somehow
Is there a meta way to change the player's overhead name? I want the username of the player and its color to a non-chatcolor entirely. Is this even possible? Prefix and suffix support non chatcolors but not the main name. Currently using scoreboard teams for that
I swear that worked at some point. Then do ArmorStand armorStand = (ArmorStand) stand; above and replace with armorStand.setGlowing(true);
public static void updateTabList(Player player, Map<Player, Integer> players) {
Scoreboard scoreboard = player.getScoreboard();
for (Map.Entry<Player, Integer> entry : players.entrySet()) {
String index = String.valueOf(entry.getValue());
Team team = scoreboard.getTeam(index);
if (team != null)
team.unregister();
team = scoreboard.registerNewTeam(index);
team.addPlayer(entry.getKey());
}
}```
how often should i be calling this?
every tick, every second, every 5 seconds
yes, per-player-scoreboards
just set the board back to the main board when disconnecting or something
how?
if you're sorting tab lists, just do it on join/leave
when a player joins it doesnt sort it
or do i loop all players when a player joins
and resort it
player.setScoreboard(Bukkit.getScoreboardManager().getMainScoreboard()
event with your code its not glowing 😄
what
sorting is based off of some order (smt like alphabetical?) just set the player's team to aOwner and it will appear on top
sort on join/leave
what verison are you on?
1.20.4
im on 1.21 🤷
so like this in pseudo code?
when join:
loop Bukkit.getOnlinePlayers():
# resort tablist```?
yea
aight
using Minecraft Development plugin in Intellij or how is the plugin called
actually should i just set the player's scoreboard to the main board at the start of updateTabList
that's not relevant in any way lmao
yeah same, that shouldn't matter though
🤷
i am not talking to your thing... wer are talking about something different
can you send over your code @vague dawn
I was talking about some else. When I wanted to create a folder recursively (same as mkdirs and not mkdir) it always said that the parent folder doesnt exist so i cant create the next folder. I had to restart my pc to fix it. I wanted to show by this that i get random stupid errors that waste my time, make no sense, and are not logic
doesn't change the fact that it's irrelevant lmao
wtf bro
sure, here or to dm?
?paste it here
here
else if statement line 118 - there is the glow thing start 😄
that's one hell of an elif block
god DAMN
if (plugin.armorstands.containsKey(player)) {``` are you sure this is evaluating to true?
you can add a debug statement to the method getting run
i am mostly beginner, but all other functions are working fine - setArms or setBasePlate
Hey
If I use a sync task in an async task, will the async task wait for the sync task to continue the execution of rest of the code?
No
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
stuff.async1();
Bukkit.getScheduler().runTaskSynchronously(plugin, () -> stuff.sync1());
stuff.async2();
});
So in the code I sent above, the execution will be async1, async2 & sync1?
Technically scheduling a sync task async the synced task becomes async to the async task lol
I'm confused by what you meant here haha
Basically in the code you sent above
The asyncrhonous task will be scheduled
Once in the queue, after one tick the scheduled runs some method. Then a sycnrhonous task is scheduled for the next tick. Then your second method runs. As far as execution order we know this much
Async 1 must finish before the synchronous task is queued. The second method however might finish before or after your syncrhonous scheduled task. For example a database call that takes 25ms. It's likely your second method will be finished before your syncrhonous call. Given each tick is 50ms and scheduling a task delays it by atleast 1 tick any operation that takes under 50ms is almost guaranteed to finish before your syncrhonous call
If you want to await the syncrhonous call you'll need to make a callback, however having asynchronous code rely on some arbotrary sync operation seems like pretty shotty design
So after scheduling the sync task, no matter what happens in my async task, after one tick the sync task will run, even if async task is still running?
Yes all that does is schedule something
Got it
is it possible to set players in ServerListPingEvent with reflection or will i have to listen to the packet?
is github only for me down?
yes
It Does, every other thing works
Only the setGlowing is not working 😀
Thx all for help, i will try to mess with it
How could I get the current player without using a second param
object Placeholder {
private val server: Server = Bukkit.getServer()
private val player: Player? = Bukkit.getPlayer("Hyro")
fun parse(string: String): String {
var parsedString: String? = null
player?.let {
string.replace("%player_name%", it.name)
string.replace("%player_uuid%", it.uniqueId.toString())
parsedString = string
}
server.let {
}
return parsedString ?: string
}
}
please explain how you expect that to work
idk rad xd its not necesary ik
let is for transforming
to parse strings from the config.yml and replace that values
this is why new programmers shouldn't use kotlin
and how do you expect it to know the player without a second param
let as I know also execute that block of code if the player is not null
well yea it's also used for that
but let is usually used for transformations
e.g. val upperName = player.let { it.name.uppercase() }
a bit silly to do but yea
Why you asume that?
Taking notes thanks rad
and?
the examples here are a bit bad since that is pretty much what you should use also for
Idk, maybe you can handle a way to do it with no param
so you expect it to pull the player out of nowhere?
no, just asking.
you could literally just do
fun parse(string: String) = string.replace("%player_name%", player?.name ?: "%player_name%").replace("%player_uuid%", player?.uniqueId.toString() ?: "%player_uuid%")
but why are you not assuming the player exists anyway
the player should definitely exist since you just do nothing if it doesn't
i would just val player = ... ?: error("player is not online / not found")
(note that would just always have the player as Hydro)
yeah
if anything just take a player param as not null
^
You can either, create a new class for each player, every single time you want to use placeholders, or just deal with it and add a new param.
apply btw
mmh it returns this
well it's meant to be used for object configuration
like applying on an item stack
i will change my project's java version to java 8 because i want it works with all java versions (java 8,java 11, java 16...) so is there important features that not exists in java 8?
define important
someObject instanceof MyClass myClassObject
hmm, is there any different solution for this
multi java versions
because i want it works from 1.8 to 1.20
I'd say FFI is probably the only thing that can really be deemed as "important" by my books, but I'm rather extreme in my defition
if(someObject instanceof MyClass) {
MyClass myClassObject = (MyClass) someObject;
}```
Plus FFI is Java 22, so chances are you aren't aware of it
so you recommend me i can change it to java 8
i said about multi java version
Isn't that that language bridge thingy
You don't really need
Just use java 8, you won't lack that much
And what you will can be replaced in some other way
ok thanks 👍
There's also JPMS that is kinda difficult to emulate in J8, but that's even less likely to be used
MRJs exist, but you probably shouldn't be using it for syntactic sugar
JP-- what?
Java Platform Module System - Also known as Jigsaw
Tf does that do
Give classloaders names and ensure that internals are not be accessed by other modules
It's the thing responsible for locking down reflection access in the java.* packages
Reflection is locked down in java.*?
On modern versions of Java: yes.
http client, varhandler, text blocks, records, pattern matching, switch expresisons, nest mates, virtual threads, sealed classes, unix domain sockets, sequenced collections, and several api enhancements in methodhandles, nio, streams, concurrent collections or completablefutures, language enhancements on lambdas, and others
those are all things i'd miss across several plugins and/or other programs if i decided to use java 8
not applicable to plugins but we do make use of jpms at work :chefskiss:
Aren't most of those features in java 8? Or is there something incomplete about them?
no
Unless you use --add-opens java.base/java.lang=ALL-UNNAMED or similar
that's why i'm listing them
Http client, varhandles, virtual threads and unix domain sockets are good ones - yeah.
Although unix domain sockets are rarely going to be used. And Varhandles are great for lower-level field access/write control but probably not going to be used by the average person
that's fair
I love VarHandles :(
Can we appreciate the jvm speedups in later java versions too :3
Faster reflection go brrrr
MethodHandles, anyone?
:nodders:
MethodHandles are also great
Java even inlines MH invocations in stacktraces - do you know how cool that is?
I don't really use the reflection api much anymore
Even tho it's internals now is just MH
My only complaint of MethodHandles is "throws Throwable"
its* ☝️ 🤓
Literally devastating
Shut
Hello, how can I add a custom biome to world gen ?
I followed this tutorial : https://www.spigotmc.org/threads/how-to-create-custom-biomes.512105
You can also do funky stuff with MH like construct loops, do try-catch logic and more purely at runtime
someone woke me up
was it your neighbour with a drill?
it was someone talking about methodhandles
Just don't get me started on runtime class transformation or maven artifact resolution ;)
thats because of a cached runtime archive :)
whar?
cds?
that is an important part, but there are several more reasons than just that
ofc
cds is very cool
wait those things are actually being used?
Well that explains why that file is already 100 MiB large
what jmods or cds?
For JavaFX, yes - but I never looked into them afterwards for that reason
cds
its just a bunch of jsa files which are dumps from the vm
JFX in it's modern iteration is a mistake.
like ImmutableCollections.EMPTY (or smth) and stuff is initialized from there
in order to avoid loading trusted classes multiple times
Whatever jsa stands for
I always assumed that was an antique feature that is no longer being used
And from the looks of it only my Semeru installation makes use of that file, so I'm kinda right?
(Sorry for interrupting this very interesting conversation that started with reflections but has devolved for i dont even know what)
I have a plugin project that uses a lot of NMS, but its using Spigot mappings which are admittedly lackluster. Is there a way to automatically change all my references to NMS code from Spigot mappings to Yarn mappings (or Mojang mappings, but Yarn mappings are more cohesive) and then convert them back into Spigot mappings on build?
just grep for occurances of CDS.initializeFromArchive(class) in the hotspot vm
Tbh, startup times have never been really a concern for me. If they were I'd probably try to figure out how to reduce them further
That's what a remapper is for
Is there any specific remapper you recommend?
No, Idk any
Well, any that do stuff automatically
For yarn - probably not the case - I'd avoid using yarn in the world of spigot regardless unless you are really familiar with them.
For mojmaps - there are a few ways there; mfnalex has a blogpost somewhere about it and paper's paperweight's userdev plugin are also a thing
I do have a project to use yarn with spigot in plans but it's probably gonna be out by 2026 considering how many projects I have
Remapping of source code is not a thing in spigot world - given that the only project capable of doing that is mercury and it probably has it's flaws. Plus, there is probably no good implementation for spigot
?mojmap
How to prevent the dragon from launching other entities into the air and dealing damage to them(canceling entitydamagebyentity doesn't help)?
?nms maybe?
Is it that?
yeh
I just searched #bot-commands for it lol
Though I'd have my concerns about the gradle section :p
The gradle sections lgtm
I have these channels muted and forget about their existence most of the time
Yeah, but it's not using paperweight
yeah i saw that, but it looks like i have to manually refactor every instance of using nms in my code. is that correct?
Though uh, that post is meant for spigot first and foremost
I wonder why the remapper needs to manually get the version set
yeah sounds like it
Sure but why use paperweight when you can run into issues where paper exposes a field but spigot doesn't
Design choice that remapper isn't specifically for spigot
Yes, although you could probably automate it, writing such an automation tool would probably take longer than actually doing that treadmill work
Though its probably where it's mainly applied
We need one designed specifically for spigot
Spigot Loom
When
Never plus I would probably not use a project you developed unless it was extensively tested
Yeah, I'd do it using gradle configurations but that's a question of choice mostly
could i compile my plugin, remap it, and then decompile it
That's a bit... Insulting?
i know its a bit of a dumb idea, but i think it might work
Yeah but that will mess up some code
Yeah but it'll cause some decomp errors you'll need to fix
For example: enhanced for loops will become some var1, var2, var3 witchery
yeah but thats fixable
Yeah everythings fixable
What's the purpose of compile remap decompile though
You can remap non compiled jars
can you tho?
You can remap .java if you wanted to
I will fuck your mom in kotlin
ok
I did that once with a forge project but that had unique method names
i havent really done anything with mappings in the past unless it was all done for me like in fabric mods
Idk if there are any current tools maybe mappingio by fabric? But otherwise you'll nee to roll your own
Tiny remapper is a thing
Or specialsource
both of those hit a jar though
oh right
Generally it's easier to remap a jar because asm gives you a nice tree
Ig you can write software to give you a tree from non-bytecode too
But that sounds a bit painful
Idk having to patch my own code also seems annoying and painful
where can i get the mapping files for specialsource? theres a repo that does transative mappings like spigot->yarn but it hasnt been updated in a while
Why would you ever want to use yarn
?stash
Inside BuildData
I have a tool to generate mapping files from many other mapping files and I have ran it through so much shit it definitely has to work but it does not support tiny v2 lmao
i like yarn better. it has more understandable names and i also used to make mods
You can also just navigate to your maven local org/spigotmc/minecraft-server for mapping files
Yarn is also incomplete though
Mojang provides the full mappings of names they use for methods and fields
Spigot and mojang mappings in it
And also for all versions you built with --remapped
they dont have argument names for a lot of methods
im willing to use mojang but i prefer yarn
Can we get parchment for spigot
amen
It's not that bad probably
Just use fabrics tools
And roll your own nms system
where can i find other versions? my project is in 1.20.6 updating it to 1.21 is the whole reason im tryna switch mappings
thanks
You'll need to use the git refs to clone
I had a tool for downloading spigot mappings of any version
lol
It is called very self-explainatory: spigot-mapping-downloader
i got it
This kid has a tool for everything under the sun
but not a single one is on his github
Don't call me a kid please, I just worked with mappings a lot
It's on my orgs github, https://github.com/SpigotCVN
even my dog
Damn kid calm down

okay I will not insult anybody here just because you dropped a schnitzel

perchance do you have a tool that just upgrades versions and i dont have to worry about mojang or yarn mappings
That's nearly an impossible ask unfortunately
I had planned a tool called spigot loom but I will most likely start in like 2026
why? just do obfuscated 1.20.6-> mojang (which is pretty much version agnostic) -> obfuscated 1.21
that was in reply to y2k
Mojmaps can change, you'd be better off using something like intermediary
Mojang is still adding and removing stuff
yeah but a lot stays the same
I just copy and paste your module
And do a replacement
Lol
That's what I do lmao
Or don't write obfuscated
oopsie daisy
I really need to make a tool that can parse java code and then turn it into a tool to remap java code
A Sweet Tropical Spigot Library. Contribute to PineappleDevelopmentGroup/Pineapple development by creating an account on GitHub.
@shadow night hows cvn doing?
It's fucked
how wonderful to hear
Lmao
wait this is totally off-topic, but i dont need to shade brigaider, right? its alr in the sevrer
Yes
yes as in i dont need to shade it
No
No need to shade it
alr thanks for the clarification
forgot to add <scope>provided</scope>
wait i dont even have to worry about my source code i can just build it in 1.20.6 for eternitiy (until it inevitably breaks) and remap the compiled jar
its not a good idea but it can be done
Np