#help-development
1 messages · Page 1868 of 1
will this get online or offline players?
it will get all registered strings to the team
for instance a team can contain the "player name" $ or sth
I would like to be able to change the default / fallback of the bungee cord with a bungee cord plug-in during operation.
yeah that should be possible
Do you know how?
not exactly but it depends on what you're doing in the operation you mentioned
a.forEach((offlinePlayer -> {
Player plr = offlinePlayer.getPlayer();
if(offlinePlayer.isOnline()) {
plr.sendTitle(ChatColor.DARK_RED + "BED DESTORYED", "", 123, 6000, 123);
}
}));```
i did that
what's the point of the user factory when it's every time User::new?
also i dont understand why using an Optional 😄
has anyone an idea on how to prevent stackoverflowerror while replacing all lava in a chunk with air ?
I only want to set a server that has already been registered, for example with the name as the default server.
yea but in this case idk
Split up the task
thought about that but that sucks ^^
avoiding nullable return types
it makes it more explicit that the return type might intentionally be null
thats to decouple User creation from instantiation (the factory)
but probably unnecessary
is there any plugin that rigs your tps? i need to test my plugin on low tps
I mean the rigging the visual tps wont do anything
however if you wanna rig the tps, could just use Thread::sleep
ehh ok
hmm unsure actually and yeah probably a question for the hs channel
is there a way to make sure ur plugin gets unloaded last
lets move over there
conclure, what do you mean with humblestorage (that makes the most sense of those two) and delegatingstorage?
the first one is the super type where the second one is designed for more specific uses?
Don't think so. Why do you need this?
also i havent thanked you 💗
no, the humble one takes away/decouples anything with concurrency and multi-threading
ah in that way
then we have a wrapper which just incorporates and wraps it around a future
i feel like if it was a depend in spigot then it would handle accordingly in unloading but nothing says that specifically
its quite a good practice to avoid poor concurrency and multithreaded designs
of course you shouldnt follow it blindly like any good practice but yeah
I have a custom block populator that's not using the world generation API (for various reasons), and it seems like Block#setBlockData(data, false); is still causing nearby chunks to be generated, even though I'm specifically against that. Any clue why it might be, and how I might mitigate it? https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/block/Block.html#setBlockData(org.bukkit.block.data.BlockData,boolean)
what version ? currently have had the same issue with updaing neightbor chunks ... i now just use getBlock().setType(material, update=false)
in 1.18.1
Statistic.html#TIME_SINCE_REST
returns the time in ticks, right?
I know I could just check it but I thought maybe someone knows
but setType doesn't set the BlockData unfortunately
could be probably seconds too ... but i think its ticks
good way to check is ingame-cmd /data entity get .... ^^
what blockdata do you set ?
Do your self a favour and use the new BlockPopulator api if you are on 1.17 or 1.18
how does that work for stats?
there should be an value in the player data for that too ^^
blockData copied from another block elsewhere
unfortunately I cannot
I really want to, but constraints and how stupid the idea I'm working on make that impossible
the problem with blockpopulator is the limited region where you can set blocks :/
You have a 3x3 chunk area to work this should be enough for normal chunk populations.
there is always something called nms ^^ bad idea to use but if you dont care about light updates you can use nms ...
it's indeed ticks
that way i would need to check if my structure will generate something out of the 3x3 area and move it back into the region ^^
anyway, it seems like the API should do what it promises to do
instead of straight up lying
will there be an exception if i try to unregister listener via HandlerList.unregisterAll(Listener), if listener isn't registered?
maybe I'll make a spigot PR
i dont see why it would tbh
also sadly generating worlds in nms is a lot faster then using api ^^
If you have structures which are bigger than 3x3 chunks than you should split them up. (Which also minecraft vanilla those with bigger structures)
i wish i had an idea to get where structures ended and need more generation if the chunks load ^^
can anyone help create some code for me? I need a small snippet of pseudocode made in java.
ok:
if question.isbad || question.hasnoinformation
// dont answer
else
// try to help
?
you want pseudocode but dont describe about what
noone will know if he can do this for you since the task is unclear
when a player places bucket of liquid:
add location to list
if it gets removed by the plugin regen, remove it from the list
if it gets picked up again, remove it from the list
if it gets blocked by a block then remove it from the list
on pickup water, check if water location is in list of player placd water, if it is then return? and if it sint then cancel and send a message "You can only pickup liquids placed by a player•
you bassically look for
PlayerBucketFillEvent and PlayerBucketEmptyEvent
and also BlockPlaceEvent
Warning: question.hasnoinformation will always be true
im bad at java lists
since im used to python more
how would i add and remove coords from a list
or a storage method
theList.add(location)
and to check it to a playerbucketfill event would be something along the lines of
if pla yer bucketfill location is in mylist
well check if the list contains the location
or would i have to loop it to check
though be aware that locations are exact
in visual basic i do smn like
for c in mylist:
if location = c
block location then
how would i check coordinates not exact
for(Location loc : myList) {
if(loc.equals(someOtherLocation)) { ... }
}
I have my own class for that, called SimpleLocation
Are there any ways to perform bytecode modification
asm
oh right
can you share it?
or how to store coords instead of exact locations
How would I go about using it in a plugin
as dependency
Alright
package de.jeff_media.test;
import org.bukkit.Location;
import org.bukkit.World;
import java.util.Objects;
public class SimpleLocation {
private final int x, y, z;
private final World world;
@Override
public String toString() {
return "SimpleLocation{" +
"x=" + x +
", y=" + y +
", z=" + z +
", world=" + world +
'}';
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
SimpleLocation that = (SimpleLocation) o;
return x == that.x && y == that.y && z == that.z && world.equals(that.world);
}
@Override
public int hashCode() {
return Objects.hash(x, y, z, world);
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public int getZ() {
return z;
}
public World getWorld() {
return world;
}
public SimpleLocation(Location location) {
this.x = location.getBlockX();
this.y = location.getBlockY();
this.z = location.getBlockZ();
this.world = location.getWorld();
}
}
Do I need to include it in the jar?
yes
thanks :)
Just wrote it new, I didnt find the original one lol
ur quick
you can now just do SimpleLocation simpleLoc = new SimpleLocation(location)
then compare them using equals()
so how would i yse that
to chdck where a player placed
water
do i use the playerbucketfill thing to
Hello! I've got a question. I have a plugin in which you can craft custom clocks which have an enchantment attached to them, these clocks have a different colored name when you craft them (the name is green). If you go to an anvil and rename the clock the color of the name will turn to blue instead of green. Is there an easy way to keep the color of the name of the renamed item green (also in the suggested name part of the anvil?)
i think thats texturepacks
maybe im wrong but i dont think plugins can change colors of items
after it's renamed, get the name, strip the color and then recolor it
I'm talking about the color of the name
use PrepareAnvilEvent then do what i said earlier
okay nvm lmao
I was thinking about this as well by making a listener, do you know if this also makes it possible to keep the name in the name suggestion part of the anvil the same color?
not sure what you mean with name suggestion part
If I would iterate over all worlds using bukkit.getWorlds() , is that going to be acceptable in terms of performance?
more specific this:
for(World world: Bukkit.getWorlds().stream().filter(this.sleepService::isEnabledAt).collect(Collectors.toList()))
If I do that every second
I'll try this, I was just hoping there was an easier way, like when you rename an enchanted golden apple the color in the anvil part remains purple
if I do that every second*
because that's a part of minecraft and not a custom name
I'll try my best to recreate it for you
unless you have thousands of world (which should be questionable on its own) or execute any complex/network stuff per world it's fine
Every second right? so a repeating task like this every second
computers are not doo doo
Wrong, they really are doo doo sometimes
most people tend to underestimate modern computing power
yea well
define modern
Is it possible to upload a video in this channel?
Don’t think that’s resource heavy at all tbh
I have no idea how heavy it can be
is a 2018 mac modern?
i'm not saying modern computers can execute any calculation instantly but
Alright, great 🙂
sure they can make pretty hard ones in matter of milliseconds
sha4096 go brr
example, i had a plugin that had to check when a player entered or left a custom claim zone
there was like a claim block that had a certain radius
so on entity move i looped all of these claim blocks
checked the bounds
it was probably not the best way but with 50+ players it had a minimal impact on performancew
because all it did was basic math at its core
It's O(n*m) with n players and m claims
more like O(n) where n is the sponges per each player movement
in worst case scenario
Might not be terribly problematic until you realize that since the number of claims is directly related to the number of players, it's essentially O(n^2)
Talking about per tick here
Because player movement is processed once per moving player per tick
iirc player move events can be called multiple times per tick
so it might have been even worse
And it's incredibly easy to set up spatial partitioning for that
i'm not sure what is spatial partitioning tbh
Basically this
I made a video to show what I mean. If you rename an enchanted golden apple the suggested name remains pink/purple, whereas if you rename an item with a custom name and a custom color the color will just change to white again. I was wondering if there was some kind of NBT tag which sets the color name of an item causing the golden apples name to remain purple when suggested
Basically just a map for approximate location -> things near that location
nope, that's hard-coded into the client for special items like enchanted golden apples
So you can quickly determine what is near a location and do your extra checks from there
😦
so it's like dividing the world in subsection
getting the subsection a player is in
as i said you could listen for anvilPrepareEvent, if it's the item you want to keep the color on, strip all color off with ChatColor.strip and then recolor the stripped new name
and then checking the elements in that subsection
yeah that sounds much more efficient
Yes, I'm thinking about doing this
Hey everyone, I'm stuck on an issue regarding villager trades.
I spawned in a villager with custom trades (diamond for a book).
It does spawn and behaves like a normal villager but when I want to trade the screen shows up for a couple of milliseconds and then disappears.
Does anyone happen to know what might cause this?
What version of Spigot?
for 1.18
maybe the trade screen will close if the villager has no job or smth
I tried giving it a profession but then it just shakes it head
I found the solution.
The vilager checks on spawn if there is a profession block nearby. If not it just reverts to a normal villager.
Somehow normal villagers are not allowed to trade anymore but by setting the experience to an arbitrary value it stays as the profession.
setting the level works too
Anyone know if FileWriter creates a file when when you instantiate it?
I prefer nio
I need to use it
Files.writeString
i believe it only creates once u call .write
Files.readAllLines is a godsend
it does lack the ability to directly write bytes tho iirc
ig it makes up for that by having .newBufferedWriter
Pretty sure you can write bytes directly but I could be wrong
iirc theres no writesBytes or plain .write
im also just kinda browsing its javadoc rn
This isn't spatial partitioning :thonk:
How is it not lol
It is a map, not at all even close to a partition tree
It's mapping things spatially so you don't have to iterate over everything to find an object near a given location
The concept is the same
Factually incorrect
It's not a k-d tree but it doesn't need to be
The implementation is not idea
oh hmmm
And yes, the concept is the same
Nope xd
To split things up based on approximate location to make it easy to find them
It is log2(n)^2 * x * z insertion efficiency
Not even close to how good a k-d tree is
x and z being what
The size of the square you define
I didn't see any support for a third dimension in your implementation
oh im dumb it's right there
Yeah it uses x and z only since the y axis is so tight
You should have support for y-axis anyways, but that's a separate issue
But insertion is O(1)
Definitely not
How not
It determines where to insert, with simple division, O(1)
Then inserts into a set, also O(1)
Yes a hash set has O(1) insertion too lol
That's bullshit
Bruh
its not
"For HashSet, LinkedHashSet, and EnumSet the add(), remove() and contains() operations cost constant O(1) time."
Hashing an element is O(1)
And the array write is O(1)
So inserting an element into the region map is O(1)
I got to go fact check this right now, I'm looking at the implementation
Lmao
I have literally implemented these days structures before and it's common knowledge that insertion is O(1)
That's the entire point of hash sets/maps
FACTUALLY INCORRECT
This region map is not as precise as a k-d tree but it's good enough for the vast majority of use cases
.-.
You would expect the average insertion time to be O(1)
dont feed the troll
Yes worst case is O(n)
But the worst case insertion time will be O(n)
Just like quick sort has a worst case of O(n^2)
Always operate your assumption of efficiency on the worst case
Yes I do
That's what it is.
...
Expected may be better *, but it is still at that level.
Quick sort is only O(n^2) if it picks the worst possible pivot every single time
The odds of that happening for a large data set are so astronomically low
but never zero
Much like the odds of a hash collision on every element are astronomically low
If you're worried about that you should worry about me mashing random buttons on a keyboard and guessing your password first try
Regardless, O(n) on the hashset, O(n) on the hashmap, x*z for the insertion on every single address
Or getting struck by lightning whenever you go for a walk
Or a UUID collision every time you use UUID.randomUUID()
Or having a Minecraft developer be a capable individual >:)
We call it O(1) because that's what it's always going to be unless you got odds better than winning the lottery multiple times in a row
So please understand why you come across as insufferable when screaming "FACTUALLY INCORRECT" in the face of common knowledge
I'm going to call my region map O(1) on insertion because under all reasonable circumstances that's what it is
I'll take the L and admit that I'm retarded with most of my claim, but I'm not going to set the fact down that what you have made is, in fact and reality, not a spatial partitioning algorithm.
You are inserting objects into a hashmap, that's not partitioning at all.
If you have 100k elements in your HashMap, the odds of them all having colliding hashes and the runtime being O(n) is 1 in 100k^100k, an unfathomably small chance; you'd have better odds of picking a random particle in the observable universe and having it be the same particle 3 times in a row
And yes, this is a form of partitioning
Factually incorrect
It's one way of dividing up the space and mapping objects within it
"wow look at these buckets! partitioning!"
You're simply not partitioning anything at all
It divides the space into equally-sized parts
It's partitioning
Chunks are a form of spatial partitioning
Quit being a pedant
This is simply not some silly little thing, though
You're using a hashmap and calling it spatial partitioning
There is no elegance there
How not
That's not an algorithm, dude
You're making a map wrapper
You have successfully made a map wrapper
Again, cry about it, it's spatial partitioning
Definitely not
It's not like I'm claiming something super impressive
Do you think Google is using hashmaps to position things in their pathfinding algorithms?
I'm claiming to have made something which partitions a space by subdividing it
Which is true
You haven't subdivided anything at all, though
LMAO
No way that you're going to tell me using an integer coordinate system is subdividing the space
.
It literally is lmao
"The world is a partitioned space because of the atoms in it"
Same level brain assertion
I'm grouping areas
No, no you aren't
PARTITIONING them into horizontal regions
r
Where do you get off?
Why are you being an elitist about the pettiest thing
This is one way of doing spatial partitioning
All you're doing is being an asshole here
Okay, I'll play along here.
Let's say this is spatial partitioning
Give me all of the areas associated with a certain group.
whats up
Hi conclure
For instance, I say that coordinates (10, 10) to (20, 20) belong to some string, "A"
hello Red
Care to tell this guy to quit being a pedantic condescending asshole?
hmm well surrounding what?
If your algorithm, in its current state, can give me all of the coordinates associated with the string "A" in comparable time to other real spatial partitioning algorithms, I'll PayPal you US$20
or yk Ill just read for myself
Good place to start
Better place to start
btw
Sure
big O notation only denotes worst time complexity
^^^^^^^^^^^^^^^^^^^^^^
@waxen plinth r u as sexy as redlib is?
I mean bk that was to you
You generally refer to average case when talking about these things but sure
We never consider quick sort as n^2
You tell me
Big O notation means worst time complexity
theta notation means average
omega notation means best
Atla
so saying average O(blah) is kinda wrong
that's sexist
what
This class offers constant time performance for the basic operations (add, remove, contains and size), assuming the hash function disperses the elements properly among the buckets
anyways O(1) for insertion, contains and removal iirc
idk why u'd say O(n) insertion
Hey, Does anyone know what the DataWatcherObject id of customNameVisible boolean is? (1.18.1)
wait red what r yu
sure, the internal array must be resized from time to time
He/him
oh oki
Well the technical worst case would be if all the hashes collide
So everything ends up in the same bucket
yeah
That would be O(n) but is so insanely unlikely that there's no use worrying about it
yeah
Are you saying I shouldn’t just return 1 for my hash codes
insertion might be O(n) also if we consider bucketing
yo mama so fat, sorting her is O(2^n)
🙄
Anyways the main argument was about whether my basic region map implementation is spatial partitioning
He says it's not when it's literally subdividing a space, which is what partitioning means
He's trying to tell me that simply putting something into an integer coordinate system is subdividing it.
You're dividing it up
Much like chunks do
And again, chunks are another form of spatial partitioning
isnt subdividing dividing the divisions? 🤔😎
I don't know why that is so hard for you to grasp
How to check if a player is flying on elytra or with a fly?
What
We're bordering on spherical brain level ideas at this point
Oh elytra
how to tell if flight is isFlying or elytra
isGliding vs isFlying
thanks
Look, you're just being so condescending for no reason. Grouping nearby objects together in equally-sized regions is spatial partitioning, and if the definition of partition doesn't convince you then I don't know what will. You're really getting on my nerves by being so pedantic about it, especially screeching FaCtUaLlY iNcOrReCt like it helps your case
anyone has an experience in the plotSquared API here? which event do i use to check if the player is trusted?
event? there's some method for that
I also have a class for PS4 and PS5
now tell me where lol
check the class I sent
ok
That's the opposite of spatial partitioning
That would be a Map<String, Set<Location>>
Mine lets you get objects of an arbitrary type mapped near a given location
And I don't want your money
Nope, it is apart of spatial partitioning
If I insert a box I ought to be able to figure out where the box is later
A reverse map is a separate thing
Required type:
capture of ? extends Event
Provided:
PlayerInteractEvent
whyyyyyyyyyyyyyyyy
package com.aregcraft.delta.item;
import lombok.NonNull;
import org.bukkit.event.Event;
@FunctionalInterface
public interface EventConsumer<T extends Event> {
void handle(@NonNull final T event);
}
and then?
package com.aregcraft.delta.item;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;
import org.bukkit.event.Event;
import java.util.List;
@Getter
@AllArgsConstructor
public class TypeInteractionHandler {
@NonNull
private final List<EventConsumer<? extends Event>> eventConsumers;
}
How can i get tools that work like the Elytra? they stop at durabilty 1 and are then unuseable?
EventConsumer<? extends Event> makes no sense
why
well any class with a generic type parameter is a type of a type constructor
Lets say we construct the type EventConsumer<Event>
this type is different from EventConsumer<PlayerEvent>
(just as an example)
usually when we have consumers we are callbacking on a specific argument
in this case an instance of Event
if you have ? extends Event
it means any a capture of any subtype of Event
now if we had ? super Event it'd make more sense, as you'd be able to pass an EventConsumer<Object>
is there a way to get the full nms source code with the mojang mappings
if you have an EventConsumer<PlayerEvent> an instance of this type might do operations only the type PlayerEvent would support
so then its very risky to pass an object to an EventConsumer<? extends Event> as you don't know which subtype is the correct one
how to check if the player is rotating the mouse?
So your design might be a bit flawed in this case
@ivory sleet
I use PlayerMoveEvent
When I go, I get a message
running build tools just returns me the one with the spigot mappings
but if the yaw and pitch are different
which is obfuscated
what build tool do you use?
thanks
maven
but I can use gradle too
i still do not know? can you help?
nothing works i am using PlayerInteractAtEntityEvent event
does this #help-development channel help kinda resourcepack problems?
Yes
checking /work/decompile-latest still has the spigot mappings
there are no spigot mappings in 1.18
I tried to make an gui, so i tried to add an gui-model to diamond_hoe and it kinda worked, but texture being darkened.
minecraft/models/guis/upper_section.json:
https://paste.md-5.net/agugizonap.json
minecraft/models/item/diamond_hoe.json:
https://paste.md-5.net/bubatejenu.json
i can't find why it darken like this
it looks like the other gui is ontop of that gui
and the whole screen darkes
is that gui a texture? the diamond hoe one
is this even server programming related ?
because when you open your inventory maybe it darkens everything around it including the diamond hoe texture
i dont know what it acually means programming-related but
probably yes
its not anythingn to do with plugins or code tho
sad 😐
i made an gui-texture and links to diamond_hoe like this
How can I grab every single line in a text file with bufferedreader?
oh wait
nvm
got it
split it by \n would be my guess
how can i check if the plotsquared player is trusted?
get the trust list of the plot?
idk how to get the plot the player is in tho
What event gets called when a block is broken by forces other than the player? Like Water breaking a torch.
BlockBreakEvent and BlockDropItemEvent are only fired when the Player triggers them.
hey @wet breach, sorry for the ping but i wanted to ask where could I find a version of packetentityapi for 1.8. I have tried to use the latest legacy release i was able to find (0.7.2) but it won't launch because it has inside stuff from later versions. I'm asking because i saw on the spigot page that 1.8 is supported (ping me back when u can reply)
I might have figured this out. Seeing if a EntitySpawnEvent (instanceof Item) can help me here
does entity.remove() call entitydeathevent?
I don't believe so
if an armor stand is riding an entity
and the entity gets .remove()'d
what happens to the stand?
i would assume it would be dismounted and left there, but it could also get deleted
hmm
check for passangers, dismount, then remove
Well, not bad, however i'd get rid of plugin/config depenency. Instead, make your constructor accept data you actually need: password, username, database name, and such.
i wanna set armor stands on entities without inserting a line after every time .remove() is called
that's not very dynamic
something like if(ent.getPassengers.size != 0){ do a thing }
Also, you shouldnt execute code in constructor like you do with insertQueryAsync - you just create the object
but when? .remove doesn't call death event
It would be a check before the remove. If you want it to call a death event you can instead do livingEnt.damage(9999)
or maybe there's a kill too
Also, do not swallow exceptions: instead of crying in logger, rethrow it by wrapping in RuntimeException. If something went wrong, code should know about this
I also would remove insertQuery async at all. Database mamanger shouldnt throw async tasks by itself.
is there a way that online players can be hidden from tab complete and commands, so that even vanilla commands would not be able to target them?
is there something to check (packets or api) if a player wants to move a horse while sitting on it for example
you would need to use nms probably
Last I remember Horse movement is clientside. If it doesn't fire from PlayerMoveEvent I can't think of where it'd come from
Im definitely sure I would need packets but im not sure what would intercept commands or tabcomplete to make the player appear offline
hmm sad ... thought an fake player as horse (horse is not fake, but despawned for player and instead the fake player is spawned) will work xD but the client does not want to control the player like a horse 😄
tabcomple will be packets for sure.... that cmds work would be that you have to remove the player from all registrations in the server ... (thats a bad idea^^)
hm, I guess I'll have to manually handle that with the command preprocess event then
is it possible that even pigs are client side movement controlled ???
i cant move the pig(disguised as player) with a carrot on a stick
Steer_Vehicle packet
PacketPlayInSteerVehicle
Usually contains a forward and side movement inputs, space and shift status
You can then use the ControllerMove's a(float, float) method to strafe any entity as if you were controlling it
(1.12) ->
float forward = ...;
float side = ...;
boolean jump = ...;
boolean shift = ...;
Player rider = ...;
Entity vehicle = rider.getVehicle();
if(shift) {
rider.leaveVehicle();
return;
}
net.minecraft.server.v1_12_R1.Entity nmsEntity = ((CraftEntity) vehicle).getHandle();
if(!(nmsEntity instanceof EntityInsentient))
return;
EntityInsentient insentient = (EntityInsentient) nmsEntity;
ControllerMove move = insentient.getControllerMove();
ControllerJump jumpController = insentient.getControllerJump();
// ControllerLook look = insentient.getControllerLook();
move.a(forward, side); // strafe
if(jump)
jumpController.a();
Will be similar for higher versions, just make sure that the ControllerMove's method takes in 2 floats, or its internals reference strafing
If you want to change the strafe speed, you need to access its e variable (often the 4th double) and set the value
Hope that helps @spiral light
the packet helped a lot
thank you^^
yeah there is no api i can see for setting the saddle O.o
Also slimes etc will need to have their ControllerMove instance set to something else if you want them to behave like regular entities
HorseInventory#setSaddle
Pig#setSaddle
ah wow ... thank you, i had pig but horse has to be different of course ^^
Does anyone here have experience with packages related to ClientboundSetEntityDataPacket?
I have an armor level and set the nogravity and customname and customnamevisible and the customname stuff doesn't work does anyone know a fix?
isnt customname for chat ?
?
customname for a armorstand
ah ok
I set both correctly and it just doesn't work, yet it has the other properties but
Thats a metadata packet, no?
yes
The armorstand is also spawned but without customname
how do i make an event that when a player places a water/lava source it saves the location to a list and i can later remove the location and add more if i need
WaterBucketEvent(PlayerBucketEmptyEvent bucketEmptyEvent)
is that the right method
It doesn't follow naming conventions but the Event you're using is correct.
ok thanks
Then just call bucketEmptyEvent.getBlock().getLocation() and that should be the location of the source block.
i saw someone say that that would get the Exact location
and not the coordinates
do you know the problem?
What
Exact location of what
https://paste.md-5.net/oyowoxeras.java --> Main file
https://paste.md-5.net/vivajusaqe.java --> DataManager file
https://paste.md-5.net/necidevubo.bash --> Error log
I am getting the following error, all of the needed classes are in this message. Why am I getting the error? I tried putting the config inside of the jar file, but that didn't seem to work.
The config should be in the same place as the plugin.yml
oh ok
this look correct?
trying to get the location of a placed water bucket
or is that the face that the water is placed on, so the block below.?
Does anyone know how to listen for events with MockBukkit?
I believe like normal spigot
Test class needs to implement listener then?
its only the mocking of calling an event which might be different?
yeah
and for setup you'd register the listener in principle
and tear down you unregister it
Does Spigot automatically map the Minecraft jar? If so what mappings does it use?
it used to have those nms mappings
you can use mojmaps now
tho you're not allowed to distribute it iirc so if you're a plugin developer might be sufficient to only depend on mojmaps at compile time
Am I able to use yarn?
nope
or well
dont think anyone has taken the effort to implement such a plugin which would support it
Doesn’t paper run mapped at runtime
yeah
Therefor requiring you to distribute mapped jars
is it possible to make a player have potion particles on the without them actually having any effect?
sounds like you'd have to use packets for that
but prolly is since the visual effect is just rendered client sided
yay
why can you not use external emojis here
sad
wanted to express my happiness to be working with packets
You need to boost
Hmm, I have an interface with a getter, in implementation A its nullable, but in implementation B its not nullable, do I annotate the getter in the interface with @Nullable still?
IMO, yes
Thanks, got it working, but I'm having to introduce another instance variable into the test class. Don't suppose this is avoidable? Ln61 getEvent() used to initialise ln43 tagEvent:
https://www.toptal.com/developers/hastebin/latodebeku.java
Just uhh
just do it
Make it an optional so it’s not nullable either way
well
you probably want to isolate the test class from the actual logic
like the test class shouldnt be a listener itself lol
lol
@QuantumNullable
Ah then I'm not sure how to get the "capture" the event in the test?
It’s both null and not null until observed
oh god lol
well you just use PluginManager::callEvent to invoke an event
I believe IDEA can differentiate based on implementation but idk.
bruh the only thing i can find on potion particles is how not to show them 😐
hmm interesting
class Test {
Listener listener;
void setUp() {
listener = new MyListnrImpl();
pluginManager.registerEvents(listener,plugin);
}
void givenEventInvocation_doesEventGetCancelled() {
MyEvent event = new MyEvent();
pluginManager.callEvent(event);
assertTrue(event.isCancelled());
}
}``` @light parcel for instance
tho that might actually test the event instead or well both parties actually
a bit problematic if you wanna isolate your units
but yeah the way spigot's event system works with explicit types its hard to mock events
But the test is supposed to be checking that this event is thrown by other conditions, throwing it myself defeats the points of the test
yeah
in that case invoke the according mock methods
and assert that the event ran
or sth
not sure you read what i sent
i want to show potion particle effects on a player
depends if you're testing the listener or the event
yeah might wanna use a MockListener then
or sth
I read it lol. Simply spawn the particles?
Both I guess, I've got one event that triggers a second that I listen for - what's sth?
oh lol
you should separate it to 2 different classes
one class testing the listener with a mock event and one testing the event with a mock listener maybe
Mm yeah it's probably a poorly designed test tbh
well
bukkit and minecraft in combo with unit tests is kinda meh
but it works almost fine
altho its hard to always apply all practices to the letter given the environment
Instead of unit tests, formally verifying the logic on your code is better
we just have to assert certain things that arent gonna happen
wym formally verifying? like manually?
because the entire point of using unit tests is to automate the process
and then whenever you add some new prod code to your system you run tests and check if everything still passes
No, no, you can automate the formal verification process. You simply have to write the rules for the code once
Fuzzing is your friend :)
It is mathematically impossible to break your code if it is formally verified to be correct
is fuzzing the same as mutation tests?
because if its that then sure its not a bad way of testing
Yes, fuzzing is a special type of mutation test
Hello there! I am currently in the midst of an unworkaroundable error in my code involving remapped NMS, i have consulted many people and many other servers and if this doesnt work idk what to do then. My problem revolves around the Clientboundinfopacket class and it being ig build tooled improperly. i dont know the root of this error and have tried rebuilding my 1.17.1 build tools 5 different ways now and nothing has worked, along with trying various other work arounds. Here is the error and i would EXRTEMELY appreciate any help if it can be provided as i cannot continue development of this plugin i WAS excited for which would suck. Upon maven clean package building and artifact building with inltellij i receive this error D:\Coding\Intellij projects\DownedRust\src\main\java\me\art\downed\downedrust\BodyListener.java:5:43 java: cannot access net.minecraft.network.protocol.game.ClientboundAddPlayerPacket bad class file: /C:/Users/Blake K/.m2/repository/org/spigotmc/spigot/1.17.1-R0.1-SNAPSHOT/spigot-1.17.1-R0.1-SNAPSHOT-remapped-mojang.jar!/net/minecraft/network/protocol/game/ClientboundAddPlayerPacket.class class file has wrong version 60.0, should be 52.0 Please remove or make sure it appears in the correct subdirectory of the classpath.
Is there a way to use unmapped?
mutation tests can take considerably more significant amount of time to do
using protocollib, is there a way to cancel the digging sound of a specific block?
so its not those tests you run after every function you write or sth
ofc depends if you do tdd or not
but yeah
if anyone could help i would much much much appreciate that
To be fair, for Minecraft, it is overkill af
hmm maybe
There are special use cases for it, like if you write an actual spatial partitioning algorithm to store your claims
wrong java version
I mean you can test your code regardless?
build it with java 17
been there done that
just that I hate tdd (to a certain extent)
hi I make aspect plugin use AspectJ and I try load this when I eneable spigot
I should write other argument when I eneable server? java -jar -javaagent:C:/Users/MatDr/.m2/repository/org/aspectj/aspectjweaver/1.9.7/aspectjweaver-1.9.7.jar spigot.jar
TDD is shit tbh
sorry that was toxic but yeah i already tried that
how can I insert a BaseComponent or any of it's deriving classes into a book?
well yeah I believe the theory and reasoning about writing tests is good
Imo the only unit tests you should write for your code are the ones where you have special exceptions that should always be accounted for
but tdd became a shit cult people commit to blindly
I.E. you're doing address parsing and one of the parcels has a special format you'd like to make sure you follow and are able to parse
Idk I usually write unit tests for anything with io and networking todo as well as parsing yeah, and possible concurrency
but for actual design, unit tests is a big no
i would like my question to be answered if thats alright
Link it
here
well I believe functional tests and those tests which aren't specifying concrete units are much better as they don't break every other second you decide to change the concretion
Have you used protocollib before?
somewhat. i have used the sample code to disable all sounds but i can still hear the walking and digging sounds
new PacketAdapter(getPlugin(), ListenerPriority.NORMAL,
PacketType.Play.Server.NAMED_SOUND_EFFECT) {
@Override
public void onPacketSending(PacketEvent event) {
// Item packets (id: 0x29)
if (event.getPacketType() ==
PacketType.Play.Server.NAMED_SOUND_EFFECT) {
event.setCancelled(true);
}
}
};
Me, breaking every unit test I have by restructuring my entire codebase ):
yeah
i write unit tests because my pc cant handle a minecraft + minecraft + intellij idea opened at the same time.
and then there's the "I want to extract a class" 
Solution: buy a better computer
Such an easy and reliable solution
Great. Here are all of the available packet types. https://github.com/dmulloy2/ProtocolLib/blob/master/src/main/java/com/comphenix/protocol/PacketType.java
I would recommend browsing through them first to see if any catch your eye. Particularly, this section should help you https://github.com/dmulloy2/ProtocolLib/blob/master/src/main/java/com/comphenix/protocol/PacketType.java#L103
Me when I want to extract a class
Real vim hours
NAMED_SOUND_EFFECT
lol
Alright, any other than that which you think might trigger a sound?
Probably. Give it a shot!
Correct. It is very easy, and very reliable.
I have never paid for something and not received it.
the reliability is probably not the issue
Simple solution: make or have money
simple
poor = !poor
Very. Are you of legal working age in your area?
no
any1 know what the boolean in the ClientboundSetEntityDataPacket constructor is?
Simple! Wait until you're of legal working age in your area.
new problem how do i make this bat @echo off IF NOT EXIST BuildTools ( mkdir BuildTools ) cd BuildTools curl -z BuildTools.jar -o BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar set /p Input=Enter the version: || set Input=latest java -jar BuildTools.jar --rev %Input% --remapped pause not use java 16 and use 17 instead, bc i dont even have 16 on my pc as a file and dont know why its still using it
Send the class file
Unit tests is a good practice right
wat
hmm to a certain extent, the reasoning behind writing tests is not invalid
Point at a specific java executable file instead of using the one in the PATH variable
if it wasnt obfuscated i wouldnt have asked and looked myself
however practices like tdd is imo going in the wrong direction
I specialize in deobfuscating code
Send the class file for the packet you're unsure about
so im assuming i woyuld use this line "C:\Program Files\Java\jdk-17.0.1\bin\java" -jar BuildTools.jar --rev 1.18... BUUUUTTT i wanna use the buildtools bat i have so where in that bat would i put that line to make it reference that
???
Don't you:
java -jar BuildTools.jar --rev %Input% --remapped
yeah but i need to point to the java jar somewhere in there right?
to run java 17
like u said
Wait, hold on, I think I'm missing something here
Are you saying that you don't have Java installed on your PC, and because of this you are not able to run the java executable file?
pretty kucvh i have jdk 17 installed, and dont have jdk 16. but for some reason running that bat uses JDK 16
You replace ‘java’ with the java install path
Wait what? Isn't that what you already said? xd
"C:\Program Files\Java\jdk-17.0.1\bin\java" -jar BuildTools.jar --rev 1.18...
You're vibing lmao
now we just wait and see if this actually fixes the original problem
which is this
When are you getting this error?
How can I check a specific inventory slot for an item?
i've probably found one of the strangest bugs ever
i have a custom enchant that plays a lightning bolt packet
People say this before showing code with errors in it lol
and when i swap to peaceful and back to normal the packet (which is just sent to the clients) puts fire in the world
this is the code
sec
Location loc = wrapper.getVictim().getLocation();
wrapper.addPureDamage(level * 0.2);
Utils.playSound(Sound.AMBIENCE_THUNDER, 1, 1, wrapper.getAttacker(), wrapper.getVictim());
PacketUtils.playPacket(new PacketPlayOutSpawnEntityWeather(
new EntityLightning(
((CraftWorld) loc.getWorld()).getHandle(),
loc.getX(),
loc.getY(),
loc.getZ(),
false,
false
)), wrapper.getAttacker(), wrapper.getVictim());
(1.8)
Why a packet
Did strikeLightningEffect not exist in old.old
Go into the EntityLightning constructor you're calling
I can't find it
Let me guess, it actually spawns the lightning bolt into the world? xd
That's gaming!
something i didn't know about minecraft i guess lol
I’ll take that as a no
Dangit 1.8
World
lemme check
oh yea its a thing
hm
something i didn't know +1
i've tried googling about it and the only answer i've found was about packets
not like it makes any differences for me as it's a private plugin that won't run on modern versions
have a listener and if it is a certain inventory, pass it on to another class to manage the logic
yes, put it as a paramter for the constructor or whatever
i have a wrapper that wraps attack events
i'll send the class
Well I only need it to handle the logic I don't really needed inside the class so I don't want to put it in the constructor
um it's a bit big
It is not very important
wait why on the constructor if the event can change its data?
yeah anyways you can pass it as any object
I did but for some reason it won't work.
Is putting the annotation necessary for the method I'm passing it on to?
No
@EventHandler
public void onEvent(InventoryClickEvent event){
manageEvent(event);
}
private void manageEvent(InventoryClickEvent event){
event.setCancelled(true);
}
To send it I listened on the actual listener class and then sent it to another class if it is a certain title but for some reason, it won't work.
Something similar to that but it won't work.
@EventHandler
public void onClick(InventoryClickEvent event){
if(event.getView().getTitle().startsWith( Resources.colorMessage("&8Edit member &e≫"))){
getMemberGUI().applyLogic(event);
}
}```
And does your if statement pass
Try it
how do i define a list w/o it throwing 15 errs and warnings at me
Yes, the event is cancelled in that same method but I removed it just now, but yes the event is cancelled so when I click it cancels. I am not sure it is passing the logic part tho.
oke
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
Yes the listener is registered and running just not passing it right for some reason
how can I check if a player is in liquid such as water, lava etc...
it doesn't, just checked the nms class
Check the block's type maybe?
Probably the best way
you need to call t_() that handles logic and also sound
I think either block or material has an isLiquid
also i love that they have 3 methods that are completely empty
with no implementations anywhere
lol
also yea apparently lightning can only leave fire if the difficulty is above easy
ah yes
thank you terminal for giving such a useful error report
[19:05:03] [Server thread/INFO]: [pvpPlugin] Enabling pvpPlugin v1.0
[19:05:03] [Server thread/ERROR]: Error occurred while enabling pvpPlugin v1.0 (Is it up to date?)
java.lang.ArrayIndexOutOfBoundsException: null
[19:05:03] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
i really dont wanna have to test every place that im using an array or List but it seems i might have to
Well
It’s during bootstrap
So that should narrow down where the error origins from a significant amount
i mean i guess?
It’s also strange no stacktrace is printed unless someone just decided to print out the error message of the exception instance
Or sth
theres so many things i initialize at startup that its like saying "instead of looking in the entire ocean, its somewhere in the mariana trench"
Wat
im not printing any errors currently
Anyone know how to grab the base64 string off of a Player Head item?
I have no issues using the PersistentDataStorage on the Tilestate when it's a block, but I'm having an issue that prevents me from getting that tilestate data before it becomes an item.
Vhoyd since you seem to be a lot more knowledgeable than me I can rest assure you that you’ll figure it out yourself
lol
even if i did have knowledge i definitely dont have the wisdom
what even is knowledge
all i know is stackoverflow and ctrl c/v
A good starting point is to share the code, if you’re comfortable with that btw
Pretty sure you need to reflect the CraftSkullMeta instance
i mean i can do that but theres just so much inefficient code to dig through
i dont want to be the cause of anyone suddenly finding themselves vomiting
That’s their own fault then
I'll look into reflection. Thanks
Yeah well reflection should be trivial if you know your Java but I think google got some info on this, at least when I googled it tho that was some time ago
I've managed to avoid reflection for a long time until now 😅
Yeah well
It’s basically that you can do fun stuff with your java classes at runtime
lmfao nevermind
the first method i threw a try catch around for error printing was the method causing the issue
now i just have to figure out why
oh cool
the stacktrace was actually logged
it just wasnt printed for some reason
lets go figured it out
i pulled a stupid
changed how a custom inventoryholder was loading so it filled the empty inventory slots with glass panes on initialization but left in another line that did that again
the loop started with the inventory's firstEmpty() which naturally in the second time since it's full would be -1
i am pepega
about this
I figured it out by..
Testing a bunch of things
it appears that for some reason
It's not enough declaring it 1 time
obj.getScore("test-player").setScore(20);
num = obj.getScore("test-player").getScore();
console.sendMessage(String.valueOf(num)); //says 20
obj.getScore("test-player").setScore(55);
console.sendMessage(String.valueOf(num)); //20
obj.getScore("test-player").setScore(20);
console.sendMessage(String.valueOf(num)); //20
sendConsole("scoreboard players set test-player output 10");
console.sendMessage(String.valueOf(num)); //20
this, wont work.
obj.getScore("test-player").setScore(20);
num = obj.getScore("test-player").getScore();
console.sendMessage(String.valueOf(num)); //20
num = obj.getScore("test-player").getScore();
obj.getScore("test-player").setScore(55);
num = obj.getScore("test-player").getScore();
console.sendMessage(String.valueOf(num)); //55
num = obj.getScore("test-player").getScore();
obj.getScore("test-player").setScore(20);
num = obj.getScore("test-player").getScore();
console.sendMessage(String.valueOf(num)); //20
sendConsole("scoreboard players set test-player output 10");
num = obj.getScore("test-player").getScore();
console.sendMessage(String.valueOf(num)); // 10
this does
Any suggestion?
I'm thinking of doing a function
That can be called num() or something like that
And each time it's called it returns a new num
ig that could work
oh wait
I think i have to update the score not the num
let's test realquick
ok yeah it's the num
How can you get a players mc version?
Im trying to make a combat log, java @EventHandler public void onDamage(EntityDamageByEntityEvent e) { if (e.getDamager() instanceof Player && e.getEntity() instanceof Player) { Player p = (Player) e.getDamager(); Player killer = (Player) e.getEntity(); combatLog.put(p, dur); combatLog.put(killer, dur); p.sendMessage(ChatColor.GREEN + "You have been added to combat log."); killer.sendMessage(ChatColor.GREEN + "You have been added to combat log."); } } But whenever I hit someone, I never get the message you have been added to the combat log
wait what
it's not the fault of
the scoreboasrd
with
int num = (int) Math.floor(Math.random()*(50-1+1)+1);
it happens the same
Hello! Anyone know any good website for learning about syncronized methods?
how would i implement both listener and commandexecutor in the same class?
class X implements CommandExecutor, Listener{…}
ok nvm
Lol no worries
Great yet another un finished project due to a major unfixable problem
Time to put this one in the archives and start something new ig
Or fix your issue?
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("stats")){
if (sender instanceof Player){
Player p = (Player) sender);
int value = stats.get(p.getPlayer());
p.sendMessage(stats.get(value + " You got this many blocks"));
}
}
return false;
}```
Basically I want it to tell the player the Integer in the hashmap.
```java
HashMap<Player, Integer> stats = new HashMap<Player, Integer>();```
could anyone help?
That was an accident
That auto did that and just saw it right now
But yeah you probably want to do something like
sender.sendMessage(Integer.toString(map.get(player));
I don’t know how and apparently a ton of people don’t know either
turns an integer into a string oofergang
Can you link me to the original post
expression expected
not sure which one but it needs something and it aint telling me what
Of course an updated variant
Why I use gradle to import gson but it's not work
single letter variables are fine sometimes
plugins {
id 'java'
}
group 'org.example'
version 'Pre-Release'
repositories {
maven {
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
content {
includeGroup 'org.bukkit'
includeGroup 'org.spigotmc'
}
}
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url = 'https://oss.sonatype.org/content/repositories/central' }
mavenLocal()
}
dependencies {
compileOnly 'com.google.code.gson:gson:2.8.9'
compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc1.18-R0.1-SNAPSHOT'
}
could you elabrote why?
Because you defined it as such?
It’s not descriptive
Sure
oofergang depends on definition of wrong but the name p itself doesn’t tell a lot about where the variable comes from, what it’s intent is and so on
@ivory sleet
@ivory sleet could you help on this?
noted
rip Conclure
Usually you go by the principle:
The name of a variable should be proportional to the scope it’s contained in
I dont understand
?learnjava
Here are some links to get you started on learning Java:
- https://www.codecademy.com/learn/learn-java
- https://www.sololearn.com/learning/1068
- https://www.learnjavaonline.org/
- https://programmingbydoing.com/
- https://docs.oracle.com/javase/tutorial/java/index.html
The last one is the only official one, however some of those concepts assume that you already know a bit about programming.
stats.get(p)
"Player is the type"
btw
Oh
because p is your variable which contains the player object
Player is the class
not the variable itself
classes != variables
i shoulda known
Yasir
testing time!
plugins {
id 'java'
}
group 'org.example'
version 'Pre-Release'
repositories {
maven {
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
content {
includeGroup 'org.spigotmc'
}
}
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url = 'https://oss.sonatype.org/content/repositories/central' }
mavenLocal()
}
dependencies {
implementation 'com.google.code.gson:gson:2.8.9'
compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc: spigot:1.18-R0.1-SNAPSHOT'
}
instead of repasting your code just wait
You there
You need to add mavenCentral() as a repo
presume its cause maven central isnt listed
Well isn’t the real jar sufficient for that?
Doesn’t spigot already have gson
thought it did
Okay artificial
my fork pulls gson from minecraft yeah
I am convinced your project can be rescued if we use gradle @lethal oxide so if you’re willing to commit yourself to gradle then sure
Btw incognitostaff how’s server rolling
Delightful
gonna rebrand under a new name and finally upgrade to 1.18.1 or whatever latest is, and get a survival server up first
Ah noice
As for v1 of the core some stuff isnt it in, mostly just punishments and vanish stuff, but that will be in post release
Open source for core?
trust me you dont want this open source
Can I get a server UUID?
Because my plugin needs a database
make a uuid then
