#help-development

1 messages · Page 184 of 1

fluid river
#

hehe

tender shard
#

php be like

$hostname = $_GET['HTTP_HOSTNAME']; // or similar
fluid river
#
int* arr = (int*) malloc(10 * sizeof(int));```
tender shard
#

yeah let's not talk about C D:

#

i wish smoking in planes would still be allowed

fluid river
#
public class MyClass {
    ~MyClass() {}
}```
#

The weirdest realization ever

#

who ever created this should burn in hell

tender shard
#

that wouldnt compile

vocal cloud
#

Just quit smoking /s

fluid river
#

that was just example

#

didn't write MyClass.h

#

and include

#

and stuff

tender shard
#

oh, you can't

#

well I also can't stop

fluid river
#

i wrote time machine in MachineScript

#

Cya 10 years ago

#

tho your current nature would be erased

#

and replaced with non-smoking one

tender shard
#

damn this flight is on time

#

already boarding and it's only scheduled to depart in 1:15h

fluid river
#
~mfnalex() {
    free(data);
}```
#
@Override
public void finalize() {
    data = null;
    System.out.println("mfnalex's data has been erased");
}

// somewhere in main class
public static void main(String[] args) {
    // entire universe
    alex = null;
    System.gc();
}```
tender shard
#

Why you erase my data 😦

#

Anyway i gotta go now, have a nice day everyone

fluid river
#

cya

#

❤️

fluid river
#

CompetablePast

half hawk
#

I have a problem with my config file

#

everytime it saves, it deletes a bunch of data

#

when generated it looks like this

#--------------------------------------------------
# Join / Leave Messages
#
# Placeholders:
# - {player} : player's name
# - {nickname} : player's nickname
# - {prefix} : player's vault prefix
# - {suffix} : player's vault suffix
#--------------------------------------------------
JoinLeaveEnabled: true
JoinMessage: "&8[&a&l+&8]&r {prefix}{nickname}{suffix}"
LeaveMessage: "&8[&c&l-&8]&r {prefix}{nickname}{suffix}"

#--------------------------------------------------
# Chat Messages
#
# Placeholders:
# - {message} : chat message
# - {player} : player's name
# - {nickname} : player's nickname
# - {prefix} : player's vault prefix
# - {suffix} : player's vault suffix
#--------------------------------------------------
ChatMsgEnabled: True
ChatMsg: "{prefix}{nickname}{suffix} &8&l»&r {message}"

#--------------------------------------------------
# Spawn
#
# Delay : Milliseconds
# SpawnPvp : Cancel tp when hit by a player
#--------------------------------------------------
SpawnEnabled: True
SpawnDelay: 3000
SpawnPvp: False
SpawnPos:
  ==: org.bukkit.Location
  world: world
  x: 0.0
  y: 65.0
  z: 0.0
  pitch: 0
  yaw: 0
#

but when i try and save the config it deletes all of the notes and saves as: ```yaml

Join / Leave Messages

JoinLeaveEnabled: true
JoinMessage: '&8[&a&l+&8]&r {prefix}{nickname}{suffix}'
LeaveMessage: '&8[&c&l-&8]&r {prefix}{nickname}{suffix}'
ChatMsgEnabled: true
ChatMsg: '{prefix}{nickname}{suffix} &8&l»&r {message}'
SpawnEnabled: true
SpawnDelay: 3000
SpawnPvp: false
SpawnPos:
==: org.bukkit.Location
world: world
x: -251.75343445139748
y: 63.0
z: -174.66100164978275
pitch: 13.800111
yaw: 79.657906```

#

this is what im currently using to save and load my code

#
public void SaveConfig() {
saveDefaultConfig();
}  
public void LoadConfig() {      
// Default Config      
getConfig().options().copyDefaults();      
saveDefaultConfig();  
}
#

and i have some code in a seperate file which also saves the config ```java
Amenities.getPlugin(Amenities.class).getConfig().set("SpawnPos", Loc); Amenities.getPlugin(Amenities.class).getConfig().options().copyDefaults(); Amenities.getPlugin(Amenities.class).saveConfig();

#

Sorry for the long post, I have been trying to fix this for a few hours now

west scarab
#

if i have one of the key it does it once
but if I have two or more, it will run twice??
why is this happening.??

vocal cloud
#

?paste that jeez

undone axleBOT
vocal cloud
#

That switch has a lot of redundant code

#

It probably doesn't even need to exist

west scarab
worldly ingot
#

mfw server crash mod

west scarab
#

lol

#

its the only version of 1.18.2 i have so yeah and im lazy

vocal cloud
#

Honestly you should just delete the switch and use an array and an if statement

array1 = [coinamnt1,coinamnt2];
array2=[gemamnt1,gemamnt2];
rand = randgen.get();

if(rand >= array1.length) {
// gen message and do the other stuff
} else {
// gen gem message and other stuff
}

#

Reduce that code by 99%

vocal cloud
#

Could probably be condensed to 10-20 lines

fluid river
fluid river
#

why do you even need this

west scarab
vocal cloud
#

You'd fix it by not having a switch

fluid river
#

or at least updating to new switch

#

-> {}

vocal cloud
#

No, no switch

#

There is absolutely no reason to have a switch

fluid river
#

int[] coins = new int { 25, 50, ...};

#

done

fluid river
#
int toAdd = randoms[rand];
event.getPlayer().sendMessage(color(MobGens.getPlugin(MobGens.class).getConfig().getString("prefix") + " &7You opened a crate and received: &b$" + toAdd));
balance = storage.grabDoubleParsed("balance", event.getPlayer(), false);
balance+=toAdd;
storage.setVariable("balance", event.getPlayer(), balance, false);
#

done

#

in 5 lines

vocal cloud
#

Yeah, except you can't also handle gems that way

fluid river
#

instead of 21 switch

vocal cloud
#

Which you can just use an if and subtract the length of the previous array to get the position in the next

fluid river
#
private int[] gems = new int { 25, 50, ...};```
#

done

vocal cloud
#

Yeah but you'd still need to if(ran.length >= firstArray.length) {
int value = gems[ran - firstArray.length];
}

fluid river
#

That's how actual spigot methods look like

proper geyser
#

Can you use Hex Codes in Player Titles?

fluid river
#

i guess with textcomponent you can use them everywhere

proper geyser
#

I have chat working just fine but for some odd reason hex codes aren't working for me in player titles

#

Title or Sub Titles. They are appearing white.

fluid river
#

hmm

fluid river
#

tho ...Config() methods usually eat comments

#

only leaving head comments(which are on top of yml) untouched

proper geyser
#

Not sure if they're handled different. Anyone know more on that?

fluid river
#

i guess guys are sleeping

proper geyser
#

The white color is the sub title.
The color is a message being sent to the player.

fluid river
#

show your title sending code

#

actually colorizing code too

#

i guess you just do sendTitle() so first part is not needed

proper geyser
#

Yeah I mean it's just how you would normally do it

#

here i'll show ya

fluid river
#

mostly worked for 1.12 so never really paid attention to Hex colors feature

proper geyser
#
String title = formatToHex(plugin.getConfig().getString("Regions." + regionName + ".Title"));
String subTitle = formatToHex(plugin.getConfig().getString("Regions." + regionName + ".SubTitle"));

player.sendTitle(title, subTitle, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);

I am just confused why it works for chat and not titles but I have seen other plugins out there sending hex codes to titles.

fluid river
#

just learnt new JDK features

proper geyser
#

First time working with them for me

fluid river
#

what is your formatToHex code

proper geyser
#
    public static String formatToHex(String message) {
        Pattern pattern = Pattern.compile("#[a-fA-F0-9]{6}");
        Matcher matcher = pattern.matcher(message);
        while (matcher.find()) {
            String hexCode = message.substring(matcher.start(), matcher.end());
            String replaceSharp = hexCode.replace('#', 'x');

            char[] ch = replaceSharp.toCharArray();
            StringBuilder builder = new StringBuilder("");
            for (char c : ch) {
                builder.append("&" + c);
            }

            message = message.replace(hexCode, builder.toString());
            matcher = pattern.matcher(message);
        }
        return ChatColor.translateAlternateColorCodes('&', message);
    }
#

Result, works perfectly in chat.

fluid river
#

yeah we got that it works in chat

proper geyser
#

Which makes me think that tiles do not support it or utilize a different way.

fluid river
#

might be PacketPlayOutTitle hehe

#

🙂

proper geyser
#

Not sure entirely though. Some individuals have gotten it to work.

proper geyser
fluid river
#

good luck with packets

#

tho you can probably do this on paper

#

but would need BaseComponent's

#

instead of strings

#

kyori adventure stuff

proper geyser
#

Okay, thanks. I will look into it

fluid river
#

Anyone. Explain what's the point of using nested classes

river oracle
#

keep things neat and in place

raw prairie
#

How can I randomly rotate a schematic?

hybrid spoke
raw prairie
hybrid spoke
#

see how they do it

#

do it like them

raw prairie
torn oyster
#

what is better, making a plugin-like minigame library, or making a custom server jar to use as the library

brave goblet
#

I added a jar to my plugin as a dependency the scope is set to compile but when I try compile my plugin using maven package I get this error
package com.gmail.nossr50.api does not exist

#

I know that jar will be in my plugins folder does that mean I would have to compile it into my plugin? and if i didn't how would i get it to work

alpine narwhal
#

If you want to add the dependency to your jar you want to use compile. If the API has a jar u can put provided.

river oracle
alpine narwhal
#

Anyways, does anyone know how to make custom player heads 1.19?

#

I've tried but it just gives me an alex head

#
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
        SkullMeta meta = (SkullMeta) item.getItemMeta();

        GameProfile profile = new GameProfile(UUID.randomUUID(), null);
        profile.getProperties().put("textures", new Property("textures", texture));

        try {
            Field field = meta.getClass().getDeclaredField("profile");
            field.setAccessible(true);

            field.set(meta, profile);
        }catch (Exception exception) { exception.printStackTrace(); } finally {
            item.setItemMeta(meta);
        }
torn oyster
#

npc skins didn't work for me without it

#

but you are doing skulls, so i'm not sure

brave goblet
alpine narwhal
brave goblet
#

i just can't do anything if my plugin won't compile

alpine narwhal
#

Make sure u put provided then

brave goblet
# alpine narwhal ```java ItemStack item = new ItemStack(Material.PLAYER_HEAD); SkullMeta ...
public ItemStack skull(String head) {

        ItemStack skull = new ItemStack(Material.PLAYER_HEAD, 1);
        SkullMeta skullmeta = (SkullMeta) skull.getItemMeta();

        GameProfile profile = new GameProfile(UUID.randomUUID(), null);
        profile.getProperties().put("textures", new Property("textures", head));
        Field field;
        try {
            field = skullmeta.getClass().getDeclaredField("profile");
            field.setAccessible(true);
            field.set(skullmeta, profile);
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException x) {
            x.printStackTrace();
        }

        skull.setItemMeta(skullmeta);
        return skull;
    }
brave goblet
alpine narwhal
daring lark
#

thanks man

raw prairie
#

How can I rotate schematics before I paste them?

marble granite
#

I need to move an NMS Player NPC relatively in 1.8.8, but i'm having trouble with fixed-point numbers. this is my code:

        connection.sendPacket(new PacketPlayOutEntity.PacketPlayOutRelEntityMove(
                fakePlayer.getId(),
                (byte) ((newLoc.getX() - loc.getX())* 32),
                (byte) ((newLoc.getY() - loc.getY())* 32),
                (byte) ((newLoc.getZ() - loc.getZ())* 32),
                followEntity.isOnGround()
        ));

Which results in the player slightly desyncing with the real location.

charred blaze
#

Hi. I wanted to check if EntityDamageByEntityEvent was cancelled with @EventHandler(ignoreCancelled = true), but it seems to not be working on worldguard. Anyway, is there any other ways with I can check if player got his damage or not?
if (!((p.getHealth() - e.getDamage()) == p.getHealth()))
I tried this ^ but that check is not working too.
Can anyone help?

elder ingot
# marble granite I need to move an NMS Player NPC relatively in 1.8.8, but i'm having trouble wit...

You want to do it like that

        connection.sendPacket(new PacketPlayOutEntity.PacketPlayOutRelEntityMove(
                fakePlayer.getId(),
                (short) ((newLoc.getX() * 32 - loc.getX() * 32) * 128),
                (short) ((newLoc.getY() * 32 - loc.getY() * 32) * 128),
                (short) ((newLoc.getZ() * 32 - loc.getZ() * 32) * 128),
                followEntity.isOnGround()
        ));

P.S you need to check if the player move less the 8 blocks,
if the player moved more then 8 blocks you need to use Teleport Entity

elder ingot
# charred blaze Hi. I wanted to check if EntityDamageByEntityEvent was cancelled with ```@EventH...

if you want to check if player got damage you don't do

(p.getHealth() - e.getDamage()) != p.getHealth()

because it will almost always be true expect if damage is 0

if you want to check if player got damage by other entity you just do

@EventHandler(ignoreCancelled = true)
public void on(EntityDamageByEntityEvent event) {
   if (!(event.getEntity() instanceof Player player)) return;
   if (event.getFinalDamage() == 0) return;
   // Do something
}
marble granite
#

but, thanks for the reply!

elder ingot
elder ingot
marble granite
#

and i just realized why your code diuffers from mine, i used the waybackmachine to view wiki.vg when it was updated for 1.8.8, and thats slightly different

brave goblet
marble granite
#

but it still doesnt

modern vigil
#

how would I go about identifying an inventory?

#

like distinguishing one person's gui from another

drowsy helm
#

get the inventory owner

modern vigil
#

i mean like

#

let's say i have a settings menu (a gui)

#

a normal player can only change their own settings

#

but an operator can change another player's settings

#

nvm

brave goblet
#

How would I add a local dependency to my project?

modern vigil
#

basically I just want a way to store nbt data in an inventory

modern vigil
drowsy helm
#

just have a separate inv for each player then if an op edits another player's settings, update the current player's inv

graceful tartan
#

hey, I created an npc, but I dont know how to spawn it. can someone help? 1.19.2

modern vigil
#

i need to identify the owner of the settings

drowsy helm
#

how are you handling custom inventories rn

#

because that will either make your life far easier or be a pain in the ass

#

you need good infrastructure

modern vigil
#

i'm not yet handling inventories atm

#

i just need the general idea on how to identify

#

i dont know if this is a good solution but i could make a single borer item have nbt

#

which stores the UUID of the owner of the settings

#

but that's probably not the best idea

drowsy helm
#
public class PlayerSettingsInventory extends CustomInventory{
  private final UUID player;

  public PlayerSettingsInventory(Player player){
    this.player = player;
  }

  @Override
  public Inventory getInventory(){
    //do inventory shit regarding player
  }

  @EventHandler
  public void onClick(InventoryClickEvent event){
    //do stuff here
  }
}```
#

with a good backend you should be able to do something like this

#

where each instance of a class is a certain palyer's gui

#

no need for any nbt stuff

#

an inventory is tied to a class

#

utilise OOP

modern vigil
#

e.g if i open this inventory to a player, can i get that custom class via a bukkit method?

drowsy helm
#

could use InventoryHolder

#

or keep track of all inventories and handle that accordingly

modern vigil
#

yea the part i'm struggling with is being able to get that owner via a bukkit method

drowsy helm
#

wdym?

earnest forum
#

InventoryHolder gives you the owner

drowsy helm
#

in that code i just gave you it's as simple as this.player

#

just need to ensure the inventory clicked is the correct one

earnest forum
#

?jd-s

undone axleBOT
modern vigil
#

so should I implement InventoryHolder..?

earnest forum
#

inventoryholder itself is a player

#

or the other way around'

#

you can get the holder of an inventory

#

and it will be instranceof player

knotty meteor
#

((CraftArmorStand)((Object)standTires)).getHandle().setLocation(x, y, z, yaw, pitch);
Why is setlocation not working in 1.19.2 in 1.12.2 it was working fine

drowsy helm
#
public class CustomInventory extends InventoryHolder{
  public Inventory getInventory(){
    return Bukkit.createInventory(this, 9, "Title");  
}
}```
#

a lot of people do this

earnest forum
#

im not sure if you open an inventory to player it will automatically set the holder

solid cargo
#

i have never seen this (when hovering above spigot dependency) can someone explain??

#

a vulnerable dependency?

drowsy helm
#

and whats up with all that casting

earnest forum
#

casting to object

#

looks like intellij';s work

drowsy helm
#

standTires will always be Object

#

it's inherently an object

onyx fjord
#

Okay so yesterday i played around with aliases and this is what i ended up with

        Objects.requireNonNull(getCommand("withdraw")).setExecutor(new Commands());
        Objects.requireNonNull(getCommand("withdraw")).setTabCompleter(new TabComplete());

        CommandMap map = Utils.getCommandMap();

        Command cmd = Objects.requireNonNull(map).getCommand("withdraw");
        List<String> aliases = Objects.requireNonNull(cmd).getAliases();
        aliases.addAll(config.getStringList("withdraw.aliases"));
        cmd.setAliases(aliases);

        System.out.println(getCommand("withdraw").getAliases());

[banknote] gets printed which is correct, however running command using banknote doesnt do anything

#

getCommandMap() essentially does this

final Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");

and sets it to accessible

earnest forum
#

you use reflection on every getCommandMap call?

onyx fjord
#

its only ran once

tender shard
bright cedar
#

Hi, I'm developing a UHC plugin, but I would like that when I generate a map, there must be a Roofted Forest biome within 200 blocks of the center. How can I do this?

onyx fjord
#

¯_(ツ)_/¯

onyx fjord
#

ultra hardcore

#

its a minigame kinda thing

bright cedar
onyx fjord
#

now time to clean that mess up

trim creek
#

i think its not possible to force the world generation to make a speficted biome WITHIN a given radius

onyx fjord
#

yeah generally world generation is ass to make

trim creek
#

But I alsoran into a problem

bright cedar
trim creek
#

Generually... I did MySQL before, mostly with not that many errors... However, I am fixing and repairing my code - because it looks like shit -, and I removed most of the "static" izék from most of the voids. Now my plugin cannot boot up, because its saying that connection is null.
First class (that one that gets and sets data from MySQL):

    public MySQLManager m = new MySQLManager();
    public void voidName() {
        try {
            PreparedStatement ps = m.connection().prepareStatement("sqlcode comes here");
            ps.executeUpdate();
        } catch (SQLException e) {
            Bukkit.getLogger().warning("§cHiba törént az adatbázisban!");
            e.printStackTrace();
        }
    }

Second class (the manager itself):

public Connection connection;

    public boolean isConnected() {
        return (connection == null ? false : true);
    }

    public void LoadDriver() {
        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
        } catch (Exception ex) {
            ex.getMessage();
        }
    }

    public void connect() throws ClassNotFoundException, SQLException {
        if (!isConnected()) {
            try {
                connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + name + "?useSSL=false", user, pass);
            } catch (SQLException e) {
                Bukkit.getLogger().warning("[Hiba] Hiba a MySQL-ben!");
                Bukkit.getLogger().warning("[MySQL] Hiba: " + e);
            }
        }
    }
trim creek
trim creek
hazy parrot
trim creek
#

I already did

hazy parrot
#

also return (connection == null ? false : true); can just be return connection != null

trim creek
#

This is how it looks like:

    SQL.LoadDriver();
    SQL.connect();
    data.voidName();
    data.voidName1();
hazy parrot
drowsy helm
#

are you doing it async?

hazy parrot
#

assuming SQL and m are not same instance

trim creek
#

SQL and m are the same

#

but since I am repairing my code

#

it might be the problem xd

hazy parrot
#

how are you getting SQL

trim creek
#
  // few lines below public class Loader
  public MySQLManager SQL;
  public MySQLGetterManager data;

  // later in code when plugin starts up
  getServer().getPluginManager().registerEvents(new MySQLManager(), this);
  getServer().getPluginManager().registerEvents(new MySQLGetterManager(this), this);
  this.SQL = new MySQLManager();
  this.data = new MySQLGetterManager(this);
    try {
      SQL.LoadDriver();
      SQL.connect();
      data.voidName();
      data.voidName1();
hazy parrot
#

so its not the same

#

this.SQL = new MySQLManager(); here you are making new instance, and also making new instance public MySQLManager m = new MySQLManager(); inside of data class

trim creek
#

Meanwhile, the path I get the error to, is another class

#

They must be named the same?

#

(the references)

hazy parrot
#

reference must be same, yes

trim creek
#

oooooooooooooooooo

#

then I am f*cked up XD

hazy parrot
#

you cant create new object

#

you are connecting with object A, but using connection from object B

trim creek
#

so thats why it always was null

#

because before I was using plugin.SQL.connection() and not (from now on) d.connection()

#

Anyway thanks :D

tardy delta
#

isnt map::get != null the same as map::containsKey?

#

handles null keys ig

ivory sleet
#

Myeah

#

But like concurrent maps such as the concurrent hash map and concurrent skip list map, null keys are not admitted in which containsKey and get != null are basically the same

eternal oxide
#

read the note in the javadoc on opening inventories in the close/interact event

#

From your error it looks like I spoke too soon

#

AcceptRules.java:44

#

something in there is null

chrome beacon
#

Don't detect inventories by their name

eternal oxide
#

they can be faked

chrome beacon
#

If someone else names an inventory that it will break stuff

#

Let's say you have an item rename plugin for example. I rename a chest to your inventory name then it will cause issues

#

You either track the inventory instance or give it a custom inventory holder

eternal oxide
#

you have an gui instance so use that

tardy delta
#

what error

#

stackoverflow still not fixed?

quaint mantle
eternal oxide
#

change all your if(event.getView().getTitle().equals(guiInv)) to if(event.getInventory() == gui))

tardy delta
#

are you getting in some infinite loop by closing/ reopening inv?

quaint mantle
#

mh, kid, you still have a lot to learn about life🗿

tardy delta
#

whats on AcceptRules.java:44

eternal oxide
#

you are also using the wrong event, line 42

#

use the close event

#

and don;t cancel the event

tardy delta
#

just to be sure, does a invclose event gets fired when players gets kicked with an inv open?

eternal oxide
#

Thats wrong

chrome beacon
#

Well yeah that's going to cause an infinite loop

eternal oxide
#

you don;t call close in the close event

eternal oxide
#

in the close event you call open on a 1 tick delay

tardy delta
#

i told him about that delay yesterday but they didnt listen

#

?scheduling

undone axleBOT
eternal oxide
#

Pseudo code```java
if (event.getInventory() != gui) return;

Bukkit.getScheduler().runTask( plugin, () -> { player.openInventory(gui) } );```

#

it calls runTask in the Bukkit scheduler to run that lambda

tardy delta
#

it runs some task a tick later

#

where there are 20 ticks in a second in a normal situation

#

dont pass in null

#

simple

#

how do you get your plugin? di or singleton?

eternal oxide
#

pass yoru plugin instance to your listener to use as plugin

tardy delta
#

?di

undone axleBOT
eternal oxide
#

so in your main class when you normally use new AcceptRules() you would use new AcceptRules(this)

#

and add a constructor to AcceptRules to take a Plugin instance

remote swallow
#

would look like

public class AcceptRules implements Listener {

    private final MainPluginClassName plugin;

    public AccpetRules(MainPluginClassName plugin) this.plugin = plugin;

}
tardy delta
#

you dont need it

#

it ensures only one instance of a class can be present

eternal oxide
#

You just need to pass an instance of your plugin to your Listener

#

don;t need singleton. Your plugin instance IS a singleton

grim ice
#

well if u dont know what a singleton does

tardy delta
#

new MyPlugin() 🥲

grim ice
#

then you never knew how to make one

#

in the first place

#

just saying, no one will turn into a cannibalist and eat you alive because you dont know what a singleton is

eternal oxide
#

When you call openInventory with an inventory already open it will trigger a close event. If you are already IN a close event you are firing teh same event over and over

#

So you have to delay the opening to allow the current close event to finish

grim ice
#

do this internally

eternal oxide
#

Not without as lot of internal checks to see if it's already fired the event

tardy delta
#

too much work 🙄

eternal oxide
#

its simpler to just fire events and let plugin devs sort it out 🙂

grim ice
#

well yeah i guess

#

that's because you said it in a way that will trigger many people

eternal oxide
#

This channel tends to turn on big egos before they get too rude.

grim ice
#

eitherway, here we have a saying that

#

two types of people never learn, the embarassed and the egotistical

#

point is, you shouldn't refrain from asking questions or stating your lack of knowledge out of embarrassment

eternal oxide
#

So long as you know basic Java, no question will be ignored.

serene egret
#

hey i have a problem, i created a bossbar with color and text but when i set it to the players it is just gray and it looks kinda weird https://imgur.com/a/gXyxBeJ

remote swallow
#

give us code

#

?paste

undone axleBOT
tardy delta
#

im not seeing much on that screen

serene egret
remote swallow
tardy delta
#

do you know && is a thing?

serene egret
#

the title works

#

but also the segments and the updatemethod works

eternal oxide
#

Sorry I can;t work out anything in the pic

tardy delta
#

^^

grim ice
#

i can see whats happening in the picture

#

basically, the bossbar is distorted

#

the bossbar is supposed to be purple

#

yet some parts are invisible

serene egret
#

but i set the bossbar color to blue why it isn`t blue?

grim ice
#

and some are black

serene egret
#

so do i have to set it visible?

grim ice
#

what version

#

are you in

serene egret
#

1.19

grim ice
#

how much is per?

#

the variable per

#

how much is it?

tardy delta
#

seconds / 1.0?

serene egret
#

it is 0.1 in the runnable

#

oh no nvm

#

it is 1

grim ice
#

just saying

#

if its above 1

#

or under 0

#

itll not work

serene egret
#

ok

#

but the progress works

#

the bar progress moves only the color isnt there

#

there is the vid

tardy delta
#

isnt your resourcepack just fucking up?

serene egret
#

wait i will check

#

omg yeah

#

thx

tardy delta
#

lmfao

elfin atlas
#
 public void onSignCreate(SignChangeEvent e) {
            Sign sign = (Sign) e.getBlock().getState();
            if(Objects.equals(e.getLine(0), "[CFGames]")) {
                switch (Objects.requireNonNull(e.getLine(1))) {
                    case "snowrace" -> {
                        Bukkit.broadcastMessage("t");
                        sign.setLine(0, ChatColor.DARK_GRAY + "[CFGames]");
                        sign.setLine(1, ChatColor.GOLD + "Snow Race");
                        sign.setLine(2, ChatColor.GRAY + "0/7");
                        Bukkit.getScheduler().runTaskLater(main.getInstance(), () -> {
                            sign.update();
                        },10);
                    }
                    case "snowballfight" -> {
                        sign.setLine(0, ChatColor.DARK_GRAY + "[CFGames]");
                        sign.setLine(1, ChatColor.GOLD + "Snowball Fight");
                        sign.setLine(2, ChatColor.GRAY + "0/10");
                        Bukkit.getScheduler().runTaskLater(main.getInstance(), () -> {
                            sign.update();
                        },10);
                    }
                }
            }

    }
``` Does someone know why the sign is not updating? I tried with out the Scheduler to run it instantly but its not working. I get the t in the MC chat logged so I don't really get it what wrong is in the code.
echo basalt
#

given the event is cancellable my best guess is that the setLine method is overriden after the event is called

tardy delta
#

hoping there is an @EventHandler

elfin atlas
grim ice
#

which mob vote candidate won btw

#

or did it not end

manic furnace
#

How can I set the value of the "name" field in GamProfile?
I make It like this:

entityPlayer.getProfile().getClass().getField("name").get(entityPlayer.getProfile())

But I get this exception:
https://paste.md-5.net/femovotiqo.bash

remote swallow
#

not ended yet

tardy delta
#

should i made db columns notnull by default in my db lib?

remote swallow
#

ends in like 3 hours 33 minutes

grim ice
#

tuff golem is the worst

remote swallow
#

nah

#

rascal is

grim ice
#

literally, just an item frame

#

rascal gives u free loot

remote swallow
#

its low lvel

grim ice
#

which makes it the best for me

#

and?

#

for casual players its cool

remote swallow
#

its pointless after getting a dia pick

grim ice
#

and u might be able to change the loot it gives with spigot

#

itll open so many possibilities

#

better than a few useless plants and a mob that we will forget in a few hours

#

and it can open the possibility for a new minigame on servers

#

a rascal hide and seek and see who gets a certain item first

chrome beacon
#

In your case the field "name" doesn't exist

#

It's probably named something else

manic furnace
#

I used getFields() and there arent any fields

drowsy helm
#

Try getDeclaredFields

manic furnace
#

Yeha it worked

drowsy helm
#

And pls just use a local variable lol

tardy delta
floral drum
tardy delta
#

combing that with reflections, basically i have no idea what im doing

manic furnace
#

How can I get the exact class with Reflections? Because when I get the nms World, I get the nms worldserver

eternal oxide
#

you need Level

manic furnace
#

Without mappingss

eternal oxide
#

good luck not using mappings

manic furnace
#

Im using reflections for mulitversion support

eternal oxide
#

?paste

undone axleBOT
eternal oxide
tardy delta
#

dont ask me what im doing

floral drum
remote swallow
#

What are you diong

floral drum
#

blank consumer?

tardy delta
#

fucking up with generics and reflections

floral drum
#

cring

tardy delta
#

basically trying to do this with reflections

torn shuttle
#

brah

#

making games is cringe

#

I think it's been 5 hours since I started implementing pathfinding and it feels like I have not even started

tardy delta
#

classic

torn shuttle
#

I just don't want lame stuff like entity overlap in a grid-based df-style map

#

but as it turns out if you're doing a df/rimworld style game, disallowing units from overlapping is uh

#

well it doesn't really work

eternal oxide
#

it does, it just blocks pathing

torn shuttle
#

well yeah, sort of permanently too, there is no good condition to avoid it

eternal oxide
#

if you want overlapping you shoudl add layers

torn shuttle
#

I'm just sort of bypassing the issue

#

there's an incremental speed debuff for stacking entities in the same grid space and entities will do a quick adjacency check to see if there's an alternative square they can use that is empty

#

so basically there's a justifiable reason to making corridors with higher circulation wider

#

without it ruining gameplay

tender shard
#

just store it as seconds remaining?

torn shuttle
#

store a unix timestamp, it will save you on headaches

#

also don't use yml files, use a database

tender shard
#

i'd just use the player's PDC

#

no need for any external storage

#

oh you want to store a fixed date? yeah then ofc go for a timestamp

#

I thought you wanted to ban them after "X hours of playtime" and not "next thursday at 3 pm"

#

sure

#

just turn the target date/time into a timestamp and save it as long on the player's PDC

#

then when they join, compare the current timestamp with the "ban date" and if it's > than that, kick them

torn shuttle
#

I keep forgetting that exists

tender shard
#

PDC is the most beautiful thing ever added to spigot

torn shuttle
#

I was already an old man when it got added, it's just not a part of my workflow

#

I mean

#

young and hip

#

as I still am

#

was back then too

tender shard
#

I only found out about it in 1.16

#

and it was added in 1.14.1

#

since 1.16.3, even chunks have a PDC

#

and worlds too, since 1.18 or so

#

as a long

#

a timestamp is just a long / large number

torn shuttle
tender shard
#

e.g. System.getCurrentTimeMillis() returns a unix timestamp

#

I'd do it like this:

private static final long DEFAULT_PLAY_DURATION = 10 * 24 * 60 * 60 * 1000; // 10 days * 24 hours * 60 minutes * 60 seconds * 1000 milliseconds
private final NamespacedKey endDateKey = new NamespacedKey(myPlugin, "endDate");

onJoin:
  long timeNow = System.getCurrentMillis();
  long timeEnd = timeNow + DEFAULT_PLAY_DURATION;
  player.getPersistentDataContainer().set(endDateKey, PersistentDataType.LONG, timeEnd);```
#

you should just check it on join and then again every second or so for all online players

#

Ofc not?

#

Why would it be

torn shuttle
#

brah

#

unless your server is known to run slow just make a task that will ban them after a set amount of ticks

tender shard
#

Inagine the huge amount of physics getting done on every tick

torn shuttle
#

and make that tick count equal to the time to ban

tender shard
#

Just comparing two longs is literally nothing

torn shuttle
#

just use a delayed task

tender shard
#

You could compare it 100 times per tick without ANY problems

torn shuttle
tender shard
#

This reminds me, i need to reinstall my rpi tomorrow

torn shuttle
#

my man

#

hey my bank account got hacked, spread the love

#

I don't trust banks anymore send me bitcoin

#

2x0=0, checks out

grim ice
#

what if im in debt? will u just take even more money?

torn shuttle
#

no, only the bank does that

grim ice
#

lmao

glad prawn
#

Is there any tutorial on ConfigurationSerializable?.

tender shard
#

the javadocs explain everything

glad prawn
#

Ok

tender shard
#

that requires two lines of NMS

torn shuttle
#

that's two lines too many

tender shard
#

then where are you going to get the "leave date" from?

#

do you actually need the data of offline players?

#

you shouldnt change their remaining time every second

#

you should rather just only store the "end date" in the first place

#

I mean, imagine you have an appointment at the barber in 3 days. you wouldnt write down "appointment in X thousand seconds" then count it down by one every second, you'D just write down "thursday at 3pm"

#

on first join, just e.g. do this:
end date = current time in milliseconds + allowed duration in seconds * 1000

#

now, you can just check every second whether the current time in milliseconds is >= the end date you saved

#

if yes, their time is over

#

yes 🙂

#

I mean you don't even have to use milliseconds, you could just use seconds

#

I only used milliseconds in this example because that's what System.currentTimeMillis() returns

#

the TimeUnit class is also very handy to convert

#

e.g. TimeUnit.MILLISECONDS.convert(3, TimeUnit.DAYS) or sth like that

#

that would return you the amount of milliseconds that equals 3 days

#

yep

#

:3

severe marsh
#

How can I cast Block to a Chest?

tardy delta
#

cast the blockstate iirc

#

(Chest) block.getState()

severe marsh
#

Thanks

tender shard
#

and be sure to check if it actually is a chest before casting it

#

the fields?

#

the "on Join" part is obviously a listener that listens to PlayerJoinEvent

fickle mist
#

How to find out which world the player is in(example: overworld)

tender shard
#

World#getDimension

tender shard
#

you could e.g. do this

myMap.put("mfnalex", null);
#

now it containsKey("mfnalex") but .get("mfnalex") would be null

sterile token
#

I need some help with nMessage library, is posible to use it to send a list of messages but on replacing each variable from each value that are diff on the next line?

tardy delta
#

me when doing reflections

tender shard
#

that's personal preference

tardy delta
#

di

tender shard
#

DI leads to so much useless code imho

crimson terrace
#

it does not

tender shard
#

people claim it's better for unit testing but those people havent heard of mockbukkit

crimson terrace
tender shard
#

sure it depends. if you just need your main class in a listener to get a namespacedkey, then a static instance getter is totally fine

crimson terrace
#

then you can do what you want 🙂

tender shard
#

i mean there isnt really a difference between passing "this" to every new object, or to just provide a getInstance() method that returns the same thing

#

it's something like "minecraft:dirt"

crimson terrace
#

technically theres always a way to get the plugin instance, by using the PluginManager

#

you dont even have to have an instance refernce yourself

tender shard
#

stuff like PersistentDataContainers heavily use NamespacedKeys

tardy delta
tender shard
#

yeah, that's why I prefer a static getter

crimson terrace
tender shard
#

javaplugins are a singleton by design anyway

tender shard
crimson terrace
#

true

tender shard
#

nothing of these is really wrong or right, I think it's just personal preference

crimson terrace
#

then I dont understand why people shame others for using static instance references

grim ice
#

i just heard static

#

whats the argument

#

:O

crimson terrace
grim ice
#

u mean geti() and stuff?

tardy delta
#
java.lang.IllegalAccessException: Can not set final int field me.fourteendoggo.database.object.DummyPlayer.level to java.lang.Integer```
does this mean i cant use `field.set(integerObj)` where the type is an int?
grim ice
#

that's 100% fine

crimson terrace
#

not in here its not

tardy delta
#

made the field accessible before

grim ice
#

if you're doing it properly

#

if anyone shames u for that

#

hes plain stupid

tardy delta
crimson terrace
# grim ice hes plain stupid

theres definitely some things that require non static references and stuff... just makes it easier for other people to expand on your code

sterile token
#

I have a string list on the config which has the next values and my goal is to know how to send the list 1 time but replacing each variable from a List. Im using nMessage

Command:
  Help:
    - "   &6%command% &7Help: "
    - ""
    - " /%command% %usage% - %description%"
crimson terrace
#

my job for example would kill me if I ever used static for pretty much anything (of course with exceptions)

crimson terrace
#

but always possible 🙂

grim ice
#

breaking your computer is also possible

crimson terrace
#

then how about we start with yours 🙂

grim ice
#

most inconvenient things are always possible

crimson terrace
#

its more convenient than not being able to get an instance at all

grim ice
#

how can you not be able to get an instance at all

upper vale
#

just split the list into header body and footer and loop the body as many times as needed

crimson terrace
raw prairie
#

how might I check if the player is in a new chunk?

grim ice
#

that's another case

crimson terrace
tardy delta
#

setting a final field with Field::set should work right?

raw prairie
crimson terrace
#

you get a HashMap, cache the player you wanna check with their current chunk, then every time you do whatever you check whether their current chunk is still the same chunk

grim ice
#

do you know how to cache an object? @raw prairie

sterile token
tardy delta
#

anyone even listening lol

raw prairie
grim ice
#

do what shreb said then

crimson terrace
crimson terrace
#

tas

grim ice
#

yikes

#

?tas

undone axleBOT
grim ice
#

there

crimson terrace
#

there ya go

upper vale
#

dont you have to remove the final first

tardy delta
#

lmao im asking cuz i posted a screen two minutes ago

#

or well just an error message

raw prairie
tardy delta
tender shard
#

usually setAccessible(true) is enough. if the security manager is annoyed, then you also need to remove the final modifier

tardy delta
#

setting an int field to an Integer should normally work?

upper vale
#

im like 90% sure you need to remove the modifier

tender shard
#
static void setFinalStatic(Field field, Object newValue) throws Exception {
      field.setAccessible(true);

      Field modifiersField = Field.class.getDeclaredField("modifiers");
      modifiersField.setAccessible(true);
      modifiersField.setInt(field, field.getModifiers() & ~Modifier.FINAL);

      field.set(null, newValue);
   }

proudly stolen from SO

tender shard
tardy delta
#

its not static

tender shard
#

ofc its just an example

#

just adjust it to your needs

tardy delta
#

well lets see

#

smh java.lang.NoSuchFieldException: modifiers

vivid skiff
#

How can i end a task from another class?

river oracle
#

?learnjava

undone axleBOT
river oracle
#

generally learning java will help you achieve that

tardy delta
#

dunno what i am doing wrong

#

throws a nosuchfield before the sysout

fickle mist
#

How can I make it so that the data that I need is displayed in the tablist

tardy delta
#

lets your command class implement TabCompletor and override the method to return a list of completions

#

assuming your talking about chat

fickle mist
tardy delta
#

the thing were you see other players?

#

there is a Player#setTabListHeader and footer

tardy delta
#

oh even headerfooter in one method

crimson terrace
#

?paste

undone axleBOT
sterile token
#

Hi

#

I have a dought how i do tab complete for sub commands?

tardy delta
#

my tabcomplete smh

#

old plugin

sterile token
#

Can u help me fourten?

tardy delta
#

what do you want to show

sterile token
#

I want to apply tab completion for everything so when you type the command its recommend you the posible arguments or sub commands and then args of each sub command

#

I dont know if i have explained

#

I have that tab complete method

tardy delta
#

you need a way to check the args.length of tabComplete

sterile token
#

BukkitExecutor handle the commands

sterile token
tardy delta
#

tell me what possible completions you want

sterile token
tardy delta
#

uh i mean what are the possible syntaxes for your command

sterile token
#

BukkitExecutor = normal command
BukkitArgument = an argument or sub a command

tardy delta
#

you know how this works?

sterile token
#

its hipotetical case but just to see how it would be done

tardy delta
#

it would allow /trade request /trade cancel /trade accept /trade decline /trade help

#

cuz youre checking what the length of your args is

sterile token
#

/faction - base command
/faction list - command argument
/faction info <name> - sub command

So, when you type only "faction should recommend, list and info"
Once you type "faction info " should recommend factions names

tardy delta
#
List<String> onTabComplete(String[] args, CommandSender sender) {
  return switch (args.length) {
    case 0 -> showHelp(sender);
    case 1 -> {
      List<String> completions = Arrays.asList("list", "info");
      yield StringUtil.copyPartialMatches(args[0], completions, new ArrayList<>() /*buffer*/);
    case 2 && args[1].equals("info") -> showFactions(sender);
    }
  }
}```
sterile token
#

Hmnn

#

How i do i apply myself?

tardy delta
#

that stringutil thing (bukkit class) just checks the already entered things

sterile token
#

Wait wait

#

Because its really diff to my things

tardy delta
#

so if you would do /faction aaaaa it wouldnt longer display list and info

sterile token
#

Because i have a List<BukkitArgument> where i keep each arg name, etc, execute, tabcomplete method

#

I mean the first part is done

#

Just to know when i need to rn the BukkitArgument#tabComplete()

#

I dont think im explaning my self

tardy delta
#

so get the BukkitArgument based on the input?

sterile token
#

That is to you to see how it works the command

tardy delta
#

uhh does that do anything?

sterile token
novel totem
#

Could someone help me fix the bug in plugin I made year ago? I have been coding in C# recently so I don't remember java. https://hastebin.com/afuxilihuv.java the plugin drops steve head with player one for some reason

sterile token
raw prairie
#

howmight I use the object checkfornewchunk?

sterile token
#

if the method is in red

#

Its because it doesnt exists or isnt a public method

sterile token
#

check the imports

#

Maybe you have imported a dif class

raw prairie
remote swallow
#

pass player instance

raw prairie
remote swallow
#

do you have a player instance in that section

raw prairie
#

for the class

remote swallow
#

okay, do you set player 2 in that section

raw prairie
#

I do not set player2 in the main class

remote swallow
#

?paste

undone axleBOT
remote swallow
#

send your main class on one too

raw prairie
novel totem
#

Plugin drops unwanted item

tardy delta
#

is it normal that this prints nothing?

#

getFIelds prints the fields ffrom Member.class

remote swallow
tardy delta
#

should have all these

remote swallow
#

you need a player instance what you can pass in on that if statement

raw prairie
remote swallow
#
for (Player check : Bukkit.getOnlinePlayers() {
    if (cache.checkForNewChunk(check)) {
        // all of your code
     }
}
fossil lily
#

https://pneumonoultramicroscopicsilicovolcanoconiosis.club/Ezi8pzRi

        StringBuilder builder = new StringBuilder();
        for (Potion value : Potion.values()) {
            builder.append(value.getName()).append("\n");
        }
        ArmorStand as = (ArmorStand) e.getPlayer().getWorld().spawnEntity(e.getPlayer().getLocation(), EntityType.ARMOR_STAND);
        e.getPlayer().sendMessage(builder.toString());
        as.setMarker(true);
        as.setGravity(false);
        as.setCanPickupItems(false);
        as.setCustomName(builder.toString());
        as.setCustomNameVisible(true);
        as.setVisible(false);
        e.getPlayer().addPassenger(as);

https://pneumonoultramicroscopicsilicovolcanoconiosis.club/OjAr0BCE
How can I make multi line names?

fossil lily
small current
#

i guess thats the way

tardy delta
#

can someone just test this for me, im getting no output altho it should

for (Field field : Field.class.getDeclaredFields()) {
            System.out.println(field.getName());
        }```
minor garnet
#

how i get the distance between two locations, with x, y and z distance values??

tardy delta
#

Location#distance

chrome beacon
#

Ugh... so I just found out how terrible the BlockExplodeEvent is to work with

raw prairie
#

because if hte player is in a new chunk

#

I want it to execute my ode

#

@remote swallow

remote swallow
#

what will cache.checkForNewChunk return if it is a new chunk

minor garnet
raw prairie
#

and reutrn true if its an old chunk

remote swallow
#

thats a bad idea

raw prairie
#

y

#

u saw in the code

remote swallow
#

change the if to if (!(cache.checkForNewChunk(check)))

raw prairie
desert loom
olive lance
#

wtf is that domain

tardy delta
#

anyways the original issue was this

#

where this is my code and it fails at the field::set

#

it should be doing unboxing to an int automatically when receiving an int so i dont think thats the problem

#

api notes say this

austere solstice
#

Hi guys can someone help me?
When I start my plugin first time it is creating Config.yml with all datas but plugin doesn't get that datas for using. After that when I reload plugin it is now plugin see those datas. Let me show with picture

charred blaze
tardy delta
#

record fields immutable ig

charred blaze
charred blaze
# charred blaze Why?
    - String cannot be resolved to a variable
    - Syntax error on token "String", ? expected after 
     this token
    - entry cannot be resolved to a variable```
#

what

tardy delta
#

final fields seem to not be included in Class::getDeclaredFields?

charred blaze
#

what

tardy delta
#

not responding to you

charred blaze
#

WHAT

#

why

charred blaze
#

what?

sterile token
charred blaze
#

uh

#

my bad

raw prairie
#

Amogus

charred blaze
#

Do i lose anything from UUID value when i turn it to an String?

tardy delta
#

record fields seem to be not accessible thro reflections

#

no

#

convert it back using UUID.fromString

charred blaze
tardy delta
vivid skiff
#

How can i stop particles from mooving away when spawing?

grim ice
#

the sniffer won

#

wow

graceful tartan
#

hey, what is TeleportCause and how do I get it?

tardy delta
#

record fields ::set doesnt work?

ivory sleet
#

No, they’re transparent immutable data carriers

tardy delta
#

so you cant change the value of their fields thro reflections?

ivory sleet
#

Nope

tardy delta
#

smh

ivory sleet
#

That’d violate the java specifications concerning records

tardy delta
#

yes i understand that, but relfections has always been a hacky solution so i thought that'd work 🙄

ivory sleet
#

Myeah

#

You mean reflection?

#

Cause reflections is a library

tardy delta
#

uhh reflection whatever

ivory sleet
#

Yeah

tardy delta
#

i guess now create a class for this :/

#

or i might use some constructor instead

#

actually yeah

ivory sleet
#

Its a bit weird, but it does make sense to encapsulate the record components strongly even against reflection

tardy delta
#

anyways is there a way to get the (default) constructor of a record, like the one declared with record Whatever(...) {}?

green dune
#

can anyone tell me how to edit download jar files in intellij idea?

tardy delta
#

i believe its clazz.getConstructors()[0] tho

green dune
tardy delta
#

you dont?

#

or you clone the project and start editing the source code?

unique pasture
#

Is there a way to fix this at BuildTools?

#

applyPatches.sh: line 2: $'\r': command not found
Rebuilding Forked projects....
applyPatches.sh: line 6: $'\r': command not found
applyPatches.sh: line 7: syntax error near unexpected token $'{\r'' applyPatches.sh: line 7: applyPatch() {
'
Error compiling Spigot. Please check the wiki for FAQs.
If this does not resolve your issue then please pastebin the entire BuildTools.log.txt file when seeking support.
java.lang.RuntimeException: Error running command, return status !=0: [sh, applyPatches.sh]
at org.spigotmc.builder.Builder.runProcess0(Builder.java:973)
at org.spigotmc.builder.Builder.runProcess(Builder.java:904)
at org.spigotmc.builder.Builder.main(Builder.java:703)
at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27)

wary topaz
#

( I just woke up and did this ) It did not work.

ivory sleet
#

getDeclaredConstructor(params)

tardy delta
#

the thing is that i dont know the params classes

ivory sleet
#

Thata fine

tardy delta
#

🤔

ivory sleet
#

Class::getRecordComponents

#

And Class::isRecord first ofc

tardy delta
#

ig smth like this

charred blaze
#

what am i doing wrong

#

Eclipse: Change to same

tardy delta
#

switch to ij

charred blaze
ivory sleet
#

@tardy delta

#

Look at the example

tardy delta
#

hmm yes

#

hmm lets see

green dune
#

2475: <illegal opcode> Setar : (Ljava/lang/Object;)Ljava/io/File;
whats this code?

eternal oxide
#

looks like someone tried to manually edit a jar

tardy delta
#

@ivory sleet fixed it 🙏

raw prairie
#

My code isn't working as intended, its intended purpose was to check if a player was at a new chunk, and paste a schematic near the player

#

it doesnt do that

#

but it produces no errors

tardy delta
#

forgot that i had two annotations for db fields: Column and Id

raw prairie
#

I need some help

ivory sleet
#

Use getDeclaredConstructor(params)

#

Cuz [0] is not guaranteed to be the canonical constructor

#

But else noce

raw prairie
#

Im trying to check if a chunk is new and near the player

#

and if it meets the requirements

tardy delta
#

ah thats what you were trying to say me

raw prairie
#

it pastes a schematic

#

it doesnt seem to work

#

heres my code

#

?paste

undone axleBOT
raw prairie
#

for my main class

#

My chunk caching class

eternal oxide
#

um you are actually putting full chunks into your Map

echo basalt
#

memory leak go brr

tardy delta
# ivory sleet Hey

liek clazz.getConstructor(Arrays.stream(clazz.getRecordComponents()).map(RecordComponent::getType).toArray(Class[]::new)); ?

#

forget the stream

eternal oxide
ivory sleet
#

getDeclaredConstructor

raw prairie
ivory sleet
#

Or well prob doesnt matter

#

But te

tardy delta
#

ye

alpine narwhal
ivory sleet
#

No not deprecated

tardy delta
#

lemme now create an class array manually

ivory sleet
#

Thats not the issue

eternal oxide
ivory sleet
#

The issue lies in the fact that you may encounter abnormal behavior as the implementation does not suppose api users to implement it as IH is just an api interface

alpine narwhal
tardy delta
#

seems to work, thanks for the help

#

entire doge army 💀

alpine narwhal
#

cool

tardy delta
#

like this is all i had to do on the surface, the rest is implemented

#

only have to find a way how to write preparedstatements with reflection 💀

alpine narwhal
#

We love reflection 😍

tardy delta
#

slow asf probably

#

then saying this is the first time it worked with it

alpine narwhal
#

It most likely is

tardy delta
#

arent MethodHandles an alternative or smth?

#

ive seen that in plugins

quaint mantle
#

hello

tardy delta
#

hi

alpine narwhal
tardy delta
#

might wanna take a look at those

quaint mantle
#

hello

#

i have this error

#

someone can help me please?

tardy delta
#

because the return value of "me.distruzionee.hubreforged.Main.getPlayerManager()" is null

quaint mantle
#

and up to here

#

I got that

#

I don't understand what java doesn't understand, the value is not null

#

public PlayerManager getPlayerManager() { return playerManager; }

#

private PlayerManager playerManager;

tardy delta
#

when are you calling getplayermanager?

#

hopefully once your plugins onEnable has been called

quaint mantle
#

i am learning how to make plugins, i wrote some code from a peer to peer course

alpine narwhal
quaint mantle
#

the IDE do not send me any error

small current
#

why sendBlockChange is not working

#

i call it on PlayerinteractEvent

#

registered, other stuffs work

alpine narwhal
#

okay, so you need to make sure you set the value of playerManager when are you doing that?

#

?paste

undone axleBOT
small current
#

not changing.

quaint mantle
quaint mantle
fluid river
quaint mantle
alpine narwhal
small current
#

i right click, with the shovel no block changing

fluid river
#

in class constructor do

tardy delta
#

update blockstate or smth?

fluid river
#

playerManager = new PlayerManager();

alpine narwhal
#

When you create the property you have to initialize it.

e.g
playerManager = new PlayerManager();

small current
tardy delta
#

compare strings with ::equals

alpine narwhal
charred blaze
tardy delta
#

or compare uuid itself with ::equals

charred blaze
#

will it fix that?

small current
#

you are not getting it, im cancelling the normal shovel behaviour

tardy delta
#

dunno what a commandexception is

small current
#

and im trying to change it to a gold block only for the player

small current
#

so im sending block change

fluid river
#

furteenbrush ruined me

alpine narwhal
#

why did i read that too

tardy delta
#

Message.java:38

#

what did i do now

fluid river
#

your receiver is null

alpine narwhal
charred blaze
charred blaze
fluid river
#

no

#

you don't

quaint mantle
tardy delta
#

ye idk didnt look much at surrounding code

quaint mantle
#

is this

charred blaze
#

uh

fluid river
#

show your class where you have

#

getPlayerManager() method

worldly ingot
#

The client is right clicking the block after you send the update, so the client requests an update for the server of the original block

fluid river
worldly ingot
#

If you do it one tick later it will update

tardy delta
#

i right click with shovel, no block changing 🤔 maybe just dont cancel anything

fluid river
#

hehe

tardy delta
#

that was a weird question lol

fluid river
#

true

#

guys are noobs ya know

tardy delta
#

ah changing it to a gold block?

quaint mantle
fluid river
#

happens

#

bro what

worldly ingot
#

No, it works fine. Just Bukkit.getScheduler().runTask(plugin, () -> player.sendBlockChange(toLocation(), Material.GOLD_BLOCK));

tardy delta
#

this is gonna be a long evening

#

i'm wondering why not just change the block type in some event 👀

fluid river
tardy delta
#

dunno much context

quaint mantle
#

bro

fluid river
#

you definitely have this method

#

but your variable is null

#

what is the class where you have this method

quaint mantle
#

this

#

?

fluid river
#

yes

#

finally

#

in onEnable do

quaint mantle
#

sorry bro

fluid river
#

playerManager = new PlayerManager();

tardy delta
#

🤔 🤔

fluid river
#

so now it's initialized

#

not null

quaint mantle
#

i try

fluid river
#

ya know that's the beginning of java

#

Declaration and Initialization

#

?learnjava

undone axleBOT
fluid river
#

or take FREE JAVA LESSONS from me

quaint mantle
#

<3

tardy delta
#

i think he will be scared when he hears your voice <3

fluid river
#

Why

quaint mantle
fluid river
#

do i sound like a child or like grown man

#

or jsut cringe

tardy delta
#

idk i forgot how you sounded like

fluid river
#

call me

#

ez

tardy delta
#

i only remember screaming kids from that call

#

from ikes basement ig

fluid river
#

umm

alpine narwhal
#

Someone tryna learn Java

fluid river
#

you probably talked to someone else

tardy delta
#

nah ike joined call too and then i heard kids screaming

fluid river
#

or maybe that was my sister terrorising my brother

vocal cloud
#

Russian accent makes it hard to tell age KEKLEO

fluid river
#

i don't have accent tho

vocal cloud
#

Smoking at 15 makes you sound 45 by age 16