#help-development
1 messages · Page 763 of 1
you can just do sendMessage on console sender
but it will clutter your logs afterwards if you go the route of adding color yourself
Good ol’ days
Does info not color?
i mean you're not using the console as its intended to be used
what do you want to do
I want it visible :p
I know some people who will refuse to use your plugin ahaha
They don’t want a rainbow in their console
and if you're gonna make ascii art you should allow the plugin user to disable it
ascii in logs is just unnecessary clutter
Let me just have fun 😭
Denied
Programming is the art of inching close to depression
if you wanna make your console gay by all means go ahead
how to get rid of containsAll
wdym
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
Close your eyes when your IDE suggests ContainsAll?!
It’s been a while since I’ve seen people abusing containsAll, i must have been inactive
I used containsAll because I'm confused about multivariate checks.
How do I use them
Ah, let me give you an example. You want to get all Entities in front of a Player, right?
That’s an entitely different question, also please post code in textformat next time screenshots are a hassle.
what?
1x1x2
Hey what's the best way to parse something like this 2d10m30s into mills
Listen to smile. He’ll teach you bounding boxes
Google it.
Screenshots are a nightmare, unless large. I have to click, then open in browser to view
Did you not listen?
.
Thank you
screenshots for syntax/errors. Else codeblocks or paste
What's the point of having this channel if youre always saying google it, don't you think I have googled it!
i not have errors
your ContainsAll will only be true if ALL of those ProtectedRegions exist
If you are using worldguard, then there is a built in feature for that
Idk found smth with one search
This channel is not a google it for you. We’re here to assist, so when we see something that has been asked often enough that a proper google search should show it. Why would we bother spending time explaining it. Obviously some of still do, I am just lazy.
Now
If you had shown a proper attempt at coverting the string into milis together with code
Helping you with modifying your code to work
Is 💪🏻💪🏻
is containsAll a bad method to be using?
For strings? Somewhat
how so?
i would assume it tries to map every value in collection 1 to every value in collection 2
false if failed true if yes
public Collection<Entity> getFrontEntities(Player player) {
double distance = 0.55;
double width = 1.0;
double height = 2.0;
Vector viewDirection = player.getEyeLocation().getDirection();
Location base = player.getLocation().add(viewDirection.multiply(distance));
Vector lowerCorner = base.toVector().subtract(new Vector(width / 2, 0, width / 2));
Vector upperCorner = base.toVector().add(new Vector(width / 2, height, width / 2));
BoundingBox boundingBox = BoundingBox.of(lowerCorner, upperCorner);
World world = player.getWorld();
Predicate<Entity> filter = entity -> !player.equals(entity);
return world.getNearbyEntities(boundingBox, filter);
}
or
public Collection<Entity> getFrontEntities(Player player) {
double distance = 0.5;
double width = 1.0;
double height = 2.0;
Vector viewDirection = player.getEyeLocation().getDirection();
Location base = player.getLocation().add(viewDirection.multiply(distance)).add(0, height / 2, 0);
World world = player.getWorld();
Predicate<Entity> filter = entity -> !player.equals(entity);
return world.getNearbyEntities(base, width / 2, height / 2, width / 2, filter);
}
Both work the same way
Ahh, i think ur thinking of the collection containsAll. That’s fine
The String#containsAll is different
Thank god they didn’t make two
I would just go from left to right and check if a character is a numeral or not.
Then accumulate the numerals and wait for an alphabetical letter.
Depending on the letter: Add time to a duration based on the accumulated numerals
Depending on the length of your time nominators you might also wanna collect letters until you hit a numeral again.
For example if Minutes = mi and month = m
Myeah usually you do M for months and m for minutes.
But if you want to support months and minutes for example, then you should probably also parse consecutive letters.
I’ve been so used to passing letters as lowercase cause idiots will type M with big when they meant m so many times ahaha. But yeah that’s a nice idea
I asked how they work
Giving me ready code wont teach me much
Math teacher smile incoming
Alright. So a BoundingBox is an Axis aligned Box with corners.
World#getNearbyEntities(BoundingBox, Predicate<Entity>) returns all Entities in that Box, using the Predicate as filter.
The rest is just basic math and java.
Nope
I dont know how to teach vectors through text and im not in the mood to draw right now. Gonna get my coffee first.
I got the perfect idea sec
teaching via text for vectors requires that the other has some math experience relating to such things XD
otherwise its a pain
Ah didn’t pan out
ah yes show them all the vectors
?nocode
It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.
Thanks
What is axis aligned box and predicate filter
I think the hardest part via text in regards to vectors is dimensions
Where is the issue @quaint mantle i don’t understand that language
most likely the player does not add ed to the list because the command cannot read it
and the code is in paper and in Polish
I would usually point you to papers discord in that case. Just highlight where you think the issues are in a new paste with a comment in english. Thank you.
?paste
public interface Predicate<T> {
/**
* Evaluates this predicate on the given argument.
*
* @param t the input argument
* @return {@code true} if the input argument matches the predicate,
* otherwise {@code false}
*/
boolean test(T t);
}
Its just a standard interface from java.
In goes something T, out comes boolean.
It is a so called Functional Interface. They can be used for lambdas.
So
Predicate<Entity> filter = entity -> !entity.equals(player);
Is just short for
Predicate<Entity> filter = new Predicate<Entity>() {
@Override
public boolean test(Entity entity) {
if(entity.equals(player)) {
return false;
} else {
return true;
}
}
};
The filter is called for every detected entity.
Honestly you can also just leave the filter away and manually remove the player from the resulting collection.
public Collection<Entity> getFrontEntities(Player player) {
double distance = 0.5;
double width = 1.0;
double height = 2.0;
Vector viewDirection = player.getEyeLocation().getDirection();
Location base = player.getLocation().add(viewDirection.multiply(distance)).add(0, height / 2, 0);
World world = player.getWorld();
Collection<Entity> found = world.getNearbyEntities(base, width / 2, height / 2, width / 2);
found.remove(player);
return found;
}
Thats a bit more understandable than the filter
If this code doesnt run, then the name of this command is not czysty
Can i see your plugin.yml and ur main class?
version: '${project.version}'
main: pl.playgroundhc.survival.Survival
api-version: 1.17
commands:
kit:
sprawdz:
czysty:
cheaty:
Does it have to be that complicated
Why do you have two commands on the same executor @quaint mantle
It’s not too complicated once you get the hang of it.
becouse i use the same array list
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
becouse i don't know how to implement mysql to java
Let me think if there is a simpler way. But you will 100% meet Vectors and BoundingBoxes for many plugins
you are going to write. I know that its a bit tricky to learn.
You don’t need to
Look at the link above
but i would
You might want to, but you do not need to.
I know what vectors are im not in special need, but my intuition says that its so excessive
you know any youtube channels to learn it?
I do not.
You PL?
yes
This is the most trivial way if you have spatial requirements
guys, who can make simple pixel art graphics?
I can in theory. What dimensions and how complicated?
?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/
It’s not complicated at all, I can send examples of graphics in private messages and tell you exactly what I need, I need very little graphics
How customizable are banners with plugins?
Oh plural. No thank you 
As in, any ingame combination or any pixel combination?
Atleast any ingame combination. But i’ve seen plugins be creative before, maybe you can mess with banners. Though a map is much easier and higher res
I am looking for experienced developers for a big project. We already got all vps and some developers, if you want to join the development team, dm me.
And they will be paid as soon as we will release our server.
?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/
Why do you edit the project file....
Does anyone know how to make a submodule in gradle?
I can do it by hand, but that seems painful
Intellij should have a button for that
💀 kotlin
Sorry, should've specified that I want this for Kotlin 😄
just make a folder for your submodule with your build file and include it in the settings file (include(":submodule-name"))
that's what I did, but then I have to make the directory structure of
src
main
kotlin
resource
test
....
which is what I was trying to avoid
Make a github template and just clone a lot easy easy
intellij autocompletes these paths in the directory creation dialog when you include the submodule
hm, it didn't for me. do i need to add a semicolon before the submodule name?
should work even without, is your submodule directory highlighted in ij?
yes, but only I've manually created the folder
(waiting for indexing to finish, and sending a screenshot)
it does work just fine for me after including it https://i.imgur.com/v5x2Fty.png
ah, can't send images here..
yeah you need to be verified
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
so, you include the submodule in settings.gradle.kts then manually make the submodule directory (by just making a regular directory with the same name)
yes
My module gets highlighed after that, and that's it
It doesn't get populated, unless you're doing something i'm not 🤔
worth to note that you probably need the java plugin applied to create the source sets
I'm not sure I understand 😦
SkillSprint is the module i just made, but it's empty
yeah so just make a new build file in the submodule and apply the java plugin
plugins { java }
when you include stuff like that, no configuration from the root project is included unless you put it into a allprojects/subprojects block, so you have to configure everything
Thank you, I haven't used gradle much before, do i make it by hand or is there a tool to generate one?
hey, im currently cancelling a BlockBreakEvent and then giving the player the drops from the block. this is the part of my code that handles the drops
// Get the drops
Block block = e.getBlock();
block.getDrops(e.getPlayer().getActiveItem()).forEach(itemStack -> {
Bukkit.getScheduler().runTaskLaterAsynchronously(breakManager.getMineManager().getPlugin(), () -> {
e.getPlayer().getInventory().addItem(itemStack);
}, 1L);
});
It seems to be working perfectly fine with something like red wool, but with a diamond and a diamond pickaxe it wont give me any drops in my inventory. If anyone could help it would be greatly appreciated
it's just a few lines, shouldn't be a problem to make it by hand
not aware of any tools that do that though
fair enough
thank you, i'm trying this out now
Any reason why you add the items one tick later?
You should also pass the Player in your getDrops() method.
(I'm only asking, because I want to automate this, as I want to create a lot of small libraries for my plugin to consume)
so instead of writing my own tools, i would rather use built in
nothing wrong with writing your own, of course :p
hm, still nothing
https://imgur.com/PvBHwuP
what does it show when you open the new directory dialog?
.....
everything
you are a legend
lol
I've tried passing in the player, although it still didn't fix the issue. I have the 1 tick delay so we give the block break animation a tiny bit more time to finish because it looks a bit out of sync when we give it straight away.
Now the question is, do I care about this directory structure, and can I just dump files into the module root directory? I really like that I don't have to mess around with manifest files, and that things in resource directory get included in the jar by default 😄
you can have anything in the submodule root, only the src directory is what matters to gradle
Thank you for your help, i really appreciate it
by the way, you can move common logic (plugin applying, stdlib dependency, repositories, ...) into a build script in the project root and have it be applied to all submodules automatically (i.e. you can remove it from the submodule buildscripts)
plugins {
kotlin("jvm") version "..." apply false
java
}
subprojects {
apply {
plugin("java")
plugin("org.jetbrains.kotlin.jvm")
}
repositories {
mavenCentral()
}
// ...
}
i did not know that...
it works the way you have it, this is just if you wanted to reduce duplication in the scripts
I do!
which file do i place this in? build.gradle.kts in root?
yes
This works perfectly fine for me:
@Override
public void onEnable() {
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onBreak(BlockBreakEvent event) {
Block block = event.getBlock();
Player player = event.getPlayer();
PlayerInventory inventory = player.getInventory();
ItemStack item = inventory.getItemInMainHand();
ItemStack[] drops = block.getDrops(item, player).toArray(ItemStack[]::new);
Bukkit.getScheduler().runTask(this, () -> {
inventory.addItem(drops).values().forEach(overflow -> {
player.getWorld().dropItemNaturally(player.getLocation(), overflow);
});
});
event.setDropItems(false);
}
and remove build.gradle.kts from submodules, or just cut them down?
yes
god
oh i forgot to do main hand, mb sorry. ty for your help
I need to commit first, then i'm trying this 😄
You should also add all items in one task and not start a task for each item.
And you should check if items got added or not and drop every item that overflows the inventory.
Much better than the C++ build system, i can tell you that...
Exactly
Everything is better than that
fair, ill modify my stuff now
I mean, gradle can also build c(++) projects with its wip plugin
I've heard of that, but I don't know how i would feel writing build specification for C++ in Kotlin (I'm not writing groovy)
I like consistency
you're compiling Kotlin, and the build system is written in Kotlin is fine
Do you know, if i need to specify a clean task? right now, gradlew clean doesn't clean any of the submodules
I made just one common build.gradle.kts file
plugins {
kotlin("jvm") version "1.7.10"
`java-library`
}
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies {
compileOnly("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
}
you need to have it in the subprojects block
the common logic
you can copypaste my example, it should work
hm, the plugin applying part didn't work, but is there anything wrong with my example?
(clean now works, for some odd reason)
How can you check if a player flies on elytra?
plugins need to be declared on the top of the buildscript and then subsequently applied to the subprojects
like in my example
this is what i have:
plugins {
kotlin("jvm") version "1.7.10" apply false
`java-library`
}
subprojects {
apply {
kotlin("jvm") version "1.7.10"
`java-library`
}
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies {
compileOnly("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
}
}
that apply block needs to be just like in my example; you declare the plugins on the top and just apply them via their id in the apply block
Ah, that's what I missed
you're right once again
it all works flawlessly...
thank you!!!!
no problem
hobby since 2017 I think
Do you do it professionally?
no, still a student
I am aware this is not the paperspigot discord server, but is there a easy way of connecting a player to another server in a velocity network? Just like in bungee
Velocity supports the BungeeCord plugin channel, so the exact same way
Favourite programming language?
probably kotlin
thank you 🙂
Mine is Rust, but making plugins for Minecraft in kotlin is very fun
i love kotlin but hate its syntax
used to be C, now it's java
and the programming language that I used and i hate the most is php
its so god damn inconsistent
🤮
the polar opposite golang is my close second :p
I actually enjoyed C/C++ (haven't done much C apart from some simple networking apps) but the ecosystem killed me
How is golang polar opposite of Rust? (GC?)
Haven't tried GO, but I heard it also has nice tooling
By the way, do you know purpose of group and version fields ?
group = "net.myname"
version = "1.0-SNAPSHOT"
I noticed that the jar file will have the version in it's name when I build it
it's for publishing to maven repos
your project looks fine right now
Not just that. They're unique identifiers so you can depend on them locally as well
What is maven and what does it do to plugin
how i can get if player al lokking hitbox of another player?
It's a build system. It will automatically download dependencies for you among other project configuration
Gradle is also a build system that accomplishes the same but using a different build file structure
Whats dependencies
hm, i just realised something actually, my project bundles all moduels into a single JAR, whereas I actually wanted them to be separate, do you know how I can do that?
it still produces sinlge Jar files per module in the module build subdirectory
the root project is called Heroes, i'm guessing HeroesPlugin and SkillSprint get bundled into Heroes.jar
if you run the clean task, does that root build folder disappear?
wait, never mind, you just need to not apply the java-library plugin at the root: id("java-library") apply false
this is my root build file:
version = "1.0-SNAPSHOT"
plugins {
kotlin("jvm") version "1.7.10" apply false
`java-library`
}
subprojects {
apply {
plugin("java-library")
plugin("org.jetbrains.kotlin.jvm")
}
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies {
compileOnly("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
}
}
I can't apply false on java-library
> Plugin 'org.gradle.java-library' is a core Gradle plugin, which is already on the classpath. Requesting it with the 'apply false' option is a no-op.
O_o
yeah you probably don't need it at all on the root
so just remove that line
(also put that version property into an allprojects block so it's applied to everything)
Pretty much by using ray tracing
compileOnly now fails to resolve
show me what you got in the root build file now
Ye
hm
You need to apply at least the java to plugin to it
else dependencyresolverhandler or whatever its called isnt bundled w said module
allprojects {
version = "1.0-SNAPSHOT"
}
plugins {
kotlin("jvm") version "1.7.10" apply false
}
subprojects {
apply {
plugin("java-library")
plugin("org.jetbrains.kotlin.jvm")
}
repositories {
mavenCentral()
maven("https://repo.papermc.io/repository/maven-public/")
}
dependencies {
compileOnly("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
}
}
If i put java in plugins, it will be bundled into a single lib
(god i need to learn what those plugins are)
if it's not painfully obvious, this is my second day with gradle
yeah I thought that too, but then how do we prevent gradle from making its dummy jar for the root project
I ignore the root project build myself 😂
Well, if some submodule x depends on the root module during building then the root module will build as well
I mean
i mean, i guess i can consume those by just specifying the artifacts in the submmodules
One way is to just fkn yeet the compileOnly dependency in the root module
Does your rootproject have actual code?
no
you can consume a submodule with implementation(project(":submodule-name")) (or any other dep configuration)
Root project just has submodules
Then why do u have a compileOnly dependency there lmao
applied to the submodules
yeah then no need for java nor javalibrary plugin
Oh I see
Yeah looks to be fine then?
I thought that's what would be applied to the submodules
it is
Yeah it should
you can just ignore the build/libs output of the root project, it's not gonna have an impact on anything
yeah, that's what i'm leaning towards too
I don't want to get stuck in this, but i do like when things are clean and tidy 😄
well the root module ought only to build if you call the task for it
I mean one otherway is to override the rootprojets build task and nullify it
I usually just call ./gradlew build
anyways
yeah that calls all of the build tasks, root project and submodules
You can make it so that gradle thinks build or w/e subtask like compileJava or sth already thinks it was built so it won’t build (goofy hackaround but yeah)
Actually this might be better
https://docs.gradle.org/current/javadoc/org/gradle/api/DefaultTask.html#setEnabled-boolean-
yeah
just saw it now :,)
can someone help me with github? It's not spigot related but its really annoying
i have a software that i wanted a certain gltich to occur in the save file, and now i have two branches. How can i essentially completely overwrite all files that are different between them?
git stash | git reset --hard | git fetch | git pull
What do you mean by overwrite?
You can merge branches if thats what you mean.
If they change the exact same line into different things then you need to resolve the conflict between the 2 branches before you can merge or rebase
its binary files
essentially, i want all binary files different between the branches to be changed to the test files
merging would corrupt them
like i have main and test as branches
i want to make main equal to the test branch
Then... just set your test branch as the main branch and discard/rename the old main branch
oh that worked thanks
If you are on the local test branch then you can push on your master branch like this btw
git push origin +test:master
Wait "master" is no longer PC, right? -.-
So +test:main or whatever
renaming it switched em around
Ah ok
how can i send the player an actionbar
1.17.1
btw it asks for a BaseComponent
what is that
Bukkit.getPlayer(player.getUuid()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent().setText(ChatColor.RED + "TEST"););
why
Player player = // ...
BaseComponent[] message = new ComponentBuilder("TEST").color(ChatColor.RED).create(); // Note: net.md_5 ChatColor, not org.bukkit
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, message);```
Because component messages are the replacement for legacy colour codes. Behaviour is undefined
Wh3n can we get the build method in spigot I saw it got merged in bungee
Oh, right, I suppose it's not in yet, I shouldn't be using it as an example lol
Isn't it harmless to just bump bungeechat version?
It'll get merged once I get the component API merged, which... y'know... hopefully soon? :p
im looking to recreate this
tbqh it might get bumped in 1.20.3 because of Mojang's NBT serialization over the network now
We're really phasing out arrays entirely
You've got a lot of conflicts :P
No it's already up to date locally I just haven't pushed yet because I'm waiting for 1.20.3
I have some pending changes in BungeeChat
It's on master now though tbh I could probably just use it
Still want to wait for 1.20.3
Fair
:c
I'm hoping we have components and registirss by 1.21
I'm hoping components should be in API by 1.21, yeah
Then maybe I nventori3s soon after
Every version that passes without it a puppy gets sad
?
Cannot resolve method 'build()'
Yeah see my snippet again, I edited it
build() hasn't made it in quite yet
Type is an array, use create() instead
Cannot resolve method 'create()'
Honestly don't know what it's complaining about lol. This seems like an "IJ is being weird" moment
Did you change BaseComponent to BaseComponent[]?
im using textcomponent
Also import ChatColor from the right place. You don't want a Bukkit ChatColor, you want a Bungee one
Yeah you need a BaseComponent[]
Bukkit ChatColor stinky
create() : TextComponent[] does not exist, create() : BaseComponent[] does
so I'm struggling to understand databases. I'm having issues understanding how to store and access said items in database? Can someone give me a brief overview on that classes needed to store and access a database?
Prob need to invalidate caches
ye doing it rn
Generally you want a class that has methods to interact with the database
Said methods would contain all the SQL code
nah
So like Class to connect to database > Class to access database > Class to store into database?
I have a class that handles the connections
And then a class that handles insert/update/read/delete
I was like wtf
like if I wanted to store a clan created, I would want to store the user who created the clan, and then another table for that clan being created.
So I would need my database connection class (to connect to the database) and then a class that stores said clan info into database, and then another class to update and delete? Or should all one class handle the insert/update/read/delete methods?
I use one for all insert/update/read/delete
So for all the question, I'm new to plugin development, and i just started using databases
Yeah, I can connect to the database, connects fine, even pooling iwth hikaricp, but i'm just trying to get a better understanding of the classes I need
The way it's usually recommended to structure things is to have an interface (or class, depends on how you want to design this tbh) for each concept. You can operate on multiple tables in a single class, that's fine, but for something like a clan you may want some sort of ClanDatabase type. This should expose methods like saveClan(Clan), or updateClanName(Clan, String), deleteClan(Clan), or really any sort of operation you want to perform that pertains to a clan object
You want to be able to hide the fact that these are operating on SQL. You're abstracting it away so that the caller of that interface or class doesn't know exactly what's happening, just what it's going to do
As an example, instead of selectAllClansInDatabase() you could call it getClans(). No reference to "select" which is an SQL concept
Alternatively, changeRelationship(Clan, Clan, RelationshipStatus) which would edit the two clans' ally or enemy status. Implementation would perform all the SQL operations necessary but to the caller it doesn't care how it does that, as long as it's done
Is there a way to implement await without looping when the future is in 'running' state?
CompletableFutures have whenComplete(), or thenAccept(), or thenRun() methods that invoke callbacks when they've completed
Or if you don't care about blocking the thread for a result, .get()
Okay, so for clan related storing such as
Who created clan, clan created info, clan war status, allies, enemy's, members, should all be in one class, like (ClanDatabase) And then for clan stats, like player deaths, kills etc, all in another class (ClansStatsDatabase), that performance the same way as the other class. and so forth and so forth?
But I should still have a third class that connects to the database separate from my classes that would interact with the database
I would say so, yes, but you could hide those behind implementation. Ideally the caller wouldn't have to worry about creating the connection themselves, the behaviour classes would be doing that
Even just a simple class that wraps and lets you more easily manage a Hikari connection pool
By any chance could you give me a simple example of what you mean, or a link to something i can read to understand that better
I don't have any articles or guides off hand, but I do have a plugin that sort of takes this generic approach, albeit not with a connection pool (because I don't perform nearly enough database queries for it to be worth that lol)
Also somewhat of a simple architecture given I only have save() and load() methods, but I really don't need more than that. You could absolutely add more methods to your interfaces or classes as you see fit
How you separate these objects into interfaces or classes is entirely up to you. If you really wanted, there's nothing inherently wrong about throwing it all into a single jumbo class that interacts with the database
i assume the callback is done on the future thread
Correct
For readability and future development if someone wants to come along and work on my clan plugin, I rather not jumble everything together , so I like the segregation
Yeah, it's up to you how you separate things
You can choose another thread btw. Most methods have ...Async() alternatives that accept an Executor. By default though it will run on the thread that the CompletableFuture is using
i see
Question, for my package name. Is this fine or should I change it to something different?
me.cmriddles.riddlesclan.RiddlesClan it seems weird compared to other peoples package name
nothing seems wrong with that main class path
if RiddlesClan is part of the package just move everything out of that package and delete it
most people just use their domain if you don't have one its fairly standard to use me.username
when I created it asked for a I guess a file name, but then asked for a plugin name, and the plugin name autofilled from the file name when I created the project, so i wasn't sure if this was okay or not
generally most people follow the package format
com.example.projectname
though some weirdos use just com.example
yep
weoo
you can use me
you should only use something else if you own the domain
com.example is more correct, but when you have subprojects the subprojects are being treated as a separate projects
forgot to ping, but you should really only use com.cmriddles if you own that domain if you don't own a domain its pretty standard to use me.cmriddles

me.dovias:dycommand
me.dovias:dycommand-api
vs
me.dovias.dycommand:dycommand
me.dovias.dycommand:dycommand-api
:o, that is gold out of context
I got you, I wasn't aware I could change the main class upon creating the project
I like latter
only psychopaths prefer the former
So when its created, it comes out like this me.cmriddles.riddlesclan.RiddlesClan
one is file name, the other is plugin name. I don't need the plugin name in my main class, so it can just be me.cmriddles.riddlesclan
doesn't really matter wht you name your main plugin class as long as it isn't Main or Plugin some pepole prefer just doing the plugin name e.g. RiddlesClan others, like me prefer RiddlesClanPlugin
Hello I have since the latest version the error that I get an error in the following code:
GameProfile profile = new GameProfile(UUID.randomUUID(), "");
profile.getProperties().put("textures", new Property("textures", value));
Field profileField;
try {
profileField = meta.getClass().getDeclaredField("profile");
profileField.setAccessible(true);
profileField.set(meta, profile);
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) {
e.printStackTrace();
}
}
Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.profile.PlayerProfile.getTextures()" because "ownerProfile" is null
Does anyone know where the error is?
i do that too also RiddlesClanPlugin since it extends JavaPlugin and sometimes i create new class named like plugin to provide some sort of api class
Alright cool, I appreciate everyone being patient with and kind with me as I learn my way around plugin development
that's why I do it too
or somethings I just have an object named the same as the project name
well
the latter is much more scalable long term
so thats why its preferred, at least at companies or organizations
day one I started using me.y2k.projectname
that's just how my friend taught me
so I stuck with it
domain.reverse.projectname:module-name:version
I do that because some forge tutorial told me too and never stopped lmao
thats how u should do it in principle
but what if your source code inside root folder
?customhead
idc
Yes base64
thats irrelevant
I mean easisest is to just have the artifact being quite literally the project name
or maybe append -core or sth
but my point is, the subdomain ought to be project related and should def be included in the group id
Spigot 1.18.1 added the new PlayerProfiles class, which finally allows us to use custom heads without needing any reflection! You can obtain them as normal items, or actually place them down into the world. I’ll show you how both works: Creating a new PlayerProfile First, we gotta create a new PlayerProfile object. To do so,...
I tried this but got the same error
is there any way to figure out which of the LootTables enum is present in something like a chest
because Lootable#getLootTable() returns a LootTable and not a LootTables value
and LootTable doesn't have like a getType() method
loop through all of those loot tables and compare class names? 💀
LootTables.<whatever>.getType
Also you can compare they key
Depends on what the goal is
no, from a chest that has a loot table
i suppose a loot table does have a getKey method so i can use that
nevermind that, thanks!
?paste
https://paste.md-5.net/mopepugibo.java bacuse Ray.getTargetPlayer Dont go?
dont give error
but retun always null
Cuz target entity?
Purpose of my plugin but it doesn't fit, I would just like to know why it returns null
Wait why are you making raytrace by urself
How should I use it?
i want player dont block
Thats
Why
reasons
Then I am not answering
I know that additional info usually helps
in solving the issue
but this is the 1%
where it does not
I don’t trust that
but if you really wanna know
I add a custom channel handler
but getting it from a map is usually faster
so I utilize packet libraries when they're present
for PacketEvents I just had to ask
but ProtocolLib does not have it's own discord server
yes
iirc yeah, but I might b lying
Hello, I am new to spigot development & coding tbh. Where do i start?
I'
Think u can find it by just navigating javadocs for plib
m asking how I could do that
JanTuck 🙏
Does that work?
Do something you enjoy
yeah, but how could I access it statically?
If you like spigot dev, try to learn java with spigot, altho that can be complicated it may prove more indulging than learning raw java
learning raw java is just as important
Myea, but its problematic when people advice newcomers to just learn java without practically applying it somewhere
that is true
Do I have to watch the 10 hour video on youtube that teaches java 💀
No
I think I'll just experiment & learn
.
why do you need a packet library to get the channel from a player?
you could just.. get it from the player
I mean, not necessarily
I goped that I could do a similar thing with ProtocolLib
so long as those Methods/Fields in your ReflectionUtil are static final then it's fine
the jvm will be able to inline the calls
I thought that only applied to methodhandles
it has its own special treatment for reflection as well
I forgot that reflection is also implemented with mh in newer jdks
Headless graphic environment
if you didn't get what I meant
given a pair of (double, object) how can i store and sort them by the double value efficiently in ascending order of the double value?
the doubles may be equal for some pairs, the objects are all disjunct
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String s, String[] args) {
List<String> result = new ArrayList<>();
if(args.length == 0) {
result.add("setWaitingLobby");
result.add("addMap");
result.add("setTeamSize");
result.add("addTeam");
result.add("addSpawner");
result.add("removeTeam");
result.add("removeSpawner");
result.add("finishMap");
return result;
} else if(args.length == 1) {
if(args[0].equalsIgnoreCase("addTeam")
||args[0].equalsIgnoreCase("setTeamSize")
||args[0].equalsIgnoreCase("addSpawner")
||args[0].equalsIgnoreCase("removeTeam")
||args[0].equalsIgnoreCase("removeSpawner")
||args[0].equalsIgnoreCase("finishMap")) {
for (GameMap map : Main.getInstance().getGameManager().getMapManager().getMaps()) {
result.add(map.getNiceName());
}
return result;
}
} else if(args.length == 2) {
if(args[0].equalsIgnoreCase("addSpawner")) {
result.add("Bronze");
result.add("Iron");
result.add("Gold");
result.add("---[1.16]---");
result.add("Diamond");
result.add("Emerald");
return result;
}
}
return result;
}
``` why does this not show me my Tab Completion when I register it as this: ```java
getCommand("setup").setExecutor(new SetupCommand());
getCommand("setup").setExecutor(new SetupCommand());
how do you exclude a certain package set from a dependency with maven
I tried
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>sh.miles.raven.provider.mongodb</exclude>
<exclude>sh.miles.ironpipe.impl.v1_19_4</exclude>
</excludes>
</artifactSet>
</configuration>
</execution>
</executions>
``` but it didn't seem to work properly
I also tried adding exclude to the Dependency but that didn't seem to work either
you on'y register your command twice
you never register the tab completer
final PluginCommand setup = getCommand("setup");
final TabExecutor executor = new SetupCommand();
setup.setExecutor(executor);
setup.setTabCompleter(executor); // this might be wrong method but its close to this atleast
Also make sure you add the plugin to your plugin.yml like so
... blah blah other information
commands:
setup:
usage: "/setup"
description: "the ultimate setup command"
.
if ur rlly tryna exclude specific packages u need to use artifact filters ig
u can see how that works here https://maven.apache.org/plugins/maven-shade-plugin/examples/includes-excludes.html
use Binary Sort
cant u just run #sort on a collection of pairs with a custom getter function
oh true ^
as a list of pairs
just a list of pair Double Object or a custom object
would there be a better way to go about this other than artifact filters, maybe a better pom setup for my other projects
currently I just use dist modules
well you can easily exclude modules
that a func on list or smth?
but shouldnt it work like this: ```java
getCommand("setup").setExecutor(new SetupCommand());
getCommand("setup").setTabCompleter(new SetupCommand());
don't call new SetupCommand() twice
its redundant
if u have command and tab complete in the same file only register it as command
oh okay sweet
let me try that
but then still it doesnt show
feels like you messed something up
so i need a custom data type then gotcha
hmm that didn't seem to do it could be be because of how I distribute my jar. I just shade all the modules into one jar and then depend on that dependency
then Comparator.comparing((pair) -> pair.getFirst()) probably
well now it shows this
?
when you are compiling view the log for the message "including blabla"
how the f
see if its doing just 1
broski
List<Pair<Double, Object>> items = new ArrayList<>();
items.add(new Pair(0.5, "Hello"));
items.add(new Pair(0.2, "Test"));
items.sort(Comparator.comparing((pair) -> pair.getFirst()));
mmm yeah it just does the entire uber jar
[INFO] Including sh.miles.ironpipe:iron-pipe:jar:2023.10.27 in the shaded jar.
``` it makes me think I should really be setting up my maven build files different then. I want to beable to depend on the entire project, but also beable to exclude certain things if I want
ofc
could you kinda explain this is on of the projects https://github.com/Y2Kwastaken/Raven
what I do currently is shade everything within the core module
then depend on that
what does that do
pretty sure it should shade them in whatever project ur using it in
does anyone know if its possible to set a WitherSkull's texture to the player's head?
@tall dragon yeah that did it thank you
of course, with a texturepack
dammn alr, ty for ur help
Map
treemap is amazing for this
It automatically sorts it with it's saving method
If you want the opposite you can just reverse it
yes
As map.values();
by entryset
Or whatever
So can a HashMap
i dont think thats how hashmaps work
Try it out
considering what i know about how hashmap works, id rather not
whats guaranteeing the hash is numerically ordered
Last I can remember is that numbers and strings are automatically sorted
actually
there are different key formulas, sometimes a bigger hash can be before a smaller hash
wouldnt it be better to do this in a list where i insert it at the proper position?
I also read the src
i calculate those values in order, so the list would always be ordered
because of elements % size
Maps are faster
Especially in a Key Value situation
Anyway
Make a simple test
Check whether I'm wrong
I only remember saving stuff and it automatically sorting itself
let me put it this way
do all these work in less than 500 (how the f do u type mu) s?
When using a Map
given a set of <= 100k entries
500 of what?
Yes
You mean
its on the key my m is on
Computational time?
yea
Yeaaa
Most code does
And what's great about maps
Is that no matter their size
Operations made will always have similar computational time
0.015 ms was the average
For hash maps
On my computer
For modifications
That's still a lot
Does anyone know how would I go about opening the Advancement menu to the player?
A tick is only 50 ms
not if u do world modifications
Well yes
I need to both read in a significant amout of blocks and modify a subset of them
Depending on that
lmc
Try searching on the web
70² * 20
Can you do it asynchronously?
no, calculation need to finish in the same tick
u cant bring async data back onto main in the same tick afaik
correct me if im wrong please
Why is that?
Explain your situation
I'll try to help you
That's correct for most cases
actually
atomic reference
make it a bool for if it finished and another for the calculation data :kekw:
arent atomic references able to carry async data onto main? i thought they could
AtomicObject
Normal variables can also do that
They can be accessed from multiple threads.
You can also transfer data between threads without using atomics.
minecraft runs on a single synchronized main thread
I know
i've had a look but can't seem to find much
i thought u need atomics to do this properly?
What are we discussing? 😄
I made a custom sync scheduler after all
I dunno, the guy talks about random stuff
potentially computing intensive calculation offload onto async
You mean this wall where all advancements are listed?
my mind jumps over the place sue me lol
You should probably do that async
yup
But why do you need it to complete in a single tick?
it's for an ability for which i need to scan the terrain if it is flat enough to execute it on (which i still havent found a good way of doing) and then start it as fast as possible to reduce both real and percieved lag
Thats part of the clients menu. You cant make the client open that.
dammn alr
Aa
I did that
Make an async task
I used a custom ForkJoinPool config
But you can use CompletableFuture.supplyAsync
Since it uses ForkJoinPool
hm
So 0.1 ms
What is this intensive calculation?
Not really that noticeable if you ask me
0.1s *
like i said, scanning around 5k blocks area of terrain for how even it is. potentially takes a long time, im not sure how long it takes to check such an area
And then synchronize in a single task all the necessary world changes
Do it async
Not sure what you mean
like, 'im not doing anything, are there any outstanding calculations'
What
Hm. That could be done quite quickly depending on what you want to check.
cant you use parallel stream
But not like BukkitScheduler async, make your own scheduler
pretty sure the terrain read in is the bottleneck
Nope. But you can calculate the tps trend and add more/less load on the main thread accordingly
What
in my experience I/O is slow
then cache it
All chunks are in memory
Get a chunk snapshot
That's how ac devs do it to avoid overhead
Can Blocks be changed on your worlds? Or are areas constant?
why is using a chunk reference a problem here?
smp, it's for a thing to spawn in a specific structure
wtf
Yo livin in 2070
nah fam he just on mobile
its pc
huh
Does it need to be instant or is it fine if you add an actionbar with Scanning area [====_______] and place after a few ticks
pvp relevant soooo.... instant kinda required
like i mentioned above, the real and percieved lag should be as minimal as possible
I'm decently sure
That it would take less than 0.5s
Which is a very insignificant difference
And since doing it sync will most likely lag
Doing it slower async is a better option
hm question
how fast is system.getNanos, while (value < other value), and if(x) ... else ...
i could just give myself a budget and if it doesnt finish in a given time like say 5 ms push it onto async
Its more precise for deltas than millis but less accurate for unix
Means the time since 1970 is less accurate
Counting time since 1970 isn't an easy job
Why nanos?
force of habit, im used to using nanos for timing
Ive got a guide where you can specify how many millis a runnable is allowed to take each tick if you are interested
yea i can just adapt that
Bruh
is on-thread runnable still on a 1 tick delay?
Yes
Then I've got a question
This guide is for distributing workloads over several ticks. Its just meant for tasks on the main thread however.
How can I register a Font in a headless graphic environment?
oh ive seen that one
my idea's to just do that on main until a certain threshold is reached, and if it aint finished push it onto async
Still having captcha problems?
This would be quite complicated
wouldnt it just be the same timing code just elsewhere?
Yeah 😭
Implement it with chunk snapshots for now, then measure the performance and see if it even needs any optimizations.
noted
Font.registerFont and every other method I've seen uses FontManager which searches for the SunGraphicEnvironment class using reflections
And a hge does not have that class and throws an error
Or the sun font manager? I don't remember
But I can't just implement my own since I might as well code the entire 3d rendering
I need for the map captcha rendering
Since it's the only way to show an image to a player
And the image can't be fixed (constant)
Since it's a captcha
Not half bad
I wonder
How FastAsyncWorldEdit
Handles this stuff
Pretty much like that
jankily
Since I once tasked it to replace certain blocks on a 200 million block area
And after using 100% of the cpu on a crappy server it was done in 45 ms
So it did lag
Do you expect it not to lag when filling half the world?
Not filling
Well, replacing
Only about 100k blocks were replaced
But not all
You still gotta check each of them
There probably is a way
To split it to not lag
Handling it on a remote server
if a item has no Meta, how do i create one?
I'm pretty sure the only item with no meta is air
kthx
also
if(!(player.getInventory().getItemInMainHand() item item.getType() != Material.AIR))
is there something similar to this just that it works?
im assuming you can create variables in if clauses in other ways than instanceof checks
why
im just curious if its possible
also does anyone know why my autocomplete is suddenly gone? I'm in plugin.yml
ItemStack item;
if ((item = player.getInventory().getItemInMainHand()).getType() != Air) {
}
if u want it
but i see no reason to do it here
never had, worked before
like this is seriously weird hitting enter and not getting the autocomplete lol
like i do have the spigot stuff in maven or i doubt it'd build and work but
like why
that was from mcdev adding a schema
?
i mean the default IJ thing
on all other stuff i did it was like 'this is a minecraft plugin heres your autocomplete'
but now its like 'this is yml idk what u want from me'
schemastore has a bukkit plugin schema by default
do you have the correct schema selected in the right bottom corner?
something mustve because its not a default intellij thing
it literally is
the json-schema store has a bukkit plugin.yml schema and ij pulls from that
how do i grab that? its clearly gone
Dont bother obfuscating
thats where it is not how to put it into intellij lol
By using an obfuscator. But you 99.9% dont have any code that is worth obfuscating.
right bottom corner has a schema selector iirc
What do you need this for?
either try to find it there or import it
to use the color on another string
ij moment
proguard should work
I changed it to 'Bukkit plugin.yml', no autocomplete
it's free
You could use ChatColor#getLastColors(String)
This kind of crumbles if a message has multiple colors

they literally have maven and gradle plugins
what in the fuck is this screenshot
nothing wrong with it
yup
Hello, do you know why when i make a player ride an entity, and after i try to teleport the entity, it doesn't work ? Im working on 1.20.1. Thanks ! 😄
if anyone can help me that can be amazing 🙂
dismount them first
but i need them to be riding
I remember you from somewhere
i used to be active here alot
Hi! How do you create an explosion with falling blocks, so it's kind of easiest to make an explosion but make sure that no blocks are damaged or how do you usually do it? 🙂
Oh, also, forgot, we usually don't help with paper as we are spigot
Try a lower java version
but class 61 is java 17
Yes im aware
and it's not supported
