#help-development
1 messages · Page 112 of 1
alrighty just had to add an extra (
Yeah i thought that too
But dont know which packet
ok but here comes the actual problem so as you can see
``` there is an edition number, and it needs to be changed every time a space helmet is given to a player by an admin how do I do this now
can u even get big_dripleaf in survival
my guess would be either the PacketPlayOutBlockChange packet, or the PacketPlayOutTileEntityData packet... dunno
save the previous edition in the config or files and read/write it everytime a helmet is given
testing i guess
howw?
Thx which protocollib you recommended me
i don't use packets, so actually no idea
i only mess with custom packets, where i just use the normal messaging channel
How can I turn this data into ItemStack?
==: org.bukkit.inventory.ItemStack
type: TRIPWIRE_HOOK
amount: 9
meta:
==: ItemMeta
meta-type: UNSPECIFIC
display-name: "\xa7f123123 key"
lore:
- "\xa77Use this to open \xa7f123123\xa77!"
ItemFlags: !!set
HIDE_ENCHANTS: null
HIDE_ATTRIBUTES: null
ItemStack.deserialize(map); i guess
Or just getItemStack
Because that exists
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
I have a question. I know that you can put JsonObjects into a Json config with multiple things in them. But how can you get these things in the JsonObject from the config?
Is this legal while loop in event?
public void onPlayerJoin(PlayerJoinEvent event){
while(true){
system.in.println("test");
}
}
That will crash your server
what the
Asking about your attempted solution rather than your actual problem
but, if sometime the condition is false, are the server will crash too?
Why would you do that?
what do you want to do
I need some looping to subtract value
what value what
why that
just tell us whats your end goal
like thirst plugin
?
idk what you mean
you want to give palyers hunger on join or what
I want subtract value from player data if player during inside the server
what data
and why do you need a loop for that
because, there is no event or what is that if the player during inside the server
playerjoinevent is ran when player joins the server
Couldnt you just add there name to a hash map when they join and run a scheduler on the names in the hashmap then remove the name from the hash map when they leave?
Does anyone know how to replace material names from "_" to ""
you literally replace _ with " "
yeah... how
does VillagerAcquireTradeEvent return the number of trade that gets added?
i need 2 override it
String.replace('_', "") should literally do 😛
what is hash map, sorry I'm beginner
learn java first ig
spigot for intermediate ish
maybe even for beginners but you gotta know the basics
Cannot resolve method 'replace(char, String)'
thats what i get
you gotta do '_', ''
if you're using char
not '_', ""
but then you'll get a char literal error
so use "_", ""
Non-static method 'replace(java.lang.CharSequence, java.lang.CharSequence)' cannot be referenced from a static context
...
it triggers once for every new trade
send code
i forreal just did String.replace("_", "");
show your method
someone told me to do string
for what u have
shall not happen
bruh
you have a string variable with some name
but _ is a character
WELL I ASK FOR A REASON DON'T I
we dont know your string name
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.
stringVariable.replace("_", "");
then you should use (stringname) i would suggest
no
String stringVariable = "this_is_dumb";
i know some basics
ye how do i know which number new trade has
not to be rude but it makes it easier for yourself and for us trying to help you
but both doesn't work
then show your method
Material item = Material.getMaterial(args[0].toUpperCase()).name().replace("_", "");
ay I now have my own maven repo (or gradle, if you are a cultured person)
Material isnt a string?
also you have a material variable
could probably get the villager object and check the trades it already has
not a string
String materialName = Material.getMaterial(args[0].toUpperCase()).toString().replace("_", "");
i’d assume no but you’d have to test that
the trade shouldn’t exist yet while the event is firing
can i somehow inject into minecrafts trading selector to add my own enchant book?
gotta make is as vanillish as possible
yeah you can check if it’s an enchanted book and if yes, add your own enchant selector logic
did something similar yesterday
instead of adding an enchant i removed mending
yeah
Enchantments.values gets you a list of all enchantments
select a random one
wait does Librarian give random enchant from registered ones or its hardcoded
i’m not sure actually
Umm i have this problem with this piece of code it should grab material by string that is being gathered from config.yml and then it should make it as ItemStack but it appears that material is null and i really dont know why since i get this in my console when i try to print out values that are gathered from config
this is how i know material is being null
even though it shouldnt ?
Did you print out the config reason string ?
how can i get the angle towards a point
config.getString("Reasons." + reason + ".Item")
i printed this
and i got those items
and if i print
config.getString("Reasons." + reason)
i get reasons
it is these lines like Anti-Knockback
dly
fly
speed
So you have to get each memory Section as a ConfigurationSection
no no i dont know if this confused you
i printed 2 things
reason variable
which gives me that name
Fly
Speed
Fast Bow
X-Ray
this second thing is totaly something random
that i printed
send config.yml, might help in the diagnosis
I dont understand can you explain more detailed
just to see where i might be making mistake
Is anybody aware how do i add trade to trade pool of a villager?
?paste
Reasons key has bunch of reason keys
each reason key has item slot and lore
lore is still not added ofc i want to just put item in inv first
So you have to just play around with ConfigurationSection#getKeys(true) and with false
i dont think that is a problem because i got those "reason" variable from doing just the thing that you said right now
i got those "Fly" "Speed" "Fast Bow" words
by printing
config.getConfigurationSection("Reasons").getKeys(false)
and it is correct
Lmao you are not explaning fully detailed
What your point!
Its imposible to help if you dont detail what you need
agh i so okay i have a list of reasons "keywords" that im looping trough with for loop and for each reason in that list i want to make ItemStack but it seems to be giving null Material somehow
i gather material by combining names of keys from config.yml file
ItemStack reasonItem = new ItemStack(Material.getMaterial(config.getString("Reason." + reason + ".Item")));
this is the line that is gathering material by string
and string is gathered from config.yml file
but i still get Material is null even though i am gathering item from config correctly
Oh no
or just this part ?
Because as far I understand you are getting a null item from the Section
i am getting Material as null but i dont know why because my path to string from config is correct
it throws error on line where i create ItemStack variable because material is null
even though i wrote correct path to string from config
HOW
You are using config.getString("Reason." + reason + bla )
"Reasons" and not "Reason
As the path is null, ítemstack is null
Could the keys have spaces in yml config ?
No!
still not working hahahaha
Keys musnt have spaces
i changed it to Reasons
That's the problem then
still same error
Remove the spaces
whats the method to get villager max stock
"Fast Bow", "Kill Aura.." ...
Yeah
He is using spaxes for keys
Rolyn
ok so why the hell
it was not a problem with spaces
Keys should be able to have spaces
Dont use keys with spaces
IT IS NOT BECAUSE OF SPACES
i tried now again
still not working
CALM down
idk just git gud
What's the line with the NPE ?
did you comment something important out maybe?
is that question for me ?
What's your version ?
@mellow pebble What's the line with the NPE?
wdym
Let me guess: Clicking outside the inventory?
Line 91
?notworking
"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.
ok boomers: expecting: getMaxAge() to work
^^^ i probably can't help you anyways but this may make it easier for others to help
but i provided the info needed
b
not even the error
Nope, but close enough.
You probably don't have anything at that key
you're missing an s
ReasonS
Kill Aura/Forcefield:
Item: "IRON_SWORD"
Slot: 0
Lore:
- "bla bla"
- "blah blah"
- "yeah yeah"
Anti-Knockback:
Item: "LEAD"```
if that's your config
yes
you're using config.getString("Reason." + reason + ".Item")));
still not working?
It does not make much sense though, you are not directly invoking Object#requireNotNull
Blame IJ I guess
Eclipse would never do that and tell you the exact reason of the NPE

Eclipse
Since you are using such an absolutely stupid IDE we cannot help you further
Why talking for everyone
Turn off null anotation enforcement and use Java 15+ NPEs and then we can talk
by stupid ide do you mean ij or eclipse?
IJ ofc

Ofc it is a user error, but let's not blame people
and once again, I'm disappointed in humans
hey, eclipse is so primitive that it would never insert bytecode in your code
Try debugging, like did you even check the getString return null ?
it doesnt return null
AHAHAH
Thanks to it we do not know what part of Material.getMaterial(config.getString("Reason." + reason + ".Item")); is null
What does it return then ?
you can properly disable these runtime enforcements
Yeah you cna
beyond that, what do you mean you don't know what part of that is null ?
are you exporting to right place
What is your version ?
?paste
this is literally what config.getString("Reasons." + reason + ".Item") prints out
anyone can help this code
https://paste.md-5.net/akevuwujeg.java
gives this error
Cannot resolve method 'setInt' in 'FileConfiguration'
so it souldnt throw an error "Material is null"
@EventHandler(
priority = EventPriority.LOW
)
public void onDeath(final PlayerDeathEvent e) {
Meridiana.getInstance().getLogger().info(e.toString());
if(e.getEntity().getKiller() != null) {
if(e.getEntity().getKiller() instanceof Player) {
if(e.getEntity() instanceof Player) {
ItemStack type = new ItemStack(Material.PLAYER_HEAD);
SkullMeta meta = (SkullMeta) type.getItemMeta();
meta.setOwner(e.getEntity().getName());
type.setItemMeta(meta);
e.getEntity().getWorld().dropItem(e.getEntity().getLocation().add(0,1,0), type);
}
}
}
}
in case for /kill what would be the instanceof?
/kill deals a lot of void damage
Just use set
what line does the error occur on
then how without the check for player?
83
83
i need only in case of player or /mill
Have you tried Material#matchMaterial ?
api version 1.19.2 server version 1.19.2
no because im not sure what it even does
API version should be 1.19 not 1.19.2
why
1.19.2 is default that intellij sets for me
Try it then we'll see
API version (in the plugin.yml) doesn't care about minor versions
Well it's not supposed to and that API version doesn't exist iirc
Oh yea possibly
i changed 1.19.2 to 1.19
and still the same error
If you hardcode some material it doesn't throw a npe, right?
anyone?
what would that mean
thanks but encountered with another error
trying Material.APPLE for example
oh yeah
Cannot resolve symbol 'editionNumber' : line number 52
'getPlugin(java.lang.@org.jetbrains.annotations.NotNull Class<org.bukkit.plugin.java.JavaPlugin>)' in 'org.bukkit.plugin.java.JavaPlugin' cannot be applied to '()' : line number 20
and printing config values also does return something, weird
if i print config.getConfigurationSection("Reasons").getKeys(false) i get normal strings that are in config
IRON_SWORD
SUGAR
DIAMOND_SPADE
POTION
and such things
Could you show the code causing the error
anyone? ^ ping pong
You need to give it a class
the editionNumber?
but I have saved it as a file
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
hm
but here is da thing
ChatColor.DARK_GRAY + "Edition: #" + (plugin.editionNumber++),```
I need the number to be presented here
What's the meaning of editionNumber?
the ```java
(plugin.editionNumber++),
do you want the plugin version?
no no
oh I didnt explain
so when an admin does /spacehelm, it give a helmet to a player with the lore of an edition number
and it changes everytime like a + 1 when a new one is given
I'd just use some variable and only save it on disable to config
wym
That's the main class
https://paste.md-5.net/aqimilawub.java
https://paste.md-5.net/jukixiyoxe.java
Does anybody have idea why it doesnt register?
(minecraft:wisdom is an unknown enchant)
You have some accessible variable you increase every time someone runs the command, and onDisable you save it to file
or if you really want you could also do it like every time someone runs the command
Or did I get you wrong
"Registered wisdom enchant." does however print
but then I want the number to be displayed in the lore
then just get the value of that variable
@tender shard with your ArmorEquipEvent when called and you check what armor the player is wearing it will say they are not wearing a full kit when they just put on the last piece
how?
Can you create an item with the enchantment added?
also who dat dude in ur pfp
eminem
ill check in a sec
okay, so you have an int variable, in onEnable() you set it to whatever is saved to file, then every time someone runs the command you give them the item with the value of that int variable in its lore and increase that variable by one, also save it to file
bro typing for to long
are you trolling or what
That's my g Em
And what is editionNumber
private static JavaPlugin plugin;
FileConfiguration config = getConfig();
int editionNumber;
public static JavaPlugin getInstance() {
return plugin;
}
@Override
public void onEnable() {
plugin = this;
config.addDefault("editionNumber", 1);
config.options().copyDefaults(true);
this.saveConfig();
editionNumber = config.getInt("editionNumber");
this
a config file
an int*
With your static call your returning a normal java plugin
Return your main class
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Don't use config defaults, it's not working that way. Instead create a config.yml with the keys and values in your resource folder. And onEnable call saveDafaultConfig
Depends on the usage but yes
He's not making a behind the scenes api it should be di
Even with most api methods di should be used
Not really, always depends on what you're doing.
There really isn't ever a reason to not use it outside of creating a singleton class
public final class YourMain extends JavaPlugin {
private int editionNumber;
public void setEditionNumber(int newEdition) {
this.editionNumber = newEdition;
}
public int getEditionNumber() {
return this.editionNumber;
}
}```
will that help to fix le problemo?
No.
fuck
?di
Guide to dependency injection: https://www.spigotmc.org/wiki/using-dependency-injection/
Hello, does anyone know why heads don't get placed properly in 1.8 when using the SkullCreator library? (https://github.com/deanveloper/SkullCreator/blob/master/src/main/java/dev/dbassett/skullcreator/SkullCreator.java) I'm using this method to create the head final Block skullBlock = this.block.getRelative(BlockFace.UP); SkullCreator.blockWithBase64(skullBlock, "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOGNjNzI1NzhhNjBjMGViMWEzZmEzODFhYTYyMmEwYzkyNzZkYTdmOTU4YWU5YTBjNzFlZTQ4ZTc3MWZiMmNjNSJ9fX0="); If anyone could help me fix this issue, it would be much appreciated.
read that
1.8 💀
1.8 is outdated and isn't supported.
Read the wiki and then apply it
I'm sure there is one insane mf around who will help with 1.8
I would but it's too outdated
Probably why 1.8 devs still exist 😁
How can I make a book_and_quill ItemStack? Because the Material is deprecated
1.8 devs will exist as long as 1.8 players will
Look why it's deprecated
Whenever anything is deprecated, look at the Java docs as they almost always state why.
?jd spigot
If it's for removal it will point you where to
Of course, though there is a limit- if it’s too difficult to develop then less people will bother.
No it doesn
In my opinion, the networks which ‘require’ running 1.8 have their own experienced developers already
What spigot api version are you using
1.13
Why?
1.13 weird version
support for lower versions
Spigot is backward compatible
Ok
So switch to 1.19
Check the javadocs for 1.13 then
Is it?
Just don’t use 1.14 or newer API and you’re fine
I'm pretty surr it's only forwards compatable
As long as you don't use a 1.19 feature it is
so i have an EntityExplodeEvent, i checked if getType is ender_crystal, now how would i check if the cause of explosion was a player?
And thats complicated because you have to research if it is. So it is easier to use a lower version api
If that event does not have a link with the cause of the explosion the. Maybe you will need to track when a player ignites or triggers the end crystal
Start old version support at 1.16.5 you lose nothing by supporting older versions than that
But you can't get helped with EOL versions
Maybe you can get the last damage cause of the entity
Lot of effort to support 1.9-1.17 relative to how many servers still run it
is there anyway to track player left_click_block_event in adventure mode ?
i tried using animation tracking but it got some problems when right click
So how do you create a Book and Quill in 1.19?
Ofc xD
They weren't removed from minecraft so you should be good to go
I don’t recall there being such an event. Wasn’t it player interact event?
Ok but why are they than deprecated
PlayerInteractEvent
?jd
Are you using a LEGACY_ constant
Look
yeah
i did mention in adventure mode
Check if the players gamemode is adventure
Player#getGamemode iirc
bc there is not normal book_and_quill
no interact event is send when player left click in adventure
Then it would have been renamed
Oh writable book
There ya go
Book and quill is now WRITEABLE_BOOK I bleieve
Ok thanks
Dunno about adventure mode. Possible workaround is checking when a player swings their arm or something. Can’t you use survival mode for your application ?
it looks like this
i use adventure mode for lots of reason
i also mention that when player right click block as chest/craftingtable/etc it also send a swing animation
Are you sure ? I already had game modes with Adventure players and still use PlayerInteractEvent
try leftclickblock
left click air is still working
Just debug the interact event and output the action name. Then test
I have no idea, the only place i would use it is a lobby. I don’t have enough time to run a server network 😁
They don't have lore by default afaik
Idk why they just don't
You could try to dig through nms and figure out why but I'm clueless
It's cause you can give yourself an empty enchantment book. It's apparently not required for an enchantment book to hold an enchantment.
Yea but with custom enchants they also don't have lore it'd weird
Unless it's changed since I last used a wrapper
Well, custom enchantments are weird. Haven't messed with them in a while, but there are two approaches.
The lore approach - Create custom enchantment logic in different classes and activate it if the item lore contains the specific string relating to it.
The proper integration - Use the enchantment API to add in custom enchantments.
is it normal that my enchant isnt shown in /enchant tho
Yea
yes
why that
Look at nms and try to figure it out lol no clue
I feel like latter is a bit more difficult though
enchant is a nms command
Oh, it is. That's why people use the first approach in a lot of cases.
Although bukkit did rewrite a lot of commands, so it could be a bukkit command actually
So since minecraft wasn't designed to be edited, enchant will only display the mc enchants
But I do not think so
:/
iirc this one is kind of exception 😂
no result
Well minecraft was designed to be edited, it's just that it most are modifing the wrong registry
If you want to register minecraft enchantments, you technically should register them to the bukkit enchantment registry AND the nms enchantment registry. But noone does that
oh the anvil. My fiercest opponent
what
This is expected behavior, isn't it?
Anvils are hard to implement correctly if you do not register them to any registry
It's actually the implementation that is a bit confusing, not the API
I'm aware but you could improve the api to make impl less weird then again that's a lot of effort
It must be huge efforts since not even the paper team wishes to do anything at a large scale with it
Although paper has a noticeably better implementation - but there are still some things you'd rather not want to deal with that are present
im running spigot
Yeah good luck.
I wonder how awful it'd be if we just used reflections to unlock registries
by injecting mutable collections n all
Most people already do that with the bukkit ench registry
I mean nms registries
I mean you could, but I am not certain if there are any advantages to that
crashing the server seems like an advantage

Nobody:
FifteenBrush:
Sending random pics from code without context
i dont know who that is
.next.next.next.next.next.next.next
Mfw no array. 😢
Do you use an API to create Animated Scoreboard ?
array is for noobs, the future is MemorySection
lol
(real thing btw)
?
I myself? no
You could?
any idea why
player.teleport(player.getBedSpawnLocation());
returns player not sleeping error
Send the exception pls
its nullable
getBedLocation().. They won't have a bed spawn location if they are not in bed
But then this would throw an NPE. So i wanna se the error.
Caused by: java.lang.IllegalStateException: Not sleeping
at com.google.common.base.Preconditions.checkState(Preconditions.java:502) ~[guava-31.0.1-jre.jar:?]
at org.bukkit.craftbukkit.v1_19_R1.entity.CraftPlayer.getBedLocation(CraftPlayer.java:1387) ~[paper-1.19.2.jar:git-Paper-135]
at com.fuckingidiotmc.fuckingidiotmc.main.onCommand(main.java:112) ~[FuckingIdiotMC-0.0.1-SNAPSHOT.jar:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.19.2-R0.1-SNAPSHOT.jar:?]
I have slept
the command works just fine while in the bed
get bed location also returned same error
This exception does not correlate to the lines you just sent.
Whats in main line 112
No. this makes no sense.
Dont modify the code, compile right now, upload the plugin, cause the error again
and then send the full exception plus the whole method that caused the exception
Ah getBedLocation will throw this exception
I thought it was still getBedSpawnLocation
do I change getbedlocation to get spawn location for the null issue
Oh. Wow, that tricked me too.
Depends- you want the bed or bed spawn location?
I just want to teleport the player back to their respawn point with a charge
I wonder if that’s a different method considering the respawn point block added a few versions ago
Respawn Anchor iirc
fuck just saw i sent the wrong method
switching 112 to getbetspawnlocation fixed everything
wdym "it will say they are not wearing a full kit"?
of course the event is called BEFORE they equip the armor
is there a way to have it called after?
Check one tick later. The event is fired before the piece is actually equipped so that you can cancel it.
wait a tick
or listen on monitor, check if it's cancelled, and if no, you can assume that it was equipped
I really think Spigot needs a postEvent(Runnable) method in the Event baseclass so that you
can do those things in the same tick. Delaying a tick feels so fragile.
Problem is that that's so extremely difficult to implement because when those should get run is entirely dependent on the event implementation
yeah that would be nice
We would need to account for every single event call in NMS to invoke them
They run if not cancelled
I see how this is quite a bit of work because every event has a ton of logic after it.
But i think this would be a very decent improvement to the whole way people can use the api.
boolean call = !(event instanceof Cancellable) || !((Cancellable) event).isCancelled();
if(call)
postEvent(event)
type thing
No I get that. But as an example. PlayerItemConsumeEvent. What if it's a potion? Sure you can run it after the event is called, but the potion still hasn't been applied by the time it's been called
but it would break the concept a bit ig
The item actually hasn't even been consumed by that point either
And that's just one example
yeah I see the issue
The proposed solution would be equivalent to just adding a MONITOR event listener
So again, depends on the event and would have to be implemented on a per-event basis
Per-event-call basis, actually
or you can just delay it by a tick and call it a day
Yeah you would have to decide for every event individually when all parameters of an event are fully used up.
¯_(ツ)_/¯
i still dont see the issue though, because in the armor equip event you just do getNewArmorPiece() and that's it
I really dont like bringing the scheduler into those things because i usually just have a few runnables at a time that always run and
the only other way im using the scheduler is by delaying something by a tick. It just feels unclean.
yeah, delaying by one tick is basically just an emergency solution
if nothing else works 😄
But sometimes there is no workaround. Take the BlockBreakEvent. You cant set the block in the same tick after the player broke it.
You need to delay that placement by a tick.
What I’ve been doing so far is the delay by 1 tick but I wanted to avoid it. Basically I’m using the event just to know when there has been a change in armor on a player so I then check to see if they are wearing certain sets
You can as well get the biece to equip and the pieces currently on the player which are on a different slot
and determine the set right there. But then you miss out on other plugins which might cancel the event after your listener.
is there any way to get the block touching a certain block's face?
getRelative?
I'm assuming getRelative(BlockFace face) would do what I'd need then?
yes
thanks a lot :D
np 😄
I'm quite new to the spigot api so ill probably be asking questions here often
thats what this channel is for 🙂
I'm having trouble trying to import FastAsyncWorldEdit-Core 2.4.4 the IDE doesn't give any problem but when try to compile: is giving cannot find symbol in
ClipboardFormats.findByFile(file)
cannot find symbol->.load(file)
Is it possible to merge/combine multiple FileConfigurations into a single one?
copilot 🤡
Are you using maven?
merge them manually by looping over their getKeys()
for(String key : conf1.getKeys(true)) {
conf2.set(key, conf1.get(key));
sth like this
90% of the time it's useless, 10% of the time it does.. well.. that
for me it's almost always working perfectly fine
How can i set a block to be facing a certain direction?
Directional#setDirection o smth?
yeah ive been trying to do taht but it hasnt been working
Directional directional = (Directional) myBlock.getBlockData();
then you can set the direction
love the method names 
Ty alex!
I was using the same block from before I set it, could that have been the problem?
Hmm seems to not be working still
yes
Show your code
its on my git
link it
I've found my error i didnt know i had to do block.setBlockData()
updating the code gimme a few mins
What's the error?
Send your command class and main class.
If anyone know about a better async world edit I dont have any problem to change the library
wat
when setting a block a torch how can i get it to be a normal torch and not a wall torch?
set the material to TORCH not WALL_TORCH
they are 2 different blocks
- Material.WALL_TORCH
- Material.TORCH
afaik
yeah i saw but setting a block as Material.TORCH still gives a wall torch
set it without physics
if its near a wall your physics update turns it into a wall torch
why would it automatically do that anyway
ill try but its not near any walls
so it is on an invisible wall?
then its impossible for it to turn into a wall torch if you are not telling it to
its turning into it on air
weird
Do it without physics so it gets no update
that shouldn't happen in normal cases
how can i set a block without physics
seType(Material, false)
why are you setting the blockData?
doesn't work if I don't
I just removed it and now it's broken again
Your BlockData will be wrong anyway. you got it from teh hitBlock not the torch
with it i can get it to stick to walls
what part doesnt work
all you have to do is setType on the block. nothign else to make it a torch
I've tried that and it deafults to a wall torch facing south
for some reason, in spigot 1.11, the colour modifier tags for dyes are wrong... 8 becomes light gray dye, instead of gray, and 14 becomes red instead of orange... is there a fix for this? I need it to be normal.
I don't see how that is possible
First off, 1.11 cringe
Secondly, just make a conversion layer for it if the values are incorrect. An enum will go a long ways.
People who code in olde r versión mostly are doing it for work.
I can't use enums in this case, it's a pain. Well, thank you!
I'm glad you understand ^^
my condolences
In my case most comisions are from old versión. And they pay much than 1.19 because there are sousans of 1.19 devs rather old versión
Kind of like how FORTRAN devs are paid basically in gold these days
what's that
Why not? You just need to return the proper value. So if you do smthing like
public enum Colors {
RED(14),
LIGHT_GRAY(5),
;
private final int value;
Colors(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}
@gray merlin
Imagine I have been offered +255 dollars for just a 1.8 simple mini game. And i rejected cuz of time
massive exageration, but yeah
This specific part of the code needs to be 100% version independent, so having multiple values depending on the version won't really work...
I wonder if the older versions of the game use the hexadecimal value for the colors. 14 = red sounds similar enough to it.
I can say that you will get more money in 1 week coding 1.8 projects rather than 1 month of 1.19 projects
That you cant argue
Hahaha
1.7.10-1.10 certainly do, i've ported my plugin there. 1.11 specifically has the values messed up, lol.
I just tested and it works perfectly. a TORCH not a wall torch.```java
public class TorchArrow implements Listener {
@EventHandler
public void onHit(ProjectileHitEvent event){
Block block = event.getHitBlock();
if (block == null) return;
block.getRelative(event.getHitBlockFace()).setType(Material.TORCH, false);
}
}```
I'll go for a walk and think of a solution. Thank you for the help ^^
I'll change my server Jar and see if thats the problem
did you set the proper api-version in your plugin.yml?
Hmm, I'm not sure if you'll find an easy solution to this if you want version independent code. If the game messed up its implementation of it on only that version, you could chalk it up to a bug and leave it be.
However, if it's only this version that's messing up, you could do a hacky workaround by checking the server version each time you want to send the colors.
if version is 1.11
use alternative values
else
use the normal values
Does it look nice? No.
Will it get the job done? Yes.
how can I get normal: special:...
in config.yml
like is there a way to get all the items inside menu
getConfig().getConfigurationSection("menu").getKeys(false)
it gets the keys?
plugin.yml or pom.xml?
plugin.yml
declaration: package: org.bukkit.configuration, interface: ConfigurationSection
you should have it set to at least 1.13
api-version: "1.13"
if you don't add this, then the server will enable "legacy material support" and will basically think that the materials you use (e.g. "TORCH") are the "legacy names", like pre 1.13
so you should always set the api-version to the lowest MC version you wanna support
thanks for the tip!
im trying it out rn
thanks now Material.TORCH is giving a normal torch
ill change up my code a little to make it attach to walls too, thanks
trying to change the damage for a sword from
Default : 6
to
Modified : 3
however it just gives me this
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier("GENERIC_ATTACK_DAMAGE",3,
AttributeModifier.Operation.ADD_NUMBER
));
No i mean in java
Isn't that what you wanted
Maybe they want to remove the armor slots? If you only want it to be main hand then Add EquipmentSlot as well
EquipmentSlot.HAND after your Operation argument
Alex is still right about -3 though btw
aight bet
im fairly new so sorry but do i had to get .getslot().Hand
Nope, just EquipmentSlot.HAND
oh nvm had a look at the api
AttributeModifier(UUID uuid, String name, double amount, AttributeModifier.Operation operation, EquipmentSlot slot)
'AttributeModifier(java.util.UUID, java.lang.String, double, org.bukkit.attribute.AttributeModifier.Operation)' in 'org.bukkit.attribute.AttributeModifier' cannot be applied to '(java.lang.String, int, org.bukkit.attribute.AttributeModifier.Operation, org.bukkit.inventory.EquipmentSlot)'
//other stuffs
meta.addEnchant(Enchantment.LUCK, 1, false);
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
meta.addAttributeModifier(Attribute.GENERIC_ATTACK_DAMAGE, new AttributeModifier("GENERIC_ATTACK_DAMAGE",-3, AttributeModifier.Operation.ADD_NUMBER, EquipmentSlot.HAND));
item.setItemMeta(meta);
sword = item;
``` i am a little bit lost
What version are you using
Oh, wait, it wants a UUID
Before the "GENERIC_ATTACK_DAMAGE"
Which can just be UUID.randomUUID()
also when o set it to -3 it does no dmage
damages yourself 
Right...
I did virtually nothing
like i didn't even change the values
and suddenly it's all as it should
welcome to development my lad
I thought that was a joke, it had never happened to me
nah that can be a thing
i made a game once
and it's stupid to see which kind of things can destroy other kinds of things
like
IIRC that was used for a particle, and broke TF2 during particle loading, cause it was associated to pyro's weapon
but yes
placing a png-texture onto something essentially made the character able to clip through walls
and people still think that all bugs are easy to fix
how can i reset a players skin after changing his skin?
afaik mojang servers have those skins saved
so
Player player;
player.getPlayerProfile().getTextures().setSkin("url");
i suppose this should do it, never tried tho
tea is nice
bump
is there a way to "listen" for methods being annotated a specific way?
wdym with "listen"?
wrong quote
you can get all method annotations using Method#getAnnotations()
lol, well i am trying to make a listener thing (not bukkit). And in order to avoid the whole like registerEvents(listener) is there a way to know what methods are annotated and listen for new instances being created to track them too
Method method = Bukkit.class.getDeclaredMethod("getServer" );
Annotation[] annotations = method.getAnnotations();
just loop over all methods in your class, then check for the annotation
its not my class tho, others can use the api
but wouldnt people extend one of your classes?
e.g.
public abstract class MyListener {
public MyListener() {
for(Method method : this.getClass().getDeclaredMethods()) // register your stuff here
and then people can just extend MyListener
Hey, is there a way to remove an entities AI without removing that the entity can attack a player (Target)
oke
Hey alex so instead of doing -3 which does negative damage i just change the value to 2
and now it does 3 damage
public static void makeUnstackable(ItemStack item) {
ItemMeta meta = item.getItemMeta();
meta.getPersistentDataContainer().set(new NamespacedKey(myPlugin, "unstackable"), PersistentDataType.STRING, UUID.randomUUID().toString());
item.setItemMeta(meta);
your plugin's main class / instance
fuck you mojang
The reference to the class that extends JavaPlugin
U can't put the class itself, u need an instance of it
Hi, I am getting an issue with the plugin instance with the NamespacedKey function. I have a non-static method called getInstance() on the main plugin class, and I want to use it from another file. The problem is I don't know how to get the main plugin class in the first place to use the getInstance method. Can anyone help or direct me to a link?
Is there a way for me to add emojis or icons to custom names
k
i want to use this emoji in a custom name for example 🌟
custom name?
custom name of what?
should work fine I guess
ok nvm its only specific symbols you can use
my name's jeff
Hey, is there a way to remove an entities AI without removing that the entity can attack a player (Target)
you can remove all pathfinder goals except the attack one
but that requires NMS or a lib
yh
||☠ ☮ ☯ ♠ Ω ♤ ♣ ♧ ♥ ♡ ♦ ♢ ♔ ♕ ♚ ♛ ⚜️ ★ ☆ ✮ ✯ ☄ ☾ ☽ ☼ ☀ ☁ ☂ ☃ ☻ ☺ ☹ ۞ ۩εїз Ƹ̵̡Ӝ̵̨̄Ʒ ξЖЗ εжз ☎ ☏ ¢ ☚ ☛ ☜ ☝ ☞ ☟ ✍ ✌ ☢ ☣ ♨ ๑ ❀ ✿ ψ ♆ ☪ ♪ ♩ ♫ ♬ ✄ ✂ ✆ ✉ ✦ ✧♱ ♰ ∞ ♂ ♀ ☿ ❤ ❥ ❦ ❧ ™ ® © ✖ ✗ ✘ ♒\n" +
"■ □ ▢ ▲ △ ▼ ▽ ◆ ◇ ○ ◎ ● ◯ Δ ◕ ◔ʊ ϟ ღ ツ 回 ₪ ™ © ® ¿ ¡ ½ ⅓ ⅔ ¼ ¾ ⅛ ⅜ ⅝ ⅞ ℅ № ⇨ ❝ ❞ # & ℃∃ ∧ ∠ ∨ ∩ ⊂ ⊃ ∪ ⊥ ∀ Ξ Γ ɐ ə ɘ ε β ɟ ɥ ɯ ɔ и ๏ ɹ ʁ я ʌ ʍ λ ч ∞ Σ Π➀ ➁ ➂ ➃ ➄ ➅ ➆ ➇ ➈ ➉Ⓐ Ⓑ Ⓒ Ⓓ Ⓔ Ⓕ Ⓖ Ⓗ Ⓘ Ⓙ Ⓚ Ⓛ Ⓜ Ⓝ Ⓞ Ⓟ Ⓠ Ⓡ Ⓢ Ⓣ Ⓤ Ⓥ Ⓦ Ⓧ Ⓨ Ⓩⓐ ⓑ ⓒ ⓓ ⓔ ⓕ ⓖ ⓗ ⓘ ⓙ ⓚ ⓛ ⓜ ⓝ ⓞ ⓟ ⓠ ⓡ ⓢ ⓣ ⓤ ⓥ ⓦ ⓧ ⓨ ⓩ{。^◕‿◕^(◕^^◕)✖✗✘♒♬✄ ✆✦✧♱♰♂♀☿❤❥❦❧ ™®©♡♦♢♔♕♚♛★ ☆✮ ✯☄☾☽ ☼☀☁☂☃☻ ☺☹ ☮۞۩ εїз☎☏¢ ☚☛☜☝☞☟✍ ✌☢☣☠☮☯ ♠♤♣♧♥ ♨๑❀✿ ψ☪☭♪ ♩♫℘ℑ ℜℵ♏ηα ʊϟღツ回 ₪™ ©®¿¡½⅓ ⅔¼¾⅛⅜⅝⅞℅ №⇨❝❞ ◠◡╭╮╯╰ ★☆⊙¤㊣ ★☆♀◆◇ ▆▇██■ ▓回□〓≡ ╝╚╔╗╬ ═╓╩ ┠┨┯┷┏ ┓┗┛┳⊥ ﹃﹄┌ ┐└┘∟「 」↑↓→ ←||
this + a lil more
is all the symbols that actually "render"
will a current opened inventory close if i open a new one
BAN
what
what
anyways
i want to delay a task
so i want to set the custom names visible then make them so they are invisible i dont understand how bukkit runnable works
you could just do this through the console
Anyone what to put for permissions in plugin.yml commands
i think it can only be one size
so you set the middle a
declaration: package: org.bukkit, interface: WorldBorder
each player can have their own WorldBorder
but each is always equal on all sides
How would I make a mob, let's say a zombie, always target the player?
Right now when a skeleton shoots it, the zombie will change targets.
ah, thanks!
public class AttackEvent implements Listener{
private MagicMayhem plugin;
@EventHandler
public void onEntityDamaged(EntityDamageEvent event){
double damage = event.getDamage();
Entity EventEntity = event.getEntity();
Bukkit.broadcastMessage(String.valueOf(damage));
Bukkit.broadcastMessage(String.valueOf(EventEntity));
EventEntity.setCustomName("❁" + damage);
}
}```
Entity gets damaged the damage is displayed on their head
now i want to setCustomName(null);
after 2 seconds of waiting
ik i have to use bukkit scheduler but iim so confused on how to use it
?scheduling
basically, im working on my first like server
and its going to be a Sword art online, Cube craft, Albion online inspired server
got a whole ass word document for it 🤣
i have been following this and couldnt get it to work
Okay guys, hold your pu$$ies tight and enable your packet brains
_ _
Context: I'm doing gif animation through map, works flawlessly, server wise and client wise, thanks to packets (ClientboundMapItemDataPacket), threads, intelligent detection of what player actually see to only animate what they see, with bunch of configurable functions that adapt parameters such as framerate, view angle, view distance dynamically according to their TPS
Server side memory allocation is also optimised to clear the ram after an extended inactivity.
For bedrock players though it's not perfect despite all my efforts (but it's perfect for java players)
_ _
=> I still want to improve the horny bitch, cuz why not, so i thought of the following:
Instead of sending a new ClientboundMapItemDataPacket every 200ms (for example), send a clientbound packet that would edit the map id inside the itemframe (i already have all the active itemframes entities in a cache dw)
So that would mean that I send only once ClientboundMapItemDataPacket of EVERY frame to the player, each frame having a dedicated map id, and then all I need to do is foul their client to think that the itemframe entity change to another map id (of the next frame)
_ _
Motivation & question My thoughts behind this change is to reduce the bandwith usage of both client and server, because (if I'm not wrong but please that's precisly where i need your support into) I think that sending a packet that changes the content of an itemframe is much more lightweight than sending a whole map data (cuz a map is an array of 128x128 bytes), and as those packets have to be sent constantly, i could expect a big boost for bandwith usage? (even if rn i don't use that much, as i said, the whole stuff works very very good already); TL;DR Do you think the optimisation can be worth it or on the whole countrary it would be worse?
If you're concerned that dedicating a map id to every frame is a bit overkill, well 1) let me remind you that the maximal map id is soooooo big so there is a big margin 2) i plan to use a pool of map ids that I reuse only for the active rendering mapimages
So feel free to give your general thoughts about that, if you don't know for sure i still enjoy your input
I love these types of error
just fix it bro
changing their held itemstack will show the "player swing hand" animation
I'm working on something similar
regardless of the approach, you'll still end up sending 128*128 bytes per packet
no way to avoid that
I'd recommend you optimize frame rendering times rather than optimizing packet times
and make a buffer that only sends up to like 5 frames per tick, per player, to avoid flickering
oh it's not their itemstack, not what they have in hand, but what they see on the wall
oh ok then never mind
On top of that, only send packets for maps whose contents have changed
I thought it was about handheld maps
And don't use bukkit's mapview stuff
make your own image -> byte[] converter like I did
@echo basalt all the optimisations you're mentioning have already been done but thanks
How long does it actually take to render an image?
From actually getting the image and updating colors, until the packet is actually sent
assuming there are no time limiters
If it's over 0.5ms, then you have a problem
idk man its very quick but i add some delay manually so that cpu cores can breathe
I mean it's not really that CPU intensive
Focus on optimizing most things but bandwidth
you still need to send a map packet regardless
ik but considering that 2000+ frames may be rendering i prefer to ensure that cpu is breathing from time to time
I always focus on optimizing bandwidth lol otherwise I can't connect to my server
there are some bandwidth parts you can't really optimize
sure you can do that id-thing if you send the data over time, and render the gif all at once
like pre-caching frames for the client ig
giving your cpu "breathing room" doesn't do anything
it doesn't get tired like a human
yeah exactly
thats what i'm planning, send them only once every frame 128x128
I tend to just optimize everything server-side and let the client do its own rendering
doesn't flicker and it's very fast
raytracing takes about 10mu (10000ns / 0.01ms), async ofc
rendering an image takes about 8mu (8000ns / 0.008ms), async
oh trust me, it does, before doing this the server would sometime freeze big time because the essential parts couldn't access the cpu
When i say breathe i ofc mean "let the cpu be totally free in case some urgent tasks need to run during that breath"
These are the kind of performance metrics that you need to have, before considering buffering images on the client
And only buffer images on the client if you actually need to
I need recommendations for designing a simple but effcient java Messenger
you can render images async, and cache them along with the packets
Hey,
I want to make a prefix plugin which supports hex colors.
Problem is that a scoreboard Team does not take hex colors, so I wantes to do it with invisible armorstands.
There's just one problem with this: Sneaking does not hide the nametag through blocks anymore...
Is there a better way to do this?
i already do that
breathing room in that context would be wasteful
I mean you can do a tcp messenger in like 40 lines tops
I mean im wondering to make a simple api over Java :ugly: sockets
no because i tested with & without breathing room, and the server definitly runs on a better mspt since i let breathing room (aka thread sleep)
Getting started with ASM?
if your async shenanigans are hitting your mspt you're doing something wrong
also if your code is that optimized, and you still need breathing room then it's ehhhh
Also protip: -noverify
Just run it through 7smile7's workload distribution and you should be good
?distro
what's the comamnd
gr
?workdistro
that
what is all the hype with optionals in java? I don't get it its just a slower wrapper to a normal null check?
they are not that slower
3x slower for no improvement over a simple null check
we should write plugins in assembly
It can be used as an immutable wrapper that includes null while being non-null itself
useful for maps ig
lol
Project panama when
i see its uses for streams, but I keep seeing people saying crap like return with OPtional if output can be nul!
thats just dumb
I myself rarely use it, but if I cannot use any nullabillity annotation library for some reason, I'd use Optionals myself
you are wrong, because the async threads do use the main memory too, many things have locks in the main thread
Also it's important to understand how a thread works
A thread shares the same cpu core with many other threads. Java thread pools makes it well so it uses threads of different cpu cores, but my server ain't a beast and doesn't have much cpu cores, so most often the threads share the same cpu core. CPU itself is like food, if a shenanigan (thread) eats all the food then the other threads using the same CPU start to suffer as well. And as every threads have at some point some locks with the main thread, it increases teh chance that some hold a lock in the main thread for too long and hence causing the main thread lag
if you aren't using something like lombok idk what you doing
But given that almost always there is the possibillity of slapping jetbrains-annotations java-5, it's very rarely the case