#help-development
1 messages · Page 963 of 1
hi
Yo
How do i make hexadecimal color code
ItemMeta kit3meta = kit3.getItemMeta();
kit3meta.setDisplayName(ChatColor.DARK_RED + "" + ChatColor.BOLD + "Archer Kit");
instead of chatcolor
how to do that
How can I check if the args length is 1 OR 2?
args.length == 1 || args.length ==2
Iirc it’s net.md_5.bungee.api.ChatColor
does Location.add modify the location itself?
Yes
so how would you combine locations then without having to clone the base location every single time?
it's like with integers, I don't want my base variable to change if all I want to do is foo + bar
I need to track when a player goes into chunks and loads entities, ones that might already be loaded by another player. (loaded clientside) Is there an event or packet for this?
if they are loaded clientside they are loaded serverside
oh
not if u send packets ofc
mans forgot the meeting of clientside
I meant if they are already loaded serverside by another player
and a vanilla client
and an additional player loads them in clientside, I want to track that
On a vanilla server and client it's synchronized
oh like that
I think I have a solution.
Just listen to the entity spawn packet
yeah
Also, my plugin involves showing a entities passenger when a player looks at that entity. Currently, I have a runnable just running in an infinite loop every 5 ticks and loops through every player, and loading the entity's passenger that they are currently look at. I am pretty sure this is the best way do it, however I am not sure. Do you guys have any thoughts on a different approach?
This plugin is not designed for large playercount servers (however it would be better if it could handle it)
whats the purpose of java.lang.Void
Eg, if a future returns an int, then you would have a Future<Integer> because primitives cant be generic arguments.
Same goes for when your Future returns nothing. So void. It would be a Future<Void> because void cant be a generic type.
hmmmm
im spawining an entity and i want to know from who it is killed. How do I use something like EntityDeathEvent specifying i want that entity to die?
How can i differenciate that entity from another one?+
The easiest way is probably to attach some NBT to that entity with its PersistentDataContainer
entity.getPersistentDataContainer(), then work from there
declaration: package: org.bukkit.persistence, interface: PersistentDataContainer
I know. I'm like a pest. You kind of can't get rid of me
and I appreciate that
?pdc
Hey guys im looking into custom generation and have been playing around with biomes on a custom world I am using the BiomeProvider and I am able to make a world all 1 biome but cant seem to get adding more than one biome correct. As of right now I am doing this to generate all desert
public Biome getBiome(@NotNull WorldInfo worldInfo, int x, int y, int z){
return Biome.DESERT;
}
Since this returns a single biome I tried doing a 50/50 change of it being a desert or bandlands but it doesnt generate how vanilla minecraft biomes generate it just sets smaller sections of blocks to either be desert or badlands. Is there anyway to get what the vanilla biome would have been then swap it?
The BiomeProvider does also come with the getBiomes method which is a list of biomes but I dont really understand the use of it if the getBiome determinse what biome will be given
you need to set biomes for a bigger area, eg per chunk. But world gen is complex, so to get something natural which is only desert or badlands is not trivial
perhaps using BiomeParameterPoint and basing the biome choice on one of the paramaters in there would work ok
alright Ill play around with some things and see what I can get
how could I store something like an itemstack persistently?
for example, a backpack, or some sort of system that combines similar items into one stack?
could I use something like a bundle?
you can't store itemstacks in pdc right
where tho
i think a bundle would be better
if I can change the look a bit
I mean... we could probably implement a PersistentDataType<ItemStack> or something :p
I don't know if md would like it in Bukkit but it's definitely possible
ok so like
wait
ig this doesn't matter anymore since ores dont drop themselves unless ur using silk touch
but when you break natural ores you get xp and when you break placed ores you dont? or at least you didn't
yeah you dont
how do you tell if a player has broken a natural ore vs a placed one
I don't recall that being the case. Because if you mine it with silk touch you're not getting the drops
ive confused myself'
That's part of the reason silk touch and fortune can't be applied on the same tool :p
how does ore xp drops work
Experience will only drop if the item drops. e.g. coal, diamonds, emeralds
It won't drop if you mine it with silk touch and get the ore
I think the ones that aren't smeltable don't give xp
So raw iron, gold, and copper won't ever give xp because you smelt the raw ore for experience
I mean iron, gold, and copper didn't give experience pre-1.17 either. They just dropped the ores themselves
wasn't copper added in 1.17?
yeah but im making a tinkers like tool leveling system and I was like oh no! how will I know if they are just breaking and placing the ore! and then I was like oh right
thats not a thing anymore
idk was it? Too many updates to remember over the last 14 years of my playing lol
Copper Ore is an ore block found underground, and planned to be added to Minecraft in update 1.17.
yer
yeah u could also use nbt if anything
still wip on the actual use cases
😭
ok so for adding custom blocks
the main strategy is to use noteblocks? and then maybe fuck around with packet stuff to make normal noteblocks look normal
but you can't really adjust the properties of the block too much
or maybe mushroom blocks?
wdym
idk it doesn't rly do much for being The New Ore They Finally Added
decoration and a few recipes just to make it feel less useless
ah I see
tbf thats true for lapis and quartz
custom blocks with textures? or you want to use existing textures?
lapis is the worst because nobody even uses it for building
yes with textures
custom textures*?
ah yeah noteblocks prob
yeah
bc like
I mean it wouldn't be the end of the world but if you make a noteblock that specific note and instrument it would look weird
also ermm how would I change stuff like mining time
idk but
for this
haste and mining fatigue change the animation too much
best option is probably mining fatigue and using nbt on the block or using yml files for how long it takes to break in ticks and divide it by 10 for each mining stage
if u don't want to use mining fatigue you could still do it but it's going to be annoying keeping them mining without destroying the block/stopping mining together and using the mining stages at the correct pace
right
and it sohuldn't change the animation too much if you just use mining fatigue it'll be a bit slower but It's way easier
well if its supposed to be an ore or stone block and they try to mine it with a diamond axe then yeah
the animation is gonna be slow as hell
am getting tired, but am I dumb ass or is this the way you do it? am used to paper.
[05:05:36 ERROR]: Could not pass event PlayerInteractEvent to Skyline v1.0
java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_20_R3.entity.CraftArrow cannot be cast to class org.bukkit.entity.Arrow (org.bukkit.craftbukkit.v1_20_R3.entity.CraftArrow and org.bukkit.entity.Arrow are in unnamed module of loader java.net.URLClassLoader @484b61fc)```
```java
Arrow arrow = (Arrow) world.spawnEntity(location, EntityType.ARROW);```
You shaded Bukkit
wait, what..
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.32</version>
<scope>provided</scope>
</dependency>
</dependencies>```
where 😮
your pom looks fine
then how did I Shade it
why do you have the shade plugin when you are not shading?
it's there by default with the addon I use, I don't build each pom.
ok
however yoru error is definitely due to a shading.
open your final jar and see what is in it
what should I look for spesifically in the jar?
any org/bukkit folders
also just use spawn(Arrow.class) rather than blind casting
yea, have no clue..
check the actual jar you are testing on the server.
also make sure your server is up to date
running a slime jar, whops. ill try another
sigh
fixed it, :p was testing a world generator thing earlier forgot to change jar
Classic
is there a system arraycopy but for collection sources?
?xy
i have an array of double size and i have a collection, i want to put the collection at a specific position in the array
i can do it with a for loop but i don't like it as much
turn collection to array and then arraycopy
i could do that, but i don't like making a copy of the array
sounds like premature optimization to me
Did you identify the problem through profiling
You use a profiler to identify issues, then you go ahead and fix them
hello its me again, how to read or write a yaml file?
can you show me it in code?
thx
does anyone know of a sleek way to prevent redstone updates entirely? I want to be able to block e.g. torch clocks or repeater clocks until a condition is met
all I found was the blockRedstoneEvent, but while that does work for 99% of cases, the block still initially receives power when a block is paced, but not after that
there doesn't appear to be a way to override the powered state of a block eitehr
never used the redstone update event
but what happens when u set the new current to 0 instead of just cancelling the event
gonna try to force the power level to 0 on block updates
well it does work, looks like arse though
https://imgur.com/cnTUhE4
right maybe I shouldn't cancel all block updates
could probably something with packets here
awesome, taht works
I guess it's inefficient but this isn't a huge-scale project
that’s usually the best way to achieve visually pleasing
it's not supposed to be purely visual
I want it to disable dispenser updates for example
https://imgur.com/okSPaGu
it really doesn't like my approach
I wonder if this is just down to some paper optimization
whow. The default is supposed to be a few hundreds of thousands. I think minecraft is constantly trying to update these blocks
Please advise how you can turn an object into a string without checking the object type through instenciof. Alternatively, I tried to use map and associate the adapter class with the element class type, but this is more like reflection and it is slow, what should I do?
https://www.baeldung.com/java-serialization this maybe?
well you can't really deserialize string to specific object if u dont know its type
if that is what ur asking
and idk why Map<Class, Adapter> would be slow
bc this reflection ?
reflection is slow
how are u using reflection in this case ?
u are just calling getClass
and reflection isn't that slow anymore regardlessly
then when this will be slow?
i mean reflection isn't as slow as it used to be
if u are that concerned about a performance do a benchmark
iirc reflection is faster than calling native methods
custom, native methods ofc (like JNI)
Uh
Great question
Something something MethodHandles faster than reflection
P sure native is quick but has overhead due to cpp conversion
Yeah haha
Pretty sure reflecting is fine as long as one caches the methods or classes or whatever :3
I once saw a benchmark table on baeldung (i think?) that showed that its MUCH slower than calling actual java methods
But as said, that‘s ofc only true for „custom“ native methods - native jdk methods like hashCode() are fast
Prob something to do with converting params
If everything's primitive it might be a lot quicker to convert
Yep sth like that
what abt writing a yaml file?
same exact thing
it's in the screenshot @rigid shoal
oh ok
isnt there a spigot wiki article about custom YAML files?
?customconfig
The home of Spigot a high performance, no lag customized CraftBukkit Minecraft server API, and BungeeCord, the cloud server proxy.
Hello, how can I do that in the config.yml there is an option to enable/disable chat moderation, and if its disabled ignore all parts of the moderation?
create the option and in your code check if its set
tbh this config wiki is way better than the spigot one (last time i checked) https://bukkit.fandom.com/wiki/Configuration_API_Reference
The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...
How?
I know more or less what i have to do but i do not know how
read that documentation and check out getBoolean()
Still dont understand
https://imgur.com/E5vDXF7 any idea how I'd iterate over all dispensers in an area? I tried this, but I don't get anything, and with type == Material.Dispenser I couldn't cast it to Dispenser
bruh here too
Chunk#getTileEntities
ugh I cannot just do this on a chunk-per-chunk basis
why not? you can still check whether they're in your area or not
it'd be much more annoying to find the chunks than to just iterate over all blocks
no
Hello, I want to make the welcome message and I have this
@EventHandler
public void onJoin(PlayerJoinEvent event) {
// Coordenadas al entrar : 0 0 0 0 0 world
Player player = event.getPlayer();
MainConfigManager mainConfigManager = plugin.getMainConfigManager();
if (mainConfigManager.isWelcomeMessageEnabled()) {
List<String> message = mainConfigManager.getWelcomeMessageMessage();
for (String m : message) {
player.sendMessage(MessageUtils.getColoredMessage(TekoCore.prefix+m.replace("%player%", player.getName())));
}
}
player.setGameMode(GameMode.CREATIVE);
Location location = new Location(Bukkit.getWorld("world"),23.38,64.0,-10.2,0,0);
player.teleport(location);
}
And in the config
config:
welcome_message:
enabled: true
message:
- "&a&m "
- ""
- "&fBienvenido &2%player% &fa &5&lTeko&f&lCraft"
- "&fEsperemos que disfrutes de tu estancia"
- "&fDiscord: &btekocraft.com/discord"
- ""
- "&a&m "
But nothing on the onJoin function works
my iteration block can go anywhere from one to three chunks in both the x and z direction, and I have no idea how I'd get the chunks efficiently
you have three options:
- Store the locations in the first place
- Loop over all blocks (not so good)
- Get all chunks in the area (or chunks that intersect it) and then loop over getTileEntities
#3 is by far the best way imho, or #1
you just call getChunk on the location, or you /16 the x,z coords
Hi , iam remaking my death system and i was woundering if it will be better to just use PlayerDeathEvent , or use EntityDamageByEntityEvent?
and check if player health is less than the damage taken if so , respawn , give kit .. etc
@tender shard
blocked
use code blocks please
?xyproblem
?xy
hmm, maybe this isn't as bad as I though it'd be. I'll try. Thanks!
I would use the death event so that other plugins (e.g. my angelchest plugin) can still handle deaths as usual
but ofc it depends - if you want to cancel the death in the first place, use the damage event
what's your actual goal?
that's how iam checking ..
i want a make a ffa pvp server server cant coudn't find a suitable plugin which has much features
#help-server or is this a coding-related question?
me , its coding related question
Wtf why?
Yo can someone help me, its important
ever heard of && and ||
because you cannot just expect anyone to help you, especially not if you ping them
don't ping me for random questions. Do not say "HELP ME, IT'S IMPORTANT" just because you didn't get an answer within 83 seconds
i have 2 problems with the PlayerDeathEvent ..
1- i want when player die , remove the respawn screen .
2- respawn , remove the droped kit items only , and keep the other to be droped normally .
tbf I think it's cleaner with nested ifs
Why cant i ssend photos
I don't
?img
Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.
Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org
use a code block
and same for yml
you'll have to respawn the player one tick after they died
on player death event -> scheduler 1 tick later -> player.spigot().respawn()
yeah ik but what if he died by a cause that is not player related?
lets say lava , or fall , or other?
how i can check?
there's getLastDamageCause() or sth
it's called sth like that
that will return the last EntityDamageEvent
ok so i need check if killer is null which means he died by player or by lava or other
Hello, I want to make the welcome message and I have this
@EventHandler
```public void onJoin(PlayerJoinEvent event) {
// Coordenadas al entrar : 0 0 0 0 0 world
Player player = event.getPlayer();
MainConfigManager mainConfigManager = plugin.getMainConfigManager();
if (mainConfigManager.isWelcomeMessageEnabled()) {
List<String> message = mainConfigManager.getWelcomeMessageMessage();
for (String m : message) {
player.sendMessage(MessageUtils.getColoredMessage(TekoCore.prefix+m.replace("%player%", player.getName())));
}
}
player.setGameMode(GameMode.CREATIVE);
Location location = new Location(Bukkit.getWorld("world"),23.38,64.0,-10.2,0,0);
player.teleport(location);
}
```config:
welcome_message:
enabled: true
message:
"&a&m "
""
"&fBienvenido &2%player% &fa &5&lTeko&f&lCraft"
"&fEsperemos que disfrutes de tu estancia"
"&fDiscord: &btekocraft.com/discord"
""
"&a&m " ```
```But nothing on the onJoin function works```
how i can do this best design?
can't you check this directly with the EntityDamageEvent?
declaration: package: org.bukkit.event.entity, class: EntityDamageEvent, enum: DamageCause
oh so you mean in PlayerDeathEvent i check if the killer is null then return
and in the other events EntityDamageEvent
i do the check for last damage
right?
invalid YAML
Please explain again what your goal is. If you only want to detect in PlayerDeathEvent whether the death was because of lava: Get the lastDamageCause, then check if the DamageCause of that event is e.g. DamageCause.LAVA or whatever
now add java after the ```
- show stacktrace
- as butter said, your YAML isn't valid
How to fix?
?paste your console error msg
write valid YAML?
i just want to make a good and decent death system for my skypvp plugin , so when a player die , give him stats , and killer too , and respawn the player who died , and give him kit .. etc
There is no error and in a YAML checker if I paste all the file it says its good
what yaml checker
i do have a combatLog so i can do :
combatlog.get(entity) -> this will give me the attacker
if you want to respawn the player automatically just dont let him die in the first place
can not read an implicit mapping pair; a colon is missed (6:46)
3 | ... rue
4 | ...
5 | ...
6 | ... "
-----------------------------------------^
7 | ...
8 | ... &2%player% &fa &5&lTeko&f&lCraft"```
yamlchecker throws
no error and yaml is fine - so what's the issue then?
There is more file
Idk im new in pl development
yeah looks good to me
yeah i was using this sytem :
https://paste.md-5.net/oyevabuvom.java
but it broke in recent version
use a damage even instead and check if the health - EDamage is less than 0
now if i hit the player 1 hit , he will die
no! why?
that will break all plugins that rely on the actual Death event
that sucks for them lol
fuck you I got mine
using the damage event is only okay if you actually wanna cancel the player dying
What happens to my pl then?
my standard response on grindr if someone offers to be my boyfriend
or if its not a public plugin lol
yes , so i don't want to break other plugin death that may use PlayerDeathEvent
nevermind i can imagine
well than you gotta do some fancy shit
then*
exactly. what you sent earlier was fine. Use the DeathEvent, check lastDamageCause() -> getDamageCause (the enum thingy)
have ignoreCancelled=true, is that what youre talking about?
the death event is not cancellable iirc
the death even wont be triggered
event*
ah ye
maybe mess with priorities
not sure though
what do you mean?
well you cant cancel the death even
so you gotta respawn the player yourself
@twin venture just write your code. Use the DeathEvent, check the damage cause. Come back here if you encounter issues
do not listen to people who complain all day haha
where are we? at the finanzamt?
whats that supposed to mean lol he asked a question and i answered
dw it wasn't meant as insult or anything
I only noticed that he wanted to get the job done and then he kept asking questions instead of just getting the job done
alright , iam sorry i just want to make it as perfect as possible to big servers :p
don't worry! death event is fine 🙂
I got the most popular death chest plugin on spigotmc so pls listen to me when it comes to deaths and stuff haha :p
alex do u wanna rate a concept i made for my rpg game
its weird the system i have now , with EntityDamageByEntityEvent works just fine , with 1.8 , but when i use it for 1.20.4 , when i hit the player once , welp he is dead
the health is 20 , and i hit him once and bom die
pls realize that I have no education about coding whatsoever. I'm a licensed lawyer, coding is only my hobby
you're much better off asking 7smile
its not code just a concept of structuring the inventory
or, if you like to get humiliated, ask frostalf
but sure, paste your code if you wanna get it reviewd by me
i aint that kinky
haha not a sub? you sure?
but yh its not code its just a concept
gimme github if you want a review
or whatever
lemme move this to general
ok
I don't humiliate people o.O
Hi, anyone here handy with nms and 1.20.4
sending chunk updates,
packet sends but does not update on the clients end
?xy
ooooh you do
why not use the API for that?
no need for NMS, unless there's an ?xy as md already said
I am using an api
i tried to get "world" but it gave me null instead
code:
try {
Player player = (Player) sender;
File yml = new File("plugins\\GDP\\DD\\DD.yml");
YamlConfiguration ymlconfig = YamlConfiguration.loadConfiguration(yml);
String world = ymlconfig.getString("world");
ymlconfig.save(yml);
player.sendMessage(ChatColor.GREEN + "You died at " + world);
} catch (IOException e) {
throw new RuntimeException(e);
}
yaml file:
player-ruthresh266:
world: overworld
X: 182
Y: 0
Z: 17
you need to acess it via the section
try {
Player player = (Player) sender;
File yml = new File("plugins\\GDP\\DD\\DD.yml");
YamlConfiguration ymlconfig = YamlConfiguration.loadConfiguration(yml);
String world = ymlconfig.getString("player-" + player.getName()+ ".world");
ymlconfig.save(yml);
player.sendMessage(ChatColor.GREEN + "You died at " + world);
} catch (IOException e) {
throw new RuntimeException(e);
}
how can i make a slot infinite?
for example if i have 64 diamonds in a slot and i pick up another diamond i want to store it in the same stack so 65 diamonds in the same slot.
You can't make it infinite
And storing more than the limit in a stack will cause client sided pain
even if it is a different gui? not the player's inventory.
Any gui
:/
You can make an item stack above the usual limit, but it'll be broken on the client and there is a limit
you could make something like that with the item's name or lore. but u cant rlly display a massive number as the amount
i fixed my problem i was missing a return xD
is this Efficent way to combine armors , and contents of player inventory?
im fairly certain #getContents() already contain the armor in modern versions
😔
btw is it just me or does bt for 1.8.8 not work anymore
it fails if you try to do sources or javadocs. One of them breaks it
not sure if that lib is included tho
uhh 1 sec
i already have support for 1.20.4 , and i will support latest version only
but i want 1.8.8 for my own server
is it possible to make a stick enchantable in a enchanting table?
https://paste.md-5.net/ebahenaqed.coffeescript running bt.exe with both sources & javadocs unchecked
https://paste.md-5.net/aratekozas.cs running bt.exe with sources & javadocs unchecked & disabled cert check
https://paste.md-5.net/lazapexici.cs running bt.jar (cli)
bt.jar gets the farthest basically
yeah I remember somethign about the jars being moved
never heard of it ☹️
thankfully i have run bt in like october or september successfully
but now it does not work
?1.8
Too old! (Click the link to get the exact time)
I mean you can open a bug report so at least it's tracked
ikik i'm not in particular need of the 1.8 nms right now but i could be 👀
do i do that with jira?
Yes
Opened an issue
hello how do i write in yaml file using YamlConfiguration?
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
yo, is it possible to add a method into Entity interface?
i want to add a method that checks whether that entity is or is not a boss
a boss?
yeah a custom mob i created
add a PDC tag to them when you spawn it
or NBT if you use older minecraft version :p
Choco told me to but i'm not that good at OOP and i am having a hard time learning to understand documentations
?pdc
If you are not good with OOP and don't understand then creating custom mobs is not a good idea.
learn OOP
it's not that i dont know it: i just have some doubts about some specific stuff. Also i dont really know when i should create a class or when i should just code it in the main method
is there an event for listening to lightlevelchanges?
No
is a hard reference to an entity only bad if i forget to clean up the memory or is this always bad practice?
Generally it’s fine as long as you get rid of it when the entity is no longer around
okay
is it possible with an enum, to have multiple method implementations? or do they need to same?
alr
How can I make a config file looking like this :
playlists:
playlist-1:
- "yes"
- "test"
- "cool"
playlist-2:
- "yes2"
- "test2"
- "cool2"
but if i want to make the player able to create many playlist they want ?
can i get how many list the section playlist have ?
ok thanks !
How can i get the duration of music/sound with the name but it's not always a sound from the Sound enum ? (like a sound added by a resourcepack
is there a way for me to prevent water from flowing to a certain block? I have a flower that could be washed away, which I want to prevent.
If that is something you can disable with block updates then I could use it for other stuff too, which I also need
BlockFromToEvent
oh thanks!
do not touch your config until after worlds are loaded if you store Locations/Worlds in it
I wanna do some stuff with water and any idea why this doesn't just work?
void onBlockPlace(BlockPlaceEvent e) {
if (world.getBlockAt(e.getBlock().getLocation()).getType() == Material.WATER) {
e.setCancelled(true);
return;
}
ah ok
is it a design issue when one manager needs another manager as dependency?
oh thanks my intellij wasn't showing that
how to know if the world is loaded?
How can I send player from the Lobby server to a another server but the request is from the plugin of the Lobby server
?pmc
but this happens when i use the command "read-yml"
?paste your yaml
Can you make a example please?
there is already an example on that wiki
But I doesn't understand it
paste your command code and the full error you get
That yaml is not giving that error
but happens everytime i used the command
i think its a player die event
That is not the yaml you are reading
wdym?
the yml you just posted is NOT the yml you are trying to load
look at the actual yml file you are trying to read
so you saying that this path is dont lead to the yml?
File yml = new File("plugins\\GDP\\DD\\DD.yml");
most likely
look at the actual yaml
use this
File yml = new File(getDataFolder(), "filename.yml");
the data IN the file is not the data you posted
there is nothing
I'll make it simpler.
When you write teh data to the config you are trying to store an actual World instead of World#name()
ohhhhh
teh file is most certainly not empty
thx it works now
Is there any up-to-date tutorial on how to control an entity's pathfinding and movements?
https://www.spigotmc.org/threads/tutorial-creating-custom-entities-with-pathfindergoals.18519/
I found this from 2013 but after reading I found out none of the methods exist anymore, so I tried to guess the renamed methods. I found some but then I noticed they're from NMS and then I searched for the NMS java docs and then I figured out there are no NMS java docs so yeah
I couldn't find a simple way of doing this but you could get the entities close to the player immediately after the event and filter out the arrows, then use projectile#getShooter to get the ProjectileSource and cast it to Player
This will be wrong if an arrow is flying near a player already, e.g. he's getting shot by an arrow as he's shooting
Meaning that there will be some false positives
thats why i said to get the projectilesource, to check if it's the same player
Though you could check if the shooter is the aforementioned player
That'll work
Yes
Missed that part
well then the shooter will be someone else. Did you try the ProjectileLaunchEvent? Or does that not trigger for crossbows?
but they should check if the arrow wasn't already used, so if they shoot right up, and shoot another arrow when the arrow is close again it doesn't glitch
here the shooter will be someone else
in that specific case
Yep. Basically there's a way to do it in a hacky way but unfortunately nothing in the API probably
👍
As I mentioned earlier, there might be a ProjectileLaunchEvent for every arrow
Could use that, too
I could be wrong, but I feel like I remember there being some quirk with the EntityShootBowEvent being called 3 times, once for each arrow of a multishot crossbow
If that a requirement then you'd have to check for the item in the main hand - if that isn't a bow/crossbow it was the offhand.
But yeah both solutions require some additional checks in this case
Again, I could be misremembering, but at the time of implementation, I think the initial draft had a EntityShootBowEvent and an EntityShootCrossbowEvent
Or maybe that was still a WIP for crossbow support
Ah okay so that is an existing quirk. And I'm not going crazy, because yes, Diamond did pull request like 5 new events, one of which included EntityShootCrossbowEvent which includes all launched projectiles in a list
It was just never merged
AbstractArrow does have a isShotFromCrossbow() method though (or something similarly named)
.
and idea how to get the minecraft gravity value from within bukkit?
I think it's the 9.81 meters per second like in real life, but I'm not sure
does seem a bit high though
Can't you measure it and then write it as a constant somewhere
I can't "just" measure it
why
I'd have to create a whole test setup
I don't know if I could get the velocity via minecraft commands
I could try that
Why, can't you just check how long it takes to fall down 10 blocks
And then use that info
that is most inaccurate
100 blocks then
oh there we go, tnt has a max velocity of -1.1 when falling
question is what exactly that means
oh yeah that divided by 20 is the velocity each tick, which is 0.055 blocks
This source says acceleration is 0.04 blocks/tick² not sure if it's reliable but you can test it
||https://youtu.be/ei58gGM9Z8k?si=qlCl4mFzOFZa4nyo&t=203||
close enough to my results, thanks!
i have issue about my custom config file
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Bukkit.html#broadcast(java.lang.String,java.lang.String) mh what would you use as the second string? The permissibles are very far from strings
?askgoodquestion
it just create empty file there is no error appear
😄
Hello sir I want help
Have you reviewed the code?
The permission string
Today when i do stream I don't how more players join our server and from more ips nonstop join my server can you help me how to solve this problem
I need help please help me please 🥺😭
but what exactly is the permission string. How do you get it? Where does it come from? The permissible type that is linked has seemingly nothing to do with that
are you running your server from your computer?
It's just a string
turn on the whitelist and go to #help-server
It can be whatever you want it to be
No I have a paid server
No I have public SERVER
then what exactly is the issue
isn't the point of a public server that anyone can join?
also this isn't development related is it? So go to #help-server please
Today when I do stream and more more players join and disconnect more players just do join and disconnect and my server performance gone bad that is the issue
so u want to block people from joining
Ok
either
- whitelist
or - player limit in the config
I can't nonstop join more players i think 500+
why would you set your player limit to a value that your server cannot handle
No my players limit is 30 but they doing join and disconnect
do I need to do anything else to make that work? I'm getting zero text in the chat: IslandWars.plugin.getServer().broadcast("Broadcasting!", "islandwars.broadcast");
Do you have that permission
I need to have that permission? I was just trying to broadcast to every player, and it's surprisingly involved
If that's all you want
I guess I'll just iterate over all players instead
use broadcastMessage
that is deprecated though
I guess the mcdev intellij plugin is trolling then. Ill just use broadcastMessage
thanks!
Also you can just do Bukkit.broadcastMessage
What is best way to edit inventory title without NMS is that possible? I´m using version of MC where u cant change inventory title with API. I need to display weight of the inventory next to title, or what would be best other way to do that?
Packets
is Bukkit the same as plugin.getServer?
yes
Everything in the server class is also available statically in Bukkit
so NMS fck, I was thinking if I can display next to inventory or somewhere... can I send 2 lines in action bar? 🤔
Not without resource pack magic
also you don't need NMS for packets, there are third party apis you can use
(Protocollib and PacketEvents)
Hello, I have a problem with my pl, when I enter the welcome message does not appear
public class PlayerListener implements Listener {
@EventHandler
public void onJoin(PlayerJoinEvent event) {
// Coordenadas al entrar : 0 0 0 0 0 world
Player player = event.getPlayer();
MainConfigManager mainConfigManager = plugin.getMainConfigManager();
if (mainConfigManager.isWelcomeMessageEnabled()) {
List<String> message = mainConfigManager.getWelcomeMessageMessage();
for (String m : message) {
player.sendMessage(MessageUtils.getColoredMessage(m.replace("%player%", player.getName())));
}
}
Location location = new Location(Bukkit.getWorld("world"),23.38,64.0,-10.2,0,0);
player.teleport(location);
}
}
And here is the config.yml
# Creado por mgt46
# Este plugin es exclusivo para el servidor TekoCraft Network
messages:
prevent_block_break: " &cNo puedes romper bloques aquí!"
command_with_console: " &cNo puedes ejecutar este comando desde la consola!"
insufficient_perms: " &cNo tienes permisos para ejecutar este comando!"
plugin_reloaded_successfully: " &2La configuración ha sido cargada correctamente!"
config:
welcome_message:
enabled: true
message:
- "&a&m "
- ""
- "&fBienvenido &2%player% &fa &5&lTeko&f&lCraft"
- "&fEsperemos que disfrutes de tu estancia"
- "&fDiscord: &btekocraft.com/discord"
- ""
- "&a&m " ```
My issue :
I have a SkullService class that creates a Custom Skull. This class works dependent on custom-heads.yml. Users enter the mcheads data they find on the internet into this file, and SkullService reads this data and creates the desired custom skull. If there is an typo in this file from which this class reads the data, it must delete the incorrect part. Additionally, this class must create custom-heads.yml in a specific format from the moment it is created. The format is attached. My problem is that it cannot create files in this format.
the file Format:
custom-heads:
example-head:
name: Football Player
minecraft-url: 5d62376f56fe8b56a019a5624e17efae73639c97e6e84d84786be269202ac21b
value: eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNWQ2MjM3NmY1NmZlOGI1NmEwMTlhNTYyNGUxN2VmYWU3MzYzOWM5N2U2ZTg0ZDg0Nzg2YmUyNjkyMDJhYzIxYiJ9fX0=
milenium-head:
name:
minecraft-url:
value:
erano-head: #for example erano-head should deleted
name:
minecraft-url:
Does anyone can help ?
register your event handler
Why can you not create files in that format
It is done, all the other events work (the file is a bit cut)
That's just standard YML
how can I do resource pack magic, then? I have no clue how to work with resourcpacks tbh. I will probably do NMS way than.. still need to learn that so thats sound like good start to learn that
did you do any debugging?
it's not that long
set section to null to remove entries
I'm following a tutorial and the person has the exact same code as me
i will share my code you guys can understand me
that is not called debugging
debugging is when you substitute random parts in your code for very simple bits until it works, then then you find out why the part you removed is not working
But couldnt u help me solve it please
@young knoll what do you mean ?
You could iterate through the structure and track which sections are proper and complete, then clear any extra sections (typos, extras, etc)
no you could just try that. if you have zero java knowledge you're not going to get far
I know some java
But idk why the person in the tuto works and mine no
i did
then you should be able to do it. 50% of the possibly problematic parts aren't even in your screenshot
How can I send my entire code?
?paste
https://paste.md-5.net/kawogewico.java Main file
https://paste.md-5.net/usabomibat.java Events file
https://paste.md-5.net/aruvizubaq.java ConfigManager file
https://paste.md-5.net/degojuxowa.makefile config.yml
ur config message enabled path is wrong
thus it defaults to false
Do you guys think it would be possible adding new biomes with unique terrain generation through plugins only without forking Spigot?
What do I change?
Considering you can already do that with resourcepacks, yes. It should be possible.
tysm broo
np
Do u know how to upload to git?
google ;d
Sooo, not sure where this is going wrong. It works in my testing.
you mean something like github or gitlab?
git is entirely local
on your machine
oh reall ?
you can add changes and then commit that
Doesn't matter if I do or don't. This code works.
how would i customize a player's name in a tablist? nms?
you only tested verifyExistingContent() method right ? @kind hatch
Player#setTabListName
Slightly modified, but yea.
jup
this is more important
bukkit or nms player?
i dont wanna delete existing custom-heads.yml
also which version?
So you want multiple head sections in one file?
bukkit
let me guess, 1.20?
not sure where exactly it was introduced
findOrCreateFile() is not working properly
https://paste.md-5.net/habinofaqo.java @kind hatch
can't even find it in the api https://hub.spigotmc.org/javadocs/bukkit/
package index
@kind hatch
that seems convoluted
each SkullService constructor call will iterate existing file
why not just
FIle customHeads = new File(plugin.getDataFolder(), "custom-heads.yml")
if (!customHeads.exists()) {
plugin.saveResource("xxxx")
}
load
i also absolutely can't get my skin changing to work, it's so annoying
ffs
i even send the respawn packet
it kinda uhm ... doesn't change it
I'm trying to change the DisplayName. GP-Name and TablistName
Because there will be a lot of yml content management code in skullService and I don't want everything to go wrong with the slightest mistake, so it is very important that the content is correct.
This just seems to work for me on my end.
thanks @kind hatch
setPlayerList name would only work for the name on tab
iirc
yeah
At least we know 1 method is working properly.
i managed to change the displayname using Player#setDisplayName and the GP-Name using NMS and Reflection
but the tablist name won't change fsr
¯_(ツ)_/¯
I'd of just split the files up if it were me that way individual files can be removed if need be, but to each their own.
i will do it also but in spigot its hard to do that
Not really. It's just file iteration.
Spigot supports yml out of the box and if that's the format you want to go with, it makes it really easy.
You also already have the core classes to do it.
FileConfiguration & YamlConfiguration
ok i will split
but find name for me 😄
doing abstraction is hard for files i readed this somewhere. you cannot do inheritance for each file type
for me i want to seperate them
why find by name
hi , trying to make something a bit hard and simple . so how i can make this command system way better , by making it not needing to register in plugin.yml
if you know the name you can just get it directly and check if exists
Honestly, the file name is irrelevant if you have a good file structure are only going to iterate over the entire subfolder.
At that point, the file contents are all that matters.
you mean seperating yml and Skull ?
Each skull would get its own file.
Frankly, I want to write something like SkullRepository and treat the file needed here as a database.
you need to look into command map
extend Command, use commandmap
Made a similar system at one point. (No file verification yet)
This seems logical, but what do you do when you do something related to these player heads, for example when it comes to deletion?
loosely coupling is more important.
I think the only mistake in the Skull Service I wrote is that I cannot establish the Repo-Service relationship.
It is better to depend on one file than to depend on multiple files.
I mean separating files is not exactly something that reduces coupling. Sometimes it will increases coupling
How o you get the displayed name of an item. I tried ItemMeta.getDisplayName() but it gave me this for an item that hasn't been renamed
If it doesn't have a custom name it doesn't technically have a name server side
do I just need to implement my own method for this
it feels like something that should definitely be there already but whatever
Just a translation key, which you can get via Material#getTranslationKey
yeah but Id just set it up to copy into your plugins folder
How bad is it to pass something an Object[] which have to be cast back to being int/doubles/strings etc instead of just like an actual int, double, string, etc.
i mean it's just annoying
I'm just looking into making some effects that can either be triggered by command or by clicking with a particular item, and those effects have various parameters that can be changed
ugh i feel like there's definitely a better way to do this
@rotund ravine would you be fine
if i explained it in more depth
and you gave me your thoughts on if there is a better way to do this that I'm missing?
the ultimate issue is i made all the effect classes implement a general interface class
which has a 'use' method
void use (Player p, Object[] parameters);
I mean instead do something like
interface Effect<P> {
use(Player p, P effectParams);
}
dejavu
Object[] param is just fucking terrible as you don't get compile time safety for the arguments you are passing
what would P effectParams be though
param typee
so like a class which has lists of different variables?
class FireEffect implements Effect<FireEffect.Params> {
record Params(int range) {}
public use(Player p, Params params) {}
}
now, if you have them in some Map<String, Effect>, you'll still not get complete type safety as you'll have to do some unchecked casts
what the fuck is that theme
but better than not knowing anything about the param order
hrm
Does anyone know how to check the blocks next to a player relative to their position, i am trying to make wallrunning and walljumping for an rpg
there are at least 20 threads on spigotmc about this
What I'm thinking of doing is having a general Params class which can be passed to any of the effects, and stores arrays of the params, and then just a list of an enum where the current enum is the paramtype for the current param slot
e.g. an effect which takes the params int double int int string
would have say five lists
one particle, empty
one double, with 1 entry
one int, with 3 entries
one string, with 1 entry
one material, empty
and then one of the enum lists
which would be INT, DOUBLE, INT, INT, STRING
@eternal night what do you think?
code it and see if you like it
these seems interesting, but i don't want to store the params in the effect class since you only call the class once to actually use the effect

what
make the type static then
but in the end, code up the system, implement the first couple effects and if it absolutely blows, revisit and try something else
Object[] is just annoying as fuck for both the effect and the caller.
If you want the range of a fireeffect, is that the first or second integer?
same goes for calling it
you are relying on a contract that cannot be enforced whatsoever
laughs at you in javascript

non overridable, not final method how
why??
why not final
chat support /n for line break?
no
dem how i shold add list string to placeholder api...
do you think more people are sitting or standing right now
in the whole world
Does laying down count as sitting?
not made for that
I saw some do like
%playertops_first%
%playertops_second%
etc
standing
China be dominating with their standing people
i need add %ch_history% bro
well that sucks then
Probably standing then
How can I create a sign in 1.20.4?
How have you tried
I'm trying sign.setLine() but its deprecated
I saw that
you saw what
setLine(10, "dummy")
Thank you
"may" "multiple" I'm pretty sure it's always exactly 2 smh
Did you say me?
my sines are triangular
According to what's written here, I should be able to use this, right?
Side side = Side.FRONT;
SignSide signSide = sign.getSide(side);
signSide.setLine(1, "a");```
is there an event when i hover a player with my crosshair?
No
something similiar? like player targeting or some shi like this?
ugh any idea why I cannot give myself an item with the material redstone_wire, only redstone being possible, but when I mine the redstone it's suddenly redstone_wire?
no, use PlayerMoveEvent (or run once per tick) and then use rayTraceEntities
what happens if you give yourself redstone_wire ? what happens if you give yourself redsone?
any error messages?
redstone wire is a block
if I give myself redstone_wire literally nothing happens
Not an item
it's the dust
that's waht I get when I give myself redstone
Redstone is the item form
why would there be two item IDs for the same thing
Ask Mojang
now I need to add some stupid workaround to my pretty neat inventory manager
BlockData#getPlacementMaterial
is that available on all blocks or only on some?
This is what happens when material isn’t separated :(
to be honest I can't remember fabric having that problem. The one thing that I remember annoying me from the very beginning is how bukkit material names are somehow mostly coherent with the in-game names and somehow partly so vastly diverging that it's actually annoying to find the material names at times
hey
We’ll get the split to ItemType and BlockType done eventually
How? I didn't understand what you were telling me to do
There's a PR open for it. There's nothing for you to do at this point.
I didn't run it because it says signSide.setLine() is deprecated
My guess is paper api
i feel like its returning null
guess ur location is borked
why?
If the location has no world it might Bork
i will test it now
okay it cannot be null so it ahs to be something else causing the error
What is ur code
im gonna debug now
no im fine
i promise a 15% success rate
getEyeHeight returns 1
yes
Obviously it returns 1
im just gonna player.getY + eyelocation
Don't overoptimize lel
but when i can why not?
Cause that's dumb
nah
Hey, does anyone know why my zombie is still pathfinding to players and villagers after I overwrite registering the goals and leave it empty?
https://pastes.dev/5xvADYTH3x
u haven't left anything empty
Because you are calling super.registerGoals
oh bruh i thought that replaced that method with this one but it does it the other way around
thanks
is the Y in f3 the location im on or in my feet?
so the block below me?
if I don't overwrite at all, it does the same as overwriting + super right? so I only need to overwrite what I want to change and don't call super in there
But not below ur feet
Yes just don't call super
Read up on what super does
alright I was scared i had to overwrite the 100 methods to make the zombie function normally
jan
i ran into an issue 😔
i can trace the block that above the player head with player.getY + eyelocationY. I want the air block tho the player looks at, at the x and z of the anchor block
what
i feel like raytrace is overkill for this, i have x and z and just need the y the player looks at, at x and z
The only 2 fluids in minecraft atm are water and lava, neither of which are air
Hey!
I'm coding a custom plugin for my Practice server, however while trying to prevent explosions from destroying white stained glass, I got it mostly working, but only half of the glass gets saved from the explosion, and the other half still gets blown up.
The code is the most basic way of doing this:
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
for (Block block : event.blockList()) {
if (block.getType() == Material.WHITE_STAINED_GLASS) {
event.blockList().remove(block);
}
}
}
Anybody aware of how can I fix this issue?
Isn’t that gonna throw a concurrent modification exception
probably
Nope, there are no errors
am a bit curious. made my own grappling hook system, and don't see a good way of handling fall damage negated only when used the grappling hook and not have an abusive way of using it ?
I tried hooking the cooldown system to it, but if the cooldown is lower than the leap it's a bit redundant
Could you elaborate a little?
event.blockList().removeIf(predicate)
is there a hook that gets called when water flushes away block like redstone? I'd have expected the blockBreakEvent to be called there, but that doesn't seem to be the case
BlockFromToEvent