#help-development
1 messages · Page 1470 of 1
yes
Async tasks are off the main thread
but it's very shortly tho.
new Thread(() -> {
}).start();
I mean that is also off the main thread
exactly 😂
I read a post about it but it was made by md5 in 2013 if I'm not mistaken, so don't mind me much
Is there any difference in these 2 examples in terms of performance or whatever```java
class IPlayer{
final Core core;
public IPlayer(Core core){
this.core = core;
}
}
class IPlayer{
Core core;
public IPlayer(){
this.core = Core.getInstance();
}
}```
runTaskAsynchronously runs in the main thread or in parallel thread?
Top one is preferred
Not the main thread
parallel
it just creates another thread.
Actually it uses one of the worker threads I believe
but if you're going to use async tasks every 2 seconds, I would honestly recommend you use "ScheduledThreadPool".
I was gone for a while but back to async methods, if I have calculateRoom running async to the main thread, and I come across a chunk that I need to take a snapshot of, what is the correct way of doing this? I haven't done parallel computing before.
when vanilla minecraft does hit delay, does the hit delay apply to all damage? Like if one player hits you the tick after another source of damage, does that hit still register? Or does the 200ms delay apply to all sources of damage?
All damage iirc
chunk.getSnapshot
yes but how do I make my thread wait for the main thread
which data structure do I use for my map
and etc
?paste
Take a look at this method I use to fetch data sync into my Async https://paste.md-5.net/ivusocunaf.java
does Player.spigot().respawn() call PlayerRespawnEvent
i dont believe it is hard to tell me
How should I go about this? After toggling, the player can look around and all blocks that meet a condition of mine, will be marked with a particle. The troubling part is finding out where to place the particle for it to be both visible (so not inside the block) and facing the player, meaning it cant be on the other side of a wall, has to be on the side a player can see
Well do your research, in the Javadocs it doesnt say it DOES or DOES NOT Call it
@torn oyster its hard to believe anyone would know that off the top of their head
?Jd
package index
I see thank you. I was told to use a CompletableFuture, what is the difference in that and should I use it?
a completable future does the same as that does.
Not sure what you are asking
What is the NMS packet for setting inventory items of the player? I tried looking for PacketPlayOutInventory
PacketPlayOutSetItem iirc
thank you
PacketPlayOutSetSlot
Hey
So basically I'm just gonna not use it (events instead of nms packets!!)
UGH I know....... I know... I'm sorry!!!!!!!!!!!!!!!!!
It's just that I'm not using it is all
HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAH
@eternal oxide does this look right? It's sync chunkloading which NNYa will scream at me for so I'll use PaperLib once I get the basic version working
looks good. be sure you check for that null at the calling end
yup, nice ty
This is an example. Imagine the wool to be particles. The person on the outside (armorstand in blue) would see particles in the position of the blue wool, and the person on the inside (armorstand in red) would see particles in the position of the red wool.
then raytraceBlocks
raytrace from the player to the target door then target.getHitBlock().getLocation().add(target.getHitBlockFace().getDirection());
will give you the location in front of teh door
if you know where the blocks are then I suggest you only raytrace against that specific block's AABB (rather than world.raytraceBlocks()), otherwise you will have particles spawning in front of the wall which stands between you and the door
or, if you are only checking doors, get teh door facing and math to see which side is closer to teh player
So I have a block that the player placed, I need to spawn a wall depending on the direction of the player, how can I execute this, ElgarL
or if you only need 1m level of accuracy then no need for raycast
ideas are useful
use BlockFace
i.e. block pos + (player pos - block pos).normalised
but you need to know which face right
Well, yes, but the entity has getFacing
declaration: package: org.bukkit.entity, interface: Entity
oh so invert that
mhm
you can use the players direction to decide the walls geometry
yeah that sounds good too, not sure which is faster but unless you're doing it a lot it shouldnt matter
its not about faster here lol. Vectors are just going to be more of a pain in the ass
in general
cause we dont like maths here
Change my mind
Bukkit vectors are kinda sucky
it all depends if you only want north-south east- west walls
if you want the alwasy 90 degree to teh player you need the vector
is there any difference between ProxyServer.getInstance() vs plugin.getProxy() in bungee?
no
probably not
So your approach all depends on how you want your wall
No
yes ik that
never been on Hypixel
No clue what that walls are like
always N/S E/W ?
it's not a cube but trying to make it simpler
no
it depends on how you place the block
or which direction you're looking
and it will spawn right in front of you.
I could figure out where the blocks are by looping blocks in a certain radius- or even just doing a database query (since the condition is the block being present in one of the rows), though I've never used raytrace so I dont know where to go from there
is there a limit of how many things I can send using plugin message?
nop
but cancel the event on the bungeecord so the client can't see the messages you're sending between bungeecord and spigot
I can give you Projectile hit code that builds a wall and you can convert it to a block place
might be a good idea.
ok show me
Thanks for the help btw
?paste
I plan to exchange the messages directly between server and bungee, no player involved
the looping approach is fine as long as the radius is reasonable
exactly
I'd just do a db query since once I have the block I would need to query anyways
I'm gonna loop every tick and have a for loop in them for each player online
but yea most efficient way is keep track of blocks as they are placed/destroyed and store them for example per chunk, then just loop nearby chunks
or maybe I should create a repeating timer for each player and remove it on disconnect
ok
how do i not save a world onDisable?
worlds are saved periodically iirc
keeping track of block destruction is a pain in the ass so prob better to verify if they still exist whenever you want to do something with them (in your case, display particles)
i disabled autosave
all but Overworld you unload(false)
yeah I have an idea of this part, but I dont know how to ensure the particles are placed in the right direction
@Override
public void onDisable() {
// Plugin shutdown logic
Bukkit.unloadWorld("world_active", false);
(more random stuff here)
}```
I will always know the block's location and the player's location
but I need to ensure the particle is facing the player, and is still within 1 block of the block's location
just create an array list
when u don't know how to store, use something
Is there a method or something that allows you to get the slot-number of the given EquipmentSlot?
wdym?
So the inventory has numbers for slots in there
well.......
and there is also EquipmentSlot enum
hand = player.getInventory().getHeldItemSlot();
off_hand is another method in that category...
he's not talking about that
then idk
and Kaktusz wasn't talking about storing the blocks, he was saying that ensuring the block is still there is a pain since theres so many fucking ways a block can be destroyed
(which is just way too true)
I could somehow use that if I make a switch/case statement
I don't know how that makes keeping track of block destruction any easier
it's simple
if you want your list to be accurate you need to listen to about two dozen events
every block break event, add the block and the material to the list?
you just asked for something
but what is it for specifically btw?
nah I was bringing it up as part of an answer to someone else's question
if you're doing a minigame, might as well just copy the world and then delete it when's done.
he was answering my problem
🙂
Does anyone know why whenever i restart my server with mineresetlite all of the mines get deleted??
but the idea is it's easy to build up a map of blocks as they are placed but then listening for events which invalidate that hashmap is a lot harder
what's your problem?
@dense goblet I will always know the block's location and the player's location
but I need to ensure the particle is facing the player, and is still within 1 block of the block's location
so you have an accurate collection of all the doors right
@vestal dome
https://wiki.vg/images/1/13/Inventory-slots.png
static int getSlotNumber(PlayerInventory inventory, EquipmentSlot slot) {
switch (slot) {
case HAND: return inventory.getHeldItemSlot();
case OFF_HAND: return 45;
case HEAD: return 5;
case CHEST: return 6;
case LEGS: return 7;
case FEET: return 8;
default: throw new IllegalArgumentException();
}
}
why 8?
LMAO thats so ugly, but still should help you understand the issue I have
in that case you loop over this collection and either take the vector approach or the entity.getFacing approach
that is wrong..............
the latter will snap to the ordinals, the former will not
it's player.getEquipment().set....
well they could be in F5 mode, so the particle should be facing the player, not the player facing the particle necessarily
to get boots, chestplate, leggings and helmet
I think f5 is only client side
I was looking at https://wiki.vg/images/1/13/Inventory-slots.png
it is, so I wouldnt get the looking at locataion
well then that's... NMS based? hm
no
because that image is not accurate.
so for example, even if the player is looking away from the block
oh
the particle should still be facing the player, not the player facing the particle
crap alright
to the head use that
im looking for the 1.16 version
to the off hand I don't know
when talking about the armor, use "player.getEquipment();"
there's NO other way to get it except that, that I know at least.
not quite sure what you mean by that. If I press f5 and dont move my mouse, should the particle's position change or stay the same?
here, proxy = bungee and server = spigot, correct?JAVA // the receiver is a ProxiedPlayer when a server talks to the proxy if(event.getReceiver() instanceof ProxiedPlayer){ ProxiedPlayer receiver = (ProxiedPlayer) event.getReceiver(); // do things } // the receiver is a server when the proxy talks to a server if(event.getReceiver() instanceof Server){ Server receiver = (Server) event.getReceiver(); // do things }
oh wait I think i get you
seriously? I am pretty sure that you can get armor using inventory.getItem(<integer-index>)
so if you're looking 90deg away from the door, it should be the same as if you are looking right at the door from the same position right
I thought ALL slots had numbers???
U can't
fuck
Yes!
in that case you want to use:
particle position = block position + (player position - block position).normalised * 0.5
I'm pretty sure, even gonna check minecraft code.
you may want to also snap it to the ordinal directions
and it asks for a slot
I dont want it to snap since that'd be weird I think
but that code would make the particle half way between the block and the player, I'd rather it be right infront of the block, regardless of where the player is
right there......
yeah I forgot to normalise it
wait what does normalize do?
interesting 🤔
look at Wiki.vg/Protocol
I'll definitely try that out, thank you :)
the value you multiply by is how far from the original block the particles spawn
mess around with it until it looks right 🙂
and a general vector maths tip if you are new to it, the direction from A to B is B-A
is that NMS code?
y ask?
I did, but I don't know what to look for in order to set an armor slot for the player without it making the sound effect
you saw nothing
whenever I send a packet to entityequipm the wearer hears a sound
then
🤨
lmfao
honestly im very bad at practical math
whenever I have a problem like this, I try and apply it to a non-minecraft situation and ask in a more general programming discord. sometimes writing it out helps, but not really in this situation lol
what
I already said thank you
I'm very confused
yes
BUT, here is the thing
now first of all
I am using PacketPlayOutEntityEquipment to send to other players
however, when I send that to the player WEARING the armor, it makes a sound
show me the code.
SO
why are you using packets for this?
is there a way to check if a block is passable from a ChunkSnapshot
I tried sending SLOT packets instead
I have my reasons
then tell me them
ughhh
no
I would imagine that
alright first of all
my plugin allows players to customize any item held in any of the EquipmentSlots (including main hand and off hand)
there are different "modes"
one mode allows cycling armor with a custom RGB equation made by the player
another mode allows "static" items to be set
so for example, the player can make their DIAMOND sword look like a fancy GOLD sword to another player
now I am running this plugin on a VANILLA server, so I can't risk using events
after all, what if I miss an event?
for example:
this makes no sense entirely
ANYWAY
If the player configures their incredible sharpness-5 sword to look like an enderpearl to other players, and they accidentally right-click, it is gone
duh I can configure events,
you have a false sense
but the point is there is so many possible combinations and events I have to look out for
I know
the NMS isnt even for Vanilla
Spigot??
what i ment is
for christs sake
like your normal spigot server.
Then what the hell are you saying that you cant use events?
holy shit
ARE YOU FU***** KIDDING?
VANILLA in the sense that there are no globohomo plugins installed that give players 1000 diamonds raining with shit filling their chests like most PAY-TO-WIN servers
VANILLA in the sense that they have to go out into the forest with their axe and chop down trees to get logs instead of going to a portal and paying $100-egirl-bucks to get a chestful of logs through these VANILLA-INTERFERING-PLUGINS
NO-GLOBOHOMO is what i mean
of course it is private
he means that he cant use events
since it has to be different for other players
he has to use packets to make it look like a different item, when it really isnt
also itzdig fuck off, I can smell the reddit on you
and then you have to listen for incoming packets
but fuck you then
get blocked
becuase nobody waants to hear your excuses for being shit at math jackass
ME?
thanks
np
aye okay to chill this down I can send you the event handlers I use to stop things like these from happening
I know about those, but ur missing my point
am literally grade levels ahead and get A's but ok bud
my point is there are too many events I have to make handlers for to make sure shit doesnt break my server
its over, shut up
I didnt even read 5 words into your miserable message
yeah it sucks but you pretty much have to listen to all of them
thats what I do to allow for custom items
yes, that is why im doing packets
If items are only to look different then you want to use custom model data
you'll have no events to listen to then
but whenever I send the packet for entity equip, the WEARER hears this awful armor-equip sound
look, if you're going to be child-ish, just please stop
try to help
thanks.,
anyway, this set-slot packets arent working
Am i trolling you?
He literally said leather
and cycling color Jadss
The ??? game? What are you on
lmao
he might of said it, and I cannot disagree with you, but he made his idea clear after he explained it better.
if you don't care LEAVE
simple.
What the hell are you saying...
FUKKIT(TM), I am going to use FABRIC api
how immature can you guys even be
LMFAO
jesus
what the fuck is going on here
read up
yes i know
idc I'm leaving
but like, what
i dont even know..
I've lost countless braincells.
Hey
So basically I'm just gonna not take it (the vaccine!!)
UGH I know....... I know... I'm sorry!!!!!!!!!!!!!!!!!
It's just that I'm not taking it is all
HAHAHAHAHAHAHAHAHAHAHAHAHAHAHAH
the core issue is this gogrut kid
let me explain
just take your vaccine smh
hello there so after a game ends im trying to unload the world to then delete it. but for some reason the world that the player left does not get deleted. this is my stack trace. https://pastebin.com/Sdd5yCVX
the part of my code where im getting the error: `
public void GameEnd() throws IOException {
for (Player player : Bukkit.getOnlinePlayers()) {
plugin.runners.clear();
plugin.hunters.clear();
plugin.playermanager.clear();
plugin.playersInGame.clear();
plugin.playersLeftGame.clear();
player.getInventory().clear();
plugin.sendToServer(player, plugin.getConfig().getString("Settings.Hub"));
}
Bukkit.getServer().unloadWorld("ManHunt", false);
Bukkit.getServer().unloadWorld("ManHunt_nether", false);
Bukkit.getServer().unloadWorld("ManHunt_the_end", false);
FileUtils.deleteDirectory(new File("ManHunt"));
FileUtils.deleteDirectory(new File("ManHunt_nether"));
FileUtils.deleteDirectory(new File("ManHunt_the_end"));
Bukkit.createWorld(WorldCreator.name("ManHunt"));
Bukkit.createWorld(WorldCreator.name("ManHunt" + "_nether").environment(Environment.NETHER));
Bukkit.createWorld(WorldCreator.name("ManHunt" + "_the_end").environment(Environment.THE_END));
} //and i have already tried sleeping in between the unloadWorld and delete directory!
SO basically I am trying to send cycling globohomo colorful LEATHER armor to other players to make it appear that a player has colorful ARMOR.
I have been successful, for I have used the entity equip packet.
BUT
When i send that entity equip packet to the WEARER, it makes this awful sound on their client
so I dont know what to do
entity equip???
hold on lemme get the name
It's a packet
does that even handle players?
stand by
You are deleteing the directory before the world has finished unloading.
oh, i thought players had a separate one
so yeah, when I send PacketPlayOutEntityEquipment to the own player wearing the armor, it makes this awful sound
I mean yeah, equipping armor makes a sound
yeah but
you see
I am trying to make it cycle colors every tick
so it spams that sound
You can already do this by modifying the data of the leather armor itself
instead of requipping
like every tick
^
as mentioned above...
so there is an update packet for updating armor?
no
because otherwise I am not going to change the state of the real armor on the server
then don't send it?
yes BUT then it wont cycle the colors
well the player
sigh
yeah I might do that
that not work
nope, this didnt work
wont work for armor at least
isnt that stupid? Cause the player itself cannot see it's own leather armor cycling
and only others
so it doesnt look good at their perspective?
ikr
im so torn
- Hear the shitty equip sound
- Look at the shitty armor
which one which one AHHHHH
give me a second
cant have both
^
ok look
I will add a 3
- Hear shitty equip sound
- Look at shitty armor
- Fix both using API, but risk losing items or gaining items etc by fucking with my precious vanilla world data
How do you lose items or gain items...
then just dont add those plugins??????
this plugin allows players to have custom "modes" applied to their items
one mode allows armor to cycle colors
the other mode is called "static" modes which lets any item be disguised as another item
Ok?
im not done just wait
so if a player wants to disguise their DIAMOND sword as a FANCY GOLD SWORD, then yeah epic it works
BUT
what if the player is a retard and for some reason wants to disguise their sword as an ENDERPEARL?
and they accidentally right click??
then I have to create an event listener for THOSE situations
then you realize
there are SO MANY situations
where items can be lost
maybe gained too
ok im done
does that make sense
well, you know
you can use NMS in spigot
too...
and use a combination of that and api
I am
to solve your issue
explain
I mean cancelling item usage is just 1 event
not the point
You didn't know that you can use both NMS and api in your project?
want to look at my project?
and see what i mean
unless you want to prepare a list of ALL the conceivable possibilities...
I wont do it
I am though
I am using NMS packets
CraftItemStack.asNMScopy etcetera
yes it also uses spigot api
ok at this point im wasting time
or bukkit api
bye
you will never be a woman
anyway
I ..... lost braincells...
what can I say
Good news.............. I found what u needed.
Jadss, I still severly doubt you improved even though you stated that you did...
nah
nah chief
you're cap
not sure wtf is going on here.... just gonna say that: if both parties do not understand eachother, a third (independent) vision can be of use. Both parties should however try to understand eachother in the first place.
Is there a way for me to code a plugin so where if you get an achievement you get an item automatically?
Advancements already support that
let me state this. The first party was using a language that was not easily interpretible by other parties. For example, he always switched back and forth between, Spigot, Bukkit, Vanilla as if they were interchangeable terms.
and his actual goal was not what we intended it was
in other words, an xy problem
Is that a plugin already?
what command would it be?
aha... that.... ||im out||
Asking about your attempted solution rather than your actual problem
Yep
Actually they run functions
So the StackOverflow way
So you can just make a function with a single /give command
Im still confused sorry
Listen to the https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/event/player/PlayerAdvancementDoneEvent.html and give them an item when it is called
declaration: package: org.bukkit.event.player, class: PlayerAdvancementDoneEvent
no. we will shit on and teabag our enemies and send them to the chambers
Lets keep it civil.
that is civil
What’s with the sudden hostility
maarten I got banned by Cloudflare 😔
And casual transphobia for some reason
rip 😦 So you cannot continue the amazing chat we had? xD
you will never be a woman
No, so from now on if you use a singleton just make every function static
holy shit I cant wait for trump to seize power in august
he wont be as soft this time around
all redditors will be sent to death camps
We have lost the battle
@grand swan
JuSt MaKe EvErYtHiNg StAtIc
wE dOnT nEed An iNStaNcE
Actual reply btw
He replied that
For a manager we dont need an instance
No one:
Bad developers: public static, public static, public static, public static, private static
I tried supporting but static debates are soo... ugh
yes change my mind
like... they happen too often and always with the kind of people thatdoes not want to learn
static is pretty cash
If I'm making a method that doesn't need any internal variables, or modification of internal variables (aka literally code that I'm running), why can't it be static?
If I don't need multiple or something, why not?
Oh no I'm talking about complete manager classes
I think I said this before
but idiots remain idiots
and will continue to be
i have a 42 static class that is just for utils 🙂
I sleep as well as before I created it, if you ask
Utils should be static
^
exactly 🙂
I had like an amazing explanation
The methods should be, not the classes (Not sure if this is what you meant but you said static)
If there's no difference possible with this if I create a different instance of the same object, it can be static.
If you have 2 instances of the manager, you can have different sessions saved. That makes them in different states, and therefor it can't be static.
also, I have a question
should I use threadlocalrandom or create a new Random() every few ticks
like every time I want a random number
threadlocalrandom
^
ok
like as a variable?
Like ThreadLocalRandom.current() ?
Hello guys, could someone help me? I would like to know if there is a possibility to make an item that is not stackable become one.. For example: music disc
Pulse correct me if Im wrong but you don't have to recreate them every time afaik
How do i spawn a tipped arrow?
yeah
that's correct im pretty sure
that's why you should store them as a singleton
It does that itself
also not clicking that
ye
sketch af
Just a STATIC GOES BRRRRRRRRR
what is this?
ThreadLocalCurrent.current() might have some stuff inside
not sure
is this gonna earrape me?
gogurt you need to not use sketch links
i need to look at the source code
GOT YOUR IP, IT IS 192.168.1.69
lol
LMFAO
Noooo 😔
how do i do that?
So you're saying I should store ThreadLocalRandom.current() in a variable?
one second
No you can use that for the singleton pattern
let me check
So it's like
ThreadLocalRandom.current().nextInt(1000)
the method itself might have some overhead
Anyone know a plugin that works on 1.16+ for plants, fruit bushes etc?
but i need to check the source code
yeah it does
public static ThreadLocalRandom current() {
if (UNSAFE.getInt(Thread.currentThread(), PROBE) == 0)
localInit();
return instance;
}
Nobody answers, so I came here instead (That chat is kinda dead)
¯_(ツ)_/¯
how do i not save a world onDisable
you should store ThreadLocalRandom as a singleton itself
Pulse read that code again
it randomly decides to save sometimes
Check what it really does
¯_(ツ)_/¯
your's?
static final void localInit() {
int p = probeGenerator.addAndGet(PROBE_INCREMENT);
int probe = (p == 0) ? 1 : p; // skip 0
long seed = mix64(seeder.getAndAdd(SEEDER_INCREMENT));
Thread t = Thread.currentThread();
UNSAFE.putLong(t, SEED, seed);
UNSAFE.putInt(t, PROBE, probe);
}
that aint free
tho
hm true
Yeah
You could just call it in your onEnable()
Come on, it's barely a difference
Although I doubt even that takes up a lot of resources
It's like once
mhm
Well yeah
Tho, I think I heard an argument that someone stated that ThreadLocal variables should be singletons
not sure however, if ThreadLocal and ThreadLocalRandom have similar impl, I'd assume they should?
So the first request takes 228x more resources than the other requests
But
The other requests take 800 nanoseconds
which is literally nothing in a 50ms tick
So the first one takes 182400 ns = 0.182 ms
is what mojang said when they looked at the individually low overhead of streams
but yeah unless it's a hyper hot loop it isn't worth the effort to store threadlocal resources in a variable
the whole point of them is that they are specific to the currently executing thread, so whenever the thread may have swapped you should get a fresh one anyhow
I'm using Math.random() now
so I have a chunk snapshot and need to know if a block in it is solid or not. I can't acces the Block itself, only BlockData, BlockState and Material. I was thinking of using Material.isSolid() but I think that won't do exactly what I need. My requirements are:
Air - not solid
signs, flowers, etc - not solid
doors and such - solid
fluids - solid
pretty much whatever can be walked through as if it was air should be considered not solid, otherwise it should be solid. Is there a good way to go about this?
not really
ig you could precompute a material enumset using material.issolid as a baseline
and then customize it by adding doors and whatever else
My entity end crystals arent dealing explosion knockback and damage, but are braking blocks,
Code:
@EventHandler
public void onSnowballThrow(ProjectileHitEvent e){
if (e.getEntity() instanceof Snowball) {
Snowball projectile = (Snowball) e.getEntity();
Location loc = e.getEntity().getLocation();
loc.getWorld().spawnEntity(loc, EntityType.ENDER_CRYSTAL);
}
}``` (When you hit it it explodes but doesnt do damage and knockback)
blocks are destroyed though
i really dont want to have to spawn another explosion when they explode
is there any other plugin on the server?
I dont see how that code can alter anything
ikr
What server brand/ver? (exact)
well that prob doesnt help
1 word, dumb
?
it does not make sense.
wdym
i set spawn prot off too
on damage, if the player is going to die from anything, i set cancelled event and set them to adventure
thing is the ender crystal doesnt set to adventure meaning it doesnt run
wanna just ese my method?
yes please
@EventHandler
public void playerDamageEvent(EntityDamageEvent e) throws InterruptedException {
if (e.getEntity() instanceof Player) {
Player target = (Player) e.getEntity();
if(Arena.getPlayers().contains(target.getUniqueId()) && Arena.getState().equals(GameState.LIVE) && target.getHealth() - e.getFinalDamage() <= 0) {
e.setCancelled(true);
target.getLocation().getWorld().strikeLightningEffect(target.getLocation());
target.setGameMode(GameMode.SPECTATOR);
for (UUID uuid : Arena.getPlayers()) {
if (uuid != target.getUniqueId()) {
Game.gameEnd(Bukkit.getPlayer(uuid));
return;
}
}
Game.gameEnd(null);
}
}
}```
stupitdly strange
maybe the damage is just too much that it just doesn't do any stuff and just gets cancelled?
i mean its <= /shrug
Ik
but what if the damage
is too much the player gets all the health damage taken?
like 20 hp gone in 1 second
<=
o_o
if the playe rwill have 0 or less hp then it should trigger?
im guessing one of their other methods they use
rather then surrounding it in a try and catch
we dont talk abt it but i used thread.sleep before i know abt bukkit.runtasklater
you 100% do not want to use blocking methods in an event listener
then remove it?..
lmfao
tryna fix the explosion thing first
I didn't wanna say a word but maybe that's the problem ya know?
I'm having issues with command permission
how can you possibly have that tho?
"You do not have permission to execute this command"
i mean intellij ignores it so it doesnt rlly matter
it is still compiled with it no?
I do have OP and I'm added into LP group that has *
code?
plugin:yml: https://paste.helpch.at/cebefigawa.http
Commands class: https://paste.helpch.at/yawosebuhe.bash
but it's not that I cannot use my subcommands, I can't even use /queenswhitelist without any arguments
i like how one is a http fine format and another is a .bash
I don't get what is this?
what is this?
did you have any formatting issues bud?
(don't ask about the 129419028409142 tabs pls)
looks like kotlin
it's kotlin, but again, the code is running normally
also why so much fucking youtube tabs
well I don't know how to help you...
the command is registered, but the onCommand it's not even called
getCommand(....).setExecutor(...)?
where do you have that @smoky lance
// my "constructor"
init {
plugin.getCommand("queenswhitelist")!!.let { cmd ->
cmd.setExecutor(this)
cmd.tabCompleter = this
}
}```
kotlin
!! makes whats before it throw NPE instantly if it's null
too smart for u
hey I was wondering if there was a way to decompile an plugin (im still fairly new to java so sorry if this sounds kinda dumb). Someone gave me a plugin to learn from but he told me to decompile it myself and idk how.
Java Decompiler.
http://www.javadecompilers.com/ you're welcome
thx
nvm
yea i did but i wasnt sure it would also work for plugins so I wanted to kinda make sure here
btw the console can execute the command, only players cannot
yeah I don't know how to help...
is it possible to get a BoundingBox a player is looking at?
i have a list of all of the bounding boxes im looking for so i can also do it the other way around
is there a method for player to get the team they are in
nvm, there was a method for team called getEntryTeam
No no no, don’t look at decompiled code because it most likely is going to be shit
Compilers do some magic when they compile code which decompilers aren’t able to reverse
oooof
Hey, does anyone know how to display a certain number of seconds left as a properly formatted string?
For example, if I had 600 secondsLeft how would I turn it into a String containing 10:00?
I could do it manually, but I wanted to know if there was any better way to do it
DateTimeFormat ?
Or just this
int minutes = time / (60 * 1000);
int seconds = (time / 1000) % 60;
String str = String.format("%d:%02d", minutes, seconds);
If time is already in seconds ignore the 1000
alright, makes sense
Blatantly copied from https://stackoverflow.com/questions/12468226/formatting-seconds-and-minutes/12468375
What does %d:%02d" do?
things
%d gets replaced by the first integer in the arguments, %02d is the same for the next given integer but formatted to look correctly
i.e. format("%d:%02d", 1, 9) = "1:09" I believe
the : is copied directly, you can replace it by whatever string you want (as long as it doesnt interfere with the formatting) and it will be put in its respective place
e.g. "%d minutes, %02d seconds" would be "1 minutes, 09 seconds"
Can I make an itemstack with amount 4 if the item is not stackable?
or will I receive an error?
and if I receive an error, how do I bypass it?
You can
kthx
But it’s prone to unstacking randomly
can I do player.sendMessage from a different thread?
player.sendMessage
will that break if called from an async environment
no
ok ty
What is required to implement a custom entity? Not sure where to start, and I can't seem to find any recent examples/guides that give a good explanation
I mean I normally just override creaturespawnevent and spawn a new entity with the attributes I want
how does the firing of that event work? would I be able to handle the spawning of multiple different entities with one event handler, or do they need to be separate?
also, is the event fired for a location before vanilla spawning so the plugin has a chance to replace vanilla entity spawning? or does it work differently?
It’s fired when an entity spawns
is it before or after an entity is actually spawned
Just before
will cancelling the event without spawning anything myself cause vanilla entities not to spawn at all
Yes
I need help.....
?ask
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.
does anyone here know packets very well in 1.8.8
more specifically the PacketPlayInBlockPlace?
1.8 is not supported officially
sadly i don't know anything in packets lol
Pissed
lol
if (!(location.getWorld().getNearbyEntities(location, 1.0, 1.0, 1.0).size() >= maxIdleEntities)) {
does this return a list of entities
at that block
or no
if not, how do i make it check for entities only at that location
the block
just out of curiosity, are you calling the method again afterwards..?
getNearbyEntities
wdym
I mean if you are calling the method again afterwards
i call it once every secon
second
cuz its a generator
i dont want more than 4 items staying there at once
no I mean within the frame of that snippet of code you just shared
no its called once
I mean that will return all entities at that location within a radius of 1 block in all directions
yea
so it's actually a full 2x2x2
well i can't read your screen so
what
consider sharing more than just a single line of code and explain what exactly isn't working and what you're expecting your code to do and how it's actually behaving
new BukkitRunnable() {
@Override
public void run() {
taskId = this.getTaskId();
if (!(location.getWorld().getNearbyEntities(location, 1.0, 1.0, 1.0).size() >= maxIdleEntities)) {
Item i = location.getWorld().dropItem(location, drop);
i.setVelocity(new Vector(0.0, 0.0, 0.0));
}
}
}.runTaskTimer(CaptureTheClay.getInstance(), 0L, delay * 20);```
it doesnt stop dropping
even when it exceeds maxIdleEntities
uh print location, put the result of getNearbyEntities in a variable and print the result too
debugging is crucial
Store the entity UUIDs in a list and then check the size
Remove them once they are picked up
Hey, I'm trying to use this for a cooldown on a PlayerFishEvent:
private Map<String, Long> cooldown = new HashMap<String, Long>(); // Outside the PlayerFishEvent
if (e.getState() == PlayerFishEvent.State.REEL_IN || e.getState() == PlayerFishEvent.State.IN_GROUND) { // Line 81
if ((System.currentTimeMillis() - cooldown.get(player.getName())) / 1000 > 3) {
long timeleft = ((cooldown.get(player.getName())) - System.currentTimeMillis()) / 1000;
PraxisUtilities.sendMessage(player, "&cWoah! You must wait " + timeleft + "&cbefore doing that again.");
return;
} else {
cooldown.remove(player.getName());
}
cooldown.put(player.getName(), (System.currentTimeMillis() + (3 * 1000)));
}
```and I get this error:
https://paste.helpch.at/pujunivipi.sql, any ideas?
The first run cooldown.get will return null
Use getOrDefault, or null check the return
I cant access org.bukkit.TravelAgent. I am using craftbukkit 1.16.5
I used getOrDefault, and now it shows I have to wait in the negatives
Api-version 1.13
The server is being run on the latest build of paper mc
and the ide is eclipse
What version is org.bukkit.TravelAgent available in?
Well what default are you using
3000L
Is it an issue with the IDE
I doubt it since it stopped working in my server because of the error
The method of importing is Class.forName("org.bukkit.TravelAgent");
Use system.currentTimeMills
Well. I want to use it in the latest version
Then you can’t
They probably don’t use it
I looked at the source code and they do. I will send u a link
Now it just removes the cooldown and if you don't use the rod in 3 seconds it starts going in the negatives again
I haven’t really read your cooldown code in depth
But set the default to whatever would work for a default if they aren’t in the map
So uh
They don’t import it directly, so it likely just triggers the catch block every time
Copy what they did with the try catch
The catch will stop the plugin from shutting down if there is an error if I am correct but it wont somehow fix my problem. I need the use the functions inside of TravelAgent
Was confused, figured it out, thanks
Well it’s been removed
No idea what the replacement is
From what I’ve found I don’t think there is a simple replacement
I mean I tried there thing on my 1.16 server and it works. There has to be something that has happened
hello
anyone? 😄
What thing
Multiverse Nether Portals
I mean like I said, I assume it’s just triggering the catch block every time
So they probably removed some key things in the source code and decompilers are not efficient maybe
Probably
Ok I'll try and see whats up with the catch
@eternal oxide you were right, there isn't really a need to do async chunkloading. This is a large apartment block from a city map, its a good order of magnitude faster than what I expected 😄 https://imgur.com/kR962Py
How to change this? (I can edit spigot)
How to check if an item is enchanted?
p.sendMessage("+");
}
Get the item stack meta data and use ItemMeta#hasEnchants
Thank you!
try to modify the server ping packet
the response is in json format so it should be easy to modify
Hey I'm brand new to programming in the plugin. I've found that I learn best when I just do it. So I code now and now the question came to me: How do I get a player to get a random item every 30 seconds? Can anyone help me with this?
List<Material> itemMaterials = Stream.of(Material.values())
.filter(Material::isItem)
.collect(Collectors.toList())
ItemStack item = new ItemStack(itemMaterials.get(new Random().nextInt(itemMaterails.size())))```
Hello guys, could someone help me? I would like to know if the server can be lagged if I create an event in which every time someone changes the item of the main hand the player's gamemode is changed.
Probably not
thank you ❤️
https://cdn.discordapp.com/attachments/816996822627123204/848437667711549470/unknown.png can i stop getting this logs, or clear this logs?
hello guys, i have another question, i'm a beginner sorry haha, i'd like to change the player's gamemode when he takes an item in his main hand, but unfortunately he's only actually changing when i take the item out of my main hand
I don't know if it was clear, my English is not good
public void aoTrocar(PlayerItemHeldEvent event) {
Player p = event.getPlayer();
if(p.getInventory().getItemInMainHand().getType() == Material.PIG_SPAWN_EGG) {
p.setGameMode(GameMode.ADVENTURE);
}
}```
if(p.getInventory().getItemInMainHand().getType() == Material.PIG_SPAWN_EGG) { --> ItemStack item = p.getInventory().getItem(event.getNewSlot()); if(item != null && item.getType() == Material.PIG_SPAWN_EGG) {
I have a NMS Material, how can I convert it to bukkit's material?
thank youu ❤️ ❤️
The Honey block got Ponged.
CraftMagicNumbers has methods I think, but please avoid using nms
is there any specific reason why?
because its not the api and there's a good chance the api does what you want to do anyway
not in lower version, many methods missing.
and by lower version I mean legacy versions.
lol, legacy versions
I'm currently programming a kind of OneBlock. As known, there is only one block on the map and my question now is how I can regenerate the ender portal when the map is reset. so it should always appear in a different place
If you are okay with it not being random, you can generate it at 1000,1000 every time your plugin is loaded in
Oh your right
Also, you might wanna change the direction in which eyes of ender fly too
are you sure a plugin of this complexity is good starting out?
Uhh if you are just starting out, scratch the eye of ender part
xd
Just generate the 21 block portal every time plugin is loaded
You can always go back to fix that part later
im not gecko20
Heh
Hmm I should get verified too
` @EventHandler
public void aoTrocar(PlayerInteractEvent event) {
Player p = event.getPlayer();
if(p.getInventory().getItemInHand().getType() == Material.PIG_SPAWN_EGG) {
if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR){
p.setGameMode(GameMode.ADVENTURE);
}
}
}
}`
Try that, now instead of just holding it you need to right click with it
Is it possible to broadcast message to Bungeecord via Spigot plugin?
emm how do I create an ItemMeta
get itemmeta from item
new ItemMeta() has way too much things
why?
does the detail matter
No, but it might help me in the feature to avoid same thing as you
How can you set an enchantment by its name? Or a key!
if i want to override the onTabComplete() method for every command i have, do i need to make a different class for each command?
I don't understand how I can pass a string!
is it Enchantment.getByKey(String) ?
I need to store the value in the database, which is why I need a string!
oh
never mind then
Thank you!
does anyone know how the hive creates mini world borders for each island in their skywars mingame?
as seen here https://youtu.be/n07dXxdpLJI
BEDROCK Youtuber Tries Hive Skywars JAVA Edition!?!
HALLOOOO AND TODAY we are on the Hive JAVA Server! and see whats the difference between java and bedrock edition :3
SUBSCRIBE NOW FOR A FREE TACO RIGHT NOW!
https://www.youtube.com/channel/UCTFeYlwEIT_xL1XKR64SJBw
If You Want to go further and beyond and Buy Mr.Beans a Taco! (Channel Members...
Writes that it is outdated.
Deprecated?
they are most likely using packets
Yes, it says it's outdated.
thought they might have been. this api looks pretty sweet https://github.com/yannicklamprecht/WorldBorderAPI
might be exactly what I'm looking for
im getting invalid plugin.yml when i launch my server with my plugin, "Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml"