#help-development
1 messages · Page 2198 of 1
oh wait ur just checking xz
yes i am an eggselent artist
i thought he was doing xyz
to not have bugs probably yes
one sec
y + 1?
how would u do this?
private void lightOnFireInRadius(Location origin, int radius) {
outer:
for (int x = (origin.getBlockX() - radius); x <= (origin.getBlockX() + radius); x++) {
for (int z = (origin.getBlockZ() - radius); z <= (origin.getBlockZ() + radius); z++) {
Location fire = new Location(origin.getWorld(), x, origin.getBlockY(), z);
int counter = 0;
while (fire.getBlock().getType() != Material.AIR) {
if (counter >= 5)
{
continue outer;
}
fire.add(0, 1, 0);
counter++;
}
fire.getBlock().setType(Material.FIRE);
}
}
}
ig something like this
Thx man, I'll try it out
or do you see any big flaws in this @humble tulip
though if it will work correctly with a nested loop like this
@limber owl I'd actually run that Async, not sync
wait i think u should label the z loop outer?
not the x loop
thats what i was thinking too yea
i was scrolling thru tiktok and was like WAIT, which loop did he continue
came back to check
@quaint mantle i think you need to move the outer: tag to the z loop instead of the x loop
tiktok
instagram better
^
Done, although I tested it and it works great. So thank you. Would my first code work better for cages? Like to create an empty box to trap players?
The one I made first
uhh no. your code would create a solid cube
could you send that again then im confused which one
int r = 5;
for(int x = (r * -1); x <= r; x++) {
for(int y = (r * -1); y <= r; y++) {
for(int z = (r * -1); z <= r; z++) {
Location b = new Location(o.getWorld(), o.getBlockX() + x, o.getBlockY() + y, o.getBlockZ() + z);
if(b.distance(o) > r)
continue; // Outside radius
if(b.distance((o)) < r - 1)
continue; // Inside radius - 1
b.getBlock().setType(Material.GLASS);
}
}
}```
This one?
Like a sphere?
oh you want a sphere?
Yes, so players can trap other players with it
Would it be better to use FAWE api for this?
pretty likely
anyway
there methods are designed to return me a list of the blocks. but you can easily modify them to just place the blocks
@lost matrix send your process load tick-spread thingy
.
haha
?workload
u should add a cmd for that
he loves you too 🙂
?workdistro
nice
Thank you, I'll test it and let u know if everything works
Alright
How do I find any new 1.19 docs for NMS?
Is this the right way to retrieve the UUID saved as string in a PDC ?
if(playerHead.getItemStack().getItemMeta().getPersistentDataContainer().has(plugin.key)) {
UUID uuid = UUID.fromString(playerHead.getItemStack().getItemMeta().getPersistentDataContainer().get(plugin.key, PersistentDataType.STRING));
}```
Yh
thx
Np
can't run that task as it's deprecated and throws error
i'm having a weird issue, i'm creating a new world and then teleporting players but for some reason some chunks don't appear
all of those are deprecated. I just used your code as a base. As thats what you picked
what error?
U need to tp them after world is loaded
i've put a scheduler for 5 ticks but the issue didnt go away
?paste
the console said the gen took 29ms
yea its prolly taking longer to load the world
it's a void world
still..
.
its not very good to just guess 5 ticks either
um, chunks not appearing in a void world?
Lol
i'm placing structures and only a part appears to the client
pov from an account i relogged with
ok, that makes more sense 🙂
this is the other one
is cafebabe made in jda?
there's a chunk boundary there as u can see
What if u reload the chunk clientside?
tried that, did nothing
i had to relog
if i step in the missing chunk the player fluctuates, kinda lagging back
yup
Send chunk packet to players that u tp on load maybe?
that sounds like a sloppy way to fix it and also even if I relog and then place new structures, a part of them is still missing
u could also gen -> listen to WorldLoadEvent -> tp
Probably cleanest soln
i missed a part at the end but the delay is 5 ticks
declaration: package: org.bukkit.event.world, class: WorldLoadEvent
Keep spawn in memory pls
i thought of that but i was not sure if worldloadevent was called when the world was done generating
as u can see this gets called when a world is loaded
Since ur already putting stuff at 0,0
aight
And maybe load the chunks before u tp the players
i might try moving the structure from 0, 0 too because chunks near it are weird
there's a 1 wide chunk slice or something
@eternal oxide a s**t ton of errors just showed up
i'll try if keeping spawn in memory helps
oh yea that seems to help
lemme do some more generations
Ask epic said tho best way is to probably listen to worldloadevent
no
World loading is done sync and even blocks the main thread with some IO operations.
so there's no need to listen for the event since the main thread is blocked
I just joined so i have no idea what this is about XD

im creating a world and immediately teleporting players and someone suggested to teleport players when worldloadevent is called for that world so i am sure the world's done generating
Sorry I made a mistake https://paste.md-5.net/abecujevel.java
The problem is not the world but the actual chunk the player is teleported to.
If you fetch the chunk first then you can safely teleport the player.
In paper you can even do something like this:
fun safeTeleport(player: Player, location: Location) {
location.world.getChunkAtAsync(location).thenAccept { player.teleport(location) }
}
Means you request the chunk async and when its loaded you teleport the player.
In Spigot you would do the same thing just blocking or by using a CF fed by the BukkitScheduler.
oh yea i was looking for something like this but i'm not noticing any issues rn as i'm teleporting the player in the spawn chunks that are always loaded
Blocking:
fun safeTeleport(player: Player, location: Location) {
location.chunk
player.teleport(location)
}
Ah ok. But keeping the spawn chunks loaded for new worlds will result in a couple of hundred milliseconds extra when the world is loaded.
So i hope you dont load worlds often.
i have noticed the increase in time and that kinda bothers me
i think i'll try doing this
thanks
kotlin's such a funny language
i have both spigot and paper's api maven imports but the getchunkatasync doesn't pop up for me
what is this sound? https://www.youtube.com/watch?v=wAxM_vvR2Jo
For more sound effects check out the other videos.
Link: https://bit.ly/3uJb08l
"Internal Exception: io.netty.handler.codec.DecoderException: java.lang.IndexOutOfBoundsException: readerIndex(10) + length(1) exceeds writerIndex(10): PooledUnsafeDirectByteBuf(ridx: 10, widx: 10, cap: 10)"
amongst Sound.[sound_name]
any solution?
are you sending some weird packets?
try Sound.ENTITY_EXPERIENCE_ORB_PICKUP
i'll try
I'm trying to get into my spigot 1.19 server and I'm getting this error
hey guys, how can I detect if the player pressed the space bar? they will be midair so it can't be the normal jump event. I'm trying to make a multiple jumps plugin
you could use PlayerToggleFlightEvent which is called when the player double clicks spacebar
I can't use PlayerToggleFlightEvent because that requires two space bar hits
yep that's it ty
np
you can use java @EventHandler public void onMove(PlayerMoveEvent event){ if(event.getFrom().getY()<event.getTo().getY()){ //Some } }
you could track the players location, and on player movement event if the Y coordinate goes up there u go
do you have any idea if the normal player jump event is only toggled when the player is grounded?
yeah but they could be climbing a mountain for example
pretty sure it is yea
multipe jumps plugin
hm?
not trying to be this guy since i avoid using paper
and stay with spigot
but
if u really need it
paper has this event
for quite some time now as it seems
put them in flight mode and listen for flight toggle
but would that event be called if the player wasn't grounded?
that's the problem, I still don't want fly hacks in my server lol
when they toggle flight mode, make them not fly anymore and do what you need to do
if flight was enabled on the server
then pretty much any shitty fly hack would work
I haven't started developing an anti-cheat but I figure that would make it harder
ive literally just given you the answer
bukkit and thus spigot has no native jump event support
paper does
that event is only called if you jump from the ground
not if you press the spacebar midair
^
i dont think thats possible though
only othert thing that comes to my mind is putting something like a boat exactly under the player so they can jump off that
well to be fair keystroke detection is super anoying but also
even IF
you acomplish this
keep in mind that movement is happening async
but the event would be sync
means that the response time for the second jump would be much higher than the vanilla first jump
yeah I should probably just stick to using double spacebar strokes
ur double jump movement delay will be bound to ping
that all doesnt matter tho because the client will not send a packet if its not grounded
so you cant detect it
hmmmm yeah, maybe space bar is the most intuitive but maybe I can use a totally different event
i also feel like double clicking spacebar is the best way for this
but wouldn't that disable creative flight and essiantials /fly ?
its how every other double jump plugin does it as far as i have seen
tbh i would prob avoid doing those things alltogether
well double jumps are kinda useless when they are already flying
so just check for that
No just add checks
If creative return
yeah I hear ya
just dont get disappointed when ur double jump wont work
does anyone know how textures for skulls work?
on a live server that isnt on ur local machine
easy
why wouldn't it work?
depends for what version
i mean, i apply the texture
just gotta be careful since it can be used to bypass anticheats and such
but like
its being drawn from the hashed version of the players skin
it's a link
one sec
public static void applyTexture(SkullMeta skullMeta, String url) {
GameProfile profile = new GameProfile(UUID.randomUUID(), null);
byte[] encodedData = Base64.getEncoder().encode(String.format("{textures:{SKIN:{url:\"%s\"}}}", url).getBytes());
profile.getProperties().put("textures", new Property("textures", new String(encodedData)));
try {
profileField.set(skullMeta, profile);
} catch (IllegalAccessException ex) {
ex.printStackTrace();
}
}
this is my method
why tf does it work
does it need to make a request to get the texture?
or is the texture data in the url itself?
not hashed lol
just encoded
so the data is encoded in the url?
because like ive said before, movement happens client sided usually. however with ur double tap the 2nd jump will be issued by the server causing a delay as big as your ping. 30ms might not sound much but ur vanilla jumps response time i less than 1ms. so compare a <= 1ms response time to >=30ms
so i should set the texture async?
Guys what is PublicProfileKey?
maybe
How do I initialise it?
it already does it async though i believe
are you sure that format is correct tho?
it works
since it’s done by the client
ohh
well I can't really "pre-jump" lol so I have to deal with that
so the server tells the client what the texture is and the client loads it
What does spigot do with empty slots when you use the Inventory#getContents() or Inventory#getStorageContents()
thats why ive said its inheritly flawed and i wouldnt bother with this
imagine some guy having 150ms
what?
just change the players velocity
even that is server sided
no but its inconsistent based on ping
which is still inline with what ive previously stated
well yeah, you might be flying for a couple milliseconds on the client if you’re laggy but other than that it works alright
I mean I can't really do much, I need the jumps for the minigame, the 150 ms ping guy should just time them right
it’s really not noticeable usually
lol wat
how can u tell a player to time their jumps right
ive played those minigames before and its terrible in performance. dont say i didnt warn u.
it's not a bug, just time ur jumps right
it's not a bug, it's not fixable
then it's a design flaw
it's a flaw that can't be worked around
bad ping is going to give a disadvantage, that’s just a general rule
yea my plugins never contain bugs either, they are eastereggs
no front but this is what happens if someone only reads 50% of the convo
xD
^
unless someone has REALLY bad ping it is not that noticeable
but its not supposed to make the async movement lagging
i have played on servers with this mechanic and i have pretty high ping, it’s never really been a problem
youre coupling a client sided async task to ping
@tall dragon yk acrobat kit from anni?
yes
ninja too
was messy to handle tho
how would you suggest fixing that? the only possible way would be to make a mod, because double jumping is not a mechanic in minecraft
still the best way though i think
yeah
id suggest not to meddle with this i barely ever do but this is one of the cases which i actually wouldnt meddle with
?paste
i think having a mindset of "well since a couple of really laggy players might not be able to use this mechanic great, so i shouldnt add this feature" is a pretty bad one to have when making games
its actually not that bad in our codebase tbh https://paste.md-5.net/ehosesukoq.cs
you never, never bind movement to the server
@eternal oxide you can just do this:
if(Bukkit.unloadWorld(Bukkit.getWorld(worldName), true)) {
try {
FileUtils.deleteDirectory(worldFile);
} catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, e.getMessage());
if(plugin.getConfig().getBoolean("debug"))
e.printStackTrace();
}
}
The method ChatColor.of() for hex colors is deprecated in 1.18. What method should be used now?
what?...
the server checks for illegal movements and resets those actions
many many games on servers usually have some sort of mechanic that alters movement
im not sure what you're talking about
even just something like tnt or knockback is technically "bound to the server"
I know this sounds stupid but is there an event to get grounded players? :P
ahh i see, nice 😄
check if they are standing on a block or if its air/null?
what event would trigger that ~check~
at all times
runnable
you could use playermoveevent
bukkit*
yeah they probably would be grounded if they are not moving
checks that go every tick are resource hungry tho
well no, just use the event and check if their localion -1y is a solid block
Spigot 1.19 (first build, don't know if there have been updates since) sends action bar messages to chat instead. Is this already known and/or where would be the correct place to report such issues?
Make sure you're up to date
Updates usually happen quite quickly after a new release
If you are up to date report it on the Jira
?jira
Building the jar with BuildTools is the only official way to get the Spigot jar
Yes, I mean for nms
Yeah you need BuildTools for NMS
well
Do u know whats the new method for using hex color codes is? ChatColor.of() is deprecated
Already in 1.18
heh is it
Isnt there a new method? But why deprecated?
It's not deprecated though?
Are you using Paper as a dependency by any chance
dont know what ive seen haha
Any ideas why I'm still getting this in the lore?
public ItemStack createGuiItem(int amount, Material mat, String displayName, String... lore) {
ItemStack itemStack = new ItemStack(mat, amount);
ItemMeta itemStackMeta = itemStack.getItemMeta();
itemStackMeta.getItemFlags().add(ItemFlag.HIDE_ATTRIBUTES);
itemStackMeta.getItemFlags().add(ItemFlag.HIDE_POTION_EFFECTS);
ArrayList<String> metaLore = new ArrayList<>();
metaLore.add("");
metaLore.addAll(Arrays.asList(lore));
itemStackMeta.setLore(metaLore);
itemStackMeta.setDisplayName(displayName);
itemStack.setItemMeta(itemStackMeta);
return itemStack;
}```
whats wrong here?
what's a nice sound for not enough money to play to the player?
low bass note
Villager_angry
like enderman hurt
k ty
probably but why does newInstance give error?
well for one getClass() is a method in Object
thats perfect ty
so probablydont use the same name
when are people going to use Arrays.asList or Collections.singletonList for their lore lol
cuz ur return type is calss
u have to return the class type
so if ur class is Projectile
fixed that ty
or extends projectile, make ur method return a projectile
but still not working
it doesn't extend it, it implements it
that too yea
same thing
durrr
nice but still error
no u understood minion wrong
ur still trying to return a class
while ur actually returning an instance of the class
you are trying to apply a method reference
trying to return an object one a place where it returns a class
and that methods throws exceptions
😣
whats wrong with aC.newInstance()
also use getConstructor.newInstance
why is it deprecated anyways?
iforgot
like this?
no wtf are u doing
getThisClass.getCOnstructor.newInstance
and return WilloProjectile
angry minion 
u also gotta try catch
a lot of exceptions there 🤐
getclass.new.getclass doesnt make sense
Class<? extends Projectile> proj = Arrow.class;
public default Arrow getArrow() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
return (Arrow)proj.getConstructor().newInstance();
}
example
and yes there's a ton of excetions
😐
it's because youre using reflection
throws Exception bruh
why are u even using reflection for this?
.
because i want to have everytime a new instance of the class i added to the enum, not the same one over and over again
with this ur class cant have a constuctor else there's gonna be an exception
it can. but it requires an empty one
yeah, i think if i want a different than null one i need to pass the arguments in the newInstance right?
https://i.imgur.com/TsKQd3d.png i am starting with NMS and the tutorial has this import, so i put 1.18.2 instead but maven doesn't like it, and i've tried reloading the maven thing to make it find it
why dont you tell us what ur trying to make with this @midnight shore we might have a better solution?
yes so u should really have a class that handles each one separately
well a lot of custom projectiles
did you run buildtools for 1.18.2?
and just yk new CustomWilloProjectile(args);
i thought the intellij minecraft development thing did that automatically for you
i was told it does
for example Fire Projectile has its own class and actually i think i will do a system for adding a sort of constructor using method concatenation
so like FireProjectile().setFirePower(15).setDamage(new WilloDamage(base:150, multiply:yes); and so on
bro if u wanna fire a specific projectile, just instantiate it, no need to use reflection
yes but i want a lot of them
different by themselves
sorry but i'm not of english origin
ye well better than using reflection
you know that is very close to exactly the same thing
Functions just take an input as well
can u use hikari for sqlite as well?
afaik yes
i saw u used for h2 so i assume its possible
pretty sure u can yes
just set jdbc url or driver class name
do yk how i can download apache commons io
all downloads i see online are zipped
it's for 1.8 support which doesnt have it
shade it into your maven thing?
nah dont wanna shade it since it'll increase file size
and it already exists in later versions
idk then
https://repo1.maven.org/maven2/commons-io/commons-io/2.11/commons-io-2.11.jar
think this is it
Does anyone know what happened to PacketPlayOutChat?
where can i find a list of all vanilla structure namespaced keys
iirc now known under its mojang mapping name
or all loaded structures idc
has anyone else expeirenced this weird bug that action bar messages gets send to the chat in 1.19?
public static void showActionBarMessage(Player player, String message) {
if(message!= null) {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(message));
}
}
this just sends a normal chat message
yep
fuck
pretty sure its been reported to jira
i always do new TextComponent(message)
is there a document with all the mappings lol
im too lazy to remap right now
thanks
we recommend screamingscandals iirc
how do i get a list of all loaded structures
wtf
fuck they changed the chat packet so much
yeah even action bar messages are broken in plain spigot
Is there a simple way of detecting when a player puts an item in their ender chest or do I have to check all the different click types and compute what they do ?
even if i do StructureManager.getStructure(StructureType.SOMESTRUCTURE.getKey()) it returns null
you have to check it yourself
annoying
why isn't there get from and get to in inventory click event 😭
feel free to PR it 😛
oh its just getStructures
pr ?
pull request
like "add it yourself and propose the changes into spigot"
i'd also love to see this happening
noone added it yet so it's not a thing right now
for some reason placing structures is giving me jigsaw blocks
🧪
or getStructures() is returning structures with jigsaw blocks
wtf is that
idk, paste it into some XML validator
stackoverflow says it's a problem with a curropted dependency
getStructues() gets the pieces of structures, how do i generate an entire structure
uh
oops
oops indeed
invalidate caches and restart worked
how do i know which versions of spigot has commons io
i saw that some dont
they all have commons as far as I can think back
but in 1.16 I think they updated it
does someone have the jira link for the "action bar messages get wrongly sent to normal chat" thing? I couldnt find it, maybe probably I am blind
nvm I found it
wtf does this mean
thanks but I already got it ❤️
for anyone doubting that i can delta time 2 block break events with greater accuracy than 50ms
ive set my anticheat to 5ms, and it just triggered
🤔
any idea if thats a bug?
apparently the affected blocks are fern
the accuracy is at 50ms because you only have 20 ticks per second
and 1000/20 is 50
iknow
still
my friend triggered my anticheat with breaking fern
which ive testfully primed
to delta time block break events to 5ms
and then trigger if the time difference is <= ms
it's easily possible to get 2 block break packets within one tick
for example if the player has a bad ping
yeah well packets are processed in a queue-like thing
It should be impossible as its single threaded TCP
What is the 1.19 version for the Spigot depandancy?
it's easily possible for the client to send two packets with a "distance" (ykwim) of one second but that they arrive at the same time on the server
1.19-R0.1-SNAPSHOT
tsym
Moved to #help-server
makes sense
can you modify the entities in a Structure without using NMS?
if not, how can I get an nbtcompound from an Entity?
Use one of the save methods
what about the opposite?
I doubt it
is there a load method?
It doesn;t matter if they arrive at teh same time. Impossible BTW as teh TCP pipe is a queue. Each packet is processed in order, one at a time.
Yeah
you ALWAYS need NMS to do NBT stuff anyway
Can't remember exactly what it is though
i'm aware of that :c
yes, that is true. but of course the "time of arrival" will then be less than the usual 50ms (as normally because of the 20 TPS limit)
i thought there was some way to set the entities of a structure without nms and incase you couldn't, i had already (kind of) figured out how to do it with nms and that involved nbt compounds
so if anyone ever decides to have a bad time by trying to code an anti cheat, you always have to take into account that packets may come in at "random" times
there's an EntityInfo list that holds all the entities and it is constructed with an nbtcompound, a vec3d and a blockposition
so time to do some digging
Kind of. However being TCP they are always passed in order. Missed packets are re-requested, and other packets are held until the correct order is received
yep. But from what I understood they simply checked "is the last packet older than 50ms ago?" and if no they triggered their anti cheat stuff. and obviously that's not gonna work reliably
Yep, not a good method
coding anti cheats is probably the most annoying kind of spigot plugins lol
I wouldn't waste my time on that
https://gyazo.com/e9d97ee2ae7517503bb0a2e8b2e00021 you guys think I could get this to work with vanilla recipes too?
i've found the method but it is not static so what am I supposed to do?
construct an entity object to call the method on it?
I believe so
oh there's a method in EntityTypes that returns an entity if you provide a world and the compound
get "what" to work?
IIRC there's a method that takes an ItemStack[] and returns the proper crafting result, if there's any
Way ahead of you there
Is there any way that I could make this work if one slot had more items than the other?
} else if ((slot0 != null && slot0.isSimilar(new ItemStack(Material.GOLD_INGOT, 1)))
&& (slot1 != null && slot1.isSimilar(new ItemStack(Material.SOUL_SAND, 1)))) {
int slot0Amount = slot0.getAmount();
int slot1Amount = slot1.getAmount();;
ItemStack output = soularium();
if (slot0Amount == slot1Amount) {
inventory.setRepairCost(6 * slot0Amount);
if (output.getAmount() > 1) output.setAmount(slot0Amount);
event.setResult(output);
}
}
I tried doing it before, but it ended up eating items
what is that supposed to do?
quick question, is it possible to allow sprinting while not having any saturation?
Basically be a recipe
isn't there Player#setSprinting(boolean) or sth? If that doesn'T work, then it'd probably require NMS or wouldnt work at all
gold + soul sand makes a custom item that's used in the crafting of an item for something that my plugin adds
why don't you just add a normal recipe instead of using the event?
Anvil recipes aren't a thing
hm
I don't think that you can do anything about it consuming the whole itemstack
you should either only allow using 1 item, or use a runnable and "give back" the remaining items one tick later or sth like that
hmm
Would probably just be less confusing to limit it to matching amounts until I figure out a way to fix it, then
yeah probably
Was Persistent Data Container introduced in 1.13 or 1.14?
1.14.1
alr
nah was just wondering if I could remove using nbt for 1.13
oh ok
but tbh
noone uses 1.13 anymore
just check bStats
do you actually have illegal entities at that position?
e.g. itemframes without a supporting block?
hm then I don't know too
will do, real quick is there a way to quickly add serialization support for 1.8 items to work with 1.18
vanilla items? like an itemstack that you have saved in a yaml file?
yea
should work fine. spigot should be able to load itemstacks from older versions just fine. or did you experience any problems with this?
anyone know how to check if an arrow was shot by a dispenser?
Projectile has a method "getShooter()" that returns a ProjectileSource
for example a red stained glass pane will turn into a normal white stained glass pane
oooh that's what you mean
I am afraid you'll have to deal with that yourself, since 1.13 changed all the material names
I'm aware why it's happening but is there a simple solution?
ik, but what would be the projectile source for a dispenser
is my real question
e.g. a red stained glass pane isn't just "GLASS_PANE" anymore but now indeed a "RED_STAINED_GLASS_PANE"
yea
You can use the XSeries library
I mean XMaterial and XBlock exist
^
do you know if xMaterials has correct serialization?
but not sure if those can handle parsing a ConfigurationSection that represents a block
I really don't know, I never used it
I only started doing MC plugins when 1.13 came out
I only need to store the materials not the full stack
ah
I suppose Ill experiment with that
yeah maybe you're lucky, i really don't know
how would you even set a red stained glass pane in code?
like the material would still be Stained_glass_pane
material data I'd assume
RED_STAINED_GLASS_PANE?
or are u using 1.8-1.12?
use setDurability
or u can use setData
is there an event that detects when a redstone lamp turns on?
For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.
I did 💀
If I use lists to store player data, will there be a memory leak?
and found nothing
If u don't remove it on leave
And maybe use maps
Map uuid, data
For quick lookups
POG md5 is my man, already fixed the "actionbar" issue
so has GameProfile been replaced by something in NMS
Nah idts
If I use .getDisplayName() on a default item, will I get the actual name?
Not sure
PlayerProfile
it's non-NMS and part of the API
and has been since 1.18.1
isn't that nullable?
Pretty sure the defult names are handled clientside by the language
but I need to extend ServerPlayer to create an NPC which requires a GameProfile?
If u wanna create a npc u still need to use nms gameprofile I'm pretty sure
Ok but my current issue is that the remapped jar doesn't have the GameProfile in it
<repository>
<id>minecraft-repo</id>
<url>https://libraries.minecraft.net/</url>
</repository>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.21</version>
<scope>provided</scope>
</dependency>
^^
oh its seperate now?
idk if u need that but i use it for skulls
idk
i use that to get gameprofile for skulls
I did not need the minecraft repo for that by the way
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>1.5.25</version>
<scope>provided</scope>
</dependency>
and this should be the most updated dependency
(this could be because I use paper)
How I can register a command like this one (in another class)
gross static access also don't name your main class Main. Anyways its really easy just instantiate the object of the listener class
u need plugin, command string, and commandexecutor
Why u passing the plugin when u have main.getInstance
I'm confusion
i didn't understood yet how to do it, but thanks for useful tips
Don't create a method like that to register listenerz
Or commands
Do it the regular way
anyway i want to do it, is there anyway?
hello static abuse
hello static abuse, i'm your dad
joch wassuuup
imajin and me are playing 1.19 survival, you should join too lol
you should never register commands in another class
i know, but i want to do it
registering commands (imho at least) should be always doe in your main class
then use yourInstance.getCommand("...").setExecutor(....)
its a util for easier use, like that example in screenshot
it does not have a getCommand for my instance
what type does "yourInstance" have?
if it's a JavaPlugin, then it definitely has that method
you definitely can use "getCommand" on that
yeah you declared getInstance to return "Plugin"
make it return "JavaPlugin" instead
can i change public static Plugin plugin; to public static JavaPlugin plugin; ? (line 11)
yes
Why are you using the generic JavaPlugin 🤔
they don'T know what they're doing
no
^
when you declare a method you always have to define WHAT it returns
and you set it to Plugin
but it should be JavaPlugin
wouldn't it be easier to just teach them Dependency Injection right away might as well considering its the best habit
I think it depends
if we'd just tell them to replace "Plugin" with "TheirMainClassName" they will never actually realize what it does or why it suddenly works now
no!
i got it
You say that it returns "Plugin"
but you should instead either return "JavaPlugin" or your main class
yeah you see? "Plugin" does not have any "getCommand" method, but "JavaPlugin" does. Ideally your "getInstance()" method shold also not return JavaPlugin but the actual class of your plugin
for example like this
public static MyPluginClass getInstance() { return instance; }
thanks, this is the reason my brain is not working right
someone who wants to get your instance will never want to get a generic JavaPlugin, they want to get the concrete class of your plugin
if they just wanted a generic javaplugin instance they'd just use Bukkit.getPluginManager.getPlugin(String)
so yeah make "getInstance()" return your main class' instance
e.g. like this
@DoNotRename
public static Drop2InventoryPlugin getInstance() {
return instance;
}
ow, so with this i do not need to create a JavaPlugin too
whut
no
you need to understand how classes and instances work
you can easily return your "MyPlugin" object by declaring a method that returns a "Plugin". But obviously your "MyPllugin" object has some additional methods that "Plugin" does not have. So you'd either have to cast the "Plugin" instance to "MyPlugin" or just directly declare that the method returns "MyPlugiN" instead of a generic "Plugin"
this is one of those things that are awesome in java but confusing to people who are new to java and come from other, not-so-strictly typed languages
when you declare a method to return a "Plugin" you can only use methods on that object that come from the "Plugin" class
So if you want people to be able to use any methods that are from a "lower" scope (JavaPlugin, or your concrete plugin instance), then you should tell everyone that "getInstance()" doesn't just return a plugin, but that it indeed does return a JavaPlugin. Or exactly your plugin. I hope you understand what I mean lol. If not feel free to ask again
go to bed
I can't
Can someone check this for me? I'm not sure if I'm still sane after working on this.
EntityDamageByEntityEvent damageEvent = (EntityDamageByEntityEvent) deadEntity.getLastDamageCause();
Player killer = (Player) damageEvent.getDamager();
PlayerInventory killerInventory = killer.getInventory();
if (!event.getDrops().isEmpty() && killerInventory.getItemInMainHand().containsEnchantment(TELEKINESIS)
&& (!plugin.getConfig().getBoolean("use-enchant-permissions")
|| killer.hasPermission("nce.enchant.telekinesis"))) {
Iterator<ItemStack> drops = event.getDrops().iterator();
while (drops.hasNext()) {
ItemStack nextItem = drops.next();
Map<Integer, ItemStack> addItems = killerInventory.addItem(nextItem);
if (!addItems.isEmpty() && !addItems.containsValue(nextItem)) drops.remove();
it's like 3 meters away
have you tried to just try&see whether it works?
No, I'd rather know if I made some stupid mistake before running it and spending another 30 mins trying to figure out what that is
hm that's stupid imho
you should test it yourself
and if something doesn't work, then feel free to ask again
I mean were not here to review your code and tell you wether it works or not. you should just try it yourself, and if something indeed doesn'T work, then feel free to tell us what exactly doesn't work and then someone will happily answer and try to help you
I'm trying to make sure I didn't do something semi-obviously wrong
it looks good to me on first glance
but noone's gonna spend more than 20 seconds into reviewing code that you haven't even tested yourself
you can probably understand that lol
I can
A glance is all was really asking for, basically if there's anything that clearly makes zero sense because half of my brain cells are fried
lol yeah I understand you. but anyway you should always just try your code before asking people "is this going to work", imho. sorry didnr mean to be rude or anything but it just makes no sense to ask for opinions if you could just try it yourself 😛
the order is like this:
- try it yourself
- if it fails, go to spigot discord
lol
If it fails google error first. Then ask when you've tried everything
Is there a way to get the type of arrow shot in EntityShootBowEvent
getConsumable()
np
balls

el huevo
What is Potion#fromItemStack() replaced by?
I guess I could do event.getItem().getType() == Material.SPLASH_POTION huh using PlayerInteractEvent
Also anyone know why my IntelliJ started randomly freezing every 10 minutes?
Never had this before, and my pc should be more than capable of running a project with 50 lines of code
ivalidate and restart
we def need a DI blog post
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
what happens if you use the Inventory#getItem() method and that slot of the inventory doesn't have anything
does it just return null?
check the javadocs
Okay, it didn't work
a joke for alex since bro has hella blog posts
still never figured out the glowing btw
partially
if it's annoted with NotNull then it will return an AIR itemstack. if not, it'll probably return null
wish I could help but I can't
if (!addItems.containsValue(nextItem)) drops.remove();
nah ur good
Do mob drops not drop if you modify them?
The javadocs simply state that the itemstack found in that slot is returned
Is this for me?
Vector forwards = Movement.getVector(player, Movement.Direction.FORWARDS);
final Location initialLocation = player.getLocation();
final boolean[] isCancelled = {false};
final World world = initialLocation.getWorld();
world.playSound(initialLocation, Sound.ITEM_CROSSBOW_SHOOT, 3f, 0.75f);
for (int i = 0; i < 15; i++) {
int finalI = i;
new BukkitRunnable() {
@Override
public void run() {
System.out.println("running");
if(isCancelled[0])
System.out.println("cancelling - " + finalI);
cancel();
Location loc = Movement.getLocation(initialLocation, forwards, finalI);
world.spawnParticle(Particle.BLOCK_CRACK, loc, 15, Material.CHAIN.createBlockData());
world.playSound(loc, Sound.BLOCK_CHAIN_BREAK, 2f, (float) (0.5 + (double) finalI /10));
System.out.println("played chain stuff");
for(Player entity : loc.getNearbyPlayers(1.5)){
System.out.println("checking players");
if(entity != player){
System.out.println("entity isn't player should be pushing now (" + entity + " ~ " + player + ")");
isCancelled[0] = true;
Movement.pushEntity(entity, Movement.fromLocations(entity.getLocation(), player.getLocation()), 1.5, true);
player.playSound(player.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 2f, 1f);
return;
}
}
System.out.println("checking block");
if(world.getBlockAt(loc).getType() != Material.AIR){
System.out.println("material isn't air let's go chief push the player");
isCancelled[0] = true;
Movement.pushEntity(player, Movement.fromLocations(player.getLocation(), loc), 1.5, false);
}
}
}.runTaskLater(this, 1 + i);
I'm not quite sure what this error means
The value it's getting is infinite
anyone know what the heck this is? Using LocaleLib.
for(Player entity : loc.getNearbyPlayers(1.5)){
System.out.println("checking players");
if(entity != player){
System.out.println("entity isn't player should be pushing now (" + entity + " ~ " + player + ")");
???
I don't get the confusion
There's no getNearbyPlayers in Location, for one
Is there an event for when an end crystal explodes
Oh fr
I'm looking at it right now
oh ok nws
am using paper so that's where the method is from
I have no idea how that's returning an infinite number
oh, wait
Is it a float trying to convert to a double?
other than EntityDeathEvent, what ways can a horse "disappear"? I'm keeping a cache of all horses on the server and I want to make sure I'm removing any horses that do not exist
@lethal coral
Could be that
should I cast to double
Yes
Numbers with decimals default to floats, I think
1.5D
getNearbyPlayers will only return player objects, not entities
I only want players
This is my first time here. Do you know if the spigot came out?
what
that's just what I named it
I suppose I should've used p
sir
Oh wait
that's what I want I just didn't name the variable well
@lethal coral other than Java converting it wrong, I'm not sure what it could be other than some weird thing with Paper's API
So if you want nearby players then just use the built in method? Not sure what your problem is
Will someone answer me? :((
Reply to it
I mean spigot is out
This is my first time here. Do you know if the spigot came out?
not sure what you mean by that
Do you mean the 1.19 version of the API?
If you mean 1.19? I don't think there are any stable builds
yes
I need a spigot core at 1.19
then use the snapshot
wait until it's updated
unless you want to use the snapshot
simple as that
use buildtools
or just use Paper if you're looking for the software
bump
I mean your hypothesis seems correct since it supers another method with a parameter named x1
still got the error though
bump
despawn I believe
Probably something incorrect happening here
Location loc = Movement.getLocation(initialLocation, forwards, finalI);
is there an event for that
EntityDespawnEvent?
oh
I wonder if EntityDeathEvent handles despawn, too
there's no despawn event for entities other than item entities as far as I can tell
You can listen to chunks being loaded and then store all the horses in the chunk
@ornate patio check here
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/EntityEvent.html
declaration: package: org.bukkit.event.entity, class: EntityEvent
well i need every horse, loaded or not
Just add it to a list when they load
yeah
i dont see anything for despawn event
Then it's probably not a thing
i think im just gonna have to like have a cron job every hour or something
You could track entity IDs and check them in a loop
to reset horse chache
nah I don't think so I haven't had problems with that method
Override horse spawning from the get-go 👀
also one more question, is it possible to use pathfinding features on NMS horses in unloaded chunks?
maybe NMS has a method for when the horse despawns?
i am using custom horses
Well if you are using custom horses that means you can interact with them already, no?
wdym interact with them
yeah I have a list of wrapper instaces for the NMS horse
I guess the only way they can disappear is entity death event
Where can I download a ready-made spigot kernel
spigot kernel lmfao
what the hell
?1.19
You can build 1.19 using BuildTools https://www.spigotmc.org/wiki/buildtools/
java -jar BuildTools.jar --rev 1.19
Is there an event that tracks when a respawn anchor explodes?
im still new to java, I have a method which creates an item in another class, how can i get that item in a different class?
how do i get verifyed
nvm
im just verifyed stupid ha ha ha
Look it up
Google is your best friend for simple shit