#help-development
1 messages · Page 1369 of 1
get the velocity vector of the source -> normalize it -> multiply it with the length of the targets projectile velocity vector
yikes
sniped
^^
thank you
should use Vector#length? sounds scarily costly
ah, i can just use it once
It kind of is (because of the square root) you could also do some complicated math with the squared lenght but unless you do stuff every tick or so you should not worry about that.
Let me think how expensive a 3 axis vector rotation would be...
works perfectly, thank you
Hey do you guys with or without NMS know of a way to stop horses from like kicking up their hooves? Ive been digging through horse AI and im drawing a blank
I think PathfinderGoalTame contains that logic. How you would go about disabling it tho, questionable
you would probably have to listen for the outgoing entity effect packet
Really? Horses seem to just rear up when your running randomly too
oh ?
Yeah like if the entity is damaged it like does the weird think where it can kick up its feet too
So I thought maybe it was under AbstractHorse since its shared between donkey's horses and mules
but im drawing a blank, i might be just blind
could be client side
But when the horse rears up it stops movement of the horse, so there has to be some kind of logic
unless the server just detects the packet for rearing up and freezes you
welp time for some fun ig
Yeaaah good luck xD
Anyone has any idea how this can be completed with? I'm inside custom class which extends NMS entity
I mean, what is your goal here ?
have your custom entity break doors ?
The predicate basically is a filter to define in which difficulties the entity should be able to break doors
i don't know what the integer in the second constructor is
I think how long the entity needs (in ticks) to break the door
but could be totally off on that one
mm i want this custom entity be able to break doors
yeah, but that is what i can't complete using predicate, i mean, be able to destroy if difficulty is hard (like zombies)
// Pseudo
NPC.move();
if NPC.getBlockInFront().getType() == BlockType.DOOR {
NPC.playAnimation(Animation.BLOCK_BREAK);
NPC.getBlockInFront().setType(Material.AIR);
}
@hasty ingot
Im in 1.16, in older versions you dont needed to specify the predicate inside PathfinderGoalBreakDoor constructor (was easier). I dont know how to create this predicate and give it to constructor
ah, well if you'd want it to only destroy stuff on hard difficulty
it would be
d -> d == EnumDifficulty.HARD
i'll try it
you know the lambda syntax tho right ?
yes
kk
it works, thanks 😄
👏👏
alr
LOL
thanks for the suggestion 🙂
Fuck off. Any IDE works fine. You think they’re well-known because they’re shitty? If that was the case, they wouldn’t be popular. Your statement was in no way related to his question.
You think. It’s your opinion.
Because I’m tired of people doing this
is breaking packet possible on bedrock?
Wdym
like the cracks display
not on my own pc right now i just wanted to know for a plugin
i were thinking about making fake bedrock mining 😂
Can the download link for buildtools be organized because it so messy and not a lot of people can find there version of the server like for example 1.8 buildtools idek where is the link for 1.8 it only shows 1.16+
It’s designed for you to run latest :/
Ohh ok thx
Just give the mobs that burn during the day a lether helmet or effect them with fire resistance i guess
Theres an other option by affecting it with fire res
I've got a plugin that keeps track of specially named chests that I'm looking to remove from the list when the chunk unloads. The problem is that something about removing chests in this function loads the chunk (and thus, all of the chests again). Am I missing something? (This code is called during ChunkUnloadEvent)
public static void RemoveChestsFromChunk(Chunk c) {
int X = c.getX();
int Z = c.getZ();
for(int i = 0; i < Chests.size(); i++) {
DisposalChest dc = Chests.get(i);
Location L = dc.getLocation();
int oX = X * 16;
int oZ = Z * 16;
if(L.getX() >= oX && L.getX() <= oX + 16.0
&& L.getZ() >= oZ && L.getZ() <= oZ + 16.0) {
plugin.getLogger().info("Removing chest at CHUNK=("+X+","+Z+")");
//very simple wrapper for arraylist.remove()
RemoveChest(dc);
}
}
}
Event calling code, if it helps.
@EventHandler
public void onChunkUnload(ChunkUnloadEvent event) {
DisposalChestManager.RemoveChestsFromChunk(event.getChunk());
}
Ignoring the question and just telling them to use a subjectively better IDE
It’s all too common
?kick @idle pier
👢 Kicked Vladimir02#6698
- camelCase your method names, not PascalCase
- IIRC doing anything with locations or blocks loads the chunk of it isn’t already
Damn md out here
Is there a way for me to check if a block is in a chunk without loading it?
Damn dude I don’t think he was at fault
You could cache your block locations and what chunk their in (coords or smth)
Poor dude was just sharing his opinion
That way you can check without actually interacting with the world
Yeah but it wasn’t relevant at the time
Wouldn't it be that if I got the coords of the chunk it would reload though? The block locations are actually cached - dc.getLocation() comes from a stored Location field, unless you mean to store it outside of the realm of a Location
(like manually store coords in a vector3 or something
Yeah, manually
Sever all ties to the world other than yk the event
See if that works
No guarantees
I'll give it a shot, thanks!
Hi, I am trying to execute commands when a user clicks an item and my problem is that when they do it it does not register when the user clicks in the air, does anyone know how I can solve it?
Are you using PlayerInteractEvent?
And also, show your code.
Oh, so you want every Action to do the command?
yes
I tried but the code does not run
is the event getting fired?
try to debug to see if the event is registered or something.
The event is executed but the problem is when the user clicks with the item in the air
that's weird, can't really help you with that.
Probably PlayerInteractEntity
Do you mean in an anvil?
I don;t see a specific event for that. You could check the interact event
yep
is it possible to set or get the ItemStack of a Trident projectile?
when in flight it is an entity
in hand/inventory its an ItemStack. Uses a standard Material
well yes, but it must have information about itself stored in the Entity somehow
otherwise how does it show as enchanted or not
the ItemStack version and the Entity version are independent of each other. There is no relation between them. Data does not transfer from one to another
no, ThrowableProjectile interface has setItem and getItem
Thats just the object you see when its in flight
how does it know what to give you when you pick it back up, then?
I would assume it would give you the item you set or a default ItemStack
I'd not actually thought about the pickup
interesting, using setItem does actually change what you pick up, but it does not change whether the trident entity is enchanted while flying through the air
If you launch an enchanted Trident does it show as an Enchanted trident in flight?
if i myself launch it, yes
but if i ProjectileSource#launch and then setItem to enchanted, it does not
Yet after setItem you can pickup whatever item you set
odd that only LaunchProjectile(Class) is exposed then
I'd have expected one to accept an ItemStack
i assume it's because it sends the packet from launchProjectile, and does not update when the item is changed
but it does affect the damage the item does, so that's good
https://pastebin.com/5L8dwLe8 can someone point out my mistake ? im not getting players uuid /name
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Um, you are checking every player on the server for the permissions when anyone clicks an Inveentory
If there is anyone without the permission the event exits
or if DisableItemMove is false it also exits
playerss is already a Player so you don;t need to call .getPlayer()
You are adding the players UUID to your player list, then attempting to fetch the player by name later.
Sorry but theres probably not a single line of that that is correct 😦
Thanks 🙂 I'll get on that
Indeed I was adding player uuid to the player array list and used the getPlayer by uuid and not by getPlayer "name" I assumed that that would work
Hello, i would like to know in what ways i could create a "magic wand". Like just a stick that shoots out some particles in the direction i'm looking and when they hit an entity it takes damage
i just want to know how i could create the magic part
There are two ways to do it...
either launch a disguised projectile and spawn particles on a timer, if you have to have a particle effect.
or raytrace the path of the projectile and spawn particles and deal with hits manually.
teh simplest one is the disguised projectile
yeah, also cause i want it to be like i snowball, i mean i want it to go down with time and not it going only straight
would i disguise the projectile with packets?
launch the Snowball and setItem to air.
At the same time start a timer to spawn a particle at the location of the Snowball entity.
stop the timer and remove the projectile on hit
i didnt understand well the first part... Wdym for setting item to air?
when you use launchProjectile you get a Snowball Entity. That entity has a method for setItem(ItemStack)
You mean like the "display item"?
Like instead of a snowball i could display sth else?
you should be able to setItem(new ItemStack(Material.AIR))
that would make the snowball invisible
And the hitbox remains the same right?
yes, its still a projectile
@eternal oxide this is the code for the snowball
Snowball ball = player.launchProjectile(Snowball.class);
ball.setItem(new ItemStack(Material.AIR));
but it still displays as a normal snowball
Do you want to hide the snowball?
He does
I thought setting the item as it works for other itemstacks but I guess AIR is not one of them
i just tried putting a diamond and it worked, so yeah i think air doesn't work
Yep, I did this for egg spawning yesterday so I know actual items work
testing something
Looking at the javadocs I cannot find anything that might help here
would packetplayoutentitydestroy work?
like destroying the ball for the player?
I'm not that good with packets so idk
What can I do with fake reviews and fake downloads? https://www.spigotmc.org/resources/chatradius.81718/reviews#review-370542-889687
reviews look genuine, why do you think they're faked?
https://wiki.vg/Protocol#Entity_Effect not sure, but you might be able to add invisibility to the snowball via packets
why would someone fake a review and downloads 
Cause a person sent me a message they faked
Account created same day age 85 never logged in since
And how can I get in 1 day 1700 downloads?
but snowball is a projectile, projectiles can't have effects (right?)
technical support here for your needs
And they were all placed on the same timestamp (20:00), and the accounts were also created on that time, and data
I DID IT
Thanks
my idea worked
nvm i
Player player = event.getPlayer();
Snowball ball = player.launchProjectile(Snowball.class);
EntitySnowball e = ((CraftSnowball)ball).getHandle();
((CraftPlayer)player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityDestroy(e.getId()));
exactly
I'm not entirely sure, it might work
You will have to recompile that every version
wdym?
You need to use reflections (jk, even though that is an option)
ok not judging but..
plugin.getConfig().getString("storage.spy").equals("true")
does that not have version specific imports?
Think of the future!
also @maiden briar in your plugin.yml you don't need
softdepend:
- tvheeAPI``` because you already loadbefore it, and checking for it onEnable is useless because it will crash without the plugin being installed
i'll just change it when important versions come out, its just a server with me and my friends, i won't share the plugin with others
there are more cooler plugins that implement wands
maven is nice
That is ment with "clean start"
I've sent an email to
Thanks for the help 😄
Because I want to play fair with downloads
though why would one want to fake good reviews and downloads on your resources?
Is there like a Block#isPlaceable or Material#IsPlaceable
To check it can be placed?
Ok, thanks
99.9% sure that's not allowed lol
exactly my question, why would anyone break the rules for something that does not help them in any way
I don't know, but I want to keep it fair
faking reviews isnt fair lol
Yes
its probably illegal too
But he has not faked it according to him
And creating more accounts also illegal?
Check rule 11. Without permission to do so, they will get banned.
does synchronized keyword ensure that a method can only be run ONCE at the same time?
(while being potentially invoked from different threads at the same time)
i know synchronized is not only about it, but is my statement a consequence of the whole process of synchronised stuff
synchronized means only one Thread can access the method at once.
IF its on the method and not inside it
Yeah pretty much. The synchronized keyword uses an implicit lock. So if one thread currently aqiured the lock by invoking the method then all other threads have to wait (blocking) until the current thread exits the method.
Got a really annoying problem that makes no sense - I'm starting a recurring BukkitTask in order to display particle effects and storing it as a field, but when I try to cancel this task using the built-in cancel() method, nothing happens
particlesTask = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
// content
}, 20L, 20L);
//
public void stopParticlesTask() {
if (particlesTask != null)
particlesTask.cancel();
}
If I use player.getWorld().spawnEntity(location, EntityType.ENDER_DRAGON); is it normal that the dragon just floats and does nothing in world ?
Did you make sure that the cancel method is actually called (for example by adding a sysout inside the stopParticlesTask method)
yeah I'm sure the method is called
The weird thing is it worked once when I manually started the task. When it auto starts from a onEnable() method, I can't turn it off though
If the method is called then the task is cancelled
Did you make sure that you are using the same instance?
public void stopParticlesTask() {
if (particlesTask != null) {
particlesTask.cancel();
System.out.println("Task is cancelled.");
}
}
Use this code and make sure again pls.
ok one sec
Directly after or one tick later?
Ok
Then the task is cancelled.
Output the task id in your cancellation and in your command
Makes no sense. What version are you on?
And the task doesnt start again afterwards?
maybe show more code
Yeah. What you described is not possible. We need more code.
What about sending that entire class?
It would surely give smile more meat on his legs to help you
Preferably all methods that modify the particlesTask field.
And the surrounding class of that field.
?paste You can put it here 🙂
"more meat on his legs" is that actually a saying? XDD
lul
I can paste more but it's not really that helpful
Its better than nothing still
this is literally the rest of that start method:
public void startParticlesTask() {
if (particlesTask != null) {
particlesTask.cancel();
}
In case a task is already running, I cancel it, that's all
this is the field:
public BukkitTask particlesTask;```
I mean if the task is already cancelled then you can't cancel it again
it's not cancelled though
it's got confidential stuff on it unfortunately
but I can tell you nothing else affects that method
"confidential stuff"
Thats something you should extract into a config file and never hard code.
no... as in the code itself is the core of a minigame plugin
I could create a brand new plugin with just that method and it wouldn't cancel
it's happened to anothoer plugin of mine as well
how are we suppose to help your ass now? I mean if you don't share what could be potential issue factors then it's implausible that we can help you tbf.
There has to be something you are not telling us. What you have shown is impossible to not work.
well I've already said nothing else in the class affects that method
OK, you codes working then. Problem solved
And don't be a fool thinking your code is the ultimate product such that you're scared of getting it hijacked here by sharing it.
the wording of the javadocs seems to suggest cancellation isn't guaranteed
thanks @lost matrix and @eternal oxide so much for ur answers :3
"will attempt to cancel this task"
public class SpigotCore extends JavaPlugin implements Listener {
private BukkitTask task;
@Override
public void onEnable() {
this.task = Bukkit.getScheduler().runTaskTimer(this, () -> System.out.println("TEST"), 30, 30);
Bukkit.getPluginManager().registerEvents(this, this);
}
@EventHandler
public void onJoin(final PlayerJoinEvent event) {
this.task.cancel();
}
}
Just tested this. Works fine.
If it's already cancelled or is cancelling then it wont cancel it
Is the task sync?
yeah
but yes that javadoc is somewhat ambiguous
Its a particle task right?
We only support Spigot here. Not forks.
Yes they matter in some very specific occasion. I thoght that the task could be async and somehow blocks. Then it would never exit the current run method and therefore could also not be cancelled.
But im just guessing because i dont have more information...
can I dm you the contents?
Sure
is a way to annotate an object without the @
papermc doesent mess with tasks on the latest builds too bad, likley not broken but as always try to develop on spigot here or ask in paper-help
I mean... annotations are done with the @ sign in Java. So it depends how you define "annotate an Object"
Probably with ASM hacks
i use beanshell for my discord java-code interpreter (to debug code live, interact with spigot api live interactively).. the language syntax is almost identical as java, except a few stuff like the lack of support of lambda expressions (...) -> {...} (but i can find easily a way around by subclassing the Runnable class)
and lack of support of annotations @Stuff
that sounds cool
Then finding an alternative is your best option, otherwise you'd need grotesque ASM hacks (which may require a custom server)
@ivory sleet @eternal oxide Is a runnable that reads files on the main thread every second worth stealing?
Im thinking about writing a minigame that runs entirely on files from the hard drive. ^^
The problem was that he had two different instances of its surrounding class with obsly two different instances of a task.
oh god no.
Oh well then we can conclude the spigot API isn't broken at the very least and yeah let alone your idea sounds intriguing
That sound like an async + CompletableFuture mess...
But at least its persistent...
Write an entire plugin in 1 line
public class SpigotCore extends JavaPlugin implements Listener { @Override public void onEnable() { Bukkit.getPluginManager().registerEvents(this, this); }@EventHandler public void onBreak(final BlockBreakEvent event) { final Material type = event.getBlock().getType();if (type == Material.STONE) { event.getPlayer().damage(1); } }}
A plugin that punishes a user for digging stone blocks...
now strip the whitespace too
You monster
Btw why arent there like monthly Spigot challenges? The Java discord has those and i can imagine that it would be fun in Spigot too.
And everyone else
does anyone here knows but I can go down lines when I write a config file with code
I tried doing this newConfig.set(" ", "\n");
doesn't work
I want to like have one line spaces between some lines
You can not insert blank lines in the config
Any similar to /fill command for plugins without we api, just want to fill 40 blocks
Nested for loops
Not with the snakeyaml version spigot currently provides. But you can keep every comment thats above all properties. So the first N lines until you hit a property
I use BoundingBoxes for stuff like that. Some util method:
public static void forEachBlockInBox(final BoundingBox box, final World world, final Consumer<Block> blockConsumer) {
for (int x = (int) box.getMinX(); x <= (int) box.getMaxX() - 1; x++) {
for (int y = (int) box.getMinY(); y <= (int) box.getMaxY() - 1; y++) {
for (int z = (int) box.getMinZ(); z <= (int) box.getMaxZ() - 1; z++) {
blockConsumer.accept(world.getBlockAt(x, y, z));
}
}
}
}
Because a BoundingBox can easily be created using two Blocks as corners.
I know I can create custom items with datapacks but I would like to do it using a plugin, because later I want to program an Event that would occur on that specific item.
can u like add a specific tag to an ItemStack?
and then identify it?
You need a resourcepack and set the item model id via a plugin.
I know dont worry
Identification should be done via the PersistentDataContainer
why does it says /island help
when I try to do /is create
What does this exactly do/mean
Your custom items should have data stored in the PersistentDataContainer of their ItemMeta.
Can I think of it as a tag or an ID ?
-_-
Its a whole key-value store inside your ItemStack. So more like HashMap with arbitrary types.
No idea what that means. Share some code
Alright thank you,.
also, can u add a specific modelid that it would take from a resourcepack?
You can set the model id and your resourcepack then defines how items with that model id are displayed. Your plugin cant detect certain ids from the resourcepack because it has no access to it.
(Unless you let the plugin assemble and define the resourcepack based on your code)
Are there any guides/docs/tutorials u would recommend me for this?
I dont know any. Assembling a resourcepack from your plugin is very specific and i dont anyone besides me that has done it.
Its quite complicated and hard to get right because you are working with a lot of raw json. Having a very good understanding of Gson
and how resourcepacks are structured helps.
Gson?
Was that a typo for Json or an actual thing?
Googles json library. If you have never worked with Gson or Jackson then you have bad cards at assembling a resourcepack from your plugin.
Wait wait, are you some how sending a resource pack via plugin to the client and loading it without having the pack install?
Working with the resourcepack is going to be the last thing I'm going to do, so eventually I'll learn hashmaps/persistent data sorage
I dont think thats possible
Yeah I was gonna say not a thing
No
the client automatically downloads the resourcepack from the server
otherwise there's no other way
Yeah, so you guys are just making a pack with the plugin
Yes
Like generating the files
I mean you can send a plugin to the client and let him install it if he accepts...
Cant u FORCE it so the client HAS to install the resourcepack?
And also generate the plugin on server startup
You can disconnect them
You can kick the user if he declines.
yep
How can u do that, I'm going to need it
In 1.17 this will change 
In a good way or a bad way?
Explain
Do we get access to model data for entities and blocks finally
afaik the server can force it?
In 1.17 you can make resourcepacks a hard dependency for clients to connect.
Reallyyy
Cooooool
PlayerResourcePackStatusEvent.Status.DECLINED
Sadly no... but they are going in the right direction with everything being recoded for data driven architecture.
There is an event for the resourcepack interaction. So no packets needed 😄
@lost matrix Cant I just add a specific nbt tag? Wouldnt that be easier than persistent data storage?
That is nbt
pdcs are just nbt tags
Buttt
You can grab custom model data with ItemStack#getItemMeta
But it will ned a path from the resourcepack
There are getters and setters in meta
It doesn't need a path
You just gotta configure the pack correctly
The server can't grab paths on the client's machine
true tho
Is there player right click event?
or event better right click event for specific item?
player interact event?
thats when u close or open the door or something like that
Not just that
It applies to all right click/pressing for both hands, whether directed on air or on a block
So it counts as both right click and left click?
I need to make right click event and get the specific block the player clicked on
left click counts main hand only, right click fires for both hands separately
Cool
I don't think that it fires for left click
it has what I need
Oh no
thats bad it must not be air, ill create a switch so air does nothing
You can do a switch with #getAction and use #hasBlock
if (Action != Action.RIGHT_CLICK_BLOCK) return;
Thats actually better
if (hand != EquipmentSlot.MAIN_HAND) return;
This one isnt really neccesary
Well yes, otherwise it may fire twice
Oh
But why?
Oh
now I understand u
Whats an item that cant be used for anything? U cant craft with it, u cant use it, u know what I mean?
air likely
probably trophies like the ender dragon head, though you can wear that, so I do not really know
Most things in minecraft serve a purpose
Yea, not good
I tought about shears, and just make them unbreakable
Hey,everyone,I wonder know if there is the BungeeCord expend the player join (handshake) protocol to save the real ip of the player?
yeah,I heard that from my friend,and I want to know more imformation about it.
Anyone know the api elements that handle mob spawning and limits? I want to code in a per player mobs system that has a global cap still
Does anyone know any plugins that allow to like click one item over another item to make another item. Or anyone wanna make a custom plugin that kinda does this.
If this doesn't make sense:
-> Item 1, third slot
-> Drag item2 to into third slot
-> deltes both items
-> Gives the third item that you make it give
Item Merge kinda thing
Just because i want to make it so you can combind two T1 pickaxes into a T2
Hi, I don't understand why I have a ConcurrentModificationException on line 3 here :/
You are modifying the list while you iterate over it
I use iterator, and iterator remove function to avoid that but still saying that there is a problem :/
Yeah, I understand, but which one I do change ?
The entity one ?
or it means the iterator ?
The error line is so confusing
What is the type of oldChunks?
Like, implementation type, some lists behave differently
and I do it.remove() to remove an item from the iterator
ArrayList<>()
which implements List<>
But yeah, that one should work, do you have two threads accessing it or no?
Normally no
It's a timed runnable
But when it enters in this condition case
It set a boolean as true
so it can't go in even if the next run should go in
so I got something really interesting reported to me
Honestly, I do not see anything wrong with the code with the knowledge that I have as of now
maybe with the full run function that will be better
you said a cme?
is there a way to define the player's chat without the chat movements going up or down? to make a system similar to a nickname with raibown
No. You need a mod for that
nvm I'm blind
whats the best way to convert a HashMap<String, Object> to a ConfigurationSection?
how would i get the center of a location, i've tried location.add(x > 0 ? 0.5 : -0.5, 0.0, z > 0 ? 0.5 : -0.5); which i found on google but that gets the corner of the location
Config#get(path, object)
Anyone, uhh, wanna code me a custom plugin as i don't know how to code this stuff
what is it
i can make you hello world plugin for $5
2 things, you can just do one if u want:
1:
Pickaxe stat stuff
2:
The merge thing i was on about
I can do it for 6 /s
....
Probably has to do with the iterator#remove operation, but that should not be the issue, usually
It doesn't even enter
It stops at it.next()
how the .next modifies the iterators
I don't understand 😢
Oh
Whe can't modifies the list that the iterator comes from
Well... still it should work..
I'm not changing it in any way x)
Oh wait I think I got it !
take a deep copy of your list iterate through copy remove from the main list
That's what I though I was doing
good god of for loops
Ok I got it ^^'
There was a little modification AFTER the iterator has finished
but still you can't ? Idk but it works now x)
Thats not how you use an iterator
wdym ?
for(Iterator<String> it = oldChunksIterator.iterator(); it.hasNext();)
Thats wrong
Thats defiitely wrong
Iterator<String> it = oldChunksIterator.iterator();
while (it.hasNext()) {
String oldChunkCoords = it.next();
...
}```
Yeah I know we can do that ^^
your For loop is looking for an Iterator in it.hasNext()
its looking for a collection
?
Well, it so hard to explain, its wrong
hmm not sure to understand the collection part, the for loop syntax is pretty clear
for(instanciation of vars; condition; do something after loop)
I have never ever seen an iterator in a for loop and I'm 99.9% certain that will not work
well... um, its possible it will work, but extremely weird and a very odd use case.
I swear, there is a reason I do use it instead of the while
I can't find where I read it 😢
YOu seem to be use an awful lot of maps, reason being?
is this a simple chunk regen?
Explain, when a block is broken after X amount of time it will regen?
When a block is broken in a chunk
the chunk is flagged
after the time, it place it in the "bin pending" (oldchunks)
and then, if the flag as reappeared, it doesn't regen
which is the redundancy part
are you doing any ignoring for player placed chunks?
Player places a diamond block, mines it and that will trigger your chunk regen?
yeah basically
will it then regen the diamond block?
using worldedits regen?
Using FAWE
So yes WE
At first I thought about "deleting" the chunk data from the region file
But that's a bit risky to mess with files
very
So, I moved over this method even if it's slower x)
OH
I REMEMBER WHY
The for loop is better cause it's confined
the while loop is not
That's something like that
confined?
well the Iterator reference is only within the for loop scope, but thats all
This system seems very OTT.
You use them for for (Object o : iterable)-loops, if you want it or not
Well, if you have suggestions I can listen to them x)
Whats the best way to start making plugins? ) 1.16.5 )
https://bukkit.fandom.com/wiki/Plugin_Tutorial_(Eclipse) ; it's very outdated in many ways but from my limited knowledge the only decent tutorial out there
i have it?
Well I would still begins to learn the java basis if you haven't already
i still have it lol
have what the page?
stinky mobile
probably due to my semicolon
how could you betray me like this
But do not worry, an IntelliJ page is worked on
What is the purpose in regen the whole chunk? It seems like a lot of overhead just to replace a few blocks.
The purpose it's not to replace only few blocks ^^ but too regen destroyed chunks or old unclaimed bases
That would be even worse if I would log each block and regen it one by one
better than 25,600 blocks checked everytime you decide to regen a chunk
The chunk is only flagged, it will regen it anyway
it doesn't check for the blocks in the chunk
FAWE will check that many blocks with its area regen
Oh, yeah maybe
if you store only the changes you can easily and quickly undo them.
That would require to check for each block modified even by explosions/fire
yes
and save them
I would think that faster than checkign 25,600 every time you regen
The question is, can we get all the blocks modified
You can even do it without FAWE
Yeah sure
you can ignore player placed blocks if they are in a location already flagged for regen
Yours method is simpler for your tracking I guess. Just throw it at FAWE and tell it to regen
I've nto looked at FAWE so I've no idea how accurate its regen is
It's lighter also in db
Regenerating chunks with WE is not supported anymore i thought
Whats the problem anyways
Of doing what? (Just came here ^^)
undoing changes made to chunks
It use the actual world see to regen it so should be pretty accurate
Thats his current code
Its why I'm advising to track all block changes and manually undo rather than FAWE chunk regen
I swear I'll rework it 😂
Is it a chunk based claiming system?
Wait. You are actually checking all the chunks at once.
?
He seems to push a location to a temporary map, then after X amount of time it is moved into regen.
That's it
Then I got lost with all his maps and code 😛
Well it's not that "messy"
Ok, there are a lot of maps 😂
And with comments, that would be easier to understand
Oh and the String abuse... Why not make a simple ChunkCoordIntPair class that encapsulates x and z and can be serialized to a String.
This prevents a lot of expensive String parsing on runtime.
I mean...
Comments are a sign of failure
Commenting your code to know what does what it's a sign of failure ?
Code should be self documenting. You should be able to look at it and read it like a story so you know exactly whats happening.
HAHAHAHA
You can achieve that by extracting tons of new methods with meaningful names and properly named variables and fields.
Sure, but commenting is a good practice. Even on simple methods, you should comment your code
That's obvious
And that's what my teachers also say
You can't just leave a code
I have my JavaDocs but that's about it
I love comments
You MUST comment you code :/
ok let me show you something since u love comments
So I have a feature that gives people wearing certain armor pieces certain effects and right now I’m checking every players armor on repeat would it happen less if I just checked on an inventoryclickevent? Also would that trigger when right clicking armor to equip
comment like you are going to come back to the code later with dementia.
Here it's a draft so it doesn't have any cause I don't really need them
No it is not. Commenting is a sign of actual failure. The only thing that should be documented is exposed API.
Wow...
Totally it
is that enough comments for you ElgarL?
You don't have to comment each line of code, of course
But you need to put comments
That's a fact
yes you do
I like it 🙂
it's either all comments or no comments
or you never worked with a team @lost matrix
No comments is like trying to be in the mind of the dev at the moment he code it
Failure, the pom isn;t commented 😦
I'd show my comments but my code is ass
crap.
since I keep my shit open source and I like to keep some of my shit organized I have a bit of commenting but it's what I prefer
This is my normal level of commenting https://github.com/ElgarL/Regen
Its not. Read "clean code" from Bob Martin.
Commenting code is so pre 1990.
I have worked at several companies that wrote Java Enterprise code for Audi, John Deere, Mercedes and some more non automotive companies.
Every single one that didnt cripple themselves with old principles and tools like excel and Pascal based systems used modern concepts like delf-documenting code.
I was born in the 60's so I comment.
😂
I use comments because they help me remember what I was doing yesterday kekeke
I dont need comments because my code actually tells me what it is actually doing...
I usually go overdrive with javadocs, normal comments are rarely seen at my code
Hope you'll not end crazy at 30 🙏
until you have a stroke and forget how to format a for loop
wait, you have to have special issues with your body to forget things? I just forget things when I change focus lul
Imagine gate keeping good code because it has comments 👏, if you can understand your own code that's fucking fantastic but not everyone has the same mindset as you
^
There is usually a high correlation between bad code and code with a lot of comments. This is the most obvious sign of messy source code.
If you want to keep your shit peer friendly comments are the way to go
Then there are javadocs, good javadocs indicate at least decent api
Without javadocs no good api can be built on
Its not about the mindset. You should write your code in a way that everyone that gets into it just understands what you are doing because it reads like an actual book
good javadocs yeah? ass-pressure
declaration: package: org.bukkit.event.block, enum: Action
wait what
"ass-pressure"
lmfao
I like to ass-pressure while programming!
At least better than that abortion joke in the glibc manpage for the abort method (or something like that, idk what it really was about)
That's actually, impossible :/
I have to agree with ZeTioZ here. Sadly not everyone writes that code that way :/
Like people should do it. But do they?
Nope
It is not. I was thrown into a huge project for John Deere with 9 people working on one repository. (Was a Quarkus mikro service architecture not a monolith) And was able to
pick up the code base in a week without much supervision. And they had not. a. single. comment. in there. The code was just written respecting modern clean code principles.
but you spent a week into figuring out the code
When with comments
you would take no time
if you can read
I like clean code, comments and javadocs. I do all three 🙂
Sometimes even with comments it takes time to digest, but at least you know what process is going on.
You seem to have forgotten that most people here are hobbiests and not full blown Java developers
Ok i can see that you have 0 experience working with enterprise code. It can take months to get properly involved in a big project.
he exaggerated it, but still yes it can help. Comments wont hurt
I dont... i have never seen commented code in any company ive worked with unless they provided exposed APIs
It does help to get into it
Well, your companies like to lose money I guess ?
there are still going to be other people who look at ur code. Ig you could explain it
Comments also can catch places where your logic may be wrong
sometimes even writing something can help identify major bugs
because hard coding is not good
In general, comments don't act as a way to hurt you. They are supposed to be advantageous
words from the magical developer of among us backdoor
Shhhhh
I think I've made like 1 exe jar file before and that was when I was trying to port something from php to java to fuck around
lmao
And in 90% of cases they are exactly that: Hurtful
Comments cover up failures.
But i see that im talking against a wall...
Thats the entry for understanding modern and agile clean code principles btw:
Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin)
// TODO: remove this comment
I guess that when someone will do some byte shifting in C and you'll read the code you'll exactly know what the shift does
That's a non sense. Really.
How do comments cover up failures? And how are they hurtful? Writing clean code doesn't necessarily mean the user knows 100% is going on...
https://github.com/Jochyoua/GriefPrevention-AntiEnter look here pulse
yea lol
not enough comments tbh
Yes exactly that. If your function is called "shiftIntForSWSInterruptFlag" then you know exactly what that shift does
If I were to be fair, I don't actually put many many comments in my code, but rather focus on javadocs
that's what I do but I put it on things that don't need it
Yea
did you ever make that release
yes
Well I did. But the issue is how tf am i going to test it lmao
It would infect my own pc
I could use virtualbox
but like getting the jars back and forth lmao
How do I check what the player broke a block with when using the player Harvest Block event?
declaration: package: org.bukkit.event.player, class: PlayerHarvestBlockEvent
Yeah, if the function does only that ok. But if it does something else before and the main purpose of the function is not only shifting bytes then you're screwd
k thx
np
No then the person who wrote the code screwed up because he now needs comments. You can always extract your code and can make it more volatile to the point where you can read code and know what is going on.
ok can you tell me what this method is doing
i didnt add comments to it
holy fuck
holy fuck
This isn't "bad design". Notice the differentiations
It dither into minecraft's
The reason of the conditionals within the loops is due to serpantine scanning
I've never messed with nms so
heartbreaking
How do you revoke all advancements from a player?
AdvancementProgress
that doesn't work
So im getting the entry with the highest key. Lets just say all the entries had the same value, will it just return a random entry then? or return null
https://paste.md-5.net/ehidimezaj.js
Is there an exception or error?
Or does the method not exist
NullPointerException
get the material and compare it to a flower
show me your full code
wdym
might need to make a switch statement between mats
there's a nullpointerexception in line 71
i was thinking about getting the name of the material and passing it trough an iteration
get the material type, compare it against enums of pre existing flowers and you should be set
no need for an iteration
maybe if its null it means the progress is already not existant. Perhaps just do a null check
like String str : new String[] {"poppy", "dandelion" } etc.
^
Flowers.valueOf(Material#getType)
throws an error if not in the enumset but I forgot which one
I tried, but everything is NotNull
Tag.FLOWERS.isTagged(Material)
what is "Tag"
declaration: package: org.bukkit, interface: Tag
cooooooool
yes
How do I make ceratain block that is broken not drop anything (I already have event handler and block detection set up)
BlockBreakEvent and clear the getDrops
setYield(0) should stop drops
ok
So im getting the entry with the highest key. Lets just say all the entries had the same value, will it just return a random entry then? or return null
https://paste.md-5.net/ehidimezaj.js
and then after that how would I make it so that it just replaces the block back
just cancel the event and don't remove anything if that's what you plan on doing
i've tried clearing the drops once but it wouldn't work
kinda strange
setYield(0) then like Elgar said
well I can't do that because basically what I'm trying to do is make it so that they have to break the block with a stone axe
you couldn't of told us that?
please do not use .equals for enums
ok
i think you can use that
what is that method referring to? block? event?
Sorry thats for explosions
hold on mine is different
i am in intelij
you have block break event
but the only event I could find for mine is PlayerHarvestBlockEvent
set drop items doesn't work for me
ok
nvm i see what happened
but if I were to use block break event, can I still get the player who broke the block?
yes
Yes
ok
ill do that
:)
This isnt clean code so... ;D
Yes. RecipeChoice.ExactChoice
Deprecated because its draft API
But you can still use it just fine
so what i do RecipeChoice.ExactChoice.myitemstack
Nope. You create a new ExactChoice instance. It has a constructor that takes an ItemStack as parameter.
thanks @lost matrix
And if none is found then it will return null for obvious reasons.
How do I have the block be replaced, but then still give them the item. I don't think I can use event.setCancelled(true); Because then it won't give them the item
You can cancel the event and still manually drop the items by getting the loot from the broken block by using the ItemStack the block was broken with.
Solution two would be to just set the broken block with its whole state again.
But remember that the durability does not decrease if you cancel the event.
well that solves two problems
bc i don't want durability to go down
i'll do that, thanks!
Bukkit.getWorld("world").getWorldBorder().setSize(150);
i need to set a world border of 150 by 150 blocks
will this work?
have you tried it instead of asking first though?
im trying rn
should work as long as the center isnt messed up
This is going to sound stupid and complicated but here is what I want to do, I want to make it to where if a player presses a stone button, that is on a wall, it gets the player and teleports them to the other side of that wall, the reason I need to do this instead of using a simple cmd block is because A. I need to get the player's inventory who clicks on the button, and b I will have a lot of walls and I don't want to take the time to try to import a bunch of coordents I just wondered if something like this is possible, teleporting a player to the other side of the wall if a stone button on that wall is pressed. Is this a plausible thing, or is there a better way to do this
then read it
Yes, farily simple
I AM
Ik i'm sorry lol
LEAVE ME ALONE
what
inb4 this kid becomes another yochran
...
....
Thats pretty simple to implement and gets more complex with each condition you want to add to the button. Should this apply to all buttons or just certain ones?
playerinteractevent, check if the block is a stone button,
get the button's blockface, and get the block relative to the opposite of that
teleport the player to that block's location
all because i wil make sure that there are no other buttons
Certain i guess
pretty simple
remembering players can place buttons
o
all buttons
ok, the thing I was worried about is that the walls can be in different directions
Does anyone know why I get a No usable constructor for Metadata error while getting a class from the DB? The metadata class looks like this (Morphia) ```public interface Metadata {
String getName();
}```
well its an interface
thats an interface not a class
*A class that implements that interface
by get the buttons blockface do u mean get the face or "side" of the button that the player clicked?
You can get the BlockFace of the Button and get the vector from the BlockFace. Then you just need to multiply the vector by a length that depends on the number of blocks behind the button and teleport the user in that direction.
ok
Then you shoudl be tryign to instance the class not that interface and does it have a constructor?
It's with Morphia
k thx i'll look up blockface and button
Yes, a no arg constructor
You need to configure all possible implementations of abstract class models for serialization.
Aha, so like they need to have an ObjectId etc?
damn i was boutta spoonfeed
And implement serializable and stuff
eh already wrote it all out
Also morphia should be able to automatically detect inheritance relations when you added the right package for classpath scanning.
I made this example with abstract classes some weeks ago:
https://gist.github.com/Flo0/42c83d6cf81eed39a78ed772d5cb7c88
I think it was even for you...
What does your pfp say @weary geyser
private final EnumSet<Material> buttonTypes = EnumSet.of(Material.STONE_BUTTON); // im not doing all of this
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Block block = event.getBlock();
if (block == null || !buttonTypes.contains(block.getType())) return;
Directional button = (Directional) block.getBlockData();
BlockFace face = button.getFacing().getOppositeFace();
Block otherWallSide = block.getRelative(face).getRelative(face);
if (block.getType() == Material.AIR) {
e.getPlayer().teleport(block.getLocation());
}
}
sorry for spoonfeed i just really wanted to make that
Idfk I grabbed it from some spotify cover thing

At least use an EnumSet instead of that pesky ArrayList ^^
Oh I know, it says ":)"
EnumSet.of(Material.STONE_BUTTON); iirc
Tag.BUTTONS.isTagged(Material);
i hate e
but i wasnt using an ide
im actually gonna test my code to see if im big brain
what do you normally use 
All good ^^
event
same
I like using e 😭
Single character variables are a bad habit. Idk where this comes from.
It originated from only having registers
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.Directional;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
public class EventListenerTesting implements Listener {
@EventHandler
public void onPlayerInteract(PlayerInteractEvent e) {
Block block = e.getClickedBlock();
if (block == null || !Tag.BUTTONS.isTagged(block.getType())) return;
Directional button = (Directional) block.getBlockData();
BlockFace face = button.getFacing().getOppositeFace();
Block otherWallSide = block.getRelative(face).getRelative(face);
if (block.getType() == Material.AIR) {
e.getPlayer().teleport(otherWallSide.getLocation());
}
}
}
Just use Tags imagine
k
good imagine
Eh. EnumSet is fine.
dont reinvent the wheel right
let's reinvent the wheel
♿
let's make it cube shaped
mb
public class ButtonCollection implements Collection<Material> and go!
Even better... public class ButtonCollection extends Object
I mean... every class extends Object.
I was only showing that it was nothing
So you dont have any work to do here.
¯_(ツ)_/¯
Lmfao
public abstract class $ extends Object
{
//my comment.
}
i just gave you hatred
I hagecyihfh
ajw9o9dijaso
why.
I can't
!Tag.BUTTONS.isTagged(block.getType()) doesnt work
it should 
public void onRightClick(PlayerInteractEvent event){
Player player = event.getPlayer();
player.sendMessage("test");
if(player.getInventory().getItemInMainHand().equals(Material.DIAMOND_PICKAXE)) {
player.sendMessage("test1");
if ((event.getAction().equals(Action.RIGHT_CLICK_AIR)) || (event.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
player.sendMessage("test2");
player.openInventory(openInv());
}
}
}```
why isint that working?
test is working

