#help-development

1 messages · Page 927 of 1

chrome beacon
#

it's fine

#

should just happen once?

#

or does it always happen

#

hm? I thought it just logged them when they were downloaded

#

oh well 🤷‍♂️

undone axleBOT
slender elbow
#

xd

sterile flicker
#

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.

chrome beacon
#

No

#

You'll have to change all snowballs

#

or implement your own item the spawns a projectile

sterile flicker
worldly ingot
#

Eyes of ender maybe :p That's probably it

chrome beacon
#

Listen for right click and spawn a snowball

sterile flicker
chrome beacon
#

change the itemstack it contains to your item with a different model

sterile flicker
#

in 1.12.2

chrome beacon
#

Try nms

sterile flicker
#

Do you know a specific method?

worldly ingot
#

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

sterile flicker
#

.a(itemStack, int f)

sterile flicker
worldly ingot
#

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!

slender elbow
#

older than some of the spigot staff .....

worldly ingot
#

bro

#

facts

slender elbow
#

older than all of the paper staff, that's for sure

sterile flicker
#

only EntityProjectile

#

in 1.12.2

compact crane
#

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

lean pumice
#
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?

echo basalt
#

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 ;)

lost matrix
lost matrix
minor junco
lament hill
#

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;
minor junco
lament hill
vast wigeon
#

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

lost matrix
timid hedge
#

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();
    }
sterile flicker
#

what is ItemSnowball.class for?

lost matrix
timid hedge
sterile flicker
lost matrix
lost matrix
timid hedge
sterile flicker
lost matrix
sterile flicker
#
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
timid hedge
lost matrix
remote swallow
#

why

#

once again its time to learn java

#

?learnjava

undone axleBOT
#

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! 🎉

sterile flicker
#

so this feature from 1.9 is useless

lost matrix
sterile flicker
lost matrix
#

Sure. In 1.14+

worthy yarrow
#

I love saying the same thing 3 times over

sterile flicker
worthy yarrow
#

The fact it’s not an api method pre 1.14 probably

sterile flicker
#

This is not a projectile change.

lost matrix
worthy yarrow
#

So then just go make a mod pack kek

umbral ridge
#

can you manually play a goat horn sound? xD

#

eg.: on player join

lost matrix
lost matrix
#

Just search for playSound in the javadocs

lost matrix
kindred sentinel
#

How to get if item was burnt by lava? EntityCombustEvent doesn't work

sterile flicker
# lost matrix To achieve what?

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

worthy yarrow
#

If it can’t burn, then you do whatever it is you wanted to do and then manually remove the item I suppose

kindred sentinel
lost matrix
umbral ridge
# lost matrix Sure

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

worthy yarrow
sterile flicker
worthy yarrow
#

Can’t you like broadcast sounds to all online players?

lost matrix
worthy yarrow
#

Really easily too?

vast wigeon
umbral ridge
lost matrix
lost matrix
worthy yarrow
lost matrix
#

No entity needed

umbral ridge
worthy yarrow
#

Entity as in the one hearing the sound ie: player

umbral ridge
#

that's it then

#

will that have a fade out effect? xD

#

or will it be the same volume no matter where you are

worthy yarrow
#

You’re playing the sound to the world

#

I think…

#

The location Param probably refers to a player location I’d assume

sterile flicker
# lost matrix You can add a passenger to entities

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);

worthy yarrow
sterile flicker
umbral ridge
#

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

worthy yarrow
#

Yeah but if you play sounds for each player location, I wonder for the players near each other would get a duplicated sound effect

umbral ridge
#

Yeah... so you DO NEED an entity at the end. I'll test it

vast wigeon
worthy yarrow
#

Idk if smile says no, then there’s probably a reason. Ie: a workaround

undone axleBOT
worthy yarrow
#

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

sterile flicker
lost matrix
worthy yarrow
sterile flicker
#

then how do I add a passenger for snowball

vast wigeon
sterile flicker
#

#addPassenger instead of #startRiding?

lost matrix
vast wigeon
#

But it shows up as it is impoprted

lost matrix
vast wigeon
#

And that is the same as pacakge

#

Would be easier if i could send images

lost matrix
#

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

undone axleBOT
#

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

lost matrix
#

And its a maven project, right?

vast wigeon
#

Ye

sterile flicker
lost matrix
# vast wigeon Ye

Then invalidate caches and restart.
Click shift twice -> search for "invalidate ..."

lost matrix
vast wigeon
lost matrix
#

Also: I think your IDE is completely broken and needs a clean reinstall.

vast wigeon
#

The code was fine yesterday

lost matrix
#

If it throws an exceptio when you press shortcuts

vast wigeon
#

I try to ide epair

#

repair

worthy yarrow
#

That's not a good look for the ide kek

lost matrix
#

I have literally never seen this problem. How did you nuke your ide like that?

worthy yarrow
#

You should feel good, you broke the best ide

pallid oxide
#

export settings and reinstall, usually fixes problems

vast wigeon
umbral ridge
#

Sorry for tagging you smile

worthy yarrow
#

Location based sound basically?

#

With real world properties of how sound works? kek

vast wigeon
#

When i woke today my pc was off

#

And it worked 2 days ago

#

DIdn't use ide yesterday

worthy yarrow
#

It doesn't seem horribly complex

lost matrix
worthy yarrow
umbral ridge
#

will try it

spring horizon
#

If that doesn't work, send me a screenshot of the start of you main class.

vast wigeon
#

That fixed it

#

Ty

spring horizon
#

Np!

worthy yarrow
spring horizon
#

IntelliJ cache sometimes (everytime) breaks everything.

worthy yarrow
#

@lost matrix I'm getting lost in this minigame project D:

lost matrix
#

Jep, minigames are hard to get right

worthy yarrow
#

Absolutely D;

#

I'm still working on the sumo mingame too

#

I'm not sure how I want to handle arenas

spring horizon
#

Tell me what are you struggling with

worthy yarrow
spring horizon
#

I have a little bit of experience with minigames (made 10 minigames in 3 months)

spring horizon
worthy yarrow
#

sec let me gather

spring horizon
#

k

worthy yarrow
#

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

worthy yarrow
#

That's an ugly ass sound sir

umbral ridge
#

XD

#

its a meme

worthy yarrow
#

Gotcha haha

umbral ridge
#

I should make it an earrape sound

#

volume to max

worthy yarrow
#

Dear god

#

It's a fugly sound, amplify to the max ofc

grim hound
#

yo

#

anybody here ever coded with anyone in intelliJ?

#

live the same project at the same time

#

live session

lost matrix
grim hound
#

doesn't it require some kind of license?

worthy yarrow
#

Yea

grim hound
#

so is it paid?

echo basalt
#

codewithme is icky

lost matrix
#

I think its in the ultimate version. If you are a student then you get it for free.

echo basalt
#

no plugins no nun

worthy yarrow
#

If you've got intelliJ then I think it comes with it no?

echo basalt
#

It works and it's surprising that it does but it doesn't work well

grim hound
worthy yarrow
#

Hmm

grim hound
#

so no license

#

I downloaded CodeTogether

#

but my friend can only edit on a web browser

worthy yarrow
#

ew

grim hound
#

ye

lost matrix
#

That one on the other hand is quite buggy

grim hound
worthy yarrow
#

(if anything)

chrome beacon
grim hound
chrome beacon
#

not Intellij specific but it should work

echo basalt
#

git

daring maple
#

is there a real need for you to be coding concurently?

worthy yarrow
daring maple
#

what benefits would you get that you would not get while sharing screen during pair programming

worthy yarrow
#

2 people working on the same project means more can get done

spring horizon
#

@worthy yarrow when working with stuff like that

#

always use teams

#

doesn't matter if it's 1v1

#

do a team

daring maple
spring horizon
#

in case you want to change it to 2v2, you just have to create a team of two.

#

it's easier to maintain.

lost matrix
spring horizon
#

Depends on the tasks to be done.

daring maple
#

Ideally you'd have separation of concerns and no one has to work concurrently on the same part of the plugin

worthy yarrow
# spring horizon it's easier to maintain.

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?

daring maple
worthy yarrow
#

Whatever way you do it, I don't think it matters as long as all of the party is contributing?

spring horizon
#

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<>());
    }
spring horizon
#

It's easier to maintain.

echo basalt
#

hm I wonder how well multi block change packets scale

spring horizon
#

If you create the packet per player, depends on how many blocks are you editing.

#

What do you want to do?

echo basalt
#

I've played with this before

#

Just like

#

farming stuff

#

estimating ~100 ish blocks per chunk

worthy yarrow
spring horizon
#

lmao, yea

#

it'd work fine

echo basalt
#

I guess

spring horizon
sterile flicker
grim hound
#

how can I share a github project with someone?

worthy yarrow
echo basalt
#

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)

worthy yarrow
#

Ah ok

spring horizon
worthy yarrow
#

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

echo basalt
#

I'd honestly have started with that before writing the whole game

worthy yarrow
#

kek

#

This is my first time trying to develop a minigame haha so ig I'll learn the hard way

echo basalt
#

hm 256 crops per chunk

spring horizon
#

yea, it's not bad

echo basalt
#

thing is we have like

#

lots of chunks

spring horizon
#

but why packets?

echo basalt
#

per-player thing and swm is overengineering it

spring horizon
#

Oh!

echo basalt
#

guy wants per-player crops but players to be able to see each other

#

I already use swm for islands

spring horizon
#

I imagine that you are using ProtocolLib, right?

worthy yarrow
#

Best way to handle uneven amount of players, toss a random bye each round til only 2 players remain?

daring maple
#

wouldnt you just use a queue

echo basalt
#

I can do this with raw nms though

daring maple
#

and then always grab first 2 people

spring horizon
#

Yea

echo basalt
#

I've done full client-sided chunks but it was a while ago

spring horizon
#

But it's easier to use ProtocolLib for intercerpting the block place and remove.

worthy yarrow
#

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.

daring maple
#

probably lacking a bit of context, but how would a queue not work here in the case of uneven players?

worthy yarrow
#

I don't want a queue is the context lol

echo basalt
#

overengineer time

echo basalt
#

meh

daring maple
worthy yarrow
#

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

echo basalt
#

ew

vast wigeon
#

So in arguments of a command, is /gamemode c the c in this argument 1?

worthy yarrow
# echo basalt ew

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

echo basalt
#

Make team objects

worthy yarrow
#

That's the plan

vast wigeon
daring maple
#

no that would be the command label

#

the command itself is not an argument

vast wigeon
#

So the command is not the first thing in the array?

worthy yarrow
upper hazel
#

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)

vast wigeon
echo basalt
worthy yarrow
#

Now that you say that

#

just split the uuid's from one list

#

yeah

upper hazel
echo basalt
#

class SumoTeam {

Collection<UUID> players
Color color
Location spawnPoint
int capacity

}

#

type deal

molten hearth
#

All my homies use audiences

worthy yarrow
#

gotcha

daring maple
spring horizon
echo basalt
#

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

daring maple
echo basalt
molten hearth
#

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

worthy yarrow
worthy yarrow
sterile flicker
quaint mantle
#

@echo basalt why do you use linked lists and linked hash maps over just the plain arraylist and hashmap

sterile flicker
echo basalt
#

I don't

#

I abuse ConcurrentHashMap

#

:)

#

Isn't LinkedHashMap ordered?

quaint mantle
#

oh yeah it is

echo basalt
#

Well

quaint mantle
#

but I see you abuse linkedlist

echo basalt
#

By insertion order

spring horizon
echo basalt
#

I use it like 10% of the time

quaint mantle
#

oh what

vast wigeon
quaint mantle
#

Whenever I see your code I never see ArrayList

upper hazel
echo basalt
#

I guess it's just the way I see the data

quaint mantle
#

Ok I'm buggin then

lost matrix
echo basalt
#

I'd argue that obsessing over LinkedList vs ArrayList is in part premature optimization

quaint mantle
#

I can understand concurrent maps

#

Isn't that like thread safe

lost matrix
#

*Except one very specific

echo basalt
#

make sure to create your array lists with an initial capacity of Integer.MAX_LIMIT to avoid resizing

shadow night
sterile flicker
lost matrix
sterile flicker
lost matrix
#

If you mount it, it will

wintry lynx
#

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.

daring maple
#

the if(args.length==0) is false

vast wigeon
#

Cuz i do /gamemode s

daring maple
#

well the argument array has length 1 because it has 1 argument

#

but that argument has index 0

candid inlet
daring maple
#

if you wanna know more you should look into Java OOP

vast wigeon
daring maple
#

yeah

kind hatch
vast wigeon
pseudo elm
#
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
kind hatch
pseudo elm
#

ok thx

vast wigeon
# daring maple yeah

What would i do in this situation then? if(args.length == 1) { if(args[0] == "gi" || args[0] == "give") {

#

Is it args[1] ==

daring maple
#

if that would be something like /eco 'player' give

#

then give would be args[1]

vast wigeon
daring maple
#

then give is argument 0

pseudo elm
#
Player player = (Player) sender;```
why is the player inbetween ()?
kind hatch
#

Casting

vast wigeon
kind hatch
daring maple
#

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
}
glad prawn
daring maple
glad prawn
#

I think you have to mention that if he understands what he's doing

vast wigeon
sterile flicker
glad raft
#

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 ...

umbral ridge
#

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?

young knoll
#

It's connected to the tile entity

umbral ridge
#

Purrrfect

tender shard
glad raft
#

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

cursive loom
#

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

worthy yarrow
#

craftblockdata cant be cast to directional

cursive loom
#

Yes I see this bur why it's happen when I break a chest

#

the event is InventoryCloseEvent not BreakBlocksEvent

worldly ingot
#

It would only ever call an InventoryCloseEvent if someone had the chest inventory open while the block was broken

cursive loom
#

I'm alone on the server

worthy yarrow
#

?paste show more code

undone axleBOT
worldly ingot
#

Yeah, something is calling that method for some reason

cursive loom
#

You want to see more of my code ?

worldly ingot
#

Yes

#

And if you have a BlockBreakEvent anywhere, that would be relevant as well

worthy yarrow
#

just paste the whole class

cursive loom
worldly ingot
#

Actually BBE isn't relevant, stacktrace says it's a close inventory event lol

lost matrix
# cursive loom

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

rough ibex
#

if (!cond) return; imo is hotter

lost matrix
#

imo its not 🙂

rough ibex
#

fair enough

lost matrix
#

But im ok with calling that a preference

cursive loom
#

what is the condition ?

rough ibex
#

any condition necessary

lost matrix
cursive loom
#

exemple ? plz

worthy yarrow
rough ibex
#

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)```
tardy delta
#
if (!cond)
{
return;
}```
cursive loom
#

yes x) but what is condition

tardy delta
#

ha ! had smile stop typing for a moment

rough ibex
#

any condition

#

its up to you

#

to use the guard clause as a tool

worthy yarrow
lost matrix
# cursive loom exemple ? plz
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
worthy yarrow
#

If it's not what you want, then its a guard tool

cursive loom
#

ahhhhhhhh ok, I don't thinking about this ! thx you

worthy yarrow
#

if it's what you want then just add the guards to ensure it does what you want

meager wolf
#

[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 ?

lost matrix
#

Plugins written before 1.13 and which didnt specify a version in their plugin.yml

vivid zodiac
#

How add libs in eclipse now ? I have no classes when i import 1.20* plugin but 1.16 works
Java problem ?

chrome beacon
#

?bootstrap

undone axleBOT
#

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

dry forum
#

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?

chrome beacon
#

I'd use PDC

#

?blockpdc

undone axleBOT
chrome beacon
#

?pdc

dry forum
#

ok thanks

spare prism
#

how can i change level of a potion?

chrome beacon
#

as in potion itemstack?

vivid zodiac
#

how use

spare prism
#

i have an itemstack and its a potion

#

and i want to change its level

chrome beacon
#

Get the effect and then increment the level and set it back

umbral ridge
#

hey

spare prism
rough ibex
#

hi

spare prism
#

only to change potion effect type

chrome beacon
#

Yeah that's what you want to do

spare prism
#

only the type of the potion

chrome beacon
#

Add the new effect

spare prism
#

and i only see a method to remove custom effects

chrome beacon
#

Why do you need to remove the base effect

spare prism
#

i want only one potion effect

#

of the given type

harsh ginkgo
#

When many chunks are loaded, memory easily becomes full. I only let it restart until the end of the day

chrome beacon
#

?

lost matrix
flint coyote
#

Does setting a world to non-persistent prevent chunk unloading?
Or does it simply reset the chunk once unloaded?

chrome beacon
#

Chunks reset

#

I believe

flint coyote
#

Yeah if that's the case there won't be a memory leak

#

But I never tested that

dry forum
#

do PersistentDataHolders save data over a server restart

flint coyote
#

Yes

#

That's why they are called "Persistent"

chrome beacon
slender elbow
#

EphemeralDataHolder

worldly ingot
#

That's just Metadatable Kappa

young knoll
#

Memory leaks included!

chrome beacon
#

was about to say

young knoll
#

It’s a feature

chrome beacon
#

then just check and change the base type

dry forum
eternal night
#

you cannot

undone axleBOT
eternal night
#

you need a third party library for this yea ^

slender elbow
#

☠️

spare prism
slender elbow
#

worse than death sentence

spare prism
#

thats what im asking about

dry forum
# chrome beacon ?blockpdc

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?
chrome beacon
#

Just new CustomBlockData

#

and then get the value

#

take a look at the example plugin

umbral ridge
#

should work right?

#

🤓

obsidian plinth
#

I’m sort of lazy anybody know of any good path finding dependencies?

chrome beacon
#

Pathetic

obsidian plinth
#

Like ones that are good enough to solve a maze

obsidian plinth
#

I couldn’t get it to function at all

chrome beacon
#

You can always make your own

#

Good practice

obsidian plinth
#

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

chrome beacon
#

There are plenty of guides for A*

rough ibex
#

At first I thought you were calling them pathetic

sand spire
#

Hey, should I store inventories as an encoded string, byte array or something else?

#

in a database

slender elbow
#

sql has a blob type

#

use that

sand spire
chrome ferry
#

Well personally I assume array and then serialise all items in the inventory to a byte[]

lost matrix
#

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.

chrome ferry
#

That is smart

sand spire
lost matrix
sand spire
# lost matrix codec is short for "encoder and decoder". You can store anything into MongoDB as...

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();```
lost matrix
#

Alright then lets not make this too complicated. Simply store your "encodedData" in MondoDB as it is.

umbral ridge
#

I love making a parser for this

young knoll
#

Binary can hold a byte[]

#

So that’s basically your blob

lilac palm
#

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;
    }```
umbral ridge
#

What's not working?

lilac palm
#

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

agile anvil
#

What does this say:
Bukkit.getConsoleSender().sendMessage(String.valueOf(xTra));
Bukkit.getConsoleSender().sendMessage(String.valueOf(zTra));

#

0 or 1 ?

lilac palm
#

nvm, just fixed it

#

ikr

lilac palm
#

Ok I need help still

agile anvil
#

For?

lilac palm
#

wait nvm again I think I got it

agile anvil
#

Bahahah

lilac palm
#

I have a question now though

#

How do I make an int[][]

#

So it can store x,z values

agile anvil
#

int[][] matrix = new int[16][16];

lilac palm
#

Gotcha thanks

#

Wait a sec

#

How do I store a chunk snapshot to an XZPair in a hashmap and access it later?

agile anvil
#

Why don't you get the location and get the chunksnapshot from it?

#

Or, why do you need to save a x z pair ?

lilac palm
agile anvil
#

So ?

lilac palm
# agile anvil So ?

Getting the chunk and chunk snapshot every time is a huge performance loss

agile anvil
#

Please tell me exactly what you want to do?

lilac palm
lost matrix
lost matrix
lilac palm
#

Is guava standard jdk?

agile anvil
lilac palm
lost matrix
#

guava is provided by spigot

lilac palm
#

Oh ok

#

spigot or spigot-api?

#

Or both

lost matrix
#

spigot-api

lilac palm
#

Ok

lost matrix
#

And transitively spigot as well

quaint mantle
#

Guys why is sharing nms like on github not allowed but it's allowed via build tools

#

I'm just confused

lost matrix
quaint mantle
#

Hm

#

So what does build tools actually do

#

Does it decompile a jar

remote swallow
#

it downloads minecraft, decompiles it, patches it then builds bukkit, craftbukkit and spigot

dry forum
#

is it possible to make a slime sit inside of a block? like how armorstand.setMarker works?

small holly
#

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

small holly
#

oml ik why its trying to serialize it... its trying to serialize the entire world

small holly
rough ibex
#

gson should definitely work with java 9+

lost matrix
small holly
#

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

small holly
lost matrix
#
.excludeFieldsWithModifiers(Modifier.VOLATILE)

squint

lost matrix
small holly
#

it was for an underlying issue that I am trying to fix

small holly
#

I don't need that to be done lol

lost matrix
#

Ok but was that a transitive serialization or did you just throw a World at it and hoped for the best

small holly
#

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

lost matrix
#

If you dont want fields to be serialized, then simply use the transient keyword

#
private transient World world;
small holly
#

mhm

lost matrix
#

Alternatively you can just register a type adapter for worlds, which saves a UUID and deserializes it back to a World

small holly
#

Might actually do that tbh

lost matrix
#

Can cause problems when worlds arent loaded while deserializing

small holly
lost matrix
#

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

small holly
#

actually gonna add that lol thanks for that

lost matrix
#

Just remember that you need to register the ItemStack one as a TypeHierarchyAdapter instead.

#

Because the CraftItemStack impl is cursed

lilac dagger
#

Does this adapter serialize the whole itemstack?

#

And not just what craft itemstack does with serialization?

hybrid turret
#

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?

lilac dagger
#

just keep it stored

#

if you ever made a connection for the first time on main thread you'll know how slow it is

wet breach
lilac dagger
#

ah sqlite

hybrid turret
#

Okay thank you

#

Lil verbose but as long as it's good for performance

lilac dagger
#

it won't improve performance

#

just that you unlock the database

wet breach
#

^

hybrid turret
#

ahhh

#

i get it

#

i'm stupid lmao

inner mulch
#

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?

hybrid turret
#

How much difference in performance do yaml/json files, sqlite-files and a mysql database server provide?

wet breach
#

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.

hybrid turret
#

I see so on a larger scale, sqlite has the same problems as flat files, did I get that right?

wet breach
#

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

hybrid turret
#

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

wet breach
#

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.

wet breach
#

BLOB = Binary Large Object

hybrid turret
#

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

wet breach
#

or you can serialize and store that serialization as a string

hybrid turret
hybrid turret
#

Just an Array of json-objects (item) in a json file. And I want to migrate this into sqlite

#

or a database

wet breach
#

I personally store such things using base64

hybrid turret
#

quality of life

wet breach
#

so that I avoid storing weird characters

hybrid turret
wet breach
#

you just encode the serialization with base64

#

thats all

hybrid turret
wet breach
#

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 😛

hybrid turret
#

So I would serialize to a string (and convert to a byte array) and then store a Base64-String?

wet breach
#

yep

#

but you don't need to go to string from serializing though

#

its serialize - > byte - > base64

#

then you have a string

hybrid turret
#

But the serializing will return a string first anyway

#

or am i misunderstanding? lol

wet breach
#

depends how you are serializing

#

there is more then one way to do it

hybrid turret
#

rn, gson

wet breach
#

then I guess if you want to deal with strings like that you could just encode the strings in your case

hybrid turret
#

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

dawn flower
#

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

wet breach
#

only profiling and testing will tell you what is or is not an issue

hybrid turret
#

huh, interesting

wet breach
#

if you are going to use the bytes, you need to use setBinaryStream

#

of preparedstatement

#

then you use a bytearrayinputstream

hybrid turret
#

Ahhhhhh

wet breach
#

and feed the bytes into that

hybrid turret
#

i'm gonna try that out rq

wet breach
#

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);
hazy parrot
#

just a note that setBinaryStream is not implemented in some drivers (SQLite for example)

hybrid turret
#

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

hybrid turret
lilac dagger
#

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

glossy sand
#

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

glossy sand
quaint mantle
#

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

echo basalt
#

you're new to java

lilac dagger
#

move task count field above run()

#

change runtasklater to runtaskEvery

#

or how it was named

#

it takes plugin, startafter, every

inner mulch
#

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)?

lilac dagger
#

with bukkitrunnable you can just call cancel();

#

from within run();

#

@tidal cove

inner mulch
lilac dagger
#

all the analysis for nought

inner mulch
#

yes

#

😔

glossy sand
lilac dagger
#

@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

inner mulch
#

but switch statements arent so great to say the least

lilac dagger
#

hmm, maybe duck it

#

or google it

inner mulch
#

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

lilac dagger
#

try ordinal if needed

inner mulch
#

ORDINAL works, but it doesnt fallback to what i want it just fallsback to whatever get into place there

inner mulch
# lilac dagger

and if ordinal number is too high and i remove to many it breaks as well

lilac dagger
#

suprised hibernate doesn't have a proper way to handle this

inner mulch
#

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

lilac dagger
#

maybe they have annotations for it like i did for myself

inner mulch
lilac dagger
#

i guess

inner mulch
#

nice bro, yeah i dont know how to process annotations

lilac dagger
#

the implementation is only for yml

#

since this is what i need it for

quaint mantle
lilac dagger
lilac dagger
quaint mantle
#

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?

smoky anchor
quaint mantle
#

yea but i already checked if item is null or nah

molten hearth
#

does java have any logging libraries that dont look ugly

quaint mantle
#

or is air considered seperate item

smoky anchor
#

ItemStack(Material.AIR) is a thing, and that returns null meta

quaint mantle
#

ic

smoky anchor
quaint mantle
#

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 ?

smoky anchor
#

getType().isAir() would be better
and with that I don't think you'd need the hasItemMeta

quaint mantle
quaint mantle
lilac dagger
#

it'll save you some headaches later on while debugging

quaint mantle
#

Thank you

quaint mantle
#

is there a config guide for spigot?

quaint mantle
lilac dagger
#

yes

chrome beacon
lilac dagger
#

you can have cancel outside run too

quaint mantle
#

i made my own config.yml in resource folder

chrome beacon
#

?configs

undone axleBOT
quaint mantle
#

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

quaint mantle
#

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?

drowsy helm
#

Dont do private final

#

Assign it after onEnable

chrome beacon
#

new File(plugin.getDataFolder(), "sprites");

lilac dagger
quaint mantle
#

thanks 👍

sand spire
#

Does a string or binary take less space?

quaint mantle
lilac dagger
#

yeah

#

it's basically a different class when you put it above/along run()

fallen lily
sand spire
#

oh

#

thanks

native nexus
#

I am assuming you do not want the data to be readable

#

And you are storing it in a flat file

sand spire
sand spire
native nexus
#

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 😅

sand spire
#

idk, I thought it might be more optimal than saving all the itemstacks with their properties readable

inner mulch
#

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)?

sand spire
inner mulch
sand spire
#

idk I asked chatgpt

shell robin
#

How can I check if a mob spawned from spawner or not?

tidal marlin
#

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);
}
inner mulch
#

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?

chrome beacon
#

I'd say it's negligable

#

Keeping the code clean and readable is more important

tidal marlin
chrome beacon
#

So it does work when a player is online?

tidal marlin
#

Yeah

chrome beacon
#

Try using the getOfflinePlayer with the user name instead

#

That should do a web request lookup

#

If possible do that async

tender shard
#

or use getPlayerProfile(), then update() it

tidal marlin
shell robin
#
    @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?
tidal marlin
shell robin
#

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

tender shard
shell robin
#
    @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

chrome beacon
shell robin
#

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

tall dragon
#

which you could then check for when they die

agile anvil
#

What about if the server reboot?

#

Pdc is safer and easier

tall dragon
#

ok what if that entity despawns

#

thats just annoying

shell robin
tall dragon
#

?pdc

jolly quarry
#

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?

chrome beacon
jolly quarry
chrome beacon
#

What part are you having problems with

agile anvil
#

How did you do for the first book?

chrome beacon
#

I'd just add the command to the PDC of the book

jolly quarry
jolly quarry
#

all this plugin have 1 problem

chrome beacon
#

so you're not making a plugin?

agile anvil
#

You should see in #help-server then. This channel is for plugin development

agile anvil
jolly quarry
chrome beacon
#

why did you say you were then

#

;/

jolly quarry
#

i learn it

#

what is PDC?

#

what is the best app for minecraft plugins?

chrome beacon
#

app?

jolly quarry
#

yes

#

no for phone

#

for windows

chrome beacon
#

if you want to learn how to make plugins

#

you need to start by learning java

#

?learnjava

undone axleBOT
#

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! 🎉

jolly quarry
#

ok i have java in the shool

#

what app is the best

tall dragon
#

Most people use Intellij or eclipse

#

My preference goes to intellij

jolly quarry
#

thanks

valid burrow
#

be aware

#

that you can only use the community edition

#

dont download ultimate

tall dragon
#

Why not

chrome beacon
#

Well you can use ultimate if you pay for it :p

tall dragon
#

Just pay Business_Okayge

valid burrow
#

he just started coding

#

he doesnt need the ultimate features

valid burrow
chrome beacon
#

Student?

valid burrow
#

mhm

chrome beacon
#

Can't sell anything you've made with that

valid burrow
#

didnt plan on it

#

all my stuff is free

tall dragon
chrome beacon
#

Did happen to an indie game studio a while back with maya

valid burrow
#

no ones gives a flying fuck if were honest

chrome beacon
#

They got sued for like 250k $

valid burrow
tall dragon
#

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

native nexus
#

I have seen people do Thread.sleep() in asynchronous tasks/schedulers. Is that even safe!?

hazy parrot
#

It's safe but don't do it

#

No reason to

grave laurel
#

Hey, I have a problem with the start.bat. Where should I put the nogui in the start.bat so that it works?

chrome beacon
native nexus
#

Why is it a bad idea?

hazy parrot
#

Why would you block thread for no reason

chrome beacon
#

^^

chrome beacon
native nexus
chrome beacon
hazy parrot
#

It is safe, no one said it isn't, but also bad practice, bad for performance and indicator of bad design in most cases

native nexus
#

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

chrome beacon
#

You can use TaskChain

native nexus
#

Would it be worth it creating a queue of some sort and somehow running tasks one after the other with a scheduler?

umbral ridge
#

Yeah you can use a repeating scheduler

native nexus
#

But the queue has to be concurrent?

umbral ridge
#

You want multiple tasks running at the same time?

native nexus
#

No multiple tasks that run one after the other. Not parallel

chrome beacon
#

Then it doesn't have to be concurrent

native nexus
#

You were referring to TaskChain by Aikar?

#

Or something different

chrome beacon
#

yeah

#

or just chain tasks yourself