#help-development

1 messages ยท Page 142 of 1

waxen plinth
#

???

jaunty crag
#

like with tellraw you would do in my case

#

[{"text":"\uE001"},{"translate":"space.-5"},{"text":"\uE001"}]

#

but i am trying to somehow use that with plugins

waxen plinth
#

If it comes down to it you can always just dispatch a command from a plugin

jaunty crag
#

i cant

#

because i need to edit the text in my scenario

waxen plinth
#

MrEpiko I'm jealous that you got profile themes

waxen plinth
jaunty crag
severe marsh
#

everyone is hating on me

#

anyways, how do I force open book and quill?

severe marsh
#

1.8

#

I know that I have to use NMS for it

#

I've successfully made it force open normal book, but I don't know how to open book and quill

eternal oxide
#

no clue on 1.8 but current book and quill is just an ItemStack of unwritten book

#

WRITEABLE_BOOK

#

1.8 would be legacy

jaunty crag
#

how do i utilize custom languages from resource packs in the Player#sendMessage

#

I am trying to use negative spaces

lost matrix
jaunty crag
#

yes yes yes yes yes thank you

lost matrix
# jaunty crag yes yes yes yes yes thank you

Inside your default.json file which defines your font chars:

{
  "providers": [
    {
      "file": "minecraft:stick/2006.png",
      "chars": [
        "ใ‰ฃ"
      ],
      "height": -3,
      "ascent": -2000,
      "type": "bitmap"
    },
    {},
    {}
  ]
}

The "height" determines how far the character is being spaced
Setting "ascent" to -2000 basically shifts it out of the screen.
The image file can be of whatever size.

jaunty crag
#

yeah but like

#

how do i use the custom characters

lost matrix
#

Just type in your replaced character.
I just started in the middle of old mandarin characters in the unicde table.

worn tundra
#

Or you can use them in the unicode form \uF000, \uF001...

#

You could also make separate fonts, if you have the ability to make your own plugins

#

Then your players won't ever be able to use those in chat

jaunty crag
#

how do i use those languages

#

in the plugin

#

thats what I am doing currently

lost matrix
#

?

#

String

#

I dont understand the question

worn tundra
#

Are you working on your own plugin?

jaunty crag
#

languages are defined in the resource pack though not the plugin right

worn tundra
#

Alright, so you could do it by separating the fonts into different files or do it all in the default.json file.

jaunty crag
worn tundra
jaunty crag
#

can i add you to a thread to explain my use case

worn tundra
#

Yes of course

jaunty crag
#

ok

#

head indicators

#

i did

tardy delta
#

hmm kinda long ago but how can i remove a few records from a database where i know the id of all those, can i use one query for that or not?

#

probably have to made a query for each removal ig

urban kernel
#

can someone help me h2 database please ty

tardy delta
#

?ask

undone axleBOT
#

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

tardy delta
urban kernel
#

how do i create read and write from h2 db pls

tardy delta
#

do people even google

worn tundra
#

no

#

they dont

urban kernel
#

mysql != h2

tardy delta
#

same for all stuff

hazy parrot
#

just use sqlite

tardy delta
#

ive used h2 before

#

dunno why actually

grim ice
#

honestly

#

its quite funny how signed ints have a whole bit worth 2.1bil in decimal just for the sign

tardy delta
#

looks kinda hot actually

grim ice
civic wind
#

1.19 way of getAction()? for player interact event to register who left clicked itemstack anyone?:)

tardy delta
#

ngl?

grim ice
#

there should be an sql wrapper

#

for sql

civic wind
severe marsh
#

How can I listen to Command block executions?

hazy parrot
tender shard
#

yeah SQL stuff should be wrapped into stuff, but I forgot the name

grim ice
#

yes

tender shard
#

what is it called again

grim ice
#

the name of what

tardy delta
#

i hope you arent lying lol

#

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

tender shard
tardy delta
#

just use db framework

grim ice
tardy delta
#

like object to table mapper or whatever its called

hazy parrot
tender shard
#

nah you usually have some object for every SQL stuff, e.g. if you put a... erm let's just say Player object into a DB, you will have sth like a PlayerDatabaseSource object or similar

#

I forgot how it's actually called

grim ice
#

i mean thats just oop

tender shard
tender shard
civic wind
#

Can anyone shed any light on why this isn't registering the right click and performing the command? I'm going to debug but just asking if anyone can help ๐Ÿ™‚

tardy delta
#

errors?

civic wind
#

Nope

tardy delta
#

put sysouts

#

๐Ÿค”

#

doesnt that mean the entity?

civic wind
#

ahh shit

#

I'm checking for entity being right clicked arent i

tender shard
#

yes

tardy delta
#

kekw im already regretting writing this

tardy delta
#

but if it works dont touch it

civic wind
#

Yeah i had a brain fog i was checking for right click of entity lol

feral pike
civic wind
#

I'm using wrong event completely

hazy parrot
feral pike
#

At*

uncut rock
#

Hello Someone have faction booster update for 1.12?
And
Killstats too update for 1.12

hazy parrot
feral pike
civic wind
#

I need PlayerInteractEvent, I'm just right clicking an itemstack i messed up

feral pike
#

okaay

civic wind
#

Thats why getAction() wasn't working i was like wtff xd

tardy delta
hazy parrot
#

check you driver impl, but default java one does that

tardy delta
#

all databases do that?

civic wind
#

It's not evening broadcasting any... Not sure why this isn't working :/

tardy delta
#

early returns where

lost matrix
tardy delta
#

mye thought about that but seemt a little overhead

fringe hemlock
civic wind
#

Yes

tardy delta
#

not really overhead, more like too much work for smth small

lost matrix
fringe hemlock
#

Is it the class loaded in your main class

hazy parrot
lost matrix
civic wind
#

Yeah i've been told this before, I will give pdc a go thanks

tardy delta
#

might wanna use PreparedStatement::setObj then

#

thanks

fringe hemlock
#

?pdc

tardy delta
civic wind
tardy delta
#

search docs

#

?jd-s

undone axleBOT
civic wind
#

ahh hand, chestplate etc?

tardy delta
#

i believe so, long time since i touched spigot code

#

went learning c++ and created expression parser lmao

civic wind
#

Do you find c++ easier?

lost matrix
lost matrix
tardy delta
lost matrix
tardy delta
#

spares me some time

civic wind
tender shard
#

just do event.getItem()

lost matrix
#

Its from PlayerInteractEvent like the docs ive sent stated.

civic wind
#

Well I'm not sure that's the only option i've got

tardy delta
#

!

#

๐Ÿฅฒ

lost matrix
# civic wind .

What are you saying? You are calling this method on an EntityEquipment object.
But you need to call it on your PlayerInteractEvent object.

civic wind
#

I have no idea that's what im saying, I'm using PlayerInteractEvent but it's giving me that

lost matrix
#

Show me a screenshot of what you are doing

civic wind
lost matrix
#

So you think p.getEquipment() returns a PlayerInteractEvent?

#

[] yes
[] no
[] idk

civic wind
#

Guessing not seen as you're saying it like that LOL

lost matrix
#

Hover over the method and tell me its return type.

outer river
#

hello, how do i jump a line pls ?

civic wind
#

Sir, entityequipment

lost matrix
iron glade
outer river
#

oh i see, i'm so dumb thx

lost matrix
remote swallow
#

run getItem() on e not p, should look like ItemStack item = e.getItem();

tender shard
civic wind
#

I was using player

iron glade
civic wind
#

damn im getting roasted

lost matrix
remote swallow
#

i can see the event calling e, but calling player p i dont get

worn tundra
tender shard
civic wind
#

damn this is how it feels to be gender fluid?

tender shard
#

after all I wrote those blog posts so I dont have to repeat myself all the time

iron glade
lost matrix
lost matrix
worn tundra
tender shard
iron glade
#

Well my projects are not open source, nobody else than myself has to look at them, and as long as I know what it does idc

tender shard
#

how would you call an entity? e3?

worn tundra
iron glade
#

jk

civic wind
#

I've learnt my lesson

#

event for event, player for player

lost matrix
#

Single letter variables are only ok if they are exclusively used in the next 3 lines. Im with Bob Martin on this one.

tender shard
#

true

lost matrix
iron glade
#

imagine having to complete player all the time

civic wind
iron glade
#

instead of p.

civic wind
tender shard
#

or you spell it out completely, it takes like 0.3 seconds to write "player"

iron glade
#

yeah and this way I press p. and i'm done

lost matrix
tender shard
#

yeah it would save like 3 minutes in a year lol

#

probably way less

iron glade
#

well as I said I don't really care as it's not open source and I know what I use p for

civic wind
#

@lost matrix it works thanks

tender shard
civic wind
#

You're a good teacher, didn't just give me the answer

lost matrix
#

Even in my for loops i dont use i actually...

iron glade
#

same somtimes

tender shard
#

for(int noti = 0; ....

tardy delta
#

crunch ๐Ÿ‘€

tender shard
#

crunchyyy newspapersmack

lost matrix
#

:newspapersmack: lol

tender shard
#

no idea where it's from

tardy delta
#

๐Ÿคค

eternal night
tender shard
#

i dont even know why I can use it

eternal night
#

its from kyori

tender shard
#

what's that

eternal night
#

adventure

iron glade
#

adventure

tender shard
#

I dont think Im a member there

iron glade
#

adventure papi

eternal night
#

you are

#

or not anymore ?

tender shard
#

weird

eternal night
#

o.O

tender shard
#

discord moment

eternal night
#

exposed

tender shard
#

oh that discord

iron glade
#

ladies and gentleman

#

we got him

tender shard
#

yes, I I will admit it

#

I am mfnalex

tardy delta
#

dang jusr discovered it got a fast charging mode on my laptop3

lost matrix
tender shard
#

why do you have 3 laptops

eternal night
#

omg I love that banhammer ๐Ÿ˜‚

#

Imma steal it

viscid ember
#

Is there anyway for me to set the damage cause

#

so i have this wand that shoots a beam

#

it does damage but it doesnt send a damage causer event

#

does that make sense?

lost matrix
#

Dealing damage with a specific cause?

viscid ember
#

e.g
I hit cow damage causer is Me the player

tender shard
#

just do new EntityDamageEvent(...), then use the PluginManager to call this event

viscid ember
#

well i have an item bound to it

#

so each time the item is rightclicked

tender shard
#

wait, are you damaging items, or damaging entities?

viscid ember
#

entity

#
        double BlocksToShoot = 10; //Number of blocks to shoot for if 10 the beam will be 10 blocks long

        Location end = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().normalize().multiply(BlocksToShoot));
        Location start = player.getEyeLocation();
        Particle particle = Particle.ASH;

        double d = start.distance(end) / 10;
        for (double i = 0; i < 10; i = i + 0.1) {
            Location l = start.clone();
            Vector direction = end.toVector().subtract(start.toVector()).normalize();
            Vector v = direction.multiply(i * d);
            l.add(v.getX(), v.getY(), v.getZ());
            start.getWorld().spawnParticle(particle, l, 20);

            List<Entity> near = l.getWorld().getEntities();

            for (Entity e : near) {
                if (e.getLocation().distance(l) <= 1.5D) {
                    if (e instanceof LivingEntity && !(e instanceof Player)) ((LivingEntity) e).damage(3);
                }
            }
        }```
tender shard
#

then as said, just call the EntityDamageEvent yourself

viscid ember
#

i do do that

#

i was using EntityDamageByEntityEvent

#

however the beam isnt a "entity"

#

i dont know if im making sense here

#

and i cant call player for "EntityDamageEvent"

tardy delta
#

just fire event yourself

lost matrix
#

Then why call the EntityDamageByEntityEvent?

#

If the player is not damaged by an entity

severe marsh
#

Is it possible for a player to execute a command and then plugin would execute some built-in command. For example, player executes /diamond and plugin will do /give {player} diamond

tardy delta
#

Bukkit.dispatchCommand

tardy delta
#

or smth

lost matrix
tardy delta
#

๐Ÿฅฃ

viscid ember
#

The reason im calling EntityDamageByEntityEvent is because i need to get the player to display some text on their action bar

severe marsh
tardy delta
#

poor cow

lost matrix
severe marsh
#

๐Ÿ‘

lost matrix
tender shard
lost matrix
tender shard
#

lmao wtf

#

good one ahaha

tardy delta
#

should buy nitro but my mom sees everything i buy with my card :/

#

then she like pissed off

tender shard
#

nitro is kinda useless unless you want a fancy colored name

tardy delta
#

i want the fancy emotes

tender shard
#

you can also just boost this server without getting nitro, but I guess your mom would see that too ๐Ÿ˜„

night copper
#

its not fancy its animated

tardy delta
#

your mom is animated

tender shard
tardy delta
#

have fun

fluid river
#

putin talks to nation

tardy delta
#

this isnt the channel for that smh

fluid river
#

Gonna start really soon

tardy delta
#

goddamn putin

#

let putin animate mfnalex' mom

#

๐Ÿค”

tender shard
#

erm yes

#

I agree

#

I think

lost matrix
fluid river
#

maybe

#

maybe not

green prism
#

How can I create a loopTask in bungeecord? (Something like bukkitrunnable)

fluid river
#

who knows what's he gonna say rn

#

maybe lnr/dnr won't join

lost matrix
green prism
#

is there any extend Scheduler?

#

or Implements

tardy delta
#

?

lost matrix
#

Implement Runnable

tender shard
#

the runnable is the thing you implement

#

ProxyServer.getScheduler().schedule(yourPlugin, new Runnable { ... }, ...);

green prism
#

Thank you!

tardy delta
#

alex you forgot your lambda again hehe

tender shard
#

I assumed they dont know about lambdas

fluid river
#

not anonymous anymore

tender shard
#

so I suggested a normal thing

lost matrix
faint frost
#

Trouble with reobfuscation Spigot 1.19.2

tardy delta
green prism
#

What are you going to do now?

tardy delta
#

call the police

tender shard
green prism
#

lmao

fluid river
#

nuke your house

tender shard
#

ofc Nuker suggests nukes lol

fluid river
#

ez

tardy delta
#

get the FREE JAVA LESSONS

fluid river
#

checkmybio

tender shard
#

Nuke extends Weapon

fluid river
#

Nuke extends God

tender shard
#

no, God is a final class

fluid river
#

implements Divine

tardy delta
#

my teacher programming asked so much boring questions today lol

tardy delta
#

"can an object be an instance of multiple classes"

fluid river
#

don't go

tardy delta
#

well i came to late to lesson anyways

tardy delta
#

damn trains

fluid river
#

nuke him

tardy delta
#

her3

lost matrix
fluid river
#

nuke him

tardy delta
#

yes lol

tender shard
fluid river
#

the proper is bro what the heck are you asking looool

tender shard
#

well it works in other languages

fluid river
#

how do you even imagine it

lost matrix
#

BMW < Car < Vehicle < Object
That makes 4 already

fluid river
#

It's an instance of BMW

tardy delta
#

i forgot my book too lmao

night copper
#

trash <

tardy delta
#

i was just making pong in lesson lol

fluid river
#

since java is c++ made, instance of BMW just hase copy constructor from the language

tender shard
tardy delta
#

she was like, now yours time to code

#

people whod never touched a line of code :

neon nymph
#

Ello! Got a quick question, is registering and unregistering events resource intensive?

tardy delta
#

ig not

tender shard
#

hi, not really

#

it basically just adds an entry to a list

lost matrix
#

It has to rebake the entire event list every time

tardy delta
#

hows event listeners even stored? Map<Event, Set<Consumer<Event>>> or smth lol?

tender shard
#

yeah but how long is that going to take? 2ms?

lost matrix
#

There is also no good reason to do that

lost matrix
tender shard
fluid river
lost matrix
#

I mean its not horrible like IO.
I just want to express my disapproval

lost matrix
tardy delta
#

std::cout << "hello\n"

fluid river
#

so you know copy constructor

#

idk how to properly translate

tender shard
neon nymph
#

I see, thanks for your input guys

tender shard
#

btw corals what you are you trying to do?

lost matrix
#

This is a copy ctor

neon nymph
#

But wasn't sure if it was alright that's why I asked lol

tender shard
#

oh that sounds like a bad idea. you should only have one listener that distributes the stuff to each separate GUI thing

lost matrix
#

Who uses this language? This was such a pain to learn even after knowing java pretty well.

neon nymph
#

Well I tried that before, the listener quickly bloated

tardy delta
#

ill probably learn assembly this year

neon nymph
#

One of the reasons I'm trying to create a better one is to have less loc

shut field
#

I hope you get better soon

tardy delta
#

seems interesting lol

lost matrix
tardy delta
#

lol

#

dont even know what a goto is

#

context switch?

fluid river
#

So basically as long as there are no pointer operators in java

lost matrix
#

Its a java keyword as well btw

tardy delta
#

isnt it just a reserved keyword?

#

without meaning

lost matrix
#

Yeah

shut field
#

Is there any reason that two players see the same mob facing different directions on there screens? I have like multiple mobs and players see them differently

tardy delta
#

so is const ๐Ÿ˜ญ

green prism
#

How can I check if a Server is full using its name? (BungeeCord)

#

Im new to bungee, sorry guys

lost matrix
#

Here are some other lesser known keywords:

exports
volatile
transient
strictfp

I use transient quite a lot actually. The rest is pretty useless in terms of usability.

willow pike
#

Hey! I made a .txt file with random names and saved it at the resources folder.
String wizzard_names = new File("").getAbsolutePath() + "/src/main/resources/wizzard_names.txt";
It says that the file doesn't exist. Can anyone help me?

green prism
tender shard
lost matrix
tender shard
tardy delta
#

i know transient, googled strictfp (sometihing with numbers), also know volatile and exports is new api so idk lol

green prism
#

nothing about performance

lost matrix
#

Documentation for a method

tender shard
willow pike
#

ok

green prism
tender shard
lost matrix
#

?jd

green prism
tender shard
#

damn only now do I realize that md heavily used lombok in bungeecord

tardy delta
#

we learned at college what javadocs were lol

#

why have i come to lessson ๐ŸŒ

tender shard
#

yeah I also remember that from university. you go there, and learn nothing. then you skip the next day and you missed new stuff haha

tender shard
#

you can ping() the server and get a Callback to a ServerPing thing in return

tardy delta
#

dont even know if i must go to lesson

green prism
#

humh

tardy delta
#

my mom wont allow me not goin lol

#

goddamn parents

lost matrix
# green prism wat

ProxyServer -> getServerInfoโ€‹(String name)
ServerInfo -> pingโ€‹(Callback<ServerPing> callback)
ServerPing -> contains all the infos you need

#

Maybe there is an easier way but this is what i put together just skimming through the docs

green prism
#

how can I get the callback

lost matrix
#

You provide it

green prism
#

wtf

#

new ServerPing()...?

willow pike
lost matrix
#

use a lambda

private void useInfo(ServerPing ping) {

}

public void something() {
  ...
  info.ping(this::useInfo);
}
green prism
#

๐Ÿง

tender shard
#

sth like this

green prism
#

Thank you!

#

That was it xD

tender shard
#

a callback is like a lambda with 2 arguments, one for success (the ping instance that you're looking for) and one for an exception in case anything goes wrong

shut field
# tender shard usually no

I am using mob.setInvisible(true) and on one player's screen they can see it and on the other they can't see the mob

lost matrix
willow pike
severe marsh
#

Placing command block while being unopped doesn't call the BlockPlaceEvent, what do I do?

tall dragon
#

did you try with another block?

severe marsh
#

yes

hasty prawn
#

PlayerInteractEvent probably

tall dragon
#

yea. that is weird tho

#

why would it not call for command blocks

hasty prawn
#

Because you can't place Command blocks when you're not opped

tall dragon
#

ah. did not even know that

severe marsh
lost matrix
hasty prawn
#

Well I don't know what you're trying to do, but check if it's in their hand first.

lost matrix
#

Wait how is he placing a command block when he is not opped?

hasty prawn
#

He's not that's the issue

#

He wants BlockPlaceEvent to be fired for un-opped people placing Command Blocks but obviously that won't happen

lost matrix
#

Why does he want that if the players cant place it in the first place?

hasty prawn
severe marsh
#

Ok I figured it out

sleek badge
#

what event should I use in my listener if I want to check if a player has right clicked a non interactable block

tall dragon
#

a non interactable block?

#

such as grass?

#

PlayerInteractEvent

vivid skiff
#

How can i get the a path key witch is a player name

Current:

return getGangsData().getConfigurationSection("gangs").getKeys(false).stream().filter(key -> getGangsData().getString("gangs." + key + ".Leader").equals(playerUUID.toString())).findFirst().map(key -> key).orElse(null);

sleek badge
tall dragon
#

you would do that exactly the same way you did with the gang name

vivid skiff
tall dragon
#

using #getKeys(false)

eternal oxide
#

why are you storing both UUID and name?

vivid skiff
#

because i need the possibility to check who is that player via data

eternal oxide
#

then just store UUID and get teh offline player for its name

latent tartan
#

i have this class called TC which i make an instance of for every one of those in the world, it has a load of info in it like its location and who has accessed it. I would like to save this to a yml file.

In my main class i have a list of all of the instances of the TC class, along with a really simple bit of code to save stuff to a yml file.

Issue im having is i cant just save the classes, because its yknow a class. Im guessing id have to serialize it, but im not really sure how to do that. Or how id then load it afterwards.

I know i should just read the docs etc but ive tried and for some reason just cant understand what to do

pseudo hazel
#

well you could make 2 functions in TC, ine to serialize data and one to read (deserialize) it

#

depending on whats actually stored in TC it might be really hard or really easy

latent tartan
#

this is whats in my TC class


import org.bukkit.Location;
import org.bukkit.OfflinePlayer;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

public class TC implements Serializable {

    private final Location location;
    private final List<String> accessed;
    private String accessCode;

    public TC(Location location) {
        this.location = location;
        this.accessed = new ArrayList<>();
        this.accessCode = "";
    }

    public TC(Location location, List<String> accessed, String accessCode) {
        this.location = location;
        this.accessed = accessed;
        this.accessCode = accessCode;
    }

    public Location getLocation() {
        return location;
    }

    public List<String> getAccessedPlayers() {
        return accessed;
    }

    public void addAccessedPlayer(OfflinePlayer op) {
        accessed.add(op.getUniqueId().toString());
    }

    public void clearAccessedPlayers() {
        accessed.clear();
    }

    public String getAccessCode() {
        return accessCode;
    }

    public void setAccessCode(String accessCode) {
        this.accessCode = accessCode;
    }
}
eternal oxide
#

implement ConfigurationSerializable, follow the instructions for that and register your class.

latent tartan
#

ima be honest none of that makes any sense to me ive been using java for all of a month

pseudo hazel
#

what does tc stand for

latent tartan
#

tool cupboard

#

im making rust in minecraft, because i regret most my life choices

tall dragon
#

making some rust eh ? xD

tender shard
#

oxidize daisy

latent tartan
#

the game rust, yknow what i mean. maybe

pseudo hazel
#

should be easy since its just like 3 things

latent tartan
#

so uh, what would i put in these functions ๐Ÿ˜‚ sorry for my lack of braincells lol

pseudo hazel
#

like elgarl says, implement configurationserializable

#

what ide are you using?

latent tartan
#

intelliJ

pseudo hazel
#

okay

#

so implement the interface and then intellij will let u know what you need to implement

tender shard
#

not completely

#

you also need the map constructor or the static deserialize method

#

read the javadocs, it explains everything

latent tartan
#

so i need a serialize and a deserialize in that class?

tender shard
#

yes

#

one returns a Map<String,Object>, the other one takes one and returns your new object

latent tartan
#

is deserialize the one taking it?

tender shard
#

basically this is all you need

tender shard
latent tartan
#

got it

#

i added that but now a 2 variables are red lining saying that they might not have been initialized

#

wait i think im just an idiot

tender shard
#

lol show your code pls

#

?paste

undone axleBOT
latent tartan
#

line 64 is eroring when i try to make a new TC

tender shard
#

you only set the "name", you never set the location or the "accessed" thing

#

usually your deserialize method should do sth like this

return new TC(map.get("location"), map.get("name"), ...);
latent tartan
#

ahhh ok i think i get what you mean

tender shard
#

btw TC is a bad class name, you should try to make it more descriptive ๐Ÿ˜›

#

but otherwise, it should work fine

#

also in your serialize() method, you ONLY save the name

#

you normally want to save all properties, not just the name

#

map.put("location", location);
map.put("accessed", accessed);
etc

latent tartan
#

oki

latent tartan
tender shard
#

just wanted to mention it haha

lost matrix
#

Call the class "p", "i" or "e"
Those are the most popular names for everything.
Or call it "main"

tender shard
#

you forgot the /scnr part mr bratwurst

#

oh @latent tartan you also misspelled the deserialize method name

#

it's supposed to be called "deserialize", and NOT "deSerialize"

latent tartan
#

oki

lost matrix
#

Hmm. Why do you need this?

tender shard
#

get the field using SomeClass.getField("..."), then call "get(myObject)" on it?

#

why do you need reflection for this

latent tartan
tender shard
#

I dont really understand what you mean

tender shard
#

e.g. ```java
return new TC((String) map.get("name"), (Location) map.get("location"), ...);

#

the object you want to get the field value from, or null if it's a static field

lost matrix
#

There are already tools for that. But here is the general approach:

    Object instance = ...;

    try {
      Class<?> clazz = instance.getClass(); // Or Class.forName("")
      Field field = clazz.getDeclaredField("number");
      Object value = field.get(instance);
    } catch (ReflectiveOperationException exception) {
      exception.printStackTrace();
    }
#

so?

buoyant viper
#

theres a generic .get method for Field

#

ezpz

echo basalt
#

Fun fact: graphs are hella cool, but also a pain to impl

lost matrix
buoyant viper
#

i thought ur example used getInt not get ignore it lolz

#

also i didnt mean generic in the literal java generics sense if thats what ur thinking

lost matrix
#

You dont. You pass the instance of which you want the field value from and
it will return the value stored in that field. This will always be of type Object

#

For marshalling you would do something like this:

    Object instance = ...;

    try {
      Class<?> clazz = instance.getClass();
      for(Field field : clazz.getDeclaredFields()) {
        String fieldName = field.getName();
        Type fieldType = field.getType();
        Object storedValue = field.get(instance);
      }
    } catch (ReflectiveOperationException exception) {
      exception.printStackTrace();
    }
vocal pine
#

Can you set a null value to a PDC?

tender shard
#

no

vocal pine
#

๐Ÿ‘ ty

lost matrix
tender shard
tender shard
vocal pine
#

ye i saw that right after :') my ide was giving it a solid maybe

tender shard
#

haha

vocal pine
#

so i thought i'd ask then realised i could just yk, check

latent tartan
#

ty for help @tender shard <3 I got another error now but i dont think its related to saving so ill try figure it out

tender shard
#

that's what this channel is for

#

:3

latent tartan
#

yea might as well im now beating my head against a wall tryna figure this out lol

tender shard
#

lol please don't do that

#

doesnt sound very healthy ๐Ÿ˜„

latent tartan
#

true true

eternal oxide
#

Might damage the wall, and re-painting is a bitch

latent tartan
#

also true

#

guess ill have to avoid beating my head against a wall i spose

tender shard
#

Arti can I dm you quickly

latent tartan
#

sure

severe marsh
#

How to let unopped players to access and modify command blocks?

pine lake
#

Hello, Is it possible to change the tab list order?

round finch
#

Setop(false);

#

Misread

wind tulip
#

Does Entity#getVelocity() return an alias or a copy of said vector?

In other words would
entity.getVelocity().add(<some vector>);
change the entity's actual velocity or just a copy thereof?

shrewd sphinx
#

pls tell me i can get the color name from dyes

#

doing a firework builder plugin thing since it popped in my head and i really dont want to have 50000 tables with different colors

fresh timber
#

So, I have some commands on my plugin and they are case sensitive. Is there a way to make them not case sensitive? Here is one of the commands:

public class GMSP implements CommandExecutor {
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            Message.send(sender, "&cOnly players can use this command!");
            return true;
        }

        Player player = (Player) sender;

        if (!(player.hasPermission("coolplugin.command"))) {
            Message.send(sender, "&cYou do not have permission to use this command!");
            return true;
        }

        player.setGameMode(GameMode.SPECTATOR);
        Message.send(sender, "Set own game mode to Spectator Mode");
        return true;
    }
}

Here is my spigoit.yml:

name: CoolPlugin
version: '1'
main: coolplugin.CoolPlugin
api-version: 1.19
description: This is a cool plugin.
commands:
  heal:
    description: Heals the executer.
    usage: Use /heal.
  spawn:
    description: Teleports the player to the server spawn.
    usage: Use /spawn.
  suicide:
    description: Kills the player.
    usage: Use /suicide.
  discord:
    description: Sends the player a prompt to join the discord server.
    usage: Use /discord.
  gmc:
    description: Changes the player's gamemode to creative.
    usage: Use /gmc.
  gms:
    description: Changes the player's gamemode to survival.
    usage: use /gms.
  gma:
    description: Changes the player's gamemode to adventure.
    usage: use /gma.
  gmsp:
    description: Changes the player's gamemode to spectator.
    usage: use /gmsp.
tender shard
#

you mean /heal works, but /HEAL doesnt?

fresh timber
#

exactly

tender shard
#

hm that's weird, lemme check if it also happens to me

fresh timber
#

k

tender shard
#

oh yeah it seems to be normal

#

what you could do, as a dirty workaround, is to listen to AsyncPlayerChatEvent, then setMessage(...) and just turn the first word to lower case

#

if you want it to apply to every command

fresh timber
#

hm

#

oh I have an idea

tender shard
#

or you switch to a proper command framework like ACF ๐Ÿ˜›

fresh timber
#

I could check if first character of asyncplayerchatevent is / and if it is then just set all letters to lowercase

tender shard
#

yeah that's what I meant

fresh timber
#

how do u do that

tender shard
#

but ofc only change the first word

fresh timber
#

I thought this was the way to do it ;-;

#

what is the "proper" way

tender shard
#
    @EventHandler
    public void onCommand(AsyncPlayerChatEvent event) {
        String message = event.getMessage();
        if(!message.startsWith("/")) return;
        String split[] = message.split(" ");
        split[0] = split[0].toLowerCase();
        event.setMessage(String.join(" ", split));
    }
#

try sth like this

fresh timber
#

that is ACF?

hazy parrot
#

acf is framework for commands

tender shard
#

noo, that's just a normal listener thing

fresh timber
#

yea ik

tender shard
#

it should work for basically every command

fresh timber
#

im looking at it from github rn

tender shard
#

but I havent tried it

fresh timber
#

im tryina see what its abt

tender shard
#

ACF is totally different from vanilla commands

#

it lets you do stuff like this:

#

(1 sec)

fresh timber
#

cus tbh I learned how to do cmds from a yt tutorial and that's what they told me to do

tender shard
#
@CommandAlias("gamemode")
public class GamemodeCommand extends BaseCommand {

    @Default
    public static void execute(Player sender, GameMode gameMode) {
        sender.sendMessage("Gamemode set to " + gameMode.name());
        sender.setGameMode(gameMode);
    }
}

#

this is e.g. how a gamemode command looks like in ACF

fresh timber
#

oh wow

#

that looks better I was wondering how to use aliases

tender shard
#

in ACF, aliases would work like this:

#

now both /gamemode and /gm would work

fresh timber
#

oh ok cool

#

do I needa download smthin onto it or does it just work

tender shard
#

do you use maven?

#

or gradle?

#

or none of that?

fresh timber
#

maven

tender shard
#

then you just add the <repository> and the <dependency> to your pom.xml. Oh and you also need to add the maven-shade-plugin if you don't have it already ๐Ÿ˜›

#

but yeah basically you only have to edit the pom, nothing you have to download yourself

shrewd sphinx
#

alex

tender shard
#

that's me

#

wassup

shrewd sphinx
#

if something is named "1 second"

#
flightTime = Integer.parseInt(event.getCurrentItem().getItemMeta().getDisplayName().split(" ")[1]);```
#

this should work

#

right

hazy parrot
#

[0]

shrewd sphinx
#

or am i really stupid and its painfully obvious-

tender shard
shrewd sphinx
#

im going to sleep

tender shard
#

arrays start at 0

fresh timber
#

so uh where do I put repository and dependency in pom.xml cus my pom.xml file has a lot of stuff in it

shrewd sphinx
#

zzzzz

tender shard
#

"1 second"
[0] = "1"
[1] = "second"

shrewd sphinx
#

yeah im hella tired please kill me asap

tender shard
#

lol

#

lets keep you alive

#

you seem too friendly to get killed by me

hazy parrot
fresh timber
#

oh what do I put in there?

tender shard
#

1 sec

fresh timber
#

k

tender shard
fresh timber
#

ok

#

what is in repositories?

tender shard
#

you also need the maven-shade-plugin

#

one sec, I'll send the repositories part

fresh timber
#

oh ok

tender shard
tender shard
#

everything is explained here

#

as version use 0.5.1-SNAPSHOT, and as "artifactId" use "acf-paper" (even if you want to support spigot, you can safely use acf-paper instead of acf-bukkit)

fresh timber
#

so I just change all this text like change the org.spigotmc to co.aikar

tender shard
#

no no

fresh timber
#

ah ok

tender shard
#

you keep that stuff

fresh timber
#

oh

#

uh

#

ok

#

what do I do then

tender shard
fresh timber
#

or uh read it

tender shard
#

and then you click the maven reload button

#

and then you can ping me here again ๐Ÿ˜„

fresh timber
#

k

shrewd sphinx
#

ok what

#
flightTime = Integer.parseInt(event.getCurrentItem().getItemMeta().getDisplayName().split(" ")[0]);```
tender shard
#

seems like you didnt click on any item

#

you clicked on an empty slot, right?

shrewd sphinx
#

nope

tender shard
#

hm not sure then. but anyway, you should NEVER use the item name to get the value in the first place

#

you should rather set a PDC tag

fresh timber
#

so uh its telling me to replace org.spigotmc in here with co.aikar is that what im supposed to do?

shrewd sphinx
#

pdc tags

shrewd sphinx
#

maaaaaaaaaaannn im too lazy for this lol

tender shard
#

you must create a second <dependency> section

fresh timber
#

dang

#

oh

#

oh ok

#

I didnt know that

tender shard
#

it should look like this

fresh timber
#

he told me to put it inside of dependencies

tender shard
#

except for all the other dependencies, ofc

#

you should have one spigot dependency, and one for acf

fresh timber
#

ah ok gotcha

tender shard
#

just dont touch your existing spigot thing and add ACF separately :3

fresh timber
#

so like this

tender shard
#

close

fresh timber
#

ok

tender shard
#

you now have 2 <repositories>

fresh timber
#

uh ok

tender shard
#

you also have to "insert" what you put into the second repositories thing into the first one

fresh timber
#

it is underlined in red

tender shard
#

as, check your screenshot

#

you have <repositories> twice

fresh timber
#

yea

tender shard
#

at the top and in the middle

fresh timber
#

so

tender shard
#

you also have to "merge" this

fresh timber
#

I put this inside of the first one

tender shard
#

like this

fresh timber
#

ah ok

tender shard
#

you have one <repositories> but you can have many <repository>

fresh timber
#

so u can have <dependencies> twice but not repositories

tender shard
#

no no

#

both can only be once

#

it works like this:

fresh timber
#

I have dependencies twice tho

tender shard
#
<pluralThing>
  <singularThing>
  ...
  </singularThing>
  <singularThing>
  ...
  </singularThing>  
</pluralThing>
fresh timber
#

ah ok

#

so

tender shard
#

e.g. you can have 100 repositories and 200 dependencies, but every single dependency must be inside <dependencies> and every single repository must be inside <repositories> ๐Ÿ˜„

fresh timber
tender shard
tender shard
fresh timber
#

why is groupId and artifactId red

tender shard
#

but replace [PLATFORM] with "paper" and replace "[VERSION]" with "0.5.1-SNAPSHOT

#

because you didnt read the text I sent ealier

fresh timber
#

its all red now

tender shard
#

that's normal. now you click on the reload button

fresh timber
#

ok

tender shard
#

this one, this floaty icon

fresh timber
#

yea I am

tender shard
#

it should take a few seconds and then it should work

fresh timber
#

k

#

its done

#

yea now its not red

tender shard
#

did you also add the maven-shade-plugin ?

fresh timber
#

nah hold on

tender shard
#

or read the guide written by the handsome dude who "invented" PDC:

tender shard
#

although I think mine is a bit easier to understand

eternal night
#

๐Ÿฅฐ

tender shard
#

yeah ofc lynx now arrived

#

hewwwooo :3 lol

eternal night
#

mentioning PDC is indeed how you summon me

tender shard
#

haha

fresh timber
#

how do I put this code it says in my jar file

tender shard
#

wdym?

#

which code

fresh timber
#

it wont let me open jar files cus u cant edit those

tender shard
#

huh

fresh timber
tender shard
#

you put this into your pom.xml as well

fresh timber
#

oh ok

tender shard
#

you can ignore the maven-compiler-plugin thing for now

fresh timber
#

k

tender shard
#

you only need to add the maven-shade-plugin

#

it should look similar to this

fresh timber
#

I have it already

tender shard
#

okay then you're good

fresh timber
tender shard
#

yeah that's good

fresh timber
#

dunno where I got it from but I just had it

tender shard
#

now you can just create a new PaperCommandManager in your onEnable()

fresh timber
#

k

#

like this?

tender shard
fresh timber
#

uh ok

tender shard
#

and the GamemodeCommand() class will have to extend BaseCommand

#

e.g. like this

#

and then you're done

fresh timber
#

so I replace getCommand() thing with PaperCommandManger?

tender shard
#

yeah, getCommand("someCommand").setExecutor(new MyCommandClass()) is basically the same as acf.registerCommand(new MyCommandClass())

#

but obviously you will now have to rewrite all your old command classes to the ACF version

fresh timber
#

ok

#

so I have to do 2 lines to register each cmd now?

tender shard
#

no, one

fresh timber
#

u sent 2

tender shard
#

you can ofc reuse the same "acf" / "PaperCommandManager" object everytime

fresh timber
#

hm

tender shard
fresh timber
#

oh yea

#

ok

iron glade
#

feels like a flashbang in csgo everytime xD

tender shard
#

I switch between light and dark mode like every day haha

iron glade
#

isn't there an option in windows switching between dark and light according to sun

tender shard
#

naaah

#

mac has that, windows doesnt

#

at least I think

iron glade
#

imagine

#

windows trash

fresh timber
#

its not working

tender shard
#

yeah windows is disgusting, I only have it to play MSFS2020

tender shard
fresh timber
#

oh frick its capitalized

iron glade
#

and even if pls capitalize the G

fresh timber
#

;-;

iron glade
#

gj

tender shard
#

and as said, remember - you have to completely rewrite your existing commands

#

ACF doesnt need you to implement CommandExecutor, it needs you to extend BaseCommand

#

sometimes I have the feeling that md5 and aikar wouldnt be very good friends haha. md loves interfaces, aikar loves abstract classes ๐Ÿ˜„

ivory sleet
#

๐Ÿ˜ฎ

tender shard
#

its trueee

ivory sleet
#

hmm I mean interfaces are just candy

#

so sweet

tender shard
#

sure, they are great

#

but so are abstract classes

ivory sleet
#

hmm partly

#

yeah

tender shard
#

always depends, ofc

ivory sleet
#

Id say its easier to misuse abstract classes

#

but yaaa

tender shard
#

true, I abuse them all the time

ivory sleet
#

๐Ÿฅฒ

tender shard
#

e.g. why can't interfaces cannot declare static fields in java 8 ๐Ÿ˜ข

#

or can they? maybe I'm confusing 2 things right now

ivory sleet
#

they cant?

#

I think private static methods or sth

#

idr acc

#

but ye

tender shard
#

I think they can do that, I meant something different but I forgot what exactly I meant ๐Ÿ˜„

ivory sleet
#

ye yea

tender shard
#

yeah there's some feature that interfaces cannot have but I really cannot remember what it was

hazy parrot
#

its static

eternal night
#

thank god for default methods๐Ÿ™

ivory sleet
#

instance fields

#

constructors also

hazy parrot
#

because static infact, cant be abstract, can they

tender shard
#

OH YEAH

eternal night
#

I mean

tender shard
#

CONSTRUCTORS

#

THAT WAS IT

eternal night
#

interfaces can have static methods

hazy parrot
#

hance there is no reason to have them in interfaces

eternal night
#

and fields

hazy parrot
ivory sleet
#

can

eternal night
#

pretty sure java 8 interfaces can have static methods and fields yea

ivory sleet
#

private default methods or sth might not be possible

#

or if it was private static

#

idr

tender shard
#

I'd love to do something like this

interface PluginHook {
  boolean canBuild(Player player, Location location);
  
  PluginHook(Plugin myPlugin); // but this doesnt work
}
eternal night
#

I mean generally private is a no go

#

Well

ivory sleet
#

yeah

eternal night
#

there isn't much point in a constructor

#

on an interface

#

not like it does anything with that parameter

ivory sleet
#

I can see why you might want it

eternal night
#

Hmm

ivory sleet
#

but it would be hassle for eventual implementers

tender shard
#

e.g. right now I gotta pass a Supplier

ivory sleet
#

just have an init method or sth

tender shard
#

which ofc also works

ivory sleet
#

ah

tender shard
#

but wouldnt it be nicer to have a way to tell javac that everything that implements PluginHook has a specific constructor?

eternal night
#

I mean yea, factory pattern is the way to go

tender shard
#

I think so

eternal night
#

but how would you provide the type

#

like the concrete type

tender shard
#

the type of what?

eternal night
#

the one that implements the interface

#

like, anything on an interface only takes effect on an existing instance

hazy parrot
tender shard
#

ofc, no problem with reflection, but that ignores the interface thingy

#

it would need some new syntax or sth to work without reflection

ivory sleet
#

oh yeah Lynx I must ask, whats your take on elegant objects as well as data oriented programming ๐Ÿ˜ฎ

eternal night
#

Elegant has some nice concepts

tender shard
#

idk just for example

new PluginHook::givenClass(myPluginsMainClass)
#

sth like that

#

idk

#

and givenClass could be e.g. WorldGuardHook.class

#

or whatever

eternal night
#

tho I get more and more iffy on the whole "don't instanceOf" thing

red delta
#

Hello someone can help me to setup phpmyadmin i getting crazy ๐Ÿ˜ญ

eternal night
#

like, at the start I thought it was really bad

#

and with more and more pattern matching support in java

#

a nice switch statement just begins to look cool

#

similar to like, your enum usage in rust

ivory sleet
#

fair

tender shard
#

at least that's how it worked 10 years ago

ivory sleet
#

I know some people who counter it by saying enums + switches are generally evil because they end up doing more than one thing and sometimes they just become a dependency magnet

#

but it does clean up the code especially with the new java features introduced

eternal night
#

I mean, enums is kinda funny

ivory sleet
#

enum is nice in Java

eternal night
#

Well yea just design wise they are funny

ivory sleet
#

hehe

eternal night
#

like, you don't want to store your data in the enum instance itself

#

because now your data is compile time

#

but on the other side, then you'd have a lookup for any form of data or relation the enum indicates

ivory sleet
#

yeah, only thing I miss is type params for Enum<?> derivatives

tender shard
#

tries very hard to not send a your mama joke

ivory sleet
#

would be so nice

eternal night
#

oh god

#

yes

#

that would be

#

sooo good

red delta
eternal night
#

I think there was a JEP

#

and it was dropped

ivory sleet
#

NOO

eternal night
#

yea, generic enums or something

ivory sleet
#

damn, thats a pity

eternal night
#

indeed

#

301

#
enum Argument<X> { // declares generic enum
   STRING<String>(String.class), 
   INTEGER<Integer>(Integer.class), ... ;
#

would indeed be very enjoyable to work with

ivory sleet
#

omg

#

yes

#

altho Ig it could be awkward for enum sets

eternal night
#

Hmm

#

how so ?

#

I mean, same issue as any other form of generic erasure

fresh timber
ivory sleet
#

just dug a little bit

fresh timber
#

k

tender shard
#

in ACF, all methods are "void"

fresh timber
#

k

eternal night
#

Well yea, it promotes the usage of raw types

#

but like

#

kinda always the case

ivory sleet
#

fair

eternal night
#

java and its fucking ? extends T

#

is annoying af anyway

ivory sleet
#

true

#

union types + yeet type erasure ๐Ÿ™

#

or acc thatd be problematic

#

but in theory

tender shard
#

I fucking hate type erasure so much

eternal night
#

I mean, the second request is coming

fresh timber
#

is it possible to register all the commands in a certain folder or no?

eternal night
#

iirc

tender shard
#

List<? super MyStuff> uuugh

ivory sleet
#

thought that was speculations merely

eternal night
#

specified generics are a thing in valhalla

#

or well

#

planned

ivory sleet
#

oh yeah fair

torn oyster
#

java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.equals(Object)" because the return value of "me.quared.itemguilib.items.CustomItem.getOwner()" is null

    public boolean isCustomItem(Player player, ItemStack stack) {
        return customItems.stream().filter(item -> item.getOwner() != null).anyMatch(s -> Objects.equals(player, s.getOwner()) && Objects.equals(stack, s.getItemStack()) && s.isEnabled());
    }```

how is this even happening anymore (1 is error, 2 is code that is causing the error)
tender shard