#help-development
1 messages Ā· Page 752 of 1
Yeah but it hast to always be above the player and move with it š¤
Make it ride them
hello is it possible to call BerryNoDamage event when in CobaltArmorEquip player have full armor like addding effect?
@EventHandler
public void CobaltArmorEquip(final ArmorEquipEvent event) {
Player player = event.getPlayer();
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () -> {
int amountOfArmor = 0;
for (ItemStack i : player.getInventory().getArmorContents()) {
if (i == null)
continue;
if (i.getType().toString().contains("DIAMOND")) {
amountOfArmor++;
}
}
if (amountOfArmor == 4) { // player has 4 pieces of diamond armor on
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 60, 50));
} else if (amountOfArmor < 4) { // player has less then 4 pieces of diamond armor on
player.removePotionEffect(PotionEffectType.FIRE_RESISTANCE);
}
}, 0L, 20L); //0 Tick initial delay, 20 Tick (1 Second) between repeats
}
private void BerryNoDamage(EntityDamageByBlockEvent event) {
if (event.getCause() == EntityDamageEvent.DamageCause.CONTACT) {
event.setCancelled(true);
}
}
}
Correct me if I'm wrong but wouldn't that queue a task every time they equip armor?
That's a memory leak waiting to happen
an out of memory error looks plausible lol
I've actually done something like this before on accident its much more likely it will lag out the server before the memory loss causes issues
considering most modern machines have so much you'll probably notice the TPS drop xD
Oh yeah thats true
;/
So is there any other way to somehow check if player have full armor on or not?
I mean isn't it a good idea when I will add before scheduler first a few "safe checks" that will only run check on certain timings?
when I make it without scheduler it's just work like on reverse so when I put 4 pieces then nothing and when i deequip after that one piece of armor then it give me the effect
because on the last one I think it doesn't update?
What is the bukkit equivalent of MobEffectList (spigot) or MobEffect (mojang) in spigot
is their anyway to translate?
dunno. anyone know the structure of the namespacedKey Enchantment.getByKey() wants?
oh ffs is there a non-deprecated way to map String -> Enchant
thats not 'list all enchantments then iterate through them'
weird that it is deprecated. JD doesn't show it as deprecated.
ah maybe because its marked as internal
try NamespacedKey.fromString("Minecraft:" + key)
NamespacedKey.minecraft
š
Good heavens
What an atrocity
how
It gonna create tasks that never end.
oh ok I didnt see the cancel();
makes sense
Is there any way to simulate enchanting at an enchantment table in code?
Congratulations, I found this
ItemFactory ify = Bukkit.getItemFactory();
ify.enchantWithLevels();
retainAll can work like that
Bros discovering server destruction methods be like š
you could filter a set based on if it is present in the other set
how can i create a runnable in bungeecord? (like BukkitRunnable)
?
can someone help with this?
im aware, but i was curious if Set has a method for that?
isnt that just lambda?
not one I know of
Do you
Know about
() ->
?
wait can you not modify MerchantRecipe instances?
I'm trying to change the thing a villager trades
is the itemstack a reference?
wtf kinda method name is adjust
adjust
Hey how would I send a message of a players face as I'm thinking to try and learn new things thank you
I donāt think you canā¦
I've seen plugins do it before
Unless you make it across multiple lines
Well... a small resourcepack with a pixel that you recolor & negative spaces.
Then you just read the texture server-side and color and move the pixels
But this feels like some hacky, janky solution :D
by "pixel" I mean a custom character
Yeah a resourcepack could
You could also just modify a player head's model/texture and show that
you can't show items in chat
Something like AquaCore displays in there lore and Chat Control displays it in image but maybe trying to convert an image into Pixel Array would work right?
Yes
I suppose heads are only 16*16 right
8x8
Really?
What
Thats smol
I mean... look at your profile picture ?
Yeah they are only 8x8
It would be a cool feature to add in but it blows peoples minds to do it haha
Which is good since a chat line is like 8 pixels tall
Idk how many pixels my avatar is
no ?
show me then
I am completely high (not really)
Wait it isn't 16x16?
Drugs are bad mkay
it's 8x8
dw I don't do em
Well, technically it can be anything
Anything that is a power of two
Steve looks fine for 64 pixels
ty :D
Not anymore
RIP HD heads
Wait what
not skins, but you could make HD heads
https://www.spigotmc.org/resources/picture-login.4514/ head like this?
I assume they want it on one line
Yeah
I mean, this would then be half of the feature - get colors of the skin
Second half would be the moving of the character
Yeah itās not that hard
not 16777216 colors
smh
ĀÆ_(ć)_/ĀÆ
I was mainly thinking to use it for when the Player Logins and show it in lore so when you hover over an item it will show the skin before disguise
If I want to change which direction a falling sand block that passengers at an armor stand look at, how do I do that?
Think it was something with a type of yaw, but didn't really understand
I am not sure I fully understand this question.
Rule of thumb:
If there is a passenger, or maybe two
Remember that teleporting will never work for you
You could just set the yaw of the armorstand, no?
I want to change which way the block should look, which is passengers on an armor stand
Canāt ya just rotate the armorstand
teleportation works if you use eject
Try to explain what the overal plan is. Maybe we have an xy problem here.
Falling block can not change rotation. If you're on 1.19.something, use display entity
of... of couse
Yes
Should look into teleporting of mounted entities
It's suppoted
spigot just... doesn't do it
I could make an ultra-quiccc pr
PLEASE DO
Okay, I want a stair to look down
This is how I do it
And I hate it
https://github.com/steve6472/StevesFunnyLibrary/blob/master/src/main/java/steve6472/standalone/interactable/ReflectionHacker.java
Im not sure what that means...
So you would just need to remove entity.isVehicle()
and you're done
welp
time to PR
You want a falling stair block which is facing downwards?
teleportWithPassengers moment
probably just new method ?
Wonder if itāll explode if you try to do it across worlds
time to remember how to make PRs
Sorry if I'm unclear, I've made a code that currently teleports falling sand blocks that are passengers on an armor stand. I want to change the angle of these blocks.
you can't
Rip
there is literally a check
Display entity
Ok but what for?
anyways how do I make a PR I forgor
If you teleport the sitting entity it will dismount
Fair
Otherwise it should probs just teleport with it
Display entity solves all of these issues
To make a space rocket with stairs
Ah, i see. What version is this for?
Donāt say legacy donāt say lega- wooo
Use display entities
You can transform them however you want
If you are a little bit patient and willing to copy some math, then this would be a good
place for display entities. They are just a little bit tricky to work with but have a much better
performance for client and server than falling blocks on armorstands.
wait really quickly
Do I make a PR to the SpigotAPI then to CraftBukkit? Like separately? (And mention them in each-other)
Wasnt there something something, you need to pr both and reference the impl/api pr in the description for each other?
Mhm
Implemented this API
Added in [PR]
What can craftbukkit do without bukkit
Craft
So I will use display entities instead of armor stands and passengers etc, And that can be rotated?
You mean I can craft bukkit?
Can I code a plugin in nms
Hmmm
Yes, they can have arbitrary size, rotation and translation.
I would also recommend writing generic code where you can define a cuboid of blocks
and translate it into a moving, multiblock vehicle/entity. But this is gonna get tricky if you
want to rotate the whole structure. Translation should be easy.
If I shade in spigot api in my plugin, how bad is it
Idk, how big is the api
~2MB?
And while I'm looking at this, is it a good idea to use WeakReference<Entity> ?
fuck I actually forgot my stash pass
Yeah kind of. But this lacks a ton of methods for proper transformations. The whole structure needs an anchor point and a few more methods.
?support
Does it matter what directory I run it in?
No. As long as your -Dfile finds the jar from where youre at.
Do I run it in the projects terminal?
Being in the folder of the jar makes it easier as you can just use a relative path
the one I want to add dependency
You can run it in any terminal you want if you have maven installed on your pc
All this command does, is copy a .jar file into the local maven repo of your pc so that all local mvn projects
can find it in their pom.
Guess this is the documentation for display entities?https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/Display.html
ok got it
https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/entity/BlockDisplay.html
Yeah and this is the Block impl
declaration: package: org.bukkit.entity, interface: BlockDisplay
Okey Thanks! š
Aren't collisions gonna be hard AS FUCK?
Just donāt collide
I programmed moving vehicles with custom nms FallingBlocks but then I got stuck on collisions
Ah yes, my VW Golf GTI is always passing through the wall to get to hogwarts
I actually gave the FallingBlocks the properties of Shulkers for collisions, but I encountered heavy bugs and issues with that
You can't just "give falling blocks properties of shulkers"
Not server-side
You can
elaborate
I would just draw a bounding box around that thing and check for overlaps. I would never check for individual blocks there. Way too expensive.
You override the getEntityType method of your nms FallingBlock and let it return Shulker
Boom you get collisions just like shulkers
Aah
That ain't even gonna work well for the client
Does that really work well?
Yes it didn't lol
client will never know about the collision property and will try to fall through
Server will teleport the player back
Could trigger anti cheats
The collisions itself worked
Ye, you just don't do this.
At best you can use shulkers themselves
but the client did some weird stuff and entered crawling state all the time
Oh I tried
Did 100% the same thing as the EntityType thing
hmmm maybe if it was moving, stationary shulkers should work normally
huh, weird
@orchid gazelle shulkers retain collission when moving. spawn a ai false shulker following the moving block
I did
wait did u get them off grid?
Wdym?
I had NoAI Shulkers being stationary in the air
You walk against it with your head, you get into crawling state mid-air
no like
ive been trying for a while to place shulkers where they shouldnt be
namely, at xz coords that arent mod 1 = 0
You can do that if they ride a different entity
bleh i feared thatd be the case
How would I make my plugin support all server versions and features for each version?
Use the lowest spigot version you want to support as your dependency.
There is a great barrier between 1.13+ and 1.12- that often require extensive
adaptation or external libraries to support legacy versions.
Okay thank you, I know it sounds wired but I always code in 1.8.8
Some people are just masochists...
Haha is that why some plugins have protocollib as a dependency
Hm?
Im just saying that programming in 1.8 is generally a horrible experience.
Its a decade old and it shows.
no, protocollib is easier than doing it yourself. some things require packets
Ah okay, I use 1.8.8 because I've took a long break and that use to be the latest version but I've now came back and there's loads of different versions that's why I was asking
side note its also possible people just shade more nowadays. our drives have grown in capacity a lot so storage space aint a concern in most cases
Spigot just deprecates methods until the heat-death of the universe
Attempting to compile Bukkit with JDK 1.8 seems to fail due to org/eclipse/jdt/core/compiler/CompilationProgress being compiled by a newer JDK
But some stuff that has been in bukkit for beta 1.7.3 isn't in modern bukkit/spigot, which means no support :(
Is it better to make plugins from 1.8 or 1.12 because I know people like 1.8 due to the PVP
Depends on who you're trying to target
If it is purely PVP server then sure, you can go 1.8
If not, the go latest
Depends on your audience and what your plugin achieves.
If you want to target pvp kiddies then go for 1.8
Otherwise dont
lmao, nearly same thing
m
I wanted to create a server core so I'm not targeting a specific type it's mainly for people who want a way to have nice and easier features for there server
then just go latest
Maybe this helps you decide
i am fairly sure thers a 1.5.2 server somewhere lol
The other 2% is me on b1.7.3
youre not that important lol
Damn they use 1.20.1 the most
I support 1.17.1 and up, seems to work fine
funny mods
that's called nostalgia
beeeg tree
what i miss from previous minecraft versions is the auto updating
due to that removed now the community is fragmented between versions
what auto updating
there was auto updating
in the minecraft launchers
when new minecraft version got released
Back in Ye old days you played latest or you shut up
Even then you had chance of going back (through third party program)
Well you could still get old versions, but the launcher only ran latest
by switching bin/minecraft.jar š
nah i liked it tbh
at least we didnt had 1.8 situation
Thatās a them issue
If You have issues with armó stand try using the client SIDE armor stands they don't have much issues. Because they are directly in the client itself
I think you forgot to reply :D
Don't e mf
Can I somehow make it so that my custom TextDisplay rotates when a player looks at it (like normal NameTags) and so that its hidden to the vehicle (player)
Hi , is there server need spigot developer ?
?services
If you wish to request or offer development/art/building/administration services, please do so at https://www.spigotmc.org/forums/services-recruitment-v2.54/
If you do that then it can't be moved
as otherwise it will end up straight to the shadow realm
Its not really working for me anyway as the TextDisplay is to low compared to the player body, the original name is still being shown and the player can see his own name... so I think might just use teams for color and prefixes
Yep
No it canāt but it can produce NPE @solar musk
Its specifically getOfflinePlayer(String) that may request mojang since UUID mustnt be null
Yes
Does a display entity as passenger not hide your name?
Normally passengers hide the names of entities they ride
is there any easier way to check if an ItemStack is a Spawn-Egg than creating a Method with a Switch-Case for all spawn eggs?
You could create a set of Materials to check against
Or check if it has SpawnEggMeta
change the bstats code so the plugin is always tracked even if he disables bstats in configš¤Æ
you would need to declare that your plugins forces tracking, if you did that
There is this method https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/inventory/ItemFactory.html#isApplicable(org.bukkit.inventory.meta.ItemMeta,org.bukkit.inventory.ItemStack)
declaration: package: org.bukkit.inventory, interface: ItemFactory
public boolean doesPlayerTargetPlayer(Player p, LivingEntity target){
if(!target.getWorld().equals(p.getWorld())) return false;
Location head = p.getLocation().add(0, p.getEyeHeight(), 0);
Vector look = p.getLocation().getDirection().normalize();
Vector direction = head.subtract(target.getLocation()).toVector().normalize();
Vector cp = direction.crossProduct(look);
double length = cp.length();
return (length < 0.1);
}
becuse dont go, dont get error.
Please don't name your variables cp
Lol dont think thats what they were after
I mean I don't think the FBI is gonna show up over a variable name
Yea bet that wont happen anytime soon
I think thats cuz its not a living entity, no?
hmm thats interesting
Maybe mojang hardcoded that
yea fair enough
Alright, so I wanna apply special code to an Entity if it got spawned by an Item a Player was using(So ArmorStand, any Spawn Egg or ItemFrames). How tf do I do that? EntitySpawnEvent sadly does not provide a way to get the player who caused it
EntityPlaceEvent iirc
mmh that only fires for armor stands, boats, minecarts, and end crystals.
According to the docs anyway
Hi, when using getNewScoreboard() setPrefix() and so on dont work but with the mainScoreboard it does.. do I have to register it or smth couldnt find anything on the api
if you get a new SB you have to set it for the Player
So adding the player to it isnt enough?
whats the best way to get the color of a block, ive already tried getMapColor() and it works pretty decent except for the fact that is doesnt work for transparent blocks.
do transparent blocks have a color?
glass, slime,etc
is it possible to change the fishing speed
Does someone know how to change the chat format (remove the <> around player name) with Adventure API?
isnt lure enchant speed?
no like
i dont want an enchant
or changing tick speed
yea ik but how in the owrld would i do that
hm
"
setWaitTime(int min, int max)"
"Set both the minimum (default 100) and maximum (default 600) amount of ticks one has to wait for a fish appearing."
but how do i listen for when ur hook is in water
theres multiple events for PlayerFishEvent iirc
Just set it on cast
can I modify the plugin.yml with java? I would like to add for example a command into the plugin.yml if the user sets it to true in the config.yml
i'm working on this parkour generating plugin, anyone have any ideas for extra features, it can already generate parkour and it has a preview mode
Could You the task about scheduling?
If You did the blog about using async un spigot
Just learn more about spigot scheduling
Si far i know that they don't run anything async they are just parallel executed
Using ?
Because You cant use threafs because they block the server
Right
What the diferente between running them with a executor or none
it runs in the forkjoin common pool if you don't specify

But if You don't pass an executor the Main thread is blocked untik You get the result
No?
Yes
By default it uses the forkjoin common pool
Which is not in fact the main thread
Well yeah
But why tf are you using get
you can;t get the result until its finished
if you try , you lock the main thread waiting
But thats messy You have yo writen many future thing
Why there isnt a thing that wait untik completaron on other thread and then jus treturn the value directly
Instwad of doing thousans of then()
Also that make you not able to call none async field
Wait until is computed on another thread and then return yo the thread caller
š¤
Is nt it that possible
wait are different blocks different size with block display?
Yes but yo need to use thousans of then for compelz fuctions
I mean is not posible yo get te value async and get it back yo Main thread
but the diamond block was like x2 and I need to drive
"transformation.getScale().set(0.5D);" for normal size
It is, just not at the time you requested the value
Otherwise the main thread would have to ⨠wait for the value
Crazy concept
Right, but why? Can't You await in a diferent thread and finally return it back yo the caller/ requested thread?
And what does the main thread do in that time
Okay so
You send your friend to go get apples
The friend plants the apple tree seed
Waits 3 years
Gets the apple
Comes back to you
In this time you can do stuff sure
But you can't do anything with the apple you wanted
It does not matter that it's your friend waiting for the apple to grow
It does not exist yet
But why that? Can't you just tell many of then to plant, continue asking more yo plants while the Friends are planting
Finally when the plant grown up get notified with the value to the requested
Yes
You can get notified 3 years down the line
That your first Apple is grown
That is what the run can do for you
You pass something that should be run/notified when the first Apple is there
finds out the seeds from apples in stores will not grow apple trees š

I do like your explanation though lol
I have seen JDA with something like:
TextResppnse smth = message.send().enqueu();
And your threead doesnt get blocked
Because enqueue doesn't send the message
You ask your friend to give an apple to your mom
It queues it to be sent, itāll be sent at some point in the future
The friend goes off
Plants the tree
Waits 3 years
Gives the apple to your friend
You never get notified if that actually happened or not
You just trust your friend
The text response you get there isn't resolved yet iirc
It's a "trust me bro, I'll get a response for you at some point"
Yes but there is the same as using .get() from conpletable to get the response object
No it isnāt
You donāt get a response, you just get the message that will be sent
It hasnāt actually been sent yet
sometimes, you just don't need a response
I know but how info that
I want to implement that System
Because si really ugly having thousans of andThen, thenAccept
ImaginƩ having 1k of lines yo get runa async
Literally just make a method
Call the method in your the accept
Be happy
No one is stopping you
Hwo??
I am
Because if in do future.get get blocked
let me translate it
I want to do some sort of consumer which allow me to get the final value directly
Instwad of using weird accept, etc
You literally cannot
Why?? Doesnt makese sense
you are not understanding Async
Bro I dumbed it down to a fucking apple tree
How are you so dense
The apple tree takes 3 years to grow
For the apple
There is fucking nothing you can do to get it instantly
You can do stuff while you wait
You can do nothing
If the value is sent on the future none knowing when. You can just add many if then to queue, when is sent. Notified the Main thread giving the result object
But you'll get your first Apple 3 years in, not a minute earlier
if you call get you are WAITING for teh task to do all its work and return the result.
omg that really cool
Right thats okay, i need some sort of awaition but Nome blocking
queue doesn't return execution result in jda
You are a lost cause
not possible
if you want to do something with result, you use queue consumer in jda lol
Thanks i was wondering that a true or not
Sorry if i didnt epzlain before
Maybe letās do an example
You clearly have 0 idea on parallel Programm
None of the concepts are java specific
If you are used to the "async" keyword magic in other languages
CompletableFuture.supplyAsync(() -> *something that returns an object*).thenAccept(object -> doThing(object));
They just do thenaccept for you under the hood (not really, but think of it that way)
Yeah i'm trying tot ecretae that
Sorry if i didnt udnerstnaf well
It is literally just syntax sugar on crack
It does the same thing
Just in pretty
you create a method which will deal with the result so you call it in your thenAccept
Given java does not allow you to implement new keywords, get reckt
Oh right
Yeah i know that, but was planning some sort of utiltit class for that
Future is the utility class
If I rotate a block does the size increase by x2 or?
I mean if you really wanted to you could make
You are trying to reinvent a wheel that people a lot smarter than us have already invented
doThingAsync(supplier, consumer)
Yes but future conpletable is a mess
Bro šššš
I mean i sound clound but i'm not
Just trying to ezplain nyself but can't really get understand because i ezplain nyself too bad
You literally pass a "run this code when value" consumer and are happy
okay but i want to get the value directly thru the consumer. I understand know?
I Will then give a deeper research thanks to all
I'm having trouble with the MySQL, it's not saving data for some reason, I've tried using a public plugin to see if the database is missing permissions or something, but it was fine, here are the classes:
Main: https://pastebin.com/Wha74unM
DatabaseManager: https://pastebin.com/ebrWbEK8
GUICommand: https://pastebin.com/Qs4m70dD
Events: https://pastebin.com/erg21cG0
Also it connects to the database but it doesn't save.

Shh thatās too advanced
Callback stuff is fun
Sadly we canāt have callbacks for entity ticking
I want to some sort of callbsck which return the value get from future directly
But wit none blocking
how can you get apples from your friend if you dont wait for him ?
Why won't exits? You can just queue many futures while they are running, if one is completed notify the thread caller and return the computation
š
if you call get on any future you just locked the main thread (unless the future has finished).
Do you think this is a reasonable format for a plugin I'm working on these are all the messages ```yml
New_Player_Join: "Welcome to the server!"
Player_Join: "Welcome back to the server!"
Commands:
Spawn:
Spawn_Set: "&aSpawn was set!"
Spawn: "&aYou have been sent to the spawn!"
Invalid: "&4Invalid please do /setspawn"
Right tht what i want to listen. Why get blocked?
because get is blocking
Right thanks i Will check that
Okay why is blocking? Can't you await in another thread and finally return the result to Main thread once task is done
Honestly trolling at this point
Pls for the love of god stop the trolling
It's not even funny
let leave it here because me i'm troller come one bro. Im not trolling that sound rude
You literally said yourself "once task is done", how can you wait for it to be done without blocking?
You don't understand whatsoever what that keywords does in Javascript
So you think it instantly returns to the main thread
Which is completely wrong
You ask a future to count to a MASSIVE number and then return the last value. If you call get on that future it can't return the result until it has finished counting. So your get forces your main thread to wait. The result doesn;t exist until the future is finished.
Right
Once i'm Home i Will translate what i mean
Sorry if sound trolling but i'm not trolling
Just being wrongly explaiened
Yea I think you just don't understand at all what other languages do when you use the "async" keyword in them
So you are under the impression that something is possible when it is not
Right thats true i Will fully read in deep hwo the cpu manage that
Why doesnāt java have async keyword smh my head
any sugesttion forbette runderstnsdign
Of Java async
I wanna read first before trying to re ezplain what i was trying to do
Sorry for taking your time
they might be misinterpreting async as meaning multi-threaded. In spigots case, async tasks do use threads but only thread workers are created for the tasks needing to be completed
No I think they just think the async keyword magically gets the value back to the thread it was "called" on XD
JavaScript async is almost equivalent to Java CompletableFuture
JavaScript await is almost equivalent to CompletableFuture#join()
@sterile token in short
thats pretty much all u need to know to understand their similarities (not true but to dumb it down)
Dangerous statement for the JS experts in the discord
š„²
lol
Oh okay, thanks man
and async is pretty much just shorthand for Promise in JavaScript if you haven't realized it
I know promise
mhm
I'm trying to soft of it but getting the value directly
soft of it?
async in Javascript is pretty much just a syntactic sugar to configure the promises for you.
Promises are CompletableFutures in java.
Java does not have a syntactic sugar like JavaScripts async keyword to configure the promise chains for you
(I say pretty much because async does some more complex stuff, but think of it that way)
yeah we need valhalla and structured concurrency
I'm trying to find out if there is already a system for Java. Which allows you to get the result of a task once it is finished, but that is none blocking. For example, using the join() or get() that you mention
so sad it just got set to preview in j21
def not
Idk maybe John java has plans
that concept does not work
You still have the wrong concept
Okay thanks not need for being before rude saying i'm trolling
I mean, on whatever thread you call get() or join() on, it will be blocking because that thread has to wait for the value to return
Right, what about with an executor like ForkJoin
doesnt matter
Okay, perfect thats okay
doesnt matter what language, what object or what interface u use
if u wna do something once the value returns without blocking you will need to use callbacks
I thought it worked this way.
You load a lot of tasks to be completed at another time, while they are being processed your thread is still on something else. Once x task is finished, the thread that called it is notified and the result is returned.
basically a callback
except
"and the result is returned"
cuz that means blocking essentially
Like they do with SQL, once value si received they expose it
once
okay the rgijt name si a callback
yea, but callbacks are called by the task when its finished, IN COMPARISON to join() or get() which is called by you
and well... if the task is not finished, then join() or get() will wait for the task to finish => shiaazzzooop BLOCKING
I'm having trouble with the MySQL, it's not saving data for some reason, I've tried using a public plugin to see if the database is missing permissions or something, but it was fine, here are the classes:
Main: https://pastebin.com/Wha74unM
DatabaseManager: https://pastebin.com/ebrWbEK8
GUICommand: https://pastebin.com/Qs4m70dD
Events: https://pastebin.com/erg21cG0
any errors or anything in console?
No errors.
Is the driver imported?
via pom.xml?
You can't execute SQL witout the MySQL conector driver
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<version>8.1.0</version>
</dependency>
Ok, is inside your compiled sources
Because if you don't include the driver within your plugin, it won't run any sql requeste
The driver is already shaded in spigot
Oh right, i never make it work like that
Is the code fine tho?
Have try souting the connection.isConnected()
if (databaseManager.testConnection()) {
getLogger().info("Connected to the database.");
} else {
getLogger().severe("Plugin could not connect to the database.");
setEnabled(false);
}
Cache the connection in getConnection method
Hey is there a way to get an alt account without buying a new account for development purposes
I've got this warning in ij:
NameColors-1.0.jar, SpiGUI-1.3.1.jar, mysql-connector-j-8.1.0.jar, protobuf-java-3.21.9.jar define 1 overlapping resource:
- META-INF/MANIFEST.MF
maven-shade-plugin has detected that some class files are
present in two or more JARs. When this happens, only one
single version of the class is copied to the uber jar.
Usually this is not harmful and you can skip these warnings,
otherwise try to manually exclude artifacts based on
mvn dependency:tree -Ddetail=true and the above output.
See http://maven.apache.org/plugins/maven-shade-plugin/
online-mode: false
Just be careful testing in offline mode
It says some of deps have exact same jar
Since itās a bit different than online
uuid is cursed
Could this be what causing the issues?
Idk. It just a warning
Should be fine
Have you tried it without shading the connector
Whatās SpiGUI
Got a link?
Thank you, I will have to have a look might add it to my core
Notice how for spigot api you have <scope>provided</scope>
Yes, should I do the same for the mysql?
I discovered something, I've added a row in data having my uuid and namecolor selected and it works fine, even if i change colors but once i remove that row it doesnt add it back once i change the color.
run us trough what you're trying to do?
Once a player select a name color via /color it supposed to save the color selected in the MySQL and retrieve it once they join back.
But it doesn't save it for some reason.
are you updating the column and can I see your save part?
Got a question lmao, is chatgbt illegal here, cuz it fixed the issue š¤£
I use it sometimes to see if I'm doing it correct but it still has a small database so I would say keep learning and trying as trial and error
What you making anyway?
A name color system for my server.
Players can select name colors and go to different gamemodes and it would sync.
via Mysql.
Oh nice, dm if you want I'm making something similar but has way more features
I like to connect with other devs aswell
All I'm good at is making good GUI designs
Oh nice, I might need your help lol
Feel free to dm me whenever u need me
Alright thank you man
Anyone can help me? I want that when I click a block I want to check if the block clicked is a skull with a custom base64 that I've in config
I'd opt for the first so you're not creating new objects when you don't need to
well
the bukkit api is annoying when they return null instead of air
but then u cant use null in place of air in their api
wdym they have the same purpose
they both create new objects
Yes but the second one does it conditionally
The first one does it every time to pass it as a method argument
ohh i see
That requireNonNullElse() is best used for something like a constant default value
i'm trying to restructure my project to have multiple modules so that i can support multiple versions of nms, but now im getting a maven error saying i don't have the mojang mappings during packaging
Failure to find org.spigotmc:minecraft-server:txt:maps-mojang:1.19-R0.1-SNAPSHOT-R0.1-SNAPSHOT
though in my .m2 folder i just used buildtools to generate them. i've invalidated caches too and stuff, any ideas?
If no lore is set the list will be null
You can have lore with no entries
_Not that it renders any differently, but that's just how it works :p _
alr
Lore: [] vs no Lore tag at all
?
You can check the data of a skull on the ground via its BlockState
I love block states
does anybody know any plugin that mocks players so I can execute commands on them? (1.20 compatible) So I can test my plugin š„²
You can try mockbukkit, which isnāt a plugin but a library for unit testing
Other than that idk if anything exists for it
e.getClickedBlock().getState().hasMetadata("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMWMyMWViYzAwMzAxMmIxMjhjNTEwYTg1OThlMTM5ZjUxZjBlYzg4YmE1Y2VhNTg1ZWYwMDdlZDc1NDgzN2ZlMyJ9fX0=w")
?
No
GetState, cast to Skull, then use getOwnerProfile
Then you can get the textures from that, then the url, then do all the base64 stuff
Alternatively, just add some pdc to the placed skull
BlockState -> Skull -> PlayerProfile -> PlayerTextures -> URL (getSkin()) -> check for equality
can i get help with nametagedit and why wont it display the tags?
Do chunks have a Persistent Data Holder? When turned off, does the server save information from there?
They are are PersistentDataHolder and the data gets saved in its nbt file when the chunk is unloaded
i ran buildtools with the following command
java -jar BuildTools.jar --rev 1.19 --remapped
and still get the error when packaging
Failure to find org.spigotmc:minecraft-server:txt:maps-mojang:1.19-R0.1-SNAPSHOT-R0.1-SNAPSHOT
anyone have an idea where else this error could come from
wait its saying snapshot twice maybe thats it lol
Use a valid version. 1.19.2
do serialized Itemstacks also serialize Enchanments?
yeah that was the issue, im not sure how it got there to begin with but
depends how you serialize them, but generally yeah
ByteArrayOutputStream io = new ByteArrayOutputStream();
BukkitObjectOutputStream os = new BukkitObjectOutputStream(io);
os.writeObject(is);
os.flush();
byte[] serializedObject = io.toByteArray();
encoded = Base64.getEncoder().encodeToString(serializedObject);
is in that case "is" is the itemstack
is is actually okay to ask java specific questions here?
Sorry, I don't understand
is it possible to make an instance of a class inside of it?
How would that make sense
Class already have "state" of its instance
Idk if I worded that correctly
What are you trying to do
im... well learning basics of java
and this one seems to work just fine
it prints out 5
I mean you can create instance of class inside of it, it's used for singleton for example
can I create main method that system would start from outside of class?
or do methods need to be inside of a class?
Not yet
Main have to be inside of class currently
But it will soon be possible
It's in preview state
I'd love if they expand this concept to utility methods
Tho i assume main being classless is just sugar
hii im new to spigot, is there a reason why Player#isOnGround() is deprecated?
read the deprecation note
Because there are better ways to check it
?jd-s
why do I get this error all the time, Im trying to edit array in my method, while array is declared in class
Sounds like static abuse
it says the error for you
great but it doesnt explain what static context even is
mhm
You need to access fields through objects
You're trying to get a field that is object specific by using the class name
you're basically trying to access a property like
Class.property
this property is not static, and so it can't be referenced from a static context
static properties are properties belonging to the class, while non-static properties are properties belonging to instances of said class
you're probably misusing static as an easy way to just "get" a property you think you want
show your class and we can show you
eh ill just dump everything into a method
how to avoid learning 101
how should I do potions if all of the constructors are deprecated:
why i cant make empty array and then add numbers
we dont know if you dont show us what you got
oh an array, no thats because arrays are of a fixed length
you have to define the array size at creation if you want to add later
if you want a list you can add elements to you need an arraylist
but thats my entire point to make it as long as user wants to
or a set if you don't need duplicate entries, sets are faster too
then you don't want an array
list or set
idk it worked in python
python isnt java
this is not python
i believe arrays are converted to lists under the hood in python
so you can just add shit to it
Python doesnt really have arrays natively. [] is a list.
just doesnt work
you said you want numbers in that list right
List<Integer> list = new ArrayList<>();
no I want every type
Your IDE should import it automatically. Also a list cant store any arbitrary object.
Only objects of one type.
List<String> someList = new ArrayList<>();
well at least integer and strings
numbers 0-9 and operators like + - / * =
Its possible but you should 100% never mix different objects inside a collection.
you wanna allow players to make formulas?
sounds like you dont need a list at all and just a string
which is just an array of chars but thats besides the point
no im trying to make a calculator
..right
which I have already done in python but it just doesnt work at all
because you're refusing to learn away from python
java is a very different language from python
How exactly does it work?
on a surface level anyway
https://github.com/Redempt/Crunch
This library can evaluate complex mathematical expressions. Its written by a fellow spigot dev.
it gets input from you by order number, operation, number, operation etc. until you hit "=" and then merges let's say 5/2 into 2.5 by changing "/" into 2.5 and deleting both 5 and 2
does it until there is no +, -, * or / left
That sounds like you should create a bunch of different classes for this
So you have clean, readable and reusable code and not just an utter mess like you often get with python.
when was EntityChangeBlockEvent added to the api?
If I want to rotate the block to the right so that it is in the opposite direction as the block to the left what should I write then if the first block is "1" on "transformation.getLeftRotation().x" it shouldn't be like -1 or I think all wrong?
So it goes like this:
you can shit on python all day if you want but that wont stop me from learning it because I've got an exam to pass
but thats beside the point
point being Ive got no idea how to conceptualize how I would do things in python to java
How extensive do you want your expressions to be? Because writing even a half decent expression evaluator
is very difficult.
It can be done statically, but java is a oop language
If you're just parsing the string
Try PI or PI/2
I dont know what expression evaluator is
neither do I know parsing the string
what you're trying to make is an expression evaluator
you mean calculator?
a calculator evaluates expressions
well whatever what does static even mean
Static let's you attach methods fields to a class rather than a object
non-static properties are properties belonging to an object, or an instance of said class
A class cant really be used on its own. Its just a blueprint for an object.
You need to create instances of that class if you want to use it by using the new keyword.
i.e. all vehicles (for the sake of simplicity) have wheels
not all vehicles are electric
flawed analogy but just so you can picture it
its just for the sake of simplicity
and primitives
the guy is new
if you want people to learn things you gotta start with something at their level
and build on that
and dont forget about lambdas
why use nms when server#getEntity() exists
They're still objects to me
they are actually not
so like what am I supposed to do it outside of class or what
They are not?
they arent objects as you may think, they have own type called Lambda in reflection
and they cant really store anything
You write a class and create an instance of that class.
great but I literally have main method that starts from inside of a class, if it starts code from that class why I cant take a variable that I made in that class as well?
It's weird, i can pass them into lists and such, doesn't make sense for them not to be objects
they arent objects, they do not behave as an object
they behave as an unnamed interface
that has only one method to implement
they dont have name and true type is hiden
anonymous class is an object
Hmm, doesn't seem to work, just goes like this:
Runnable something = () -> System.out.println("Test");
This results in an anonymous class, implementing the Runnable interface
no, java uses runnable as wrapper around Lambda type
and Runnable is interface
not an actual class
Explain what that means
š¤ erm actually it's a hidden class
lambda expression werent added before java 1.8
whats the difference between class, method, field or object
why overcomplicate this with technicalities
Bc last time i checked the Java compiler generates bytecode that creates an anonymous class that implements the Runnable interface and provides the implementation for the run method by using the lambda expression as the body.
no
no longer true
anyways
class is a declaration of type
method is a function on some class
field is just variable on some class
and object is initialization of class
can someone help me for a sec? my intellij aint starting
lets use cars as analogy
class is the "blueprint" for the car
object is a new Car
method is the behavior of the car, a car can drive()
field can represent a property of the car, a variable, like a car has int wheels = 4
Since which java version? I want to compile and see for myself
Im just gonna use 17
when lambda declaration been added, also it isnt about bytecode but how jvm recognizes the implementation, and thats why i hate doing reflection on lambda expressions in java becuz you use Lambda type instead of the actual type
so why is my program starting all the time from just a blueprint that doesnt really exist until its used as an object?
because java always starts at the main class
becuz jvm makes it exist
you gotta start somewhere and so java makes you start at main
okay but why doesnt it also start variables when i set them in here
well it should, depends on how you do it and how you're accessing them
thats the part you're likely not understanding
and we cant help you until you show us
like what
tf you mean like what
dont think this ever was the case?
I actually made some readable python code
I mean if u anonymously instantiate a functional interface then yes it would be anonymous
else nope
show you what
your class that you're having this problem in??
then made it unreadable because a function call (not the actual code, like literally calling the function) was taking 14 seconds because "python is fast /s"
your code
anyway, i got a multi-module project and the server isnt seeing where my plugin.yml is, im not sure where to look on how to sorta set one of these modules as the main plugin
so what you do is you have your module with your plugin.yml in resources and it depends on all the other modules as dependency
and you just shade the others in
anyway @lost matrix here https://cr.openjdk.org/~briangoetz/lambda/lambda-translation.html
it should already be doing that
(and yes as emily said, there is sorta hidden class which is classloaderless^^)
and a list isn't an array
you cant access non-static stuff from static methods
why not make main non-static
so I need to add static to every single piece because yes?
why isnt it default then
java has considered doing that (heck thereis even a feature enhancement proposal about it)
I still cant run code
because
you shouldn't run your code in main
main should be the entry point which launches a non-static class
I got this to work but I get an error when someone joins: java.sql.SQLNonTransientConnectionException: No operations allowed after connection closed.
and you're missing generic types
???
so where am I supposed to run code
let me give an example
Oh, so lambdas are mostly anonymous methods
lambdas create an instance of the interface and it is stored as a non-named class
Have tried with PI etc. doesn't seem to get the right angle, maybe you know of another solution, or should yours work?
well ig thats one way to spell it out
public class MyClass {
public static void main(String[] a) {
new MyClass().runCode();
}
public void runCode() {
// Run your code
}
}
```I would do this (maybe even main in another class)
why
because you shouldn't make everything static
when things are static you lose one important property, types
also that ^
which is?
Java is object oriented
Python and c are different in this aspect
Tho python also has object support
It's just a later lesson
And not needed for most basic tasks
@slender elbow the method was in an object, so you're right
it looks up the name every time you call the function
and loads it