#help-development
1 messages · Page 1863 of 1
and then if it manages to not crash, crash anyways by pushing a block outside the boundary
Just as it should be
Do you wanna share some or do you have some specific tips, I am highly interested?
Pushing tile entities should be possible server side
They may not render in motion on the client, but eh
No, thats good.
wot
bunch of packets ig, yea?
oh spigot jar is better?
but can anyone answer me heh
do nested/inner record needs to be static?
Then you make a new eclipse project like in the shown above tutorial.
Then we will really have some flying carpets 😄
Yeah
Quark already does this with a few mixins
So it should be easy enough to do as a CB patch
When you click on Spigot, is there another jar file?
the spigot folder?
depending on the version the tutorial is for, what they see could be different
the tutorial is 1.18.1 but im doing 1.18
so for example if I think I have a section of my code that seems to be a detached component, say database, I might think of isolating that component, allowing only one class to communicate with the rest of the software, which is facade pattern
but I don't sit down and think that I need that pattern
Then just change the steps a bit.
Yeah.
Let’s say I gave a player a block with the persistent data container of a key and the string key is hello
Is there a way to see if that key is there / get it if the block was placed and using the playerInteractEvent
Would event.getBlock().getMetaData work or no?
PDC is in ItemMeta
@jolly inlet what do i do if the craft bukkit is missing
I see. Is there anyway to assign a value or data to that item and when they place that block/item I can check that blocks value when a user right clicks it via the event
do i need to run the batch file again with craft bukkit specifications
Why is nms bell class implementation missing :'(
BellBlock?
It's called BlockBell if you're using Spigot's maps
net.minecraft.world.level.block.entity.BellBlockEntity
I assume it is the same thing
Those are the implementations
I can find other classes' implementation other than bell in that package...
As in the methods' implementation
Yes...? BlockBell and BellBlockEntity are the implementation classes.
That isnt what i meant
Im looking for how are the class's methods implemented
Or simply, the java file
I don't understand what you're asking for. Where the methods are called? The package that contains the BlockBell class file...?
So open the file LOL, I told you what it's called
You see, I can see how Beacon's method are implemented
You want this?

send me lmao
net.minecraft.world.level.block.BellBlock, you're in the wrong package
It's not in entity
still
But there is indeed a BlockBellEntity class in the entity package, cuz I can import that class
Well now how did you manage that
What version are you using?
and this is the one im looking for actually
Hm weird, well if you end up needing the BellBlock you might just want to refresh your dependencies. It should be there.
Bells are tile entities?
No
BlockBellEntity says otherwise
The classes can be imported just fine
Oh yeah I guess they are
Welp anyone with the java file can send me plwase
I try running buildtools one more time
Hey guys im trying to make it so that players on the same team can see each other glow, https://www.toptal.com/developers/hastebin/sevixikujo.swift
The part of the code that is not working is line 48 as this error keeps on popping up (Error about datawatcher not existing anymore), how would I be able to fix this?: https://www.toptal.com/developers/hastebin/ajehoxifik.apache
Logging on, my friend can always see me glow
But I can never see him glow
I assume if the part that was throwing the error worked, he would see me glow as well]
You sure
?jd
This can set glow for specific players only?
In mysql is it possible to only allow row selections through specific columns?
like if I have an "ID" variable am i able to make it so users can only retrieve rows through the ID variable?
SELECT Id FROM TableName
I meant like, set up a table so that rows can only be retrieved by certain columns
cause doing SELECT * FROM TableName will display everything
id like to make it so people can only do Select * FROM TableName WHERE ID=?
Don't think you can with just SQL
Make an API to access the table
But you can limit them to interacting with it through an API
Like a web api?
Yes.
I don't know of any SQL server implementations that allow per-column permissioning for visibility
im pretty new to SQL so i was just wondering if it was possible
time to learn JS for the api ig
What? XD
You don't need javascript to make a web api
oh i thought you did
Web APIs can be written basically every language
What are you most comfortable with?
Java
Great, I there are a bunch of great Java web APIs
yeah ill see if i can learn some of it
Javascript, often short as Java
If you're looking for something with built in super easy sql support, you can use something like Spring https://spring.io/projects/spring-boot
he probably want to use java script not java lol
He said he prefers Java.
ive done web dev stuff with js but im much more familiar with java
so if i can do it in java ill choose that
my main is greyed out and the server isnt seeing my plugin
ive had this problem before but i forgot how to fix it
Check your plugin.yml
Send it here
name: Vanish
version: '${project.version}'
main: me.gamma.vanish.vanish.Main
api-version: 1.18
load: STARTUP
authors: [ Gamma ]
depend: [ProtocolLib]
did u try launching it?
What build system are you using?
Zip the whole project, send it here
@tidal skiff thats fine it should still run when you compile
its grey because its not used anywhere in the current project but will be used when the plugin launches
Right click on the project in the right hand navigation menu, then click "Open In > File Explorer"
in my other plugins its not greyed out and they always work fine
do you have any static variables that you use?
Just try running it on ur mc server, itll run
i have
Does it run?
Clearly not
lmfao
i dont understand
mind sending the jar?
do you mean left hand
sure
wont the jar corrupt if you send like this
nah
it was gonna be a vanish plugin originally but i started following a protocollib tutorial lol
just ran this on a server, it works fine
same for me
my server is just a little special
ill try restart it
Is the problem that you're having that your messages aren't being sent to you?
I promise you that the greyed Main class isnt an issue
yeah
itll be an issue if there is an error in the console saying something about the plugin.yml not registering it properly
You might be using the ProtocolLib API wrong
Today's mood
Send the part you have with the lambda
Just that whole onEnable block, even.
@Override
public void onEnable() {
ProtocolManager manager = ProtocolLibrary.getProtocolManager();
manager.addPacketListener(new PacketAdapter(this, ListenerPriority.NORMAL, PacketType.Play.Client.POSITION) {
@Override
public void onPacketReceiving(PacketEvent event) {
super.onPacketReceiving(event);
PacketContainer packet = event.getPacket();
Player p = event.getPlayer();
double x = packet.getDoubles().read(0);
double y = packet.getDoubles().read(1);
double z = packet.getDoubles().read(2);
boolean isOnGround = packet.getBooleans().read(0);
p.sendMessage("INBOUND PACKET - x:" + x + " y: " + y + " z: " + z + " On Ground: " + isOnGround);
}
});
}
Impressive
I'm Notch
You probably want POSITION_LOOK and POSITION
Well, the client can send a couple different movement packets
Position look is when you move and turn at the same time. Some MC clients send this all the time instead of just the move
im using badlion so ill try that and see if it works
if the client sends exclusively only sends pos_look, most definitely a cheater..
Factually incorrect.
ik
???
?
still nothing
noob mistake most likely, but trying to setup spigot w/ gradle on eclipse, but i get the Unresolved dependency
maybe i forgot something? like running buildTools (but at where should i run it?)
r u specifically trying to use spigot instead of spigot-api?
How about LOOK and GROUND?
ok i fucked something up LOL apparently you need protocol lib in the plugins folder
--uh
i just had it in the build path
u kinda need it
Yes you need to run BuildTools, run it anywhere on your computer.
Factually incorrect!
ok well we're closer but now protocol lib is broken
I mean as long as it isn't somewhere like OneDrive
how 2 nms without buildtools? smh
Which isn't technically on your computer, doesn't really matter. 🤷♂️
compileOnly 'org.spigotmc:spigot:1.18-R0.1-SNAPSHOT'
should likely be
compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT'
Reflection.
yeah but how tf u gonna know what u need without first looking at nms
i was reading off the documentation -- but if i was to
now we're even further
Remember to filter the packet types in the listener, as they do in the ProtocolLib example
create a minigame, say, then shuoldn't i also be doing server logic, hence i should need spigot instead of spigot-api
You don't need to add the dependency to your classpath to be able to reference the NMS.
not to directly access at least, ik
i checked the error apparently its something to do with this line ProtocolManager manager = ProtocolLibrary.getProtocolManager();
You don't need the underlying implementation to make a minigame.
It might have to do with the fact that your plugin is set to run pre-world, isn't it? Check your plugin.yml
oh probably
Then you don't need the whole Spigot JAR to be in your build path.
but what if i wanted to directly access nms components
i set it to post world, same thing
Without reflection? What sort of bastardized techniques are you planning?
pure torture
Reflection library.
Why in the hell would you use reflection instead of just adding NMS into your classpath
reflection is torture in its own right, but working directly is more fun
It looks like that error is from accessing invalid stuff in the packets, though I'm not ProtocolLib guru.
I'd try filtering the packets like they GitHub for ProtocolLib examples show:
// Disable all sound effects
protocolManager.addPacketListener(
new PacketAdapter(this, ListenerPriority.NORMAL,
PacketType.Play.Server.NAMED_SOUND_EFFECT) {
@Override
public void onPacketSending(PacketEvent event) {
// Item packets (id: 0x29)
if (event.getPacketType() ==
PacketType.Play.Server.NAMED_SOUND_EFFECT) {
event.setCancelled(true);
}
}
});
Cross version compatibility
Doesn't change too much.
I don't support cross versions, any other reasons?
cross versions would be the only reason to use reflection over just adding nms to classpath
This guy doesn't support cross version compatibility. Pleb hours.
😛
Why should I?
the only version i need to support is the one i run
i just made a core that handles all my cross version stuff
Directly accessing the underlying implementation of the Spigot API is a forbidden technique. In a perfect world, everyone would just use the Spigot API and nothing more to support non-NMS server implementations.
Then when you need to update to a newer version you'll be crying changing all of your imports from the old to the new lmao
yea, well i very often need to access it lol
Second monitor.
fueled by depression, what can i say
no monies or desk space
Step one: job. Step two: new desk. Step three: extra monitor.
already did step 1
Why shouldn't you?
living is just expensive 😦
Sacrifice food for a new monitor. Praying for you from a distance.
Why support outdated software? Far more work for extremely little gain considering most people either use latest or 1.8.9
u drive a hard bargain
Not outdated software, newer versions. New stuff is constantly getting released.
I try to always avoid reflection and instead i end up just having a core with this
Everything is expensive and I’m not even having a good time
I have cancer from looking at this.
straight up not having a good time
Yes, I only support latest. Did you think I developed against 1.15 and just stayed on it? 
after its all added it really isnt hard to maintain
I update my stuff with MC, and drop old versions.
all you do is add a new folder for new versions
Yeah, but it is shit design.
Modules > Reflection
and it runs much faster than reflection
Bloatware hours.
just about anything will
Factually incorrect, you're just using reflection wrong.
:/
that’s just not true
reflection simply can not run as fast as direct access
Even if reflection is faster in modern java versions, it will never be as fast as direct method calls
it may come close, but thats all it ever could do
My trust in what bk says: 📉
cant say i had any, im just here for the ride and to keep the party goin
You could slim down on it substantially, meaning that it is bloat. A little reflection goes a long ways.
Spigot switching from Java 8 to Java 16 did force me to change how i handled my multiversion support
Okay but like
but thats about the only issue i had
Who cares about a few kB
i had an outdated version of protocol lib
rip
woo
Reflection: 1,777,003,600 nanos, non-reflection: 1,422,204,200 nanos
One million runs.
for what?..
what benchmarking are you using?
one sec
Printing to console.
ill write a benchmark
public static void main(String[] args) throws Throwable
{
Field outField = Class.forName("java.lang.System").getField("out");
Method printMethod = Class.forName("java.io.PrintStream").getMethod("println", String.class);
int runs = 1_000_000;
long totalReflectionNanos = 0;
for(int i = 0; i < runs; i++)
{
long startNanos = System.nanoTime();
printMethod.invoke(outField.get(null), "Gaming! (reflection)");
totalReflectionNanos += System.nanoTime() - startNanos;
}
long totalNonReflectionNanos = 0;
for(int i = 0; i < runs; i++)
{
long startNanos = System.nanoTime();
System.out.println("Gaming! (non-reflection)");
totalNonReflectionNanos += System.nanoTime() - startNanos;
}
System.out.printf("Reflection: %,d nanos, non-reflection: %,d nanos%n", totalReflectionNanos, totalNonReflectionNanos);
}
I'd recommend JMH as it shows more accurate results
Then you're not doing it right.
not entirely true
a good abstraction of ur reflection can make it look tolerable
and also, how is that faster
Fair
It isn't. It is roughly the same.
ah so wait
Actually no, the server still runs obfuse
ah right sorry
forgot less was better
benchmarks immediately make me go into an op/s mode as opposed to an s/op
😂
You're looking at about a 350ns difference between reflection and non-reflection on average
Isn't that 350ms...?
and also JMH is still going to be more accurate
350ms??
Doesn’t reflection break often now since spigot no longer maps anything?
Fuck no
Divide by one million for the one million runs
That would be truly insane
We really going to pull out the method lookup here? Maybe the invokedynamics it will compile into will make it faster since the JVM caches the call lmao
Reflection is going to use method handles internally in j18 I believe
Fancy
ah yeah I saw that JEP
Just to reduce the surface area of the jvm
'twas cool
also technically means reflection is gonna be somewhat faster
Or is this not how it works? I haven’t really reflected anything since the removal of spigot mappings
I say "somewhat" cuz I dunno how they're gonna do caching
Not that reflection is all that slow
in newer versions*
HotSpot 😖 😫
There is essentially no reason why you shouldn't use reflection in your code when dealing with NMS
It is just the best choice.
There is essentially no reason why you should use NMS
It is just the best choice.
But what if the obfuscated method name changes from a to b
Factoids. See my earlier message.
The names change constantly
Not by that much lmao
What if the server impl changes drastically?
bk I'm sorry but the way you talk is so pretentious
Two different modules.
I'm typing, not talking.
Not by that much means they still change
They can.
So you would need multiple modules anyway
Incorrect. One module.
Yeah man you're only proving my point here
Shut up, baby, I know it!

A form of talking. Free speech applies to written words, therefore "talk" applies to "text."
hey shawty i think ur program made a mistake
i thought reflection was supposed to be faster
*about the same
The situation that is being tested is not really comparable to what would be done in normal plugins
Over a million trials on your slow boy computer ;)
The small difference matters when you start doing it in hot locations
<5% difference
Not so much.
what r specs u benched on?
I typically love to over-optimize.
Me too
There's something fun about making a program run in literally like a few milliseconds.
But at the same time I love my super high level abstractions with reflection
I go both ways I guess
5950x, 64gb @ 3666mhz, 5800xt, and a 980 pro
You wanna over optimize my task that melts and places snow?
ryzen 9 3900x
Going from a 3900x to a 5950x is like going from a Honda to a Ferrari
have some class, its more like a supra to a lambo
It is at least one third faster lmao
Then you starting looking at the cores, and, well...
The "print two million 'Gaming!'s" benchmark speaks for itself.
What'd yours take, less than 2 seconds each?
I also ran my benchmark in the IntelliJ runner, which is notoriously slower.
Let me take a run in my terminal
And theirs took, 40+ seconds each?
Yeah yours might be a tad faster. 🤏
Something like that, yeah
ah, java 8 is slow as fuck
my results still didnt improve but
at least it hit sub-30 now lol
Speed running 1 million "Gaming!" prints
xd
clearly our good main man bytekilo is just very bad at programming
What the fuck is a java
a cofeee
reflections any%
Is it a glitchless run
They're allowed
Time for some backwards long jumps
o.O
I ACCELERATED BACKHOPPED ON YOUR MOTHER'S FACE WOOOO
System.out.print("Gaming!\n".repeat(1000000));```
Would be faster than looping println because no flushing in between
Engineer Gaming
Genius
That’ll be a big boy string
Ruined with nerd explanation 
anyone ever new BufferedWriter(new OutputStreamWriter(System.out))?
rip lmao
does listening for packets have to be in the main class? im trying to do addPacketListener() in a new class and its just saying it doesnt recognise the symbol
or it cant resolve it
No
As long as you have the protocolmanager
is intellij idea ultimate worth it?
ehhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
just get the community edition
need to add the import for it
Reflection: 1,762,114,253 nanos, non-reflection: 1,968,469,980 nanos
^ my results in console
you have to verify your forums account
i already have, but i am interested as to if it is worth it
which is stupid because ive never posted to the forums and am not planning on it
gaming chat
guys dont say the ch word its banned
Children
chad ?
get him outta here
cheese
no, **eese
eese?
dont say ch**se or the mods will get mad
Wack.
Beat... what?
your mom
It is the method caching
"I somehow managed to completely divert the topic of conversation with cheese." -Maow, 2022.
God bless invokedynamics
methodhandles r just 2 stronk
What is everyone doing?
This guy wants to be spoonfed
🥄
lucky for him i want to be a milf
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.reflect.*;
public class Reflector {
public static void main(String[] args) throws Throwable {
Field outField = Class.forName("java.lang.System").getField("out");
Method printMethod = Class.forName("java.io.PrintStream").getMethod("println", String.class);
MethodHandle methodHandle = MethodHandles.lookup().unreflect(printMethod);
int runs = 1_000_000;
long totalReflectionNanos = 0;
for (int i = 0; i < runs; i++) {
long startNanos = System.nanoTime();
methodHandle.invoke(outField.get(null), "Gaming! (reflection)");
// printMethod.invoke(outField.get(null), "Gaming! (reflection)");
totalReflectionNanos += System.nanoTime() - startNanos;
}
long totalNonReflectionNanos = 0;
for (int i = 0; i < runs; i++) {
long startNanos = System.nanoTime();
System.out.println("Gaming! (non-reflection)");
totalNonReflectionNanos += System.nanoTime() - startNanos;
}
System.out.printf("Reflection: %,d nanos, non-reflection: %,d nanos%n", totalReflectionNanos,
totalNonReflectionNanos);
}
}```
Catch me doing sub 1 second times with this
the findVirtual shebang
i only know unreflect idk
o.o
I'd write one myself but I don't feel like getting on my laptop
sorry i dont work with reflections
as it was typically inherently slower on the version of java i worked with
After using the IntelliJ console, I was able to get:
Reflection: 546,855,325 nanos, non-reflection: 348,793,429 nanos
I didn’t even know about method handle until now
tfw you're printing different length strings in your benchmark
nooooo
Okay, asshole, I'll change it.
also not using JMH still
theyre a pretty solid way of making ur reflections a little quicker
also I wouldnt be using an io method as a benchmark if youre not intending to benchmark io
not a little, a lot
now generate code at runtime with asm
These are the facts, though.
wait wait no wait god fuck
I can do that
true
i know of a few kotlin librarys that can do that
noooo
Damn! IntelliJ really has my terminal beat right now in I/O speed.
kotler 🙄
I now know method handles
ByteBuddy 🤝
what is kotler
I’ve thought about using asm to modify internals, but it scares me
Using the same cp entry, results:
Reflection: 355,034,239 nanos, non-reflection: 318,455,707 nanos
So I’ll probably stick to modifying spigot
it's not technically possible
Why not
Ah
well
This seems like it is factually incorrect.
Spigot internals, not java
I mean the classes can
but not the Java stdlib classes
there's safeguards against it in instrumentation and classloading
Mixins for spigot when
Mixins are great
I wuv mixins so much 🥺
Jeez, if you like them so much then go program in C# and get extensions instead lmao
but that's not how that work
oh actually same
Hm?? How what works?
I've only used like IL injection tho
can you modify existing class behavior with extensions
I'm pretty sure extension functions are just
Don't quote me on it, but yeah
"secretly this method belongs to this class instead of the other one >:)"
Not so secretly when the location of the method call is explicit in the binary ):
Some guy named Dort is already trying to do that to me
Speaking of which, time to go make fun of him for trying to dox me. Back later.
well you just gotta keep track of all your witnesses
thankies uwu
:3

back
ummm what?
you heard me
As their name says, consider them OP
answer the question stranger
ok, so basically you know how a massive percent of people on this earth believe in god?
well basically im god
but better
no I am
Consider_Me_OP = god + 1
are you trying to steal my identity??
i am better than god, you can feel free to be one below that though 😛
im not fighting for the role of god
im not god
im better
was about to throw my pc out the window only to remember i forgot to run javac before running java again
:/
do it anyways
anyway
then
You fuckin what mate
I haven't said "what" out loud in
a long time
in response to a public message
in a public server
y'know what I think I'm taking that W now thank ya very much good sir
you lose via the power of rape
what? XD
did your hearing improve? o.o
you cant rape me, im the best + 1
hmm
just "the"
what?
mhm
I'm crowning myself the best^2
cant too busy optimizing reflection benchmark
I dont need a crown to be the best 😎
it's an expression, loser
public class Benchmark {
public static void main(String[] args) throws Throwable {
int runs = 2_000_000_000;
Method method = Benchmark.class.getMethod("addTwoNumbers");
long totalReflectionNanos = System.nanoTime();
for (int i = 0; i < runs; i++) {
method.invoke(null);
}
totalReflectionNanos = System.nanoTime() - totalReflectionNanos;
long totalNonReflectionNanos = System.nanoTime();
for (int i = 0; i < runs; i++) {
addTwoNumbers();
}
totalNonReflectionNanos = System.nanoTime() - totalNonReflectionNanos;
System.out.printf("Reflection: %,d nanos, non-reflection: %,d nanos%n", totalReflectionNanos, totalNonReflectionNanos);
}
public static void addTwoNumbers() {
int k = 1992131 + 1235431;
}
}
Reflection: 2,237,045,200 nanos, non-reflection: 1,272,700 nanos
XD
almost as sexy as me!
nepotism
reflection is just slow..
and that's why you're not the best ^
reflection can be just as fast as direct access if done properly
find a way to make reflection anywhere close on this
I'll wait
challenge accepted
🍿
depends
recursion can sometimes be faster
i managed to break it
send code
my reflect time is reporting 34mil NS but the program time in total is like 2s
wait
just send the printed line
:/
public class Benchmark {
private static int added = 0;
public static void main(String[] args) throws Throwable {
int runs = 500_000_000;
Method method = Benchmark.class.getMethod("addTwoNumbers", int.class, int.class);
long totalReflectionNanos = System.nanoTime();
for (int i = 0; i < runs; i++) {
method.invoke(null, 1992131, 1235431);
added = 0;
}
totalReflectionNanos = System.nanoTime() - totalReflectionNanos;
long totalNonReflectionNanos = System.nanoTime();
for (int i = 0; i < runs; i++) {
addTwoNumbers(1992131, 1235431);
added = 0;
}
totalNonReflectionNanos = System.nanoTime() - totalNonReflectionNanos;
System.out.printf("Reflection: %,d nanos, non-reflection: %,d nanos%n", totalReflectionNanos, totalNonReflectionNanos);
}
public static void addTwoNumbers(int first, int second) {
added = first + second;
}
}
there, i changed it up a little
Reflection: 2,444,041,600 nanos, non-reflection: 9,794,300 nanos
why are we measuring in nano seconds?
bc thats how we started
Accuracy
using shit like System.out.println() to benchmark it is meaningless. 99.9% of the time is going to be spend running the code inside of the method
it all started with this
and 0.01% of the time will be spent actually calling the method
so ofc the times would be close
it means nothing to do it like that though and doesnt show the speed difference
import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
import java.lang.invoke.MethodType;
import java.lang.reflect.*;
public class Benchflect {
public static final MyClass myClass = new MyClass();
public static void main(String[] args) throws Throwable {
Field mcField = Class.forName("Benchflect").getField("myClass");
MethodHandle mh = MethodHandles.publicLookup().findVirtual(Class.forName("Benchflect$MyClass"), "sum",
MethodType.methodType(int.class, int.class, int.class));
int runs = 500_000_000;
for (int i = 0; i < runs; i++) {
// JVM WARMUP
i++;
i--;
}
long reflectTimeNs = System.nanoTime();
for (int i = 0; i < runs; i++) {
mh.invoke(mcField.get(null), 127 + i, 127 + i);
}
reflectTimeNs = System.nanoTime() - reflectTimeNs;
long nonReflectTimeNs = System.nanoTime();
for (int i = 0; i < runs; i++) {
Benchflect.myClass.sum(127 + i, 127 + i);
}
nonReflectTimeNs = System.nanoTime() - nonReflectTimeNs;
System.out.printf("Reflection: %,d nanos, non-reflect: %,d nanos\n", reflectTimeNs, nonReflectTimeNs);
}
public static class MyClass {
public int sum(int a, int b) {
return a + b;
}
}
}``` 😎
:/
oh oh god fuck oh shit oh no i forgot to warm up 127 + i
I love seeing code in this channel, because I always learn little things I’ve never encountered before
use jmh
Like %,d
i didnt know %n was a thing, i always used \n
I didn’t either
are we trying to prove reflection is slower?
The original claim was that they were almost the same
this is all thats needed to prove it
its nowhere near as fast
yeah, it didnt click that my reflect test was /right/ (using this term loosely with improper benchmarking) when i thought the difference was too large to be accurate
i forgot how small of a time scale i was working with
I didn’t think so
not usually, depends on what you are using the reflection for.
Reflection is better than it used to be, but it’s still not the same
it all started over whether u should include NMS in ur project or access it reflectively
Although now I know to use methodhandle in the future
oh yeah defo
😎
MethodHandles r the fucking boss when it comes to reflection
Well, you should only use reflection if you need to.
the only time you should need to is if you need to access something that is private
Some people say you should use it over this
if reflection was faster I would use it
however since it is not, i see no need to use it
what are we trying to benchmark this time
?jd
Reflection
oh boy
Benchmark Mode Cnt Score Error Units
Benchmark.testNormal thrpt 25 4067349252.773 ± 37683002.671 ops/s
Benchmark.testReflection thrpt 25 107593929.401 ± 744853.491 ops/s
those are my results
yours done?
?paste
the code i used for my test as well
ignore private static final int runs = 250_000_000;, it was not used at all in there
Either the benchmark is set up incorrectly
OR
reflection is an order of magnitude faster
send your code
mine is here, its a really straightforward test
and reflection is 40x slower
I did the sum test that Alerithe did.
Also you're using traditional reflection lol.
This has the benefit of lookup being resolved once per fork (process of the JVM started by JMH)
hey is it possible to remove a crafting recipe from game?
(which is also conventional for method handles btw, you should typically store them as static fields)
aand it makes use of Blackhole to avoid compiler optimizations
Benchmark Mode Cnt Score Error Units
Bench.Benchmark_Direct avgt 25 ≈ 10⁻⁶ ms/op
Bench.Benchmark_Reflect avgt 25 ≈ 10⁻⁵ ms/op
Afaik this may or may not be accurate, I'm not a JMH professional, but
direct access and method handles are essentially equivalent in speed
method handles are used commonly by the JVM's dynamic operations and in fact by lambdas
lambdas use invokedynamic + LambdaMetafactory
LambdaMetafactory links a MethodHandle to a specific functional/SAM interface
Oh yeah this is also in Java 17
Alerithe didn't take advantage of Java 9's VarHandle
was able to use a lambdametafactory correctly once and only once
And modern Java includes even more optimizations over reflection
and god do i wish i kept that code somewhere
Hell you can skip the resolution overhead here with LambdaMetafactory but it doesn't matter as it's not factored into the time.
So yeah, @dense kestrel, reflection can be fast :)
i'll address this tomorrow
i have work in the morning
im going to bed
How can i set the playerskin using url? i mean how can i get the signature of this skin.
how can I reload my custom config?
This is what I have for it, config file being the File and dataConfig being the FileConfiguration
public void reloadConfig() {
if (!this.configFile.exists()) {
saveDefaultConfig();
return;
}
if (this.configFile == null) {
this.configFile = new File(plugin.getDataFolder(), fileName);
}
dataConfig = YamlConfiguration.loadConfiguration(configFile);
}
bungeecord?
@dense kestrel @lavish hemlock ive managed to make something that clocked out all around the same test time.. no jmh tho
spigot
just use the reloadConfig method of the main class
smh
it's there because you extend java plugin anyways
you cant use the reload config method of the main class on a custom config file
What doesn't work?
It doesn’t reload any new data entered, it just will check if theres a file and if there isn’t it will create the new file. It’s supposed to load the newly edited data
The
if (this.configFile == null) {
this.configFile = new File(plugin.getDataFolder(), fileName);
}
is bogus as you already tested the nullabillity of configFile via this.configFile.exists()
Yeah I was had that in there as a test while trying to see what was up must’ve forgot to remove it
i have made a command which will summon a sign and the text you wanted but is only works for one world at a line is there is any way so that player can write whole sentences
You can change the line based on how much text is entered, I believe that the max characters per line is 12 but I could be mistaken so you can check if the message the player wants is greater than 12 characters, and if it is then switch to the next line up to 4 lines
And when adding the text to the sign if the player enters a set of characters like “/n” you can addd a new line
Atleast that’s how I’d go about it
ok but i am talking about that i have made a comand /sign and if u type /sign 2 hello then it will summon a sign with that text in line no.2 and i want to make is so that if they type the whole sentence like /sign 2 hello there it should summon a sign like that but i cant do that so i need help in it
writing a sentence on a same line
\n
Oh alright, so in that case you can use the args part of the command and do I believe args.length to get the a number of args in the command and then make a loop or something that will add each of the args up to the given length of the command message, keep in mind that you already used args[0] so it Would be 1 and up
But that may not be the best way possible but should work none the less
Ahh always forgot if it’s a backslash or slash
it really easy to remember
Don’t use it enough for it to be in my mind
Hello! i have a problem
I have a code that reduces the damage that a mob does to a player, but when the mob is from other plugin (MythicMobs) the damage keeps and doesn't reduce.
Here is my code:
@EventHandler
public void onHit(EntityDamageByEntityEvent e){
Entity player = e.getDamager();
Entity victim = e.getEntity();
ArmorStand armorStand = (ArmorStand) player.getWorld().spawnEntity(new Location(player.getWorld(), 100, 700, 100), EntityType.ARMOR_STAND);
if (e.getEntity() instanceof Player) {
System.out.println("1");
double calculation = plugin.data.getDefense(player.getUniqueId()) + 100;
double damageReduction = plugin.data.getDefense(player.getUniqueId()) / calculation;
// 0.95
ActiveMob mob = MythicMobs.inst().getAPIHelper().getMythicMobInstance(e.getDamager());
double mobDamage = mob.getDamage();
double almostFinalDamageMM = mobDamage * damageReduction;
double finalDamageDefenseMM = mobDamage - almostFinalDamageMM;
System.out.println("2");
e.setDamage(finalDamageDefenseMM);
System.out.println("3");```
I have tried getting instance of the plugin instead of normal ENtityDamageByEntityEvent but doesn't work, could someone help me?
if(sender instanceof Player){
Player player = (Player) sender;
if(args.length<=1){
player.sendMessage(ChatColor.RED+"Pls specify the line and the word");
}else if(args.length>1){
player.getWorld().getBlockAt(player.getLocation()).setType(Material.OAK_SIGN);
Sign sign1 = (Sign) player.getWorld().getBlockAt(player.getLocation()).getState();
int Line = Integer.parseInt(args[0])-1;
String sentance = args[1];
sign1.setLine(Line,sentance);
sign1.update();
}
}
return true;
}```
thats what i have made till now and i am unable to make it so that it will get all the args after 0 in that line
Why not?
?
how can I make my 1.18 plugin work in 1.17?
in plugin.yml remove api version
and don't use method that only 1.18 have
don't really know if there are
change the api versionb
you dont need to.
I do it like that
unnecessary, i would guess it is change to api version 1.16, but not delete it entirely
is there something like a group that all 1.18 plugins support up to like 1.16?
no. the api version actually tell the server that this plugin is not legacy, according to the log in the server in startup
so remove it = u tell the server you are supporting legacy versions
Just do something like
||String temp = “”;
For (int i =1; i > args.length; i++) {
temp += args[i];
}
// add temp to sign line ||
On my phone so I can’t test it or give super accurate code
thx i will try it
In response to this
Probably want to use a string builder but yeah
There may be a better way for it but that’s the best way I could think of at 3 am
ooo thanks for helping me 🙂
Yeah no problem, anyways ima head to sleep. I’m sure if what I said didn’t work someone else can fix it lmao
But from what I know it should work
ok good night
sleep tight
Basically i use deepl api to translate messages into all the languages and sometimes i dont get the right translation cuz im translating with colorcode how do i remove the colors temporarily for translation and add them again?
You can remove them, but you can;t add them back contextually
declaration: package: org.bukkit, enum: ChatColor
Are there better alternatives to EntityInteractEvent for ringing of bells
PlayerInteractEvent does not include villagers who might use the bell, while right clicking of bell does not necessarily mean it is rung too...
how do i make 1 location face another?
So I have this in my pom
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
Which doesn't display any errors, but when trying to import a craftbukkit class I can't import the 1.17 version. I do also import 1.18 which works fine, my guess is that it's a build-tools issue or smth, what do u guys think?
fuck
my bad, ty
funny how my 1.18 import also has just spigot, weird that I missed that XD
Wdym by facing
Locations are faceless, isnt it?
what does 'to face' mean?
I believe locations also store a direction
yea i want the dir to be changed to have loc1 look at loc2
Right
well as setdirection just uses a vector you would just need to do some vector stuff, am very bad at working with vectors so can't help you with that XD
loc1.setDirection(loc2.toVector().subtract(loc1.toVector()))
damn that easy huh
oh ty
Bump
Inb4 i use protocollib
?paste
is this something to run it async?
https://paste.md-5.net/topowuximu.cpp
Hey quick question: I am trying to add to my plugin that players can claim chunks for themselves. That means if they claim the chunk, only they can build and mine there.
But now I'm trying to add that players can't claim a chunk infinitely often but only e.g. 5 times. For this I have added 2 columns to my MySQL database. One that increases every time the player claims a chunk ("chunkcount") and one that contains the maximum value of chunks the player can own ("chunkcountmax"). when the player then tries to claim a chunk, it is compared whether chunkcount is smaller than the value in chunkcountmax and if it is, the process is aborted.
However, I have the feeling that this is not the smartest way to implement the limit. Does anyone know how to implement it in a simpler way?
Yes you can run it async
so my method would work?
It should
ok
I assume you have a table that stores the owner of each chunk?
yes
public void OnFirstJoin(PlayerLoginEvent e) {
main.sellingOff(e.getPlayer(), Material.IRON_BLOCK);
}
public void sellingOn(Player p, Material name) {
getPlayerData().set("Players." + p.getName() + "." + name, getSell(p, name, true));
save();
}
public void sellingOff(Player p, Material name) {
getPlayerData().set("Players." + p.getName() + "." + name, getSell(p, name, false));
save();
}
public Boolean getSell(Player p, Material name, Boolean status) {
return getPlayerData().getBoolean("Players." + p.getName() + "." + name, status);
} ```
playerdata.yml:
Players:
LifeWienty:
IRON_BLOCK: false
When I get the material "false" 1 time, it doesn't work the next time I get it "true" save.
Because imo claim count is a statistics, not the data
package command;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;
public class command implements CommandExecutor {
private final JavaPlugin plugin;
public command(JavaPlugin plugin) {
this.plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
console(ChatColor.RED+" "+sender);
console(ChatColor.RED+" "+command);
console(ChatColor.RED+" "+label);
console(ChatColor.RED+" "+args);
plugin.disablePlugin(this);
plugin.getPluginLoader().enablePlugin(this);
return false;
}
public void console(String data){
Bukkit.getConsoleSender().sendMessage(data);
}
}
What's wrong?
there is an SQL query you can do to compare automatically
What's wrong?
Error
help
I want to Dependency Injection to command.java
Very informative
select * from players where claimed == maxclaimable;
select * from players where claimed == maxclaimable OR claimed > maxclaimable;
@burnt current
There are a few things generally quite wrong with this snippet
Your command executor not your plugin, you can't set This
PascalCase for class name, command as class name is inaccurate, and yea, this is not a plugin class
I wrote the command processing program separately, so dependency injection is needed. I read https://www.spigotmc.org/wiki/using-dependency-injection/ at least 10 times, but I still don’t know how
But I need to use disenableplugin()
Bukkit.getPluginManager().disablePlugin(plugin)
You are currently feeding it a commandexecutor
Not a plugin
if i relocate h2 driver, do i have to explicitily set the driver class name?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
okok
hello?
can anyone help me make a plugin or tell me a tutorial?
I'm new
just beginner trying to learn
EnderPearl#getItem NoSuchMethod for 1.8. Ideas how to get ItemStack from EnderPearl on 1.8 and also is it really possible?
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Seems like there is no ThrowableProjectile interface for 1.8?
easy solution:
do not use 1.8
when lava is placed just check if the nearest player is within 5 blocks?
why ask if it works when you can try it?
How can I give the player this new freezing effect?
setFreezing ig
Hi ! Is it possible to get the biome name of a custom data pack modifier ? like theralith ? When i test a simple get biome it return me CUSTOM and with getKey "minecraft:custom" but not "theralith:something"
I don't know if the server can have this information
setFreezeTicks
server can. but spigot trashy api cannot
no, sadly
Fuck md_5
well md_5 is great person, this is not a reason to say that
yikes
You ever wonder how some people haven’t been kicked
🤠 md fanboys
i mean, for sure i have respect to md_5 as person, but sometimes when i see spigot api..
fuck md_5
the legacy support policy
Some of the API is now 10 years old
EntityLightning lightning = new EntityLightning(EntityTypes.U, ((CraftWorld) getLocation().getWorld()).getHandle());
java: cannot access org.bukkit.RegionAccessor
class file for org.bukkit.RegionAccessor not found
at CraftWorld
but why?
NMS for lightning?
i just use spigot build tool jar in m2
I see, only the player
neither that
Then
World#strikeLightingEffect
You can both summon a proper lightning strike or only the effect
Yes
Anyone know or able to make a single plugin that allows a enchant or attribute to a tool to mine in a 3x3(or bigger/smaller) radius?
Add a PDC tag and look for said tag in the block break event
im sadly not familier with creating plugins 😦
I wrote this code to look at another entity and double the speed of the arrow.
But the direction in which the arrow is fired is normal, but direction which actually looking at is strange.
Vector vector = normalize.clone().multiply(2);
Hi, good morning, i have a problem with items in inventories, i'm trying to code a duels plugin, so i am creating kits and when loading the contents to the player, when the player tries to move the item it seems to be in the destination slot but when you try to use it, it disappear.
here is the code: https://paste.md-5.net/ewafexohor.cs
What spigot version?
1.8
well...
Thanks
That wont fix your problem btw.
Update to a version that still receives updates. 1.8 has been buggy for half a decade now and it wont get any better.
yeah i know, but still helpful answer :)
i think it takes too short time to turn maybe
Well, what spigot version do you suggest to me?
latest
1.18
Hmm.. If a create the plugin with that version, can i make it compatible with other versions?
Depends on the API features you use. But i wouldnt bother supporting anything below 1.16 and def not below 1.14
Oh, but in that versions the pvp is different,I can't make the pvp like 1.8, can I?
You can with old combat mechanics plugin
Run your server with 1.18 and use via backwards
the solution is pretty sucky, but it works
Oh, so the players that joins with 1.8 will still have the default 1.8 pvp?
Not without the plugin
why
lmfao
When an arrow is objectified, like Arrow arrow1, is there a way to make it disappear when this arrow1 hits the floor?
declaration: package: org.bukkit.event.entity, class: ProjectileHitEvent
Thanks
To prevent any memory leaks when an arrow is shot into unloaded chunks you should tag the arrow
using its ScoreboardTags or PDC then listen for the ProjectileHitEvent and check if the arrow is tagged
I almost forgot that the arrow is an Entity lmao
how can I list all the beds or at least check if the block is bed (of any kind) | EDIT: ARRAYLIST/HASHMAP DOESN'T HURT
How can I get maxY and maxX value with getConfig()?
double maxY = getConfig().getDouble("tpr.maxY");
double maxX = getConfig().getDouble("tpr.maxX");
ty
my closest guess was Integer asd = Aquatic.getInstance().getConfig().getInt("tpr/maxY");
Hey! i got this error with my custom recipes but i don't have any replicated recipe, could someone help me?
bump
but you have..
i haven't find nothing
because it was already registered before..
Is it because you’ve got 2 different recipes for the same item?
this thing?
?
does anyone know how I can get a user's discord roles with JDA when they leave the server?
In GuildMemberRemoveEvent, the user returns null
is HashMap#containsKey(something) the same as HashMap#put(something, value) != null?
no
if you use put you overwrite existing values
Don’t use PlugMan.
ok
Restart it
dont sure but shape can also have 2 lines too... no need for 2 recipes
Would be worse 😂😭
@acoustic pendant it worked?
All good
uhh hey people :), im creating a custom recipe with custom items input, but the thing below also lets in all things of the type that is paper
