#help-development
1 messages · Page 927 of 1
should just happen once?
or does it always happen
hm? I thought it just logged them when they were downloaded
oh well 🤷♂️
xd
can I set the texture for a snowball in 1.12.2?
I can't use a method with durability since they don't have it.
No
You'll have to change all snowballs
or implement your own item the spawns a projectile
well, except for the snowball, there is no entity/item/object in 1.12.2 that has a custom texture and can be thrown?
Eyes of ender maybe :p That's probably it
Listen for right click and spawn a snowball
already
change the itemstack it contains to your item with a different model
there is no .setItem method
in 1.12.2
Try nms
Do you know a specific method?
It's probably obfuscated so, unsure
There's a method somewhere in EntitySnowball that will accept an NMS ItemStack
EntitySnowball nmsSnowball = ((CraftSnowball) bukkitSnowball).getHandle();
nmsSnowball.setItem(CraftItemStack.asNMSCopy(new ItemStack(Material.DIAMOND_SWORD)));
It won't be setItem() though. It'll be some obfuscated method name
I see b(ItemStack) in some old patches, so start there I suppose
Or it might even be mapped to setItem() already
.a(itemStack, int f)
Can you say what the f means?
Should just accept an ItemStack, no boolean
If you open the source for EntityProjectileThrowable you'll probably find the method you're looking for
Unless that didn't exist in 1.12. idk. We're talking about like 5 y/o software
7 years old even!
older than some of the spigot staff .....
older than all of the paper staff, that's for sure
there is no EntityProjectileThrowable class
only EntityProjectile
in 1.12.2
Hi, how can I query as an event when several signs have been placed next to each other and then drop? BlockBreak event is only triggered for the first sign
package dev.bsbedwars.it.scoreboard;
import dev.bsbedwars.it.utils.ChatUtils;
import fr.mrmicky.fastboard.FastBoard;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@Getter
public class PlayerScoreboard {
private static final List<PlayerScoreboard> players = new ArrayList<>();
private final Player player;
private final FastBoard scoreboard;
public PlayerScoreboard(Player player) {
this.player = player;
this.scoreboard = new FastBoard(player);
players.add(this);
}
public void update(List<String> lines) {
scoreboard.updateLines(lines);
}
public void update(String... lines) {
scoreboard.updateLines(lines);
}
public void updateTitle(String title) {
scoreboard.updateTitle(title);
}
public static PlayerScoreboard getOrCreate(Player player) {
return players.stream().filter(playerScoreboard -> playerScoreboard.getPlayer() == player).findFirst().orElse(new PlayerScoreboard(player));
}
}
why the scoreboard is not visible at the second time you have do the update?
Static list and methods -> dedicated class
This is static abuse
Hard player references are memory leak prone and will cause problems in your current impl ;)
I think the physics event is fired for subsequently destroyed blocks
Hey there, i would highly recommend using a Map for this. A List is not suitable for this use case.
And your List (or preferably Map) should be in its own singleton class. Call it PlayerScoreboardManager or similar.
ok
I would add: if you want to keep a Player to PlayerScoreboard relationship, you could use a WeakMap whose keys are weakly referenced, ensuring your Player and PlayerScoreboard objects are freed correctly
Does anyone know about ormlite and if this would work? I've set the type to SERIALIZABLE
@DatabaseField(columnName = "item", dataType = com.j256.ormlite.field.DataType.SERIALIZABLE)
private ItemStack item;
ItemStack is not implementing the Serializable interface, it does implement ConfigurationSerializable which differs entirely. So I don't think this would work as expected.
ggs, ill make a work around, thank you for the quick answer
I just opened intellij and got a error i have not had before with this.getServer().getPluginManager().registerEvents(new Events(this), this); when in Events i have ``` private static PalassetCustom plugin;
public Events(PalassetCustom plugin) {
this.plugin = plugin;
}```
It says Cannot access caneless.com.PalassetCustom
Firstly, make your plugin field non-static
Does someone know why it says that it have may read the config wrong?
public void onEnable() {
plugin = this;
getCommand("kit").setExecutor(new KitCommand());
config.options().copyDefaults(true);
saveConfig();
}
what is ItemSnowball.class for?
Where do you initialize config?
FileConfiguration config = getConfig();
I am trying to set the texture of a thrown snowball or replace it with another object on 1.12.2
Thats only a declaration, not an initialization
Doesnt exist
I dont then, this is all i have with the config, the rest is just getConfig....
it exists in the api for 1.12.2
If you never initialize a field, then its always gonna be null.
Calling a method on null will throw a NullpointerException
ItemSnowball snowball = new ItemSnowball();
snowball.b(CraftItemStack.asNMSCopy(new ItemStack(Material.SNOW_BALL, 1, (short) 1)));
EntitySnowball nmsSnowball = ((CraftSnowball) p.launchProjectile(Snowball.class)).getHandle();
nmsSnowball.shooter = ((CraftPlayer) p).getHandle();
nmsSnowball.setLocation(p.getEyeLocation().getX(), p.getEyeLocation().getY(), p.getEyeLocation().getZ(), 0.0F, 0.0F);;
nmsSnowball.getBukkitEntity().setVelocity(p.getLocation().getDirection().multiply(1));
p.getWorld().spawnParticle(Particle.PORTAL, p.getLocation(), 20);
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 5, 255));``` my code is more like random guessing to implement a snowball throw with a texture or a snowball throw with another object displayed
I dont understand how i do initialize the config
You can only add potion effects to LivingEntities.
Changing a snowballs item was only introduced in later versions of the game.
so your using config and getConfig
why
once again its time to learn java
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
as for the texture? right now I'm using durability, which won't work like that. The snowball has no durability.
so this feature from 1.9 is useless
Changing a snowball projectiles item was added in 1.14
is it possible to set a texture?
Sure. In 1.14+
I love saying the same thing 3 times over
Why? what prevents from setting the texture
The fact it’s not an api method pre 1.14 probably
This is not a projectile change.
The capabilities of both the client and the server
So then just go make a mod pack kek
You could try a workaround, make the projectile invisible (not through potion effects) and mount it with an item that has a custom damage model.
Sure
Just search for playSound in the javadocs
can I use packets?
To achieve what?
How to get if item was burnt by lava? EntityCombustEvent doesn't work
in order to replace the snowball display with another item, maybe this was added to the api in 1.14.+ but there is a way to do this through packets
I don’t remember if there’s a player drop item event of sorts, if there is you’d probably have to get the item as it’s dropped and figure a way to make it not burn. But that’s just if you want to get the item and make it not disappear ig, there’s more you could do with it before it burns.
If it can’t burn, then you do whatever it is you wanted to do and then manually remove the item I suppose
oh, it's too difficult... To follow every dropped item, and wait until it burn/despawn/fall down
Ok let me explain again:
The minecraft client, has no way of handling or displaying a snowball with a different texture in those old versions.
You can send him all the infos you want, but the client will simply not understand it.
ok. I understood
So I need an entity to play it, Is it possible to play it for everyone on the server within the same world (spawn)? and have a fade out effect based on thier location like how its done with the note block, cd player? xD
No it’s rather just detection (the event/listener) and doing what you want before the item is burned, this all happens in your code as soon as the item is dropped meaning it won’t burn until your process is finished, or if you make the item unburnable
You dont need one
but what do you mean by "mount it"
Can’t you like broadcast sounds to all online players?
You can add a passenger to entities
Really easily too?
I've always used it as static
Yeah but "This function will fail silently if Entity or Sound are null."
Cool. Now dont.
Search for other methods
The entity only needs to be the players currently online no?
No entity needed
Entity as in the one hearing the sound ie: player
that's it then
will that have a fade out effect? xD
or will it be the same volume no matter where you are
Same I think with that method
You’re playing the sound to the world
I think…
The location Param probably refers to a player location I’d assume
i already have code for this java EntityItem item = new EntityItem( ((CraftWorld) e.getWorld()).getHandle(), e.getLocation().getX(), e.getLocation().getY(), e.getLocation().getZ(), CraftItemStack.asNMSCopy(new org.bukkit.inventory.ItemStack(Material.SEA_LANTERN))); item.setNoGravity(true); for (Player player : Bukkit.getOnlinePlayers()) { ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutSpawnEntity(item, 2)); ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityMetadata(item.getId(), item.getDataWatcher(), true)); ((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutEntityVelocity(item)); } item.startRiding(entity);
So perhaps run a for loop to get all online players locations
Or is it something else?
That kind of sucks xD
I could calculate the volume based on player distance from the location
that's one way
and for each entity play the sound with different volume
based on distance
Yeah but if you play sounds for each player location, I wonder for the players near each other would get a duplicated sound effect
Yeah... so you DO NEED an entity at the end. I'll test it
I made it private PalassetCustom plugin; and still get the message Cannot access caneless.com.PalassetCustom
Idk if smile says no, then there’s probably a reason. Ie: a workaround
Lets see both classes
?paste
I’m not as versed in spigot / java as they are so perhaps just try a bunch of different processes and figure out a solid way to do what you’re trying to do
7smile7 Is that what you mean by passengers?
Main filehttps://sourceb.in/hUR8X4IvWP
Events filehttps://sourceb.in/6ylKrmeTRV
You are mixing real and virtual entities again. This wont work properly.
I think the universal practice for event listeners is one per class
You didnt import your class
then how do I add a passenger for snowball
What is that supposed to mean?
#addPassenger instead of #startRiding?
You can take that literal. You did not import your class.
Ahh, now i understand
But it shows up as it is impoprted
Cuz file of main is in caneless.com
If its packet based, send packets. If it actually exists, call the mount class
Ah if they are in the same package then you might have a different problem.
What IDE are you using, and whats your package manager?
?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
intellij
And its a maven project, right?
Ye
i found PacketPlayOutMount packet
Then invalidate caches and restart.
Click shift twice -> search for "invalidate ..."
Double shift gave m,e this error https://sourceb.in/ibmirFpUgI
Try it out. Dont remember anything from 1.12 🤷
What happens if you run mvn clean
Also: I think your IDE is completely broken and needs a clean reinstall.
The code was fine yesterday
If it throws an exceptio when you press shortcuts
That's not a good look for the ide kek
I have literally never seen this problem. How did you nuke your ide like that?
You should feel good, you broke the best ide
export settings and reinstall, usually fixes problems
I was wrong, there is Sound.Emitter, @lost matrix am I going in the right direction with this? xD Need to play a sound at a specific location and based on that location, players far away won't be able to hear it as loud as players that are closer to the emitter?
Sorry for tagging you smile
Location based sound basically?
With real world properties of how sound works? kek
I didn't do anything
When i woke today my pc was off
And it worked 2 days ago
DIdn't use ide yesterday
To be fair for what you said you want it to do... I'd just play around with everything
It doesn't seem horribly complex
public void playSomeSound(Location location) {
World world = location.getWorld();
Sound sound = Sound.ENTITY_GENERIC_EXPLODE;
float volume = 1.25F; // How far away the sound can be heard
float pitch = 1.0F; // How high or low the sound is
world.playSound(location, sound, volume, pitch);
}
Hey btw, volume in chunks?
Ok thanks!
Trying that
will try it
If that doesn't work, send me a screenshot of the start of you main class.
Np!
lmk on the volume measurements, I actually never figured...
IntelliJ cache sometimes (everytime) breaks everything.
@lost matrix I'm getting lost in this minigame project D:
Jep, minigames are hard to get right
Absolutely D;
I'm still working on the sumo mingame too
I'm not sure how I want to handle arenas
Tell me what are you struggling with
Figuring out what I need to do now haha
I have a little bit of experience with minigames (made 10 minigames in 3 months)
What have you done?
sec let me gather
k
https://paste.md-5.net/hovigadeza.java
https://paste.md-5.net/oxoxaxonex.java
https://paste.md-5.net/zobetarofo.cs
https://paste.md-5.net/awazowehit.java
https://paste.md-5.net/vokibosixu.java
Alright this is the foundation. The sumo minigame class is probably only about 20-25% done I'd say? The logic for the actual "sumo" battle is only decided by a 50/50 math.random right now haha
I've been quite busy the past couple days with birthday and what not so I haven't been able to work as much on it... now coming back to it after like 3 days has me quite lost
works xD
That's an ugly ass sound sir
Gotcha haha
yo
anybody here ever coded with anyone in intelliJ?
live the same project at the same time
live session
Sure, CodeWithMe is decent.
doesn't it require some kind of license?
Yea
so is it paid?
codewithme is icky
I think its in the ultimate version. If you are a student then you get it for free.
no plugins no nun
If you've got intelliJ then I think it comes with it no?
It works and it's surprising that it does but it doesn't work well
I downloaded intellij when it was for free
Hmm
so no license
I downloaded CodeTogether
but my friend can only edit on a web browser
ew
ye
That one on the other hand is quite buggy
well are there any alternatives?
What do you use?
(if anything)
You can always just connect with Parsec
what's that?
not Intellij specific but it should work
git
is there a real need for you to be coding concurently?
@spring horizon any thoughts? Or have you dismissed it haha
what benefits would you get that you would not get while sharing screen during pair programming
2 people working on the same project means more can get done
LMAOOOOO
@worthy yarrow when working with stuff like that
always use teams
doesn't matter if it's 1v1
do a team
in reality I don't really think this will be the case, unless two people can perfectly work together with minimal communication where as I wouldnt see the need of pair programming anyways
in case you want to change it to 2v2, you just have to create a team of two.
it's easier to maintain.
Sometimes its a case of:
If one violin can play a piece in 3 minutes, then 3 violins surely will be able to play it in 1 minute.
^
Depends on the tasks to be done.
Ideally you'd have separation of concerns and no one has to work concurrently on the same part of the plugin
Hmm I got suggested that, I just don't understand why "sumo" normalized as a 1v1 game, would ever need to be expanded. But you're right for other minigames, I could instead use teams for the rest of minigame impl. So basically just convert to a teams system and just modify matchups based on the minigame yeah?
in which case you could just use git and branches
Whatever way you do it, I don't think it matters as long as all of the party is contributing?
Don't do this, or every time you'll obtain this, it'll recreate the arraylist:
public List<Event> getActiveEvents(MinigameType minigameType) {
return minigameEvents.getOrDefault(minigameType, new ArrayList<>());
}
Instead, do this, this will add the created list to the map if it doesn't exist.
public List<Event> getActiveEvents(MinigameType minigameType) {
return minigameEvents.computeIfAbsent(minigameType, ignored -> new ArrayList<>());
}
Yup!
It's easier to maintain.
hm I wonder how well multi block change packets scale
If you cache it and use to all players, it'd be good.
If you create the packet per player, depends on how many blocks are you editing.
What do you want to do?
I've played with this before
Just like
farming stuff
estimating ~100 ish blocks per chunk
uh
Ah that's a good catch, thank you!
I guess
np!
is it possible to make the passenger follow the snowball?
how can I share a github project with someone?
How should I go about the teams system? Probably some util used by all minigames?
wdym?
The way I currently do teams in my minigames is that each minigame has its own team impl
Which is created from a team template defined in the map data (spawn positions etc)
Ah ok
Yea, that's how it should be done.
Well that brings me to the next concern, I'm not too sure on how to handle the arenas... creation, handling of the areas (for sumo such as getting knocked off the platform), spawn locations, etc
I'd honestly have started with that before writing the whole game
kek
This is my first time trying to develop a minigame haha so ig I'll learn the hard way
hm 256 crops per chunk
yea, it's not bad
but why packets?
per-player thing and swm is overengineering it
Oh!
guy wants per-player crops but players to be able to see each other
I already use swm for islands
I imagine that you are using ProtocolLib, right?
Best way to handle uneven amount of players, toss a random bye each round til only 2 players remain?
wouldnt you just use a queue
maybe
I can do this with raw nms though
and then always grab first 2 people
Yea
I've done full client-sided chunks but it was a while ago
But it's easier to use ProtocolLib for intercerpting the block place and remove.
It's a chat prompt minigame such as you get the prompt, join, wait til minimum players join / start timer runs out, then battle it out and try to win.
probably lacking a bit of context, but how would a queue not work here in the case of uneven players?
I don't want a queue is the context lol
overengineer time
meh
why? isn't the datastructure made for these situations?
Not currently, it's only like 20% written
public class MatchPlayers {
private final UUID player1UUID;
private final UUID player2UUID;
private boolean isMatchEnded;
public MatchPlayers(UUID player1UUID, UUID player2UUID) {
this.player1UUID = player1UUID;
this.player2UUID = player2UUID;
}
public UUID getPlayer1UUID(){
return this.player1UUID;
}
public UUID getPlayer2UUID(){
return this.player2UUID;
}
public boolean isMatchEnded() {
return isMatchEnded;
}
public void endMatch() {
isMatchEnded = true;
}
}
This is the current impl to pair players for matches
ew
So in arguments of a command, is /gamemode c the c in this argument 1?
yes
Hey I'm pretty sure you said it was a valid way of pairing players :P, that's not to say you didn't mention how much you don't like it however
args[0] tho
mutable object icky
Make team objects
That's the plan
args[0] would be the command right?
So the command is not the first thing in the array?
Would 2 lists of uuid's be fine?
how to shut down the system when the value taken from the section is empty and because of this the value is taken from the config with the default value from intelji resource (config.yml)
So in /gamemode c the arg c would be 0?
Why 2 lists?
I don't like that this system ignores checks like section.isInt and get default value from intelju resurce
class SumoTeam {
Collection<UUID> players
Color color
Location spawnPoint
int capacity
}
type deal
All my homies use audiences
gotcha
yeah
💀
class SumoTeams {
Collection<SumoTeam> teams
int getTotalCapacity() -> ...
void addPlayer(Player)
void removePlayer(Player)
boolean isPlayer(Player)
}
idk
somn like that
shitty code so you can't copypaste
in the args array 'c' would have index 0

That was a trick message I in fact hate anything paper related you pass my vibe check
Thank you haha

I wasn't trying to lol, this is a learning project.
Teleport entityitem to the snowball's position
@echo basalt why do you use linked lists and linked hash maps over just the plain arraylist and hashmap
I can't do it in any way
oh yeah it is
Well
but I see you abuse linkedlist
By insertion order
i do that too LMAO
I don't?
I use it like 10% of the time
oh what
https://sourceb.in/LG3nlAXCw7 Then why whenever i do gamemode s nothing happens?
Whenever I see your code I never see ArrayList
this only applies to sections with numbers
You never see list in the first place
I guess it's just the way I see the data
Ok I'm buggin then
You dont need to do that.
I'd argue that obsessing over LinkedList vs ArrayList is in part premature optimization
LinkedList is always worse, in any scenario.
*Except one very specific
make sure to create your array lists with an initial capacity of Integer.MAX_LIMIT to avoid resizing
I love when my list allocates 2 billion bytes (or something, idk)
and what can I do besides this to achieve the expected result?
Just mount the entity on your snowball
But entityitem won't move together with a snowball
If you mount it, it will
Its used once and Im the only one who will ever touch the code, plus, the code is only 12 lines long and this is at the top.:
Its not accessible via a method either so its never used.
because the length of the array is not 0
the if(args.length==0) is false
Then how i make it not false
Cuz i do /gamemode s
well the argument array has length 1 because it has 1 argument
but that argument has index 0
ArrayList is almost better in all cases, I don't see why would you prefer LinkedList over ArrayList
if you wanna know more you should look into Java OOP
So i check if args.length is 1 and i do args[0] to get the gamemode then
yeah
LinkedList is memory management type shit.
Doesn't make sense, but thanks
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if cmd.getLabel() == "Testcommand" {
}``` is it getlabel getname or what is it to check which command was executed
#getName() returns the name of the command.
#getLabel() returns the alias of the command that resolves to #getName()
ok thx
What would i do in this situation then? if(args.length == 1) { if(args[0] == "gi" || args[0] == "give") {
Is it args[1] ==
It /eco give 'player' 'amount'
then give is argument 0
Player player = (Player) sender;```
why is the player inbetween ()?
Casting
I will send my whole code for it, cuz right now it does nothing https://sourceb.in/m5XCqGTUQa
CommandSender != Player
However it can be converted to one by casting.
so you would then have something like
if(args.length==3) {
string command = args[0];
string playerName = args[1];
string amount = args[2];
// do something based on these variables
}
but CommandSender could be Player, so
keep in mind that you mind not get a player returned in Bukkit#getPlayer() if the name is wrong
I think you have to mention that if he understands what he's doing
I know, but should i use .equals instead of ==?
https://pastes.dev/8g1Rqa999U Swords fly randomly in the sky
Hello guys, i m passing hours struggling with the lootables
LootContext.Builder builder = new LootContext.Builder(location)
.lootedEntity(entity)
.luck(1)
.killer(player)
.lootingModifier(0);
player.sendMessage("builder : " + builder);
LootContext lootContext = builder.build();
player.sendMessage("lootContext : " + lootContext);
Inventory lootInventory = Bukkit.createInventory(player, 27, "Loot chest");
player.sendMessage("lootInventory : " + lootInventory);
try {
lootTable.fillInventory(lootInventory, new Random(), lootContext);
player.openInventory(lootInventory);
} catch (IllegalArgumentException e) {
player.sendMessage("error inventory fill : " + e.getMessage());
}
The error : Missing parameters
I assume it comes from the lootcontext
Is anyone have an idea ? i ve worked for hours on it ...
Is PDC per block? What if I have a chest with size 2 blocks? is PDC transferred via Chest or Block? I guess it's a Chest?
It's connected to the tile entity
Purrrfect
is location null? that's the only required parameter
Apparently not ahaha
I am under paper btw
Could not pass event PlayerInteractEntityEvent to LootableEntity v1.0-SNAPSHOT
java.lang.IllegalArgumentException: Missing required parameters: [<parameter minecraft:direct_killer_entity>, <parameter minecraft:block_entity>, <parameter minecraft:block_state>, <parameter minecraft:explosion_radius>]
at net.minecraft.world.level.storage.loot.LootParams$Builder.create(LootParams.java:132) ~[?:?]
at org.bukkit.craftbukkit.v1_20_R1.CraftLootTable.convertContext(CraftLootTable.java:127) ~[paper-1.20.jar:git-Paper-17]
the function is triggered by a rightclick event
Hello ! Do you know why when i break a chest that call an inventoryCloseEvent ?
if needed thats my code
if(event.getInventory().getLocation().getBlock().getBlockData() == null &&
event.getInventory().getLocation().getBlock() ==null &&
((Directional) event.getInventory().getLocation().getBlock().getBlockData()).getFacing() == null)return;
BlockFace chestFacing = ((Directional) event.getInventory().getLocation().getBlock().getBlockData()).getFacing(); <---- LINE OF THE ERROR
Block signBlock = event.getInventory().getLocation().getBlock().getRelative(chestFacing);
if(signBlock.getType() == Material.OAK_WALL_SIGN) {
signBlock.setType(Material.OAK_WALL_SIGN);
Directional directionalData = (Directional) signBlock.getBlockData();
directionalData.setFacing(chestFacing);
signBlock.setBlockData(directionalData);
signBlock.getState().update();
Sign sign = (Sign) signBlock.getState();
Error
craftblockdata cant be cast to directional
Yes I see this bur why it's happen when I break a chest
the event is InventoryCloseEvent not BreakBlocksEvent
It would only ever call an InventoryCloseEvent if someone had the chest inventory open while the block was broken
I'm alone on the server
?paste show more code
Yeah, something is calling that method for some reason
You want to see more of my code ?
just paste the whole class
Actually BBE isn't relevant, stacktrace says it's a close inventory event lol
Pls allocate more variables at the beginning, like the Inventory, Location and Block.
And use guard clauses:
if(!condition) {
return;
}
It makes your code way cleaner
if (!cond) return; imo is hotter
imo its not 🙂
fair enough
But im ok with calling that a preference
what is the condition ?
any condition necessary
Whatever you want it to be
exemple ? plz
Ig it depends on how you want to handle those cases
instead of doing ```java
if (cond) {
// a bunch of stuff
// many lines
// like a lot of lines
}
```java
if (!cond) return;
// a bunch of stuff
// not indented anymore (we don't need to)```
if (!cond)
{
return;
}```
yes x) but what is condition
ha ! had smile stop typing for a moment
Instead of checking to see IF something... check to see IF it's not something
Inventory inventory = event.getInventory();
Location location = inventory.getLocation();
Block block = location.getBlock();
if(block == null) {
return;
}
BlockData blockData = block.getBlockData();
if(!(blockdata instanceof Directional)) {
return;
}
Directional directionalData = (Directional) blockData;
... and so on
If it's not what you want, then its a guard tool
ahhhhhhhh ok, I don't thinking about this ! thx you
if it's what you want then just add the guards to ensure it does what you want
[21:03:33 ERROR] [STDERR]: Initializing Legacy Material Support. Unless you have legacy plugins and/or data this is a bug!
what are legacy plugins ?
Plugins written before 1.13 and which didnt specify a version in their plugin.yml
no ideas guys ?
How add libs in eclipse now ? I have no classes when i import 1.20* plugin but 1.16 works
Java problem ?
?bootstrap
Bootstrap Jar
The main spigot-1.18.jar is now a bootstrap jar which contains all libraries. You cannot directly depend on this jar. You should depend on Spigot/Spigot-API/target/spigot-api-1.18-R0.1-SNAPSHOT-shaded.jar, or the entire contents of the bundler directory from your server, or use a dependency manager such as Maven or Gradle to handle this automatically.
Please read the release notes for further information: https://www.spigotmc.org/threads/9-years-of-spigotmc-spigot-bungeecord-1-18-1-18-1-release.534760/#post-4305163
if i have a block and i want to do stuff when a player right clicks it, is the best way to store data for that block to store it in a config file then check the clicked location and get data like that?
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
?pdc
ok thanks
how can i change level of a potion?
as in potion itemstack?
what's this shit lol
how use
yes
i have an itemstack and its a potion
and i want to change its level
declaration: package: org.bukkit.inventory.meta, interface: PotionMeta
Get the effect and then increment the level and set it back
tried to find here
hey
dont see any methods to do that
hi
to set a level
only to change potion effect type
Yeah that's what you want to do
but it doesnt change the level
only the type of the potion
declaration: package: org.bukkit.inventory.meta, interface: PotionMeta
Add the new effect
yeah but then i have to remove the base effect
and i only see a method to remove custom effects
Why do you need to remove the base effect
cause i dont want to duplicate the effects
i want only one potion effect
of the given type
When many chunks are loaded, memory easily becomes full. I only let it restart until the end of the day
?
But if the world is only reset on restarts, then there is no way of a memory leak developing.
And simply setting the world to be non-persistent doesnt create a memory leak on its own.
Does setting a world to non-persistent prevent chunk unloading?
Or does it simply reset the chunk once unloaded?
do PersistentDataHolders save data over a server restart
yes hence the name presistent
EphemeralDataHolder
That's just Metadatable 
Memory leaks included!
was about to say
It’s a feature
thats why: https://imgur.com/a/z14IRMB
then just check and change the base type
idk if im missing smthn but how do i get the persistentdataholder for a block? in this guide https://www.spigotmc.org/threads/a-guide-to-1-14-persistentdataholder-api.371200/ it only shows how to do it for a sign, not a generic block variable
you cannot
?blockpdc
Learn about CustomBlockData here:
https://www.spigotmc.org/threads/custom-block-data-persistentdatacontainer-for-blocks.512422/
you need a third party library for this yea ^
☠️
howwwwwwwwwwwwwwww
worse than death sentence
thats what im asking about
i see you can set the data to a block
PersistentDataContainer customBlockData = new CustomBlockData(block, Satiscraft.getPlugin());
NamespacedKey key = new NamespacedKey(Satiscraft.getPlugin(), "test");
customBlockData.set(key, PersistentDataType.STRING, "TEST");```
but then how am i supose to get the data if the block variable doesnt have a method to do that?
Just new CustomBlockData
and then get the value
take a look at the example plugin
I’m sort of lazy anybody know of any good path finding dependencies?
Pathetic
Like ones that are good enough to solve a maze
Trying to avoid that because it takes an extreme amount of time
It is not good practice when it comes to stuff like
That’s like saying make your own spigot jar it’s not worth it because there’s hundreds of them already
There are plenty of guides for A*
At first I thought you were calling them pathetic
Hey, should I store inventories as an encoded string, byte array or something else?
in a database
I'm using MongoDB rn is any of these blob?
Well personally I assume array and then serialise all items in the inventory to a byte[]
For MongoDB you shouldnt manually serialize objects. Make sure your codec can serialize your data and then simply use a MongoCollection<YourObject>.
That being said: You can just use a String if you must.
That is smart
What is "my codec" in this situation, is it built in my IDE or MongoDB, And the datatype inside the MongoCollection can only be a datatype I can normally use too right? Or can I somehow save stuff like a file or like these weird characters
codec is short for "encoder and decoder". You can store anything into MongoDB as long as your codec knows how to serialize it.
You could for example create a custom PlayerData class and store it directly in a MongoCollection<PlayerData> with the UUID being your document ID.
How are you serializing your ItemStack?
Right now I'm doing it like this in the players PDC
ByteArrayOutputStream io = new ByteArrayOutputStream();
BukkitObjectOutputStream os = new BukkitObjectOutputStream(io);
for (Map.Entry<Integer, ItemStack> entry : items.entrySet()) {
os.writeInt(entry.getKey());
os.writeObject(entry.getValue());
}
os.flush();
byte[] rawData = io.toByteArray();
String encodedData = Base64.getEncoder().encodeToString(rawData);
data.set(new NamespacedKey(CustomItems.getINSTANCE(), "PlayerVault" + number), PersistentDataType.STRING, encodedData);
os.close();```
Alright then lets not make this too complicated. Simply store your "encodedData" in MondoDB as it is.
Alright thank you 👍
I love making a parser for this
yo obis
I need some help
private BlockData blockData;
public ChunkBlock(Material material, BlockData blockData){
this.material = material;
this.blockData = blockData;
}
public Material getMaterial() {
return material;
}
public BlockData getBlockData() {
return blockData;
}```
What's not working?
1 sec I gotta post the rest
public ChunkBlock getChunkBlock(int intX, int blockZ, int y, World w) {
int cX = this.chunkX;
int cZ = this.chunkZ;
Bukkit.getConsoleSender().sendMessage(String.valueOf(cX));
Bukkit.getConsoleSender().sendMessage(String.valueOf(cZ));
Bukkit.getConsoleSender().sendMessage(String.valueOf(coordX));
Bukkit.getConsoleSender().sendMessage(String.valueOf(coordZ));
int x = this.coordX + intX;
int z = this.coordZ + blockZ;
Bukkit.getConsoleSender().sendMessage(String.valueOf(x));
Bukkit.getConsoleSender().sendMessage(String.valueOf(z));
int xTra = x / 16;
int zTra = z / 16;
Bukkit.getConsoleSender().sendMessage(String.valueOf(xTra));
Bukkit.getConsoleSender().sendMessage(String.valueOf(zTra));
cX = cX + xTra;
cZ = cZ + zTra;
Bukkit.getConsoleSender().sendMessage(String.valueOf(cX));
Bukkit.getConsoleSender().sendMessage(String.valueOf(cZ));
x = x - xTra;
z = z - zTra;
ChunkSnapshot CS = w.getChunkAt(cX,cZ).getChunkSnapshot();
BlockData bd = CS.getBlockData(x,y,z);
Material bm = CS.getBlockType(x,y,z);
return new ChunkBlock(bm, bd);
}```
player.sendMessage("CX - " + cc.getChunkX());
player.sendMessage("CZ - " + cc.getChunkZ());
player.sendMessage("EX - " + cc.getCoordX());
player.sendMessage("EY - " + cc.getCoordY());
player.sendMessage("EZ - " + cc.getCoordZ());
ChunkSnapshot csA = cc.getChunkSnapshot(17, 17, player.getWorld());
player.sendMessage("R: " + csA.getX() + " - " + csA.getZ());
ChunkSnapshot csA2 = cc.getChunkSnapshot(-17, -17, player.getWorld());
player.sendMessage("R: " + csA2.getX() + " - " + csA2.getZ());```
Test command ^^^
In a nutshell, when 17,17 was added, It was supposed to return chunk 3, -13, when I was at chunk 2, -12
What does this say:
Bukkit.getConsoleSender().sendMessage(String.valueOf(xTra));
Bukkit.getConsoleSender().sendMessage(String.valueOf(zTra));
0 or 1 ?
Ok I need help still
For?
wait nvm again I think I got it
Bahahah
int[][] matrix = new int[16][16];
Gotcha thanks
Wait a sec
How do I store a chunk snapshot to an XZPair in a hashmap and access it later?
Why don't you get the location and get the chunksnapshot from it?
Or, why do you need to save a x z pair ?
I want to check MANY blocks inside a snapshot
So ?
Getting the chunk and chunk snapshot every time is a huge performance loss
Please tell me exactly what you want to do?
Scan a radius of 600 blocks for certain materials
I would use a table from guava. It maps two keys to a value.
So a Table<Integer, Integer, ChunkSnapshot>
What for?
Is guava standard jdk?
no
Limiting blocks in a region
guava is provided by spigot
spigot-api
Ok
And transitively spigot as well
Guys why is sharing nms like on github not allowed but it's allowed via build tools
I'm just confused
Its a grey zone, you are practically changing nms on your local machine by building with BuildTools.
Publishing shanged code on the other hand is not allowed.
it downloads minecraft, decompiles it, patches it then builds bukkit, craftbukkit and spigot
is it possible to make a slime sit inside of a block? like how armorstand.setMarker works?
quick question, I am having some issues with GSON and NMS honestly no idea why its trying to do this class but I will get to that when I do lol anyway I am getting this error Caused by: java.lang.IllegalArgumentException: Class net.minecraft.core.BlockPosition declares multiple JSON fields named 'a'; conflict is caused by fields net.minecraft.core.BlockPosition#a and net.minecraft.core.BaseBlockPosition#a
// gson builder
private static final Gson gson = new GsonBuilder()
.disableHtmlEscaping()
.setPrettyPrinting()
.serializeNulls()
.excludeFieldsWithModifiers(Modifier.VOLATILE)
.create();
1.20.4 btw
ideally I wanna avoid adding Modifier.FINAL even though it will likely fix it
oml ik why its trying to serialize it... its trying to serialize the entire world
Ik the likely cause it doesn't Realllllyyyy support java 9+ from what I can find
gson should definitely work with java 9+
What are you trying to serialize?
Its a general issue now with gson in java 17 trying to serialize stuff that it cant I think I know what to do
but also I am changing what caused that issue
It was attempting to serialize org.bukkit.World when it really shouldn't
.excludeFieldsWithModifiers(Modifier.VOLATILE)

Are you trying to serialize a Location?
it was for an underlying issue that I am trying to fix
not it was like an entire world
I don't need that to be done lol
Ok but was that a transitive serialization or did you just throw a World at it and hoped for the best
Its something from a while ago that I forgot I still had
I used to have .excludeFieldsWithoutExposeAnnotation() so it was mostly ignored
but I am trying to not require that lol
If you dont want fields to be serialized, then simply use the transient keyword
private transient World world;
mhm
Alternatively you can just register a type adapter for worlds, which saves a UUID and deserializes it back to a World
Might actually do that tbh
Can cause problems when worlds arent loaded while deserializing
wanting to remove this because I am using gson to serialize classes for custom NBT data it was working with @Expose ofc but I wanted to add other stuff like ItemStack and stuff so I can't rely on @Expose
Btw a few days ago we came up with a pretty neat type adapter to serialize ConfigurationSerializable objects like ItemStacks, Locations, etc
#help-development message
actually gonna add that lol thanks for that
Just remember that you need to register the ItemStack one as a TypeHierarchyAdapter instead.
Because the CraftItemStack impl is cursed
Does this adapter serialize the whole itemstack?
And not just what craft itemstack does with serialization?
ic, thank you
I'm establishing a connection do my sqlite .db-file using DriverManager#getConnection. Is it better practice to use try-with-resources (to close the connection every time I'm done with my request) every time I want to access the DB or can I keep the connection instance stored in my Database-object?
just keep it stored
if you ever made a connection for the first time on main thread you'll know how slow it is
there is no connection for sqlite db's as they are files. That being said yes you should close the resource since it is a file if you are done with it.
ah sqlite
^
does some1 know how i can setup "fallback values" in hibernate, so that a column has some default values as well as if there is an error gathering values it can return back to default?
How much difference in performance do yaml/json files, sqlite-files and a mysql database server provide?
mysql database server is just that, it is its own server and therefore its an entire application that takes care of a lot of stuff that is normally issues with flat files. Json, yaml, are flat file human readable files. Sqlite is a file but its binary storage since you can't just simply view that data by opening the file. MySQL if we compare all these is the most optimal and none of the rest will come close to it. Next is the Sqlite with its disadvantage being if its size becomes too large it starts to decrease in performance. Then you have Json/Yaml which also suffer the same thing as Sqlite but at smaller sizes then sqlite.
I see so on a larger scale, sqlite has the same problems as flat files, did I get that right?
should use Yaml files mainly for config files or small amount of data storage. Json itself isn't meant as a storage medium and its format is best use for transmitting data
yes
understandable
When trying to store items in a db (or rather ItemStack-Arrays, for storing an Inventory), would it make sense to store a singular item as a json string?
Bc i have no idea how else I would be storing and much less retrieving the data of an ItemStack
if you are going to store a lot of data and also need that data everywhere else, best to go with MySQL or Mongo however I don't have any personal experience with mongo but I have heard and been told it is pretty good too depending on what you are doing or how you are using the data.
You could serialize and store as a BLOB if you wanted
BLOB = Binary Large Object
I want to try creating a QoL plugin for smaller and bigger servers. So: scalable for big servers but easily understandable and usable for smaller servers
or you can serialize and store that serialization as a string
Okay, I'll be reading up on that then
yeah, that's what I intended. Bc rn I'm storing in inventories in json
Just an Array of json-objects (item) in a json file. And I want to migrate this into sqlite
or a database
I personally store such things using base64
quality of life
so that I avoid storing weird characters
how would that work?
that's the reason i'm using sqlite rn, I (at least rn) do not want to make small having to setup a mysql server
and then you just ensure to decode it. Sometimes weird characters which you can occasionally get from serializing can cause issues if you are not expecting them, especially in java 😛
So I would serialize to a string (and convert to a byte array) and then store a Base64-String?
yep
but you don't need to go to string from serializing though
its serialize - > byte - > base64
then you have a string
But the serializing will return a string first anyway
or am i misunderstanding? lol
rn, gson
then I guess if you want to deal with strings like that you could just encode the strings in your case
what would the optimal way for doing this?
I'm a lil perfectionist lmao
And I feel like, optimazation-whise, my plugin is horrible, but I'm still studying, so ig that's fine
if i want to make an event system (player events only) that the player can listen for events ingame directly and execute 'activators', something like skript but ingame not a text-based language, do i have to make a listener for each player event possible and save all the changeable fields possible in a custom class, for example PlayerJoinEvent has join message that can be changed, or is there a better and more optimized way to do it?
it'd take like 2 hours just writing everything for like 13+ events and marking everything as cancelable or not cancelable and the changeable args and the immutable args
no like, i want to know if there's a way to tell the difference between fields that can be changed and fields that cant
using code
how?
alr
shouldn't worry about this. You should make your plugin according to the design you have in mind. Then afterwards test and profile it
only profiling and testing will tell you what is or is not an issue
huh, interesting
yeah that makes sense
if you are going to use the bytes, you need to use setBinaryStream
of preparedstatement
then you use a bytearrayinputstream
Ahhhhhh
and feed the bytes into that
i'm gonna try that out rq
the other method you could use is setBytes of preparedstatement
but I think the the binarystream is a bit better as its less prone to messing up
pSstatement.setBinaryStream(2, new ByteArrayInputStream(bytes),bytes.length);
pSstatement.setBytes(2,bytes);
just a note that setBinaryStream is not implemented in some drivers (SQLite for example)
Okay interesting, so I just set setBytes or setBinaryStream and it writes a string (or varchar, whatever) to the db, cool
So I can skip the final String base64String = new String(base64Bytes, STandardCharsets.UTF_8);
cool
tbh it seems to work for me, I'm using SQLite
i like saving it as string
not sure which data type would require to save as bytes instead
it's easier for a human to read
some people might wanna search the database themselves
that's cool
definitely worth it
there isn't one
i have a bedwars_time table that tracks weekly monthly
last time since purge
i have no idea about h2
but this is how i did it
pretty much what i did
you can do a repeating task that repeats every day
make the first be at 0
so if he restarts it'll always trigger
task = Bukkit.getScheduler().runTaskTimer(getEngine().getPlugin(), () -> getDatabase().getPlayerData().checkPurge(), 0, 7200);
actually it's uhm 1 hour?
wait it's minutes wth
6 mins
i forgot a 0
Alright so.... It would seem after a whole bunch of investigation from me and a lot of other people, we seem to have found the issue of what https://hub.spigotmc.org/jira/plugins/servlet/mobile#issue/SPIGOT-7475
does - and potentially also a quick easy fix for it. Now whom can I bother with all the information pertaining to it who can hopefully also make a PR or something?
Perfect, can I take this into your dm's?
Yes
This is currently not fixed. I don't want to send in issues/discord threads from other discords here but it seems the issue has likely since been found
It just takes someone to implement the fix and quite frankly I don't know anything about anything in that regard.
Yes. But the plugin is not at fault, it's because of a spigot implementation.
i can either link to the thread where a bunch of people smarter than me are discussing it, or i can try to regurgitate the conclusions and hope i get them right
But as far as i understand, this would be a working fix to the issue
One second, i may have sent the wrong issur
I can link you pretty much all the info necessary to reproduce, everything found in testing plus the details about how to likely fix it - i just don't think i am allowed to link to these things here
I'm just saying - this goes for anyone who'd be willing to look into it and make a pr with my info. (I really desperately need this fixed lol)
i apologize if this is a stupid question, but is there a way i can cancel a BukkitRunnable task with an event?
i wanna cancel this task when the player dies
im new to the spigot api
you're new to java
move task count field above run()
change runtasklater to runtaskEvery
or how it was named
it takes plugin, startafter, every
when using hibernate, imagine i have an enum save it with hibernate and later change something in the enum (might remove constants) how do i handle illegalargumentexceptions from hibernate (if it tries to find an enum that alr got deleted)?
i think he left the server
all the analysis for nought
if you're bored wink wink
@inner mulch try to ask chatgpt, there's no way they didn't account for removal
i never used hibernate so i can't help
but it sounds like a basic feature
i asked chatgpt and he tells me to use a converter which consists of switch statements to convert everything to an enum to my liking
but switch statements arent so great to say the least
i alr googled and they said the same
thats where chatgpt got it from it seems
and personally this solution is not it, I'd rather have a fallback value that it changes to when its null or an exception is thrown
ORDINAL works, but it doesnt fallback to what i want it just fallsback to whatever get into place there
and if ordinal number is too high and i remove to many it breaks as well
suprised hibernate doesn't have a proper way to handle this
they have to have a proper way
be4 using hibernate this could easily be fixed by catching illegalargumentexception and then setting the value to a default value
i cant believe they havent implemented this as its that easy
you created your own hibernate?
i guess
nice bro, yeah i dont know how to process annotations
Appreciate the help, thx
it's not as hard as you think, just the tiniest amount of reflection is required
yay, welcome back
if i use PlayerSwapHandItemsEvent does event.getMainHandItem() return the item which player is trying to put in offhand?
also mainHandItem.getItemMeta().hasDisplayName() how can this give nullpointer exception?
if(mainHandItem != null && mainHandItem.hasItemMeta() && mainHandItem.getItemMeta().hasDisplayName() && mainHandItem.getItemMeta().getDisplayName().equals(itemName))
i mean does it look goofy?
if meta is null, which happens for air item
yea but i already checked if item is null or nah
does java have any logging libraries that dont look ugly
or is air considered seperate item
ItemStack(Material.AIR) is a thing, and that returns null meta
ic
make a var for the itemMeta, don't get it thrice, it creates a copy each time
oh alr
if(mainHandItem != null && mainHandItem.getType() != Material.AIR && mainHandItem.hasItemMeta() && meta.hasDisplayName() && meta.getDisplayName().equals(itemName)){
does it look fine now?
can u drag air ?
getType().isAir() would be better
and with that I don't think you'd need the hasItemMeta
That makes sense, my goal is for the task to cancel when the player dies
Yea, sorry I left in the beggining, my social awkwardness got to me 😅
make sure you do all i said
it'll save you some headaches later on while debugging
is there a config guide for spigot?
Just for clarification
I should move the task count field above run
Rename runtasklater to runtaskevery
And only have cancel() within run()
??
yes
Do you want to make your own config?
you can have cancel outside run too
yes
i made my own config.yml in resource folder
?configs
See this wiki page on how to use custom configuration files: https://www.spigotmc.org/wiki/config-files/
but i want to see its saving and stuff
alr thanks <3
so just adding this.saveDefaultConfig();
will work?
its onEnable method ig so it will work
And all the logic for task count should be outside of run?
i have a small question
private final File dir = new File(WhosThatPixelmon.getInstance().getDataFolder().getAbsolutePath() + "//sprites"); is this correct way to go to sprites folder in my plugin foldor?
new File(plugin.getDataFolder(), "sprites");
no, just the field, it should be within the runnable that executes it otherwise it'll break when more than 1 player needs it
thanks 👍
Does a string or binary take less space?
So I should move the task count field to be just above run()
They will be indifferent lol
I am assuming you do not want the data to be readable
And you are storing it in a flat file
I want it to be readable by my code
i'm storing it in a document, in a collection, in a database using MongoDB
I was about to suggest sqlite but nvm
And I have never seen someone put binary data into a database, maybe that’s just new to me 😅
idk, I thought it might be more optimal than saving all the itemstacks with their properties readable
when using hibernate, imagine i have an enum save it with hibernate and later change something in the enum (might remove constants) how do i handle illegalargumentexceptions from hibernate (if it tries to find an enum that alr got deleted)?
try {
// Hibernate operation that may cause IllegalArgumentException
} catch (IllegalArgumentException e) {
// Handle the exception, perhaps by logging an error or performing some fallback action
}```
thats not how hibernate works tho
idk I asked chatgpt
How can I check if a mob spawned from spawner or not?
#getEntitySpawnReason()
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/entity/CreatureSpawnEvent.SpawnReason.html
declaration: package: org.bukkit.event.entity, class: CreatureSpawnEvent, enum: SpawnReason
Hello !
I'm trying to display players' head in menus.
Here is my problem : when a player is offline, the displayed head is a default one, not the player's head.
Someone knows how to fix that ?
This is the code :
// baseItem : an ItemStack object, the meta of this item is an instance of SkullMeta
// id : the UUID of the player
// Set the player skin on the head
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(id);
SkullMeta meta = (SkullMeta) baseItem.getItemMeta();
if (offlinePlayer.getName() != null) {
meta.setOwningPlayer(offlinePlayer);
baseItem.setItemMeta(meta);
}
remove the getName check?
is having 10 runnables splitting tasks less efficient than having one containing all the task of the 10? or is the notice in performance ignorable?
He's not null, I've already checked
So it does work when a player is online?
Yeah
Try using the getOfflinePlayer with the user name instead
That should do a web request lookup
If possible do that async
or use getPlayerProfile(), then update() it
I can't, don't have the plyer name here
@EventHandler
public void onSpawnerSpawn(SpawnerSpawnEvent e){
if(e.getEntity().getType() == EntityType.ZOMBIFIED_PIGLIN){
if (Math.random() < 0.60) {
e.getDrops().add(new ItemStack(Material.GOLD_BLOCK));
}
}
}```I'm trying this but I couldn't use #getDrops() method in this event. How can I set items that the mob will drop?
I've already tryed with PlayerProfile, but not with an update, I'll test that thx !
Yeah
Players collect the items dropped by the mobs coming out of the spawner with a hopper
Therefore, I need to adjust the item it will drop when it dies
note that update() returns a Future so you'll have to use whenComplete() or get() or join() (or whatever) it before getting the username
@EventHandler
public void onEntityDeath(EntityDeathEvent e) {
LivingEntity entity = e.getEntity();
if (entity.getType() == EntityType.ZOMBIFIED_PIGLIN) {
if (Math.random() < 0.60) {
e.getDrops().add(new ItemStack(Material.GOLD_BLOCK));
}
}
}```
I can do it like this but I don't know how can I check a zombified piglin spawned from a spawner in EntityDeathEvent
As I know yes
Try what mfnalex mentioned
But it is possible and if this is not a wrong choice, I think I can get what I want by using the getDrops() method
youuu could apply a tag on entities that are being spawned in CreatureSpawnEvent
which you could then check for when they die
What do you mean by tag? Should I give them a special name and check if the piglins with that name are dead?
?pdc
Hello, I'm looking for help because I want to put a command on an object, in this case a book, and I do it using various plugins, everything works, but if I want to create a second book but with a different command, that command is excluded, does anyone know how to do it?
Are you trying to make a plugin
yes, but I'm not doing very well
What part are you having problems with
How did you do for the first book?
I'd just add the command to the PDC of the book
part of the problem is when I create a new book and want to give it another command
by mycommend or commenditem
all this plugin have 1 problem
this
so you're not making a plugin?
You should see in #help-server then. This channel is for plugin development
Otherwise that's the solution
no im not
because I made scripts but they don't work well
i learn it
what is PDC?
what is the best app for minecraft plugins?
app?
if you want to learn how to make plugins
you need to start by learning java
?learnjava
For Beginners:
Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/
For Intermediate to Advanced Learners:
Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/
Practice and Hands-on Learning:
Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/
Free Resources and Documentation:
Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/
Community and Support:
Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/
Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉
thanks
intellij
be aware
that you can only use the community edition
dont download ultimate
Why not
Well you can use ultimate if you pay for it :p
Just pay 
i got it for free :p
Student?
mhm
Can't sell anything you've made with that
I always wonder how the hell is anyone going to find out
they dont
Well you can accidentally leak it
Did happen to an indie game studio a while back with maya
no ones gives a flying fuck if were honest
They got sued for like 250k $
dayum
Well i woulnt do it out of courtesy. They worked very hard for such a nice product
They deserve to get paid
If if am to get paid
I have seen people do Thread.sleep() in asynchronous tasks/schedulers. Is that even safe!?
Hey, I have a problem with the start.bat. Where should I put the nogui in the start.bat so that it works?
Safe yes, bad idea also yes
Why is it a bad idea?
Why would you block thread for no reason
^^
You can put it at the end. I recommend using this: https://docs.papermc.io/misc/tools/start-script-gen
Fair but it’s still safe if it’s not on the main thread and you use an executor service?
Do you have a good reason to sleep
It is safe, no one said it isn't, but also bad practice, bad for performance and indicator of bad design in most cases
I have no good reason to use it I was just wandering what the main drawbacks were. As google gave me mixed opinions
What would you suggest for having multiple delays after another
You can use TaskChain
thanks!
Would it be worth it creating a queue of some sort and somehow running tasks one after the other with a scheduler?
Yeah you can use a repeating scheduler
But the queue has to be concurrent?
You want multiple tasks running at the same time?
No multiple tasks that run one after the other. Not parallel
Then it doesn't have to be concurrent
