#development

1 messages Β· Page 31 of 1

worldly cobalt
#

Big brain

dusky harness
#

It'd work
But you'd have to register every single placeholder

#

And if there's duplicates then there's trouble

signal grove
#

you could say that about identifiers

icy shadow
#

how would that fix it?

#

you dont know which plugin the placeholder is coming from

dusky harness
#

Well not that exact map

icy shadow
#

if the identifier was the key that would maybe work

dusky harness
#

But the idea

#

Bad fix

#

But it'd theoretically work

icy shadow
#

but it still doesnt handle duplicates yeah

dusky harness
#

Yeah

signal grove
#

well plugins have to register with identifiers, and im those have an exception for duplicates

icy shadow
#

sounds like a whole lot of effort for very little gain

dusky harness
#

And reduces clarity

signal grove
#

yeah its not worth it for the devs to change that right now

dusky harness
#

I'm just saying it would "work" but not any better than with identifiers - mainly because of duplicates and clarity

#

Unrelated but {} > %%

#

Papi3 should do {} 😌

signal grove
#

() 😎

dusky harness
#

Sad
Last commit to Papi3 was a year ago

icy shadow
#

"xD"

lyric gyro
#

having both be % causes a whole load of issues

#

maybe that's a slight exaggeration but you can't really do nested placeholders

vital drum
#

why is this not working: ``` public void Kill(EntityDamageByEntityEvent event) {
Entity Damger = event.getDamager();
Entity entity = event.getEntity();
double damge = event.getDamage();
if (entity instanceof Player);{
if (Damger instanceof Player){
Player player = (Player) event.getEntity();
Player player1 = (Player) event.getDamager();
if (player.getHealth() == 0){
player.setMaxHealth(player.getMaxHealth() + 1);
player1.setMaxHealth(player1.getMaxHealth() + 1);
} else if (player.getHealth() < 0){
player.setMaxHealth(player.getMaxHealth() + 1);
player1.setMaxHealth(player1.getMaxHealth() + 1);
}
}
}

}
signal grove
#

you probably want to use a PlayerKillEvent

#

not an entitydamagebyentity if health == 0

#

what is the purpose, every time someone is killed, they both gain a maximum heart?

#

also, the damage hasnt been applied to the health yet, that happens after your listener, so using getHealth() will not be accurate. And the last condition will never be true, since health is always positive (probably)

vital drum
sleek wedge
#

how i modify paperclip?

#

im trying to make a paper fork

pulsar ferry
sleek wedge
pulsar ferry
#

Read the readme

sleek wedge
lyric gyro
#

if you want to fork paper, check the paperweight-examples repo

river solstice
#

why its kotlin :omegalul:

lyric gyro
#

I'm on mobile, it's there in the org

sleek wedge
sleek wedge
pulsar ferry
sleek wedge
#

oh, everything explains it self

river solstice
#

where's @EventHandler annotation, and did you register the listener

vital drum
#

yes i did

sleek wedge
vital drum
#

wait

#

how to fix that maven build plugin on wrong version

sleek wedge
#

hm?

dark garnet
#

how do i make a falling block never despawn? or at least last a long time?
ik its something to do with FallingBlock#setTicksLived(int), but im not sure what to use as the int

vital drum
sleek wedge
vital drum
#

i use maven to build the plugin

#

but maven build plugin on wrong version

sleek wedge
#

change the version that is on the .pom file

#

ig

sleek wedge
vital drum
#

yes

sleek wedge
vital drum
#

<version>1.19.2-R0.1-SNAPSHOT</version>

sleek wedge
vital drum
#

wich then?

sleek wedge
#

send .pom

vital drum
#
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>Drache</groupId>
    <artifactId>.de</artifactId>
    <version>Beta</version>
    <packaging>jar</packaging>

    <name>KeyAll</name>

    <description>Key all large small and meduim</description>
    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>8</source>
                    <target>8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

    <repositories>
        <repository>
            <id>papermc-repo</id>
            <url>https://repo.papermc.io/repository/maven-public/</url>
        </repository>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>io.papermc.paper</groupId>
            <artifactId>paper-api</artifactId>
            <version>1.19.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
</project>
sleek wedge
#
    <groupId>Drache</groupId> // groupID like io.github.sdxqw
    <artifactId>.de</artifactId> // name of the file
    <version>Beta</version> // my version of the jar
    <packaging>jar</packaging>```
vital drum
#

then how do i fix this?

sleek wedge
vital drum
#

it build on wrong minecraft version

sleek wedge
sleek wedge
#

which version you want?

vital drum
#

1.19.2

sleek wedge
vital drum
#

1.19.2

signal grove
#

what

sleek wedge
#

tf

vital drum
#

1.19.2

sleek wedge
#

its already there

#

lol

signal grove
#

^, just click build and it will replace the dependencies with paper 1.19.2

vital drum
#

but it dont work

signal grove
#

what doesnt work

sleek wedge
vital drum
#

ok

neat pierBOT
sleek wedge
#

are you trolling?

dusky harness
#

Is who trolling

#

@neat pier ?

vital drum
#

its to long

sleek wedge
icy shadow
#

dkim is an infamous troller

vital drum
sleek wedge
dusky harness
#

Funny cube has not fixed @neat pier in so long

sleek wedge
#

Das Handle ist ungΓΌltig

dusky harness
#

😦

signal grove
#

2 is outdated

dusky harness
#

There's like 3 issues with Barry that it had for like months

#

The paste being one of them

icy shadow
dusky harness
#

Partially fixable with modals

dusky harness
icy shadow
#

???

#

????????

vital drum
dusky harness
sleek wedge
sleek wedge
signal grove
#

whats the name of your plugin

sleek wedge
vital drum
#

yes

sleek wedge
#

pretty sure it BetterCrystal vBeta

sleek wedge
vital drum
#

its for discord webhook

sleek wedge
vital drum
#

why

sleek wedge
#

what

#

WHAT

signal grove
#

paste code

vital drum
#

when i make /pl the plugin is re

#

d

sleek wedge
#

because paperclip and paper-api cant load it

vital drum
#

how do i fix?

signal grove
#

2

sleek wedge
#

tf

#

did i miss something here?

signal grove
#

you missed 1

signal grove
vital drum
#

ok

sleek wedge
signal grove
#

use the paste to paste that, it's a bit large

neat pierBOT
signal grove
#

xD

sleek wedge
#

more worse

#

1 line code

vital drum
sleek wedge
#

why its parsin a link as a file?

vital drum
#

idk

sleek wedge
#

somethin is wrong with JSON

signal grove
#

im confused

vital drum
#

i send the main .jar file

signal grove
#
public final class de extends JavaPlugin {
    private URL url;
    public static  de INSTANCE;

    public de() {
        INSTANCE = this;
    }

it seems like the constructor stores an instances of itself?

signal grove
#

you won't need that, you can always just use 'this'

vital drum
#

yes

#

ok

sleek wedge
#

oh lmao

#

he call it

river solstice
#

using static instance access from the same class

#

hm

sleek wedge
signal grove
#

new design pattern just dropped

sleek wedge
#

using the this πŸ€“
using static instance from the same class 😎

river solstice
#

when does the new access modifier drop?
privatetoself

sleek wedge
vital drum
#

Do you see an error in the file apart from something else that could be done better?

river solstice
signal grove
#

im wondering how line 44 this.register() is not a syntax error

#

is that some paper thing?

pulsar ferry
river solstice
vital drum
# signal grove im wondering how line 44 ``this.register()`` is not a syntax error
        //listener
        PluginManager pluginManager = Bukkit.getPluginManager();
        pluginManager.registerEvents(new JoinQuitListener(), this);
        pluginManager.registerEvents(new ChatListener(), this);
        pluginManager.registerEvents(new DeathListener(), this);
        pluginManager.registerEvents(new CommandListener(), this);
        pluginManager.registerEvents(new SchildListener(), this);
        pluginManager.registerEvents(new CrystalSettings(), this);
        pluginManager.registerEvents(new PlayerHitListener(), this);
        pluginManager.registerEvents(new Hearth(), this);
        //commands
        Bukkit.getPluginCommand("firestrike").setExecutor(new FireSrikeCommand());

    }
signal grove
#

ah i didnt see that

vital drum
#

do you have any idea why the plugin is on wrong version

sleek wedge
signal grove
#

i dont think it's on the wrong version

#

what makes you think that

vital drum
#

the log says its on wrong version?

sleek wedge
#

command to paste?

#

!paste

neat pierBOT
sleek wedge
signal grove
#

the log probably says "wrong version?" because of your error

#

it is the right version

sleek wedge
#

ong 1 line code

#

alright have fun readin it

#

im out

vital drum
#

wait

signal grove
#

the version is correct, it's just an error in your sendToDiscord() method

vital drum
#

i send it in more lines

sleek wedge
#

here

#

check this error buddy everything from here its wrong

vital drum
#

its now working

sleek wedge
#

retrying restating the server lol

#

always "debug"

vital drum
#

ok

#

all is working

sleek wedge
#

alrigth

dusky harness
#

alrigth

signal grove
ashen lodge
#

When im using the Flame particle it creates like a explosion instead of just staying in place (trying to make a flame circle around a player). is there a way to fix this?

pulsar ferry
#

d;paper World#spawnParticle

uneven lanternBOT
#
void spawnParticle(@NotNull @NotNull Particle particle, @NotNull @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra)```
Description:

Spawns the particle (the number of times specified by count) at the target location. The position of each particle will be randomized positively and negatively by the offset parameters on each axis.

Parameters:

particle - the particle to spawn
location - the location to spawn at
count - the number of particles
offsetX - the maximum random offset on the X axis
offsetY - the maximum random offset on the Y axis
offsetZ - the maximum random offset on the Z axis
extra - the extra data for this particle, depends on the particle used (normally speed)

pulsar ferry
#

@ashen lodge I believe the "extra" argument is what you're looking for, normally it's the speed of the particle, making it 0 (i think) will make the particles stay still

ashen lodge
#

I fixed it thankss!

#

I had a 1 for the count

sleek wedge
dense drift
#

Welp

sleek wedge
pulsar ferry
sleek wedge
#

lel

#

only talking

pulsar ferry
#

It's an example, the repository itself is a fork
There is also different branches that show how to do different things
And lastly read paper's CONTRIBUTING.md, should be more than enough to understand it

lyric gyro
#

As I said, check the paperweight-examples repo, it's another repository in the same organisation

sleek wedge
lyric gyro
vital drum
#

this is not sleeping: ```while (chair.getTicksLived() < 100) {
try {
sleep(20); // sleep for 20 milliseconds
} catch (InterruptedException e) {
// handle interrupted exception
}
chair.setVelocity(velocity);
double p = chair.getLocation().getPitch();
double yaw = chair.getLocation().getYaw();
double p1 = p + 1;
double yaw1 = yaw + 1;
chair.setRotation((float) p1, (float) yaw1);
chair.setPassenger(player);
chair.setGravity(false);
}
chair.remove();
return false;`

proud pebble
#

i dont think your supposed to use sleep

#

use a repeating task

vital drum
#

how i make sleep in a while?

sterile hinge
#

you don't, at least not when working on the main thread

#

it'll kill your server

vital drum
#

is there any way to replace while with something that work

proud pebble
#

yes

#

use a repeating task

#

also a minecraft tick is 50ms

#

btw what entity is this chair?

#

im a little confused on what your doing exactly

vital drum
#

chair is an arrow

#
        double yaw = chair.getLocation().getYaw();
        ActionListener taskPerformer = new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                double p1 = p + 1;
                double yaw1 = yaw + 1;
                chair.setRotation((float) p1, (float) yaw1);
            }
        };
        new Timer(50, taskPerformer).start();```
#

like this?

proud pebble
#
chair.setVelocity(velocity);
chair.setPassenger(player);
chair.setGravity(false);
BukkitTask task = Bukkit.getSchedular().runTaskTimer(plugin, ()-> {
    double p = chair.getLocation().getPitch();
    double yaw = chair.getLocation().getYaw();
    double p1 = p + 1;
    double yaw1 = yaw + 1;
    chair.setRotation((float) p1, (float) yaw1);
}
,0L,0L);
Bukkit.getSchedular().runTaskLater(plugin ()-> {
    task.cancel();
    chair.remove();
},20*5);
#

is this some sort of controllable missile?

vital drum
#

yes

proud pebble
vital drum
#

openai

proud pebble
#

i dont think using AI to write code for you is a good idea cus then your never gunna learn yourself

#

and its gunna pull this out of its ass that doesnt have enough context to write something that would actually work

#

ActionListener from a quick google search looks like its used for when you click something in a gui for awt

ashen lodge
#

I am currently using a Custom Event called PlayerAttackPlayerEvent, which uses the EntityDamageByEntityEvent. This is working out great for me and makes it easier. However, I want to use the event.setDamage() from EntitnyDamageByEntity event in my PlayerAttackPlayerEvent. If i can, how can i achieve this?

dark garnet
ashen lodge
#

ill send my current code

#

1s

#
@EventHandler
    public void onPvP(EntityDamageByEntityEvent event) {
        if(!(event.getDamager() instanceof Player)) return;
        if(!(event.getEntity() instanceof Player)) return;
        Player victim = (Player) event.getEntity();
        Player attacker = (Player) event.getDamager();
        if(attacker.getInventory().getItemInMainHand().getType() == Material.AIR) return;
        Model weaponModel = new Model(attacker.getInventory().getItemInMainHand());

        Bukkit.broadcastMessage(event.getDamage() + " : BEFORE PVP");
        event.setDamage(event.getDamage() + (event.getDamage() * (weaponModel.getFrenzyStack()/100)));
        Bukkit.broadcastMessage(event.getDamage() + " : AFTER PVP");
        Bukkit.getPluginManager().callEvent(new PlayerAttackPlayerEvent(victim, attacker, weaponModel, event.getFinalDamage(), event));

        this.plugin.getCombatManager().setCombatTime(victim, 16); this.plugin.getCombatManager().setCombatSet(victim, true);
        this.plugin.getCombatManager().setCombatTime(attacker, 16); this.plugin.getCombatManager().setCombatSet(attacker, true);
        NBTEntity nbtEntity = new NBTEntity(victim);
        nbtEntity.setUUID("lastAttacker", attacker.getUniqueId());
    }```

```java
private static final HandlerList HANDLERS = new HandlerList();
    private final Player attacker;
    private final Model weaponModel;
    private final double finalDamage;
    private final EntityDamageByEntityEvent event;

    public PlayerAttackPlayerEvent(Player victim, Player attacker, Model weaponModel, double finalDamage, EntityDamageByEntityEvent event) {
        super(victim);
        this.attacker = attacker;
        this.weaponModel = weaponModel;
        this.finalDamage = finalDamage;
        this.event = event;
    }

    public static HandlerList getHandlerList() {
        return HANDLERS;
    }

    public HandlerList getHandlers() {
        return HANDLERS;
    }```
#

i recently just added the EntityDamageByEntityEvent parameter, that didnt work

dark garnet
ashen lodge
#

im extending player event

#

public class PlayerAttackPlayerEvent extends PlayerEvent

dark garnet
#

try extending EntityDamageByEntityEvent

#

then u can use all the methods that it has

ashen lodge
dark garnet
#

ur constructor can look like this btw (using Player instead of Entity):

public PlayerAttackPlayerEvent(@NotNull Player damager, @NotNull Player damagee, @NotNull DamageCause cause, @NotNull Map<DamageModifier, Double> modifiers, @NotNull Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions) {
    super(damager, damagee, cause, modifiers, modifierFunctions);
}```*u dont need the `@NotNull`s*
ashen lodge
#

yes, i already did that just not in the same order

dark garnet
ashen lodge
#

the paramaters

#

in the constructor

dark garnet
#

the parameters should be in the same order as the parent constructor from EntityDamageByEntityEvent

ashen lodge
#

the super is the same

vital drum
#

how do i make an arrow fly in an cicle

dark garnet
dark garnet
#

unless its different on the version im using

ashen lodge
#

it asks for

public EntityDamageByEntityEvent(@NotNull final Entity damager, @NotNull final Entity damagee, @NotNull final DamageCause cause, final double damage) {
        super(damagee, cause, damage);
        this.damager = damager;
    }```
#

for me

dark garnet
#

what mc version?

ashen lodge
#

1.17

dark garnet
#

ye doesnt look like its deprecated so ur good

#

unlucky for me tho cause its deprecated in 1.11 sadge
and idk how to get these from the original event: Map<DamageModifier, Double> modifiers, Map<DamageModifier, ? extends Function<? super Double, Double>> modifierFunctions

#

maybe it might be best to just remake all the methods that EntityDamageByEntityEvent has instead of extending it, im not sure what consequences extending it might have, i havent made my own event before

ashen lodge
#

Basically, what im trying to do is make it so the enchants im making work together. For example if you proc a Lifesteal and a Electrocution at the same time it will do more since Elec will remove damage and Lifesteal will check the damage delt and heal you that much. what i do for Elec to do damage is victim.damage(scorch * 0.75); what should i be doing to add that to the total damage which will be collected by the float heal = (float) Math.min(event.getFinalDamage() / 3,2); in lifesteal

unborn ivy
#

Does anyone know why the int i is not increasing when it finds itself looking at null or with no item meta? (context: im trying to remove items with item meta, to do that, i have a for loop, ++i for each null or item without item meta, once it bumps into something with item meta, it gets deleted)

                            for (int i = 0; i < 36; i++) {
                                ItemStack items = p.getInventory().getItem(i);
                                if (items == null || !items.hasItemMeta()) {
                                    i++;
                                    return;
                                }
                                if (items.getItemMeta().hasLore() || items.getItemMeta().hasDisplayName() || items.getItemMeta().hasEnchants()) {
                                        items.setAmount(0);
                                }
tender thicket
#

Hey can someone help me out

#

What is the boolean parameter arg2 in the constructor of net.minecraft.server.packs.FilePackResource

#

and what is the String parameter arg0?

#

I assumed java.io.File arg1 was the actual resource pack file

#

I also assume String arg0 is the file location? Or is it the actual name of the pack?

signal grove
unborn ivy
signal grove
#

what i mean is, you dont need to i++ in the first condition

#

your for loop already increments by one

unborn ivy
#

oh

#

but how can the loop find out if its null

#

or has no itemmeta

#

beacuse those are the issues that prevent the code from working

signal grove
#

you return early

#

if any item has no meta, it just breaks the whole loop

#

try inverting your condition and nesting it

unborn ivy
#

ok i removed return;

#

and it removes everything except for the next itemstack AFTER items with no meta

signal grove
#
                            for (int i = 0; i < 36; i++) {
                                ItemStack items = p.getInventory().getItem(i);
                                if (items != null && items.hasItemMeta()) {
                                    if (items.getItemMeta().hasLore() || items.getItemMeta().hasDisplayName() || items.getItemMeta().hasEnchants()) {
                                        items.setAmount(0);
                                    }
                                }
                                
#

now it goes through each item, never returns. and if it has meta, and the meta has lore, name, ench, then set it to zero

unborn ivy
#

ill see if that works

unborn ivy
#

im all out of ideas idk what to do

#

with the code above removing just return

#

it would delete all the dirt apart from the one next to the stone slab

trail wigeon
#

anyone have an idea why the tnt is spawning where the player is looking instead of 50 blocks above them?

Player player = (Player) sender;
            World world = player.getWorld();
            Location pos = new Location(world, player.getLocation().getX(), player.getLocation().getY() + 50, player.getLocation().getZ());
            TNTPrimed tnt = (TNTPrimed) world.spawnEntity(pos, EntityType.PRIMED_TNT);
            new BukkitRunnable() {
                @Override
                public void run() {
                    Location tntLocation = tnt.getLocation();
                    tnt.getWorld().spawnParticle(Particle.COMPOSTER, tntLocation, 50);
                    if (!tnt.isOnGround() && tnt.isValid()) {
                        return;
                    }
                    TNTUtils.explosion(tnt.getWorld(), tnt.getLocation(), CustomEnchants.getTNTLevel(player.getItemInUse()) / 5);
                    cancel();
                }
            }.runTaskTimer(plugin, 1L, 1L);
signal grove
#

paste your current code

unborn ivy
#
                        if (p.getGameMode() == GameMode.CREATIVE && !p.hasPermission("limitedcreative.preventcheck")) {
                            for (int i = 0; i < 36;) {
                                ItemStack items = p.getInventory().getItem(i);
                                if (items == null || !items.hasItemMeta()) {
                                    i++;
                                }
                                if (items.getItemMeta().hasLore() || items.getItemMeta().hasDisplayName() || items.getItemMeta().hasEnchants()) {
                                        items.setAmount(0);
                                        i++;
                                }
``` current code rn, it deletes everything but also halts?
signal grove
#

move the i++ into the top of your for loop

#

and get rid of all other i++ inside

#

negate your condition and nest the statements, like i had

unborn ivy
#

thats literally what i did

#

and nothing worked

#

ill try it again

signal grove
#

in your code, the null check doesnt have a purpose, since it continues to the next if statement anyways

unborn ivy
#

if a player's itemstack slot is null

#

it doesnt continue

#

its just stuck

signal grove
#

yeah because its an error

unborn ivy
#

same goes for itemstacks with no itemmeta

signal grove
#

thats why you want to check if its not null, and if so, run your lore, name, enchants check inside

#

otherwise it will throw a null pointer exception

#

when you're done, if it doesnt work, paste the code that you have and ill look at it again

unborn ivy
#

well i did something yesterday

#

and it said

#

my plugin generated an exception

#

etc etc

#

i think it works now

#

ill have to do more testing

trail wigeon
signal grove
#

when you say "in front"

#

is it in the direction the players facing

#

or just in like x direction or z

#

(the tnt)

trail wigeon
#

no literally like where you are looking itll spawn at the tree or if you look at the sky itll spawn at height limit

signal grove
#

wtf, bro accidentally added raycasting

trail wigeon
#

???

signal grove
#

honestly don't see what's wrong with the tnt code at a first glance

#

what command is this btw

#

it seems like youre overriding cmd

#

(tell me it's not antioch)

trail wigeon
#

you talking to me?

signal grove
#

yes

trail wigeon
#

the heck is antioch

signal grove
#

a command that spawns tnt where youre looking

trail wigeon
#

nononoo

ashen lodge
#

Whats a good api for checking when armor is equip and dequip

signal grove
#

there's no way you can accidentally add tnt spawn where you're looking, so im assuming some other command is in conflict with yours

trail wigeon
#

hmmmm

#

is that a part of essentials maybe

signal grove
#

yes

trail wigeon
#

;-;

#

did i set it as the same command give me a sec

signal grove
trail wigeon
#

oml

#

i literally changed the command and it works perfect now

signal grove
#

xD

#

nice

trail wigeon
#

im not even kidding you i was so confused why it wasent working sat here for like half an hour just confused

#

thanks lmfao

signal grove
#

was it /antioch by accident or something

trail wigeon
#

no i had it at uhh

#

spawntnt

#

i think

signal grove
#

ah

trail wigeon
#

smth like that

#

was hooked to essentials somehow

edgy lintel
#

listener wont register for some reasons
is asyncplayerchatevent deprecated?

bright pier
river solstice
#

I've heard the chat system changed in 1.19.

        protocolManager.addPacketListener(new PacketAdapter(
                plugin,
                ListenerPriority.HIGHEST,
                PacketType.Play.Server.CHAT) {
            @Override
            public void onPacketSending(final PacketEvent e) {
                PacketContainer packet = e.getPacket();
                Messenger.debug("Packet " + packet.toString() + " sent to " + e.getPlayer().getName());

...

this used to work in 1.18, but it doesn't in 1.19. what changed?
(protocollib)

dense drift
river solstice
#

ah it's SYSTEM_CHAT, not CHAT

dense galleon
#

Trying to shade two dependencies into my plugin's jar file, but when running the build gradle command the libs arent getting shadowed in

#

I am not sure what I could be doing wrong

hoary scarab
#

IDK much about gradle but last time I used it I needed to add shadowJar to my tasks. Have you done that?

dense galleon
#

Yeah It was that mb

dense galleon
#

I'm trying to implement HikariCP to my project, though I am really struggling to figure out what my dataSourceClassName is.

#

I tried the MariaDB one and the MySQL one, but neither work

#

Both of them throw a ClassNotFoundException

icy shadow
#

you also need to shade the driver

dense galleon
#
shadowJar {
    dependencies {
        include dependency("com.mysql:mysql-connector-j:8.0.31")
        include dependency("com.zaxxer:HikariCP:5.0.1")
    }
    relocate("com.mysql", "shaded.com.mysql")
    relocate("com.zaxxer", "shaded.com.zaxxer")
}
``` am I not?
icy shadow
#

what specific error do you get?

icy shadow
#

well that doesnt look like the right driver class name lol

#

why are you using the ms sql one?

dense galleon
#

i honestly dont know, I originally tried using the MariaDB one since the database I am trying to connect to uses MariaDB

#

as a library

#

But writing that as the dataSourceClassName did not work either

#

The error looks the same with either string

icy shadow
#

well if you want mariadb you need to shade the mariadb driver, not the mysql one lol

#

although i think mysql should be compatible with maria, you just need to use the jdbc url instead

dense galleon
#

in my repositories section

icy shadow
#

no?

dense galleon
#

Ah

icy shadow
#

either:
use mysql connector and jdbcurl instead of data source class
shade mariadb driver and use the mariadb data source class

dense galleon
#

I suppose the latter is better since the database I am connecting to uses MariaDB?

icy shadow
#

doubt there's much difference

#

ive always done the former and it's been fine

dense galleon
#

Where do I find the jdbcUrl though for MySQl's driver

icy shadow
#

it's just mysql

dense galleon
#

I'll try doing the latter though just cause it makes more sense to me

#

Let's see

#

Are the errors displayed for an incorrect password and access being denied altogether separate?

icy shadow
#

?

ashen lodge
#

Is there any API I can use for when a player c hangs their gear

dense galleon
#

I am trying to connect to my university's database through a Minecraft plugin, not sure if my password is somehow wrong or if the database is not allowing me to connect

#

This is the error I get

icy shadow
#

(using password: NO)

#

seems like you're not properly setting the password

tight junco
icy shadow
#

what do you mean by that

tight junco
#

i dont know

icy shadow
#

i do

tight junco
dense galleon
#

I think I am though

#

yeah the value returned by getPassword() is correct

icy shadow
#

hm

#

well then maybe it is getting rejected

#

try connecting with a normal sql client

#

if u have IJ ultimate there's one built in

dense galleon
#

Yeah the reason why I was connecting to the uni one was cause it was easier than setting up a dummy server myself πŸ˜…

#

At that point i'll just make one on my machine

dense galleon
icy shadow
#

Β―_(ツ)_/Β―

#

maybe a \n character or something in the password

#

or try with jdbc url

#

like i said that's always worked perfectly for me

dense galleon
#

it's some issue with MariaDB

#

Though I still don't follow where I can find out the jdbc url of different drivers

icy shadow
#

google dot com

dense galleon
#

jdbc:mariadb://server.company.domain:3306/dbname this is what I found online

icy shadow
#

mysql will work for maria

#

and they all follow that format

#

the only thing that changes is the start

dense galleon
#

I see

#

ClassNotFoundException

dense galleon
#

I'll try using the MySQL one

#

Yeah even with the mysql one it throws a ClassNotFoundException

#

Okay I had to change way that I initialize the data source mb

#

Now I get the same access denied error THOUGH it says using password: YES

icy shadow
#

well then the username or password is wrong

#

or the database isnt accepting connections from ur ip

dense galleon
#

Yeah okay the password was actually changed by the uni and I forgot lol

sterile hinge
#

imagine not using DataSource

#

ah well I see

dense galleon
#

Is there any way in minecraft 1.19.3 to have itemstacks go over 64 at least visually?

dense galleon
#

Got a strange Failed to initialize pool: Too many connections error

#

I forgot to close my connections when the plugin is disabled, though now how can I close all the current connections to my database?

#

They are all sleeping

vestal forge
#

on off

#

maybe lol

dense galleon
#

What

warm steppe
dense galleon
#

It's my university database

proud pebble
#

what packet im not sure, imma have a look at wikivg

#

Set Container Slot

#

if you cant do it with the regular bukkit itemstack then using nms might be an option, i dont think there is any strict checks when using nms if there are any using bukkit

#

actually ive tried quite a few different thinks other then a packet and cant get it to show it as more then 64

#

maybe in fake inventories its not possible idk

dense galleon
#

Ah alright :/

dense galleon
#

I close my connection in my onDisable() withconnection.close() though, and the actual variable is only ever assigned in my onEnable()

#

So the connection isn't being initialized a bunch

proud pebble
#

afaik your supposed to close the connection as soon as your done with it or reuse the same connection instead of making more

#

ive reused the same connection tho that was with sqlite

dense galleon
#

I am using Hikari though just so that I don't have to look after closing and opening connections over and over again

#

Nah this whole thing is buggy as hell

dense galleon
dark garnet
#

HELLO!!!!! i have api, i use implementation for my api when i use it in my other plugins
i want to make it so that a dependency from the api is compilyOnly for the plugins that use the api
how can i do this? does it involve the java-library plugin?
im doing this so i dont have to compileOnly jetbrains annotations for all my plugins, so if there is another, easier, way to accomplish this, please lmk (i remember i used to not have to declare jetbrains annotations as a dependency, but i have no idea what i changed)

silver horizon
#

oke

lyric gyro
#

share code

dusky harness
#

and the implementation version of that would be api

#

and i think it does involve java-library plugin

dark garnet
lyric gyro
dense galleon
#
    public Connection getConnection() throws SQLException {
        return dataSource.getConnection();
    }```
lyric gyro
#

Yeah that's good πŸ‘

dense galleon
#

But then why do a million connections keep popping up

#
    @Override
    public void onDisable() {
        // Plugin shutdown logic
        try {
            getConnection().close();
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }``` I close the connection onDisable
spiral prairie
#

infinite loop or not closing them or not reusing

dense galleon
#

Doesn't HikariCP open and close them automatically?

spiral prairie
#

no dont think so

spiral prairie
#

no

#

the guide says the try with resources closes it

#

but with the code you have it should close automatically, yes

frosty hearth
#

Anyone can help me with regards of having server boost together with nitro? My nitro seems not activate bcoz its said it was credited?

spiral prairie
#

you arent executing the statement, are you?

lyric gyro
dense galleon
#

I am for my method with the SELECT query

dusky harness
lyric gyro
#

And you should use try-with-resources each and every time you use a Connection, PreparedStatement, ResultSet etc, so hikari knows how to properly lifecycle the connections, it isn't automagic

spiral prairie
dense galleon
#

Those are two separate queries

spiral prairie
dense galleon
#

Yeah that's just the insert one I got

#

The updated one looks like this:

spiral prairie
#

yeah where are you executing it?

lyric gyro
dense galleon
dusky harness
spiral prairie
#

no PreparsedStatement#executeQuery

dense galleon
lyric gyro
#

you are the client

dusky harness
#

ohhhhh

#

i see

#

wb for like files? should those also be closed in onDisable?

dusky harness
#

actually idk when you'd be constantly opening files

#

but for the weird chance that you were

dense galleon
#

It doesnt throw any errors however

spiral prairie
dusky harness
#

yeah

spiral prairie
#

where is it

dusky harness
#

but im just saying for the weird case that someone has it open πŸ₯΄
would there by any diff in closing in onDisable vs not closing at all?

dense galleon
#

So I made it static

dense galleon
spiral prairie
#

nobody else asked about it though

spiral prairie
lyric gyro
dense galleon
dusky harness
#

oh wow

#

thats more complicated than I thought

spiral prairie
dense galleon
spiral prairie
#

i was talking about the static abuse

#

i actually replied this time to the message

#

but eh

#

does ProfileManager have a constructor?

feral raptor
#

what is acceptable syntax for instance fields to be referenced outside its class

spiral prairie
#

dependency injection usually

spiral prairie
#

with a getter / setter

feral raptor
#

without a getter / setter in this case

spiral prairie
#

huh?

dusky harness
#

well

#

there's no acceptable syntax

#

πŸ₯²

#

afaik

spiral prairie
#

yeah

dusky harness
#

properties 😌 😌 😌 😌 😌

feral raptor
#

then why do they have access modifiers

#

is it just for child class access management

spiral prairie
#

private use

dense galleon
spiral prairie
#

no problem

dusky harness
#

and set what it needs to

#

and allows you to modify info sent in or out

dense galleon
#

But yeah I create a single instance of ProfileManager

#

Either way:

spiral prairie
#

with contructor parameters?

dense galleon
#

cannot issue statements that do not produce result sets

dense galleon
dusky harness
#

usually it's just the simple return value but if you want to change something (and to keep it consistent overall), getters/setters are recommended

spiral prairie
feral raptor
dense galleon
#

The execute query line

dusky harness
#

no modifier does not mean private

spiral prairie
dense galleon
#

Or is it just execute

dusky harness
#

no modifier = package private meaning that every class in its package can access the variables

feral raptor
#

yeah but my point is whats it matter if its private or not if you cant use it outside the local class w/o inheritance

#

even if its public, without a getter/setter I cant use it

dusky harness
#

wdym

#

if it's public you can use it, no?

#

unless you mean by following the "private variables" rule, then you should make getters/setters anyways

spiral prairie
dusky harness
#

for ex in an interface: ```java
public interface Something {
SomethingElse getSomethingElse();
}

dusky harness
#

i wasn't entirely sure what they meant

feral raptor
#

say I have a class, Options thats in the same package as Main, and Main has an instance field thats public. Even if its public, that doesn't mean it can be referenced in Options right?

#

Assuming Options does not extend Main

spiral prairie
#

excuse me what

dusky harness
#

it can

#

you're thinking of protected

#

protected is what you're explaining right now

spiral prairie
#

do you mean public static vs public etc

dusky harness
#

no not static

#

wait did you change it

#

ok maybe i read it wrong
you're referring to no modifier at all now

#

wait what

spiral prairie
#

whats an instance field in your opinion

dusky harness
#

no you're referring to private

#

mb

feral raptor
#

let me rephrase the question again

dusky harness
#

okay

#

πŸ₯²

spiral prairie
#

please just make a code example in a few seconds

dusky harness
#

is what i think of

spiral prairie
#

yeah so no

#

you cant access it in Options without an instance of Main

dusky harness
#

im just gonna wait for his rephrased question

#

πŸ₯²

spiral prairie
#

depending on the access modifier though

dusky harness
#

while he's typing, I'll mention this: ```ansi
nothing = only within that same package
private = only within that same class
public = ANY class
protected = must extend or implement that class

spiral prairie
#

^

lyric gyro
#

I could πŸ€“ about how some of those are partially wrong but I won't :D

dusky harness
#

please elaborate

#

πŸ₯²

spiral prairie
#

lol

feral raptor
#

Im saying is it possible to reference an instance field in another class without the use of getters/setters.

Code example;

public class Something {
  String cheese;

  Something(cheese) {} //constructor
}

Is there any acceptable syntax that would allow me to use that instance field below (whether it be with this or whatever

public class SomethingElse {

public void myMethod() {
  this.cheese = "expired";

}
dusky harness
feral raptor
#

what xd

spiral prairie
#

hold up what

pulsar ferry
feral raptor
#

I know the difference between the access modifiers, its just about the legality of an instance field im asking about

spiral prairie
#

yeah no i think my answer was somewhat correct

dusky harness
#

legality as in what's recommended?

feral raptor
#

what will be allowed to be compiled

spiral prairie
#

if you want to access cheese in something else from something then you could extend it

dusky harness
#

no, not extend

spiral prairie
#

our dependency injection

dusky harness
#

that's package private

feral raptor
#

Is there a way to do it without extending tho

dusky harness
#

make it public

spiral prairie
#

di or just creating it yourself

lyric gyro
# dusky harness please elaborate

you can't have protected on an interface so that last bit is incorrect
private means on the same class and inner/nested classes (more specifically, "nest members")
protected is also package-private accessible, so you don't have to extend the class to access a protected member if you're in the same package

spiral prairie
dusky harness
#

okay that I really did not know and didn't expect πŸ₯²

lyric gyro
feral raptor
spiral prairie
#

and by the naming im guessing they are package private

dusky harness
spiral prairie
dusky harness
#

rn it's package private

spiral prairie
#

YOU

dusky harness
#

I'm assuming that they know how to make an instance of a class and are using that

#

here's an example:

spiral prairie
#

no they arent

#

you

#

donut

dusky harness
#

oh

spiral prairie
#

i think

#

if it isnt ill call myself donut

dusky harness
#
public class Something {
    public String cheese = "CHEESE"; // public!
}

public class SomethingElse {
    public void coolStart() {
        Something something = new Something();
        something.cheese = "No cheese";
    }
}
```this works
#

not recommended

#

but it works

lyric gyro
#

if it's public you can access it from anywhere lol you just need an instance of the class

spiral prairie
#

for example

spiral prairie
#

but you need an instance

lyric gyro
#

yes

spiral prairie
#

yes

lyric gyro
#

you always do

spiral prairie
#

yes

#

exactly

lyric gyro
#

you can't modify an instance field without an instance

spiral prairie
#

but they dont have that yet

#

yes

lyric gyro
#

there always has to be an instance for you to modify an instance field

spiral prairie
#

yes

#

but they dont have that yet

#

thats their question afaik

lyric gyro
#

how to create an instance of something?

dense galleon
#

is it correct to have the player UUID as my primary key in my database?

#

My father who's worked on databases many years says that I should have a separate table to pair auto-incrementing IDs with player UUIDs instead

#

And use the auto-incrementing ID as the primary/foreign key for all tables instead of the player UUID

icy shadow
#

i cant see much benefit to that

#

as long as the rows are all related to an actual player

dense galleon
#

Yeah that's what I mean, I think it just complicates things with avoiding duplicate values

dense galleon
spiral prairie
#

its better for bigger structures as you can change the uuid in case

#

especiall if you have no control over the system that hands out the uuids

#

but for that stuff, nope, no need

dense galleon
#

correct

spiral prairie
#

yes

leaden sinew
# lyric gyro how to create an instance of something?

I hope this helps!

public class instancE {

  public static instancE.somethinG SomethingInstance;

  public static instancE.somethinG creatEinstancE() {
      SomethingInstance = new instancE.somethinG();
      return new instancE.somethinG();
  }

  public instancE() {
    throw new IllegalStateException("This isn't something!");
  }

  public static class somethinG {
          
    public somethinG() {}

    public static somethinG creatEinstancE() {
      return instancE.creatEinstancE();
    }
  }
}
lyric gyro
#

it doesn't

leaden sinew
#

Oh no

#

How can I help you to understand?

#

Should I add comments?

lyric gyro
#

No

#

You can't, sorry

leaden sinew
#

No, I'm sorry

lyric gyro
#

Yeah you better be

leaden sinew
#

i aM

feral raptor
dusky harness
#

like which part of it makes you think it's invalid syntax?

feral raptor
#

how can SomethingElse reference an instance field it was never assigned?

dusky harness
#

it was assigned

#

assigned to "CHEESE"

leaden sinew
#

I think you're misunderstanding what encapsulation / inheritance means

feral raptor
#

My point is that it was not assigned within the constructor

dusky harness
#
public String cheese = "CHEESE"
```If it's already set, I don't need to set it again
#

HOWEVER

#
public String cheese;
```this would still work, but `cheese` would be null
#

(it won't give any errors I believe)

feral raptor
#

So can any object reference any instance field

#

(within its range)

dusky harness
#

yes

tacit belfry
feral raptor
#

Ah I see..

dusky harness
#

and then you said you already know this but just in case I'll bump it back down: ```ansi
nothing = only within that same package
private = only within that same class
public = ANY class
protected = must extend or implement that class OR package private

tacit belfry
feral raptor
#

Right yeah

#

But then still, if cheese is accessible, why can't I reference it with this

dusky harness
#

this refers to SomethingElse

tacit belfry
dusky harness
#

notice how above you do something.

#

that is because it is not this

feral raptor
#

yeah but this would be any object coolStart2() is called from

dusky harness
#

no

#

it is an instance of SomethingElse

feral raptor
#

this itself isn't an instance.. its a reference to an instance

#

right?

tacit belfry
#

so in that case, this would be referring to the SomethingElse object

dusky harness
#

πŸ₯²

dusky harness
# feral raptor But then still, if `cheese` is accessible, why can't I reference it with `this`

so look here
coolStart2() is not static, and it is in the class SomethingElse
so, that means that this would refer to an instance of SomethingElse (if it was static, then this wouldn't work at all because static does not refer to any instances - static works fine with 0 instances of the class)

for example, you can do this: ```java
public void coolStart2() {
SomethingElse instance = this; // perfectly fine syntax
instance.test();
this.test(); // does the same thing
}

public void test() {
System.out.println("Hi!");
}


so, that means that you can call whatever methods you want on `this` that you can on an instance of `SomethingElse` (because it is)
#

does that make more sense?

edgy lintel
#

yes

dusky harness
#

._.

feral raptor
#

Lol

#

well right yeah I get that part. this will take the form of any SomethingElse you call the method against

dusky harness
#

ignore the caller

#

the caller only matters when there's an error and it's shown in the stacktrace

feral raptor
#

Oh hold on. So you mean its not valid syntax in the case I sent above because this is a reference to SomethingElse and that only. It doesn't matter if you call the method using a Something, this will only behave as a SomethingElse

dusky harness
#

correct

the caller can be anything you want, as long as it has an instance of SomethingElse

feral raptor
#

I see..

dusky harness
# feral raptor I see..

this is because when writing java code, if this was the caller, then it wouldn't be able to run any methods or get/set any fields because how would it know what the caller is?

spiral prairie
#

is there any programming language you are comming from?

feral raptor
#

I get what you mean now

dusky harness
#

πŸ‘ awesome

feral raptor
#

appreciate it :P

leaden sinew
#

I agree, Skript is awesome

dusky harness
#

lol

spiral prairie
#

yup

leaden sinew
spiral prairie
#

cause ive had a few people come from languages not having inerhitance and everything just being one single instance of itself

feral raptor
#

Nah not really, my knowledge of coding was zero up until 2 ish weeks ago. started learning only recently

spiral prairie
#

i see

feral raptor
#

idek how to code in skript lol

spiral prairie
#

good

leaden sinew
#

Blasphemy

spiral prairie
#

lets keep it like that

dusky harness
#

denizen

#

scripting

#

it literally has a hiring channel

#

believe it or not

feral raptor
#

Unless you call Bitcoin Script a language, albeit very low-level

spiral prairie
#

do you need any diagrams to understand it better or

dusky harness
#

people go for like hourly pay in there (and they get hired)

feral raptor
#

but even in that Im adequate at best

leaden sinew
feral raptor
#

its a low level language

spiral prairie
#

i hope it isn't

#

oh

#

you mean it has a low level

dusky harness
#

lol

spiral prairie
#

low level in programmer terms basically means that it is very close to the actual hardware

#

such as C

dusky harness
#

or assembly

spiral prairie
#

or even better, assembly

leaden sinew
#

Or Skript

dusky harness
#

high level = scratch

#

or python

feral raptor
#

It is very close to C

edgy lintel
#

I literally saw someone say f you

leaden sinew
edgy lintel
#

I’m so confused lol

dusky harness
#

i mean

spiral prairie
#

what dont you understand

dusky harness
#

its medium level

#

πŸ™ƒ

leaden sinew
#

No it's not

spiral prairie
#

ever heard of jvm?

edgy lintel
dusky harness
#

okaaay

#

medium to high level

leaden sinew
#

lol

spiral prairie
#

its running it its own container

#

medium doesnt even exist

signal grove
#

python is low level 😎

leaden sinew
#

The order is Skript -> low level -> high level -> python

lyric gyro
edgy lintel
dusky harness
spiral prairie
spiral prairie
leaden sinew
dusky harness
leaden sinew
#

Yeah you said it was awful

leaden sinew
#

I heard you hate Kotlin

signal grove
#

why dont we just take all the packets and redirect them to a python server. spigot.py

leaden sinew
#

Sky you have to swear at someone again

spiral prairie
#

die /s

edgy lintel
#

Lmaooooo

signal grove
#

people really adding flags to regular speech

spiral prairie
#

/s = /seriously /s

signal grove
#

i know

#

its a flag xD

spiral prairie
#

what you know

leaden sinew
signal grove
#

🎲

spiral prairie
#

πŸ‡ΆπŸ‡¦

feral raptor
#

a gas reserve?

lyric gyro
dusky harness
#

java is cool

lyric gyro
feral raptor
#

what is the highest level language

#

probably haskell

spiral prairie
#

scratch

icy shadow
#

declarative languages are definitely higher level than imperative ones i'd say

#

so yeah haskell, sql, prolog, etc are all pretty high level

#

higher than java and co that is

#

scratch is definitely imperative though

spiral prairie
#

yeah

#

although scratch has some declarative stuff

edgy lintel
#

no assembly is highest'

#

i will direct minecraft packets to my cpp middleman, which will then optimize packet syntax by adding random hash-99999 number (a long one) to have checksum 100-200 times
then finally direct the minecraft packets back to the assembly server

feral raptor
#

when does it suit java naming conventions to make a variable all caps with underscores

#

example is the static Integer.MAX_VALUE

#

as opposed to the unconventional everyLetterCapitalized

edgy lintel
edgy lintel
#

EveryStartingLetterCapitalized is usually for declaring classes and interfaces

feral raptor
#

right yeah

feral raptor
dusky harness
#

it's when the value is always the same (for example, Integer.MAX_VALUE will never ever change)

feral raptor
#

fair enough

#

Is it expected or just accepted

dusky harness
edgy lintel
#

reverse also

#

average java enjoyer
average kotlin fan

spiral prairie
#

SCREAM_CASE or something like that is usually used on constants

#

static final

#

so not instance based

feral raptor
#

are constants always public

spiral prairie
#

no

tired olive
spiral prairie
#

they can be private too

tired olive
edgy lintel
#

just code more lol thats how i got around all these conventions

spiral prairie
#

idk why

edgy lintel
#

theres no need to memorize them

spiral prairie
#

im happy to review your code anytime :D

edgy lintel
feral raptor
spiral prairie
edgy lintel
spiral prairie
#

although i really only know to review java, kotlin and maybe some other stuff KEKW_laugh

tacit belfry
#

I'm trying to use a gradle task to run my server after the jar finishes building, and this is what I have so far:
https://paste.helpch.at/afubexakog.typescript
Right now the problem that I have is that the runServer task isn't even being called. Am I doing something wrong?

dusky harness
#

@trail wigeon

#

?startuplog

neat pierBOT
#
FAQ Answer:

Startup Log Location
Your latest startup log can be found in the logs folder of your
server directory, labeled as latest.log.
Please copy the contents and paste them to a paste service.
Type ?paste for more information.

trail burrow
#

Failed to read artifact descriptor for com.gmail.nossr50.mcMMO:mcMMO:jar:2.1.202

#

the code works in one plugin just not in another

edgy lintel
#

how to get the translatable component key for each material?

trail wigeon
#

so I need a player in the constructor in order to do some of the things in the gui but when I try and register the event than it needs the player parameter passed in and I'm confused what I'm supposed to put there since its the system and not player specific

public EnchanterGUI(GalaxyMC plugin, Player player) {

getServer().getPluginManager().registerEvents(new EnchanterGUI(this, ), this);

does anyone know how you would fix this

bright pier
#

I don't see anywhere in that where you're actually using an event.

#

You implemented listener, but you're not actually listening for any events.

trail wigeon
#

Because later imma add a inventory click event I don’t have that in yet

#

But I need the player in the initializeItems how do I get that in that method

bright pier
#

You can't from the onEnable. You would need to use the listener for it. as that will give you a way to get the player.

trail wigeon
#

So like a listener for when the inventory gets opened maybe and get the player through that

bright pier
#

InventoryOpenEvent

trail wigeon
#

Ok thanks

trail wigeon
# bright pier InventoryOpenEvent

so I added this

@EventHandler
    public void invOpen(InventoryOpenEvent event) {
        if (event.getInventory().equals(Page1)) {
            player = (Player) event.getPlayer();
        }
    }

but im still having the issue from before it is disabling the plugin because player is null

here is the class again:
https://pastes.dev/sZAHRNjRRq

bright pier
#

Call your initialize items method in the event, and pass player to it that way

#
@EventHandler
    public void invOpen(InventoryOpenEvent event) {
        if (event.getInventory().equals(Page1)) {
            Player player = event.getPlayer();
            initializeItems(player)
        }
    }

Then change public void initializeItems() { to public void initializeItems(Player player) {

trail wigeon
#

ya

#

it worked ty

unborn ivy
#

Does anyone know what the events are when:

  1. someone destroys a block, that has something attachable like a torch, button etc
  2. someone destroys a block that has another block on top of them like rails, carpets
    im trying to prevent these attachable blocks from dropping, whenever someone breaks the root block in creative mode, and idk how to start
#

pls dont direct me to the wiki i have looked there and dont know where and how to start

hoary scarab
#

You have to check for the attached blocks and if there is an attached block cancel the blockbreakevent and set the block to air without updating its surrounding blocks.

edgy lintel
#

hey guys trying to tell the player the translated name of some material
heres the code
library method

    public String getItemTypeTranslationKey(Material material) {
        if (material == null) return null;
        net.minecraft.world.item.Item nmsItem = CraftMagicNumbers.getItem(material);
        if (nmsItem == null) return null;
        return nmsItem.a();
    }

usage

TextComponent text = new TextComponent("");
                TranslatableComponent materialTranslation = new TranslatableComponent(Main.getInstance().handler.getItemTypeTranslationKey(block));
                DebugHandler.log(5, Main.getInstance().handler.getItemTypeTranslationKey(block));
                materialTranslation.setColor(ChatColor.BLACK);
                text.addExtra(materialTranslation);
#

getting the minecraft key works

#

but it doesnt work when i print it in book

#

please help

unborn ivy
edgy lintel
#

setting a block to air is a hard way to make block vanish, not to break block normally

hoary scarab
unborn ivy
#

or getRelative

#

im confused

hoary scarab
#

@unborn ivy you could try this... (Might need to adjust the code)

private BlockFace[] faces = new BlockFace[] {BlockFace.UP, BlockFace.DOWN, BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
private List<Material> attachables = Arrays.asList(Material.TORCH, Material.ITEM_FRAME, Material.RAIL);
    
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
    Player player = event.getPlayer();
        
    Block block = event.getBlock();
    Material blockType = block.getType();
        
    if(attachables.contains(blockType)) {
        event.setCancelled(true);
        player.sendMessage("Can not break attachable blocks.");
        return;
    }
        
    for(BlockFace face : faces) {
        Block relative = block.getRelative(face);
        Material relativeType = relative.getType();
            
        if(attachables.contains(relativeType)) {
            event.setCancelled(true);
            block.setType(Material.AIR, false);
            return;
        }
    }
}
```This might be wrong if I misread your question lol
unborn ivy
#

1 sec ill try my own code

hoary scarab
#

Need the full trace please.

edgy lintel
#

no error
it just doesnt show anything when i print it

#

block.minecraft.oak_log
i tried printing the translation key, and found it in the texture pack language txt

#

the translation key is correct

#

i dont get it

#

when i tellraw translate it works

hoary scarab
#

Can you screen shot those scenarios please.

#

tellraw, outputting etc...

#

@edgy lintel you're writing block but the method takes Material is this invalid?

edgy lintel
#

im actually dealing with legacy code right here
the type of block variable is Material lol

hoary scarab
#

Ok just making sure

edgy lintel
#

its really hard to screenshot the actual senario

#

the translatablecomponent is supposed to go there

#

apologies for japanese

hoary scarab
#

Its fine the arrow helps xD

#

So what does your DebugHandler output?

edgy lintel
#

exactly as it is supposed to be

edgy lintel
unborn ivy
edgy lintel
hoary scarab
# edgy lintel

Try debugging text I could be reading it wrong but it looks right to me.

hoary scarab
unborn ivy
#

Is it possible to just set the relative block to air?

edgy lintel
unborn ivy
#

Yea thats what I was gonna do

edgy lintel
edgy lintel
#

somethings wrong with adding translatablecomponent as extra in textcomponent

#

it just vanished

#

for some reasons

hoary scarab
#

If you break a block and it has attached blocks those blocks will receive an update.
To use your example, a torch. If the block the torch is attached to it will drop the torch. If you want the torch not to be broken use my above method. If you want the torch to still be broken just remove its item on spawn event or you can still use the above method and just modify it to set the torch to air as well.

hoary scarab
edgy lintel
#

wow thx so much!
i just couldnt figure out exactly whats the problem until this
probably addextra isnt meant for translatablecomponent or sth
i guess i just have to find another way round by checking other method alternatives

hoary scarab
#

Np.

hoary scarab
unborn ivy
edgy lintel
#
TranslatableComponent giveMessage = new TranslatableComponent("commands.give.success");
TranslatableComponent item = new TranslatableComponent("item.swordDiamond.name");
item.setColor(net.md_5.bungee.api.ChatColor.GOLD);
giveMessage.addWith(item);
giveMessage.addWith("32");
TextComponent username = new TextComponent("Thinkofdeath");
username.setColor(net.md_5.bungee.api.ChatColor.AQUA);
giveMessage.addWith(username);
player.sendMessage(giveMessage);

guess i completely messed it up lol
it isnt how it seems to work at all lmao

hoary scarab
hoary scarab
unborn ivy
edgy lintel
#

im stupid lol
and i dont know what parameters to pass in addwith
really dont wanna look into the source code πŸ’€ '

unborn ivy
hoary scarab
#

Sugarcane and cactus are easy. But things like chorus flower etc... can get annoying.

unborn ivy
#

well actually if it did check all 6 faces, then none of the torches would have dropped

hoary scarab
#

Can I see your code? Also make sure the listener is registered

unborn ivy
#

with this code rn, it only checks for 1 face

#

and im assuming that the first face it checks for is whatever is in faces first

#
   @EventHandler
   public void AttachedBlocks(BlockBreakEvent e) {
       Player p = e.getPlayer();
       GameMode gm = p.getGameMode();
       Block b = e.getBlock();
       for (BlockFace f : faces) {
           Block relative = b.getRelative(f);
           Material relativeType = relative.getType();
           if (attachables.contains(relativeType)) {
               if (gm == GameMode.CREATIVE) {
                   e.setCancelled(true);
                   relative.setType(Material.AIR);
                   b.setType(Material.AIR);
                   return;
               }
           }
       }
   }
}
hoary scarab
#

So my code would break the block but keep the attached. Because it removes the block without updating physics.

Your code will return on the first attached and set the block to air and will update the physics, so all other attached blocks will break naturally.

unborn ivy
#

right... so that means ill need to get the other relative types

#

and set them to air, before setting the block to air

hoary scarab
#

yes