#help-development
1 messages ยท Page 2153 of 1
Yeah I know that much
you mean the ExecutorService?
Yeah its better to use java Executor
myes
Like an executorservice?
yup
yay
Oh ok
idk if this is acceptable here, if it isnt please tell me but i would like a combat plugin
saying info abt combat
Conclure running Bukkit#taskTimer() do they block the thread?
how do i cancel a task from within it?
new BukkitRunnable() {}, istead of runnable
Get the bukkittask
pretty much
if you want that made for you by someone else I don't think its the appropriate place. maybe try messaging people in private for that?
And call task.cancel from wothin
now you learned something new ๐
Hum, so why many plugins uses spigot tasks to save the data async, when they still block the thread. Its strange
i want a public one
like this?
Ty
a plugin like this that already exist
yay
yeap
ty
have you looked for it on spigot?
spigot is miles away from best practices
It's kinda stupid that everyone says to use async runnables for every read/write operation on the forums
yeah i do not find something interesting
How can I hide the item lore of an item via packets?
i always find anti combat log etc etc
probably better to move this to the #help-server channel @sterile cobalt
Think I'm gonna start doing that
or #general
yeah just make sure you're not passing the server thread executor to your future
๐๐
Server thread go brrr
oh okay, ill go there later thanks in advance
futures has the same problem as asycn bukkit tasks unless you make use of executor service
np
Learned a lot today thx guys
because it is an asynchronous computation
which means that it won't necessarily use another thread unless you specifically tell it to
I would still recommend using futures using thread pool since it has a nice api
https://youtu.be/VER8cPR4r-A i've come across this weird bug where inventory click events are not called when you have an item in your hand, you hold and drag and then release
as shown in the clip
I mean by default it uses fjp common pool if and only if parallelism if over one, else a thread factory executor
did anyone else ever notice this kind of issue
or is it me being stupid
@EventHandler
public void onBackpackInventoryClick(InventoryClickEvent event) {
Bukkit.broadcastMessage("click event");
if(!(event.getWhoClicked() instanceof Player player)) return;
if(!openBackpack.containsKey(player)) return;
Bukkit.broadcastMessage(String.valueOf(event.getAction()));
//more code
}
this is what i used to debug in the chat
DragEvent
Inventorydragevent
so that doesnt' count as a click
interesting, thanks
it makes sense tho
it'd be weird if those were the same event
The start of the drag should still count as a click tho
So u can cancel ot which would cancel the drag
I dont think so iirc
at first it was so weird because i thought it was because double clicking didnt call the event for some reason
but then i noticed it was about drags
yea it does not
now thats weird
No wait its not
its because minecraft only sends the packet once you release the button
^^
Cuz usually when you're dealing with inventoryevents you deal with the first pickup
how can I make a light thing (not sure what to use for it) follow a player + i also want to change the intensity
how often do you want to ask this question? vinesh: yes
i k i should use lightAPI
remember the last location and reset it each time you move the light
what are you about to do? a 2000x2000 light field?
not really. my idea is to make a light around the player with editable intensity. kinda like a spotlight
All light calculations are fairly heavy operations.
yea thats why
but a little spotlight will not even scrape the performance
so all you need is the players eye location
o ty
Hi, i have created a command that is creating a random maze that is being stored in an mcfunction. Whats the code in Intellij in order to access and use that file??
why eye location?
thats his head
so get the butt location
Instead of /function test:mytest
hehe got a bulb in da butt
ohh and place there an armorstand with glowstone as head
set teh light level, store that in a variable so you can remove it when you set teh next location
oo and glowstones have eeditable intensity
i m storing it in a map
Thats fine, you only need one location per player for a single light
I recommend just recoding that in to Java instead of using mcfunctions
and then how do i store the intesnity
you could also make use of OOP
yea
i m doing that
i should make an object which contains a Player, Location, Intensity
and then use an array of it ig
if you have many spotlights a map would be better
yea i do
I would also advise against using mcfunctions in a plugin. More than likely you can make a more suitable solution with just Java code. There are no Bukkit methods to invoke a function.
what are artifacts doing in intellij? are they just the same as what the mvn build command does?
so build artifact and execute maven goal (build) is the same
No not the same
?paste
im just trying to setup the local debug thing
Minecraft Plugin Development with hot swap and remote debugging.
Take a shot every time I say "ok"
Want more tutorials? Leave in the comment.
hope you use dcevm for it
dunno what that is
uhh
Ohh u can do stuff before you start the debugging session
Such as maven build
but mvn build will probably output it to the default directory, i want it to build it to ~/mcserver/plugins
one of the more dramatic thumbnails for a coding tutorial
Can't you change tje directory?
dunno is the mvn build command takes flags
mvn compile is not outputting the jar or is it?
Not sure ๐
Tbh just use the artifacts in intellij
It's what i do when I'm debugging
mye
Hi i have a code line that have a white line over the text
what
Nice
That's cool
I'm glad for you tbh
Does it look cool?
so guys, i m running 1.18 on a server and the build limit should be 319 but its still 256, any clues?
someone stole my plugin and reuploaded it on bukkit.org, I reported it but nothing has happened yet. is there anything else I should do?
you can have a plugin that can make so you can hav build limit on 256 or you maby don't have update the world
have you update the world and take this in #help-server
Aight, thank you
Is there a way to tell if a plugin is compatible with a specific minecraft version just from its code used ?
look at its API version in the plugin.yml
tells you how far back you can go
But mostly, look at its Spigot page
What does it mean
I'm surprised your ide doesn't tell you
hey guys, what should I do to make a player glow.
My plan is to spawn an invisible armor stand but I dont know what to give it.
Should I give it a glowstone?
Or put it in his head if thats a thing
uh i m looking for something more intense
like i m tryna make a spotlight effect
can i make its helmet a glowstone?
What version are you programming for?
1.15.2
that doesn't have the light blocks in it, does it
sadge
can u put a block on a armor stand
which also makes it light-y around the armor stand?
you should be able to put a block as a hat
o
not sure about the light part tho
using #getEquipment()#setHelmet()?
never done it, but I was able to put boots on my head when I had my array the wrong way around so I guess it should work
well crap
packets?
I think nms or packets in general are the only solution there
no i think glowstone implements the Light interface
and it has a setIntensity method
Damn, thats convenient
but I dont know if its the glowstone itemstack
glowstone has a block
i should use that
oh
Glowstone is a block
its GlowstoneDust that isnt
Ye
some days my dumb surprises me
wait so
setHelmet requires an itemstack
how can i pass a block?
new ItemStack(Material.TNT)
do i need to get its itemstack, if yes, wont that just like remove its properties?
what properties?
lets keep it slow.
you probably have to mess with meta
So how do I get the Glowstone block
wait wait
- I need to get a
Glowstoneblock - Change its intensity using
setIntensity - Put it on the armor stand
how can I do the first step, as I cant just instanciate a block
and Glowstone isnt a class
Intensity? Glowstone has no intensity
They don't. Nothing, to my knowledge, has a changeable light value in 1.15
when the intensity is 15, use glowstone
when the intensity is 14, use X block
Well
I think I found something
Light blocks do exist in 1.15
Oh, never mind they dont, i was looking at the bedrock section
ayy debuggin my plugin via ij works
fr?
that must be a life saver
Where can I find the list of blocks sorted by their light level
I want to find blocks from 1 to 15 light levels
can u use breakpoints
uhh lets see
idk
what block has the light level 1?
Yep
Think there's something u can change in the server settings to stop player timeouts
But u can't stop server timeouts
and it crashed
what block has the light level 1?
kekw
@golden kelp there is a literal light block
Which is an invisible light source whose light level can be set
not in 1.15.2
oh god
Julia yee
ye
How can I create a site from my minecraft plugin so that I can send a player the url in chat and he can open the site and view the content Iโve added such as for example the missions he completed?
Something like Pastebin but not quite that
Do you have a website?
no i wish i could create something like a pastebin site on the fly
every time i need it
Uh I have a trie for a blacklist system, but right now if "Hello" is blacklisted, "Hell" is also considered invalid
use the pastebin api?
Idk how to fix it
A trie?
smth like this
Tree
sure
its a trie..
Oh a trie tree
preface: Trie tree is also known as dictionary tree and word search tree. The biggest feature of trie tree is to share the common prefix of string to save space.Then we can filter sensitive words and automatically associate them according to the characteristics of its public prefix. The data structure of trie tree is abstracted [โฆ]
it gets called when you close the inventory?
i guess youre clicking a button which is openeing a new inv
so the prev one gets closed
if thats your problem
?paste your code
Did you modify the code? It shoukd work
dw i just forgot to add a state
should i let my Storage#saveUser also handle the creation of users if they are not present in the db yet?
instead of having a createUser method handle that
Hover over it lol
Brih got an ide and don't even know how to use it
๐
Hey, wenn packaging my project with maven, I'm getting this error: Unsupported class file major version 62 Does anyone know what this means? There is no additional information
Have you tried googling the issue?
Yes, there are only answers for errors 60 and 61, I didnt find anything about 62
hey what would be the best way to have an item with a config that a player can get at any point, and updates the config on reload? i dont want to use static abuse anymore
my code is currently hideous
whats the best way to project a video onto maps in say a 5x3 size? ive seen protocallib has a method unless its old but its just for 1 map?
thats literally the same thing. just different java version
Oh. So what should I do?
Up to you tbh you can have a getOrCreateUser
Or create user on save
Or get and if null create user
?paste your pom.xml
I have a question, storing the db credentials ina string is not a good way to do it obviously, so what would be the best way to do it ?
Wdym?
I changed it, still doesnt work
Ohh okay, i thought there were better ways.
Oh wait
Change the compiler target to 1.8 or 11
Which is java 8 or11
What version of java are you using @rich inlet
17
I mean to run the server
do you mean minecraft version?
17
Not the one you're using to code
I am using 17 on my PC and in my code, both
I was getting this error a while back
I forgot how exactly to fix
Change java.version to 17 and try again ig
I did, still the same
If you mean that, then no
i need help to understand instances and static abuse a bit better
Basically my code is hideous and i need help improving it. I think i learn best from criticism tbh.
basically most of my methods look something like this: (my goldenhead section for a custom item that i coded a couple months ago)
https://pastes.dev/V7leqm7cJq
https://pastes.dev/PofHAP0vkH
idk what i was on when i coded the second one but its ugly asf and a great example of 'if it works it works'
( if the code makes no sense then i'd still appreciate some help on how to use wrapper classes to make my code cleaner, and remove static abuse )
whats the best way to project a video onto maps in say a 5x3 size?
I'll help you in a bit
can anyone check this out for me thanks.
sending a OPEN_SIGN_EDITOR packet to the player with the nbt attached to TILE_ENTITY_DATA packet
How fast are hash maps with get and remove with sizes of around 2k?
it depends on the map
HashMap?
no I mean it depends on how the map was made, what values were used. but it should still not be too slow. cant give exact values but ideally a HashMap would have a runtime of O(1) for get
meaning the performance of those methods does not increase as more elements are added to the map
but thats most of the time not the case
hashmaps are dope
especially with that many values there is bound to be some duplicate hashes
not necessarily
Wat, that is kinda crazy lol. I understand your profile Redempt, hashmap enthusiast
in the worst case it could be O(2000)
if you are astronomically unlucky
yes
you'd sooner be struck by lightning ten times in a row
but it could happen, im just making a point
and as I said, the map could have bad values or just not be rehashed for whatever reason. in that case it would be real bad
not really
2000 iterations is obviously not optimal but it's unlikely to create significant issues
this is what I mean. if thats chosen badly it could create problems
you would truly need to be so unlucky that you'd sooner have to pick a specific atom from earth randomly and get it first try than get that bad of a distribution
ok yeah if load factor is 99%
still though
HashMaps are good, lets agree on that. they can have a bad time when youre really unlucky
@sacred mountain
switch (item) {
case THROWABLEFIREBALL: case THROWABLEFB: case TFB: case TFIREBALL: case FB: case FIREBALL:
return fireballConfiguration.getWithdrawAmount();
case THROWABLETNT: case TNT: case TTNT:
return tntConfiguration.getWithdrawAmount();
case GOLDENHEAD: case GH: case GHEAD: case GOLDHEAD: case HEAD:
return goldenHeadConfiguration.getWithdrawAmount();
case MOBPACK: case SPAWNPACK: case SPAWNER:
return spawnPackConfiguration.getWithdrawAmount();
}
why do you have so much of the same enum
do you have a github for the project?
Hello I was wondering what do the parameters villagers-every: 600
villagers-for: 100 do in spigot .yml ?
Try deleting all java versions and installing them again, worked for me when I had that issue.
But first, install 17
Thats how I fixed mine.
I don't think that's true
Any mod developers here?
ye
i need to check if an inventory (in a click event) is one that i have created. whats the best way to do this? store a list of Inventory instances and check if the instance returned by the event is contained? or a list of hashcodes
Use a Set<Inventory> for that.
right
More advanced guis are often done like this:
Map<Inventory, SomeCustomHandler>
and as long as i remove the inventory from the set in the close event, i should be fine eh?
If you only want to have one viewer per inventory then yes.
yeah that makes sense, all my inventories are handled in the exact same way though since the contents are completely arbitrary
they are created per player out of necessity :)
so hashcode/equals does not change when the inventory's content is changed? or
It will still be the same inventory if the content is changed... So even if it changes the hashcode or equals outcome it wouldnt matter.
what is the best way for the player to fly a vehicle with a increasing speed over time? (I have w and s input working already)
elite dangerous
planes?
yea about
ngl, havent watched 1 star wars movie so I dont have a clue what that is called
x wing
resource pack
ok so
we have a mod that does that currently, we are just hoping people wouldnt just steal the models
we will have a resource mod version, just lower poly models
mods ๐คข
nothing you can do about it but it's unlikely
is it possible?
not easily
you do it then
huh you can change the roll of a mob?
jeb_
no
its a instant roll though?
can the PlayerMoveEvent be called more than once per tick? (per player)
im kidding
var player; // assume this is the player
var loc = player.location;
var r = loc.roll;
r += Math.toRadians(180f);
loc.roll = r;
player.location = loc;```
bammo
(it's minecraft)
OHHH
(silly block game)
sad, wish there was a way
jeb_
thats just
I a the ultimate prankster
you cant rotate with a and d
jeb.
oh yeah you had a question
umop apisdn
iwej laksd
fool
dw I found the answer
you leave unchanged
c#
how do I get the 1.18.2 spigot file with CraftEntity? I tried Maven and it didn't work. Idk what to do
It is like what am I supposed to depend on?
Or what am I not doing right with Maven
yeah
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
get the minecraft development plugin
and make files
using that
so much easier, maven is all setup
I depend on spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar and it isn't working
because thats the api
because it doesn't contain CraftEntity
read the linked post and its link to the 1.17 post
It explains all you need for NMS
I did, I did, but I didn't understand what it is telling me to do
someone else told me to do exactly that, and I don't kjnow what it is saying to do
I downloaded both the "SpecialSource" and used buildtools to make one with --remapped and neither of those had CraftEntity in it
or as a whole net.minecraft
where is my Local Maven?
read the post again until you see correct dependency <classifier>remapped-mojang</classifier>
literally everything you need is in those two posts
the 1.17 post tells you about running buildtools. The second shows you all the pom entries for 1.18
yeah, it says the exact same thing, "It downloads additional files into your local maven"
that doesn't actually say what a local maven is tho
its a secret .m2 directory on yoru computer where resources are stored
you don't need to know exactly where it is
maven handles all that
just run buildtools correctly (remapped)
then add teh correct parts to yoru pom
and uhh, what would the right thing to put in the Maven be?
just like what it has in the "Example Dependency Config" on the 1.18.1 but changed to 1.18.2?
yes
you mean this? xml <dependency> <groupId>org.spigotmc</groupId> <artifactId>spigot</artifactId> <version>1.18-R0.1-SNAPSHOT</version> <classifier>remapped-mojang</classifier> <scope>provided</scope> </dependency>
that is what I put, but that said it wasn't found so I put 1.18.2-R0.1-SNAPSHOT
but it is still saying I don't have any CraftBukkit stuff
if you are using InteliJ I believe you have to refresh or something
type an import and see if it has NMS import net.minecraft.
nah, I just reloaded and it still doesn't
?paste your pom
does your pom show any errors?
I can't still understand public, private, static and... stuffs, is there a video to explain it completely?
?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.
check those out
thanks
no, none
then you should have nms access
are you sure you are trying to use a valid nms import?
wait, net.minecraft is back!
but where is EntityInsentient
did they rename it or smth?
no guarantee anything has the same name
anyway, thank you very much for your help
but stuck on this issue for like many dayys now
I have an issue myself, I went to a Java programming Discord and they told me I should "ask the experts over at Spigot" so now I'm here
This... isn't exactly developing anything so I'm not sure if I'm allowed to post this in here or not
?ask
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!
Fair enough
Essentially I need to compile this plugin here https://github.com/SaitDev/MobArenaExtension
I went over to the Java programming Discord and they told it was more complicated than it seemed and that I should come to people who knew about Spigot
Its a maven project so quite simple
The artifacts on this page have all expired, that's why I need to compile this myself
I loaded the project on Idea, and exported it, and the guy told me it basically just made a ton of smaller files and not an actual usable jar file
looks like its for Spigot 1.13
All it does is help 2 plugins work with each other, MobArena and MythicMobs
its been updated 6 months ago, and it used to work just fine on 1.17
that pom on Github says its for Spigot 1.13.2
It also uses a local jar file <systemPath>${basedir}/libs/MythicMobs-4.4.1.jar</systemPath>
Hmm, maybe it won't work with the newest MythicMobs then?
Hello I was wondering what do the parameters
villagers-every: 600
villagers-for: 100
do in spigot .yml ?
Since I upgraded to MythicMobs 5.0
The version you linked will not
So essentially I'm stuck then unless I backport my server to an older version?
or you update that code to support newer. You will need to be adept at Java for that though
I know a basic amount, this project will probably be too much for me
That's a real shame
Thanks for your help though!
does Mythic mobs not have a repo?
They have a repo
I was just wondering why that code used a local file for the MM jar. I guess its the paid version
Sure but MythicMobs also include the paid version repo too, idk why they use local file xd.
just found a really bizarre behaviour in my plugin.
for (int i = 0; i < enderChest.getInventory().getViewers().size(); i++) {
System.out.println(i + ": " + enderChest.getInventory().getViewers().get(i).getName());
}
prints
[20:21:41] [Server thread/INFO]: 0: minion325_
[20:21:41] [Server thread/INFO]: 1: minion325_
[20:21:41] [Server thread/INFO]: 2: minion325_
[20:21:41] [Server thread/INFO]: 3: minion325_
why are there deuplicate viewers?
if i open it 10 times, there are 10 duplicate even though i close the inventory with esc
are you holding a reference between opening to either the chest or the viewers?
the enderchest holds a reference
protected void openInventory(Player player) {
player.openInventory(this.inventory);
}
that how i open the inventory
i dont recreate a new one
are you doing anything crazy like canceling a close event or something?
the only listener is inventoryopenevent
i cancel opening of an enderchest to open my inv instead
u wanna see the src?
sure
enderchest manager onleave
You are doing somethign funny with viewers in your EnderChest#setRows
is that for resizing the inventory?
yeah when its resized, i wanna reopen it for those that are viewing it
but when im testing right now, im using a constant size
let me just debug if that's being called
that part of setrows isnt even being called
8 entries means i opened the chest 8 times
I see no obvious reason for it in that code. its as if the close event is being ignored
but you do not even listen to that event
gonna listen to it and see if the number of views goes up
it does
thought i was somehow calling openinventory twice
but im not
i'm so confused
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
private void onInventoryClose(InventoryCloseEvent event) {
event.getViewers().remove(event.getPlayer());
}
@eternal oxide look at how stupid this is
why do i have to do that manually?
it fixes my problems
very odd
API problem maybe
happens on 1.8.8 as well as 1.18.2
Should i use this as a solution?
Feels wrong
infinitely incrementing viewer list?
If so, I'd open a bug report on the JIRA because it's probably something that needs to get fixed
Everytime i open it the viewerlist increases by 1
e.g. equivalent of
for (int i = 0; i < 5; i++) {
player.openInventory(inventory);
}```
?
(obviously not that stupid, but same general idea? opening without explicitly closing?)
How could I Implement Item Sets?
Inventorycloseevent is called
but isn't removed from the viewer list
Nope
Yeah, I'd file a report on the JIRA for that then. If you can make a minimal reproduction plugin (as little code as possible but enough to replicate/demonstrate the bug), that'd be ideal
?jira
Ok will try
tyty
Question, I am messing around with custom dimension heights, but when I change the dimension height and start up the server, I am getting spammed with Ignoring heightmap data for chunk [-26, -1], size does not match; expected: 43, got: 37 warnings
They really pollute the log, can I supress or avoid them somehow
how would I get a player head via dcode
theres no HeadItemMeta
how do I tell a stack of what player to get its hed form
how do I specify it via nbt
declaration: package: org.bukkit.inventory.meta, interface: SkullMeta
Thatโs backward compatibility
When it was introduced all โheadsโ were just skulls with a data value of 3
hmmm
?jira
@worldly ingot https://github.com/minion325/BugReportPlugin This is code to reporduce the bug
never used jira
Where is PacketPlayOutMapChunk in 1.18(.2)? It seems to no longer be located at net.minecraft.network.protocol.game.PacketPlayOutMapChunk
(Please ping me when responding)
how can i open an anvil gui with a custom title? i saw some old forum posts where someone said you could do it
declaration: package: org.bukkit, class: Bukkit
InventoryType.ANVIL
in the same thread someone said they tried to do that where they specified the title but it still showed the anvil title in the client
try it
yeah
cool :)
I'm attempting to recompile Bungeecord with a 1 line change, and I get this.
I don't get it
I just downloaded bungeecord from the github 2 seconds ago.
r thos the lines u edited
did ur editor do some mad spaces/tab stuff
ยฟ
Put a space before closing brackets and after opening
And remove imports that are unused
Can someone lmk how to get a list of currently online players on a server in my plugin?
Bukkit.getOnlinePlayers
?jd-s
Another server i think
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
they didnt really ask that
True but no way they don't know about Bukkit.getOnlinePlayers
who says?
And they said "a" server
maybe he is using Word to create their plugin and it doesn't have auto-completer
you never know..
Why do I need to manually insert the id in the database table even though I already set it to auto increment? This is how I create the table.
Ok and how do I use a for loop with that though because when I do Player[] onlinePlayers = Bukkit.getOnlinePlayers(), it gives me an error so yea
?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.
LUL
it returns a Collection<? extends Player>
It was actually Bukkit.getOnlinePlayers
Agree with you
not a ? extends Player, but yes a Player
its literally a ? extends Player
wall what other object implements the Player interface?
Yeah cuz under the hood itโs of the type Collection<CraftPlayer>
(Which is a derivative type of Collection<? extends Player>)
I understand this, but as far as I am concerned, it should be a "Player" (casted) object.
not a ?
something that implements Player
not the Player interface
still
unneeded explicit
Well this is just generic type inheritance variance
i dont get the point
Because
Collection<CraftPlayer> is a subtype of Collection<? extends Player>
But
Collection<CraftPlayer> is not a subtype of Collection<Player>
bad java
the id become null, when I put NOT NULL on the create table it throws an error
forget about this, thanks anyway
I really gotta be honest, I don't get this shit, I understand that java interpretates it this way, but this is so dumb, as far as I am concerned, a Collection<CraftPlayer> is literally a Collection<Player>, and can be achieved with a stream, for example.
Yeesh thats a lot of bold
(shouldn't be needed imo tho)
Anywayyyy
that's what i do
ok I need help, basically I'm trying to "disable jline", so I could read the console, I marked as white the things I changed, but it doesn't work, and I don't understand it, can somebody help me here?
so uhh, anyone knows jline ?
And what about when needing to keep an interface, and then 2 implementations together, but knowing that each impl has extra methods that are not in the interface. Because if i cast "interface" => "implementation", then i get NPE
I just dont know how to do it with a map
- Map<UUID, Menu> (menu its an interface)
- InventoryMenu (normal menu), implements menu interface
- PaginatedMenu (menu with pages), implements menu interface
So im the fuck literally because when casting, menu to paged i get NPE and if i dont cast it, them i cannot access to methods that are not in the interface
๐ค
I explain have you read on top?
.
why wouldnt this work
?paste
Why? Because menu contains some common methods and each impl contains others methods that are not included in the interface: so then when doing:
PaginatedMenu paged = Map#Get(UUID) => Then i get NPE
Know i think its clear
This is my example paginated menu https://paste.md-5.net/ideqonelay.java
you're not checking?
Why would i check? I dont care, the 2 are the same shit, but one contains some extra methods
๐
That what i tihink. But i realise im wrong
then at that point
final local variables ๐คข
verano i dont think you're understanding interfaces and casting
Its really annoying not getting understanded :(
Its an example/ final is ment to indicate, don't fuck with these values.
Why? One usage of interfaces is for common things btween classes
are you just wondering how to make a paginated gui
So im not wrong at all
No no
Im just wondering to be able to do:
InventoryMenu menu = Map#get(UUID) - Which returns a "Menu" object
PaginatedMenu paged = Map#get(UUID) - Which returns a "Menu" object
But them i get NPE
lmao
LMFAO?
Lmao why the fuck i taken "advanced international exam" if no one understand me
๐ฎโ๐จ
dude
are you literally saying that we are below your exam?
if you get an npe from that
the key (UUID) is null or the map is
you havent even shown us the fricking NPE yet
On the map nothing its null, its happen by cast
what
Because Menu its an interface right?
.
"and casting"
I dont know i have this code
IF YOU DON'T UNDERSTAND, why you say this?
okey bro
show us your code
do it
public class MenuHandler {
private final Map<UUID, Menu> menus = new ConcurrentMap<>();
public void register(UUID uuid, Menu menu) { this.menus.put(uuid, menu); }
public void unregister(UUID uuid) { this.menus.remove(uuid); }
public Menu getMenu(UUID uuid) { return this.menus.get(uuid); }
}
public class Test {
// I need to cast the menu object to PaginatedMenu, because then i cannot use next(), previus(), etc methods
public void test(Player player) {
PaginatedMenu menu = (PaginatedMenu) MenusPlugin.getInstance().getMenus().getMenu(player.getUniqueId());
menu.getPage().next();
menu.open(player)
}
}
I think know i have explained
Or atleast im wondering to be understand
Its longer but that a simple demostration of what i have
I see one main issue here something like MenusPlugin#getInstance is this a bug?
No no, that came from my fully code
I dont have the code atm, but its demostration code of what i have
oh I was just offended by the lack of DI
What do you think? Im really annoyed since yesterday
that idea looks pretty solid though for a 1 menu per player system I'm not to advanced in java so I don't know if there'd be some unforceen extreme overhead of doing it that way, but I think it looks fine
For me it fine, because i dont even touch the register/unregister methods, its auto managed by the MenuListener
Dont worry of the key-value map
Its my way of tracking my custom inventory
showed the error

well if there was an NPE which their shouldn't be it means you added a player without adding a menu
But i think its caused because im casting the getMenu which returns Menu object into PaginatedMenu
I've never had an NPE with a map before though so 
no
if i know java that does not cause an npe
casting null to something is just null
null is null
Maybe its not an NPE
you will not get an npe from casting to anything other than a primitive
Its a cast exception

you confuse me too much
just wait till you get the error
Or im either dumb
than post it here
well actually you dont fricking CHECK YOUR CAST
it'll be easier for all
my idea doesn't care about blind casts, but thats because I told it not to ๐
Im turning pc on
PaginatedMenu menu = (PaginatedMenu) MenusPlugin.getInstance().getMenus().getMenu(player.getUniqueId());
menu.getPage().next();
you just blindly cast
blindly?
without checking instanceof
Oh thanks
I shouldnt check instanceof
im gonna go kms
Because i wont know if the uuid has at the moment opened either a paginated menu or normal menu do i explain?
That hat fucking me
instanceof
holy shit
?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.
if(menushitwhynoDIlMFAO instanceof PaginatedMenu menu){
// logic here this is a safecheck no errors will be thrown
}```
I know about instanceof
obviosuly fucking not
theres stuff abourt abstractation
in those tutorials
Allright, now my worst enemi lamda with instanceof
Lmao
that will be al amazing party
uhm not a lambda
what
I think you are having trouble with english translation? or your just dumb
Can you even use a lambda for an instance of?
Better question is why the fuck would you
I have taken advance international exam, and my english is wors tthan a 5y american child
๐
I dont really support thousans of line in a return
I know im really specially
do you know what a lambda is?
๐
-> the cute little bolded arrow symbolizes a lambda
wrong, =>
that the correct one
what
what
what
no
no
are you trolling?
JS is disgusting mistake of a language
JS is dogshit
I know lmao that hwy i prefer typescript
The day I use JS is the day I've given up my dignity
rust 
In fact to solve my shity issue i need to do an instanceof in the Menu getMenu() methods right?
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Hmn?
rather than static reference
?di ck
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
nice
I already use that
ty ty
oooh i wonder something
your code says otherwise
Hmn i be clear please
Your statically accessing the main plugin ๐ญ
Im really dumb 3 shots of gummy voodka and i look like having nightmare in a bot
The main class that extends JavaPlugin should be a static method
Or ima wrong?
there should be no static method
If I send a TextComponent without the player.spigot().sendMessage is the text still have like a click event?
I only have the MainClass getter static method
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
^ read very good shit
i made dis
then it was edited
good job Imajin
/**
* Logs a message in red using the associated plugin's logger.
*
* @param message the message to log
*/
public void logRed(String message) {
// accessing JavaPlugin's logger
plugin.getLogger().info(ChatColor.RED + message);
}
@dusk flicker this doesnt actually work
you know this would be easier if I spoke spanish but my spanish is the equivalent of a 1 year old
it needs console sender
i will implement!
nvm dont feel like it
Yes if talk in spanish you understand what i mean in less than 1m
your not using Dependency injection for your main class though
thats the issue
you wanna be using Dependency Injection there
Ohh ok
Always learning smt new here
also fix your casting too
no lambda needed just
if(menu instanceof PagedMenu pagedMenu){
// logic
}
simple Di
Yeah i think it will be fixed by:
Menu getMenu(UUID uuid) {
return (this.menus.get(uuid) instanceof InventoryMenu) ? (PaginatedMenu) this.menus.get(uuid) : (InventoryMenu) this.menus.get(uuid);
}
public class ThePlugin extends JavaPlugin {
@Override
public void onEnable(){
new OtherClass(this);
}
}
public class OtherClass {
private ThePlugin plugin;
public OtherClass(ThePlugin plugin){
this.plugin =plugin;
}
}```
I kno that what are you correcting tho?
I had an annurism reading this but uh maybe
static access is just a bad habbit and makes code less portable
why the fuck are you casting
OMG
IT ITS A MAP OF MENUS
GET RETURNS A MENU OR NULL
im more pissed that you have not read a single thing said by your ide than not understanding
idk why he doesn't just do
if(this.menu(uuid) instanceof PraginatedMenu menu){
// logic
}
I need to do it because i dont want to be checking instanceof every time i call getmenu()
you
still
will
holy shit
thats a micro optimization
bad habbit
just check the instanceof and move on
no its actually slower with whatever the hell that useless ternary statement is
idfk wtf that is bro
he will STILL have to check the instance
I just read it and gave up it was so horrid
return "true" ? true : "false";
wtf does that mean
imajin so the code is okay or not?
why would you wanna one liner something so big
no just check theinstanceof
seriously
delete
this, all of this
... y2k
Allright
if you dont understand then im done bothering
But them i still need either the casting or instanceof
kms
I thinkyou dont undertand what i really want to say
that on the getMenu() method right?
MAP STORE MENU
METHOD RETURNS INTERFACE {
GET THE MENU FROM THE MAP AND RETURN IT
}
^
I have that lmao
NO YOU DONT
Menu getMenu(UUID uuid) {
return (this.menus.get(uuid) instanceof InventoryMenu) ? (PaginatedMenu) this.menus.get(uuid) : (InventoryMenu) this.menus.get(uuid);
}
...
Really im not trolling, im just dumb and my cmmunication its horrible
