#help-development

1 messages · Page 444 of 1

wise mesa
#

im just joshin

young knoll
#
  • Custom resource pack with red moon!
wise mesa
#

did you check that it isn't

#

like did you actually test the plugin

#

oh it costs money

#

my bad

cobalt thorn
young knoll
#

It says in the description it’s a resource pack

#

So yeah

cobalt thorn
young knoll
#

They could have made the sky red without a resource pack though

#

Bit of a missed opportunity

wise mesa
#

by making the time sunset?

#

or something else?

cobalt thorn
wise mesa
#

ah

young knoll
#

Using biomes is really fun for this

#

Custom seasons

wise mesa
#

woah that's super cool

#

packets are fun

#

alright im off to bed night yall

mint nova
#

How i can create a personal gui?

lost matrix
#

How much java experience do you have?

mint nova
#

A quite of bit

#

Omg my internet dying

lost matrix
#

The general idea is that you create a new inventory for each player
and an instance of a handler for each inventory.

lost matrix
mint nova
#

Ok thanks

pale escarp
#

How would i go about disabling my plugin if a dependency plugin is not found?

#

apparently depend: does not seem to work from plugin.yml

vocal cloud
#

send plugin.yml

#

?paste

undone axleBOT
wet breach
#

that is because your depend is not a list

#

depend: [WorldEdit, Towny]

#

this is how it should be

pale escarp
#

ok

#

still doesnt seem to work

wet breach
#

do you have JPremium on the server or shaded in?

pale escarp
#

no not on server

#

not shaded

wet breach
#

are you sure it didn't disable later down on the log?

#

otherwise, not sure then why it isn't working for you, but maybe it could be that underscore in the author name causing the problems

#

since your log and what you posted don't seem to match in regards to author

pale escarp
#

hmm lemme try that

#

nope the name aitn an issue

wet breach
#

try moving it above commands

pale escarp
#

ok

#

no luck

wet breach
#

then I guess it is a bug

#

try using depends

#

if that don't work then I would recommend creating a ticket on spigots jira

#

?jira

undone axleBOT
pale escarp
#

ok

#

Right, it seems to be a bug

wet breach
#

actually no its not a bug

#

not for spigot anyways

pale escarp
#

mm

wet breach
#

I see the issue now, you are using waterfall

pale escarp
#

mm lemme try bungee then

wet breach
#

I don't think bungee has this functionality

pale escarp
#

hmmm

wet breach
#

you could try it and see, but if that is the case the thing is you are not testing with spigot related things to begin with

quaint mantle
#

does anyone know a discord server for help with the forge mod loader?

wet breach
#

you can't say something is an issue with spigot when using someone elses implementation

quaint mantle
#

similar to this one?

pale escarp
wet breach
#

you can however implement it in code

#

all you have to check for when your plugin loads is if whatever you are depending on exists, if it doesn't disable or don't do anything

pale escarp
wet breach
#

You don't even need to do all that

#

just don't allow your plugin to register anything

pale escarp
#

could you guide me?

wet breach
#

its similar to the above

#

except you want to reverse the check

#

check if not null, then register those things

#

in this manner, you shouldn't encounter NPE because you are not allowing anything to run

#

in your plugin that is

pale escarp
#

oh damn

#

it was bungee.yml

#

i was making plugin.yml xD

chrome beacon
#

Or just the Forge discord if you're on a supported version

versed canyon
#

The Spigot javadoc isn't 100% clear on this.. is Tag.WHATEVER.isTagged() the same as Tag.WHATEVER.getValues().contains()?

remote swallow
#

im pretty sure you can call contains directly but check source for 100% confirmation

eternal oxide
#

?stash

undone axleBOT
eternal oxide
#

getValues is slower, it streams to an unmodifiable Set

#

then performs your .contains

terse ore
#

How do you shade a jar?

ivory sleet
#

There are many ways to do it

#

But most commonly gradle, ant or maven

terse ore
#

I am on Intellij and using gradle

ivory sleet
#

You’d either be writing a custom jar task, or use shadowJar (a third party gradle plugin)

#

then for all dependencies that you want to shade, use implementation or runtimeOnly

terse ore
#

let me try

tender shard
# terse ore I am on Intellij and using gradle
  1. add the thirdparty shadow plugin:
plugins {
  id "com.github.johnrengelman.shadow" version "7.1.2"`
}
  1. configure shadowJar to run on build
tasks {
    build {
        dependsOn(shadowJar)
    }
}
  1. add relocations when needed to your existing build block:
tasks {
    / ...
    shadowJar {
        relocate("some.librarry", "me.mypackage.myplugin.some.library")
    }
}
  1. set the dependencies you wanna shade to "implementation"
dependencies {
    implementation "someone.else:some-library:1.0.0"
}
#

you also need to add mavenCentral() to your repositories because shadow is not part of gradle

#

or mavenLocal() if you already have the shadow plugin in your local repo

terse ore
#

ty

#

let me try

tender shard
#

and then you'll end up with a .jar called "myplugin-whatever-all.jar" (it ends with -all.jar), that's the shaded one

terse ore
#

now I understand why it wasn't working

#

I skipped step 3

tender shard
#

the relocations are optional

terse ore
#

one question

tender shard
#

it should also work without relocations

terse ore
#

tasks { shadowjar }
and tasks { build }

#

need to be in a different tasks wrapper?

#

or I can add them inthe same one

tender shard
#

if you don't do step 2 and 3, you could also just run ./gradlew shadowJar, but I#m not sure whether you manually have to run build first

tender shard
terse ore
#

tasks {
    build {
        dependsOn(shadowJar)
    }

    shadowJar {
        
    }
}
#

okk

tender shard
#

like this

#

if you don't relocate, this should be enough:

tasks {
    build {
        dependsOn(shadowJar)
    }
}
terse ore
#

what does relocation do?

tender shard
#

it moves the dependencies to its own packages. that was needed when plugins didnt use their own classloader, it shouldnt be needed anymore

#

but it also can't hurt, and e.g. bstats refuses to work if you dont relocate it

#

e.g. it moves bstats from org.bstats to your.plugin.bstats

ivory sleet
#

Appending shadowJar to build?

#

Or well the other way around

#

Think just running the shadowJar task is enough

tender shard
#

It runs shadowJar when running build

ivory sleet
#

Yes but that essentially builds the jar 2 times

eternal night
#

The gradle build task is a lifecycle task

tender shard
#

Idk, all i know is that it works lol

eternal night
#

It doesn't do anything on its own

terse ore
#

no errors, let's hope it works on server startup

tender shard
#

In maven i just tell it to run shade during package

ivory sleet
#

Yea

terse ore
#

wait

#

look

#

it generated the -all.jar

tender shard
#

Yes

#

Thats what i said ealier

#

Shadow uses a classifier for the shaded jar

#

Dont ask me why

#

You can also make it replace the existing jar with some additional configs

terse ore
#

so I need to use the -all.jar right

tender shard
#

Yes

ivory sleet
#

Like completely substitute it

terse ore
#

letsgo

tender shard
terse ore
#

now it's an sql error

#

but it shaded the jar

ivory sleet
#

Yeah, but build calls jar by default already

#

Mostly curious if build would still keep invoking the jar task, after shadowJar

terse ore
#

yoo it works

#

ily

tender shard
#

that's how I do it too

ivory sleet
#

Lmao yea

terse ore
#

is gradle that hard?

ivory sleet
#

Its a bit complicated but we were discussing the build task, which is just a composition of other tasks

tender shard
#

it's way more complicated than maven imho

terse ore
#

but it is faster right?

ivory sleet
#

Not really

#

Maven can be just as fast

tender shard
#

especially when using maven 4

ivory sleet
#

But gradle allows u to append small snippets of code to ur build pipeline execution more conveniently

terse ore
ivory sleet
#

There might be some maven plugin that can allow u to define build logic in other languages

#

Idk

terse ore
#

I just remember trying to execute a task after build but not being able to do so

tender shard
#

build.finalzedBy(yourOtherTask)

#

finalizedBy*

terse ore
#

it didn't work

#

I swear I tried everything

tender shard
#

however the docs are often wrong or outdated lol

#

the javdocs shouldn't be, though

ivory sleet
#

Yea since the wrapper gets updated so often

#

Some docs are just not updated even though the api changed, and so u end up looking at the right doc version but still sth is missing

#

Probably less likely to happen now

tender shard
#

yeah that is so annoying

ivory sleet
#

But it was case back a year ago or sth quite frequently

tender shard
#

no docs are better than wrong docs

ivory sleet
#

I think gradle becomes a hassle with all the build scripts

#

Like when the complexity of the build logic increases its almost as if we have to start writing tests to test the build logic itself

tender shard
#

lol yeah

ivory sleet
#

Not sure if maven would be better off here

#

But yea

tender shard
#

my bathtub is ready, bb

ivory sleet
#

Oo nice

terse ore
#

I am the only one who their entire family asks them to fix computer stuff?

tender shard
#

just tell them you don't know

terse ore
#

doesn't work

#

"then learn" (mostly from my mom)

ivory sleet
#

Lmao

#

Yea my friends always go down a similar route

terse ore
#

some times I miss python

ivory sleet
#

Oo

#

I mean I hate it

sullen marlin
#

Ah gradle fun lol

remote swallow
#

Gradle stuff?

terse ore
#
conn = sqlite3.connect("mydb.db")
c = conn.cursor()
ivory sleet
#

Yup gradle

remote swallow
#

For shadow jar on build just asd

Build {
DependsOn shadowJar
}

#

Phonde is hard

ivory sleet
#

you can just run shadowJar tho?

#

build is as lynx said just a life cycle task

terse ore
#
tasks {
    build {
        dependsOn(shadowJar)
    }
}```
#

this worked for me

remote swallow
#

Most people know to run build

ivory sleet
#

Its not any different from shadowJar?

#

Or am I missing something here 😅

#

I mean i would understand if you redefine build

#

but that just looks to me like you’re gonna run the jar task 2 times effectively if im not stupid

#

(Since shadowJar does call jar on its own sorta)

ivory sleet
#

Yeah

#

But build already calls jar, no?

eternal night
#

Yes

#

But gradle is smart enough to not run jar twice

#

If build depends on shadowJar

ivory sleet
#

Ah alr it substitutes out jar to shadowJar then?

eternal night
#

Well, the jar task is finished and cached

#

So it's output it reused

ivory sleet
#

Oh even smarter

eternal night
#

Ye

#

It's pretty smart

ivory sleet
#

Thanks for the enlightenment <:

eternal night
remote swallow
#

md

#

offical special source plugin when

sullen marlin
#

When you make it

remote swallow
#

why me

ivory sleet
#

Why not you

#

(:

remote swallow
#

i dont grooy or kotlin

eternal night
ivory sleet
river oracle
ivory sleet
#

Transpile Java to kotlin else wise, I think IJ supports it

remote swallow
#

oh truwe

terse ore
#

Is it possible to get the generator that mojang used for the moon generation?

sullen marlin
#

Can't it just be java

remote swallow
#

no idea

sullen marlin
#

Moon generation???

ivory sleet
#

Yeah probably since interoperability

terse ore
river oracle
terse ore
#

you can go to the moon lol

sullen marlin
#

I mean you can decompile it

terse ore
#

I only interacted once with modifying generation

torn shuttle
#

da moon

quaint mantle
#

if i define the target like this can i do if (target == sender)?

hazy parrot
#

You probably can as online players have reference equality

#

You just have to make sure both players are online as getPlayer may not return object for offline player

quaint mantle
#

okay thx another question can i have a listener inside a command bc i need to use args of the command inside the listener

#

idk how else i would transfer that

young knoll
#

No

hazy parrot
#

Can you elaborate a bit further, I'm sure that is not correct approach

young knoll
#

You need to store them somewhere

quaint mantle
#

i have this command /duel <PLAYER> and i opens a gui

#

when click a certain item in the gui its supposed to send the <player> a msg and some other stuff

#

and i dont know how to get the player inside the listener class

hazy parrot
#

Why are you checking if player is in diel with permission

#

Duel*

quaint mantle
#

because if they already are in a duel with another player i dont want it to send the request

broken flax
#

If the GUI is only able to be opened through your command, then you could just give it a unique name to make sure it's "that" GUI?

quaint mantle
#

not quite sure how that would help my problem

#

let me explain again maybe i didnt explain it right

#

i have sender lets call him player 1

#

and the target player 2

#

the sender uses /duel player2

#

and then a gui opens for player 1

#

when player 1 selects a specific item in that gui it send a request to the player 2

remote swallow
#

make a concrete gui class with the listener in and take a player as aparam

quaint mantle
#

okay thx

torn shuttle
#

when creating javadoc-style documentation do the comments go on the interface a class implements or the class that implements it?

#

I should be able to put it on the interface and have the interface methods uniformly documented right?

eternal oxide
#

interface

torn shuttle
#

cool thanks bby xoxo

terse ore
#

One question, I am creating a method that adds a world to my database but idk which parameters are better

public void setWorld(String worldName, String owner, int maxPlayers, int size, Location spawnpoint, List<String> participants)
public void setWorld(World world, Player owner, int maxPlayers, int size, Location spawnpoint, List<Player> participants)

Which one should I use?

eternal oxide
#

first

#

Player objects go stale

#

List<UUID> would be better

#

or at teh minimum a stringified UUID

versed canyon
#

Yeah never store a Player object in a list, always store UUIDs

eternal oxide
#

internally it stores the magic numbers, so fetchign valued performs a lookup for every entry and enters it into Set.

terse ore
#

but sqlite doesn't support direct UUID

eternal oxide
#

using .isTagged performs a single number lookup

versed canyon
eternal oxide
#

UUID as a String is fine

versed canyon
#

Also works as a String

versed canyon
young knoll
#

You can also do binary

undone axleBOT
versed canyon
#

Ah brilliant, thank you!

#

Yeah I had an entire class in my plugin with a bunch of lists for grouped materials, then I found out Tag had 90% of those same lists

daring lark
#

is there any way to store nbt on entity without nms?

eternal oxide
#

?pdc

young knoll
#

?pdc

daring lark
#

but how to store it on entity?

#

not itemstack

young knoll
#

Read the part that says “storing on entities”

quaint mantle
#

my java skills are garbage so sorry for asking again but how do i get the target from the command

remote swallow
#

handle the event in the inventory class

#

then have a class var for the target

#

and on ur constructor have a player var for the target

regal scaffold
#

Hey,

Lets say I have the following structure:
IBasePhone interface
Interface methods
APhone abstract implements IBasePhone
Contains base stuff that all implementations will have, such as type.
Phone class extends APhone
Contains override for specific stuff per phone type.

--//--
I want to have a custom item which I will assign a PDC value to identify. If I for example want to open a GUI when the item gets clicked, I would get check that the PDC value exists, if so, search for the identifier in a list previously saved and then do stuff accordingly with the information from the clicked item.

#

Is there a better way to do this

fluid river
#

wha

regal scaffold
#

I guess I'm asking for ways to identify a event being triggered from a specific item

fluid river
#

no

#

pdc

regal scaffold
#

Should I store an identifier on the pdc then? So I can keep track of items that way?

ivory sleet
#

Yes

fluid river
#

yes

regal scaffold
#

Ok perfect

#

Thought so

#

Thanks

flint coyote
fluid river
#

actually i do but

#

when somebody needs help i just type the phrase

#

as a meme

flint coyote
#

did you get "customers" that way?

regal scaffold
#

Should I just store a random UUID as string

fluid river
regal scaffold
#

Or should I do things to be able to store the UUID as a UUID type

fluid river
flint coyote
#

Yeah that's why I used the quotes

fluid river
#

and get it in your inventory event

flint coyote
#

What's wrong with saving a UUID?

fluid river
#

a lot

flint coyote
#

Or are we talking about file storage?

fluid river
#

i guess he is storing to PDC

flint coyote
#

I see

flint coyote
fluid river
#

university student

terse ore
#

is this good?

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            Realms.logger.log(Level.INFO, "The console can't use this command");
            return true;
        }
        
        return true;
    }```
Like defining player inside the if
fluid river
#

don't have a job

#

so ez

terse ore
fluid river
#

yes

#

and only this way

terse ore
#

okok

fluid river
#

i mean i hate logger but

#

that's how it should be

flint coyote
fluid river
#

i just use Server#getConsoleSender#sendMessage(String s)

remote swallow
#

why not just sender.sendMessage

fluid river
#

true

#

but sometimes

terse ore
#

why not logging?

#

idfk

remote swallow
#

why use the logger when you have a var right there

terse ore
flint coyote
#

I made a static class with log function so I can call "Log.info(message)" - it's an ugly solution but the logger is meh

remote swallow
#

Realms.logger is another class

fluid river
#

mi

private void send(String text) {
    getServer().getConsoleSender().sendMessage("[EtalonGame] " + paint(text));
}```
terse ore
#

ill use sender.Sendmessage

hazy parrot
#

Well in this case you are not actually logging some error, info or warn but you are telling console that you can't execute command as it

fluid river
#
public static String paint(String text) {
    return ChatColor.translateAlternateColorCodes('&', text);
}```
hazy parrot
#

I would just use sender.sendMessage in this case, but if you actually logging smth, pls don't use ConsolesSender to send colourful logs

ivory sleet
#

Yea

quaint mantle
#

upfirst I have never really designed a game mode before:

so when i want to make a command /ff or /surrender
how would i make it that the command knows who you are in a game with.

torn shuttle
#

we need to address the biggest issue with java, how unsexy it feels to write decent APIs

#

here's my first proposal, an intellij plugin that randomly changes the IDE background to different waifus when it detects you're writing javadoc documentation

flint coyote
#

Or do you want to start a voting?

gritty lake
#

Hi, Is it possible to set NamespacedKey without it including plugin name in the key?
I need it to match datapacks key values so then i can't include the plugin name

For meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, "switch");

currently it being "cubedcraft-warzone:war":"switch" but i need it to be "war":"switch" without the : seperation

sullen canyon
terse ore
#

what would be the best way to make a command, should I just use a shit ton of ifs for checking parametrs?

winged anvil
#

some reason the curriculum my teacher is teaching from states that with a statement like

Cake cake = new Cake();
cake.doStuff(this);
``` the ‘this’ references the object stored by the cake alias.
#

Where doStuff() takes in a Cake object

torn shuttle
#

that doesn't sound right

winged anvil
#

it’s not

torn shuttle
#

quality education

ivory sleet
#

Lol

#

this is just a special function parameter that exists within every instance method/constructor

torn shuttle
#

hit them with my favorite burn of all time, "I should be doing what you do and you should clean my balls!"

rotund ravine
torn shuttle
regal scaffold
#

What type of storages can I use to be able to modify individual objects instead of having to rewrite the entire file like for example data.yml

torn shuttle
#

databases

regal scaffold
#

If I only want to save a specific data field instead of having to resave everything

#

Thought so

#

Or pdc

#

I like pdc tbh

ivory sleet
#

Pdc i mean

#

Its in memory and writes to file io during important events

#

Not so different than a yml data storage

terse ore
#

is it possible to define subcommands in plugin.yml?

ivory sleet
#

Nope

#

Subcommands is not a thing

#

They’re just literal arguments

terse ore
#

still, arguments are not defineable right

ivory sleet
#

Nope

#

I mean u can define the usage iirc

#

And permission message

terse ore
#

it would be nice ngl

ivory sleet
#

But not arguments and literals

#

I mean u have commodore

#

If u so prefer

terse ore
#

TabCompleter ill use then

ebon topaz
#

how does grindstone work out what to do with two picks that have low durability?

ivory sleet
#

(Commodore)

#

@terse ore

terse ore
#

ty let me check

young knoll
#

Or ACF

#

Or cloud

terse ore
#

too many names

#

too many names x2

young knoll
#

Or like 5837363 other command frameworks

ivory sleet
#

Acf and cloud are command frameworks

#

Commodore isnt

#

It just brings tab completion

terse ore
#

guys, one question

#

which was the difference between | and ||

#

ik that one of them if the first argument was true it didn't check second one

ivory sleet
#

|| is boolean operator OR

#

the other one is well…

terse ore
#

because

ivory sleet
#

I think it falls under bit operator

#

Dunno the name

icy beacon
#

imagine two conditions A and B

terse ore
#
if (args.length == 0 || args[0].equals("help")) do;
icy beacon
#

with ||, if A is true, B is not checked

terse ore
#

should I do it like this?

icy beacon
#

but if A is false, B is checked

#

with |, A and B are checked whatever the case is

terse ore
#

hmm

terse ore
icy beacon
#

you shouldn't

#

the same applies to & and && btw
with && if A is false, B is not checked

terse ore
#

oh

icy beacon
#

and also | and & have something to do with bits

terse ore
#

now I realise, python uses && and ||

icy beacon
#

but i'm not versed in those

ivory sleet
#

| and & are bitwise OR and AND

icy beacon
#

yeah i don't know what those do haha

tardy delta
#

doesnt python has and and or

terse ore
#

yay ik what those do

tardy delta
terse ore
ivory sleet
#

Yea

#

Cuz java is good sometimes

#

Yes akex

tardy delta
#

only doesnt have operator overloading

terse ore
#

I am starting to like Java

icy beacon
#

yay

ivory sleet
terse ore
#

||still python will be better for a lot of stuff||

tardy delta
#

ill probably make my own programming language

#

ive been messing with bytecode fuckery the last time

ivory sleet
#

FourteenScript#++

terse ore
#

FScript#

icy beacon
#

otherwise no fun

tardy delta
#

it gotta be less verbose

icy beacon
#

so, no keywords

#

public static void main -> <|> !! :() main

tardy delta
#

speaking about no keywords, ive been doing this yesterday: java code above it

terse ore
#

can someone check my code and tell me how bad it is

undone axleBOT
icy beacon
#

send it here plz

tardy delta
#

but uhh imma not continue my weird assembly stuff lol

ivory sleet
#

Got it on github?

terse ore
terse ore
ivory sleet
#

Ugh

#

Ehm

#

Akex are we allowed to go full out?

icy beacon
young knoll
#

Run

terse ore
#

please

young knoll
#

HES GOT A KNIFE

tardy delta
#

why do people use

connection.prepareStatement()
statement.execute(...)```
instead of

connection.prepareStatement(...)
statemennt.execute()```

terse ore
#

I do it because of parameters

#

statement.setInt(1, 69)

#

and then statement.execute()

tardy delta
#

also you are not giving your connection back to the pool

terse ore
#

can you explain

icy beacon
#

i haven't worked with hikari but your code seems like a scramble and i'm afraid

tardy delta
#

you have to 'close' it, it doesnt actually close it but it tells hikari that its inactive

young knoll
#

Won’t the try with resources handle that

icy beacon
#

i only see th estatements twred

torn shuttle
#

oh man how do I even resolve this cursed thing

tardy delta
icy beacon
torn shuttle
#

this works when I don't use the this keyword

quaint mantle
icy beacon
#

oh like inferred type or

young knoll
#

? super x is like ? extends x

#

But backwards

torn shuttle
#

more specifically it works when I instantiate it outside of this class

icy beacon
#

this is the shit that i click on while reading stackoverflow and then procrastinate for 3 hours

young knoll
#

Conclure making text wall

terse ore
remote swallow
#

im correct in saying a something-sources.jar is just all the .java files squashed together into a jar

ivory sleet
#

Arguably static abuse, config can be static but make sure it to name it as a constant then.

Your static initializer is way too big, the issue is that its hard to test logic of methods and classes when you use so much static.

Don’t use poopy File legacy api, use Path instead.

Those SQL statements, make them into constants, that way your code becomes a bit more readable and maintainable.

Be consistent on the names of your names for the exception variables, you go between e, throwables etc. Stick with one, arguably e since it follows the proportional name principle.

Also feels like these database calls should be async.

Use this keyword if possible, its better as it shows if a method call or field access is from the instance itself.

Use PreparedStatement.

remote swallow
#

pretty much the real jar just with -sources

tardy delta
#

ah fun hikaris code is written by a code generator so there are no sources for the ::getConnection impl

torn shuttle
#

where is programming jesus when you need him

tender shard
icy beacon
#

not "can i"

ivory sleet
torn shuttle
torn shuttle
# ivory sleet How does addActivity look
    public void addActivity(Activity var0, int var1, ImmutableList<? extends BehaviorControl<? super E>> var2) {
        this.addActivity(var0, this.createPriorityPairs(var1, var2));
    }
terse ore
torn shuttle
#

?paste

undone axleBOT
torn shuttle
terse ore
#

should I make a thread?

ivory sleet
#

No and yes

icy beacon
#

callbacks and futures are better i think

ivory sleet
#

And I meant with constant
static final THIS_IS_HOW_WE_NAME_THEM

icy beacon
#

or/and bukkit-scheduler-async

ivory sleet
#

Constructor is ONLY responsible for constructing the unit on an object level

twilit roost
#

I have playtime in ms
how do I convert it into days,hours,minutes,seconds?
I'm trying it like so, but it shows absurd times

ivory sleet
#

The create table should have its own function

terse ore
#

should I make a method called createTables and call it in constructor?

ivory sleet
#

Well, I’d do sth like

icy beacon
tardy delta
terse ore
#

What's wrong with my code thread

torn shuttle
#

hm maybe I just pass it unassigned and hope for the best?

#

it should work anyway

terse ore
fluid river
twilit roost
#

any replacement?

ivory sleet
#

DataTimeFormatter if possible

#

For representing a duration use Duration

icy beacon
#

joda time maybe?

twilit roost
#

imma take a look on it

ivory sleet
#

And you have Instant that represents a timestamp

twilit roost
#

oh no :D

ivory sleet
#

No

#

DateTimeFormatter.ofPattern

terse ore
#

Conclure can you check the thread when you're able to

analog thicket
#

Where would i change the name of the file? ive looked for Plugin.yml, and porm changed everything to big letters, doesnt change anything tho.

tardy delta
#

finalName in pom.xml

ivory sleet
#

plugin.yml changes the name used for /pl, and in console

twilit roost
#

never worked with times
soo yee :D

fluid river
#

remember the ol' times when you could just import spigot jar and compile by exporting...

ivory sleet
#

Like what do u wanna parse

twilit roost
#

aand long is playtime in ms from CMI

ivory sleet
#

Okay

tender shard
ivory sleet
#

ACTIVITY_FORMAT.format(Instant.ofEpochMilli(myLong))

tender shard
#

you could just extend Behaviour<LivingEntity>

analog thicket
tender shard
ivory sleet
#

And u have a string @twilit roost

twilit roost
#

ooh tysm

tender shard
# tender shard

no need to add another <E>, that would only hide the super classes' generic type

tardy delta
analog thicket
#

Here right?

#

If so nothing is called finalName

fluid river
#

?google

undone axleBOT
glossy venture
#

nah you need to add it

fluid river
#

maven properties

analog thicket
#

Yeah i know..

#

im not stupid

icy beacon
#

?ecosia

undone axleBOT
tardy delta
#

yes

analog thicket
#

Nvm

#

it works now

#

It didnt wanna take it before for some reason

#

Oh nvm again, it doesnt change the name..

tender shard
#

?paste your pom

undone axleBOT
analog thicket
tender shard
#

it goes into <build>

#

not into <properties>

analog thicket
#

Someone just said properties tho lol

tender shard
#
<project>
  <build>
    <finalName>...</finalName>
icy beacon
#

shouldn't modifying plugin yml be sufficient

tender shard
#

what does plugin.yml have to do with the file name?

tardy delta
#

nothing

icy beacon
#

perhaps

#

xd

analog thicket
#

That worked thanks!

terse ore
#

@ivory sleet for creating the database calls async I need to use the BukkitScheduler right?

hazy parrot
#

its one of the many ways

ivory sleet
#

Yeah that works

terse ore
ivory sleet
#

Im not a fan of that for async io device tasks

terse ore
#

:p

ivory sleet
#

Yes but not with bukkit scheduler

terse ore
#

"Also feels like these database calls should be async. "

#

oh

ivory sleet
#

It just drops them in a cached thread pool

#

Which is… well… meh

#

Doubt it has any significance in ur case tho

terse ore
#

how should I do it?

hazy parrot
#

i think BukkitScheduler is also using cached thread pool under the hood

ivory sleet
#

I like to just have my own work stealing pool for such tasks

terse ore
#

too advanced for me I think

ivory sleet
#

Well bukkit scheduler is fine, its just i prefer not to use it as it can become a hassle if you’re planning on scaling ur server (for these tasks particularly)

twilit roost
terse ore
#

can UUID.randomUUID() return the same uuid 2 times?

eternal oxide
#

its possible

winged anvil
#

lemme see if i can access the slides

eternal oxide
#

but extremely improbably

terse ore
#

I am safe on not checking if I already used an uuid?

eternal oxide
#

depends

#

if you are using it in some kind of persistence you should check it

terse ore
#

I need to generate an uuid per player

eternal oxide
#

ie. Mojang issue a random UUID for new accounts, but they also check it's not already assigned.

#

why per player? the player UUID is already unique

terse ore
#

maybe in a future I will need to generate more

#

(like one or two more)

ivory sleet
eternal oxide
#

you have not explained why you need to generate a UUID per player

ivory sleet
#

U need to specify time zone

terse ore
#

yeah mb

#

I am making a realms plugin

twilit roost
#

riight
dynamic way to make it so?
Or just hardcode it in

terse ore
#

you will be able to create a world where you can invite people

#

(like realms origin)

twilit roost
#

and what for do you need those UUIDs?

terse ore
#

for the world name

ivory sleet
#

ACTIVITY_FORMAT.withZone(ZoneId.systemDefault())

#

I think itstomko

twilit roost
#

use owners UUID

ivory sleet
#

And then just the rest

eternal oxide
#

theres a plugin called personal worlds written by Gravypod. It's LONG out of date but the source should be out there still

twilit roost
fluid river
#

player UUID + world counter

#

if player has more than 1 world

terse ore
#

hmm

#

I likethat

fluid river
#

or player UUID + world name

twilit roost
#

makes it easier then randomly guessing UUIDs when retrieving players world

terse ore
#

yeah ngl

#

I will code again my class

fluid river
#

guy needs free java lessons

#

99% sure

terse ore
#

ngl

#

I do

#

I am trying to learn Java the same way I learned python

#

and as far as I am concerned my level is shit

#

but better than yesterday's shit level

fluid river
#

cool

terse ore
#

so I am making progress

twilit roost
#

looks like it's adding additional hour onto it
maybe CMI issue?

eternal oxide
terse ore
#

making the world name the player name

twilit roost
#

*player UUID

analog thicket
#

What would be the best way to store a shit load of locations?

analog thicket
#

I have to get the locations every now and then

lost matrix
#

What are you doing with those locations

twilit roost
#

config?
I reckon

maybe one config per some region of yours?
but thats complicated

twilit roost
#

jk :D

analog thicket
twilit roost
#

load it into some hashmap?
and on disable save it into config

lost matrix
twilit roost
#

then load on start

analog thicket
#

Was thinking about that too

#

Probally the best option

lost matrix
#

smh, we have no idea what the best option is because there is not enough information.

regal scaffold
#

How can I give a item like a chest which has pdc data into the users inventory

#

Without needing to break it, Like a pickup button

analog thicket
#

Okay. I'm making a generator plugin. I have to get the player's generators every like 5 seconds. Then i have to drop an item at that specified location where a player put a generator. If that makes sense.

young knoll
#

You’ll need to construct an ItemStack with the pdc you want

twilit roost
young knoll
#

Then give it to the player

twilit roost
#

ig

regal scaffold
#

Wait, if the placed item already has the data in a pdc

#

It's not the same data when having the item in hand?

twilit roost
#

blockmeta -> PDC -> convert values to itemmeta -> give?

icy beacon
#

fun game: write https://www.spigotmc.org/threads/ into your search bar and add a random number there; the more cursed the thread you found is, the more points you get

young knoll
#

It basically is

#

But a placed item is not an item

regal scaffold
#

Ohhhh

#

Ok ok

regal scaffold
#

So construct a new item using the current pdc data

young knoll
#

Mhm

icy beacon
#

i found a 1.7-1.8 Spanish Lobby plugin

twilit roost
young knoll
#

I don’t think there is a method to copy the values from one pdc onto another

#

Could be useful

lost matrix
analog thicket
weak meteor
#

how to get a older version? (IntelliJ IDEA & Minecraft Development Plugin)

icy beacon
#

after creating the plugin

lost matrix
analog thicket
icy beacon
#

but tbh api older than 1.13 sucks ass

twilit roost
weak meteor
icy beacon
#

even though i love 1.8 the version, its api is unbearable

icy beacon
weak meteor
#

k

#

but if you say the api is ass

#

how tf i use a newer api and make it compatible for 1.8 to 1.19

young knoll
#

You don’t

icy beacon
#

yeah sorta

young knoll
#

You can only use 1.8 api methods if you want it to work on 1.8

icy beacon
#

just abandon the older versions

#

:p

weak meteor
#

damn

icy beacon
#

or you can code for 1.8 but refer to the modern documentation

#

and pray that you find the relevant methods

#

the biggest no-no of 1.8 api for me is the lack of nullable/nonnull annotations

weak meteor
#

well

#

i gotta test it

#

version by version

young knoll
#

No pdc either

weak meteor
#

or maybe if i try it on 1.8 server and 1.19 server it will be compatible with all of the versions between them?

icy beacon
#

for materials and sounds and particles and whatnot use XSeries btw

weak meteor
#

i think i'll give it a try

icy beacon
#

sure

#

gl

lost matrix
# analog thicket At all times when the player is online.

Alright then lets explore some options. So when a player joins the server you can load his generators
in a Map<UUID, Set<Generator>> to keep track of the players generators.
You will also want to store them in a Map<Location, Generator> for fast event
detection purposes. When the player joins you load this data async from a file <UUID>.json/yml
and when the player quits you remove the generators from both maps and store
them back in the file. Now the tricky part. There are several approaches to this.
Here is an interesting one:
You are ticking your generators every N ticks. If the chunk at the generatos location is loaded
then you can just drop the item. If not then you store this ItemStack inside the Generator object
and drop all stored items the next time the chunk containing this generator is loaded. I would
suggest a max limit of stored ItemStacks.

analog thicket
lost matrix
#

Depends on how big the chest is and what you do with items that dont fit anymore.

analog thicket
#

I was thinking about just the item, and then putting the item name as how many items there are.

#

If that makes any sense

#

LIke this

lost matrix
#

Well in that case its faster because you just have to increment an integer in a Map<ItemStack, Integer>

analog thicket
weak meteor
icy beacon
#

printing a message should work universally on all versions yeah

#

good job

#

i'm proud

weak meteor
#

it was the first thing i wanted to try.

icy beacon
#

😭

weak meteor
#

Btw i dont think im gonna to use like new stuff such as shields and that

#

just guis and inventories, nothing more

icy beacon
#

if multiversional support of spigot was so bad that you weren't able to print a message with the same method, there wouldn't be so many 1.8-1.19 plugins

weak meteor
#

well, that's true

lost matrix
#

If you want to support the garbage version and every version afterwards
then you need to build for the garbage version

icy beacon
#

^

weak meteor
icy beacon
#

i wish you luck

weak meteor
#

Thanks

icy beacon
#

the last time i tried to make a serious plugin in 1.8.8, i recoded it fully for 1.16

weak meteor
#

1.8.8 is a shit

#

but im focused in pvp servers and stuff

icy beacon
#

yeah i love the version but the api brings me misery

weak meteor
#

but i also want to give support to 1.16.5

#

and up stuff

terse ore
#

Is there a way so you can pass unlimited arguments to a method like in python?

young knoll
#

VarArgs?

icy beacon
#

yep

gaunt relic
young knoll
#

Ie ItemStack… items

icy beacon
#

Object... obj

terse ore
#

yup exactly

icy beacon
#

shit you sniped me twice

young knoll
#

Which will be treated as an array

icy beacon
#

lmao

terse ore
icy beacon
terse ore
#

would it be a good idea to make a method that accepts an sql statement and the args would be the rest of arguments

eternal oxide
#

no

#

use try with resources and prepared statements

terse ore
#

inside of the method I would handle that

#

instead of handling it every time I want to do a select for example

regal scaffold
#

How can I convert a enum as in

enum.values() into a List of values for command completion?

young knoll
#

Arrays.asList(Enum.values)

regal scaffold
#

Negative

tardy delta
#

Arrays.stream(Enum.values()).map(enum -> enum.name().toLowerCase()).toList()

regal scaffold
#

Oh... it's the long version

tardy delta
#

and please cache that

regal scaffold
#

Gotcha

#

Thought so

young knoll
#

Ah right they aren’t strings

regal scaffold
tardy delta
#

streams internally do a bunch of bs

hazy parrot
regal scaffold
#

Yeah then just Arrays.asList("ANDROID", "IPHONE", "BRICK"));

#

It's just a static values

#

Not that scalable but still really easy to adapt

torpid blaze
#

Hey,
I have a problem. When a player rightclicks on an enchamtne ttable with an item in his hand, the PlayerInteractEvent does not get triggere. But when the player is op, it does. Any one any Idea why?
(Plugin for 1.8.8)

tardy delta
#

wondering who lol

undone axleBOT
#

It’s hard to answer a programming question without code
Oh no! You ran into a problem. But no worries, people are willing to help, but first they need to see your code. This is because otherwise, they would be providing help based on guesses instead of concrete knowledge. Whether it be a compile error, runtime error, or an unexpected output, I'm sure that if you were to provide code, you'd receive a quick solution.

icy beacon
#

?paste

undone axleBOT
icy beacon
#

use this if you have a big text wall of code

torpid blaze
# icy beacon ?nocode

there is not readly code to show. I did a Sout at the first line of the event and it does not get triggered

fluid river
lost matrix
icy beacon
torpid blaze
#

the only other plugin I have on teh server is WorldEdit

icy beacon
#

try it with no plugins

#

you never know

torpid blaze
#

and I checked. I don't listen to the InteractEvent somewhere else

icy beacon
#

and tbh if you sent the code it'd still help maybe

#

i g

torpid blaze
#
@EventHandler
    public void onShopClick(PlayerInteractEvent event) {
        System.out.println("clicked");
}
icy beacon
#

oh

torpid blaze
#

when I click on teh grass block for example it works

#

but on the enchantmenttable it doesn't

icy beacon
#

i wouldn't be too surprised if it's one of the 1.8 api shenanigans

torpid blaze
#

😄

hexed falcon
#

so im trying to add an attribute to an item to make it swing faster

#

this is what i've got so far

#

i'm not sure what to put for modifier cuz i've tried numbers

lost matrix
weak meteor
lost matrix
hexed falcon
#

it's already &

weak meteor
#

its not

hexed falcon
#

that's for the color

weak meteor
#

yes

#

change it to &

young knoll
#

Why are you running it through translateAlternateColorCodes if you are already using the color character

weak meteor
#

you have to use & if you declared it that way

quaint mantle
#

i know this might be irrelevant for this server but has anyone ever worked with the forge mod loader?

tardy swift
#

guys with friend we create a cod for a uhc mtp plugin with char like werewolf bet we cant compil it can ssomeone compil it pls

quaint mantle
#

i was trying to create a mod and forge seems a lot more like bukkit than fabric mod loader so i was able to kind of able to make some more progress than i did with the fabric mod loader though.

#

i was wondering how if any of you work with forge, how did you learn it?

tardy swift
#

guys

quaint mantle
#

i saw the basic documentation tutorial but it is not exhaustive and there does not seem to be a documentation like the javadocs for spigot.

#

or is there a documentation that i might be able to use?

weak meteor
#

How to prevent my plugin from being decompiled with Luyten?

#

i know it is illegal but theres people that does that...

quaint mantle
#

obfuscation probably?

#

take a page from mojank's book?

hazy parrot
#

It's not illegal lol

lost matrix
#

Dont bother. Why would you want to prevent decompiling?

weak meteor
#

im going to connect to a SSH to make a interaction with a db

#

i just dont wanna leak the ssh

hazy parrot
#

Then don't hardcore credentials

quaint mantle
#

use environment variables or something.

hazy parrot
#

Use config or some kind of environment variable

weak meteor
#

its a personal db for a license

quaint mantle
#

also, people can just read memory dumps to find those credentials probably.

weak meteor
#

u know

#

people would only put the license to check

quaint mantle
#

and java is not like other languages either they can still look for the string probably.

#

its easy to decompile.

lost matrix
quaint mantle
#

even with obfuscations.

weak meteor
#

i dont understand it

young knoll
#

What don’t you understand

lost matrix
#

A plugin basically has to work without internet connection

hazy parrot
#

Anyway, if you want to check license you sure don't need credentials for licensing database, it's not how things work

weak meteor
#

i know theres spigot api license and stuff but i never used it before

#

and if you mention that if i use my own license manager i cant post it on spigot

regal scaffold
#

@tender shard Question about MorePDC

quaint mantle
#

bukkit api is kind of easy compared to writing mods for forge probably.

regal scaffold
#

Can I serialize a class which extend an abstract class? As in, I want to store all the info from the class and it's parent in the PDC

pseudo hazel
#

probably, why not?

regal scaffold
#

I assume I serialize the child class

rotund ravine
#

Yeah

gaunt relic
regal scaffold
#

So then my serialize and deserialize just get the data from the parent

#

Is that the way to do it?

rotund ravine
#

Depends

#

There is so many ways to do it

pseudo hazel
#

depends if the parent will always be extended by something that will serialize

tardy swift
#

can someone help pls

quaint mantle
daring lark
#
 @EventHandler
    private void onEvent(PlayerInteractAtEntityEvent event) {
        Entity entity = event.getRightClicked();
        int stack = plugin.getEntityManager().getStack(entity);

        if(stack == 1) {
            return;
        }

        Entity spawn = entity.getLocation().getWorld().spawnEntity(entity.getLocation(), entity.getType());

        ((Ageable) spawn).setBaby();

        Logger.log("dupa");

        plugin.getEntityManager().setStack(spawn, stack / 2);
    }```
why my event is called two times when i clikc at entity?
quaint mantle
#

or perhaps any documentation you used?

rotund ravine
pseudo hazel
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!

gaunt relic
undone axleBOT
#

The PlayerInteractEvent may be called once per hand. If you only want code to be executed once, you can check the result of https://hub.spigotmc.org/javadocs/spigot/org/bukkit/event/player/PlayerInteractEvent.html#getHand(), then decide functionality.

For example, only executing code if the main hand was used:

@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
    if (event.getHand() != EquipmentSlot.HAND) { // * if the hand used is NOT the main hand:
        return; // do not progress past this point  |
    }
    // provide functionality
}
young knoll
#

This is an entity interact event

twilit roost
#

does someone know something like ?paste but with java api?
So I can upload to it via code

young knoll
#

Specifically the At one

tardy swift
# pseudo hazel ?ask

with friend we make a code for a uhc plugin mtp with roles for pvp for fun but we cant compil it can u pls

rotund ravine
compact haven
#

no java api but its legit just a rest api

young knoll
#

You should be using the normal PlayerInteractEntityEvent

gaunt relic
terse ore
#

can someone explain me this contraption that alex gave me

    public static IntStream getPermissionValues(Permissible permissible, String prefix) {
        int prefixLength = prefix.length() + 1;
        return permissible.getEffectivePermissions().stream()
                .map(PermissionAttachmentInfo::getPermission)
                .filter(permission -> permission.startsWith(prefix)).map(permission -> permission.substring(prefixLength))
                .map(valueAsString -> {
                    try {
                        return Integer.parseInt(valueAsString);
                    } catch (NumberFormatException e) {
                        return null;
                    }
                }).filter(Objects::nonNull)
                .mapToInt(Integer::intValue);
    }```
twilit roost
pseudo hazel
compact haven
#

it aint "rest lang" it's a fucking rest api

#

you call generic java methods to send a request

tardy swift
rotund ravine
#

No

copper scaffold
#

is there a way to get from the BanList the entries/names from the banned players?

regal scaffold
#

Holy shit

#

Serializable is so damn COOL

tardy swift
#

can someone help me pls

icy beacon
pseudo hazel
icy beacon
#

so for example if you have permissions perm.1, perm.2, you can pass in a player with prefix perm and it should output an IntStream with 1 and 2

terse ore
icy beacon
#

well take perm.1, perm.2 and perm.shit

#

trying to Integer.intValue("shit") will throw an exception

#

the method will handle it by instead returning null

tardy swift
terse ore
#

makes sense

tardy swift
#

@pseudo hazeli can send u the code or ???

#

for u see

pseudo hazel
#

no

#

how do you knwo the code is right if you cant compile it

icy beacon
tardy swift
#

someone telled me

#

can i show u ?

rotund ravine
#

Noty

pseudo hazel
#

I mean you does it fit in a paste?

#

?paste

undone axleBOT
icy beacon
tardy swift
#

ye

copper scaffold
icy beacon
#

i'm scared...

tardy swift
#

i sended u

copper scaffold
#

yea

pseudo hazel
#

for (BanEntry entry : getBanEntries())

pseudo hazel
#

just send it in here

icy beacon
terse ore
icy beacon
#

because you have multiple permissions

#

basically could add something like .collect(Collectors::toList) and return a list instead

#

i think

terse ore
#

but why would someone set

#

foo.bla.5

#

and

#

foo.bla.9

tardy swift
icy beacon
#

well say it's access to plots in a plot plugin

#

and someone has multiple plots

#

that are for some reason defined by perms

#

use cases are there for sure

tardy swift
#

Plugin uhc like werewolf

icy beacon
#

i can't think of one rn but that's acceptable

young knoll
#

Essentials uses it for how many homes you can have

icy beacon
#

?paste

undone axleBOT
young knoll
#

Actually no they map it config values

terse ore
pseudo hazel
#

okay

icy beacon
pseudo hazel
#

then get the first int from the stream

terse ore
#

I was asking why someone would have the same permission but with different number at the end

pseudo hazel
#

this looks very complicated to get a single permission value

icy beacon
#

bro sent the code

#

check the thread