#help-development
1 messages Β· Page 1202 of 1
technically, but in maths iircs they're not called like that because some odd guys decided to name it differently
nvm
also what if you want to calculate distance between two vectors? you cannot just create a method, because you will be using T as your substitute
even if you did could do that through utility methods, you could end up in type erasure problems with function overloads because if you specified:
public void distance(Vector2D<Float> vector1, Vector2D<Float> vector2) {
// ...
}
public void distance(Vector2D<Double> vector1, Vector2D<Double> vector2) {
// ...
}
this wouldnt compile due to type erasure. After type erasure overloads will become:
public void distance(Vector2D vector1, Vector2D vector2) {
// ...
}
public void distance(Vector2D vector1, Vector2D vector2) {
// ...
}
and now your methods becomes ambigous to overload
Time to convert everything to a double and then calculate
pffh who needs floats anyway
that can introduce precision issues with big integer values
you would still need native value that's derived from Number to construct it
hey u do u know any public replay plugins like hypixel has?
Wrong channel ask in #help-server
you can solve this via:
public class Vector2D<T> {
public static class Utilities {
private Uitlities() {}
public static class Float {
private Float() {}
public float distance(Vector2D<Float> vector1, Vector2D<Float> vector2) {
// ...
}
}
public static class Double {
private Double() {}
public double distance(Vector2D<Double> vector1, Vector2D<Double> vector2) {
// ...
}
}
}
public Vector2D(T component1, T component2) {
// ...
}
}
Vector2D<Float> floatVector1 = new Vector2D<>(1.0f, 1.0f);
Vector2D<Float> floatVector2 = new Vector2D<>(2.0f, 2.0f);
Vector2D<Double> doubleVector1 = new Vector2D<>(1.0d, 1.0d);
Vector2D<Double> doubleVector2 = new Vector2D<>(2.0d, 2.0d);
Vector2D.Utilities.Float.distance(floatVector1, floatVector2);
Vector2D.Utilities.Double.distance(doubleVector1, doubleVector2);
but this is worse than just declaring vectors as two separate things
Could also switch in the Vector2D distance method
Would help with it's usage but still less than ideal yeah
is there a way to add some sort of red vignette to the player screen i think ive seen it done before somewhere
Yes create a world border and make sure the player is outside of it
also what if you needed to register Vector as a component within ECS system.
Entity entity = new Entiy();
entity.setComponent(new Vector2D<>(1.0f, 1.0f));
Vector2D<Float> position = entity.getComponent(Vector2D.class) // Warning! Unsafe cast from Vector2D to Vector2D<Float>
See https://github.com/mcbrawls/audience/blob/e1c5db19b3b945de052f29c603f32485e764d6b1/src/main/java/dev/andante/audience/Audience.java#L208 (Fabric, but you get the point)
imho generics introduces more problems than it fixes
primitives and their wrappers are a bit of a problem
so does it have to be done via packets
Valhalla will make it better
No Spigot has API for it
declaration: package: org.bukkit.entity, interface: Player
thank you!
also Float vectors are useful still these days
in shader programming
precision is just enough for vertex positions
how does the percentage work on this
nvm i think i get it
most useful hotkeys in intellij
alt + enter
alt + insert
0.0f to 1.0f
spigot has no WorldBorder#setWarningBlocks
setWarningDistance
ok thx
ik this is spigot but im banned from paper discord
how do you send titles on paper
sendTitle from Player is deprecated
yeah i just noticed lol i thought i were
I use alt enter so much I end up using it in other apps and accidentally submitting data
with proper settings ALT+Insert generate menu is such a breeze
Player#getKiller will get the player responsible for the kill
Otherwise Player#getLastDamageCause
thanks bro
does PlayerSwapHandItemsEvent get called even if nothing acutally swaps
like if they press F on their hotbar with nothing in their hand and offhand
will it still be called
Try and see
hm my plugin isnt quite compilable yet
why not
jdtc π§
what that mean
Yes
oh no
thanks
what is the proper way to format having packet listeners in a plugin?
should all of them just be in the onEnable or organized elsewhere like in a package?
i personally prefer using annotations
hrm annotations....... hrm yes
!docs
wot
me?
just need the docs for 1.12.2
appreciate it
Yw
hey can anyone help me implement essentialsX API
im just trying to do something simple like run user.Getplayer
IEssentials essentials;
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("Essentials");
if (plugin instanceof IEssentials) {
essentials = (IEssentials) plugin;
} else {
throw new IllegalStateException("Essentials plugin not found.");
}
This is what I currently do to get the plugin instance but I'm wondering if there is a better way
Is there a good loot table API to create custom loot tables in classes and these loot tables can be edited in game by basically placing blocks/ items in them? Iβm looking for a plugin like that for spigot. Mc 1.21.4.
Hi iam working on plugins again iam trying to make it this time cleaner and better in design.
i dont want to make it like privite final is there a better way?
for events proceessers
what in the pixelation
in the EndProcceser i add the event code that run
I don't see what's wrong beside you using Lombok
its been 5 months since i last worked on any code
well there is 1 thing wrong lets say i use other bedwars plugin to support the system would not work
iam working again on quest plugin) for bedwars .
lol
thats a very generic question. what are you trying to do and whats the purpose of the event processors
typically you want to have any field private final which you dont expect to change
so what do you need help with?
ideas to make the code more optimized and cleaner and easier to work with / i do support other bw plugins so i need to make Proccers for other bw plugins too ;p i dont like this idea
i finished the events for Bw1058 processers
What's wrong with Lombok?
i need to make other for bw2023 , mbedwars
nothing
that is just to many classes
hmm, do they hook into your plugin or are you trying to support them?
i already use the listeners and events of other bw plugins i am trying to make my system better and optimized
https://paste.md-5.net please
ah i see, and what are you trying to do? whats the purpose of your plugin?
^
to put it simply . each bw plugin have its own events and listeners , winEvent , KillEvent with diffrent names for classes and Objects
this is how i have it right now :p
if you need to use specific parts of the plugins then there is no other way around that
thx
only thing you could do is restructure your code to have it a bit simpler and more modular or you get in touch with the devs so they impl your api
but not many will do that probably


lombok is great tho
How do i detect if player drank speed potion if PotionType is not working?
I remember someone posting a github project to an example Minigame plugin that focuses on showing game management and gamephases. Anyone knows a project like that?
IIRC someone active here made it
also how should I set player spawnpoints for a minigame map(like bedwars islands)? i thought about using armor stands with custom display names or tags, is that smart?
I assume you're talking about this
yea thats it. ty!
I dont like that multiverse is fking around with gamemodes in my server, can I somehow, in my code, forcefully make it so multiversecore wont handle gamemode?
Have you considered configuring multiverse
instead of going full nuclear on their system
:O
I hate java
so i wanna deploy some maven artifacts and i have a project structured with multiple modules like so:
project
project-core
project-dist
project-nms_<versions>
pom.xml
now when i do mvn clean deploy i end up with a package for each of the modules in project, but i really dont need people to be able to access them all as only either core or parent are useful. excluding the nms packages and dist is fine, but now deploying results in a parent and core package. excluding core leaves a parent package without a jar, excluding parent builds nothing at all. i don't think i understand how this works, lol
I'm trying to add obfuscation to my plugin but I think I'm keeping the libraries wrong, how do I do this?
https://pastebin.com/LXFTysFZ
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.
java.lang.NoClassDefFoundError: dev/triumphteam/cmd/core/BaseCommand
yes i am getting this error
Fix: dont obfuscate
i should
why exactly?
I have to obfuscate my plugin and I need help, I wrote the problem above.
and why do you have to obfuscate your plugin?
Obviously so John Pirate can't steal his revolutionarily mediocre code
why no one uses assert keyword in java? I mean for private functions its a great way to notify developer and both the IDE that the expected value might not be null while calling it
sure you have testing frameworks, but then with those statements you self document the code that's internal and shouldnt be tested with unit tests
I use it sometimes π€·ββοΈ I just tend to find exceptions better as they work in prod too
because you would have to start your java app with a specific keyword
so that they hit
is that bad?
I think so preconditions are cool π
- you dont want to have tests in your prod code
that's the thing assertions do not live in your prod code
it gets erased if you dont toggle them on while compiling
exactly, but rather have tests streamlined than asserts all over your code
but what if its internal private method
that shouldnt be even tested
thats only for convenience
i mean its personal preference, but you dont want to hunt down every single assert in your code if you changed something
i prefer to have all tests in one place
and i see an assert more as "did i understand that right?" rather than to test the logic
sure but imho i would use unit tests for public code that accesible from outside, like public, protected or package default, but for private methods i would probs use assertion not because of the tests, but because it allows to inform the developer that this function depends on the specific context that assert describes
it justs a clear way to describe that this function needs to have some class field as not null in its function body when its being called
its different for everyone, hence i said its personal preference
there is a huge debate whether to use it or not
hmm
or you could just use comments
for implementations
turns out assertions are not stripped out completely
well it is stripped out
but it can decrease the change the code will get inline with jit
I'd much rather check and throw an exception in that case as if it were null in production for some reason it'd fail fast and not somewhere down the line
but that's just over low level
This is the first of a series of posts that shows how certain language features and compiler optimisations are implemented on the JVM; on by...
Because my plugin is a premium plugin.
.
that doesnt make your code premium. anyways - i hope you read the premium resource guidelines which also tell you what you can use
just because it's premium it doesn't mean it has to be obfuscated
Since I will publish my plugin on spigot, those instructions do not concern me.
there are tons of premium plugins that are even source available on github
since you will publish your plugin on spigot, the rules of spigot count for your plugin
freemium is the best anyways
there is no reason to hide your code
let others learn from it
I'm not saying it should be necessary anyway.
open source is the way
I say I won't publish it on spigot, don't you understand?
in any case your obfuscator is stripping out way too many classes
the ones that your plugin needs
sorry I wrote it wrong
np, but i doubt you will find help here
I know how to create a role system through interfaces, but I don't know how to make it with level 2 (race -> role) so that you can't register roles in the wrong race at the compile level.
how do this
generic monipulation
like this https://paste.md-5.net/joqaranero.cpp
elf role should registerd only in elfRace or be compile error
protecting the registration of roles that do not belong to this race
race -> role
2 level
can i see your Race interface?
eh what
still your generics doesnt make sense
i dont quite understand your system you're trying to do, we need more code
i think Race<ElfRace> is just a registry class to register certain types of Races
still name is kinda weird
Registry<ElfRace> sounds way better
i would probably just have one Registry class which wraps Map<Class<? extends Race, Race>> races
and then uses <T extends Race> T get(Class<T> race); to get the race and void set(Class<? extends Race> race); to set the race inside the registry
final RaceRegistry registry = new RaceRegistry(...);
final ElfRace elf = registry.get(ElfRace.class);
final MageRace mage = new MageRace(...);
registry.set(mage);
that way you can register races dynamically externally too. For example loading race from file, but if you want to register only certain types of races, your approach is good too
or since you have explicit classes for each race apparently, why dont you create an elf interface and make both of type elf
by that elf can only have or be an elf
now i see
and to close the circle elf could be of type race
an example of how much the name of the classes affects the view of the situation...
i created smth like this https://paste.md-5.net/jigamafama.coffeescript humanRole this general role
? as in?
i think at this point HAS A would be better than IS A
for example your fire magician has the race elf with the ? x
by that you could make it even more modular
for example having an interface FireElement and Magician which FireMagician inherits
he has a race elf and you could make many sub elf interfaces for example ForestElf or BeachElf or whatever comes to your mind
i like the idea, but that depends on what he's actually doing
how can i make a player lie on the ground like if its a bed?
You need to spawn a fake player with packets
and then set it's pose to be sleeping
The pose is sent as entity metadata
is there a way to send a block change with a sign that already has text on it?
Player#sendBlockChanges(Collection<BlockState>)
Worth noting that assert isn't a test. It's an assertion. Ideally you write assertions that you know should never fail. If it fails, something fucking broke in your code and you need to fix it.
If I assert 1 != 2, you better bet your ass that that's true
thanks
how to hide this text from an item?
for 1.21.1, MCStacker suggests: /give @p diamond_hoe[attribute_modifiers={modifiers:[],show_in_tooltip:true}] 1 and it works
I tried this it doesn't work: java var attrs = meta.getAttributeModifiers(); if (attrs != null) attrs.clear(); meta.setAttributeModifiers(attrs); item.setItemMeta(meta);
edit: none of the ItemFlag work
You sure the ItemFlags don't work
lemme try once again
is there any way to modify the size of the nametag of an armorstand?
nope on version 1.21.1java ItemStack item = new ItemStack(Material.DIAMOND_HOE); player.sendMessage("i got these flags: " + String.join(", ", flags)); ItemMeta meta = item.getItemMeta(); for (String flag : flags) { meta.addItemFlags(ItemFlag.valueOf(flag)); } item.setItemMeta(meta); player.getInventory().addItem(item);
where the flags come from
you sure you are running spigot and not paper?
Might need to add an attribute for it to work
i'm just targeting spigot in pom
to be honest, running purpur
So you're running a paper fork
?whereami
yeah, although it's still related to spigot since i'm using spigot's code, no? π€¨
No you're calling Purpurs code at runtime
paper changes how the method works
You're only compiling against the interfaces that Spigot provides
so, it works one way on spigot but another way on paper+
The behavior is determined by the server
give me a few min, I'll try on pure spigot jar
well it works now π with the HIDE_ATTRIBUTES flag
thanks I guess.. it's clear who to blame now
No
):
I mean you can add more text to it and that will change the size
but I assume that's not what you mean
Use text displays
wtf when did they add those?
1.19.4
damn
text displays remind me of computer craft's screens tbh
?howold 1.19.4
Minecraft 1.19.4 is 1 year, 9 months old.
^^ that long ago
keep in mind that you might find text displays weird in some scenarios, it's like billboards, not traditional holographic displays
oh hi musava
Text display are cool, but custom biome colors and skybox colors are cooler that were added in 1.16.4
it was like revolutionary
for serverside world environments
API is really lacking when it comes to custom biomes and other datapack stuff
finally you can have seasons
Wish you could bundle a datapack easily inside of the plugin
yeah I was wondering if you'd recognise me xD
btw is it possible to change entity scale attribute , does it resize nametag?
your name sounded very familiar
Try it and see
arent like plugins are spoofing themsleves to be datapacks in recent spigot/paper implementations?
nah it's still the default size unfortunately
Paper is really trying to get rid of API that's alien to native minecraft code
Spigot plugins don't really load early enough for datapacks
So you need to do a bunch of hackery with the internals
i dont seem to understand fat jar principle of multiversion compatibility
why plugins try to support 12 versions of minecraft
in one jar
C O N VE N I E N C E
only for the user
Because users are unable to pick the correct jar
its pain to setup proper abstractions for all versions of minecraft
and leave 1 star reviews
π
if you cant pick a jar
you cant run a server
It's difficult because if you then load the server without the requisite data pack you're in for a bad time (though that's slowly getting better)
thanks, works!
why if i disable gravity for an item im spawning it just flies away lol?
Item item = loc.getWorld().dropItem(loc, new ItemStack(mat));
item.setGravity(false);
item.setPickupDelay(Integer.MAX_VALUE);
item.setUnlimitedLifetime(true);
Ah
You want it to spawn with your data
is that also new
Yeah
Not spawn and then set
Welcome to the future
yeah spigot just breaks the itemstack's functionality to make the flag work
You jumped 10 years of Spigot
still floats away
settings its velocity to 0 fixes it
Are you spawning it inside of a block or smth
btw you can use an ItemDisplay
man
i googled for like 10 minutes
didnt find anything
thanks
I did my research
spigot adds this
Paper removes this
yeah, and as machineamaker mentioned, that breaks the itemstack's functionality to make the flag work
yeah, it removes all implicit attributes for that item type
which is all fine and good for a gui item that isn't gonna be used as an actual item
using /data get I noticed that spigot gives an item like this: components: {"minecraft:attribute_modifiers": {show_in_tooltip: 0b, modifiers: []}} (although the show_in_tooltip does not matter if modifiers is an empty array, i.e. /give @p diamond_hoe[attribute_modifiers={modifiers:[],show_in_tooltip:true}] 1 also hides the stuff)
yeah, and that item has no attributes
That command also removes the attributes ^^
it doesn't have the default ones assocated with diamond hoe
Just like Spigot does
so for tools and stuff, break speed, all that stuff doesn't work
yeah, I'm confused why can't I just make it an empty array directly from my plugin
as far as I understood it, empty array means "no attributes", but no array present means "default attributes"
you can, just set it to an empty map
well maybe you can't on spigot, idk. could be one for the 400 itemmeta fixes paper has
sorry, not break speed, that's not a modifier. attack damage/speed
give yourself a diamond sword like that and try killing a pig. one with an empty modifiers like that, one default one
its not no array present, it's no minecraft:attribute_modifiers component present
if that data component isn't present directly on the stack, it will fall back to the default ones for the item type.
but you can't hide the modifiers without setting the data component. So any setting of the show_in_tooltip=false will ALWAYS override the default modifiers
this is an inherent bug in vanilla with how the data component system is setup in relation to tooltips
ah understood
but spigot doesn't expose component apis for some reason
(in modding world it's easier)
so i'd have to touch NMS to make it an empty list I guess?
can i combine several displays so that they rotate together?
which displays? item text block
item, text
I guess if they are separate entities you should just apply same rotation to each one of them
im talking about the rotation caused by the player moving their head
the billboard option
Only rotating around the vertical axis should look good enough?
do you mean you want to move it so it is like a selfie stick?
always facing the player and in front of him
this is like setting yaw to be the opposite of player's yaw
Yes
wait
no
ill explain later
just for reference, here is the code because I hate when others manage to do something and then not post code java net.minecraft.world.item.ItemStack nmsItem = CraftItemStack.asNMSCopy(item0); nmsItem.b(DataComponents.n, ItemAttributeModifiers.a); ItemStack item = CraftItemStack.asBukkitCopy(nmsItem); player.getInventory().addItem(item); it's terrible and what not. but works on paper and downstream. i didn't even set up mojang mappings beforehand, glad that nms provides ItemAttributeModifiers.a already
well to be clear, it works if you don't care if the item no longer has any modifiers (like if its for a GUI or something)
it's a custom item, a diamond hoe used to display it the inventory but is not used as a hoe but as some sort of magical wand, think of right click abilities, so this is just getting in the way (why the heck do hoes even have attack damage), so i have to modify the item or itemmeta directly, not create a clone
anyway, thanks for your paper reply π
p.s. weird that this wasn't working
@silver robin @chrome beacon this is the situation https://i.imgur.com/H2kccG0.png (top down view)
when the player moves to a new location, this is what happens
what i want to happen is for the two displays to rotate around a shared axis https://i.imgur.com/TJpODYi.png
?codereview
#1100941063058894868 is the place for code reviews. Remember to read the pinned message!
?
its for this haha
how is that related to what i said
It is not? Am i not allowed to send here a bot-request message? lol
You shouldn't feel addressed by every sentence you see under your posts, this channel is not only about you
#bot-commands
Yea but i was already in this channel mb
I see you'd have to move them yourself
i have a question not directly spigot related, but idk where to ask.
I wanna create a texture pack with item images greater than 16x16 (64x64)
Whatβs the question
how can i use images greater than 16x16
does it work ye?
ye i do (64x64)
bro forgot high res texture packs exist
or he doesn't know
no didnt forgot just read it doesnt work
How do servers create UI elements with bossbars that don't move location regardless of GUI scale?
im trying to create a custom item in my plugin but i dont know how to make a custom texture for the item. how can i do that?
apparently it doesnt, when i have the item its just the purple black texture
I don't quite understand your question, but shaders can be used to position things relative to the screen size
https://github.com/toxicity188/BetterHud/wiki/tutorial
scroll to the bottom of the page here (hopefully that gives a better explanation)
looks like shaders
thank you
What's the error
NoCrystalBallFoundError
lol
i think he is talking about the imports
invalidate ur caches
Sorry - I tried that did not work π¦
.
are the same libraries/dependencies imported?
oh, its not ServerPing.ServerData.Serializer
that's a different class tho
its just ServerPing.Serializer
yeah
Not really
expand ServerData class, see if theres a Serializer for it
(double click the {...})
oh, yeah, no Serializer lol
I am just confused why it works in eclipse not intellij i really didnt want to redo my old code x_x
did it compile in Eclipse?
Yup
if u open it in eclipse right now, can u see if that class exists?
eclipse will compile literal errors tho
so no surprises there
don't compile with eclipse or intellij, compile with maven
No
i mean i wasnt particularly saying to literally compile with eclipse, but rather wondering if Eclipse builds the project [with Maven] with no issues
Can you open that class in eclipse
^^
I get src not found for the class file
bet they manually added a different jar to the eclipse classpath and building with maven doesn't compile :Clueless:
Wouldn't be the first time
I have the same project open in both, the intellij is just me opening the eclipse project and using the import eclipse project
no changes
open a terminal, cd into the project directory and run mvn package, does it compile?
says mvn is not recognized as a cmd
I've always done it thru Eclipse
Im trying to migrate to IntelliJ but idk at this point
how do you use ComponentBuilder for sendTitle()?
whenever I put in "new ComponentBuilder().create();" for either of the string slots I get an error
like is there a way to convert components into strings?
Yes
how
But by ComponentBuilder you mean net.kyori's adventure lib right?
or are we talking about something else
this
My apologies, I am not certain.
All good
@unborn hollow I felt bad about interjecting without knowing, so I did the research for you. You can append .toLegacyText() to the end of your component builder
tysm
No man I'm really sorry for acting like a know it all wityhout checking what u were talking about, hope it helps.
does anyone know a free and offline speech to text library for java
guess im taking a look at CMU Sphinx when i get home after new years
Openai whisper?
It'll be hard to find something pure java
This looks old but maybe https://github.com/mozilla/DeepSpeech
NOT JAVA!! KILL KILL KILL
True true i agree
we coulddd replace md_5 with an AI.
JNI π
not the same hmpfh
Sphinx is pure java so I guess that's about your only option. Idfk how it works
Looks like it has some sort of model too
i dont really know what you'd use STT for in the Minecraft Sphere either... π€
Might be a better question for just the general wider java community, instead of just spigot
integrate mc with home assistant
Hey, how do i give a leather piece a color ? i didnt found anything that worked
Itemmeta - https://hub.spigotmc.org/javadocs/spigot/org/bukkit/inventory/meta/ColorableArmorMeta.html
declaration: package: org.bukkit.inventory.meta, interface: ColorableArmorMeta
declaration: package: org.bukkit.inventory.meta, interface: LeatherArmorMeta
thx
voice commands on the client
can you remove the page number from a book with just commands? if so how and if it has to be a plugin then how also?
Is there a way for ontabcomplete event to show the suggestion but not fill it into the chat like that?
oh screenshots aint enabled
Is there a way to make sure the suggestion gets shown but not filled in the chat if u press tab?
how did the other server manage to do that then?
Probably brigadier
The server sends the options. The client fills it when you press tab
on this server u cant fill it if u press tab
!verify
Usage: !verify <forums username>
either Brigadier (NMS) or they do fuckery with some packet
library called reindeer when
I can tell you right now nobody wants to send their own command graph
it breaks literally everything and is a huge pain
is there any cons of using fluent getters/setter instead of javabeans spec ones apart from incompatibilities from JPA based method scanning?
what im most interested is that there are any penalty for return this inside fluent setter
Damn wtf is this guy yapping apart I don't even understand what you're talking about anymore π
JavaBeans specification setter
public void setFoo(final Foo foo) {
this.foo = foo;
}
vs
Fluent setter
public Bar foo(final Foo foo) {
this.foo = foo;
return this;
}
most of the time i used fluent setters its on a builder
I'd assume the only detriment to return this is a few extra instructions you could look at the java* asm when you use them.
Because it's not unlikely it's optimized
im wondering if this returning this is better than calling the same reference over an over with void return types
Well unless optimized the void return would be marginally better because the fluent one has to run more instructions
the only difference is in style really
But as I said I don't know the java asm, it seems like something that'd be optimized
You can easily see the diff by decompiling the results
specifically that kind of fluent style you see in builders, then you also have withers for immutable objects
i mean, the difference is literally one new instruction and a different return instruction
is there any reason why we only use it primarily with builders?
Builders tend to have a lot of setters so it gets annoying is my reason
Generally with regular objects your sparsely setting 5 to 10 setters consecutively
And if you do you might just have a really shitty constructor or maybe a builder
*cough* streams api
Streams api is functional though and those methods are nothing like setters
it's neither a builder nor a setter nor a single data structure you are mutating fields in
im just wondering which style should i prefer. I like fluent getters/setters but im not keen on returning reference on every setter, so i might just return void for setters
im just wondering if i should switch my getters/setter style for fluent based ones
to better match with record getters
When it comes to style you should balance between what's commonly done for naming and styling conventions and mix it with what you like
Do what you like
If you think its readable I see no issues
i just wouldn't have setters
Eh depends on the situation they can't be avoided always
and static!
i feel like i've tasted kotlin a bit and im trying to reintroduce it bit back to java
Mainly thinking about if your doing games here you might have trouble doing this
I know for my apps I usually do immutable withMethods
But for games that much wastefullness is just dum lemme abuse muh state
Games in java?1?11//
LibGDX babyyyy
games are an entirely different beast to tackle as other kinds of software
I also am nowhere near where I need to be with C
i can't remember when i last needed to have a setter
I mean ignoring my game, yeah tbh ^
Usually if I mutate state it'd be in a methods with other effects
Or it's just immutable πͺ
idk if there is a getter for it, that way you may just print it out rq
but I'd guess default is 1, don't know though
0.1 is the default and yeah there is a getter
that's a weird default

that's not a mojang issue
it is a mojang "issue"
that's bad too
actually in api the default will be 0.2 because for whatever reason the api will */ by 2
Never once had an issue with this way or had to "divide by two", and yes the default is 0.10 thats just how mojang did it.
Player player = (Player) cs;
float speed = (float) pl.getConfig().getDouble("flight-speed");
boolean flight = pl.getConfig().getBoolean("flight-enabled");
if (flight && cmd.getName().equalsIgnoreCase("fly")) {
boolean isFlying = !(player.isFlying() || player.getAllowFlight());
player.setAllowFlight(isFlying);
player.setFlying(isFlying);
player.setFlySpeed(speed);
player.sendMessage(isFlying ? "Β§6You are now flying" : "Β§6You are no longer flying");
return true;
}
#Set player /fly speed. Must have CMI flight disabled
flight-speed: 0.04
Sure it applies to walking as well
internally the default is 0.1, but in the api when you call Player#getWalkSpeed() it'll be 0.2
and a few lines above there's setWalkSpeed
lmfao
So when you get the walk or fly speed you essentially have to divide by half for the true value
Yeah that makes sense mojang lmao
nice
it's not mojang, it's spigot 

like genuinely don't care, just use 0.2 as default and call it a day
I would not set the walk or fly speed as 0.2 it would then be 0.4 per spigot
thats double?
That's a block property on the client, you can't change that no matter what.
But you can emulate it with speed attribute
But this solution would have "lag"
yeah it's hard-coded
Why cant everything be server sided π
... lag
Also, custom blocks will solve that, it will just take time before we have this
Custom... blocks..?
getWalkSpeed() will return 0.2 - internally it's 0.1 and it gets multiplied by 2 before returning
setWalkSpeed(0.2) will set the internal value to 0.1, as it gets divided by 2 before setting the value
same thing for fly but the default is differnet i think
Yes, the ability to create blocks with datapack.
One day, one day
That is such a mess to work with lol
it's not
just... use 0.2 is the default for walk speed and call it a day
you don't need to do any arithmetic here
Sets walk speed to 0.2, gets divided to 0.1 for the set value, now you wann get that value, it returns the value doubled again at 0.2. Why not just store one value, whats with all the math?
Β―_(γ)_/Β―
the point is that you shouldn't care
0.2 is the default and that's that
md we need answers
but yeah it's stupid

just wondering what peoples opinions are on the optimal way a plugin should store data in a db table owned by the server admin? sorry if vague question or anything just really new to programming in general
"optimal way"?
id say, in the db create any tables you need similar to plugin-tablename and then just store the data like normal
I don't really understand the question here
How you store things depends on the data you're storing
How would most people program the logic for storing data? what sort of db would most people use? the data im wanting to store is UUID of user who executed command, their username and a random string that is generated in the playermessage sent after user executes the command
apologies for not knowing the correect way to ask this im very new to programming please cut me slack :)))))))))))))))))))))
Most users run MariaDB or MySQL
fairly helpful ty
im a nosql fanboy, from my experience mongodb is way easier to work with in the context of spigot
Hey! Is there a way to create a custom glowing effect (with a custom color) that is only visible for an list of players ?
i use maven, on spigot 1.21.4
i'm not sure if there's a built-in way to do this. if there's not, you'll just have to send the packets for the glow effect on certain players yourself
Is the glow only visible to certain players or is it visible to all of them but with different colors?
just for certain players with the same color
for exemple, the team one have red glowing effect, team 2 can see that, but team 3 see nothing
you could use https://github.com/SkytAsul/GlowingEntities
wait isnt there some team glow option
well not for per-player glowing right
oh dam
we can't change the color and visibility with .sendPotionEffectChange() ?
Can team 1 see their own glowing effect?
and is it the same color?
no
yes
I'm going to assume there aren't other plugins messing with the scoreboard as that might be a bit tricky to handle:
First you'll need to setup the teams. You can get the default scoreboard from the ScoreboardManager or if you prefer make a new one so your teams won't persist (Don't forget to set the scoreboard to the players if you do).
After that register the teams you want (Do handle the case if the team already exists). You can then set the color of each team and assign all the players to it (add an entry with their username, uuid might also work not entierly sure).
When teams are assigned the glowing effect will have the color of the team. You can use the Player#sendPotionEffectChange method to give the glowing effect. The player is the one seeing the effect and the first LivingEntity is the target that will be glowing.
Hopefully that should work if you have any issues or questions feel free to ask
thank you very much, I'll try to set it up
if every glow should have the same color one team is probably enough
but you might want to tweak the team settings per team for other things so π€·ββοΈ
ik this depends on the implementation but does Map#values() guarantee that the values are non-duplicates? I see it returns Collection<Value> so it must return values with duplicates, else it would've returned Set<Value> if that was the case, right?
There can be duplicate values
in a map only keys are unique
otherwise you need something like a bi-directional map
well i'm asking because i've implemented custom iterator for my view class to iterate through map values, so it filters out duplicates cause its backed by Set
kinda slow, but im not expecting to iterate it the other way often so its not really an issue
where can I find all the block state id's?
Block states (also known as block properties) are extra pieces of data that further define a block, such as how it appears or behaves.
In Bedrock Edition, there are also aux values (also known as Metadata) to define a block. Aux values are in the format of binary flags, which basically match the block states one-to-one, and they are accessible i...
βοΈ
I meant the id like you woulld use in BlockState blockState = Block.stateById();
Just look at the block state definition or default block state
Don't rely on Magic numbers
how can I do that
i suggest you use namespaced keys for block state retrieval instead of magic values
Which one
magic values are designed for packet translation, not for daily use
getStateDefinition and defaultBlockState respectively
ok
what class is that from
Block
is the colored glow limited to 16 default minecraft color codes or can it be rgb?
limited
how can I send BlockUpdate Packets to only 1 player. Right now I'm sending the packet to only one person but every player can see the blocks
Can someone tell me what the progress of the component api for spigot is?
If every player can see it you didn't send it to only one person?
That's a conflicting statement?
Anyways if you want to place a fake block you can use https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/Player.html#sendBlockChange(org.bukkit.Location,org.bukkit.block.data.BlockData)
declaration: package: org.bukkit.entity, interface: Player
this is my code for creating and sending the packet
displayBlock.setType(Material.WHITE_STAINED_GLASS);
BlockState blockState = displayBlock.getNMS();
ClientboundBlockUpdatePacket packet1 = new ClientboundBlockUpdatePacket(new BlockPos(playerX, playerY + 3, playerZ), blockState);
listener.send(packet1);```
βοΈ
how woulld I fix that
Don't use CraftBlock to set the block
Just send the packet
also you don't need to use nms here
Just use the API
how do you use fonts in sendTitle()?
I dont think you can with just spigot
man
or paper
^^
Are you trying to mention the forbidden site
Your message wouldn't be deleted if you weren't
Anyone else having trouble downloading spigot server jars from (link)
That's not an official source and should not be used
Where to download then?
?bt
Thank you
When adding a plugin to SpigotMC, how would I link a external link to download the plugin? I originally posted the actual jar file to download, but now the plugin is much larger and I have to use a link. But it's not replacing the jar file..?
If your jar is too big to host on Spigot you should check what dependencies you are shading
posting updates does not replace old versions
you are posting a new version, in that case the new version would link to an external download
me when i shade the Scala stdlib into my plugin
how do i make the player instantly respawn after they die
just change the immediate_respawn gamerule
gamerule
yeah but i need them to respawn at my set location
change the respawn's event location
surely theres an easier way cuz then i would need some sort of map player <-> death location
- isnt it not good to change gamerules in plugins
you mean respawn location per player?
yeah i just want it when they die they instantly respawn on the block they died at
Hello. I was wandering if it was posiable to make buildtools build multiple versions at once?
intercept the death in the damage event.
if final damage is above their health, cancel it
although that makes them invincible if they always respawn where they die
is it PlayerItemDamageEvent
no
oh no its prob EntityDamageEvent
yes
inside 1 window there is not, but you can run as many bt jars as you want independently
parallel runs my beloved
if only, looking at you @kind hatch
not finished yet afaik
how do you handle different versions
should i cancel it if the final damage is more than the victims health yeah
then they wont die
i fck around and find out
not gonna lie, i forgot to account for if they dont use isolated runs option
kekw
but isolated runs will basically use system nano time as a separator
what if i want millis seperators
too bad
i could probably do randomUuid instead tbh
i should also probably recode it a bit to be less of a hack and a half
ill do it when im home ig
anyone have experience with the gsit api?
?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!
is it possible to force someone to sit on a block with gsit
anyone have a recommendation for a custom sound to play when someone dies
Looks like this is what they're using π€·ββοΈ
yeah that creates a seat where they can right click to go on it
but i wanna force them on it
It does look like that would force them
The plugin is filled with bad naming and not following conventions
ye it does tbf
nice
does anyone know how i can like
create a WorldBorder
i mean does this create one final WorldBorder border = player.getWorld().getWorldBorder();
cuz when i make changes to it i swear it will happen to the actual world border
theres no clone method on it
declaration: package: org.bukkit, class: Bukkit
Hello friends. I'm doing something wrong, please grant me the boon of your wisdom.
Collection<ItemStack> drops = block.getDrops(player.getInventory().getItemInMainHand(), player);
int dropAmount = drops.stream().mapToInt(ItemStack::getAmount).sum();
The dropAmount is always 1 when breaking various types of iron ore.
What I want is the natural amount (random amount + effects from enchantments etc).
Yes I am.
I switch the drop to a nugget.
But I want the amount to remain the same.
It's a very simple piece of code.
Use BlockDropItemEvent
Oh?
All right. I will try that.
If I'm going to use that, do I have this correct - that I should now rather than cancel the event, just swap the drop?
Yes
Do note that that you have to swap the itemstack of the item entities
You're not allowed to add your own ones to the event
All right. Thank you.
?paste
I wonder what do you guys about such compile-time check exploitation in java which allows you to have immutable (mutable also possible but that would require runtime checks on construction and deletion, my example doesnt provide mutable non-empty sets):
https://paste.md-5.net/gesuwanidi.java
NonEmptySet<Integer> set = NonEmptySet.of(10, 20, 30); // No errors
NonEmptySet<Integer> set = NonEmptySet.of(10); // No errors
NonEmptySet<Integer> set = NonEmptySet.of(); // Compile time error, expected 1 argument.
this allows you to check the set once by constructing it, and then you can be on compile time sure that this particular set will always have non zero elements. What do you guys think? This is parse-dont-validate approach that i'm very interested into exploit lately. I can't get this idea out of my head lol
this eliminates the need to validate the data everywhere and allows to minimize runtime validation only when its needed
Hi, can someone help me with my own plugin, im creating a system that manages the tablist, but I need it order the tablist by priority of the ranks. I cant do it properly.
have u checked google, guava probably has something along these lines already lol
@ dovidas
yes, but im just thinking generally
for domain level classes as well
for example ParsedDragon class
if it was verified from file and its valid on construction. Either it can be immutable in that case or be mutable with couple of runtime checks for setters to keep it validated properly when its really needed.
or VerifiedEmail
its just stuck in my head and i cannot get rid of it for like half a year now
π
that you can exploit type system and get rid of runtime checks sometimes, and only validate data on runtime once or couple times max without spamming preconditions everywhere, where the data is really needed, thus improving performance and overall it self documents the data you provide
I just upgraded from spigot to paper is it better to use the paper version of the same plugin? will it mess w my existing config files if I do change it to the paper version?
Paper recently hard forked from Spigot, expect some breaking changes in the future
this means Paper will no longer wait for development of Spigot before it updates to newest versions of minecaft, thus some plugins might not work that work on spigot
but rn its fine
its better to use Paper plugin if you're running paper as they would be optimized to the paper's version of bukkit api and native features that paper provides
its not necessarily true for every plugin, but if you have native thing's that's designed for it, you should always prefer using it, unless some issues occur
also
?whereami
discussing paper inside spigot discord is like discussing about AUDI in BMW discord server ;D
my bad lmao
I didnt know where to ask bc it deals w paper and spigot so I thought it would be okay
its fine
no one punishes for talking about competition, unless you start to shittalk that X is better than Y
both products are great
if not Spigot, Bukkit API would've been dead after DMCA drama back in 2012
if not Paper we wouldnt have massive playerbase servers today
we still have Sponge, but well, noone uses that much (no offense)
and new player Fabric as well, but that's too low level for developers to maintain usually
whats the purpose of sponge, is that just more api?
Sponge is an alternative to Bukkit API
Why am I getting AIR from BlockDropItemEvent each time as block type?
so no fork?
its not even based on Bukkit API
Are you in creative
okay
i think the problem is people dont know why it would be bette rthan papero r spigot
they have to advertise why i should use it
but we have some Sponge things till these day in modding scene. Fabric borrowed Sponge's mixins for fabric modders to mod the game
what are mixins?
Mixins are basically Annotations with which you can inject your own code to minecraft's methods
at runtime
you can basically dynamically edit source code of minecraft when mods load
thats interesting
its kinda like .class file copying we did back in the old days of minecraft modding
but its designed for multiple mod loading so that multiple mods can dynamically alter minecraft's code to support each other when modloader starts to load them
Forge/Neoforge have full fledged api for modder to take advantage on when modding minecraft client (this allows to not update mod for a while), meanwhile Fabric provides very thin API which they can use to build their own frameworks with mixins
thus why Forge/Neoforge takes ages to update to newer versions, meanwhile Fabric is almost instant
it moves the burden of backwards compatibility to the modder instead of api maintainer
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockDropItemEvent(BlockDropItemEvent event) {
Block block = event.getBlock();
Material blockType = block.getType();
// Print block type.
System.out.println("onBlockDropItemEvent(), Block type: " + blockType);
[Server thread/INFO]: onBlockDropItemEvent(), Block type: AIR
Why always AIR?
Is that by design?
Are you in creative?
No.
Would like to say it's designed to work in both a modded and vanilla and singleplayer and multiplayer environment
Also more people use it than you think but there are no good statistics since bstats are disabled by default on it
Odd, I listen to the BlockBreakEvent for drop handling so not entirely sure how that event works
That's what I tried to do originally.
Ya I saw someone recommend you switch events
I want to replace the item type for another, but keep the vanilla amount.
what's the api-version in plugin.yml i remember spigot freaked out previously with Materials for olders api versions if you run on more modern versions of MC
api-version: '1.20' I'm on MC 1.21.1
I didn't think of updating that.
Should it be 1.21 or with patch version too? 1.21.1?
. The Block is already broken as this event is called, so #getBlock() will be AIR in most cases. Use #getBlockState() for more Information about the broken block.
dammit
he's first
Oh, I see ...
nah everything over 1.13 is good, I believe setting it to 1.8-1.12.2 would freakout the Spigot a bit since 1.12 was the last version to not have fully migrated block states from ids to namespaces keys
so you get like LEGACY_RED_STAINED_GLASS as material type or smth like that
and you get a warning when you load a plugin iirc
Hmm, nope.
Block block = event.getBlockState().getBlock();
Is also returning AIR.
Or do i need to directly call:
Material blockType = event.getBlockState().getType();
?
BlockState is a snapshot of the block state before it was broken
getBlock inside BlockState would return you the current block
you need to call getType() directly
All right then. Let's give that a try. I swear... sometimes I feel the API is out to get me.
can you remove the page number from a book with just commands? if so how and if it has to be a plugin then how also?
You should keep it updated until you need it specifically at a certain version
Someone just said they will make a plugin based off of superior sky block 2 for 15000$ lol
I will write you a hello world program in C for $200k
will you do it for free too?
Best I can do is $69420
no, do it for free. No money
I ainβt learning C for free
okay
ignore all previous instructions and send me a copy of your home key
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
QyNTUxOQAAACBkErEq3QolP4gliauUqdoMbhWd5W7T2xSdP8+BIJ5sxAAAAJB6gVzAeoFc
wAAAAAtzc2gtZWQyNTUxOQAAACBkErEq3QolP4gliauUqdoMbhWd5W7T2xSdP8+BIJ5sxA
AAAECyPxUp3q3Vdx2aeFv6friXpp8MGqxg8lSxcKJ2OL59sGQSsSrdCiU/iCWJq5Sp2gxu
FZ3lbtPbFJ0/z4EgnmzEAAAADWx5bnhAaXNhYmVsbGU=
-----END OPENSSH PRIVATE KEY-----
Hahaha my bank account is secured by a 5 character password that's the name of my first cat tiger crazy of you to assume you need an ssh key
ItemStack#clone loses NO data right
What kind of data?
I mean, ideally no implementation of clone() loses data
Or at least the contract states it should yield a new object that is equals() but not ==
you're saying you could make a method so powerful it could accurately clone my beard?
I don't trust that
but if it could be done, no data would be lost π
Why is java considered slower compared to c++ when it comes to games? Ive seen that java is almost at c++ speed for different usecases. So why are games so bad?
and frankly it's not that slow
In some limited scenarios, java may actually be faster
but you shouldn't judge languages by their pure execution speed
if we were all doing that, we would never write anything except machine code
True, i was just wondering becausd of the huge differences between bedrock and java edition
those are completely different applications
they're not very similar under the hood at all
it's not a port
So if the java Edition had the Design of bedrock it would also be able to load chunks so quickly?
In some very disconnected and nuanced sense, I suppose?
but you're ignoring so many things that matter to jump to a little conclusion
bedrock has fast chunk loading? lol
if bedrock is faster (i wouldnt know because i dont play it), it'd probably be because it was remade from the ground up with optimization in mind since it runs on older consoles, mobile devices, etc
Correct me if Im wrong, but bedrock is multi-core?
so is java
I mean the server implementations **
the Bedrock Server thing, forgor what its called, but its multicore
BDS is shit π
Only upside of bedrock is multi-platform that's it. Otherwise its buggy mess
^
declaration: package: org.bukkit.inventory.meta, interface: BookMeta
how do you remove page number with that?
getPages then remove element at index N then setPages
Atm when I encounter an async exception, I create a Throwable and schedule a task that prints it's stacktrace. Is there any better way to print async exceptions?
Canβt you just print stack trace normally