#help-development
1 messages · Page 1548 of 1
I have this: ``` @EventHandler
public void onPlayerClicks(PlayerInteractEvent event) {
Player player = event.getPlayer();
Action action = event.getAction();
if (action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK)) {
if (player.getItemInHand().getType() == Material.NETHER_STAR) {
player.sendMessage("This works");
}```
It won't send the message. I temporarilly removed all gui stuff just to test the listener.
did u register
event ?
set a boolean to true when you start the runnable, and set the boolean to false where you end the runnable
Sounds like no
That might have been a good idea
yep I am avere of that will need to do small recod because of it but dam it Thanks 🍻
np.
anyone know what this is a result of, never had it before: https://paste.md-5.net/ihopayupev.apache
ok, so ive been working on a plugin, and i need my on disable code to run when i update the plugin, but it does not run
it runs every time unless i replace the jar with a new version
Can't u call the onDisable function, then run the updater,then run your onEnable function?
How can I get the "name" of an Advancement?
Like "Stone Age" to "story/mine_stone"
I should be able to get an Instance of the class just fine, just not sure where to go from there
I'm trying to make a joining animation thing when players join my server (it makes them jump out of a fountain onto the spawn area, I can't use setVelocity because the water prevents setVelocity from working) but for some reason, despite me not setting the player's pitch or yaw, the player is unable to turn their head. It also seems very laggy, despite being run every tick. Any ideas why? https://paste.pythondiscord.com/diyopexaka.java
Having a bit of a problem, I need to set the value of the field responsible for disabling armor stand slots. I got a value for 1.16.3 which is disabledSlots, but on 1.17 this field doesn't seem to exist. Does anyone know what it's supposed to be or how I can find out what it might be?
declaration: package: org.bukkit.entity, interface: ArmorStand
@cosmic patrol if there are other fields that are truly only accessible by reflection that you need
I would run buildtools at 1.16.5
Go to the builddata folder
I want to fix ArmorStandTools I believe it's called and for that I need the name of the field. Though of a way by just dumping all the fields into the console so hopefully that works
And look at bukkit-1.16.5-members
It will tell you the mappings
All fields were reverted to their obfuscated states
The members file should be correct for the most part
Otherwise you can use a decompiler to look in the class file
I wonder why I didn't think of this first. Thank you for your help
if I was making the plugin I would, just that I want to update an existing plugin and it uses reflections to accomplish it's multi version compatibility which gives some problems when updating.
Is there a map somewhere I can use?
😢

Hey so I want to make a plugin that makes it so spawners don't drop xp, I've never made a plugin how would I do it?
Do you know Java?
listen to BlockBreakEvent, check whether the broken block is a spawner, if so, use setExpToDrop() to set the dropped xp to 0
i have this plugin source code
he is white tho NNYa, not a blue guy. chanced are he has never seen java
how i make it into a jar file
compile it
do you have an ide
yes
send the repo link
intelj
send the repo link
dm
ok...
whats the best way to drop a itemstack
ctrl+q
no like
xD
xD
create a itemstack
idk
So, basically you want to create an itemstack and then drop it into the ground?
lol
World#dropItem
Hello. Is there an easy way to check if a particular dimension is an instance of a World?
Or is there any link present between something like world, and world_nether
other than the name
I have a plugin that I'm making that will load an intance of a plugin based upon WorldInitEvent.
void test() { local l = {}; }
@granite stirrup I'm getting a lot of (edited)
?
I guess I could just make a function getWorldPrefix, and check if they are related based on the name :/
;p
its meant to be like that
how do you use the world interface
implement it ?
I mean, it's a way to use it xD
World.dropItem(player.getLocation(), item);
so how would i do this
without the World?
as stated, both player and player.getLocation() have a getWorld method
Bukkit.getWorld("world name or what ever")
edit: nope
no
How can i set connection properties?
player.getWorld().dropItem...
Id need autoreconnect=true
ok thank you
what kind of connections are you talking about nuxoria
interpersonal connections
I'd love an autoreconnect on those 😭
man, this channel is getting crazy every night
MySQL
what connection pool are you using
public void openConnection() throws SQLException {
if (getConnection() != null && !getConnection().isClosed()) {
return;
}
connection = DriverManager.getConnection("jdbc:mysql://" +
this.host + ":" +
this.port + "/" +
this.database + "?autoReconnect=true",
this.username,
this.password);
}
This didnt work out for me
My connection times out
after like 20 mins
and my plugin stops working
?paste
Why does this not set custom names for the items but rather only put them in a GUI? (point of interest lines noted out)
Player player = event.getPlayer();
Action action = event.getAction();
if (action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK)) {
if (player.getItemInHand().getType() == Material.NETHER_STAR) {
Inventory inventory = Bukkit.createInventory(new menuGUI("Menu"), 9, "Menu");
ItemStack item = new ItemStack(Material.PAPER);
ItemMeta meta = item.getItemMeta();
//Paper
//meta.setDisplayName(ChatColor.WHITE + "Welcome message!");
List<String> lore = new ArrayList<String>();
inventory.setItem(0, item);
//Diamond
item.setType(Material.DIAMOND_BLOCK);
//meta.setDisplayName(ChatColor.DARK_BLUE + "Shop");
inventory.setItem(1, item);
player.openInventory(inventory);
}
}
}
}```
Ooh, thanks
@vital ridge I'm not from a PC to see it, but check out hikariCP it may come in handy at some point
basically tells you why autoReconnect will not actually always reconnect
Well Idk what to do then
either deal with a potential re-creation of the connection yourself
or use a pool like any normal human
e.g. hikaricp
So with hikaricp
\💻
the pool should maintain open connections
you can set how long you want them open
but the pool maintains, well, a pool of x open and ready connections for you
creating new ones when old ones are closed
⊞
How to you properly prevent a user from taking an item from a custom GUI?
Cancel the click event
I thought so, but when I do this it doesn't work:
if(event.getView().getTitle().equals("Menu")) {
event.setCancelled(true);
}```
You shouldn’t compare with title
You should compare with the view returned by openInventory
Also make sure you have @fresh templethandler and that you registered the event
I'm pretty sure I registered the event. How would I compare using openInventory?
@fresh temple
^
I have the actual inventory down, I just want to lock the items in it
and for some reason I can't find any helpful articles or videos online
store the inventory instance somewhere
then check if the view involves that inventory instance
with f.e if (view.getTopInventory() == myInventoryInstance)
Using views is the best
Add the view returned from openInventory to a hash set, and then check contains() in the event
if you have multiple inventories that you're juggling around, that is an option
and remember that a player can modify an inventory even without directly clicking it
for example, if the player doubleclicks a dirt block in their own inventory, this will attempt to collect all of the dirt blocks in the inventory view onto the player's cursor
which will also pull from the top inventory
so just checking whether getClickedInventory() == myInventory isn't sufficient
It’s always worked fine for me
I think that triggers a click event for the top inventory
i don't remember that being the case
is there a way to get the weapon used in EntityDamageByEntityEvent?
Get the item in the attackers main hand
i think you can shoot a bow from the off hand
splash potions will also rekt you
i don't know if there's a good way of getting the weapon used, as I think even under the hood nms trips over this
Yes but those would not be directly caused by the attacker
it was a thing for a long time that your main hand item's looting enchant would be applied to all mobs you killed with a splash potion while holding it
You can store the bow with the shootBow event, but potions are a bit harder
sure, but they still fire an entity damage by entity event
also if you switch weapons after firing a bow
yeah you used to be able to get looting bonuses if you shot a mob and swapped to a sword with looting before the arrow hit
you can at least get teh shooter from that though
not sure if that still happens
You can store the bow Itemstack with the shoot bow event
Into a map with the projectile
for potions, I think the thrown itemstack is accessible in whatever event is fired when the actual splash happens
as for how to link the splash to the damage event, I'm not sure
Potions have their own events
dont get custom inventory by name
le epic rename chest to inventory name and profit
i just need it for an axe @wraith rapids
but how would i get that item? i know how to do it for a player, but im not sure how to do it if a pillager/zombie has an axe
Quick bungeecord question. What event should I use to get the ProxiedPlayer when he joins the network (proxy). I don't want it it trigger when the player switches server but only when he joins the network.
tysm
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:item/snowball"
},
"overrides": [
{"predicate": {"custom_model_data":101938483}, "model": "items/garlic"}
]
}```
why it dont work :/
resourcepacks are annoying bc theres like no means of debugging
You gave yourself garlic in-game?
im trying to
Also why items instead of item
I would suggest you name it as item
ah ok, @digital plinth just saw your resource pack, you need a json of an existing minecraft item
your current garlic.json should be snowball.json
wait you dont even have a model file for garlic
as mentioned, you will need a snowball.json like so:
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "minecraft:item/snowball"
},
"overrides": [
{"predicate": {"custom_model_data":101938483}, "model": "item/garlic"}
]
}
and since you referenced the model to be item/garlic, you will then need to provide the model garlic.json:
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "item/garlic"
}
}
and there you go
Thank you
hm
weird
i added the snowball and garlic.json
"parent": "minecraft:item/generated",
"textures": {
"layer0": "item/garlic"
},
}```
garlic
Whatever that is referenced here
its item
maybe i should relaunch mc?
Yes you need garlic.png in textures/item directory
lol
Tysm
npnp
indeed
alos what is DEUS VULT
oh nvm
google told me
lol
Btw apparently i Entity(progetile) dont have customModelData
theres .setItem for projectiles
is there like a .getItem?
dont think so
but why
:<
i want my garlic(snowball with custom model data) to deal dmg
Cast to Snowball
okay
i need a try ctach?
What? No
okay
but the prjectile might not be a snowball
its not avaliable in projecilte hit or launch
declaration: package: org.bukkit.event.entity, class: ProjectileHitEvent
then you test what is the projectile instanceof
entities
i can use .getUniqueID
after the .launchProjectile
but if i do that
then i cant use .setItem
store it in a variable
then call the methods on the variable
in other words, learn java
so when it is thrown, is the model gone?
i can store it in a var
entities dont have custom model data apparently
"Projectiles are not ItemStacks, you cant convert a projectile(entity) to a itemstack" --- someone on spigot forum
yea, just confirming that the model is gone
Hi, I'm trying to make the invisibility effect hide armor too (instead of the vanilla functionality where it still shows armor). I've searched around a bit and found a solution using ProtocolLib + NMS, but I can't seem to find a jar file for NMS. Does anyone know where I can find it (or build it myself if necessary)?
So long as its not been messed with you can call getItem() on the Projectile
it is in the spigot.jar built using buildtools
no need to cast entity to projectile
So long as it is a Projectile, yes
if you use ProjectileHitEvent, the entity you get from #getEntity is of type projectile
sorry, wdym by this
in the spigot server jar?
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
^ you use this to generate a spigot jar
oh NMS is inside the spigot jar?
you have to set your artifactId as spigot instead of spigot-api too, if you use maven for the spigot dependency
no it returns an entity
you can cast it to a projectile i think
huh?
wait fr?
i wasnt able to use .getItem on them tho
i can after i casted it to snowball
yes cuz snowball is also a ThrowableProjectile
so ThrowableProjectile is the interface that has this #getItem() method
not Projectile
ohh
so thats why
okay
btw does anyone know a pixel art software that let you upload a 16by16 picture and edit the pixels
so i had this very weird bug where spawning pillagers with nms pathgoals would give a nullpointerexception with no reference, despawning the pillager entity
does anyone know something about it? or things i need to watch out for when spawning pillagers?
That’s not Paint.NET
Paint.NET is free image and photo editing software for computers that run Windows.
thx
why the fuck is fastutil relocated
welcome to the greatly disappointed club
okay, there's this method. can someone please explain me what uOffset and vOffset are? never heard that. i only know x and y tho
(has nothing to do with spigot. it's actually rather a question in general, bc i think u and v are something that i should know what they are?)
uh what's the context
rendering a texture from a png

Whats the method from?
mc
package?
if you want the exact class, AbstractGui
do you have a package for that? can;t be bothered to search
at a guess I'd say it was probably the offset coordinates for texture wrapping
so basically at which position the end-texture is located in the png file?
or am i getting that wrong
hey guys, anyone know why PacketWrapper's BlockPlace doesn't support the blocklocation?
it could be
what i'm doing rn is in general the dumbest and probably most complicated thing i've ever done lmao.
i see literally no way to implement custom fonts into the mc-system, and so i'm rendering the fucking letters from png files lmao.
you can customize the text font via a resource pack
i mean via code
for my client
i dont want to change all of the font. i want to have like a custom font for example for my buttons
like arial or smt different
but because the mc system itself renders from png files too... i cant simply render a normal font to the minecraft-existing display. because it doesnt use jlayer, or whatever exists out there.
either that, or i simply dont know how lol
Afraid I've not played with the client at all
Slick util is incompatible with lwjgl 3.2.2
and there's probably no other library like slick
why does mcasset.cloud not have wooden sword's json
Though you do understand that you have those assets, right? On your local computer?
%appdata%/.minecraft/versions/1.17.jar
🤷
jar is like a zip, it is a folder containing random shit, including default texture folder
ik i can open it with winrar
so you can get the wooden sword's json from there then
its a teeny bit more convenient to use mcasset
yea
I mean I rather depend on sth given by default
sth?
something
what is something given by default
I rather depend on things that are given by default
like minecraft providing you with the version jar
must as well use it, will not go wrong
why tf would you use an asset browser? tf...
just go to your versions folder, copy all of that into for example documents/assets/*
and there you have all your assets for all your versions (if you use multiple ones)
there's no reason for using an asset browser, except pure lazyness
Even with laziness, you can make a copy once and for all...
Yea thats a comment for @digital plinth haha
lol
for example i have all my assets in my documents for this cases. so i don't have to everytime open the jar and manually searching for it
im not really familar with winrar so
does shift clicking items into a crafting grid fire the inv click event
why be familar? all you need to do is open your jar with winrar. and it looks like a normal windows explorer
🤷
ofc
ohh okay
every click into your inventory fires that event.
even clicking on empty slots?
handled under InventoryClickEvent#getAction i guess? but idk
nvm, that was interactEvent
yep
iirc, even outside of the inventory is fired. but idk for 100%
i mean like left and right of your screen when opened your inv
okay, question to everyone.
is there an EASY method to render text to the existing minecraft-client-window with a custom font? as minecraft uses its own (btw VERY complicated) bitmap-system, i cannot use that for it
[1.16.5]*
Action bar?
isnt that mods then?
for example, i want to change the font of this buttons
it basically is mods, yea
but without a modloader/api lol
plugins can do that?
nothing but pure lwjgl 3.2.2
^
texture pack? XD
i want to change only specific stuff
this is for spigot plugins lul
like for example the buttons
if i ask in general, you can see them sending me in here lol
you can change the buttons
wdym
gecko: here this will explain it "google.com/search"
tf
he does that quite frequently
for self-explanatory questions that can be searched, yes
and then i even googled it for the retard
he also posts random emojis 👍
oh
so back to my question... is there a way? what i want is just render text in lwjgl 3.2.2
but like all util-libs are outdated or trash
i dont even know lwjgl is :/ lol
i could send you the ip of a server whose texture pack changes some of the ui buttons
if i wanted to make a Vector that points in the direction the player is facing, how would i do that even if the player isnt looking in a cardinal direction?
god
i really wanna hear that?
posts random emojis
oh you already saw?
wasnt this lax?
i didn;t know my video was that popular
also guys the anime of the year
its is
dun dun dun
dun dun dun
Record of Ragnarok
any disagreement
fully disagree
its unique and really good
because i dont watch anime
get out
#help-development message
seems like we're getting off track here, but I've definitely seen it possible with a texture pack
no u
no u
whateverrrrr
and if your humor wouldnt be as old as my grandma, your would get that joke
eeeeeexxxactly
ahh both of my grandmas died to cancer
lets get cancer out of the world
worse than covic
d
actually a german youtuber recently died to cancer.. thats saad
the thing is... if you have cancer, you know that you will die to like 90% or smt
i dont wanna be in such a situation tbh
imagine you know you only have a few days
never had hiv, so idk
never had cancer tho
well if you have it
you cant get rid of it
hiv = death sentence
but recently theres more effective drugs
or what even helps:
disable dm's from people from spigot/paper/forge/etc discord
thats where 90% from that people come from
miss those, ahhh
an actual person joined my server and asked if I wanted dm ads
its mostly even enough for such people if you just have it in your 300 follower instagram bio
god, my instagram is so full of sex bots lmao
the account probably already got deleted by dc itself
idk
anyway, i disabled dms, and now i dont get those anymore
bc people have to send friendrequest first. and i dont accept friend requests without reasons lol
imagine having DMs enabled to start with lol
i actually never bothered before i got those ad dm's
btw...
am i the only one who thinks that the logitech software is nothing but trash? holy fuck
you can only apply macros or whatever to the f-keys
arrows lose custom model data when shot and picked up
is there a way to keep the data
no idea
NNY how are you doing
you want to everytime call him by his dc name?
sure
then you officially have too much time
@everyone call @wraith rapids NNY from now on
thats what he/she said
worst joke ever
e
imma go work on math now
nny is the intended shorthand yes
hah
people from certain languages prefer nnyak
NNYaKNpGms0eUVpiSdHx
as some languages intuitively want to end things with consonants
my language just wants to call people idioten
at least i like that
like i said
too much time
imagine if contributing bug reports and shit was so easy with everything as it is with towny
i dont think someone who is wasting their time talking on discord on random topics get to criticize anyone as having too much time
you just go on their discord and have like vague screencaps of a spark report
and boom shit gets done
nobody even complains
so to go back to my question.. maybe you can help me...
i need to render some text in lwjgl 3/java-in-general, but i have no clue how. do you hav an idea?
i dont think theres anyone who knows about that stuff
thats java
maybe ask in minecraft official discord
🤷
i'm sure they'll love to support that xd
a pure java discord could server you better to that end
its not like they are gonna ban you
server you better
i do very little pure java myself
imagine using java for literally anything if you don't have to
java is cool
kind of crummy
what was that word that one oversensitive fuck tried to report me for
what should i use instead, pythong?
NNY: learn java
and your telling ppl to learn java
cool
thon*
ah yes
ew get that out of my face
KONZENTRATIONSLAGER
i have a catalogue of nazi-germany associated words
to trigger people
oh wow
i only use it appropriatly
the hyporcrisy of this new and modern, 'tolerant' world is laughable
you cannot use that phrase appropriatly
im glad the discords are back to normal
i mean, i personally dont care. my humor is pretty dark
no more gay plane
but maybe others do
why does someone caring about something make that something bad
would delete that gif
i certainly don't like certain things
^
that doesn't make people saying those things be in the wrong
godcipher, maybe you can help me? :(
no one can help me, i'm sad
google can help :>
that reminds me of smt, gimme one sec
i have gore of israeli bombs splattering children into bloody little giblets
Free2use Meme
Ich muss raus!
#Ichmussraus #meme #busjunge #raushier #busichmussraus #jungemitblauerjacke
such a legendary clip
there's also a video of a cat being microwaved
that channel got quickly converted into a meme channel
these are not funny, supa
a video of around 30 pigs being shoved into a pit, covered in gasoline, set on fire, and then buried alive
i ahve more gifs then gecko
well, idk if i like that tbh
that video that ran around recently of like a wolf or something being eaten alive in a zoo or something
if thats too dark for me
i have all sorts of things
bc im google's best friend
best joke ever
i don't like all of the things I have either
you want funny?
imma go 2 bed
you wanna google for me how to do it without creating a separate window? :)
u dont know my bedtime
i know it was several hours ago
ooff
is this funny to you supa
been compiling this fucking maven project for 17 minutes 45 seconds
you want funny?
sause: Record of Ragnarok
Discord: https://discord.gg/ywKqThFrMu
twitch: https://www.twitch.tv/supagamertwitch
Twitter: https://twitter.com/SupaGamerYT
bet its paper
sause: classroom of the elite
Discord: https://discord.gg/ywKqThFrMu
twitch: https://www.twitch.tv/supagamertwitch
Twitter: https://twitter.com/SupaGamerYT
#horikita #suzune #ayanokoji #kiyotaka #classroomoftheelite #anime #cute #funny
yeah but anime is retarded
it's like a 40 source file project
sause: Misfit of demon king academy
Discord: https://discord.gg/ywKqThFrMu
twitch: https://www.twitch.tv/supagamertwitch
Twitter: https://twitter.com/SupaGamerYT
thank you
yetis are retarded too
who was talking about yetis
frogs are bad
u
who talked about frogs tf
what...
you need better glasses
omg you have amnesia
it's a fucking gecko idiot
you need better fucking glasses if that looks like a frog to you
how stupid are kids these days
finally it's done
my server took 40 minutes to shut down today
oh wow
#kumoko #anime #funnymoments #moments #dancing #spidersowhat #sowhat
sause: So I'm a spider, So What? (ending)
Discord: https://discord.gg/ywKqThFrMu
twitch: https://www.twitch.tv/supagamertwitch
Twitter: https://twitter.com/SupaGamerYT
how long was it online
now I can run it just to run into a NPE, do a 2 line change, and start over
i fucking hate development
funniest video
what did I even change
ahh i should make this into a gif
what was even the issue
thats what i love with coding clients. having to restart even after just a change of a single rgb-value
what am I even doing
https://www.youtube.com/watch?v=Axp0CpahwHs you sound stupid in this video
because my intellij doesnt like hotswaps
you are being called NNY
you are being called to bed
thats not me
you are not alive
you are a skeleton
you are dead
:>
you really need to up the magnitude on your glasses
By the way I am not an AI program that has been assigned to keep chatting while my owner have a nice sleep
so you link anothers persons youtube on your discord profile?
or am i getting smt wrong
Youtube account can be shared
Would it be to intensive to do this ?
brilliant
there is nothing wrong with that code
the move event is undoubtedly the best place to put any given logic
theres everything wrong on that
I mean I query database each time player moves idk about that
why is that on iphone lol
make sure that PlayerData.lives is a blocking network IO request
at least it looks like
to spigotmc
you definitely do not want to fucking query a database every time a player moves
sure he does
god
he just said so
lol
with what
i need to render some text with a custom font inside my client.
but because minecraft has such a weird own window-system, i cannot use all that jlayer etc ways... and thats basically all i could find on google.
also i cannot use slick util anymore, because the old version depends on lwjgl 2. the new lwjgl 3 version is not compatible with 3.2.2.
and i know no alternative except rendering them all from png files, and thats nothing but a trash way to do it.
you got any ideas?
hm. never really dealt with clients. not sure if any client even does this. if so you could reverse engineer it and see how they do it.
i actually tried with badlion, but their code isn't really readable, and i have no knowledge about how deobfuscation or whatever works
i think it's more a generic java thing, than just client. i mean, i basically just need to draw a string with a custom font. and dont really know how to do that
if i have two plugin files, with one version greater than the other, will it automatically load the newer one?
i mean, i wouldn't call that readable lol
how does one define an api in their plugin.yml
Hello! I'm changing inventory's item. but it doesn't work
Inventory inventory = event.getClickedInventory();
inventory.setItem(47, new ItemStack(Material.LANTERN));
player.updateInventory();
}```
add the line api-version: <mc version> to your plugin.yml
https://www.spigotmc.org/wiki/plugin-yml/
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
- you don't need to update the inventory. that's completely redundant in this case. except you do something different that needs it
- can you paste the whole event?
sure
public void onInventoryClick(InventoryClickEvent event) {
if (!event.getView().getTitle().equalsIgnoreCase("fryingpan")) return;
if (event.getClickedInventory() == null || event.getCurrentItem() == null || event.getClickedInventory().getType() != InventoryType.CHEST) return;
Player player = (Player) event.getWhoClicked();
if (event.getSlot() == 46) {
if (totoAPI.checkNameContainsInInventory(player, "oil") == 0) {
player.closeInventory();
player.sendTitle("§6cook", "§eyou don;t have oil");
return;
}
totoAPI.removeNameContainsInInventory(player, "oil", 1);
Inventory inventory = player.getInventory();
ItemStack item = inventory.getItem(45);
ItemMeta meta = item.getItemMeta();
meta.setLore(Arrays.asList("§7click to start cook", "§ccheck recipe"));
item.setItemMeta(meta);
inventory.setItem(47, new ItemStack(Material.LANTERN));
player.updateInventory();
}
}```
where is ItemStack item = inventory.getItem(45); for?
It's a itemstack that starts cook
ah you just change the name of it, i see
yes
delay the updating. if that not work just reopen the inventory
and I tested that I changed another slot like inv.setItem(1, new ItemStack(Material.STONE); and it doesn't work
if this returns true:
if (totoAPI.checkNameContainsInInventory(player, "oil") == 0) {
player.closeInventory();
player.sendTitle("§6cook", "§eyou don;t have oil");
return;
}```
the code below doesnt run
maybe it does return there?
I already tried delay task but it doesn't work 😦
nop, It return !0
public void run() {
player.updateInventory();
}
}.runTaskLater(totoServerPlugin.getInstance(), 1);``` this is what I tried
- use a lambda
What slot is 47 in player inventory?
(looks cleaner)
I never want reopen sorry
It's CAMPFIRE (Starting cook button)
I don't see any slot 47 in player inventory.
https://proxy.spigotmc.org/bb6b57bf472c9d8fcc6399f1a9dbd663191a0413?url=http%3A%2F%2Fredditpublic.com%2Fimages%2Fb%2Fb2%2FItems_slot_number.png
can you maybe print out some stuff to see if it even runs? (the setItem(...);)
ok
Well, you're getting the player's inventory.
Inventory inventory = player.getInventory();
not this inventoryhttps://proxy.spigotmc.org/bb6b57bf472c9d8fcc6399f1a9dbd663191a0413?url=http%3A%2F%2Fredditpublic.com%2Fimages%2Fb%2Fb2%2FItems_slot_number.png
It's chest
omg wait
You need to get the top inventory then, because the inventory is a PlayerInventory.
interesting
thanks you @ EVERYONE
dud. if i see your name, i always read angler. what is wrong with my eyes ahhhh
god
glad you had a space between the @ and everyone lol
kinda hate it tbh lmao
nah, my one eye is dead already, and my other one is probably dying soon too. at least i feel like
i mean, there is much stuff i cannot read/see properly lol
you use glasses?
nah, got one of that door thingys in my eye when i was a child. my left eye is fully dead lol
idk if there's smt for that case, but tbh, i dont wanna be a cyborg lol
these door opener things... still no clue how theyre called in english lmao
not that old
i was 8
my brother and me was beefing, i ran after him, he knocked the door in my face, boo
unlucky tho
in your eye?
dumb fucker
in my eye, yeah
how can this dumb fucker be so evil
such a small silver thing
what is that for?
thats probably the way to go
the door knob in your eye
I don't want because my mouse goes middle
idk if that is called knob... translator said so
In English it's a door handle, or door latch. Knobs are always round
blame google translator lol
that is if you close the inventory before. just dont close it. overwrite it
but ty
Türschnalle???
never heard that word in my entire life ahahaha
i guess google translator is really really bad
Honestly i feel like all the translators have degraded over the years. like how?
deepl is great
you weird austrians lol
osteoporosis
lol
sounds like a bone or organ
osteoporosis is some sickness if i remember correct?
yep
österreichisch means austrian in german lol
nothing with osteowhatever
and btw, if i read your name, i always read CodCipher lool
bump
it also looks like that packet is only sent when the client right clicks in the air
it's not called for actual block placement
I'm getting this error when using HikariCP (API for MySQL):
java.lang.Exception: Apparent connection leak detected
at com.zaxxer.hikari.HikariDataSource.getConnection(HikariDataSource.java:100) ~[?:?]
at net.geekxboy.apt.Database.isConnected(Database.java:220) ~[?:?]
at net.geekxboy.apt.Database.query(Database.java:105) ~[?:?]
at net.geekxboy.apt.MySQLDatabase.isPerkActive(MySQLDatabase.java:204) ~[?:?]
at net.geekxboy.apt.PermTimer$1.run(PermTimer.java:196) ~[?:?]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftTask.run(CraftTask.java:100) ~[patched_1.17.jar:git-Paper-46]
at org.bukkit.craftbukkit.v1_17_R1.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:468) ~[patched_1.17.jar:git-Paper-46]
at net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:1488) ~[patched_1.17.jar:git-Paper-46]
at net.minecraft.server.dedicated.DedicatedServer.tickChildren(DedicatedServer.java:477) ~[patched_1.17.jar:git-Paper-46]
at net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:1404) ~[patched_1.17.jar:git-Paper-46]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1180) ~[patched_1.17.jar:git-Paper-46]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:320) ~[patched_1.17.jar:git-Paper-46]
at java.lang.Thread.run(Thread.java:831) [?:?]```
Method that is erroring is: (on return dataSource.getConnection();)
```java
public Connection getConnection() {
try {
return dataSource.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}```
and I have these checks when I definite dataSource:
theres no errors, it prints is VALID
oh also should probs mention
it spams that error
until the server dies
but its weird, because getting the connection gives that error
probably because you've incorrectly configured hikari is why it spams
Are you closing the connections after you are done with them
doubt it
config.setJdbcUrl(jdbcURL);
config.setUsername(username);
config.setPassword(password);
config.setLeakDetectionThreshold(10000);
config.setMaximumPoolSize(100);```
Yeah seems like you are exhausting the pool
seems to not fully understand what is happening with mysql pooling
if (isConnected()) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
try {
preparedStatement.execute();
preparedStatement.getConnection().close();
} catch (SQLException e) {
e.printStackTrace();
}
}
});
}
}```
i am closing
ohboy
Also there is this method, which may also be causing some form of issue
if (isConnected()) {
FutureTask<ResultSet> task = new FutureTask<>(() -> {
return preparedStatement.executeQuery();
});
new Thread(task).start();
try {
return task.get();
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
}
}
return null;
}```
Those 2 methods arent fully mine
i'd hope not cause they are horrible
try-resource Blocks are crying
the connection is definitely not closing in that execute
preparedStatement.getConnection().close();
this grabs a completely new one
right, wt should it be
closing the actual connection making that prepared statement
but you can't do that with the current setup since you async the execute
it would close before that runs
It isn't even async
Like
You are literally polling the future in the same method you throw it off onto a different thread
am a bit confused still sorry
you should just rethink how your setup works. If those methods arent yours, who coded them and should you be using Smth like this ¯\_(ツ)_/¯
the server i dev for recently updated to 1.17, the dev who made this plugin a while back no longer does stuff for us, so i had to try to update it to 1.17 and now all of this crap is happening
I don't know much abbt MySQL so i just need a simple-ish way to fix these messages
Oooof 😭 the worse kind of updates. Well as of right now, the code does not execute anything off the main thread. While it runs the future on a new thread, Future#get will wait on the main thread until it's done
So you aren't gaining much here anyway
Concerning you are running a server with this, you might want to spend the time learning how the mysql pool/ it's connections work
yeah, i definitely plan to, this is just a plugin to manage some timed-perks & stuff for us which needs to be done ASAP ;/
Well, an attempt would be to pass the Connection object around to the executor
To actively close it once you are done with querying it
Like, you are probably using it in some commands or listener
Prepare Statement method incase it would help
try {
PreparedStatement preparedStatement = getConnection().prepareStatement(query);
int x = 0;
if (query.contains("?") && vars.length != 0) {
for (String var : vars) {
x++;
preparedStatement.setString(x, var);
}
}
return preparedStatement;
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}```
Oh god
So basically where you'd wanna go is whereevrr the getConnection methods are being called
In there, after you are done using the result set you close the connection
ItemStack recipeBook = new ItemStack(Material.WRITTEN_BOOK);
BookMeta bookMeta = (BookMeta) recipeBook.getItemMeta();
BaseComponent[] page = new ComponentBuilder("Click me")
.event(new ClickEvent(ClickEvent.Action.OPEN_URL, "http://spigotmc.org"))
.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Go to the spigot website!").create()))
.create();
bookMeta.setTitle("TEST");
bookMeta.setAuthor("HELLO");
bookMeta.spigot().addPage(page);
recipeBook.setItemMeta(bookMeta);
player.openBook(recipeBook);
}``` Hello when I open book with this code, book looks like
how to fix it?
what version are you using
remove parts til it works
also 1.15.2 is not supported
especially not a forked one
your fork/old version might just be fucked
nooooooo
huh ? Just write a simple test plugin for 1.17
if this is still an issue, it would have to be fixed by spigot
it if isn't you are on your own
Hi ! I have a list of object implementing all the same interface and i want from an Enum get the linked Object how can i do this (if you need more detail i can give you)
and i wanna for example GodsEnum.ZEUS call Zeus()
like GodsEnum.ZEUS.getObject() return new Zeus();
enum Gods {
ZEUS(() -> new Zeus());
private Supplier<God> factory;
private Gods(final Supplier<God> factory) {
this.factory = factory;
}
public God createGod() {
this.factory.get();
}
}
could work
okay thx i try this
if that works ive been overcomplicating it hella
thats the usecase for functional interfaces^^
So I'm following https://www.spigotmc.org/wiki/mongodb-with-morphia/ & they have example code snippets at the end, but I'm failing to understand what the DUser type is
it only seems to be used in those code snippets, my best guess is a typo of User
but i guess the supplier is redundant. you could probably just return new Zeus() and require God as a parameter
seems to me like DUser is the DTO and user the normal user
wdym?
DUser is just used to transfer datas which belong to the user from or to the database
so its a DTO
Data-Transfer-Object
[HELP WITH NMS] 😄 Hello, When I open book with this method, the book looks like picture
player.getInventory().setItemInMainHand(recipeBook);
((CraftPlayer) player).getHandle().openBook(CraftItemStack.asNMSCopy(recipeBook), EnumHand.MAIN_HAND);
player.getInventory().setItemInMainHand(item);```
what is problem?
So the thing is NMS isn't really supported
yup, but what nms?
asMnsCopy(recipeBook).toString works fine
and openBook method is of same as mine as 1.16.5 spigot
Are you even supposed to be able to read recipe books?
in irl?
It's probably just his variable name
ah
what's recipeBook?