#help-development
1 messages · Page 1938 of 1
click on the general compiler section
isnt actually mine but yes
oh yeah and guess what
it's actually enabled for me
but
it doesn't add anything to the code
im confused why result.entity[0] is null
so maybe its only for intellij internal build system
because tbf who compiles by clicking on "export"
and when you compile with maven and gradle it doesnt work?
As said
Because you never set entity.result to anything
Build automation tools manage this
did you reload the maven changes after changing the pom?
it is
for instance you must declare annotationProcessor with gradle if given library is to be used as one dovidas
No...?
Undoubtedly something similar with maven
well they set entity to gson.fromJson
print out entity
and print out entity.result
there is no maven
right-click pom -> add as maven project
what are you trying to get from this JSON?
Nope
something MUST happen when you click on "Add as Maven project"
the result[0] info
are yo usure this is what you did?
yes
it's returning, he just isn't getting the result array it seems?
im noobie with gradle but im trying to get away from maven since paper stopped supporting maven as much as gradle, so if i want to bring back intellij's functionality of annotation processing i would need to specify the dependency of processor?
did you actually replace A-KEY with a valid key?
yes
obviously
how is that obvious
oh wait - CoordsJSON is your own class?
yes
class CoordsJSON {
ResultJSON[] result;
}
yep
doesn't look like you ever set it to anything
how do is set it
entity.result = whatever??
@NotNull vs @NonNull, which do you use?
where
?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.
bruh what do I know. I have no idea what you want to set it to or why you even need that class
just always use Lombok 😛
@NotNull
I use NotNull to simply declare "don't make this null" and NonNull if I want it to actually check if it's null
@NonNull/@Nonnull is already javax.annotations and checkerframework (or whatever it is), so I'm using something I won't accidentally import
unless entity.result[0] is being called on the JSON response? wouldn't that not work? don't you need to getJSONArray("results") and then get the JSONObject in there?
should i add precondition clauses inside the method body
never used Gson before lol
I doubt that Gson can simply create any class without declaring it how it should do so
that is up to you
i like conventions
If you do static analysis and do it in a pedantric fashion there is little reason to check for nullabillity at runtime unless you have an API
I thought this all was about creating an API lol
didn't fully catch that
it wasn't mentioned, I just thought it
ok
my rule of thumb: if its internal - don't, if its meant to be public - do because there are monkeys that could pass null values into methods
Think of the CPU cycles
Honestly, it isn't really your fault if they do not interact with the API in the right way
HEY
HELLLOOO
I need help please, im really stressed
I see.
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
here's help
?permissions grant @quiet ice owner
Syntax: ?permissions
canrun Check if a user can run a command.
explain Explain how permissions works.
aw
Im trying to create this class:
HttpRequest request = new HttpRequest.builder().uri("http:google.com").headers(bla bla); // How can i do this?
I have been with this for over an Hour
class?
make builder() a static method that returns new HttpRequest()
Mfnalex
and then just do HttpRequest.builder()
and what'Äs the problem
I explain
?paste
HttpRequest = Class
Builder = inner class of HttpRequest
here's my very simple ItemStack builder class
but I am not using a static builder() method
Do you want to use this or recreate?
recreate
I just do new ItemBuilder(Material.DIRT).setLore(someLore).build()
Yeah my problem its that i want to skip the new ItemBuilder()
Thats its killing me
a JEP similar to the jspecify specs might be proposed once jspecify has been proven in production
public class HttpRequest {
public static Builder builder() {
return new Builder();
}
class Builder {
}
}
???
I don't really understand the problem
but there you are not using an inner class
oh, you probably forgot the static
question, what's the best way to learning all the options that spigot has for plugins like all the settings and possibilities
do you just like, stay on the api page for years researching?
As a rule of thumb, in 80% of cases there is nothing wrong with using static class when declaring inner classes
well I don't really care about features I don't need to use
the general rule is that a class should be static if it doesn't need the other class
The javadocs are your friend
I have this class and i cannot access to .build that its what its~~ fucking~~ me https://paste.md-5.net/aqemefeyok.java
javadocs? what does that refer to
?jd
Sorry for bad words but im stressed
because you didn't add any builder() method
teach others, expand on your knowledge by adding new features to your plugin I'd say
yo @opal juniper and i need help. important. please vote <#general message>
o ty
ah okay
The builder method must be only on builder class
wat
the point of a static factory method for the builder is to decouple builder instantiation from creation (which comes with some benefits, namely easier to support)
Wait with this https://paste.md-5.net/aqemefeyok.java i cannot call build() mehod
that makes no sense
Do you want to use Builder.builder() or HttpRequest.builder()?
You do not have a #build() method
You want to use HttpRequest.builder() so HttpRequest needs a method that returns Builder
you create a new Main in your COmmand class
you must never ever have more than one instance of your class that extends JavaPlugin
do you know basic concepts of OOP?
I want to use it like this:
HttpRequest request = HttpRequest.builder().build().paramA().param();
- Should create HttpRequest instance
- builder() should create inner class instance (Builder)
- build() should return me the HttpRequest instance
Explain?
I have told you 5 times
to do this:
It doesnt work
public class HttpRequest {
public static Builder builder() { return new Builder(); }
}
it does work
But how i create http isntance?
what is http instance
thats not rly the intention of the builder pattern
like you always invoke build() lastly
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
He’s using us for website traffic!
yeah because I profit so much from traffic on a website that doesn't sell anything 😄
Yes
99% of my traffic is my api 😦
IP logging
Hmn?
No I just want know if I let all servers make connection to database or if I let a server or proxy to make calls at the db ?
what's the problem with having all servers connected to the DB?
oh yeah let me check the IP of whoever visited the link last
someone from UK
Ireland to be precise
huehue now I will sell this information to...
erm
Wait
Coll do you want to buy this information?
Northern Ireland?
nfalex
Not working
I only saw "Ireland" on the last line
Really it doesnt work and im stress
all those details you provided are hurting my brain
?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.
my child
I explain all again
I know what you want to do
Ok
but you didnt tell what's not working
You know what @sterile token
just switch to Lombok
There please 1 oportunity more, this last code https://paste.md-5.net/yuduhupedo.java
I have fixed all
?
you still don't have a builder() method
there is no builder() method
But not the protected constructor
in what line should it be?
This last link
oh you named it newBuilder
ye
well okay, a bit weird but sure, it works
looks alright
if i add a plugin as an external library, initialize a class from it, then use its methods after checking if the plugin is installed, what are the dangers of this?
well why do you provide "this" into the builder
tho the "this"
makes no sense
instead of giving an existing HttpRequest(), the BUILDER is supposed to create one
that's why it's called BUILDER
remove this inside the () and remove the Builder constructor
and simply do HttpRequest request = new HttpRequest(); in your builder class
also wait whut
this whole thing is fucked up
You will get a CNF if you try to initialize a class from it without it installed
Why is this still broken
your builder requires a HttpRequest and your HttpRequest requires a builder?
that makes no sense at all
I said after checking if its installed though
?
Look im tryin to do somethis like this:
I take it from OkHttpClient but the thing its that i dont want to use a new HttpRequest i want to be static
Then you’re fine
yeah you know
fuck it, I'll rewrite it completely for you
"Does not working"
I choose to believe that’s intentional
Does not is work
Thank you very much indeed, because I got a blue fart trying to do this
myes
Sorry for tag, but just i need the Request class with the builder inner class
Them im fine
@sterile token make your life easier
use lombok
import lombok.Builder;
import lombok.Getter;
@Builder
@Getter
public class HttpRequest {
private final String server;
private final Integer conTimeout;
private final Integer readTimeout;
private final Boolean redirect;
private final Boolean cache;
}
this does everything you want
Or just generate a builder with intellij lol
how?
there's no Builder for me in idea
let me open IJ
rather sure its been around for quite a while
No please
I hate lombook
good
well it creates perfectly working builders for you
please don't torture me
yours is totally flawed 😛
Not matter
Verano I very much share your feelings concerning lombok
As do I
Conclure is a very smart dog so I agree with whatever they said
to each their own ¯_(ツ)_/¯
Just use delombok afterwards
mfalex but please helpme without using loombok please
I rather spend my time creating real code
weird flex, but valid
I rather spend my time not using java 🙂
ye
Just use python :D
and iirc you can actually change the template it uses to generate the builder 😛
Oh?
Hey I'm from planet minecraft
Hi from planet minecraft
Meanwhile I am not even OP on my own server
weird name tbh
/op @e
generally isn't needed anyways XD
😢
Really thanks it works perfect
the code I sent is from lombok 😛
That’s not the vanilla /op output
it is
Really?
Wft loombook use the same as i was trying to do?
prolly, tho I personally oppose lombok
Ah
can someone explain the hate against lombok?
Still haven’t fixed the spacing smh
🥄
why do you send a soup eating device
🍲
where's the problem if it works?
Well, for one, I don't think you should use setters at all.
erm
why
immutability
Well thats both yes and no, kinda a double edged sword gepron1x
that makes no sense
Some things have to be mutable
*most
Unless you want to like
imagine having mutable events
Make a new home instance to rename a home
imagine doing this
public void onSomeEvent(SomeEvent event) {
event.cancelled = true;
}
That's fine
WHY though
I agree, not everything should be immutable
sure you get thread safety, but like, as soon as you your project scales to millions of lines of code, you will end up layering your code, where each layer must use an api to talk with another layer, in which creating contextual objects might be necessary thus setters and getters might be needed.
I don't think that "lombok is a compiler hack" is any reason to not use it
Well tbf, lombok is just useless
CraftBukkit also is a "vanilla hack" yet most people here use it
how?
imagine the builder class from above
now you add a new field
it doesnt add any inherent abstraction like most other libraries do in some way
you now have to create the new builder methods
Meh
You can just regenerate the builder
and it damn requires an ide to use
it basically does the same that intellij does
which you may not always have
yeah but with lombok you don't have to
intellij allows you to expand if you want to
But breaking on every java release
lombok? how does lombok require an IDE
it merely virtually collapses
lombok does not require any IDE
you sure?
as far as I am aware it does require an IDE
Lomboker
alr cool
Lombok is nice, but like most things some like it, some dont
Are you telling me
nah
That a lot of programming is personal preference?
Loomboks sucks
^
For all the people saying it breaks shit, etc, ive never had that happen to me at all, and I havent heard a single person in this discord say it broke anything for them
Where would you recommend me executing the get, post, methods? on HttpRequest class right?
I am still looking for a VALID reason why lombok sucks
who said this?
except all the features it has
"Imma do everything procedurally in static methods cuz u know personal preference"
"bro wtf maintainability means"
which do not add any behavior like other libraries do
Alex?
@blazing scarab
it just adds some compiler hacky annotations
me.
how does it affect maintainability?
which to every extent, do not abstract the code I write
Setters are a necessary thing o.O
and turns them into code you'd normally have to write yourself
I said “a lot” not “all”
how would you abstract a getter though
or a builder
you couldn't be dynamic without setters
or @ SneakyThrows
no im not talking about abstracting semantics of Java
how would i go about spawning an entity in a world with data? say if i were to store the entity in a hashmap and spawn it that way?
yo uhave to serialize it yourself somehow
and then spawn it again and apply all the metadata it had
I expose all of my builders and getters through interfaces
you can't just store an entity blueprint
sure you can
I don't see any reason to do this
Object storing is a thing 🙂
how?
yeah and how would you then spawn a copy of that entity?
I'm totally fine with people not liking lombok. I however like to just do @ Builder and have a perfectly fine working builder. or adding @ Data and automatically have working getters, setters for non-final fields and constructors, etc etc.
you need to invoke the spawn method to get a new instance, and then you can copy the data from one object over another
that's exactly what I said
yes but I have to use java 8 for 90% of stuff
API requires that. It is necessary to decouple abstraction and implementation details
it's true that Data is basically just a record
It is so nice to design api first and then do implementation
not everything you write needs to be an API though
Hello guys, how can I spawn a shulkerbox at X, Y, Z with 5 totems in it?
for example, everything that does not get implemented more than once, you could also just directly implement it
- set the block to shulkerbox
- get the blockstate
- cast it to ShulkerBox
- getInventory()
But then it’s not decoupled
oookay
Or soemthing
some people like to obsess over non-existent API's XD
Sure, thing is lombok does not provide any behavioral abstractions as opposed to something like Guava, Caffeine or such libraries. IDEs have many keybinds to generate code equally quickly you'd write it with using lombok. In addition, having all the verbose code in source files (as opposed to Lombok) makes it extremely much easier to refactor code later on, which was one of the reasons I stopped using lombok. More over does lombok cause source and class file mismatch (tho that was not a problem but still annoying) (it used to, idk if it still does)
Heretere has a good writeup on why people saying lombok is hacky/bad/etc is wrong, id recommend checking it out if you havent yet #general message
Also, interfaces allows us to do such a great pattern like Decorator
yeah it's always quite funny imho
I dislike annotations
that's finally some valid reasons!
although
probably one of the things I dislike most in regards to some things Java >>
why would you care about source / class file mismatch
Because I couldn't navigate through files with CTRL + Left Click
you can
so I had to double shift click and search for the class
is that the same like Ctrl+B?
Yes. As i said before, a mental overhead. You don't see the code, you have to imagine its existence
Idk how to make a good API.
Like, should I have a getAPI method in the plugins main class or something
Ah right, objects get their data magically
works fine for me
ye alex
through constructors you know
no idea, only used lombok for about a year 🙂
ah fair
Static API class? ServiceMansger? Idk
Which is the code for website that describe an error?
Brain small
?
Internal Server Error is 500
sure some classes you could do this, however what about a singleton class? o.O
going to destroy and recreate the instance everytime?
And for client which should be?
kind of counter productive to a singleton
weren't you the person who sent the link about how constructors are so bad that noone should ever put any code inside them?
i think they were
how to get the block state from a Shulker box object?
First, build a couple of interfaces representing your plugin functionality and its beans. Secondly, make an entry point to the api, where you provide factories and builders or managers idk
yourBlock.getState()
or wdym?
in constructors, you just set your fucking values and do nothing else
Yeah the entry point is where I struggle
Who tf cares about singletones
It is doesnt stick to OOP like at all
Java isn’t purely oop thankfully
what are you on
Well singletons aren’t elegantly object oriented
well most java builtin classes do way more then simply setting some values
The only part it doesn't adhere to is so called object reuse, but not all objects are destined to be reused because they don't go away in the first place XD
Singletones are procedural programming. This is what you want and can avoid in object oriented language
Java devs did mistakes too. They cant chnage it easily
you are the only calling this a mistake
yes you know better then the ones that create it XD
how to set the inventory to that block then?
Gepron1x do you truly believe in pure object orientation?
what's your current code?
By your own definition on object orientation that is
Elegant Objects (EO) is an object-oriented programming paradigm that renounces traditional techniques like null, getters-and-setters, code in constructors, mutable objects, static methods, annotations, type casting, implementation inheritance, data objects, etc.
As the definition seems to be somewhat subjective sometimes
that describes a lot
p.getWorld().getBlockAt(p.getLocation().getBlockX() + 2,
p.getLocation().getBlockY() + 32,
p.getLocation().getBlockZ()).setType(Material.YELLOW_SHULKER_BOX);
Block block = p.getWorld().getBlockAt(p.getLocation().getBlockX() + 2,
p.getLocation().getBlockY() + 32,
p.getLocation().getBlockZ());
BlockState bsm = (BlockState) block.getState();
ShulkerBox box = (ShulkerBox) bsm.getBlock();
box.getInventory().setItem(14, new ItemStack(Material.TOTEM_OF_UNDYING, 5));
this sounds horrible
yeah
if this doesn't work, try to add "box.update()" at the end
Guys what time is it for you?
ok
4:37pm
22:39
oh god my pc time is wayy off
Same!
22:39 people unite
why don't you use NTP
hmm?
honestly never heard of it
Actually it’s 2 books
||or free as pdf||
Isn’t the default to sync time
yes recommend me a book to buy on it when I think that is horrible o.O
At least for windows
yes
at least it is the default on windows, macOS, ubuntu, debian, and even centos 7
What about uhh
No. Honestly, i dont follow elegant objects fully. Some of ideas are too radical and crazy, you werent meant to do such stuff in java. IDE's are not designed to follow Elegant Objects. But still, there's ideas i really respect and found them awesome. They made my code better, even if at the first look it felt weird.
Slako Puppy
Ah fair, there are definitely some interesting debates that can be made over the topic.
makes a lot of sense in why they believe setters shouldn't be a thing
Frostalf define a setter first and foremost
Is there any way to get the timezone of a specific player?
lol
it is a method to update a value
Oh god
All code goes in the constructor, all fields must have a setter
it can be a value of an object or variable
well you could get their ip and do like a geo locate
Tru
not sure how accurate itd be
So a method which mutates some state?
not a reliable one
That is one way of saying it I suppose?
Neither a method to get the geolocation of a player connection(
I saw it in some servers
Yeah alright, in that matter I also believe totally dissuading yourself from it is a bit too extreme
Alternatively you could just make a /settimezone command
already exists
its builtin
lmao
Fair enough
System.out.println(geolocation.getTimezone().getCurrentTime());
I mean it sounds like some advocate to a string standard which is fine I suppose but strict standards also don't mean optimal either or easy to use
Ty guys you are always helping me
I might have to try that
Gn for the people in 22:45
Auto detecting timezone sounds cool
Bye
Can you detect client language?
I understand where a build factory and all that comes in handy
but I mean really do you need a build factory to update just a single value?
Yuh, and truth is, there are exceptions to every rule, and practice must be separated from theory
would seem a bit excessive if you ask me in that scenario
You can detect client language
system language?
Heck yeah
Minecraft language
How can i check if packet entity was hurted?
ah
Yuh, I mean sometimes leaning towards principles like KISS can be more insightful than following strict oop
you should ask if its alright
Listen for packets
I’m currently checking how Essentials Does the geolocate thing
Specifically the damage one
it requires you to download some geoip db IIRC
at least it required that 10 years ago
Isn’t it dead now
I never liked plugins doing geolocate shit
IP's have to all be registered, so its basically just doing a reverse ip lookup and seeing which region it belongs to
no
you could then further query the IP DB and see if the ISP added any additional regional info on said ip
Ah
my server is located in austria in almost all DBs although it's in bavaria
You gotta sign up now
Simplicity is subjective
also people could use VPN, proxies, ...
And get an API key
Yeah idk about giving geo location data to server owners
But getting the time zone seems innocent enough
most geolocation things generally don't care about proxies and the sorts. Sometimes you might not want certain region ip's accessing your server
in which case proxies doesn't matter in the equation
Most other things are relative and subjective nevertheless
what is an "open" slot?
slot with no items
Loop between the two slots
A non closed slot
Hey sue
yes lets check for sue
for instance the, a function must only do one thing is subjective, one thing is extremely subjective in spite of bob’s objectification
I’ll sue y’all
Now that's rude
Autocorrect hates me and actively tries to screw me
And generally software is subjective because you cannot prove your software to be correctly written, we can only prove our software to not be incorrectly written gepron1x
you could always reset it
True
I could also disable it but that would probably be worse
Phone keyboards are hard
don't you mean to say we can only prove our software to be incorrectly written? Got a double negative in there that seems confusing o.O
Yes ik it’s double negation
But that’s the only way to word it
We can surround our software with tests much like proving science
- check if it's not null
- it's AIR not Air
If those tests do not fail, then we haven’t written our software wrongly to the extent of the tests
right, we only know that it was written wrong only when there is a problem 😛
Indeed
we can also know it's wrong when it was written by @unreal quartz
lol
oh shit he's here
a better way of doing what?
and you MUST check for null, otherwise getType() can throw an NPE
You want code written wrong?
It is actually incredibly hard to prove that a specific design is the right correct one Frostalf, I believe merely proving a method engages a rabbit hole of predicates and other mathematical theories
declaration: package: org.bukkit.inventory, interface: Inventory
a method for this already exists
Look at Chocos code
[21:57:45 ERROR]: Block at -67,52,-287 is ENDER_CHEST but has net.minecraft.server.v1_8_R3.TileEntityBeacon@67cb2838. Bukkit will attempt to fix this, but there may be additional damage that we cannot recover.
Anyone know how to fix this? I'm setting a block to Ender Chest the moment the falling block lands (beacon spawned with world#spawnFallingBlock) (also before you say use 1.18, i'm using 1.8 for the tnt mechanics)
you can use the contains method
1.8 alert
do it a tick later
but wait
why is there even a beacon
What its the response code when you are tryin to use an http verb invalid (that its not: GET, POST, PUT, or DElETE) ?
yeah i've tried it up to 5 ticks later
is the beacon your falling thing?
yes
and then instead of manually finding a free slot
did you kill your falling block before setting the block?
np
Why do most programmers I have talked to believe that if an underlying entity is mutable, an object is mutable too? I think the answer is simple—they think that objects are data structures with methods. That’s why, from this point of view, an immutable object is a data structure that never changes.
This is where the fallacy is coming from—an object is not a data structure. It is a living organism representing a real-world entity inside the object’s living environment (a computer program). It does encapsulate some data, which helps to locate the entity in the real world. The encapsulated data is the coordinates of the entity being represented. In the case of String or URL, the coordinates are the same as the entity itself, but this is just an isolated incident, not a generic rule.
Btw
Ye if we look at oo as being a representation of the real world
Which to some degree was a selling point why people should use oo I believe lol
I suppose you could think of it as a living organism but people like myself understand it isn't and thus can be manipulated at will even if the programming doesn't want you to do that 😛
i dont think there really is a "wrong" verb
interesting that you are not able to use that method
why people like to add final inside method arguments
its not as if the parameters are passed by address pointers
or smth
final public final void final test(final int final amount)
but typically an invalid request results in a 400 Bad Request @sterile token
depends at which end it originates
Because compiler can sometimes use that to reduce the amount of bytecode instructions it has to compile, in addition it’s a good way of ensuring non reassignments
400's are generally user errors and 500's are generally server errors
yeah
really? by adding final i can micro optimize my code?
Lol technically yes
and its not set in stone what verb is valid, a server software could expand upon its base with more
interesting
sometimes, but other times you can do the opposite too
Tho must be said it’s in realms of negligence
im gonna brown
this is a bit of an interesting topic in itself
Undoubtedly 🙂
especially if approached from, at what point do those micro optimizations become non-negligible
do you wait till it gives you a whole second more?
O that’s a very interesting question
i took that as a joke previously
but i guess it is not
People from adventure just likes the final keyword you know
especially if you also add on there how do you even test for this as well? lmao
like how do you know when to see if those micro optimizations are worth it XD
Bukkit.getPlayer
Yeah Frostalf, it’s an intriguing debate… Maybe I could see if I can benchmark it tomorrow
Reverse-engineer Player.toString and write your own parser
always thought using final for parameters was decompiler garbage lulz
Netbeans will yell at you to add final
Allright thanks
.size > 0
i wouldnt be surprised if theres an option for it in like intellij
I will send that error when you are trying to use an http ver that the server doesnt support
Why using ChatColor.Color?
!slots
?jd
?slots
That command doesnt exists
Lol are you literally bruteforcing bot commands
I wonder if you reach a point where you have to take advantage of micro optimizations if it then would be more worth it to make your own compiler XD
?gimmestaff
Want to See Inv slots
Dangit
?help
selfrole Add or remove a selfrole from yourself.
cleanup Base command for deleting messages.
embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.
findcog Find which cog a command comes from.
names Show previous names and nicknames of a member.
userinfo Show information about a member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.
permissions Command permission management tools.
public static String style(String text) { return ChatColor.translateAlternateColorCodes('&', text); }
public static List<String> style(List<String> text) { return text.stream().map(Chat::style).collect(Collectors.toList()); }
Slot 0
Slot counts from 0
I know
But in a Chest
Slots in chest and inventory counts from 0
Use: I am trying to make when a player uses a specific item it gets the nearby entities and strikes them with lightning, I got the other functions I want with it to work but this specific line of code doesn't want to work.
@EventHandler
public void PlayerEvent(PlayerInteractEvent event) { event.getPlayer().getWorld().strikeLightning(Arrays.stream(event.getPlayer().getLocation().getChunk().getEntities()).toList().listIterator().next().getLocation());
}
I might be using the wrong method of doing this, as I am barely even scraping by with understanding java so if you know a better method or why this doesn't work I would appreciate it!
Just use getNearbyEntities
How can i check if player sees entity (from player#hideEntity)
declaration: package: org.bukkit.entity, interface: Player
Yay javadocs
is there any reason to use WeakHashmap for storing player objects
i mean does spigot clean up references
Yes
what if dumb plugin holds the player reference
Then it hangs around
But having Strong reference would not make any difference right
even if dumb plugin holds the reference strongly
Hmm?
Correct
wait
my question just doesnt make sense
lol
nvm
do you use WeakHashmaps?
I'm thinking of using it
but i don't know if i really need it
I’ve never used one
since i could just clean up the map via onDisable()
I just make sure to cleanup on leave
and playerquitevent
Or I just hold the uuid instead
does anyone know whether HttpURLConnection follows 301/302 redirects?
How do I use mojang mappings
I have a blog post about that
Dovidas for player data, I’d stick with a UUID -> V and no weak hm
Can you send me it
np
Like do you know the semantics of gc and weakly reachability?
WAIT THATS YOURS
If you don’t then don’t use the weak hash map tbf
yes, why lol
But what if I need the player methods
Oh I had that page open lol
XD
Server::getPlayer
Overhead
And the player is merely acting as a key there isn’t it
Well, probably not much overhead I guess
Just because a player object is weakly reachable does not mean its gonna be garbage collected whatsoever
is there anything you didn't understand in that post?
I thought the GC ignored weak references
Yes but post weakly reachability is phantom reachability
that's why i asked if Spigot cleans up the player objects correctly
Well one thing, the specialsource-maven-plugin cannot be found
for the plugin
is there a repository?
if plugins don't clean up the references to player objects it would stay in the memory
just like Strong references
Depends, like this also depends on what gc implementation the jvm uses
Strong references aren't guaranteed to be GC'ed even if they're nulled too
Actually I must just need to wait for buildtools to finish installing
Whole GC cycling is undefined
for a programmer
only JVM devs know how it works accurately
Mhm, well anyhow in conclusion you should only use a WHM when you are dealing with internal objects that you have full control over
So perhaps not the ultimate use case here
yea
ughm maven should download it automatically
that's why i was doubting
did you try to hit the maven reload button?
it should be in maven-central, so no repository needed
and i won't be holding UUID's since I don't need them, i need to access player methods frequently
For what purpose?
i will cleanup those in events
inventory manipulation
Alr
I was going to hold player references
😮
But I know some plugins need to make economy users that aren’t real players
Ohh
Sure
Wait fr?
I wish vault had some more options
Econcluremy
Lol almost
hm sorry then I have no idea
And if I should have everything be an interface
maven should download that plugin automatically. if it doesnt - sorry, no idea
Ah
My current entry point is a class with static methods but ehhhh
Yup
Is this spigot related?
like if you’re just doing something generic, technically you could provide the service with ServiceLoader
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
I think its just an ide glitch - but after i add the classifier remapped mojang none of the imports work, for bukkit as well
Wait i just realized i need to import both
sorry
dont think they can? He aint verified
then verify.
Yes
Does somebody agree that Collections util class is a godsend too
You’re not the first one lol
it allows to wrap Maps,Lists,Collections into immutables
Ah, maybe just use the service manager or static singleton where you reflectively set the instance
@quaint mantle you're asking for some pretty complicated maths, may i ask what the usecase is
Yeah dovidas
As well as the singleton proxies and the empty ones
hm please show your whole pom.xml
?paste
Very nice, probably the most solid way of doin it
its okay
I do it myself also (;
reino's images for anyone interested
turkish person detected
pirated windows detected
I'm a private detective
jk you have turkish stuff in your discord profile, arkadas
Ah sorry, I fixed it
np! what was the problem?
I just had to add the api dependency as well
Now Im just confused on how to send packets and shit lol
oh yeah makes sense lol
All of the names are changed haha
packets have different, as you now use mojang names
sorry not really, i am not good with physics
what packets are you looking for @tall nova ?
you will probably go have to read some published papers on it
erm wtf is that
Scoreboardteam, PlayerInfo, EntitySpoawn, EntityMetadata all of that
Also EntityPlayer changed
ServerPlayer
no, it's NMS = no API
Yikes
The Metadata thing should be ClientboundSetEntityDataPacket
Thats true
@tall nova are you using intellij?
Yeah I am
Here is my break event: https://hastebin.de/ehojuvobil.csharp
Does anyone know why I would be getting this problem? No errors to console and other than this the stacking system works perfectly fine.
on the left side, scroll down to "Libraries" or what it's called, then open Mavn: org.spigotmc
remapped-mojang -> net.minecraft -> network -> protocol -> game
Ah I see
there's a list of all packet names
ofc you have to search a bit, but most have similar names
Clientbound = packets from server to client, Serverbound = client to server
wdym
there are multiple references
just skimming over, if the surface is at 0 deg, the bounce is equal to 90-firstangle
I just use ""
Strings.EMPTY
Because most likely it gets internalized anyway
Intern it yourself just to be sure
I assume java interns “” itself
^ that picture represents my current state of my back
Experienced an empowered top spin and back spin then we presuppose?
Lol
My back is also a tennis ball reflecting off a wall
How can I get if a block is inside two locations?
I am not sure how a block could be in two locations at the same time, unless you are referring to falling blocks?
thats not possible
or two locations or two whatever
You mean like
wdym?
Inside an area
yeah that
With 2 corners?
basically that ty
bounding boxes?
BoundingBox is your friend