#help-development
1 messages · Page 366 of 1
That should be asked to a staff member, also wrong channel, this must only be use for programming questions
well what channel then
Maybe #general and tag a staff, to ask, maybe choco or any other
alr
Any resource staff should be able to help you
spawn itemframes with packets
Set the ItemFrame to fixed
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/entity/ItemFrame.html#setFixed(boolean)
declaration: package: org.bukkit.entity, interface: ItemFrame
If you need to prevent breaking of already placed ones then either update them on chunk load or listen to this event and prevent them from being destroyed:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/hanging/HangingBreakEvent.html
declaration: package: org.bukkit.event.hanging, class: HangingBreakEvent
Is there any difference between using item.setAmount(0) and inventory.removeItem(slot) ?
hi i tried < current players . but same :
in console i get only this message after 1 player left in arena :
[23:29:09 INFO]: Game is in finished mode
this is my code
Is this something not from Java 8, because the method DateTimeFormatter#format() doesnt expect a duration as input
Duration duration = Duration.ofMilis(36610214L);
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss");
String formated = formatter.format(duration);
System.out.println(formated);
Yes. Those are completely different methods...
A Duration is not a point in time so it cant be formatted like that
i think a piece of my code is whacking out because i am using setAmount
removeItem(ItemStack) removes the first item it finds in the inventory
Oh right, so must be an issue from ChatGPT
Right nothing to say just a fast reaidn help me to fix the issue
does anyone have idea?
my brain , there is no reason why it should not contiune the code :()
Ah yes, let's reject the patch of an embarassingly stupid mistake. Well, I guess it's all about manual patching then. I posted the diff, we can just tell that to people if they ask in here.
You tried! :)
I posted it twice, and it was above like so many chats so how could anyone else see it?
Yes, but i wont loss my time discusing with you...
Thank you
Ok 👍
Ask about what? I cant take my nap not knowing what issue happened
if i wanted to make a cutting board that you can place down, put an item onto, and right click with a knife to receive an output item, how would I go about that? is there a plug-in already out there that does this?
Building 1.8.8 javadocs, where they screwed up and referenced members with dot notation instead of hashtag notation. Somebody reported this today, I fixed it, somebody else created a patch request, and it got denied with the lovely message of "just update", smh
right
In my case doesnt allow to build 1.8.8 javadocs from BuildTools, is that related to it?
Somethings like this
re texture an elytra?
Isnt a mod that? 🤔
can't you just... play A LOT with vectors?
Yep but i want to make this as item
Oh well it wont be easier, you will have to play a lot with vectors as Ilussion has said
Nah elytra isnt what i want
basically slow fall + flyspeed
Sounds very specific. I would probably use a pressure plate, invisible armor stand with item on the head and then add a knife item to interact on that, haha
How i give fly speed on interact?
Using vectors
vector<uint8_t>
💀
It's worse: that's stdlib
I dont really now how to explain, but i suggest reading about then onlyne
oh, and we are not talking about java.util.Vector vectors
Those are some cursed vectors
even if the idea is the same
Alrrr
sorry my sintax, cellphone goes brr
How should I store information about a noteblock? Should I store the location of the block with it's information?
this looks like the hang glider is pushing the player upwards and forwards using vectors
Yeah, what we told him, but is reading what are vectors because didnt know about them
you didn't really mention the setting velocity /pushing player part
oh right i forget that my bad 😬 i just do my best for helping
im working on a rpg-like pathfinding algorithm. but i am having difficulty knowing where to start. let me explain the idea.
There are going to be paths from Locations to Locations and the player should be able to set a target location. the algorithm will then calculate the shortest path to that location given a list of paths it knows about. my initial idea was to have "path points" and when looking for a location it would first look for the closest path point and just do a whole lot of looping to find out what the best path would be. i am wondering if there is a better solution though. i have included a shitty drawn picture to explain the idea better.
The structure would look like this in java psuedocode:
public class Path
{
// begin / end
private final Location primary, secondary;
private final List<Location> pathPoints;
}
public class RpgWorld {
private final List<Path> paths;
}
Any ideas. to make this optimized or maybe a whole differect approach to it?
ps. sorry for the wall of text.
Search up some A* or Flood-Fill
does that work with a structure like this though
never meddled with any pathfinding before so
which would you recommend for my application?
Depends on how many nodes you have
hmm well thats gonna vary massively on different kind of servers
could be small, could also be a ton
Flood-fill is not an algorithm that can be used here
You likely mean BFS or DFS
uh oh algorithms
Flood-filling can be remarkably complex
hmm what would you guys recommend here then
rlly have zero knowledge about pathfinding yet
Dijkstra's algorithm will probably be enough
would prefer to go with something a little easier to learn, its just a hobby project and does not have to be of production quality
just tryna teach myself something new
For small amounts of nodes, BFS suffices
Since there is no notion of depth DFS is probably not ideal
what does BFS even stand for
breadth-first-search
hmm okay. i have no idea what that means yet. but it sounds interesting
Basically you iterate over all child nodes recursively until you find the node you'll want - once you hit it you know the path
does that get you the shortest path then tho? given there are multiple paths to a destination?
Pretty easy to implement for DFS (depth-first-search) (which basically goes in depth first) but it wouldn't return the shortest path, to make it BFS you'd need to basically create layers
just copy & paste some code from wikipedia
i want to know how it works a little bit tho haha
anyway, thanks for the information so far. i'll do some more researching
You can imagine it like a circle that is expanding gradually until it finds it's target
hmm okay. but don't i already know the target?
Uh, you can't really create a path if you don't know the target.
right
hmm, though looking at the graphic more closely you most likely want to find the path node closest to you
right
then i have to find out which route to take to get the shortest distance to the destination
However that doesn't mean that it is the shortest path (e.g. in your case it would first go south), so I guess you can be a little bit inefficient and just do the distance check on all nodes, skipping any that are already known to belong to an already existing path
yea thats also a problem. the node closest to the player might not belong to the path that is shortest to the destination
difficult
Alternatively you could use something like A* and give blocks near path nodes a smaller resistance value than those far away
I'd maybe make a system of crossings and intersections
That however means that the pathfinder could sometimes cheat and perform shortcuts that may go in the middle of the wild
If you have ever played cyberpunk, you will notice that the pathfinding algorithm they use is a bit choppy and tries to make you follow roads rather than going through buildings
Once the player is on the path it is easy - but once the player is in the wild it gets complicated
yea thought bout that too. but coulnt rlly think of a way to implement yet
For 3d space it's a bit complex
not really, you may have an obstacle in the way
Yeah I think I'd go with an A* pathfinding lib and set the resistance value of paths to be much lower than for other blocks
hmm
I'd probably go with a tree search adding weights to each path
It'd struggle a bit with mountains or otherwise impassable terrain if you go with a 2D representation
It's easy once you are within the tree - but the player may start far outside it
how would that work
weight each connection between nodes by it's distance
you then tree search connected nodes between start and destination adding up the weights
select shortest path
wher are you starting from?
since tis ^
example ^
The black dot in this example
you will be calculating to all near paths though
if you are not starting on a path/node
so i will be doing the tree search on each near path then u mean?
well where you start is yoru origin
you begin yoru tree search from there to each nearest path, then add weights in a tree search
How do you format a timestamp (represented via int or long) using DateTimeFormatter because the format method doesnt accept any timestamp rom what i have being seeing+
ah so u include the distance to the first node as weight?
yes
convert timestamp to Instant and convert that to LocalTimeDate
You probably can instantly convert from long to LocalTimeDate though
Also: Are you out of your mind to use ints for timekeeping?
hmm seems like a cool idea which i am able to grasp, think i will try this approach. thanks 🙂
Are you still trying to format a Duration? A Duration is not a point in time so you cant use a DateTimeFormatter for that.
that too
HMNN
So how i display in a cutom format?
A Duration or an Instant?
I was wondering to specif ask them to insert a format like: HH:mm:ss and then conver my timestamps into that format to be displayed
?
it shouldn't be too hard to convert it yourself
too much work and need to reiveint the wheel
asking is takes longer

this is just a String#split and String#codepointAt
What are those? I never use them before i iwll prob read about them
perhaps even with an underlying switch
Instant = Specific time
Duration = The difference between two times
hmm would it make more sensing throwing an exception saying that "some invalid stuff" cannot be parsed instead of one saying that the pi() function doesnt accept any params?
A duration is a timeframe. An instant is a point in time.
So an Instant because im keeping how much he has played on the server
Though not every point in time need to be an instant, which is where it gets complicated
An Instant is the amount of milliseconds since 1970
that is the de-facto standard definition
You cant represent that with a point in time
tiem played is a duration
epoch/unix?
Yeah
Okay and can duration be formated with DateTimeFormatter?
Is a duration a date?
No, its just a long or int value
The underlying datatype is irrelevant
i dont under you question so, im just saving how much milis he has played
So a Duration. So either manually format a String
public String format(Duration duration) {
long HH = duration.toHours();
long MM = duration.toMinutesPart();
long SS = duration.toSecondsPart();
return String.format("%02d:%02d:%02d", HH, MM, SS);
}
Yeah, it's not a date - but it CAN be a time
There is no buildin java functionality for duration formatting (as far as i know)
If you want to you CAN use LocalTime or similar but it is a hack
well just pass in the format then
fkg java
This are the reasons that Js libs are better designed and make it a better lang for working with rather this oddy lang which you have to make everything for it
DateTimeFormatter would at least be able to format and read LocalTime
¿
Im not even gonna bother commenting this. Just take it a a typical Verano comment.
HOWEVER there is a catch with timezones
It's dangerous but if you really don't want to write a few lines of code you CAN use LocalTime
Im mainly looking a way to conver long/int durations into the formats like: HH:mm:ss/HH/mm:ss/ etc. Is not diff the question
It will not be able to store more than 24 hours though
For anything under 24 hours, LocalTime CAN be used
then write a method that formats it...
I have an util for that
But really it is more meant to store a specific time at an unspecific date
But i cant because the format must be specified by config
yea so?
Can i see it¡
A>Fgnköklefvdbjaslmnnbjdm,bjkbum
get the format from the config, use it
?
Not today
right
Ok we get it
No need to scream
You can even work with DateTimeFormatterBuilder - only issue is that you can't easily convert a LocalTime to a Duration
He?
I just want to format my timestamp to a format similar to DateTimeFormatter ones
Its not diff to understand, you are just giving circle walks on something simple to explain
Yeah use LocalTime
It's the wrong choice but you want the wrong choice so I give you the wrong choice
Don't complain that LocalTime breaks on intervals of >= 24 hours
I really don't understand what is so hard about getting seconds and dividing it
Because i need to parse timestamps bigge rthan 24 hs
then do it yourself
I cant bruh, because they must configure themself the format
DateTimeFormatter CANNOT work
/**
* Format time in "X days Y hours Z minutes Å seconds"
*
* @param seconds
* @return
*/
public static String formatTimeDays(final long seconds) {
final long minutes = seconds / 60;
final long hours = minutes / 60;
final long days = hours / 24;
return days + " days " + hours % 24 + " hours " + minutes % 60 + " minutes " + seconds % 60 + " seconds";
}
here just take this, modify it a little bit to use a format configured and be happy.
unless you go the insanely stupid move of using LocalDateTime...
But as I said, INSANELY stupid
right i know how to do it, but i cannot since they must configure the format
You can easlу make it configurable
bruh what is the problem then i dont get it
get the format from the config -> use it
And ho you format it? because i cant use DateTimeFormatter
istg
i have just shown u?
i want the normal formts
Like: hours:minutes:seconds, hours:minutes, etc
yea i also told you "modify it a little"
SO there is no class for this shit right? 😡
DurationFormatUtils.formatDuration(millis, "**H:mm:ss**", true); From Apache Commons
public String format(Duration duration, String format) {
String hh = String.valueOf(duration.toHours());
String mm = String.valueOf(duration.toMinutesPart());
String ss = String.valueOf(duration.toSecondsPart());
return format.replace("hh", hh).replace("mm", mm).replace("ss", ss);
}
Its literally not black magic
int hour = 0;
int min = 0;
int sec = 0;
int ms = 0;
for (int i = 0; i < format.length(); i++) {
int format = format.codepointAt(i);
swtich (format) {
case 'H':
hour *= 10;
hour += Integer.parseInt(string.codepointAt(i));
break;
// ....
}
well there you go
are u kidding, is only that 🤦♂️
Of course it is that easy!
why didnt just sent that from the start instead of rounding around a circle, it was going to be faster for all
cuz we dont want to spoonfeed
Apache Commons is shaded with Spigot
oh right, so i ill use it thanks
thanks to all in general
Yeah apache commons has a util method for that. But is it still shaded? I thought its gone now
2 is included or 3 I forget which
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/time/DurationFormatUtils
Fkg spigot 😡
depend on Spigot not API or add the dependency with a scope of compile
error given on server, not while testing thru IDE
Yeah lets shade in half a megabyte for replacing 5 lines of code 😄
Agree
That why i asked if java didnt already implement something like that
commons lang is still useful tho
I mean currently java is being really oddy compare to other langs, i would think why spigot is till coded over Java. Because in others langs you have all the commons utiltiies you will need for parsing durations, dates, etc without harcoding like Java
it only takes like 5 lines to make a method that does this for u tho
If you would have worked properly with other languages and Time related problems then you know that
Java has a very decent approach (post java 9 at least) in comparison.
Decent aproch, oh please, javascript that is even easier to learn has everything for parsing timestamps or dates, and java that is a more complex lang doesnt even have it, so the problem is the lang
please dont compare js and java
JavaScript -> inconsistent nightmare or needs 500mb of node modules
Python -> inconsistent nightmare vanilla but has some decent libraries
C++ -> horribly complicated
C# -> decent
Java -> decent
Rust -> complicated
Additionally very few java projects suffer from Y2K38
what is that? I
Bug that will occur in 2038
overflow ?
Yeah
JavaScript doesnt even have the notion of what a Duration is... What are you even saying?
Y2K38 is the prime example why timekeeping and int don't mix
All you have are milliseconds in js. For everything else you need massive 3rd party timing libraries
That onyl with plain Js, in Deno have fixed all that issues
also making spigot in anything else but java would have been a pain since it kinda needs to interface with minecraft java edition xD
no? Cant you recode the whole server, its a protocol
XD
barring some exception like maybe kotlin
See Glowstone, Minestom and Cuberite
yeatthat hy
MCHPRS is perhaps also another example of why you can't just reimplement minecraft
i will read what is that MCHRPS
There is actually a C++ minecraft server implementation out there
I see
(Cuberite being that implementation)
good to know I guess
I see. Never bothered looking upt the name.
but it must not have been easy
MCHPRS (Minecraft high-performance redstone server) is a more specialised server, but it is written in Rust apparently
Meh. You can probably code up a barebones server in js/java/kotlin/python etc in a week or so.
it apparently has worldedit
and luckperms, pretty cool
anyways ill leav now xD
If only writing plugins for that would be possible. I think Rust is a pretty cool language.
there also used to be truecraft if you are into that sort of stuff but it wasn't maintained for AGES now and I don't know how good it was
woulnt that technically be possible then?
if someone decided to create a whole api for it
this also exists https://github.com/valence-rs/valence
And how would the plugins be loaded? How would IPC be realised?
no clue 😄
Ah i see they use Bevy...
Which means you would still have to recompile the whole server with all your plugins
What's the difference between Player#hasPermission vs Vault's Permission#has(Player, String)?
One is a static reference and the other isn't. Usually use Player#hasPermission
I just checked and Vault just calls the bukkit's method lol
Algarl doesn't hasPermission still return the same?
Neither is static
Player#has will test active permissions on teh player but will not test against wildcards
oh true, yes
Vault#playerHas will support wildcards as it direclt queries the permission plugin
wdym by wildcards?
no
Some people get confused because they use LuckPerms and it uses reflection to replace PermissibleBase and as such wildcards work using Player#has
Chat gpd doesn't access the internet
none of the sites work lol
Just use Bing 
Chatgpt doesn't have access to anything past 2021 cause it doesn't actually connect to the internet
Watch this
https://www.youtube.com/watch?v=llonR885bMM
Luke and Linus try out the new Chat-GPT-enabled Bing.
Watch the full WAN Show: https://www.youtube.com/watch?v=AxAAJnp5yms
► GET MERCH: https://lttstore.com
► LTX 2023 TICKETS AVAILABLE NOW: https://lmg.gg/ltx23
► GET EXCLUSIVE CONTENT ON FLOATPLANE: https://lmg.gg/lttfloatplane
► AFFILIATES, SPONSORS & REFERRALS: https://lmg.gg/masponsors
► O...
kek
Som1 have an example how i can give effect on armor equip i try a lot of things with protocol lib and it never work
https://paste.md-5.net/ezaledoyif.java i try this
but it do somethings weird
how can i execute a method on other thread and receive the result of the method
you can't without waiting for the result.
ie locking the first thread
usually you would call a method to pass the result
i solved it, i just used bukkit runnable
@EventHandler
public void AsyncPlayerChat(AsyncPlayerChatEvent e){
Server server = e.getPlayer().getServer();
server.broadcastMessage("test1");
System.out.print("test1");
for(Player p : Bukkit.getOnlinePlayers()){
System.out.print("test2");
System.out.print(p.getDisplayName());
if (e.getMessage().contains(p.getDisplayName())){
System.out.print("test3");
Player player = p.getPlayer();
e.setMessage(e.getMessage().replace(p.getDisplayName(), ChatColor.YELLOW + p.getDisplayName()));
player.playSound(player.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_STEP, 10, 29);
}
}
}
any idea why this doesn't work? none of the tests show up and there's no error
Have you registered event?
they're good audio books if you can't fall asleep lol
Hi, I'm trying to make a particle line with this code:
Location loc2 = player.getLocation();
Vector vector = loc2.toVector().subtract(loc1.toVector());
for(double d=0; d<vector.length(); d+=0.5) {
vector.multiply(d);
loc1.add(vector);
Particle.DustOptions dust = new Particle.DustOptions(Color.LIME,2);
player.getWorld().spawnParticle(Particle.REDSTONE, loc1,15,0,0,0,0, dust);
loc1.subtract(vector);
vector.normalize();```
But this doesn't make any line, it just spawn all the particles in the start location. And that's probably because the loc1 value never changes, but I don't know why xD
Why do you normalize the vector after?
Pretty sure you want to do it before and also might want to multiply a large value after normalizing
ok, will try
Is there any nametag library that can be shaded that's decent enough to change them?
NametagEdit works perfectly but it can't be shaded cause it's a actual plugin
I can imagine lol
But that didn't work for what I needed
Do you have any idea?
Man nametagedit works perfectly
is there no workaround to shade it and not cause any issues?
Wait, isn't a nametag just a change ion the display name?
Can I not use p.setDisplayName to make my own nametags or am I missing something
Where is that from?
Thought so
Damn
I guess time to see how nametagedit does it
Fake teams...
Oh god
Yeah no
?
Well technically you can't just shade an entire plugin no?
You can, but most times plugins require being initialized to work properly
Yes I know that's what I've been doing
I want a workaround to use NameTagEdit API without having to put the plugin in the plugins folder
Just modify the main class to not conflict and feed it whatever it needs in the classes
And voila can shade and best part is you can probably do all this using maven lol
Wait so I can actually do that
I add something in my main that checks if the plugin happens to be installed
If not, use the shaded one?
How would I do all of that using just maven?
Why check at all. Just use the shaded one since it wont get initialized. As long as you relocated there should be no issues
O
Ok ok I like this idea
So to use maven with a jar I gotta install the jar to my local repo first, right?
You can use a configuration to modify the class with easy search and replace
So you would remove the java plugin thing, and the relevant methods in main. And then you would just hand what the classes need from your main
Relocate is necessary so the package is not the same as the plugin that might be on server
Have fun 
I have a small idea but a bit confused still
I need to read on that configuration to modify the class first
Wait did you give me 2 different ways of doing this? Or is the whole thing the same idea
How can I edit someones elses code from their main file just like that?
Because recompiling is a thing and if it is an api it will have sources
Sources are basically the uncompiled version of the jar but packaged in a jar
Api would be hard to use if it didnt have sources lol
Oh ok so I clone the plugin. Then do the changes. Then save to my local repo, Then use maven to import
If you really wanted to you could also clone their repo into your plugins repo and then have your pom to treat that as a module to make it easier
This isnt necessary
Sources jar is something provided in maven repos typically or included in the api jar
You would pull those out make changes toss those files into your project where you want them and compile
But you can do it the way you said too
Yeah the sources are probably attached to the jar itself
I kinda wanna learn your way. Seems to be something useful learning on
I only see class
There is multiple ways to do it lol
Their main class has a bunch of stuff going on
I don't even need 90% of their actual functionality
Its not important in what is going on in the main class rather if anything depends on main class exclusively
I literally need 2 methods from their api lol
If not then you can handle what their main class does
You know, following the path of stuff that happens from the api calls
It doesn't seem like it does need the main class
Typically not
Except just passing plugin reference
That's what I need
Ok so
If I don't need the main class
Can I just exclude and test first?
Sure, but might need to pass a plugin reference to relevant classes
It doesnt matter that it isnt their plugin reference just that one is passed
How would I make those changes then
Pass your plugin reference when creating an instance of the class
Wait wait back up.
Since there are no sources in the jar
I first need to get editable code
Reason most times which plugin reference is not relevant is because they are most times just making use of methods provided by JavaPlugin
Ok no lets try this other method instead
I wanna try the clone, change and local repo
Up to you lol
I need to understand this way first because I happen to believe it's a bit easier to understand just not better to do
Possibly
Ok so what exactly am I trying to do with his main class
The idea of this is what
To not have duplicate plugin loads?
So the easiest route is to just change your structure to have modules
Oh god more stuff lol
Basically
Can't I just change the plugins name and some stuff and make it be NameTagEdit2?
Is that terrible idea?
But once you remove that some methods are no longer valid and wont compile
Unless you do bytcode manipulation
Man I want to cry
I knew this was complicated but not this much
So then the clone and compile method won't work correctly
Well clone and compile is the easiest because you have java files to work with
So when you say, some methods won't work
Am I just supposed to straight remove them?
Until the whole thing compiles? lol
All you have to do is just remove their main class and ensure main class references throughout are changed to yours
And then compile
If it isnt needed nothing. If it is needed add it to your main class lol
Alright I understood that part
But only add what is necessary which is most likely not going to be everything
Now when you say change each plugin deference
private static NametagEdit instance;
You mean change that to my class?
Yes or make it generic plugin
But how can I change that to my plugin if this still doesn't have knowledge of my plugin
Like I have the plugin cloned, I can't just make it be part of mine
It won't compile to even add it to mine
As i said most times they use main class for the javaplugin methods and not because of something specific in main class
I know I'm making you pull your hair out rn
But I can't seem to understand what the changes need to be hands on. I get the idea of what I need to do. Just not how to do it
You do know when you extend a clas you inherit the methods from that class and any classes it also extends
So most times the reason they use their main class is to get a plugin reference which contains methods like getconfig
Yes so far so good
If that is all they are doing you can just create a generic plugin object to pass
I will be home in a couple of hours
original doesnt have shaded stuff
somethings being shaded, i doubt a jar can be 2mb without it
?paste
Oh yes, 1
its that
best to use the one that is BetterPrefix-1.0-SNAPSHOT.jar
without shading anything they will be the same but shading anything would cause original to be different, idk the point of -shdaded but that would be identical to the no additions
When I make my plugins I should be using spigot api right?
Cause currently i'm depending on paper and it suggests to change setDisplayName() to displayName(Component)
yeah
But spigot doesn't have components meaning if I do that, It won't work on spigot, correct?
depend on spigot/spigot-api and it works on spigot and paper
Gotcha
Ummm
How does https://github.com/wikmor/LPC
Have a command without registering it
It's only in plugin.yml
Oh wait
Do commands in main file
Not need to be registered in onEnable()
?
i do know JavaPlugin implements CommandExecutor
but im pretty sure commands still need to have their executor assigned
Indeed it goes to JavaPlugin
Lets check rn
That's kinda cool
Had no idea
Works without needing executor
huh. interesting
idk how the plugin would know which command to assign then but okay
I guess if you only have 1 command doesn't really matter?
fair enough. but what if u have multiple
I mean like
If you have 1 global command
Not subcommands
Cause you can have /command <subcommand>
As many subcommands as you want
But it works perfectly rn with multiple subcommands
Which is still interesting
yea true, but im still interested as to how this would work with multiple normal commands
Probably won't
You might get an error on enable
There is a reason that the arguments have a Command command
is that really the reason?
Yes?
so u dont have to register in the main class?
xd
Well, not the entire reason
i guess u could assign multiple commands to the same executor tho
and it'd work the same way
tho i would never do that
New challenge:
Making an entire plugin in 1 file
Does ChatColor#translateAlternateColorCodes remove whitespaces?
probably not
I'm trying to set a players displayname to
player.setDisplayName(colorize(prefix + " " + player.getName() + " " + suffix + ChatColor.RESET));
And it's not adding the space
idk, but thats not from ChatColor.translateAlternativeColorCodes
its always worked fine with spaces
Is there a Composter version of CauldronLevelChangeEvent?
@terse pumice Composters only work when a player interacts with it right?
They don't just update "randomly"
Player interact and hopper
Well I have a way to do it but it won't work for hoppers, just players
So probably have to wait for someone else
I know of a way to do it, it's more whether there is an event that I haven't spotted
Hmm alternatively is there a way to see when an inventory updates, I only particularly need to know when the bonemeal is being generated in the composter's inventory
might well just do a BlockPhysicsEvent and do a check to see if it has an item in it
I think that doesn't work with what I've read
valid
I'll just manually work out the ways of the item exiting the block and if I miss one I am sure someone will report it to me aha
hi
i have a few questions about indexing on sqlite.
so
in the documentation i was reading, it states something along the lines of "indexes are ordered by the first column, the second column, the third column... and so on".
what does that mean? Is it like if i have a composite index with (colA, colB, colC), it optimizes queries for colA, (colA, colB), (colA, colB, colC)? Same as how indexes work in MySQL perhaps?
It basically means that if you have an index on (colA, colB) then a query on (colA, colB, colC) can be optimized
but if you have an index on (colB, colC) a query on (colA, colB, colC) can not be optimized because the first
queried column does not have an index to optimize for.
And for standalone queries: Yes composite indicies help with the speed of single column queries (eg (colA, colB) index speeds up a colB query) but its nowhere as
fast as a single indexing on colB
Hm just thinking about if this also applies to sqlite
Probably
I am home now
You can basically imagine that there is a new Map with the key being the columns that you have indexed and it now being faster because you don't have to use the List anymore.
That's not how it practically works, but it makes it easier to understand
Do you feel like retaking the issue I had earlier @wet breach. I can understand if you got other stuff to do or just don't want to
He has a concern about composite indices which dont really work like a map. More like a tree.
so where are you stuck at
The hands on part of what you suggested to do lol
Ok so, you said to change the plugin references to mine and remove the extends javaplugin
if you dont extend javaplugin youll get an exception
unless youre extending the main class of your other plugin but i wouldnt bet on it
can't have 2 extend JavaPlugins
But then I do need to clone the repo and go from there, correct?
so easiest way to start with this, is to restructure the project. Need a parent pom, then you have modules. One will be the plugin you want to depend on and shade
the other is your plugin
make sure the plugin you want to depend on is listed first for module because we want maven to do stuff to that first
Ok let me do the restructuring first but I've never done parent poms
super easy
that repo has it setup where it has a parent pom and the plugin and api are modules
OK sick
Wait as a side note
That's your plugin? jesus I remember it
That's so sick
my solution is to just copy pasate whatever project i had last time
Oh wait nvm it's a fork XD
its a fork because the original creator is HawkFalcon but the majority of the code is from me, and he ended up giving me full ownership
2 questions but regarding intelliJ
so it is indeed mine 🙂
That's so sickkk
Like in the example, serverTutorial and API are 2 different packages/folders whatever
yep
Do they go straight under the project?
Just folder
Otherwise intelliJ has a module thing
And that was my second question
after you done with the directory structure you are going to change the top level pom, which is what is currently loaded
so that it is formatted to be read as a parent pom
do the restructuring of the directories manually
so while in BetterPrefix directory, run the git clone command for that plugin you want as a depenency
it should create a directory for it
In the nametagedit folder
and then create another directory to stick your plugin in, and call it BetterPrefix-Plugin
move all the sources and everything for your plugin, into that new directory
including the pom
make a new pom, and structure it to be setup as parent pom
modify the pom of your plugin so it points to your parent pom
and then you will do the same with the nametagedit pom
then tell intelliJ to reload the pom or just close and open the project again
and it should make it appear in the IDE properly
https://paste.md-5.net/icikohipux.xml
parent pom
And added
<parent>
<groupId>me.tsans</groupId>
<artifactId>BetterPrefix-Parent</artifactId>
<version>dev-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
to both child poms (I hope that's enough?
because when you compile from the parent, you want maven to do things to NTE first
now, I don't know the code for NTE, but either you manually remove the main class and fix the rest of the references, or you can use maven plugin to do a replacement using some regex or search and replace
Wait I have an issue before that
Inside NTE
Probably something to do with my poms
Does it not matter that it can't find those?
find what exactly? the imports?
Yes
not really and its most likely because in the NTE pom it has possibly an api version then what you currently have available
which you can fix
easy way is if both the NTE and your plugin use the same API version
just list that api version in the parent pom as a dependency
and it makes it listed for both automatically 🙂
I can do that?!
That's sick
ok brb
sub poms inherit anything the parent pom does, and when you add the same thing to the sub poms it means you want to override the parent
Does that mean I should add both the repo and dependency straight to the parent?
you can yes
me.tsans:BetterPrefix-Parent:pom:1 was not found in https://oss.sonatype.org/content/groups/public/
uhhhh
did you try to build?
I tried reloading the poms
So it's missing
import org.apache.commons.lang
But as far as I know the package changed for newer versions
Meh there's a vulnerability but who cares. I just added the old version
xd
OK Frost when you're back you're gonna be proud
now, I don't know the code for NTE, but either you manually remove the main class and fix the rest of the references, or you can use maven plugin to do a replacement using some regex or search and replace
Does this mean I need to manually change every single instance to now be my plugin?
good luck lol
you don't have to manually do it, you can use the maven replacer plugin
and use some regex
i know that bit, but what column pairs is it indexing?
I wanna do it manual just to check
probably best
what combination of column pairs am i gonna have optimized queries on?
o.O
Am I dumb?
I am not sure what it is in reference to
But I can't actually add an import
For my file
Because it gives me a warning about circular something
yeah circular dependency that will never be satisfied because you are depending on betterprefix which dependes on NTE
press tab and autocomplete and let the ide do an autoimport thing perhaps, for that sort of issue.
i just do that and it seems to work most of the time.
So what do I do then to be able to make the plugin reference be mine
which is why I said, you should see why it needs a JavaPlugin Object, if they are not making use of anything specific in the main class, you need to use a generic Plugin object
What's a generic Plugin object
this way from your plugin, when you got to initialize those classes you can just toss your plugins, plugin object and it will still accept it
Plugin plugin
instead of (Mainclass) plugin
It does some stuff like plugin.debug
So instead of just removing infinite debug lines
I think generic is the way
private static JavaPlugin thisPlugin;
public static Logger logger;
@Override
public void onEnable() {
thisPlugin = this;
logger = this.getLogger();
}```
or just keep their main class
but remove onEnable() and onDisable() as well as the extends
And call an instance of their class from my onEnable passing it my plugin instance?
or better yet if you want to use your main class don't worry about the errors
and don't compile the plugin
the code i posted above works for me.
My head is exploding
for getting the main plugin class.
Ok I like that alternative too
Lets try that
So I assume keep everything and ignore the errors
wait that won't work lmao
My head xd
give me a sec
Oh yeah we need an instance
what are you guys trying to do here? i am a bit lost.
I need to depend on NTE but I don't wanna have to add the jar to the servers
So I want to include it entirely in my plugin loll
NTE?
hey
just download the plugin from the source maybe?
I know sgtcaze
then use it.
lol that's funny
That's what we're trying to do
they showcased both my plugins 🙂
the plugin isn't designed to work being shaded
well to be fair some people (me) dont design plugins with other people in mind
true, doesn't mean someone can't make a build setup to accommodate such things
My plugin is literally 1 file 4 methods and I need to add this entire thing to make it work
yeah have to go with the generic object
but, for the debug stuff you either remove it, or fix it to point back to the main class that isn't a main class anymore
Yes
Exactly what I was gonna ask
Ok remove it is
brb
Do I make it extend anything?
public class NametagEdit {
private static Plugin instance;
instance = this;
Obviously gives an error
Wait what method is this. Is this where I remove their main file. Move it to mine?
main class extends javaplugin
then this isnt a plugin instance
whats the problem
wdym "how would I use generics here"?
simple
I need to depend on NTE but I don't wanna have to add the jar to the servers
So I want to include it entirely in my plugin loll
ask bukkit to give you a plugin instance of a particular plugin
aka mine?
shading it?
It's not made to be shaded
then add it to the server?
That's what I want to remove
Bukkit.getPluginManager().getPlugin("Plugin Name")
Ok let me try changing all to generic then
you cannot just steal the inner workings of another plugin and put it into your own o0 at least not without sticking to their license: https://github.com/sgtcaze/NametagEdit/blob/master/LICENSE.txt
"you cannot"
he is not
will everyone stop making assumptions o.O
...
6 hour conversation going on here
Frost if I do instance = Bukkit.getPluginManager().getPlugin("BetterPrefix");
then methods like getLogger() won't work.
what logger
what else is meant with "include that plugin in my plugin without installing it on the server"?
Bukkit.getLogger()
I see where this is going ok
Hello friends , i have something a bit complex to do :
i have a (Registered arenas in a list when server start it load them )
ok so what iam trying to achieve is :
1- broadcast a clickable message (done)
2- broadcast the arena name , minimum players/maximium players(done)
3- if there are no players in any arena (get the first arena loaded in the list and broadcast that arena) , if there are other arena with players broadcast that arena (not done)
so my problem is with
3-
if there are no player's in any arena (Get the first arena in the list of arenas that loaded when server start) , if there are players in lets say an arena named Vortex broadcast that arena insted bcz it have players
make each arena keep track of the players in it, then make a method for said object to obtain that number
then when you iterate the list you can use that to compare
id do some stream stuff
this is the broadcast :
this is the method to get the avillable arena :
i use them both in a runnable
just for testing , i set it to 5 seconds
but the thing is :
player will not be able to join throw a command
only throw the broadcasted message
he will click on it and join
so in other words , there will never be a players on any arena
well first problem
instantiating bukkitrunnables ew
you are setting online to the same number of players in a arena
and how is that wrong?
unless online is being used differently then what it would typically mean
why doing getter on fields if whole class has getter annotation
so using it backwards then got it lol
i forgot to remove that
What prevents you from getting the amount of players from the list instead of manually counting up/down?
Also: Never ever create getters and/or setters for collections or data structures.
It will always lead to very fragile design.
Tremendously important to never expose data structures
^^
Ok @wet breach.
Did all that. created an instance of nte and then started stuff. How do I now use that in my plugin import
you need to build NTE
alright thanks
and get it to successfully compile and install to local maven repo
which your plugin should be able to use to depend on
Why did I go out of the way to make parent-child poms instead of just doing in a separate project
Ok I installed it
because you wanted to try it the manual way first
I was going to tell you additional things where you don't have to do it manually lol
you could just have a maven plugin take care of most of that for you
It was fine I used find and replace in files
Will look into that in future seems useful
maven replacer plugin will do a find and replace
and then if you specify a regex, it will do special finding and replacing
Pretty dope that stuff like that exists
.
Do I do normal shading as I would always?
Well if NTE compiled, now you can shade to your plugin
and its just normal shade plugin setup with some relocating
and then once that is done, run from the parent clean build
Need some assistance with the reloating part
and see if it all works 😄
plugin
I assume pluhin
thats how you relocate
Ok then it was something diferent than that I confused the terms xd
once you get this setup you can try a semi or fully automated way, and then its just a progression from there with more efficient ways
and then once you learn some of that, then anytime you want to include something like this again where its a plugin but not designed to be shaded you could easily set something up and pretty much does everything that needs to be done to get it to shade XD
So I got a class implementing Listener, and in its constructor I register that listener, but it doesn't seem to work. Is that actually a thing you can do, or should I register it outside the constructor?
so what activates the constructor?
well a class constructor doesn't magically run on its own, something outside of the class has to initialize it
Yeah of course, I create the object
you create the object and it doesn't register the listener?
No, its really weird
?paste
It concerns about 3 classes, kinda hard to paste
oh copy them
Can I copy them somewhere where they work but they cannot be accessed by user?
Is there any more effective way to check if the block at a specific coord has a direct access to the sky, other than checking all blocks from top to bottom?
So small explanation, I create a new MissionEditorMenu in MissionEditor, which extends from GUI, and GUI implements Listener
Using spigot api, ofc
anything on a users system is accessible to them 🙂
you could but requires modifying the code to handle such things
So not worth for now
and wouldn't really make the file editable without more modifications
either change NTE's config name, or you use a different name other then config.yml
Hello again , this does work , but is it efficent?
ok
But I do need to copy the /yml files directly to where my plugins config.yml files are
Yes I was gonna do that
if no players in any arena , it will return the first arena in the list , if there are players in other arenas does contain players it will return that arena
it is the easier option, or just copy whatever is in the config.yml for NTE into yours
yup
you have an odd setup
just get index 0 or smth?
Wouldn't surprise me lol
mmm?
in the first check or second check?
else return right?
/**/ you mean?
Letters with lines
since the abstract class isn't actually implementing any listener methods, move the implements listener to the class that extends gui
What exactly do you mean not implementing? I might be missing some info on abstract, not sure
well you don't have any EventHandler methods in the abstract class
I do right
Its those inventory events at the bottom of the GUI class
I put a comment there
return arenaWithPlayers.orElse(arenas.get(0))
I would still move them to the actual class that is doing the implementing
its quite possible the abstract is messing with it since it can't initialize the class
Yeah thats what I was thinking
