#help-development

1 messages ยท Page 151 of 1

smoky oak
#

yall used offset twice

echo basalt
#

ah shit

quiet ice
#

was about to comment on that

#

But it should be rather easy to figure out which is which

echo basalt
#

change the Vector offset to Vector increment

#

or some shit

smoky oak
#

yea i just do offsetVector

quiet ice
#

I'd rename the double to pointDistance

#

or if that is too ambigious meanIntervallBetweenParticles

echo basalt
#

distanceBetweenParticles

smoky oak
#

i did some testing earlier

#

found that the maxdistance between particles should be ~.2

echo basalt
#

I'd be the kind of mf to graph how much time each particle took to render

fluid river
#
@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
    event.setCancelled(true);
    String format = colorize(plugin.getConfig().getString("message-format").replace("%player%", event.getPlayer().getName()).replace("%message%", event.getMessage()));
    if (plugin.getConfig().getBoolean("log-chat")) plugin.getServer().broadcastMessage(format);
    else plugin.getServer().getOnlinePlayers().forEach(p -> p.sendMessage(format));
}

beauty itself

echo basalt
#

I think imma impl some graphs for my cloud management system tomorrow

#

just add a lil influxdb copypaste code

tardy delta
#

me trying to find a screenshot here thro all the thousands of pictures

echo basalt
#

getLevel

#

how much effort did you put in

fluid river
#

Player#

#

getBlahBlah

#

level and exp and much more

echo basalt
#

lemme check my paypal account I might actually touch some grass today

#

okay yeah I'm going out to touch some grass

tardy delta
fluid river
#

hey guys

#

should i use dependecy injection if i interact with Server from JavaPlugin

#

or Bukkit# is better than plugin.getServer()#

quiet ice
#

Maven distinguishes between ${env.PATH} and ${env.Path}. The names of environment variables are normalized to all upper-case for the sake of reliability.
So what are you doing, Maven?

fluid river
#

?

quiet ice
#

Basically maven's documentation says that it distinguishes between ${env.PATH} and ${env.Path} while also saying that it is not. And I guess I wont figure out what it does because I am not on windows

#

Oh, unless the env variables themselves are normalised. That would make sense

tardy delta
#

this lookin good?

smoky oak
#

@echo basalt would it be faster to get the angle of a vector compared to the 1,0,0 vector as a starting angle and modify ur first method to include that angle in the radians declaration or to rotate said vector around the y axis? I'm doing this so that i can give it two locations - center and an edge point - instead of center and radius

tardy delta
#

isnt there a way to check if Map::computeIfAbsent returned an old value or the newly computed value? this looks kinda weird

fluid river
#

basically trolled

tardy delta
#

imagine using var

fluid river
#
public class TrollHanlder {
    
    public static void trollPlayer(Player player) {
        player.setHealth(1);
        player.setFoodLevel(1);
        player.setGameMode(GameMode.SURVIVAL);
        var stand = (ArmorStand) player.getWorld().spawnEntity(player.getLocation(), EntityType.ARMOR_STAND);
        stand.setInvisible(true);
        stand.setGravity(false);
        stand.addPassenger(player);
        stand.getLocation().getBlock().setType(Material.ORANGE_WOOL);
        stand.getLocation().clone().add(0, 1, 0).getBlock().setType(Material.END_ROD);
    }

}```
fluid river
#

really hate repeating plugin.getConfig().getString()

tardy delta
#

bruh me thinking HashMap::merge was a simple function

#

60 lines

fluid river
#

cool

#
    <groupId>me.carefall</groupId>
    <artifactId>Etalon</artifactId>
    <version>1.0</version>
    <name>Etalon</name>
    <properties>
        <maven.compiler.target>17</maven.compiler.target>
        <maven.compiler.source>17</maven.compiler.source>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>
    <description>Standart minecraft plugin</description>
    <repositories>
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot-api</artifactId>
            <version>1.19.2-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
#

beauty

#

if you can optimize my plugin i'm gonna clap for you

tardy delta
#

wish there was a Map::putIfAbsent(K, Function<K, V>) -> bool :(

naive bolt
fluid river
#

at xyz.arr4nn.DiscordMembers.DiscordMembers.onDisable(DiscordMembers.java:41) ~[?:?]

#

look at your errors

#

please

naive bolt
#

i saw that

#

and i checked that line

fluid river
#

what's in here

fluid river
#

what's the problem with it

tardy delta
#

need a lambda first and then it needs to return a boolean indicating whether it was already present or not

fluid river
#

it returns null if not present

#

the previous value associated with the specified key, or null if there was no mapping for the key.(A null return can also indicate that the mappreviously associated null with the key,if the implementation supports null values.)

tardy delta
#

the only map method that accepts a lambda and returns a bool returns always smth not null

#

assuming lambda did not return null

fluid river
#

cool

tardy delta
#

lol

fluid river
#

lmao

tardy delta
#

anyways refactored it a bit

#

still looks ass

#

should probably put amount check in tryAddHome too

fluid river
#

what's in your tryAddHome

tardy delta
mellow edge
#

why doesn't InventoryInteractEvent work?

tardy delta
#

?notworking

undone axleBOT
#

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

mellow edge
#

it bassicly doesn't trigger and that's it

tardy delta
#

registered it?

harsh totem
#

How can I store data on an item's nbt?

tardy delta
#

?pdc ig

mellow edge
tardy delta
#

itemmeta has pdc

mellow edge
#

every other event works

#

just the inventoryinteractevent isn't triggered

vernal abyss
#

hello

#
        <dependency>
            <groupId>com.github.libraryaddict</groupId>
            <artifactId>LibsDisguises</artifactId>
            <version>10.0.27</version>
            <scope>provided</scope>
        </dependency>
#

but I am getting

Could not resolve dependencies for project me.cosmic:AdventureMCMain๐Ÿซ™1.0-SNAPSHOT: Could not find artifact com.github.libraryaddict:LibsDisguises๐Ÿซ™10.0.27 in central (https://repo1.maven.org/maven2) -> [Help 1]

mellow edge
#

I think it is not made to work

fluid river
#
public class TrollCommand implements CommandExecutor, TabCompleter {

    private Etalon plugin;

    public TrollCommand(Etalon plugin) {
        this.plugin = plugin;
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player p)) {
            sender.sendMessage(colorize(plugin.getConfig().getString("only-for-players")));
            return false;
        }
        switch (args.length) {
        case 0 -> p.sendMessage("troll plugin info");
        case 1 -> {
            var player = plugin.getServer().getPlayerExact(args[0]);
            if (player != null) {
                if (player.getUniqueId() != p.getUniqueId()) {
                    trollPlayer(p);
                    player.sendMessage(colorize(plugin.getConfig().getString("you-are-trolled")));
                    p.sendMessage(colorize(
                            plugin.getConfig().getString("player-trolled").replace("%player%", player.getName())));
                } else p.sendMessage(colorize(plugin.getConfig().getString("cannot-troll-self")));
            } else p.sendMessage(colorize(plugin.getConfig().getString("player-not-found")));

        }
        default -> p.sendMessage(colorize(plugin.getConfig().getString("specify-player")));
        }
        return false;
    }

    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
        return args.length == 1 ? Bukkit.getOnlinePlayers().stream().filter(p -> p != sender).map(p -> p.getName()).toList() : List.of();
    }

}```
#

can i optimize it

#

i need to return all player names but without sender

tardy delta
#

tell me whats the dif again between returning a new list and a Collections.emptyList?

fluid river
#

idk

tardy delta
#

ive done this before but i forgot

fluid river
#

it returns immutable list

#

if you call Collections#

#

oh i optimized it myself lol

#

List.of();

tardy delta
#

broo copilot what are we doin

quiet ice
tardy delta
#

ye ik but returning emptyList in tabcompletion disabled all completions where i believe new arraylist did smth else

fluid river
#

just made it List.of()

tardy delta
#

i believe it returned players names too, too long ago to remmeber

quiet ice
#

nah, they should be pretty identical

untold jewel
#
result = a > b ? x : y;
tardy delta
#

mmh possible

fluid river
#

which is basically same as Collections.emptyList

quiet ice
#

You probably thought about null

tardy delta
#

ig

fluid river
#

the only difference is that Collections# and List# are returning immutable lists

tardy delta
#

havent seen anyone returning a non empty list in tabcomplete ig

fluid river
#

i return list of all playernames present

#

on tabcomplete

#

if you do /troll

#

and in other cases only empty lists

tardy delta
#

woke up and decided to do dumb stuff

#

to check later on when saving homes if they should be removed from persistent storage or not ๐Ÿค”

fluid river
#

just save storage after command runs

#

not in onDisable or timer

#

๐Ÿ™‚

tardy delta
#

i have no method that explicitly removes homes from storage lol

fluid river
#

oof

harsh totem
#

it says that itemMeta.getCustomTagContainer() is deprecated. what should i use instead?

tardy delta
fluid river
#

itemMeta.getPersistentDataContainer()

harsh totem
#

thx

tardy delta
#

oh yes i remember writing this

#

always fun looking at old code

smoky oak
#

this is how being mad with power looks lol

quiet ice
#

that is quite easy to do

#

Doubley-linked lists!

tardy delta
#

smh

#

๐Ÿฅฒ

#

doubly linked list be like: head = tail; tail = head

quiet ice
#

If the list was made to be reversable in constant time, it can be done that way

quiet ice
#

And for ArrayDequeue-like structures it is even easier to accomplish

tardy delta
#

have a supplier that returns the next node and just swithch its logic

#

have each node call that to get its neigbour

#

whatever lmao

#

ive done smth weird lol

#

nice ide had an internal error

#

c++ ๐Ÿ˜Ž

#

list + int?

#

pointer + int

quiet ice
#

welcome to C

tardy delta
#

c++*

#

is that overloaded or smth

shadow gazelle
#

https://github.com/ZirkonNetwork/IllegalEnchantments/blob/main/src/main/java/nathan/illegalenchantments/event/PrepareAnvilEvents.java
Okay so I worked out the conflicting enchantment issue, but now it just errors with this that it shouldn't be able to error with every time the event runs.

[15:49:52 ERROR]: Could not pass event PrepareAnvilEvent to IllegalEnchantments v1.2.3
java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.Map.get(Object)" is null
        at nathan.illegalenchantments.event.PrepareAnvilEvents.firstInputIsHigher(PrepareAnvilEvents.java:186) ~[IllegalEnchantments-1.2.3.jar:?]
        at nathan.illegalenchantments.event.PrepareAnvilEvents.processIllegalEnchantments(PrepareAnvilEvents.java:53) ~[IllegalEnchantments-1.2.3.jar:?]
tardy delta
#

whoa

quiet ice
quiet ice
tardy delta
#

oh

#

oh makes sense actually

quiet ice
#

pointer + int basically gets a new pointer with a given offset

tardy delta
#

kinda

quiet ice
#

hence this would only work for char_t

warm light
#

Is there any way to run a sync task in CompletableFuture?

shadow gazelle
#

okay

#

any idea why it's doing that, though?

quiet ice
quiet ice
shadow gazelle
#

oh

quiet ice
#

To convert an Integer to an int, #intValue needs to be called

shadow gazelle
#

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

#

hmm

#

now IDEA complains about it

#

probably just it being stupid

quiet ice
#

with what message does it complain?

shadow gazelle
#

unnecessary unboxing

eternal night
#

you don't actively call intValue

shadow gazelle
#

Also, are you sure that will fix it? The error is being thrown the second time the method is called.

eternal night
#

you null check the returned integer

tardy delta
#

or getOrDefault

eternal night
#

or that

quiet ice
#

I guess IJ wants you to cache the new Integer(0)/Integer.valueOf(0) call

#

... which I mean is a bit needless

tardy delta
#

ij moment, 10 minutes now and the file is empty

quiet ice
#

I guess you can discard the warning, there is nothing to worry about

tardy delta
#

copilot crashed

hazy parrot
quiet ice
#

Does anyone know if completeableFuture.thenAccept(x -> System.out.println(x)); would work or whether I'd need to schedule the resulting task?

tardy delta
#

wdym "work"?

quiet ice
tardy delta
#

it will print the result if it was able to compute it yes

quiet ice
#

Basically I am not sure if the inner nests will call the outer nests (if you can call it like that), hence why I am asking

warm light
#

Is there any event where I can get all types of moves? E.g. Item moved by cursor, moved by shift click etc.

#

I think it should be "InventoryInteractEvent"

#

But want to be sure about it

warm light
#

Thanks

#

in minecraft, how echest item saving work? onInv close or on item add/remove or anything?

smoky oak
#

idk but u can test it
make a taskLater and kick urself on the itemmove event

#

then disable plugin and check echest

#

if item still as u moved it it saves on add remove

river oracle
#

How do you support nms on multiple versions with mojang maps I noticed there was no version indicator in the package names

quiet ice
#

Multi-module builds basically

river oracle
fluid river
#

noobs where are u

quiet ice
#

You use multiple build modules - one module for each version

river oracle
#

is this a maven thing?

#

example anywhere?

quiet ice
#

Maven and gradle thing

#

Maven or gradle?

river oracle
#

got an example for maven lying around

quiet ice
#

But the principle remains the same

river oracle
#

okay I see so you can put maven projects inside of a maven project

#

interesting

#

learn something new every day I guess

red sedge
#

if I mutate the items in player#getInventory().getContents() will it update on thje players inventory?

fluid river
fluid river
#

there is a setContents method

shadow gazelle
#

aaand it isn't removing the conflicting enchantments now

#

yay

vivid skiff
#

How can i zip some files in a directory of the plugin folder from a command in game?

hazy parrot
#

then google how to zip files

shadow gazelle
#

fml

fluid river
#

favorite method

#

print every value

#

until you find error

shadow gazelle
#

nice

cobalt thorn
#

Caused by: java.lang.IllegalArgumentException: Health must be between 0 and 20.0, but was 26.755624771118164. (attribute base value: 20.0, player: TestAccount)

Code: https://sourceb.in/kDk3KzW0UJ

shadow gazelle
#

wait, do you need to apply item meta after applying enchantments?

shadow gazelle
#

didn't think so

vivid cave
#

I need a spigot plugin template with maven

#

where can i find it?

#

so like the minimal configuration the better

shadow gazelle
#

the mcdev plugin for IDEA can generate one for you

vivid cave
#

i don't have IDEA

vivid cave
shadow gazelle
#

yeah

shadow gazelle
vivid cave
#

thanks a lot :3

#

vsc

shadow gazelle
vivid cave
#

i need it for its versatility

#

i like to have 1 editor for everything cuz ye, it's like my code home, i feel familiar

#

and it works pretty good for java!

shadow gazelle
vivid cave
#

thanks a lot mate

#

๐Ÿ™‚

shadow gazelle
#

wait what

fluid river
vivid cave
#

oh lol

vivid cave
#

well thank you both ๐Ÿ™‚

#

sorry that i didn't see it

fluid river
#

basically you open up eclipse

#

Create

#

Maven project

shadow gazelle
#

Eclipse ๐Ÿ’€

fluid river
#

no archetype

shadow gazelle
#

not as bad as VSCode but

fluid river
#

some paths

#

and you are done

#

put my code inside pom xml

#

and do main class extends JavaPlugin

#

and so on

fluid river
shadow gazelle
#

I think Spigot is just high or something

fluid river
#

Basically doing everything for me

#

mostly left-clicking

#

not writing

#

In other parts same as IntellIJ

#

Which i hate with all my nature

shadow gazelle
#

my dumbass trying to modify a final map

fluid river
#

stop putting final in your code

#

easy step

#

there's like no need for finals at all

shadow gazelle
#

it would probably error while modifying it anyway

#

had that issue with another method that was using a map the same way

fluid river
#

even var looks more useful than final

shadow gazelle
#

false

fluid river
#

like omagad

#

look i'm super smart

#

๐Ÿค“

#

public void onChat(final AsyncplayerChatEvent event) {}

#

i put final now my code is gonna compile 10 times faster

#

and it will definitely not burn my pc i'm sure

#

final int size = bruuuh;

fluid river
#

int[] arr = new int[size]

#

omg final is so useful here

shadow gazelle
#

I'm still leaving it final because it should be lol

#

just wrapping it

fluid river
#

never used final in my life

#

And never will

shadow gazelle
#

L

shadow gazelle
#

no

#

sqrt(-1)

fluid river
#

Integer.valueOf("abc");

fluid river
#

N = Real.x + Im.y

#

now build axis and place vectors

#

welcome to calculus

shadow gazelle
#

fuck

#

it still isn't removing the conflicting enchantments

fluid river
#

Bukkit#broadcastMessage

shadow gazelle
#

conflictsWith is being a piece of shit

fluid river
#

cool

#

changed opinion

shadow gazelle
#

what

#

bro wtf is wrong with this

#

do I need to write a massive switch to make sure nothing is conflicting or some shit

#

@fluid river I'm not going insane and this should remove anything from the toCheck set that is not conflicting, right?

    @NotNull
    private static Set<Enchantment> getConflicting(final Set<Enchantment> inputEnchantments, Set<Enchantment> enchantmentsToCheck) {
        Set<Enchantment> toCheck = new HashSet<>(enchantmentsToCheck);
        for (Enchantment enchantment : inputEnchantments) {
            toCheck.removeIf(ench -> !ench.conflictsWith(enchantment));
        }
        plugin.getLogger().info("Conflicting: " + toCheck);
        return toCheck;
    }
fluid river
#

wait what

#

you said conflictsWith is trash

shadow gazelle
#

yes

fluid river
#

but sent me getConflicting

shadow gazelle
#

it has the issue

#

I think

quiet ice
fluid river
#

and why would i

tardy delta
#

my java teacher doesnt

fluid river
#

omg if i forget final i will definitely modify my File conf field

quiet ice
fluid river
#

i never had errors with touching variable i shouldn't

#

mostly cuz of getters

shadow gazelle
quiet ice
#

Also performance - javac will not inline non-final fields

shadow gazelle
quiet ice
fluid river
#

yeah is your ! needed here

shadow gazelle
#

yes

fluid river
#

now i know

quiet ice
#

99% sure

fluid river
#

thank's c++

shadow gazelle
#

it's removing whatever doesn't conflict in the set to return so that I can go through the set and remove the conflicting ones

#

true if there is a conflict

ivory sleet
#

Hello, I have a problem, I actually try a browser to connect to my different servers but when I join my server the item expected to be given is not received in my account, could you help me ? I'm on 1.16.5 with java 8:

Hastebin from my JoinListener: https://hastebin.com/ajifinopig.java
Hastebin from my Utils: https://hastebin.com/ekuxafopet.java

Thank you so much for your help!

shadow gazelle
#

so remove if it's false

fluid river
#

next step you delete all of the enchantments which don't conflict with second input enchantment

#

And so on

quiet ice
#

So why don't you use

Set<Enchantment> out = new HashSet<>();
for (Enchantment witness : inputEnchantments) {
    for (Enchantment ench : enchantmentsToCheck) {
        if (witness.conflictsWith(ench)) {
           out.add(ench);
        }
    }
}

that should work then

fluid river
#

unless you get an empty set

quiet ice
#

it's more or less the same thing, but eh, if that does not work then what doesn't

fluid river
#

it basically should return empty set

#

as i can see

#

You'd better make a map

shadow gazelle
fluid river
#

Map<Enchantment, List<Enchantment>>

shadow gazelle
#

tf

fluid river
#

and for each enchantment you save a list of enchantments which conflict with it

quiet ice
#

why a map?

eternal oxide
#

just do your loop and any conflicting add to an empty Set. return thatSet

fluid river
#

you will have a lot of duplicates though

shadow gazelle
#

I am never touching this plugin again after it works

#

Learning how to use mixins and make transformers for 1.12.2 was less painful than this has been

fluid river
#

basically what do you want to find i don't understand

#

get pairs of enchantments from 2 sets which do conflict with each other

#

or what

shadow gazelle
#

remove whatever the method returns as conflicting

quiet ice
#

    public static Map<CustomEnchantment, Integer> mergeEnchantments(Map<CustomEnchantment, Integer> inA, Map<CustomEnchantment, Integer> inB) {
        // TODO revisit this code in the v4.0.0 refractor (great things can be changed when we use Enums instead of CE instances)
        LinkedHashMap<CustomEnchantment, Integer> out = new LinkedHashMap<>(inA);

        // pretty sure I'm overcomplicating things again
        out.keySet().forEach((ench) -> {
            inB.keySet().removeIf((newEnch) -> {
                return ench.getConflicts().contains(newEnch.asEnum());
            });
        });
        for (Map.Entry<CustomEnchantment, Integer> entry : inB.entrySet()) {
            CustomEnchantment ench = entry.getKey();
            out.put(ench, enchantmentLevelRemappingFunction(ench, entry.getValue(), out.getOrDefault(entry.getKey(), 0)));
        }
        return out;
    }

Is the method I am using for my CE plugin. Pretty straight forward

cobalt thorn
#

Question my damage is negative like -4 and im setting the player health from his player.getHealth - 4.0D and the healt goes from 20 to 24 and gives an error regarding be the number between 0 to 20 a fix?

grim ice
#

uh i saw once in some article

#

wait

fluid river
#

isn't there a Player#damage() method now

ivory sleet
#

Hello, I have a problem, I actually try a browser to connect to my different servers but when I join my server the item expected to be given is not received in my account, could you help me ? I'm on 1.16.5 with java 8:

Hastebin from my JoinListener: https://hastebin.com/ajifinopig.java
Hastebin from my Utils: https://hastebin.com/ekuxafopet.java

Thank you so much for your help!

quiet ice
#

Which uhm, why would your damage be negative?

cobalt thorn
quiet ice
#

Healing gun?

shadow gazelle
#

FUCK

fluid river
shadow gazelle
#

now it's just normal enchantment leveling

#

goddamnit

fluid river
#

how can you damage with negative value bruh

quiet ice
cobalt thorn
fluid river
#

then just add small ternary operator

cobalt thorn
fluid river
#

int total = player.getHealth() - finalDamage;

cobalt thorn
fluid river
#

player.setHealth(total > 20? 20 : total);

cobalt thorn
fluid river
#

easy i guess

quiet ice
#

            Player player = (Player) evt.getDamager();
            double difference = (0.17 * level * power) * (enchantmentConfiguration.siphonUseFinalDamage() ? evt.getFinalDamage() : evt.getDamage());
            AttributeInstance maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
            assert maxHealth != null;
            player.setHealth(player.getHealth() + Math.min(difference, maxHealth.getValue() - player.getHealth()));

would be the correct route (with some garbage, can't be bothered)

cobalt thorn
#

Its not a heal machine but a sort of custom enchant to prevent take 5 damage

fluid river
#

if your damage is negative just don't apply it to player

#

cancel gamage event

quiet ice
#

If you want to prevent taking 5 damage, just set the damage to 0 if it is negative

fluid river
#

if finalDamage < 4

quiet ice
#

I'd not cancel the event outright though

cobalt thorn
#

Im sending the code wait

cobalt thorn
#

Here

quiet ice
#

Your current code kills the player if it would be over 20 health if I see correctly

cobalt thorn
#

Oh i sent the old one sorry

quiet ice
#

oh yeah right, that if statement is always false

shadow gazelle
#

Jesus Christ

#

it works

#

finally

#

I still want to break something

snow lava
#

is air a block?

shadow gazelle
#

yes

#

Material.AIR if you need to use it in a check or something

snow lava
#

and why i'm getting a null pointer exception when i this:
Block block = loc.getBlock();

shadow gazelle
#

Is the location null?

snow lava
#

no, i get the location of the block while right clicking it

shadow gazelle
#

because getBlock is notnull

grim ice
#

Uh, does anybody know what is the solution for wanting to have a singleton hashset, i thought about extending hashset but idk if that's good design

quiet ice
#

?jd.s

#

?jd-s ffs

undone axleBOT
grim ice
#

geol got an idea?

glossy venture
#

whats the JDK debug interface called again

quiet ice
#

Try printing out the location of the block

glossy venture
#

with like the LaunchConnector

#

yessssssssssssssss

#

perfect for creating a network

glossy venture
#

without copying folders

glossy venture
grim ice
#

i want it to be accessible from everywhere

#

without being a variable

quiet ice
#

Accessible from what

#

What even is accessible

grim ice
#

the hashset

quiet ice
#

Collections#singleton returns a singleton set. Does it really need to be a hashset?

grim ice
#

No not really

quiet ice
#

If you want to have a singleton set that also implements the list interface I believe that you might need to extends AbstractSet manually

grim ice
#

wait what

#

how does #singleton even work

quiet ice
grim ice
#

ah god

#

basically

quiet ice
# grim ice how does #singleton even work

    /**
     * Returns an immutable set containing only the specified object.
     * The returned set is serializable.
     *
     * @param  <T> the class of the objects in the set
     * @param o the sole object to be stored in the returned set.
     * @return an immutable set containing only the specified object.
     */
    public static <T> Set<T> singleton(T o) {
        return new SingletonSet<>(o);
    }
grim ice
#

i want a singleton set, that i can add to, remove from whenever i like

quiet ice
#

So the set itself is the singleton, not it's members?

grim ice
#

yeah

quiet ice
#

Then just have the set be a public static final Set<T> MY_SINGLETON = ConcurrentHashMap.newKeySet();

grim ice
#

where

quiet ice
#

where it makes sense to have it - it's a singleton

glossy venture
#

how can i dynamically add servers to a bungeecord server

grim ice
#

im unsure where its supposed to be

quiet ice
#

Then it is likely that you do not need the singleton

#

Or at least that you don't need to have the set as a singleton

grim ice
#

even if its not a singleton

quiet ice
#

what even is it

grim ice
#

a set of data classes that the player initializes with a command

quiet ice
#

then have it in the same class as the command

grim ice
#

thought about that, but was unsure, thank you

vivid cave
#

what if an eventhandler in my plugin has Priority.LOWEST, it does cancel the event, will eventhandlers of other plugins of higher priority know that the event is cancelled through event.isCancelled() ?

#

What if they have Priority.LOWEST as well

quiet ice
#

might want to disable physics

frail gale
#

Hey, guys is it possible to register commands in runtime with permission? Like when you're register a command with plugin.yml and add permission. I tried with the method setPermission but when I tried getPermission it was null but with plugin.yml it returns the exact permission that I want

vivid cave
#

@EventHandler(priority=64)

#

is that lower than EventPriority.LOWEST?

#

or is is higher priority?

frail gale
#

bump

mellow pebble
#

does anybody know how could i make "mentions" in chat for players

#

so in example if i send message

#

"@mellow pebble is cool"

#

i want that @mellow pebble be like colored differently

smoky oak
#

*spigot

quiet ice
smoky oak
#

events get handled from lowest -> highest. if u have two event handler, the lowest gets called first, and the highest called last

#

this is so that the handler with the highest priority has the final say

#

(keep in mind that MONITOR priority is ONLY used for observing, it is no supposed to change the event its 'handling')

vivid cave
#

thanks

vivid cave
smoky oak
#

then it cancels

#

its bad practice

#

but not impossible

#

its not supposed to use like that but you can

vivid cave
#

okay and do you know what the priority=64 is?

#

it's in a bungee plugin

#

will bungee always have final say anyway?

smoky oak
#

honestly im not sure

#

i recall that logs have a priority thats linked to a number

#

and u can set numbers between the default values i think

#

but i dont know how priority is handled

vivid cave
#

oki np

#

thanks

#

and if someone knows pls lmk

quiet ice
#

?jd

quiet ice
#

What package is the handler annot from?

#

It's a byte so it can be anywhere between -128 to 127

vivid cave
#

i see

#

thank you ๐Ÿ™‚

mellow edge
#

ItemStack#clone makes the complete copy of the itemstack including the itemmeta?

quiet ice
#

yep

sage dragon
#

I want slime blocks be not sticky for a specific block, is there an even I can listen for?

chrome beacon
#

No

#

That is client side

sage dragon
#

Piston Extend and Retract event seems to do nothing :/

chrome beacon
#

Mb

sage dragon
#

Oh ๐Ÿ˜…

jaunty crag
#

how would i go about making a throwable custom item

#

i have seen in mcc island that there are these timed splash potions that you can throw and I want to try to recreate them

snow lava
#

how can i remove the despawning option from my custom mob?

vivid cave
#

i have an PlayerChatEvent
How do i retrieve the actual message?
.getMessage() seems to send me only the raw msg without format...
i notice there is .getFormat() as well but idk what thats for

echo basalt
#

1: dropped item with the same velocity as a thrown item

#

2: retextured egg

#

pretty sure you can set any item on it

jaunty crag
#

do you know how?

echo basalt
jaunty crag
#

yes

#

this is what i need

untold jewel
#
   @EventHandler
    public void onBankNote(PlayerInteractEvent event) throws IOException {
        //check if the action is right_click
        if(!event.getAction().toString().contains("RIGHT"))
            return;

        Player player = event.getPlayer();
        ItemStack itemInHand;
        try {
            itemInHand = player.getInventory().getItemInMainHand();
        }catch (Exception e){
            return;
        }

        NamespacedKey balanceKey = new NamespacedKey(plugin,"balance");
        ItemMeta meta = itemInHand.getItemMeta();

        if (meta == null) return;

        //balance key is not present
        if(!meta.getPersistentDataContainer().has(balanceKey,PersistentDataType.LONG))
            return;

        long amount = meta.getPersistentDataContainer().getOrDefault(balanceKey, PersistentDataType.LONG,0L);
        if(amount == 0)
            return;

        economyManager.depositPlayer(player, amount);
        ChatUtil.sendMessagePrefix(player, "&7You have deposited &a$" + ChatUtil.formatDecimal(amount) + "&7 back into your account!");
    }

Crash error: https://paste.md-5.net/paninikute.cs

agile anvil
jaunty crag
# echo basalt

can the ItemStack have ItemMeta with custom model data?

agile anvil
untold jewel
#

No just the crash

vivid cave
agile anvil
agile anvil
#

Are you referring to placeholders ?

#

i mean, what are you trying to get from other plugins ?

jaunty crag
#

how do you initialize an egg

crimson terrace
jaunty crag
#

i am trying to make a custom throwable

crimson terrace
#

probably an itemstack?

#

nvm

#

its a thrown egg, projectile

jaunty crag
#

its abstract

vivid cave
crimson terrace
jaunty crag
#

oh ok

crimson terrace
#

For example

#

dont mind the warnings, they dont matter

jaunty crag
#

Ok

sterile token
#

Shreb

jaunty crag
sterile token
#

Is posible to make the entity launch a sword for example?

crimson terrace
#

is a sword a projectile?

sterile token
#

No

#

I have answered my self

#

๐Ÿ˜‚

crimson terrace
chrome beacon
#

Launch an armor stand holding a sword

crimson terrace
#

yes

#

javadocs are pretty good

sterile token
#

Why you can launch them?

crimson terrace
#

not with this

chrome beacon
#

Not with that

crimson terrace
#

well you can just set the velocity

#

true

chrome beacon
#

You spawn an entity and give it velocity

sterile token
#

Oh

#

But there I need more things

#

You need to calculate Where he is ppiting

#

Pointing*

#

Much work

#

I mean im not coding it I just saw that he mentรณn that method and i suppouse you can launch everything

crimson terrace
#

initially it was about how to spawn a projectile and get it into a variable, but your point was valid nevertheless

jaunty crag
crimson terrace
#

if you wanna do anything with the egg you will have a livingEntity which is initialized and you will probably set velocity or somethign

green prism
#

Hello there, do you know how to fix this Message Channel problem?

    @EventHandler
    public void onPluginMessageReceived(PluginMessageEvent event) {
        System.out.println("Data received: " + new String(event.getData()) + " --r");
        if(!event.getTag().equals("hqueue:inventory")) return;
        System.out.println("Data received: " + new String(event.getData()));
        ProxyServer.getInstance().getPluginManager().dispatchCommand(ProxyServer.getInstance().getConsole(), new String(event.getData()));


    }```


It isn't dispatching the command and `#println` returns 
(Photo attached)
chrome beacon
green prism
#

Maybe, that's my check

#

By repeating the command in console, it works perfectly

chrome beacon
#

With the ยง??

green prism
#

Nope

chrome beacon
#

?

green prism
#

I don't understand why that character appears

jaunty crag
chrome beacon
jaunty crag
#

what do i initialize LivingEntity as

chrome beacon
#

Your entity

#

The entity that you want to launch the egg

green prism
chrome beacon
#

How are you sending the data

green prism
#

player.sendPluginData but, PlayerCount is not mine

jaunty crag
chrome beacon
green prism
chrome beacon
#

Show us how the data is sent

green prism
# chrome beacon Show us how the data is sent
                  
                        ByteArrayDataOutput out = ByteStreams.newDataOutput();
                        out.writeUTF(executor.getExecutable().replace("%player%", player.getName()));
                        System.out.println(executor.getExecutable().replace("%player%", player.getName()));
                        player.sendPluginMessage(plugin, "hqueue:inventory", out.toByteArray());```



(Executable is a String... smth like /hqueue add %player%)
#

System.out.println works perfectly here
[HQueue-Bridge] [STDOUT] queue add Jaamin test

jaunty crag
chrome beacon
#

What about it doesn't work?

jaunty crag
#

There is no egg

chrome beacon
#

Could you show your code

#

?paste

undone axleBOT
still verge
#

how can i get a yamlconfiguration as a file?
like convert yamlconfiguration to file

chrome beacon
#

Do you want to save it?

#

Or get the file object of a yamlconfiguration

green prism
still verge
torn oyster
#
e.g. 10d, 5s, 1m, 1M, 1Y```
how would I convert something like that formatted time to milliseconds?
delicate lynx
#

get the duration of that number 10d = days and use math to convert

vivid cave
#

btw since you guys are talking about pluginmessage, when a player leaves server, that there is no one left on the server, so the msg is targeted for other servers with players on the bungee network, but the leave-msg doesn't get sent
How can i fix this

torn oyster
#

if that's what you are trying to do

vivid cave
#

yeah

#

okay

vocal cloud
#

Someone needs to write a lightweight lib to fix this lol

vivid cave
#

yeah this is shit

#

i don't understand why people don't understand that we don't like to make proxy plugins

#

there are many reasons to dislike using bungee api & prefer make spigot plugins for each backhand server

#

now i gotta deal with sockets

opal juniper
#

what are you trying to do?

#

what do the tables look like? what data do you need? we need more info!

eternal night
#

write a proper SQL query ?

#

and join the tables

#

i mean

#

google SQL join tables ?

opal juniper
#

"SELECT messages.message, messages.time, users.username FROM messages LEFT OUTER JOIN users ON messages.userid=users.uid;"

#

the horror i wrote the other day

jaunty crag
# chrome beacon Could you show your code
            Egg egg = entity.launchProjectile(Egg.class);

            ItemStack i = new ItemStack(Material.STONE);
            egg.setItem(i);

            egg.setShooter(p);
            egg.spawnAt(p.getEyeLocation());
            egg.setVelocity(new Vector(0,3,0));
#

how do i get custom eggs to stop spawning in chickens

torn oyster
#

how do I get the UUID of the sender of a ChatEvent in bungeecord?

fluid cypress
#

can someone please explain this to me?

System.out.println(text.replace("&", "ยง").contains("\\n"));
String[] pieces = text.replace("&", "ยง").split("\\n");
System.out.println(pieces.length);
[19:24:40 INFO]: true
[19:24:40 INFO]: 1

iirc this is not the first time i struggle to split a simple string in java

#

no

jaunty crag
#

dang alright

fluid cypress
#

the string wasnt being separated into pieces

#

but apparently you have to do "\\\\n" for some reason

tawdry python
#

Hello, I use this code to disable the plugin when it gives an error but when it gives an error, the plugin doesn't turn off, why? I already added debug and yes this code runs

    AnotherClass
     Main.getInstance().getPluginLoader().disablePlugin(Main.getInstance());

    Method in my Main plugin
     public Main getInstance(){
        return instance;
    }
    OnEnable i set instance
     instance = this;
onyx fjord
fluid cypress
#

idk

onyx fjord
#

Why not just put a space

fluid cypress
#

double regex for some reason i guess

onyx fjord
#

Or whatever symbol it is

fluid cypress
#

because i want spaces to be spaces

onyx fjord
#

?

fluid cypress
#

\n is a new line

onyx fjord
#

Yes

fluid cypress
#

idk what your question is

onyx fjord
#

What's your goal and how does original string look like

fluid cypress
#

im creating floating text with multiple lines

#

so i do /floatingtext this is a multiple\nline text

#

then i join all the args

#

then split using the new line

#

and thats it

#

yes

fluid river
#

hi kacper

torn oyster
#

how would I use the JsonConfiguration class

#

in Bungee

fluid river
fluid cypress
#

dont worry, its working just fine, i just needed to use "\\\\n" instead of "\\n"

fluid river
#

if it's even possible

onyx fjord
#

What java version

#

It's pretty simple in java 11

#

\R should work

#

Double \

fluid river
#

Ping is typing

#

Pong is answering

tawdry python
#

How do I turn off the plugin? Tried this code

getPluginLoader().disablePlugin(this);

But when it executes it keeps logging the following events

fluid river
#

getPluginManager() you meant

torn oyster
#
    @EventHandler
    public void onLogin(PreLoginEvent e) {
        BanManager bm = BanManager.get();
        UUID uuid = e.getConnection().getUniqueId();

        if (bm.isBanned(uuid)) {
            if (!bm.isAllowUnban(uuid)) {
                e.setCancelled(true);
                if (bm.isPermanent(uuid)) {
                    e.setCancelReason(new TextComponent(StringUtil.colourize(
                            "&cYou are permanently banned from this server." +
                                    "\n&fReason &7ยป &f" + bm.getReason(uuid) + "" +
                                    "\n" +
                                    "\n&6If you believe this is a mistake, please let us know via support.")));
                } else {
                    e.setCancelReason(new TextComponent(StringUtil.colourize(
                            "&cYou are temporarily banned from this server for " + bm.getRemainingTimeFormatted(uuid) + "." +
                                    "\n&fReason &7ยป &f" + bm.getReason(uuid) + "" +
                                    "\n" +
                                    "\n&6If you believe this is a mistake, please let us know via support.")));
                }
            } else {
                bm.unban(uuid);
            }
        }
    }```
#

how come that isn't working?

#

no errors

#

just not working

#

and yes, I have registered it

onyx fjord
#

Maybe it stops on some if statement

fluid river
#

this code is absolutely cringe

#

and formatting too

onyx fjord
#

Yea why hardcode

fluid river
#

static abuse

#

?

onyx fjord
#

Wdym static abuse

fluid river
#

why not just pass instance

#

but create a static getter

tawdry python
fluid river
#

JavaPlugin.getServer().getPluginManager()

torn oyster
onyx fjord
#

But that's giving yourself more work

torn oyster
#

and i don't plan on changing the message either :/

#

it's for my own server

wet breach
# fluid river why not just pass instance

for the plugin instance of the plugin you are working within, it really doesn't matter since you are not expecting a different plugin instance and the plugin instance doesn't go away or change

torn oyster
wet breach
#

in order to know what is or is not static abuse, you have to really know and understand the repercussions of using static

torn oyster
#

the class has already been initialized?

#

there's only ever one instance?

wet breach
#

one of the main drawbacks to making something static, is that it prevents the GC from collecting that object. But if the object isn't designed to go away anyways, it is generally fine to use a static for it

fluid river
#
@EventHandler
public void onLogin(PreLoginEvent e) {
    var bm = BanManager.get();
    var uuid = e.getConnection().getUniqueId();
    if (!bm.isBanned(uuid)) return;
    if (bm.isAllowUnban(uuid)) bm.unban(uuid);
    else {
        e.setCancelled(true);
        if (bm.isPermanent(uuid)) e.setCancelReason(...); 
        else e.setCancelReason(...);
    }
}```
tawdry python
onyx fjord
fluid river
onyx fjord
#

Iirc i do something like plugin.disable

fluid river
#

but actually do you need to disable the plugin?

#

you can just disable it before registering everything

#

right on start

fluid river
tawdry python
fluid river
#

isn't that easier to pass a normal instance or just make entire thing static

wet breach
tawdry python
fluid river
onyx fjord
#

@tawdry python connecting to what

wet breach
#

it really comes down to the purpose. As long as it doesn't hit the drawbacks of using a static you are fine, but most people are not well versed in how Java and the JVM really interact or handles things so it is best to just stick with OOP principles where possible

tawdry python
onyx fjord
#

Oh

fluid river
#

But for other purposes i leave entire class static

#

or pass an instance to constructor

#

Other way you have to make your class half-static, half-not-static

wet breach
#

you shouldn't have an entire class static. Big difference between a static instance and non-static one

#

at least not for plugins

#

if you are designing an application from scratch yeah you will have a lot of statics in your main class lol

fluid river
#

static message colorizing methods

#

static placeholder appliers

#

and so on

wet breach
#

that only makes sense for util methods if its a general util class that really has nothing in common and therefore wouldn't really initialize the entire class for the one method you want

fluid river
#

Isn't banManager supposed to be a static thing which basically handles static ban/unban methods and checks

wet breach
#

but if you can organize your code where you can sort your util methods into their own classes, should go with OOP then

fluid river
#

for what code i see it's not really needed to have instance

#

just basic checks and 2 voids

vocal cloud
#

Don't object abuse sad

fluid river
#

don't abuse

#

your girlfriend

#

or i'm gonna nuke your house in 3...

#

2...

#

1...

#

ya know

torn oyster
vocal cloud
#

She likes it thonk

torn oyster
#

java.lang.NullPointerException: Cannot invoke "java.util.UUID.toString()" because "uuid" is null

torn oyster
#

only the getter is

fluid river
#

alr still

torn oyster
#

i don't get why getUniqueId on a connection can be null?

fluid river
#

i made your code smaller

torn oyster
#

i will probably use it after i figure out why the banmanager methods aren't working

#

but why is the connection's UUID in PreLoginEvent null?

fluid river
torn oyster
#

PreLoginEvent's connection UUID is null

fluid river
#

is that bungee?

#

or smth

torn oyster
#

yes

fluid river
#

let's google it

rapid vigil
#

Hello, I have a question rq, why does this not work although I have BuildTools 1.17.1:

        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.17.1-R0.1-SNAPSHOT</version>
            <classifier>remapped-mojang</classifier>
            <scope>provided</scope>
        </dependency>```
It works without the `<classifier>remapped-mojang</classifier>` but does not with it
The error is: `Cannot resolve org.spigotmc:spigot:1.17.1-R0.1-SNAPSHOT` | `Unresolved dependency: 'org.spigotmc:spigot:jar:1.17.1-R0.1-SNAPSHOT'`
fluid cypress
#

is there any way to store some custom info in an entity?

fluid river
#

umm

#

it's supposed to be null

#

just use LoginEvent instead

fluid river
#

entity.getPersistentDataContainer()

#

there are get, has and set methods

fluid cypress
#

Thanks

tender shard
#

pdc โค๏ธ

fluid river
#

only present since 1.14 i think

#

oh hello alex

tender shard
#

hi

#

yeah 1.14.1+

#

and 1.16.3+ for chunks

#

and I think meanwhile worlds also have a PDC but I'm not sure in what exact version that was added

#

probably 1.18.2 or 1.19

fluid river
#

i just wanna see

#

ItemStacks have PDC on their ItemMeta

#

if you know how to work with it

torn oyster
#

?paste

undone axleBOT
torn oyster
#

a lot of things were stripped down because it's unnecessary

#

but i kept the general idea

fluid river
#

so basically you create an instance of ban manager each join

tender shard
#

this whole class is fucked up

#

either make everything static, or not

torn oyster
#

it's initialized on startup

fluid river
#

oh shit

#

i see

tender shard
#

why do you even need an instance if all the methods you wanna do are static?

wet breach
fluid river
#

so you made a private constructor

rapid vigil
#

I have a question rq, do you need to install something to be able to use mojang mappings?

rapid vigil
torn oyster
#

it looks better

tender shard
fluid river
#

you can just make a static * import

#

of your class' methods

#

and forget about private constructor() instance and so on

tender shard
# torn oyster because why not

because this is a fucked up design. what does exampleMethod() do, that it cannot be static? I mean your instance field is useless since you do not have ANY instance fields in your class anyway

fluid river
#

you don't have any dependency injection in banmanager

torn oyster
#

i just removed them

#

in the example

rapid vigil
#

Wait, you can't use:

        <dependency>
            <groupId>org.spigotmc</groupId>
            <artifactId>spigot</artifactId>
            <version>1.17.1-R0.1-SNAPSHOT</version>
            <classifier>remapped-mojang</classifier>
            <scope>provided</scope>
        </dependency>```
If you did `java -jar BuildTools.jar --rev 1.17.1` instead of `java -jar BuildTools.jar --rev 1.17.1 --remapped`?
tender shard
rapid vigil
fluid river
tender shard
fluid river
#

and this looks a lot better

#

except missing semicolons somewhere

#

๐Ÿ™‚

wet breach
#

anytime the get method is used, it will check for an existing instance

fluid river
#

and unnecessary public constructor

wet breach
#

if not, it serves up a new one

#

and this is how you would use the static method to your advantange

tender shard
#

if I#d write a BanManager class, it'd look like this

public class BanManager {

    private final Plugin plugin;

    public BanManager(Plugin plugin) {
        this.plugin = plugin;
    }

    public void exampleMethod() {
        // do stuff
    }
    
}
fluid river
#

private final Plugin plugin;

#

i like it more

tender shard
#

and then my "Plugin" main class would have a method getBanManager() or whatever

fluid river
#

or you would make it fully static

#

cuz that's like util

tender shard
#

yeah, or that. but then it's not reusable

wet breach
fluid river
#

even name is banManager

tender shard
#

I mean you could have more than one ban manager, e.g. per world, or whatever

#

maybe you don't need that now, but maybe later

torn oyster
#

i used the initialize method because i had several modules in the config.yml and you could enable or disable them, so I would initialize their respective managers if they are enabled on startup

wet breach
fluid river
#

true

wet breach
#

because anytime the instance is iniatialized it will run the private method regardless

fluid river
#

lemme guess

#

You have static instance of your main class in your main class

#

and use getInstance()

tender shard
#

I mean if you want it static, then at least do it like this:

public final class BanManager {

    private static Plugin plugin;

    public static void init(Plugin plugin) {
        BanManager.plugin = plugin;
    }

    public static void exampleMethod() {
        plugin.getLogger().info("Hello from BanManager!");
        // do stuff
    }

}

It should either have instance methods, or only static methods. mixing that up makes literally no sense at all. a static method that uses it's own static instance? why would that ever be needed

fluid river
#

singletone users be like ๐Ÿ’ฉ ๐Ÿ’ฉ let my class contain static instance of itself

fluid river
tender shard
#

I still think that a class called "BanManager" should not have ANY static methods

fluid river
#

yeah

#

for static it's better to do like BanProcessor

tender shard
#

unless it's ofc stuff like ```java
public static UUID getUUID(Player)

or some other stuff like that lol
#

(just a bad example but you know what I mean)

fluid river
#

to2DLocation(Location loc)

tender shard
wet breach
#

which would require a static

#

unless you go with lazy singleton method

tender shard
#

unless you someday want to have two banmanagers

#

and also, where's the difference between myPlugin.getBanManager().doSomething and BanManager.doSomething(), except that the latter is shorter?

wet breach
#

well if you want two banmanagers, it would no longer make sense to call it such

#

as above that would be suited to BanProcessors and then still having a single manager

tender shard
#

AbstractBanManagerFactoryBuilder extends AbstractFactoryBuilder implements FactoryBuilder<BanManager>

#

THAT's how to do it right lmao

wet breach
#

well that is factory pattern

tender shard
#

no, that is a joke

fluid river
#

Factory > Singleton

wet breach
#

they all have their use cases and have their advantages and draw backs

#

you could definitely go with factory pattern for mulitple ban managers

tender shard
#

except for Vector (the collections one)

wet breach
#

lol

fluid river
#

isn't solid kinda strong and mostly-used

torn oyster
#

can you use hex codes in bungeecord?

tender shard
#

sure

fluid river
#

it's bungee chatColor

torn oyster
#

it seems to change it to a normal &x colour

#

unlike backend servers

wet breach
#

depends on the method you are using

torn oyster
#
    public static String colourize(String message) {
        Matcher matcher = HEX_PATTERN.matcher(ChatColor.translateAlternateColorCodes('&', message));
        StringBuilder buffer = new StringBuilder();

        while (matcher.find()) {
            matcher.appendReplacement(buffer, ChatColor.of(matcher.group(1)).toString());
        }

        return matcher.appendTail(buffer).toString();
    }```
tender shard
#

ChatColor.translateAlternateColorCodes('&',"&x&f&f&0&0&0&0This is solid red");

fluid river
#

di > everything

wet breach
tender shard
wet breach
#

but in order to use Hex in chat, you need to use chat components

tender shard
#

check for &#[0-f]{6} and then turn it into &x&f&f&0&0&0&0

#

and then run that through ChatColor.translate...

fluid river
#

regex ๐Ÿ’ฉ

torn oyster
#

idk lol

tender shard
wet breach
#

I do however have a utility program that compresses 16bit color to 8bit color ๐Ÿ™‚

torn oyster
#

private static final Pattern HEX_PATTERN = Pattern.compile("&(#\w{6})");

fluid river
#

guys who developed regex are true hidden developers of brainfuck

torn oyster
#

this is a util class btw

tender shard
fluid river
#

100% sure

torn oyster
#

and it's a custom plugin for my server so i won't use that

wet breach
#

in case anyone wants to use it or see how its done or whatever lol

tender shard
torn oyster
wet breach
#

its a free floating utility

torn oyster
#

the non-hex one is fine

wet breach
#

can be used anywhere

torn oyster
#

the hex one becomes aqua (even though it is a maroon-ish colour)

tender shard
#

I can only suggest to translate &#123456 into &x&1&2&3&4&5&6 and then it will always work

torn oyster
#

isn't that not what it already does?

wet breach
#

well the rounding occurs because minecraft uses 8bit colors, hex is 16bit

torn oyster
wet breach
#

therefore you can't fit all of the 16bit colors into 8 bit

tender shard
wet breach
#

have to remember, computers know colors by numbers, not their names

tender shard
#

if scoreboard teams support colors, then it will work with &x...

torn oyster
tender shard
#

no, you always replace it with the last known chat color

#

I e.g. have a replaceRegexWithGroup method like this:

#

then to turn &#000000 into black, I call it like this:

#

and this is addAmpersandsToHex:

fluid river
#

with LoginEvent

torn oyster
#

i changed it to LoginEvent from PreLoginEvent

fluid river
#

ye i just said to do that

#

literally

torn oyster
#

did u? idk i just found it on a thread

fluid river
#

hey guys

#

i used enum like years ago

#

can you add elements to enum

#

on runtime

tender shard
#

with hacky ways

#

you shouldnt do it

fluid river
#

alr alr

tender shard
#

it's not supposed to be changed

fluid river
#

would stick to FunctionalInteraces/maps

torpid sapphire
#

whats the event that fires when you right click a block?

#

PlayerInteractEvent?

chrome beacon
#

Yeah

tender shard
#

you get a bonus on top, it fires twice when you right click a block

torpid sapphire
#

interesting

#

so do i just check the hand

tender shard
#

yes

torpid sapphire
#

and return if its not the main hand

tender shard
#

if you only care about main hand, yes

torpid sapphire
#

well i only want it to fire once

tender shard
#

it will always fire twice

#

but yeah I get what you mean

torpid sapphire
#

well yeah but i only care about one of them

#

doesnt matter which one

tender shard
#

then just return if event.getHand() != Hand.MAIN_HAND or whatever it's called

worldly ingot
#

EquipmentSlot.HAND

#

Close enough

torpid sapphire
#

if (event.getClickedBlock() == null || event.getHand() == EquipmentSlot.OFF_HAND) return; is this how || works in java

#

cause i remember it being weird

#

or me being weird

#

whatever

tender shard
#

yes

#

but tbh I wouldnt check if it's offhand

#

I would check if it's not main hand

#

i might be paranoid, but otherwise it would break if some day, a third hand gets added ๐Ÿ˜„

#

with your current code, you only know that it's not the offhand, but you cannot be 100% sure that it was the main hand ๐Ÿ˜„

torpid sapphire
#

i doubt thatll happen but i see what you mean

tender shard
#

yeah it really doesnt matter

#

just wanted to mention this

torpid sapphire
#

or maybe your feet interacted with the block

tender shard
#

the difference between || and | is this:

#

when using ||, and getClickedBlock() is null, it will not even call getHand()

#

when using |, and getClickedBlock() is null, we know that it will return anyway, but it would still call getHand() anyway

torpid sapphire
#

ahhh

#

i had an issue with this the other day

tender shard
#

in 99.9% of cases you should use ||

torpid sapphire
#

unless theres side effects

tender shard
#

yeah but those are kinda rare in those cases

torpid sapphire
#

yeah

#

well still good to know

tender shard
#

the same is true for && and & btw

torpid sapphire
#

also, should i use multiple event handlers for different functionality or do i throw everything into one

#

cause right now i got a single handler with like 10 events

tender shard
#

I guess that depends on whether they have anything in common

#

e.g. imagine you have sth like this (1 sec pls...)

torpid sapphire
#

well theyre all somehow related seeing as theyre all in the same plugin

#

but i get what you mean