#help-development
1 messages · Page 1865 of 1
oh lol
Nozemi yours isn’t bad but the comment is redundant, it could be just extracted to its own method where the name of the method is explanatory such that it can express your intent of the code
yeah, I just added it to clarify for those who aren't familiar with Kotlin
Ah alright
you should only add comments when you fail to express yourself codewise
@dense heath still participating?
Hurry up
Yeah
6 min left
Oh ok
but yeah, my idea is to implement something similar to what you have @waxen plinth, with your command files and what not
You could use mine 👀
It's mature and stable and Blockchain and tech stack + many other buzzwords
but what if I want to do more? 😮
Like what
it's open source fwiw, so I guess that could be done
It has a pretty huge feature set
idk, it's also nice for the sake of learning to implement my own
Red is there a highlighting color plugin on idea for your command file format thingy?
Yes
if I implement my own doesn't mean I have to use it
For intellij
That’s very delightful to hear
---
- name: "command_name"
description: "This is a testing command."
actions:
- name: "test"
type: "send_message"
arguments:
- name: "message"
type: "PLAIN_TEXT"
value: "Message content. "
- name: "message_additional"
type: "PLAIN_TEXT"
value: "More message?"
- name: "test2"
type: "send_message"
arguments:
- name: "message"
type: "PLAIN_TEXT"
value: "- New message?"
- name: "command_name2"
description: "This is a command that will broadcast a message."
actions:
- name: "broadcast"
type: "broadcast_message"
arguments:
# Broadcast a message
- name: "message" # Can be whatever really, it's for placeholder targeting.
type: ""```
Isn't it?
I did this for testing purposes 😛
Someone else made it
Haha free stonks
Skript
Looks like a scalable format so yeah cool altho I hate yaml for other stuff than readable and volatile shit
yeah, gets out of hand if I want to add lots of stuff to my command
this is just a proof of concept though
I don't like how you do arrays
not sure what that is, sounds like a scripting language for Java?
Like nothing personal, but yaml specs are just too diverse
It's a scripting language for spigot
It's a shitty scripting language for plugins
oh!
I was planning to make my plugin able to load .class files from plugin directory tbh
parsing this will also be a pain too
Yeah
whether it's any good or cool in use is another story
I have a library that helps with parsing though
nah, works well, I use Jackson for parsing
If you want to make your own format
Yeah but gson isn't really about speed
mhm
Just don’t use json simple and it’s pog
Jackson is simpler imo
Bk better hurry up
for FileConfiguration what would be the best way to delete a value / location in it? just by setting it to an empty string or what
Set it to null
Times out
kk ty
I have another challenge ready for the next round, or someone else can suggest one
make google
Just started writing code, had to grab some of my old code lol
You want painful YAML script?
but yeah, I can definitely manually register event listeners and commands, but I'd like to have my plugin base class automatically do it
abilities:
- triggers: TICK
effects:
- ITEM_COOLDOWN(user,shield,1200)
- triggers: ORIGIN_ADDED
effects:
- 'ADD_ATTRIBUTE(user,so:shell_armor,generic_armor,add_number,4)'
- 'ADD_ATTRIBUTE(user,so:no_legs,generic_movement_speed,add_scalar,-0.2)'
- triggers: HAND_ITEM_SWAPPED
conditions:
- IS_SNEAKING(user)
effects:
- SHELL_SHIELD(user)
- triggers: ORIGIN_REMOVED
effects:
- SHELL_SHIELD(user)
- 'REMOVE_ATTRIBUTE(user,so:shell_armor,generic_armor)'
- 'REMOVE_ATTRIBUTE(user,so:no_legs,generic_movement_speed)'
- ITEM_COOLDOWN(user,shield,0)
- triggers: ENTITY_TARGET
conditions:
- TARGET_REASON(closest_player)
- ENTITY_TYPE(opponent,shulker)
effects:
- CANCEL_EVENT()
Enjoy
damn 😛
Looks scrumptious
You know, I want a file format which doesn't use indentations, but also doesn't have so many curly brackets its hard to keep track of
and also doesnt use - on every new line
Lisp
HOCON I guess
Yeah but python is interpreted
Believe toml might be your answer
Cant hocon specialize in a various amount of identifiers
HOCON or TOML, but if it's really simple, regular properties will do the job
Noz, up for another round?
is there really any point? 😛 I need to work out my library before
will be more fun when I've developed my library more
Mmk
You could decide to not make a command
A library for making parsers
Ah
nice
You know, i want a gui library which uses files
Here's the format for json
That’d be amazing
Like a lite declarative format
Mhm
I wrote a JSON parser in <70 lines with this
Perhaps I'll add support for other file types later, but for now YAML is what most people know
but for this stuff I'll probably eventually make it able to just load .class files from the plugin's data directory
Yeah, it’s not bad when you simply parse it to get data and have a readable format
would end up being plugin(s) for my plugin lol
Hmmmm
but for writing, I’d say terrible
i hate how some server providers have a "configuration files" tab and it only shows files ending with .yml
so annoying
Why not an abstract recursive configuration factory
full control myself
Hi md
Redlex seems pretty impressive
Much more advanced than the average thing you see around here
lol
Well to be fair
The average thing you see around here is an NPE with "help pls how do i fix eror"
heh
what about array index out of bounds? 😛
Well I'd argue RedLex is indeed much more advanced than that 
In spite of this; looking through threads there aren’t many about NPEs
is there a way to save custom ints to a player via persistentdatacontainer or can i save data to their user.dat file? or no
k ty
PersistentDataType.INT or smtng should do the trick
Integer
i thought you could just didnt see it in javadocs entity.player
Yeah NPEs are surprisingly uncommon but it's about the same level of what is often asked
Maybe I'll make some kind of program for people to edit this format easier
It's tough because I understand that many people want to use spigot as a way to learn java
Or like, a VS code addon
Hmm yeah true
But while it can be a good motivator by giving more interesting projects
It's not exactly the best way to learn java, it's like jumping in the deep end
I can attest to that
And that can make it frustrating to help people
I just feel like people become way too reliant on help channels like these ones before they’ve even tried for themselves
Help vampires

Term I learned recently and have been using super often ever since
Vampires?
No....
🥲
Help vampires, people who rely far too heavily on help/support channels and basically use them to outsource their work rather than learning
reminds me of someone asking in a help channel for something really simple about Git... I told them they could easily Google for an answer, and they responded "yeah... except I need this for some work stuff! so I'd like an answer here thanks!"
🥴
Entitlement is a terrible thing to have when asking for help
Whenever I ask for help I just always remember that I'm the dumbass in the conversation
Pretty sure I'm done with my submission
Would someone like to test for me? I don't have the latest stuff on my partition
here it is
Let’s have a look bk
No worries if it doesn’t work, I’ll merely look at the code as is
Yeah let's see it
?paste

Little bit bigger than that will allow for lol
Oh
wat
Then you already lost
Interesting
It's just a smite command lol
Hit or miss
You'll get it when you see it lol
Oh boy
🌝
Gonna be in binary
AbstractSmiteCommandFactoryController
Whoops! Forgot the plugin.yml :)
Do we really need that
Well, if you say so!
Yeah we are not gonna test your plugin in an integrated way
^
mhm
Oh so should I get rid of the unit tests, then?
We're just here to review the code itself
you did unit tests?
Lmfao
Send them tho
I was joking, I'm not going to formally verify this at all lmao
paste your code in code blocks in Discord, they shouldn't be so long, right?
Lol alright
uhhh
uhhhh
But we’ll if you did tdd then unit tests should be submitted also (:
Second challenge when
Going to put it in a repo!
dude
Red I can do one tomorrow
Let’s do an economy command interface then (: a bit more challenging and time consuming
Well I have covid and am stuck in one room on my phone lol
oof
Okay maybe not then
I'm visiting my girlfriend
oh
Got covid probably from the plane
That sucks
:(
Annoying because I took every precaution and the other people were so nonchalant about it
Damn anti vacc people
I have my booster and wore a really high quality single use mask and never once took it off to eat or drink for 10 hours
people generally seem to have forgotten all about covid by now lmfao
First time?
Lots of other people were just taking off their masks willy nilly
Yeah honestly covid's a bitch when you're boosted
It's the confinement that sucks
double mask
All I'm really feeling is a mild runny nose and sore throat
Gotta get that AbstractAbstractMaskFactoryFactory
my friend was legit considering triple masking
Why
Lol tf
Well my mask is effectively n97
I was double masking after a classmate near me started coughing shit everywhere
Hope you get well soon anyhow (:
^
Dude there was a guy on my first flight that was coughing up a storm next to me
We've had more covid cases in the last 3 days than the entire pandemic lol
Thank you
its cause she usually double masks. And after omicron variant shes like yep im gonna consider it
I'm sure I'll be alright
Has anyone had it twice?
Just hoping I didn't infect anyone else and can get home in time
Wouldn't mind just getting it when convenient and be done with it lol
you could probably have it twice, except the second time it would be significantly more mild
My cousin is a nurse, she had it for her third time this Christmas
Yes, people have had it many times
I've managed to avoid it completely fortunately 
you think covid will be gone after 3 years?
I mean like commonly
or is merica still gonna be full of karens
No
ugh, looks like a lot of work to write ngl
At this point it's just going to replace the flu
i hate my life lmao. im going through this while in highschool and growing up will be shitty lol
For context, we've had so little covid that 3 weeks ago was the first time I personally knew someone that got it
but at least its a good story to tell
where are you from?
we've had ton of covid in Norway lol
Australia
The command itself was pretty straight forward. It is better at scale lol
ahh
Interesting but first of all, what’s up with the //TODO document
Secondly, those boolean fields which switch the state on text decorations could simply be a set of Enum constants
Thirdly, you do not need a factory for everything
And a decorator inclusively
Use the patterns when you’re in need of it
This is all we really needed
Not having a factoryfactory smh
Does anyone have any suggestions for making this easier for the average user to customize?
yikes
That function could be extracted into smaller functions as that function clearly does more than one thing bk but not bad
If you don't have a factory builder you're doing it wrong
custom formats or scripting languages
Something something sufficiently advanced yaml config always becomes turning complete programming language
Isn't this just Vagdede's minigame maker? xd
Also this looks a bit too compact, it took me some seconds to figure out what’s going on here
A custom format might be good
So maybe don’t bulk logic like that
always split the conditional logic into a method too
"If the provided player is null, error out"
are you sure you are 10 years java dev man?
I want to avoid scripting langs as that will take away from it being compiled
Yes bk I understood the intent of the code
Yeah this is really overengineered
But it took my more than twice as long to figure out what it did as opposed to the rest of the code
Smite plugin boutta have an RCE
Major facts lmao
But yeah bk not gonna say it’s bad
Yup, pretty sure.
bk
It achieved the task in the most complicated way possible
10 years, and u produced this code
The whole point was to showcase clean code
You’ve done an over engineered design however it is adequate to say it’s quite future proof and extendable so I’m not blaming you
Wasn't told this lmao
🙃
That was the point
you know complicated code doesn't mean it's good 😛 readable code usually means good code
Yup, most of it was from when I was younger
Correct lmao
age literally doesnt matter
In conclusion I’d rate the following:
Red first
bk and nozemi shared second
Younger meaning I was less experienced lmao
Kinda unfair but I guess that was the point all along lmao
Ehh, can't debate that xd
Yeah
Yeah true red
DI for one constructor giving me the me-mes
Your wasn’t bad, you should just think about where to deposit all the time at
mine was about as simple as you can get it with the default Bukkit/Spigot API, as I haven't really added a lot on top of it (yet) 😛
at least mine was way easier to read though, imo anyway
Had to dig through hard drives to find the stuff lmao
i think you should watch uncle bob
Yeah nozemi I put you in shared second due to the comment and the fact that it wasn’t capable of handling the console sender iirc
ahh
Someone should join future competitions using pure Bukkit Command API
on my server I don't really have console access anyway
Mine is basically the Bukkit Command API with a lot of extra steps lmao
you should also separate https://github.com/randogai/smite/blob/a8308278897b4ac1438858db1e4678ff26237cc7/src/main/java/org/example/smite/commands/impl/SmiteCommand.java#L27 somewhere else like maybe instead of putting it inside the class, make 1 big class for everything for those keys
Nozemi no worries I don’t think you showed your full capability given the minimal code you so produced
yeah, I just implemented it the way I'd personally use it 😛
also while we were talking about parsing custom formats, it reminded me of advent of code
day 10, was a nightmare
Didn’t do aoc 😅
Looks appalling
when I understood how to manually do it, writing the code was easy fwiw
but understanding how I was supposed to solve it was a bitch at first
i remember i had to do a usaco problem where u cant brute force it
Recursive descent parsing would annihilate this problem
As in the actual answer itself? Because you get timed out for a minute if it's wrong
did you finish 1-25, md_5?
wat
Dunno let me see
also exponentially increases afaik
From what I briefly read, a simple recursive algorithm would easily solve this
no, code wise obviously
What was the challenge?
I don't think it increases
that's what I heard
also i remember this problem from last year https://github.com/PulseBeat02/Advent-of-Code-2020/blob/master/src/main/java/com/github/pulsebeat02/AllergenAssessment.java
it was a nightmare to debug
but yeah, some of the answers won't fit in an int, so bruteforcing the answer would be bad
but bruteforcing the solution can be a good option a lot of the time
This is what botnets are for
I remember one of the days it was quicker to just do it by hand
except everyone has their own answers, tied to their own accounts, so botnet would do fuck all
nice
this year I stopped at day 12, it fucked me
fucking pathfinding with extra conditions
i did all 25 last year each day
this year i did the first one, then i didnt have time
for the other ones
AoC releases at 5am for me which is annoying
I did a few last year, but then I couldn't be arsed to read all the long problem descriptions
6am here 😛
didn't care about that though, I just wanted to complete it
I don't care about the public leaderboard but I was competing against people from my uni
Answer always fits in a 64 bit int, right?
I also wrote unit tests and used example data from the problem descriptions, got it working... fed it my own input data, and it didn't work after all
So you'll always be able to solve within 64 minutes 🥲
Lol
Your puzzle answer was 1609314870967.
Relatable
thankfully you don't (usually) need any libraries for big numbers
as far as I know longs are enough
BigInteger?
no idea
big number libraries are probably for other languages
I just heard it being mentioned
Big number library for python
and every time I see a python solution, I'm like "what the heck am I looking at?"
What does numpy even do
but it kinda ruins it if all you do is import djikstra
import brain
How does that even work
import djungelskog
import bergentruckung
blahaj
well its for manipulating stuff like matrices
That dang shark follows me everywhere...
lmao
do do do
baby
this is what I've made with my library so far (just a very simple plugin for now) 😛
Very cool
class ToggleFlagCommand(
override val name: String = "toggleflag",
override val description: String = "Toggle a flag for your account.",
override val aliases: List<String> = listOf("toggle-flag")
) : PluginCommand() {
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
if (sender !is Player) return true
if (args.isEmpty()) {
sender.sendMessage("You need to specify a flag.")
return true
}
val flag = flagManager().findFlag(args[0])
if (flag == null) {
sender.sendMessage("Couldn't find flag '${args[0]}'.")
return true
}
when (sender.hasFlag(flag)) {
true -> sender.removeFlag(flag)
false -> sender.addFlag(flag)
}
sender.buildMessage(DefaultTranslations.FLAG_TOGGLE_COMMAND_SUCCESS)
.addPlaceholderValue("flag_name", TextComponent(flag.identifier))
.send()
return true
}
}```
For some reason?
here is the command's code
Lol
kotlin grrrrr
it does support translation, so players can actually pick which language to view the server in
o.o
Minecraft bee also trans icon
yass 🏳️⚧️
why do everyone hate kotlin? 😛
Cause it bad
?
Someone use the nokotlin sticker please
scala >
cause its impossible for any language to be better than java
Except rust
why is Kotlin bad?
rust bad
Rust 😩 💦
C >
u wont
Don't doubt me
i always live in doubt
Don't ask me how it happened ¯_(ツ)_/¯
brb gonna push you down the shower drain
Trans people will appropriate one character per week until they receive adequate media representation
You have been warned
So forever?
Yeah lol
one of the major reasons I use Kotlin is for extension methods, they are very handy in Spigot plugin development
not sure what traits are tbh
Like interfaces but better
scala my beloved
kotlin has the sexiest collection manipulation I have seen in a language
Thought it was for coroutines and null safety and stuff like that and better variance
Coroutines < goroutines
yeah, of course, though I haven't (yet) had any need to use coroutines for Spigot plugins
Go sucks but goroutines is an iconic name
also I don't really know coroutines at all (yet)
id love jvm languages a little more if i didnt need to include their runtime in my project
2mb jar for empty kotlin project 👌
Basically async await but better
Hmm alr
Always remember that Lua did it first

(lua was actually the first programming language ever created)
jar size doesn't really matter much these days though, at least most of the time
it matters to me
why?
(lua is now the 43rd programming language ever created)
Gonna go sleep noe so gonight yall
good night!
Goodnight conclure my love
it feels gross knowing i couldve saved an MB or 2 by just using the native language
😳
i lived on very tight drive space for a few years so unnecessary things like that just bug me
fair enough
I have about 18TB of space to waste for my Minecraft server so 😂
tbf I wouldn't really use a lot of it for MC
rip
it had like 120gb total
ye my new systems have storage in the TB but i still live like im on a space budget ig lol
PTSD 😂
basically
do i need to make a new class for every single command i make for a plugin (eclipse ide btw) but under the same commands pakcge?
post traumatic storage disorder
you don't need to
You don't need to
you can structure it however you like
but highly recommended ig
how would it work if there wasnt a new class for each command? where would they type the onCommand stuff anyways
depends really
iirc there are tutorials for doing just this
it was the first way I learned to do it lol
so do u guys think u should just stick with making a new class for every command
like I said, it depends
but chances are your commands are big enough to justify being contained in their own classes
what cases would mean that they could occupy the same class
for really small commands I guess
I don't remember exactly how you tie them to a command name, it would become sub commands of another command I think
wouldnt it still be better to just make a new class still? for organization's sake and also to make tweaks to the code easier
I would personally just have separate classes
like for access maybe i could add a method to pass info or maybe by making some things public
at least I can't think of any specific scenarios I wouldn't
there are plugin libraries out there though, that will help with command implementations
do u mind sharing one with me
this one for example
not sure of other libraries, and not sure there are other libraries that solves it in a nice way
👍
Damn he recommended mine
Thanks man
Ramen, if you need help using it, check out the wiki, DM me or join my support discord
alr thanks
Generally commands are not actually large enough to take up an entire class on their own when you take away all the logic of conversions, tab completions, permission checks, sender checks, etc
Then you're just left with the raw logic of the command's actual execution, which is usually pretty small
im trying to make a plugin that works with buycraft, how do these plugins work
You can hook into their api
np, it is a good library, and I'd probably personally use it as well if I developed plugins for the sake of feature gaps and not learning purposes 😛
Understandable
all i know is that the buycraft runs the commands onto the server
ACF is a big one.
what cases would u need to make them in the same class
Commands?
I do it all the time
Because usually the logic is pretty small when you abstract away the boilerplate
I could play the same game with you that I played earlier
Let's pit the command libraries against each other to see which is cleaner
ok lol
How about this
A command /chance <chance> <command>
Chance is a double 0-100
Command is a string for the rest of the arguments rolled into one
It has a chance% chance to run the given command from console
Simple enough right?
Feel free to suggest your own if you have a better one
i just said acf is a commonly used command framework. they mentioned not knowing any other ones.
i dunno why you're going out of your way to show off your lib n make a big deal of supposedly how much better it is to me
Yeah I enjoy comparing
I know acf is common and have recommended it before
I'm bored and in quarantine with nothing better to do if that helps answer your question
why is it such a big deal that someone wants to show off their library? if you don't care for the comparison or show off, simply move on
I for one like to see comparisons
I don't mean to come across as showoffy
I know
man, i could care less about someone wanting to show off their lib. they just came off very showoff-y
so simply move on, no need to be rude about it
not that i'm mad about that at this point either since it was a misunderstanding
I thought you were game cause you said "ok lol"
oi, i'm just irritated that you're on my case now. i say somethin here not even once a week, so the last thing i'm looking for is drama in the dev help section
eh
What drama?
the drama that nozemi seemed to think i was looking for 🤔
yeah, nobody likes drama in help sections 😛 the case is closed and we can probably safely move on
Drama keeps the channel lively
doesn't keep my sanity intact tho
*as long as you are not the main characters
oh hi einKnuffy hello
I just realise how powerful PlayerStatisticIncrementEvent can be. Even though it is not a very ideal practice to listen in to statistic events, and that you can't cancel the related actions performed, but spigot's api is pretty limited otherwise
Its good for detecting jumps
Though that can be spoofed
I just used it to detect ringing of bells
Jumping can always be spoofed
tf did I just read
entertainment
Technically, ACF isnt a library
How not
not at all
inversion of control
I just think of a library as a tool you can use in your code
Ah yes
What makes something a framework?
When the framework is the one in charge of control flow
Hm
Like ACF has annotations to create some kind of a control flow, you are just using it, not building on top of it
I see
I have noticed that certain types of abstractions can't really be built on top of
Libraries can always be wrapped but I guess you can't really wrap a framework
Well, java collections is a framework too..
is there a way to block players from left clicking a noteblock but allow them to mine it? cancelling the playerinteractevent works for the first time but doesnt after the next attempt
That means allow the interaction only when they are using the correct tools?
cant u mine it with anything and itll drop
well i want them to be able to break the block, just not interact with it
yes
declaration: package: org.bukkit.event.block, class: NotePlayEvent
But not sure if that existed for previous versions
if ur not on latest what r u doing with ur life?
My only concern is if it will cancel note playing on right click too
looks like the event has some deprecated features so u could assume its existed for a while
So sad, cant set instrument
its what we want
That could be useful af for custom blocks
were doing something similar to how origin realms does their custom blocks
Ahh, just when i say custom blocks lol
now for the shulker box under the note block. shulker blocks cause block updates which update the noteblock too
Isnt that part of redstone
Which is part of this too
the shulkerbox updating noteblock?
Updating or playing?
well observers detect when a shulker box open
at first i tried storing the data in a hashmap and restoring it whenever interacting with a shulker box under a noteblock but whenever it closes it does same thing
i even attempted to cancel interact event and opening the inventory but it still acts as if i opened the shulker box
Maybe you can ask LoneDev on how he does it lol
event.setCancelled(true);
Container shulker = (Container) block.getState();
event.getPlayer().openInventory(shulker.getInventory());
does what?
Nothing, he has this ItemsAdder plugin
That uses noteblocks for custom blocks too iirc
You can stop the update with the BlockPhysicsEvent
But what if you want the block to act like a normal block
Like getting powered by redstone
i have used this for blocking the physics https://www.spigotmc.org/threads/prevent-noteblock-blockstate-updating.483242/?__cf_chl_tk=FjBvpeX4jf0ajeAb94S_An.DvTVaGAEySlzOqjUt4X4-1641256107-0-gaNycGzNCGU
it works but the piston pushing the block and the shulker box still update it
how do i get a blocks new location after it being pushed by a piston?
declaration: package: org.bukkit.event.block, class: BlockPistonExtendEvent
unless im using the wrong method, but it displays the old location
ive been thinking of that but i dont know how to go about it
yea, im trying somethng
Well you should have a reference to the blocks you are keeping track of. In that Event you can grab a list of blocks and then compare if any match the block you are tracking. If a block matches, grab the direction the piston is facing then +1 on the location of the block you are tracking. 🙂
@drifting vault
Storing player-specific data
I figured it out
idk if its good
or efficient enough
but this is what i have
@EventHandler
public void onPush(BlockPistonExtendEvent event) {
BlockFace direction = event.getDirection();
for (Block block : event.getBlocks()) {
Location nLoc = block.getRelative(direction).getLocation();
dataMap.put(block, block.getBlockData());
Bukkit.getScheduler().runTask(BedAdditions.getPlugin(), () -> {
nLoc.getBlock().setBlockData(dataMap.get(block));
dataMap.remove(block);
});
}
}
private final HashMap<Block, BlockData> dataMap = new HashMap<>();
and i did the same with the retract event
Could you just put the scheduler outside the for loop, therefore only running 1 task.
it just does what it did before
if the scheduler was in the loop itll change the block soon as it has been pushed
for some reason it has to update the block after it has been pushed
make it a delayed task?
delayed or run later
what about async?
this is flawed
why do you need to update all the blocks from the list of blocks from the event? and because it is a loop, you are creating tasks for every single block pushed by the piston o.O Don't think this is what you are intending?
im wanting to only update the note blocks
then your loop needs to be changed to check if any blocks in the list are note blocks
otherwise you are unnecessarily creating tasks and looping for no reason if none of them are
for (Block block : event.getBlocks()) {
if (block.getType() == Material.NOTE_BLOCK) {
Block nBLock = block.getRelative(direction).getLocation().getBlock();
dataMap.put(block, block.getBlockData());
Bukkit.getScheduler().runTask(BedAdditions.getPlugin(), () -> {
nBLock.setBlockData(dataMap.get(block));
dataMap.remove(block);
});
}
i changed it not long ago
is this not efficient?
for some reason it doesnt update the block if not in the scheduler
and what needs to happen with the noteblocks?
it doesn't keep its data if it gets pushed?
well i dont want the instrument to change
ah got it
origin realms method of custom blocks
then the best way to get the new location is to get the piston block direction and then grab the block at the new location, which you should only need to +1 from the location of the old reference which would be the block from the event. I don't think I am making this easy to understand XD
wonder if use a iterable or using a for loop would better?
well need the event to complete
while (iterator.hasNext()) or for (? monkey : setOfSomething)
thats kinda what i did here
Block nBLock = block.getRelative(direction).getLocation().getBlock();
new block
only thing needed from the event is to check if any blocks are note blocks, if they are grab their data/instance reference, schedule a task a tick or two later to update the block after it is pushed in the new location
the getLocation() doesn't automatically shift the location
get the block relative to the pistons direction location
does anyone have a good resource for fireworks
give me a bit and I will show some code 🙂
please
Depends, no difference really
Unless you modify the collection while iterating
spigot don't have any mappings for 1.18?
try and see
it has
Use specialsource plugin
without? on 1.17 its normal
There's no runtime mappings anymore, soo
😭
y works
I switched from maven to gradle and am currently using the userdev gradle plugin.
Very pleased so far. Its really neat to just read the NMS code as Mojang has written it with descriptive naming etc.
i am using gradle too
If you want i can share a quick setup
yep
thanks, ill try it
Hey, is there any better way to utilize futures?
requireClan(player).thenComposeSync(clan -> {
if(clan == null) return nullFuture();
ClanMember member = getMember(clan, player);
if(!checkPermission(player, member, ClanPermission.SET_DISPLAY_NAME)) return nullFuture();
return clanManager.editClan(clan, editor -> editor.setDisplayName(displayName));
}).thenAcceptSync(c -> {
if(c != null) player.sendMessage(messages.commands().displayNameSet().with("name", displayName));
});
nullFuture basically returns CompletableFuture.completedFuture(null)
hey guys some trouble im running into with pandas
for some reason i cant get its custom name to show up
also, how do i give it a brown colour and a bamboo stick in its mouth?
declaration: package: org.bukkit.entity, interface: Panda
im looking through this but i dont really understand how the genes and stuff work haha
Panda panda = (Panda) new NMSPanda(location);
panda.setMainGene(Panda.Gene.BROWN);
panda.setCustomNameVisible(true);
panda.setCustomName(ChatColor.AQUA + ChatColor.BOLD.toString() + "Pandie");
thisd idnt work for me
how do I put/get a hashmap in config?
do I have to convert them into a list hashmap?
i think u have to split all hashmap and write it line by line
you can storage arraylist
but hashmap not
You can put a map as a map
Oopsies
whats the difference from .setDefaults() to .set() and .getDefaults() to .get()
getDefaults() gets the boolean status of defaults (if applied).
setDefaults(config) applies a config file as default values
set assigns a value to a path, or clears it if null
get retrieves the value at a given path
the value can be anything?
not anything
data types?
an object or null
how do you get NMS entities to persist again?
i thought this.persist = true would work but i tp'd away and it did not
declaration: package: org.bukkit.entity, interface: LivingEntity
does this also handle when it re-renders and loses it's AI
not sure
ill check
persist kind of works but it loses AI
wonder if its the same
it does not, funnily enough wandering traders are fine
this.setDespawnDelay(0); by doing this inNMS
is there a reason villager mobs would persist their AI and not despawn but pandas dont?
If this is deprecated, what else I can do ?
i think its armorStand.addPassenger(player); now
yea thanks
as for my issue i think maybe adding some sort of nbt tag would work or help
if anyone knows how to persist nms entities + their behaviour through going far away lmk pls
Read deprecation notes
tbh idek where to find deprecation notes
I'm trying to create something like "Warzone Sliding" this is my code and this is the result
Player player = event.getPlayer();
Location location = player.getLocation();
Vector vector = location.getDirection();
ArmorStand armorStand = location.getWorld().spawn(location, ArmorStand.class);
armorStand.setVisible(false);
armorStand.addPassenger(player);
BukkitTask runnable = new BukkitRunnable() {
int count = 0;
@Override
public void run() {
if (count == 20) { cancel(); }
vector.multiply(5);
location.add(vector);
armorStand.teleport(location);
count ++;
}
}.runTaskTimerAsynchronously(Main.getInstance(), 1, 2);
armorStand.removePassenger(player);
armorStand.remove();
PlayerSwapHandItemsEvent, happens when i press F
what's warzone sliding
if you dont mind me asking
should be using velocities for this i think
much smoother
Siliding on the ground in call of duty warzone
whya re you moving vertically there
oh and you want an animation where their bum is on the ground?
thats why you want them to ride
Also that BukkitRunnable should be sync
Sure
public void addAdditionalSaveData(CompoundTag nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
Bukkit.getServer().broadcastMessage("y1");
nbttagcompound.putString("MainGene", this.getMainGene().getName());
nbttagcompound.putString("HiddenGene", this.getHiddenGene().getName());
}
public void readAdditionalSaveData(CompoundTag nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
Bukkit.getServer().broadcastMessage("x1");
this.goalSelector.removeAllGoals();
this.setMainGene(Panda.Gene.byName(nbttagcompound.getString("MainGene")));
this.setHiddenGene(Panda.Gene.byName(nbttagcompound.getString("HiddenGene")));
this.goalSelector.addGoal(10, new LookAtPlayerGoal(this, Player.class, 8.0F));
}
ow right, thanks
something like this
im trying to get my panda's behaviour to persist
but when it despawns it becomes a normal panda
so "y1" prints
but "x1" doesnt
im trying everything but just cant get it to work
let me try somthing
This looks fine. Could you send the entire class in a paste and I can do some testing
ok
ok
public class NMSPanda extends Panda {
public NMSPanda(Location loc) {
super(EntityType.PANDA, ((CraftWorld) loc.getWorld()).getHandle());
Level craftWorld = ((CraftWorld) loc.getWorld()).getHandle();
this.goalSelector.removeAllGoals();
this.goalSelector.addGoal(10, new LookAtPlayerGoal(this, Player.class, 8.0F));
this.setPos(loc.getX(), loc.getY(), loc.getZ());
System.out.println(isPersistenceRequired() + " is1");
this.setPersistenceRequired(true);
System.out.println(isPersistenceRequired() + " is2");
craftWorld.getWorld().addEntity(this, CreatureSpawnEvent.SpawnReason.CUSTOM);
}
public void travel(Vec3 vec3){
}
public boolean hurt(DamageSource damagesource, float f){
return false;
}
public void playAmbientSound() {
}
public void addAdditionalSaveData(CompoundTag nbttagcompound) {
super.addAdditionalSaveData(nbttagcompound);
Bukkit.getServer().broadcastMessage("y1");
nbttagcompound.putString("MainGene", this.getMainGene().getName());
nbttagcompound.putString("HiddenGene", this.getHiddenGene().getName());
}
public void readAdditionalSaveData(CompoundTag nbttagcompound) {
super.readAdditionalSaveData(nbttagcompound);
Bukkit.getServer().broadcastMessage("x1");
this.goalSelector.removeAllGoals();
this.setMainGene(Panda.Gene.byName(nbttagcompound.getString("MainGene")));
this.setHiddenGene(Panda.Gene.byName(nbttagcompound.getString("HiddenGene")));
this.goalSelector.addGoal(10, new LookAtPlayerGoal(this, Player.class, 8.0F));
}
}
im trying something for u, i kinda like this idea too haha
gimme a sec
Could you make the armor plates be on top of the hearts like armor
:D thanks
lemme post
good idea
So i am making my plugin in kotlin, and i needed to evaluate some code, so i found the ScripteEngineManager and i am using it with the js engine, the only problem is that whilst it works when testing in intelli, whenever i put it on the server it does not work (no engines are present), what could be causing that?
No script engine is present in newer versions
You will have to include it yourself
public void test(Player player){
Item item = player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.STONE_PRESSURE_PLATE));
item.addPassenger(player);
int time = 5990;
item.setPickupDelay(time);
item.setTicksLived(time);
Vector tosend = player.getEyeLocation().getDirection().normalize().multiply(4);
tosend.setY(0);
item.setVelocity(tosend);
}
``` @sage patio
how would i do that?
theres an animation cancel where they can get off the pressureplate to make it faster and save time, you can make a runnable to force them on it 24/7 but i think its fine
you could also make the entity they ride a falling block however i think for this purpose its fine
thanks lemme try it
Shade it in or load it via the library loader
public void test(Player player){
Item item = player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.STONE_PRESSURE_PLATE));
item.addPassenger(player);
int time = 5990;
item.setPickupDelay(time);
item.setTicksLived(time);
Vector tosend = player.getEyeLocation().getDirection().normalize().multiply(4);
tosend.setY(-100);
item.setVelocity(tosend);
}
this works better @sage patio
i've never heard of the lib loader, what is it?
enjoy
thanks
by the way @sage patio do you understand why i made it setTicksLived(5990)?
do u know how ticks work and stuff
20 ticks = 1 second
items despawn at 6000 ticks
so this exists for half a second
means u dont need a scheduler
Read about it here; https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/
this is the holy grail
finally, a plugin smaller than 2MB
@chrome beacon is there a way to make the travel method always act as intended
public void travel(Vec3 vec3){
}
this is what i want on load/reload of the nbt tag
turns out removing pathfinders isnt enough
@quaint mantle it works so nice and ty, but there is 2 problem
its very fast, and player should press Shift for onmount
i dont mind waht the pathfinders are i just need him to not move/take damage
for unmount?
removePassenger ?
So judging by your code you want the pandas to only follow the player, nothing else. Is this correct
no, it's meant to be an NPC at shops
you go there for quests
my shopkeepers are wandering traders and their behaviour persists
this however does not
i have them not move/take damage
@sage patio
public void test(Player player){
Item item = player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.STONE_PRESSURE_PLATE));
item.addPassenger(player);
int time = 5990;
item.setPickupDelay(time);
item.setTicksLived(time);
Vector tosend = player.getEyeLocation().getDirection().normalize().multiply(1);
if(!item.isOnGround())tosend.setY(.2);
item.setVelocity(tosend);
}
what for? it will despawn in half a second
you dont really need to handle the despawn
i have a quick question, i am adding bstats into my plugin and it requires to be moved to a different package, can this be done or do i still have to include bstats?
no it will not
If you're using the library loader it's fine no need to relocate
public void test(Player player){
Item item = player.getWorld().dropItem(player.getLocation(), new ItemStack(Material.STONE_PRESSURE_PLATE));
item.addPassenger(player);
int time = 5990;
item.setPickupDelay(time);
item.setTicksLived(time);
Vector tosend = player.getEyeLocation().getDirection().normalize().multiply(1);
if(!item.isOnGround())tosend.setY(.15);
item.setVelocity(tosend);
}
this is the final one
ok lemme check
@sage patio when an item despawns, the player will be removed
try it out
trust me
you dont need to worry
it will, they can choose to dismount early, or after half a second it will auto dismount them
i cant upload videos but it works
@chrome beacon im thinking the loading of the nbt tag might not work bc its not considered the same nms entity
idk
are you talking about preventing players from seeing already loaded chubks
chunks
i would think canceling the event like they said would work
let me see
Direct Known Subclasses:
ChunkLoadEvent, ChunkPopulateEvent, ChunkUnloadEvent, EntitiesLoadEvent, EntitiesUnloadEvent
of ChunkEvent
so the last reply here
idk if this was the one sent in ur post you just made
but basically i think it may mean to intercept the ChunkPopulate or Load Event and do smth to make the chunk void
if it matches what you want
hopefully that helps @spare magnet otherwise maybe someone else might know more
it already does this
thanks for your help
you don’t need a scheduler
no it will not
get rid of the scheduler and show me a video
actually does, but takes too long
ok
yea I did it with this runnable, removes the item too
it will work i promise
umm ok lemme try
when an item despawns it will get removed and player will demount
lemme record a video for you
I recommend using a packet listener to stop the chunk packets from being sent to the clients, granted there is no real way as far as i know to stop the chunks generating this without changing the code of your server with patches. This sort of manipulation gets quite messy though
ok
wait actually just use a custom terrain generator
@quaint mantle this is without the runnable, now lemme record a new video this my runnable
@xii69#2344 pressing shift how many times? also that’s odd i guess 1.12 is different. have you considered upgrading?
its only gonna be a few chunks, and if you just put a world border there there wont be any ticking entities
ok so its easy then
make a custom generator
and if the chunk coords are not the desired ones
what is a custom generator
there is no way to stop this
just set teh renderdistance low or something to minimise it
well
just look for where the chunkloadevent is called
@opal juniper do you know how to make NMS entities persist through going far away