#help-development
1 messages ยท Page 1937 of 1
Oh right, that one also exists
it returns the entity that was used, yes
thank you!
idk what could be the issue ๐
It's 1.18.1-R0.1-SNAPSHOT not 1.18.1-R0.1-SNAPSHOT/
oh oop
weird its the same issue
Hey peeps ๐ long-time listener first-time caller ๐ - I'm working with runTaskTimerAsynchronously - have web background but still feeling around in java and having an issue grasping what is meant by "You shouldn't use any Bukkit API in an async task" or "Never touch the world in an Async Task". Happy to go into more detail if need be, but I would assume if I can pass the player object to my Runnable object I could do as I see fit with them?
Searched in the following locations:
- https://repo.maven.apache.org/maven2/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/maven-metadata.xml
- https://repo.maven.apache.org/maven2/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/spigot-api-1.18.1-R0.1-SNAPSHOT.pom
- https://oss.sonatype.org/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/maven-metadata.xml
- https://oss.sonatype.org/content/repositories/snapshots/org/spigotmc/spigot-api/1.18.1-R0.1-SNAPSHOT/spigot-api-1.18.1-R0.1-SNAPSHOT.pom
Required by:
project :
edit: fixed
for some reason its not grabbing from spigot
No you cannot. 99% of methods within the bukkit API do not support any off-thread requests
The operations that can run fine in a concurrent manner are explicitly defined in their javadocs. Not respecting it might lead to strange issues
How can I'll check if a player is sitting on a entity?
how can i check if the shooter is a player?
I think this is the shooter, but i dont know how to check if its a player event.getEntity().getShooter()
instanceof Player
Check entity's passengers
thank you
Can't I'll just check it on the player him self?
pretty sure not
and should i use instanceof to check if the entity is a tipped arrow too?
Yea
๐
Although there could be better practices out there
Ok, so calling an async event creates a new thread ( ie. not the main thread ) which is what we do in the web world to some degree with things like JS and even Node ( still JS really ). What is considered the 'main thread' in this java plugin? ( happy to read some docs if you can point me there to save your time ).
It does not create a new thread
there's a method to check if arrows have effects, so perhaps that way
The main thread is the thread that is responsible for the main ticking loop.
JavaPlugin#onEnable, JavaPlugin#onDisable, most (there are exceptions!) Event handlers and runTaskSynchronously (and family) are on the main thread
Hello, I have a hashmap with the items as keys and the % as value.
How can I make a method that gets a random key based on the % change of getting that item?
The web world doesn't necessarily need a constant main thread for websites. Servers on the other hand themselves need a main thread. This is the main loop in code that keeps the software from exiting. This loop however is more critical in how fast it goes in regards to game servers because this is what mainly controls how fast you can check a given thing. ๐
Now to come back to my "it does not create a new thread". Bukkit makes use of a shared thread pool for the scheduler. this means that you shouldn't do anything too expensive via the Scheduler as it may prevent other plugins from using async tasks themselves
I already have the percentage, private final HashMap<ItemStack, Integer> items. And I have a function called selectRandomItem, that gets a ItemStack from the HashMap based on the percent change of getting that. But I dont know how to make that function work
Right, I was thinking in terms of XHR requests - whereas the main say PHP and JS script can make an async request, which in the server's eyes is a separate request, though I realize request !== thread just trying to draw some similarities in my brain
How would I do that?
Look at the link I sent
And the double in that class is the percent right? and with poll() you get the item? or..?
Yes
Right that's the issue I was having, I originally doing stuff on the main thread apparently so the server was on a full-stop until the task was done. Someone moved the API call to an async in a pull request ( and it worked ) but kept the player-modifiying code on the main thread and for the life of me I can't fully understand how/why it works so I'm just trying to learn ๐
Hi, how are you? I want to askyour opinion about creating minecraft plugins with JDK 9?
No
why 9
Use 16 or 17, nothing else
I ask because in Java 9 i found something called Reactive Streams
What mc version
Oh
Use 11
Ok
Well if it's public you probably want to use 8
A lot of old servers don't run 11 because they smell
^^
If it's private use whatever you want
The problems is that on java 8 you dont have Reactive Stream and i have been reading that are used for async and non-blocking
This should work right?
public ItemStack selectRandomItem() {
WeightedRandom<ItemStack> weightedRandom = new WeightedRandom<>();
items.keySet().forEach(item -> {
weightedRandom.add(items.get(item), item);
});
return weightedRandom.poll();
}```
try it
Allright another question, no matter the JDK version its should run on every server right?
Not really
Explain please
The server has to use at least the version you compile for
What do you mean?
Ditch the original map and just use a weighted random
Unless you need the map for something specific
Thanks
Ah, alright. Thank you very much.
Well, if you're not using java 8 there's no reason to blt use tge latest imo
8 probably shouldn't be used
hi, how can i check if the entity of onEntityShootBow event, is a TippedArrow? TippedArrow is deprecated and i think somehow i need to check if the arrow has some potion or whatever
Would you recommend using http://www.reactive-streams.org/ for working wth Java Sockets? Thanks
Maybe check if the arrow has effects?
How can I push a player upwards?
What I'm having an issue wrapping my head around is this:
// Run check off the main thread
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
String msg = chatPrefix+" ";
if (plugin.check()) {
msg = msg + plugin.getLang("general.processed");
} else {
...
The plugin.check() is a boolean which is whathandles the API request(s) and resides in the main plugin file. It will scheduleSyncDelayedTask() to modify player data eventually depending on the output. My understanding of Java's Lambda's when used on things like scheduling a task is that it forces the async task to run on the main thread, is that incorrect? If so, this seems like what we use in the PHP/JS world called an arrow function which would be basically a shorthand way of creating a method.
That also begs the question, if not, can one scheduleSyncDelayedTask from an async task?
For versions like 1.8 you don't have much of a choice if you want it to be a public plugin
how can i do that?
But in conclusion which version of JDK should i use for working on multi spigot version?
wait cant i do two times target
lmao it works
Arrow#hasCustomEffects
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Arrow.html
declaration: package: org.bukkit.entity, interface: Arrow
there is a break so why doesnt it accept it
i actually, never thought of that ever
that is big brain
lol
it is big brain
ive always used a different variable name
it will never evaluate to the previous value
I never thought of using {} in switchโs
thanks!
i didnt know it was possible
Does someone know any good tab list api i can use? (1.12.2)
Like this:
https://www.spigotmc.org/attachments/columns-png.15945/
Lol idk why people use switch, instead of if - return true/false
Because switch is cleaner than a ton of if else
Wait i never said else if, dont confuse
i've made an itemstack for all enchanment available in the game and made a gui page system to obtain them, but when i open the gui all items are stacked by two why is this happening
When i started i used to use if + else, then i learnt that its not necessary using them, cuz you can use if + return
Im planing to make a tab api. If i do it and it work. I can link you to my github to see the code
how can i convert an entity (arrow) to an itemstack?
Do you have a link to that? I can't find it
because if else with 5 cases goes brr
That also begs the question, if not, can one scheduleSyncDelayedTask from an async task?
Yes, you can.
Java's Lambda's implement functional interfaces. I. e. interfaces with just a single abstract method. See the javadocs of @FunctionalInterface.
However Java's lambdas do not dictate method flow. They are more or less just a shorthand to creating a class
Hey thanks - I think it clicked now.
Lambdas work differently rather than just anonymous classes
I owe you a beer ( or coffee, or soda depending ) ๐
Yes, internally they are different
That is not what i'm looking for but thanks (I'm looking for a api i can use to change to "Players" in the tab list to create something like this)
Ah
But for the developer (especially newcomers), they can be the same
There is no reason to annoy them with LambdaFactories, Method callsites, Method handles and all that shit
You can use simply:
if (!(args[0].equalsIgnoreCase("enable") || args[0].equalsIgnoreCase("disable"))) { return false; }
Player target = Bukkit.getPlayer(args[0]);
if (target == null) { bl bla}
more code
return true;
switches in some cases are more optimal
I have a pretty good background in web ( php, JS, SQL, html, css, react, node.... ) just trying to learn more and draw some parallels between what I know and java
Ah ok
doing if ! that and not that etc for 5 cases goes brr
if else means the server has to at minimum run the check to see if the code block should run. In switches the cases are constants so checking wise it is faster usually in which to choose from. Not always the case, but for cases where it is not it might make it more cleaner in terms of viewing in understanding what it is going on.
yeah but pretty useless for just "enable" "disable"
But would his code be all time re-executing cuz he didnt put return?
have no idea, didn't look at any of the code above lol. Just answering why people use switches ๐
What? No, i'm trying to find a api to create something like that. For example: https://github.com/thekeenant/tabbed (It doesn't work on new versions)
but cases in a switch automatically return until they hit the last case unless there is a break clause
oh sorry
np
I guess its more accurate to say, switch returns automatically once it hits the last case unless a break clause is encountered ๐
Well this is the same for everything
while loops won't return unless the condition being tested is the condition that needs to be met ๐
Example:
{
System.out.println("abc");
break;
System.out.println("def");
}
In this case def will be dead code.
so not true for everything, most things sure lol
Well, was more talking about the break behaviour
oh right
while 0; do
sleep 1
done
who for the love of god uses while do syntax
generally people are using java and not bash
And the fact that I am getting more and more tired caused me to read something along the lines of "switch statements do not stop until stopped via return or break."
poor people
That sentence took far too long to formulate
lol
Http requests made from plugins should be Async right?
bad. I counted 0 switch statements
typically yes
occasionally me when i need to run something at least once
in general yes
Thanks
i see two ._.
then you sent the wrong file
because I did Ctrl+F and there's not a single switch
Thatโs do while
theres not a single switch in that file
It triggers me that your package names are not conventional
ah yes, two switches, I rate it a perfect 5/7
Oh yeah upper case package names
perfection comes in all kinds of shapes and sizes
why not on 10 ._.
Thatโs gonna make it 4/7
5/7 is the best rating there is
thats my plugin name probably
5/7 refers to a rating for the 1999 drama film Fight Club shown in a Facebook status update attributed to user Brendan Sullivan. After the screenshot widely circulated on Imgur in December 2015, users began posting โ5/7โ ratings in comments sections as an inside joke on the image-sharing site.
fine
Ideally i'd avoid code in constructors
why that
Okay, registering listeners is a bit atypical, but otherwise I see nothing wrong with having code in constructors
Hidden side-effects not requested by object owner. Those ones are visible in public contract
new Something(fst,snd,thd).register()
See
haven't read but the title is pretty bullshit
if constructors MUST be code free they would not exist
^
If I did that Iโd have to parse everything outside the constructor and then pass it to the constructor
yeah that some bs
I mean, the constructor is fine as is
Or id have to make the variables non-final
There are no considerable side effects in that constructor
Hmm yea
CreateBossBar
So, that one is a pure method afaik
I mean stuff like that could be easily moved to their declaration instead
how to get the real amount of EntityShootBowEvent.getConsumable ?
but "constructors must be code free" is a funny and untrue statement
the real amount? what does it return?
"constructors must be logic free" if you want
but why?
If a constructor contains all your logic make it a method 
And then you have a init method that MUST be called just after the ctor?
yeah that doesn't make any difference
sure, it can be done lazily, but eh
if i add this to the player inventory, its always x64: ItemStack arrowItemStack = event.getConsumable()
so i need to create an itemstack with the amount of arrows fired
uhm, static factory method, for example?
But an init method means you canโt assign final variables
Or move that logix to object's owner rather than actual object
I still wonder - why?
I've sent an article
Overly zealous OOP
it says it makes objects unextensible, which is just not true
look at JavaPlugin's constructor
I am pretty sure that I extended JavaPlugin quite often
Bukkit is not the best example
And, extensible doesnt awlays mean directly that you can extend it
Well, if you cannot extend it, then why bother using it?
actually that's exactly what it means
no. Here, author is against implementation inheritance at all
and I simply think that the author is a bit stupid then
you're wrong
okay you know everything better, I got it
and the java developers are all stupid because they invented stuff like constructors, super(), etc
oh by the way
the dude who claims that code in custroctors MUST not be used...
uses code in his constructors
here for example, first file I opened
What entity collisions are there, other than between arrows and players?
well almost all entities can collide
player <> zombie, pig <> sheep, ...
There's different opinions on OOP. Java developers can do big errors too
as I said, the dude who claims constructors must be code free uses code in his constructors too. so either he is stupid himself or his statement is just bullshit
That is a java limitation
IOException does not accept integers
it's just reasonable to use code in constructors because that is what they were made for
Is entity collision a thing between for example a player and a zombie even pre 1.9?
so why didn't he use HttpException.fromHTTPReturnValue(int)
It changed at one point if I remember correctly
no idea, I don't use ancient versions
i'd just try it
And have a constructor which takes a string?
That may break the contract
what contract?
public static HttpException fromReturnCode(int code) {
return new HttpException(String.valueOf(code));
}
would be easily possible without problems but also pretty stupid
the statement that constructors must be code free is bullshit and the author didn't provide ANY good reason to explain why
What about my giant constructor :p
I don't have problems with constructors ๐
Nobody wants to hear about the size of your constructor
I do
God, have some modesty for those of us who don't have as big of constructors as you
I am into big constructors
What a lovely first sentence to read, thank you Choco
Using the CreatureSpawnEvent, after I check if it was spawned from a spawner, how can I get the location of the spawner?
you can't
Isnโt there an event for that
SpawnerSpa- yeah
o/
See Alex likes my constructor
yes but I am weird, always remember that
Where i can find JDK 11 source code? Cuz i wanna check the source code of a specific package
But i cannot find the package on the github repo
which JDK?
11
Ah
here's openjdk 11
The one who has support for http request
jdk11 has
they all have the same features
and anything above 11
Hi guys! How can i make a player teleport in the direction of facing like you would do with vectors?
their implementation is just different
Well the diff between the JDKs is minimal
But where its the package named: java.net.http? i cannot find i
wdym?
Like on hypixel the Aspect of the end, which makes the player "dash" in a straight line forward but with teleports
Lol THANKS i was looking more than 20m and didnt find
lol it took me 20 seconds ๐
sorry still no idea what you are talking about ๐
you can use Player.teleport which accepts a location
and locations have a world, x,y,z, and pitch and yaw
pitch/yaw is basically the "direction"
if you meant that
i'm trying to do with something i already had... if i don't succeed i'll be back! ๐
alright ๐ sorry but I really didn't understand what you meant ๐
You can get the players facing vector, multiply it, and then convert it to a location
(and normalize it before multiplying ๐ )
Yes
nevermind! it worked!
And then hypixel also ray traces to prevent you from going through blocks
how to check if an arrow entity, is a tipped arrow?
instanceof
hasCustomEffects does not do the trick for some reason
if(arrow intanceof TippedArrow) // It's a tipped arrow
No
oh wait
Thatโs deprecated
yes ๐ฆ
tipped status depends only on base potion type not being UNCRAFTABLE and effects being empty.
declaration: package: org.bukkit.entity, interface: Arrow
Check those
just check whether the list is empty
if(!arrow.getCustomEffects().isEmpty()) // tipped arrow
how to check if its uncraftable?
just do this
why not just check whether the customEffects is empty or not?
i will try this now
Custom effects may only work for custom tipped arrows
Vanilla ones may just use the base potion data
tbh I have never ever used a tipped arrow in my whole life
No idea how mojang did it
Heh, Iโve used them on some kit based servers
Never in survival
My original question:
Hello! I am trying to make a mob stacking plugin. I have gotten most functionality down except for the part where I want the entities to stack when they get close to each other. I know I can track the movement of the entity and constantly check if there's entities around it, but I feel like there might be a more efficient way of detecting it. Thanks in advance
The response I got:
Just loop all loaded chunks in the world & loop entities in the chunks and then compare distance between entities...
And yes, it will cost a little more performance
Am I wrong or is this a horrible idea for a server with 200+ constant players?
what should I exactly check with getBasePotionData ?
Yes but what if the mob walks away
i want to check if its "any" tipped arrow
I used to check for the nearest mob when spawning
And stack with that
What if the nearest mob is 500 blocks away xD
If there isnโt one in a reasonable distance, make a new stack
well but
heheh BUUUURN
what if an entitiy moves
Every stacker plugin I have looked at is so confusing
just don't stack entities ๐
lowkey just gonna disable movement from spawner's spawn
I don't understand why everyone gets blind from light mode
I'm just the dev that's not my decision lol
and light mode kinda fire
Also there is .getNearbyEntities
That is what I'm using atm
so how can i check if getBasePotionData is not empty? i think its never null
lol
I managed to call someone trying to tap on the text box
I was like "Who tf is Josh"
I donโt... what
yeah me lol
i managed to do that too
Josh bloch?
people have done it with me too
Anyway, when I made a stacking plugin I made it only apply to player placed spawners
It would disable AI and stack them, but leave natural ones alone
That way it didnโt remove the challenge from dungeons
._.
hmwoa i looked at it and it couldnt fully persuade me to use it
github is so weird
it's like the largest coding repo thing and it does not support IPv6
I have to pay 4โฌ per month for my IPv4s D:
Oof
A lot of shared hosts add extra charge for them too
I assume because they arenโt cheap
yeah understandable
Why canโt we just fully yeet ipv4
if google would disable IPv4, everyone would have IPv6 in a week
Eeeee
because of lazy ISPs
Ipv6 address are infiite or what?
340 trillion trillion trillion
because ipv4 still has its uses
technically we could remove ipv4
I mean
ipv6 is nice
it allows to use some words in the address
like fc00::cafe:babe
We can at least transition away from it for most things
I wouldn't need ipv4 at all except for email and github
I want to shove a raw ipv6 in my minecraft server box and be done with it
Hypixel can be fc00::hypi:xell
what kinds of dataabases should i support for my storage? i already have h2 and mysql now
Aww hex
postgre if you want
what's special about that?
Now Iโve noticed cafebabe is valid hex
SQLite?
Idk the different between that and h2
neither do i
CAFEBABE is actually the first 4 bytes of each java class file
sqlite doesn't require a server
mongo? ๐๐๐ณ
in german mongo is a bad word to insult disabled people
du mongo
I might be homo but I'm not officially disabled
^ example usage of that word
Does h2 require a server?
yes
TIL
TIL again
Iโve heard itโs faster than SQLite
the developer has the most german name ever
Thomas Mรผller
that's like "John Johnson" in english
I wonder if it supports the same syntax
sqlite or h2 one of them is written in java
h2 is java
And don't use the one that is written in VB
ah C isnt dotnet ๐ณ
not even remotely close lol
TIL?
TIL = Till I learned
No, the java class file format
Whatโs the difference
True
till is a synonym for until
Till can also be a german surname
Cinnamon
well in the US I am not surprised about names
considering we have people named after fruits and vegetables now XD
Now?
cat
We probably always did
Do not question the hivemind
there are still people called Adolf hitler in some countries lol
well, can't exactly ban names at least not in the US
someone on a talkshow had to say a fruit: pizza idk was his answer
Some states restrict them
X AE A-XII lol
That isn't a ban on the name, the original way it was written used characters that were not supported
I didnt mean to say it was banned
otherwise, there is no ban on any specific names in the US
I was just giving examples for stupid names
California's ban on diacritical marks, such as in Josรฉ, a common Spanish name.
Not federal tho
Cali does not like the mexicans huh
what ?
his name has a capitel e with dots above it in the middle
Not quiet
oh
Middle name is Noรซl
his last name has a capital letter in the middle
Something like McKenzie
and his middle name has a e with dots in it
Yeah
most states ban accent marks, however in states that don't they tend to ignore them anyways
why is that allowed ๐ฎ way to complex naming
Isn't that Christmas in french?
I want a name that breaks databases
this is precisely the reason behind some bans on certain characters/marks
Canโt we just learn to sanitize input
Well you do not know the context
It will take a while to come up with a truely atomic way to deal with this
uuid is 4 longs iirc
2
ah
then how will you store a UUID inside a long if it's too long?
Basically something like
private final AtomicLong currentId = new AtomicLong(ThreadLocalRandom().nextLong()));
method () {
long nextId = -1;
while (true) {
nextId = currentId.get();
if (currentId.compareAndSet(nextId, nextId + 1)) {
break;
}
}
// Then use nextId
}
oh ok
If you were to save the currentId across restarts you can guarantee uniqueness for a pretty long time
You could use currentId.getAndIncrement but the issue is that I am not too sure about it's atomicity
just use a NuclearLong
Itโs atomically safe
Yeah, looking from the javadocs of varhandle is appears to be
Okay, then you could use AtomicLong#getAndIncrement
how can i add potionEffect to player?
Player.addPotionEffect
yea but what about arguments?
?jd-spigot
Construct a new potion effect
i mean new p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED)); not working
Right
?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.
Because thatโs not the constructor for potion effect
don't you need to add the level?
yes
you have to read the bot answer that showed up after this message
this:
?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.
this
I hope that people are not that dum
I mean we know why itโs not working
Even if I knew the answer to it
Anyone have a good tutorial on multiple config files?
Wtf did I just read
it throws an error
I hope so
you can just create a new YamlConfiguration
Made my eyeballs throw up
you can load existing Yamls with YamlConfiguration.loadConfiguration()
In some days i will be posting my own library. In documenting it. It contains many utils things. And include a simple FileHandler
pls stop trolling
you don't need a library for multiple configs
^^
You need org.json:json
I'm down to read it although I gotta learn it now since I have a deadline xD
Best config lib in the world
We need one lib to rule them all
org.json:json already does it, sorry
And given that all json is valid yaml it is a fully valid yaml writer
p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED)); i can't use PotionEffectType.SPEED it's telling me that i have to cast it to (Map<String, Object>)
We already told the issue my man
You have to read the javadocs
?jd-spigot
because they tell you how things work
Look at the PotionEffect class
bruh what that doesnt makes sense i copied the spigot docs link
Something something spoon me
you
did you just reply to a 364 days old message?
shit, should've waited another day
lol
and now, a premature answer
lmao
how could you
What is the best way to query every 5 levels of a player? So I have an Int level that defaults to 1 and the player gets 3 xp per block removal. Every 5 levels the xp should increase by 2 for example.
im dumb atm
but i dont want 2 write it every 5 levels u know?
Sup all! Got a problem where the player sending wayyyy to many packets when they press a "button" in a GUI and get teleported, anyone know why?
gui.setCloseGuiAction(e -> player.teleport(config.teleportLocation()));
Liek they get kicked for sending too many packets
How can I clear the ItemOnCourser?
private static String addEmoji(Player p, String str, boolean requirePermission) {
List<String> emojiList = Config.getStringList("emojis");
for (String i : emojiList) {
int o = i.indexOf(" | ", i.indexOf(" | ") + 3);
String replacement = i.substring(0, i.indexOf(" | "));
String syntax = i.substring(i.indexOf(" | ") + 3, o);
String noColorSyntax = "!" + syntax;
String permission = i.substring(o + 3);
if (requirePermission &&
(!p.hasPermission("server.chat.emoji." + permission) && !p.hasPermission("server.chat.emoji.*"))) {
continue;
}
str = str
.replaceAll(noColorSyntax, ChatColor.stripColor(Misc.coloured(replacement + "&f")))
.replaceAll(syntax, Misc.coloured(replacement));
}
return str;
}```
and htis is why "it just works" is not a good idealogy
becaus eyeah
it works
but its also dogshit
Set it to null or an air itemstack
Isnโt it in the player
Config.getStringList
ty
I used it wrong for so long
Me too
i still dont use it lol
I thought replace just replaced the first one
i'm learning new things today ๐
no
replace replaces all occurences
No, I know now.
replaceAll should actually be called replaceRegex
Yes exactly
๐ณ
It took me 2 years to realize it
how
Yeah, that's what I was saying 
doesnt the normal one works with regex?
no
I think I realized it the first time I used it
Regexplace
oh not that i use it that often but yea
Well, I had no idea about regex back then so it wasn't so cool
no he uses eclipse
Oh right
what is your way 2 go then :(
Quite the pain to figure out what went wrong back then
?paste
Someone say eclipse
no.
Getting this error here: 'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type
https://paste.md-5.net/efucuzozip.java
casting?
That would add every five levels
Can someone please tell me why this is not working:
if(t.getItemOnCursor().hasItemMeta()) {
if(t.getItemOnCursor().getItemMeta().getDisplayName().equals("ยง7Head")) {
t.setItemOnCursor(new ItemStack(Material.DIRT));
}
}
?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.
This is not working because it's not replacing the item
add debug messages to see which of those if statement actually gets executed
Getting this error here: 'x()' in 'net.minecraft.world.entity.EntityInsentient' clashes with 'x()' in 'net.minecraft.world.entity.EntityLiving'; attempting to use incompatible return type
https://paste.md-5.net/efucuzozip.java
my guess: the displayname is wrong
^
^
should I store data from plugin into a file, for example home locs and this kind of things, or database
Well, it would increase every 5 levels
I would say database
Flatfile
you must use mojang mappings
But a file is usable
What is that?
bdw I want to publish this plugin
Then use flatfile, most do not know how to setup a db
let the admin decide
Or have an option
Or use a db like h2
SQLite
ok
Or that ^
lol
I don't want to make work for people
Never used CMI. Probably the reason I have a dead server
uuugh
EssentialsX + a couple of free plugins > CMI
CMI is good but it also has a ton of unfixed issues without answers from the dev
I think flatfile is a way to go
Ok so i am using a multi module thing atm and i want opinions.
I have an API module that has a method that returns an instance of a class that is impl'd in the Main. Main implements the API so the API has no access to main cause thats a cyclic depend
If i set a singleton of that class, its fine and it works but i wanted a new instance for each call. How should i go about this?
e.g. basic stuff like global chat isn't working in CMI and the dev hasn't replied in 2 months now
ty
Just be really carefull about your format
create an interface for what gets returned in your API
why?
Don't use YAML and always store a version byte or something like that
The Display name is 100% right
how did you determine this? did you add debug statements?
If you want to do async saving you should also never use Collection#size
ok, I actually heard for flatfile for the first time but it looks good to work with
Heyo guys. First time being here and I want to use that to ask you for some ideas about what to implement on my new SMP server.
Administration plugins are not the thing I'm asking for as I got already everything I need (some I don't even really need...)
Your ideas are appreciated!
maybe ask in #help-server instead
yes, but how do i actually create a new instance of something that the api has no access to
Is this an incorrect channel? Sorry.
i do already have an interface that gets impl'd
you don't. can you show an example / some code?
this is for coding plugins ๐
Yeah, okay, I asked in the other channel.
If you dont have it on your classpath then reflections are the only way. Otherwise you would just cast to the implementing type.
How can I convert a string to a list but like "{0} | {1} | {2}"
so it would only contai nthe values
and not the " | " part
String.toCharArray returns ... well... a char array
:D
then you can do Arrays.asList
MessageFormat.format will replace "{0}" "{1}" etc strings with the corresponding arguments
public class OLIAPI {
private XCOM xcom = null;
public XCOM getxcom() {
return xcom;
}
Where XCOM is an interface that gets impl'd in main. What i do atm is set the XCOM singleton and just return it but i want a new instance each time
no those only for example
the string would be like "aaa | rsdfzh | saj"
Omg im stressed im looking the class "okhttp3.OkHttpClient" on okhttp repo. But i cannot find where fucked its the class.
ugh yeah, im contemplating just using the #newInstance() but it kills me a bit inside
use String.join
I need to convert it to a array from a string..
I already told you
String.toCharArray
and Arrays.asList
I'd use ServicesManager tbh
Do you want "{0}{1}{2}" to an array containing [0, 1, 2] ?
an array containing [0, 1, 2]
wouldnt that just return back an array with all the chars tho
Im looking it on the official repo but i cannot find it
split? Lol
split it by " | "?
I would try regex. Something in the neighbourhood of "\\{.*?\\}"
One day i wont have anymore my desk. cuz for this shit
public static List<String> toList(String string) {
return Arrays.asList(string.toCharArray()).stream().map(aChar -> "" + Arrays.toString(aChar)).collect(Collectors.toList());
}
what the fuck
So um
Thats not what he meant
if you want a new instance, then use the new keyword when returning the object
smth like this?
ArrayList<String> split = new ArrayList<>(Arrays.asList(i.split(" | ")));
well the itemstack is right above:
ItemStack Item = new ItemStack(Material.IRON_HOE, 1);
ItemMeta Itemmeta = Item.getItemMeta();
Itemmeta.setDisplayName("ยง7Head");
Item.setItemMeta(Itemmeta);
if(t.getItemOnCursor().hasItemMeta()) {
if (t.getItemOnCursor().getItemMeta().getDisplayName().equals("ยง7Head")) {
t.sendMessage("hi");
}
}
I already told you twice to add debug statements in your if's
if you don't do that, I can't help
And the problem is at t.getItemOnCursor().hasItemMeta()
Yes, ArrayList<String> list = Lists.newArrayList(string.split())
I wonder why Lists.newArrayList() exists
does it legit just do new Arraylist<>()
oh because ArrayList() doesn't take arrays maybe?
yes it doesnt
then it makes sense
Arrays.asList(T[])
does that not only return the instance you provide tho
we know right
The problem is.. Hr wants an ArrayList
Huh? yeah ik how to instanciate classes i just dont have access to the class directly
Yes, doesnt that what yoy want to do?
i want a new instance for each time its called
if your API creates an implementation specific thing it's bad design anyway imho
For a plugin api, you should create only 1 instance and use it on every plugin
how to fix this
i decompiled a plugin (with permission)
however classes look like this
I mean, provide a factory with services manager, which will produces those instances
Dont skid plugins :/
So, what is the issue?
i was asked to decompile it
Skid all the plugins
Yeah i dont like decompiling
Decompilers are perfectly fine
look like what?
Yes, WHAT IS THE ISSUE
yes that looks like valid java code to me
Did you unzip the jar?
move it to the proper src folder
the folder where it's inside must be tagged as sources folder
oh there isnt a src folder
right click the folder where it's inside
Mark Directory as -> Sources Root
@grim ice
bruh you are using eclipse and want to give other people opinions about what software to use? ๐
This does not look obfuscated, so CFR isn't the best choice here
(assuming that it is what it is)
oh, it does not use CFR
Eh, makes it even worse
does someone know a good tutorial about coding intellij plugins?
JD-GUI is not bad
create a project with the preset and play around with it ๐คท
recaf on top
there's a IntelliJ plugin preset?
intellij on drugs bro?
pretty sure there is?
no you marked the wrong folder
but where
what the hell is that project
ok then im on drugs
you marked "me" as sources root
what do i mark then
so the classes are now called border.something
you have to create an aupper directory called "src" or whatever
then move the whole "me" thing inside
that makes sense
src/main/java
and mark "src" to be sources root
or that, yes
it actually doesn't matter what you call it but yeah, usr /src/main/java
that looks like a preset ._.
but I don't have this D:
bruh
gotta check the marketplace
whats wrong with the intellij platform sdk tutorial ?
use CE :kekw:
CE?
thx
I don't use intelliJ ๐
community edition with da latest updates
I have Ultimate, why would I downgrade to CE ๐
then what were you complaining for? lol
because it has the preset ._.
ultimate has everything that CE has. I probably just disabled it while installing
why would I stay on an old version?
lol
the thing you replied logs htis
[?, , |, , :, c, o, p, y, r, i, g, h, t, :, , |, , c, o, p, y, r, i, g, h, t]
i though you dont get updates after subscription runs uot
found it
stinky plugin
wait no I'm thinking of the minecraft plugin dev kit
that one's stinky
worst intellij plugin ever
Sorry for still asking questions, but I've never really decompiled a whole plugin and tried to edit it
Oh?
why ._.
Doesnโt everyone here recommend it
it provides almost 0 functions and it always keeps crashing after new intellij updates
use recaf then ._.
maybe it only sucks in ultimate, no idea I haven't used community edition in years
i use it just to save time setting up mvn plugins
never had trouble with it
maybe it only sucks in the ultimate edition, idk
Minecraft Development plugin?
yes
Isn't it more useful for mod dev than spigot dev
i mean not if ur doing versions under 1.12
minecraft dev plugin is great for working with mixins
thats not true it puts a spigot icon on some files
^
yeah great lol
Hell yeah
Imma switch to IntelliJ just for that
File -> Invalidate Caches
erm how does the mc intellij plugin even generate a pom?
Alr
there's no preset for it
erm of course I need a pom.xml
or maybe it does have one but its internal or something, you dont certainly have to see it right?
the intellij plugin aint great
it's there for me
why isn't it there for me lol
its good for beginners but after that just do it yourself
^
ugh I am stupid. I installed the plugin but you also have to enable it afterwards
https://paste.gg/p/anonymous/c9de22992b714641a64c0ebbbf9ba762
can someone tell me the issue of this
It tells you the issue
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
show GetLocation line 326
entity.result is null
good idea
entity.result is null
do you guys use @NotNull/@NonNull or @Nullable annotations? If so, do you guys use guard clauses to check them runtime, or let the IDE handle that for you?
oh no
nft monkey
I use them but wdym with guard clauses?
tgat was pseudocode
Preconditions.checkNotNull(argument, "Argument is null!");
I either let it fail if someone is too stupid to read the annotations, or I let lombok create those Preconditions things
that doesnt really have anything to do with the annotations as far as I am aware
@ NonNull is lombok I think and automatically adds those
no, intellij for example does annotation processing at runtime
to check if the values are null
ah
it doesn't add guard clauses. you need lombok @ NonNull
Yeah but won't it still allow them to pass null?
So you should still check probably
I need to also mark something related to pom xml now right?
whut? no. it doesn't add any guard clauses to your code
this is the last question istg im annoying y'all sry
Yes, i do
This too
Objects.requireNonNull tho
see? plugin is @NotNull but there's no check in the code
Thatโs only if you declare the annotations library to be an annotation processor iirc
When you compile your project in IntelliJ IDEA, it instruments the bytecode of compiled classes to add runtime checks for various flavors of @Nonnull annotations. This behavior is controlled by the option:
Settings | Build, Execution, Deployment | Compiler | [x] Add runtime assertions for not-null-annotated methods and parameters.
well alright, if you specifically enable it, ok
but it's disabled by default
Some decompilers remove the added code by default
they can't know if it was added by the IDE or not though
For instance with gradle, (merely) using compileOnly would disregard the annotation processing
weird. maybe you enabled it years ago or sth? ๐
no
i reinstalled it
couple weeks ago
This feature was added back in IntelliJ IDEA 5.0, but at that time it only supported JetBrains' @NotNull annotations. The support for other annotations was added recently.
it was removed long time ago
is your version totally old?
for me the annotations have a specific subsetting
its 2021 release
this seems occupied but if someone is free It's still unsolved
show your pom
?paste
