#help-development

1 messages · Page 1001 of 1

storm crystal
#

so It'd result with 49 different constants in total

echo basalt
#

Technically yes but at some point you might just want to generate them and cache them

pseudo hazel
#

doesnt mc or spigot just reuse keys if you make new ones with the same key?

storm crystal
#

like serialize and deserialize into binary?

echo basalt
storm crystal
#

that's why im trying to figure out a way to declare and store those keys

pseudo hazel
#

I would atleast create it with your plugin instance

#

new NameSpacedKey(plugin, "key")

storm crystal
#

just throw passed plugin via dependency injection?

#

wait if I have to use passed plugin I cant keep that class Keys static, right?

pseudo hazel
#

unless your plugin is static 😉

storm crystal
#

isnt making everything static like that not recommended at all?

pseudo hazel
#

yeah

short plover
#

is there a way to listen for when a player right clicks air or just water? PlayerInteractEvent doesn't get called when a player right clicks anything that isn't a block with an empty hand

#

I'm assuming the client just doesn't send anything to the server when right clicking air with an empty hand so it might not be possible

eternal oxide
#

Not possible as no packet is sent from the client

short plover
#

😭

tall saffron
#
package chiru.generatetest;

import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.generator.BlockPopulator;

import java.util.Random;

public class Generation extends BlockPopulator {
    @Override
    public void populate(World world, Random random, Chunk chunk) {
        //Check
        System.out.println(ChatColor.GOLD+"Generating a new chunk.....");
        //Geting the cordenates of the chunk (the multiplication by 16 is because the chunks in mc are 16x16)
        int x = chunk.getX() * 16;
        int z = chunk.getZ() * 16;

        //Randomizing the cord of the chunk the bound is all the chunk 16 x 16
        int cx = x + random.nextInt(16);
        int cz = z + random.nextInt(16);

        //Check if that cordenate is a plains biome
        if(world.getBiome(cx, cz) == Biome.PLAINS){
            //Get the highest point in that cordenates
            Integer highestPoint = world.getHighestBlockYAt(cx,cz);
            //Check if is grass
            if(world.getBlockAt(cx,highestPoint,cz).getType() == Material.GRASS_BLOCK){
                //Generate a cherry tree
                world.generateTree(new Location(world, cx, highestPoint,cz), TreeType.CHERRY);
            }
        }
    }
}
``` This code doesnt generate any cherry tree
#

i want to generate one per chunk

young knoll
#

Well, does the grass check pass

tall saffron
#

Let me check

#

I added the grass thing because without that

#

it generated the trees only in the water that was wierd

#

Let me check tho

#

Yep

#

it pass the biome check

#

and grass

#

it has problems actually generating the tree

young knoll
#

Ah wait you are generating it inside the grass block

#

Generate it one higher

tall saffron
#

It cant generate inside?

#

I added 1 to highest value

#

let me try

#

Nop

#

It still dont work

#
 package chiru.generatetest;

import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.generator.BlockPopulator;

import java.util.Random;

public class Generation extends BlockPopulator {
    @Override
    public void populate(World world, Random random, Chunk chunk) {
        //Check
        System.out.println(ChatColor.GOLD+"GENERATING NEW CHUNK...");
        //Geting the cordenates of the chunk (the multiplication by 16 is because the chunks in mc are 16x16)
        int x = chunk.getX() * 16;
        int z = chunk.getZ() * 16;

        //Randomizing the cord of the chunk the bound is all the chunk 16 x 16
        int cx = x + random.nextInt(16);
        int cz = z + random.nextInt(16);

        //Check if that cordenate is a plains biome
        if(world.getBiome(cx, cz) == Biome.PLAINS){
            //Check
            System.out.println(ChatColor.GOLD+"PLAIN CHECK PASS");
            //Get the highest point in that cordenates and add one
            Integer highestPoint = world.getHighestBlockYAt(cx,cz) + 1;
            //Check if is grass
            if(world.getBlockAt(cx,highestPoint,cz).getType() == Material.GRASS_BLOCK){
                //Check
                System.out.println(ChatColor.GOLD+"GRASS CHECK PASS");
                //Generate a cherry tree
                world.generateTree(new Location(world, cx, highestPoint,cz), TreeType.CHERRY);
            }
        }
    }
}
#

This is the code

#

It prints every message

#

But the trees arent in the game

eternal oxide
#

Do not use world#get-anything in a populator. Use the chunk provided

spice burrow
#

are there docs for the new protcol changes from 1.20.2?

mental moon
#

Anyone know the correct way to add custom crafting and smithing recipes in 1.20.6?
I get packet errors on join that kick the player.

https://pastebin.com/4aB1HrMt

Code Context: the MobHead.getHeadItem is a unique never-null itemstack.
The smithing recipe is to attach an identifier onto a weapon.

mental moon
worldly ingot
#

And be sure you're on the latest build of Spigot as well. It's either you've found a bug in the API, or maybe you're just doing something else wrong. But if you can reproduce it with a very simple smithing recipe, then you know it has to be a bug

#

Oh, wait, nevermind lol. You're just inserting air into your smithing recipe

#

There should probably be some better validation for that in Bukkit so it throws an exception earlier

lethal coral
#

why doesn't a text opacity of -127 for text displays set the text to be see-through?

worldly ingot
#

127 might be a better value for semi transparency

#

But that's only going to be 50% transparent

lethal coral
worldly ingot
#

You should be able to. That would be 0

#

The text opacity is an unsigned byte, but Java doesn't have unsigned bytes. So 0 is 100% transparent, 127 is 50% transparent, -128 is 49% transparent, -1 is fully opaque

#

The default is -1

lethal coral
worldly ingot
#

These are text displays? PandaThink

worldly ingot
#

Are you trying to make the text transparent? Or the background?

lethal coral
#

The faces are the text

#

6 text displays total

worldly ingot
#

Ah I see

#

Yeah, 0 should be fully transparent. Maybe you need a 1

lethal coral
worldly ingot
#

Actually, wiki says

Similar to the background, the text rendering is discarded when it is less than 26

#

So maybe you need 26 or 27 😄

lethal coral
#

25 worked! 26 and 27 were almost but not quite

#

that's so odd

#

do you know why it works that way?

worldly ingot
#

I suppose they're just so transparent that they say "fuck it, you're probably not gonna see it anyways"

#

25 being about 10% of 255, the maximum opacity

lethal coral
#

ohhh I see

#

thank you so much for your help

worldly ingot
#

o/

spice burrow
#

Is there a way to get the packet status from a BlockDamageAbortEvent? the goal is to get the status value and send a packet for that block so mining progress can be saved

lethal coral
spice burrow
drowsy helm
#

Pretty sure theres an actual event for that

lethal coral
#

Wait there IS

#

It's just under a different name

drowsy helm
#

theres the actual BlockDamageEvent but pretty sure thats one time

lethal coral
#

Yes

drowsy helm
#

listening to an animation is pretty hacky

lethal coral
#

That's what people have had to do for a while now

#

Though aren't you supposed to be able to change the break speed attribute in newer versions

#

1.20.5+? Or is that coming soon still

spice burrow
drowsy helm
#

If you can be bothered use a apcket listener

#

listen to the Block break animation packet and you can get the block damage level

#

there should be a block metadata one aswell

spice burrow
#

mmm ill have to get caught up on packet listeners, only packets ive ever learned to pass was a basic npc without any functionality

#

but ill give that a shot thx

drowsy helm
spice burrow
#

That's essentially modifying packets instead of sending right?

spice burrow
drowsy helm
#

no need to modify

spice burrow
#

ye makes sense for the most part, still only a few days into learning java so i've been on a struggle bus

drowsy helm
#

cant find my old code, but look into ProtocolLib. Might be a bit complex but it will be most robust

spice burrow
#

yup i just added it in my depencies actually lol, thx for the help

wet breach
spice burrow
# drowsy helm cant find my old code, but look into ProtocolLib. Might be a bit complex but it ...

got one more question for you if you don't mind, do you know where I can find docs on block break animation? seems like most stuff in minecraft has loose documentation/none at all

private void packetListener(){
    ProtocolManager manager = ProtocolLibrary.getProtocolManager();
    manager.addPacketListener(
            new PacketAdapter(this, PacketType.Play.Server.BLOCK_BREAK_ANIMATION) {
              @Override
              public void onPacketReceiving(PacketEvent event) {
                event.getPlayer().sendMessage("packet obtained c:");
                super.onPacketReceiving(event);
              }
            }
    );
}

i believe this should work, I'd just like to have a better idea of what BLOCK_BREAK_ANIMATION gives me

spice burrow
drowsy helm
#

pretty straight forward, just id pos and stage from 0-9

sullen marlin
dry harness
#

Hello, I am trying to build a plugin from source code but I get the following error, how can it be solved?

A problem occurred configuring project ':v1_20_R4'.
> Failed to create service 'paperweight-userdev:setupService:a77b6b7fc970a2fc1fc285d4820d0a5fcdd3f00801c4a47eda3632746be3d0cc'.
   > Could not create an instance of type io.papermc.paperweight.userdev.internal.setup.UserdevSetup.
      > The paperweight development bundle you are attempting to use is of data version '5', but the currently running version of paperweight only supports data version
s '{2=class io.papermc.paperweight.userdev.internal.setup.v2.DevBundleV2$Config, 3=class io.papermc.paperweight.tasks.GenerateDevBundle$DevBundleConfig, 4=class io.papermc.paperweight.tasks.GenerateDevBundle$DevBundleConfig}'.
sullen marlin
#

?whereami

dry harness
#

oh

dawn flower
#

how possible is it to change the camera prespective of a player

#

so basically move the player's camera

royal heath
#

I don't think you can do that. I believe this is client side

dawn flower
#

some servers do it tho

#

like replay plugins

royal heath
#

They might be moving the player itself

dawn flower
#

in some parts of hypixel they show u that ur camera is going backwards (u cant move ur head) and ur player is still there

#

unless there's a non straight forward way

royal heath
#

They might be moving the player itself back and cloning the player model

dawn flower
#

like spam sending movement packets to the player, that prob will work

dawn flower
#

and that would most likely cause game breaking bugs if the server crashes cuz i'd have to make the player spectator

dawn flower
#

the only idea in my head rn is faking a spectator packet to the player and spam sending a movement packet and create an npc at where the player was at their place, this makes it fully clientside and others would see the player as if they were standing still

ivory sleet
#

Yeah spectator sounds reasonable

#

tho u would need some sort of dummy entity u can control, but that’s fine

royal heath
#

Yeah that sounds like a good way to do it

echo basalt
#

Have we tried spectating display entities yet?

spice burrow
#

im just a bit lost when it comes to reading the data that i get from the packet i suppose

drowsy helm
drowsy helm
dawn flower
#

what the flip is a packet meta

spice burrow
#

idk lol

spice burrow
# drowsy helm Im not at pc rn, can send an example in a bit

i got it figured out, for some reason it didnt click that it was the fields I was getting from the packet for some reason lol. im just a bit slow, since it's a byte it should realistically be packet.getBytes().read(0) im assuming for the field index

quaint mantle
#

any can help me to make a commandlistener for my limbo server? (auto command trigger send server)

#

this is my code

#

BungeeUtils.java:

import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import dev.jay.limbocore.LimboCore;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class BungeeUtils {
    private final LimboCore plugin;

    public BungeeUtils(LimboCore plugin) {
        this.plugin = plugin;
        Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
    }

    @SuppressWarnings("UnstableApiUsage")
    public void sendPlayerToServer(@NotNull final Player player, String serverName) {
        ByteArrayDataOutput byteArrayDataOutput = ByteStreams.newDataOutput();
        byteArrayDataOutput.writeUTF("Connect");
        byteArrayDataOutput.writeUTF(serverName);
        player.sendPluginMessage(plugin, "BungeeCord", byteArrayDataOutput.toByteArray());
    }
}

CommandListener.java:

public class CommandListener implements Listener {
    private final LimboCore plugin;

    public CommandListener(LimboCore plugin) {
        this.plugin = plugin;
    }

    @EventHandler
    public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
        Player player = event.getPlayer();
        String command = event.getMessage();

        if (command.startsWith("/")) {
            command = command.substring(1);
        }

        if (shouldSendToLobby(command)) {
            sendToServer(player, "lobby");
        }
    }

    private boolean shouldSendToLobby(String command) {
        boolean autoLobbyCommand = plugin.getConfig().getBoolean("auto-lobby-command", true);
        return autoLobbyCommand && (command.equals("lobby"));
    }

    private void sendToServer(Player player, String serverName) {
        plugin.getBungeeUtils().sendPlayerToServer(player, serverName);
    }
}
valid burrow
#

cant u just use normal commands?

#

dont really see the reason to listen to commandpreprocess

quaint mantle
#

With what? when we type "/" or the slash substring command

valid burrow
#

have you ever used the spigot api

inner mulch
#

and go into ur main class

#

then getCommand("commandName").setExecutor(clazz);

valid burrow
#

here

#

full tutorial

#

for commands in bungee

#

u dont need a listener

#

infact you shouldnt use a listener for that

#

NEVER!

quaint mantle
#

alright

#

lmme try

#

using normal command

inner mulch
#

then you dont need pluginmessages

sullen marlin
drowsy helm
#

Not continuously

sullen marlin
#

I thought it was continuous but maybe I'm wrong

unborn breach
#

anyone making plugins for people? il pay decent

drowsy helm
#

?services

undone axleBOT
echo basalt
#

Pretty much yeah

unborn breach
#

ow thx

royal heath
#

Is it bad practice to use a singleton class to store references of multiple objects in a repository like manner?

For example if I have objects that are instantiated on start up from a config, would it be bad practice to put these in a list inside of a storage class, and access this storage throughout the application?

drowsy helm
#

Same thing as storing them in the JavaPlugin class, just modularised a lil

royal heath
#

Sounds good, thank you!

wet breach
#

where you don't want multiple instances of said classes

#

so you use a singleton for it

royal heath
#

Ahh okay, I wasn't too sure of the naming of these sorts of classes. I spent a long time googling wtf it was called what I was doing

wet breach
#

lol

#

well now you know

#

and also have your answer that your usage of singleton is acceptable

royal heath
#

perfect, thank you

slender elbow
#

the manager manager, the factory factory, and the registry registry

#

best buddies

remote swallow
#

what about the factory factory manager manager registry registry

river oracle
slender elbow
#

AsynchronousSocketChannelStreamFactoryFactory.Builder

icy beacon
#

I need a provider for that

#

AsynchronousSocketChannelStreamFactoryFactory.BuilderProviderRegistryStrategy

remote swallow
#

can i get manager for them

icy beacon
#

certainly, you can have a AsynchronousSocketChannelStreamFactoryFactory.BuilderProviderRegistryStrategyManagerSingleton and a AsynchronousSocketChannelStreamFactoryFactory.BuilderProviderRegistryStrategyManagerSingletonObserver

quaint mantle
tardy delta
#

boo

#

nerds

inner mulch
#

does some1 know how big servers have a robust system for all their cross server stuff? when using a messagebroker (what i think they use) how do they ensure this stuff is received on the server the player is on? or even that it is received, when the player leaves at the same moment?

echo basalt
#

Lots of locks and atomic operations

pseudo wraith
#

help

#

im on oracle ubuntu and my ssh has stopped working

#

when on the console I try ssh localhost it says connection timed out

fluid cypress
#

i want to save a history of transactions for each player, using a shop, /pay command, or whatever. up until now i have been using just the essentials economy. i tried to look for alternatives but apparently there is none that continues to be updated, or at least i couldnt find any (free, i mean)

#

so i guess ill have to implement my own economy provider. any idea how to do it? i know it has something to do with vault, but nothing else

eternal oxide
#

iConomy is maintained

#

Eco systems generally need no updating.

fluid cypress
#

ok but i specifically need a transaction history, does iconomy have that?

#

the spigot page is not very descriptive apparently

echo basalt
#

You could probably do something hacky by creating a proxy class

fluid cypress
#

and what does it mean by uuid support?

eternal oxide
fluid cypress
#

using uuids instead of player names i guess?

eternal oxide
#

thats a fork of the original iConomy 5 I did long ago

#

it says it requires towny but It doesn;t

fluid cypress
#

ok, does it have a transaction history or something?

eternal oxide
#

it has logging yes

fluid cypress
remote swallow
fluid cypress
eternal oxide
#

um, seems Llama added it back

#

I removed it when I came back

#

Yeah I remove the depend 4 years ago, odd how it got back in with no commit message mentioning it

fluid cypress
#

mm seems like I have to manually migrate from essentials to iconomy, do I?

eternal oxide
#

looks like you can;t use Ico unless you remove the depend in its plugin.yml

fluid cypress
#

im using it rn and i dont even know what towny is, so

eternal oxide
#

you sure? its got a depend so it shoudl error and not start

fluid cypress
#

yes, unless i have it installed as a dependency from something else, but its a dev server so i dont think so

eternal oxide
#

Yeah don;t use it. an Eco shoudl not be depending on Towny

fluid cypress
#

what you mean dont use it

#

towny or iconomy?

eternal oxide
#

um, that should be impossible

#

if its working for you use it, but it should not work at all

fluid cypress
#

it doesnt seem to have any dependency on the plugin.yml inside the jar itself, the one i downloaded from spigot

lilac dagger
#

frconomy is better than iconomy @eternal oxide

fluid cypress
#
# General Data
name: iConomy
main: com.iCo6.iConomy
version: 6.0.10b

# Command Data
commands:
    money:
      aliases: [iConomy, iCo]
      description: Distrobute, Check, Use Currency.

# Generator Data
generators: [bukget]
categories: [ECON]
description: Simple, easy, and intuitive economy for minecraft.
maintainer: Nijikokun
authors: [Nijikokun, SpaceManiac]
website: http://ico.nexua.org
thread: http://bit.ly/iConomy
location: "http://mirror.nexua.org/iConomy/Latest Build/iConomy.jar"
conflicts: []
required: []
optional: [Permissions]
engine:
    craftbukkit:
        min: 0
        max: 1100
    glowstone:
        min: 1
        max: 100
fluid cypress
#

btw i dont think it should be called SpigotPlugin.jar

lilac dagger
#

frconomy is what iconomy wanted to be

fluid cypress
#

?

eternal oxide
#

I forked iCo5 as it was simple and just worked. iCo 6 was a nasty monster

lilac dagger
fluid cypress
#

why is it a nasty monster

eternal oxide
#

You can no longer use the iCo5 fork though ans thats been locked to Towny

#

I don;t remember now but I remember everyone hating it

fluid cypress
#

mmm then, back to implementing my own economy provider?

eternal oxide
#

it was a lot of years ago

fluid cypress
#

it shouldnt be that hard, i mean

#

i just dont know which classes to inherit and all that

#

is there any docs for it?

eternal oxide
#

its not, just depends what you need your eco to do

#

just Economy.class

fluid cypress
#

the same as the basic essentials economy provider + a history

fluid cypress
eternal oxide
#

yes

fluid cypress
#

ok so extend from that class, implement all its methods

#

but how do i register it, i need some docs or something

eternal oxide
#

just register it as a service provider

#

with Bukkit

fluid cypress
lilac dagger
#

wait

#

iconomy 5 is not looking bad at all

fluid cypress
#

ok so, if i want to withdraw from a player from another plugin, and i want to add details to my history thing, is there a way i can do that?

#

like, when i implement withdrawPlayer, can i add a third optional parameter or something like that, just for some plugins to use (meaning my own)

#

bc if i manually create an entry in the history after withdrawing, how can i know from the economy provider side that i will do that, and not create a log from there bc of that?

#

or maybe i can "prepare" the provider for the transaction, giving it details about it beforehand

#

assuming its all a single thread and synchronous, if there is a plugin that does the withdrawal or the payment in another thread, that could break it, right?

native gale
#

Just syncronize it with the scheduler then

eternal oxide
fluid cypress
#

yea but i mean, the other plugins that i didnt make

fluid cypress
#

then i dont know how could i achieve that, without having to reimplement the withdraw logic from all other plugins, like quickshop, plotsquared, and all of that

#

at least it could be nice to know which plugin initiated the transaction, is there any magic way to know that?

#

like looking at the call stack or something

native gale
#

What people tell you here is to use Vault for economy, afaik, both Essentials and Plotsquared rely on it (I might be wrong)

#

You replace Essenatials economy with your own implementation, hook it into Vault and it will just work

#

(theoretically)

fluid cypress
#

yea, i know that, but the vault methods for withdrawal and all of that

#

only have the player and the amount

#

nothing else, like details or something

#

not even the plugin that called the method

#

and thats what i wanna know, a transaction history of only the amounts is not very informative imo

native gale
#

I mean, the point of using the interface is decoupling the consumer and provider

fluid cypress
#

i could at least show the plugin, like quickshop, plotsquared, the pay command, whatever, and then specify a bit more, doing some weird stuff, on the transaction originated by my own plugins

native gale
#

your plugin doesn't know what calls these methods, and callers don't know who handles the calls

#

So you're able to swap them all hovewer you wish

fluid cypress
#

yea, that makes sense for making them all compatible with everything

#

and not having to add every single economy provider as a dependency

#

but, it would have been nice to add something, even just a string that you could parse as json or whatever

#

to do stuff like logging, i dont think thats a niche feature

native gale
#

Eh, the author of Vault didn't think about that back when was designing it. Good news is that it's opensource and even updates once in a couple of years

#

Though, I don't think you can do much here, even if the Vault updates the interface, plugins have to adapt to it first

fluid cypress
#

yea, you would have to update all consumers

#

but thats why i was thinking about checking the call stack

#

to even get just the jar file name of the plugin that used the withdraw or pay method

#

can i do that? maybe getting a class by name somehow, and then getting the jar that contains it? is that possible in any way?

native gale
#

Hmm, I'm not that good ||(aka I suck at)|| in metaprogramming in Java

#

Maybe someone else knows

ivory sleet
#

not entirely reliable

ivory sleet
#

i thought either u could walk through the stack trace and get the class loader and if its the plugin class loader… bingo, or maybe grab whatever class through the reflection thingy that gets the caller class

native gale
#

I think these might be useful

native gale
#

Get the previous caller > Get it's class > Get the name of .jar file

ivory sleet
#

No need to get the jar file?

#

You can probably grab the plugin instance from the plugin class loader and then fetch the name

native gale
#

classname = Thread.currentThread().getStackTrace()[2].getClassName()

#

Uhh

#

Class.forName(classname).getProtectionDomain().getCodeSource().getLocation()

#

I think something like this, I might be very wrong though

ivory sleet
#

I mean there is StackWalker also

native gale
native gale
native gale
ivory sleet
#

Yea well I was just suggesting java’s built in class for traversing a callstack ^^

native gale
#

All what I just wrote

#

I learned less than 10 minutes ago

#

By lurking the documentation

#

I have no idea if it will work or not

fluid cypress
tardy delta
#

StackWalker?

fluid cypress
#

just an identifier

#

the plugin name

fluid cypress
#

and from there just get the plugin name

#

the thing is i know nothing about metaprogramming in java, and idek if thats the right term to use

#

so ill have to try all that, but before that i need to implement the economy provider

kindred sentinel
#

I'm not sure but something went wrong

tardy delta
#

something lagging

#

dunno if /timings is a spigot or paper thing but could try that

glad prawn
#

both

remote swallow
#

use spark

tidal kettle
#

can i prevent a player to break an end crystal with an event

#

because interacevent didn't work

royal heath
#

Yes, call the BlockBreakEvent and check if the block is an end crystal

#

then set setCancelled to true

broken nacelle
royal heath
#

Ah yeah good point

#

Didn't think of that

broken nacelle
kindred sentinel
#

Is Brewery made of tick function?

royal heath
#

Try EntityInteractEvent

tidal kettle
#

okay i try

outer cloak
#

everytime i change the pvpmanager config from this
Anti Border Hopping:
Vulnerable: true
Push Back:
Enabled: true
to this
Anti Border Hopping:
Vulnerable: false
Push Back: true
Enabled: true
and i save it then i refresh the page and its just goes back for some reason
i rly need help

#

and i cant even use the spawnshield plugin because it just tells me and inernal error occured

sinful matrix
#

Hello Guys
I am currently programming a spigot plugin where I need PlayerConnection. However, this is not found

tardy delta
#

sounds like nms

#

are you using the spigot dependency instead of spigot-api?

sinful matrix
#
repositories {
    mavenCentral()
    maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
    maven("https://libraries.minecraft.net/")
}

dependencies {
    implementation("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT")
    compileOnly("com.mojang:authlib:1.6.25")
    testImplementation(platform("org.junit:junit-bom:5.9.1"))
    testImplementation("org.junit.jupiter:junit-jupiter")
}
#

Those are my build.gradle dependencies

#

And there is spigot-api

chrome beacon
#

So the answer is no

#

If you're going to make NPCs I recommend just using Citizens

sinful matrix
tidal kettle
#

how can i cancel an event if a player interact with an entity in PlayerInteractEvent

chrome beacon
#

PlayerInteractAtEntityEvent

tidal kettle
#

punch a mob for example

broken nacelle
#

EntityDamageByEntityEvent

tidal kettle
#

i have error in PlayerInteractEvent when punching an end_crystal

#

can i like see if the block is an end_crystal and cancel the event?

chrome beacon
#

An end crystal is an entity

tidal kettle
#

in playerInteractEvent

chrome beacon
#

not a block

tidal kettle
#

yes but

#

i got error

rapid vigil
#

then share code and error :p

tidal kettle
#

event.getClickedBlock()).getType())

chrome beacon
#

There is no block if you're clicking on an entity

sinful matrix
#

It shows syntax errors if i change spigot-api to spigot

chrome beacon
#

Have you run BuildTools yet

sinful matrix
chrome beacon
#

Also I recommend using one of the Remapping plugins

#

So you don't end up working with an obfuscated environment

broken nacelle
#

if (event.getMaterial == Material.END_CRYSTAL)

sinful matrix
chrome beacon
#

you can but that would make everything harder for yourself

#

Good luck writing nms code with methods such as a(), b() and c()

tidal kettle
rapid vigil
tidal kettle
#

it work but

tidal kettle
#

getMaterial return Material.AIR and after the material so don't use it

#

use event.getClickedBlock().getType()

broken nacelle
#

Material.class

broken nacelle
broken nacelle
#

and check if the entity is a crystal

#

and the damager is a player

#

then cancel the event

tidal kettle
#

problem is i need to use playerintercat event

#

apart if an event who only check block exist

#

but i don't think

#

like the same event but with block only

broken nacelle
#

and cancel

tidal kettle
#

End_Crystal when place is an entity

rapid vigil
gentle inlet
#

Hi, I'm having a lot of trouble try to do this as I'm quite bad a coding. I was wondering if you could give me a code example that does what you say. I'm sorry if this is too much to ask

wet breach
#

your better off attempting it yourself and then showing your code here. This way, even if I am not here as well as I am not always the best, it gives others the ability to help you 🙂

#

I typically don't spoon feed and instead give you pseudo code or concepts 😄

gentle inlet
#

lol

wet breach
#

pretty sure someone around here has some kind of library for tasks in fact

#

just can't remember who that was

remote swallow
#

aikars task chain?

wet breach
#

maybe? Thought someone else had one that wasn't as complex

gentle inlet
#

if just searching for tasks libary on this discord rn

remote swallow
#

oh are you talking about work distro

#

?workdistro

tardy delta
wet breach
#

maybe

#

their issue from yesterday in a code piece they showed, they were creating tasks but they never died and they never bothered checking if a task already existed

#

and thus eventually their server crashes and burns

#

so I suggested that they implement a check for an existing task as well as implementing in the task code a check that would kill the task

#

so now you know their issue, anyways reason I brought up a task library was merely so they could see how it could be done

#

not exactly to be used but I suppose they could lol

chrome beacon
#

then just keep a reference of the task and stop the old one if you want to make a new task

#

also does that task need to keep running forever?

wet breach
chrome beacon
#

Then one task is enough

wet breach
#

but I will let them explain since they are here 😄

gentle inlet
wet breach
#

and there is some helpful devs about

chrome beacon
#

No need to create more than one task

wet breach
#

or they could go with a worker queue

chrome beacon
#

You don't really need a task per player

chrome beacon
gentle inlet
wet breach
#

it works like the task scheduler in the api, you put the things you want done into a queue, and then you have worker threads that spawn to clear out the queue and do work on those tasks. Handy to distribute work load and keeping track and what have you

#

there is a variety of ways to implement it depending on your needs

quaint mantle
#

Async Await

ivory sleet
#

CompletableFuture<T>

tardy delta
#

extends ItemStack oh no

#

server isnt gonna respect your itemstack

#

also so much mismatched responsabilities

worthy yarrow
#

I love 500 line listener classes

worthy yarrow
quaint mantle
# gentle inlet This is what ive got so far: https://paste.md-5.net/omuqaqajez.cs

Something you did not ask for:
On each case statement, you can extract

meta.setDisplayName("§aʀᴇʟɪᴄ ᴏꜰ §4§lᴄᴏᴍʙᴀᴛ 1");
lore.add("§f§lᴄᴏɴᴛʀᴏʟ §4§lғɪɢʜᴛɪɴɢ");

To before the switch statement so it always gets added regardless of the level

Also, avoid writing comments, they are something that can confuse you in the future, as if you change a line of code for which you have a comment, that comment would be now "outdated" with the new code, and the compiler won't even tell you about it because comments are not code

tardy delta
#

Arrays.asList

quaint mantle
quaint mantle
#

If you try push instance of it to inventory you may get a exception

quaint mantle
#

It might break

#

Allright, so that might be the problem

public void sphereTask(Player player) {
        Location loc = player.getLocation();
        player.getWorld().playSound(loc, Sound.BLOCK_BEACON_ACTIVATE, 10f, 0f);
        final int[] i = {0};
        final boolean[] f = {false};
        int id = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(WardenRelics.getInstance(), new Runnable() {
            @Override
            public void run() {
                double radiusSquared = 40; // Radius squared, adjust as needed
                for (Player players : loc.getWorld().getPlayers()) {
                    if (players.getLocation().distanceSquared(loc) <= radiusSquared) {
                        if (players == player) {
                            players.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 20, 4)); // 20 ticks = 1 second
                        }else {
                            players.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 40, 9)); // 20 ticks = 1 second
                        }
                    }
                }
                createSphere(loc, 0.03 * i[0], (i[0] + 1) * 0.03);
                if (i[0] <= 1) {
                    f[0] = false;
                }if (i[0] >= 20) {
                    f[0] = true;
                }
                if (f[0]) {
                    i[0]--;
                } else {
                    i[0]++;
                }
                i[0] %= 33.333;
            }
        }, 0, 1);
        Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(WardenRelics.getInstance(), new Runnable()
        {
            @Override
            public void run() {
                Bukkit.getScheduler().cancelTask(id);
                sphereEnd(loc, player);
            }
        }, 200);
    }
#

You are creating a 1 tick delayed repeating task

tardy delta
#

whoa

quaint mantle
#

And you schedule it for 10 seconds

#

This is good for 1-4 players

#

When there's 20 it might go wrong

worthy yarrow
#

@tardy delta you didn't mention the lambda method as oppose to the anonymous methods haha

tardy delta
#

i didnt mention shit

#

its too much

worthy yarrow
#

Actually

#

Yeah that's true lol

gentle inlet
worthy yarrow
#

@gentle inlet first thing I'd work on is seperation of concerns

quaint mantle
worthy yarrow
#

The fact you have like 10 different functions in one class is already clogging enough, that being said start moving your specific functions to specific classes... this helps you avoid 500 line monsters that are incredibly hard to maintain and read through

gentle inlet
worthy yarrow
#

I mean it depends on your whole structure, I like to keep my classes function specific

quaint mantle
#
worthy yarrow
#

ie: a group of methods that work to achieve one thing should be in it's own class

#

Keep your concerns separated like this^ and you'll begin to have a way easier time maintaining

tardy delta
quaint mantle
#

It's an hour talk of good things

worthy yarrow
tidal kettle
#

hey i got an error with playerInteractEvent when i right click an end_crystal with an item in my hand, the "event.getClickedBlock().getType()" is null and i got an error, did anyone know why?

gentle inlet
slender elbow
#

you are clicking an entity, not a block

tidal kettle
worthy yarrow
# gentle inlet Oh i see what you mean alright
private boolean isOnCooldown(Player player) {
        return cooldowns.containsKey(player) && System.currentTimeMillis() < cooldowns.get(player);
    }
    private boolean isOnCooldown2(Player player) {
        return cooldowns2.containsKey(player) && System.currentTimeMillis() < cooldowns2.get(player);
    }

    private void startCooldown(Player player) {
        cooldowns.put(player, System.currentTimeMillis() + cooldownTimeMillis);
    }

    private void startCooldown2(Player player) {
        cooldowns2.put(player, System.currentTimeMillis() + cooldownTimeMillis2);
    }


    private String getCooldownMessage(Player player) {
        if (isOnCooldown(player)) {
            long remainingTimeMillis = cooldowns.get(player) - System.currentTimeMillis();
            long remainingTimeSecs = remainingTimeMillis / 1000;
            return "§6" + remainingTimeSecs + " Secs";
        } else {
            return "§aReady!";
        }
    }

    private String getCooldownMessage2(Player player) {
        if (isOnCooldown2(player)) {
            long remainingTimeMillis2 = cooldowns2.get(player) - System.currentTimeMillis();
            long remainingTimeSecs2 = remainingTimeMillis2 / 1000;
            return "§6" + remainingTimeSecs2 + " Secs";
        } else {
            return "§aReady!";
        }
    }```

Like this bit could be put into it's own "Cooldown class" of sorts
tidal kettle
#

and i didn't know why

slender elbow
#

yeah because you're trying to get the clicked block

#

but there is no clicked block

#

because it's an entity

worthy yarrow
tidal kettle
worthy yarrow
slender elbow
#

check the event action

#

there's also an event for interacting with an entity? PlayerInteractEntityEvent I think? I don't remember the exact name

tidal kettle
#

but i wan't to use PlayerInteractEvent because i need to check if the block is a chest, an anvil , etc

slender elbow
#

check the action to make sure it's a block

tidal kettle
#

umm

tidal kettle
#

with action you can only check if it's right or left click ?

slender elbow
#

you can check if it's right/left click block/entity

#

look at the enum

tidal kettle
#

OO

#

I SEE

tidal kettle
slender elbow
worldly ingot
#

Emily already making good use of the new emote by threatening those asking for help

slender elbow
#

yep

#

you better be grateful

worldly ingot
#

"or else >:("

worthy yarrow
#

Why don't spigot have more emotes

worldly ingot
#

Nobody's suggested any :D

worthy yarrow
#

We need a cat being pet

worldly ingot
#

If you can find one, propose it to md when you see him next and he may add it :p

eternal night
slender elbow
worldly ingot
#

weeb

eternal night
slender elbow
worthy yarrow
worldly ingot
#

He's usually here every night

#

Night EST, that is

worthy yarrow
#

Yeah but that's only a 15 minute window kek

#

@worldly ingot do you know of any display entity drawbacks? General ones rather

worldly ingot
#

They're not interactible. That's really the only flaw with them imo.

worthy yarrow
#

I saw someone doing some funky omni color blocks the other day and I wanna know how easily achievable that is

slender elbow
#

something something interaction entities

worldly ingot
#

I know about interaction entities!

#

:(

worthy yarrow
#

Idk I just want to expand with display entities but idk what to do to the damageHolograms plugin

#

(past damage indicator holograms anyway)

tidal kettle
#

is EntityCombustEvent work for end_crystals?

worthy yarrow
#

It only works for engines unfortunately :p

tidal kettle
#

or maybe EntityExplodeEvent

#

is better

worldly ingot
#

It would be the explode event, yes

rapid vigil
worldly ingot
#

I mean, assuming you're looking for an explosion lol

remote swallow
worldly ingot
#

Combust event is for entities being lit on fire

worthy yarrow
#

Oh snap

#

choco

#

You just gave me a new temperature change trigger thank you sir

blazing ocean
#

what do I cast to org.bukkit.block.Sign? can I cast a Block?

tidal kettle
slender elbow
tidal kettle
#

right click doesn't break end crystal...

rapid vigil
#

oh right

tidal kettle
#

x)

rapid vigil
#

I totally forgot :-:

worldly ingot
#

I think you're looking for EntityExplodeEvent then, yes

tidal kettle
#

but the code you gave me is (i think) gonna be usefull for me for later 😄

worthy yarrow
#

That's always the hope aint it

rapid vigil
#

hope that makes sense :p

tidal kettle
#

but the end crystal disapear

#

just have to get the location and place another one, i hope i'm not going to create a duplication glitch lol

rapid vigil
#

oh right that just cancels the explosion, cancel the EntityDamageByEntityEvent on ender crystals instead then

worthy yarrow
#

If you cancel the explode event that should be enough shouldn't it?

rapid vigil
tidal kettle
gentle inlet
#

@EventHandler public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); ItemStack relic = new ItemStack(Material.ECHO_SHARD); ItemMeta randomItemMeta = relic.getItemMeta(); randomItemMeta.setCustomModelData(102); relic.setItemMeta(randomItemMeta); if (player != null) { player.sendMessage("join"); } }

Why is the playerjoin event running multiple times when i join i got 8 messages saying "join"

worthy yarrow
rapid vigil
rapid vigil
#

oops

worthy yarrow
gentle inlet
worthy yarrow
#

😛

gentle inlet
worthy yarrow
#

Please cuz that makes no sense

blazing ocean
gentle inlet
rapid vigil
worthy yarrow
#

Ah

#

do the check before you declare the player maybe

worldly ingot
#

org.bukkit.block.Sign, cast Block#getState()
org.bukkit.block.data.type.Sign, cast Block#getBlockData()

blazing ocean
#

it's the first one, will try

worldly ingot
#

State contains NBT data about the sign, so if you're wanting to edit lines and whatnot, that's the one you want

blazing ocean
#

ty

quaint mantle
#

@sullen canyon sir could you help me with my plugin?

worthy yarrow
worldly ingot
#

I think you have another plugin doing something stupid that it shouldn't be

#

There's no reason your PJE should be firing more than once, or for your Player to be null for that matter

worthy yarrow
#

Maybe it's that

worldly ingot
#

It smells like AuthMe or something

worthy yarrow
#

the player is null...

#

WHAT

worldly ingot
#

What would help is the stacktrace because it would tell you what plugin called the event

blazing ocean
#

keep it english

worthy yarrow
blazing ocean
#

was that optic or choco 👀

remote swallow
#

prob choco

rapid vigil
#

choco

gentle inlet
worthy yarrow
#

Well error + stacktrace

gentle inlet
worthy yarrow
#

Looks like that

#

we need the caused by

gentle inlet
worldly ingot
#

The error you get on startup, yes

worthy yarrow
gentle inlet
worldly ingot
#

Well there's an error somewhere if your plugin is red

worthy yarrow
tidal kettle
#

uuh another question with end_crystal
Ow can you set a end_crystal in the world? loc.getBlock().setType(Material.END_CRYSTAL); didn't work (loc = event.getLocation();)

worldly ingot
#

End crystals are entities, not blocks

#

You would have to spawn one

gentle inlet
worthy yarrow
#

ctrl F and search the name of your plugin in the log

tidal kettle
worldly ingot
#

That's the error we want. What does your RelicOfCombat class look like?

worthy yarrow
#

Show us

tidal kettle
#

someting like spawnentity?

worldly ingot
#

Yes, spawnEntity() or spawn() would work fine

remote swallow
#

can i spawn a 2nd choco

tidal kettle
#

umm

worldly ingot
#

And can we see your onEnable() and registerEvents() methods?

#

The Player you're passing to that constructor is null

#

I'm unsure how you're getting a Player at all from your onEnable() to begin with

tidal kettle
worthy yarrow
#

It's coming from before the player has actually joined so that's weird

tidal kettle
#

i think this is not possible but can you make the little bedrock thing disapear...

worthy yarrow
#

pm.registerEvents(new RelicOfCombat(0, null), this);

#

I assume the fact you're passing "null" here is the issue

worthy yarrow
#

That being said, you have to get the player some other way within relicOfCombat class

gentle inlet
#

But anyway can someone actually help with what I asked for lol

worthy yarrow
#

What did you ask for?

gentle inlet
worthy yarrow
#

Try fixing the null thing first then test it again

#

And then we can see if it's still trying to trigger 8 times

tidal kettle
# tidal kettle

someone know if it is possible to have only the end crystal and not the bedrock thing?

quasi gulch
tidal kettle
#

how can i set a variable to be a EnderCrystal?

#

with the loc

worthy yarrow
#

I wonder if you could map it to an offset

tidal kettle
#

idk

rapid vigil
tidal kettle
#

kay i try

worthy yarrow
tidal kettle
#

bruh

#

ur so strong

#

it work

worthy yarrow
#

So you don't need a location?

rapid vigil
worthy yarrow
#

I thought he needed to like cache a location though lol

#

Didn't realize he was simply just spawning it

rapid vigil
#

haha

worthy yarrow
rapid vigil
worthy yarrow
#

boo

#

I wanna do some cool stuff, but I don't know what exactly that entails

rapid vigil
#

I will probably give it a try some day :p

worthy yarrow
#

They are really fun

worthy yarrow
#

Anyways I've got damage indicators, what do I do with em now...

rapid vigil
#

stuff ig

worthy yarrow
mortal hare
worthy yarrow
gentle inlet
# worthy yarrow And then we can see if it's still trying to trigger 8 times

@EventHandler public void onPlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); ItemStack relic = new ItemStack(Material.ECHO_SHARD); ItemMeta randomItemMeta = relic.getItemMeta(); randomItemMeta.setCustomModelData(102); relic.setItemMeta(randomItemMeta); player.sendMessage("join"); startTaskForPlayer(player); }

Fixed null thing and now for some reason it says join 2 twice not 8 times now

worthy yarrow
#

Is that the only onPlayerJoin method you have?

sullen canyon
#

@echo basalt is life going zaebis?

worthy yarrow
#

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();

}

this is in your main class btw

#

Try removing that

gentle inlet
#

ok

gentle inlet
worthy yarrow
# gentle inlet ok

Also, after removing that you can take away ", Listener" at the top as well, you don't need your main to be a listener

worthy yarrow
gentle inlet
worthy yarrow
#

Uh wherever the onPlayerJoin method is

gentle inlet
#

what was the paste website again?

worthy yarrow
#

?paste

undone axleBOT
gentle inlet
#

?paste

undone axleBOT
gentle inlet
#

thanks lol

worthy yarrow
#

Are you creating multiple instances of that class?

gentle inlet
worthy yarrow
#

No worries so firstly let me give you the links

#

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

worthy yarrow
#

Ok and secondly, you should move all the eventhandler methods to another class

#

So make a new class that handles the event listeners

worthy yarrow
#

After you do that, go to your main class and redo the event registry method to match the appropriate listener class

tidal kettle
#

how to delete entities?

worthy yarrow
#

should be entity#remove

tidal kettle
#

i can get entities in a raduis with getNearbyEntities

#

but

#

umm

worthy yarrow
#

What are you trying to delete? The crystals?

tidal kettle
#

yep and it work

worthy yarrow
tidal kettle
#

the java doc say that is mark the entitie as remove so i was thinking it didn't remove the entity

#

but it work

gentle inlet
worthy yarrow
#

Ah ok, so you need to move the cooldown logic either to that class, or to another class that will be your cooldown class or wtv, you use di (dependency injection) to get an instance of that class + it's methods so you can access isOnCooldown(player), startCooldown(player), etc. Or if you wanted to do it lazily, the first option, you just move the logic to that listener class

#

The second option makes this project easier to expand on when it comes to cooldown related stuff

tidal kettle
#

can i get a player by Entity?

#

like cast it to something

worthy yarrow
#

Only if the entity is actually a player

#

So make sure to check that first

pseudo hazel
#

if (entity instanceof Player player) {
player.eatShit()
}

#

for example

worthy yarrow
#

^

slender elbow
#

woah

worthy yarrow
#

But also

#

that's rude

slender elbow
#

when did spigot add that method

pseudo hazel
#

1.21

slender elbow
#

epic

pseudo hazel
#

atleast youll remember it now

tidal kettle
#

bruh it doersn't gonna work in EntityExplodeEvent

pseudo hazel
#

event.getEntity() instanceof Player player

gentle inlet
tidal kettle
#

i dont think endcrystal is a player x)

worthy yarrow
pseudo hazel
#

then it wont work

#

but then again, what is in the explode event

gentle inlet
tidal kettle
#

x)

pseudo hazel
#

maybe the endcrystal knows what hit it

tidal kettle
#

maybe the handler?

worthy yarrow
tidal kettle
#

event.getHandlers()

pseudo hazel
#

wdym by the handler

#

no

worthy yarrow
pseudo hazel
#

thats all methods/classes that handle the event

#

thats what every event has

tidal kettle
#

i think i can't get the player

#

maybe if i do entityDamagebyEntity and then instanceof EntityExplodeEvent?

gentle inlet
worthy yarrow
#

You made all the changes?

gentle inlet
worthy yarrow
#

Send me pastes of the main, relics, listener, and the cooldowns class if you made one

tidal kettle
#

men

#

EntityDamageByEntityEvent

#

is what i want for an hour

worthy yarrow
#

it happens man

tidal kettle
#

?paste

undone axleBOT
charred blaze
#

whats a namespace?

vast ledge
#

It's a namespace?

#

it a string of characters, in addition to a plugin instance

charred blaze
vast ledge
#

What are you trying to do?

charred blaze
#

persistentdata

vast ledge
#

?pdc

charred blaze
#

again what is namespace?

vast ledge
#

"Represents a String based key which consists of two components - a namespace and a key. Namespaces may only contain lowercase alphanumeric characters, periods, underscores, and hyphens."

charred blaze
#

it literally starts talking about it

vast ledge
#
NamespacedKey key = new NamespacedKey(plugin, "your namespace")
charred blaze
#

lemme rephrase my question. does namespace mean anything in english language?

vast ledge
charred blaze
#

aaaaaaaa

#

thanks

vast ledge
#

ex

NamespacedKey myCustomItemIdentifier = new NamespacedKey(plugin, "myCustomItem")

if(item.getItemMeta().getPersistenDataContainer().get(myCustomIdentifier, PersistenDataType.BOOLEAN)) return isCustomItem = true;
return isCustomItem = false;
tardy delta
#

nice npe

mild walrus
eternal oxide
vast ledge
#

I wrote that without code reference, but thats probably better

potent ocean
#

Anyone know how to change the server name, like when doing Bukkit.getServer().getName()?

tardy delta
#

i believe its packets

tardy delta
#

or that ye

potent ocean
#

So they must have gotten rid of the way in the server.properties

hazy parrot
#

yeah, its hardcoded

undone axleBOT
potent ocean
# sullen marlin ?xy

Well, I had just gotten confused I thought Bukkit.getServer().getName() would return Unknown Server or whatever it would be in server.properties since when I last used it.

#

I had just thought it was moved somewhere else, sorry for the confusion tho

storm crystal
#

how can I introduce getOrDefault based on type?

carmine mica
#

I don't think you want the same generic param for both generic parms of PersistentDataType

#

but you would just add another parameter of the "value" generic type

storm crystal
#

like that?

worthy yarrow
glad prawn
storm crystal
#

what does def stand for?

glad prawn
#

default

glad prawn
storm crystal
storm crystal
#

I uh

#

got the wrong order

glad prawn
# storm crystal

I see you seem to be overloading this method quite a lot. You can still use generic for the second parameter if you understand how to use it.

sullen belfry
#

?paste

undone axleBOT
sullen belfry
sullen marlin
storm crystal
#

I dont use another method with same name

glad prawn
#

You can have many methods have the same name but different parameters.

storm crystal
#

And im not doing that

#

Is this what you mean

glad prawn
#

yeah

storm crystal
#

Why would I make several methods to get pdc

glad prawn
#

you can have just one

#

with generic

storm crystal
#

So why am I overloading it a lot

#

Im not creating any methods of same name

glad prawn
#

uh k, so it's fine for u

storm crystal
#

You said im overloading it, I looked up the definition and it doesnt seem like Im doing it

#

I really dont understand you

glad prawn
#

It's just that I see above that there are 2 methods with the same name but different parameters, so.

storm crystal
#

No its the same method

#

I was editing it

storm crystal
glad prawn
#

Nothing

storm crystal
#

I finally did something good

#

Lol

glad prawn
#

🤔

pearl forge
#

hello, I come to ask if it is possible to call a function from a datapack in a plugin, is it possible?

chrome beacon
#

Should be possible

young knoll
#

If nothing else you can run the function command

spice burrow
#

How should I go about preventing the block break animation destroy stage from resetting? i.e. whenever its on stage 5/9 and mining stops it resets to -1. I want that stage to remain at 5 when mining stops (essentially saving mining progress)

I try to set the destroystage to the status of the current animation, but since it resets it doesn't retain the packet info.

my code


  @Override
  public void onPacketSend(PacketSendEvent event) {
    //        Cross platform user abstraction
    User user = event.getUser();
    //    whenever player receives a block break animation packet
    if (event.getPacketType() == PacketType.Play.Server.BLOCK_BREAK_ANIMATION) {
      WrapperPlayServerBlockBreakAnimation breakAnimation =
          new WrapperPlayServerBlockBreakAnimation(event);
      Byte status = breakAnimation.getDestroyStage();
    // doesn't work
      breakAnimation.setDestroyStage(status);
    }
  }
young knoll
#

BlockDamageAbortEvent -> Player#sendBlockDamage

#

The only issue is I don’t think there is a way to get the damage progress of a block, so you’d need packets for that

spice burrow
#

Yea, that's what I was trying to do with the break animation packet with the packetevents lib

young knoll
#

You’re just setting the destroy stage to what the destroy stage already was…

#

That’s not going to change anything

#

If the server sends the packet to reset it to -1 you can just cancel that

#

But I assume the client handles that

vagrant stratus
slender elbow
#

pass

native nexus
#

wtf

vagrant stratus
#

Yea, ChatGPT didn't figure it out either LMFAO

young knoll
#

Confusion?

#

Isn’t the least amount 2/1

vagrant stratus
#

Ya boi has problems and they need solved

young knoll
#

If you want infinity I’m pretty sure you can get everything in a single enchantment use

#

Otherwise you need 1 enchantment and then 1 anvil use to add mending

#

Ah I see

native nexus
#

why in python and not just java

spice burrow
vagrant stratus
# young knoll Isn’t the least amount 2/1

Yes, but given the mess that is my storage the fun is

  1. Finding every valid combination
  2. Preferably doing it in the least amount of books & bows while providing the most amount of valid combinations
#

I'd throw them away but server econ 👀

vagrant stratus
young knoll
#

Grindstone them, then throw em away

vagrant stratus
young knoll
#

Are they even worth much

#

The bow is generally the easiest part of my gear to make

vagrant stratus
#

Eh. I have a bunch enchants & bows, might as well throw automation at it

#

plus, if that specific issue can be figured out then it can be expanded to the other items on the list lol

vagrant stratus
#

Gotta make everyone broke LMFAO

worthy yarrow
#

I don't understand the prompt

slender elbow
#

that means you passed the Turing test

vagrant stratus
#

prompt?

shadow heath
#

Hello, I have an error, I want to lose half a hearth each time I activate a totem with EntityResurrectEvent, but sometimes it removes half a hearth and others an entire hearth

shadow heath
#

private int totemCount = 0;

@EventHandler
public void onEntityResurrect(EntityResurrectEvent event) {
if (event.getEntity() instanceof Player) {
Player player = (Player) event.getEntity();
totemCount++;

        // Check if every 3 totems are activated
        if (totemCount % 3 == 0) {
            // Calculate the new max health after removing 1.5 hearts
            double currentHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
            double newMaxHealth = currentHealth - 1.5;

            // Ensure the player's current health does not exceed the new max health
            if (player.getHealth() > newMaxHealth) {
                player.setHealth(newMaxHealth);
            }

            // Set the new max health
            player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(newMaxHealth);

            player.sendMessage("You lost a permanent cora and a half due to activating 3 totems!");
        }
    }
}
drowsy helm
#
   if (player.getHealth() > newMaxHealth) {
                    player.setHealth(newMaxHealth);
                }
#

this isnt necessary

#

and 1.5 is 3/4 of a heart

#

not half

river oracle
#

Yeah

royal heath
#

I know this is a Java question, but it could apply here as well.

If my plugin is using an SQLLite database, and say 2 players do something at the same time, will it lock and choose a victim, or will they be queued?

For example, someone joins and it say adds a coin to a table, but someone else joins at the exact millisecond, will one of these error, or will it queue? I know SQLLite does database locks, so I'm not sure what entails in this scenario.

Additionally, what if a player say runs /coins at the same time someone is writing to their coins on server join? Will it queue this, or will it throw an error on read?

#

I have no problem using MySQL, but with the scale of this I would like to use SQLLite to save resources

eternal oxide
royal heath
#

That's a true point, and I understand that. Just the off chance. I guess it shouldn't really be a concern as SQLLite is pretty fast

eternal oxide
#

You must do things sync for SQLite

#

There is no async access

worthy yarrow
#

Why is that?

eternal oxide
#

because it doesn't support async

worthy yarrow
#

Oh it's one of those kek

royal heath
#

Doesn't it just mean the database itself is synchronous?

eternal oxide
#

I believe it will throw an access violation or some other error if you try to use it async from two threads

#

lol nothing in java ever synchronises.

worthy yarrow
#

I should learn about threading

#

any recommendations for this?

eternal oxide
#

Its a bitch. I still get it wrong myself

royal heath
eternal oxide
#

nope they driver will just throw an error

worthy yarrow
royal heath
#

Ah okay

worthy yarrow
#

oh boy oracle source

eternal oxide
#

thats nice for handling sync access from many async threads

worthy yarrow
#

We love oracle

eternal oxide
#

it will basically make all other threads wait until it's free

worthy yarrow
#

So like a queue pool ?

eternal oxide
#

yes

worldly ingot
#

Java 7 docs?

eternal oxide
#

Theres many ways to do it, but basically you have to expose a thread safe API to hide your SQLite access

#

With Spigot so long as you are not on the main thread you can block

worthy yarrow
royal heath
#

Ah okay makes sense. Wouldn't work well then with my scriptable bot plugin.

I'll add MySQL functionality to it

worthy yarrow
#
void
clear()
Does nothing.  ```
...
royal heath
#

Sigma function

worthy yarrow
#
boolean
isEmpty()
Always returns true.```

There are a couple of them haha 😅
royal heath
#

"Does nothing"

rare rover
#

classic mojang code right here

#

Thread.sleep FR

worthy yarrow
drowsy helm
#

Just use thread.sleep(-1000) 4head

royal heath
#

Quantum Java

quaint mantle
worldly ingot
worthy yarrow
#

What do I work on other than smoke weed and wonder what I want to work on

nova notch
#

make a weed farm plugin?

worthy yarrow
#

Now that is just

nova notch
#

brilliant, i know

worthy yarrow
#

Why hadn't I thought of that

#

Where do we start with this is the question

#

It'd be cool to get some models but I have no clue how to work with those

nova notch
#

model engine

worthy yarrow
#

Last time I tried playing with meg, I just ran into a lot of frustration

#

I want to mess with display entities more, have you any ideas?

nova notch
#

uh

#

make your own model engine?

blazing ocean
#

will save you a lot of time

worthy yarrow
#

Hmm

#

Some brainstorming is in order

blazing ocean
#

maybe switch to #general

swift sable
#

god what am i doing wrong with skulls?!?!

            spiralBlock.setType(Material.CREEPER_HEAD);
            BlockState blockState = spiralBlock.getState();
            Skull skull = (Skull) blockState.getBlockData();
            skull.setRotation(blockFace);```

I think skull is depreciated too but i cant find the new one
spice burrow
#

If I add NPCs (via packets) that have custom logic and they display to all players on the server (within a specific range), will this tank performance heavily?

buoyant viper
#

well as long as ur logic code isnt pure dogwater id say nah ur probably fine

drowsy helm
#

which is generally more performant then checking it serverside

spice burrow
#

thanks homie

charred blaze
#
        for (Display display : ItemRotator.Displays.values()) {
            Slime hitBox = PersistentDataUtils.getHitBox(this, display);
            System.out.println(PersistentDataUtils.getDisplayItemName(this, hitBox));
            hitBox.remove();
            display.remove();
        }```
#

somehow this code doesnt remove itemDisplay?

#

i have this in ondisable

#

i even debugged it above

sinful matrix
#

So i implemented NMS, runned the BuildTools and imported local dependencie.
Why can i not call the function getProfile()?

inner mulch
charred blaze
#

WIll try that out

charred blaze
charred blaze
#

setPersistent worked

upper hazel
#

Is there a special event that monitors whether a player sets fire to blocks? To protect me from arson and similar things

tardy delta
#

bungee docs down?

#

doesnt appear to indicate nullability in the jd

bright spire
#

Hey guys, what happened to reflection? Nothing seems to be working anymore.

[06:05:33 WARN]: java.lang.NoSuchMethodException: net.minecraft.network.chat.Component$Serializer.a(java.lang.String)

hazy parrot
#

I doubt reflection stopped working

bright spire
#

I mean NMS

#

What happened to NMS?

hazy parrot
#

Most likely the method name changed in a different version

#

Are u using mappings ?

bright spire
#

Everything changed because no method is working, I would like to know from someone who knows what changed

bright spire
hazy parrot
#

?nms

bright spire
#

I am using reflection and this is since 1.20.5 spigot update

hazy parrot
#

u have to look at mappings to see what that method name changed to ¯_(ツ)_/¯

#

There are some online mappings but idk link

bright spire
#

Because everything dissapeared on this version

hazy parrot
#

No, as they are obfuscated names

bright spire
#

Dunno where it is anymore

#

Are there any plans to add getPipeline() methods to players or something similar?

#

the spigot api is not very useful

hazy parrot
#

Tbh doubt, that is pretty much internal api

hazy parrot
eternal oxide
#

?mappings

undone axleBOT
hazy parrot
#

Yeah that is the link ^

bright spire
#

Is there any serious dev chat were plugin developers are talking about this?

#

Not useful when I am trying to port my plugins to support 1.20.6