#development

1 messages ยท Page 59 of 1

minor summit
#

that's kinda cursed, ngl

#

yeah let me just load every single class until i find the one that extends placeholderexpansion

light pendant
#

kinda lol

#

i removed my standalone plugin subproject now, now it only creates an actual PAPI extension

light pendant
#

you know what's funny

#
            // If the last char was an escape, check if the current char is a backtick or an escape
            if (lastWasEscape) {

                // Two escapes in a row are actually two escapes in a row!
                if (current == Parser.ESCAPE) {
                    lastWasEscape = false;
                    builder.append(Parser.ESCAPE);
                    continue;
                } else if (current == Parser.BACKTICK) {
                    lastWasEscape = false;
                    builder.append(Parser.BACKTICK);
                    continue;
                } else if (current == Parser.UNDERSCORE) {
                    if(!inBackticks) {
                        builder.append(Parser.ESCAPE);
                        // Don't continue! I mean, do continue...
                    }
                } else {
                    lastWasEscape = false;
                    builder.append(Parser.ESCAPE);
                    builder.append(current);
                    continue;
                }
            }

Not calling continue means it continues with the code lol

icy shadow
#

Least horrific imperative parser

light pendant
#

oh damn I thought I totally fucked up. Making it able to parse \ in unescaped strings without double escaping the \ char broke 4 tests. Adding a single ! to a condition in the parser fixed it lol. I will never touch this again

atomic trail
#

Which GUI api would you guys recommend? I remember someone in here that developed one but cant find it

spiral prairie
#

triumph gui or @leaden sinew's

atomic trail
#

Ah yeah triumph gui is the one I remember

#

Thanks

#

Ahhhh yeah it was Matt

light pendant
#

there's also InventoryFramework

#

no clue if it's any good though

spiral prairie
#

i used it once, didnt like it more than triumph

forest jay
#

RedLibs is also really good

strange remnant
#

this is my debugger:
[01:21:25 INFO]: [Marry] [STDOUT] Divorce method called for player: OhLqvely
[01:21:25 INFO]: [Marry] [STDOUT] OhLqvely is married.
[01:21:25 INFO]: [Marry] [STDOUT] Partner for OhLqvely: null
[01:21:25 INFO]: [Marry] [STDOUT] Error: Partner is null.
https://paste.helpch.at/pibekuhono.typescript

dusky harness
strange remnant
#

What should I change it into then?

#

@dusky harness

dusky harness
#

but if you want to use names, you can use Bukkit.getOfflinePlayer() (although not recommended)

strange remnant
#

I'm so dumb

#

you are right

#

;s

#

UUID are always better then playernnames

#

and I forgot it

#

I changed it into UUIDs but It still gives me null

torpid raft
#

marriage plugin????

strange remnant
#

yes

#

why?

torpid raft
#

i dabbled in making a marriage plugin a lil while ago

strange remnant
#

and?

torpid raft
#

idk just excited it's a meme in my friend group

#

i took a novel approach where instead of only tracking marriage player pairs, i have a stat called amiability; any two players that are nearby each other have an 'amiability' with each other that changes depending on how they interact

strange remnant
#

I can't get it to work to read my partners to divorce

#

I think my plugin does't like people divorcing

#

Do you have a spigot page on it

torpid raft
#

no it's not a public plugin

#

at least not one with a spigot page

#

the code is open source tho

strange remnant
#

wdym interact

#

Like being in a radius

torpid raft
#

that's one form of interaction

#

it's very broad

#

for me i tracked stuff like if they slept in adjacent beds, ate food at the same time, damaged / killed each other

#

etc

strange remnant
#

Yeah I want to work with a point system if they are near each other if they do the same stuff etc

torpid raft
#

yeah my project does that

#

i think for you tho the foremost thing you should consider is using something like this to track player pairs

static UUID generatePairID(UUID a, UUID b) {

        // upper halves of each uuid
        long ah = a.getMostSignificantBits();
        long bh = b.getMostSignificantBits();

        // lower halves of each uuid
        long al = a.getLeastSignificantBits();
        long bl = b.getLeastSignificantBits();

        // long multiplication conveniently overflows so as to fit perfectly into the result UUID
        return new UUID(al*bl, ah*bh);
    }
#

basically this is a communative way to associate two player ids with a marriage/pair id

#

aka it doesn't care if you mix up the order of players, you still get the same marriage id as a result

#

very powerful because now you won't have to worry about tracking the same data twice or having to use if statements weirdly

dusky harness
#

if you don't have either pair

torpid raft
#

wait wdym either pair

dusky harness
#

without either player

torpid raft
#

so like you only have the marriage id?

dusky harness
#

yea

torpid raft
#

then yeah you need to call a method that looks it up in a map or something

#

but you'd have to do that anyways

spiral prairie
#

that kind of defeats the purpose

torpid raft
#

this just makes the direction of player1, player2 -> marriage better

#

with basically no downside

dense drift
#

Map<UUID, Marriage> with entry for both players xD

torpid raft
#

eepy

#

big reason for doing it the way i have described is if a player can have multiple relations at once

#

which is unavoidable if there's going to be something like amiability between people

dusty frost
#

bro needs a graph database setup

#

facebook connections-style

torpid raft
#

tbh its almost at that level

#

and the moment other people's amiabilities get involved it will be at that level

#

man maybe i should start work on this again

obtuse grove
#

Does anybody know how to disable DamageTicks?
Im trying but im getting nowhere and I just wanna disable it entirely since im using custom plugin guns.

package com.koboyashi.disableiframes.events;

import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent;

public class Disablediframesevents implements Listener {

    @EventHandler
    public static void hitByProjectile(EntityDamageByEntityEvent e) {
        if (e.getEntity() instanceof LivingEntity) {
            LivingEntity damagedEntity = (LivingEntity) e.getEntity();
            //set damage
            damagedEntity.setNoDamageTicks(0);
            damagedEntity.setLastDamage(Integer.MAX_VALUE);

        }
    }
}
hoary scarab
obtuse grove
hoary scarab
#

Yes

obtuse grove
#

Ill try that and see if it works

obtuse grove
# hoary scarab Yes

still not working, I can combo by hitting with my shotgun and then shoot but not all of the pellets get registered, only 1.

#

im not sure but I think its not telling the server to disable the iframes.

package com.koboyashi.disableiframes;
import com.koboyashi.disableiframes.events.Disablediframesevents;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

public class Disablediframes  extends JavaPlugin {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(new Disablediframesevents(), this);
        getServer().getConsoleSender().sendMessage(ChatColor.GREEN + "No IFRAMES is enabled.");


    }

    @Override
    public void onDisable() {
        getServer().getConsoleSender().sendMessage(ChatColor.RED + "No IFRAMES is disabled");
    }

}
hoary scarab
#

Maybe I miss read your initial question. I thought you wanted to disable all damage except your custom damage.

Could you explain what exactly you're trying to do?

obtuse grove
torpid raft
#

i had to do a double take, for a moment i thought you were recommending imgur to fix the iframe issue

obtuse grove
leaden sinew
obtuse grove
hoary scarab
obtuse grove
hoary scarab
#

Oh I think I get what you're saying now. So not all of the pellets are running the event?

torpid raft
#

isnt there a way to set the invincibility duration within the damage event

#

or am i misremembering

proud pebble
obtuse grove
proud pebble
obtuse grove
proud pebble
#

i would assume so, would mean that the internal counter wouldnt beable to tick up

hoary scarab
#

Maybe try -1?

proud pebble
#

tho if that doesnt work, you could calcuate how many projectiles actually hit the entity and just times the damage by the quanity of successfully hit bullets

#

tho id try different values then just 0 like yapperyapps said

#

also else fails the method i suggested moght work well enough

obtuse grove
hoary scarab
#

What do you mean?

obtuse grove
#

going back to like 2008 and 2011

river solstice
#

iFrames ๐Ÿฅด

#

thought you're talking about <iframe>

obtuse grove
river solstice
#

just call them invulnerability frames ๐Ÿซก

icy shadow
#

iframes is a pretty common term

river solstice
#

what is this

proud pebble
river solstice
#

apple?

proud pebble
#

if so glad i pointed you in the right direction

obtuse grove
minor summit
icy shadow
#

what do you mean no

minor summit
obtuse grove
#

one singular problem rises, lava is now just insta killing

torpid raft
#

set invincibility ticks differently for stuff that isnt your bullets

proud pebble
#

since you removed the iframes, you will have to add them back for all other instances

obtuse grove
torpid raft
#

modern problems require modern solutions

obtuse grove
dusky harness
torpid raft
dusky harness
#

Uh

torpid raft
#

lmao

obtuse grove
#

term of endearment

somber gale
#

Is there a way to only apply CSS styling if the element has specific classes and only those?

Like in my case would I like to only apply some formatting if the classes of the element are foo and bar but not f.e. foo, bar and foo-bar

light pendant
#
.foo.bar { ... }
dusky harness
somber gale
#

It does

light pendant
#

oh yeah I misread

dusky harness
#

try this

#

idk how to combine it with two classes but

#

ยฏ_(ใƒ„)_/ยฏ

#

wait

#

yeah

#

.foo.bar:only-of-type

#

right?

somber gale
#

It seems [class="foo bar"] would work too

#

But I'll also try the pseudo class option

somber gale
light pendant
#

Did you find a working solution?

somber gale
fast glade
#

Weird question, (avoiding invisible entities + teams) is it possible to show the item frame floating text (when looking at a named item inside an item frame) but like... when not looking at an item frame

For example (https://prnt.sc/9ZRIrdZi4CHw), I'd like to be able to look at the sign above, and see the floating text, but only when looking at the sign. I don't want to have the item frame below.

I've tried placing an invisible item frame behind the sign, but its not triggered for the player because the sign is in the way.

I know I could spawn a named invisble armor stand, or zombie or whatever whenever a player looks at a sign, and if I only want the player to see the text i could put the player and named entity in the same team and hide other nametags, but I'm trying to avoid this as im using teams for a seperate function.

atomic trail
river solstice
#

no it's not

torpid raft
#

since you're already calling super() which would already do it for you

atomic trail
#

Just not sure how else to access those variables in the child class then

torpid raft
#

you're already accessing them

#

oh i see where the confusion is i think

atomic trail
#

Ohhh it needs protected access right?

torpid raft
#

the variables you have declared in the abstract class carry over to the child class, so even though you don't explicitly redefine them you can still access them

atomic trail
torpid raft
#

that would do it yeah

river solstice
#
  • The access modifiers inside the base class should be protected, not private. You inherit the properties of the main class, so you want to be able to access them.
  • You should avoid using the same variable names for the parent and the child class.
  • You should not override the static fields.
public abstract class ConfigFile {
    protected static final Logger LOGGER = LoggerFactory.getLogger(ConfigFile.class);
    protected final JavaPlugin main;

    protected FileConfiguration config;
    protected File file;

    protected String path;
    protected String fileName;

    public ConfigFile(JavaPlugin main, String path, String fileName) {
        this.path = path;
        this.fileName = fileName;
        this.main = main;
        
        setup();
    }
}

public class KitsConfig extends ConfigFile {
    private final Map<String, Kit> kits = new HashMap<>();

    public KitsConfig(JavaPlugin main, String path) {
        super(main, path, "kits");
    }
}
atomic trail
#

The FileConfiguration shouldn't be static then I assume?

atomic trail
#

Also yeah how should the logger be setup?

royal hedge
river solstice
#

well I'm not sure what's the point of the custom logger, just use Bukkit.getLogger()

sterile hinge
#

first step would probably be not using the bukkit config stuff

royal hedge
#

use the plugin logger

#

not bukkit's logger

river solstice
#

isnt that the same

royal hedge
#

no

river solstice
atomic trail
#

Also I'm just using it to learn rn mostly

torpid raft
royal hedge
#

the loggers are fine though

atomic trail
#

I prefer understanding how it works before using a potential API for the configs

royal hedge
#

it doesnt rly matter if u use a per class logger or ur plugins logger

#

just dont be misleading by logging to someone elses logger

sterile hinge
royal hedge
atomic trail
sterile hinge
#

and then you model your config in code, not weird inheritance things mixed with static state and low level impl details

royal hedge
atomic trail
#

Gotcha

#

Is this the correct way of just using the parent method?

river solstice
#

sure

royal hedge
# sterile hinge jackson, configurate, whatever

honestly i think it's fine, for now at least. they said they're still learning stuff and i'd say that bukkit's configuration api, while not great, is definitely simpler than other ones like the ones you listed that use "fancy" things like reflection and annotations

sterile hinge
atomic trail
#

Is it automatically using the super method?

#

Ig it is

torpid raft
#

are you sure you want the child class methods to be static

atomic trail
#

Oh not the config actually, but the logger yeah I think so

#

Wait yeah it should be static no?

#

Im not sure lol

torpid raft
#

no i meant your getKits() and isKitEnabled(String kit) methods

atomic trail
#

Ohhh

torpid raft
#

like i guess you could make them being static work but it seems a bit scuffed

atomic trail
#

I don't see any reason why not honestly

torpid raft
#

imagine you try to call those methods before the constructor is ever called

#

since they're static that would be allowed, but the member variables are still undefined

#

if they weren't static you wouldn't be able to find yourself in that situation

atomic trail
#

Ahhh yeah that's true, thank you

#

Changing it now

#

I should have a config manager that gives the instances of the config classes though right?

#

Instead of using dependency injection whenever I need one config class

torpid raft
#

if you want you can have probably have one class that holds all the individual config classes yeah

#

idk your exact situation but that seems fine

#

you'd still want to use dependency injection for the manager class tho

#

just because good practice

sterile hinge
#

the setup method should be private

atomic trail
#

Preferably I want this config "util" to work in other projects as well, so I can just copy it over there without much configuration

atomic trail
sterile hinge
#

though loading files in a ctor generally isn't best practice I guess

royal hedge
royal hedge
#

constructor

atomic trail
#

Ah

#

I got told it's better than using a public setup method, can't remember why

sterile hinge
#

I mean, you generally want to separate file loading logic from config data

#

because data should just be data

atomic trail
#

And a constructor should just load data?

river solstice
#

a constructor's responsibility should always be only to initialize the fields and prepare the class to be used (that doesnt mean using any setup/init methods), it should never to any complex operations or loading any data on initialization

sterile hinge
#

so you rather have a separate class that handles the file loading logic and then creates a simple data object

torpid raft
#

woah is that a factory reference

atomic trail
#

But this can't really be extracted from the abstract class?

    public void setup() {
        InputStream stream = this.getClass().getClassLoader().getResourceAsStream(fileName + ".yml");
        if(stream == null) {
            return;
        }

        file = new File(main.getDataFolder(), fileName + ".yml");

        main.saveResource(fileName + ".yml", false);
        config = YamlConfiguration.loadConfiguration(file);
    }

Changed it to public because it's removed from constructor

sterile hinge
#

I mean I'd generally just not use abstract classes whenever possible

atomic trail
#

How come?

sterile hinge
#

inheritance often brings more problems than it solves, composition can often be used instead. You might need to rethink things this way, but often the result is more clear than inheritance

river solstice
#

might I ask why are you using InputStream stream = this.getClass().getClassLoader().getResourceAsStream(fileName + ".yml");?

atomic trail
#

Got it from someone yesterday, in his config class. Not entirely sure why honestly... But the config is loaded now at least

atomic trail
torpid raft
#

that way it works whether it's in the IDE or a jar

royal hedge
torpid raft
#

yeah if i'm running my code from within the IDE

royal hedge
#

so in the cwd?

atomic trail
#

Ohhh I'm not doing that but I'll just keep it if I'll do it in the future

royal hedge
#

getResourceAsStream only works on the class loaders resources

#

which in most cases is the files inside the jar

royal hedge
#

so rather than KitsConfig being a ConfigFile, it would use a ConfigFile

for example, you might define ConfigFile as a concrete class with methods similar to FileConfiguration, and then define KitsConfig to take in a ConfigFile and uses it:

class KitsConfig {
    private final ConfigFile config;
    public KitsConfig(ConfigFile config) { this.config = config; }

    Map<String, Kit> getKits() {
        // TODO: use the config in some way
    }
}
#

this way, if we want, we can swap out the ConfigFile for some other version, like a test double or something else

atomic trail
#

Hmm I see, but I think I still prefer using abstract. Easier to troubleshoot I think but not sure

#

Thanks for explaining it btw, makes sense now

royal hedge
#

even if you don't end up doing that, at the very least i'd recommend sorting out that KitsConfig class

#

the way youre using static is just asking for the class to be misused

#

it's also kind of weird that you're loading the config field by instantiating a class

#

you might wanna look into the basics of oop before diving into some more intermediate things like abstract classes because it doesnt seem like its there

atomic trail
royal hedge
#

looks like you just copy pasted the ConfigFile from M0dii and quick fixed the errors ij gave you

atomic trail
#

Well yeah, it is, but can't see how else it would be

royal hedge
#

yes

#

because you don't know the basics of oop

#

kits is still static. if you understood oop, you would've changed that as well

atomic trail
#

Didn't notice that... I know it shouldn't be static now

#

Where would you recommend I learn oop then? I thought I did but yeah

river solstice
#

I'd recommend college or university

#

๐Ÿ™‚

atomic trail
#

Well yes...

#

Alright nvm

#

I'll just try myself

river solstice
#

sure, there are online courses and what not, though it's not nearly the same as having an entire education course for it

grand island
#

Education Course is not necessary

river solstice
#

I never said it is neccessary

grand island
#

fair

river solstice
#

but from personal experience, my work colleague never went to a college or university and instead went the 'online course' route and now he's struggling with basic concepts

#

online learning will only get you so far, though usually depends how much effort you put in (of course that applies to education too)

torpid raft
#

ngl my friends who went through uni with me also struggled with basic concepts up until the very end

#

imo biggest factor is just sincerity

atomic trail
#

One last question and I'll leave you be. If I have a manager class to dispute the config instances, how should that be done? I guess this would be bad lol

private static final Map<String, ConfigFile> configFiles = new HashMap<>();

    public static ConfigFile getConfig(String configName) {
        if(instance == null) {
            LOGGER.error("Method cannot be called before class is initialized");
            return null;
        }
        return configFiles.get(configName);
    }

The null check to make sure the manager is actually instantiated

river solstice
#

yeah, I know some people too that went to uni with me that didn't do good in programming

#

and that's usually because the person is not, let's say, 'meant' for it

grand island
#

Ig idk

torpid raft
river solstice
river solstice
grand island
river solstice
#

why not

grand island
#

Like call it a ConfigRegistry or more valueable name and youre done

river solstice
#

though it really depends on your overall implementation

atomic trail
#

Wait no I wouldn't, thanks

royal hedge
atomic trail
#

Any recommended guides for it?

river solstice
#

a lot can be recommended

grand island
#

You gotta understand the benenfits it gives you

atomic trail
#

Also is this alright then?

private static final Map<ConfigRegistry, ConfigFile> configFiles = new HashMap<>();

    public static ConfigFile getConfig(String configName) {
        if(instance == null) {
            LOGGER.error("Method cannot be called before class is initialized");
            return null;
        }
        return configFiles.get(ConfigRegistry.valueOf(configName));
    }

    public enum ConfigRegistry {
        KITS
    }
#

Wait

grand island
#

nah thats not what I meant

atomic trail
#

But other than that

#

Oh

river solstice
#

just google and see what works for you

royal hedge
atomic trail
torpid raft
atomic trail
#

Before you guys told me to seperate data and logic from constructor, but I don't see how that would be possible without making things worse here.

    private ConfigManager() {
        main = BossEvents.getInstance();
        config = main.getConfig();
        
        instantiate();
    }

    private void instantiate() {
        setupConfig();

        new BukkitRunnable() {
            @Override
            public void run() {
                saveConfig();
            }
        }.runTaskTimerAsynchronously(main, getInt("config-save-interval") * 20L * 60L, getInt("config-save-interval") * 20L * 60L);
    }

    public static ConfigManager getInstance() {
        if(instance == null) {
            instance = new ConfigManager();
        }
        return instance;
    }

I setup the instance in the main class like this configManager = ConfigManager.getInstance();

#

This way only getInstance() has to be static

river solstice
# atomic trail Also is this alright then? ```java private static final Map<ConfigRegistry, Conf...
public enum ConfigType {
  MAIN("config.yml"),
  KITS("kits.yml");
  
  // + Getter
  private String fileName;

  ConfigType(String name) {
    this.fileName = name;
  }
}

public class ConfigManager {
  private static final Map<ConfigType, ConfigFile> configFiles = new HashMap<>();

  public static ConfigFile getConfig(ConfigType cfg) {
    if(instance == null) {
       // This shouldn't happen and there's an issue with the code. Though not sure why you need to check if the instance is null here. Consider only checking the return of the method, because the instance can be not null but the returned ConfigFile can be null too.
       return null;
    }

    return configFiles.get(cfg);
  }
}

consider this.

#

of course this is just a rough idea what you can do, it really depends on your whole implementation.

atomic trail
river solstice
#

static access has nothing to do with class being instantiated

atomic trail
#

Oh yeah because the map is static anyway, mb

river solstice
#

if all your public methods in the manager are static, you will only access it by class name ConfigManager.blah()

sudden sand
#

Guys it me or on runTaskTimerAsync is creating another thread at each executions ? ๐Ÿง

hoary scarab
#

It should

sudden sand
#

Like a single async thread

hoary scarab
#

In terms of minecraft, yes. In terms of optimization, no

torpid raft
#

i figured it'd be using a thread pool of some sort

hoary scarab
#

Pretty sure it does

sudden sand
torpid raft
#

yeah in that case it's not like every execution makes its own thread

sudden sand
#

is that logic or is there some better way ?

torpid raft
#

but also no guarantees that only one specific async thread will forever be used

sterile hinge
#

uh oh but running things async isn't automatically safe to do

sudden sand
hoary scarab
sudden sand
hoary scarab
#

If the scheduler isn't working how you want atleast.

hoary scarab
sudden sand
#

I mean creating a thread pool executor servcice and stuff

#

Yes

#

Ok thank you

sterile hinge
sudden sand
hoary scarab
sudden sand
#

I'm an experience developer don't worry

sudden sand
#

Let me repeat once more, I don't know about how the bukkit async work

#

I thought it would keep one thread per async timer

#

(What seemed logic to me)

sterile hinge
#

there are docs which tell you what you can rely on, everything that isn't written down, you can't rely on

nimble vale
#

hey there i achieved to run this in IDE but not working outside it thonking

fun onEachResource(path: String, action: (File) -> Unit) {

    fun resourceToFile(path: String): File {
        val resource = object {}.javaClass.getResource(path)
        return File(checkNotNull(resource) { "Path not found: '$path'" }.file)
    }

    with(resourceToFile(path)) {
        this.walk().forEach { file -> action(file) }
    }
}

onEachResource("templates/paper") // folder is in my main/resources folder
sterile hinge
#

one thread per async timer would be a huge waste of resources

sudden sand
#

At least that's why the answers I got told me

#

You might also check this, not very well documented that's the first place I went to

sterile hinge
sudden sand
#

Nvm thanks for your help

nimble vale
sterile hinge
#

don't use the File api is a good start

nimble vale
#

i need to loop through folders and files i couldnt figure out streams in this situation

hoary scarab
#

Pretty sure getResource() is an InputStream right?

nimble vale
#

yeah

#

no

#

getResourceStream i guess

hoary scarab
#

Ah

nimble vale
#

getResource returns URL

#

there is getResourceAsStream

#

but as i said couldnt figured out looping files with it

sterile hinge
#

if you want to loop through files, you should open the the jar as a zipfs

#

resources of classloaders are more general and not limited to local file systems

nimble vale
#

whats zipfs

hoary scarab
#

Treat it like a zip file

nimble vale
#

are we talking about ZipInputStream

#

or something else

sterile hinge
#

fs=filesystem

nimble vale
#
FileSystems.newFileSystem(resource.toURI(), emptyMap<String, String>()).use { fs ->
            Files.walk(fs.getPath(path))
                .forEach { file -> println(file.toUri().toString()) }
        }
#

i have tried something like this

#

is this the right direction

sterile hinge
#

yeah

nimble vale
#
Files.walk(pathInJar)
                .filter { Files.isRegularFile(it) }
                .forEach { path ->
                    println("File in JAR: ${path.fileName}")
                    action(path.toFile())
                }
#

paths are seems to be correct

#

but toFile not working obviously so how am i going to read, copy these files

minor summit
#

make sure to .use the steam returned by Files.walk

minor summit
icy shadow
#

nio my beloved

flat coyote
#

hey

#

i tried adding papi as a expansion but the placeholders dont work

#

i did everything like shown in the wiki

#

can someone help me if so dm me

#

or write here

river solstice
#

if you did everything right then it should work

flat coyote
#

import org.bukkit.OfflinePlayer;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;

public class MyExpansion extends PlaceholderExpansion {

private final SwordFFA plugin;

public MyExpansion  (SwordFFA plugin) {
    this.plugin = plugin;
}

@Override
public String getAuthor() {
    return "someauthor";
}

@Override
public String getIdentifier() {
    return "example";
}

@Override
public String getVersion() {
    return "1.0.0";
}

@Override
public boolean persist() {
    return true; // This is required or else PlaceholderAPI will unregister the Expansion on reload
}

@Override
public String onRequest(OfflinePlayer player, String params) {
    if(params.equalsIgnoreCase("placeholder1")){
        return plugin.getConfig().getString("placeholders.placeholder1", "default1");
    }

    if(params.equalsIgnoreCase("placeholder2")) {
        return plugin.getConfig().getString("placeholders.placeholder2", "default2");
    }

    return null; // Placeholder is unknown by the Expansion
}

}

public void onEnable() {
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new MyExpansion(this).register();
}
}

Not Even this works

river solstice
#

?codeblocks

neat pierBOT
#
FAQ Answer:

Use codeblocks for formatting code or configuration files:
```<language name>
<your code here>
```

For example:
```yaml
test:

  • โ€œhiโ€
  • โ€œthereโ€
    ```

Produces:

test:
- โ€œhiโ€
- โ€œthereโ€```
flat coyote
#

please help:

import org.bukkit.OfflinePlayer;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;

public class MyExpansion extends PlaceholderExpansion {

private final SwordFFA plugin;

public MyExpansion  (SwordFFA plugin) {
    this.plugin = plugin;
}

@Override
public String getAuthor() {
    return "someauthor";
}

@Override
public String getIdentifier() {
    return "example";
}

@Override
public String getVersion() {
    return "1.0.0";
}

@Override
public boolean persist() {
    return true; // This is required or else PlaceholderAPI will unregister the Expansion on reload
}

@Override
public String onRequest(OfflinePlayer player, String params) {
    if(params.equalsIgnoreCase("placeholder1")){
        return plugin.getConfig().getString("placeholders.placeholder1", "default1");
    }

    if(params.equalsIgnoreCase("placeholder2")) {
        return plugin.getConfig().getString("placeholders.placeholder2", "default2");
    }

    return null; // Placeholder is unknown by the Expansion
}

}

public void onEnable() {
if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new MyExpansion(this).register();
}
}

Not Even this works

light pendant
#

does getPlugin("PlaceholderAPI") maybe return null? which placeholder did you try exactly? did you try with /papi parse? Does your expansion show up in /papi list?

flat coyote
#

yes i tried papi parse

#

both dont work

light pendant
#

Does your expansion show up in /papi list?

flat coyote
#

nope

light pendant
#

did you add PlaceholderAPI as depend or softdepend in plugin.yml?

flat coyote
#

yes

light pendant
#

then add some System.out.println("registered") or something into the if block in onEnable

#

check if it actually registers it

flat coyote
#

alright

light pendant
#

are you sure you didn't get any console errors?

river solstice
#

is it an expansion or is it inside another plugin

flat coyote
#

its for my plugin

river solstice
#

did you register it

flat coyote
#

depend:

  • PlaceholderAPI thats in my plugin.yml
#

its formatted weird

flat coyote
#

if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new MyExpansion(this).register();
} you mean this?

light pendant
#

does getPlugin("PlaceholderAPI") maybe return null?
add some System.out.println("registered") or something into the if block in onEnable

#

are you sure you didn't get any console errors?

flat coyote
#

like this?

#

if(Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
new MyExpansion(this).register();
}else{
getLogger().info("null");
}

light pendant
#

yes

flat coyote
#

no errors yes

light pendant
#

also did you maybe accidentally shade PlaceholderAPI into your plugin?

#

show your pom.xml / build.gradle(.kts)

torpid raft
#

FERDI long time no see

#

```java
put code here like this so that it looks better
```

#
System.out.println("tada");
#

also if you're wondering yes we have never met before

flat coyote
#
    id 'java'
}

group = 'org.srino'
version = '1.19.4'

repositories {
    mavenCentral()
    maven {
        name = "papermc-repo"
        url = "https://repo.papermc.io/repository/maven-public/"
    }
    maven {
        name = "sonatype"
        url = "https://oss.sonatype.org/content/groups/public/"
    }
    maven {
        url = 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
    }
}

dependencies {
    compileOnly "io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT"
    compileOnly 'me.clip:placeholderapi:2.11.3'
}

def targetJavaVersion = 17
java {
    def javaVersion = JavaVersion.toVersion(targetJavaVersion)
    sourceCompatibility = javaVersion
    targetCompatibility = javaVersion
    if (JavaVersion.current() < javaVersion) {
        toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
    }
}

tasks.withType(JavaCompile).configureEach {
    if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
        options.release = targetJavaVersion
    }
}

processResources {
    def props = [version: version]
    inputs.properties props
    filteringCharset 'UTF-8'
    filesMatching('plugin.yml') {
        expand props
    }
}

flat coyote
light pendant
#

Also add a System.out in case the plugin is not null

icy shadow
#

also double check the logs (go right to the start) to make sure there are zero errors

#

it might be that something didnt load properly

#

right at the start

light pendant
#

Yeah does your plugin even show up in /plugins ?

flat coyote
#

yup

flat coyote
#

so its not null

light pendant
#

You shall print sth out in both the if and the else part

light pendant
flat coyote
#

idk i didnt do anything there lol

flat coyote
#

but its not printing anythin

light pendant
#

that's why I asked you three times already to add more debug outputs

    @Override
    public void onEnable() {
        getLogger().info("Trying to hook into PAPI...");
        if (getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
            getLogger().info("PAPI is installed, registering expansions...");
            new MyExpansion(this).register();
        } else {
            getLogger().warning("PAPI is not installed, not registering expansions.");
        }
    }
#

if this still doesn't print anything, you simply are not using the correct .jar in your plugins folder

#

this MUST print something

flat coyote
#

1s

#

I GOT IT

#

lets goooo

light pendant
#

What was the issue?

flat coyote
#

i was dumb lol

#

i was using a jar from another folder that was simply called the same

#

๐Ÿ˜ฌ

light pendant
#

Yeah thats what i figured lol

flat coyote
#

im so sorry for wasting your time

icy shadow
#

classic

#

all good

light pendant
#

No problem lol

flat coyote
light pendant
#

Happened to everyone once

flat coyote
#

it will never hapenn again xD

acoustic plank
#

Which plugin dependencies does voteparty need? help please

flat coyote
#

nuVotifier or smth i think

river solstice
light pendant
#

๐Ÿฅฒ

#

Ah its IntelliJ mcdev plugin that adds this weird stuff

#

I wonder why it doesnโ€™t just always set a toolchain

thin tendon
#

I did find asNMSCopy tho

#

or asBukkitCopy

dawn viper
#

yeah those

#

the first one turns Bukkit's ItemStack into a NMS one, and asBukkitCopy does the other way around

thin tendon
#

ahhhh

#

seems like I have to use asBukkitCopy actually

#

hmm, would this work? java List<ItemStack> stacks = new ArrayList<>(); classImplementation.createInventory(stacks); stacks.stream().map(CraftItemStack::asBukkitCopy).forEach(stack -> { player.getInventory().clear(); player.getInventory().addItem(stack); });

river solstice
#

I love the 'would/will this work?' questions

#

how about you try and find out? ยฏ_(ใƒ„)_/ยฏ

thin tendon
#

I know I need to test it ๐Ÿ˜„

#

but it's a lot of work just to build it and then put it on my server and then start it ๐Ÿ˜„

river solstice
#

what's the point of clearing the inventory on each iteration and then adding the item

thin tendon
#

it's for a sorta kit command, it replaces your inventory with spesific items

river solstice
#

so if there's 10 items in the list, you:

  • clear the inventory
  • add first item
  • clear the inventory
  • add second item
    ...
  • clear the inventory
  • add tenth item
    ?
atomic trail
icy shadow
#

maybe not slower but definitely worse

#

there are a lot of meta quirks for all the different items which require a lot of effort to fully cover

atomic trail
#

But if I don't use those, will it not then be faster?

icy shadow
#

i really dont think it's going to make any noticeable difference

#

even if it does, premature optimisation is bad

#

premature micro-optimisation is even worse

light pendant
#

This ^

#

Spending 30 minutes on useless code to save 7ns on startup is pointless

icy shadow
#

^^

thin tendon
#

right?

torpid raft
#

looks better yea

#

if you're gonna use the :: stuff i bet you can do something like

stacks.stream().map(CraftItemStack::asBukkitCopy).forEach(player.getInventory()::addItem);

and really smoosh it into a one liner

thin tendon
#

ye, ended up doing that

#

this was originally from one of the things suggested for beginners

#

but I'm just expanding upon it just for fun

light pendant
#

how do you people call your unused lambda params? I've seen __, TypeName, sometimes "unused", etc

    public NamespacedKey getKey(final String key) {
        return keys.computeIfAbsent(key, String -> new NamespacedKey(plugin, key));
    }
river solstice
#

__ works

icy shadow
#

_ is preferable but thats not possible (yet)

#

but yeah multiple underscores is good

torpid raft
#

you can call it hole

#

since that's what the _ is called i think

icy shadow
#

or of course you make a full lambda util class with curry & const functions to write it in a point-free style

icy shadow
river solstice
#

usually people call it

  • $
  • __
  • unused
    or just ignore it by keeping the default name
icy shadow
#

linters dont like $ usually

river solstice
#

true that

torpid raft
#

i personally use e

#

for throwaway stuff

light pendant
#

a book I read suggests to use the class names, e.g.
(String, Integer) -> ...

#

but that looks horrible lol

icy shadow
#

yeah thats not nice

torpid raft
#

does that even work in java?

#

that doesn't seem like it would be valid code but i guess i've never tried it or looked into it

#

oh wow it totally works

light pendant
#

yes sure, you can also do String String = "this var's name is cursed";

#

speciรคlรŸymbรถls are also valid

#

I've seen people use russian or turkish variable and method names ๐Ÿ’€

marble heart
sterile hinge
#

var String = "Hello World"

light pendant
#

is the dev-general channel gone or however it was called

torpid raft
#

this is kinda mind blowing to me

river solstice
#

only primitives are

torpid raft
#

mandela effect hitting me hard

#

actually i dont think i used that right nvm

icy shadow
#

Theyโ€™re reserved in real languages

river solstice
#

java isn't real

#

it's an illusion

light pendant
#

does anyone know why PlayerEditBookEvent#getSlot() is deprecated?

green hound
atomic trail
#

What is the general naming convention for yaml files?

icy shadow
#

there isnt one

#

but i guess snake-case, if thats what you're asking

dark garnet
#

yeah its typically snake

atomic trail
#

Also for the file names?

dark garnet
#

yeah

atomic trail
#

I thought that was just the variable names but ig it makes sense

dark garnet
#

well as BM said there rly isnt one but ppl just use snake

atomic trail
#

Gotcha, thanks

nimble vale
#

thanks for the help

light pendant
light pendant
clever relic
#

Folks, I am trying to find an API that allows you to input lon and lat and then returns the region. For example:

If I inputted: 48.8584ยฐ N, 2.2945ยฐ E it would return Europe

clever relic
river solstice
#

aka openstreetmap, it has an api, totally free of use

light pendant
#

well it outputs a country, not the continent

#

but it doesnt require any online stuff, so maybe it'd be worth it if you'd just create a map for country<>continent

clever relic
light pendant
#

oh alright

#

the lib I linked just uses a grayscale map, kinda smart lol

hazy nimbus
#

Like

#

Really really long

dusky harness
#

without any IO too

#

btw hows this even work

hazy nimbus
#

Prolly a hardcoded list of countries and their borders

proven carbon
dusky harness
atomic trail
#

Is it possible to get which config file a placeholder was called? Or the configurationsection

I've got a kit / class setup where one class has one config file. And I want to check if a player has access using a placeholder. The expansion is setup for this, but I'm unsure how to get the kit / class name (just the file name or a string in the file)

    @Override
    public String onRequest(OfflinePlayer player, String params) {
        if(params.equalsIgnoreCase("unlocked")){
            return KitManager.getBePlayer(player.getPlayer()).ownsKit();
        }

        return null; // Placeholder is unknown by the Expansion
    }
sterile hinge
#

not sure what that means

atomic trail
# sterile hinge not sure what that means

So in this lore

  lore:
    - A kit made for testing purposes
    - "&bThis kit will be removed"
    - ""
    - "%player_unlocked%"

The placeholder should show either "UNLOCKED" or "LOCKED", based on if the player has the kit unlocked or not

#

I hope that explains it better

river solstice
#

everything is possible

#

it's not rocket science

#

you just have to have sufficient knowledge how to do it ๐Ÿ™‚

atomic trail
#

Yeahh lol but where does the placeholder get the file or section it has been used in?

#

Oh is it just this.getConfigSection("");?

#

It's apparently a thing in the expansion

river solstice
#

onRequest will never know where it was called from, more specifically how do you thinl it will know that it exists in a file that is exactly in your filesystem

#

everything is loaded into memory, from that point there's no trace that placeholderapi parsed the placeholder that is in your config file

atomic trail
#

You said it was possible though?

river solstice
#

didn't read into question enough, but why would you even need to do that

sterile hinge
#

sounds like your structure is insufficient to solve your problem

atomic trail
#

I know I can change the placeholder for every kit but that seems a bit weird

#

Might be the best solution though

atomic trail
#

Nvm found a better solution

light pendant
#

let me spin up JMH and test whether it's true lol

sterile hinge
#

It loads an image each time, so not really surprising

light pendant
#

in my tests, it took 12ms on average

#

does it not keep the image loaded or sth lol

#

weird

sterile hinge
#

no

#

look at the code

light pendant
#

too lazy, I believe you that it is like you say lol

dusky harness
#

No I mean what command r u using to test

#

Or code

#

Of what the placeholder outputs

proven carbon
#

Im putting it into a luckperms rank right now. I've tested and its worked with non relational placeholders

dusky harness
#

Can you try /papi parserel?

proven carbon
#

Hm that works

#

I'll have to test this more later. I have to go to school.

clever relic
iron sparrow
#

Anyone can help me?

still cosmos
#

help me

#

plz

#

my plugin does not see the brewing stand

green hound
#

code?

#

and what's current and expected behavior (specifically, not just "does not see brewing stand")

green hound
#

provide code in text, not screen

#

?paste

neat pierBOT
#
FAQ Answer:

Paste Services
When asking for help with a config/menu/code issue please use our paste bin:
(we prefer it over pastebin.com)
โ€ข HelpChat Paste - How To Use

still cosmos
#

there are no errors in the console

#

wtf

pulsar ferry
still cosmos
#

no

#

I need help, the plugin is not working

still cosmos
pulsar ferry
#

Oh

#

Then send code not config lol

green hound
still cosmos
#

only brewing stand

green hound
#

try brewing_stand_item in caps

still cosmos
#

wait

#

no

#

dont work

dusky harness
#

Also wdym it can't "see"

#

?help

neat pierBOT
#
FAQ Answer:
ยป Give the helpers some details
ยป Ask suitable questions
ยป Be polite
ยป Wait

Source

dusky harness
#

We helped the most we were able to - without code, errors, etc we can't help more

#

If this is DeluxeMenus help, this is not the right channel @still cosmos

#

As Matt mentioned above

#

#coding-help ๐Ÿ˜”

sonic nebula
#

i work on an region system and i want to hear some opinions on my optimization ill write quick code so u get the way it works

#
@eventhandler
public void BPE(BlockPlaceEvent event){
    Chunk chunk = new Chunk.getFromLocation(event.getLocation);
if (this.plugin.RegionManager.chunks.contains(chunk) {
  //todo if chunk exists in the memory chunks are only stored in the map only if some modifcation was done to it
}
#

maybe ill get chunk in string value and check if it exists in the map as a string

#

instead of getting the object

dusky harness
#

but besides that it's just an if statement so idk how else you'd optimize it

#

ยฏ_(ใƒ„)_/ยฏ

sonic nebula
#

chunk is basically x y z w in different value like 100 = 1 and everything shorter so if there region from 33-10 in x crossing it it will return true

#

i mean instead of everytime looping thru all effected blocks and etc

#

because regions can be in different shapes and from A-B

dusky harness
#

chunks are only x and z

sonic nebula
#

i dont use game chunks...

dusky harness
#

oh

sonic nebula
#

lemme copy line from my object

#

the toString

sterile hinge
#

why would you call it chunks then

#

also what is that code style

sonic nebula
#
    public static HashMap<String,List<Region>> Chunks = new HashMap<>();

    public static String getChunkIDFromLocation(int X,int Z,int Y) {
        int x = X / 100;
        int z = Z / 100;
        int y = Y / 100;
        return ("CHUNK{" + x + "," + z + "," + y + "}");
    }
#

here changed it to string

#

i dont think i need an object

#

maybe ill make it into a smaller number

#

like 20 or so

#

so when adding new region it will register the chunk to system so later it will load into server memory for quick accses instead of expensive disk operations often

#

how ever if i stick to regions it will be heavy shit why? because regions dont have an spesfic shape it can be in a shape of a cat or a unicorn for example not just an sphere or cube

sonic nebula
#

instead of having to browse everytime all existing regions i try to achieve just browsing thru regions that exist in the chunk to make it more efficent

#

can u think of something better?

still thicket
#

I created a custom Unicode that is pretty big to make a custom GUI, its not in the right spot tho. Its like 3-4 pixels to the left. I googled how to fix this, and couldnt find much. I found this post that explains they did it with a width of -10, but I dont understand what they changed to make that happen. Could anyone Help? https://www.spigotmc.org/threads/advanced-resourcepack-mechanics-how-to-create-custom-items-blocks-guis-and-more.520187/
https://cdn.discordapp.com/attachments/1143588884341588091/1146520851131408586/2023-08-30_15.04.20.png

sterile hinge
#

well I wouldn't overload names with different meanings

sonic nebula
sterile hinge
#

also not sure why you're using strings there

#

and also not sure why you're having static mutable state there

sonic nebula
#

to be able to accses from everywhere

#

its not an utility

#

and i do DI

sterile hinge
#

that's not how DI works

sonic nebula
#

ik how DI works

#

u cant use static with DI

sterile hinge
#

and also not sure why you'd choose fixed size that isn't a power of 2

sonic nebula
#

wdym?

sterile hinge
#

there is a reason why chunks are 16 blocks wide

sonic nebula
#

never really digged into it its not meant to be minecraft chunks

#

i just did it to split things up

#

first thing came to my head on how to call it lol

sterile hinge
#

division by something that isn't a power of 2 always requires more cpu resources

sonic nebula
#

cant really get it

#

power of 2?

dusky harness
#

ohh so thats why mc uses 16 wide chunks

dusky harness
sonic nebula
#

oh

#

fuck

#

then imma change math formula

#

so it always return numbers by 2

#

hold my beer

dusky harness
#

but the performance different is extreeeeeeemely small (compared to the rest of the program) so its not a big thing

sonic nebula
#
public static String getChunkIDFromLocation(int X, int Z, int Y) {
    int x = X / 100;
    int z = Z / 100;
    int y = Y / 100;
    
    x = thepowerof2(x);
    z = thepowerof2(z);
    y = thepowerof2(y);
    
    return ("CHUNK{" + x + "," + z + "," + y + "}");
}
public static int thepowerof2(int two) {
    if (two % 2 != 0) {
        two--;
    }
    return two;
}
#

i think it should work

#

it always will be diviison of 2 now

#

or it must be x2 each time?

#

then it makes the whole concept pretty useless of that chunk system

dusky harness
#

uhhhhhhhhhhhhh

neat pierBOT
#
<:discord:699228850537889854> - HelpChat Stats

Here are some guild wide stats for your eyeballs. :eyes:

XP Generated:

xp32,421,670

Level Ups:

levelups 34,460

Pastes Created:

pastes undefined

Commands Ran:

commands 191,441

Images Generated:

images 118,198

Words Scrambled:

words 89,980

Total Messages:

messages 5,861,574+

Guild Members:

members 15,765

Date Created:

calendar Mar 29 2016

iron sparrow
sonic nebula
#

wrong chat

iron sparrow
#

can you see my code?

sonic nebula
#

please delete ur messages its related to general plugins its the devolopers chat and what error said show me again

#

ill tell u whats wrong show me error stacktrace from console

sterile hinge
#

power of 2 != divisible by 2, e.g. 6 is divisible by 2 but not a power of 2

sonic nebula
#

so its 2 4 8 16

sterile hinge
#

powers of 2 have exactly one bit set in their binary representation

#

that's why it works nice with bitwise instructions like shifting, and, or, xor, not

sonic nebula
#

i see

#

make sense

#

nah not gonna loop over it

#

stupid idea

#

hm ill think

#

on how to sort it better

sterile hinge
#

you can also consider using a data structure like PRtrees or whatever, not sure if that helps you

sonic nebula
#

not familiar with PRtrees

#

its just what of i thinked would work good

#

lemme see PRtrees

#

not sure how it works but simillar concept of splitting into many groups in groups

#

nah Duck i think im way too dumb at the moment to be able to understand the concept of PRtrees but thanks alot for the advice

sterile hinge
#

or build a quadtree/octtree yourself, that's pretty simple

strange remnant
#

https://paste.helpch.at/ejatopecef.java
https://paste.helpch.at/uqozudesox.yaml

The code works I can marry someone and it will store in the config BUT I can't get it to work to divorce I really can't i also tried with you @dusky harness even with the line of code you used I now added UUID'S because with the playernames it also doesn't work so I transfered to UUID'S I really don't know how to get it to work I tried everything please help me.

strange remnant
#

I had a debugger on the code and it probably will return my partners to null

fading stag
#

so then which part of your code is not working?

strange remnant
#

Divorcing

#

Probably reading the UUID to know that is my partner

torpid raft
#

why does this only remove one of the two players' marriage entries

 private static void removeMarriage(UUID player1UUID, UUID player2UUID) {
        ConfigurationSection marriagesSection = marriageDataConfig.getConfigurationSection("marriages");
        if (marriagesSection != null) {
            marriagesSection.set(player1UUID.toString(), null);

            saveMarriageConfig();
        }
    }

shouldn't you be setting both player 1 and player 2 to null if your config looks like this?

marriages:
  9ee31426-8ec8-4f4e-969f-2c8c6c0350cc: efe046ed-15a6-420a-b503-8506c58955ef
  efe046ed-15a6-420a-b503-8506c58955ef: 9ee31426-8ec8-4f4e-969f-2c8c6c0350cc
strange remnant
#

Yes probably yes

#
    ConfigurationSection marriagesSection = marriageDataConfig.getConfigurationSection("marriages");
    if (marriagesSection != null) {
        marriagesSection.set(player1UUID.toString(), null);
        marriagesSection.set(player2UUID.toString(), null);

        saveMarriageConfig();
    }
}```


?
torpid raft
#

```
put your code in a block like this
```

strange remnant
#

I did

torpid raft
#

you can also specify what language you are using like so

```java
code code code
```

strange remnant
#

I can't send screenshots

neat pierBOT
torpid raft
#

what are you sending screenshots for

strange remnant
#

When I run /marry divorce it will say i'm not married

torpid raft
#

like @fading stag says you should try debugging your code to try to sniff out exactly where it goes wrong

strange remnant
#

I will it will say what I said it wait a second ok

#

[21:05:01 INFO]: [Marry] [STDOUT] Divorce: Starting divorce process for player OhLqvely (9ee31426-8ec8-4f4e-969f-2c8c6c0350cc)
[21:05:01 WARN]: Nag author(s): '[Ohlqvely]' of 'Marry v1.1' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
[21:05:01 INFO]: [Marry] [STDOUT] Divorce: Player OhLqvely (9ee31426-8ec8-4f4e-969f-2c8c6c0350cc) is not married.

torpid raft
#

doesn't really tell you much

strange remnant
#

What do you want to know

#

What part should I also debugg

torpid raft
#

what do you want to know

strange remnant
#

It just doesn't know who I'm married too

#

How I will fix that It knows I'm married to a person so it can divorce because It doesn't seem to know I'm married

torpid raft
#

this is going to be a common occurence, you should try to internalize what the process is for cases like this

#

i'd recommend adding a ton of print statements to see exactly what your flow of execution is

#

as well as why it is happening at every junction

#

that way you can see exactly where things go wrong and why

strange remnant
#
public static void divorce(Player player) {
    UUID playerUUID = player.getUniqueId();
    System.out.println("Divorce: Starting divorce process for player " + player.getName() + " (" + playerUUID + ")");

    if (isMarried(playerUUID)) {
        System.out.println("Divorce: Player " + player.getName() + " (" + playerUUID + ") is married.");
        
        String partnerUUID = getMarriagePartner(playerUUID);

        if (partnerUUID != null && !partnerUUID.isEmpty()) {
            System.out.println("Divorce: Player " + player.getName() + " (" + playerUUID + ") has partner UUID " + partnerUUID);
            
            UUID partnerPlayerUUID = UUID.fromString(partnerUUID);
            
            removeMarriage(playerUUID, partnerPlayerUUID);
            player.sendMessage("You have divorced your partner.");
            System.out.println("Divorce: Player " + player.getName() + " (" + playerUUID + ") has successfully divorced partner " +
                    Bukkit.getOfflinePlayer(partnerPlayerUUID).getName() + " (" + partnerPlayerUUID + ")");
        } else {
            player.sendMessage("An error occurred while processing the divorce (No partner UUID).");
            System.out.println("Divorce: An error occurred while processing the divorce for player " + player.getName() + " (" + playerUUID + ")");
        }
    } else {
        player.sendMessage("You are not married.");
        System.out.println("Divorce: Player " + player.getName() + " (" + playerUUID + ") is not married.");
    }
}````
torpid raft
#

ok

strange remnant
#

do you see anything that could be wrong

#

because I canโ€™t find a fix i know what the problem is

torpid raft
#

what gets printed when you run the code

strange remnant
#
[21:05:01 WARN]: Nag author(s): '[Ohlqvely]' of 'Marry v1.1' about their usage of System.out/err.print. Please use your plugin's logger instead (JavaPlugin#getLogger).
[21:05:01 INFO]: [Marry] [STDOUT] Divorce: Player OhLqvely (9ee31426-8ec8-4f4e-969f-2c8c6c0350cc) is not married. ```
#

it doesnโ€™t recognise that iโ€™m married

torpid raft
#

okay so what can you tell about your flow of execution from that output

#

where does everything go wrong, which if statement

strange remnant
#

else

torpid raft
#

else doesn't run any logic

#

so it will never be else's fault

#

what is the if statement that returns false for the else to be run

strange remnant
#

if (partnerUUID != null && !partnerUUID.isEmpty()) {

torpid raft
#

no

#

that if statement is actually never even reached

#

if it was, you would see the print statement System.out.println("Divorce: Player " + player.getName() + " (" + playerUUID + ") is married."); in the console

strange remnant
#

but do you already know the solution

torpid raft
#

vaguely

strange remnant
#

so what do you think

torpid raft
#

i think you gotta figure at least this much out on your own ๐Ÿ˜ญ๐Ÿ˜ญ๐Ÿ˜ญ

torpid raft
#

which if statement is the lead to that else block

strange remnant
#

Bukkit.getOfflinePlayer(partnerPlayerUUID).getName() + " (" + partnerPlayerUUID + ")");

#

or is it the first 1

#

the first 1: if (isMarried(playerUUID)) {

torpid raft
#

this is the first (and only) if statement that you can clearly see not giving you what you want

#

so dig deeper and figure out why

strange remnant
#

because probably my ismarried is broken

#

but how can i retrieve that from the config

torpid raft
#

repeat your process

#

add a bunch of print statements to the isMarried method

#

and see whereverything goes wrong

strange remnant
#

tbh iโ€™m not on my pc anymore.

#

gotta sleep i have work in the morning

#

but i will use this advice tomorrow

#

so probably my ismarried is broken and i will have to fix that

torpid raft
#

ye

strange remnant
#

thank you

torpid raft
#

ofc anytime

minor summit
#

okay, now add support for polygamy suffoKappa

past crystal
#

Does anyone have experience with minecraft server development i am making a upcoming server and need people to configure plugins and maybe make a custom one i may be able to provide a custom role or opportunity to become admin if you help

dusky harness
past crystal
dusky harness
#

oh

#

do you see it now

past crystal
#

yeah thanks

orchid niche
#

Hey I'm trying to set the player as glowing through packets using protcol lib, and I'm getting this error with this code.

    private fun setTeamGlowForPlayer(player: Player) {
        val packet = protocol.createPacket(PacketType.Play.Server.ENTITY_METADATA)
        packet.integers.write(0, player.entityId)

        val watcher = WrappedDataWatcher()
        val serializer = Registry.get(java.lang.Byte::class.java)

        watcher.entity = player
        watcher.setObject(0, serializer, 0x40.toByte())

        packet.watchableCollectionModifier.write(0, watcher.watchableObjects)
        protocol.sendServerPacket(player, packet)
    }

Error: https://hst.sh/anosuhogiq.lua

atomic trail
#

Is it recommend to use a TypeAdapter over just a Data class that's parsed in the constructor on initialization? Where the data class would override hashCode() to save the data

sterile hinge
#

the data class would override hashCode() to save the data
what does that mean

atomic trail
sterile hinge
#

hashCode has nothing to do with being serializable

atomic trail
#

Oh, forgot what I used it for then

icy shadow
#

Well, hashing

mellow pond
orchid niche
#

Yeah, it would just be nice to do this with packets though as its such a minor feature of my plugin

orchid niche
#

Yeah, not a bad idea

#

they dont use protocol lib :/

#

I'm sure I could do it with nms, but I need to use protocol lib

mellow pond
#

protocollib is known to be horribly optimized i thought

orchid niche
#

I've never used it before ๐Ÿคท, the project im working on uses it, and adds the paper api as a dependency so no nms

mellow pond
orchid niche
#

The lead developer of the project told me to use protcol lib, ik how to add nms with paper

#

usually I would use paperweight

warm steppe
#

maven ๐Ÿ’€ ๐Ÿคก

mellow pond
icy shadow
#

well

serene cairn
#

need help optimizing code for my library.
what can i do?

when i use pasteSchematic() then it blocks the main server thread if the region is big, in this case i'm using this for big regions (testing it)

https://paste.helpch.at/natutetefu.java

river solstice
#

run it async? fingerguns

serene cairn
#

@river solstice ?

#

also i'm not even talking only about async, overall the server freezes entirely for like 1 second or more.

river solstice
#

then hardware diff

serene cairn
serene cairn
nimble vale
#

anyone knows a decent api for file hosting except dropbox and gdrive apis

sterile hinge
serene cairn
#

sorry im getting help already and i was wrong

strange remnant
#

Me again ๐Ÿ™‚

#

Still didn't fix the divorce but I have gotton further

#

Now the error is:"
Caused by: java.lang.IllegalArgumentException: Invalid UUID string: CaptainMiner_Z

#

So can someone please help me find out why this isn't working

#

If you can help me please just @me โค๏ธ

serene cairn
strange remnant
#

I will I am just adding a quick command to see if it can retrieve marriage and partners so i'm 100% sure that is not the problem

serene cairn
strange remnant
#

Send it in private

#

@serene cairn

strange remnant
#

Can anyone help me because he didn't react anymore

#

Never did that wrong

clever relic
#

Someone give me a colour to put this text:

#

Main colours of the site are:
#252525
#539d65

torpid raft
#

#262626

clever relic
light pendant
icy shadow
#

groovy moment

sterile hinge
#

groovy doesn't even properly support method handles

#

bad language

light pendant
#

I prefer groovy over kotlin because ij always gets a stroke when I use buildSrc scripts in kotlin

icy shadow
#

ij always has a stroke over anything in groovy

#

why yes I would like to cast String to String

#

thank you

light pendant
#

I currently got a tiny project setup that consists of many tiny sub-projects, how can I now publish them all to maven local at once?

My "parent" build.gradle looks like this:

plugins {
    id("maven-publish")
}

allprojects {
    tasks.withType(PublishToMavenRepository).configureEach {
        dependsOn("build")
    }
}

but when I run gradle publishToMavenLocal, it doesn't even try to build the "child projects"

20:33:19: Executing 'publishToMavenLocal'...

> Task :buildSrc:extractPluginRequests UP-TO-DATE
> Task :buildSrc:generatePluginAdapters UP-TO-DATE
> Task :buildSrc:compileJava UP-TO-DATE
> Task :buildSrc:compileGroovy NO-SOURCE
> Task :buildSrc:compileGroovyPlugins UP-TO-DATE
> Task :buildSrc:pluginDescriptors UP-TO-DATE
> Task :buildSrc:processResources UP-TO-DATE
> Task :buildSrc:classes UP-TO-DATE
> Task :buildSrc:jar UP-TO-DATE
> Task :publishToMavenLocal UP-TO-DATE

BUILD SUCCESSFUL in 267ms
#

oh wait I don't have the plugin declared in allprojects

dusky harness
#

Ur not implementing subprojects

#

In dependencies

#

I'm pretty sure it needs that, at least for gradle build

light pendant
#

when I run gradle build, then it builds all submodules

dusky harness
#

Oh

#

Wait

#

Oh

light pendant
#

here's my structure, if that helps (currently I only got papi-replacer and yaml-commands as children, the currently opened file is the main build.gradle)

#

it seems like it simply doesn't apply the maven-publish plugin to my sub projects

icy shadow
#

idk if theres a better way

#

probably is

dusky harness
#

Why are there two different projects in the same project tho

light pendant
icy shadow
#

add them then

#

problem solved

#

or put it in subprojects{} in your main script

dusky harness
icy shadow
#

yes

#

full example in the file i linked

light pendant
#

well that's what I'm trying. but neither allprojects { } nor subprojects { } allow to declare plugins { }

dusky harness
icy shadow
#

you can if you use apply

#

^

dusky harness
#

Also you can do plugins {}

#

Just not existing ones

#

Declared already

#

Kinda

light pendant
#

oh yeah, apply seems to do the trick, thanks

#

hmm it still doesn't publish anything, when I run publishToMavenLocal on a subprojects, it only always claims that task is UP-TO-DATE

#

probably I have to configure which artifacts to publish

dusky harness
#

It doesn't have to build fully every time if it's built already

light pendant
#

it just says "publishToMavenLocal" is up to date and doesn't do anything

#

I fixed it by simply adding the maven-publish plugin and the publishing section to my java-conventions buildsrc script

plugins {
    id("java-library")
    id("maven-publish")
}

group = "..."
version = "..."

publishing {
    publications {
        maven(MavenPublication) {
            from components.java
        }
    }
}
#

hm unfortunately now the pom it generates doesn't include any dependencies

#

how can I make it so that the published pom correctly lists the dependencies?

dusky harness
#

why do you want to publish those plugins all in one artifact?

#

assuming that's what you're trying to do?

#

since otherwise you wouldn't have the maven publish plugin in the base module

light pendant
#

I don't want them to be all in one artifact, they should all be published as separate artifact

dusky harness
#

act like they're all separate

#

there might be a way to do it how you're doing it, but idk since I only do 1 module, so I'm suggesting that instead since that's what bm suggested

light pendant
#

I can publish them just fine, the issue is that the generated pom is completely empty

#

it's missing all the dependencies, it doesn't even mention <packaging>jar</packaging>

dusky harness
#

what file and directory is that? and send the build script

light pendant
#

that's my .m2/repository/com/jeff-media/cesspool/yaml-commands/1.0-SNAPSHOT/yaml-commands-1.0-SNAPSHOT.pom

dusky harness
#

(also make sure to not commit .idea)

light pendant
#

but that pom is useless

#

it does not even mention there's a .jar file

#

it doesn't mention all the dependencies

dusky harness
#

idk if thats even required

dusky harness
#

i think

#

only if its transitive

light pendant
#

as I didn't shade anything, the dependencies are required to be in the pom

dusky harness
#

if its compileOnlyApi it should show

#

u can test if u want

#

to see if that works

light pendant
#

oh ok, let me try that

dusky harness
#

same with api for implementation

#

but you should only make some dependencies transitive

light pendant
#

thx, that worked. the pom is still missing the packaging part, which means maven won't be able to find this dependency

dusky harness
#

are you sure?

light pendant
dusky harness
#

well that has to be defined manually, at least in my setup

light pendant
#

hmmm

dusky harness
#

wait no

#

the issue

light pendant
#

in maven all I gotta do is mvn install without configuring anything ๐Ÿฅฒ

dusky harness
#

is that u made a typo

#

replacder

light pendant
#

lmao

#

yes, lol

#

thanks

#

usually IntelliJ auto completes the dependencies, this time it didn't so I had to type it manually

icy shadow
light pendant
#

ok next question ๐Ÿ˜„

if I use compileOnlyApi, then the generated pom uses <scope>compile for those dependencies - what do I have to use for dependencies that should up as <scope>provided in the generated pom?

icy shadow
#

depends if you want them to be exposed as transitive or not

dusky harness
#

so that things like exclude would work

#

well

#

not compile only

#

maybe implementation

#

assuming it doesn't already

icy shadow
#

yh i believe implementation will include

#

but... not transitive iirc

#

if you want transitive i think it's just api

dusky harness
light pendant
#

using api(...), it still lists them as "compile"

dusky harness
light pendant
#

here's my generated pom. I'm using "api(...)" for jetbrains annotations, and compileOnlyApi(...) for my papi-replacer dependency. Both show up as "compile", which leads to jetbrains annotations getting shaded if one simply uses my project as dependency in maven now

dusky harness
#

why are you shading annotations

light pendant
#

?

icy shadow
#

bro

light pendant
#

my question is how to avoid that

dusky harness
#

the annotations are supposed to be for IDEs btw

#

not the JVM

icy shadow
#

honestly just go through them all with trial and error

#

implementation might work

dusky harness
#

but also, read my above messages

light pendant
light pendant
#

then they don't show up in my pom at all.

#

They should show up as <scope>provided

dusky harness
#

why do you want it?

#

it'd be nice but imo it isn't really something that is needed

#

idk why gradle excludes it

dusky harness
#

for jb annotations at least

icy shadow
#

yes but they CLEARLY know that and already said they want to AVOID shading it

dusky harness
#

oh ok
It's just that I already said what api does and replied to their question, and didn't suggest using api in it