#development

1 messages · Page 129 of 1

icy shadow
#

You can still right click I think

forest jay
#

that might work

pulsar ferry
#

Well right clicking doesn't do anything

icy shadow
#

It might

forest jay
#

I just dont want the player to know that there is a sign there

lyric gyro
#

you can right click signs tho

icy shadow
#

🤔

lyric gyro
#

they can have cmds

#

"have"

icy shadow
#

I smell xy problem

lyric gyro
#

the root component of each line can have a valid run_command action, and the server checks for that when you right click a sign

forest jay
icy shadow
#

So called "adventure maps"

median glen
#

Does this AtomicBoolean look good for you?

public boolean unlinkContainer(@NotNull Container container) {
    Location containerLocation = container.getLocation();
    AtomicBoolean isAnyRemoved = new AtomicBoolean(false);

    _hopperRepository
        .findByContainerLocation(containerLocation)
        .forEach(hopper ->{
            boolean isRemoved = hopper.removeContainer(containerLocation);
            isAnyRemoved.set(isAnyRemoved.get() | isRemoved);
        });

    return isAnyRemoved.get();
}

IntelliJ recommended this over using a local variable which obviously did not compile. Does this do what I want?

forest jay
#

it should

icy shadow
#

oh you mean with a resource pack?

forest jay
icy shadow
#

Ah

#

Hmm

pulsar ferry
#

Probably because of font glyphs

forest jay
#

I dont want the nametag thing where it moves with the player

lyric gyro
hoary scarab
#

Item frames can be set to keep name visible right? You could use them the same as signs if thats the case

icy shadow
#

Given that you don't want short circuiting

#

oh or filter

median glen
#

cause it's stream

lyric gyro
#

mh yeah if you want to run it for each one then yeah

#

filter + allMatch wicked

pulsar ferry
lyric gyro
#

surely you can setCustomNameVisible(true)?

#

🤔

dense drift
#

it might work, the name you see when hovering over is of the item that's inside

forest jay
#

also, how do I rotate a sign from code?

lyric gyro
#

getBlockData and cast to Sign, do the thing and set it back

forest jay
#

yeah I have the Sign object

#

I just dont know how to rotate it

lyric gyro
#

setRotation?

forest jay
#

not a thing

lyric gyro
#

it definitely is

#

Make sure you're importing the right Sign interface

#

the second one from the screenshot above

pulsar ferry
forest jay
#

is there any built in methods for turning a yaw into a BlockFace rotation enum?

#

nevermind

icy shadow
#

No I mind

forest jay
#

its literally Player#getFacing

#

sometimes I question my intelligence

median glen
#

How can I store an object of MyClass into PDC?

lyric gyro
#

honestly I'd just serialize to json and store it as a string

median glen
hoary scarab
#

Does PDC automatically deserialize?

median glen
hoary scarab
#

Wait I'm thinking of NBTTags. If I give a list or int or string to NBTBase will it converter to NBTString, NBTList, NBTInt and so on?

lyric gyro
graceful hedge
lyric gyro
#

please for the love of yourself don't use java's Serializable API

graceful hedge
#

🥲

hoary scarab
#

I use json-simple

graceful hedge
#

Moshi :3

steady ingot
#

Jackson works if you are knee deep into that

queen plank
#

When you read a value from a persistent data container, is the entry removed from the container. Or have I done something stupid in my code?

dense drift
#

not, is not removed

lyric gyro
queen plank
#

Ahhh, then I've done something. Ughhhh, well, thanks 🥲

lyric gyro
queen plank
#

stfu lol

lyric gyro
queen plank
#

:>

lyric gyro
flat anchor
#

Could someone make little code review? :>

queen plank
#

Yes

spiral prairie
#

ok

lyric gyro
#

mf put the entire ass license as header 💀

spiral prairie
flat anchor
#

Gradle plugin :<

spiral prairie
#

200 lines just for that

flat anchor
#

I thinking about change to mit license

spiral prairie
#

just get a smaller paragraph of that

lyric gyro
#

this is the only part that's actually needed as header lol

flat anchor
#

Oh, gonna change

#

Ty

spiral prairie
#

and maybe a title

sterile hinge
#

SPDX identifiers ftw

spiral prairie
#

oh

dusty frost
#

MIT gang

lyric gyro
#

Just know my D is like a anaconda

flat anchor
#

truncated

sullen tangle
#

Hello! Recently I was wondering if a server-side mod for fabric that allows me to make scripts exists. I need something like Skript, but for fabric servers. Preferably something up-to-date.

If you know something like this feel free to DM me.

kind granite
#

no such thing exists

#

just learn java

storm comet
lyric gyro
#

yooo scarpet

#

brings me back

#

it's actually really cool, +rep

storm comet
#

Yea, and gnembon is now a senior dev at mojang

robust flower
pure crater
#

not really sure if this would help, but try running buildtools for 1.18.2

lyric gyro
#

did you run the applypatches script?

#

mmh you need to run bt and then run the applypatches script pointing to the decompiled classes dir

#

man this is ancient

robust flower
#

(sorry for the ping)

lyric gyro
#

yeah this is so badly explained lol

#

it's like "you need maven and buildtools"

#

but it doesn't tell you shit under the actual "compilation" section

#

First run buildtools, then cd into each repo and do this

#

well, "each"

#

idk

robust flower
#

I actually don't even need to compile the code, I just need the intellij highlight and ctrl clicky clicky to work, I'm just doing some field investigation today

lyric gyro
#

it's easier to build paper lol this is too convoluted

robust flower
#

After running the buildtools like PulseBeat suggested there's only 50% of errors remaining, I'm wondering if there's some "buildtools" equivalent for Bukkit too

pulsar ferry
#

Why does it even use "bukkit"? thonk

lyric gyro
#

because it builds on top of it?

robust flower
#

I think it is because Spigot depends on CraftBukkit which depends on Bukkit

#

Bukkit is the API (lots of interfaces), CraftBukkit is the implemention of these interfaces (for the most part), and Spigot just adds some things to it

#

Though I have no idea why does CraftBukkit jar doesn't come with Bukkit shaded in it

lyric gyro
#

presumably for a clean dependency tree

#

like the actual project depends on the other actual project

robust flower
#

hmmm, but the buildtools actually built the final jar, correct? Shouldn't craftbukkit shade bukkit for it to work?

hoary scarab
#

Bukkit is the api so doesn't it shade craftbukkit?

lyric gyro
#

they can coexist as separate jar files and so long as both are in the runtime classpath they will work fine

pulsar ferry
hoary scarab
#

Are you sure? Spigot is the api and it shades (use to) bukkit

lyric gyro
#

the implementation ships the API

robust flower
lyric gyro
#

the API doesn't know jack about the impl being there

pulsar ferry
robust flower
lyric gyro
#

craftbukkit ships bukkit

pulsar ferry
#

Craftbukkit is the base, the rest are api

robust flower
#

my -> meant "is a dependency of" or "is used as base for"

pulsar ferry
#

Then you have to flip the entire thing around

lyric gyro
hoary scarab
#

Craftbukkit is the library bukkit is the api to access it... so why wouldn't Bukkit (depend or shade) on craftbukkit?

robust flower
#

where craftbukkit is the library?

past ibex
#

Bukkit is completely separate from craftbukkit

robust flower
#

craftbukkit is a server implementation of bukkit, that's literally the description of it

past ibex
#

Bukkit is an API. There are several implementations of bukkit. The primary one is craftbukkit. However, Glowstone is an implementation of bukkit that doesn't use any mojang code.

hoary scarab
#

Ah Ok. Always thought craftbukkit was the server implmentation that bukkit was accessing.

past ibex
#

bukkit and craftbukkit devs are different.

robust flower
#

anyway, back to my point, how can I get Maven to download and/or recognize the bukkit jar that should have been there

past ibex
#

post your pom

pulsar ferry
past ibex
#

I'd suggest using the spigot-api and copy this stuff

robust flower
past ibex
#

spigot-api forks bukkit and adds some things, idk spigot even hosts bukkit anymore

pulsar ferry
robust flower
robust flower
thorn cape
#

I am bad at vector math
I am trying to create a function that will duplicate custom regions. I get the cardinal direction the player is facing and taking an input I multiply the direction vector by the distance (in this case 20) and then apply that vector to the region points.

But it seems that I'm getting the wrong number after the first region is moved.

First teleport is an original region, the second is the first cloned and the third is meant to be a clone of the first but it has a Z of 8014 instead of 34
(20 blocks away)

Clone Command: https://paste.helpch.at/awicosiqoz.java
Region: https://paste.helpch.at/oralezuhap.java

edit: The clone of the second teleport would be at origin 16.5, 65, 14.5

sterile hinge
#

d; spigot Vector#multiply

uneven lanternBOT
#
@NotNull
public Vector multiply(@NotNull Vector vec)```
Description:

Multiplies the vector by another.

Parameters:

vec - The other vector

Returns:

the same vector

sterile hinge
#

Someone had the great idea to make vectors mutable, so you should only multiply it once

lyric gyro
#

probably dinnerbone

#

@author sk89q
lol alright

past ibex
#

that screws with me because the vanilla codebase doesn't do that

#

so a bukkit vector is mutable while a nms vector is immutable

dense drift
#

🤗

queen plank
#

I calculate a value like this Math.sin(Math.toRadians(value)) where value is 180 degrees, but get the value 1.2246467991473532E-16 from it when it should be zero. When I then parse the result to a string turns out as 01.2246467991473532. Is there a way to fix this, apart from rounding the result?

past ibex
#

By turning it into a string using formatting options

#

String.format(number, ".%9") or something. idk exact code but it's on stack overflow somewhere

queen plank
#

Ok then, thanks

median glen
#

How can I listen on sugar cane breaking event when it is breaking because another one is broke under it?
So there is a 2 tall sugarcane, I break the bottom one: bottom will fire BlockBreakEvent and BlockDropItemEvent, but what will fire for others?
I found that BlockDestroyEvent is actually fired, but there are no list of items to be dropped, but I want to manipulate the items to be dropped. How can I do that?
(I use Paper API)

hoary scarab
#

Block.getDrops()

median glen
hoary scarab
#

👍

median glen
# hoary scarab `Block.getDrops()`

Is it a good decision to use it though?
Does it take into account that a player may have luck or any modifier that would increase drop yield? 🤔

median glen
hoary scarab
#

Well you could just check if above blocks match the block you're breaking and remove them manually.

median glen
#

yeah I thought about that but that is not a general solution

#

so I would implement it for sugar canes, but I don't know all the types of other blocks that can do the same stuff

#

maybe cactuses

hoary scarab
#

Well the break or interact event would be the only point you can check the player and held item. The other wvents are blocks only.

median glen
#

well the BlockDropItemEvent is fine too because then the final list of dropped items are there, I would need something like that but for indirect breaks

hoary scarab
#

Sugar cane, Cactus, End flower, bamboo and I think 1 more thing.

#

Coral and kelp

median glen
#

do they work all the same way as sugar cane?

hoary scarab
#

Those all break upwards.

Breaking downwards is; vines and I think lichen

icy shadow
#

and glow berries

hoary scarab
#

"What are those?" lol

#

Seriously asking though

icy shadow
#

1.18 addition

hoary scarab
#

Ah ok

median glen
#

Is there a fast way to apply new versions of a plugin while developing? currently I do:
gradle clean build, then copy jar file manually to plugins folder**, stop server, start server again, wait until reloads.**
the bolded part takes a lot, can I help on that?

dense drift
#

Theres a thing called hotswap, but for some things you still have to restart the server

#

I usually click on the restart button from IJ and it waits for the server to stop and then start it again

median glen
#

I guess plugman reload is bad 😛
(it works in most cases though but I heard its bad so I am trying to avoid)

dusky harness
median glen
#

I know

dusky harness
#

alr

#

was just making sure

graceful hedge
#

idr the name

#

but there is a plugin which detects file changes

#

and reloads plugins

west socket
#

That’s hot

dusky harness
#

wouldn't that have the same issues as plugman tho?

graceful hedge
#

idk

dusky harness
#

¯_(ツ)_/¯

west socket
#

I mean plugman works fine for plugin development purposes as long as something doesn’t noticeably break

dusky harness
#

tru

graceful hedge
#

I mean hotswap could potentially also cause some weird side effects shrug

dusky harness
#

also true 🥲

#

and iirc hotswap only works if u dont add any new methods/classes

#

so its useful for testing some minor things ig

median glen
graceful hedge
#

yeah tho dcevm makes it a bit more powerful dkim

dusky harness
#

no even with dcevm

#

wait is there dcevm yet for java 17?

graceful hedge
#

nope

#

or not when I checked

dusky harness
#

this one i think u can add methods

#

idk about classes

median glen
#

Can someone check if I implemented this method well?
https://paste.helpch.at/qoceqipiji.cs

this.hopperActivator.activateHoppersInChunk(chunk, items);
may touch items (reduce itemstack amount or remove items altogether), and since if I modify items they will still drop, I had to redo the block break feature manually with the remaining drops.

Edit: change link to contain other method too

graceful hedge
dusky harness
#

¯_(ツ)_/¯

#

maybe i just wasn't using it correctly

#

lol

graceful hedge
#

yeah well im not a dcevm expert myself so ye

lyric gyro
#

why not

graceful hedge
#

good question

icy shadow
#

plugman and dcevm are fine in development

#

the problem is when u use them in prod

#

issues will start to occur

graceful hedge
#

🥲

tidal canopy
#

Is this the correct channel to ask for assistance when it comes to creating plugins?

tidal canopy
#

Am allowed to send an open source project and ask someone to help me understand the concept so I can use that concept for something else?

dusky harness
#

yes

#

i'm pretty sure

lyric gyro
#

I'm Emily

dusky harness
#

-_-

#

Hi Emily

lyric gyro
#

hi

dusky harness
#

😃

tidal canopy
#

https://github.com/ArtFect/BlockHighlight

This person created a way to highlight blocks for players using debug/game_test_add_marker without making any modifications to the client. My understanding of coding plugins is to basic to able able to try and understand how the things work?

#

I simply want to use this idea, and make a command that highlights a blocks.
For example

/highlight x y z

#

.

Ive been starring at this plugin for hours and cant seem to understand how on earth this person was able to do this

dusky harness
#

this is the actual highlight code

#

and highlight.getColor() is Color.RED.getRGB() for ex

#

this also uses ProtocolLib

#

what it does is it sends a Custom Payload packet with the channel debug/game_test_add_marker, and it serializes the marker (aka the block highlights) into bytes (ByteBuf) and sends it to the client

tidal canopy
#

Thank you, ill see what I can do. You helped alot

dusky harness
#

np :D

tidal canopy
#

do you think the blockPosToLong is necessary?

dusky harness
#

instead of 3 integers, it just sends 1 long

#

hm

#

it seems to be under MIT license

#

well

#

are you going to use ProtocolLib?

tidal canopy
#

Depends

#

For now im not planning on it

dusky harness
#

alr, it should still be similar though

#

so i'd recommend just coding it based off of PacketUtil and sendBlockHighlight

tidal canopy
#

Thats the plan 🙂

#

thank you

dusky harness
tidal canopy
#

basically just trying to understand how he did things, then do it from scratch

#

wont be using the plugin anywhere, just self study proposes

regal musk
#

Heyo anyone used jackson serialization and know how to register a way for serializing enchants? I keep getting com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot find a (Map) Key deserializer for type [simple type, class org.bukkit.enchantments.Enchantment] when trying to convert an itemstack to json

past ibex
#

Paper has an API for serializing itemstacks

dusty frost
#

not into JSON

#

Paper's serializes into byte[]s

pearl topaz
#

What different ways do clients send credentials to authentication servers? I assume the primary way is form data, for an app I made I had it send using a Basic authorization header, the server then sends back a token that the client can send in all future requests using a bearer header. Is there a standard way?

graceful juniper
#

Anyone have any idea how to keep a message on the bottom of chat? (Through packets or something else?)

median glen
#

Is making own events for domain model use cases a good idea for better code design?

high edge
#

domain model?

median glen
#

my code's own model

high edge
#

generally events are clean if you have multiple things being done in a single listener

#

So I guess?

graceful hedge
storm comet
#

Does anyone know if it's here or another channel where I could request a relatively simple mod made that I'm willing to pay for?

kind granite
storm comet
#

thanks

median glen
#

Hello, how can I subscribe to event when a chorus plant gets destroyed and it is dropping its items? For example I have chorus tree, I hit the bottom block and the others get destroyed automatically. I get the event for the bottom block but not others. How can I receive other events?

tired thorn
median glen
tired thorn
#

i m

median glen
tired thorn
median glen
#

bro patience is a virtue

tired thorn
#

XD

rugged nymph
#

hey

#

itdoesnt let me verify my acc via my phone

lyric gyro
#

what are you talking about

kind granite
#

sounds like a ?not-discord moment

#

?not-discord

neat pierBOT
#
FAQ Answer:

Looking for discord support?
HelpChat is a Minecraft plugin and development support server and is not affiliated with discord in any way.
If you require support from discord, we recommend you to visit their official support website at https://support.discord.com
On this website, you can read their FAQs, or open a support ticket if necessary.

lyric gyro
#

@rugged nymph read this THIS

hard wigeon
#

is there an example somewhere for using intelliJ debug mode on a plugin in a remote server? (and possibly live-updating changes)

mental cypress
#

That?

hard wigeon
#

yessir

#

that's the one I was looking for

#

should've checked piggy's section

frosty quiver
#

would someone be able to trigger a build there (and/or push to any other ecloud distribution thing, idk how papi's infrastructure works at all)

warm steppe
#

0 bugs

dense drift
#

@mental cypress this

thorn cape
#

How would I get the players message from AsyncChatEvent (text only)?

mental cypress
#

Done @dense drift @frosty quiver

charred mason
lyric gyro
#
        int time = Integer.parseInt(Main.instance.getConfig().getString("time"));
        p.sendTitle(Format.chat("&5Test Title"), String.valueOf(+ time), 1, 20, 1);
    }
#

Some1 that can confirm if it works? The "time" int need to be a subtitle

high edge
#

sendSubtitle?

#

Can't remember what the actual params are, but if you Ctrl + P on the method it'll show the required params

sterile hinge
#

what about getInt? no need to use parseInt every time...

dense drift
#

d;spigot player#sendtitle

uneven lanternBOT
#
void sendTitle(@Nullable String title, @Nullable String subtitle, int fadeIn, int stay, int fadeOut)```
Description:

Sends a title and a subtitle message to the player. If either of these values are null, they will not be sent and the display will remain unchanged. If they are empty strings, the display will be updated as such. If the strings contain a new line, only the first line will be sent. All timings values may take a value of -1 to indicate that they will use the last value sent (or the defaults if no title has been displayed).

Parameters:

title - Title text
subtitle - Subtitle text
fadeIn - time in ticks for titles to fade in. Defaults to 10.
stay - time in ticks for titles to stay. Defaults to 70.
fadeOut - time in ticks for titles to fade out. Defaults to 20.

lyric gyro
dense drift
#

thats an adventure method, Frosty

high edge
#

eee

lyric gyro
#

and my question was if i get the subtitle now xd

high edge
#

Yea the second param is a subtitle

#

When in doubt

but if you Ctrl + P on the method it'll show the required params

#

or ctrl click on the method and it'll take you to the implementation which usually has javadocs attached

lyric gyro
#

jupp

#

So it will work now, with the little tip from sirywell?

dense drift
#

Yes but you still have to make it a String

lyric gyro
#
        String time = String.valueOf(Integer.getInteger(Main.instance.getConfig().getString("time")));
        p.sendTitle(Format.chat("&5Test Tile"), String.valueOf(time), 1, 20, 1);

    }
#

wait

#

i can now remove in the subtitle String.valueOf right?

#

'cause i got it in my string alr

high edge
#

Make your time variable an int, and use getInt for the config, then just use the valueOf in the method

#

Your IDE should also be yelling at you right about now that you're using unnecessary methods

lyric gyro
#

it does 😂

#

actually no, it doesn't

high edge
#

what IDE you using?

#

cause that String#valueOf is unnecessary

lyric gyro
#

but i fixed it

dense drift
#

Which IDE not what version

lyric gyro
#

com

high edge
#

com?

quasi kraken
#

I'm trying to make a custom item in spigot 1.8, and it says "Unknown command" when I run the dommand, help please ;-;

#

This is where I created the item


import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

import java.util.ArrayList;
import java.util.List;

public class ItemManager {

    public static ItemStack axeOfJustice;

    public static void createAxe() {
        //Axe of Justice

        ItemStack item1 = new ItemStack(Material.STONE_AXE, 1);
        ItemMeta meta = item1.getItemMeta();
        meta.setDisplayName("&k&6Axe of Justice&k");
        List<String> lore = new ArrayList<>();
        lore.add("");
        lore.add("&7The Axe of Justice is a weapon once used");
        lore.add("&7by the &cOwner &lqHydro &7himself.");
        meta.setLore(lore);
        meta.addEnchant(Enchantment.DAMAGE_ALL, 1000, false);
        item1.setItemMeta(meta);
        axeOfJustice = item1;

    }

}
#

This is the commands file


import me.qhydro.customitem.items.ItemManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.Main;
import org.bukkit.entity.Player;

public class Commands implements CommandExecutor {


    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {

        Player player1 = (Player) sender;
        if (label.equalsIgnoreCase("giveaxe")) {
            player1.getInventory().addItem(ItemManager.axeOfJustice);
        }

        return true;
    }
}
#

I can send plugin.yml and the Main.java file

high edge
#

did you register the command?

cinder forum
high edge
#

I smell a kek spigot tutorial

quasi kraken
#

This is the Main.java file

package mq.qhydro.customitem;

import me.qhydro.customitem.commands.Commands;
import me.qhydro.customitem.items.ItemManager;
import org.bukkit.plugin.java.JavaPlugin;

public class CustomItem extends JavaPlugin {

    ItemManager is = new ItemManager();

    @Override
    public void onEnable() {
        getCommand("giveaxe").setExecutor(new Commands());
        ItemManager.createAxe();

        getServer().getConsoleSender().sendMessage("&9Hybrid Items has been started.");


    }

    @Override
    public void onDisable() {

    }

}
#

plugin.yml

main: me.qhydro.customitem.CustomItem
name: HybridItems
version: 1.0
author: qHydro
api-version: 1.8.8

commands:
  giveaxe:
high edge
#

is the plugin enabling?

cinder forum
#

i dont think so

#

because api-version

#

should be 1.8

#

not 1.8.8

quasi kraken
#

Ah alright

#

Still doesn't work ;-;

high edge
#

plugin properly enabling or you getting any console errors?

quasi kraken
#

Unknown command. Type "/help" for help.

high edge
#

On enable, not when you run the command

quasi kraken
#

Enable is fine

#

Lemme check actually

#

Nope, it doesnt enable

high edge
#

There's your issue then

neon wren
#

The issue is your API version @quasi kraken.

#

As you aren't using 1.13 or higher, you don't put api-version.

thorn cape
# charred mason event#getMessage()

I'm using the Paper AsyncChatEvent event#originalMessage() returns a net.kyori.adventure.text object which is json. I was wondering if any one just knew how to get the content from the object. If not I'll probably just use the AsyncPlayerChatEvent from spigot

neon wren
#

Also are you using 1.18 @thorn cape? as it seems like it returns a Component, where you should be able to component#text().

#

By following the java docs for the 1.18 asyncchatevent for original message, you get a component object that you can turn into a text component.

kind granite
#

youll probably want PlainComponentSerializer or just use the spigot event if you dont care about formatting

thorn cape
#

I'll probably just use the spigot event then, thanks for the input.

shell moon
#

you can set api-version: 1.13 so 1.13+ recognize it but it's ignored in versions older than 1.13

lyric gyro
#

plugins prior 1.13 should not have that field at all!

#

spigot will apply all sorts of class loading hackery to ensure the plugin using old API works fine on 1.13+ if the field isn't there

shell moon
#

as long as i remember ( i remember i read it some where) some things dont work if you dont specify the api version

dense drift
#

Materials afaik

lyric gyro
#

mainly materials, but some other enums as well

lyric gyro
#

and that means you're doing it wrong

quasi kraken
#

It doesn't show up when I do /plugins

neon wren
quasi kraken
#

Wdym

#

I don't exactly understand.

winged pebble
#

If it doesn't show up in /plugins then it's either not in the plugins folder or there is an error when it tried to load

quasi kraken
#

So my custom join/leave and staffchat plugin are loading, but the custom items are not

winged pebble
#

The console will show the error that caused it to not load

quasi kraken
#

No error at all

winged pebble
#

Is it in the plugins folder?

quasi kraken
#

Yeah

winged pebble
#

Find in the console where it tries to load in the plugin and find the error there

#

ctrl + f in the latest.log is a quick and easy way to find it too

quasi kraken
#

Getting an error from another one

quasi kraken
#

It should work.

#

Loading the plugin

neon wren
pearl topaz
#

but i can't work out how to do this with generics

#

it's just public void setValue(ArrayList<T> value) {}

#

i've tried adding

    public Class<T> getType() {
        return this.type;
    }
```to the `ArrayMonitor` class
#

so you set the type when you make it

lyric gyro
#

generics ugh

pearl topaz
#

but i can't seem to substitute that in for TYPE here new ArrayList<TYPE>(List.of(value.split(","))))

icy shadow
#

what in the hell

#

Um

#

can you show the code for ArrayMonitor

#

Because I have no idea what this is supposed to do

pearl topaz
#

arraymonitor basically just sets a redis value every time there's a set operation

#

so i'm overriding ArrayList<T>

icy shadow
#

😵‍💫

#

please show the full class

pearl topaz
#

there's nothing else relevant

icy shadow
#

kinda is

#

Are you overriding every single arraylist method?

pearl topaz
#

no, i actually only override public T set(int index, T element) {} and then i have my ownsetValue method i showed above

icy shadow
#

Ok

#

Well first off consider implementing List rather than forcing it to a specific implementation

#

I still don't really get what the problem is though

#

If you have an ArrayMonitor<Integer> then T = Integer and so setValues must take an ArrayList<T>

pearl topaz
#

yes but how do i get java to know it's an ArrayMonitor<Integer>

icy shadow
#

where?

#

it'll know as soon as it's created

#

ArrayMonitor<Integer> blah = new ArrayMonitor<Integer>();

pearl topaz
#

as i said above

#

i'm retrieving it from a hashmap

#

of type HashMap<String, Monitor>

#

where Monitor is an interface that ArrayMonitor implements

icy shadow
#

Then there's no way of knowing at compile time

#

Unless you as the developer know from the context

pearl topaz
#

again

#

as ive said i did

public Class<T> getType() {
        return this.type;
    }
#

in the arraymonitor class

icy shadow
#

Yeah that doesn't change anything

#

Not at build time anyway

#

Generics only exist for the compiler

#

At runtime, they don't exist

#

And so <arrayMonitorType> won't work

pearl topaz
#

well then i need a switch statement

icy shadow
#

🤔

lyric gyro
#

match relieved

icy shadow
#

shut it

pearl topaz
icy shadow
#

oh dear lord

#

You're gonna do that for every single class?

pearl topaz
#

sure works tho doesnt it

lyric gyro
#

scala 😩

sterile hinge
#

but the arraylist will neither contain booleans nor bytes?

icy shadow
#

just keep it unchecked, there's really no better way

pearl topaz
#

i mean yeah this gives me many errors

sterile hinge
#

you cannot cast strings in a list to any other type randomly

icy shadow
#

ArrayMonitor or ArrayMonitor<?>

#

Unbound not unchecked*

#

If you're looking for a way to arbitrarily parse Strings into different types that's a whole different issue without a great solution

pearl topaz
#

so it's not easy to reverse this.value.toString() for private ArrayList<T> value;?

#

even if i know the T

icy shadow
#

not trivial, no

pearl topaz
#

well i need to do that

icy shadow
#

I mean if you know all the types then sure, write the parsing logic manually

#

Boolean.valueOf, Integer.parseInt, etc

#

But for any arbitrary type this is pretty much impossible

sterile hinge
#

toString might not be enough then either

icy shadow
#

toString is not designed for serialisation so yeah

#

literally anything else would be better

pearl topaz
#

what would you recommend for serialising more complex types like this?

#

the reason it's a pain is im forced to use redis

#

which stores strings

icy shadow
#

JSON if you want user friendly formatting, otherwise Java persistence API might actually be the easiest option

#

it's not human readable but it just works

#

in most cases

pearl topaz
#

can't say anything i've read so far about JPA makes any sense

icy shadow
#

oh wait sorry not jpa

#

Java serialization api

#

Got them confused

lyric gyro
#

java.io.Serializable 😵‍💫

icy shadow
#

Problem?

pearl topaz
#

still can't really find any examples that make sense to me, for doing it easily with multiple types like ArrayList<Boolean>, Char, ArrayList<Float> etc

lyric gyro
#

If anything take an ObjectMapper type or w/e and let the client provide a (de)serialization function

icy shadow
#

look I'm pretty much having to guess the context

#

But afaik the types will always be known

icy shadow
pearl topaz
icy shadow
#
ObjectInputStream whatever = whatever
Serializable value = whatever.readObject()
ArrayMonitor<?> monitor = map.get(idk)
List<?> valueList = (List<?>) value;
monitor.setValues(valueList);
#

Roughly what needs doing

#

It's not pretty but should work

#

Or the ObjectMapper thing or JSON, the end result is the same

lyric gyro
#

Just to make it clear: I don't think there is a "safe" way to know the (unknown) types at compile-time, so you're going to have to cast unsafely eventually

icy shadow
#

Yeah I'm 99% sure there's no "proper" way of doing it

pearl topaz
icy shadow
#

that does not help at compile-time

lyric gyro
#

^

icy shadow
#

Storing the class is useful if you need to know the type at runtime, which you may need to

#

But it won't stop the fact that you need to do unsafe casts sooner or later

neat pierBOT
#
📋 Your paste: Emily
https://paste.helpch.at/ebezoveyik

A member of staff has requested I move your message to a paste,
Most likely because it contains a config/error/code snippet.

icy shadow
#

shit

#

Sorry

lyric gyro
#

bru

icy shadow
#

Wrong reaction

lyric gyro
#

xd

icy shadow
#

I meant to do this

lyric gyro
#

lmfao

icy shadow
#

you don't need the switch statement

#

The point of using the serialization api is that you don't have to explicitly specify any types lmao

#

It's arbitrary

lyric gyro
#

the switch statement won't change the type of what the stream reads nor the type of newValue

icy shadow
#

^

lyric gyro
#

in all cases you will read and set it

#

regardless of type

icy shadow
#

Boolean?

pearl topaz
#

mistake

icy shadow
#

Try it and see ig

#

you might also need to add base64 into the mix, idk if redis allows binary data

pearl topaz
#

i tried adding

    public void setValue(ArrayList<?> value) {
        this.value = (ArrayList<T>) value;
        setRedis();
    }
#

inside ArrayMonitor<T>

lyric gyro
# pearl topaz

they may be different types, that can't be known at compile-time, that's why you ought to "unsafely" cast eventually

pearl topaz
#

so this is the warning i just have to accept?

lyric gyro
#

yes

lyric gyro
#

looks about right I suppose

keen herald
#

@chrome briar you can ask here too 🙂

icy shadow
#

Might wanna make a separate private / package-private method which takes the unsafe list

#

So you don't accidentally call it with an actually unsafe list

chrome briar
pearl topaz
#

btw thanks a lot, and Emily, for your help

lyric gyro
icy shadow
pearl topaz
#

i don't really get the advantage of passing it to a private method

icy shadow
#

Aside from the extremely unhelpful error message, looks fine

icy shadow
#

It's not a necessity but the private public thing means you only bypass the safety when it's necessary, making it harder for accidental bugs

pearl topaz
#

ohh i see

#

that makes sense now

#

wait but then if i do something like

public void setValue(ArrayList<T> value) {
    setValueInner(value);
}

then i still get the error

icy shadow
#

that's the safe method

#

For the deserialization you use the unsafe method

#

i.e setValueInner

pearl topaz
#

oh so in general i use setValue

#

just here i use the unsafe one

icy shadow
#

yeah

pearl topaz
#

ok sweet, thanks

pearl topaz
#

should i use a "wrapper package", or prefix each package name?

#

like i have a package called redis atm which conflicts with the real redis package

#

so should i name it myapp.redis or should i make a package myapp and put all my packages in there

icy shadow
#

All your classes should typically be under a reverse domain name package

#

eg me.bristermitten.projectname.blah

keen quarry
#

How can i check if a boolean inside a list in my config is true or false? Right now i am using this```java
if(Main.getPlugin().getConfig().getBoolean("help") == true) {}

Config file:```yaml
help: true
fly: true
vanish: true

But i want to change it to be like this in the config:```yaml
Commands:

  • help: true
  • fly: true
  • vanish: true
And then i also need to change the .getBoolean() thing. But how do i do that and check if for example help is true or false inside the "Commands:" list?
dense drift
#

for booleans you dont need to do == true/false btw, just do (bool) for true and (!bool) for false

#

Get the commands list with getStringList, split at : , the first part will be the command and the second the boolean

broken elbow
#

but why a list tho?

dusky harness
dusky harness
#

sorry for ping gaby

#

didn't mean to

#

🥲

lyric gyro
#

gaby wtf

dense drift
#

I GAVE THEM A SOLUTION FOR WHAT THEY ASKED FOR

dusky harness
#

🥲

#

🥲

keen quarry
#

Ohh... That's what i thought about. Just forgot that you don't need - before it...

dense drift
#
for (String command : config.getSection("Commands").getKeys(false)) {
  boolean bool = config.getBoolean("Commands." + command);
}```
With this you can add as many commands as you want
broken elbow
keen quarry
#

Hmm. Yeah, so if i use a - it makes it a stringList instead of a boolList?

broken elbow
#

well there is no bool list.

keen quarry
#

Yeah, i just kind of call it that... xD

broken elbow
#

and if it would've been a thing it would've looked something like this:

boolList:
  - true
  - false
  - false```
keen quarry
#

Ohhh true

#

Okay yeah thanks for the help you guys! Appreciate it 🙂

dusky harness
#

seems like Mutable has a T generic

#

and since MutableBoolean sets that to boolean

#

I think it'd be setValue(Boolean value) maybe?

#

¯_(ツ)_/¯

pearl topaz
#

i need a setValue(Object value) though

dusky harness
#

how come?

pearl topaz
#

it's suggested by intellij

#

i tried using generics

#

but it seems i need to use Object then cast to what i want

dusky harness
#

you can't use generics here because MutableBoolean already set it to a Boolean

pearl topaz
dusky harness
#

and you're using Boolean instead of T?

pearl topaz
dusky harness
#

what's Monitor?

#

try doing ```java
public class BooleanMonitor extends MutableBoolean implements Monitor<Boolean> {
// ...
@Override
public void setValue(Boolean value) {
this.value = new MutableBoolean((Boolean) value);
setRedis();
}
}

pearl topaz
#

when i do

Monitor<?> monitor = monitorMap.get("m1");
monitor.setValue(monitor.deserialise(value));
dusky harness
#

huh

lemme try experimenting in my ide

dusky harness
#

so the class itself has no errors?

#

it's just that part?

pearl topaz
#

yeah

#

it tells me to change it from T to Object

dusky harness
#

you might have to do (Monitor<Boolean>) monitorMap.get("m1")

#

instead of <?>

pearl topaz
#

the point is i'm not sure of the type here

#

that's why i wanted to use Object

#

then cast within the class

dusky harness
#

ill test in my ide

dusky harness
#

ic

#

wait

pearl topaz
#

seems everything will work if i can figure out how to override the public void setValue(Object value) method

#

it is possible that this is actually impossible though

dusky harness
#

is monitorMap a Map<String, Monitor<?>>?

pearl topaz
#

i'm relying on the fact that java knows which monitor to run the methods from, once i retrieve a monitor from the map

pearl topaz
#

i wonder if this is something more doable in kotlin

dusky harness
#

ohhh i see whats happening

#

so

dusky harness
#

gimme a min

pearl topaz
#

as in it's impossible

dusky harness
#

no

pearl topaz
#

and i'll need to use instance of or something like i did before

dusky harness
#

okay i got it working

#

i think

#

not sure if this is how you wanted, but this is the best way that I can think of

#

then ```java
Monitor monitor = monitorMap.get("m1");
monitor.setValue(monitor.deserialise("a"));

#

but for getValue, you'll have to cast

#

unless

pearl topaz
#

the problem with not extending from MutableBoolean is that i want all the methods exclusive to that type

pearl topaz
#

that are not in Mutable<Object>

dusky harness
#

u can just copy it over

pearl topaz
#

not so easy when i have like 20 of these D:

dusky harness
#

make ur own MutableBoolean

#

but setValue and getValue has to be Object

#

and it has to implement Mutable<Object>

#

wait what

dusky harness
pearl topaz
#

i have IntMonitor extends from MutableInt, DoubleMonitor extends from MutableDouble etc

dusky harness
#

ohhhhhhhhhhhhhhhh 💀 💀 💀

there is one bad way which sorta abuses java's type erasure and that's to make the map Monitor<Object> and just cast everything to Monitor<Object> and suppress IJ's warnings

but

dusky harness
#

or less

#

why do u have 20 tho

#

🤔

pearl topaz
#

that wouldn't fix 'setValue(Object)' in 'monitors.BooleanMonitor' clashes with 'setValue(T)' in 'org.apache.commons.lang3.mutable.Mutable'; both methods have same erasure, yet neither overrides the other anyways

dusky harness
#

since the one i linked i tested

pearl topaz
#

Monitor<Object>

dusky harness
#

oh 🤔

#

no i mean

#

in the map

#

and only in the map

#

so you'd keep this

pearl topaz
#

i'm trying to actually test any of this

#

but it keeps running classes im not using

#

so i have a package monitors with the interface and all the classes

#

and on all the classes i've written @Ignore except ArrayMonitor and Monitor

#

and it just gives me errors from the ByteMonitor class???

#

it's running code not even inside that package

#

wtffff

neon wren
#

IDE? and provide what you are running

pearl topaz
pearl topaz
#

it's doing :test --tests "MiscTests"

neon wren
#

So did you tell it to run the tests or run the projects.

pearl topaz
#

it's running misctests

neon wren
#

What library are you using for the Tests.

pearl topaz
#

Junit

neon wren
#

Next to the line number click to the right and it should offer a message to run tests that way

#

Give me a moment, as I am on my phone but that should work to run individual tests for methods

pearl topaz
#

same thing

#

idk why it's running the task compileJava

#

which presumable tries to compile everything

neon wren
#

Because the project name is MiscTests? I’d presume it is running the project which is everything.

pearl topaz
#

i'm just trying to execute the code i sent above

#

which only uses one class and one interface

#

i dont want it to run everything thats the point

neon wren
pearl topaz
#

i havent made the rest compile yet

#

i'm using gradle

dusky harness
pearl topaz
#

even if i literally make

import org.junit.jupiter.api.Assertions;
import org.junit.Test;

public class TestTests {
    @Test
    void shouldShowSimpleAssertion() {
        Assertions.assertEquals(1, 2);
    }
}
#

it STILL runs my whole project

#

?????

dusky harness
#

yes

#

thats what tests do

#

it builds your project and tests it

pearl topaz
#

ok, so that's what ive been asking to change

#

could you show me how to make the test only test what i need please

#

this one

graceful hedge
#

I mean your tests literally test your production code

dusky harness
graceful hedge
#

So obv it needs to compile the actual source as the test source depends on it

dusky harness
graceful hedge
#

Also that test there will always fail

pearl topaz
#

it's obviously not the case that you cant test some classes when other classes are giving errors

pearl topaz
#

i literally just want to run tests on some classes and ignore the rest

graceful hedge
pearl topaz
#

i.e. they compile

graceful hedge
#

Well did you run the tests as well?

pearl topaz
#

....yes

graceful hedge
#

Alright, anyways if you really wanna avoid a recompile of your entire system, you might wanna divide your system into smaller subprojects/modules

pearl topaz
#

i think you're misunderstanding what i'm saying or dont know how to use junit (i dont either)

dusky harness
pearl topaz
#

no offense it's just

#

i want to do it the proper way

#

going forward

dusky harness
#

proper way of using junit = testing production code

#

or

graceful hedge
#

I mean you literally shouldn’t avoid compileJava

#

It’s crucially necessary for you

pearl topaz
#

if you're actually telling me i can't run tests on any part of my project because i have a missing { in one file in one package, then you clearly dont know how to use junit

dusky harness
# dusky harness or

or delete the other files (or comment them out and delete all their usages)

graceful hedge
#

Like if you wanna test your code, obv ti needs to be compile-able

pearl topaz
#

that's the whole point

#

there is no reference to any of that code

#

in my tests

#

or the classes used in my tests

graceful hedge
#

And?

#

You don’t seem to know how this test procedure goes exactly

pearl topaz
#

bruh can literally anyone else respond

dusky harness
#

if you run gradle build, just because spigot might not use some of your code doesn't mean that it can have errors

pearl topaz
#

you are clearly misunderstanding

dusky harness
#

same thing here, except that instead of spigot it's junit

graceful hedge
#

No, like even if you have the class com.dkim.FinalizableAbstractFactory which does not compile, but is still in source, then of course you won’t be able to run tests for the source

#

because junit isn’t some magical wizard that can figure out every little interdependence of every unit you have

#

The task compileJava is fundamentally integral to pass in order for the tests to run, that’s just how it works, even though your test might not depend on the entire code base, but only the compiling parts

#

If some parts still don’t compile, it won’t run the tests as it can’t for sure know whether the failing parts are crucial to the actual compiling parts that you’re essentially testing

#

And yes this is ofc caused by IntelliJ (possibly gradle) in principle, altho for good reasons, you could in principle go and compile the test src for yourself and then run the tests but that’s just masochistic

wintry grove
#

so, basic possibly stupid question with gson, I'm trying to make a file, and writing an User Object (a class I made (name : string, id : int, age : int, money : int)) on it, but when I open it, its just blank.

Lil Code here:
https://paste.helpch.at/umagolexuz.cpp

#

tried also just using primitives

#

the same

#

never mind just had to ask fucking copilot to do it

dusky harness
#

🥲
🥲

wintry grove
#

what

dusky harness
#

yes

hoary scarab
#

Can't wait to see the complaints about why people are forced to open source their code because it's written by "copilot" lol

dusky harness
#

u have to OS code generated by copilot?

hoary scarab
#

Not currently. But it's not your code if it's generated by ai lol

dusky harness
#

but that also means it's not someone else's code fingerguns

hoary scarab
#

Technically it would mean it's github's code

lyric gyro
#

The training samples are from OS repos, but the generated code isn't necessarily generated from them, depending on context and what you do exactly it can come up with something that is not out there

#

It can stitch things together or, yes, copy code from existing repos

pulsar ferry
#

It also generates from samples from your own code

lyric gyro
#

It highly feeds and depends on existing context, yeah

#

It's scary sometimes

#

Annoying mostly

wintry grove
#

can agree

pulsar ferry
#

I just want them to add function to do suggestion with a shortcut similar to ctrl + space

#

Instead of constantly suggesting

lyric gyro
#

You can do that already?

pulsar ferry
#

As far as I know, only open that side bar

lyric gyro
#

Disable live completion suggestions and use the "Open Copilot" thingy

pulsar ferry
#

Yeah that's not what I mean though, I mean like the current way it suggests but manual

lyric gyro
#

It definitely needs more configuration on the plugin side of things

#

Which should be trivial!

pulsar ferry
#

Yeah, then I would turn it back on

pearl topaz
#

i have a class i'm extending from with a method i want to override

override fun addAndGet(operand: Int): Int {
    this.value?.add(operand)
    logValue()
    return this.value?.toInt() ?: 0
}
```however, `this.value` is nullable as the class needs to be able to be instantiated without a value, then set one later. i can't change the return type to `Int?` as the method i'm overriding returns `Int`
#

what's good practice for this? ?: 0 is a temp fix

kind granite
#

give it a default value

pearl topaz
#

ah yes

#

smart

#

or else i could do return this.value?.toInt() ?: throw NullPointerException("Value is not set")

sterile hinge
#

well what happens if the method is called before the value is set initially?

pearl topaz
#

somethin like that

pearl topaz
sterile hinge
#

and what would you like it to do?

kind granite
#

or define it as lateinit and just make sure you set it

pearl topaz
#

feel like a default value is the easiest way to go

sterile hinge
#

like, if you don't want someone to call the method before the value was set, you should throw an exception

#

lateinit sounds like a good approach ig

kind granite
#

it's literally what lateinit is designed for

pearl topaz
#

so i'm a bit confused

#

as to what it actually achieves

#

like sure i hope it's set before they try and do operations on the value

#

but how is that different

kind granite
#

how come you need to be able to instantiate it without a value?

pearl topaz
#

it's in the spec i was given, not certain tbf

#

maybe i'll just remove that

#

unless you can explain the lateinit thing or why it helps

pulsar ferry
#

Only difference would be that lateinit will throw an error if you access it without initializing it

pearl topaz
#

what's the appropriate way of accepting a parameter when i want to immediately change its type? i have a parameter to my class value: Int that i run MutableInt(value) on

#

right now i'm doing

class IntLogger(private val intValue: Int) {
    var value : MutableInt = MutableInt(intValue)
}```
#

i never use intValue again

#

i just want to be able to instantiate with a regular int

kind granite
#

what youve got there is fine

pearl topaz
#

ok thanks

#

i'm really confused about extending actually

#

class IntLogger(private val intValue: Int) : MutableInt(), Logger {

#

i'm trying to extend from the class MutableInt

#

but it's making me initialise it

#

then whenever i try use methods from MutableInt, it just thinks the value of my IntLogger is 0

#

if i initialise it with MutableInt(intValue) then it just wont change when i change the value of IntLogger

#

this seems bizarre, why would i want two "versions" of my object here? i just want one IntLogger instance that can access the methods from MutableInt

kind granite
#

there you're creating a logger that is a mutable int

#

mutableint is a class itself

#

logger is just an interface

#

which is quite a strange way of doing what you're trying to achieve

#

what is the end goal?

pearl topaz
#

i'm trying to make my own MutableInt, where i override all the setter methods to log the value change

kind granite
#

ah

#

that is not what a Logger does

pearl topaz
#

the way it's working now, there's one value returned by logger.getValue() (defined in IntLogger) and another returned from logger.intValue() (not defined in IntLogger)

#

i know 🙂 this is a trivial explanation, i'm confident of that though

#

i just need to get this extend working

kind granite
#

are you familiar with calling methods on super

pearl topaz
#

yes

kind granite
#

do that

#

inject a logger in the constructor

#

shim each method and log to that logger

pearl topaz
#

this is v confusing

kind granite
#

yes

#

except you don't need to override methods that just call the super

#
    override fun serialise(): String {
        return super.toString()
    }``` does basically nothing
#

and you don't need the value variable, that's defined in super too

pearl topaz
#

but the value in super is Int, my value is MutableInt

kind granite
#

your value doesn't exist

#

the class itself is a mutableint

#

we're only shimming the mutableint class, we don't care about what's happening in the class itself

pearl topaz
#

ok i think i get it

kind granite
#

also don't implement logger

pearl topaz
kind granite
#

your class implements logger

#

don't do that

pearl topaz
#

logger is my own interface

kind granite
#

it should write to a logger, it is not a logger itself

#

oh

#

be aware that can be very easily confused for java.util.Logger which does something slighly different

wheat carbon
#

is it good practice to name your own class Logger when java also has a Logger

pearl topaz
#

is this correct btw?

kind granite
#

yeah

pearl topaz
#

thanks

pearl topaz
#

i'm trying to make my own serialisation method for ArrayLogger<T> which extends ArrayList<T>

#

however, i can't seem to get it to work since ArrayList has no getValue() method

#
val targetStream = ByteArrayOutputStream()
val out = ObjectOutputStream(targetStream)
out.writeObject(super.getValue()) // write our serialised object to the output stream
val serialisedValue = targetStream.toByteArray() // get serialised byte array
out.close()
targetStream.close()
Base64.getEncoder().encodeToString(serialisedValue) // encode byte array to String with B64
```like i just want to do this
dense drift
#

what even is an ArrayLogger?

pearl topaz
#

so i'm overloading set, add etc in ArrayList

kind granite
#

why are you serialising for logging

#

that seems like a bad idea

#

in fact why do you even need that, it sounds like a very backwards debugging technique

dense drift
#

info(x.toString()) ?

pearl topaz
#

i was trying to abstract some details but maybe not helpful

#

the logging is using redis

#

which only stores strings

#

so i need a serialise and a deserialiseAndSet method for ArrayLogger

pearl topaz
kind granite
#

serialisation is not human readable

#

which is pointless for logging

pearl topaz
#

sorry i have complicated it

#

i know that it needs to be serialised

#

this method works except for when i switched to super

#

when i was just storing the value in ArrayLogger, it worked fine

#

but i can't do super.getValue()

#

so i have no idea how to serialise/deserialise it

kind granite
#

explain what you're trying to do from a high level

pearl topaz
#

i'm trying to create a class (let's call it ArrayLogger) that overloads any method inside ArrayList that updates any of its value

kind granite
#

to do what?

pearl topaz
#

and if that happens, i write the new value to a Redis DB

#

which has to be serialised to a string as that's all redis takes

kind granite
#

so a redis-backed array?

#

sounds like you need an orm

pearl topaz
#

orm?

kind granite
#

basically a client

pearl topaz
#

well im using jedis

kind granite
#

ill be honest im not all that familiar with redis in general but you really ought to be wrapping this stuff in some kind of manager class

pearl topaz
#

but how can i do that if i can't even get the value of the arraylist

kind granite
#

you can

pearl topaz
#

how?

kind granite
#

you use super

#

pass all the arguments youre given

pearl topaz
#

wdym

#

how can i get the value of the arraylist

#

when there's no super.getValue() method

kind granite
#

iterate over itself?

#

for (T thing : this)

lyric gyro
#

^ In your case ofc

quasi kraken
#

I didn't? But aight

#

It works

lyric gyro
quasi kraken
#

Uh huh

lyric gyro
#

the fuck are you talking about

#

what

#

that is wrong on so many levels wtf

#

?

quasi kraken
#

That's what I thought

#

Imma just go-

lyric gyro
#

load: STARTUP means the plugin will enable before worlds are loaded on the server
load: POSTWORLD means it will enable after all worlds are loaded but before the server fully starts

icy shadow
#

@quasi kraken if there's an error please send it

lyric gyro
#

it has nothing to do with reloading or restarting or entering new worlds

#

Oh

quasi kraken
#

I fixed it.

lyric gyro
icy shadow
#

Oh alr

kind granite
#

what

#

have you ever considered just returning this

pearl topaz
#

no idea what you mean tbf

kind granite
#
fun getValue() = this
pearl topaz
#

that wont return the value of super though will it?

#

as an ArrayList<T>

kind granite
#

this and super are the same object

pearl topaz
#

that will give me an ArrayLogger<T>

kind granite
#

super is used to access methods defined in the superclass, but still refers to itself

lyric gyro
#

ArrayLogger is an ArrayList

kind granite
#

good old liskov substitution principle

lyric gyro
#

if you really want to be pedantic about the return type being an ArrayList then fun getValue(): ArrayList<T> = this

kind granite
#

i believe its from a generic interface

pearl topaz
#

i replaced your getValue() with mine and it broke the serialisation

#

so it must not be equivalent

#

i mean

#

replaced mine with yours

kind granite
#

i have so many questions

#

why are you trying to serialise stuff

#

what is the purpose of putting all this stuff in redis

lyric gyro
#

to start with I don't think extending the types you're supposed to store is good design

pearl topaz
kind granite
#

dont do that

lyric gyro
#

either don't do it at all or make use of kotlin's by delegation/proxying

#

inclined towards the first option

neon summit
#

How could i disable taking out items, putting in items, dragging items from my gui?

Current code(Not Working):

    @EventHandler
    public void onInventoryClick(final InventoryClickEvent e) {
        if (!e.getInventory().equals(inv)) return;
            if(e.getCurrentItem() == null) return;
                if(e.getCurrentItem().getItemMeta() == null) return;
                    if(e.getCurrentItem().getItemMeta().getDisplayName() == null) return;
                        e.setCancelled(true);
                            Player player = (Player) e.getWhoClicked();
                            if(e.getSlot() == 22) {
                                player.sendMessage("test");
        }
    }
round sail
#

That indenting aPES_Shake

broken elbow
#

why?

round sail
#

Are you asking me?

broken elbow
#

no. them

round sail
#

👍

broken elbow
#

why the indentation xD

pearl topaz
#

i looked into it but couldnt figure out why it's applicable

kind granite
#

as in the delegation bit?

pearl topaz
#

yeah

#

or any other way to approach it

#

i have an API that updates the value of this class

#

so surely i need a setValue method

#

since arraylist doesn't provide one

kind granite
#

setting an arrays value to another array doesn't make sense

#

like when would you ever do that

#

why do you need that method

pearl topaz
#

when i have a wrapper class that's monitoring something, and that instance starts monitoring something else

kind granite
#

setting a list's value to another list is not a list

#

at that point its more of a list container

pearl topaz
#

that's what it is

kind granite
#

then it's not a list

#

so don't override ArrayList

pearl topaz
#

so just write it all myself? or what

#

what's the difference there though

kind granite
#

what you have there is effectively a mutable reference

#

for primitives, that works

#

for lists that does not

#

which is why the approach youre taking is not suitable

pearl topaz
#

i dont see another approach

kind granite
#

what is the end goal

#

what are you trying to achieve by logging mutations and storing them on a redis server

pearl topaz
#

it's just for fun mostly, like a telemetry service

#

everything else works just stuck on arraylist

lyric gyro
#

having fun much? 🥲

pearl topaz
#

yeah mostly tbf

dusty frost
#

tilted, obviously

inner jolt
lyric gyro
#

Cause i think he can't find the inventory to cancel the items dragging etc

pearl topaz
#

what's the correct way to implement a global variable that's used between multiple classes? i have a single map accessed in my main loop but also in the Ktor REST API

#

i was planning on making the methods @Synchronized

#

companion object?

#

is it just as simple as

#

and when i update it in either, they both change?