#help-development

1 messages Β· Page 513 of 1

idle loom
#

I'm just trying to get it to work

#

this is just a little part of it

#

I've got an idea

remote swallow
#
private static final Material[] allowedMaterials = Arrays.stream(Material.values()).filter(Material::isItem).filter(UtilClass::isBlacklisted).toArray(Material[]::new);
#

i think that will work

green prism
#

Does anyone know how to write inside a SQLite database using HikariCP?

tardy delta
#

.filter(Predicate.not(BLACKLIST::contain)) uwu

tardy delta
#

theres not even a reason to use hikaricp with sqlite cuz its file based

#

only one thread can write to the file at the time

idle loom
#
    public static Material getRandomMaterial() {
        Material returnedMaterial = MATERIALS[ThreadLocalRandom.current().nextInt(MATERIALS.length)];
        List<String> items = new ArrayList<>(Main.getConf().getStringList("blacklistedItems"));
        for(String item : items) {
            materialList.add(Material.getMaterial(item));
        }
        if(materialList.contains(returnedMaterial)) {
            return getRandomMaterial();
        } else {
            return returnedMaterial;
        }
    }
    public static List<Material> materialList = new ArrayList<>();```
#

couldn't that work

tardy delta
#

dont do the blacklist part every invocation

#

have you used streams before?

idle loom
#

considering idk what tyhat is

#

imma say no

tardy delta
#

could also just use a static block to populate your arr

idle loom
#

idk!!!!!

idle loom
#

I dont need to populate the array every time

green prism
# tardy delta what part

I want to write a new entry, specifically, all the content inside here:

@Getter
@Setter
@AllArgsConstructor
public class AuctionData {
    private UUID id;
    private String buyer;
    private long timeStamp;
    private double price;
    private String seller;
    private ItemStack item;
tardy delta
#

but doing it without stream is kinda weird

#

creating a new list πŸ’€

idle loom
#

:chad:

            for(String item : items) {
                materialList.add(Material.getMaterial(item));
            }
        }```
tardy delta
#

probably want to normalize your table so itemstack is another table

undone axleBOT
idle loom
#

pft

#

learning java

#

who do you think I am

#

some scrub

tardy delta
#

learning streams*

idle loom
#

I did watch like 20 episodes into a learning java course and then forgot it all

#

and I haven't slept

green prism
idle loom
#

I'm going off my knowledge of other languages to hopefully carry me through this

#

its

#

not working

tardy delta
#

you just ask it a connection and thats all, for the rest you just write to your db as any other normal db

idle loom
#

typescript is the language I'm most proficient in

hazy parrot
#

why would you use hikaricp for sqlite

tardy delta
#

told him that

wet breach
#

sqlite doesn't have connections

#

just file handles

young knoll
#

I mean it does work

#

It just doesn't actually make a pool

tardy delta
#

but its useless

hazy parrot
#

it does work, but its kinda useless

young knoll
#

Good if you are doing multiple impls

#

Just use it for all of them

tardy delta
#

i just have hikaricp as an impl detail

wet breach
tardy delta
#

actually i have a boolean useHikari <sniffs>

wet breach
#

so why would you use a library method that isn't anymore efficient then just creating a file handle

#

third, hikari is pointless if both server and db are on the same system

#

ever since java 17 unix sockets are now native to Java

#

which is far better then any tcp socket

#

even windows 10 can handle unix sockets as well

young knoll
#

Like I said

#

It's good if you are doing multiple impls

wet breach
#

its pointless if said implementations don't even use it to begin with

#

sqlite nothing in hikari is touched, can't use hikari for unix sockets because hikari doesn't support that

#

so that only leaves tcp socket implementations only

agile anvil
#

do you have examples of unix sockets?

young knoll
#

I don't really feel it's worth it to make a separate system for local and not local dbs

tall saffron
#

Where can i learn the basisc of using an api like placeholder api or vault to get the group and how to import it into the pom.xml as rn the pom is as it generated on default

agile anvil
#

API's docs or webpages

wet breach
#

so it would depend

idle loom
#

man

#

screw this

tardy delta
#

isnt tcp just the protocol that runs on the socket?

idle loom
#

I'm deleting this and doing it the simple way

wise mesa
#

Just rewrite hikari to use native sockets 😎

tender shard
tardy delta
#

like why are you comparing tcp with unix sockets?

#

or are unix sockets localhost?

tender shard
#

it's basically just a file where you can "write to" or "listen to"

tardy delta
tall saffron
hazy parrot
#

its for exchanging data between two proccesses on server

wet breach
# agile anvil do you have examples of unix sockets?

jdbc:mysql:///?user=test&password=test&socketFactory=<classname>&<socket>=/tmp/mysql.sock
you are going to need to create a socket factory
https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-reference-configuration-properties.html
https://code.google.com/archive/p/junixsocket/wikis/ConnectingToMySQL.wiki
https://github.com/kohlschutter/junixsocket

GitHub

Unix Domain Sockets in Java (AF_UNIX). Contribute to kohlschutter/junixsocket development by creating an account on GitHub.

tardy delta
#

thats a short article lol

tender shard
#

I'm tired of explaining this over and over again

tall saffron
#

Thanks sorry i now nothing about the pom.xml

tender shard
#

np lol

#

I'm just tired of explaining it twice a day, so I put it into a blog post

#

did reloading maven work?

tardy delta
#

now people will ask where the blog post is instead

#

πŸ€”

young knoll
#

?mavenplz

#

Darn

tall saffron
wet breach
#

maybe I should make a new library for spigot

#

to make it easier to use unix sockets

buoyant viper
#

frost sockets yaknow

wet breach
#

Hot Sockets πŸ™‚

tall saffron
#

If i put a soft dependecy should i disabled the example code that gives placeholderapi that if you dont have the placehodlerapi plugin it disables the plugin right?

wet breach
#

you could design your plugin in a way that it isn't crippled just because of a dependency missing

#

in this manner it shouldn't matter if they have it or not

tender shard
#

or does your plugin REQUIRE papi to work?

tall saffron
tender shard
#

otherwise, use the string as it is

tall saffron
#

Oh yeah thanks

tender shard
#

e.g. sth like this should work just fine

public class NMS extends JavaPlugin implements Listener {
    
    private boolean isPapiInstalled = false;

    @Override
    public void onEnable() {
        if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            isPapiInstalled = true;
        }
    }
    
    public String parsePlaceholders(Player player, String textToParse) {
        if(isPapiInstalled) {
            return PlaceholderAPI.setPlaceholders(player, textToParse);
        } else {
            return textToParse;
        }
    }
young knoll
#

You can also just use isPluginLoaded rather than getPlugin != null

tender shard
#

or that

tender shard
#

wait, it still does not exist

tall saffron
#

so this should work? hasPapi = Bukkit.getPluginManager().isPluginEnabled("PlaceholderAPI");

tender shard
#

I wouldn't do that

#

because of cyclic dependencies, your plugin could get enabled before PAPI

#

so it would return false even though PAPI is installed (just not enabled YET)

young knoll
#

Might be isPluginEnabled

#

oopsie

tall saffron
#

Oh yeah right, its better to do getplugin

tender shard
#

getPlugin("PAPI") != null is definitely always working - isPluginEnabled will only work if PAPI actually gets ENABLED before your plugin, and you can never be sure about that, unless you depend on it

#

but since you only softdepend on it, the enable order can be random

tall saffron
#

Yeah amma use getplugin in case

wet breach
tender shard
tall saffron
#

oh its soo cool like with the PlaceholderAPI.setPlaceholders() it automatticly sets the placeholders that you putted %% here

wet breach
#

what kind of checks are you creating?

wet breach
#

you would only need to check at most 2 times, anymore then that is pointless

tender shard
#

why not just check only once, by using getPlugin(String) != null

#

that's foolproof

wet breach
#

but, everyone always assumes that there can never be outside interference

#

and therefore loves making assumptions of everything

tender shard
#

using != null is btw also the way that PAPI's docs suggest

wet breach
tender shard
#

no

#

it's only null if it doesn't exist (no matter whether enabled or not)

wet breach
#

then your check requires 2 checks, where as the one above that was stated you can check for all 3 states

#

in a single line

#

you can make a ternary from it πŸ™‚

#

if its neither true or null then its false πŸ™‚

tall saffron
#

i dont get how it works lol ``` public final Simples plugin;

public Chat(Simples plugin) {
    this.plugin = plugin;
}

@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event){

    Player player = event.getPlayer();

    if(plugin.hasPapi == true){
        PlaceholderAPI.setPlaceholders(plugin.getConfig().getString("Config.chat-format"));
    }

}```
tender shard
#

ok here's the absolutely, overcautios, quite funny rock-solid solution lmao

    @Override
    public void onEnable() {
        Plugin papi = getServer().getPluginManager().getPlugin("PlaceholderAPI");
        if(papi != null) {
            getServer().getScheduler().runTaskTimer(this, task -> {
                if(papi.isEnabled()) {
                    isPapiInstalled = true;
                    task.cancel();
                }
            }, 0, 1);
        }
    }
#

note, it's meant as a joke. just check if it's != null is the usual solution

tall saffron
#

first i need to get to wich player purse the papi

golden turret
#

is it good to use a BlockData[] instead of BlockData[][][]?

tender shard
tardy delta
#

referencing a whole chunk?

golden turret
#

I just want to create a simple copy and paste system

wise mesa
#

i hate passing my plugin and my scheduler around everywhere

#

to schedule things

#

like im fine with passing around my scheduler

young knoll
#

Are you talking about a flattened array vs a regular 3D array

wise mesa
#

but I hate that I have to pass my plugin around too

#

is there a better way?

tardy delta
#

passing around your scheduler?

tender shard
#

I would use a Map<BlockVector,BlockData> or sth where the BlockVector is the offset of the origin

young knoll
#

Why do you even need to pass around a scheduler

tardy delta
#

there exist di frameworks

wise mesa
#

because I have things that have to schedule stuff

tardy delta
#

but thats just a rabbithole

young knoll
#

Bukkit.getScheduler?

tender shard
#

yo ucan always get the scheduler through Bukkit.getScheduler() or through yourplugin.getServer().getScheduler()

tardy delta
#

plugin.getServer().getScheduler() oh god dont

wise mesa
#

see I'm fine with passing around the scheduler

tender shard
wise mesa
#

its passing around the plugin that makes me feel yucky

tardy delta
wise mesa
#

@tardy delta what do you prefer?

#

if you are so adamant about it

tender shard
# tardy delta NO

then why does the JavaPlugin take a Server object in the constructor and make it accessible to subclasses

golden turret
wise mesa
opal juniper
#

getServer().getScheduler()

wise mesa
#

alright well there is no alternative unfortunately i guess

#

i mean idk what it would be anyways

#

a plugin scheduler lol

#

maybe I should just make my own

tardy delta
#

does anyone else have the idea they re talking to theirselves?

tender shard
#

yeah

wise mesa
#

yea I kind've am

#

oh well

tall saffron
#
package events;

import chiru.simples.Simples;
import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;

public class Chat implements Listener {

    public final Simples plugin;

    public Chat(Simples plugin) {
        this.plugin = plugin;
    }

    @EventHandler
    public void onPlayerChat(AsyncPlayerChatEvent event){

        String chatformat = plugin.getConfig().getString("Config.chat-format");

        Player player = event.getPlayer();

        if(plugin.hasPapi == true){
            String chatformatpapi = PlaceholderAPI.setPlaceholders(player, chatformat);
            event.setFormat(chatformatpapi);
        }
        else {
            event.setFormat(chatformat);
        }

    }

}
``` I dont get why this doesnt work when you dont have papi installed
tardy delta
#

whoa

wise mesa
#

none of the suggested solutions actually answer my question

undone axleBOT
#

You can use the discord code block format to display code or just text in a more pleasing way:
```java
public class MyPlugin extends JavaPlugin {
@Override
public void onEnable() {

}

}```
Becomes:

public class MyPlugin extends JavaPlugin {
    @Override
    public void onEnable() {

    }
}```
wise mesa
#

but it makes sense because there is none

tardy delta
#

THE BIBLE πŸ™

tender shard
tardy delta
#

oh man im outta here

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

tall saffron
#

and instead it appears the default minecraft format

tender shard
#

because you misunderstood what setFormat is

tall saffron
#

wait i think is my fault

tender shard
#

have you ever used String.format?

tall saffron
tender shard
#

The default format looks exactly like this:

%s: %s
#

the first %s automatically gets replaced with the name

#

the second %s is the message

tall saffron
#

yeah

tender shard
#

what did you set it to instead?

tall saffron
#
#Simples - The only plugin you need
#Made by Chiru

#Placeholders will work if you have PlaceHoldersAPI installed :)

Config:

    chat-format: "%player_name% >> %message%"

    SimpleServerWelcome:

        enabled: true

        welcome-message: "&e&kI &a&lWelcome %player_name%! &rThis welcome message, has been created with &6&lSimple Welcome&r!, change this on the &4&lconfig.yml &e&kI"
tender shard
#

your "chat-format" contains exactly 0 %s, and so it won't work

#

at least IIRC, it should throw an error

rotund ravine
#

Probably does

tall saffron
#

o i understanded the api web it said to get the players name and get the message

tender shard
#

imagine this:

        String myFormat = "%player_name% >> %message%";

        System.out.println(String.format(myFormat, "Jeff", "Hello world!"));
#

String.format now sees "Ah, there's a %p"

#

there is no "p" datatype though in String.format

#

so you get this cute stacktrace

#

if PAPI is not installed, you manually have to replace %player_name% etc with %1$s and the %message% with %2$s

tall saffron
#

oh yeah i get it

tender shard
#

in theory, you could also just ignore the %s stuff and just manually insert the whole formatted thing into the format

tall saffron
#

when it worked i did this

tender shard
#

but in that case, you gotta escape % signs with %%

tall saffron
#

event.setFormat(player + event.getMessage());

tender shard
tall saffron
#

oh yeah in this case player is = event.getPlayer()

#

that was when it worked, then i changed the code idk why

rotund ravine
#

Don’t do that either

#

Just use it properly

tender shard
#

quick and dirty, ugly solution: ```java
if(!papiInstalled) {
String formattedFormat = formatFromConfig
.replace("%","%%")
.replace("%%player%%", "%1$s")
.replace("%%message%%", "%2$s");
event.setFormat(formattedFormat);
}

river oracle
#

formattedFormat lmao

tender shard
#

yeah well how would I call it lol

#

I would just encourage people to use %1$s by default in the config instead of manually parsing player_name and message

tall saffron
#

1 question how can i get the message sent with papi like in the config

#

i have this rn ```java
String chatformat = plugin.getConfig().getString("Config.chat-format");

    Player player = event.getPlayer();

    if(plugin.hasPapi == true){
        String chatformatpapi = PlaceholderAPI.setPlaceholders(player, chatformat);
        event.setFormat(chatformatpapi);
    }
    else {
        event.setFormat("%s: %s");
    }```
#

in the config i have the same as before chat-format: "%player_name% >> %message%"

hazy parrot
#

question, why would you use papi for that ?

tall saffron
#

if i dont have papi it works and sets the format to that, but wiht papi not as it doesnt get the message sent

hazy parrot
#

why not just setFormat("%s >> %s")

tall saffron
#

if i want to display the group of smone or their kills idk

#

amma do a replace

tender shard
#
    private static final String DEFAULT_CHAT_FORMAT = "%player%: %message%";

    @EventHandler
    public void onChat(AsyncPlayerChatEvent event) {
        String formatFromConfig = getConfig().getString("chat-format", DEFAULT_CHAT_FORMAT);
        
        // If the format contains % symbols, we gotta escape those
        String percentagesEscaped = formatFromConfig.replace("%","%%");

        // No need to use PAPI for the playername - we let Bukkit do it. Note, we use %%player%% instead of %player% because we escaped % earlier
        String playerReplaced = percentagesEscaped.replace("%%player%%", "%1$s");

        // Same for messaage
        String messageReplaced = playerReplaced.replace("%%message%%", "%2$s");

        if(isPapiInstalled) {
            // Now we can replace the remaining placeholders (everything that's NOT %player% or %message%)
            event.setFormat(PlaceholderAPI.setPlaceholders(event.getPlayer(), messageReplaced));
        } else {
            // ... or not
            event.setFormat(messageReplaced);
        }
    }

@tall saffron

tall saffron
#

Thanks, i question i donmt get the % why 2

tender shard
#

note that placeholders could again mess up the format if they themselves contain %

tender shard
#

now a player types "I have 20% of HP", it would throw an error

#

so you have to turn % into %% to tell String.format "the following % is NOT a placeholder, but it's really just a percentage sign"

tall saffron
#

get it

#

but why is so improtant to use %s instead of player.getname idk

ivory sleet
#

its a java string format specification

#

and thats what AsyncPlayerChatEvent uses

tender shard
#

you could in theory ignore the %s stuff and replace it yourself, but it would give everyone nightmares who knows how the chat event works

#

also players could then still type %s themselves and mess up everything

#

imagine you set the format to "mfnalex: I'm mfnalex, I got %2$s money"
then bukkit throws it into String.format, then in chat it'd look like this:

mfnalex: I'm mfnalex, I got I'm mfnalex, I got %2$s money money
remote swallow
#

can anyone tell why im somehow getting this error https://paste.epicebic.xyz/sowiyigadu.sql from this yaml ```yaml
questions:
Doug Engelbart was the inventor of what computer accessory? The first one was made from wood.:
answers:
- Mouse
THINK was this company''s motto for more than 40 years.:
answers:
- IBM
True or False. The platypus is a mammal.:
answers:
- "true"

tender shard
tall saffron
remote swallow
shadow night
#

If I'm storing player homes, should I rather use a proper database or just another config file? I'm lazy to make it work with a database but if it is critical, I will

tender shard
remote swallow
#

it is snakeyaml

tender shard
#

note, it's valid YAML, but spigot splits key names by "." and hence you get that problem

remote swallow
#

oh

tender shard
#

you could set this to e.g. \u0001 BEFORE loading the config

#

or you do it properly, like this:

#
questions:
- question: "This is the question"
  answers:
  - First answer
  - Second answer
- question: "This is another question"
  answers:
  - Another answer
#

this would be the proper way (using MapLists), because you don't rely on the key name

#

then you can get it with getConfig().getMapList("questions")

remote swallow
#

only problem i have is needing to update the config to use the new format

tender shard
#

yeah but that's the only proper solution

#

how many questions do yo uhave? if it's more than 20 or so, just write a regex or awk script

wise mesa
#

is there a function to get a material from a namespaced key

tall saffron
tender shard
#

as said, a dirty workaround would be to use a weird symbol as separator

remote swallow
#

to use snakeyaml directly would mean i need to recode the entire game system and i really dont want to do that

remote swallow
idle loom
tender shard
#

it'll work with any string

wise mesa
remote swallow
#

looks like im writing a config updater for it

glossy venture
#

anyone know why this is not working?
the dependency has been downloaded and is on the compileClasspath, yet intellij shows it doesn't exist and when i try to compile it also gives me the errors
the project is a fabric mod with gradle

#

the build.gradle

wise mesa
tender shard
tall saffron
#

I ended up using this, as i think it would be better ```java
@EventHandler
public void onPlayerChat(AsyncPlayerChatEvent event){

    String chatformat = plugin.getConfig().getString("Config.chat-format");

    Player player = event.getPlayer();

    event.setFormat(chatformat.replace("{DISPLAY_NAME}", "%1$s").replace("{MESSAGE}","%2$s"));

}```
#

i will add idk 5 more

glossy venture
#

its in okhttp3.OkHttpClient

#

but intellij doesnt recognize it

grim oak
#

Hi I have a custom config file which is located in my resources folder in my plugin in a folder called β€˜rewards’, how do I make the config file/ rewards folder automatically copy across to the data folder when the plugin is run on the server?

tardy delta
#

you talking about plugin.saveResource i believe

grim oak
#

Okay thanks ill try it in a minute

tender shard
#

I got the same problem in IJ on maven

glossy venture
#

neither does javac tho

#

it doesnt build either

tender shard
#

it does compile fine for me

#

but IJ just can't see it

glossy venture
#

hm

tender shard
#

I found the issue

#

when I switched the scope to "compile", it found all the dependencies

#

which makes little sense, as that's the default scope

#

seems like IJ is borked

#

try to set the scope to implementation, reload gradle, does it show up now?

#

If yes you should be able to change it back afterwards

#

I also tried with gradle but your build file throws a million other errors for me lol

tardy delta
#

ij has been fucking up the last time

slim wigeon
#

Still working on my shop, does "Warped Stem" count as wood?

frail gazelle
#

how would i go about returning values from listeners?

i essentially want to make a reaction type minigame within a gui and i want to know when someone clicks the item

is there a better way to go about this?

tender shard
hazy parrot
slim wigeon
#

Thanks, that is what I needed. I did not know I can see that in the F3

tender shard
#

(it could in theory be changed through datapacks though, so if you wanna be sure, use Tag.LOGS.isTagged(Material.WARPED_STEMS)

frail gazelle
hazy parrot
#

What exactly is not clear?

slim wigeon
#

I cannot do that with my shop but thanks, I will use that when needed. Maybe my future plugins

glossy venture
#

oh wtf

#

it just fixed itself

frail gazelle
# hazy parrot What exactly is not clear?

i’m just confused as to what you mean by all of it

when the item is clicked, add that to a variable then check if that variable is the right value or something else?

hazy parrot
#

That is what I meant with check conditions

frail gazelle
#

ah yeah

frail gazelle
#

not within the actual listener

hazy parrot
#

Why?

#

What's wrong with doing it inside of listener

#

I mean you sure can

#

Just pass inventory event as method argument

frail gazelle
#

when the item is clicked i want to change the inventory so that the item moves to a different position

#

which is why i would want to know from a different function when the item is clicked

rotund pine
#

hello, I have a problem with maven and NMS where when I try to package my plugin, the "remap" goal does not get executed and when I try to directly run the remap goal I got an error saying that the srgIn param is invalid or missing. Any idea why this happen? my pom.xml file https://paste.md-5.net/asemusuyed.xml

frail gazelle
#

so it can signal it to shuffle the position

slim wigeon
tender shard
#

?nms

shadow night
#

If I'm storing player homes (/sethome), should I rather use a proper database or just another config file? I'm lazy to make it work with a database but if it is critical, I will

slim wigeon
tender shard
slim wigeon
shadow night
tender shard
# shadow night Maybe sometimes, in rare cases

if you wouldn't need to, I'd use the player's PDC.

You can easily access offline player's PDCs but it requires 2 lines of NMS.

If you don't wanna use PDC, I'd go for either YAML + optional MySQL, or SqLite + optional MySQL

tender shard
#

PDC is easiest to use and requires zero setup

slim wigeon
tender shard
#

Thatll do! Use that @shadow night

#

I mean, if a world gets deleted, the homes are gone anyway. Perfect solution

slim wigeon
#

Just replace setlastlocation to gethome

tender shard
#

You can use my lib to store eg map<uuid<list<location>> for the homes in eachβ€˜s worlds pdc @shadow night

#

?morepdc

undone axleBOT
regal scaffold
#

Yo alex

#

Can you send me your IJ xml java style file

tender shard
regal scaffold
#

That looks a lot better than what I was using

#

I hate that it's so close to the left though but easily changable

#

Thanks!

#

Sometimes I feel like the IJ formatting doesn't actually work anyways

#

Like it doesn't change stuff it should

rotund pine
tender shard
# shadow night Hmm, I'll think

here's a tiny example of how you could store homes in each world's PDC using MorePersistentDataTypes. The example only lets you query existing homes, but ofc you can also just easily add to that. It will also work for offline players, as the data is stored in the world.

https://paste.md-5.net/ucidipowor.cpp

regal scaffold
#

Alex your styling makes it hard to read methods with many parameters

regal scaffold
#

Or do you actually side scroll

tender shard
regal scaffold
#

So you actually like it being all in 1 long line?

tender shard
#

I actually don't care

regal scaffold
#

Even though 70% of the stuff above will be empty

tender shard
#

the issue is that whenever I change the settings, they are again gone in the next project

regal scaffold
#

Why is that? There's a default thing for all projects

tender shard
#

don't ask me, IJ is weird

eternal loom
#

πŸ‘

regal scaffold
#

I wanna see more xml files

worldly ingot
regal scaffold
#

If anyone feels like sending their own would appreciate it a lot

worldly ingot
#

#match() only having been added in 1.19.2 or something

regal scaffold
#

Choco you've been doing this for years you probably have a tweaked style file πŸ‘€

worldly ingot
#

Hm?

#

Checkstyle?

regal scaffold
#

IntelliJ java style xml file

worldly ingot
#

I use Eclipse but I use a modified version of Bukkit's Checkstyle file

#

Unsure if IJ uses Checkstyle

regal scaffold
#

That seems almost same as default

worldly ingot
#

Yeah my standards tend to adhere 1:1 with default styling guidelines

chrome beacon
#

IJ has a checkstyle plugin

regal scaffold
#

Interesting

tender shard
regal scaffold
#

I just find some stuff

#

So hard to do with

#

legible code formatting

#

Alex's system is like 1 super long line cause he has 12312 ultrawide monitors so he has a electric chair to spin around

tender shard
#

can you show me any example of any of my "super long lines"?

regal scaffold
#

But I've done some exploring and I find it so hard to find something that actually looks nice

tender shard
#

because I actually don't think they are overly long

regal scaffold
#
    protected InventoryButton createUpgradeSlotsButton() {
        return new InventoryButton().creator(player -> getButton(Objects.requireNonNull(Config.getStringMaterial(ConfigPath.GUI_MAIN_MENU_UPGRADE_SLOTS_ITEM)), TextUtils.color(" "), PlaceholderUtils.replacePlaceholders(Config.getStringListLore(ConfigPath.GUI_MAIN_MENU_UPGRADE_SLOTS_ITEM), ultraChest))).consumer(event -> {
            Bukkit.getScheduler().runTask(plugin, () -> {
                plugin.guiManager.openGUI(new SlotUpgradeInventory(ultraChest), (Player) event.getWhoClicked());
            });
        });
    }
#

lmao

#

creator in a return

#

That's why

slim wigeon
#

Are these not the same, I only seeing one in the shop? ANDESITE: purchase: 20 sell: 2 DEEPSLATE: purchase: 20 sell: 2 COBBLED_DEEPSLATE: purchase: 50 sell: 5But it exists somehow when typing this command/give MrnateGeek cobbled_deepslate

tender shard
#

this is the longest I've written today, I don't think it's too long. it's maybe 50% over the normal limit lol

wise mesa
#

since its notnull

#

does it throw an exception?

#

thank you so much for the help btw

regal scaffold
#

This just looks so damn weird bruh wtf

wise mesa
#

oh i checked they're actually both nullable

#

that helps alot choco, thank you!!!

tender shard
tender shard
regal scaffold
#

I know

#

Like wtf

rotund pine
# tender shard how do you compile?

i have maven installed on my computer and i just do mvn package, I have also tried mvn clean compile before doing mvn package but this did not solve the issue

wise mesa
tender shard
undone axleBOT
regal scaffold
#

Still looks ass

tardy delta
#

brr

tender shard
tardy delta
#

ultrawide monitors, meanwhile my screen

regal scaffold
#

That looks a lot better indeed

tardy delta
#

still a small screen

regal scaffold
tardy delta
#

alex probably got a tv

regal scaffold
#

lmao

#

Wtf is going on

#

In this styling

#

How can it be so ass

slim wigeon
#

...

tardy delta
#

dont chain it

#

and use variables

tender shard
#

you're all just noobs. this is only 2.5 screens in width btw

#

the right one is in portrait mode rn so that's why it's 2.5 screes

tardy delta
#

i can give you a

slim wigeon
tardy delta
#

man why is that line so long

tender shard
tender shard
regal scaffold
#

Maybe it's time for a ultrawide

tender shard
tardy delta
#

just buy a smart tv

regal scaffold
#

I have a sick monitor setup now

regal scaffold
#

That's not even that big

tardy delta
#

i have an old monitor

tender shard
#

as I said, 3x27"

regal scaffold
#

Oh

#

Right

#

And the electric chair

#

To spin around

tender shard
#

you put all your plugis into <pluginManagement>

#

they belog directly into <build><plugins> as mentioned in the blog post:

#

?nms

tender shard
#

btw 90% of your plugin declarations are kinda useless

#

e.g. maven-install-plugin, why?

regal scaffold
#

Why is this thing wrapping

#

wtf is going on with ij

slim wigeon
tender shard
# slim wigeon I tried searching it and it showed 2 editors from Linux command-line and Notepad...
slim wigeon
#

I talking about the Text editor

tender shard
#

wdym

#

which text editor

#

lol

slim wigeon
#

You use Atom, bracklets or what editor?

tender shard
#

the screenshot? IntelliJ.
as normal editor I got notepad++ and sublime on windows

rotund pine
#

thanks for the help πŸ™ƒ

tender shard
#

np

regal scaffold
#

I'm losing my mind

#

File just isn't reformatting until I set it myself first

#

And then it keeps it

slim wigeon
regal scaffold
#

Alternatives to IntelliJ formatting? I getting annoyewd

tender shard
#

I would never bother about changing any icons lol

slim wigeon
#

Its red and blue border with black box

kind hatch
#

That's IntelliJ

tender shard
#

yeah that is IntelliJ

kind hatch
#

It's the Ultimate Edition icon.

#

The community icon is just a square.

tender shard
#

Community has another icon?

#

i never knew

sage patio
#

yes

tender shard
#

on macOS, the icon looks sooo beautiful

tardy delta
#

ultimate

kind hatch
tardy delta
#

theres one imposter

tender shard
tardy delta
#

whats the space doing there

tender shard
#

seperating most important from middle important

kind hatch
#

All the community edition jetbrains tools use the square icons.

tender shard
tardy delta
#

go look at your emails

#

this mc?

sage patio
#

PolyMC

tardy delta
#

ah i thought i heard smth about a new icon

sage patio
#

Prism Launcher is better

tardy delta
#

dunno any of those things

tender shard
sage patio
#

nothing

#

the icon is better

#

lol

kind hatch
#

It's the same thing, but the devs from that got kicked from PolyMC work on it.

tender shard
#

I prefer the polyMC icon, it looks like minecraft and not like some photo editing software lol

#

also the name is much more descriptive

#

"poly mc" literally means "multiple minecrafts"

kind hatch
#

MultiMC also fits that descriptor.

tardy delta
#

i like prism more then

tender shard
#

I prefer descriptive names, i mean look at my plugins… ChestSort, Drop2Inventory, MorePersistentDataTypes, etc lol

regal scaffold
#

I'm giving up

kind hatch
#

I guess, but I'm sure you get the idea though. Prisms refract light resulting in the entire infinite spectrum.
I'd also rather use the PrismLauncher just to avoid the repo drama with PolyMC.

chrome beacon
#

^^

regal scaffold
#

Why does IntelliJ do different stylings like what the

tender shard
tardy delta
#

wat

chrome beacon
regal scaffold
#

It's not

tender shard
tardy delta
#

please dont put that into production

kind hatch
slim wigeon
#

Can I speak to you privately?

regal scaffold
#

I'm not, I'm trying to fix it

tender shard
regal scaffold
#

I literally reset

#

To default

young knoll
#

Woah where is this going

regal scaffold
#

And reformat

#

And nothing happens

chrome beacon
#

As I said line length setting

regal scaffold
#

By default

#

It shouldn't wrap ?

quaint mantle
#

this is definitely a long shot in the dark, but is anyone here experienced with minecraft core shaders/glsl?

regal scaffold
#

But it doesn't do anything

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Make sure you use the right channel regarding the topic of your question. Create a thread in case the channel is already in use!

kind hatch
regal scaffold
#

omfg

#

Yes

#

2 of those were selected

#

Holy sht

#

Now I can actually make my design...

tender shard
#

tbh changing those code style settings takes so much time and is so much not worth it imho

#

I just stopped caring about it, I only changed it to not use * imports

#

which is only possible by setting the threshold to 999 btw lol

regal scaffold
#

In the imports section?

tender shard
#

IJ resets it for every new or already existing project anyway from my experience, especially if you use it on two or more PCs

tender shard
#

Code Style -> Java -> CLass count to use import wit h* -> 999

regal scaffold
#

Gotcha, ty

tender shard
#

otherwise people complain when you PR to bukkit lol

regal scaffold
#

lol

#

Alright still can't figure out good settings for these weird methods but I'll just commit to fixing it and exporting the xml

tender shard
#

yeah they also complain about missing spaces between function name and brackets

regal scaffold
tender shard
#

you're making it worse with every screenshot

tardy delta
#

whats even the problem? rewrite it?

regal scaffold
#

It's literally unreadable

tender shard
#

copy/paste that code here once

tardy delta
#

variables my man

regal scaffold
#
    private InventoryButton createSettingsButton() {
        return new InventoryButton().creator(player -> getButton(plugin.gui.getString("main-menu.settings.material"),
                                                                 TextUtils.color(" "),
                                                                 PlaceholderUtils.replacePlaceholders(plugin.gui.getStringList("main-menu.settings.lore"),
                                                                                                      ultraChest)))
                                    .consumer(event -> {
                                        Bukkit.getScheduler()
                                              .runTaskLater(plugin,
                                                            () -> {
                                                                plugin.guiManager.openGUI(new SettingsMenuInventory(ultraChest),
                                                                                          (Player) event.getWhoClicked());
                                                            },
                                                            1L);
                                    });
    }
#

Beautiful format

#

Absolutely gorgeous

kind hatch
#

Absolutely abhorrent.

regal scaffold
#

lmaooo I know

#

It's so bad

tardy delta
#

discord fucking it up even more

tender shard
#
    private InventoryButton createSettingsButton() {
        return new InventoryButton().creator(player -> getButton(plugin.gui.getString("main-menu.settings.material"), TextUtils.color(" "), PlaceholderUtils.replacePlaceholders(plugin.gui.getStringList("main-menu.settings.lore"), ultraChest))).consumer(event -> {
            Bukkit.getScheduler()
                    .runTaskLater(plugin,
                            () -> {
                                plugin.guiManager.openGUI(new SettingsMenuInventory(ultraChest),
                                        (Player) event.getWhoClicked());
                            },
                            1L);
        });
    }
#

the only thing I'd put on a new line is the consumer

regal scaffold
#
    private InventoryButton createSettingsButton() {
        return new InventoryButton().creator(player -> getButton(plugin.gui.getString("main-menu.settings.material"), TextUtils.color(" "),
                PlaceholderUtils.replacePlaceholders(plugin.gui.getStringList("main-menu.settings.lore"), ultraChest))).consumer(event -> {
            Bukkit.getScheduler().runTaskLater(plugin, () -> {
                plugin.guiManager.openGUI(new SettingsMenuInventory(ultraChest), (Player) event.getWhoClicked());
            }, 1L);
        });
    }
#

Still kinda hard to see the parameters

#

I wish they would just be like, 1 parameter per line, evenly

tardy delta
#

im still wondering, why dont you rewrite this?

regal scaffold
#

Why do I need to rewrite it?

#

It's just the styling

tardy delta
#

cuz it looks horrible

#

and not just the styling

young knoll
#

What does TextUtils.color(" ") even do

regal scaffold
#

Placeholder, replacing it right now

#

The method is literally smiles gui implementation

#

That looks a bit better

#

Actually that's pretty decent

#

Lastly maybe the consumer() down 1 line

#

Really? lmao

agile anvil
#

Builders are cool, but sometimes it's easier to just use setters

#

I usually use builders when it's not too long, and in the code directly, not representing the whole method

flat lark
#

Example: /punish <Player> I want to have multiple categories. So I would need to create another gui from my knowledge. But I want the GUI Title to say be the display name of the player throughout using the gui.

tardy delta
#

remove {}

tender shard
#
    private InventoryButton createSettingsButton() {
        String materialName = plugin.gui.getString("main-menu.settings.material");
        String name = TextUtils.color(" ");
        String lore = PlaceholderUtils.replacePlaceholders(plugin.gui.getStringList("main-menu.settings.lore"), ultraChest);
        Button button = getButton(materialName, name, lore);
        
        return new InventoryButton().creator(player -> button.consumer(event -> {
            Bukkit.getScheduler().runTaskLater(plugin, () -> {
                plugin.guiManager.openGUI(new SettingsMenuInventory(ultraChest), (Player) event.getWhoClicked());
            }, 1L);
        }));
    }
regal scaffold
#

Hmmm

#

That actually does look better

kind hatch
#

Did you... just 1 up him in the bathtub?

tender shard
#

I only refactored it a bit lol

regal scaffold
#

Now noob question

#

Doesn't delcaring those variables just to be used in the creator

agile anvil
regal scaffold
#

"waste" of memory?

young knoll
#

Not really

regal scaffold
#

Is it the same as doing inline?

young knoll
#

They are local variables

regal scaffold
#

Isn't it actually creating a temp variable?

#

So temporarily yeah it uses memory

tender shard
#

what's more important? that your code does not look like shit, or 0.0000002% of your RAM?

regal scaffold
#

But then GC

young knoll
#

Does GC even touch local variables

regal scaffold
#

What if 1000 players using this

kind hatch
#

It's supposed to.

tender shard
regal scaffold
#

Is it still not noticeable?

young knoll
#

I though they just get discarded after the method is over

regal scaffold
#

So using a lot of local variables is for the most part, good

agile anvil
#

A local variable isn't even really put in memory isn't it?

kind hatch
#

It is.

regal scaffold
#

Alright cool, thanks for clarifying

kind hatch
#

Any variable you declare is reserved a space in memory.

#

It's just up to the GC to un/deregister them.

young knoll
#

Local variables go on the stack

flat lark
# agile anvil You'll have to be more precise
gui = Bukkit.createInventory(new GUIHolder(), 54, playerName);```
the argument <Player> would be set to the GUI Title. Now if I selected a category. How could I pass the playerName variable to it.
tender shard
agile anvil
#

depends on how you manage the "select a category"

slim wigeon
#

How I only see one of these in my shop? DEEPSLATE: purchase: 20 sell: 2 COBBLED_DEEPSLATE: purchase: 50 sell: 5Are these not the right names?

regal scaffold
#
    private InventoryButton createSettingsButton() {
        String materialName = plugin.gui.getString("main-menu.settings.material");
        String name = TextUtils.color(" ");
        List<String> lore = PlaceholderUtils.replacePlaceholders(plugin.gui.getStringList("main-menu.settings.lore"), ultraChest);
        ItemStack button = getButton(materialName, name, lore);

        return new InventoryButton().creator(player -> button).consumer(event -> {
            Bukkit.getScheduler().runTaskLater(plugin, () -> {
                plugin.guiManager.openGUI(new SettingsMenuInventory(ultraChest), (Player) event.getWhoClicked());
            }, 1L);
        });
    }
#

There you go

#

Much better indeed

#

Thanks all

flat lark
kind hatch
agile anvil
#

But I guess you want to open a new gui

tender shard
agile anvil
#

So just create a method

flat lark
agile anvil
#

and input playername as argument

agile anvil
kind hatch
#

If so, pass it in there.

flat lark
#

Alright.

slim wigeon
tender shard
#

you forgot to set api-version to 1.13 or newer in plugin.yml

#

maybe

slim wigeon
#

I think I see what I did

tender shard
#

but wouldnt you get any console errors if it cannot find the material?

#

how do you even turn the string into a material?

halcyon citrus
#

idk if i should ask here since its not really code related

#

but i recently got some code from github, and it refuses to compile

kind hatch
slim wigeon
tender shard
#

did you set an API version in plugin.yml

slim wigeon
#

Who?

tender shard
#

you

slim wigeon
#

I got the 2 blocks to show up but not the stairs and slabs

#

When it comes to Deepslate

remote swallow
#

do you have a api version set in plugin.yml

kind hatch
#

When it comes to materials, it's just a matter of names.

tender shard
#

he earlier claimed that deepslate isn't working at all, that's why I keep asking for api version, but sadly, no answer

kind hatch
#

Does api-version do anything other than prevent legacy material loading?

tender shard
#

No. But legacy material support means you dont see the new materials

slim wigeon
#

Ok, only Cobbled Deepslate Stairs is showing DEEPSLATE_STAIRS: purchase: 40 sell: 4 COBBLED_DEEPSLATE_STAIRS: purchase: 100 sell: 10

kind hatch
tender shard
#

Nobody knows, we have no code nor answers about the api version

#

I wont ask a fifth time

slim wigeon
#

The api version is set to 1.19

tender shard
#

Good

#

Whats your code to turn the list into materials / itemstacks?

slim wigeon
#
        for(String section : this.data.getKeys(false)) {
            if( !this.data.isSet(section+".icon") ) { continue; }
            if( Material.getMaterial(this.data.getString(section+".icon")) == null ) { continue; }
            
            ShopGroup group = this.manager.add(this.data.getString(section+".name"),Material.getMaterial(this.data.getString(section+".icon")));
            if( !this.data.isSet(section+".items") ) { return; }
            
            Set<String> items = this.data.getSectionKeys(section+".items", false);
            
            for(String item : items) {
                if( Material.getMaterial(item) == null ) { continue; }
                if( this.manager.hasMaterial(Material.getMaterial(item)) ) { continue; }
                
                List<Integer> prices = Arrays.asList(
                    (this.data.isSet(section+".items."+item+".purchase") ? this.data.getInt(section+".items."+item+".purchase") : 0),
                    (this.data.isSet(section+".items."+item+".sell") ? this.data.getInt(section+".items."+item+".sell") : 0)
                );
                
                if( prices.get(0) != null || prices.get(1) != null ) {
                    group.add(Material.getMaterial(item), prices);
                }
            }
        }```
tender shard
#

Add debug outputs into every if / before every return

#

Looks like you return instead of continuing or sth

#

Hard to read that code on the phone

kind hatch
#

Can you paste it instead? It's just hard to read in general.

#

?paste

undone axleBOT
slim wigeon
#

If I use return, it will exit the for loop

tender shard
#

No, itll end the whole method

kind hatch
#

Also, can you paste your full config?

slim wigeon
remote swallow
#

break ends the loop, continue goes to next iteration, return ends the method

slim wigeon
young knoll
#

return immediately jumps to the end of the method
break jumps to the end of the loop
continue jumps to the next entry in the loop

remote swallow
#

im quicker

#

this hurts, just add a def to the getInt

young knoll
#

Gotta love the get methods with defaults

kind hatch
#

Facts

native nexus
#

Why not just utilise plain old fileconfiguration rather than creating a wrapper in datamanager?

slim wigeon
#

This song here, weird as f***. Anyway, I know how these for loops and all that works

tender shard
remote swallow
tribal quarry
#

Sounds like it's good stuff

slim wigeon
#

Freak Nasty - Bounce 2 This (Groove)

tender shard
remote swallow
tribal quarry
remote swallow
#

this song isnt weird as fuck

slim wigeon
#

I show you, one second

tribal quarry
#

Who listened to dream mask Sus remix

#

That shit was fire

slim wigeon
kind hatch
#

Why why why is there no formatter on the paste site. :3

slim wigeon
#

But that code is working perfectly. Its just the material names

tribal quarry
#

Instead of adding like goofy functions

remote swallow
#

yeah that doesnt seem like it would be less code

#

it would save you a few seconds to type it

kind hatch
#

Holy shit, what is this indentation? You've got a gap and a half of whitespace.

young knoll
#

The code gets claustrophobic

tribal quarry
#

That is tab

#

I think

kind hatch
slim wigeon
#

Why change it when it works?

kind hatch
#

You don't have to change it, but that's not going to change the fact that I'm bothered by it.

tribal quarry
native nexus
warped canyon
#

where can I find the spigot mappings

#

not the mojang mappings

tribal quarry
#

?nms

echo basalt
tardy delta
#

what happened with yalls fonts

kind hatch
echo basalt
#

sniped

kind hatch
#

I was so close too. :3

warped canyon
#

is there an api to download the mappings

slim wigeon
#

Also, I found my issue. There is no Deepslate stairs and slabs. They called DEEPSLATE_TILE_STAIRS

warped canyon
#

i need the raw mappings

tender shard
warped canyon
#

ik

tender shard
#

Methods and fields are obfuscated

warped canyon
#

ik

kind hatch
warped canyon
#

i need an api to download the raw mappings for spigot

remote swallow
#

spigot mappings are just what you get if you have the spigot dep instead of the spigot-api dep

warped canyon
#

I'm not using the mappings for development

#

i need the mappings to map all the spigot remapped class names to the original obfuscated names

tribal quarry
#

Use paperweight

warped canyon
#

also I need to have it automated

tribal quarry
#

And reobfJar task after build

warped canyon
#

so is there an HTTP API i can get the raw mappings from

tribal quarry
#

And somehow maven does it

tribal quarry
young knoll
#

Maven does it with the special source plugin

kind hatch
#

Which the special source jar can convert.

warped canyon
#

does buildtools generate the mappings?

slim wigeon
remote swallow
#

why does it matter?

kind hatch
#

Buildtools will install the remapped stuff to your local maven repo provided you use the --remapped flag.

warped canyon
#

once again i need a mappings text file

#

not a jar

warped canyon
#

does that include the mappings file

tender shard
#

It includes the mappings as files

warped canyon
#

alright

tender shard
#

org.spigotmc:minecraft-server:1.18.2-R0.1-SNAPSHOT:txt:maps-mojang

#

Its a txt file in your local maven repo

warped canyon
#

minecraft-server-1.19.4-R0.1-SNAPSHOT-maps-spigot.csrg is what I needed

#

thanks

agile anvil
#

Are you guys working as dev / SE or do you do something completely different?

young knoll
#

MD is a solicitor

#

@tender shard is a lawyer

agile anvil
#

Ahah that's amazing

#

What about you Coll?

young knoll
#

I’m a SE

agile anvil
#

Makes sense

lilac pier
#

hey guys i need help for a plugin i try to furnace an entier inventory but i don't find how to do it if someone can help me it's can be really usefull for me

agile anvil
#

Furnace an entire inventory? What do you mean ?

young knoll
#

I think they want to smelt stuff?

tender shard
#

?paste

undone axleBOT
tender shard
young knoll
#

I just generate a Map<Material, Material> on startup for that

#

Granted if you want to handle the xp and whatnot you need to store a bit more than just the output material

lilac pier
#

(sorry i'm french my english is not very good)

tender shard
#

just loop over the inventory, and do the same thing for every item inside

lilac pier
#

how i can create a loop for check every slot ?

tender shard
#
for(ItemStack item : player.getInventory()) {
  // Do your stuff for "item"
}
young knoll
#

Inventories are

tender shard
#

Iterable

#

yes

young knoll
#

Uhh what’s th- yeah that

tender shard
#

they've been iterable at least since 1.8, idk about before

icy beacon
#

hi yet good night

#

bye

tender shard
#

hi, good bye

lilac pier
#

mf can i send u my furnace plugin and tell me what i need to change ?

tender shard
#

why don't you just send it here?

lilac pier
#

how i can do it

tender shard
#

upload it to github

#

in IntelliJ you can do VCS -> GitHub -> Share Project on GitHub (or sth like that)

lilac pier
#

tell me if it's good

agile anvil
#

404

#

Mets ton projet en public

shadow gazelle
#

Is there a way to get the loot for an animal kill with an item stack?

young knoll
#

Yes

#

You have access the mobs loot table

tender shard
#

On the repo, go to Settings -> scroll down -> Change Visibility

shadow gazelle
lilac pier
young knoll
#

You make one

tender shard
young knoll
#

LootContext has a builder

lilac pier
#

no why ?

young knoll
#

Granted you can’t just stick an item in the loot context

#

But you can stick the items level of the looting enchant

agile anvil
lilac pier
#

ben j'ai tout perdu je sais pas pourquoi

agile anvil
#

🫨🫨

#

Il faut que tu aies une fonction qui prend en entrΓ©e un ItemStack, et qui te donne l'ItemStack "cuit". Une fois que tu as Γ§a, tu l'applique Γ  tous les items de l'inventaire

lilac pier
#

ben je l'avais mais plus maintenant xD

#

oh pire je le refais et je t'envois en privΓ© ?

agile anvil
#

Fais la fonction

#

Et mets lΓ  ici:

#

?paste

undone axleBOT
tardy delta
#

oui oui bien-sur

tender shard
#

je suis un Baguette

#

I am a long bread

#

I can say weird useless things in at least 10 languages

tardy delta
#

imma keep quiet

tender shard
#

In turkish i can ask the bus driver to stop at the insurance company

#

Dont ask me why

tardy delta
#

lawyer things

tender shard
#

Nah that was a personal thinf

pliant wind
#

How safe is it to store player inventories using persistent data versus something like files/databases?

tardy delta
#

why

kind hatch
young knoll
#

Meh

#

Not really

#

It might making loading it a tiny bit slower, but that’s done async anyway afaik

chrome beacon
#

^ and it's done once

candid kindle
#

im trying to add a player to an sqlite table if they arent already in it. how can i check if the table does/doesn't contain an entry (their uuid)?

young knoll
#

Iirc there is

#

INSERT OR IGNORE?

candid kindle
#

admittedly no

candid kindle
agile anvil
#

I advise you to checkthe basics first

#

And chatGPT does know SQL really way if you need help with requests

candid kindle
#

thats true actually, i should be using that

agile anvil
#

Well, we're still here to help you

#

But SQL is really simple and it's a great skill to learn

#

We don't want to spoonfeed ya

lilac pier
#

@agile anvil c'Γ©tait ou que je devais te mettre la class ?

undone axleBOT
tardy delta
#

no english?

lilac pier
pliant wind
# tardy delta why

I need someway to temporarily store player inventories when they join/leave a world. I figured using PDCs might be more convenient than files

agile anvil
#

I'll do the bridge for you

tardy delta
#

now we get a combination of french and englush πŸ’€

agile anvil
#

We call it franglish

tender shard
tardy delta
#

serializing a whole item state is already terrible enough, dont make it worse

lilac pier
agile anvil
tardy delta
#

kekw

lilac pier
chrome beacon
#

This discord is english only

agile anvil
#

For real?

young knoll
#

Yes

agile anvil
#

πŸ’”πŸ’”πŸ’”

tardy delta
#

bruh turns out if you read a file line by line, the \n character is gone

#

been looking at overflow bugs for two hours now

pliant wind
agile anvil
#

Could you please just have a look on the code guys? L3onis wants to "furnace" all of it's inventory

tardy delta
#

that sounds funny though

agile anvil
#

Isn't there a cheaper way to find the furnaced result of an item?

tender shard
#

it's the easiest way, it has no leftover files or any database needed, and it automatically gets loaded when the player joins

#

it's perfect for this

tardy delta
#

but can you serialize an itemstack directly to a pdc or is there some tricky mess?

tender shard
young knoll
#

I need to finish that PR for offline PDC access

tardy delta
#

does that involve loading the player files?

young knoll
#

There is no PDC adapter for ItemStack

tender shard
severe oracle
#

Hello, why is Player.getVelocity() returning 0.0,-0.0784000015258789,0.0 While i am walking?

young knoll
tender shard
tardy delta
#

meh i should just save it to a file then

young knoll
tender shard
#

but x or z should be non-0

chrome beacon
undone axleBOT
chrome beacon
young knoll
#

Well, no built in one*

severe oracle
tender shard
tender shard
young knoll
#

I mean

#

It works

severe oracle
tender shard
#

show more code

young knoll
#

NMS has a system to serialize them but meh

severe oracle
#
        NBTItem weaponNBT = new NBTItem(weapon);
        JSONParser parser = new JSONParser();
        JSONObject weaponTag = (JSONObject) parser.parse(weaponNBT.getString("usbus_item"));

        String weaponType = String.valueOf(weaponTag.get("weaponType"));

        System.out.println(player.getVelocity());
        GenericRangedWeapon tmp = new GenericRangedWeapon();
}```
pliant wind
#

That's helpful thanks

weak meteor
#

how to make tab completition

tardy delta
#

kinda interesting but this char is on the end of an empty line πŸ€” Γ¦

#

wdym empty

wicked ember
#

Does anyone know how I could spawn a mythic mob in code? Or know how I can compile with an error in intelliji

severe oracle
tender shard
#

show the whole event code too

severe oracle
#

here

tender shard
severe oracle
#
private static void weaponRightClick(ItemStack weapon, Player player) throws ParseException {
        NBTItem weaponNBT = new NBTItem(weapon);
        JSONParser parser = new JSONParser();
        JSONObject weaponTag = (JSONObject) parser.parse(weaponNBT.getString("usbus_item"));

        String weaponType = String.valueOf(weaponTag.get("weaponType"));

        System.out.println(player.getVelocity());
        GenericRangedWeapon tmp = new GenericRangedWeapon();
        tmp.shoot(player.getLocation());
    }

    /** FCT: function that runs on left click with weapon
     * @param weapon -> item with which the player has executed the action
     * @param player -> the player that executed the action
     * @return void */
    private static void weaponLeftClick(ItemStack weapon, Player player) {

    }
    @EventHandler
    public static void playerInteractWithWeaponEvent(PlayerInteractEvent event) throws ParseException {
        if(event.getAction() == Action.RIGHT_CLICK_AIR) weaponRightClick(event.getItem(), event.getPlayer());
        else if(event.getAction() == Action.LEFT_CLICK_AIR) weaponLeftClick(event.getItem(), event.getPlayer());
    }```
tardy delta
#

printing out the last char of each line, what happens on the empty line lol

wicked ember
flat lark
agile anvil
tender shard
severe oracle
slim wigeon
#

Since I got the deepslate issue fixed, I been driving at 100 mph around GTA SA

flat lark
wicked ember
severe oracle
slim wigeon
#

I know my ways around GTA SA, just like me with programming. I keep repeating this, there are times I needed help but I should have looked in the creative mode

#

DEEPSLATE_SLAB -> DEEPSLATE_TILE_SLAB

agile anvil
young knoll
#

Please don’t identify inventories by name

tender shard
severe oracle
tender shard
#

It will be accurate, as the timer always runs at the start of tick. first, we create a class that can hold two of any, where you can push one object in, and get the previous one out, I called this PairBuffer

    public static class PairBuffer<T> {
        T current;
        T previous;

        public void push(T value) {
            previous = current;
            current = value;
        }

        public T get() {
            return previous;
        }
    }
#

then we need a runnable that keeps track of the velocities in a map<UUID,PairBuffer<Location>> (or use a Vector instead of location, doesnt matter)

    public static class VelocityTracker implements Runnable {

        private final Map<UUID, PairBuffer<Location>> lastLocations = new HashMap<>();

        @Override
        public void run() {
            for (Player player : Bukkit.getOnlinePlayers()) {
                lastLocations.computeIfAbsent(player.getUniqueId(), __ -> new PairBuffer<Location>()).push(player.getLocation());
            }
        }

        public org.bukkit.util.Vector getVelocity(Player player) {
            Location locNow = player.getLocation();
            Location locLast = lastLocations.computeIfAbsent(player.getUniqueId(), __ -> new PairBuffer<Location>()).get();
            if (locLast == null) return new org.bukkit.util.Vector();
            if (!Objects.equals(locNow.getWorld(), locLast.getWorld())) return new org.bukkit.util.Vector();
            org.bukkit.util.Vector velocity = locNow.toVector().subtract(locLast.toVector());
            return velocity;
        }
    }

computeIfAbsent because the return value could be null, ofc

#

and then just use it

    private final VelocityTracker velocityTracker = new VelocityTracker();

    @Override
    public void onEnable() {
        getServer().getScheduler().runTaskTimer(this, velocityTracker, 0, 1);
        getServer().getPluginManager().registerEvents(this, this);
    }

    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        if (event.getHand() != EquipmentSlot.HAND) return;
        player.sendMessage(velocityTracker.getVelocity(player).toString());

    }
#

works for me, and it also doesn't show the gravity that you probably don't want to have

#

value is also always the same if I walk as straight as possible

tall saffron
#

How can i keep them dying till the time elapsed? ```java
package commands;

import chiru.deathconsequences.DeathConsequences;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerRespawnEvent;

import java.util.HashMap;
import java.util.UUID;

public class Death implements Listener {

private HashMap<UUID, Long> deathTime;

public boolean canSpawn;

public Death(DeathConsequences plugin){
    deathTime = new HashMap<>();
}

@EventHandler
public void onDeath(PlayerDeathEvent event){

    Player player = event.getEntity().getPlayer();
    deathTime.put(player.getUniqueId(), System.currentTimeMillis());
    if(deathTime.containsKey(player.getUniqueId())) {

        long timeElapsed = System.currentTimeMillis() - deathTime.get(player.getUniqueId());

        long timeElapsedS = timeElapsed / 1000;

        if(timeElapsedS > 50){

            deathTime.put(player.getUniqueId(), System.currentTimeMillis());

            canSpawn = true;

            player.sendMessage("Respawn!!!");

        }
        else {
            canSpawn = false;
            player.sendMessage("Wait : " + (50-timeElapsedS));
        }

    }

}

@EventHandler
public void onSpawn(PlayerRespawnEvent event){

    if(canSpawn == false){
        event.getPlayer().setHealth(0);
    }

}

}

edgy crystal
#

hey, i am getting this error:

    at java.base/sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:339)
    at java.base/sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:281)
    at java.base/java.util.jar.JarVerifier.processEntry(JarVerifier.java:321)
    at java.base/java.util.jar.JarVerifier.update(JarVerifier.java:234)
    at java.base/java.util.jar.JarFile.initializeVerifier(JarFile.java:763)
    at java.base/java.util.jar.JarFile.getInputStream(JarFile.java:846)
    at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:173)
    at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:144)
    at org.bukkit.craftbukkit.v1_16_R3.CraftServer.loadPlugins(CraftServer.java:381)
    at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:224)
    at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:928)
    at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$0(MinecraftServer.java:273)
    at java.base/java.lang.Thread.run(Thread.java:831)

and these are my dependencies:

#
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.16.5-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.github.NuVotifier</groupId>
            <artifactId>nuvotifier</artifactId>
            <version>2.7.2</version>
        </dependency>
        <dependency>
            <groupId>com.jeff_media</groupId>
            <artifactId>CustomBlockData</artifactId>
            <version>2.2.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20230227</version>
        </dependency>
        <dependency>
            <groupId>net.dv8tion</groupId>
            <artifactId>JDA</artifactId>
            <version>5.0.0-beta.3</version>
        </dependency>
        <dependency>
            <groupId>com.github.theholywaffle</groupId>
            <artifactId>teamspeak3-api</artifactId>
            <version>1.4.0-SNAPSHOT</version>
        </dependency>
    </dependencies>```
edgy crystal
tender shard
#

which plugin are you trying to compile?

edgy crystal
#

the reason is this:

            <groupId>com.github.theholywaffle</groupId>
            <artifactId>teamspeak3-api</artifactId>
            <version>1.4.0-SNAPSHOT</version>
        </dependency>```
#

since i have added this, i am getting this error

tender shard
#

are you shading it?

edgy crystal
undone axleBOT