#help-development
1 messages · Page 954 of 1
Ok so how would I do the companion object, I don't intend to be fed but I haven't given them a look
kotlin is pretty easy to understand tbh, I can read it okay-ish but I can't write it because I don't know it
class BlahEvent {
companion object {
// ... static handler list stuff
}
}
Yeah I'm still a bit lost.
I've got this ```kotlin
private val HANDLERS = HandlerList()
override fun getHandlers(): HandlerList {
return HANDLERS
}
companion object {
val handlers = HandlerList()
fun getHandlerList() : HandlerList {
return handlers
}
}
Should I make the companion object extend event?
Cuz this doesn't work and I tried a couple guesses already that all didn't work still. The issue is that when I use the companion it can't find any of the pieces its looking for so idk how this helps. I know I'm not understanding something
no, you're having two HandlerLists. The instance getHandlers() method must return the companion object "handlers" object, too
you are creating two separate HandlerList objects
I just got it figured out I think I have this now ```kotlin
companion object Event {
val HANDLERS = HandlerList()
@JvmStatic fun getHandlerList() : HandlerList {
return HANDLERS
}
}
class MyEvent : Event() {
companion object {
private val HANDLERS = HandlerList()
@JvmStatic
fun getHandlerList(): HandlerList {
return HANDLERS
}
}
override fun getHandlers(): HandlerList {
return HANDLERS;
}
// Other stuff
}
sth like this should do
(the whole design is flawed anyway though lol)
What design is flawed?
How?
I meant bukkit's event system, not the code sent. It feels pretty weird to require BOTH, a static get handler method, AND an instance method returning the same handler list. should be a registry taking in a Class<? extends Event> instead or sth
We didn’t have generics back then!
pretty sure it's done that way as an 'optimisation'
no map.get(..) call, baked into the event itself
Event system overhaul when
But whats the purpose of the static method
Ah ok
does the server lag if i registered my player move event listen 25 times
Who cares, you dont have any players anyway
no, because how do you get the consumers for an event
true
Gson somehow is able to get around type erasure or sth
think you're both missing the point
Probably
the point is it eliminates a Map<Class, EventConsumerCallerThingyMajig>
I‘m a coding noob, dont ask me questions or assume that I know things
Lol
because rather than map.get(event.getClass()) you just have event.getEventConsumerCallerThingyMajig()
All i know is that kotlin is great (pls dont ban)
banned
Again? Conclube?
yea :,)
UwU
So are you
He went to grab a pizza
might run into the one who we wont name
Why not? :P
the one who I banned?
maybe
ah ok
idk if you banned them
Yeah he banned the pope
In which order plugins are loaded?
i think its just alphabet
Hm, okay
that means:
on linux: random
on windows: by alphabet
and then ofc by their depend/softdepend
on linux it's by inode iirc
ah
definitely windows goes by alphabet but linux doesnt, so I assume linux goes by inode
macOS: no clue, probably inode too
send your code please. it should work. iirc it's possivle to make eggs invisible, so it'd be weird if snowballs wouldnt work
does it maybe have to do with the fact that im doing it with packets?
?nocode :p
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
Is it recommended to check to avoid overflow even though it is not likely to happen?
i will try it with api first, if that doesnt work i will send the code, i think my packet usage is the problem
is Foundation API actually good? (https://github.com/kangarko/Foundation)
It's only used by minecademy ppl
it looks good tbh
how?
And it was a huge headache to figure out what exactly caused that
IIRC, at some occasions it tries to place an ad there as comment
At the same time it saves it in wrong encoding
mm auto registering
fancy
I hate anything that scans shit with reflections and auto registers magic
Since my motd contains Japanese characters, every time I started a server it was turning into mahsed potato of symbols
so its not really good
Idk how good it is, I avoid it
i mean, the bro spent so much time on it
The code's clean but it's just not great
each package has packages with classes
and the reputation it brings is whatever
?paste
The other thing is you don't learn much by using all the libraries already made
real
And if you want to disassociate one day you're fucked and have to learn everything again
it will never hurt to check it anyway.
best thing is
learn how the original thing works
make your own private api
But I wanted to know if it's a good practice or not
I even have to do things like this:
does Bukkit.getPlayer(playerName) actually return something in PlayerDeathEvent?
Because some plugins create a fake player and stuff like that... so yeah, better check twice!
in fact I got 3 NPC checks lol
wtf? why do you use bukkit.getplayer(player.getname))?
if player was null, it would throw a nullpointerexception when executing player.getname
because some plugins call a PlayerDeathEvent with their custom Player object. And ofc Bukkit.getPlayer(customPlayer.getName()) then returns null
(for example Citizens iirc? Or another NPC plugin, I don't remember)
why would an npc call this event
because that plugin calls that event
spigot itself doesnt call the event, but the respective NPC plugin calls it
Check #general
and then you end up with this:
where 277 is this
1112 omg -'
you're the ew dude
TRUE Bukkit.getServer the goat
preferring static hacks over the DI'd server instance? epic, fr?
Bukkit.getPlayer > Bukkit.getServer().getPlayer > PLUGIN#getServer().getPlayer
No.
TRUE
I prefer the last one btw
Why do you pass the event to the method instead of just passing the player instance?
Bukkit#getPlayer easier to write fr
passed server instance > Bukkit.get....
because, as I said earlier, angelchest's code is a mess
I'm a lawyer and not somebody who studied O(n^2) shit lol
here is not the player instance, you used bukkit.getplayer. If this is within that spawnangelchest method, why didn't it just pass the player instance?
depends - never used MockBukkit?
for unit tests it's pretty normal to pass in a custom class implementing Server
this isn't a unit test
they initalize the Server field in the javaplugin class with bukkit.getserver
no ofc not, but that class is tested through unit tests?
idk
why would I rely on the static Bukkit.getServer() if I already got a Server object?
easier to type and they reference the same thing so tbh it's not a huge issue
easier to type? does your IDE not feature auto completion?
Bukkit.getServer() versus creating a variable to reference my plugin just to access getServer
tbh Bukkit#getServer only makes sense if you don't already have a plugin instance
that's what alex is insuating
well yeah but there's no negative differences
the class I sent has 3500 lines. dw, it's not the only time I access the server
actually _
you can take 2 points into consideration: performance and organization
If it takes into account performance, using bukkit.getserver is better. if it takes organization it is debatable
please explain how it's better, and please also explain how (if it's true) it's not considered premature optimization
here's the full source code for that class btw:
https://paste.jeff-media.com/?630d8d777fc3e48c#AxG4eFpJFHtBz4qfeqPUwhw9ksiQwEmF82T4gZEAcDUS
Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.
and I know that many of this stuff is very bad
remember, I did not study computer science, and this code was written by me in 2018, when I just started coding
public fields go brrr
passing a variable in the constructor uses memory. the static method avoids this
If you already have a server instance Bukkit.getServer is an extra method call
But yes it does save like
8 bytes
yeah I know it's bad. it's kept for backwards compat reasons because I know some other plugins rely o nthose fields being public
Sorry, 4 bytes in most cases
pretty sure the memory difference is very minimal yeah
allocating a reference to ur plugin vs just accessing it through bukkit
What will I do without those 4 bytes!
Think of the garbage collection overhead
pretty sure the allocation to the plugin instance is constant runtime
/s
Even worse, if my heap is over 32gb it’s 8 bytes!!!!!11
make everyone access thru reflections
do a little trolling
late april fools update
tl;dr: yeah I know that my code isn't great. but there's no point in rewriting sth that's working fine
i'll just use a public static final MethodHandle _ 0% performance loss
here's an example of me writing good code: https://github.com/SpigotBasics/basics/tree/main
TRUE
now go and critize this!
Ok, I'm sure I could've somehow found this out myself but I can't for the life of me figure this out. When I take the decompiled classes for a 1.12.2 or a 1.8.8 version of minecraft from the decompile-latest folder after running BuildTools, there are a few files that have decompile errors with seemingly no patches associated with those files. The one file I'm really stuck on right now is the PlayerSelector.java file, is there something else that spigot does other than patch files that I'm not aware of?
Spigot doesn't use all the files
So if you're adding a new file you need to fix the error yourself
i was highkey waiting for someone ty say 🤓 we don't support 1.8.8 and 1.12.2 here
can you reallym ake eggs invisible i tried everything, but .setinvisible doesnt seem to work on entities which arent livingentity
^ probably even more so in older versions you need to make your own patches
Decompilers aren't perfect
what?
bro ahahh
i cannot make eggs inviislbe
Hide entity / set visible by default
which version? (client AND server)?
i cannot hide it because then i cant make it setpassenger
Though if the method is on Entity it should probably work, although that's like the invisibility potion type of inviaibit
So if you can't splash potion it Mojang probably doesn't support it
Even the computer barely detects the difference. you can create Integer.MAX_VALUE of variables and display them in the console and you will not see an increase in memory
right, so if I just don't include that file it will still compile? I'm sorry I do not know about the custom POM setup Spigot likely uses to accomplish that and I'm just trying to set up a server that I can directly mod for quick experiments, and am not sure how Spigot can get away with not fixing those decompile errors despite BuildTools logging that it decompiled the class
Because it uses the compiled class
Spigot patches like < 20% of the server or something
people commenting mfnalex' 2018 code:
"huehue mfnalex writes bad code, his code sucks, he does noob mistakes"
mfnalex sends code he wrote this year:
(no answer anymore)
md_5 are you the dev of velocity?
so eggs cant be invisible?
no
is there any entity with not hitbox which can be invisible
Idk test with a /summon command in vanilla
Did you try setItemStack
oh ok thx
im not using dropped itemstack
Or setItem or whatever it is
i have a real egg
Yeah but projectiles have a method for that too
ok so what makes Spigot use compiled classes in place of source files during jar creation? There's like 10 POM files and I am not good with Maven lol
md_5 = spigot and bungeecord
everything else = someone else
ThrowableProjectile#setItem
I'm not just "someone else", okay?
i will set it to air, good idea
ok
When they ask you this, include my name with my projects
A dependency on the original jar
Thank you for your attention
setitem doesnt seem to do anything
Try with something other than air
it works
Alright then it doesn’t like air
maybe it would work but the itemstack creation doesnt work?
can i create a itemstack of air?
Yeah
yo what is Material.CAVE_AIR
Cave air
Well if you had a resource pack you could solve that
any ideas to create an entity with no hitbox, which can be invisible, but not hidden? invisible but still exists client side?
problem is it has to be a perfect size like the snowball, so that i can make my hologram have lines
i need entities in between
i cannot use display entities as im supporting bedrock
i hate bedrock too, but crossplay servers are better as every1 can play on them
Well with enough effort you can just use bedrock stuff for bedrock players
Bedrock can have custom entities
fr?
i saw that being done from the server side and i was like huhhh
oes anyone know of an plugin that can do something like the dungeons in the game Trove, where they are randomly generated around the world and have mobs placed inside them?
a custom world generator with structure support can do this
I'm sorry
import de.jeff_media.daddy.Daddy_Stepsister
Nobody's gonna mention this?
nope
ive seen worse
public class PetRegistry {
private static Map<UUID, ChickenPet> chickenPets = new HashMap<>();
public static void registerChickenPet(ChickenPet pet){
chickenPets.put(pet.getPetId(), pet);
}
public static Map<UUID, ChickenPet> getChickenPets(){
return chickenPets;
}
public static void unregisterChickenPet(UUID petId){
chickenPets.remove(petId);
}
}```
Any suggestions for more methods? I was thinking of refining the registry to take / store any instance of a pet class but didn't have the time to actually mess with it
Hey there, I haven't touched plugin development in 5 years so I'm looking for some help with saving Player Data.
I've made PlayerData and WandData classes, and the yaml is saving as:
[[REDACTED]]: !!com.starfluxgames.basicwands.configurators.PlayerData
wands:
- amplifier: 1.0
appliedPotion: BAD_OMEN
cooldown: 10.0
duration: 10.0
self: true
wandType: DIAMOND_SWORD
Although upon either reloading the config, it complains that Global tags aren't allowed !!com.starfluxgames.basicwands.configurators.PlayerData
I'm not sure if I'm missing something here. Any pointers are appreciated. Thanks
I may be 100% incorrect, but pdc should be your fallback for persistent data. 1.14+, not too difficult
?pdc
Thanks, wasn't aware of that I'll have a look into it.
It's the modern way to persist data nowadays so have some fun
I'm guessing config files are still using FileConfiguration? Or has that changed too
Brilliant thanks
No worries!
https://paste.md-5.net/opufezefav.java
Could I get some notes / suggestions on this structure/implementation?
maybe an AbstractPet for uuid, name, level
The logic for each pet ability would still have to be written individually no?
yes but only the pet specific stuff
Right right yeah you're right
Considering the abstract bit, would I still implement the interface?
yes
Ok and I'm doing this to keep common methods among all pets I assume?
Right
Alright let me work on the abstractpet
and then probably just chicken abilities for now
I want to go for something similar to the saicopvp chicken pet where you take no fall damage and I'm pretty sure it changed your gravity iirc
naming it Pet is fine not need to AbstractPet
only reason it's abstractpet rn is because the interface is currently called pet lol
my psychology book says it's most likely because you eat when you think about that
or have in the past
So make your Pet class abstract?
If you're thinking about it that much then that's your likely answer lol
I'm working on it man jeez
Apologies if I'm misunderstanding PDC here,
I've got myself setup with
public class PlayerData implements PersistentDataType<byte[], UUID>
This is just storing a UUID correct?
Are there any examples on storing an entire serialized class? ie.
public class WandData {
public String wandType;
public String appliedPotion;
public float duration;
public float amplifier;
public float cooldown;
public boolean self;
}
^ Reading the examples for toPrimative and fromPrimative it looks like it's serializing the byte[] directly
https://pastebin.com/JJnLDU2V
There's this string array example from the pdc link if it helps
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
I'll take a peek thanks
Yeah, so this is essentially breaking the string down into it's bytes directly
Oh boy this is gonna be fun
put each value as a different pdc key and assemble it that way?
theyre all primitive typs
I'm looking to store a List<WandData>
Ah I get what you're talking about now
Is this what you mean? 😅
Obviously I'd need some helper methods, but that's my idea
yeah something like that
Looks fine to me
I was made aware of a cool thing with the namespacedkey: private static final NamespacedKey chickenPetKey = NamespacedKey.fromString("coolpets:chicken_pet_key"); requires no real instance of the main
this convo
https://paste.md-5.net/bitirodibu.java
How does this look?
it's been mentioned more than once lol
pls don't name the api "API" but rather "PetsAPI" or "CoolPetsAPI" or sth
haha it was just temp
ah ok. besides that, looks good
i was refactoring everything to implement pet, interface was originally called pet
https://paste.md-5.net/jorequdosu.java
How about the two util classes, the taskManager is only written out to handle chicken pet rn
why is your TaskManager a singleton? Why not just static methods?
And you're still not caching the namespaced key in line 20 of that paste
oh and what's runChickenTasks? 🥲
I think I forgot, only had like half hour before work when we were talking
singleton cuz it was originally to just manage chicken pets, but now I implemented an abstract pet class so I'm just gonna use it to handle all pets
And finally, I uh haven't done a lot with tasks
private final NamespacedKey chickenPetKey = ChickenPet.getChickenPetKey();
private static boolean isPetInsideInventory(Player player, UUID petId){
for (ItemStack items : player.getInventory().getContents()){
if (!(items != null && items.hasItemMeta())){
return false;
}
ItemMeta itemMeta = items.getItemMeta();
PersistentDataContainer container = itemMeta.getPersistentDataContainer();
if (container.has(chickenPetKey, PersistentDataType.STRING)){
String petIdString = container.get(chickenPetKey, PersistentDataType.STRING);
if (petId.toString().equals(petIdString)){
return true;
}
}
}
return false;
}
So is this fine?
I'll put it into a flat file later when I get to that bit
Im working on custom autopickup plugin and how can I handle mending enchant? I kinda dont want repair item with own method and want to keep PlayerItemMendEvent to be called and let MC repair that item, is there any way? I want exp to be autopicked up (give to player) as well
you can't just call an event and expect the server to do vanilla stuff
that's not how events work
hmm, so it will not be possible in that case probably?
you'll have to actually recreate the original mending behaviour. I'm currently greping my IntelliJ folder to find how I'm doing it, because I also had to do this once
Im making that for server with using own custom durability of items and kinda want to be ezy to hook to it ideally true MendEvent. This custom durability is one of reasons Im making that autopickup plugin so 😄
that will help a lot. basicly I need to "naturally" let player pickup xp.
ok weird - in my Drop2InventoryPlus plugin, I have commented out MendingUtils and it still seems to work somehow lol
u are giving xp from breaking block directyl to player with Player#addXp (or how its called) method?
tbf I have no idea what I am or was doing regarding XP
auto pickup plugins are a mess
tbh I really have no idea how I'm doing it in Drop2Inv. I only know that I'm only calling giveExp and somehow it works. I have searched the whole project for the "mending" string and I found nothing, but somehow it still works
I also looked into CraftPlayer#giveExp and there's no mention of mending either
ghost functionality 😄
loooks like u are saving the ExperienceOrb from events (witch will be problem bcs Im cancelling exp drop) and probably mending will edit that orb and what left will add to player? Im kinda confused. But I was thinking about same method kinda... but will be pain to do it anyway lol
Well the mending is probably tied to xp increase instead of xp pickup. Therefore you don't have to explicitly do anything
yeah but all I'm doing with that map is this
nah, medevent is not called when u give XP to player with method
oh alr
was Enchantment.MENDING renamed at some point or sth maybe?
nop
then sorry, i have no clue how I was doing it
no worries, so u are not seting xp drop in BlockBreakEvent for example? bcs Im setting it to 0 and before that I will do event.getPlayer().giveExp(event.getXp()) to prevent double pickup of them
I will try to find a way to let player pickup exp naturally somehow
These are the base listeners of my auto pickup plugin
https://paste.jeff-media.com/?c55d5d7e6b234fe3#C2ftsd182cxFCLY16iBpz6gBnixNCxikaRmWhJ1yg3vp
https://paste.jeff-media.com/?a9680384be1d391b#6CExGcQZ6YWVRnVHt1dmkJPvNZb3SHKkXGfmT6ooCqz4
Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.
Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.
it references EventManager.giveAdjustedXP which I already showed above
EventManager: https://paste.jeff-media.com/?bef3f4d9a3fc08be#2i219SW5kzECDCLVwj2kY3eiucBMXGLSAsAbZPSWuRvw
Visit this link to see the note. Giving the URL to anyone allows them to access the note, too.
perfect I probably got it how I will do it, just spawn orb at player and should be good lol, kinda looks like u are doing that way
it shouldnt be picked up by another player hopefully
oh yeah probably that's what I'm doing haha
pretty sure that it'll take the closest player
I appreciate it that u shared the code! u are always soo helpful! thanks man
np!
https://repo.md-5.net/content/repositories/snapshots/ appears to be down
yo what's a good method to try to fix ghost blocks? if it's even possible serverside (i'm not asking for code i just want a method)
my idea is send block updates more frequently but i'm not sure if that's a good way
like maybe if you can ask the client for the blocks visible to it using nms
thanks, fixing now
ram requirements for everything just keep increasing
Thanks for the quick fix 🙂
Yea reposilite isnt such a bad software
How would I get the the item a player has placed into a custom gui? Cause I cannot figure out how I'd get the item as when the event (InventoryClickEvent) is triggered it is still null
InventoryClickEvent is the way to go.
And there are multiple ways of bringing an item into your custom GUI (eg shift clicking).
Do you need the item to be detected immediately? Otherwise i would just scan the Inventory for added items in the InventoryCloseEvent.
yes, i need it to be detected when the item is placed in the inventory
the problem is i cannot get the slot where the item was placed and even if it'd be null apparently
Because the item is still on the cursor of the player at that point in time.
ik
is there any way I could check in which slot the player wants to move th item into?
Hello does anyone know how i can stop furnaces from dropping xp when broken? setting the blockbrokenevent exptodrop to 0 doesnt work.
how can I remove 100 itemStacks from inventory?
public static void removeAmount(Inventory inventory, ItemStack itemStack, int amount){
ItemStack cloned = itemStack.clone();
itemStack.setAmount(amount);
inventory.removeItem(cloned);
}
``` I wrote this, but it doesn't work
it only takes one item
Use Inventory#remove instead https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/Inventory.html#remove(org.bukkit.inventory.ItemStack)
it does nothing, if I do it using Inventory#remove
It says that it only works in the case of amount = itemAmount
but I have 64 items, but I need to remove only 5, for example
for loop? 😅
oh. ok 😦
I've never worked with inventories
This should work. Did you debug the method and made sure that the amount isnt set to 1?
I did it using for, and everything works just fine
what is the difference between yaw, pitch and direction. One is in the angles, and the other is like a vector, don’t they describe where the player is looking, for example?
So you simply wrote the same logic which already existed again...
Yes
Yaw is your left-right rotation
So if you look right your yaw increases type deal
The default value is 0 which is facing +Z iirc
Pitch is your up-down head rotation
So if you look up, the pitch increases
The default value is 0 which is facing straight ahead
if I change the vector, will yaw and pitch change?
Your direction is what happens when you grab your yaw/pitch angles and you convert them to a Vector
So if you look up it's 0,1,0
The only way to change yaw/pitch is to teleport the player to the new position
That has the new angles
(Or force the player to spectate an entity that's being teleported)
method by ChatGPT
private static Location addLocation(Location location, double x, double y, double z){
Location result = location.clone();
double cosPitch = Math.cos(Math.toRadians(location.getPitch()));
double sinPitch = Math.sin(Math.toRadians(location.getPitch()));
double cosYaw = Math.cos(Math.toRadians(location.getYaw()));
double sinYaw = Math.sin(Math.toRadians(location.getYaw()));
double newX = x * cosYaw * cosPitch - z * sinYaw * cosPitch - y * sinPitch;
double newY = x * sinYaw * cosPitch + z * cosYaw * cosPitch + y * cosPitch;
double newZ = x * sinPitch + z * cosPitch;
return result.add(newX, newY, newZ);
}
public static Location countLocation(Location location, double dX, double dY, double dZ){
Location bulletLoc = addLocation(location, dX, dY, dZ);
Bukkit.broadcast(Component.text(location.toString()));
Vector oldDir = location.getDirection().clone();
Vector newDir = new Vector(oldDir.getX() - dX, oldDir.getY() - dY, oldDir.getZ() - dZ);
bulletLoc.setDirection(newDir);
Bukkit.broadcast(Component.text(bulletLoc.toString()));
return bulletLoc;
}
I wrote this, but nothing happens. locations continue to be identical
What are you trying to do?
don't use chatgpt
i am trying to offset it
To achieve a random spray pattern?
so that the "display entity" flies out from the muzzle, and not from the player's eyes
This will depend on the client setting as well. Keep in mind that some people are left handed.
I can ignore that other people are left-handed)
Is it possible to access a furnaces inventory on the block break event ?
Here is what you should do:
- Trace the impact Location
- Change the origin Location to your gun
- Calculate the vector from impact to origin (convert to vectors and subtract [impact - origin])
This will give you a new Vector which points from your origin (the gun) to your impact.
Sure, the Block isnt broken yet so you can still get its BlockState and modify it.
uhm a question that gets me curious, if all events happen before the action is done whats the point of having "Pre" in some event names, its always gonna be pre
like pre command preprocess or pre async join etc
Probably just for clarification
then they should add Pre to all event names :p
or what I usually do
change the original eye location's yaw and pitch by a tiny amount before tracing
that's random spray
as for the gun thing yeah you need uh magic
https://paste.md-5.net/jajiyexiwu.cs
was wondering if someone can help solve this invName and invtype area i can't figure out what to put there
how would i specifically display its inventory in console im finding it difficult to find the corrects methods
You shouldn't compare inventory titles in the first place
not really my friend gave it to after mine failed after trying a million times
Get the block state, check if it's Furnace and get the inventory after casting
casting to furnace?
- Get the BlockState
- Cast to Furnace
Here are all methods like getting its inventory etc:
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Furnace.html
declaration: package: org.bukkit.block, interface: Furnace
It turns out that if I change the direction, then the pitch and yaw will automatically change, or do I need to calculate it manually?
No you dont. The direction is literally defined by the pitch and yaw.
It only difference is that it also has a length
Which is usually 1
so code may be look like?
What is dx dy and dz?
This looks a bit weird
anyone know where the internal xp is stored of the furnace block?
deltaX, deltaY, deltaZ, for offset for bullet start Location
public Location calculateBulletPath(Location gunLoc, Location impactLoc) {
Vector direction = impactLoc.toVector().subtract(gunLoc.toVector());
Location bulletLoc = gunLoc.clone();
bulletLoc.setDirection(direction);
return bulletLoc;
}
thank you, now it works
lol, but how can I find start gunLoc?
Location result = location.clone();
double cosPitch = Math.cos(Math.toRadians(location.getPitch()));
double sinPitch = Math.sin(Math.toRadians(location.getPitch()));
double cosYaw = Math.cos(Math.toRadians(location.getYaw()));
double sinYaw = Math.sin(Math.toRadians(location.getYaw()));
double newX = x * cosYaw * cosPitch - z * sinYaw * cosPitch - y * sinPitch;
double newY = x * sinYaw * cosPitch + z * cosYaw * cosPitch + y * cosPitch;
double newZ = x * sinPitch + z * cosPitch;
return result.add(newX, newY, newZ);
}``` I have this, but it is incorrect
if there is -1 for x or -1 for y, then it will shift down
moving forward is not a problem, but right/left, down/up
did you try Vector direction = location.getDirection();?
assuming it's the direction you want
public Location getGunLocation(Location eyeLocation) {
// The hard part is finding those magic numbers.
double forwardOffset = 0.5;
double rightOffset = 0.3;
double downOffset = 0.3;
Vector direction = eyeLocation.getDirection();
Vector adaptedForward = direction.clone().multiply(forwardOffset);
Vector adaptedRight = direction.clone().crossProduct(new Vector(0, 1, 0)).normalize().multiply(rightOffset);
Vector adaptedDown = new Vector(0, -1, 0).multiply(downOffset);
return eyeLocation.clone().add(adaptedForward).add(adaptedRight).add(adaptedDown);
}
why does this command give me a default looking leather chestplate?
minecraft:give SunwooHan minecraft:leather_chestplate{
Count:2b,
tag:{
Count:1b,
Damage:0,
id:"minecraft:leather_chestplate",
tag:{
Damage:13,
Enchantments:[
{id:"minecraft:thrive",lvl:2s},
{id:"minecraft:unbreaking",lvl:4s}
],
Trim:{
material:"minecraft:diamond",
pattern:"minecraft:silence"
},
display:{
Lore:['{"italic":false,"extra":[{"color":"#D2ED87","text":"Идеальный волшебный нагрудник, для волшебников"}],"text":""}'],
Name:'{"text":"","extra":[{"text":"Волшебный нагрудник","obfuscated":false,"italic":false,"underlined":false,"strikethrough":false,"color":"#D2ED87","bold":false}]}',
color:10043692
}
}
}
}
Not a development related question i would argue
i wasnt sure where to post it because i generate this command in my plugin sorry
Use McStacker
How can i have a string like this: 1,2,14,15,19 and split it to get every number? I'm thinking on using #split and a loop but not sure
You’re thinking right
You should def not generate this command in plugins. Spigot has a perfectly fine API for that.
i''l try then
wdym?
got ya
but
i have to get all the nbt from an item
and apply it to the command
Why do you need the command tho
The api is perfectly capable of giving an item to a player
I'm making a plugin that would generate a /give command from an item in hand
it should support all the nbt data
PDC is not enough, cause it doesn't cover all the nbt
its a good website as i see, but it doesn't help with my case
i get NBTCompound with a library and just parse it to a json
String boughtPets = plugin.data.getConfig().getString("Available." + player.getName());
String[] ids = boughtPets.split(",");
int number = ids.length;
if (plugin.data.getConfig().getString("Available." + player.getName()) != null) {
for (int k = 0; k < number; k++) {
if (Objects.equals(ids[k], String.valueOf(petManager.getId()))) {
//code
}
}``` something like this?
i just dont get why is the item a default one
You can save and load a List<Integer> btw. Saves you all this parsing.
Yea, can do that as well
thx!
how do i make an entity look at a certain location?
How can I make enchantments on essentials kits such as from efficiency 5 to efficiency 9? If I enter 10 I only get efficiency 5
You may have to enable the unsafe enchantment config setting
thx it worked
teleport
Is there anyway to cancel villager inflation from hit?
ClientboundBlockUpdatePacket packet = new ClientboundBlockUpdatePacket(
new BlockPos(x, y, z),
Blocks.DIRT.defaultBlockState()
);
sendPacket(player, packet);```
what's the alternative to this in 1.20.4
Just use the API?
Player#sendBlockChange()
Please paste your pom.xml file, or build.gradle (or build.gradle.kts) if you're using gradle on the following website: https://paste.md-5.net/
so uh i sent a fake block update to the player and i want to listen for when he breaks the fake block, i used my tiny brain and thought of a packet listener but the thing is it sends 2 packets, one for when you start digging and one for when it's broken and i'm really confused, i tried to use my last 5 brain cells to debug the fields maybe there's a field that tells you if the block was broken was attempted to be broken but there are 0 fields
what should i do?
Is there any pom.xml tutorials?
why do u need a tutorial for pom.xml..
If you install the minecraft development plugin in Intellij and let it generate a default spigot maven project, then the pom is quite good.
pom.xml is basically a configuration file for your maven project.
yeah and if you need dependencies 99% of the time they provide a copy paste
but there are enough useless stuff
like shading
I wanna try to make it by myself
you don't have to worry about shading tbh
pom.xml is usually covered on basic java tutorials so look for that
oh ok thanks
?
but it takes argument
Looks like you're using two different Java versions
one in the IDE and another when compiling
^^
Can I change the Bungeecord messages in the message.properties with a plugin?
?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!
just try to make it
and if you are stuck at one point ask here
thats way more efficent than looking for a tutorial you will forget 2 days later anyways
???
good morning
like it's a Location, you change everything BUT rotation?
ohayo
retroopaj
h
make em array instead of maps for your packet listeners
you tell me to do a lot of stuff hm
@grim hound i could optimize it kind of using EnumMaps technically
okay lemme just rewrite that whole class for you
why u keep telling me what to do
like I said
go make ur own project
I am
this ruined my plans
cuz now I have to TELEPORT the player
which is slower
than a location set
PERFORMANCE NOOOO
having readable/understandable code is also important
and your idea makes it more difficult for people removing and adding listeners
later on
so i say no to your idea
ehhhh does it really?
but it
s like 7 times faster
I'm so confused what the fuck
registerSubcommand(object : Command(CommandLabel("deserialize", "test.test")) {
override fun execute(sender: CommandSender, args: Array<out String>?): Boolean {
val player = sender as Player
val deserialized: ItemStack = GenericAdapters.INSTANCE.deserialize(serialized, ItemStack::class.java)
player.inventory.addItem(deserialized)
player.sendMessage("Deserialized Stack")
return true;
}
})```
`TestCommand.kt:25:13 'execute' overrides nothing`
it literally overrides something, I feel like I need to nuke gradle
setting a location and teleport are the same under the hood
yes, really think through your idea gain
again
but its already a no from me to accepting it
you can use reflection to replace my event manager with your idea on your own platform
fixed it smh had to remove out and ? because its not nullable and just a string array fml kotlin
and override my methods
that'd be disrespectful
am just finishing
i'll send you the class
think it through
bruv
too late
on your own plugin that shades packetevents you can overide methods in my event manager
simple
does it the way you want
but he wants you to instead to adopt his listener platform!
that's a red flag
no its not you just don't understand how its better. Providing an option to make your own is not good enough
your sentence was written confusingly
but like if someone says no, continually trying to shove it up their throat for weeks or whatever isn't smart
sure you can make an issue on githbu and ill look at it
my mind is too rotten
show your code idea on github issues
your idea
or whatever
and ill just look at it
and we'll see
Hey!
I urgently need help in my Minecraftbut plugins
I have the top quality plugins but are in Turkish language
Can anyone help me in translation
I am also ready to pay.
@alpine urchin hey!
Hey!
sup
Actually I needed your help in translation
@grim hound did not listen to me
Bezpłatna usługa Google, umożliwiająca szybkie tłumaczenie słów, zwrotów i stron internetowych w języku angielskim i ponad 100 innych językach.
👍
look at the class
ain't it nice?
But I can't do it myself
I need your help, I can pay too!
buy yourself something nice instead
you implemented one method
brah
But these plugins are best quality... I am a Youtuber
fom what language to what
I have purchased these plugins for 150$ each
Turkish to English
i only know english
like I said
You can use Google translator
i can try using google translate to evaluate
The problem is not translator
ADD ME TOO
dont add him
The problem is how to translate the plugin.
brah
@alpine urchin
Accept my request
u didnt incorperate priorities in my event system at all
I did
no unregister method uses your listeners array
not in this https://paste.md-5.net/aciletuxip.java
some still use the map
okay
I don't think you understood how that class works
private final NavigableMap<Byte, Set<PacketListenerCommon>> map = new TreeMap<>();
sorts the values by pritority
can someone help me
who has to die?
i’m trying to make an enchantment called QuickDraw and than another one called SwiftShot, these 2 can’t be on at the same time, can only be on a bow or crossbow, the first level of quickdraw pulls back the bull at 15% more, level 2 is 30% more, and level 3 45% more. SwiftShot makes the bow more accurate so the “bulletdrop” is smaller for when you are farther away.
you.
order executed
with what do you need help? what have you tried? at what point are you? or do you just have genuinely no idea where to start?
i have tried to code it but i do all the steps i make the rarity, what it can be enchanted on, and all of that but then for the first one rn i have NO idea how to make the bow pull back faster
dont think you can fuck around with the bow since thats client sided iirc
but you can manipulate the velocity of the arrow if its shot sooner
Hey!
if i can’t then i will just make a procedure that replaces the bow as soon it gets enchanted with the enchantment making it an exact replica of a normal bow but it says the enchantment
@hybrid spoke
Hey!
maybe this helps https://wiki.vg/Protocol#Player_Action
sup
thanks
Hi there, I'm trying to get my head around block display entities and having some troubles.
I am applying two transformation matrixes, which are only sort of working:
float[] display1Matrix = {0.5000f,0.0000f,0.0000f,0.0000f,0.0000f,1.0000f,0.0000f,2.0000f,0.0000f,0.0000f,1.0000f,0.0000f,0.0000f,0.0000f,0.0000f,1.0000f};
float[] display2Matrix = {1.0000f,0.0000f,0.0000f,0.0000f,0.0000f,1.0000f,0.0000f,0.0000f,0.0000f,0.0000f,1.0000f,0.0000f,0.0000f,0.0000f,0.0000f,1.0000f};
display1.setTransformationMatrix(new Matrix4f(FloatBuffer.wrap(display1Matrix)));
display2.setTransformationMatrix(new Matrix4f(FloatBuffer.wrap(display2Matrix)));
display.addPassenger(display1);
display.addPassenger(display2);
The resizing of display1 works fine, it goes half the width like I would expect. However, I would expect it to be two blocks above display2, but they render inside each other within the game.
What is causing this? It's like the passengers can not exceed the width/height of the display itself, but I tried setting a height and width on the display and this did not help in any way.
Any ideas? Thanks
then ask for it here
float[] display1Matrix = {0.5000f, 0.0000f, 0.0000f, 0.0000f,
0.0000f, 1.0000f, 0.0000f, 2.2f, // Adjust this translation
0.0000f, 0.0000f, 1.0000f, 0.0000f,
0.0000f, 0.0000f, 0.0000f, 1.0000f};
thats what gemini told me
do they work without being set as passengers
As in as their own individual block displays?
yeah
maybe its how you spawn them, their init location could be important as well
im not that experienced in transformation matrix's
I'm jusg using the location of the player
and if you add the y to the one which should be above?
I mean, sure I can do that, but that's a bit of a nightmare, I was hoping I could pass in a bunch of matrix to be rendered
maybe @lost matrix can help with that
i think he has done more than me with matrixes
Okay, I look forward to hearing what they say then
For reference, these display entities can expand the boundaries of a normal block just fine - i.e. a 2x1 block
plural is matrices
then english sucks
XD
And to say that something belongs to a matrix you'd say matrix' instead of matrix's
English totally sucks
Wait nvm I forgot if this rule applies to x or z
I have a mod to wall climb and I want to make a plugin that when a player is at an Ice wall (I get it via Player#getTargetBlock) he like slides down there but smoothly how would I do it I tried applying veloctiy but that "bugs" him down I want a smooth slide
give him levitation
otherwise simulate cobweb
or fake a ladder or smth
https://paste.md-5.net/izuzibopal.java
can someone tell me why even though i cancelled the event players can move the blocks in the gui
well, first of all, dont compare inventories by their name.
second, have you registered the listener? make sure that its actually the name. debug
but can you give negative levitation?
isnt levitation the one where you fall smoother?
slowfalling
that might be it
levitation is that what shulker give
well how else can i make sure then their name?
yeah then slowfalling
either you do the hacky way where everyone will jump on you by making a custom InventoryHolder or go the complex way by storing the inventory references and who opened them in a map
?gui
i've seen this
whats so bad with getView?
you can rename a chest and it will match
colorcodes?
as well
May someone help me to understand better how practice servers work for example those arenas they will be objects which will be added to HashMap which will store available ones but like i then need tons of arenas in singular world like idk if i have 50 players i would need minimum of 25 arenas for example ?
usually you load them dynamically instead of having a set set of arenas
what do you mean dynamically i mean I would personally make arena manager which would load all possible arenas into HashMap which will take Name and Arena as key and value and basically if it is available it will be in that HashMap if not it will not be added but once game in that arena is finished it would be cleared (since blocks placed would be tracked and removed on game finish) and then added back to available arenas
with dynamically i mean that you have a schematic of the map and generate a new arena once a player needs it
and once he's done it will get removed
with that you can also keep a few preloaded so that they will be available sooner without having to wait until it finished generating
well i never worked with schematics like that to dynamically load them somewhere in worlds
well how much could it take for map like 100x50 to load 🤷🏻♂️
ill check it out but i always had problems using FAWE on legacy for some reason
you can come back and ask for help with fawe if you cant manage to do it
but see in schematic how can i know location of map so i can track player spawnpoints etc
you would have a setup of the map which will be loaded for every generation
for example you build the map at 0,0,0. you can just generate the new one in his own world at the given coords
with that all the location points you might have set stay the same
just the world changes
ill have to see with that really
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Bukkit.getScheduler().runTaskLater(PacketInterceptor.plugin, () -> {
PacketInterceptor.injectPlayer(e.getPlayer());
}, 1L);
}```
```java
public static void injectPlayer(Player player) {
Channel channel = getChannel(player);
Interceptor interceptor = (Interceptor) channel.pipeline().get(handlerName);
if (interceptor == null) {
try {
channel.pipeline().addBefore("packet_handler", handlerName, new Interceptor());
} catch (NoSuchElementException e) {
e.printStackTrace();
}
uninjectedChannels.remove(channel);
}
}```
this throws
```[17:56:56 WARN]: java.util.NoSuchElementException: packet_handler```
which makes no sense because it only does it if i try to join but if i was already in the server and i reload the server (it does this onEnable)
for (Player player : plugin.getServer().getOnlinePlayers())
injectPlayer(player);
it works normally
you really dont want to set up 25 arenas and have your players wait until someone is done
yeah if im going to make that i will make 70 arenas or so and thats it
yeah well no. i mean its up to you, but thats the worst you could do
Hello, what is the equivalent for AbstractCriterionTriggerInstance in 1.20.4 in nms?
Im starting a new plugin strictly for versions 1.13-current and I am wondering which Java version is best for programming in? I previously used Java 8. Should I stick with Java 8 or move to Java 17?
java 8, because using a higher java version will make your plugin unavailable for <1.16
to support 1.17 and before, you need to compile your plugin for java 8
but you can dev with java 17
at least if you use features of higher java versions
you can also use java 17 and only use java 8 features, luckily java is backwards compatible
using java 8 will using spigot-api 1.16.5+ in you code will throw an error, so you can use java 17 to be more confortable
ah wasnt aware of that thank you 👍🏼
thanks for the help 🙂
Hey I have the following hashmap
Hashtable<Integer, Material> materialHashMap = new Hashtable();
Iterator<Material> materials = Arrays.stream(values()).iterator();
int i = 0;
while(materialHashMap.size() < 256 && materials.hasNext()) {
Material material = materials.next();
if (material.isSolid() && !material.hasGravity() && !material.isInteractable() && !material.equals(FARMLAND) && !this.isTagged(tagBlacklist, material)) {
materialHashMap.put(i, material);
++i;
}
}
Im trying to get the block id aka the integer in the hashmap
getKey() doesnt seem to work any suggestions would be appreciated
blockID = (materialHashMap.getKey(((Player)sender).getWorld().getBlockAt(x, 256 - y, 16 * row + z))).ordinal();
Why dont you use an actual java HashMap?
And why are you mapping from int to Material if you want to get the int by Material.
Why not map the other way around?
Been using a hashtable since the start didn't conisder using a hashmap tbf might re do the entire thing with it if I must
I had some other functionalities where I needed to transform file bytes to int and from int to Material now im trying to reverse this process but im struggling a little with getting from Material to int part
Use two maps and map in both directions, or use guavas BiMap which internally maps into both directions.
Aight, ty for the help
whats the ratio for texture pack icon?
1:1?
r u sure bro 16x16 is super small _
Hello, I've got a big problem, when I compile my maven project (who use nms with mojmaps), I got this error:
https://paste.md-5.net/viranaponi.sql
here is my pom.xml:
https://paste.md-5.net/oliyufacec.xml
Nice nitro
embeds 💪
i see
Hello, can you please help me finding the solution for this problem?
(What I did is a double click over an equal item that was in my inventory)
Cancel the InventoryClickEvent
Cancel inventory drag event
Cancel all the inventory related events 😄
When it comes to separation of concerns, say you’ve got an event listener that has multiple functions based on properties of said event, would it be better to just split functions into helper methods or perhaps multiple instances of the event listener?
Cancelling the InventoryClickEvent will always prevent the InventoryDragEvent from being fired
it doesn't
As in a sort of manager I suppose you could say that dictates the functionality of the event when it occurs, based on some properties
can you help me with geyser and playit gg so my friends can join me?
i'm probably too dumb for google rn, but google won't help.
how do i get a list of strings from an sqlite db?
in this table i basically store options for an action and the action is stored with each options so that my PreparedStatement looks like this:
SELECT options FROM GUIOptions WHERE action = ?;
I then just set the String to the action supplied and want to get all the results in a List of Strings or an Array, doesn't matter tbh.
if i understood right
List<String> foo = new ArrayList<>();
while(resultSet.next()) {
foo.add(resultSet.get(...));
}
something like that
can someone help me with geyser and playit gg so my friends can join me?
oh yeah that makes sense lol
thanks
thx
@EventHandler
def notifyPlayerSpawnLocation(event: PlayerSpawnLocationEvent): Unit = {
event.setSpawnLocation(SpawnLocation)
}
```even though i have this, the first time a player joins they spawn at a random location
and yes, the listener is registered
is there any way so the IDE doesn't give an error when doing this?
its only the first time where this doesnt work
\\{
yea thanks
Could someone help me with tasks/runnables? I'm unsure of what to use for a task that should be ran every second during runtime, it should only stop when onDisable is called / plugin shutdown
Hello! How can I get an item which was added to the inventory by /give command? I can't find correct event
InventoryClickEvent, InventoryMoveItemEvent, InventoryPickupItemEvent don't work
what is this language ? scala ?
I don't think there's any method for this. You'll have to essentially recreate whatever item you're looking for and implement detections for when that item is added to a player inventory @hot dune
I think so yes
well rip
Is it a custom item or vanilla?
item that given by vanilla give command, so I think it's vanilla one xd
Well then depending on how many items you're trying to detect, pretty simple
I try to check if the item is an equipment (e.g. sword or tool), so they are always are one in the stack
I just write /give @p minecraft:diamond_axe and I need to get this item and then change it's lore and other stuff
Mmmm
I'd rather just do a custom command that gives an item, then within that class you can define the items lore/meta/etc through pdc meaning you create an itemstack object that has persistent data. This itemstack now holds data that will persist over server restarts and what not
I'm 99% sure there's no method to access the vanilla commands... meaning you can't really do anything without recreating the command yourself
Okay so i've done this to get the following string:
effect[FIRE_RESISTANCE,1]
And i was wondering if this is the correct way or maybe other more optimized would work
https://paste.md-5.net/emijeqicov.java Here's an example you can use, it's very simple and functions as a way to create a "new" itemstack (chickenpet) each time the command is ran, meaning every single chicken pet acquired with said command is an individual as in it's own persistent data
I was talking about the split xd
don't make use of split this can be done in one iteration with a for loop
you have a couple "tokens" here first the [ token which is some sort of arguments then , which denotes the start of a new argument and ] which denotes the end of an argument
Is this for loading an effect from a config?
yea
if you use a for loop you can use this to your advantage if you want to go crazy and have much more advanced tokens in the future you can use an abstract syntax tree
ngl bukkits serializations are almost never as ideal as they could be but changing them is also problematic in of itself
Back when potionEffect.getFromName (or wtv it was) wasn't deprecated D:
PotionEffect effect = ...;
FileConfiguration config = ...;
// Saving effect:
config.set("some.effect", effect);
// Loading effect
PotionEffect loaded = config.getObject("some.effect", PotionEffect.class);
saying use the serializable isn't really as cool as it sounds
Well you can save the key
granted their serialization method isn't Ideal either
But you still need other data
But randomly splitting a String and hoping for the best sounds more hip and cool?
I guess you could do key,duration,level
or
type: type
duration: duration
level: level
lol
see whjat I said above
Outside my screen, scrolling up take effort
I said their solution wasn't great either
public class ChickenPet extends Pet {
private static final NamespacedKey chickenPetKey = NamespacedKey.fromString("coolpets:chicken_pet_key");
private static final NamespacedKey chickenLevelKey = NamespacedKey.fromString("coolpets:chicken_pet_level_key");
private static final NamespacedKey chickenMetaKey = NamespacedKey.fromString("coolpets:chicken_meta_key");
public static NamespacedKey getChickenPetKey(){
return chickenPetKey;
}
public ChickenPet(UUID petId, String petName, int petLevel){
super(petId, petName,petLevel);
registerPet();
}
@Override
public ItemStack petItem(){
ItemStack chickenPet = new ItemStack(Material.CHICKEN_SPAWN_EGG);
ItemMeta chickenPetMeta = chickenPet.getItemMeta();
chickenPetMeta.getPersistentDataContainer().set(chickenPetKey, PersistentDataType.STRING, getPetId().toString());
chickenPetMeta.getPersistentDataContainer().set(chickenLevelKey, PersistentDataType.INTEGER, getPetLevel());
chickenPetMeta.getPersistentDataContainer().set(chickenMetaKey, PersistentDataType.STRING, petName);
chickenPetMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', chickenPetMeta.getPersistentDataContainer().getOrDefault(chickenMetaKey, PersistentDataType.STRING, "&4Chicken_Pet")));
List<String> chickenPetLore = new ArrayList<>();
chickenPetLore.add(0, ChatColor.translateAlternateColorCodes('&', "&6" + getPetLevel()));
chickenPetLore.add(1, ChatColor.translateAlternateColorCodes('&', "&7Chicken pet allows you to fall gracefully through the skies!"));
chickenPetMeta.setLore(chickenPetLore);
chickenPet.setItemMeta(chickenPetMeta);
return chickenPet;
}
public void registerPet(){
PetRegistry.registerChickenPet(this);
}
}```
Given that I'm using final namespeacedkeys, would saving them to a flat file be ideal?
how do i make an entity look towards another entity
Teleport it with a looking direction on the teleport location
yeah but how do i calculate what angle it should look at
How to connect sqlite driver to plugin? I got an error "No suitable driver found for jdbc.sqlite", after trying just use sqlite
Location eyes = ...;
Location target = ...;
Vector direction = target.toVector().subtract(eyes.toVector());
You need to shade the jdbc driver for sqlite
Do you have any example?
I only added this to plugin, how should I shade driver?
Btw there is also the LivingEntity#setTarget(Entity) method, which will result in the eyes following the target (usually)
Did you ask earlier about how to learn poms? Or was that someone else?
Yeah..
And didnt you say something about the default pom containing "useless stuff" like shading
Anyways. You need to add the maven shade plugin to your pom.
Then the dependency gets shaded
How do you compile?
Alright that should do the trick
,_,
?pom
Please paste your pom.xml file, or build.gradle (or build.gradle.kts) if you're using gradle on the following website: https://paste.md-5.net/
https://paste.md-5.net/dodocedeki.php Code
Exception: java.sql.SQLException: No suitable driver found for jdbc.sqlite
https://paste.md-5.net/vopoyiwade.xml - Pom
I thought spigot shaded the SQLite driver
it does, but you have to init it on older versions
When it comes to pdc, is it a good thing to store namespacedkeys in a flat file?
That's what I thought, I was just confused with some description of "caching" the keys
That just means that u don't have to create new namespacekey every time u need it
Just save it in variable and reuse it
Like I said, was a bit confused on the description was all
How to create entities with metadata? it's just that I can create the entity itself, but I can't ask it some things ProtocolLib 1.20.4
private static final NamespacedKey chickenLevelKey = NamespacedKey.fromString("coolpets:chicken_pet_level_key");
private static final NamespacedKey chickenMetaKey = NamespacedKey.fromString("coolpets:chicken_meta_key");```
So as an example:
now just implement getters for my keys and use them this way correct?
Either that or you use dependency injection (DI) to hand them over. In that case you can use a keyholder class you create a single instance of
I was avoiding this according to mfnalex's suggestions
Avoiding what?
di
Well in that case I'd just make a seperate static class (private constructor) and declare those keys public
This convo
That also helps others to work with them if they need/want to
he also declared it as public which is perfectly fine as they can't be modified
I think I’m just gonna do this, the di part was only a concern since I didn’t want to pass the main class that way
Who understands something in ProtocolLib
Is there any way I could reliably (or at leats most of the time) refresh an inventory? (without closing and reopening as items will be lost upon doing that)
Just ask if you have a question, there is probably someone around to help
Sure, just call setContents on it.
XD
Or edit single slots
that's what I'm doing, but it isn't updating
How do I set the type for Villager packages ProtocolLib set metadata?
my code:
player.setItemOnCursor(new ItemStack(Material.AIR,1));```
(activeInvenotry is just the current active inv for the player)
So, I was trying to make the easiest plugin with some characteristics, but I got exception "No suitable driver found for jdbcc.sqlite" it's my first time when I try to use sqlite, so idk how to solve it
https://paste.md-5.net/dodocedeki.php Code
Exception: java.sql.SQLException: No suitable driver found for jdbc.sqlite
https://paste.md-5.net/vopoyiwade.xml - Pom
?
isnt it should be jdbc:sqlite:path?
Call Class.forName("class.of.your.Driver") to touch the Class in your ClassLoader.
Im assuming you are on older versions?
I don't really know about versions, I tried to use last version
Yes, that is part of the metadata
yeah lol
Oh, it explains a lot
My method to see if an inventory has space for a list of items is somehow modifying the item I'm checking. Can anyone see what is causing this and why? https://pastes.dev/QpONvo5UhR
edit: I still have no idea why this is happening but chatgpt said the itemstack is getting split in partial stacks to try and fit them in the inventory and for some reason that modifies the original instance
btw it didn't solve the problem, "No suitable driver found for jdbc"
fine for me
My guess would be that Arrays.copyOf(inventory.getContents(), 36) does not do what you hope it does
it will not copy the objects
those objects is the original inventory, only the items I'm trying to add get modified. I think it's because of this line
Map<Integer, ItemStack> map = fakeInventory.addItem(itemStackList.toArray(new ItemStack[0]));
actually it sounds like this line on the wiki is explaining my exact problem now I'm just confused if it's a bug or a feature
I guess I will just do this to solve it
List<ItemStack> itemsToAdd = new ArrayList<>();
for (ItemStack itemStack : itemStackList) {
itemsToAdd.add(new ItemStack(itemStack));
}```
or stream idk what is better
if i want to make a chat filter using regex, should i put all of them in a enum? like
public enum FilterRegex {
WORD("regex")
final String string;
FilterRegex(String string) {
this.string = string;
}
}```, and then loop through enum values and check the message word matches the regex?
That sounds quite slow. Going over the same String with different expressions can get slow quickly.
i've got this java for(WordType type : WordType.values()) { System.out.println(ass.matches(type.string)); System.out.println(ass.replaceAll(type.string, "no bad words")); } but i don't think its good
how can i make it better
replaceAll is regex
matches will match the whole string, are you planning to do that?
is your string just contains Ass
btw u can see, it didnt match
Why is it, that when I do setItem in an gui it only updates when the amount is greater than one?
What version are you on?
Setting the amount to 0 should remove the ItemStack iirc. In older versions it resulted in ghost items.
hey, im getting this error whenever whenever i try to log into my server (it seems to be to do with tab prefixes) and im not too sure what im meant to do to fix it in my code, cus the prefix its trying to load is under 16 chrs
i see, so basically having non-stackables refreshed upon using setItem is impossible, right?
Player names are hard capped at 16 characters. Anything more crashes the client.
Not sure what that means
but arent team prefixes meant to have a 16 chr limit too?
basically that when I use setItem and it is a not stackable (the item) that it won't update the inventory and result in weird behaviour
I dont... each Material currently has a maximum stack size. And you cant create stacks with bigger stacks than their current maximum.
ik
It would be easier to understand the issue if you show some code
okay, wait
player.setItemOnCursor(new ItemStack(Material.AIR, 1));```
activeInventory being the current opened inventory for said player and the item on the cursor being a netherite pickaxe with some metadata
when this happens it results in lots of weird behaviour and inventory bugs/ghost items
Ah, the behavior in this also depends on the cancelled state of the event. Its quite tricky.
when cancelled it just doesnt do anything, when not cancelled the weird behaviour occurs
I guess it rlly all just comes down to testing a whole lot of stuff and seeing if it works, am I right?
Are ressource packs cross compatible can anyone use a ressource pack no matter befrock or java?
no
What do i need to change?
So I think I fixed something and now I have another err with SQL:
"SQL error or missing database (near ")": syntax error)"
https://paste.md-5.net/eketujiwob.java - Code
https://paste.md-5.net/vopoyiwade.xml - Pom
Could you help me please?..
Poor smile getting blasted with 19 questions at once
Pre-1.13 16 is the limit for both prefixes and suffixes. Now the limit is around 1024 iirc
You can hack in with reflections a bit
Or you wait for 1.20.5 🙂
OHhh
Exactly
It works! Thanks!
What event is this?
Hello, how can I change the name of displayed on a villager trade popup but without modifying villager's name?
Hello do you know how to lock the head movement of the player like for a cinematic?
modifying that
Set him in spectator mode and let him spectate an armorstand or other entity.
Then move the spectated entity around while keeping the eyes on a focal point.