#help-development
1 messages · Page 427 of 1
Di isn’t that bad
But it gets annoying when you need to like
Run something 1 tick later deep in the bowels of your code
Well it isn't hard if you design a system from scratch
thats why we have both
But once you inherit something from a codebase that wasn't designed that way it gets complicated
you dont?
Oh god it has an uppercase
how do you make it without a pluginn
Wait that isn’t even valid anymore
💀
Gotta run fast
(to be honest I haven't tested that code for like a year now)
Huh
.
new NamespacedKey(namespace, key)
I guess it’s Mojang that throws an exception if it’s not all lowercase
Or just use a parse method
is namespace stringed now
Been for a while now
huh
Due to the minecraft and bukkit namespace
IJ is so weird sometimes.
How is the "additional parameter" in this constructor related to the enum declaration lol
Stringed namespaces have been a thing ever since the namespaced key: https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/commits/5ad2ecf658276b8aae336b0e5bfb894a5151b578#src/main/java/org/bukkit/NamespacedKey.java
how have i not known
Most likely unexpected type
bruh is this thing just saying the same thing twice?
didnt know TPS can go higher than 20 o0
its about 20tps
yeah but it's slightly higher than 20
im wondering how to server actually waits for the next tick
I thought it would never be above 20, only <=
no clue, id love to look at the impl but thats probably in the vanilla server
what do you modify when doing /gamerule randomTickSpeed?
randomTickSpeed isnt tps
could you uncap the 20 TPS?
Which often is annotated the 20*
Yes, but not easily
what would happen if you set it to 40 TPS?
What do you think?
nothing very interesting
well it makes the game in 2x speed
all mobs wpuld move faster, crops would grow faster, red stone, day time cycles
players would feel slower in comparison to the rest of the world
stuff using Thread.sleep or smth?
ive seen minestom using LockSupport.parkNanos
same
protected void waitForTasks() {
Thread.yield();
LockSupport.parkNanos("waiting for tasks", 100000L);
}
Though they used to use a special thread so it doesn't wait wrongly
But I believe ever since LWJGL 3 it is built-in into LWJGL
ive probably been reading about deadlocks for too much
How can I check if BukkitRunnable is done and rerunit?
wdym with "done"?
do you mean whether it's scheduled? or whether it's currently running it's "run" method?
If the run method is over
I can paste here my Runnable
But its kinda complicated mby to understand 😄
?paste
public class MyRunnable extends BukkitRunnable {
private boolean isRunning;
public boolean isCurrentlyRunning() {
return isRunning;
}
@Override
public void run() {
isRunning = true;
// Do your stuff
isRunning = false;
}
}
Do you mean sth like this?
If player has specific item in main hand I want to rerun runnable. So mby that will help
bruh copilot still believes branches are called main but its master now
i didnt know either
bruh all i had to do was git checkout -b recipes-constructor-change upstream/main why is git that difficult
That kinda helps 😄 Thanks.
UnsupporteOperationException: Use BukkitRunnable#runTask(Plugin), but i cant find in the docs which methods run the task delayed
BukkitRunnable#runTaskLater(plugin, long)
uuse the scheduler??
the Scheduler methods for BukkitRUnnable are deprecated
Using the schedule gives the operation exception
no need for bukkitrunnables, use a runnable
I need to cancel the task
if you need one, use a consumer with bukkitrunnabme
that
scheduler.runtask(task -> {logic; task.cancel()})
that's a Consumer<BukkitTask>
He?
🤔
runX() is not a method from Bukkit Runnable
lambdas look better than anomymous classes
no shit - it was an example
where X could be "Later" or "Timer" or nothing
too tired to write smth usful
Hey, hey! I need help with my entity data sending packet. I'm trying to change a TextDisplay entity's text
Here's what I've got so far.. ```java
public void spawnEntity(Player player, int entityId, UUID uuid, Location location) {
ClientboundAddEntityPacket packet = new ClientboundAddEntityPacket(
entityId,
uuid,
location.x(),
location.y(),
location.z(),
0,
0,
EntityType.TEXT_DISPLAY,
0,
new Vec3(0, 0, 0),
0
);
((CraftPlayer) player).getHandle().connection.send(packet);
sendEntityMetadata(player, entityId, List.of(
getMetaEntityText("test")
));
}
public SynchedEntityData.DataValue<Component> getMetaEntityText(String text) {
return new SynchedEntityData.DataValue<>(5, EntityDataSerializers.COMPONENT, Component.translatable(text));
}
public void sendEntityMetadata(Player player, int entityId, List<SynchedEntityData.DataValue<?>> dataValue) {
ClientboundSetEntityDataPacket packet = new ClientboundSetEntityDataPacket(
entityId,
dataValue
);
((CraftPlayer) player).getHandle().connection.send(packet);
}
Spawns it in but the text isn't there
Can I schedule next runnable after previous one? 🤔
I just made like this:
double ticksDuration = 1.5*20;
new BukkitRunnable() {
int ticks = 0;
boolean done = false;
public void run() {
if (done) cancel();
ticks++;
// just for waiting xD
if (ticks > ticksDuration) {
done = true;
//Is done, run again or cancel
}
}
}.runTaskTimer(RoleJob.getPlugin(), 0, 1);
mby is not best solutuion 😄
1000L = 1 ms?
1000L = 1000
L just means long, could be milliseconds or ticks or whatever, depends on what you need it / use it for
right, i need to run it every 1 second = 1000ms
the scheduler uses ticks, so it'd be 20
right
kinda fun how people believe 1000L has any difference with 1000
Why Im doing thinks too complicated? Why I didnt do just this instead of running that ever tick...
double ticksDuration = 1.5*20;
new BukkitRunnable() {
int ticks = 0;
boolean done = false;
public void run() {
//do think evry ticksDuration
}
}.runTaskTimer(RoleJob.getPlugin(), 0, (int) ticksDuration);
use the scheduler :)
it does
e.g.
public class Test {
static void doSth(long l) {
System.out.println("Long is " + l);
}
static void doSth(int i) {
System.out.println("Integer is " + i);
}
public static void main(String[] args) {
doSth(1000);
doSth(1000L);
}
well ye
i was talking about cases where a long was expected actually, in comparison where a cast happens at runtime
would this work
public void onBrew(BrewEvent e) {
e.getResults().toArray(new ItemStack[0]);
}```
Probably not needed. I just need to run evry 30 sec for example. And if the condition is not met I will cancel it.
it would compile and run just fine, but what's the purpose of doing that?
im trying to get
the potion that the player
brewed
no
do you maybe mean Stream#toArray(IntFunction<T[]>)?
Oh probably
the normal List#toArray just takes in any array
or nothing, but then it returns Object[]
and those can't be casted
oh well, in java 11+ List#toArray(IntFunction) also exists
kinda weird that the IntFunction exists for streams in java 8 but not for normal collections lol
Probably toArray for collections is inherited from older java's and when added stream api they just didn't care enought
Lol
IJ stores the profiles in the .idea folder
might wanna remove that and see if that helps
how can i create a custom config object like how you can save a ItemStack to the config
hi guys
oh you are one of those
bump
What are you trying to do ?
Spawn a TextDisplay entity with packets, and then set it's text with packets
thx
show the method on how you set the text
sendEntityMetadata(player, entityId, List.of(
getMetaEntityText("test")
));
public SynchedEntityData.DataValue<Component> getMetaEntityText(String text) {
return new SynchedEntityData.DataValue<>(5, EntityDataSerializers.COMPONENT, Component.literal(text));
}
public void sendEntityMetadata(Player player, int entityId, List<SynchedEntityData.DataValue<?>> dataValue) {
ClientboundSetEntityDataPacket packet = new ClientboundSetEntityDataPacket(
entityId,
dataValue
);
((CraftPlayer) player).getHandle().connection.send(packet);
}
hm I also tried it using new Display.TextDisplay(...), then send a packet, but it also doesn't show anything
lmk if you find anything
how do i pass an instance of my main class
Jobs jobs = new Jobs();
doesnt work
because java.lang.IllegalArgumentException: Plugin already initialized!
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
im confused
about what?
your artifact with all the dependencies shaded. It should be the same as the .jar that does not end with -shaded
alright got it#
unless you messed up your maven-shade-plugin's configuration
im still getting this error
java.lang.IllegalArgumentException: Plugin already initialized!
even though im using
public BreweryJob(Jobs jobs) {
this.jobs = jobs;
}
oh wait
is this causing the issue
JobInterface breweryJob = new BreweryJob(new Jobs());
yes, you must NEVER do new MyPlugin()
first, because it's not allowed, and second because it wouldn't be what you want anyway - you want to always use the same instance instead of creating new ones, even if it'd be possible
yeah my bad
public JobManager(Jobs jobs) {
this.jobs = jobs;
}
JobInterface breweryJob = new BreweryJob(jobs);```
why doesnt this work
Variable 'jobs' might not have been initialized
in JobInterface breweryJob = new BreweryJob(jobs);
because the fields get initialized before the constructor gets called
do it in constructor
oh ye
you gotta do it like this:
private final Jobs jobs;
private final JobInterface breweryJob;
public JobManager(Jobs jobs) {
this.jobs = jobs;
this.breweryJob = new BreweryJob(jobs);
}
yep i got it
i have this here
double breweryPay = config.getDouble("payments." + potionType.name());
this is the config
config = YamlConfiguration.loadConfiguration(configFile);```
and this is what the config looks like
MUNDANE: 0.0
THICK: 0.0
AWKWARD: 1.0
NIGHT_VISION: 2.0
INVISIBILITY: 2.0
JUMP: 2.5```
don't use jobs.getDataFolder() + filename
but it always give 0
what should i use
use ```java
File file = new File(getDataFolder(), "filename.yml");
depends whether that was the issue lol
does the actual yaml file inside your server's plugin folder actually has that content you sent, or is that just your config included in the .jar file?
one question alex
why do we use Main#getInstance() instead of just accessing Main#instance ?
dw i already have all that set up
it works now lol
cuz thats the naming convention for getters?
always getter unless its a constant
is there any reason that isn't standards?
you mean a public field?
you could also do that ofc
doesn't matter
okok
I wouldn't use a public field because otherwise people could change the instance to sth else
with a getter you can be sure that people can get the instance, but not set it to sth else
since you obviously can't make it final in this case
You can still change it if private, a bit more dificult but still possible
Sure, but then you know you‘re doing sth „illegal“
If a field is public is not final, one could assume its allowed to change it
If you need reflection, its obvious that you are not supposed to do this
It wouldnt be possible to change it to sth else anyway, except for null
Unless you create a subclass without calling the constructor but that is even nastier
you can always allocate an uninitialized object with Unsafe::allocateInstance
Yeah
but it gets really dirty there
A problem occurred evaluating root project 'PrivateMines'.
> Could not get unknown property 'pluginVersion' for root project 'PrivateMines' of type org.gradle.api.Project.
Me when my every class is record
Any gradle gamers
i like descriptive names for methods.
getSomething() obviously just returns "something".
But "something()"? It could simply return "something", it could also do "something" and return the result
you are using the property pluginVersion somewhere but never defined it
Bad, the best solution is to create a virtual kernel in where only your application has access, with a virtual ram and that stuff.
Well, I cloned a project on gh and it works for the author
Never used gradle, what can I do
obviously, "something" was an example
Doing some debug, runTaskLater() isnt scheduling
it could e.g. be a boolean "invulnerable". calling invulnerable() could e.g. make the mob invulnerable isntead of just returning the existing invulnerability status
that's why I think calling it getInvulnareble or isInvulnerable makes more sense
Call it the class name, like if your class name is "MyClass", make a method called "myClass"
Well, it is
noone will ever know what this method does or returns 💀
few days ago there was this dude who was like "why is my code not working"
public constructor() {
...
}
and no, the class was NOT called "constructor"
Dude mixed kotlin and java
Did he try to create the constructor in javascript like constructor?
yeah sth like that
Doing debugs alex, the scheduling dont work as a delayed task
wdym
yes, the delayed task, is executed every x time
You using gradle?
every dev uses different gradle tasks
Unfortunately the Original Author is
import me.clip.autosell.events.AutoSellEvent;
I assume just like maven I need to install that to gradle?
Report it to the authorities
I think there's no such thing as "install" in gradle.
Are you sure the dependencies are setup correctly?
I cloned his project
And it works for him...
But this is the least descriptive resource in the world
Rule #1 of developer
You can't go to the client and tell your application worked for you (joke)
he probably has the AUtoSell jar in their local maven repo
Yes
oh god, I hate gradle
tf
🤨
True, my bad
Anyway, I still don't like gradle
yeah the AutoSell plugin looks dead
What? 🥺
I'd message the author and ask if they give you the plugin for free for dev purposes
always worked for me
Whyyy u hatin on my gradle :(
but it looks dead, last update almost a year ago
Because gradle is not like maven
It looks dead and so bad
No
Yes
XML 😨
Graven >> Gradle >> Maven
You use gradle and you instantly get problems and head caches. Meanwhile maven users: "I want this dependency sir, install it on my local repo" 🧐 🍷
gradle is worse than maven in many things, e.g. because the docs are so shitty (and usually outdated), it breaks compatibility on many new updates, and it lacks basic features such as properly shading dependencies without third party plugins
Graven will be all life better 😂
Gradle but in xml 💀
Docs arent outdated waat
maven docs are not outdated
You technically can shade without an external plugin
yeah but where are the docs about that? can it relocate and minimize as well?
can you link the docs pls
Docs to what?
depends. if you also count the initial setup time... you need to compile 300 times before it's still faster in total
also people always compare maven with 1 thread and without build-cache-plugin to gradle, ignoring the startup time and having build cache enabled on gradle
It takes me basically no time to set up
I mean u can run maven on multiple threads ye
no shit, Graven is better
U also have incrementa builds on gradle
Graven
Graven hmm
Gaben
Marven
maven has that too but nobody uses it (which is fair enough since it's still in beta)
where do yall find people that pay for plugins
on spigotmc
ive just been making them for myself now i wanna cash
Ye well I just prefer gradle since its a bit easier to append some functionality on top of the build pipeline
I like a no frills clean pipeline
Everything u can do with maven can be done with gradle and the converse
same
paper would disagree
I mean its pretty much true
I mean they wrote a gradle plugin
Ye
Execution failed for task ':shadowJar'.
> Unsupported class file major version 63
What shall this mean
Like I know what it means, how to fix for gradle, instead
tbh commissions probably make more than premium plugins
This might help
It's there
Its not entirely untrue
kinda nerve racking developing for others
But my point is, its not like gradle nor maven has any features that cannot be implemented within reasonable time
Then ofc maven is less usable when it comes to individual configurability
Agree
Well i mean actually not really
Python cant do memory management and low level stuff
the maven-build-cache extension sped up my build from 1:30 min to 4 seconds
I mean
Then u’d have to write a py module through some low level code at least
What happen when a ConfigurationSeriliazable object, has a null property? Is it saved the object
Usar graven!!!!
Everything you do in any programming language can be done in assembly 💀
but the build cache extension is an official one
How do u do that with only using Py?
It kinda is
Ofc u can use sth like RMI
But that’s implemented natively
Which uses low level code directly
like java native
doesnt md have a post for proper plugin standard
So no py can’t operate on the low level the same as CPP
Oi lads I'm about to go to bed but as interesting as the python talk is, this bois question got missed.
We need a dev general chat asap for this discord ong
that depends on whether you save it or not in your serialize() method
it's your job to write that method
idk
Is there any way to detect a player igniting something with a fire charge in BlockIgniteEvent?
There's IgniteCause.FLINT_AND_STEEL, but that doesn't trigger for a fire charge
Not in the same way cpp does it
If you really want to you’d have to, again, use functions implemented natively
Cpp has built in semantics that support these type of low level operations
IgniteCause.FIREBALL
Ah, perfect. Thank you!!
np
Whilst ur here,, and I'm gonna use the technicality of this being the dev help chanel....
Can u let the lads further up the chain know that it might help keep questions from getting lost in cool dev convos if we had a development general chat? 🙏
just use #general
Development general channel? Is that what you’re suggesting?
Not a bad idea
Ik other servers that have it
The python convo we just had shows that isn't what we do 😅
true yall do be chatting
everything's calling AsyncPlayerChatEvents here
that god discord doesn't use Components
Aye folk chat a lot about dev stuff here really cool dev stuff too.
Think it's worth it's own channel as questions do get lost sometimes lol
Raziel, I can bring it up with the others and we’ll see what they think about it
Yeah in addition
A forums channel would be nice
But doubt that’s gonna be added
It was brought up some time ago
what'd that be for?
Easier tracking questions
For forums to chat to each other obvs smh
oh you mean this discord forums feature?
yes
ah I see
yoo alienware is about to drop a 500hz monitor, finally I can get an edge in competitive minecraft pvp
wtf
But then again, that’d render spigot forums more useless arguably
meanwhile MSFS2020 running at 29 fps using RTX 4080
It's time to let go 🤣
@tender shard I pulled it off
The future is now old man lmao
TextDisplay with packets
what was the issue?
wrong id, I used reflection to get access to the field (to get the id via that)
oh ok
btw mfn I did manage to get the modules working, thanks for the help
I'm just wrangling how the adapter is meant to work rn
also ironically my biggest issue was that I had lingering code I didn't even notice that was completely messing up the maven repos
great!
any recs on how to do the adapter part of it, I heard some back and forth between reflections and not reflections
wdym with adapter? the thing that creates the proper NMS instance thing?
Btw ... me and a friend got the bit manipulation for reading raw chunk data (the long arrays in chunk fkles) to work so we can read a every block in a chunk + coords in under a second....
And then we realised this file... that has 4000+ blocks with 20ish unique blocks in it... takes up 3kb of space...
Why the hell do plugin devs not use this for data storage?
yeah
public static void enableNMS() throws NMSNotSupportedException {
final String packageName = JeffLib.class.getPackage().getName();
final String internalsName;
if (McVersion.current().isAtLeast(1, 19)) {
internalsName = "v" + McVersion.current().getMajor() + "_" + McVersion.current().getMinor() + ((McVersion.current().getPatch() > 0) ? ("_" + McVersion.current().getPatch()) : "") + "_R1";
} else {
internalsName = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3];
}
try {
nmsHandler = (AbstractNMSHandler) Class.forName(packageName + ".internal.nms." + internalsName + ".NMSHandler").getDeclaredConstructor().newInstance();
} catch (final ReflectiveOperationException exception) {
// Ignore this part
}
if (nmsHandler == null) {
throw new NMSNotSupportedException("JeffLib " + version + " does not support NMS for " + McVersion.current().getName() + "(" + internalsName + ")");
}
}
this is my weird way of doing it
I did read it
Alr I just delegated ur suggestion (:
so if I've got some method ```java
public Object getSomeObject() {
try {
//Some stuff that throws an exception
//return something
} catch (Exception e) {
e.printStackTrace();
}
return null
}
Instead of printing the stack trace I should throw anew RuntimeException(e);``` and not return null? And why?
gift me knowledge
I didn't quite mean the chunk itself. I meant the method.
Building jt from scratch using the same storage method. E.g core protect ends up being GBs in size. I did some napkin math.
A 10gb CP file could probs be squeezed into 500mb ish using that storage method
this is a good design question @winged anvil
I was left wondering though how do you link the nmsHandler back to everything else in a way that is not annoying to write?
It is very compact and efficient but it's much easier to just read/write to a database for most of the stuff we need to store in plugins
so people know that an exception was thrown and that "null" is not a proper value returned
The general idea is this
I'm not really sure what you mean
to access methods or classes you do it through your NMSHandler right
If a method cannot fulfill its contract, it should then throw an exception @winged anvil
yes
how do you then store references to the various classes and methods that might use?
to throw an illegalstate would make more sense
and explain way more
or am I thinking about this incorrectly
The general rule is, only the method that knows how to handle the exception should catch it
well imagine I got the AbstractNMSHandler that declares "getItemStackSizeInBytes". And I have a class ItemStackUtils with the same method. It then just delegates that to the NMS handler and returns what that one returned
I'm confused where you found a 3kb chunk
so like keep throwing it up the call stack?
also when do you guys make custom exceptions
ofc if you only need it internally, you could just directly call myNmsHandler.methodIWannaUse(...)
A dumb method that just gets data from a database or something should throw it up the callstack, exactly, until there's a method that knows what to do if the data isn't available. For example, display an error to the user or just stop whatever is happening if the data is critical
sooo I am not really sure what the problem is
the bit I'm asking about is actually the bit inside of the Nms handler, I don't really know how you have the object setup, does it actually contain every method that uses nms methods without offloading it to other classes?
ok that makes sense thank you
Anyway zlaio, iirc effective java also proposes to avoid returning null if possible
Because you have to javadoc why null to make it clear
No problem! People try to avoid the try/catch stuff, and it is annoying, but when used properly it is quite helpful
Cause it can be returned cause of different causes
for instance Map#get
null can mean absence or just null element
i see. like the Player#getTarget(int range) or something returns null if there isnt a block in the range
I've been using Optional a lot for that. Not perfect but it works.
the AbstractNMSHandler is just an interface.
E.g. in the core module:
public interface NMSHandler {
void doSomethingThatRequiresNMS();
}
Now the 1.19.4 module, depends on core:
public class v1_19_4_NMSHandler implements NMSHandler {
...
}
Then in your core module, you Class.forName the correct NMSHandler implementation (with reflection because core cannot depend on the other modules) and save that instance in a field
Optional is nice, a bit handicapped since u dont have present and absent subtypes
i dont think that was for me
right so you actually have every single method implemented?
yeah, but it only has stuff inside that actually requires NMS, nothing else
yeah that's the not so pog bit I was trying to think my way around
I guess for what I'm doing it would be silly to try to avoid anyway, it's an extremely restricted scope
Yup it could definitely be improved, but it does clarify the intent of the return better. That it's a value that may not be available whereas null is a bit ambiguous
Agreed, but some lambda functions make it easier to deal with
True
Still a pain though lol
I don't think there's a better way. Well, check out my 1.19.4 and 1.19.3 nms handler. the 1.19.3 e.g. also implements TranslationKeyProvider, while in 1.19.4 I can just use bukkit methods. So instead of having one large NMSHandler interface, you could also create one interface per feature for versions where it requires NMS, then fall back to bukkit on versions that can do it with api
there's most likely a way to do it through reflections but man does it sound like it would be no less of a hassle
I've been using @urban grotto and @ Nullabe too
poor minecraft noob
alright thanks for the help, if I ever find more than 20 ways of doing pathfinding I'll maybe reconsider what I'm doing
Lol wasn't thinking about using @ in chat lol
yes i was actually about to ask about those
well depends, 2 years ago you could do "getField("maxHealth")), but now with spigot using obfuscated mappings, that field might be called a or c or xA lol
do you only use those to signify to others?
lol
oh right obfuscation, I forgot about that one
notnull gets pinged a LOT 😄
The annotations are good for public funcitons, so others know how to use them
there's also a dude called NotNull on github, I bet they got email notifications disabled lol
im not aware on practices used in public repos since i make plugins privately
I have misusage of nullable annots put on error inspection level as to not miss them
Well not even a public API, can even be useful in your own code
Indeed
and contracts ❤️
Yeah it's nice because your compiler will warn you if you're passing null to something annoted NotNull
Yuh, the least we can do when java doesnt give us any better tools
i will start to implement them
It really does help. It was so nice when the Spigot API implemented them
Yeah very nice, i remember once the annot lied, but apart from that, epic stuff
You can't even make a PR without proper nullability anymore :p
Never have to worry if that itemstack is null or Material.AIR
🥲
contracts are nice, with contract IJ knows this is not null, but without it'll complain it being nullable
I need to start using contracts more. Doesn't that let you show range of values in returns and stuff?
Sorta yeah
I don't understand contracts syntax
it's explained very well here: https://www.jetbrains.com/help/idea/contract-annotations.html#syntax
Well, it defines assertions of given null inputs, what the method will do then
Like throw/return/null
I'll check that out, thank you!
kt 💀
Its good because it also forces api methods to be contracted, that is altering them becomes a bit harder since u want to keep the api compatible, thus it makes u more precautious of how u write ur api
@Contract(value = "null, _ -> fail", pure = true)
public static void notNull(final Object object, final String message) {
if (object == null) {
throw new IllegalArgumentException(message);
}
}`
this e.g. means that it will throw an exception ("fail") if the first parameter is null ("null") and the second parameter is <whatever> ("_")
"pure" means it doesn't change any of the objects that were passed as args
idk I never used rust
Ah I had saw pure before, that makes a lot of sense
"I won't dirty up your referenced objects"
It means any concrete statefulness is absent within the method
match int {
1 => (),
2 => (),
_ => panic!()
}
Not only the args, but like also other mutable variables
or in simple words, pure=true means "if you don't use the return value of this, then calling me is useless"
Yeah, by definition a void method cannot be pure also
hm well it could be if it only prints out sth
Nope it does alter the state of the system
Maybe not within the scope of the method, but an underlying method call def has some side effect
So a pure method doesn't alter ANYTHING, it only does calculations on the parameters without modifying them and returns a brand new object
the jetbrains docs sure pure is intended for methods "that do not change the state of their objects". arguable whether System.out.println changes any state
or primitive
PrintStream
well but returning a new object would also alter the state, since it would allocate memory for a new object, so the whole definition is a bit unprecise
Statelessness, side-effect”less”, purity means in general, you should be able to write down ur function inputs to outputs in terms of a table, aka be able to memorize the output for an input
Then in programming this definition is a bit different from the mathematical side
Since many methods are shallow pure
But deeply speaking, impure
What cause to a serialible object, not being saved?
A pure method for example would be
public int add(int a, int b) { return a + b; }
Yep
Yeah yeah
My CPU is impure 😔
Yeah you're changing the heap, even though that isn't technically addressing a particular object
Seems like there wouldn't be too many truly pure methods
yea, but if you only talk as far as the langauge goes then more methods become pure
Such as urs
Right
Chaotic evil is to label every method as pure
And make sure every method does something to the parameters
👀👀
plugin.saveConfig()
no, chaotic evil uses reflections to access a random class when the method is used and changes a field at random
no?
Im not using default config
Its a class for config, but the config class works perfect
Sounds like ur avg spigot dev trojan java horse edition plugin
Ah
plugin.getConfig() uses the default config
How does the save method look verano
Premium plugins = broke
Free plugins with crypto miners = woke
Im overringd it
My custom file class, extends YamlConfiguraiton
Ah
But the point is that my obects are not being saved
Ur static analyzer didn’t detect that tho
Well if u dont save then it wont be saved
Idk if there’s anything else
It really depends on what and how you are overriding YamlConfiguration
Shouldn’t you be overriding saveConfig
Verano show the FileConfiguraiton class
Chaotic good is making an xray plugin that secretly records their movements and sends em off to a db to be used to train AI to spot xrayers 😎
You aren't calling super in constructor
The point is not that, because im using the file on ther plugin and data is saved
So must be something else causing the problem
As an example, which uses the same file handler, and everything works perfect
How do u use the config serializable objects
Do u register it also?
yes
or do u use getSerializable?
Is the first thing on my onEnable()
Ah alr
I registered it as ConfigurationSerialization
btw once this is done, anyone want a 1.18+ pathfinding api?
And then im initializing the file
Doesn’t it also need a deserialize?
I mean wouldnt say no
Yes, needs to be serialize and deserialized
Can I pr it? :p
I just want it so I don't have to add the same nms logic to a bunch of my projects, especially since I want to use mappings and I'm also using gradle
I'll put it out there when it's ready if I remember I guess
[00:28:22] [Craft Async Scheduler Management Thread/ERROR]: Caught previously unhandled exception :
[00:28:22] [Craft Async Scheduler Management Thread/ERROR]: Craft Async Scheduler Management Thread
java.lang.OutOfMemoryError: unable to create native thread: possibly out of memory or process/resource limits reached
if (percentageTask == null) {
//Create a new Bukkit task async
percentageTask = Task.asyncRepeating(() -> {
double percentage = getPercentage();
double resetPercentage = mineType.getResetPercentage();
redempt.redlib.region.CuboidRegion cuboidRegion = new redempt.redlib.region.CuboidRegion(
mineData.getMinimumMining(), mineData.getMaximumMining());
if (percentage > resetPercentage) {
handleReset();
airBlocks = 0;
}
}, 0, 20);
}
Is this such a bad idea?
Memory leak lol
gg
Lovely memory leak indeed but why
Wait why is that even async... Shouldn't it just be sync
So? What can cause the issue?
my new keyboard is getting here in like 30h hopefully
really looking forward to that
an error or not calling save
When you say you are overriding the configuration, are you overriding plugin.getConfig()?
no error, and im calling the save method
Now i created separate file, and same issue
Because plugin.getConfig() will NOT return your custom class
then you are calling save on a different instance
No no i mean i created another class
No
Im not doing that
I can send code
Right, I see that, but that in your class
your getData() is probably returning a new instance each time
no it cant
Its initialized on onEnable()
So, i dont understand the reason of it
The original code you posted uses plugin.getConfig(), and then saves on that config
So you must also be doing something else
I removed that code, and created another file
Collections.emptyList() returns a immutable list
Oh shit
Indeed it does
Didn't even see that, nice catch
I'm surprised that didn't throw a bunch of UnsupportedOperationExceptions though
got another problem 😦
i have this:
dependencies {
implementation project(':CropMC-API')
}```
in my CropMC-Core module
but it says the class doesn't exist?
Are you shadowJaring
because maven kinda slow. and i wanna learn gradle
i mean
it ain't that slow
but meh
ye
Its apply to gradle buts called shadowJar
or something like that, i dont use Gradlen sorry
Atleast you can have an idea where to start
right, the problem is the next
Your src from module a, is not getting included on b, so JVm doesnt find that code
like it recognizes it but wont add it to the compiled code
Exactly that
The code is not being added while compiling
ye
That why youhave to do a shade to dependencies
;-;
man
o nvm
had to add this: id("com.github.johnrengelman.shadow") version "8.1.1"
nvm
it broke
also maven in term of dependency its better because Gradlen doesnt allow to install local sources like does maven
Meaning that gradlen doesnt have the mvn install <project>
i think.
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.1.0'
}```
yeah now it works
shadowJar
perfect
I explain
Let say you have this structure
.
Project = com.josh.<project>
--> Plugin-API = com.josh.<project>.api
--> Plugin-Core = com.josh.<project>.core
--> Plugin-1.16 = com.josh.<project>
right?
Gradle does allow this it is just done differently
oh right
Can you help him
ye
I dont really have much experience to explain him
sorry again, i've barely used gradle before
Nai ts okay were are here to learn
I think you have to manually install into local repo using gradle unlike maven where it is just a simple goal
An example you could look at is buildtools
Buildtools manually installs the api and server to local repo
He is wondering to know how to use shadowJar
Frost can you respond in your DMS from me if possible?
Best person is probably going to be illusion or coll to help with this at this time
Your structure, how its?
Or maybe magmaguy might know
You use gradle?
Yes, having problem with it
Yeah someone needs help with it and i dont use gradle so i cant really help with specifics
this is the error
you def didn't shade anything there
yes how do i shade?
again, never really used gradle before
with shadowJar
ik that
I'm not that amazing with gradle but take a look at the relocating a package section of my implementation https://github.com/MagmaGuy/EliteMobs/blob/master/build.gradle
one question how would i relocate a project?
the way it is on there
that and the bit before the sonatype implementation
and it requires some other minor tweaks as listed in the shadow plugin for gradle
which you need to use
?
🤷
Yea
nope isn't showing up in the decompiled version
Looks right
do the archiveclassivier and filename
How do u build the jar?
mfn left?
Wrong
wat do then
shadowJar
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
should be a configuration
There’s a screenshot there
It shows u how to pull up the gradle tasks
There should be a new tab under the gradle window called shadow
Expand that tab
And run shadowJar
?paste
That will give you a jar with the suffix -all iirc
?
trying to figure this one out, something's wrong I can feel it
Yes but this one is named shadowJar
if you set gradle up correctly and refresh it it should give you the shadowJar configuration
o
And its under shadow, not build
Progress must be between 0.0 and 1.0 (5.0) any recomendation?
?
put it between 0 and 1
im doing it via timer
Also josh
okay
The dependency of urs
are you doing a lerp?
YEP
It should be compileOnly in case u dont have it at that
Displaying time on bar progress
Im dkn dumb
waht did you do that it requires a number between 0 and 1
ah
it's a %
oh right
Epic
So how would i dispaly it?
with a number between 0 and 1
I can't figure this one out
buw how?
0.99 = 99%
.5 is 50%
verano I understand that your work pipeline is you get a commission and then immediately hop on spigot to ask for help on how to do it but this is really basic math
Im cero math bro
then don't take a project on that requires you to do divisions
its 1/5
currentTime / 5 right?
christ
and to run backwards as you want it's 1-(1/current_time)
ok, but why 1?
because a full bar = 1
ohh right
verano have they taught you fractions at school yet
i mean i dont even remember how to calculate % percentaje
yeah no we know that
I wont lie, im 0 math literally
Anyone having an issue where IntelliJ just decides "I'm going to use 100% of your CPU, then crash"?
It's getting really, really annoying
saw that one coming a mile away
Yeah had those moments
Yes, happening in last day
I'm not sure what triggers it. I'm pretty sure it's indexing, but I'm not sure why it would be indexing when it happens
I don't get it, is there a trick to adding a dependency from a multi module project?
Lots of issues posted about it online, but IntelliJ devs don't seem too interested in fixing it
I try to use shared indexing as much as possible, dk if itd help tho
I'll look into that, thanks!
trick as in?
https://paste.md-5.net/irunuqikuh.xml is what I currently have
and it ain't working out
Ah u depend on other modules?
yeah
Ugh, I know that there is a way to make it work
But i havent touched maven for long time
it didn't work for the parents either, but I could bruteforce those with relativePath
Doesnt maven docs go over this
the issue really is that I don't know where to start with this one
What the issue magna?
I’d rather trust SOF than myself here lol
I need to install it to local?
Im disabling changing note block notes by canceling a PlayerInteractEvent when it is a right click on a note block but I still want players to be able to place blocks on and interact with items in their hand with the blocks with right clicks just not change the note any ideas?
oh no lol
Why long parsing issue?
why ain't this working?
public static Collection<CommandData> registerAllCommands(@NotNull JDA jda, @NotNull String packageName) {
Collection<CommandData> data = new ArrayList<>();
Reflections reflections = new Reflections(packageName);
for (Class<? extends CropMCSCMD> clazz : reflections.getSubTypesOf(CropMCSCMD.class)) {
try {
CropMCSCMD cmd = clazz.newInstance();
data.add(registerCommand(cmd, cmd.getName()));
} catch (InstantiationException | IllegalAccessException e) {
e.printStackTrace();
}
}
jda.updateCommands().addCommands(data).queue();
return data;
}```
```java
BotManager.registerAllCommands(jda, "me.outspending.cmds");```
shouldn't that get all classes that have implemented the interface?
send me a ping when someone replys
thanks
Is there any way to change the note block in the opposite direction so instead of increasing the note decrease it? I know you can set it but when I try to get the note I cant seem to get an int type at all to be able to set it to the one before even though you can input an int kind of weird?
getNote has a deprecated getId method
brah
how does this default pathfinding work
you'd think if I told it to start going to a point it would start going towards that point
Did you say please
I told it that if it doesn't work I'm going to bed
yeah I don't get it
I created a goal, it is set to always be true, I made sure the mob doesn't have any other goals, I tell the move to start and I make sure the goal and target of the mob match the goal
oh hold up I sense fuckery afoot
use gradle smh
Are there any events that check for when players change the note of a note block im trying to allow players placing blocks on note blocks but not change the block right now im canceling a playerinteractevent and its stopping the placement
I don't even want to think about how many hours I've spent working on this in the last two days
hey, im having a bit of trouble loading a custom yaml file, because it contains Locations which its worlds has not been created yet, but in order to create these worlds i would need the custom yaml file to have been loaded, is there a workaround to this?
Load them up into a string array then loop over to get the world names you want to create. Then you can use those very same strings to then create a location object
I would probably create a class to create custom location objects that these strings can be fed into which contains a method to create the world upon object creation and then another method to obtain location object so that you dont need to really do any looping except maybe one
alright my new multimodule nms library works and covers everything starting from 1.17.1 which is probably plenty
Yeah at some point it just has to be someone elses problem 
anyone know off the top of their heads if entity targets are only applied in a hostile context?
You can target without hostility
that's what I thought thanks
Where are the tutorial videos?
Hello, is there a method for knowing if an item is placeable? Like, a water bucket is placeable, but it's not considered a block, so Material#isBlock returns false.
That wasn’t for me simpleton (but yes gradle is better)
nah gradle better
how can i create a bossbar and change its name instead of creating a new one?
If you have paper idk if it’s on spigot u can do /bossbar
I have paper
its something Bukkit.createBossBar
Yes, I know this, but I don’t understand how to change the name, there is no such method. I thought about deleting bossbars and creating them right away, but for some reason it doesn't work for me. Stored bossbars in Hashmap<Player, BossBar>
If the player has a bossbar, then I delete it, and create a new one, which is deleted after 3 seconds
In fact, it is on the server, it sometimes updates the bossbar, and sometimes not
Probably stops working after Schudeler, but why?
It's because of how you create your objects.
You are creating a local bossbar instance and storing that in a global map.
The map value is getting overwritten the second time, so when it tries to remove a bossbar, it's actually failing since it's trying to remove one that no longer exists in the map.
Use UUID not Player for your HashMap. Also bossbar has a setTitle according to the docs
good morning, would it be a good practice to do smth like this instead of delegating it to the proper class:
class Something extends Reloadable {
[...]
}
abstract class Reloadable {
static final List<Reloadable> components = new ArrayList<>();
Reloadable() { components.add(this); }
static void reloadAll() { components.forEach(Reloadable::reload); }
abstract void reload();
}```
static void reloadAll()?
well ye its currently in my main class but i was just thinking
its for the dynamic reload impl of my plugin
I’d say the way you do it now is a bit too much of a design compromise
Shouldn't list be static too?
Oh, right, edited
i just got out of my bed
so id have to register that reloadable impl every time
why are we talking about inner classes
oh ye
if the player is online, it will get the players name
you can query the mojang api
probably ye
i got some code for it somewhere i think
why are you working with names and not uuids tho?
id def cache the result though
if you dont have a util yourself
theres some code i had
how do i make an entity continuously avoid a player? with what i'm currently doing, it seems as it doesn't care enough after like 5 seconds
public static void addRunAwayPathfinder(final EntityCreature entity) {
entity.goalSelector.a(0, new PathfinderGoalAvoidTarget<>(entity, EntityPlayer.class, 10, 1.2D, 1.5D));
entity.goalSelector.a(1, new PathfinderGoalPanic(entity, 1.55D));
}
Who development ?