#help-development
1 messages · Page 1932 of 1
mhm
I never called them singletones though
i mean yeah the point of a singleton is that it should be immutable (so thread safe, constant, etc), and there is only a "single" instance in a program (hence the "single"ton)
are we talking about singleton or static singleton?
static singleton prolly
It doesn’t matter whether you call it something if that happens to be the appropriate name lol
yep
for example, if i want my child classes to access a protected variables from the parent class
is it fine?
Protected variables are fine yes
i mean i just think its tedious if i have to retype it
yeah i do that
I mean they are in the language for a reason
however im not always sure that implementation inheritance is good
we should favor composition to inheritance, but we do not rigorously avoid inheritance
(talking about impl inheritance obv)
im gonna get back into programming lol
had some life issues the past month, stuff is much better now cause friend and i are healing now
yeah pulse, you feelin better?
yeap
the story is complex, dates back to mid-december of last year
basically irl friend had depression and she said some toxic stuff to me
but i know its just her depression which is doing that
and now we are getting better
ah ye, well best of luck, I hope can thrive still :p
yep
Friends and love come first ofc, no doubt
she liked me at one point, and i still like her, and i know of a cool event happening next month so i might try to land a shot
XD
ah, that sucked
yep but as long as we are healing ya know
she knows it's her fault which is good
been through a lot of pain and stuff but i got other good friends and also playing piano helped me
sounds excellent, keep healing 💪
yep
Hmm today i will move to kotlin qnd code a plugin 100% following elegant object principles
lol
@blazing scarab still wanna play?
I just saw your message in general now
Sorry, cant, going to bed soon
ah no worries, well I hope you sleep well dreaming about perfect object orientation
u play sb?
used to
ahh
first month
ic
😆
I played with knattekalle, sirdeadly and onlyskelett
sb is very grindy
very hard for beginners
lol
i remember when i started
Yeah
🦀 🦀 🦀
this is an important concept in terms of multi-threading
if you support multiple threads but need to ensure that all threads have the same instance, singleton is one of the ways to ensure that
sounds like a design issue
reusability isn't a factor if the object isn't intended to be thrown away to begin with
This can be achieved without singletone
I am sure it could be, but singleton is by far the easiest
?paste
thx
https://paste.md-5.net/movoqevafa.nginx
i tried to create a mcreator project and this happened
might be an mcreator specific problem
I really couldn't tell you the issue here other then it involves some kind of reflection
what are the inventory sizes we can use in spigot api
I'm thinking maybe I give the player permenant-1 mining fatigue when they join then upon blockdamage event depending on what block it is I change the level of the effect on a mushroom block or remove the effect if its a normal block then reapply it I would have to test how well it works
9,18,27,36,45,54
Thread safe singletons can be hard to test and ensure they’re actually operating atomically
And then the special containers like hoppers and dispensers
That could work, would just be annoying for the player to have constant mining fatigue
It wouldn't be visible at all I dont believe i would change the effect textures and whatnot and once they hit a normal block its gone
Their hand will be slow all the time
Doesn't -1 solve that?
I'll have to see if that's still a thing I read up and people used it and it worked fine
You can
Pretty sure you just give a value above 128
And it’ll overflow to negative
Well 129 makes my hand disappear entirely so not sure thats gonna work lOL
And even if -1 does make it look normal, won't they still break the mushroom block instantly?
maybe, haven't done much in regards to testing singletons for this. However though in terms of ensuring the instance of class is the same regardless of what thread it is being accessed from though singleton will help with that.
No it would stop it entirely I believe
I'll have to test it real fast
true, conceptually its an easy way to address given problem
but I was also just giving an example where a singleton is useful
there are other reasons for using singletons
indeed
how can I make particles and potion effects(glowing in particular) appear for a specific player?
one of my favorite places for using singletons is management classes
like for files or for queue like systems where you have the one class that is responsible for doing things and you really don't want another instance of said class
because writing to a file from two different classes generally is a no-go 😛
I mean java is somewhat procedural
it can be object oriented if yoy want
nope it works perfectly
not sure if it will work on every version but it seems to do exactly what I want it to
yeah
well in reality, methods are just functions where their nullary argument is the invoker itself
Oh cool, I guess the vanilla command just blocks negative numbers.
yyeah, but we have such a cool thing called encapsulation
indeed
Objects encapsulates logic inside them, so we dont have to keep in mind it
which also sucks ass from time to time but yeah
what event is on right click with a specific item
PlayerInteractEvent
ty
?gson javadocs
?jd gson
Okay so I don't think ?gson is a command
and ?jddoesn't give you info on any ol' dependency
I think everyone has suggested that feature
But thanks for answering
Im dude
Same
Its Gson.fromJson(json, Object) right?
Im tryin to serialize and deserialize with Gson
fork paper then
Isnt bukkit died?
you probably lack the experience required to make a "better" server jar
if you say shit like "forking Bukkit"
Okay first of all
(paper)
Bukkit: The interfaces used to communicate between plugins and the server
CraftBukkit: An implementation of Bukkit that uses modified Mojang server code
Spigot: A continuation and fork of CraftBukkit
So essentially always Spigot or Paper :p
Forking Bukkit would be adding new API features and forking CraftBukkit is pointless
We should have a ?forks command or smthn
To explain Bukkit/CraftBukkit/Spigot
Yes
Actually fuck it gimme a sec
Well, if you care about performance, paper would be the best. It already has dozens of optimizations
I am trying to make a plugin that sends a custom join message customized for each person using UUID's and was wondering how I would set up the UUID part
Yeah
There's a couple of other interesting forks like Purpur as well
Yeah this is true too
Paper's API is a big improvement over Spigot/Bukkit's
?jd Gson.toJson()
I would never recommend developing plugins specifically for Paper unless you're working on internal server plugins.
Verano that doesnt work
I have the UUID but I don't know how to use it in the code
Why? Before it was working
I would recommend developing plufins for paper, especially when hangar will come out
I would never fork paper. Cuz no many plugins doesnt support it
I'd personally recommend developing plugins for multiple platforms :)
Lol every plugin coded for spigot works on paper
You can create multi-module projects in Maven or Gradle
For now
I have tried paper 1.8x with implementation of 1.7 and no many plugins works
So common, spigot, paper, etc.
To much shit
Problem is that for a few forks, you need to heavily abstract common
Thsts just annoying
Yeah
Especially with components
I don't 🤷♂️ I was listing it as an example
.
I mean I'm eventually planning on doing that for my own framework, Limestone
How would i serialize class with Gson.toJson() and Gson.fromJson()?
Note: This thing is not close to finished, check it out anyway: https://github.com/LimestoneMC
uhhh smthn like Gson#toJson(<OutputStream here>, MyClass.class)
Why ouputstream?
Because toJson serializes :p
Every packet class im creating its implementing my interface
What is your interface
It allow me to register the packets
But
When I run CompletableFuture.supplyAsync, does it coordinate with Bukkit scheduler somehow ?
My int its called Packet
No
What does it have to do with Gson
Im trying to serialize and deserialize class object for sending it and receiving it in redis
🤔
I think i was mixing you everything
Redis only allow you send and receiving strings
You can turn an object into a string with gson
Something like that?
That why im asking
Okay then uhhh
But i dont remember how it was
okay so it is literally
I know that Gson.toJson() - return json string
gson.toJson(myObj)
THANKS
Deserialization*
I was looking this for hours
yes
anyway
I don't know how you managed to miss it
?
I tried ?jd gson
and it shows you all the methods
But didnt work*
Oh really?
Yes
I feel like you should've picked up on that by the fact you tried it 3 different times and we told you multiple times it did not work that way
What would you recommend me
Im creating a packet system. With a listener where you listen to that packets
Google knows all
Not talking anymore about Gson
based on Redis
What would you recommend me?
Yeah @quaint mantle
Im making it based on Redis. Cuz i get tired of getting shity erros with sockets
How can I modify the players name tag when the scoreboard is already in use (Each player has his own scoreboard so teams won't work)?
Do I have to use packets or is there a simpler way?
What's the best way I could add cooldown to an event? I'm unfortunately still on 1.8 and want to implement something that already exists in 1.9 which is the hit delay, but only on a specific entity.
LocalTime.now? and then calculate the difference between every attempt
If difference is greater or equal to cooldown/delay then proceed with event
It seemed to caused some lag when I tried implementing it. I'll try using LocalTime.
I use currentTimeMills and a simple map
If each player has his own delay you can use key value pairs (hashmaps) with UUID as key and Localtime.now (or a class) for value
I actually tried using a map to store player uuids, added a check between values and just wrapped what I wanted to update in that event and it kind of worked but there was some lag so that was concerning.
Depends on where you put it and how often it was being used I guess. Mine is connected to a large class and gets called quite often. Doesn't seem to be laggy
Map lookups are quick
It was used in the EntityDamageByEntityEvent event, so whenever a player hit a mob.
*not every mob, only one specific
Yeah that should certainly not be causing lag
Oh well then, I guess I rollbacked that solution for no reason and didn't save the code so gonna have to rewrite it! Thank you.
how would i tell once the player has stopped mining a block
I use a runnable
There’s a packet
armanimation?
Someone PRed an event for it but I’m not sure it’s accepted yet
How can I make a itemstack (Lingering potion) which has a effect.
declaration: package: org.bukkit.event.block, class: BlockDamageAbortEvent
though I'm really not sure of the obsession with stopped mining a block
I really can't think of a proper use for it
hello md_5, I am a big fan of yours
Custom blocks with breaking speeds I imagine
wdym by runnable?
PotionMeta
yes
exactly what I needed it for
unclear why you need the abort event for that
there is already a damage event
Ooo, thanks do u think if I apply a effect to it, it will also change the color of the pot?
When I did it I used the damage event to start a runnable and the abort event to stop it
that's a silly approach
Since the damage event only fires at the start I need a runnable to keep damaging the block
just damage it more each time the event fires
no it fires each damage increment
Nope, Coll is right. It only fires when they start.
I just used the runnable to increment the damage each tick
I'm planning to make a pvp related plugin, but I'm not so sure on which version to go with. I'd like it to be compatible with 1.7/1.8 servers but also with newer versions. What's the best version to pick for backward and/or forward compatibility?
Gives precise control over how many ticks to break the block
Same, I added Mining Fatigue when they start and everything needs to stop when they abort! The event is useful :>
for example i have a runnable running every 2 ticks, that update the scoreboard for every online players
That what i was making refence
Ah I can't use the scoreboard cause the KitPvP plugin is hoarding it 😄
So you are doing your own scoreboard api or tags?
No longer need any NMS for custom block breaking, which is fun
Im confused now
Since each player has his own scoreboard and the scoreboard changes every kill/death I cannot use teams for name tag color changes
Was asking if there's some other way (if possible other than packets) to change name tags
Nametags?
I dont udnerstand that
Player name above the players head
press tab when the intellisense pops up for the classes you want to import
Ah that its different
You are trying to update player name tag
Not scoreboard so
You can modify the nametag with scoreboards
What plugin version should I go with to support 1.7 to latest version servers?
1.7
yikes
But it's fucking annoying
I've found 1.14 is a good version
Apparently 1.13 is unstable or smthn? At least that's what I've heard
well, it's a plugin for pvp
1.14's performance = shit
But yeah with older versions you lose out on stuff like PDC
so I'd like to support those versions as well
its possible to do a custom thread executor that allow me throws Exception? Cuz by default if i do:
new Thread(new ConnectionHandler()).start(); Say me that i need to try-catch and its fucking annoying doing try-catch everywhere
Don't support 1.7, just have server owners use ViaVersion like they already should be doing.
or whatever they called
If you go 1.13 or less support is hard to come by. I'm coding in 1.8 atm and it's hell
and 1.7 API will work fine with later versions?
fixed thread pool with 1 thread perhaps
Maybe
If you work on server backends like I was going to
Who knows, 1.7 was like 7 years ago
then pass an uncaught exception handler to the executor service verano
obv support is less to come by
It's fun because sometimes the owners are smart and use up-to-date versions w/ Paper
as it isn't officially supported
So you can get Paper API w/ 1.18 and be ✨ modern ✨
can i get an example pelase?
777 jackpot
declaration: module: java.base, package: java.util.concurrent, class: Executors
then you can pass a guava ThreadFactoryBuilder
Nah
But anywhere thanks i will try
That's just the version of the javadocs
Ah allright. So possible in every version i sopuse
Yeah
If there's no Since then it means it exists in all versions that class exists in
And java.util.concurrent has existed since Java 6 iirc

Not AutoCloseable, just Closeable
Yeah
I'm pretty sure there's no real difference but it's convention 🤷♂️
Allright i will need to implement it there? or in class which implement connection?
If I want a moving WorldBorder I need to use this right?
Yes
oki ty <3
make your interface extend Closeable
why not AutoCloseable, makes it useable in try-with-resource statements doesnt it?
Closeable extends AutoCloseable
oh
You're not technically supposed to use AutoCloseable
Allright thanks. I will use this interface on my Socket library
Thanks
thought it was the other way around lole
I think it's from a readability standpoint or smthn
But yeah it's like a backwards compat thing
With this and ThreadExecutor i can execute code in separate threads right?
you need to find the proper obfuscated name
it's going to be a or b or smthing like that
go into the class and try to find it
Or use mojmap
how to teleport entity in inverted player direction 100 block further?
Pulse and Coll have given you your options
look into the class
and tried to find the playerconnection variable
or use mappings
like Col said
If you are using Intellij just open class declaration
i cant explain it any simpler than that breh
control click it
double shift click
search PlayerConnection and check in all files and non project files
Isnt it player.getHandle().playerConnection__()__.sendPacket(packet); ?
?
playerConnection with ()?
its not a method...
for me it working with playerConnection()
If not use Protocol Lib
With protocol lib, you can send and receive packets really easy
that's not it.
final PlayerConnection conn = ((CraftPlayer) player).getHandle().b;
conn.a(packet);
The connection is just a public field in ServerPlayer. Depends on the mappings you are using.
i found it from my 1.18 code
that's not my issue
?...
update
Im so confused lmao
Me too
ServerGamePacketListenerImpl connection = ((CraftPlayer) player).getHandle().connection;
(If you use mojang mappings)
VERANO im confused as you injected yourself into the problem but it's not you that is having the problem
and for fase Pulse gave you the code above (for 1.18 that is)
Im even more confused with this
and yeah you should use mappings, i was just lazy :p
Check the 1.18 spigot post
?1.18
You can build 1.18.1 using BuildTools https://www.spigotmc.org/wiki/buildtools/
java -jar BuildTools.jar --rev 1.18.1
a lot of this you cannot just follow a simple tutorial to figure everything out
you have to put the time to read stuff
and search things
anyone recommend any tutorials for plugin dev in general?
everything im seeing is like
do you know Java?
made a year ago
i never watched tutorials
c++
yeah im looking over all that rn
syntax for basic stuff like loops and things are mostly the same
c++ and java r very similar syntax wise
ya
interfaces, abstract classes, etc
Once you know the basics it will be much easier to work with, and those tutorials from a year ago are prob fine, generally most that dont touch packets will still work even if they were made for 1.8
😭
lol
just no
i dont care
don't watch him
I found a good series earlier but im too lazy to pull it up
some youtube tutorials are decent, but not many
Havent heard of them before, i'll watch a quick minute of it and see
also, any of u guys run thru this? https://java-programming.mooc.fi/
Helsingin yliopiston kaikille avoin ja ilmainen ohjelmoinnin perusteet opettava verkkokurssi. Kurssilla perehdytään nykyaikaisen ohjelmoinnin perusideoihin sekä ohjelmoinnissa käytettävien työvälineiden lisäksi algoritmien laatimiseen. Kurssille osallistuminen ei vaadi ennakkotietoja ohjelmoinnista.
?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.
heard it was good for java
Good resources ^
So far this actually looks decent
Why are you shitting me? when im trying to help
What?
??
...
😉
yes?
Yes bob is good
Bob the builder?
bob? 💀
pulsebeat, what does clean code mean to you?
No soil on the code
no functions
everything in main function
no include files
just namespace std
No code
easy to understand + easy to change
Can’t have messy code with no code
Yes, you made another person's problem yours, for no apparent reason, when you arent even having the issue
o fair
if you can only choose one
But why where you shitting me?
easy to understand
easy to understand imo
cant have code if u dont
only true way to code
i use vim
good job
i compile my code by hand
I don’t
Does anyone know if exists an implementation of VIM with TabNine or gth Copilot?
I just write the machine code
LMAO
bro has cheese and peanut butter for breakfast
What the fuck does that mean
bro thats kinda gay bro
⏸️
god i wish
Wrong channel
Im the only one that think every girl is lesbian?
So idk sometimes i dude lot about girls
If every girl was a lesbian I would be less nervous about moving to 🏳️⚧️
⏸️
⏸️ bro
spigot discord is as depressingly garbage as always 👀
Yes let’s not continue this random discussion
merci 🙏
THIS IS A MINECRAFT SERVER FOR DEVELOPMENT
conclure to the rescue
?kick @grand flint stop already
Done. That felt good.
i never stopped typing so fast
I feel like I missed something
ayo?
A random question where should i mange the runnable interface? On my conenction class or another class?
Depends
I didn't know 🏳️⚧️ was a state
but generally you wanna separate concerns verano
its like the best one
all the cute girls come from it
Mmm I disagree, I don't think any states are that good.
I ask because im doing a socket implementation library
pa is the worst state
Ye I saw
I thought it was a country
And equality is about having no exceptions.
that too
I ask because i always have thread problems
its a country state
Learn multi threading wouldn’t hurt ya
I see
anyone wanna help me install intellij and make it look all pretty
This wouldnt cause thread lock right?
Sorry for tag
I mean wym by thread lock
Do you mean deadlock?
obv it’s gonna be blocking on the thread it’s called on
I know that when you send and read it block the thread until its finish
Pretty much
I mean to some extent, every method is blocking, however methods may opt in to submit their actual task onto another thread
how would I check if a player is typing a command?
like if a player types /a, does an event fire for that, and then /ab?
I mean the problem is when expensive tasks block the flow of the program
e.g. performing IO tasks on the render thread 😬
(that's what Minecraft does iirc)
does it?
I'm pretty sure Minecraft doesn't utilize threads so, yeah maybe?
You can maybe hook into the command completion event
Oh yikes
Minecraft is not optimized at all.
which?
Pretty sure nobody does that
TabCompleteEvent says it only works for arguments, not the main command name
Minecraft utilizes threads
Yeah just realised
Chat is a thread
This is evident from the like, 7+ Fabric mods for optimizations.
Worldgen is several worker threads
The client receives the command when he connects to the server... didnt think of that. Then there is no way.
is there really no event that accomplishes this?
i just need to send a user a message if they do /h or something
The server doesnt even know about that because the client never sends information about when a player types something.
the client does not constantly send what the user types
not rly
its unfortunate it only works for command names and not arguments
Arguments are looked up on the server
But the names are all cached client side on login
Why are you trying to do that?
I want to send the user a message whenever they do /h
Is there any short way to access spigot.yml thru api?
Bukkit#getServer#spigot#getConfig
Thanks
Hello I want to dev an API for the servers with Proxy -> Servers. Idk what's the best id: Centralize the servers's data on the proxy (Bungee Cord or maybe Flam Corde) or server manage her data and send it to database ?
If I wanted to make an item un-stackable, would it be practical to put a UUID.random() into the persistent data container of the item? or is there a better way to do it?
how can i make it so players can still break and place blocks even though there is an armorstand passenger?
ArmorStand as2 = (ArmorStand) e.getPlayer().getWorld().spawnEntity(e.getPlayer().getLocation(), EntityType.ARMOR_STAND);
as2.setVisible(false);
as2.setGravity(false);
as2.setCollidable(false);
as2.setCanPickupItems(false);
as.setVisible(false);
as.setCustomNameVisible(true);
as.setCustomName(ChatColor.translateAlternateColorCodes('&', "&7Rank &9" + e.getPlayer().getLevel()));
as.setGravity(false);
as.setCollidable(false);
as.setCanPickupItems(false);
as2.addPassenger(as);
e.getPlayer().addPassenger(as2);```
setting marker to true wont help me because i need to stack armorstands and setting marker to true makes them collapse into eachother since the hitbox is removed
you don't necessarily need it to be random, just having a custom lore is good enough
But it would have to be different lore each time
Thats usually my approach
And lore is visible
true but when it comes to crafting items id like to make it so people cant stack em
gotcha thanks
Be aware of bulk crafting. Handling that is a bit tricky.
yeah just prevent shift-clicking when crafting the item
:/ if u have an opinion I'm interesting
Or... you dont just block it but let the player craft in bulk
Won’t the name tags be way above each other with this method
Sry but this doesnt really make sense to me. Do you want to have a master - slave setup for data consistency between multiple server instances?
When you create a custom recipe and pass in an itemstack as the parameter, does bulk crafting base it on a singular itemstack? Like if I add a UUID in the itemstack object, will all of the items that are bulk crafted contain that same UUID?
Make them marker armorstands
And this is a weird setup
I mean they did say the issue with marker
Yes. Thats why you need to detect that and actually split the stack manually.
thought so, thanks for the help ❤️
Ah i see
Use another entity that has a smaller hitbox. Entities can have multiple passengers.
Example:
[Marker]
[Marker] + [Endermite]
[Endermite]
[Player]
That’s a lot of entities
all packet based ofc
How can I make a piston be powered without redstone? (please ping me)
I've tried this but it glitches out and does the animation extremely quickly 🤔
PistonBaseMaterial piston = (PistonBaseMaterial) block.getState().getData();
piston.setPowered(true);
block.setData(piston.getData());
blockAbove.setType(Material.PISTON_EXTENSION);
PistonExtensionMaterial pe = (PistonExtensionMaterial);
blockAbove.getState().setRawData(pe.getData());
blockAbove.getState().update(true, true);
block.getState().update(true, true);
Other than scoreboards
I wonder how wynncraft does multi line names, those are nice and smooth
[Marker]
[Marker] + [Endermite]
[Endermite]
[Player]
Can I change world border's color¿
You can make it red
How?
With a resourcepack probably... Why?
without a resourcepack
Could be it
with resourcepack ik
its possible but i dont remember how
Make it expand or contract slowly is my guess @terse ore
Or negative sized slimes and normal armor stands
Expand = Green
Contract = Red
Yeah just tell it to move a short distance with like, Integer.MAX_VALUE delay
Ah you just want to color it red or green. Expand it for 0.001 Block over a million seconds. ^
is it possible to send a packet to a player saying that a player x left from the Team? (from the scoreboard)
why would you need to use packets for it
because i need that for specific players only
Player#sendMessage?
Unless you mean it to be on the scoreboard, not fully sure of your question
i mean something like
team.removeEntry("APlayerName", player /* the team will be updated only for the player */);```
Oh so like remove it just from that players scoreboard?
yes
Hmm, I'm not experienced with scoreboards, but someone else might be able to help you
Only idea I would have is creating a team for every player and removing it when they leave but I doubt that is efficient
🤡
Check if it’s a sheep and then cast it to sheep
??
bump
Why are you updating it
block.getState() returns a brand new instance every time you call that method
because I want it to power it
If you want to edit a BlockState you should retrieve it, modify it and then call update on the modified BlockState
update(true is gonna trigger physics and undo any hacking you have done
Not to mention since states are copied each time you're just updating whatever the block currently is
That's what I did
so no params then?
Read the docs
No thats not what you did
But your update is completely pointless because of the copy issue
What does this do then?
PistonBaseMaterial piston = (PistonBaseMaterial) block.getState().getData();
piston.setPowered(true);
block.setData(piston.getData());
blockAbove.getState().update(true, true);
block.getState().update(true, true);
This does exactly nothing.
Ok but I did what you said to do no?
Nope
Did you not say to do this?
Oh wow
This replaces the BlockData of that piston with its own copy. So you can remove the line and have the same outcome.
This is a problem with instances.
if my world.rayTrace hits nothing, will the RayTraceResult be null?
Could be
Its a bit weird but yes
I assume if it hits neither an entity or block it’ll be null
bruh
Does that not mark the piston as powered?
ok, i was using rayTraceEntity in async
but it was complaining being in async because of getNearbyEntities
does the rayTrace method uses getNearbyEntities too?
?tryandsee
Is there anywhere I can find minecrafts vanilla block class code? I found the interface in the api files but of course it shows no method code.
In NMS
Thank you.
yes, it uses getNearbyEntities
but i need it for enttity
specifically
players
i need to check if a player is looking at another player
maybe i can just copy the rayTraceEntitities method
and use Bukkit.getOnlinePlayers instead the nearby entities
Ray tracing async might break at some point. For entities it wont work for sure.
For blocks it might look fine but you will get serious issues if you try to trace into unloaded chunks for example.
my goal is for loaded chunks only
Thats not really for you to decide 😄
What are you trying to do anyways?
Or just check if the target area is loaded each time
i think the client will use only a max of 3 blocks
and if the chunk is not loaded
that means no players is there
I have read both of those.
https://www.spigotmc.org/threads/powering-a-piston-programmatically.510597/
This doesn't work on 1.8.9 as there's not BlockData
The other thread points to the same solution above ^
1.8 moment
yikes 1.8
Tell me about it
true developers only develop against 1.6.4
Could you not update? I presume from your last message you cant
i saw 🕵️
Wait there was a method with Set<Entity> for all tracked entities iirc
something something getTrackedPlayers
Do you mean looking directly at another player or is possibly visible for this one player (not obstructed by blocks)
i did
private static RayTraceResult poorRayTrace(Location start, Vector direction, double maxDistance, double raySize, Predicate<Player> filter) {
Validate.notNull(start, "Start location is null!");
start.checkFinite();
Validate.notNull(direction, "Direction is null!");
direction.checkFinite();
Validate.isTrue(direction.lengthSquared() > 0.0D, "Direction's magnitude is 0!");
if (maxDistance < 0.0D) {
return null;
} else {
Vector startPos = start.toVector();
Collection<Player> entities = new ArrayList<>(Bukkit.getOnlinePlayers());
entities.removeIf(entity -> !filter.test(entity));
Entity nearestHitEntity = null;
RayTraceResult nearestHitResult = null;
double nearestDistanceSq = 1.7976931348623157E308D;
for (Player player : entities) {
BoundingBox boundingBox = player.getBoundingBox().expand(raySize);
RayTraceResult hitResult = boundingBox.rayTrace(startPos, direction, maxDistance);
if (hitResult != null) {
double distanceSq = startPos.distanceSquared(hitResult.getHitPosition());
if (distanceSq < nearestDistanceSq) {
nearestHitEntity = player;
nearestHitResult = hitResult;
nearestDistanceSq = distanceSq;
}
}
}
return nearestHitEntity == null ? null : new RayTraceResult(nearestHitResult.getHitPosition(), nearestHitEntity, nearestHitResult.getHitBlockFace());
}
}
ctrl c trlc v
change something here and there
gg
You need to compare your distance between you and the player you're looking at, just do the math
and see if he is looking directly
Is there an API way to remove arrows stuck in a player?
setArrowsInBody
How would one prevent respawn anchor explosions in the overworld
Does anyone know why this error? Put it exactly as in the bosshop api wiki.
https://i.imgur.com/LiGvx1p.png
public void registerBossShop() {
Plugin plugin = Bukkit.getPluginManager().getPlugin("BossShopPro"); // Get BossShopPro instance
if (plugin == null) { // Not installed?
console.sendMessage("§cLBActions: BossShopPro não foi carregado com sucesso.");
return;
}
bs = (BossShop) plugin;
console.sendMessage("§aLBActions: BossShopPro carregado com sucesso.");
}```
Who tag me? I couldnt see the tag
It is likely that you are trying to cast the class to a class with the same name from a different classloader
did you shade that dependency in unnecessarily?
if you really need it shaded in, you can consider relocation
You don’t, this is an external plugin
The only place it is is the mainclass
Are you using maven
are you on linux or windows?
what IDE
try booting up intelij as administrator. There is probably a chance you created the project when you were running it as administrator. outside of running intelij as admin and trying to build from there I have no clue
does it work when you export elsewhere?
maven build? or just regular export
my only guess is when its going to use command prompt its not been given admin perms for some reason or another. As long as your the only use on the computer and have the highest permission levels there should be no issue with exporting it
have you tried exporting directly from command line
run command prompt as administrator cd into your directory and run the mvn compile command
what your trying to build
just use command prompt make sure its run as admin
if thats where your project is
yea project folder should do as long as you have maven installed
whatever your build arguments are
for example
mvn install -f /home/redacted/Desktop/Java/Project/project/pom.xml",
Is there a way to track when someone switches worlds?
your pom has all of the project settings output paths plugins dependencies etc ofcourse
Oh awesome
but is that applied to every world?
or just the overworld nether or end
yea but I mean would it detect a change in someone like a different multiverse world
as the event name specifies I would assume its not specific
the event names are very descripitive of its purpose
Awesome thanks
did you run command prompt as administrator
@grand flint why would you export your projects to documents?
or have some instance of command line open as admin
are you the only user on the PC?
sus
mvn deploy and move it to documents
he said earlier the issue is with every directory
so just mvn deploy and move it to whatever directory he wants
that gets tedious especially if you have to do it a lot
compile and deploy the project and then you have the .jar in the generated file
don’t call me stupid when you don’t even know how to use mvn properly
send a ss
it saying acces denied
its probably a firewall issue tbh
usually there is more lines that explains the reasoning error codes etc
makes it easier to solve the issue
I’m just trying to help, maven is built into Intellij
it should already be installed granted your using intellij
you create a maven project
are you using the command line given to youby intellij
br on ?
there is a high likely hood its not being run as administrator how to do so on windows and intellij I have no clue.
you can make a thread on the forums theres an entire section for that
Do u want it to explode still without any blocks being broken or stop it from exploding entirely?
As long as it doesn't injure entities and break blocks, idk
I am trying to only allow specific items in a chest, but this won't let me modify my own inventory while being in the chest
and it allows all items for some reason :(
@EventHandler
public void onClick(InventoryClickEvent event) {
if (event.getCurrentItem() != null) {
if (event.getCurrentItem().getType() == Material.AIR) return;
if (event.getCurrentItem().getType() == Material.STONE) {
event.getWhoClicked().sendMessage(event.getCurrentItem().getType().toString());
event.setCancelled(true);
}
}
}
It should only allow stone blocks
easiest way is to listen for a PlayerInteractEvent and cancel when event.getClickedBlock().getType()==Material.ANCHOR
Alternatively you can listen for a BlockExplosionEvent and then do the check above, then do event.getBlockList().clear()
check if the clicked inventory is a chest
if (!(event.getClickedInventory() instanceof Chest)) return;
event.getClickedInventory().getType().equals(InventoryType.CHEST)
oh-
so
@EventHandler
public void onClick(InventoryClickEvent event) {
if (event.getCurrentItem() != null) {
if (!event.getClickedInventory().getType().equals(InventoryType.CHEST) return;
if (event.getCurrentItem().getType() == Material.AIR) return;
if (event.getCurrentItem().getType() == Material.STONE) {
event.getWhoClicked().sendMessage(event.getCurrentItem().getType().toString());
event.setCancelled(true);
}
}
}
should probably also check if event.getClickedInventory() is null but it shouldnt ever be
hm
i think i may have messed up my stone check
well now i can move everything but the stone 🤡 -
@EventHandler
public void onClick(InventoryClickEvent event) {
if (event.getClickedInventory().getType().equals(InventoryType.CHEST)) {
if (event.getCurrentItem() != null) {
if (event.getCurrentItem().getType() == Material.AIR) return;
if (event.getCurrentItem().getType() == Material.STONE) {
event.getWhoClicked().sendMessage(event.getCurrentItem().getType().toString());
event.setCancelled(true);
}
}
}
}
is there any way i could call this furnace burn event to happen after the last if statement?
isnt that what u want
the last if statement of the onFurnacePlace that is
wait
i can ADD stone, but not remove it-
You talking about prio?
prio?
and you dont wanna be able to add stone?
event priority?
i want only stone to be added / removed
nothign else should go in the chest :thonk:
would i just check the instance of the inventory, see if it's a player inventory, and allow removing it if it is?
sorta, i want it to check if the block placed is the reinforced furnace then if it is do the bottom code (the furnace burn event)
theres a few checks u need to make, like inventory actions
isn't that all just covered in InventoryClickEvent
no its also covered in InventoryDragEvents
oh
alright thank you!
cause if you drag click to split into even stacks its handled under another event
is onFurnacePlace annotated with @fresh templetHandler?
oh ._.
yeah i just didnt put that in the screen shot lol
you can set the prio of events by adding the priority parameter in the @fresh templetHandler annotation
so to make it run first you can do @fresh templetHandler(priority = EventPriority.HIGHEST)
sorry evan
can i make it so that if the first thing comes out false then the other one doesnt run
lmao
I think so, just check if the event is cancelled
with event.isCancelled()
but make sure u cancel it in the other event
so i set the prio of the thing i want to go first then i cancel the other event if it comes out false
?
cancel it in the first event
whichever event u want to run first, set that priority to HIGHEST and the other to NORMAL or a prio lower than it
Yes cancel it in the first handler then check if it was cancelled in the second
ok
if it is cancelled then return
what do u mean
ur not setting the method to be cancelled ur setting the event to be cancelled
then checking if it is
so i do e.setCancelled?
wouldnt that just cancel the event im already on though, sorry this is what i meant
whats the condition you dont want the other method to run?
yeah
so basically if a comes out false i dont want b to run
but if a comes out true i want b to run
so if the event is cancelled, u dont want the other handler to run?
well than how to other plugins make it so that you can have levels of furnaces or like better furnaced
furnaces
im not sure, ive never done anything with furnaces
might wanna ask @ivory sleet
ping him when hes online
For working with player profiles, what would i use Player or Offline Player?
We talking NMS player profiles?
probably the new player profile API added to spigot
alr
oh thats really interesting
I might have to do some work with that
oh cool capes as well
Hi there, just checking here, plugins are required to follow GPLv3, right?
(Asking for a plugin of my own creation)
no
draw your own conclusions from that
might be good for elgar to also look at that
Spigot is v2 isn;t it?
What is the rare achievement sound called in the api?
Try UI_TOAST_CHALLENGE_COMPLETE
ok thanks
Has anyone made a script by any chance to speed up development process? Currently, my process is
- stop currently running test server
- compile new jar
- manually drop new jar in server plugins
- restart server
Definitely could be automated was wondering if someone had already done it, save myself some effort.
how can I stop a event for a specific player? (AsyncPlayerChatEvent)
PlugWoman
/plug reload -c PluginName done
I mean I guess you can't replace the jar while the server is running on windows
Very cringe
Check the player
And if it is a specific player
Cancel the event
You can also use symlinks to prevent having to drop the new jar in every time by the way
Ooh nice, this is way better than what I was thinking. Thanks!
Yeah, I tried using windows shortcut briefly, but the server didn't pick up on it, so I was exploring some other options
Windows is just terrible for development
If you want to work fast, set up linux dualboot
I hit ctrl twice to open up intellij's command prompt, then hit down and enter to run my last-run command (usually gradle build)
That updates the jar in the build folder and my running server has a symlink to it
Then on the server I just run /plug reload -c PluginName, or if it was my last-run command, I just hit enter-up-enter
It takes all of 3-5 seconds
That is the biggest advantage of using linux for plugin development
huh
Yes you can
It'll say it's in use

