#help-development

1 messages ยท Page 186 of 1

river oracle
#

it can be shared

#

like it could also be put in chests etc which i think may be a huge issue

rough drift
#

is the item made by a player or given by a player trough a command, or found in chests?

river oracle
#

well I was planning for it to be crafted

rough drift
#

oh!

#

okay

#

so I got an idea

#

Assign to each item a pdc entry called "binding" or whatever you want, and set it to a random UUID
Then in the database use that same UUID to store a list of items
Then whenever an item is clicked, fetch the data and display it (maybe also cache it)

#

that way the items are stored in a database, but bound to a uuid

river oracle
rough drift
#

yeah

river oracle
#

my idea was actually semi similar accept without the database

#

I was going to just store the item stacks in PDC

rough drift
#

That would be worse

river oracle
#

๐Ÿ’€ ik lol which is why I asked

rough drift
#

if the item got deleted the items would be deleted as well, in this way you can have a recovery period

#

so like delete items after a week, so you can do other stuff in case

#

like refunding in case of a glitch

wet breach
#

not sure why you are trying to avoid a database

river oracle
#

I wasn't

wet breach
#

pdc isn't going to be better, the only advantage it would provide in using that is convenience but nothing more

rough drift
#

yeah

river oracle
#

I asked here because I figured that was a bad solution and wanted to know a good way to link the items to the DB as far as storage goes

rough drift
#

I might make a lib for it actually

#

Was already working with perma storage shit

river oracle
#

I've never touched SQL in my life do you have any learning materials

rough drift
#

w3schools

river oracle
#

Everything I've done has always used mongo lol

rough drift
#

mongon't

wet breach
#

is there going to be different items for different inventories

#

or does this one item just open their inventories in general

rough drift
#

click item -> load inventory

river oracle
#

^

wet breach
#

then just store in the metadata that is the item to open inventory

#

nothing more needs to be done other then that lol

river oracle
#

mmm DB would be needed so we have persists over restarts though can't afford contents dissapearing in this case

#

my plugin concept is like a pouch for specific items

rough drift
#

you could use redis

#

it has a backup feature

#

(unlike what most people say, redis is also a disk db, not only in memory)

wet breach
#

if you were needing to tie specific items to specific inventories then you could go the route of storing in the item's pdc a UUID you generate ๐Ÿ™‚

river oracle
#

okay thanks my 3am brain makes me like 1000x more slower than normal xD

wet breach
#

the unique thing of doing that is you would introduce the concept of being able to lose inventory

#

even further you could introduce a feature in being able to break into inventories as well

river oracle
#

I sat down for 3 hours today and came up with like 10 plugin ideas

#

I can't wait to release it even though it prob won't get many downloads

severe marsh
#

So I have a shop GUI in which every item has the "Price" tag as the last element in lore:

#

I want that price tag to disappear upon player purchasing an item

#

I made this code but it removes price tag from the placeholder item as well

#

How do I make it remove last element from lore just from an item that I will give to player, not an actual placeholder?

rough drift
#

I think

severe marsh
#

The issue is, it will update both item in player's inventory and the one in shop that should stay the same

rough drift
#

clone the item stack

rough drift
#

show me your full cod

#

?paste

undone axleBOT
severe marsh
#

Hold up

wet breach
#

sounds like you are not obtaining the correct instance of the item

severe marsh
#

Oh, I fixed it

#

Forgot to add #clone()

rough drift
#

dude

#

I told you

severe marsh
#

๐ŸšŽ

brave goblet
#

I have 3 doubles

double requiredAmount;
double actualAmount = 0;
double progress = 0;
//code
progress += (actualAmount/requiredAmount)*100;

I get actual amount from player statistics
and then I use a formatter to format it to 2 decimal places

DecimalFormat f = new DecimalFormat("##.00");
progress = (double) f.parse(f.format(progress));
rough drift
#

Nice

brave goblet
#

But I get an exception

#

Caused by: java.lang.ClassCastException: class java.lang.Long cannot be cast to class java.lang.Double (java.lang.Long and java.lang.Double are in module java.base of loader 'bootstrap')

rough drift
#

?paste

undone axleBOT
brave goblet
#

I don't use longs?

rough drift
#

please paste your entire class :D

brave goblet
#

Ok

rough drift
#

Also

#

Double.parseDouble(String.format("%.2f", progress));

#

wait no

brave goblet
rough drift
#

I guess

#

but more might be needed for conext

brave goblet
#

Ill try provide as much info to understand the context

rough drift
#

nope

#

nope

#

not touching that

#

fuck that

chrome beacon
#

I really hope that isn't the config format you chose

brave goblet
brave goblet
#

map.put("Merchant","Playtime*2*hours|Pick*13*lily_of_the_valley:Walk*2.2*km:Mine*2500*stone:Mine*2500*logs");

#

Using a map

brave goblet
chrome beacon
green prism
#
import com.cryptomorin.xseries.XMaterial;
import lombok.Builder;
import lombok.Getter;
import net.kyori.adventure.text.Component;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;

import java.util.List;

public class BookUtil {
    @Getter private ItemStack itemStack;
    private List<Component> lore;
    private List<Component> pages;
    private Component title;
    private Component author;

    @Builder
    private static BookUtil of(List<Component> pages, Component title, Component author, List<Component> lore) {
        BookUtil bookUtil = new BookUtil();
        bookUtil.pages = pages;
        bookUtil.title = title;
        bookUtil.author = author;
        bookUtil.lore = lore;
        
        writeBook(bookUtil);
        return bookUtil;
    }

    private static void writeBook(BookUtil bookUtil) {
        ItemStack stack = XMaterial.WRITTEN_BOOK.parseItem();
        BookMeta meta = (BookMeta) stack.getItemMeta();
        meta.author(bookUtil.author).title(bookUtil.title).pages(bookUtil.pages.toArray(new Component[0]));
        meta.lore(bookUtil.lore);
        stack.setItemMeta(meta);

        bookUtil.itemStack = stack;
    }
}```

First time using lombok builder, is this the best way?
drowsy helm
#

you can just do it on the overarching class

green prism
chrome beacon
quaint mantle
#

d

green prism
chrome beacon
#

You can add the @Data annotation to BookUtil and remove that Getter

green prism
chrome beacon
#

Yeah Lombok can remove a lot of boilerplate code

green prism
#

Do you use it a lot in your projects?

chrome beacon
#

I usually don't use it

#

but in my current project I do

brave goblet
#

how would u suggest storing it without using config?

chrome beacon
#

So you are going to make it a config??

green prism
#

?paste

undone axleBOT
brave goblet
remote swallow
#

how are you storing it then

brave goblet
#

In a linked hashmap

remote swallow
#

what about restarts

brave goblet
chrome beacon
#

So you don't need to store it to a file?

brave goblet
brave goblet
chrome beacon
#

Then there's no reason to store stuff in strings like that

brave goblet
#

since its a private plugin and when the owner wants to add sum ill just do it inside the code

brave goblet
remote swallow
#

it is 100% easier to just create a config

brave goblet
chrome beacon
#

They already said they don't need one

#

Just store a map of String, Group

#

Group being an object that has requirements and such

green prism
#

Olivo, would you have any alternative ideas for this?
For each type of CreditCard there are limits described in this code. This map should take care of performing these limits and, every 24 hours reset them. This seems to me to be one of the worst codes I could make
https://paste.md-5.net/uxerimesut.cs

brave goblet
#

but then how would i know what requirements to go with which rank using String,Group

chrome beacon
#

You put the requirements in the group object

brave goblet
#

Wouldn't it make sense to have a requirements object then?

#

that can return task, material and amount

#

and have Map<String(group), Requirements>

chrome beacon
brave goblet
#

Can I safely convert long to double, I use long for getting play time counted in ticks and * by 50 to get to seconds so would that be too long for a double?

brave goblet
amber vale
#

What's an effective method of making multiblocks?

#

Since cheking surrounding blocks one by one for each orientation doesn't sound too efficient as it would be quite a lot of if statements.

chrome beacon
#

You can always see how multiblocks work in Forge and Fabric mods

#

and if you're worries about lag don't check for multiblocks every block place but instead something like a right click with a specific item and give it a cooldown. When detecting someone breaking a multiblock you can store block locations in a map

#

When the chunk unloads save the locations (that are in the chunk) in the map to the chunks PDC

quaint mantle
#

hi, how can i make an updated scoreboard? I mean, I have a coins value that takes the value from a database, I want that when the db changes it automatically changes also in the score

brave goblet
quaint mantle
brave goblet
#

thats why i was thinking wouldn't it make sense for your group object to be named requirements?

chrome beacon
#

How you structure things is up to you

#

I would keep a group object and have requirement objects in it

#

This way you can add group methods and such

brave goblet
#

Alr ty for the suggestion ill structure it properly

quaint mantle
brave goblet
#

sorry i have never worked with scoreboards before

tardy delta
#

time to break my head with more reflection

trim creek
#

Scoreboards doesnt really need reflections... I guess....

#

Just some... braincells....

tardy delta
#

aint talking bout scoreboards

trim creek
#

ohk

#

xd

#

updating scoreboards are more complex ๐Ÿ’€

tardy delta
#

smh some neigbour child is blowing on a stupid whistle

#

sounds terrible

trim creek
#

Yeet the c.... I mean whistle XD

quaint mantle
trim creek
#

i mean

#

its good to just

#

blabla.setScoreboard(asdwdasdasdasdasdassdadsadsa)

#

but

#

it gonna kill scoreboard teams

#

(teams are in scoreboards for some reason)

quaint mantle
#

I will try on youtube

trim creek
#

like, you "refresh" your scoreboard with that code, and then you had prefixes. now you dont

#

only if you used custom prefixes from your own plugin

#

using NTE will fix it xd

green prism
chrome beacon
#

They shouldn't be enums if the values change

tardy delta
#

me for a whole day

#

gl reading that

keen basin
#

guys how can i create baby npc ?

chrome beacon
#

You set the entity meta

trim creek
green prism
trim creek
#

(irony)

green prism
#

hum

#

hm

#

humhm

#
limitsType = switch (limit) {
            case MAX_BALANCE -> new LimitsType(value, limitsType.maxWithdraw(), limitsType.maxTransactionPerDay(), limitsType.maxDepositPerDay(), limitsType.transferLimitPerDay());
            case MAX_WITHDRAW -> new LimitsType(limitsType.maxBalance(), value, limitsType.maxTransactionPerDay(), limitsType.maxDepositPerDay(), limitsType.transferLimitPerDay());
            case MAX_TRANSACTION_PER_DAY -> new LimitsType(limitsType.maxBalance(), limitsType.maxWithdraw(), value, limitsType.maxDepositPerDay(), limitsType.transferLimitPerDay());
            case MAX_DEPOSIT_PER_DAY -> new LimitsType(limitsType.maxBalance(), limitsType.maxWithdraw(), limitsType.maxTransactionPerDay(), value, limitsType.transferLimitPerDay());
            case TRANSFER_LIMIT_PER_DAY -> new LimitsType(limitsType.maxBalance(), limitsType.maxWithdraw(), limitsType.maxTransactionPerDay(), limitsType.maxDepositPerDay(), value);
        };```

This should do the trick
mighty pier
#
    public void setup() {
        try {
            c = DriverManager.getConnection("jdbc:sqlite:" + (Utils.file == null ? ":memory:" : Utils.file.getAbsolutePath()));
            Statement statement = c.createStatement();
            statement.execute("CREATE TABLE IF NOT EXISTS players" +
                    "uuid varchar(255) PRIMARY KEY" +
                    "muted varchar(255) NOT NULL" +
                    "mutereason varchar(255) NOT NULL" +
                    "banned varchar(255) NOT NULL" +
                    "banreason varchar(255) NOT NULL;");
            statement.close();
        } catch ( Exception e ) {
            System.err.println( e.getClass().getName() + ": " + e.getMessage() );
        }
    }

    public boolean isMuted(OfflinePlayer p) throws SQLException {
        Statement statement = c.createStatement();
        String uuid = p.getUniqueId().toString();
        ResultSet result = statement.executeQuery("SELECT * FROM players WHERE id = '" + uuid + "';");
        statement.close();
        return result.getBoolean("muted");
    }
    
    public boolean isBanned(OfflinePlayer p) throws SQLException {
        Statement statement = c.createStatement();
        String uuid = p.getUniqueId().toString();
        ResultSet result = statement.executeQuery("SELECT * FROM players WHERE id = '" + uuid + "';");
        statement.close();
        return result.getBoolean("banned");
    }``` is this a good way of doing it?
tardy delta
#

why do people do conn.createStatement(); statement.execute(sql) rather than conn.createStatement(sql); statement.execute()

green prism
mighty pier
#

uh

#

idk

#

does it make a difference?

#

i was thinking i would make a user and it would extend player

#

and i would put the banned and muted inside of it

#

so i wouldnt have to get it from the sql file every time

tardy delta
#

also use preparedstatement

#

?

#

doesnt matter actually

mighty pier
#

whats a preparedstatement

keen basin
tardy delta
#

connection::prepareStatement returns a PreparedStatement anyways

mighty pier
#

brb

tardy delta
#

so assigning it to a Statement has no effect

hazy parrot
#

How does it matter ๐Ÿค” I've always using just prepared

trim creek
#

like SELECT * FROM players WHERE UUID = ?

mighty pier
#

ok

tardy delta
#

read the link i sent

mighty pier
#

why should i use preparedStatement?

tardy delta
#

cuz sql injection

#

google it

mighty pier
#

ok

#

ty

tardy delta
#

lol

trim creek
#

Not using statements = not having the ability to manage the data in your MySQL

#

using statements = having the ability to manage your MySQL

green prism
tardy delta
#

anyways can i use methodhandles to gain a lil performance in a situation where i need reflection?

mighty pier
#
    private Connection c;

    public void setup() {
        try {
            c = DriverManager.getConnection("jdbc:sqlite:" + (Utils.file == null ? ":memory:" : Utils.file.getAbsolutePath()));
            PreparedStatement statement = c.prepareStatement(("CREATE TABLE IF NOT EXISTS players " +
                    "uuid varchar(255) PRIMARY KEY " +
                    "muted varchar(255) NOT NULL " +
                    "mutereason varchar(255) NOT NULL " +
                    "banned varchar(255) NOT NULL " +
                    "banreason varchar(255) NOT NULL;"));
            statement.close();
        } catch ( Exception e ) {
            System.err.println( e.getClass().getName() + ": " + e.getMessage() );
        }
    }

    public boolean isMuted(OfflinePlayer p) throws SQLException {
        String uuid = p.getUniqueId().toString();
        PreparedStatement statement = c.prepareStatement("SELECT * FROM players WHERE id = '" + uuid + "';");
        ResultSet result = statement.executeQuery();
        statement.close();
        return result.getBoolean("muted");
    }

    public boolean isBanned(OfflinePlayer p) throws SQLException {
        String uuid = p.getUniqueId().toString();
        PreparedStatement statement = c.prepareStatement("SELECT * FROM players WHERE id = '" + uuid + "';");
        ResultSet result = statement.executeQuery();
        statement.close();
        return result.getBoolean("banned");
    }``` like this?
undone axleBOT
mighty pier
#

yes

tardy delta
#

did you read any of the link i sent

mighty pier
#

little bit

hazy parrot
mighty pier
#

i will the basics first

hazy parrot
mighty pier
#

yes

hazy parrot
#

ResultSet#next

tardy delta
#

a preparedstatement is used like this:

try (PreparedStatement ps = conn.prepareStatement("DELETE FROM players WHERE id = ?;")) {
  ps.setInt(1, someId);
  ps.execute();
} catch ...```
#

basically using ? as placeholders and setting them later on

#

sqlite doesnt support uuid tho, use a BLOB type to store the uuid and not a string

#

i can give you the code if you'd like

hazy parrot
#

you can use just binary

tardy delta
#

well ye blob is byte[]

#

is BINARY a type or smth?

mighty pier
hazy parrot
quaint mantle
#

error:

Caused by: java.lang.NullPointerException
    at net.polarlabs.methods.database.update(database.java:30) ~[?:?]
    at net.polarlabs.Commands.Clan.onCommand(Clan.java:53) ~[?:?]
    

code: database.java

private static FileConfiguration config;
private static File database;

public database() {
        database = Main.getDatabase();
        config = YamlConfiguration.loadConfiguration(database);

}


public static void update(String path, Object data) {
        config.set(path, data);
        try {
            config.save(database);
        } catch (IOException e) {
            System.out.println("could not update database" + e.getMessage());
        }
}

whenever i call update to update some data from a YML file, it returns NULL ...

tardy delta
#

why static

quaint mantle
hazy parrot
tardy delta
#

ig you havent called your constructor

echo basalt
#

I just woke up, saw this and now I regret waking up

tardy delta
#

well anyways, if you wanna save uuid as a blob you can use this

#

then doing ps.setBytes(uuidToBytes(uuid))

#

or UUID id = uuid.fromBytes(rs.getBytes("some_column"))

quaint mantle
tardy delta
#

why are you initializing static variables in a constructor tho

torn shuttle
quaint mantle
torn shuttle
#

go back to bed, today is not the day you surpass the master

mighty pier
#

can i nest try statememts

tardy delta
#

yes

drowsy helm
#

Yup

mighty pier
#

ok

tardy delta
#

thats a bunch of thenAccept

#

cant you combine cfs?

echo basalt
#

you can somewhat

#

but I need the output of each one

quaint mantle
# tardy delta yes

how would I be able to set those varibles then ?

database = Main.getDatabase();
config = YamlConfiguration.loadConfiguration(database);
echo basalt
#

thenCompose is like a stream#map

tardy delta
#

uh just instantiate them directly ig

#

๐Ÿค”

quaint mantle
echo basalt
#

imma just do a runAsync and join em all internally

tardy delta
#

also where are your naming conventions smh

drowsy helm
#

Why do they need to be static anyway

tardy delta
#

a database class which wraps a yaml file ๐Ÿค”

quaint mantle
drowsy helm
#

Oh my

vocal cloud
#

Lowercase class name sad

tardy delta
#

i have no idea what im looking at

drowsy helm
#

There is no need for them to be static

#

They are private aswell

vocal cloud
#

Main class

drowsy helm
#

None of those methods should be static

quaint mantle
drowsy helm
#

Use the class instance

tardy delta
#

whats the point of wrapping a yaml file tho

quaint mantle
drowsy helm
#

?di

undone axleBOT
quaint mantle
#

fuck that

drowsy helm
#

This is basic java man

quaint mantle
#

im not doing dep injection

drowsy helm
#

Alr keep static abusing ๐Ÿคท๐Ÿพโ€โ™‚๏ธ

quaint mantle
#

illegal ?

trim creek
quaint mantle
#

thats what i was looking for

trim creek
#

example: public MySQL sql = new MySQL(<plugin (only if it depends on it)>);

#

if your class contains

public JavaPlugin plugin;
public <classname>(JavaPlugin plugin) {
  this.plugin = plugin;
}

you will need to do it like
public MySQL sql = new MySQL(plugin);

trim creek
tardy delta
#

?di

undone axleBOT
quaint mantle
trim creek
#

send the code

#

again xd

mighty pier
quaint mantle
#

i've got a command listener, I want to call the database class to update a yaml file

tardy delta
#

ye

mighty pier
tardy delta
#

hows that returning an object

mighty pier
#

magic

tardy delta
mighty pier
trim creek
mighty pier
#

if i dont do the flip() then it returns byte[]

quaint mantle
trim creek
#

wait...

quaint mantle
trim creek
#

so search

#

would be update?

quaint mantle
trim creek
#

Trying to save an ItemStack?

quaint mantle
trim creek
#

have you tried ItemStack item instead of Object item?

drowsy helm
#

What error is it giving you

#

When you hover

quaint mantle
trim creek
#

uhh... making another update method then? ๐Ÿฅด

#

like updateString(), updateItem(), etc?

quaint mantle
#

oh right

#

yeh

#

didnt though about that one

quaint mantle
trim creek
#

it aint the best idea, but is a bit better sometimes to just mess with "harder code you dont know"

#

ahhhh

drowsy helm
#

Youโ€™re trying to use it as if it were static

#

You need an instance

quaint mantle
quaint mantle
tardy delta
#

i'm wondering if a ClassValue<T> is just something like a IdentityHashMap<Class<T>, T>?

#

hmm more like a weakhashmap essentially

drowsy helm
#

Yes

#

Essentially

#

But none of the elements can be gced until the map is

#

With the hash map*

tardy delta
#

๐Ÿค”

drowsy helm
#

So itโ€™s a teeny tiny bit more efficient

minor garnet
#

does anyone out there who is good at math know how to get the middle of a cube, which can be rotated up to 90 degrees, but having the corners and the middle between those corners?

I tried to get the x, and the y of these ways but it wouldn't work

drowsy helm
#

So you only have yhe red square locations?

minor garnet
#

i just want the middle location

tardy delta
#

hmm 70 lines of reflections to create a db table based on a class

minor garnet
#

i blended the middle of these corners by taking the x and y and adding to get the middle, but that only works if it was at 0 degrees, now at 45 degrees it wouldn't work

tardy delta
#

not too bad

drowsy helm
#

What

#

What do the red marks signify

#

You arent giving us much info

#

And what info is there to work with

tardy delta
#

seems to work

drowsy helm
minor garnet
tardy delta
#

nosql :(

#

isnt mongo just json files?

drowsy helm
#

Json format yes

#

Proper db storage methods though

minor garnet
tardy delta
#

and then some weird syntax around it

#

i should try it ig

drowsy helm
#

Just make it into a triangle

#

Get the hypotenuse length

#

Half it

#

Or use a linear equation between the two corners

tardy delta
minor garnet
#

i so bad on maths but ok

drowsy helm
#

Y=mx+b type shi

minor garnet
#

when I say bad at math I mean even in formulas xd

echo basalt
#

middlePoint = point between corner3 and corner2

minor garnet
minor garnet
echo basalt
#

or middlecorner - middleLocation

minor garnet
echo basalt
#

aka corner2 + ((corner3 - corner2) / 2)

drowsy helm
#

Mid point formula

#

Corner 2 and corner 3

echo basalt
minor garnet
#

hm let me see

echo basalt
charred blaze
#
                if (!(args.length == 1)) {
                    Utils.sendMessage(p, "&cUsage: /friend list");
                    return true;
                }
                List<String> uuids = plugin.config.getStringList("Data."+p.getUniqueId().toString()+".Friends");
                if (uuids.isEmpty()) {
                    Utils.sendMessage(p, "&cYou don't have any friends yet! Add some with /friend add player");
                    return true;
                }
                Utils.sendMessage(p, "&aFriends list: &b"+String.join(", ", uuids));
            }```
Why is this sub-command not working?
(other sub commands is working well)
drowsy helm
#

show the rest of the code

#

is it just not running after the if statement?

charred blaze
#

it just sends nothing to me

#

no messages

#

no errors

#

nothing

drowsy helm
#

put some debug printlns

#

and see where it stops printing

minor garnet
# echo basalt

so for this method i need transform the location#toVector?

tardy delta
#

plugin.config ๐Ÿค”

charred blaze
# drowsy helm and see where it stops printing

i just added debugs:

                if (!(args.length == 1)) {
                    System.out.println("1");
                    Utils.sendMessage(p, "&cUsage: /friend list");
                    return true;
                } else {
                    System.out.println("5");
                }
                List<String> uuids = plugin.config.getStringList("Data."+p.getUniqueId().toString()+".Friends");
                if (uuids.isEmpty()) {
                    System.out.println("2");
                    Utils.sendMessage(p, "&cYou don't have any friends yet! Add some with /friend add player");
                    return true;
                } else {
                    System.out.println("4");
                }
                System.out.println("3");
                Utils.sendMessage(p, "&aFriends list: &b"+String.join(", ", uuids));
            }```
and its working now lol
#

but why

#

๐Ÿค”

charred blaze
drowsy helm
charred blaze
#

lol

tardy delta
charred blaze
#

wdym

tardy delta
#

plugin.getConfig()???

crimson terrace
brave goblet
#

How can I cast long to double? I have 2 long numbers to work out the percentage from, and I get Long cannot be cast to class Double
I see double has a method .longBitsAsDouble would that work in my case?

crimson terrace
#

try using the primitive data types?

charred blaze
#

help

crimson terrace
tardy delta
#

pff

charred blaze
crimson terrace
#

its a NPE I assume

crimson terrace
strange ermine
#

Hello there. I'm trying to make a Flying/Floating sign. I call the BlockPhysicsEvent and I cancel it. But my sign still broke. Do you have any idea why that thing happen ?

My code here

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onSurroundBlockSignBreak(BlockPhysicsEvent e) {
        System.out.println(e.getChangedType()); // Debug
        if(e.getChangedType().equals(Material.AIR)) {
            if(SignShop.getShops().containsKey(e.getBlock().getLocation())) {
                SignShop shop = SignShop.getShops().get(e.getBlock().getLocation());
                // Check if still item in the shop
                if(shop.getAmount() > 0) {
                    System.out.println("Event cancelled !"); // Debug
                    e.setCancelled(true);
                    return;
                }
                // Remove the shop
                SignShop.getShops().remove(e.getBlock().getLocation());
                System.out.println("Removed by" + e.getEventName()); // Debug
            }
        }
    }

(In my code, the debug message "event canceled" is fired but the sign break)

charred blaze
crimson terrace
charred blaze
#

ok

strange ermine
#

Yes, I write this message to another discord, but I want to use the bukkit api and not another thing

crimson terrace
brave goblet
#

ill try that

charred blaze
#

why?

#

huh?

hazy parrot
#

you are using #getPlayer(String) both times

#

it will actually look for player with that name, not uuid

charred blaze
#

a

elfin atlas
#

How can I check at ProjectileHitEvent if the entity is a player?

brave goblet
# crimson terrace try using the primitive data types?

Nope doesn't work

long actualTime = player.getStatistic(Statistic.PLAY_ONE_MINUTE)*50;
long requiredTime = timeToLong(requirement);
double time = (double) (actualTime/requiredTime)*100;
percent += time;

still gives an error

tardy delta
elfin atlas
#

When I'll try to give a player a potion effect is the duration ticks or seconds?

native ruin
#

ive been thinking of refactoring some of my projects into different folders and need some inspiration
currently i have events and commands

tardy delta
#

what other stuff do you have

#

i usually do things like commands, listeners, storage etc and an utils package with some general stuff

native ruin
#

what would storage be for?

echo basalt
#

storing data

tardy delta
#

persistence and cache

hazy parrot
tardy delta
#

current setup is like this

echo basalt
#

current setup

native ruin
native ruin
#

i will take a look at it

#

ty for the insight

brave goblet
hazy parrot
glossy venture
#

i think

brave goblet
quaint mantle
#

I've set some lore (text) into a book, how can I remove the lore I added and keep the book vanilla with it's vanilla lore ?

hazy parrot
#

dividend/divisor = quotient

green prism
#

Can I use config.getLocation(key) without yaw and pitch?

tardy delta
#

stringbuilder lmfao

brave goblet
#

forgot basic maths

#

what if the dividend is too long for a double?

hazy parrot
brave goblet
hazy parrot
#

It can maybe loose some least significant bits as it's widening conversion

#

But I don't think it should matter

brave goblet
#

alr ty

hazy parrot
#

Someone correct me if I'm wrong

brave goblet
#

just googled that

hazy parrot
#

๐Ÿค”

hazy parrot
#

A widening conversion of an int or a long value to float, or of a long value to double, may result in loss of precision - that is, the result may lose some of the least significant bits of the value. In this case, the resulting floating-point value will be a correctly rounded version of the integer value, using IEEE 754 round-to-nearest mode

brave goblet
#

from stack overflow

amber bronze
#

I try to do custom mobs but whenever I try they are invisible

Custom Entity:
https://paste.md-5.net/yupopufolo.java

Spawning:

(((CraftWorld) event.getPlayer().getWorld()).getHandle()).addEntity(new WoodWorm(event.getBlock().getLocation()));```

Registering:
```java
new WoodWorm(Bukkit.getWorld("world").getSpawnLocation()).registerEntity("woodworm", 39, EntitySilverfish.class, WoodWorm.class);```

It hits me but I can hit it and its invisible
hazy parrot
# brave goblet

I sent you oracle docs, conversion from double to long is narrowing

brave goblet
hazy parrot
#
double foo = 5.2;
long bar = (long) foo; //narrowing
long foo = 1200;
double bar = (double) foo; //widening
#

according to oracle docs i sent you

brave goblet
#

sorry

#

from double to long

#

๐Ÿคฆ

tardy flame
#

Imagine using default command system

fluid river
#

goksi just trying to not look like he failed smth

#

๐Ÿ™‚

balmy valve
#

Anyone know how to prevent these symbols from coming up when using formatting code in pages?

#

Im setting the bookmeta to have the pages and wherever it uses a formatting code well you can see what it does

hazy parrot
stiff zinc
#

Is there any reason why the HoverEvent doesn't work, and the click event does?

private void addConfirmButton(BookPage page, BookComponent component) {
        if (!component.isClickable()) {
            throw new IllegalArgumentException("Component must be a button component");
        }

        String command = String.format("/hybook %s", this.view.getBook(1).getId());
        component.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
        component.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Hello")));

        System.out.println(component.getHoverEvent());

        // Add to a book
        page.addComponent(component);
    }

This is the output
HoverEvent(action=SHOW_TEXT, contents=[Text(value=Hello)], legacy=false)

chrome beacon
#

Also don't register the entity as a real entity type

#

That might mess things up when the server tries to send data to the client

solid cargo
#

is it safe to store stuff like passcodes (temporary) in a hashmap and if no, whats better

fickle mist
#

Hi all! I have a question how to make it so that when crafting an ItemStack, the name contains not only the name that is in SetDisplayName, but also the nickname of the player who crafted this item

tardy delta
#

reflection can be wonderful

river oracle
tardy delta
#

just an annotated class

river oracle
#

?pdc

river oracle
#

If you want the data shown use lore or sum

novel totem
#

How can I use the LocalDate in day month year format?

tardy delta
#

hmm 302 ms to create a db table with reflections

#

well ye taking into account that the table already exists

fluid river
#

everything else is fine

fluid river
tardy delta
#

30 ms now lol

fluid river
#

unbelibubul

tardy delta
#

dunno why it would take less time lol

fluid river
#

hu knows

icy beacon
#
public int findLastUsedID(final JavaPlugin plugin) {
        final File newsDirectory = new File(plugin.getDataFolder(), "news");
        final File closedNewsDirectory = new File(plugin.getDataFolder(), "closed-news");
        int lastUsedID = 0;
        if (!newsDirectory.exists() && !closedNewsDirectory.exists()) return lastUsedID;
        
        if (newsDirectory.exists()) {
            for (final File file : Objects.requireNonNull(newsDirectory.listFiles())) {
                if (file.getName().endsWith(".yml") || file.getName().endsWith(".yaml")) {
                    final int id = Integer.parseInt(file.getName().replace(".yml", "").replace(".yaml", ""));
                    if (id > lastUsedID) lastUsedID = id;
                }
            }
        }
        
        if (closedNewsDirectory.exists()) {
            for (final File file : Objects.requireNonNull(closedNewsDirectory.listFiles())) {
                if (file.getName().endsWith(".yml") || file.getName().endsWith(".yaml")) {
                    final int id = Integer.parseInt(file.getName().replace(".yml", "").replace(".yaml", ""));
                    if (id > lastUsedID) lastUsedID = id;
                }
            }
        }
        
        return lastUsedID;
    }

is there a more efficient and elegant way to do this? I am walking through all the YML files in 2 directories to fetch the last used id. maybe this can be better with something from Apache IO, or Files.walk, anything?

tardy delta
#

do not assume dir.listFiles will return smth notnull

#

lastUsedID = Math.max(lastUsedID, Integer.parseInt(file.getName().replace(".yml", "").replace(".yaml", ""))) but lets not do that ig

icy beacon
#

that looks like a good idea, why nto?

#

not*

tardy delta
#

it just looks bloat

icy beacon
#

i guess so

tardy delta
#

reflection ๐Ÿ’€

#

will be fun when doing that for a few tables

icy beacon
tardy delta
#

kinda confused but when i drop table before, then do create table if not exists, its just 30ms but when idont drop before its like 300ms

icy beacon
#
if (!newsDirectory.exists() && !closedNewsDirectory.exists()) return lastUsedID;
        if (!newsDirectory.isDirectory() && !closedNewsDirectory.isDirectory()) return lastUsedID;

        if (newsDirectory.exists()) {
            for (final File file : Objects.requireNonNull(newsDirectory.listFiles())) {
                if (file.getName().endsWith(".yml") || file.getName().endsWith(".yaml")) {
                    final int id = Integer.parseInt(file.getName().replace(".yml", "").replace(".yaml", "").replace("id", ""));
                    if (id > lastUsedID) lastUsedID = id;
                }
            }
        }

        if (closedNewsDirectory.exists()) {
            for (final File file : Objects.requireNonNull(closedNewsDirectory.listFiles())) {
                if (file.getName().endsWith(".yml") || file.getName().endsWith(".yaml")) {
                    final int id = Integer.parseInt(file.getName().replace(".yml", "").replace(".yaml", "").replace("id", ""));
                    if (id > lastUsedID) lastUsedID = id;
                }
            }
        }

is this better? by the documentation of listFiles, now this should never be null

tardy delta
fluid river
#
Stream.of(newsDirectory.listFiles())
.filter(f -> f.getName().endsWith(".yml") || f.getName().endsWith(".yaml"))
.map(f -> Integer.parseInt(f.getName().replace(".yml", "").replace(".yaml", "")))
.mapToInt(Integer::intValue).max().getAsInt();
tardy delta
#

maybe cuz connection was already opened before

fluid river
#

๐Ÿ™‚

tardy delta
#

im closing it after every statement so idk

icy beacon
#

i guess

#

thanks

fluid river
#

done

tardy delta
#

mye time has to do with whether the conn has been opened before or not

#

now a stable 30ms3

#

setting up two tables 35ms

amber bronze
#

and its spawning

#

cuz i can get hurt

#

and hear it

raw prairie
#

how might I set a radius around a user in chunks?

tardy delta
#

your question is kinda abstract

raw prairie
tall dragon
fluid river
#

public abstract void setARadius(player);

raw prairie
tall dragon
#

get chunk XY and subtract radius from both for point 1, then add radius to both for point 2

#

and you got your square

tardy delta
fluid river
raw prairie
#

whats point 1?

fluid river
#

now it is

tall dragon
#

point 1 is a chunk

raw prairie
#

loc is my variable for location of a player

tall dragon
#

yea

raw prairie
tall dragon
#

no, yuo want to create 2 more chunk variables. one subtracts radius from the playerchunk pos

#

and the other adds radius

raw prairie
grim ice
#

im so bored aaa

tall dragon
#

sure.

raw prairie
tall dragon
#
    private List<Chunk> getChunksInRadius(Player player, int radius) {
        Chunk playerChunk = player.getLocation().getChunk();
        int cx = playerChunk.getX();
        int cy = playerChunk.getZ();
        
        List<Chunk> chunks = new ArrayList<>();

        for (int x = (cx - radius); x < (cx + radius); x++) {
            for (int y = (cy - radius); y < (cy + radius); y++) {
                chunks.add(playerChunk.getWorld().getChunkAt(x, y));
            }
        }
        return chunks;
    }
#

does this make sense ^ ?

raw prairie
tall dragon
#

huh?

raw prairie
#

trying to implement it into a pasting logic

#

for world edit api

raw prairie
tall dragon
#

well i havent rlly worked with world edit api before

#

so i can't help you with that

raw prairie
#

calculate the distance from the radius to the user

#

and paste schematics to fill it

#

@grim ice

#

help me if bored

#

pls

#

nvm

#

sowwy

#

uwu

grave plover
#

Hello, how can I let players with specific versions join, even if they don't have exactly the required version. (A solution without Protocollib would be nice)

For example, I want to let somebody join with 1.19, although the server is on 1.19.2 .

remote swallow
#

via version

tall dragon
#

i would not try to make that urself tbh

remote swallow
#

via backwards too

grave plover
tall dragon
#

well viaversion is opensource

#

i wish you goodluck with that

remote swallow
#

but uses protocol lib

grave plover
tall dragon
#

i mean you can still see which packets they use

grave plover
grave plover
remote swallow
#

can i ask why you dont want to use viaversion and/or protocol lib

grave plover
chrome beacon
#

Sounds like you're over optimizing

grave plover
tall dragon
#

sure. but stuff like viaversion is tough to get right

#

and viaversion is battle tested

grave plover
#

hmmm :(

#

i thought that I could manage to do it with purely bukkit packets

remote swallow
#

you probably can, just with a hell of a lot of trial and error

tall dragon
#

it might be possible. but i would have no idea how

grave plover
#

so it already should be easier

#

but still hard, obviously

#

okay, but if I would use protocol lib, how would I allow players with 1.19 join the 1.19.2 server?

chrome beacon
#

Just use ViaVersion

sterile token
#

Is my condition okay?

chrome beacon
#

What version of Minecraft are you making the plugin for?

chrome beacon
#

Set Java version to 17 and use toList instead of collect

sterile token
#

ok

#

But the conditon is okay?

sterile token
#

๐Ÿ˜ก

tardy delta
#

thats a strream

sterile token
tardy delta
#

.toList()

sterile token
#

I need help!

sterile token
tardy delta
#

then why doing ::tabcomplete

sterile token
#

๐Ÿคฆโ€โ™‚๏ธ

#

I mean you were helping me yesterday

#

But i never could do it

tardy delta
#

get the argument based on the args and call ::tabcomplete on it?

sterile token
#

I dont understand when people talk without examples sorry

quaint mantle
#

how i change the value on a list? example:
spawn-location:
-x: 12
-z: 12
-y: 12

i want change x on 130, how?

noble crown
#

hi, i'm trying to run something after left clicking air/block, but idk why event only triggers when clicking block

quaint mantle
rough blaze
#

?paste

undone axleBOT
quaint mantle
sterile token
tardy delta
#

thats not even a list

quaint mantle
#

how

tardy delta
#

no need for a list

noble crown
#

and also, if you want to have it as list, you're missing space between - and text

quaint mantle
#

so nameList:
-x: value

#

is not a list?

noble crown
#

no

quaint mantle
#

shitty

noble crown
#
list:
  - something
quaint mantle
tardy delta
#

just use ```xml
whatever:
x: 1
y: 34
z: 12

noble crown
#

^

tardy delta
#

config.set("whatever.x", 12)

quaint mantle
#

and how i can write the same things on a different method?

tardy delta
#

wha

quaint mantle
#

now go

#

thanks

sterile token
# tardy delta wha

Location location = config.getLocation("what-ever");
config.set("what-ever", location);

#

No need to complicate yourself!!

#

๐Ÿ˜‚

tardy delta
#

uhm yes

sterile token
#

He just need to get the location with Config#getLocation("path/to/location") and then use Config#set("path/for/location", location here)

sterile token
#

Because i lost 1d waiting you

fickle mist
#

Hi all! How to make an item from an ItemStack impossible to rename

chrome beacon
#

Detect when it's renamed and cancel the event

#

if you want to detect a specific item you can store pdc on it

#

?pdc

tardy delta
chrome beacon
fluid river
#

you either need

spawn-location:
  - 12
  - 12
  - 12

or

spawn-location:
  x: 12
  y: 12
  z: 12
sterile token
# chrome beacon Help with what?

Because im trying to recommend each argument name when args is 1, and if args is more than 1 recommend each List<String> completions from the Argument obj

#

That is what im actually trying to do

fluid river
#

you can do getConfig().getLocation("spawn-location");

#

and getConfig().set("spawn-location", location);

sterile token
fluid river
#

ye

sterile token
fluid river
#

but i pasted 2 other examples

#

too

sterile token
fluid river
#

idk what you are talking about, too lazy to read:)

#

i just answered Smo question

sterile token
#

hmnn

#

Have you seen command completations?

fluid river
#

?

#

implements TabCompleter

@Override
blah blah blah

sterile token
#

But do you know how to recommend the arguments "list" and "info" when you enter /faction. And when you enter /faction info it will recommend the factions "topOne, etc".

tardy delta
#

always nice when having such exceptions with reflection

sterile token
tardy delta
#

i dont know how your stuff works

fluid river
tardy delta
#

and you didnt explain very well

sterile token
#

I have explained really well LMAo

tardy delta
#

i know yes

#

return StringUtil.copyPartialMatches(args[0], Arrays.asList("list", "info"), new ArrayList<>())

sterile token
# tardy delta i know yes

And its simple i have 2 classes:

BukkitCommand which extends BukkitComand class (bukkit one)
BukkitArgument

remote swallow
#

why not

fluid river
#

if (args.length == 1) return List.of("list", "help");
if (args.length == 2 && args[0].equals("help")) return getFactionListOfYourPlugin;

sterile token
#

Because it depend on what you input

tardy delta
fluid river
tardy delta
#

well get the bukkitargument thing based on the input and call tabcomplete

sterile token
fluid river
#

well i don't give a fuck

#

it's spigot channel

#

helping with spigot api

#

not with random API i don't even know name of

sterile token
#

3rd time i sent the code

fervent gate
#
this.getNavigation().createPath(new BlockPos(-1, 67, -7), 0);
new BukkitRunnable() {
     @Override
    public void run() {
         getNavigation().tick();
    }
}.runTaskTimer(this.plugin, 0L, 1L);

Is this not a way to make an entity move with nms?

sterile token
chrome beacon
sterile token
#

Im doing a command framework based on BukkitCommand class

fluid river
#

PathfinderGoals

fervent gate
fluid river
tardy delta
fluid river
#

i answered yeah it's not

fervent gate
#

ah

#

is it possible with the navigation.createpath?

remote swallow
fluid river
#

ifs/switches

fervent gate
#

is there a pathfindergoal for moving to a specific block?

chrome beacon
fervent gate
#

cuz I can't seem to figure out MoveToBlockGoal or smth like that

tardy delta
#

im wondering if my sql primary key is a varchar, can i use autoincrement?

#

just debugging

sterile token
#

I dont catch what you want me to try

fluid river
#

if (args[0].intern() == "bruh".intern())

chrome beacon
#

Don't compare strings with ==

remote swallow
#

?paste

undone axleBOT
fluid river
#

oh true

#

sleep moment

#

changed the code

#

i compared with ==

tardy delta
#

hmm looks like sql (?, ?, ?) without setting values defaults to null

sterile token
fluid river
eternal oxide
fluid river
#

why not

eternal oxide
#

== is instance checking

fluid river
#

look at the changed code

tardy delta
#

me corrupting database

eternal oxide
#

two strings may have the same contents but not the same instance

fluid river
native ruin
#

can you use a generic type as persistentdatatype?

fluid river
eternal oxide
#

I don;t care about any code. Just answering your question as to why not use ==

fluid river
#

to use it later

fluid river
#

with true result

tardy delta
#

literals yes

fluid river
#

by placing .intern() method

tardy delta
#

assuming they have been interned smh

fluid river
#

so the == would refer to string pool address for both

sterile token
#

EpicBic i also have 3rd class whcih register all my custom command obj into the CommandMap

tardy delta
#

you know what we're talking about ๐Ÿฅบ

fervent gate
remote swallow
fluid river
#

Elgar really thinks i don't know about == ๐Ÿ™‚

remote swallow
#

why not

sterile token
#

Because i wont know the tab one, etc

sterile token
# remote swallow why not

I want to achieve the completion system, so that when you use a command and it has an argument or sub command, it will recommend it to you. But at the same time it will recommend you completions of the arguments/sub commands.

eternal oxide
sterile token
#

That is the perfect message

remote swallow
#

if (args[0].equals("tab one")) do stuff here

sterile token
#

๐Ÿ˜‚

#

None of you have understand how it orks

remote swallow
#

im telling you how to do it

fluid river
sterile token
#

its pretty simple what i need to do: if args[0] == 0 recommend each argument name and if args[1] != null, recommend the command argument completations

fluid river
#

tho it's kinda cringe

#

but it works

remote swallow
#

heres something i made before just go off what it says and change it to your need

fluid river
#

i was already corrected by olivo

sterile token
fluid river
#

spoonfeeded guy

remote swallow
#

i can barely understand half the stuff you type and that isnt that hard to change to what you need

fluid river
#

upgrade your brain

chrome beacon
sterile token
grim ice
#

he legit told you what to do.

#

i dont understand the problem here

alpine narwhal
#

Not too hard just annoying

native ruin
#

how can I set the persistentdatatype as a generic type ?
rn i have something like this

sterile token
river oracle
alpine narwhal
#

Let me show you my solution

tardy delta
#

where naming conventions

sterile token
alpine narwhal
river oracle
#

JB ๐Ÿ’€

alpine narwhal
grim ice
#

?

tardy delta
#

fleet goes brr tbh

grim ice
#

bros using fleet??

#

wtf

river oracle
alpine narwhal
#

Yea, it runs about the same as iJ

remote swallow
#

use vs code

sterile token
#

I want to make an auto complete system for mi class BukkitCommand and BukkitArgument.

In BukkitCommand it will work like this:

  • When you enter the /test command and args[0] is null, it recommends you the names of each known argument (Which is already done).

  • When you enter the command /test info and its parameter/argument is null, it will recommend a List<String>

grim ice
#

use notepad

native ruin
tardy delta
#

use nano

remote swallow
#

use vim

alpine narwhal
#

I use iJ daily

river oracle
grim ice
#

use irl paper

tardy delta
#

vim sucks

#

use stone and uhh

alpine narwhal
#

Fleet is shit

tardy delta
#

other stone

sterile token
native ruin
remote swallow
#

read

alpine narwhal
remote swallow
#

?spoon

undone axleBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

tardy delta
#

error messages getting fancy

#

me discouraging users using things i wrote myself ๐Ÿค”

alpine narwhal
tardy delta
#

its some lib

#

ill see how i do it

#

reflection being slow asf as usual

native ruin
tardy delta
#

im not seeing a pdc datatype in that method

alpine narwhal
#

thats because they're trying to assume the type using generics.

tardy delta
#

ah there

#

take a class<T> param

#

wait

alpine narwhal
#

you cant

tardy delta
#

what does it expect

alpine narwhal
#

it has to be class<?>

elfin atlas
#

Is there a way to split a List with player in it into 2 lists?

native ruin
#

yea

elfin atlas
#

How?

tardy delta
#

๐Ÿคก

chrome beacon
elfin atlas
#

one has 2 objects and the other as well

novel totem
#

Localdate.now gives me 2022-10-16 date but how can I get 16-10-2022?

trim creek
#
public static JavaPlugin plugin;
    public static HashMap<UUID, PermissionAttachment> playerPermissions = new HashMap<>();

    @SuppressWarnings("static-access")
    public SQLiteManager(JavaPlugin plugin) {
        this.plugin = plugin;
    }

public static void setupPermissions(Player player) {
        PermissionAttachment attachment = player.addAttachment(plugin);
        playerPermissions.put(player.getUniqueId(), attachment);
        BukkitScheduler scheduler = Bukkit.getScheduler();
        scheduler.runTaskLater(plugin, () ->{
            permissionsSetter(player.getUniqueId(), player);
        }, 1L);
    }

My question: why is plugin null...?

#

All I get... is an IllegalArgumentException... saying plugin cannot be null

trim creek
#

heading over those codes

remote swallow
#

isnt java plugn meant to be your main class name

sterile token
trim creek
#

Doin... its job... Now only doing permissions...

#

I think I should rename it to PermissionManager haha

trim creek
#

but you can call it whatever you want

remote swallow
tardy delta
#

heh Nuumber.class.isAssignableFrom(int.class) should return true, no?

sterile token
#

I mean my goal was to make it on less lines

#

๐Ÿ˜‚

remote swallow
#

why do you want less lines

tardy delta
remote swallow
#

fourteendoggo

#

do you have 14 dogs

tardy delta
#

wish i had

remote swallow
#

fake

tardy delta
#

better than fourteenbrush

#

dont have 14 brushes either

remote swallow
#

ive been meant to be coding pretty much all day ive just been finding things to not have to doit

tardy delta
#

to not have to doit?

remote swallow
#

yeah

#

anything to not do what im meant to

tardy delta
#

bruh the type is int and yet the 2nd one fails

sterile token
#

haha

#

I finally achive what i need

tardy delta
#

hows this false System.out.println(Number.class.isAssignableFrom(int.class));

#

or is it the other way around

#

nop

grand geyser
#

so i wanna know what my target player is inside the listener,
so i would open a gui with a player as target so that when i click something in the gui, it would open up gui2 and that will also have the same player as targer. but how do i make the onInventoryClick event listener recognise what the target player is

tardy delta
#

bruh is there a dif between INT and INTEGER now too in sql

#

mye doesnt error anymore

#

looks like some bug with primary keys

#

myes reopening connection every time for 8 queries ๐Ÿ’€

eternal oxide
#

using batch?

tardy delta
#

i might but ii cannot interpret that the user is doing things like this and therefore the connection can stay opened

trim creek
quaint mantle
#

what's the random for in structure.place()??

tardy delta
#

might do smth like connector::execBatch(Query<?>...) probably

#

check docs if not nms

quaint mantle
#

oh i see now

tardy delta
quaint mantle
#

one more thing

#

should i use List<Player> or Player[]?

tardy delta
#

for what, you generally shouldnt use arrays tho

quaint mantle
tardy delta
#

list or set

quaint mantle
#

accidentally put public

quaint mantle
tardy delta
#

dont expose collections tho

#

anyone who wants can manipulate them

quaint mantle
#

yeah

#

i put private for all of them

tardy delta
#

and uhh storing player references isnt the best thing too in terms of gc

#

store an uuid or a weakref<player> if youre really mad ||like me||

quaint mantle
#

Alr

#

probably the best idea ๐Ÿ˜…

tardy delta
#

100 lines reflection code for Query::setupTable ๐Ÿ˜ข, well not all of it

quaint mantle
#

also, how would i get the reference of the class without using a map?

#

?paste

undone axleBOT
quaint mantle
#

this is my class

#

i would want to do

#

luike

#
public static Pmine getPmine(String name) {
        return pmine;
    }```
#

without using a map to get the pmine

#

or would i have to use a map?

tardy delta
#

isnt pmineMap.put(name, this); already workin?

quaint mantle
#

i want to get the pmine later

#

so i can edit locations, players, ect

tardy delta
#

you cant get a pmine without instantiating it?

#

or a singleton?

#

im not understanding

quaint mantle
#

im just wondering if i could get the pmine with the name without using a map to do that

#

because ram

tardy delta
#

uh no?

#

you shouldnt be wondering about the ram usage of a map lookup too lol

#

server does already so much map lookups for basic things

quaint mantle
#

oh, okay

#

great

tardy delta
#

hehe fun thing about working with a db is that you shouldnt care too much about slow code

trim creek
#

I would like to know why is plugin null... Or how is it null...?
Seriusly I tried lots of things. Once it said config doesn't exists, once it said attachment is null. Now what?

public static JavaPlugin plugin;
@SuppressWarnings("static-access")
    public SQLiteManager(JavaPlugin plugin) {
        this.plugin = plugin;
    }
public void setupPermissions(Player player) {
        PermissionAttachment attachment = player.addAttachment(plugin); // error occurred at this line
        playerPermissions.put(player.getUniqueId(), attachment);
        BukkitScheduler scheduler = Bukkit.getScheduler();
        scheduler.runTaskLater(plugin, () ->{
            permissionsSetter(player.getUniqueId(), player);
        }, 1L);
    }
#

Using either static or non-static, doesn't helps at all btw xd

#

btw here is an errorlog

java.lang.IllegalArgumentException: Plugin cannot be null
        at org.bukkit.permissions.PermissibleBase.addAttachment(PermissibleBase.java:131) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.craftbukkit.v1_18_R1.entity.CraftHumanEntity.addAttachment(CraftHumanEntity.java:227) ~[paper-1.18.1.jar:git-Paper-152]
        at neonowlgery.*************.core.managers.SQLiteManager.setupPermissions(SQLiteManager.java:149) ~[AmariaCore.jar:?]
        at neonowlgery.*************.core.managers.SQLiteManager.onJoin(SQLiteManager.java:73) ~[AmariaCore.jar:?]
wet breach
#

second, instead of using JavaPlugin plugin, just put (main class plugin) instead

#

unless you are expecting other plugins to be using your methods

trim creek
#

Recently I killed that second method completely, because it was breaking stuff

#

Now to put it back

#

will kill some things again

#

so put JavaPlugin plugin instead of plugin?

fluid river
#

put YourMainClass

trim creek
#

Declaration goes to public JavaPlugin plugin btw

fluid river
#

instead of JavaPlugin

#

also

#

?learnjava

undone axleBOT
trim creek
#

...

#

if it worked before

#

completely fine

#

then how is ?learnjava coming here...?

grim ice
#

Well

#

you obviously dont know java

#

so he recommended you the act of learning java

#

pretty simple isnt it

fluid river
#

or at least take FREE JAVA LESSONS from me

#

and stop using static when there is no need for it

earnest lark
#

how would i convert a sentence into each induvidual word