#help-development
1 messages · Page 1257 of 1
that said, final in my mind is one of those things that ought to be used sparingly and only when needed, with the exception of fields which should be final by default
final classes and final methods usually don't make sense, except when they do, and that's usually fairly clear design-wise; for example a doThing method that overloads to a final or private doThing0 so that you can both allow extension (by overriding doThing) but be certain that sensitive logic (doThing0), when called by you in this class, works exactly as expected
my mind tells me if you want to override something from a class which already has implementation, you should replace inheritance with composition
im not saying that it should be used everywhere but lets say if you know that these values are only for public access, are immutable but also used internally, it can be good way to enforce that implementations would not touch those variables and getters, thus prevent nullability issues that might occur in buggy implementations
you shouldnt patch the code from the inheritance, you should edit source code if you see that it bothers you how it works.
ofc not everytime this works, especially with legacy applications where we need shady hacks to do we want because code is riddled with tech debt
one example would be getter for retrieving name Player#getName() of the player, you shouldnt override that variable, because that might mess with various classes which depend on that, so you might as well make that method final in abstract class and not let implementations of Player touch neither the field, neither the getter, but let them use that variable for read access only from subclasses
imagine if OfflinePlayer overridden getName() to one thing and OnlinePlayer to be something else. Its clearly a field that shouldnt be mutated and only be handled from base class
funny you should take that as an example because this is exactly a case where this doesn't hold
OfflinePlayer's aren't guaranteed to have a name; getName on an offlineplayer can actually fire a blocking network request to mojang to resolve the uuid -> name association
im not talking about minecraft in general
whereas for (online) Player it's a fixed value
yes, but it is a counterexample of how assumptions about subclass internal behavior can fail down the road
generally the assumption is that the implementor is competent
beyond that as long as they follow the documented specification of the method/behavior they're overriding, everything's fair
but having something that nags you when you might do something wrong is kinda nice tho
"something wrong" is very difficult to define programmatically
the best we have are probably flow/contract annotations
my main point is that api contract should define as much as it can by itself instead of relying on javadoc comments
by preventing errors that might occur by hacky solutions
instead of editing the source code
that's what annotations are essentially, they're javadoc comments that the compiler/linter can read and emit warnings about programmatically
the difference to the final keyword is that it doesn't nag, it outright stops you from doing things
which very easily slides into nanny protectionism rather than anything productive
if it's critical that the behavior not be overridden/changed, it should be final
if that's the case why most implementations use final keyword for private variables
if it's non-critical then it's better to opt to be more flexible and assume the implementor is competent
isnt that nanny protectionism
fields are quite a bit different from methods
like i noted at first, fields should be final by default
sure you cant inherit them, but still the point is that you emit errors to not mutate them, the same is done with method but from inheritance perspective
self describing contract in a sense
not only mutate, but making them final also ensures that they are initialized
e.g. take a class with 8 different constructors
labeling your fields final ensures that each constructor assigns each field exactly once
labeling fields final also enforces stricted read-write ordering because the compiler can have perfect information about whether the field has been initialized at the time of being read or not
and compared to e.g. making all your methods final which prevents extension outright, there are very few drawbacks to making fields final
im not proposing to make all methods final, only immutable data getters
like record data
in c# you have this
what if you're making a library and cant expect to be everyone competent enough who uses your lib
what if someone wants to for example add a last-accessed timestamp that gets updated on read? the whole point of having getters for fields rather than making them public and final is that you can slide arbitrary logic in between the read and the access
you could argue that nobody needs to do that, and it is a fairly contrived example, but it's better to assume competence and allow extension than disallow it outright
because needs and applications will arise that you can't foresee
if everybody was competent enough we would be using c till this day. there's a reason why abstractions and high level syntax exists. mainly encapsulation in OOP and ease of use
anyways good discussion
C? Why not assembly
there's no clear answer anyways to this, it depends what kind of code you write. imho if you write a lib, that someone would use externally maybe you're right but if someone writes code for internal processing where data safety makes sense, maybe im right idk
punch cards
like with all design and paradigms and this nonsense, being consistent is more useful than being right, because no two people are going to agree on what right is
i stick to my view that final is something that ought to be used sparingly only for critical things, but sure if your entire thing is critical it probably should all be private or final; be judicious and try to find a principle that fits and then stick to it
im learning assembly right now and this shit is annoying as fuck
Just do better
7. Invalid mov Instructions - Explain why these instructions are
invalid in a 64-bit assembly program.
a) movl %eax, %rdx
b) movb %di, 8(%rdx)
c) movq (%rsi), 8(%rbp)
d) movw $0xFF, (%eax)
😭
Because they don’t pass the vibe check
vibe code the test
whatever
heyy i need some help with making NMS clones
elaborate ?
I don't exaclty know what to imagine under "NMS clones"
So basically I need a clone of a player to lay on the ground in order to simulate them being knocked out
and the player should be invisible at that time
but i cant seem to find any docs or anything helpful at all
for 1.21 btw
If you don't want to cause yourself painful pain, use Citizens
yeah i probably will
or libsdisguises
comes out of the box with a "copy player with all equipment+cape+whatever" facility
and yes i will continue to shill libsdisguises
Isn’t that the one that doesn’t have half its source on GitHub
Huh? I don't think so
i think that was PlayerLib or something
or PlayerNpc
Ah
This one is entitylib
Yeah this one seems to be actually decent
how do i get entitylib working in intellij idea
how do i use clientboundaddentitypacket to respawn the player? i tried this constructor, No matching static constructor: ClientboundAddEntityPacket.<init> called with (4485 (Integer), *insert uuid here* (UUID), -28.92 (Double), 96 (Double), -44.5 (Double), 7.95 (Float), 93.75 (Float), minecraft:player (EntityType), 0 (Long), x: 0, y: 0, z: 0 (Vector), 93.75 (Float)), i also tried creating a new serverplayer with server, level, gameprofile, and clientinformation yet that didn't work either
ChatGPT? *insert uuid here*
i removed it myself... lmao
also that's an error message, so it would make no sense for chatgpt to generate it
the add entity packet constructor has changed many times over teh past few months. It really depends on teh version you are compiling against
also, that error seems to indicate you are using some lib or reflection to build your packet
if a Lib make sure it is updated to support the version you are building for
alright, i'm fairly certain it's up to date for 1.21 (my version), and i have all the information it says is needed on the mc protocol page as well as 1.21 nms mappings site, maybe i'm missing something idk
whats wrong with Player.Spigot#respawn() ?
i sent a clienside respawn, so i have to readd the entity for others
i guess i could just use that
I need some help with entity lib please dms
people aren't going to personally give assistance in DMs, at least not without pay
just ask here and wait for an answer
use libsdisguises
💪
lib has a dedicated support channel on the mythic discord
which i think is a shame because mythic is cancer, but he does very actively answer questions and help with the api and command usage
thats what im sayin
i hate support thru dms
cos 1. usually need to send a friend request, n then 2. i forget to unfriend these ppl like 99.99% of the time
and now i have a friends list of 400 when i talk to maybe 3 people
Hi, I have a rather important question. If I have a plugin for eggwars (I'd be glad for a recommendation) and for example in npc I click on start, I would like it to port me to such a pre-lobby where it will wait for players, select teams, select kits etc. or how to say it and the question is whether the pre-lobby is in the plugin of eggwars or it is done separately.
Thank you for the answer
My issue with it is mostly that people become entitled when you personally give help, instead of using the proper channels they’ll directly ask you for anything, even things I might have no idea or couldn’t be bothered to answer
It’s fine if it is a friend, but it is just weird to take that burden for someone you barely know lol
Is this a development question? Are you making a bedwars plugin?
yea its a devlopment question for 50/50
If that’s the case, it really can be either way, if you have found an egg wars plugin that doesn’t have a pre-lobby and want to add that feature within a separate plugin, as long as the other plugin gives you enough leeway to intervene with its lifecycle, it should be fine
But if you’re making an egg wars plugin from scratch, I’d just have the functionality from the get go
What’s good about eggwars is that you can also just take any bedwars plugin and configure it to work for eggwars lol
okay thanks
I am trying to use the spigot API, and i have it in my refrenced libraries but I cannot use anything with it, like I am trying to extend JavaPlugin but its not showing up
How are you importing it? Are you using maven/gradle?
https://paste.md-5.net/jibudehoci.makefile
Hello, I currently am making a minecraft plugin and I want to publish it into my maven local and when I do the publishInMavenLocal task, it works fine and it creates folder but I can't import it anywhere...
maybe youre right its better to give implementors full control on what they do, but leaving safe access for public contract
in either case you can fuck up the implementation in other places even if you did force final for getter methods
its just not worth to keep final methods for such things, as you can write bad algo anyways and no matter if getters are correct or not it will fail
Adding external jars
I’m new to all of this stuff so I’ve heard of maven but I don’t know what it does or how to use it
in very rough sense maven is just a glorified java library downloader from internet
allows you to add libraries to your java project, by just declaring what you need inside pom.xml file and it will auto download that for you from maven central repository on the internet
Oh ok, I’m not home right now so I’ll try to set it up later
Is it pretty straight forward
its mostly copy pasta boiler plate
but you can also set up other things to do with maven, for example package your application under .jar file
preprocess files, like variable interpolation where you can substitute placeholders with values in files
its just a build tool for java
currently there's two popular build tools for java development: maven and gradle. Most spigot projects use maven build system, but for example Paper uses gradle
Ok ok, but js for referencing do you know what I could be doing wrong? I took the spigot jar straight from the server to add to the external library
i prefer gradle, but its easier to learn maven
you shouldnt do that, you need to declare spigot-api dependency inside pom.xml file
and it will automatically do that for you
the point of maven is that you can reproduce the same builds over accross different systems, for example you can setup git repository and put it on the cloud and anyone else who clones the repository will have all the libraries downloaded that are attached to pom.xml file
Oh ok
note that NMS is not included with spigot-api dependency so if you depend on that you should look for buildtools tutorial
I already set up a test server with btools in it
I just needed to make my first plugins
i suggest you just use spigot-api dependency
for now as it includes like 80%-90% of what you need mostly anyways
I was following a tutorial for a simple hello world one, but I couldn’t get the spigot to work which is why I am here
Instead of the jar?
Ok cool, is a tutorial needed to set it up or will it be real easy
thats how mostly pom.xml should look like
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
Also what’s the difference between intellij and eclipse
I understand but is one objectively better?
which can catch bugs
I prefer the eclipse look
Intellij is free and community version is open source
and its usually better
but it eats ram like its nothing
it can eat like 3GB of ram on idle on certain projects
due to how it indexes the whole project
and analyzes code
its heavy but nothing better is really compared to that IDE
(Eclipse is also free)
I was abt to say cuz I have it installed and was using it
Eclipse also suck. Last time i've used it, extensions were broken
i mean official build ships with broken marketplace
never used it after
intellij is literally all you need
works for me
I’m just trying to do simple shit, and I know the layout already cuz I used to do this stuff a while ago but I forgot almost all of it
Eclipse is fine
Is maven different to use on eclipse and intellij
no, just the interface
maven is a command line tool
but usually ide's integrate that tool with fancy GUIs
to make maintaining a java project less a hassle
by just clicking things instead of writing the commands
honestly i just use command line at least for gradle
i hate those buttons
at least terminal gives me consistency across different environments
same with git for me
probably overthinking this...I have a system similar to factions and I want to have some various settings on the Faction object such as power, some misc settings such as leaf decay/future settings. I was thinking about three different options for implementing this...
option 1) in the main class, standard
option 2) map of config options attached to the option so option-id as the key and value as a string in the map
option 3) separate class for settings such as FactionSettings with the variables and getters/setters then store this in the faction class
thoughts? I was leaning towards the FactionSettings class, map seems overkill, but it allows for flexibility later on
main class IS NOT standard
the Faction class having the variables?
yeah
iirc that's how I saw others do it
doesn't adhere to the single responsibility principle
Map is the best approach as it allows for custom settings made by third-party plugins
Make sure your generics check out
now to follow up, I was thinking about creating some classes to simplify the serialization/deserialization/validate process such as Integer setting, String setting, etc for the map stuff that would validate the input and auto convert to/from the string, would this be overkill or no?
so like Map<String id, Setting object which is the parent for String setting/integer setting>
eh strings
the way we do it at work is with a "typed key" / codec system
think of the following
public interface FactionSettingKey<T> {
String getName();
FactionSettingCodec<T> getCodec();
}
public interface FactionSettingCodec<T> {
T decode(Container or whatever);
void encode(Container or whatever, T value);
}
public interface FactionSettingContainer {
<T> T getValue(FactionSettingKey<T> key);
void setValue(FactionSettingKey<T> key, T value);
...
}
gotcha so the container is the faction object?
oh so like the separate FactionSetting class
Yeah
You can then yeet all your builtin keys into a BuiltinFactionSettings class
or something similar to that
FactionSettingDefaults type deal
interface enum hack?
I did, but it's just so convenient
public final class FactionSettingKeys {
private FactionSettingKeys () {}
public static final FactionSettingKey<String> WELCOME_MESSAGE = FactionSettingKey.create("welcome-message",
FactionKeyTypes.STRING);
}
type deal
yeah I got what you mean
it's somewhat limitless and you get to yeet it all into a map in your setting container class
I'd also make a value holder to differenciate between not-set and null
it also makes it convenient for codecs and defaults
public class FactionSettingValueHolder<T> {
private final FactionSettingKey<T> key;
private T value;
...
}
then your map is exclusively Key<?> to ValueHolder<?>
and the generics check out
I've made like a dozen systems of this style at work
Yeah seems really convenient
it CAN eventually get really annoying when you start having different subtypes of Number and you need to do math between them
(for example adding 12% (float) to a base value of 10 (double))
but you can just keep going with generics until it works out
Understandable, I don't think that would be an issue with factions stuff
Oh, definitely!
where you have a 35% durability modifier on an item that also stacks with whatever
yeah all the rates and modifies for an rpg since there's so many xD
well now I get to start coding again, thanks again
cheers
cheers
Illusion
Are you the one that made the modern way to handle inventories post
Oh no, that was mfnalex
Byte
thx!
ah yeah
I was going to ask if there's any difference now with the API prioritizing handling of inventory views rather than inventories
whats the event when a player picks up a shot arrow? Like someone shoots, it falls to the floor and someone picks up the arrow
try with EntityPickupItemEvent
yes but this only works with items, not the shot projectiles. I have been trying
declaration: package: org.bukkit.event.player, class: PlayerPickupArrowEvent
thank you
I don't know why I thought that event was deprecated lol
Child of a deprecated event, so fair assumption
It's not deprecated though. Works fine
I am using it, but I think it doesnt work because I am using spectral arrows, is there one for spectral arrows
it should work for any arrow
no
well you can't pickup arrows in creative either
@EventHandler
public void onArrowPickup(PlayerPickupArrowEvent event, Player player, Item item, AbstractArrow arrow) {
getServer().broadcastMessage(ChatColor.RED + player.getName() + " picked up the basketball!");
BHandler = player;
}
its not broadcasting
I don't remember, it's been a while since I played MC lol
that isn't how you use events
myf bro pls help me out
remove all method params except the event you're listening to
ok
it's better if they just read the wiki for it
yeah but in this case it's an easy fix
you're assuming they've properly implemented Listener for that class as well as registered the listener to the plugin manager, though
ig
ill try later
well I have a first listener that works
@EventHandler
public void onProjectileShoot(ProjectileLaunchEvent event) {
if (!(event.getEntity() instanceof Projectile)) return;
if (event.getEntity().getShooter() instanceof Player) {
Player shooter = (Player) event.getEntity().getShooter();
getServer().broadcastMessage(ChatColor.RED + shooter.getName() + " shot the basketball!");
}
}
This one works
unsolicited advice: there's no need to check whether the event entity is a projectile as that event overrides getEntity accordingly to only deal with projectiles. Also, since I assume you're using a newish java version, you can do instanceof pattern matching to "avoid" the cast
ok
also I know how to register a listener inside the main class, but how would i do so when it is in a seperate class?
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
wait so does using uneccessary params break the listener?
ok good to know
@sly topaz @jagged thicket~~ wow it worked~~
tysm to both
no wait
i think is from my playerjoin implementation
💀
ill do it
yea didn't work
i give up
lol
ill use my playerjoin stuff
:sadge:
sadd
is the same problem happening
even with using longs
yea
that sucks
i give up
i was so happy to see orange there
then i remember that i fixed it using pjoin event
@manic delta
when a problem is too cooked i give it to chat gpt
and do you think it is speaking the truth
yah it kinda makes sense
Yeah i figured out the problem
The thing is the pets are loaded only during player join event but
see the pets are loaded only in playerjoin event after 20L
but , PlayerChunkLoadEvent is called before the 20L
so the initial chunks are not getting counted
@manic delta
i think the proper way to handle this is using AsyncPlayerPreLoginEvent
Kt 😢
What.
the weird part is like
it used to work
one version prior / the gui on my spigot account
50$ and i’ll remake it in paint
hardcoded blood particles for entities loosely based on what i think their blood would be
ie. creepers have tnt particles, nether mobs have lava particles, etc
concern
will i make it configurable? probably not
resolution

fixed i guess
maybe i compiled a version without flatlaf setup and didnt realize it
my maven package is adding -shaded to the output name D:
couldve sworn i specifically disabled that..
I DO??
maven moment
if I save a Player object to a variable, then the player disconnects, can I still use player.getUniqueID() or will that not work?
Maybe, not really sure. I mean it’s all sort of undefined behavior after the player leaves
Why not just get the UUID before
?tas
trying it won't help you with a bunch of UB and edge cases
just realized how scuffed mine is rn
I'm just making an impl of shadows designs
mine is sadly part of the inspiration for the official
made the silly mistake of trying to actually use List<Integer>
silly me.. ambiguous calls for .remove 
i could track processes with a UUID instead of an int... 
i have a list of "processes" and i was just tracking them with an int lol
are you currently using pids
...yeah
don't see an issue with that
List#remove takes either Object or int(for index)
removeIf 
and when my type is int i guess autoboxer shits the bed
couldve sworn ive written something like this that did work, but it honestly mightve been in C# lol
i think c# List uses removeAt or something
unironically might
i could name the process instead ig
like task-{ID}
or just .toString the pid itself
i also need to make a system that takes a snapshot of the users current config
bc i realized i could change an option mid-process and affect output functions
this is autistic but fuck it
just implement Cloneable 😭
true
ok it looks slightly less autistic with a copy constructor
Anybody know of a good conversation api
they said good
Anyone wo wants to develop for some money?
?services
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/
WHAR
portablegit install x18 ish
had to make sure my task counter worked lol
can I display a 1994x1994 bitmap?
Wat
well
you see
I have a txt pack
and a 1994x1994 bitmap
and well
it doesn't render
might be too big
doesnt minecraft have a max texture size limit
like wtf is the height?
You can split it into multiple characters though
okay, but still
never understood it
the wiki
also doesn't clear it up for me
It defines how tall the character should be when rendered in game
Generally you want it the same as the height of the actual image or you’ll get ugly squishing/stretching
good god
nope
is there a way to tell if player joined with a custom client? are there packets that custom clients send to the server?
hm
it can be spoofed so easily that it is not useful
dQw spotted
lies
use https://orang3i.com
instead from now on
no
Does the item model component support any kind of fallback
Aka if the specified model isn’t found it’ll show as a default item rather than a missing texture
not that I'm aware of
Poop
you could use the actual fallback as the item and set the model
or, no, nevermind
that wouldn't work
That’s unfortunate
Does custom model data default to the standard item if the custom model isn’t found?
I seem to remember it did but that was the old custom model data
"are you a terrorist?" airport question vibes
that actually reminds me I was also going to give it a go, wasn't I? Lol
what did I even say I was gonna make it in, I don't remember
I think tauri
I started working on one in Tauri a while ago as well
Had a working version selector and runner with logs
@ xpdz make one in electron
its your time!!!!
use your frontend skillz
ok fk it ima make it in electron fr
time to learn front end
can anyone explain why this happens?
Is that a class from a dependency or the same project
same project
idgaf about my windows username lmao
so why do you care about your github username
cuz its my actual name
if you don't want people to see that, then don't use that as your username 
yk what lemme just change it rq
it looks like you manually imported a jar and did not add it as a dependency
Your IDE sees it but maven can;t
if its on github.....not sure why you would need to sensor it here? its public already
You mean gregory?
anyways not like even if people on the internet knows your name makes a difference in anything
I mean there is like 100+ countries
197, +/- 10 depending on who you ask
yeah, and if your named steve
no one is going to find you
there is like a million steves
lol
Good evening, handsome guys!
May I ask how to use ProtocolLib to send particle effects to players?
I used the method given by the AI, but it seems like it doesn't work.
public static void sendFakeExplosion(Player player, Location loc) {
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
PacketContainer packet = new PacketContainer(PacketType.Play.Server.WORLD_PARTICLES);
System.out.println(packet.getModifier().getValues());
packet.getIntegers().write(0, 15);
packet.getBooleans().write(0, true);
packet.getFloat().write(0, (float) loc.getX());
packet.getFloat().write(1, (float) loc.getY());
packet.getFloat().write(2, (float) loc.getZ());
packet.getFloat().write(3, 0f);
packet.getFloat().write(4, 0f);
packet.getFloat().write(5, 0f);
packet.getFloat().write(6, 0f);
packet.getIntegers().write(1, 5);
packet.getIntegerArrays().write(0, new int[0]);
protocolManager.sendServerPacket(player, packet);
}
well that shouldnt happen, there all part of the same plugin and nothing is being imported
I want to use ProtocolLib to send particle effects to a player individually, but I haven't used ProtocolLib before.
Then run clean package, or if using IJ clear caches and restart
May I ask for the link?
declaration: package: org.bukkit.entity, interface: Player
There are a couple of overloads depending on what you want to do
But I want to use ProtocolLib to make the particle effect visible only to one player.
the API allows you to send particles to one player, or the world
But the version I'm using is 1.12.2
And I want to try using ProtocolLib because I've heard that this plugin is very powerful.
It is
but it's also not easy to use and is highly version specific
(depending on what packets you use)
Thank you for your help, I will try using Bukkit.
I tried it, and it really works.
double offsetX = (Math.random() - 0.5) * 2;
double offsetY = (Math.random() - 0.5) * 2;
double offsetZ = (Math.random() - 0.5) * 2;
// Send particle
player.spawnParticle(Particle.HEART, location.add(offsetX, offsetY, offsetZ), 0);
// Restore original location
location.subtract(offsetX, offsetY, offsetZ);
Thank you!
ohhh
WAIT
THAT MAKES SENSE
i dont know why did i put that 20L
kotlin is good
If the player.spawnParticle() method is used asynchronously, will it cause errors in higher versions?
isnt there a way to load Player in AsyncPlayerPreLoginEvent?

wait leme see
i dont think Bukkit.getPlayer will work
because the player is not even there
i can try tho
no you can't i think
so do smth like pre loading the data into a temporary list
or map
yeah i don't think so because the player would have loaded the chunk as soon as the playerloginevent fires
so race condition blah blah blah
alright
See, the problem is the PlayerChunkLoadEvent probably fires before PlayerLoginEvent
that is the problem here
orange is here
congrats
CONFIRM THAT
lol
yeah
LETS GOO
I did nothing but you're welcome
I will never make pets again
so the problem was that the pets were added to petsbychunk after the PlayerChunkLoad event fires because of 20L
yea lmao
yeah I was following the convo
i dont remember why i put that 20L lol
i gave it to fucking chat gpt and it couldnt figure it out
could've caught that if I had actually taken the time to read the code carefully, but my eyes get itchy when I read kotlin
chatgpt was a smart move, it can do the reading for you
hahah fr
kotlin is good
but at this point chat gpt couldnt help
i moved from java to kotlin a weeks ago
I don't remember but I know it was for something
ok ok
in memory of the two
Nicee cars
now smth else is gonna break because of that 💀
is this some convoluted way to call me a discord kitten
probably
why is it on spanish btw
yes
because im spanish
lol
makes sense
damn they died
what is the very complex tag beside the bracket
are u gonna release this on hangar?
is it measuring code complexity by the number of branches
Probably
I want to write a method
public void showParticle(Player player, Location corner1, Location corner2),
which will send a particle effect in the form of a cuboid based on these two coordinates. However, the only approach I can think of right now is:
public void showCuboidParticleEffect(Player player, Location corner1, Location corner2) {
double minX = Math.min(corner1.getX(), corner2.getX());
double maxX = Math.max(corner1.getX(), corner2.getX());
double minY = Math.min(corner1.getY(), corner2.getY());
double maxY = Math.max(corner1.getY(), corner2.getY());
double minZ = Math.min(corner1.getZ(), corner2.getZ());
double maxZ = Math.max(corner1.getZ(), corner2.getZ());
for (double x = minX; x <= maxX; x += 0.5) {
for (double y = minY; y <= maxY; y += 0.5) {
for (double z = minZ; z <= maxZ; z += 0.5) {
Location loc = new Location(player.getWorld(), x, y, z);
player.spawnParticle(Particle.HEART, loc, 0);
}
}
}
}
This approach may cause lag. Are there better ways to prevent multiple packet sends?
No
There is no way to send multiple particles at once?
Can it be done using ProtocolLib?
I mean, the particle sending isn't the part that's gonna cause lag
yes
is that for me?
do you need to fill the whole cuboid? Or just the outline
probably the outline
maybe i can implement that to my lib
I only need to draw the outline.@sly topaz
i had 100% kotlin before adding bstats metrics lol
yeah
@jagged thicketrate my lib from 1 to 10 lol
i know it sucks thats why 1
i have my docs page
7.5/10
-2.5 for no documentation
Yes, not everything is documented yet
what I would do is precompute a cuboid unit then just scale it up as necessary when it comes time to spawn it
this one is the most cool https://github.com/system32developer/SystemCore/blob/master/src/main/kotlin/com/system32/systemCore/utils/minecraft/ChatHeadUtil.kt
but the current way you're calculating the cuboid is inefficient if you're only looking for the outline, you'd want to loop over the coordinates and only add the edges of each
This seems like a good idea. I'm thinking if it's possible to control the movement of particles to draw the edges of the cuboid, thus reducing the number of particles.
yep that do be cool
yep it worked, thanks
the number of particles would only be an issue if you plan to show too big of a cuboid
and the only way to reduce it would be to make the step/spacing bigger
@sly topazIs the spacing the distance the particle moves? How can I make the particle move?
no, I mean the literal spacing between each particle from location to location
since you can spawn particles with a precision of 2 I believe, you could spawn a bunch over a single block
Do you mean making the particles move from one location to another, thus reducing the number of particles used?
your current code spawns one every half-block, meaning it is 2 times the amount of particles if we take blocks as point of comparison
I see what you mean, reduce the number of particles along the path.
Is there a way to make the particles move from one location to another?
not really, no
some particles have a speed parameter but they don't move that much, and not every particle has a speed param
Alright, thanks for your help
when shot by an arrow in entitydamagebyentity event, how would I find who SHOT the arrow? Because I am finding what arrow hit them by getDamager() so what would it be for the arrow shooter?
getDamager to get the arrow, cast to projectile, getShooter
I was going to make an example for this but ended up playing around with javafx to test it lol
And then check if the shooter is an entity
hi, it appears player.isInRain() returns false for when the player is in snow (its raining and player is in snowy biome), and there is no isInSnow method, what should I use?
there is no isInRain method as far I am aware
nvm then its a paper method
@sly topazCan I add you as a friend?
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/
?services
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/
I don’t really add people I don’t know as friends, sorry
omg you know me then
Who are you
stranger danger!
ok, I just want to make some friends here. I can only communicate using a translator.
Heyo! I'm kind of going insane right now xD My goal is to increase TNT knockback towards other TNT by a factor of whatever I desire. This is the code I tried to use. It detects player knockback but not TNT entity knockback. Any help would be highly appreciated
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void TNTKnockbackEvent (@NotNull EntityKnockbackEvent e) {
if (!(e.getCause() == EXPLOSION))
return;
System.out.println("We have an explosion: " + e.getKnockback().toString());
// Increase knockback by factor provide from config
e.setKnockback(e.getKnockback().multiply(TNTKnockbackFactor));
}
hey, is there a way to simulate a player damaging an entity with just what they have on?
so basically pretending a player just swung at a mob
Player#attack
thanks
you have a point xD Would you happen to have any suggestions on other ways I could go about this?
there's only two scenarios where a TNT has "knockback", when a plugin artificially adds velocity and when another tnt (and I believe other explosives too) explode near it
for the first one, there's no easy way around that but for the second one you can probably check the damage event and whether the damage cause was explosion?
idk if damage event is triggered for tnt tbh
but if it does, you can just multiply the velocity there
I sincerely hope it does 😭
alright thank ya Ima try that
(!(e.getCause() == EXPLOSION)) to e.getCause() != EXPLOSION
sorry, that was bothering me
ngl I feel dumb for that one thank you
I've done worse dw
check if the entity type is TNTPrimed too
tbh I don't mind if creepers also get the boost lmao
it would make any entity damaged by the explosion get a boost if you're trying to do what I think you're trying to do lol
tnt cannon range boost mainly but the entities being boosted just sounds like a funny side effect xD
didn't count for the event at all ;w;
only option left is the Block/Entity explode events then
I don't know if tnt exploding counts as entity exploding or block exploding, ig entity
Wait but wouldn’t the velocity be 0 in that moment since they haven’t been moved yet?
you could do it a tick after
kinda wack but running out of options right now lol
Cursed but definitely an option xD
Wait
Is it possible to like
Make all TNT considered LivingEntities somehow?
not possible, no
if you are using a fork I won't mention, they got a better knockback event which includes tnts I believe
isn’t that the deprecated one?
no, they deprecated the spigot event with the same name
Oh bet
I’m using that one already .-.
that one should trigger for tnts tho, ask in their discord what's that about
Aight will do ty
refactored!
can anyone help with this
gets the entity. this method may be used for retrieving the entity.
shocker
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
is this related to the skin change thing you were doing
yes lol, by not working i mean it does absolutely nothing
is there a reason you're manually removing/adding the entity?
for others
Player#show/hideEntity should do for that
^ was about to say
o
all these methods do is literally send the entity add/remove packets so yeah
though I do wonder whether it removes the entity from the tracker
also, you want to hide the entity, change the gameprofile, then show it and only then use the refreshPlayer method I sent earlier
partially finished
is there any good way to encode states into types in java or c#?
public class Chatroom {
private readonly Dictionary<string, IUser> _participants = new();
public void AddParticipant(IUser user) {
if (!_participants.ContainsKey(user.Id))
_participants.Add(user.Id, user);
}
public IChatParticipantContext? GetParticipantContext(string userId) {
if (_participants.ContainsKey(userId))
return new ActiveParticipantContext(_participants[userId]);
return null;
}
}
public class ActiveParticipantContext : IChatParticipantContext {
private readonly IUser _user;
public ActiveParticipantContext(IUser user) {
_user = user;
}
public void SendMessage(string text) {
// Ensure the participant is allowed to send the message
Console.WriteLine($"{_user.Name} sends message: {text}");
}
}
This code allows user to only send message whenever it is part of the chat only and it enforces validation only once.
This makes contract resistant to runtime invalid data since you can't input wrong player id in the instance through public methods (there's no Chatroom#SendMessage(string userId, string Text) because you can mistakenly input wrong data at runtime and compiler wouldnt give a damn and will just compile that successfully). with Chatroom#GetParticipantContext(string userId) you validate participant once and then you can send message safely at runtime.
This works, but goddamn its kinda expensive to trash around GC just for compile time constraints like these. I can see this as a problem with thousands of IUser objects, so this isnt optimal.
My question is there a better way to encode states and validations into types? I cant any info apart from resemblences to parse dont validate and state machine approaches of doing something like this?
yes
if (event.getDamager() instanceof Player && !(event.getEntity() instanceof Player)) {
Player passer1 = (Player) event.getDamager();
if (passer1.getInventory().getItemInMainHand().getItemMeta().getItemName().contains("Bow")) {
for(ItemStack i : passer1.getInventory().getContents()){
if (i.equals(Material.SPECTRAL_ARROW)) {
Bukkit.broadcastMessage(ChatColor.BLACK + event.getDamager().getName() + " has hit something that isn't a player");
}
}
}
}
Can anyone explain why nothing broadcasts
isnt this just an event?
No
That looks like some real odd code
I am new and going straight off of forum research so thats prolly why
So what's the goal here? You just want to print a messsage when a player hits someone with a spectral arrow?
I want to broadcast when he has a spectral arrow somewhere in the inventory, and a bow in the hand
the arrow marks him which is why it is important
I actually know that when it checks for the bow in hand it works, but I am having trouble implementing checking for the arrow
can someone help me? I just bought a new host bcs i played on aternos, and i want to set my old world to my new host but i cant figure it out
Did you shoot the arrow
for(ItemStack i : passer.getInventory().getContents()){
if (i.equals(Material.SPECTRAL_ARROW)) {
specifically this is breaking it ig
Don't crosspost
ItemStack will never equals a material, your IDE should have warned you about this
well it says that it has a low chance of being used, never the less I would have no clue how to fix it
Get the material with getType
ok i will try that
Can't see why you would want it to behave this way though 🤷♂️
its for a game. the arrow acts as a ball and the bow is how you shoot it. I want the ball to be passed to another player when he is hit with the bow so you dont have to waste time shooting when it isnt needed
does anyone know of any api that tracks currencies and converts them, eg. eur to usd, gbp to eur, vice versa
need to use it in my plugin
https://openexchangerates.org I believe
The original simple, accurate and transparent exchange rates and currency conversion data API.
It is
really?
I tried
for(ItemStack i : passer.getInventory().getContents()){
if(i.getType().equals(Material.SPECTRAL_ARROW)) {
But still nothing happens, maybe it is how I am looping?
it's limited to 1000 requests per month
yes
hmmm
then i need to think of something else
1000 api requests could be enough only for a few days
Why do you need to update it that often
You could even do it once per hour if you wanted to
im making a currency system and players can have different banks in the server with different currencies which is why i need a currency api (dynamically convert between currencies based on real-time exchange rates)
yea
you could do 33 request per day if you use the free plan
or 12 for every 2 hours
yeah no point in querying it that many times
yeah
Since it says it's only updated once per hour
Is this from bedrock client not allowing to view items mounted in armor stand that are invisible?
Looking for a way to give glowing effect to entity (Player or another) or block (not necessary) using only Velocity proxy.
I recommend you head over to the Paper discord
Okay, but if anyone knows the way ping me or DM.
hey how are dynamic signs done (eg.: show the player name on the sign that is looking at it)? I've done it in the past somehow, do i Need protocolLib for this? or can it be done without it
Iirc there is a Player#sendSignChange
I noticed that my scoreboard is heavier than (i think) it should be, what am I doing wrong?
Scoreboard board = Bukkit.getScoreboardManager().getNewScoreboard();
Objective obj = board.registerNewObjective(plugin.getName(), "dummy", plugin.getConfig().getString("Scoreboard.Title"));
obj.setDisplaySlot(DisplaySlot.SIDEBAR);
lines = plugin.getConfig().getStringList("Scoreboard.Lines");
size = lines.size();
for (String line : lines) {
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
line = PlaceholderAPI.setPlaceholders(player, line);
}
Team team = board.getTeam("line" + size);
if (team == null) {
team = board.registerNewTeam("line" + size);
team.addEntry(ChatColor.BLACK + "" + ChatColor.WHITE);
team.setPrefix(ChatColor.translateAlternateColorCodes('&', line + "&r ".repeat(size)));
team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
}
obj.getScore(team.getPrefix()).setScore(size);
size--;
}
if (player.getScoreboard() != board) { player.setScoreboard(board); }
}```
https://imgur.com/a/ETyge33
why dont u use a lib
telling somebody to "just go use a lib for this" isn't good advice
and, without the full spark report, we can't help
But it's better than reinventing the wheel
I tried using fastboard but it increased the size of my plugin by +400kb (obviously since i had to shade it) so i didn't end up using it
and i couldn't find other methods than shading it so
ight let me send report
reinventing the wheel isn't as bad here
well
(but are you really trying to avoid it just because it's 400kb?
)
i guess so
reinventing the wheel is how you learn how the wheel works and is built
if he uses jda he will lose his mind
ever heard of fastutil
it add 13mb lol
fastutil is 35mb uncompressed
400kb isn't bad but I figured that making a scoreboard shouldn't be that hard and therefore I could save 400kb from the size of the plugin
(you can always just library it)
that's just regex taking 0.06ms
and like, why complain about something taking half a millisecond per tick
yea
you could do that a hundred times in a tick and still have time
well, not much time, but you get the point
If it doesn't cause any issues that I can fix then that's fine with me
and why exactly do you need 150 bots online
but yes you're right I am in the wrong discord that's my bad
how do you have 150 bots
well I don't really need that many but yeah
anyways thanks
despite common myths, windows actually can ran servers
it is just prohibitively more expensive is all when you consider the amount of resources needed for the OS itself
also, it is more expensive when renting a server not because of resources but also because you need a windows license which you have to buy for every server
so yeah it is crazy to use windows for something like mc hosting XD
also those licenses expire every year and have to buy a new one
so a windows server renting wise is like $10.5k yearly around about
seems like EntityChangeBlockEvent fires for sheep eating grass but the getTo is Material.AIR. I see at least one forum post but there's no real explanation on why this is. I can ignore this and just expect it's "really" dirt but is there any kind of work around?
Hey, I might be being an idiot, but Im trying to set the CustomModelDataComponent for an item, but it isn't working
private static final ItemStack baseMenu = new ItemStack(Material.STRING);
static {
ItemMeta baseMenuItemMeta = baseMenu.getItemMeta();
assert baseMenuItemMeta != null;
baseMenuItemMeta.setItemModel(NamespacedKey.fromString("menu_system:game_select_menu"));
CustomModelDataComponent customModelDataComponent = baseMenuItemMeta.getCustomModelDataComponent();
// customModelDataComponent.setStrings(List.of("\"base_menu\""));
customModelDataComponent.setFlags(List.of(true));
baseMenuItemMeta.setCustomModelDataComponent(customModelDataComponent);
Bukkit.getLogger().warning(baseMenuItemMeta.getCustomModelDataComponent().toString());
baseMenu.setItemMeta(baseMenuItemMeta);
Bukkit.getLogger().warning(baseMenu.getItemMeta().getCustomModelDataComponent().toString());
}```
The first logger has it working, but after I try to apply it to the ItemStack, suddenly it gets deleted?
`[00:27:15] [Server thread/WARN]: CraftCustomModelDataComponent{handle=CustomModelData[floats=[], flags=[true], strings=[], colors=[]]}`
`[00:27:15] [Server thread/WARN]: CraftCustomModelDataComponent{handle=CustomModelData[floats=[], flags=[], strings=[], colors=[]]}`
This is my first time working with the new CustomModelDataComponent, am I doing something obvious wrong? xd
what is the output of /version
1.21
1 ignored message this late into the night?
youre modifying the CustomModelDataComponent that was fetched from the old ItemMeta

itemmeta at it again
How should I do it without doing that?
can you just paste the /version output 😭
This server is running CraftBukkit version 4477-Spigot-e339edc-ba251cc (MC: 1.21.5) (Implementing API version 1.21.5-R0.1-SNAPSHOT)
(if that was to me*)
Alright XD
you managed to get one of the two builds that had a regression in that area
LOL
Alright welp
at least its been fixed hahaha
Thanks a lot I felt like I was going insane XD
🥺
Hi, Im trying to create a 1.16.1 server but when i enter 1.16.1 into the .bat file it says (Java 8 or Java 16 (for 1.17.1 only) or Java 17?)
does anyone know where to find server developers to hire?
?services
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/
?services
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/
On my phone rn
@jagged thicket yea it is good now
same lol
Nice
the problem was that task lol
how do you hide attributes on armor. the HIDE_ATTRIBUTES flag is not working
What does /version say?
Is there a recommended lib for making “ui”s like inventory ones? I know of one but am curious if there’s any better ones
Does sending particles to a player using ProtocolLib have better performance than using player.spawnParticle();
okk
thanks, that's one I was planning on using but it errors with their basic example so I'm waiting on Matt to look into it
Wym
unlike his command lib, the gui one errors, probably because of how my plugin bootstraps the code the gui is used from. I'm in his discord a lot because he works very closely with me on the cmd lib, so I mentioned the error to him
What error?
Caused by: java.lang.IllegalArgumentException: class network.darkhelmet.prism.libs.triumphteam.gui.guis.BaseGui is not provided by class org.bukkit.plugin.java.PluginClassLoader
at org.bukkit.plugin.java.JavaPlugin.getProvidingPlugin(JavaPlugin.java:427) ~[spigot-api-1.21.4-R0.1-SNAPSHOT.jar:?]
at network.darkhelmet.prism.libs.triumphteam.gui.TriumphGui.getPlugin(TriumphGui.java:20) ~[?:?]
at network.darkhelmet.prism.libs.triumphteam.gui.guis.BaseGui.<clinit>(BaseGui.java:71) ~[?:?]
I just copied the example provided in his docs but as I said, it's probably something due to how we bootstrap the code this is used in. that's an uncommon scenario so he's not expecting it, hence why I reported it to him but reminded him of our setup
Maybe
his command lib works fine so I'm just waiting on his reply
is there any support for removing components from items, like making an inedible poisonous potato?
?gui
Repost: Looking for a way to give glowing effect to entity (Player or another) or block (not necessary) using only Velocity proxy.
Velocity is not a Spigot product
how do i get a random element in a set based on the getProbability of each one
Don;t use a Set
sure but same question
thanks
heyo! How can i make my mobs only attack players up to a designated radius from its spawn point, otherwise it just goes back?
public class TargetNonFactionPlayersGoal<T extends Mob> extends TargetGoal {
private final T customMob;
private final UUID kingdomID;
private final KingdomManager kingdomManager;
public TargetNonFactionPlayersGoal(T customMob, UUID kingdomID) {
super(customMob, false);
System.out.println("TEMPTEMPTEMP " + kingdomID);
this.customMob = customMob;
this.kingdomID = kingdomID;
this.kingdomManager = KingdomManager.getInstance();
}
@Override
public boolean canUse() {
for (Player player : this.customMob.level().players()) {
UUID playerKingdomID = kingdomManager.getPlayerKingdom(player.getUUID()).getID();
// CHANGE LATER TEMP TEMP TEMP
if (!player.isCreative() && !player.isSpectator() && !kingdomID.equals(playerKingdomID)) {
this.customMob.setTarget(player, EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true);
return true;
}
}
return false;
}
i already have its spawn location stored
do you guys personally use inner or inner static classes in java?
or do you no matter what declare it under another file
sometimes it feels wrong to declare it under different file, for example iterator implementations
Depends
worst part of programming
True
i feel general approach would be if class can stand on its own in its behaviour should have its own class, while classes which represent certain scopes or views (like iterators) should be inside the same file
I barely use actual inner (non-static) classes tbh
for sql, what to use? mysql-connector-java?
ohh i see
but yes that is the mysql driver
with sql in java the driver doesnt matter, the API is the same for all jdbc databases
do I need it?
no
CustomGuard customGuard = new CustomGuard(world, kingdomID, new BlockPos((int) spawnX, (int) spawnY, (int) spawnZ));
customGuard.setPos(spawnX, spawnY, spawnZ);
customGuard.getBukkitEntity().getPersistentDataContainer().set(namespacedKey, PersistentDataType.INTEGER,
0);
Is this a proper way to set persistent data containers?
im currently using an integer to map to each different custom entity
dont do it in one massive line like that but yeah thats how
final var created = container.getAdapterContext().newPersistentDataContainer();
container.set(key, PersistentDataType.TAG_CONTAINER, created);
created.set(...); // Will this save?
Will editing a container after setting it edit it or not
how can i split the PDC line?
Make a variable for the container
No idea, tas
I think I do need it
No suitable driver found for jdbc:mysql://...
and on top of that, I need to shade it in the plugin
don't you have to Class.forName it on older versions
Im lactose intolerant
XD
it's vegan cheese dw
how do i change the light level of every single block
without needing a rocket science degree
Invisible light blocks :p
what happens if players builds on it
It gets removed
Is the GitHub Codespace free? There’s a lot going on in its wiki—can someone explain it simply? Or is it just limited free hours, and then I’ll be charged?
is that the name of your codespace
o.O
?
codespaces isn't an IDE
it is a remote development environment
it's convenient if you don't have a good PC, or work with multiple desktops thorough the month
I used it at times to host a development minecraft server for example, that way I don't have to do it all on my computer lol
if you have IntellIJ ultimate you can connect to it, otherwise you're gonna be stuck with vscode whose java extensions kinda suck
I’m making a guns plugin and for all guns i’m using a cross bow since it works with 3d models and looks like they’re pointing to shoot. The main problem is the fire rate, some guns have a really fast fire rate, some are slow, but when i hold down right click it’s a constant fire rate, which is slower than the fastest fire rate i have. Is there a way to speed this up in an interact event? Without using runnables since i need tap fire to work as well
@short pilot Hi Pvz
guns are against EULA
it’s a private server
well, that doesn't quite make it okay but whatever lol
as for the question itself, you could probably just get rid of crossbows and shoot projectiles at the rate you want
Max you can do is 1 per tick
what if your projectiles are particles



