#help-development
1 messages Β· Page 2196 of 1
y
c++ != java
?
isnt java channel?
Or others lang are support
Oh lol
Didnt know that
I think i have a new place where i can atomize with typescript questions
π€
it wasnt a syntax/language question it was just a cross-compiler thing
uh no
what
dont know what you mean with frontend
Yeah
ye ik but ive only used visual c# for frontend
@sterile token i think you're mistaking "frontend" with "clientside"
Mye
Lmao conclure included into my lang the "mye"
the client sends the message, then the server hashes the message, then sends the client the hash
same
if the client's hash doesnt match the response hash, then the messages are being tampered with
Because im doing a form validation which i send it as a POST into backend
But everybody can do that
So it a big issue
or It's Just Bugged
Fourten?
What Happens at my Local Mail Service
This is not a programming question
you can probably sue for that
But meh
not here
can you stop examining everyone's balls
are u bri'ish?
i cannot
π€¨
I dont kno
i talk english but nothing to be british
hhaha
I can also fallao portugues
i wasnt talking to you
sPAINish
voze fallao br?
el amigo aqui habla espaΓ±ol tambien
xD
Really?
i Have a lot of Friends from there
Decompilers don't make random fields final
they don't
there might be an option to tell some of them to, but they don't by default
The semantics of final is only enforced during compile time
I think they actually do exist in the class file, just most decompilers choose not to include them probably cause of performance or smthing
That's the Thing
But Recaf does the Final Fields thing to me
and i don't Put Final on those Fields
idk What Decompiler i used
that's kinda odd
i Just use Whatever it Works
always add it when you can
i use a plugin to do it for me
anyone know how to make chunkgenerator?
For Intellij?
i will Look into Using it
Looks Good
tell me
Let me get the post
im too lazy
You can only put ingots in the second input slot of the smithing table, right?
While that may be the case, there are also other benefits too besides mutations
serves for the compiler as a hint to apply optimisations??
You Help the Machine to Stop Looking for Another Modification of the Same Variable?
^ that and also it saves the programmer time
what if you want to find a variable that mutates?
would you want to go searching all around in your code
to find 1 god damn variable
lol
xD
im not mutating my variables by accident lol
Mutations aren't always bad
Sometimes you have to mutate something
You can't always assume that everything will never be changeable lol
anyways i see no reason not to rlly, unless you are really lazy or something, but at that point just use a plugin to do it for you
i just use final for every variable
until i think that i need it to be modified
final overrated x)
basically same case with kotlin val and var
yeah kotlin makes it a little bit more appealing
always use val until u need to use var
rust is just mutable and threadsafe by default
π
immutable*
devs getting fatter and fatter as technology progresses
2055: writes 1 letter code works
its like 12
im not sleepy yet aaa
im not either but i will be in class aaa
i dont drink that
idk it tastes weird
WHAT
smh
HOW DOES COFFEE TASTE WEIRD
coffee is ew
then u dont like both?
bruh
just smelling coffee makes my day
i loved coffee from my childhood lol
gn
Cofe is amazing
so what is an alternative for the || symbol, I am trying to get something to work where a listener detects if an arrow hit a block, but I realized that I need to listen for multiple different blocks, by using the or symbol, the problem is that Material. wont let you use the || symbol
loops
ok
Set<Material> -> contains
ok
could u give me an example on like how to use that
- Create a Set field.
- Initialize a HashSet
- fill it with Materials
- call contains on it in the listener
ah ok
Hi, does someone knows how to spawn an AreaEffectCloud with AIR particles (to make particles invisibles) through NMS? I can't figure out how to change the particles :/
Its an entity. You can just make it invisible.
I know, but then in spectator mode, you'll be able to see its "ghost"
Does anyone know why I am getting these errors? I got the code snippet from the Spigot wiki (https://www.spigotmc.org/wiki/connecting-to-databases-mysql/)
Code:
https://gist.github.com/Christian-Madlansacay/e824c41dff255d3ea5ce162d5c28e107
Errors:
';' expected:19
')' expected:19
Not a statement:19
Unexpected token:19
Unexpected token:19
Not a statement:19
Unhandled exception: java.sql.SQLException:20
Unhandled exception: java.sql.SQLException:21
Unhandled exception: java.sql.SQLException:22
Make the effect cloud server side only by cancelling packets to the client
do you even use an IDE?
Lest see ur sql statements
I am working with some GUI stuff, and was wondering what this Component is. I can't seem to find documentation on how to initialize it or how it works, but maybe I'm just blind. In this case I just want to give a string, but not sure how to make the component a string
I use IntelliJ IDEA
I need the entity to be visible client side since I use it to make holograms which is why I'm looking into NMS since I need it to be visible per player (already works via the normal API)
Huh?
Oh. I forgot about that. My bad...
That seemed to fix it. I believe
is there a better way to search a 10x10 cuboid? https://gyazo.com/57bc67d43ce01f1d3a7388fe0eef1af9
for what reason are you creating a new location to add to the arraylist?
could just do block#getLocation() no?
yeaa true. but i do feel like its cleaner
just my opinion ig haha
though i get annoyed over little things
for example the fact that ur looping Y->X->Z
i would never do that to myself
you right
bless up
we got anything for ArmorEquipEvent?
or does anyone know a way
https://www.spigotmc.org/threads/arnuhs-armorequipevent.545188/?__cf_chl_tk=usBV4iB1FboKK4FXn1YA473E7Ih7Gk6ouPpnmZaeGnk-1654559202-0-gaNycGzNCZE could consider this
awesome
if anyone knows what a component is :(
When my plugin runs onEnable, can I immediately access the scoreboard? or do i have to wait
hmm, it says it is only loaded ater the "first world has been loaded"
do plugins load before or after
okay i looked and it looks like they do so i should be fine but pls correct if im wrong there are no javadocs on onEnable
Plugins load after the world loads
Unless u want your plugin to load before then it won't
Sorry
frqnny most stuff is accessible when onEnable runs
things like the scheduler isnt
how do I check if a player is critting?
how to check if hit is critical hit in damage event?
if (player.getFallDistance() > 0 && !player.isOnGround()) event.setDamage(event.getDamage() * 1.5F); fig out ty guys
?paste
for some reason this will not stop throwing a NoClassDef exception. I have everything the same as what's in the github from mfnalex as well as their website on how to shade. I've tried a different dependency as well and that doesn't work either
getEntity in PlayerDeathEvent returns the player that died, right?
Just wanted to ask, does using the inventory#getSotrageContents() give you an array with only itmes, or are there placeholders
yes
for emtpy slots
how does pathing work inside a jar file?
i'm trying to get a resource with the path 1.13\somefile.yml
should i not use \
ill try / and report back
generally I reccomend staying away from \ for files your going to want to use /
nvm i used / and it worked
\ is a windows only thing
i didnt use \ intentionally
used File.separator
jarfiles use / i assume cuz / works now
unix standard for file seperator is / generally safe bet is File.Seperator
Alright, here is an advanced reflection question
I am writing a automatic annotation based nbt serializer
As such, I have "NbtParser" maps which map a certain type to a valid nbt element
The NbtParser has two generic parameters, the origin type and the resulting nbt element
But since I am iterating reflectively over annotated fields, I don't have any specific types
So how can I capture the actual type of the field in a way where I can pass it to the parsing method?
reifiable types
are spigot 1.16 and 1.18 fully backward compatible?
cause Im trying to port a mod from 1.18 and i noticed i accidentally had 1.16 as the main dependency and never noticed till now
wdym
depends I wouldn't be so certain a lot can change with certain aspects of the API all depends what your working with. Usually I'd try to do forwards compatability vs backwards compatability for plugin support as it can be a bit strenuous to support older API
Again its not safe to assume. I'd do quite a bit of testing
i accidentally made it portable is what Im saying
like I made a whole mod for 1.18.2 using the 1.16.5 api
a 1.16 plugin should fully support 1.18 depending on the use-case
I thought you meant the other way around
I did say it like that
1.18 plugin meant for 1.16.5
so i understand your confusion
yea you should be fine, but its just better to use the most up to date API in the future as I'm sure your aware there are more features and stuff
how can i add damage to the base damage i deal to a mob? I have a strength system where if you have 4 points of strength, you deal 1 extra damage so if i do 5 damage base, and have 4 points of strength, id deal 6 damage in total
weird
probably something with EntityDamageEvent check that out
yep im using that event but there is no real addDamage or something
plugins {
id 'java'
}
group 'me.xyz.abc'
version '1.0'
repositories {
mavenCentral()
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' }
}
dependencies {
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
}
task afterJarRemoteCommands(type: Exec) {
commandLine 'cmd', '/c', after_jar_remote_script, jar.getArchiveFile().get().asFile.getPath()
}
task afterJarLocalCommands(type: Exec) {
commandLine 'cmd', '/c', after_jar_local_script, jar.getArchiveFile().get().asFile.getPath()
}
this is my build.gradle
works for 1.18
but not 1.17
π€·ββοΈ
or maybe, is there a way to get the damage i did then add another damage point and set that to the damage i should deal to the mob?
double dealtDamage = damaged.getLastDamage();
damageModifier = userStrength * .25;
edmg.setDamage(dealtDamage + damageModifier);```
just did this
should hopefully work
LivingEntity#getHealth, LivingEntity#setHealth may be of your interest oh also EntityDamageEntityEvent#getDamage and setDamage
yep that will probably do the trick π
im now even more confused
it doesnt work for 1.16 either
even though build.gradle says 1.16
its because you specified your api version in your plugin.yml as 1.18
ah
plugin.yml -> using 1.18
gradle using -> 1.16.5
[21:10:38 ERROR]: Could not load 'plugins\DuelPlugin-1.0.jar' in folder 'plugins'
org.bukkit.plugin.InvalidPluginException: Unsupported API version 1.18```
org.bukkit.event.EventException: null```
what exactly does this mean?
need more of an error than that
?paste
send everything
the entire error or the code?
entire error
lets see where you register the event at
Where do you register the even though?
oh in a class called EventListener
also did you send the entire stack trace with the error? I'm not seeing any of your classes in there
you may be registering it incorrectly would be my guess without seeing much of anything from the rather incomplete stacktrace
lemme get it to print a stack trace
well see, its other events work fine
but this one doesnt
are all your events in one class?
nope, only the smaller ones
well since that stack trace you sent doesn't see the whole picture something in teh code you sent is null
the stack trace should tell you exactly where hunt out for your class names in it and it should provide an exact line
?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.
thanks bro
seems like an database error which is weird as hell
lol
1s
SQLStatsHandler data;
whats the right way for me to instantiate this?
i'm not sure how your sqlstatshandelrclass looks
however your constructor looks would be my guess
Yes sir
so based off this, how should i be instantiating it?
i had this same issue earlier but i got no idea what i did to fix it
Just create a new object but I'd be passing the same one around if your dealing with a db a bit overkill to have so many connections open
instantiate in ur main class
create a getter
and get it frm ur main class in your lsitener
im so lost lol, ive lost the ability to think this.data = new SQLStatsHandler(this); this?
this is in my main class
Yes
And create a getter
Then pass your main class to ur lostener the same way u do in ur statshandler
And do plugin.getData()
And voila u have ur data instance
where should the getter be made?
Main class
public SQLStatsHandler getData() {
return this.data;
}
like this right?
yes
and wdym by this?
public SQLStatsHandler(ThunderLearn plugin) {
this.plugin = plugin;
}
do something like that with ur listener class
so then u can do this.plugin.getData()
and u have the data
this goes in the Listener?
uh i already had one in this class java public EventListeners(ThunderLearn plugin) { Bukkit.getPluginManager().registerEvents(this, plugin); }
should i just modify this one?
yeah
how did u write a whole sql data class without knowing abt constructors and dependecy injection
lmfao
im fairly new to java with basic knowledge but ive working with python a lot so i have some programming knowledge
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
read that quickly
ig u already read it hence why ur passing ur plugin instance to constructors
public EventListeners(ThunderLearn plugin) {
this.plugin = plugin;
this.plugin.getData();
Bukkit.getPluginManager().registerEvents(this, plugin);
}```
should i be removing that second line?
feel like it shouldnt be there lol
yeah
u can have a data instance in ur listener class
or every time u wanna get data just do plugin.getData.whatever method
goddamit still getting this.data is null
yeah cuz u didnt set this.data to this.plugin.getData
oh shit wait
obv it's still null
this.plugin = this.plugin.getData();
like this..? in that code i sent above
no
sorry if im being stupid lol
how can u set plugin to be a data
yeah thats what i was wonderin
thats like setting an integer as a string
then what exactly should i be doing :thonk:
think abt it a bit
so like, I want to check if a player shoots a target block but the thing is, that 'Material.target' is not a thing so what should I do
i need to set this.data to this.pluget.getData(); right
Material.TARGET
that doesnt work
ok then
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
I am missing something
What version of spigot are you on
And what version are you depending on in your build script
it'll be there in 1.18
is there any quick why of just switching my plugins version?
Wdym?
like switching the spigot version from 1.15 to 1.18
Do this.data = this.plugin.getData
Maven?
k
i needed to just remove the parenthesis!!?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
ty
that doesnt sound good
do this.data = this.plugin.getData
oh my gosh
@humble tulip it still doesnt work in 1.18.2 π
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
so much fun
it does
not for me atleast
did u reload ur pom?
is nms used for NPC's or can i do it thru spigot
u can use citizens or nms
I just remade the plugin, it was way easier sense the thing was short
which is better iyo?
citizens is easier
then ill do that once i move to making npcs
nms is messier but ur plugin wont depend on another
depending on ur plugin tho u may wanna go nms
like a minigame plugin, u wanna do nms
if it's for servers like survival or prison that's gonna have citizens already feel free to use citizens
what version were u using in that screenshot?
1.18.2
ok then idk what to do
remade what?
because I put it in 1.18.2
where?
in the external jars...
remove 1.15
lol wtf
ok
use maven
is it ok to have a long ass method to load a file?
sure
idk bro
if u had maven all u had to do was change 1.15.4 to 1.18.2 and click a button
ok
for example this is my method to load recipes from a yaml, it's long as hell too https://github.com/JEFF-Media-GbR/JeffLib/blob/dc71756f3b0371480d4895a9c1ec7834e8aca9c9/core/src/main/java/de/jeff_media/jefflib/RecipeUtils.java#L40
sure
most of them are just checking that the user isnt stupid tbh
seems ok to me on first glance
how can i combine a sharpness 6 book with my sword? can i do this thru some event?
me half the times i make a project
listen to anvil event
there doesnt seem to be an anvil event
or inv click even or something
declaration: package: org.bukkit.event.inventory, class: PrepareAnvilEvent
oh cmon bro, another guy and i were looking for it yesterday and we both didnt find it
I just googled "spigot anvil event" lol
hmm, there doesnt seem to be a way for me to get both the items placed in the anvil slots
of course you can
getInventory() returns an AnvilInventory
then you can check the items in the first 2 slots
and then set the result
oh well then, and how can i get the player who opened the anvil? maybe im stupid but you cant do like e.getWhoOpened or something similar to an inventoryclick event
check the viewer of the inventory: event.getInventory().getViewers().get(0)
what does .get(0) do exactly?
getViewers returns a List, and get(0) gets the first one from that list
since anvil inventories are unique to everyone, there will never be more than 1 viewer anyway
Performance Better
I saw a prem resource that there is none similar to and i feel like i can make a better one. should i give they guy some competition?
i wanna do it just cuz
eclipse is simply stupid
it always wants you add random casts
intellij is so nice
for example if you do someItemStack.getDisplayName() it suggests you to cast someItemStack to Player
lmao
Have you tried?
yes, I've used eclipse until 2 years ago
it's simply stupid
try this
Why?
hmm yes, lets do that!
because of what I said
^
Oh
to You prefer this to performance
I mean wtf is this
instead of telling me "getDisplayName() is not a method on ItemStack" it adds a random cast to Object and obviously there's still no getDisplayName
isn't getDisplayName only on ItemMeta
ItemMeta
and IntelliJ has problems like that sometimes too lol
IntelliJ cache drives me crazy sometimes
IntelliJ at least tells you "there's no method called XYZ on class ASD"
reading baeldung tutorials are so much shit
fucking need to invalidate like 5 times for it to work
ah well yeah that's what happens lmao, it doesn't suggest nonsense like that
yes
bro I know that
i just used this example to show you how shitty eclipse is
alex do you have the new UI preview
instead of giving a useful hint, it just makes everything worse
no
did you apply for it
no
why would I exchange my sweet intellij ultimate with a weird hamburger app
LOL
It has nothing to do with being bad, it has good features that it does not have intellij, and also Intellij has good things that it does not have eclipse
it's ok and not ok at the same time
it looks nice but some of the things are terrible
once I switched to intellij, I have never looked back, not for a single second
I noticed instantly that I can't select a whole line by clicking to the left of a line number
@EventHandler
public void AnvilPrepare(PrepareAnvilEvent e){
Player player = (Player) e.getViewers().get(0);
Inventory anvilInv = e.getInventory();
player.sendMessage(anvilInv.getContents().toString());
}```
that final line sends an... uh... well not the items i guess
all it does is add a break point
and the entire top nav bar is collapsed into a hamburger
I used intellij for large projects and realized that it takes a long time to index and sometimes you get very lagging and I can not code properly so I went to Eclipse and it is much faster
like actually just let me select the line pls
yeah maybe it is indeed faster, idk. all I can say is that I'm very glad that I switched away from eclipse
for example eclipse's maven integration is upper bullshit
it breaks everytime when you have a .project folder lol
yeah it needs a plugin
@EventHandler
public void AnvilPrepare(PrepareAnvilEvent e){
Player player = (Player) e.getViewers().get(0);
Inventory anvilInv = e.getInventory();
player.sendMessage(anvilInv.getContents().toString());
}```
that final line sends an... uh... well not the items i guess
and mfnalex, is your name alex or jeff...
it's mfnalex lol
or do you mean my real life name
True, eclipse are harder than Intellij, and some do not
he means ur irl name
irl, unless ud rather not share
my real life name is ALEXANDER CHRISTIAN MAJKA!!!!1111one
christian
im doxxing you as we speak
weirdchamp
lol
because that's how it works
cant dox someone if they dox themselves first
that could be a bad idea
Information pursuant to Sect. 5 German Telemedia Act
JEFF Media GbR
JunkerstraΓe 17
48153 MΓΌnster
Represented by:
Herr Alexander Majka
JunkerstraΓe 17
48153 MΓΌnster
Herr Nikolai SchΓΆning
BodelschwinghstraΓe 7
48165 MΓΌnster
Herr Tobias SchΓ€uble
BrΓΌderstraΓe 14
48145 MΓΌnster
Frau Marlen Beckmann
A
it's required by law
it's a requirement
oh
thanks lol
but i do need a response, i cant use .getType on it, should i be putting it in a for loop?
getType on what?
.getContents should allow me to call getType on it no?
Bruh
remove the borders around the icon and I can't complain
i like the borders
the icons aren't centered properly lol
it sends the memory location or whatever the name is
look at like the phone and mic, then the graph
the icons are aligned to the upper left
oh that's what you mean lol
alex
no idea where the icons are from
what does it say?
tell him to shut up and do its job
lol
so
anvilInv.getContents().toString() gives me what i said above
right now im tryna use NMS and even the plugin to remap the jar just doesnt give me any jars
did u run buildtools?
https://gyazo.com/93651b51741c9eb294497fb96a63e32d theres supposed to be stuff here right?
yes
with --remapped?
yes
check out this: (1 sec pls)
then i cant help cuz i followed the steps on spigot and like magic it worked
still cant explain it
and then to compile just run mvn package
I can see that none of the representatives on the site notice are named Jeff
how exactly did you come up with that company name π
I shit you not, but: noone at microsoft is called microsoft too π
holy fuck
I watched 21 Jump Street
I hadn't thought about that
lmao
just so you know I'm emailing HR about your transgressions.
i copied and pasted EXACTLY how it is on the page, built it, no jars
send ur pom?
?paste
i love you
lmfao
did it work?
yes
awesome
lovely, can i set a artifact to build that directly to my test server plugins folder like i do with other projects?
sure, one sec
bro has a blog post for everything i swear
yeah well
when you explain the same things over and over again, you get tired and just put it into a blog post
understandable
i love you and your blog posts bro
π
im straight but if ive got a problem alex for sure has a blog post
for FAQ #1 if you're shading you can just <finalName> in the <build> section and it works π
do u know how i can allow ppl to put boolean login in my plugin
yes but then you cannot change the output directory
welll
π
whoever automatically builds into the plugin directly is irrelevant anyways
What time is it there?
nothing wrong in doing that for testing etc
6:10 am
lmao I'm just messing with you
I almost died :<
._.
is there a quick and easy way to make my plugin load jars?
quick and easy, I don't think so
like a lib or something
in my folder
@EventHandler
public void AnvilPrepare(PrepareAnvilEvent e){
Player player = (Player) e.getViewers().get(0);
Inventory anvilInv = e.getInventory();
player.sendMessage(anvilInv.getContents()[0].getType().toString());
player.sendMessage(anvilInv.getContents()[1].getType().toString());
}```
how come it sends the message 3 times per item i click into the anvil gui
quick, print out the byte code and slam it in a frame and hang it on your wall
forπ
https://blog.jeff-media.com/dont-jump-off-bridges-or-why-you-shouldnt-use-exceptions-to-control-code-flow/ and another argument for this is that it generates a stack trace, I believe it does that on construction and not when you call getStackTrace()
Maybe PlayerInteractEvent
yeah that's true but I'm too lazy to edit it now
i want you know alex that I was tryna figure out whether to use protocollib or straight nms and i saw a message in here you sent that said protocollib was too complicated and i said "im using straight nms then"
ProtocolLib is really useful to listen to incoming packets, but I'd never bother using it to simply send a packet
god maybe I should make a blog
sure, same as my portfolio it'll be W.I.P for the next, approximately, 1 to 2 years
@jagged quail has a really useful blog too https://blog.oliver193.gq/how-to-jokni/
Generated with: Jekyll v3.9.2
Author: oliver193
oh no he removed the pictures
is there any way to load a single function externally in java and execute it at native java speeds? i see i can run javascript files but idk if that takes place as fast as running it as java after after the .js file is loaded
we recently found a plugin on spigot that included a ton of .dll and .so files lol
for(int i=0;i<anvilInv.getContents().length;i++){
player.sendMessage(anvilInv.getContents()[i].getType().toString());
}```
still keeps sending the message 3 times
link pls
yeah well that makes sense
it does? what am i doing wrong
you have 3 items in the anvil inv contents
oh right..
first slot, second slot, and result slot
let me try to find it
ty
I think it was removed
probably, I and other people reported it. I'm currently checking my notifications but it seems to just be gone
it SHOULD be here somewhere but it isn't D:
yeah what should i be doing to fix that? i want to take it out of the for loop too and all but im not sure how to get the items in the anvil
i have this class
you just do this
ItemStack firstSlot = event.getInventory().getContents()[0];
ItemStack secondSlot = event.getInventory().getContents()[1];
if(/* whatever */) {
event.setResult(/* changed result itemstack */);
}
OH COME ON MAN i did something so similar
i wish u can just drop a .java file somewhere and execute it in java
fk it gonna use java script engine and js
@humble tulip for this, you'd have something like
public class DisplayNameExtension implements Function<Player, String> {
@Override
public String apply(Player player) {
return player.getDisplayName();
}
}
that'd be compiled into extension.jar. For simplification, I'm going to assume you have the class file DisplayNameExtension.class from the jar already, however there are ways to get that programatically because a jar is just a ZIP basically.
Then, you'd class load using https://docs.oracle.com/javase/7/docs/api/java/lang/ClassLoader.html#defineClass(java.lang.String, byte[], int, int), which gives you a Class object. From there, you can create an Object with the Class by using https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#newInstance. With that, you can cast it to Function<Player, String> and call casted.apply(player) to get the display name of a player π
None of that goes into details, but that's how you'd load Java classes at runtime & invoke code from them
IIRC one has to get the list of constructors and then create an instance from that, but anyway, doesn't change the fact that what you said is probably the answer to minion's question :3
i'll let them specify the jar file and class path in a config file
lol yeah it's deprecated since java 9
lmao my browser takes me to JDK 8 docs whenever I search "something javadocs" so
same lol
np minion, best of luck
if this works i'll make an extension lib
and have extensions in all future plugins
cuz why tf not
well typically it's best practice to make an actual API
that plugins can depend on & use
then if there's anything plugins need to hook into or change before you perform logic/execute you'd use the bukkit event bus
RIP
Some plugins don't do this, like PAPI has a mix- the API exists completely but extensions are downloaded & loaded at runtime by a separate class loader, instead of the pluginclassloader
yeah im aiming for something like that
it'll have an api
but it can also load extensions
I'd check out the source of PAPI or similar plugins like BentoBox to see how they are doing it
who thought papi was a good acronym
listen here you little shit
oh this was easy
never said it'd be hard
though am surprised you got it that quick
I didn't explain how to get the Jar -> class file -> bytes kekw
i had no need to do that?
URL url = new File("test.jar").toURI().toURL();
URLClassLoader classLoader = new URLClassLoader(new URL[]{url});
Class<?> clazz = Class.forName("me.saif.test.Main", true, classLoader);
that only works if the other .jar is also a plugin
not if you want to load it yourself
oh
that's what i have
ok now you edited the message
sorry xd
lol
would it unload safely if say my plugin gets unloaded by plugman?
or do i need to unload somehow ondisable?
the class will still be loaded in memory
but that won't cause any problems perse unless it's still executing logic that depends on your plugin be enabled
but with no references to it gc should clean it up?
the class itself will still stay loaded. that's why stuff like
static { ... }
ever only runs once
I wouldn't worry about it
i can close the classloader
I'd simply tell people to not use Plugman lol
i'll do that to just be safe
btw how does spigot know when i use a dependency that i dont have softdepend or depend for?
every plugin has its own classloader IIRC and it's a custom one
lol funny name "maybePlatformClassLoader"
this is the code you were looking for
when i restart the server, it closes too fast and my stuff on onDisable() stops abruptly, what can i do to tell spigot to wait until my stuff finishes?
this doesn't happen when i shut it down though
you can do anything you want in onDisable
unless you are scheduling new tasks or similar
ah thats probably why
its async
so if its not it waits until everything finishes?
yeah you should run stuff synced in ondisable
gotcha
alex you have any experience adding potion effects to mobs using nms?
this what i got rn
no sorry
no blog post π¦
I never really did any stuff related to NMS mobs besides spawning holograms
im tryna spawn a magma cube in a block and give it glowing and invisibility
hm as said, no idea π what's the issue exactly?
just spawning with no glowing
hm what exactly is the "12" for?
okay and the "2000, 0, false, false"?
maybe you could set the NBT tag for the glow before you send out the "spawn" packet instead
maybe you can do what CraftEntity#setGlowing is doing before you actually send the "spawn entity" packet
damn nothing
hm then I also have no idea :<
yeah if you find out pls ping me, I'd be interested in what the problem was ol
because both the packet, and setting the NBT tag should work D:
wdym NBT tag?
CraftEntity#setGlowing is setting a special NBT tag IIRC
the NMS Entity has the following method:
public void setSharedFlag(int i, boolean flag) {
byte b0 = (Byte)this.entityData.get(DATA_SHARED_FLAGS_ID);
if (flag) {
this.entityData.set(DATA_SHARED_FLAGS_ID, (byte)(b0 | 1 << i));
} else {
this.entityData.set(DATA_SHARED_FLAGS_ID, (byte)(b0 & ~(1 << i)));
}
}
and CraftEntity calls it like this to enable glowing
setSharedFlag(6, true);
i dont think I can get the craft entity from the packet can i?
no but that's not needed
simply do yourEntity.setSharedFlag(6,true)
BEFORE you send the "spawn entity" packet
I have no entity
huh then how did you get the UUID of the entity?
lmao I'm just testing rn with one entity and just put 12
mbmb
so
lmfao
you should create an instanceof the NMS entity
and then use that in the packet
for example, this is how I spawn holograms
entity = new AreaEffectCloud(world, location.getX(), location.getY(), location.getZ());
then you can just pass that entity into the packet's parameter
new ClientboundAddEntityPacket(entity)
and yeah between those two, you can do the setSharedFlag(6,true) thing
and then it should hopefully work lol
why is it yelling at "serverPlayer.getServer()" ?
nullpointer
hmmm then I really have no idea :<
but its not or else it wouldnt create the entity right?
does it work fine if you use a bukkit slime?
maybe glow only works for certain entities? idk
yep
i mean you can add glow to normal magmas in game
hm then it's weird, sorry I have no idea
all good, appreciate you tryna debug with me
ooh I see
I know a pugin that aso does this but they are using ProtocolLib. but maybe you can check it out nonetheless how they do it
where did you get the 6 from in #setSharedFlag()
CraftEntity#setGlowing
Tweakin, it's on spigotmc and github but yeah as said they use protocollib
this is from the NMS Entity class
and that's what CraftEntity#setGlowing calls
yeah i just saw and i tried to just call setGlowingTag but it didnt work either
potential @tender shard
how tf does java do memory
Hi tell me the best way to clear all mobs in a certain radius from a given position
malloc I guess lol
ConcurrentModificationException
or not? idk
maybe it works
maybe
yeah should work since remove() is a method on the entity and not remove() on the collection
yeah you're probably right
Thanks. However, I have heard that there is a way in which suitable chunks are allocated and completely cleared of mobs. Will this method be faster?
wdym chunks that are allocated
you don't have to worry about the performance of looping over entities and calling remove() on each
yeah no thats a really quick
And if there are 10k + monsters ? sorting through so much is no longer fast ..
I thought you were doing getNearbyEntities()?
How do you spawn particle BLOCK_MARKER with specific material?
there wont be 10k near you they'll have despawned or not generated yet right
just toss in the blockdata
alright, thanks
anyone know why intellij could possibly not allow me to add files to git versioning?
I've never really seen this before
is it in your .gitignore?
example:
player.spawnParticle(Particle.BLOCK_MARKER, player.getLocation(), 1, Bukkit.createBlockData(Material.DIRT));
hm
you do have a git repo in your project though? π
yeah, I do
I can commit my main class which tbf on this project is the only class file
but I wanted to add the plugin.yml and some of the gradle stuff
what happens if you run git add filename manually? it would probbaly either work or show a message that explains why you can't do that
Material.BARRIER.createBlockData() π
or that lol
however, during the getNearbyEntities call, the server takes all the existing monsters in the world and returns the ones I need with the usual brute force.
fatal not a git repo: .git
you can also get all entities in a Chunk using Chunk#getEntities
but it is a git repo
then you do not have a git repo :/
ok how can I nuke this garbage
lol that's weird. you could rename your existing .git folder and create a new repo
it doesn't really matter this was something I started like 4 years ago and only has a couple of commits
simply rename or delete the existing .git folder, restart intellij, then do VCS -> Create git repo or however its called
you know what I just realized I don't see a .git folder
but intellij still says this is a legit git project
I think intellij had a stroke
btw intelliJ won't show the .git folder
hm that is really weird
idk if it's "hidden" on windows by default
let me check
yeah it's hidden
it isn't, I checked on my main project and I can see the .git directory
I mean I can see hidden files
not that it's not hidden
it's hidden for me
ooh ok
yeah well if it's not there, it's not there. very weird
I mean
it even gives me a proper git log... I wonder if it's reading it from online sources?
but it gives me a local... wtf
maybeeeee your .git folder is in a parent folder or sth? i have no idea
nope
then I have no idea :X
ok guess I have to find how to nuke an invisible git repo...
if the repo is in the same folder it should look like this
yeah so the git repo is at the level of my class, that's why
aah
it can't add files that are above its own directory
yeah that's definitely not good
how large are you gettin gthe nearby entities
no clue of how this happened, this is old enough that it might've been an issue with passing things on from netbeans to intellij
yeah just remove the old .git, restart IJ and do a new one :3