#help-development
1 messages · Page 589 of 1
wdym?
I thought you read the javadocs of ConfigurationSeriazable
The ClassPath thing seems like it is doing exactly that
all the clases that i eant them to be saved are serializable
yea
both having a serialize method and a deserialize method
Yess, it's the same way but it's a little less resource-intensive
Serializable or ConfigurationSerializable?
second one
not gonna type that
Let's be real: You'd not do it at runtime if this is a concern
bump
then read the javadoc, you have to register them
okay but then how do i add it to my List<MyClass>
it returns a boolean
read the javadocs again. https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/configuration/serialization/ConfigurationSerializable.html
declaration: package: org.bukkit.configuration.serialization, interface: ConfigurationSerializable
cus i got this:
List<ClassPath.ClassInfo> classInfoList = ClassUtils.classesFromPackage("org.joe.testplugin.Abilities");
for (ClassPath.ClassInfo classInfo : classInfoList) {
if(classInfo.load().isAssignableFrom(Ability.class)) {
abilities.add(classInfo.getClass());
}
but that aint working
not how it works
oh
in onEnable?
You still need to invoke the ctor if you want to get a concrete instance - so do exactly what you have before
Also, do you know what a PACKAGE is in java?
yes
okay leme try that
this?
i hope it works
yea i hope so
i spend 8+ hours infront of my laptop dying to fix this
A package should be all lower case, so it is alarming that your "package" is formatted like a class
yea i get that but the problem is, i had some compile errors when i had lowercase shit
Yep, so
for (ClassPath.ClassInfo classInfo : classInfoList) {
if(classInfo.load().isAssignableFrom(Ability.class)) {
abilities.add((Ability) classInfo.load().getConstructors()[0].newInstance());
}
yea so that doesnt work
🤨 well as long as it works...
With what error message?
?paste
ConfigurationSerialization.registerClass(HypixelPlayer); Expression expected
Oooof, I mixed up the order of the isAssignableFrom call
it should be Ability.class.isAssignableFrom(classInfo.load())
how am i gonna fix that
already tried everything
that doesnt change anything tho does it?
by passing a class instance
HypixelPlayer.class
cus there error is in that it has arguments for the constructor
Also - are you sure that every subclass of Ability in that package ONLY has a no-args constructor?
Otherwise you'd need to get rid of the other constructors, only obtain the no-args ctor or use the sun Unsafe (i.e. maximum carnage)
when that idiot who uses skript to make his "plugins" told me java is a shitty language, i should have listened to him
What
HypixelPlayer.class
I was late
but i use the args constructors tho
not really
Then you need to define no-args constructors and only get the no-args constructor instead of a random one
how do i get only the no args constructors
So MyClass.class.getConstructor().newInstance();
Or in your case classInfo.load().getConstructor().newInstance()
what is this
bro said this
that is also doable
You can use getDeclaredConstructor with arguments to get your constructor
Either getConstructor().newInstance() or getDeclaredConstructor().newInstance(). Either will do the job
It takes the class of each arg
I don't know what the difference is anyways
it depends on the data stored
List<ClassPath.ClassInfo> classInfoList = ClassUtils.classesFromPackage("org.joe.testplugin.Abilities");
for (ClassPath.ClassInfo classInfo : classInfoList) {
if(Ability.class.isAssignableFrom(classInfo.load())) {
abilities.add((Ability) classInfo.load().newInstance());
if(Listener.class.isAssignableFrom(classInfo.load())) {
Bukkit.getPluginManager().registerEvents((Listener) classInfo.load().getDeclaredConstructor().newInstance(), TestPlugin.plugin);
}
}
}
?
so i would have to make a new instance of that class inorder for it to be seperate ?
mongo is more than likely a p good thing for MC servers as it makes it easy to use pojo classes to get/set data
alarming usage, but I guess that should be finee
Wtf is clazz? Isnt it class?
class is a reserved keyword
not only reserved, it is a keyword
heaven forbid you need 2 clazz's ins the same scope
A reserved keyword would be goto and _
clasz
clazzzzzzzzzzzz
do you like it
last time I tried mongo on my plugin did got the clases
var_10001
whats alarming about it
You basically alluded that you register these event listeners twice or more
Else they wouldn't have an args constructor
You don’t have listeners that take your plugin as an arg?
Dynamic registration and args constructors are always iffy anyways
i fixed an error, came back with 20 more...
cool error, 👍
https://paste.md-5.net/uxuwotoxus.bash
Well that is great, you just squashed a fatal syntax error. Now to solve the non-fatal syntax errors
CNFEs usually hint at packaging errors
in which file is the PDC data stored????????
player data
Try to nuke all caches
depends
yea i renamed all my packages to lowercase
i do that were
Uh, are you explicitly calling loadClass?
dont think so
Under maven, remove the target directory, for IJ idk
Eclipse has no notable caches so you are clean in that regard
Quick question how can I in the 1.20 this code:
Dispenser dispenser = (Dispenser) block.getState;
with an anvil, because "Anvil anvil" does not exist
b;m���K>�+IK�V)�y`�.Ht~2x��M*�["Z��P!ŀ�8��3ƙ����f�I�&v�]ow��v>�6V(�ze�إ_�}e���Fb��4�}��ׂՈ�K����<�|��X���M. ���{��Q��M%dh��<.B�4g��^��^s>�x�A�,@*6#�=tUX#�S7P��|���%��y���V�"y��J{>�+��c�������EI]Ҋ�l���Yfa�t��X�D�P�wn�����~���;�z��6pn�kR���L�p�(���Z>�"h(�K����H�1�Q�~=#8&9�} �a6���.'��W]Gz���hl��ρ;����
is someone able to translate this into human language?
and then?
how else do i get from a block to an anvil, would like to open that
are you trying to browse a .dat file
rebuild the application
if thats a .dat file use nbtexplorer
oh but i have a outputDirectory in my maven plugins so it doesnt build there
decompress it (Ark supports unzipping that, other things may be able to decompress it too) and open it up as a standard file
Though it wont be too readable even if you do that
java isn't shitty just because you don't know the basics
isnt nbtexplorer just easier
If you need to do that more often, yes.
But decompressing it with my archive manager of choice and opening that with my editor of my choice is a thing of seconds.
You generally only want to verify whether something exists or not so eh
A getter for a public final is only really appropriate if you need to use it for Steams and like the short lambda things
The other usecase is if you want to make the field private later on
well I mean
if I have a final variable
isnt it just easier to make it public
since it cant be changed anyways
that is a coding style question
okay
@quiet ice
I wouldn't do it if you get graded on it, but privately - sure.
lol
ironic
well I am past the days of getting graded for my java code
but yeah im just using a ton of pubic final for my config class
Me neither. But I am giving tips to my peers where they sometimes get grounded for it
because I didnt want to bother making the getters
Look, I have no clue what the hell you are doing wrong
i dont know either
noclassdeffound usually means it wasnt build correctly
Could you give us your built jar?
can anyone read this error and help me fix it?
unless you are using class metadata witchcraft ig
yea 1s
In this case I am almost fairly sure it's that IJ case change cache bug
why should you explain to the compiler that a class is a class
you didn;t register your classes before accessing the data, OR you didn;t write to the pdc correctly
leme check
But I do not know how one can nuke the IJ caches
oh got it thanks
you only need register the class once
i forgot to call my methond in onEnable
another time: java.lang.NoClassDefFoundError: com/mongodb/MongoException someone knows how to fix it?
"String" or "Field" or "YourClassName" are not classes but just symbols
Did you shade mongo
did you add it to the libraries section of your plugin.yml as you were told?
@quiet ice
did got it
Yeah, delete every instance of that jar, all caches you can find and restart your IDE
?paste code where you are trying to use mongo
private class MyClass { }
// ...
String MyClass = null;
ConfigurationSerialization.registerClass(MyClass); // Error - MyClass is NOT a class, but a String! That's why you need to use .class to refer to actual classes
ConfigurationSerialization.registerClass(MyClass.class); // Correct
i can't promise, I'll do it when I feel like it 😛 currently I'm playing MC
alr seems to work
driver may not be loaded, add a Class.forName("mongodriverhere")
where
before you try to access any mongo
so a HypixelPlayer is a HypixelPlayer?
should i swap to eclipse? my github student is running out soon and i am no longer a student
this is the pom.xml
AHHH LIGHTMODE
in the meantime, why don't you try to write the first part, that takes in 2 colors, and one number (length) that returns an array of "length" colors where the first one is color1, the last one is color2, and everything inbetween are the inbetween colors? because that's like 50% of the work that needs to be done
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
@quiet ice opinions?
sorry
are you using the maven-shade-plugin?
wtf is that, i used the docs gave me
you gotta shade mongo -> https://blog.jeff-media.com/common-maven-questions/#how-to-shade-dependencies
im too tired but i have to test my plugin one mre time before watching spigot plugin making series by kody simpson
Generally eclipse isn't something I would recommend unless you already know how to use it at which point it is extremely great
oh you called static MongoClients. Surely you should be using new MongoClient("localhost") or whatever connection
he;s using plugin.yml libraries so no need to shade
in the docs never used new
so u shouldnt start using if u dont know how to use it but to know how u use it u need to start using it at some point right?
okay colors are just vectors with 3 components (r,g,b). let's imagine we only have one component.
color1 = 50
color2 = 150
difference is 100.
if the length is 5, then the difference per char is (150-50) / 4 = 25 (for length 5, we divide through 4, because we already got the first color as starting point)
so first char has color 50, second char has color 75, then 100, 125, 150.
you do that for each component (r,g,b)
cant do that
that looks correct except that the length should be length - 1
What I am saying is that IJ is more powerful, unless you already engrained in the workflow eclipse allows you to do - at which point IJ is utter garbage
fair
but where it does the math, it should be red = start.getRed() + (redDiff / (length-1)) * i
ill just use intellij community :/
I might be wrong though lol. you gotta try it out.
try <=
doing it your way you shoudl be using a ConnectionString not a String
in the for loop, check for length -1
and then the last color you just set to the end color
how is the last one off?
yeah, and then see if it even compiles
are you trying to shift from red to blue in increments?
Revision is basically always 0.1
or you trying to make all possible red-blue combinations?
if you want to optimize this
you only need half the numbers
because the other half is just the inverse
came back with another error
again...
so tired
ill just create a thread.
its 12:22 AM and i started work 1PM. 11 hours of pure coding
any help appreciated
will look at it the nex day
0-255 there is a middle point, the first half of the number can get you the second half of the numbers
it's always <version>-R0.1-SNAPSHOT
so that means somewhere there is a middle
so 1.17 is 1.17-R0.1-SNAPSHOT
to give an example of only needing half the numbers
lets take the numbers 0-100
1+99 = 100, 2+98=100
You going color interpolation?
you would only need get to 50 to have used up all the numbers 🙂
Error(the PlayerQuitEvent Included)
let me try
so this means you only need half the numbers
HSV is generally preferable over RGB for that
Error java.lang.NoClassDefFoundError: com/mongodb/MongoException
Code: https://paste.md-5.net/firedukobi.java
shade the mongo driver in
how
you didn;t change to using a ConnectionString
yes I did
oh you did inside
did you read the blog post I sent?
I was having dinner sorry, where is it
?paste your plugin.yml
yeah that's good. now use only half the length, then fill the rest of the array in reverse going back to the original color
e,g. 0 5 10 15 20 15 10 5 0
Ironically I have a 32/16 bit color compressor 😛
you did not add the libraries section you were told to
and if you got that, you can just offset it by one every tick to get the animation
at the mongo docs is never done, and why here
in case you ever want to look at it, this compresses colors into 8 bit colors
you were told yesterday to add a libraries entry to your plugin.yml
because this is spigot
mongo wouldnt add docs just for spigot
but I have done with the pm.xml why there, i don't understand
You likely need both
unless you want to shade the driver, use plugin.yml libraries
it means you dont have to shade it and loads it from the server
okey
pom.xml to give the dependency to the IDE and library thing in plugin.yml for spigot
now I have to search what exacly line I have to use
please check the latest thread.
still having the same error
in discord
?paste yoru current plugin.yml
oki
can someone please check the latest thread created in discord?
oh my 1.8? serously
yeah 🙂
pretty sure yesterday you said you were on a much newer version
average minigame server
pleaseeeeeeeeeeee
i don't remember sir
else no one would have recomended libraries
emm
im pretty sure the more you beg for someone to look at it the lower chance you have of people actually reading it, ask again in half an hour to an hour or tomorrow
not every minute
perahps I/we mis read somewhere
okay imma go bye
then do as booboo said yesterday and mfnalex said today. use teh maven shade plugin
how i do that 😓
Show your pom.xml
Is 199 the second color?
You still didnt the blog post i sent
You gotta shade it
Then it looks good
can you send me again please?
let me know if its useful or if you want me to add more features 😉
I don't mind implementing more into it, I made it for someone who needed to compress to 8bit for console
Second headline https://blog.jeff-media.com/common-maven-questions/
thank you
Hello, is it possible to set the light level of a block type using a plugin? ie. the torchflower
Thanks
now you'd need a method that "shifts" the array, e.g.
1 2 3 2 1 -> 2 3 2 1 2 -> 3 2 1 2 3 -> 2 1 2 3 2 -> 1 2 3 2 1
first and last element should always be the same, otherwise it'll look weird I guess
and yeah then you're basically done with the logic, then all you gotta do is translate those colors back into &x&r&r&g&g&b&b stuff, apply them to every character, and run it through ChatColor.transate...
nooo, then you'd have a hard "border" in the gradient
you shoud never have 1 2 3 4 5, but rather 1 3 5 3 1
unless you want to have that hard color change
Something is missing here i think https://paste.md-5.net/nixunepela.cs
Do these do the same thing?
if(mana.get(uuid) + value < 0) {
mana.put(uuid, 0);
} else {
mana.put(uuid, mana.get(uuid) + value);
}
// ------------------------- //
mana.put(uuid, Math.max(mana.get(uuid) + value, 0));
I'm making a plugin which randomises block drops, but I want containers to still drop their original contents. However, I'm finding that if I do InventoryHolder.getContents() on an InventoryHolder from BlockDropItemEvent.getBlockState() then the slots with items show as a stack of 0 air and the empty slots show as a stack of 1 air (so I can see which slots had items, but not what those items are). How can I get the contents from a BlockDropItemEvent?
what is the sound effect called for when you get hit while wearing iron armor?
is Gson safe to run async
wdym &x thing
just do ChatColor.of("&#FFFFFF")
bungeechat
They mean buckit colors, don't use that when coding use stuff like ChatColor
so yuo want to shift colors over?
just use hexadecimal its way easier to do math with
don't worry about &x&f&f&f&f&f&f&f
then you can run ChatColor#of on the hex
Do you know how to fix the YamlConfiguration#set problem which, for a String containing a quote, does this: 'a: b n''avez c' ? (With initial String : "a: b n'avez c"
Where can I find the src for this World.java function?
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks);
?stash
U usually search for Craft + interface name
Oh, so it's in the CraftBukkit src not Bukkit?
Bukkit is API
CraftBukkit is implementation
I see. Thank you for the help
Don't. Just do with Y2K_ said, which doesn't require any formatting or &x stuff
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.ItemStack.getType()" because "item" is null
This is on a PlayerInteractEvent, The event works and everything, but it gives an error when a player is holding nothing. I've asserted that the held item cant be null and if its Air it should return. My thought process means, there should be no errors. at least no Null errors. I'm still getting it.
So my question is, how can you stop a PlayerInteractEvent when the player isn't holding the correct item?
Yes, but you can still use ChatColor#of for each color
Show code
e
?paste
Check if item is null
And not with assert
^^
Just use an if statement
Does anybody here use asserts?
isn't assert suppose to be better?
pattern matching?
so use
if(item == null) return;
instead of
assert item != null;
yes
Okay, Thanks!
I gave you a good solution you just ignored the formatting advice I gave
don't bother doing it raw
use ChatColor#of with hexes
and use pattern matching to replace them
Assert is for debugging. The whole point is that it opens your debugger if the expected statement isn't true (well, depends on IDE and Java implementation, I think there's also a Java flag that causes it to throw an exception if it isn't true). It doesn't actually do anything if you're not debugging
One color per letter
for loop
anyways I sent you fully working gradient code earlier
No
Mods only
Well that doesn't matter
Who cares if it's a component or no
t
The gradient code calculation is the same
Ohh. I did not know that. I've been told, and by people here too, that I could just assert. I thgought it made it so it couldn't be null and it would just return. Thank you for the clarification, and now I have to go fix a few things.
Looks like you're passing in hash function. lol
Are you using ChatColor#of() for the hex codes?
The format for hex colors is &x&r&r&g&g&b&b
as I said earlier no clue why you are avoiding the easy way but ^
Much easier to just use ChatColor.of with a Color
not to mention pattern matching hexes is way easier than pattern matching that hell
https://ibb.co/54hQxCw
I wanted to open an anvil window. Why doesn't it work? ver. 1.20
Error: https://ibb.co/R45tt9z
Yeah sadly colour characters kind of kill your length
the component one?
I wish MD_5 would atleast look at the Component PR its done
Thats's how life is
legacy chat moment
I don’t know if components solve this issue but I think they do
I also don’t know if scoreboards support them but again I think they do
Wouldn't team prefix/suffixes be the current workaround?
I think all 3 get 128 characters
Not for the title of the scoreboard
I did not read the context Im ngl
review CHoco's PR
hopefully one day MD5 sees it :*(
for the time NMS / adventure ftw
components is pain
I did it :)
Well I assume he’s busy, either that or the Austrian wildlife got him
Australian*
How do I make a Text Display entity type not be seeable from just 1 side?
Make it centered instead of fixed.
Display#setBillboard
Oh oh, tyvm
I need to serialize a shit load of item stacks to base64 what'd be a good way to do this
or bytes it really doesn't matter as long as its fast
alright
Like so @kind hatch ?
Entity entity = block.getLocation().getWorld().spawnEntity(block.getLocation(), EntityType.TEXT_DISPLAY);
((TextDisplay) entity).setText(ChatColor.GOLD + "+ " + blockExperience + " XP");
((TextDisplay) entity).setSeeThrough(true);
((TextDisplay) entity).setAlignment(TextAlignment.CENTER);
entity.teleport(block.getLocation().add(0.5, 1, 2));
private static void savePlayerInventory(Player player) {
try (var fos = new FileOutputStream(filePath(player.getUniqueId()).toFile())) {
try (var boobs = new BukkitObjectOutputStream(fos)) {
boobs.writeObject(player.getInventory().getContents());
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}```
hehe boobs
?tas
can I use both Spigot and Paper API? ( Paper has a PlayerArmorChangeEvent event )
Not if you want to support spigot servers.
okay, So can i just add a depend for paper or do i have to create a paper project?
If you want to support spigot servers, depend on the spigot API. (As spigot plugins can run on paper no issue.)
If you want to only support paper servers, depend on the paper API.
Hey. Showing item from players hand info in chat with Chat component API. Is there any way to do this without NMS? Is there any way to convert itemstack to json, that hover event would take as SHOW_ITEM? Hours of googling and still no good solution :/
No. Use the library Epic sent ^
I'll still have spigot support if I use that?
#general message
Yeah, i know that. Problem is that I can't find a way to use item from players hand as a hover. Every answer i've found uses CraftItemStack.asNMSCopy(stack).
Yeah. All my tries for now either showed minecraft:air or items without enchants/lore etc
Gonna try that tomorrow. Thanks 🙂
Hello, Spigotmc today I ask you all mods and very simple question?
How async my file IO actions I give eaxemple below
try (var fos = new FileOutputStream(filePath(player.getUniqueId()).toFile())) {
try (var boobs = new BukkitObjectOutputStream(fos)) {
boobs.writeObject(player.getInventory().getContents());
}
} catch (IOException e) {
throw new RuntimeException(e);
}
``` I want write this to file! H owever, how do I do this ASYNC? I run this while many players on and load and save these every so often hwo do I do async I don't want to lag main thread
fos boobs
BukkitScheduler
ExecutorService
ForkJoinPool
Any of those should do it.
I can do the streams async?
I thought you couldn't do any IO streams asynchronously
in that case :}
CompleteableFutre#supplyAsync can do everything
You sure can
Doesn't work, which is why I was asking lol
nope
int current = playerData.get(new NamespacedKey(ToastsRPG.getPlugin(), "manaPerSec"), PersistentDataType.INTEGER);
^^^^^^^^^^^^^^^^^^^^^
When creating a name spaced key. is it unique to that plugin? You have to pass your plugin, and the actual key. If i want to access that datatype from another plugin, do I have to use the instance of the plugin that created it or does it not matter?
I'm asking because im getting an error that says "manaPerSec" doesn't exist. but it does, cause my mana goes up by 1 ever sec.
it uses the plugin name as the key, like minecraft has minecraft:poppies urs would be pluginname:manapersec
Okay, that would make sense on why it’s giving me an error then.
Really?
Mhm
Ima use that lol
Why you skullin me boi @river oracle
get double skulled
Fuckin nitro users and their cringe super reactions
Lmao
ur cringe
I use them all right away cuz its funny
to super react the stupidest shit
@Override
public CompletableFuture<? extends ItemStack[]> asyncLoad(UUID key, Executor executor) throws Exception {
if (Files.isRegularFile(PlayerInventoryCache.filePath(key))) {
return PlayerInventoryCache.retrievePlayerInventory(Bukkit.getPlayer(key));
}
return CompletableFuture.completedFuture(Bukkit.getPlayer(key).getInventory().getContents());
}
guys how can I improve this code
Why ? Extends itemstack
Ur just jealous of me swamp
tis how Caffeine cacheing works
though it'll just always be ItemStack[] so I can just remove that
It's cache library
its THEE cache library
can i have a link
shut
?caffeine
The Caffeine Cache Library Below:
https://github.com/ben-manes/caffeine
gimme an example
Mine is as performant as normal hashmap
@onyx fjord if yours is better can you do similar testing against caffeine and guava and make a performance chart
make sure you don't miss any features
I don't want bloat
or how would i use it in loading playerdata, delting it after 5-15 min if they leave and dont join back
Doubt you can beat a hashmap
lol but you also lose out on all the convient cacheing features. Features aren't bloat.
💀 that's what this does
nothin?
How big is caffeine in lines of code
smh
I know guava is bloat
No i just like simplicity
plus what are extra features going to do to your performance? i doubt itll affect it drasticly.
I mean you can stick with a ConccurrentHashMap, but it lacks expirey time removal listener, eviction listener, refresh time etc
Can anyone help me out with modifying chat tab completions? I'm trying to prompt fake player names when using tab, both in commands and in chat for a minigame I'm developing. It works fine when executing a command, but if I were to just press tab in chat to display all online players, including the fake ones, I get a random selection of numbers and letters. When utilizing tab in commands it works fine. Anyone got any idea what the issue is?
I'm afraid I can't see this method anywhere, is that a new feature?
I don't have the option to call it, as if it doesn't exist
what version
When did this become a thing?!?
if you're asking me, I'm using the latest api version
who solte it off paper
Wasn’t me
Why do you use it
to update an item i modify inthere inv
Why would you need to do that
without making it disappear and appear
What
Getting an item from a players inv should give you a mirror
you only really need to call it if you do shit with packets or some crazy other shit
Which will automatically reflect changes
oh
My favourite part about mirrors 
Epic = 🥄
isnt the best part you can see ur uskies
just tested it out, works as expected, thanks for the assistance!
can I just ask, is there a way to remove those letters and numbers as well? because I'm getting the custom tab completions properly, but alongside those sequences of numbers and letters
it seems to be done automatically
this is what I mean
try using set instead
as in Set<String>, in contrast to a collection?
setCustomChatCompletions
still the same issue unfortunately
the problem is I don't understand what those number represent, or are supposed to represent
if the correct player name is being added as well
this doesn't look smart
The player is always online
There's no point in spinning up another thread to call a getter
I can only imagine this is an NPC or something
It is, yes, I'm adding npc instances as the fake player modules, setting their custom display names both in the tablist and in chat
do you know any way to remove them from the chat completions?
I don't think you can. At least not as far as I'm aware
Would the result be the same if I modified the tablist to display fake player instances through packet manipulation? I would mitigate having to utilize npcs that way
if the NPCs are the issue here
bro via version translates text display's so weird like \n doesn't make new lines for users on versions with text display's
What
?whereami
Why don’t you report the issue in ViaVersion discord server?
ion know what their cord is
\n doesn’t make new lines on versions with text displays?
It does
So you meant without
.
Im saying when playe4rs on 1.18 join via version translates them to holograms but the \n don't make no new lines
Ah
Yeah that’s pretty expected
Other entities don’t support \n in their names
Via version would have to spawn an armor stand per line I guess
Text display's do so I would figure via version would translate them using multiple entities
I would hope
Backwards compatibly isn’t really meant to be a thing
The fact that it works at all is a miracle sometimes
Well yeah
Ah shit
Either way it’s a massive hack
True. I really cannot think about a way to translate blockdisplay and item display in <1.19.4
And display entities are basically impossible to translate properly
well when I cut off versions less player's play
I mean if your using text display's for basic holograms
You can use armor stands
But they can’t be scaled or rotated certain ways
Or interpolated at all
It could be calling from a file I have the inventory serialized to a file for redundancy
I highly doubt reading files from main thread while the server is running is a good idea.
Generally I feel like doing FileIO, and Database calls Sync is not a great idea.
This method just ensures none of that occurs.
Personally don't see the issue with this method.
If The player's inventory has a cached file load that.
Otherwise just grab their current inventory (not asynchronously) using CompleteableFuture#completedFuture
Why is this sytem necessary? I'm clearing player's inventories for a minigame in the same world. You don't want inventories being lost on crashes etc. Which is the reason why something like this would be necessary. Yes the inventory is stored in memory, but a backup is necessary given all hell breaks loose and a crash occurs. Players losing items really isn't ideal especially on an SMP like server. I'd be happy to take advise on a better implementation of such a system with the same redundancies i'm including
I mean i myself just thuoght of a slightly better model to implement my idea, but still holds that I'm storing player inventory and need some form of redundancy to ensure data isn't loss on server crash etc. Still open to recommendations though
I need some help with thinking. I am trying to determine when a player is wearing a full 4 piece set of my armor. When they are wearing all pieces they get a special unique buff geared towards that armor. Now, I have already checked and got working, How to get their armor contents and to know when they are wearing a full 4 piece set. The 1 thing I need to figure out how to is, to determine when they are wearing it and not.
When the ArmorEquipEvent goes of, it checks armor contents and armorSetValue = 0; hasHelm? -> armorSetValue++; ... etc when armor piece on add +1 to counter. if counter = 4 give set bonus. The thing is, a player can spam the take off and put on and double their bonuses. to infinite levels. What kind of approach should I be taking here?
Spigot has no ArmorEquipEvent. You are using a fork
Yeah
Jeff
thats him
all i do is work on things. i have nothing to do lol. so i have a lot of questions and errors. 😆
do bukkitrunnables cause server lag
how do I use it incorrectly
Else no issues
Schedule 5000 of them per tick
Im trying to stay away from them. I alreadyt have a shit ton.
is it that bad xd
I mean use BukkitRunnable if you have to
Have a repeating runnable that runs every tick and loops over every block in every loaded chunk
how many is considered too many
Depends
Im quite sure you won’t run into that issue tho
Where you have too many that is
That’s easy to fix
idc about indents lol
just want to know if it will cause lag
I minimize them yeah..
so what would be the best alternative to runTaskTimer?
?scheduling goes over it briefly, I didn’t wanna dig in too deeply about the differences but yeah
Might have to write that in sooner or later tho
If ur really worried about performance grab spark and do some profiling
I guarantee anything you are doing with schedulers tho is probably a fraction of what the server itself is doing every tick
^
The main issue with creating too many bukkit runnables, or using bukkit scheduler to allocate new tasks is that the id task incrementer eventually will run out of ids and go negative probably lol
True, I forgot there is a counter
Should’ve been a long >:(
I never use task ids
Same tbh, BukkitTask just too good
Could always be changed
Dk if it could
Cuz I mean, int auto promotes to long but not the other way around necessarily
Ah right the return type
Yea right, sadge :(
Probably wanna look at the command api, then yeah as pvbble said iterate thru and add them to a team
say I wanted to launch a player then detect if they collide with another player in th next 5 seconds
how would I do this without using runTaskTimer
Just compare time stamps based on some epoch (Java has an Instant and Duration class made for ur convenience here)
wdym by duration class
Its a class that just represents a duration quite verbatim
And Instant represents a time stamp respectively
Yeah if there isn’t an event for collision all you can really do is every tick check if their bounding box intersects another players bounding box
Via a scheduler
I guess you could also use the move event for the same purpose
can you dumb it down so a 50 IQ person can understand
Yea, I was gonna say reflection proxy and nms but don’t listen to me
the duration thing
Do you know what the english word duration means?
There is a class in java, provided by java just like HashMap, List and String
Oh i just meant quite literally
ah
It represents a duration, yeah that’s it
Duration duration = Duration.ofMinutes(5);
This would represent 5 minutes
I it think I understand
Now have you heard of the method System.currentTimeMillis() ?
yeah
I know this is quite late, but turns out this doesn't work for all entities. There is a Material.SNOW_GOLEM_SPAWN_EGG but not an EntityType.SNOW_GOLEM because it's called EntityType.SNOWMAN. I'm guessing there's probs other exceptions I haven't encountered yet. Any other ideas?
Instant instant = Instant.now();
This is like that currentTimeMillis method
But it returns an instant instead
(Consider it to be a time stamp representation)
Now with these two, you can easily manage timestamps and durations, that is compare them, create them and so on
is there a way i can set a tag to a item?
Nbt tag?
What will we do after 2038
Random or not?
like this in SKript "set metadata tag "fancyTable""
how do i use it
There’s this magical api called persistent data container instead
nope
Wdym nope?
no api\
Yes api/
no api\
?pdc
Not sure if skript has api for it
Ah, myes maybe yeah
But that is why java is more superior
Indeed
no i'm trying to set the metadata tag in JAVA
There is itemmeta
In the api
I mean for some people skript has a use. It was designed for people like server owners who were not devs
It was never designed as a replacement for plugins
@EventHandler
public void onArmorEquip(ArmorEquipEvent event) {
Player player = event.getPlayer();
PersistentDataContainer playerData = player.getPersistentDataContainer();
int currentMana = playerData.get(new NamespacedKey(Mana.getPlugin(), "maxMana"), PersistentDataType.INTEGER);
Inventory playerInv = player.getInventory();
ItemStack[] armorContents = playerInv.getContents();
PersistentDataContainer helmetData = armorContents[39].getItemMeta().getPersistentDataContainer();
PersistentDataContainer chestplateData = armorContents[38].getItemMeta().getPersistentDataContainer();
PersistentDataContainer leggingsData = armorContents[37].getItemMeta().getPersistentDataContainer();
PersistentDataContainer bootsData = armorContents[36].getItemMeta().getPersistentDataContainer();
}
How can i determine when to give the player a set bonus without it stacking. i have been playing around and i don't know what to do. I am using Jeffs Fork for the event.
package org.o555.bonemealer;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
public final class Apply implements Listener {
private final Bonemealer plugin;
public Apply(Bonemealer plugin) {
this.plugin = plugin;
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
return;
}
ItemStack item = event.getItem();
if (item == null || item.getType() != Material.BONE) {
return;
}
ItemMeta itemMeta = item.getItemMeta();
if (itemMeta == null || !itemMeta.hasDisplayName() || !itemMeta.getDisplayName().equals("Magical Bonemeal")) {
return;
}
Block clickedBlock = event.getClickedBlock();
if (clickedBlock == null) {
return;
}
boolean bonemealed = applyBoneMeal(clickedBlock, event.getBlockFace());
}
private boolean applyBoneMeal(Block block, BlockFace face) {
Material blockType = block.getType();
if (blockType == Material.OAK_SAPLING ||
blockType == Material.BIRCH_SAPLING ||
blockType == Material.SPRUCE_SAPLING ||
blockType == Material.JUNGLE_SAPLING ||
blockType == Material.ACACIA_SAPLING ||
blockType == Material.DARK_OAK_SAPLING ||
blockType == Material.WHEAT ||
blockType == Material.CARROTS ||
blockType == Material.POTATOES ||
blockType == Material.BEETROOTS ||
blockType == Material.MELON_STEM ||```
blockType == Material.PUMPKIN_STEM) {
// Simulate bone meal application
boolean success = block.applyBoneMeal(face);
return success;
}
return false;
}
}
sorry if its too long
but i have this class which applies bonemeal to the rightclicked block
is there a way i can make this work inside a dispenser
so i get the block infront of the dispenser and apply the same stuff to bonemeal it?
Yes
is there anyway to send a fake block with the API
does the packet fail when its interacted with?
well
The server sends a block change packet to correct for ghost blocks
what I've done in the past is just.. cancel that second packet
and then things work
do I need NMS if I do I'll just find another way I really don't feel like keeping up NMS for a commission
sendBlockChange is a bit too icky for me to use in its current state if all it allows for is fake-ish blocks that disappear when you click
pretty sure I had major code for this
But it used protocollib
And it was a bit braindead
And we had our custom blockstate system
meh not worth it I'll just make the server owner put wool around the zone if he wants it :P
I should probably clean it up and post a gist or something
The real sigma move is to inject new blocks into the game
Because there was quite a bunch of work
I made FakeBlockWrapper as uhh
I just need to finish this dumb minigame
funny
I should've asked for more than $250 😭
some simple thing, I just get distracted
I have a game engine its just intertwined with the core from the server I worked for. Its one of my best pieces of code tbh. Not being able to use it makes me wanna cry
it's so much yet so little
its a bunch of QOL stuff that I can recreate it'll just take time. It's mostly not coupled, just a bunch of like translation stuff that ofc makes sense to be coupled with the core as well as data handling
adapter
sun tzu been real quiet since I dropped that one
one more question, i found some code online and it has getFacing() in it but for me it shows red in intellij, how do i fix it? BlockFace dispenserFacing = dispenser.getFacing();
.
do you have the correct class imported
org.bukkit.block.data.type.Dispenser (correct) vs org.bukkit.block.Dispenser (wrong)
do basic items have a PDC key by default?
Items have no pdc by default
okay so i can return if its null.
ty this works, let me test it and see if my code is actually working and bonemeals stuff
ChatColor is showing deprecated on 1.20.1 Spigot-API, is there an alternative we're supposed to use?
Edit: Paper deprecated ChatColor, nevermind...
Lol
my code is perfectly fine in the ide but it doesnt do what its supposed to do, it doesnt apply the bonemeal rather just spits the item out
We need some more context or just send your code.
So ultimately we know it's not cancelling the event since its just dispensing the item
Which means your appleBoneMeal method is returning false for some reason
Do some debugging by logging your values into the console to see if you're getting the values you're looking for
ok thanks
I also suggest you perhaps add those materials into a list and asking if your block type is contained within that list instead of having a huge if statement
Use a set for extra speeds
config
ah of course
yesterday I left off and had an issue where things were offset too high
today I boot and they are too low
I see the code gremlins have been chewing away at my code
why login event kick dont work
Cause the Login event is fired before the Join event. If you want to prevent them from joining using the Login event, use PlayerLoginEvent#disallow()
The player can't be kicked during Login since they haven't even joined the server yet.
In a project I'm planning there are going to be alot of "select" menus? How should I go about storing and interpreting the players choice? Is there an api to make stuff like this easy? e.g selecting a chat colour or prefix or a "theme" for their plot. Should this be saved on internal memory or on a db?
Depending on your input, you could do GUIs if the player doesn't have to type anything out. Interpreting is up to you, but you should store that information in a database. Then load the information when the player joins and unload the information when they leave.
I'm planning on using a gui, I simply want to know the cleanest and best way to store it. So if they select something out of say like 10 options, thats the one which will run code ect. It's quite abit of work to edit a db entry every time. There is small stuff that it doesn't matter if there is a corruption or something and its reset. Is there an api / util to make this easy?
Depends on your menu system
For example at work we have a "PaginationLayer" that lets you add elements easily
We also have layers for selection (SingleSelectionLayer)
Is there a specific util for menus you recommend to make this easier?
how can i "hit" a non entity programmatically for example causing an end crystal to explode, a boat to shake, a itemframe to break
what is IF short for?
InventoryFramework
ah
found it https://github.com/stefvanschie/IF
thanks, I'll look into both and see if they fit my needs
I've been trying to use NMS with my paper plugin and I got the dependency added to my project, but im not able to use the classes or anything with spigot
do you have the spigot dependency loaded?
well i think any sort of nms goes through spigot so its still relevant
paper doesnt have their own nms dependency system or anything
depends on if theyre using paperweight-userdev or md5 specialsource i think
never heard of paperweight userdev ngl
still gonna be the spigot dependency though
seems like thats just a plugin
correct me if im wrong though
guys i want to make interactive boards and i want a starting clue to help me start the project
Does PlayerItemDamageEvent not work on swords?
should
Its not for me
Hi, question about playerCommandsendevent
because if I understand correctly it works as it is
when the list will be sent
on the edit
on the evening
So the default roster before being modified will not be sent to the player just the modified roster?
so the player never receives the first list?
item#getItemMeta#getDisplayName
to get item use getCurrentItem off the inventoryclickevent
assuming you are referring to https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/InventoryClickEvent.html
declaration: package: org.bukkit.event.inventory, class: InventoryClickEvent
does anyone know what a timing command is?
I keep getting those errors that Im using timing commands and it's depricated
but i, not sure where im using it.. i dont even know what it is
sounds like u might be using Paper, as i dont believe Spigot mentions timings command being deprecated
Paper on the other hand heavily recommends the Spark profiler iirc
What have i exactly messed up here?
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (isPlayerInGroup(player, "testGroup1") || isPlayerInGroup(player, "testGroup2") || isPlayerInGroup(player, "testGroup3") || isPlayerInGroup(player, "testGroup4")) {
if (player.getWorld().getName().equalsIgnoreCase("C")) {
new VagtshopC().open(player);
} else {
if (player.getWorld().getName().equalsIgnoreCase("B")) {
new VagtshopB().open(player);
} else {
if (player.getWorld().getName().equalsIgnoreCase("A")) {
new VagtshopA().open(player);
}else{
sender.sendMessage("You dont have permission for this.");
} else {
sender.sendMessage("You cant do this in your world.");
}
} else {
if (sender instanceof ConsoleCommandSender) {
sender.sendMessage("You need to be a player to do this");
}
}
return true;
}
}
}
}
}
At
} else {
sender.sendMessage("You cant do this in your world.");
}
} else {
if (sender instanceof ConsoleCommandSender) {
sender.sendMessage("You need to be a player to do this");
}
}
It says: 'else' without 'if'
give us some context on what is not working
also try and avoid all those nested if statements, you can just use a switch
I have updated the message
else if statements also exist
which one is it the first else or the instance of bit giving you the error?
You can just do
if (!(sender instanceof Player)) return false;
So i just need to replace that with if (sender instanceof ConsoleCommandSender) { right?
Wait I will send a fix
its more than just that
if (sender instanceof Player) {
Player player = (Player) sender;
if (isPlayerInGroup(player, "testGroup1") || isPlayerInGroup(player, "testGroup2") || isPlayerInGroup(player, "testGroup3") || isPlayerInGroup(player, "testGroup4")) {
if (player.getWorld().getName().equalsIgnoreCase("C")) {
new VagtshopC().open(player);
} else {
if (player.getWorld().getName().equalsIgnoreCase("B")) {
new VagtshopB().open(player);
} else {
if (player.getWorld().getName().equalsIgnoreCase("A")) {
new VagtshopA().open(player);
} else {
sender.sendMessage("You dont have permission for this.");
} else{
sender.sendMessage("You cant do this in your world.");
}
}
}
}else {
if (sender instanceof ConsoleCommandSender) {
sender.sendMessage("You need to be a player to do this");
}
}
return true;
}
}
Thanks
But im getting 1 error still
'else' without 'if'
} else{ sender.sendMessage("You cant do this in your world."); }
like i said your indentaion is off
What do you mean with that?
your brackets are everywhere
you have one too many aswell
and use else if statements instead of else { if{}}
But i cant just use else if here
} else{
sender.sendMessage("§8[ §3§lEXON §f§lMC §8] §7Du kan ikke gøre dette i dit world.");
}
in your world check you are doing
else{
if (){
} else{
if (){
}```
you can just do
if(){
} else if(){
} else if() {
}```
its much cleaner
or just use a switch
if (!(sender instanceof Player)) {
sender.sendMessage("Only players execute.");
return false;
}
if (!(isPlayerInGroup(player, "testGroup1") || isPlayerInGroup(player, "testGroup2") || isPlayerInGroup(player, "testGroup3") || isPlayerInGroup(player, "testGroup4"))) {
sender.sendMessage("No perm");
return false;
}
Player player = (Player) sender;
switch (player.getWorld().getName()) {
case "A" -> {}
case "B" -> {}
case "C" -> {}
default -> {
player.sendMessage("cannot do it on your world!");
}
}
return true;
stop spoonfeeding
Im trying to help
they wont learn if they just copy paste your code
working on my prototype server idea in General 1. If there is anyone with some spare time, could you help me with some technical parts. @here
Ping faliure.
whats the question
sorry if this isnt the right channel, but it isnt jsut one question
i doubt anyone will hop on vc so its probs easiest to ask here
i am asking for someone to help me with the problems I am currently working on
to be honest, i want someone to hear my idea and jump on my team.
yeah not the place to ask
general chat?
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
this discord isnt for recruitment
thank you for the link
Did you just try to ping a few thousand discord users 💀
Just let him put the shovel down with dignity olivo lol
what i really need is someone that has technical abilities and is able to grasp the concept i have for a server that could change how servers are created entirely
Sir im gonna have to confiscate that shovel rn
If you don't have enough patience to wait for an answer then you'll be a real bad person to work with
Big red flags my man
that is why i am in vc,
what are you doing?
i am happy to explain, just not here
unexpectedly wholesome lol
I have a server idea that nobody has ever seen before
X
The talk about it in a forum post
i aam looking everywhere for those who can see it the way i do
sounds intriguing but definitely not something I'm interested in
well so do I and I'm already working on it for 3.5 months. It is however not a server concept but a plugin (and yes, it will be public) - still a lot to do though
It is working already but needs some more polish :)
i hear that like 3 times a week
Go... make. A ... forum post...
I'm trying to get my plugin to work just 4 days and I thought that was a lot, jeez
the thing is, this idea to to valuabale to share
well it's a whole engine - even if I knew exactly what I had to type (codewise) I would not be done in 4 days since it's just too much code
when it's too valuable to share then why do you wanna share it? lol
This is still the wrong place
ok @quaint mantle
I am trying to look for people with the skills i need and the ability to understand the opportunity that i offer
thank you all
i will make my forum post in the appropriate location
Dude I'll take the hit from the mods.
Shut the hell up my man. Your unique one of a kind super 3000 mega idea is not gonna Steve jobs you to spigot royalty.
Be open, honest excited about the concept and just do it.
And stop using this supercalifrajulisticexpialibullshit to try and sell the idea.
Its painful and makes folk less likely to listen
Make a forum post
Do it properly
dude, this idea could be worth a big chunk of cash for those who assist me
i will!
is it worth to join the VC or will I be bored when doing so?
to be fair, he got a decent story teller/youtuber voice
Sry for my late respons
So in {} is where i can put VagtshopA().open(player);?
Yup
Okay thanks
Wait he is in the VC?
Don't give em the time of day
I'm just listening while working. Got a meeting in 7 mins anyway
Charismatic entrepreneurs are cursed runes.
The dude came in, barged I to chats was told to stop but still got a decent sized discord call.
Dude is bad news 😂
I have way too much to do to join any server anyway
the funny thing is that he talks about a server that I imagined creating one day - well kind of
+1
Not in the near future - maybe once I win the lottery
All I know is that the engine I'm working on would be pretty much the core of that concept
He wants free labour as he can't be arsed to learn him self.
Do ?java, chuck him at it with a catapult and forget about him
I'll just go on with my day in 2 mins. Got a meeting.
Was nice to have some background noise
That's how they trap ya
Cause moment ur I the call there's a shred of chance he reels u in
guy tried to offer me $20 000 for this if I remember correctly
Don't fall for this
But now there is more stuff :D
Lmao
it indeed was entertaining to listen to
Very, yes
Do you know why it isnt working with a but is with b and c?
switch (player.getWorld().getName()) {
case "A" -> {
new VagtshopA().open(player);
}
It says Enchanted 'switch' blocks are not supported at language level '8'
Update to 17 if you working with newer versions of mc
You can't use the -> syntax for switch in java 8
Also my brother I christ what the hell is that use of a switch.
Man gonna write all the players names who'll ever log on into those cases? 😂
That is world-based shop
Yeah wow I'm blind. I blame morning brain
Even so...
understandable
What happens if they install multiverse or something?
What if the end user wants shops in other worlds
🤷♂️
Seems like the perfect spot for a hashset
Or perhaps a map of they need different info for each world
New spigot movement #DitchTheSwitch
I'm at work making actual monry
I need my IQ points lol
Do you also procrastinate actually working ?
Lol no waiting for something to load
Ask the guy how many lines of code have been written for plugin needed for his idea
Demand an objective number
oh so
On my behalf , Ask him I want a number as a potential investor
unless he made more since I helped him, it would be just 40
a simple ping pong response event
Raziel the rich investor
guy claimed to know some C, I doubt it
not necessarily, you would know some programming concepts at least
I don't think he knew anything
Someone tell him he is a 2nd rate duelist with a 3rd rate deck
Also someone explain his full idea here
Like
In full
Or in general and ping me
No the whole thing berbatim
Verbatim
Just bunch of random shit put together


