#help-development

1 messages · Page 526 of 1

topaz atlas
#

because

wet breach
#

you can do that in the duels class

topaz atlas
#

my guine pig isnt on

#

for awhile

#

lmao

wet breach
#

I don't think you seem to understand what I am saying

#

you know what parameters are right?

topaz atlas
eternal oxide
#

can there be more than one duel happening at a time?

topaz atlas
#

and you want me to initilize the duel

wet breach
topaz atlas
#

when both player objects are avalible

topaz atlas
#

i wouldnt mind keeping it open for later edits and expantins

eternal oxide
#

Then you needjava // add all players currently in a duel. Set<UUID> participants = new HashSet<>(); Set<Duel> activeDuels = new HashSet<>();

smoky anchor
#

From my limited search: If you can give the player a resourcepack then create an item model of the shape you want but with invisible texture.
Not sure if there is other way.

eternal oxide
#

a Duel class which takes two player UUIDs

wet breach
#
public class Duel {

public Duel(Player player1, Player player2) {
}

now, because the Duel class requires 2 player objects you can't create a Duel object IE new Duel() unless you pass in 2 player objects

eternal oxide
#

as I suggested before it could be a record

wet breach
#

you could use UUID's as well

topaz atlas
vital sandal
#

how to force a player run a command even they don't have perm?

eternal oxide
#

UUID is safer, in case a player relogs

#

keep them in teh duel for a while

wet breach
topaz atlas
#

so

#

the first person clicks, added

thick oracle
#

Hey!

I'm currently having some issues with setting a spectator target.

Basically, what I'm doing is teleport the player to the target and then set the spectator target. The target doesn't move at all, yet as soon as I set the spectator target, the camera seems to always do a 180 degree turn. Does anybody know what could cause this or how to prevent it?

(The teleport as well as the delayed task are to help with larger distances.)

Edit: tried manually rotating 180 degrees to test, but there's still rotation happening

Spigot 1.19.3 / Java 17.0.3

public void setSpectate(Player target) {
  player.setGameMode(GameMode.SPECTATOR);

  PotionEffect blindness = PotionEffectType.BLINDNESS.createEffect(30, 9);
  PotionEffect slowness = PotionEffectType.SLOW.createEffect(30, 0);
  player.addPotionEffects(Arrays.asList(blindness, slowness));

  player.hidePlayer(plugin, target);
  player.teleport(target.getLocation());

  Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
    player.showPlayer(plugin, target);
    player.setSpectatorTarget(target);
  }, 10);
}
topaz atlas
#

second person, added then starts

eternal oxide
#

every player who enters a duel gets added to the Set, IF they are not already in it. If they are already in there then they are already in a duel

topaz atlas
eternal oxide
#

if both participants are not in teh Set you create a Duel object for them, puth both in the participants Set and add their Duel to the other Set

wet breach
#

and not just one and then hanging left waiting for the other

eternal oxide
#

Yes you also use a Duel object

#

the participants contains ALL players currently in a duel.

topaz atlas
eternal oxide
#

could be 100 players in there

#

but it allows you to quickly check if a player is engaged in a Duel and not able to start another

wet breach
#

slowly we are getting through to them

eternal oxide
#

Your duel object contains all the code you need to manage each duel

topaz atlas
#

Now I need 1 or two sets, for player 1 and 2, or one that holds both players, and adds to it.

wet breach
topaz atlas
#

when two reaches

#

the set empties?

wet breach
#

you would benefit in learning some more concepts and what not

topaz atlas
wet breach
#

if you did, you would have instantly understood everything I was telling you

#

but that isn't the case, same with what ElgarL was saying

topaz atlas
wet breach
#

that makes no sense, anyways I am out. I don't spoonfeed

topaz atlas
#

thats spoonfeeding

#

like, a set for both players each, or a set that contains both players?

wet breach
# topaz atlas your not writting the code for me

with the amount of questions you keep asking it is almost to that point. I have nothing else to add. I have explained and told you what should be done, how you go about implementing it is up to you. We can't dictate and tell you 100% of everything

topaz atlas
topaz atlas
wet breach
#

well the question is probably for ElgarL

topaz atlas
#

@eternal oxide

pseudo hazel
#

to do what, type something into a file?

cunning shard
#

yeah ig

pseudo hazel
#

im sure most can manage to do that

#

yes so you can store the yml files you create with the file configuration in your plugin folder

cunning shard
#

How would I go about doing that?

tardy delta
#
BukkitWiki

The Configuration API is a set of tools to help developers quickly parse and emit configuration files that are human readable and editable. Despite the name, the API can easily be used to store plugin data in addition to plugin configuration. Presently only YAML configurations can be used. The API however was designed to be extensible and allow ...

cunning shard
#

I'll check it out

#

thanks

#

would it make a difference that the thing itself uses a seperate API repo?

grizzled oasis
#

Hi, its possible to read and call this function from a string like "SKRIPT".load() even using Reflection or something else
https://paste.md-5.net/dogucetoze.java

After all of them are loaded?

rotund ravine
#

No not like that

grizzled oasis
#

yea i know Java doesn't work like that, but was for explaining what i meant

worldly ingot
#

No because a String is a String. You would need to have some way to convert that String into whatever instance you need

rotund ravine
#

Manifolddd

remote swallow
#

if (String is String) when

river oracle
#

Jotlin in Java

wise mesa
#

Lombok has extension methods

river oracle
#

Really that must be new

#

Didn't know aby that

gleaming grove
#
   var configB = YamlConfiguration.loadConfiguration(new File(name2));
  //var configC = configA.combine(configB); ``` Is there some kind of build in method that I can use to combine 2 configs?
tardy delta
#

wdym combine?

gleaming grove
#

merge

river oracle
#

No

quaint mantle
#

Nahh

river oracle
#

That'd be crazy useless lol

tardy delta
#

you can probably write sections

river oracle
#

Yassss

gleaming grove
#

oke

fringe yew
#

I'm getting "org.bukkit.plugin.InvalidPluginException: Cannot find main class `co.uk.robuxtrex'" in console when i try start up my server. i can send code snippets if required. first time ever messing with spigot and i have basic knowledge of java (via other languages like cs)

chrome beacon
#

I assume robuxtrex isn't your main class

#

and I hope you have more CS experience than basic unity knowledge

fringe yew
#

like a year ago

#
package uk.co.robuxtrex.permavision;
import org.bukkit.plugin.java.JavaPlugin;

public class App extends JavaPlugin {
    @Override
    public void onEnable() {
        getLogger().info("Hello, SpigotMC!");
    }
    @Override
    public void onDisable() {
        getLogger().info("See you again, SpigotMC!");
    }
}

app.java

chrome beacon
#

co.uk.robuxtrex.App

#

^ that would be the main class

#

I recommend using a proper Java IDE like Intellij or Eclipse instead of vscode

fringe yew
#

i prefer vscode only because i have mastered it (mostly)

#

and i don't like other IDEs

quiet ice
#

Well then

#

As long as you don't have any IDE-specific issues it shouldn't be an issue

fringe yew
# chrome beacon co.uk.robuxtrex.App

so would I need to rename the app.java file to something like permavision to change it to my preferred package name (co.uk.robuxtrex.permavision) or do I have to change other stuff?

#

i'm recreating the maven project

chrome beacon
#

<package>.<class>

#

Also app.java should be App.java

fringe yew
#

it is

fringe yew
chrome beacon
fringe yew
#

shoot yeah

#

i just realised that when revising the tutorial

fringe yew
#

same error this time with .Main at the end (i changed the class)

quiet ice
#

what is the file name?

fringe yew
#

Main

quiet ice
#

And directory structure?

fringe yew
#

wait there

quiet ice
# fringe yew Main

Could you show the project view within your IDE? Right now I have no concrete idea of what you are doing

tender shard
#

if your class is called App, the file also has to be called App.java, not Main.java

scenic onyx
#

C:\Users\feder\IdeaProjects\PlaxerCore\src\main\java\org\plaxer\it\plaxercore\command\Guimenager\GuiManager.java:3:26
java: package com.mojang.authlib does not exist
C:\Users\feder\IdeaProjects\PlaxerCore\src\main\java\org\plaxer\it\plaxercore\command\Guimenager\GuiManager.java:4:37
java: package com.mojang.authlib.properties does not exist
C:\Users\feder\IdeaProjects\PlaxerCore\src\main\java\org\plaxer\it\plaxercore\command\Guimenager\GuiManager.java:62:9
java: cannot find symbol
symbol: class GameProfile
location: class org.plaxer.it.plaxercore.command.Guimenager.GuiManager
C:\Users\feder\IdeaProjects\PlaxerCore\src\main\java\org\plaxer\it\plaxercore\command\Guimenager\GuiManager.java:62:35
java: cannot find symbol
symbol: class GameProfile
location: class org.plaxer.it.plaxercore.command.Guimenager.GuiManager
C:\Users\feder\IdeaProjects\PlaxerCore\src\main\java\org\plaxer\it\plaxercore\command\Guimenager\GuiManager.java:64:53
java: cannot find symbol
symbol: class Property
location: class org.plaxer.it.plaxercore.command.Guimenager.GuiManager

#

how i resolve this?

tender shard
#

by adding authlib to your classpath

#

are you using maven or gradle?

scenic onyx
tender shard
#
<repositories>
        <repository>
            <id>minecraft-repo</id>
            <url>https://libraries.minecraft.net/</url>
        </repository>
</repositories>
<dependencies>
        <dependency>
            <groupId>com.mojang</groupId>
            <artifactId>authlib</artifactId>
            <version>1.5.21</version>
            <scope>provided</scope>
        </dependency>
</dependencies>
#

there might be a newer version, haven't checked

scenic onyx
#

<version>1.5.21</version> give error

tender shard
#

reload maven

scenic onyx
#

Thank you so much @tender shard

tender shard
#

np

#

anybody know where I can find the JLS (doesn't matter whether version 8, 11 or 17) in one SINGLE html file? I can only find the one where you can only see one chapter at a time, but I cannot ctrl+f through that

thick oracle
#

I have the delay that high because if I go any lower the effects will feel to abruptly applied and removed

tender shard
thick oracle
tender shard
thick oracle
fringe yew
#

main.java

package co.uk.robuxtrex.permavision;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin {
    @Override
    public void onEnable() {
        getLogger().info("Hello, SpigotMC!");
    }
    @Override
    public void onDisable() {
        getLogger().info("See you again, SpigotMC!");
    }
}
hazy parrot
#

it means you are using old version of plugin

#

clean package it and try again

fringe yew
#

yeah did do so

#

thanks

tender shard
thick oracle
#

I see, so a delay would work, it just needs to be longer. Not really something I want to do so I guess I'll have to live with the roation.
Thank you for testing this^^

fringe yew
#

when i use this.getConfig(); do I need to define the location of the configuration file in order for this to work? plus, does this need to be in the onEnable() public void

echo basalt
#

getConfig defaults to pluginDataFolder/config.yml

young knoll
#

It used the default config.yml file

#

If you have one

echo basalt
#

saveDefaultConfig grabs the embedded config.yml on your jar and saves it there

fringe yew
echo basalt
#

server makes it for you

#

getDataFolder usually defaults to plugins/<your plugin's name>

#

don't worry about it too much

#

just put your files in the resources folder

#

as if they were in the plugin's folder

fringe yew
#

will it just grab the yml file from there?

echo basalt
#

yeah

fringe yew
#

cool

#

also

#

where do i put the FileConfiguration config = this.getConfig();? in public void onEnable()?

echo basalt
#

wherever you're using it

fringe yew
#

alright

#

thank you

#

i'll report any problems i have here

#

also

#

is getLogger().info("Hello, SpigotMC!"); meant to print something to the console?

#

on enable

echo basalt
#

yes

fringe yew
#

ah yeah it did lol

#

my console is such a mess

tender shard
#

use error instead of info, then its red lol

echo basalt
#

I'd recommend testing your stuff in a clean server

tender shard
#

^

echo basalt
fringe yew
echo basalt
#

localhosting ??

fringe yew
#

true

#

for now i can use ctrl+f to find any logs

echo basalt
#

usually what I do

#

I also have a free oracle vps in case I need any databases or maven repo

fringe yew
#

also, does .getList() retrieve an array from the config?

echo basalt
#

something like that

rough drift
#

You can send a bundle packet, send spawn and rotation, and use bundle again so that both are run at the same time sequentially

#

so it doesn't render the flick

rough drift
#

lmfao

fringe yew
#

we love sytem

rough drift
#

I did that on accident once, it actually works

#

(sent message to console on accident)

tender shard
#

lol funny how the same project works on macOS but not on windows

fringe yew
#

does .getList() retrieve the desired array from the configuration file?

#

or is there another function (or whatever it's called in java) to retrieve and define an array

rough drift
fringe yew
#

what keyword is used to define it? i'm using array right now and it's complaining that it's undefined (Array cannot be resolved to a typeJava(16777218))

#

( Array players = config.getList("players");)

rough drift
#

show the error

#

Ah it's not array

#

use List<Object> (you can also use getStringList to get a list of strings)

#

Array is a reflection thing, to use arrays in java you do type[]

#

like int[]

fringe yew
#

"List cannot be resolved to a typeJava(16777218)"

rough drift
#

import java.util.List

#

what's your main language btw @fringe yew

fringe yew
#

i primarily use typescript/luau

rough drift
#

ah

fringe yew
#

very rarely rust

#

Type mismatch: cannot convert from List<capture#1-of ?> to List<Object>Java(16777233)

rough drift
#

oh yeah it's List<?>

#

my bad

fringe yew
#

thank you so much

#

also

#

one last question

rough drift
#

what are you using that list for though

fringe yew
#

which links into my next question

#

how do i apply an effect to a player

echo basalt
#

First you gotta have a player

rough drift
#

^

echo basalt
#

How do you want to format your list

#

Player names? uuids?

#

partial name matches?

fringe yew
#

player names

rough drift
#

So you might want to use getStringList, change the type to List<String> and use that, i gtg now though

echo basalt
#

Alright so let's say you have something like

#
players:
- 'ImIllusion'
- 'IllusionTheDev'
- 'Notch'
#

What's the type of that list?

fringe yew
#

string list?

echo basalt
#

Are the elements strings, integers, booleans?

#

They are strings, alright

#

So in code, you'd do something like

#

List<String> playerNames = config.getStringList("players");

#

Now you have a collection of player names

#

Let's loop through that and get a player

#
for(String name : playerNames) {
  Player player = Bukkit.getPlayerExact(name); // replace with getPlayer for partial matching

  if(player == null) { // may be offline
    continue; // don't break out of the loop, just skip to the next iteration
  }

  // apply effect
}
rough drift
#

@echo basalt What about streams though?

echo basalt
#

stick to the basics

rough drift
#

fair

echo basalt
#

streams are for people that are too eloquent to actually write a for loop

rough drift
#

though they should cache it

#

oh wait no what am I on

fringe yew
#

also, does .getPlayerExact() include the geysermc prefix

echo basalt
#

use streams if you know what you're doing

echo basalt
echo basalt
#

It just does a name match

rough drift
#

You need to add the geyser prefix

fringe yew
rough drift
#

If it is a geyser player*

echo basalt
#

Alright

#

as for adding a potion effect

fringe yew
#

also Player cannot be resolved to a type? do i need to import something

echo basalt
#

you do

#

org.bukkit.entity.Player most likely

fringe yew
#

yea

echo basalt
#

Alright

#

Now look through the player methods and see what might be useful for potions

#

these might help

fringe yew
fringe yew
#

alright

echo basalt
#

That type of comparison only works for booleans

fringe yew
#

kk

fringe yew
echo basalt
#

Alright

#

Let's use the top method as it'll be the one most commonly used

#

It takes a PotionEffect as a parameter

#

So looking at the constructors, just pick the one you need

#

speaking from experience, the duration is in ticks

fringe yew
#

would PotionEffect be something like 'NIGHT_VISION' or an ID?

echo basalt
#

It's an object

#

Here's a sample

#
PotionEffectType potionType = PotionEffectType.NIGHT_VISION;

PotionEffect effect = new PotionEffect(
  potionType, // night_vision
  100, // 5 seconds -> 100 ticks
  0 // amplifiers start at 0
);
#

It's ok to just have these all as a single line honestly

#

player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 100, 0));

#

You can set Integer.MAX_VALUE as the duration if you want

#

for a permanent effect

fringe yew
#

would that also re-apply the effect on death/totem used

#

or would i have to make an event for that

echo basalt
#

no

#

You'd need to make a listener for that

jagged bobcat
#

does Inventory.getSize() return: 1 or 8

fringe yew
echo basalt
#

so uhh

jagged bobcat
#

ight

echo basalt
#

5 for hoppers, 9 for single row chests

#

27 for regular chests

#

54 for double chests

#

uhh

#

45 for players

#

something like that

jagged bobcat
#

yee ty

echo basalt
fringe yew
#

yeah

echo basalt
#

personal recommendation

#

add spigot as the first word

#

and then just sum up what you're looking for in 2-3 keywords

#

like this

chrome beacon
#

I always add spigot at the end

echo basalt
#

usually at the start narrows it down a bit more

#

as the initial words are prioritized a lot more

fringe yew
#

also

#

is 'night_vision' a string or something else?

tender shard
#

or in the middle: how to listen SPIGOT to events

young knoll
#

PotionEffectType.NIGHT_VISION

#

It’s an enum constant

#

Well, for now

flint coyote
#

PotionEffectType is not an enum

echo basalt
#

PotionType is

#

PotionEffectType is a weird keyed registry thing

flint coyote
#

yeah I hate it

young knoll
#

Fair

#

Everything is going to that so

#

Get used to it

flint coyote
#

really?

young knoll
#

Enums are not expandable

echo basalt
#

it's a weird pattern that's somewhat expandable

#

with hardcoded values

young knoll
#

Minecraft is increasingly becoming more expandable

tender shard
#

"some day"

flint coyote
#

The Keyed Interface should get a "getByKey" in that case.

echo basalt
#

well

tender shard
#

it has been announced like in 1.17 but still hasn't happened

flint coyote
#

It's super annoying to instantiate dynamically

echo basalt
#

the registries have them

#

keyed is just an instance so

young knoll
#

It’s targeted for 1.20

#

Hopefully™️

flint coyote
echo basalt
#

pretty much any

tender shard
#

bukkit registries

flint coyote
#

Yeah that's not the interface though

young knoll
#

Some classes have a direct getByKey

flint coyote
#

I stumbled over that with dynamic configurations

young knoll
#

But all the registries have it

#

They also have match which is more dynamic

flint coyote
#

Hmm I might be able to work with the registry then instead of doing this

if (Keyed.class.isAssignableFrom(type)) {
            try {
                Field field = type.getField(s.toUpperCase());
                if (!asString) {
                    return field.get(null);
                }
                return s.toUpperCase();
            } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignored) {
            }
        }
young knoll
#

💀

flint coyote
#

yeah that's why I wanted a getByKey in the interface

#

The class is dynamic

#

So I can only check for "Keyed"

young knoll
#

I mean

#

Probably not a hard thing to add

fringe yew
#

when i'm making a new listener, it's complaining that the DeathListener doesn't exist!
getServer().getPluginManager().registerEvents(new DeathListener(), this);
DeathListener cannot be resolved to a typeJava(16777218)

young knoll
#

Do you have a class called DeathListener

flint coyote
#

Definitly would make the parsing of string to object less painful

fringe yew
#

oh shoot

young knoll
#

I would just use registry.match

fringe yew
#

if i made the new class in a new file would it still work?

#

or do i need to import it

flint coyote
#

So just get the registry via reflection and then use match?

tender shard
#

why not just get the registry using the class name?

young knoll
#

I’m curious what you have where a user can input any keyed object

flint coyote
#

It's not the user. It's an engine and developers can create fields of any class

#

therefore I have to create them by reflection based on a string input from the configuration

tender shard
#

the enchantment registry just falls back to methods in Enchamtent lol

flint coyote
#

Basically like this. I check the type of the annotated fields and I have to instantiate them using a string input

#

And since PotionEffectType is not an enum I had to do this annoying Keyed workaround

dense falcon
#

How can I do a counter when the player click it add +1 to a var?

fringe yew
#

is a FileConfiguration decleration mutable?

kind hatch
flint coyote
fringe yew
#

thanks

flint coyote
#

Would still require reflection to access the Registry but would look cleaner

kind hatch
flint coyote
#

Aight I'll rework that part then

tender shard
#

PotionEffectType does not have a registry

flint coyote
#

Yikes nvm then

tender shard
#

weird because everything else I know is Keyed does have a registry

#

however I think I checked on 1.19.3, not 1.19.4

#

these are all registries

flint coyote
#

I'll stick with getting the static fields then. And I really hope every class implementing Keyed (that's not an enum) does have them lol

#

Orrr they actually improve the Keyed Interface. That would be a blessing

dense falcon
#

There is the event when a player do a left click (in the air or other) ?

flint coyote
#

PlayerInteractEvent with some checks

dense falcon
#

PlayerInteractEvent can be used ?

#

Alr.

#

So, I am trying to wait 1s before get the CPS of the player in 1s, is it good for you ?
https://sourceb.in/jFrqXXUg0F

    @EventHandler
    public void onInteract(PlayerInteractEvent event) {
        Player player = event.getPlayer();
        Action action = event.getAction();
        ItemStack item = event.getItem();
        FileConfiguration config = this.plugin.getConfig();

        ...

        if (config.getBoolean("cps." + player.getUniqueId() + ".enabled")) {
            int currentCounter = config.getInt("cps." + player.getUniqueId() + ".counter");
            config.set("cps." + player.getUniqueId() + ".counter", currentCounter + 1);
        }
    }
flint coyote
#

I would add an access layer to your configuration

#

also don't forget to save the config (not in the event though)

eternal oxide
#

Config is not a place to store a statistic like CPS

flint coyote
eternal oxide
#

Does he need the statisitic when offline?

subtle folio
#

save map on disable and refresh it on enable

flint coyote
eternal oxide
#

Also config is for plugin settings not for data

#

make s custom data file

flint coyote
#

A lot of plugins use "config" files for data. Not the standard plugin config though, true

eternal oxide
#

yeah bad plugins 😉

flint coyote
#

Essentials did that for a long time aswell and yet still it was quite popular

eternal oxide
#

It didn;t store data in its config

#

every player has their own data file

flint coyote
#

no but in yml files in the plugin folder

dense falcon
eternal oxide
#

yes, yaml is fine

flint coyote
#

that's why I said "config" files

eternal oxide
#

ah

subtle folio
# dense falcon What?

A better approach is to make a Hashmap that stores the CPS of the player. Then onEnable and onDisable you can save/read the stored data

eternal oxide
#

Shoudl probably clarify with "custom" config 😉

subtle folio
#

Either by looping or serialization

flint coyote
subtle folio
#

..

eternal oxide
#

doing a Map would be best

dense falcon
#

Why it's deprecated ? ```java
Bukkit.getScheduler().runTaskTimer(plugin, new BukkitRunnable() {
@Override
public void run() {
config.set("cps." + target.getUniqueId() + ".enabled", true);
}
}, 0, 20);

flint coyote
#

Sure you could do another map to put back into that map. I don't know if there's a huge benefit though.

subtle folio
#

new BukkitRunnable() -> {

eternal oxide
#

UUID is already ConfigurationSerializable so you can just .set("path", map)

dense falcon
flint coyote
#

For that many accesses it's probably worth it. Generally idk about caching already cached config/file data.

worldly ingot
#

I would personally opt for the Runnable in this case because you're not cancelling it

#
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
    config.set("cps." + target.getUniqueId() + ".enabled", true);
}, 0, 20);```
flint coyote
#

Choco will there be an improvement for the Keyed interface for 1.20?

worldly ingot
#

What improvements do you want?

#

It denotes an object that has a key

flint coyote
#

a getByKey

worldly ingot
#

That's why Registry exists

fringe yew
#

Received the error java.lang.IllegalArgumentException: Plugin already initialized! on plugin startup in my server console. Is having two onEnable()'s in two different files the issue?

flint coyote
#

Well how do I dynamically get a registry based on a Class that implements Keyed?

worldly ingot
#

I think you have a backwards design

dense falcon
eternal oxide
flint coyote
#

Backwards as in?

fringe yew
tender shard
eternal oxide
#

?di

undone axleBOT
dense falcon
#

Break?

worldly ingot
tender shard
#

call cancel() on the returned BukkitTask

flint coyote
#

Well I wanted to create an api that would fill those fields based on a string input. Therefore I kinda need to fill that field just by knowing the Class implements Keyed

tender shard
flint coyote
#

I can workaround it with reflection but I'd prefer a cleaner way

#

And even with reflection there's no clean way and I just have to expect that the Class implementing Keyed is either an enum or has constants for its values

#

Also PotionEffectType doesn't have a Registry for some reason

dense falcon
worldly ingot
#

Is there any reason you don't just assign the field a default value? Why does that have to come from the annotation?

flint coyote
#

Because it's configurable

worldly ingot
#

The default value is configurable? How so? You're hard-coding it in the annotation too

flint coyote
#

No that's a default. Therefore it can change.

worldly ingot
#
@ConfigurableValue(defaultValue = "REGENERATION")
private PotionEffectType effect;
@ConfigurableValue
private PotionEffectType effect = PotionEffectType.REGENERATION;
#

imo the second one makes more sense

#

There's no reason to make your default value a string in an unrelated annotation

#

You can still set the effect value to whatever you want, or leave it as is if it's not set in the config

tender shard
# dense falcon Uh what?
        // Scheduler + Consumer<BukkitTask>:
        Bukkit.getScheduler().runTaskTimer(this, task -> {
            if(something) {
                task.cancel();
            }
        }, 1, 1);
        

        // or BukkitRunnable without scheduler
        new BukkitRunnable() {

            @Override
            public void run() {
                if(something) {
                    this.cancel();
                }
            }
        }.runTaskTimer(this, 1, 1);
flint coyote
#

True removing the default value would make sense.
I'd still require a way to overwrite it with another value. That would lead to the same problem

worldly ingot
#

Sure. Though there's not really much you can do about that unless you hard-code in the registries into your annotation processor

#

Which is definitely an option. Not pretty, but an option

flint coyote
#

What about PotionEffectType? There's no registry

#

And it's not an enum. And it implements Keyed

worldly ingot
#

Not entirely sure why there isn't one tbh

#

One's added in 1.20

flint coyote
#

That's why I currently workarounded it by expecting constant fields and accessing those by reflection.
It's not clean though.
s is a String

if (Keyed.class.isAssignableFrom(type)) {
            try {
                Field field = type.getField(s.toUpperCase());
                    return field.get(null);
            } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException ignored) {
            }
        }
eternal needle
#

Is there some plugin that is a addon to griefprivention and make it so players can transfer claimblocks to each others? if not how do i get the 2 args? tag me

flint coyote
# worldly ingot One's added in 1.20

Hmm so either hardcode all registries which would break on updates or get the registry by reflection just like I'm getting the constants in the code I just pasted

#

Or hardcode them and back it up with reflection

worldly ingot
#

Better imo to hardcode them in this instance

#

Reflection is about as maintainable as hardcoding is here

dense falcon
#
    private void cpsPlayer(Main plugin, Player player, Player target, FileConfiguration config) {
        player.sendMessage("[" + ChatColor.GOLD + "ModUtils" + ChatColor.WHITE + "] Informations sur les CPS du joueur : \n"
                + "- Nom du joueur en analyse: " + ChatColor.AQUA + target.getName() + ChatColor.WHITE + "\n"
                + "- UUID du joueur en analyse: " + ChatColor.AQUA + target.getUniqueId() + ChatColor.WHITE + "\n"
                + "Veuillez patienter pendant l'analyse de " + ChatColor.RED + target.getUniqueId() +  ChatColor.WHITE  + "."
        );
        // Enable counter + start heck
        config.set("cps." + target.getUniqueId() + ".enabled", true);
        config.set("cps." + target.getUniqueId() + ".counter", 0);
        plugin.saveConfig();

        // Timer
        new BukkitRunnable() {
            int i = 0;
            @Override
            public void run() {
                i ++;
                if (i == 3) {
                    this.cancel();
                }
                player.sendMessage("COUNTER TIMER : " + i);
                player.sendMessage("COUNTER CPS : " + config.getInt("cps." + target.getUniqueId() + ".counter"));
            }
        }.runTaskTimer(plugin, 0L, 20L);


        // Disable counter + end check

        player.sendMessage("End timer");

        config.set("cps." + target.getUniqueId() + ".enabled", false);
        config.set("cps." + target.getUniqueId() + ".counter", 0);
        plugin.saveConfig();
    }

Why "End timer" started before the end of the runnable?

flint coyote
#

Well reflection doesn't have to be maintained if I just get Registry.CLASS_NAME via reflection.

I don't know if such an if-else if-cascade for checking all registries will be faster than reflection though.

kind hatch
dense falcon
#

60 ticks.

#

Bc I want 3s.

kind hatch
#

Add however much you need.
20 ticks = 1 second.

dense falcon
#

Yeah I know.

#

The delay is before start running...

#

@kind hatch

tender shard
flint coyote
#

that's actually smart. I'll do that

#

It will be a Map<Class<?>, Registry> but besides that it's a perfect idea

kind hatch
dense falcon
#

No problem.

#

I think I found a solution.

tender shard
# tender shard I'd just get a Map<String,Registry> with reflection on startup, then you don't h...
    private final Map<String,Registry<?>> registriesByName = new HashMap<>();

    @Override
    public void onEnable() {
        
        for(Field field : Registry.class.getFields()) 
            if(field.getType().equals(Registry.class)) {
                try {
                    String name = field.getName();
                    Registry<?> registry = (Registry<?>) field.get(null);
                    registriesByName.put(name,registry);
                } catch (ReflectiveOperationException ignored) {
                    
                }
            }

sth like that is what I'd do

flint coyote
#

Oh right I can't get the classes since they are erased at runtime. It actually has to be a String (unless I do the Class.forName() at startup aswell)

#

But that's a pretty neat idea. I'll adapt that

tender shard
#

there should be Registry<Registry<?> to get registries by name

#

just saying

flint coyote
#

lmao

tender shard
#

i mean why not lol

flint coyote
#

actually a fair point

#

would save me from building something myself

#

And enable a dynamic way of obtaining all registries

dense falcon
#

There is an event for players when there is a fight?

flint coyote
#

There is an EntityDamageByEntity Event

#

You would utilize that

tender shard
#

do you consider it to be a fight when a player meelee attacks another player once with bare hands?

#

and if yes, how long?

dense falcon
#

When a player do damage on a other player.

young knoll
#

There is a damage event

#

Yes

flint coyote
#

The EntityDamageEvent won't suffice unless you don't wanna know who attacked. The EntityDamageByEntityEvent does have both.

#

Keep in mind that the Damager can be a Projectile in which case you wanna check for the Shooter

kind hatch
#

You’d want to check regardless because the damager could be another entity.

shadow night
worldly ingot
#

The thing stopping me currently has been custom Bukkit registries

young knoll
#

But then where will we store the registry registry

worldly ingot
#

In a registry, obviously!

young knoll
#

It’s registries all the way down

halcyon mica
#

What event is fired when the player clicks on a recipe book to put items into the grid?

ivory sleet
#

I wanna say the prepare event

#

But that isn’t synonymous to the click

young knoll
#

Google only shows me a certain fork has an event for it

#

-_-

halcyon mica
#

The client sends a packet when placing the items for a recipe

#

So there has to be some sort of event for it

eternal oxide
halcyon mica
#

SlotType doesn't seem to cover the recipe book though

young knoll
#

Looks like spigot never got an event for it

#

Unless I’m missing something

quaint mantle
#

Im uncreative anyone got a easy way to make cool looking guis

#

i asked chat gpt but hes dumb

#

man cant even count

tardy delta
#

i told it to change the 7th bit and it changed the 5th

young knoll
#

Resource packs

#

Gotta get them super detailed GUIs

ivory sleet
quaint mantle
tender shard
quaint mantle
#

i mean thats also a way x)

ivory sleet
slim wigeon
#

Hey @tender shard . I seen you I would not say sick but lets say my brother had that issue in the past and I know how you feel. Continuous going to the hospital every month

young knoll
#

I still need to figure out how to make a gui for selecting RGB values

ivory sleet
#

That usually goes well since you get a good design for parent child behavior then inferred

young knoll
#

That isn’t horrible to use

slim wigeon
#

Anxiety and depression with that does not mix well

slim wigeon
young knoll
#

Okay but that doesn’t have anything to do with making a GUI for selection RGB colors

slim wigeon
#

We can use RGB on bukkit plugins?

grave plover
young knoll
#

Mhm

#

Well for text

#

You could make other stuff RGB for much longer

slim wigeon
#

Show a example please because I don't know if this is true

undone axleBOT
#

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

young knoll
#

Just a random google image

young knoll
#

Anyway I want to make an rgb selector for some particles

#

Sure I could have people just put the hex code in chat but that isn’t very end user friendly

eternal needle
#

Player target = Bukkit.getPlayer(args[0]); how can i get the args and the uuid at the same time? tag me

keen ferry
#

Why is Bukkit#broadcastMessage deprecated? What should I use instead?

wise mesa
#

its not?

keen ferry
wise mesa
#

maybe you're using paper api or something

keen ferry
#

ye im using paper

wise mesa
#

well don't ask here

#

they deprecate stuff they don't like

keen ferry
#

understandable, ty

wise mesa
#

and replace it with their own things

#

like adventure

keen ferry
#

Thought it was a bukkit thing!

wise mesa
#

no worries

pseudo hazel
#

making an rgb selector sounds like fun

#

but ig the hardest part would be the actual ui, like how do you make it intuitive to use

slim wigeon
# young knoll

I see, I think I remember seeing something like that. So that is what you want to do?

eternal needle
pseudo hazel
#

?learnjava

undone axleBOT
pseudo hazel
#

probably

#

like you can us getUniqueId() on your player to get its id

#

but idk what you mean by at the same time

eternal needle
pseudo hazel
#

okay, then do what I suggested

wise mesa
#

the one bad thing about the discord is that it doesn't filter out beginners as well

#

like when I was a beginner I never wanted to post on the forums because that was a lot of work so I would just google

#

but discord its so easy to ask dumb questions that I do it constantly all the time

young knoll
#

How do I integer?

wise mesa
#

use Integer all of the time

#

int is bad

quiet ice
#

Sorry, but this is objectively wrong. Use BigInteger instead.

pseudo hazel
#

actually, you need to buy my premium resource API GiantInteger

#

also known as Gi-Int

quiet ice
#

I don't get it

pseudo hazel
#

well i guess you dont think big enough

abstract rampart
chrome beacon
#

Then yeah it is affected

copper scaffold
#

Is there a way to cancel firespreding in a specific area that i have set?

young knoll
#

iirc our version of snakeyaml may also have some vulnerabilities

#

Mayhaps it's time to bump things

chrome beacon
copper scaffold
#

okay thx

buoyant viper
#

Hmm

eternal oxide
abstract rampart
#

True, but that situation could exist. This is a random example, but think a person helping an admin configure a plugin. Admin copies the config over with malicious SQLite URI and bam

chrome beacon
#

Well that admin could probably just install a malicious plugin

#

or if they have access to the config the credentials are probably there

eternal oxide
#

yep, any user who has root server access can exploit it.

abstract rampart
#

I'm not saying it's super likely or that the admin in question wouldn't be stupid for trusting it. Just that it's a possible situation that could be easily fixed by updating a dependency

eternal oxide
#

not easily as it would break any plugins using teh current SQLite dependency

young knoll
#

Oh?

#

Does it contain breaking changes

eternal oxide
#

They changed the connection URL in newer SQLite

#

old string will error

young knoll
#

I see

eternal oxide
#

I forget off the top of my head but I remember it breaking iConomy

sullen marlin
#

looking at the fix, it seems like they would already need to have the malicious code on the server too

abstract rampart
chrome beacon
#

true

#

Don't let your admin touch things if you don't trust them

abstract rampart
eternal oxide
#

I remember looking at it a while ago and reverting an version increase as it wasn;t much of an exploit.

sullen marlin
#

Doesn't look like it to me

#

Looks like all it allows is a carefully controlled URL to load a specific database file from the server's temp directory

#

I assume that allows code execution somehow, but still relies on getting that file into the server's temp dir

young knoll
#

Is the SnakeYaml update also breaking?

sullen marlin
#

Honestly I don't think this sqlite change is breaking

eternal oxide
#

It was probably not this specific fix, but a change to protocol in one of the newer versions

sullen marlin
#

The snakeyaml issue is different still, and also quite far overstated (just a default option allows loading arbitrary classes, which are already present on the server)

eternal oxide
#

I remember it bitched about the connection method and tells you to change to something else. I forget the details though

sullen marlin
#

That was MySQL not sqlite I think

young knoll
#

Still if the snakeyaml update doesn't break anything then I imagine it's worth it

eternal oxide
#

one sec I can go over commits and see

sullen marlin
#

It does, that's why it was foreshadows in 1.19

young knoll
#

Ah

sullen marlin
#

The Spigot sqlite is already very recent

buoyant viper
#

Me personally i would simply just

eternal oxide
#

Actually it wasn;t SQLite, it was h2

#

my memory bad

young knoll
#

if (hasRCEExploit) {
dont();
}

buoyant viper
#

hMod for MC 1.20 when?

young knoll
#

I think we are up to iMod now

#

Oh shit now apple is gonna sue me

sullen marlin
#

F

tender shard
#

https://paste.md-5.net/famufogime.cpp is anyone else doing configs like this, or just hardcoding the key names everywhere?
Or rather create a class that returns the values directly, like this?

public class MainConfig {
    
    private final Drop2Inventory plugin;
    
    public MainConfig(Drop2Inventory plugin) {
        this.plugin = plugin;
    }
    
    public boolean getEnabledByDefault() {
        return plugin.getConfig().getBoolean("enabled-by-default");
    }
    
    // etc
    
}

or maybe even another way?

#

I somehow do it differently in every plugin lol

ivory sleet
#

I would probably just depend on FileConfiguration or an anti derivative type instead of ur main plugin type @tender shard

livid dove
#

Enums are life

ivory sleet
#

But else that’s how you usually define rich configuration objects

tender shard
#

or maybe like this, caching the values

public class MainConfig {

    private final AnotherPlugin plugin;
    
    private final boolean enabledByDefault;

    public MainConfig(AnotherPlugin plugin) {
        this.plugin = plugin;
        this.enabledByDefault = plugin.getConfig().getBoolean("enabled-by-default");
    }

    public boolean getEnabledByDefault() {
        return enabledByDefault;
    }

    // etc

}

subtle folio
#

enum as for config ?

tender shard
ivory sleet
tender shard
#

I just wondered how other people usually do it

ivory sleet
#

I know a lot of plugins like to do straight raw object mapping

tender shard
#

because I've see so many times where people call plugin.getConfig().get("someKey") in 20 different places and I wonder why

ivory sleet
#

that’s bad

tender shard
#

like, they hardcode "someKey" everywhere instead of doing it once, and I always wondered why

ivory sleet
#

Thats leaky abstraction v

ivory sleet
tardy delta
#

i saw code where every time someone called getKey it loaded the same json file, man called it 14 times in startup 💀

ivory sleet
#

Its a never do

livid dove
tender shard
#

that's almost as bad as synced update checking

young knoll
#

Did someone say raw object mapping

tardy delta
#

im still wondering why people use that crap

ivory sleet
#

That’s how I do it professionally probably

ivory sleet
#

A weird constructor and some stuff but else nice

livid dove
#

Any feedback is good feedback

ivory sleet
#

Myea well, I think alex wanted a more strongly typed config class definition

young knoll
#

I’ve got that wacky reflection going on

ivory sleet
#

so he does not have to fill in keys as string every time

livid dove
young knoll
#

If you just don’t look at the reflection code then it’s fine :D

ivory sleet
#

interface Configuration {
boolean enableBypassHacks();
String mySqlPassword();

}

#

Such that the members match the typed config format Ig?

#

@tender shard no?

#

(I mean obv u dont need an interface)

tender shard
ivory sleet
#

Looks fine

tender shard
#

where Config extends YamlConfiguration

#

I think that's my favorite way

livid dove
wary topaz
#

what was that config api again?

ivory sleet
#

Thatc

wary topaz
#

Or class

ivory sleet
#

?

wary topaz
#

mfnalex

ivory sleet
#

Jefflib

#

I think?

#

@tender shard have you looked how luckperms does it for instance

wary topaz
#

is it a spigot page?

ivory sleet
#

Its a bit of an enterprise engineering but ye

river oracle
livid dove
#

Im trying to figure out if the way ive done it with the Enums and a manager isnt a good solution to the problem

wary topaz
#

alr than thas it

river oracle
tender shard
#

I always have everything as top-level-keys

river oracle
tender shard
young knoll
#

Make a gui to change it in game :p

livid dove
ivory sleet
tender shard
#

that depends on what you mean with that. what does it do? do you mean it should run a bungeecord server directly? because very little plugins I can imagine, where this would make sense

ivory sleet
#

(It allows for powerful abstraction)

livid dove
tender shard
river oracle
#

this is prob one of the worst impls and makes 0 sense

ivory sleet
ivory sleet
#

That way you decouple the loading logic, source sink logic and pathing logic from other modules

#

So if something regarding the config module implementation needed a change, your other modules would stay unaffected by the change

eternal oxide
#

spigot uses plugin.yml. Bungee supports plugin.yml IF it doesn;t find a bungee.yml

tender shard
#

ah okay. In that case, you'd have two main classes, one extends Bungee's plugin, and one extending spigot's JavaPlugin.
then yo uhave a plugin.yml for spigot and a bungee.yml for bungee

wary topaz
river oracle
tender shard
#

yeah that's what I would have written next

wary topaz
#

oh wait thats not it

ivory sleet
#

Let’s say you use plugin.getConfig().getInt("blobIsDodoDinosaurSpigot”) in ur commands, listeners etc

wary topaz
#

ty

ivory sleet
#

What if you need to change the config object? Or change the path? Or something else?

#

That’d imply having to find every class that uses the plugin.getConf… and change it manually

#

painful, and if you work with multiple jars, even more painful

river oracle
#

the abstraction thing I said, but otherwise no

#

I'd recommend using a multi-module project

#

bungee module
spigot module
api module / core module

livid dove
ivory sleet
young knoll
#

The key for handling configs is all the annotations

ivory sleet
#

I think the issue with using an enum is type awareness

tender shard
#

yeah and then you have to ofc also write code for both. I would use three maven modules

  1. core (handles loading config, etc, has an interface for e.g. "announce")
  2. bukkit (handles spigot stuff, e.g. main class, and implements the interface by using Bukkit.broadcastMessage)
  3. bungee (same as bukkit for bungee)
ivory sleet
#

Since enums don’t allow generic type parameters

tender shard
river oracle
#

no

#

entire separate modules

#

otherwise you'll have dependency issues

livid dove
# ivory sleet I think the issue with using an enum is type awareness

The enum in this case is designed to go grab the value.

I.e. there will always be a "getValueAdress".

The beauty of the types of my values is that each value type has its own method. So there is no chance of grabbing the wrong type etc. Hell in future I could set the manager up generically and have it sanity check the type its grabbed before sending it back to the user

river oracle
ivory sleet
#

like if u wanted to add a method to get org.bukkit.entity.Player for instance

#

that'd have to be hard coded

livid dove
#

From a config?

ivory sleet
#

yes

#

as an example

#

more appropriately u might have the class MySqlCredentials, or ItemStack or sth

#

the amount of classes is a spectrum, continuum yk

livid dove
#

With the greatest gosh giddigy garn respect. Why in the great jumping jesus on a pogo stick would you use configuration files for anything other than just your base values....

#

Im not gonna be storing players in a config file. My config files are not hotels damnit!

#

xD

ivory sleet
#

I mean why would skip deserialization of complex types with only base values

#

that's not the point tho

#

its not uncommon to have config types of lets say List, Collection Set etc

livid dove
#

Now that is fair but still... I dunno... it seems really odd to be storing that stuff in a config.

Or at least in my mind, configs are supposed to be user side friendly. Its what your joe schmo down the street is used to right?

#

So adding all the extra gubbins in

ivory sleet
#

it has nothing to do with user friendliness

#

like its just that u decide to make it simple for u

livid dove
#

I do not follow

river oracle
#

not really any good oens I know of

ivory sleet
#

would u favor

ComplexType type = new ComplexType(config.getString(Key.KEY_1), config.getInt(Key.KEY_2),...,config.getString(Key.KEY_N))

or just

ComplexType type = config.get(Key.KEY_T);

(Key.KEY_T is not an enum constant)

#

I mean I can already say I'd prefer the latter

atomic swift
#

i though BlockBreakEvent had like an getAffectedBlocks method to get a block like a door if it was broken by a block

livid dove
# ivory sleet would u favor ```java ComplexType type = new ComplexType(config.getString(Key.KE...

Ngl this is where I start to disagree. I think having the enum constants in there is a great idea purely for the reason i can compartmentalise my various settings more easily.

I think there is benefit to be had, perhaps in even a mix of the 2 options. But I feel uncomfterble having to continoually rely i havent screwed up my file types in the config, not finding out till i try testing the damn thing xD

ivory sleet
#

u do u

young knoll
#

I prefer

livid dove
#

Id be interested to try a mix of the 2

young knoll
#

@ConfigEntry("enabled")
    @Comment("Enable/disable this spell part. Disabled parts cannot be used in spells.")
    private boolean enabled = true;
ivory sleet
#

looks usable but a compromise in respect to design

livid dove
ivory sleet
#

well it is abstraction layers and just a lot of thought put into design

#

whilst it does compromise usability a bit

livid dove
#

I dunno man. Im looking at this and all I think is "jesus this could of been turned into an ENUM or literally anything else.

Break down each section of the config into different classes, be able to be more easily compartmentalised / envisioned by devs working on it

#

Im an aerospace engineering lecturer irl and I have "Raz's Rule" (Real name obvs)

#

The rule? "Human beings will screw up at least 20% of the time"

#

I see a 740 line class and I just see "Accident waiting to happen"

ivory sleet
#

I mean u have test driven development

#

which is what companies enforce

#

sometimes just AGILE in general

livid dove
#

I get that. I really do. But it doesnt change the fact 700 lines in one class is bad form imo

#

Its a class... for configuration settings

ivory sleet
#

yeah u can spread the key constants out into different classes sure

#

its just a compromise of maintainability to centralization

livid dove
#

Ew

#

Centralization

ivory sleet
#

its needed often

#

in fact ur design is also involving it

livid dove
#

Eh The way I see it I could slap a new section of my config today, and all it requires is a new enum.

ivory sleet
livid dove
ivory sleet
#

here u centralize around ur plugin main

livid dove
#

The class does one thing

#

manages the config

ivory sleet
#

thats not the point

#

it is coupled to ur plugin main class type lol

livid dove
#

Right? So whats the issue?

#

When i heard "Cetralization" i figured u meant more like what LP did

#

Where they slapped everything and the kitchen sink into one 700 line monster of a class

#

Values, methods etc

ivory sleet
#

na not rly

#

lines is irrelevant to some extent

#

but obv 3000 lines does imply bad design choice

livid dove
#

What would you suppose the "new line to new addition" ratio of that class from LP is?

#

Thats where i'm getting seriously off vibes with LP's example

ivory sleet
#

which class ?

livid dove
#

keys

ivory sleet
#

its in one class for several reasons

livid dove
#

I mean if i am completely blunt?

#

Its almost like, in my humble little dumb dumb brain, looks to me as they have just essentially accidentally rewrote the configuration file again in that class

#

E.g: You mentioned the more complex cases and values right?

ivory sleet
#

yes but there are other benefits to object mapping

#

tho its more of an enterprise and pro practice

livid dove
#

For record, if I needed more complex values in my plugins, i'd add a new method to the config manager ngl.

#

same retrieval processes

#

Just... more complex.

ivory sleet
#

na not really

livid dove
#

Ah anywho

#

Its better than core protect ad thats the important thing xD

ivory sleet
#

its better than 95% of plugins design wise

livid dove
#

im touched

ivory sleet
#

I meant LP

livid dove
#

-_-

ivory sleet
#

urs is also probably better than most tbf xD

livid dove
#

I will fight LP

#

xD

ivory sleet
#

:)

livid dove
#

Im half irish so i can get em for copyrights

livid dove
#

lmao

#

There are things im 100% not happy with in landlord

#

for example, the messages class is a mess

#

Actually embarassing

ivory sleet
#

idk

#

looks decent

#

doesnt know how to use components

livid dove
#

You dont or I dont lol

livid dove
livid dove
#

How so?

ivory sleet
#

first of all I'd use other, more sophisticated component framework clsses

#

but also mini message lmao

livid dove
ivory sleet
#

nrn but later sure

orchid gazelle
#

Eww textcomponents

#

String with color codes gang here

livid dove
#

You hurt me

orchid gazelle
#

No why make extra effort?

livid dove
#

Custom colors, easy formatting, hex colors

#

etc

young knoll
#

Strings support all of that

livid dove
#

And strings totally tell you when youve got it wrong right?

#

Right?

#

Unless ive missed a trick, if you make a multi color string for a message raw... the moment u'll find out if its worked proper is in the test 😉

orchid gazelle
#

Or you just... know what you are doing?

livid dove
#

Another thing I teach my students literally all the time.

"protect your stupid"

young knoll
#

All my messages are just pulled from a file anyway

livid dove
orchid gazelle
#

Its not for a simple and unimportant thing like multicolored messages lol

livid dove
#

Cause im always happy to see other perspectives

orchid gazelle
#

Someone give me an example rq

ivory sleet
#

what are you a teacher in if I may ask?

livid dove
ivory sleet
#

ah

#

I assume it does not involve that much design practices etc? rather just programming related to aerospace stuff?

livid dove
#

*for coding side

#

I did not self teach myself aerospace engineering xD

#

Let me rephrase:

I have a first class masters in aerospace (honrs babbyyyy) and ive self taught myself java in the last 6 months.

ivory sleet
#

ah alr

wary topaz
#

`getLogger().info("======================================");
getLogger().info(translationManager.getTranslation("plugin.enabled"));

    List<String> startupMessages = translationManager.getBulkTranslation("plugin.startupMessages");
    for (String message : startupMessages) {
        getLogger().info(message);
    }

    getLogger().info("Version: " + getDescription().getVersion());
    getLogger().info("Author: " + getDescription().getAuthors().get(0));
    getLogger().info("======================================");

`
This look good?

ivory sleet
orchid gazelle
#

I have been coding for 6 years and my code is still the biggest garbage ever ;)

ivory sleet
#

ye

#

sadly time is irrelevant to ur experience

orchid gazelle
#

The thing is

livid dove
#

Indeed

orchid gazelle
#

I do not have that low amount of total projects written

livid dove
#

Easiest way to learn anything imo? Do the stupid shit intentionally

#

to see how dumb it is

orchid gazelle
#

But yeah... idk what im missing on

livid dove
#

then do it the proper way

livid dove
abstract rampart
livid dove
livid dove
abstract rampart
#

Lol yes. Trial by fire

livid dove
#

Nasa blew up 30 million dolar engines to fix a problem by Randomly changing the shape of holes in a plate with no maths involved to fix a problem once

orchid gazelle
#

Idk if its a bad habit if its the the thing I like most

livid dove
#

trial by fire is how we got here

ivory sleet
livid dove
livid dove
ivory sleet
#

i disagree

orchid gazelle
livid dove
orchid gazelle
#

xD

ivory sleet
#

:>

livid dove
topaz atlas
young knoll
#

That’s like

#

Nearly every case

livid dove
orchid gazelle
#

Lol

abstract rampart
#

Why use descriptive names when random letters do trick

young knoll
#

Exactly

topaz atlas
#

i cntr f and replace

young knoll
#

Manual obfuscation

livid dove
#

Put all ur code onto one line. That way you know where everything is

ivory sleet
#

i mean the rule is the name should be proportional to the scope

livid dove
#

everything onto line one

#

easy

topaz atlas
ivory sleet
#

no always

#

always always

topaz atlas
#

Why?

orchid gazelle
#

My methods be like: public void a0Lan4fB1sI()

abstract rampart
#

Had a stroke reading that

livid dove
topaz atlas
#

the reason naming conventions exist is for clear communication of your code

livid dove
#

Audible is prefered as the ADHD hits hard sometimes

#

xD

topaz atlas
#

otherwise it has no purpise if you dont want to share

livid dove
topaz atlas
#

Indentation is a good practice, but there are things that automaticall format

young knoll
#

Until you come back to your code 6 months later and don’t understand anything

livid dove
#

Dont be like einstein

topaz atlas
orchid gazelle
livid dove
#

Relative

young knoll
#

“What’s this variable for and why is it called boobs”

livid dove
#

😉

abstract rampart
#

Fr though, I have a ton of small-ish plugins I maintain and any time I need to fix something I have to borderline reverse engineer it to figure it out. Poor naming conventions would make it 10x harder

livid dove
#

Did u guys ever spot btw how the crops modifier in spigot was broken fro like 4 years?

topaz atlas
orchid gazelle
livid dove
young knoll
#

Did spigot even patch the crop modifiers

#

I thought that was downstream

livid dove
#

lol

#

it was a week into me learning java i spotted it. It was the moment I went "jesus christ if I put effort in I'ma gonna fuckin thrive here"

orchid gazelle
topaz atlas
livid dove
ivory sleet
livid dove
#

To name a few personal benefits

young knoll
#

I’m on it

topaz atlas
# ivory sleet well mainly but there are other reasons also

If your going to bring up rememberance, then, yeah if you have trouble remembering things then use descriptive names, I mean for example, js has crazy naming conventions, like, for (let i, Array.lenght, i++)
apprently for loops your supposed to have only i or j as varibles, which is probably going to be cared about in a professional setting

orchid gazelle
#

Psssht md5 you won't read this message

young knoll
#

Yeah just slip it in

#

No one could ever notice

topaz atlas
#

lmao

ivory sleet
orchid gazelle
#

md_5 checking the PR: "hmmm this is FINE, im in"

orchid gazelle
#

It also may be an issue that I gotta go to school in 5 hours

livid dove
#

I hope you can forgive this single intrusion. But I just got Chat-GPT to write something as a funny and it honest to god SLAPPED on the first try lmao.

I met a coder from an antique startup
Who said: "Two vast and trunkless classes of code
Stand in the workspace . . . near them, on the desktop,
Half sunk, a shattered comment lies, whose symbols,
And function calls, and unreadable syntax,
Tell that its sculptor well those passions read
Which yet survive, stamped on these lifeless things,
The hand that mocked them and the heart that fed:

And on the commit message, these words appear:
My name is Coderzmandias, King of Kings;
Look on my Works, ye Mighty, and despair!
Nothing beside remains. Round the decay
Of that colossal wreck, boundless and bare
The lone and level sands stretch far away."

Revising, I read through his cryptic verse,
Straining to glean some logic from the terse.
For his creations, so complex and vast,
Yet to others, they're relics of the past.

Of these lines of code, to his boast's compare,
Only confusion and frustration bear.
His 'Works', once mighty, in obscurity lay,
Engulfed by the sands of time, in endless array.

topaz atlas
ivory sleet
#

na

#

like for instance

#

catch(Exception e)

#

that scope is small

#

thus the variable name can be short

young knoll
#

How small are we talking

topaz atlas
#

Thats a rule that I can agree with, small scopes get small names

young knoll
#

What about a zero width space

ivory sleet
topaz atlas
#

im just saying, you need to focus more on comments than naming. Comments are literally the best way to communicate what your doing

ivory sleet
#

na