#help-development
1 messages · Page 1221 of 1
But what happens is that if by some mistake the villager disappears or is not saved, it can happen, that's why I was thinking of respawning the villager, at least I think Shoopkeepers does that.
Are you trying to make the trades configurable in the config or smth
I still have no idea what exactly you're trying to do
then it would only make sense to kill them before
yes
and instead save locations and data in files
something like shoopkeepers
just that
Define a type of villager in the config and attach that type to the villager with PDC
on open you make sure it has the right trades
if you wanna respawn the villagers aftwr each restart what use is it to still acsess the old ones
kill the old ones onDisable
respawn them from data u have in files onEnable
Better to just not make them save in the first place
if you plan to do it that way
mhm
or can I make it so that when the server starts, it checks if the villager exists, if not, it spawns it and replaces it, but if it exists, it doesn't do anything to it
sure you could
but why would you
when theres so many better options
like what
mmm
and on enable spawn them
on chunk load* but ok
or well yh probably that but same thing either way
or just this
Which is better
ill try
tysm
oh yeah i dont need to save data
i can save it on the entity itself
i can modify the entity with a menu
I love when restarting something just randomly fixes a bug
real
no clue why my command suggestions weren't working and now they are
inside my StringPrompt, i have a condition so that if the player enters the thing i dont want em to enter i player#sendMessage them a message telling them whats wrong so that next time they enter it correctly
but the message never shows in my chat
classic pom
have 7 different projects using the same library
update the pom of them all
one of them randomly can't do it right
even though they're all using the same library, same version, same everything
because you put them in a chat between the server and the player
its like moving them into another room
they are technically getting it btw
you just don't have the conversation factory set to allow showing chat
general chat that is
by default when you initiate a conversation it is hidden, but still receiving it and when they exit conversation you should go back to see the chat including what was missed
declaration: package: org.bukkit.conversations, class: ConversationFactory
as you can see from this method, the default is true for it
so you need call this from the factory method and set it to false
i see, thank
i didnt even think to look at conversationfactory
i was trying to find it for conversation
I am a fan of the conversation api
the infamous repo I use for demonstrations uses it btw
it is one of the oldest api's in the entire API lmao
think its been there since like 1.2 or 1.3
and still many people don't know about it =/
so not only is it one of the oldest, but also the most under utilized or used in general lol
as you can see from the link above
I provide a way for the person to escape the conversation
in case they don't want to continue or something happens etc
well the api provides it, just I usually set it
let me know if you need more help or need something explained đ
currently writing code to save and load schematic files, so i can save the selected arena and load it into as many instances as needed
if i run into a roadblock ill ask
in case you need it
lets you manipulate NBT without having to use NMS for it
I am not the original author fyi, however I maintain a fork of it
i dont think ill need that
im just saving and loading schematics with worldedit
well never know, I even have a color compressor too doubt you will find that useful at all
Maps console color codes to hex and vice versa. Contribute to frostalf-games/ConsoleColors development by creating an account on GitHub.
the color compressor, good example in how to use bitshifting
Hey, is it possible using protocolLib to catch when a specific plugin send a message to a player or no ?
Without a hacky solution probably not. You could catch the message by its content though
depends on the kind of message you are referring to?
For exemple to translate pluginâs messages
when a plugin sends a player a chat message, it comes from the server so packet wise there isn't like information embedded in such a packet. You would have to intercept before it reached the network layer. If instead you are referring to plugin messaging then yes
there is even api for it
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/plugin/messaging/PluginMessageListener.html
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/plugin/messaging/PluginMessageRecipient.html
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/plugin/messaging/PluginMessageListenerRegistration.html
declaration: package: org.bukkit.plugin.messaging, interface: PluginMessageListener
declaration: package: org.bukkit.plugin.messaging, interface: PluginMessageRecipient
declaration: package: org.bukkit.plugin.messaging, class: PluginMessageListenerRegistration
is it possible to change the armor visible on a player without using protocol nonsense?
player.sendEquipmentChange
guys i think obaut smth
how you think use proxy in bukkit pointless?
minecraft itself is resource intensive with its single-threaded nature.
if i will add proxy this will do more harm than good.
how you think?
???
^
A proxy server runs independently of bukkit
It can be written from the ground up to leverage more threads
i say obaut proxy class generation
Sounds like your ambition is bigger than your knowledge & skill
maybe
i know how create proxy but
how i was say this be more harm then good
but idk
how you think?
it's not slang-
Region arenaRegion = data.getArenaRegion();
BlockArrayClipboard arenaClipboard = new BlockArrayClipboard(arenaRegion);
arenaClipboard.setOrigin(arenaRegion.getCenter().toBlockPoint());
File arenaRegionFile = new File(plugin.getDataFolder(), "schematics/arena_"+data.getArenaID()+"_region.schem");
try {
arenaRegionFile.createNewFile();
} catch (IOException e) {
throw new RuntimeException(e);
}
try (ClipboardWriter writer = BuiltInClipboardFormat.SPONGE_V3_SCHEMATIC.getWriter(new FileOutputStream(arenaRegionFile))) {
writer.write(arenaClipboard);
}
i am using FAWE
arenaRegion is not null, it is a selection of basically a square of blocks
when i load the schematic it is saving, no blocks show up
nothing in console
com.sk89q.worldedit.entity.Player actor = BukkitAdapter.adapt(player);
LocalSession localSession = plugin.sessionManager.get(actor);
Region arenaRegion;
World selectionWorld = localSession.getSelectionWorld();
try {
if (selectionWorld == null) throw new IncompleteRegionException();
arenaRegion = localSession.getSelection(selectionWorld);
} catch (IncompleteRegionException e) {
this is how im getting region
and are you pasting it
Hey i have some errors i cant use bungeecord chatcolro or TextComponent/ComponentBuilder do anyone have a fix for that?
Coding on Spigot 1.21.3 it says "The type net.md_5.bungee.api.ChatColor is not accessible"
sounds like youre missing a depend
bungee chat is in the api
the code is running perfectly and i can use everything from spigot only BungeeCord Doesnt Work! for weird reason even i have this spigot version too! Spigot/Spigot-API/target/spigot-api-1.21.3-R0.1-SNAPSHOT-shaded.jar
yes
show how
well i tried by copying saved schem file and using //schem command, that didnt work either btw
heres the code for pasting
File arenaRegionFile = new File(plugin.getDataFolder(), "schematics/arena_"+arenaId+"_region.schem");
if (!arenaRegionFile.exists()) {
return -1;
};
int gameId = registerNewGameId();
Clipboard clipboard;
ClipboardFormat format = ClipboardFormats.findByFile(arenaRegionFile);
try (ClipboardReader reader = format.getReader(new FileInputStream(arenaRegionFile))) {
clipboard = reader.read();
} catch (IOException e) {
throw new RuntimeException(e);
}
// create a new world, with void
World createdWorld = new WorldCreator("arena_"+arenaId+"_game_"+gameId).generator(new VoidChunkGenerator()).createWorld();
com.sk89q.worldedit.world.World arenaWorld = BukkitAdapter.adapt(createdWorld);
// paste the schematic into the world
try(EditSession editSession = WorldEdit.getInstance().newEditSession(arenaWorld)) {
Operation operation = new ClipboardHolder(clipboard)
.createPaste(editSession)
.to(BlockVector3.at(0,64,0))
.ignoreAirBlocks(true)
.copyBiomes(false)
.copyEntities(false)
.build();
Operations.complete(operation);
log("pasted schematic");
}
where does data#getArenaRegion come from?
You may also have to make an FEC
its an object where i stored the region showed previously
and then am using that object to create however many copies of the "game arena" i want
whats FEC
i really cant figure out whats wrong here, i copied the docs almost letter for letter
forwardextentcopy
so you're telling me i cant just give Region to a diff class so it can do what it wants with it
well every time i ask in their discord i get a reply exactly never
so i just dont bother anymore
If the people maintaining it don't know, what do you expect from us lol
i am sad
just bump your question and hope for a reply
ill just read FEC docs and go FUC myself
it works!
and my relative spawn position system also sent me to the correct team spawn definitely on the first try
what is the most efficient way to set the biome of the whole world? it is for a skyblock system
For a whole world whilst it is loaded? probably no good way, but you can do it for a large area with something like worldedit
if it's not loaded, you could just edit the region files
public class SingleBiomeProvider extends BiomeProvider {
private final Biome biome;
public SingleBiomeProvider(Biome biome) {
this.biome = biome;
}
@Override
public Biome getBiome(WorldInfo worldInfo, int x, int y, int z) {
return biome;
}
@Override
public List<Biome> getBiomes(WorldInfo worldInfo) {
return Collections.singletonList(biome);
}
}
Generate it with a biome provider yea ^
set the biome of the chunks they can access
im assuming your skyblock world isnt infinite and has a world border, so yeah just set the biome for all the possible chunks
of if you are open to a slightly less efficient solution, just change the biome of all the chunks around a player while they are on their island to the biome they have selected
how do i convert ticks to milliseconds then to seconds again? meaning 9 ticks is 0.45
and stuff like that
9*1/20
i wanna do it for an item cooldown
N*1/20
i was gonna do 1000 / N / 20
In java, make sure to mark 20 as a double literal
So, 20d
To do floating point division instead of integer division
Yea
W thanks
What would be the best way to wait?
?scheduling
The scheduler ^
What values can I set on a dolphin to make it so it doesn't need to come up for air (never need to breathe)
declaration: package: org.bukkit.entity, interface: LivingEntity
can you tell a player to act as if they are not underwater, ie get rid of the air bubbles over the hunger bar?
Why
System.out.println("Trading with "+recipe.getIngredients().get(0).getType() +(recipe.getIngredients().size()>1 ? " and a "+ recipe.getIngredients().get(1).getType(): "") + " ingredients will result in a "+recipe.getResult().getType());
shows the villager trade result as AIR?
same here
you could try and give them loads of air
ha fair lol
I hate maven
y
it's a bad system made by bad people
it's bad on purpose, specifically to spite me
one day I will lose it and make my own maven
with blackjack, and hookers
with enough plugins in <build> you can
and a shading strategy that can actually handle multiple shaded projects containing different versions of the same library
shot in the dark but what happens if that recipe is selected
it works as normal
the problem is with the entity
im making a villager editor and it shows the result as AIR
for some reason
How would I make a players name bold with scoreboard teams?
if you dont need the villager data, then have it one-way; serialize and store the GUI somehow
what if you made the editor in the villager's own ui but use the player's inv for controls
wym
ill show you how im doing it now
I'll do one more annoying nitpick
color("#FFA500")
You could just use Color.fromRGB(0xFFA500)
And I believe you can return the switch itself.
Inventory Creation:
https://paste.md-5.net/nawuqafuxi.java
Handling Inventory:
https://paste.md-5.net/sohijocoki.java
Thank you
anyway, why the trading result is giving me AIR
Hmmm
I can't see you doing anything wrong from this
You could try to create a minimal plugin to test this and if it does not work then report it as a bug
Not sure how Spigot deals with bugs that are not on latest version tho
okay
Hey there i purchased 2 plugins and didnt received them, it still gives me the Buy option, and ppl on their discord that i asked, said they had to wait months till they received anything
Hi, i need help me finish my projet plugin Minecraft conect game in the chat tiktok live
If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!
Probably should try and contact the plugin author
@pliant topaz i did
But can you set this to infinite?
could try -1 or int limit
they would need to live for 1,243 real life days before they have to get air
What if that's not enough :(((
Okay thank you though I'm going to try -1 right now
What's the method for when a name tag gets added to a mob?
Then constantly reapply it every 1243 days?
Even if the dolphin was at spawn and someone was always online at spawn that would still take 3 years
Totally just check every 1 second and reapply it for 3 seconds đđ»đ€ź
probably some interactevent
dk the exact name
maybe entityinteractevent or playerinteractevent
I thought there would be a OnEntityNameChange or something as there are similar commands to other interactions
I ended up having to use PlayerInteractEntity and just check if player was holding a name tag, then if name tag had a display name which felt weird
?pdc
https://paste.md-5.net/aroqotovis.java
Shouldn't .setVisible() make the armor stand invisible?
It isn't doing it for whatever reason
You should be using the consumer in the spawn method when modifying an entity that you want to spawn.
Also you shouldn't be spawning the armor stand in the constructor like that
https://paste.md-5.net/yokuharivo.java
Any better?
Still not using the spawn method consumer
How am I supposed to do it?
is there a way to save worlds in a custom folder instead of the server's root directory?
my plugin creates instances of game arenas and if someone has a lot of games going on all the world folders might spam the root directory and maybe even cause confusion
name teh world including a path
i zee
check your mojang mappings
you've probably used mojang mappings based build on a build which uses old spigot mappings
since 1.16 iirc, both spigot and paper switched to use mojang mappings and then at runtime servers will recompile those plugins to obfuscated mappings iirc
do you have NMS code in your plugin
do you use paperweight gradle plugin
i use maven
its done on intellij thru paper if you know what i mean
this has worked before, indentical version, indentical code
i use gradle all the time so i cant really help, but im like 99% sure it due to faulty mappings
do you run reobfJar task or smth like that on maven
nah
how do you compile your plugin
with maven
yeah, but with what task/runner
clean package
in gradlew you would use ./gradlew reobfJar to build the plugin with reobfuscated mappings
doesnt your output folder have two types of jar files compiled?
yes
which one do you use
have you tried running the second one?
i'm pretty sure you're building it wrong
in either case server should reobfuscate the plugin at runtime, but im not too sure
i haven't touched plugin development in like 1,5 year now
can't really help more soz
try asking in paper's discord
because im 99% you will get
?whereami
Is there an easier way to add newer materials with an older API version without having to do multi modular projects?
XMaterial
Or update
How fast is pdc?
2
Yeah Iâd say at least 2
Hashing?
PDC is just an NBT wrapper
Dont you have to hash the namespacedkey's string each time you access values in it
i've never realised that this such debated topic
I know
its like tabs vs spaces
I mean hashing is pretty quick
Itâs just maffs
I believe the bigger overhead would be deserializing/serializing the values
I mean, alright
uhh?
and i getting java.lang.ArrayIndexOutOfBoundsException
in here
java.lang.IndexOutOfBoundsException : Invalid array range: 0 to 0...
probs because new string[0] {} is legal if i had to guess? (highly unlikely)
I'm just trying to do custom enchants, this just seems weird to do:
(How they're stored in pdc)
enchantments: {
entity_damage_by_entity: {
ench_0: 1,
ench_1: 2
}
}
var events = pdc.get(EnchantmentManager.FRACTURED_ENCHANTMENTS, PersistentDataType.TAG_CONTAINER);
var enchantHandler = events.get(ENTITY_DAMAGE_BY_ENTITY_EVENT, PersistentDataType.TAG_CONTAINER);
if (enchantHandler != null)
{
for (NamespacedKey key : enchantHandler.getKeys())
{
CustomEnchantment.getByKey(key).invoke(event, pdc.get(key, PersistentDataType.INTEGER));
}
}
nuh
I wouldnât store them by events
compiler say ars[] not can be null
What's the showHelp method do
I would probably just pass all events to the enchantment and only act on the ones that are relevant
Huh?
private void showHelp(CommandSender sender) {
sender.sendMessage(ChatColor.GOLD + this.plugin.getDescription().getName() + ChatColor.RED + " v" +
this.plugin.getDescription().getVersion() + ChatColor.GOLD + " by " + ChatColor.DARK_PURPLE +
this.plugin.getDescription().getAuthors().get(0));
sender.sendMessage("");
sender.sendMessage("§6/joinmanager reload - пДŃДзагŃŃĐ·ĐžŃŃ ĐșĐŸĐœŃОгО.");
sender.sendMessage("§6/joinmanager clear <ĐœĐžĐș> - ĐŸŃĐžŃŃĐžŃŃ ĐžĐłŃĐŸĐșŃ ĐČŃĐ” ŃĐŸĐŸĐ±ŃĐ”ĐœĐžŃ.");
}
Why, it's easier to handle I can just iterate through each enchant for the event instead of getting all the enchantments individually
nvm that doesn't even use it
You can do the same if you just pass the event to all enchantments
And let them decide if they want to handle it
ChatColor and § dear lord
What line is it on?
Is it on the line you have highlighted?
Are you sure
Also, people really should look into making their onCommand methods static. Why use an object, I don't get it
womp womp
I've been sitting at my computer for six hours and I'm starting to get confused.
I thought you fixed it
yea
oh, okay
but anyway i getting many money:)
is there a way to make it so the player can see only the chunk that they are currently in?
lower server render distance to 1 maybe?
why do you want groups in essentials
doesnt work btw
anyway um what i actually wanna do is
how can i only render the chunks that I want to on the client's side?
like if i want the player to only see chunk 0,0 and 1,1 then thats the only ones that will load for the player
i want to make a spawn for each group like for red group spawn and for blue group spawn using essentialsX spawn but i cant really make a groups idk why
use luckperms for groups and ess probably provides a way to set a permission for spawns
bc afaik essx doesnt have a way to create groups inside of it
Esssentials doesn't handle permissions itself, rather just checks if someone has the permission. Historically it relied on group manager and used to distribute this permission plugin.
as for groups, the most it has is to handle the default permission levels the server can use
hey i am attempting to use NMS with ProtocolLib to manipulate chunk packets
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.21.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.21.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
this is my dependencies but I cant use stuff like LevelChunk and i cant figure out what i did wrong exactly
so permissions are setup according to these groups if I am not mistaken
but otherwise you need a permissions plugin
?nms iirc
you dont have the remapped mojang classifier
and you dont need the api dep if you have the non api one
?contribute
You can find information about contributing to Spigot at the following links:
https://www.spigotmc.org/wiki/cla/
https://www.spigotmc.org/wiki/guide-contributing-to-spigot/
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/README.md
https://hub.spigotmc.org/stash/projects/SPIGOT/repos/craftbukkit/browse/CONTRIBUTING.md
What's the problem with inheriting ItemStack?
how can I rotate a block display of any known transformation, by let's say 90 degrees yaw?
what Vector do you suggest I call this on?
the entities direction
will test that out
you can get its pitch/yaw from its Location Object. then setRotation for your new values using rotateAroundY
like this?
ah the angle is in radians
okay, besides that
no need to set it to the location as that is a clone. just use the dir you alreay modified
other than that, yes
...but isn't there a bunch of math to be done?
just Math.toRadians
actuallyu no
not even that
the vector is all you need
loc.getDirection().rotateAroundY(Math.otRadians(90))
I think it uses radians
Yea pretty certain that should use a sane unit
yep its just angle
ye
its radians
ye
I'll let you know how it goes
also, lynx
you can use here setThreadFactory(new io.netty.util.concurrent.DefaultThreadFactory("the whatever netty name"))
could you uh
tell what/who diff is?
I seem to be lost
John Diff
Well I presume you told me this because its on paper?
the setNameFormat thing is mojang code
we only add the warning handler
so we don't touch mojang code for no reason
well this just enables minor optimizations
doesn't change much besides that
well mojang doesn't seem to have read netty's src, nor would they care about some minor network optimizations
is there something I'm not noticing?
the entity doesn't rotate
you are rotating around yaw of 0
...nvm I was cancelling packets xd
welp doesn't work as intended
the entity will rotate around its actual location
and not middle of its rendered location
yes, do the rotation before you do a transformation
okay, will try that
The transformation shifts it from its origin, but its still AT its origin
nothing changed
these two have the same transformation
and only differ in the yaw input here
15 & 135
while I wanted to rotate the entity at its rendered location as if it were any normal entity
why can;t you use teh rotation of the transformation then?
cuz it's applied per: translation -> leftRot -> scale -> rightRot
transformation.getRightRotation().rotateY(rotation)
I mean I could try
Transformations are in object space
oh that works
thanks!
would the leftRotation be inaccurate cuz it's before scaling?
isn't Z for roll?
no, it all depends on the other rotations
is there a way to suppress the x joined server message that aint protocolib block packet?
In object space if you rotate x then z, then y, it will give a different orientation if you do y, x,z
Which is why it uses Quats
PlayerJoinEvent#setJoinMessage(null)
Sometimes params are nullable :p
okay, could this be somehow applied relative to the very center of the text display, instead of their (I think their positive Z axis)?
since well
it messes up their actual locations
ah nvm
I had the scale set too big
how do i verify if i found a bug in the world gen?
does Player#hidePlayer only apply for a single world or does it apply for all the worlds on the server (meaning if I go to nether and back will another player see me)?
all worlds
good
Try and reproduce it
i have a seed, a set of coordinates, and this screenshot. what i want to know is if a stronghold generating without libraries is a bug in the first place lol
probably not? stronghold generation is really scuffed
(on purpose)
according to the wiki there can be anywhere between 0 to 2 libraries per stronghold
how many chest corridors can their be emily
ive ran through almost 100 strongholds in the last 2 days, this is the first without exactly two libraries
how lucky
Make sure you are using java 21
and like, your build.gradle.kts or pom.xml is fine
?paste your whole pom.xml
done
now press the save button and send the url here
did you hit the refresh maven button
This?
Yeah there's a refresh button in there
reload all
I don't even know what that means
in this case it's like "I'm done for"
best shortcuts in intellij
ALT+INSERT
ALT+ENTER
CTRL+ALT+L
i've actually ditched lombok from my project due to how good code generation in intellij is

i've edited on code gen template so that it makes record style getters for me
blends with records well
fluent getters?
kinda, but without return this
i call fluent getters, getters which return itself
so idk
i mean setters not getters
ah setters
builder pattern in a nutshell
public void foo(Foo foo) {
this.foo = foo;
}
public Foo foo() {
return this.foo;
}
i made a template which generates getters/setters like this
kinda kotlin style if we dont take into account operator overloads there
Hello everyone, I have a question regarding a problem I had while trying to code my Minecraft plugin. I wanted to create a craft that allowed me to have the head of a player named "luck" but when I imported my plugin, the craft gave me the head of Alex. Can you help me resolve this problem please?
skins are not tied to usernames of the players since 1.7.10
the problem you were probably having is that you havent applied the skull metadata properly
When creating a kotlin project intellij directly creates a file at src/main/kotlin. My question if is a good pratice to go directly there or like create your artifacts folders
What
stupid generics with its type erasure, i've setup my class structure that works perfectly fine and compiles, but then due to type erasure Jackson cannot get all the fields through reflections
now i need to rollback all the changes
nice
you can technically handle the type erasure
technically i can just make a concrete type
but i have nested inheritance of generic types
so it would be quite pain to set up
let me translate from my native lang
You could roll your own type tokens I guess
But then I could do to solve this problem
fuck it, im just going to use @JsonIgnore to hide user password from serialization. its just that i wanted to return User<UserCredentials> object when i login which doenst provide a method to get the password via user.details().credentials().password()
Why not just use GSON with their type tokens
because this is a shitty spring boot project
Do they have their own serialisation or what
they use Jackson library to do that
but add like container beans and stuff like that on top of that
so you dont have to pass instances manually
it uses the power of R E F L E C T I O N S
declaration: package: org.bukkit.inventory.meta, interface: SkullMeta
you need to apply UserProfile
to the skull itemmeta
SkullMeta meta = (SkullMeta) itemStack.getItemMeta()
reflection đ€ź
half the times I use it are for injecting fucky shit into jar files that aren't mine
meta.setOwningPlayer(Bukkit.getOfflinePlayer("user"))
itemStack.setItemMeta(meta);
something like this should work
could not work tho as i havent used bukkit api in ages
so i dont remember exactly
I need to block all the villagers trades that give players emeralds
I try something like this
@EventHandler(priority = EventPriority.HIGH)
public void onVillagerAcquireTrade(VillagerAcquireTradeEvent event) {
// Controlliamo la ricetta del commercio
ItemStack[] sellItems = event.getRecipe().getSell();
for (ItemStack item : sellItems) {
if (item != null && item.getType() == Material.EMERALD) {
event.setCancelled(true);
Player player = event.getEntity().getWorld().getPlayers().get(0);
player.sendMessage("I villager non possono darti smeraldi!");
return;
}
}
}
Just make them yours
Trade acquisition is when they unlock a new one
e.g. they've leveled up and got a new trade
So that event won't encompass the villager's base trades
So how can I do this?
I have problem with reading java docs
The Villager object has a way to get/set its recipes, so you'd have to get a Villager somehow (probably in a player interact event) then update trades there
cba rebuilding obfuscated projects with a million deps
when I can just extend their classes and inject them in
Mixins :)
ok, I'll try thanks
Imagine having public projects
custom CraftCommandMap / CraftScheduler
Literally could not be me
sometimes you use bytebuddy and make your own "mixins"
Ok, I do this, but now I can't even open the trades gui
`java
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteractWithVillager(PlayerInteractEntityEvent event) {
if (event.getRightClicked() instanceof Villager) {
Player player = event.getPlayer();
Villager villager = (Villager) event.getRightClicked();
// Otteniamo le ricette del villager
for (MerchantRecipe recipe : villager.getRecipes()) {
// Controlliamo se uno degli oggetti venduti Ăš uno smeraldo
ItemStack sellItem = recipe.getResult();
if (sellItem != null && sellItem.getType() == Material.EMERALD) {
// Se il villager sta cercando di vendere uno smeraldo, annulliamo l'interazione
event.setCancelled(true);
player.closeInventory(); // Chiudi la GUI
player.sendMessage("Errore: i villager non possono darti smeraldi!");
return;
}
}
}
}`
Yeah cause you don't want to cancel and close it, you want to remove the recipes
no no, I just want to have my trades with the villagers, but If the villagers give me emeralds the trave have do be cancelled
Cancelled how? You want the trades to still exist in the villager UI, but you don't want the player to be able to use the trade?
Well, no, I'm asking a question đ It's okay
I just don't know what your end goal is
thanks for the help
You may be interested in https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/inventory/TradeSelectEvent.html instead
That you can cancel and it won't let the player select the trade
MerchantRecipe recipe = event.getMerchant().getRecipe(event.getIndex());
That will get you the recipe that was selected, you can check for emeralds there
thanks, do you have a tutorial for read in a easyest way the javadocs
I really have difficult understading it
The search bar in the top right goes a long way. You could search for whatever you need (in this case I just searched for "trade event" and it listed 3 different events). Then it's just a matter of reading what the documentation says about that type
If English isn't your first language, that might be more difficult, but that's why you can always ask questions here đ
I'm italian đźđč đ đ«
But my problem it's not reading english
I'm not good at writing but I know how to read it, I have understand problem with something like this
What about it is confusing?
I understand that "getMerchant()" returns me the merchant, but sometimes I don't know how to create a entire string with this
So you wouldn't know how to go from getMerchant() to something like event.getMerchant().getRecipe(event.getIndex())?
The return type in the Javadoc is clickable, so if you're unsure what all is part of Merchant, you can click it to open its page which will show you all of its methods. Or you can open your IDE, write event.getMerchant(). and see what your IDE suggests. It will show you all the methods available, and getRecipe() would have showed up (though maybe overwhelming because it also includes all the methods from its parent types, like Entity, LivingEntity, etc.)
But if I click on the Merchant Javadoc page, this top area gives me a good idea of what all is available to me
Ok, I try in this days to read it with these tips
It will take some getting used to, but you'll get there :) Super handy once you know how to navigate them
okok, thanks, but it's not all :D
This is my code now, but I have some problems that Idk how to fix
- When I click in the first slot of the trades with emeralds, even if the item that villager gives me isn't a emerald the plugin close the gui.
- When I select the trade from the left side list the plugin don't "see" this action
@EventHandler
public void onInventoryClick(InventoryClickEvent event) {
// Verifica che chi ha cliccato sia un giocatore e che l'inventario sia quello di un villager
if (event.getWhoClicked() instanceof Player && event.getInventory().getHolder() instanceof Villager) {
Player player = (Player) event.getWhoClicked();
Villager villager = (Villager) event.getInventory().getHolder();
// Verifica che non si tratti di uno spazio vuoto
if (event.getCurrentItem() != null && event.getCurrentItem().getType() != Material.AIR) {
int slot = event.getSlot();
// Verifica che l'indice del commercio sia valido
if (slot < 0 || slot >= villager.getRecipes().size()) {
return; // Se l'indice non Ăš valido, non fare nulla
}
// Ottieni la ricetta del commercio selezionato
MerchantRecipe selectedRecipe = villager.getRecipes().get(slot);
// Verifica se il commercio implica uno smeraldo come risultato
if (selectedRecipe != null && selectedRecipe.getResult().getType() == Material.EMERALD) {
// Se il commercio contiene smeraldi, blocca l'evento
event.setCancelled(true);
// Chiudi l'inventario e mostra un messaggio di errore
player.closeInventory();
player.sendMessage("Errore: Non puoi commerciare smeraldi con i villager!");
}
}
}
}
For your second point, that's where the TradeSelectEvent would come in handy
@EventHandler
private void onSelectTrade(TradeSelectEvent event) {
MerchantRecipe recipe = event.getMerchant().getRecipe(event.getIndex());
if (recipe != null && recipe.getResult().getType() == Material.EMERALD()) {
event.setCancelled(true);
}
}
To be fair, that's probably all you need. I'm not sure if the InventoryClickEvent you sent is necessary
The concept of the plugin is that I can't earn emeralds from all types of villagers
only this
I suppose you could do this as well. This might work?
@Override
private void onReceiveEmeralds(InventoryClickEvent event) {
Inventory inventory = event.getClickedInventory();
if (inventory == null || inventory.getType() != InventoryType.MERCHANT) {
return;
}
ItemStack itemStack = event.getCurrentItem();
if (itemStack == null || itemStack.getType() != Material.EMERALD) {
return;
}
if (event.getSlotType() == InventoryType.SlotType.RESULT) {
event.setCancelled(true);
}
}
A combination of both is probably a good idea
You shouldn't need to close the inventory either. That will just prevent players from picking up emeralds from the result slot of a villager trade
It works, thank for the support.
I really appreciate people who do their best to make people understand things even to those who know less than them, instead of disrespecting them
Glad it's working!
I am currently working on a MiniGame, to be more precise on the part where you define the region, currently I show the region with HAPPY_VILLAGER particles, but they are a bit mixed up and not so clear. Do you guys have any ideas for better particles?
marching ants sparkles?
what
dust with different colors?
or instead of a grid just do an outline
Yeah but how? The last time i did something like this was in the 1.8 xd
blockdisplay
Using solid colour player heads works well for that
Oh that is nice
tying to understand something - wouldnt using services require the presence of a plugin providing the interfaces to be implemented?
Yes
seems to me like import with extra steps tbh
like, you need to provide an interface in the first place to have it be implemented, and why would you implement another libraries interface?
like, is the usecase here to allow other plugins to overwrite it in case it stops working or something?
gets not updated and breaks coz of that
basically, im asking what the advantages of this are because 99% of the time its just register(this, this), no?
I mean bukkits service api is good when u dont know who the implementer is, for example there are a bizillion economy plugins
but having a common abstraction is just self explanatory why its nice
then again the service api considers priority iirc
so that might be what u're after perhaps?
well im not, ive been told to use services instead of imports directly :V
atm im trying to figure out how to do libraries/APIs 'properly'
i guess? I'm currently abstracting the things i expect to need in more than just one plugin into a library
ah mb thought u meant the servicesmanager api
well here's the thing, there are really no zero cost abstractions
tbh I don't think you need to over abstract your library api, but having interfaces may provide flexibility if u wna swap implementation, or change underlying class type etc, ofc in the real world when the api is written poorly (such that there is little flexibility) people turn to design patterns
cost mean anything, space, time, compilation-cost, runtime-cost
for example using interfaces means ur program is bound to use more invokeinterface jvm bytecode instructions which is negligibly slower, though it can sometimes be considered a cost (u obviously dont need to worry at all)
hold it. are you saying that cost incurs every time you call a method on that interface
or just on the load(Interface.class)
the cost is EXTREMELY NEGLIGIBLE
fair enough
mm. its so annoying theres like nothing i found on apis beyond frosthalfs git repo which... im too stupid to understand (how the heck does a separate pom.xml help)
well i suppose thats just classic modularization
like obv u can write everything in one module in ur buildsystem workspace
but like
ur ide wont even index what isnt needed if u separate it
so a mistake where the api calls/refers-to an implementation will never happen
or well almost never
would using modules mean you would have to do something extra when using a library? the goal for this is ease-of-use bc... well, text is small lol
im more interested in the implication you can generate the code fully, or just the public static methods + javadoc so you dont have to download the entire library
i mean yea
thats one other benefit
u can depend on just the api jar
and not the impl classes
ofc at runtime the impl classes must still be loaded, then whether thats through shading or class loading is for the application to decide I suppose
my go-to is provided coz then the code only needs to be present once lol
myeaa :)
do you have any resources on how to do that? modules, api jars, separating the interfaces from the implementation etc
probably gonna be a waste of time unless you have a reason to
imillusion yells at me otherwise
plus, similar to the sql thing, i want to know how it works, so i know how to use it later
yes but u dont always need to apply the best industry, cutting edge, meta practices
sometimes its fine to stick with the simpler, more banal option if the scope of the project allows you to
thats fair enough though
is there a way to move a player along a path at a set speed using velocity instead of teleporting them? I currently made a projectile using item displays that has gravity and drag, and I have all the velocities at every tick of the projectile using x = x0 + v0t + 0.5at^2, and I could just teleport a player using relative projectile flags, but it feels clunky. I tried setting the player velocity to that of the projectile at every tick, but it didnt work, and i suppose its because the player also has some inherent drag applied to them
I mean look into maven (or gradle) modules would be like the one tip (which is quite obvious :>)
yeah, i guess
Sadly you've basically understood it. Also teleporting every tick is just what moving is
yeah but the teleport packet is not the same as the player mov packet isnt it? which is how movement is smooth and teleportation isnt
im trying to make the player follow this
I think it is, movement is smooth because of velocity and client prediction
make player ride an invisible arrow maybe?
for it to have a custom projectile trajectory then i would have to teleport the arrow, and that'll kick any passengers off, unless i use the retain flag but that'll also feel clunky
is there any way to link entity with foreign key entity, while preserving the value of the foreign key in a field in spring boot data jpa/jakarta/hibernate:
this is how you usually do it (but then you have all the Facility entity data loaded, which sucks really)
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "facilityId", referencedColumnName = "id")
private Facility facility;
but i woud love to have something like:
@OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "facilityId", referencedColumnName = "id")
private Integer facilityId;
so that the entity loading will only happen when its was explicitly stated
idk sounds simple, because using a projectile you can have it follow the exact same arc, and not have to simulate the velocity.
Tried setting fetch to lazy?
or am I missing understanding what you want to do?
can you publish a .jar to maven local?
well never consciously used it, thus the question
Have you unconsciously used it
Well since you are using gradle just run publishToMavenLocal
ooh and just like chat said?
You don't need to add maven local specifically
You don't need repositories there ^^
cuz it ain't on the web
You have the project, no?
I mean it is on github
??
Just jitpack it or something?
but downloading the rep, updating and compiling it each time seems excessive
I also love censoring versions
it'd be unholy to mention it here
Version 69
probably something about paper sex
thsi would just fetch all user data on the first call
it will still try to fetch all the data
instead of just id
is there any way to apply jspecify@NullMarked on a method parameter?
it would be neat that i could declare that implementation object in the calling method parameter should contain non null values
hmm
i just tried recently and it didnt worked for some odd reason
well this is great, now i can reuse the same interface
but with different implementation goals for nullability
neat
non null applies for nullable value of reference
i want to check for nullability of object fields
not the object reference itself is nullable
object fields?
what
Did you mean like "null marked here means that the passed type needs to be null marked"?
class foo {
Integer bar;
}
baz(@NullMarked foo buzz) {}
Which, das impossible
i would love to have a way to define whether Integer bar in the class is nullable or not depending on the method parameter type is annotated with @NullMarked or not
How would a method parameter have any affect on a classes field types nullability
What
that isn't even OOP
@NullMarked is merely just a hint, it doesnt check aynthing at runtime
Well yea but why would there be a hint about something on a method param??
lets say for example i have an interface, and two impls
one impl might return null
and one might not
Yea, then the interface's method return type is nullable
marking @NullMarked an interface in method parameter would inform the typechecker that in this parameter it expects and implementation with nonnullable types
That makes 0 sense
the caller to such a method would have 0 ability to consistently provide "an implementation that yields non-null"
what you want is a sub-interface the just re-defines the methods as non-null
and have your specific implementations implement that
i guess it just impossible from java's standpoint to implement that
it is impossible in every sane type system
in typescript you can override types from nullable to nonnull
in a method param?
yes
but isnt it an interface to make it exchangeable? so your usecase has to work for the broadest set of return values. and that includes null values, regardless of the implementation
Types which are globally included in TypeScript
if one implementation may return null, then all of them could and your implementation has to check for null values anyways for that one implementation that does return null values
Yea but that is a new type
not really, its a hint just like jspecify
no
Constructs a type consisting of all properties of Type set to required.
a type
typescript is not strictly typed, i guess you can interpet that as a new type
but that doesnt change the fact that you cant do something like this on java, unless you use bytecode generation or some sort with annotations
yes indeed
java does not have such dynamic typing mostly because it is statically typed
too bad
ÂŻ_(ă)_/ÂŻ
well i have love and hate relationship with that
I'd argue you are probably doing something wrong when you have a type that may return null and a subtype that then doesn't
yes I thought that was what you wanted
that sounds more like you'd want a type that does know of the field bar in the first place, and one that does
nah i want to declare a foreign key constraint without fetching all the user data
something like
@ForeignKey(maps = "me.dovias.foo.Bar.id")
private Integer barId;
@JoinColumn returns whole object reference im not using anyways
probably im just lazy to implement a separate record or a class to handle PATCH operations for rest api
thought i can reuse the same classes that i use for PUT operations (because they're pretty much compatible apart from nullability checks) by just using nullability hints
basically i had very similar records:
import org.jspecify.annotations.NullMarked;
@NullMarked
public record PublicationDetails(long ownerId, long borrowerId, boolean available, PublicationData data) {
}
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
@NullMarked
public record PublicationPatchDetails(long ownerId, @Nullable Long borrowerId, @Nullable Boolean available, @Nullable PublicationData data) {
}
but i guess maybe its even better to keep it separate, no need to autobox primitives for no reason
I built a github project with Grade and the build is successful, but I can't find the jar anywhere even though I set it to Desktop. Can someone assist me?
where do I find that?
how do i do that?
tasks.register<Copy>("copyJar") {
from(tasks.jar) // or tasks.shadowJar if you use shadow
into("your target directory")
dependsOn(tasks.build)
}
would that go in build.gradle.kts?
Yep
thanks
Rad stop infecting people with your copy tasks
:p
no :3
K work time bai
can you make me a coffee too
correct copy task 
copy task your coffee into my hands
Is there a way to detect if a player is trying to open the debug screen?
The F3+S, I'm not sure what it's called exactly
no
why when i join to game or respawn i not getting effects
in debug mode i get but in minecraft not all
potion effect
paste the entire code đ
That doesn't make sense what even is debug mode
jvm debug mode
Not sure if you're doing that, but I don't think you should reuse the PotionEffect object
Apparently I wasnât supposed to go in today so no I cannot
lmao wat
Weekdays arenât that busy and they already had another barista scheduled
They just transitioned from the GM handling the schedule to the AM so thatâs probably why we were both scheduled today
I could make you a nice cup of Java tomorrow though
I'll take a Kotlin
:)
There's a couple coffee places around here with Java in the name, should pull that one sometime
Anyone have useful links about chunk generators?
?jd-s
More like example snippets
I looked through the impl in stash a little bit... not enough to get a handle tho kek
Maybe I just go back to doing that
What about them do you want to know?
I guess just how they work? Trying to integrate my wfc with them because I wrote it so inefficiently, it crashes the server every time lol
For example, generateSurface, I wasn't able to tell if I should be extending worldInfo somewhere or just making it up on the spot... though again, I didn't really look hard enough
worldinfo is provided to you by the server tho?
^^
Oh is it now
You get it as a method param
hold on a sec
WorldInfo info = Bukkit.getWorld("");
wow didn't realize this worked
no...
I wouldn't
what the hell are you doing lol
I literally just wrote that cuz I wanted to see if it worked kek
sure.. but in no situation you would actually do that
Mk lol
and before you get any funny ideas, that does not imply that all WorldInfos are Worlds
@emily
yeah?
You asked what I was trying to do
with the worldinfo
Oh just that I need it as a param in #generateSurface
Are making a chunk generator or trying to call one
yes but you don't call that method yourself
Making one
the server calls the method
Then why are you calling the method
I guess I thought I had to
I would show the wfc impl but it is abysmal to say the least
Hi there, is there any reason for Spigot to save/load the tickCount value into the entity nbt data? As it causes some entity behavior inconsistencies between Spigot and Vanilla
What's the behaviour difference
Because it's used by Entity#getTicksLived()
Wouldn't be very accurate if it were reset to 0 every time the entity gets unloaded
Here's the patch if you want to discard it in a fork
Guys, if a have a class Game would it be considered better classes to make its constructor create and start the game or would it be better to make a static method startGame and make it return a Game instance?
I made a GameInstanceFactory
and then you have an initialize method that starts the actual game and registers it to the instance manager, thus it starts ticking
GameInstanceFactory that would have only the non-static initialize method
?
For example, Withers lost their targets and run out of cage after chunk unloading and reload
I don't see why that NBT tag would cause that to happen?
Probably this part, vanilla parity is always weird =-=
Guys, is there a way to freeze person who is gliding in place? Iirc canceling move event causes it to be jittery
What's the name of that app that checks plugins for viruses? Author gave a link to the repository here a long time ago.
It's OpticFusions app called Spigot AntiMalware
2024 isn't long ago
what does it check for exactly
does it find me messing with inventory events so i have my fast item handling when you install my plugin
you're alive?
no
â ïž
I'm not a sum?
u still alive?
damn right I am more than ever
How so?
fair
how do I stop player from interacting with the item they have in hand? (eating, charging a bow, aiming a trident, etc.) I want to know how to cancel the thing their doing at any time (as if they scrolled away from the held item), NOT cancel the actual usage of them.
declaration: package: org.bukkit.event.player, class: PlayerItemHeldEvent
idk woman i feel pretty dead inside the longer im awake :V
sleep
why the first dont get error but the second yes?
because DataInteger does not extend DataObject<Integer> or something
hard to tell without knowing your full code
?paste
i found this, but i wonder why that doesn't work the first đ€
Yeahhhh... casting with generics is a bundle of fun
Reject generics
Embrace java 1.4
đ đ đ đ de generify spigot
Biome#valueOf will be removed in 1.22, what is the alternative?
Registry.BIOME.get
ty :)
Will it? That's news to me lol

didnt you know?
fucking troll
Nuhuh
smh choco
Someone knows why ProtocolLib(packets) entities keep disappearing when
- Player world change
- Player dies
- Player goes too much far
And how to fix it?
Whats an efficient way to do that?
I mean, It is not recommended to do a spawn entity loop every 20 ticks right?
Hey, does anyone know how to achieve a natural mob spawn? use case, I am reworking an existing plugin of mine that used to replace existing mobs with custom mobs. However this has some pitfalls as you might imagine. Any possiblity you can think of to manipulate this differently? Without NMS
wdym natural mob spawn
So long story short, I want to control the mobs that are being spawned without using specific locations
And the way I achieved that earlier is listen for the CreateSpawnEvent
just replace the mobs you want with CreatureSpawnEvent?
Yeah that's what I did before
A detailed explanation of how the spawn mechanic works
That sounds very much like reinventing the water :p
So replace of the spawned mobs is still a good solution
alright
i love reinventing water
Yeah okay, then CreatureSpawnEvent it is
It's what I used to do, it's what I'll use again
I think this is just 2 water molecules instead of Water 2
It's just that replacing the existing mobs has casued some difficulties. For example worldguard. I didn't want to integrate with worldguard directly, but apparently, when I Just replace them upon spawn, I thought that worldguard would take priority on this and cancel even before my plugin can process it.
Many people have reported that mobs can still spawn in protected regions
It should if your event is set to ignoreCancelled
And is a higher priority than worldguards
Yeah which I thought worldguard would do
Just put the event in MONITOR and check if it is cancelled, no?
Not sure if I changed the priority of my event listener, so might be
but would I still need to check for isCancelled in my listener? or can I assume that the listener never got triggered in the first place?
It wonât be triggered
For some reason worldguards listener is on high
So youâll have to use highest
So the higher the priority, the later it gets processed?
Yes
Alright, got that. Okay, that would have been a very ez fix
Thank you for the feedback
Anyway, would this work?
I had tried that before myself, the challenge is to spawn it on a more natural base, instead of behind you. The "Custom spawn" mechanic as I called it, I was about to deprecate it the revamped version
I donât think the games spawning logic is super complicated
So itâs probably not that hard to remake
Use rng and spawn in a random place around the player
Yeah, but I don't have an idea on what is the general algorith around it, plus for example you got the caves etc. You would need to check also on the Y axis for empty spaces
Idk too, but i think chatgpt can help u with that
Yeah, possibly, I honnestly had lots of solutioning discussions with chat gpt already
we're talking about nights, not minutes
or even hours
xd
Probably Minecraft uses rng and cuboid
A example: every 20 ticks theres a 1/100 chance to spawn a zombie, if it spawns, it checks every block arround player to find a proper place to spawn it
There's some #isSolid method somewhere you can use
I think that's what it's called anyway
(for checking the block below your location)
For each spawning cycle, attempts are made to spawn packs of mobs per each eligible chunk. An eligible chunk is determined by the same check for which chunks are random ticked. A random location in the chunk is chosen to be the center point of the pack. The X and Z coordinates are chosen completely at random, while the Y coordinate is a random coordinate between the block above the highest block in the column and -64. This makes lower maximum elevations a strong way to increase spawn rates and is the reason why perimeters are so effective. If the block in which a pack spawn occurs is an opaque full cube, further pack spawn attempts are canceled. There are a maximum of 3 pack spawn attempts per mob category.
Before the attempt to spawn each mob in the pack, the position is offset by ±5 (triangular distribution) on the X and Z axes. Thus, while the pack can be spread out up to 40 blocks from the initial position for a pack size of 4, it's much more likely they'll be closer to the center. Approximately 85% of spawns are within 5 blocks of the pack center, and 99% within 10 blocks of the center. Mobs spawn with the lowest part of their body inside this area.
Yeah, that would work