#help-development

1 messages · Page 1236 of 1

blazing ocean
#

SO TRUE

thorn isle
#

i haven't used it much, but it works for bulk tasks where you don't care about timeout errors or things taking forever

#

i used it to generate a few thousand textures for custom sword trims, with like sd 1.5 or something iirc

blazing ocean
#

a few what

#

why do you need so many trims

thorn isle
#

well uh i actually only meant to generate a few hundred

#

but it took so long that i left it running and forgot about it for days

#

at least now, no two players will have the same trim

#

digital scarcity, yes?

grim hound
#

Ohh it does?

thorn isle
#

it does

#

expect all of your data to get stolen by the chinese, however

thorn isle
#

also goblets

#

for le dungeon loot

#

they look kind of crinkley and shit but at least there are thousands of them

#

i also have 2000 rings somewhere but i can't find them

grim hound
#

All generated?

thorn isle
#

yeees

#

i'm not drawing 10,000 textures by hand

grim hound
#

Can you somehow check which ones are used?

thorn isle
#

the model card on their site usually says on the sidebar how popular it is and whether it's eligible for inference on the spot

umbral ridge
#

what ai did you use

#

looks nice

#

@thorn isle

thorn isle
#

just simple diffusion 1.5 with a lot of post-processing

fickle spindle
#

how can i check if the player connects from one or another ip or if he connect by direct connection or if the server is in the player list

thorn isle
#

simple diffusion

#

🤡

#

i mean stable diffusion

fickle spindle
thorn isle
#

not replying to you

fickle spindle
#

oh okay sry

thorn isle
#

there should be something on the async prelogin event for that iirc

#

the client tells the server what address the client is connecting to, which could e.g. be a domain name rather than the server ip

#

idk if that's what you mean though, i can't really make heads or tails of what you're saying

pliant topaz
fickle spindle
pliant topaz
#

well the first part with direct connection etc is something thats only for the client, the server has nothing to do with that. The second thing tho can be achieved through some sort of proxy perhaps (never worked with so no clue on the how excactly, sorry)

fickle spindle
eternal oxide
#

never allow direct connect when using a proxy

fickle spindle
eternal oxide
#

k

pliant topaz
thorn isle
#

i still can't parse what you're saying

#

try using some punctuation

#

you want to give someone a reward if they join from a server list?

eternal oxide
#

sounds like he wants some kind of referal system

thorn isle
#

maaaybe

#

he does mention 2 different subdomains

thorn isle
#

but you'd have to have a separate subdomain for every server list

#

and you probably don't want players getting rewards every time they join with that address

#

not sure why you'd want to reward people from a server list specifically either

#

referrals would make more sense

fickle spindle
#

ye i think that referrals is better too but i was just couriouse how a stuff like that is possible and if it's possible do use it for do something cool

thorn isle
#

the async prelogin event iirc has a method to get the address the player is connecting with

fickle spindle
#

what this do e.getPlayer().getAddress().getHostName()?

thorn isle
#

not what you want

eternal oxide
#

Yep, even has a check for isTransferred, but its just a boolean

flint coyote
#

How would I make a skeleton shoot rockets in the same direction as the arrow?

    @EventHandler(ignoreCancelled = true)
    public void onEntityShootBow(EntityShootBowEvent e) {
        if(!(e.getEntity() instanceof Skeleton)) return;
        if (!(e.getProjectile() instanceof Arrow arrow)) return;

        Firework firework = (Firework) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.FIREWORK_ROCKET);
        FireworkMeta meta = firework.getFireworkMeta();

        meta.addEffect(FireworkEffect.builder()
                .with(FireworkEffect.Type.BALL_LARGE)
                .withColor(Color.RED)
                .withFade(Color.YELLOW)
                .flicker(true)
                .build()
        );
        //meta.setPower(1);
        firework.setFireworkMeta(meta);
        //firework.setVelocity(arrow.getVelocity());
        e.setProjectile(firework);
    }
```I tried this and also experimented with the velocity and power (also set it to 0) but all it does is make the rocket fly straight upwards
thorn isle
#

get the velocity of the arrow and set that as the velocity of the rocket

#

that's the first thing that comes to mind at least

flint coyote
#

that's the second to last line but it didn't change anything, probably because rockets change their velocity by themselves

thorn isle
#

it could be that they're hardwired to go up

#

try setRotation maybe

flint coyote
#

But a player can shoot rockets with a bow in any direction so there has to be a way

#

*crossbow

thorn isle
#

man i'm so behind on the times with game features

flint coyote
#

It's quite easy to miss since they are only loaded into the crossbow when they are in your offhand

thorn isle
#
    public void tick() {
        super.tick();
        HitResult hitResultOnMoveVector;
        Vec3 handHoldingItemAngle;
        if (this.isAttachedToEntity()) {
            if (this.attachedToEntity == null) {
                ((OptionalInt)super.entityData.get(DATA_ATTACHED_TO_TARGET)).ifPresent((target) -> {
                    Entity entity = this.level().getEntity(target);
                    if (entity instanceof LivingEntity) {
                        this.attachedToEntity = (LivingEntity)entity;
                    }

                });
            }

            if (this.attachedToEntity != null) {
                if (this.attachedToEntity.isFallFlying()) {
                    Vec3 lookAngle = this.attachedToEntity.getLookAngle();
                    double d = 1.5;
                    double d1 = 0.1;
                    Vec3 deltaMovement = this.attachedToEntity.getDeltaMovement();
                    this.attachedToEntity.setDeltaMovement(deltaMovement.add(lookAngle.x * 0.1 + (lookAngle.x * 1.5 - deltaMovement.x) * 0.5, lookAngle.y * 0.1 + (lookAngle.y * 1.5 - deltaMovement.y) * 0.5, lookAngle.z * 0.1 + (lookAngle.z * 1.5 - deltaMovement.z) * 0.5));
                    handHoldingItemAngle = this.attachedToEntity.getHandHoldingItemAngle(Items.FIREWORK_ROCKET);
                } else {
                    handHoldingItemAngle = Vec3.ZERO;
                }

                this.setPos(this.attachedToEntity.getX() + handHoldingItemAngle.x, this.attachedToEntity.getY() + handHoldingItemAngle.y, this.attachedToEntity.getZ() + handHoldingItemAngle.z);
                this.setDeltaMovement(this.attachedToEntity.getDeltaMovement());
            }

            hitResultOnMoveVector = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity);
        } else {
            if (!this.isShotAtAngle()) {
                double d2 = super.horizontalCollision ? 1.0 : 1.15;
                this.setDeltaMovement(this.getDeltaMovement().multiply(d2, 1.0, d2).add(0.0, 0.04, 0.0));
            }

            handHoldingItemAngle = this.getDeltaMovement();
            hitResultOnMoveVector = ProjectileUtil.getHitResultOnMoveVector(this, this::canHitEntity);
            this.move(MoverType.SELF, handHoldingItemAngle);
            this.applyEffectsFromBlocks();
            this.setDeltaMovement(handHoldingItemAngle);
        }
#

try setShotAtAngle

flint coyote
#

Oh that sounds reasonable from the javadoc, thanks. I'll try

thorn isle
#

i have this bad habit of going to the impl source rather than the docs

#

maybe because half of the bukkit docs are

setShotAtAngle(boolean shotAtAngle)
sets if shot at angle
shotAtAngle: whether shot at angle
flint coyote
#

hahaha yeah fair point

#

it still doesn't work though, wait let me record that

#
 Firework firework = (Firework) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.FIREWORK_ROCKET);
            FireworkMeta meta = firework.getFireworkMeta();

            meta.addEffect(FireworkEffect.builder()
                    .with(FireworkEffect.Type.BALL_LARGE)
                    .withColor(Color.RED)
                    .withFade(Color.YELLOW)
                    .flicker(true)
                    .build()
            );
            meta.setPower(3);
            firework.setFireworkMeta(meta);
            firework.setShotAtAngle(true);
            firework.setVelocity(arrow.getVelocity());
            bowEvent.setProjectile(firework);
```I set the velocity back but no luck
#

oh the arrows velocity is 0 for some reason, lemme check that

thorn isle
#

get the shooter's direction and multiply appropriately i suppose

chrome beacon
#

You should use the spawn method that takes a consumer and modify the firework there. Otherwise you will spawn it and then modify instead of spawning a modified firework

flint coyote
flint coyote
robust helm
#

why not js cancel it and use launchProjectile(Firework.class) on the skeletton

#

by canceling i mean removing the arrow

flint coyote
#

Would be kinda against the api to cancel an event, just to trigger another one if it has a "setProjectile" method, wouldn't it?
I'll just do what vcs2 said and get the direction with multiply

robust helm
#

true

flint coyote
#

Works now :)

glossy laurel
#

Chat, im tryna make enchanting bottles with specific PDC data drop a specific number of xp orbs. My plan was to set the xp to the value the shattered bottle would have in its PDC, however I cannot find a way to transfer it from the item to the entity when it's thrown. Any ideas?

glossy laurel
umbral ridge
#

how do you get player's ip address accurately

#

how could it be unresolved

chrome beacon
#

Won't get more reliable than that

#

You can use that method

glossy laurel
#

I have this weird bug, sometime a player doesn't appear to their opponent, and their opponent cant hit them or interact with them in any other way. The player itself can hit the opponent though. Does anyone know what could be causing this behavior? P. S. The player appears in tab for the opponent. P. P. S. when I /vanish the player twice they appear for the opponent.

chrome beacon
#

Is Spigot up to date

#

Unless you believe it's your code causing it

glossy laurel
#

I do

#

cuz its when people get put in duels

#

fixes after first round

glossy laurel
chrome beacon
#

Time to update

remote swallow
chrome beacon
#

khajiit Paper emoji

remote swallow
#

uhhhhh

#

ignore that

chrome beacon
#

📸

remote swallow
glossy laurel
glossy laurel
#

Is tthere some way to make an item glow without enchanting it?

fickle spindle
#

how can i make npc and store them so when i restart the server they are back where they was

glossy laurel
fickle spindle
#

but i just want to create and remove an npc stop

glossy laurel
#

what kind of model is expected in setItemModel

blazing ocean
#

a key to an item model in a resource pack

chrome beacon
#

an item model

chrome beacon
glossy laurel
blazing ocean
#

not the texture, the model

#

but yes

glossy laurel
#

also, I'm assuming it won't work if I want to retexture a an item to a specific player's skull?

fickle spindle
#

why it doen't work now?
import com.google.common.collect.Lists;
public static final List<String> players = Lists.newArrayList();
i never touched this list from 1h

blazing ocean
glossy laurel
#

where did new ArrayList

#

go

blazing ocean
glossy laurel
#

💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀 💀

#

you cant be making this shi up

#

lmfao

#

I cant

fickle spindle
#

Cannot resolve symbol 'Lists'

chrome beacon
#

Did you get rid of Guava from your dependencies

blazing ocean
#

I mean you don't need it in this case

chrome beacon
#

^^

#

Also a String list of players 🤔

blazing ocean
#

yep, use UUIDs

fickle spindle
fickle spindle
chrome beacon
#

Transient dependency

fickle spindle
#

i don't have it

chrome beacon
#

You had it if it was working before

#

If you haven't modified your dependencies at all and you're using Intellij you can try invalidating caches

fickle spindle
river oracle
river oracle
#

Might need to refresh your maven

#

Otherwise a good old invalidate caches

fickle spindle
lost matrix
#

with the old sd model it gives you something like this:

blazing ocean
#

that's honestly not too bad

lost matrix
#

It can probably get better with more stylized words and negative embeddings

lost matrix
# blazing ocean

This was done before the diamond operator could be left empty.
To prevent

List<String> someList = new ArrayList<String>();

and

List<String> someList = Lists.newArrayList();

could be used instead. But since java introduced type interpolation for the diamond operator a decade ago, all those methods are pretty much obsolete now.

worldly ingot
#

People forget that Guava's kinda old as shit lol

eternal night
#

What do you mean, I was around when they released guava 😦

#

Hater

blazing ocean
#

you're also 829 years old

dry hazel
#

true

placid estuary
#

i have a permission check in my plugin, and i have the permission assigned to a player via luckperms, but for whatever reason, the check always returns false unless the player has every permission
any ideas on what might be causing this?

rough ibex
#

Show code

#

Every permission ever? Or your permissions? Or op

placid estuary
#

every permission ever

rough ibex
#

odd, how are you checking

placid estuary
#

it happens in several different places but this is one example:

@EventHandler
    public void onBlockBreak(BlockBreakEvent e) {
        Match match = Queues.GetMatchContainingPlayer(e.getPlayer());
        if ((match == null || !match.hasStarted) && !e.getPlayer().hasPermission("novinitypvp.bypassprematchrestrictions")) {
                e.setCancelled(true);
        }
    }
#

i have also spell checked it

rough ibex
#

are you sure the permission is it

#

Try checking only that

#

Maybe the match is failing

placid estuary
quaint mantle
#

can I add to spigot server fabric engine?

placid estuary
quaint mantle
#

Where i must put it

#

and if I had it how can i add mods

silver robin
placid estuary
#

but still returned false with hasPermission

eternal oxide
#

Player#hasPermission can not return false if it is in their effective permissions

placid estuary
#

also it's evidently working with the workaround, which uses their effective permissions

eternal oxide
#

then you have the permission granted but set to false or op

placid estuary
#

how do i fix that?

eternal oxide
#

set it properly!?

silver robin
#

i feel something is wrong here i just cant explain it :/

placid estuary
eternal oxide
#

output the getPermission and the getValue

placid estuary
#

righto

silver robin
#

CraftEntity has a Map<String, PermissionAttachmentInfo>, calling getEffectivePermissions() returns a set of the values, and hasPermission() does a string lookup in that map, if it finds something then it returns the value of that permission (which may be false!), otherwise it returns something depending on whether the player is op

quaint mantle
#

Then what is the best method to do it

silver robin
#

Try java Bukkit.getServer().getPluginManager().getPermission("novinitypvp.abcdefgh") and see what it outputs

placid estuary
#

that specifically? or replaced with the problem permission?

silver robin
#

whichever permission you'd want to test with
preferably turn it into a debug command

tidal kettle
#

hey anyone know why the enderDragon health can't be changed (with NMS)

public class EnemyDragon extends EnderDragon {
    public EnemyDragon(EntityType<? extends EnderDragon> entitytypes, Level world) {
        super(entitytypes, world);

        this.setHealth(10f);
    }
}

I only have this

silver robin
eternal oxide
silver robin
tidal kettle
placid estuary
eternal oxide
#

do you ONLY set it in LP?

thorn isle
#

doesn't luckperms have a verbose mode for shit like this

silver robin
placid estuary
thorn isle
#

one of the few actual improvements over pex

silver robin
#

luckperms also has a command to test permissions i think

thorn isle
#

it does yeah

placid estuary
#

do yk what it is?

#

permission check says its true too

placid estuary
#

i also dont know how to do that though lmao

silver robin
#

ask chatgpt that

#

also, you're using player.hasPermission which, afaik, luckperms performs a hack to make it work
(e.g. if your plugin never calls player.hasPermission("novinitypvp.somestringhere"), then luckperms will never offer that autocompletion in the web editor)
it would probably be the best to use Luckperms API directly

placid estuary
#

but what if i dont want the plugin to require luckperms

silver robin
#

that's why it's a softdepend

eternal oxide
#

if you don;t need wildcards then Player#hasPermission is fine

placid estuary
#

will calling the api not make it a requirement?

#

since itll just give an error if it doesnt exist

eternal oxide
#

IF you don;t care about the value then use Player#isPermissionSet

young knoll
#

You don’t need the luckperms api to check permissions

silver robin
young knoll
#

That’s exactly what hasPermission is for

silver robin
#

I believe his problem is that his plugin loads before luckperms, and luckperms does not catch up all the hasPermission calls

thorn isle
#

how can the player be online before luckperms loads

#

or are we working with an offlineplayer?

silver robin
silver robin
#

i meant the plugin that needs permissions but does setup before luck perms can create some invalid state in between

tidal kettle
placid estuary
#

it does in fact load before luckperms

thorn isle
eternal oxide
#

should not really matter as you are using SPigot API

thorn isle
#

the permission is resolved when the call is made

#

which is long after luckperms loads

placid estuary
#

oh my god

#

im such a moron

eternal oxide
#

You should/could register your permissions in your plugin.yml (as ALL plugins should)

placid estuary
#

the user had 2 roles: builder and default
default had the permission set to false
builder had it as true

#

i forgot that default had it as false and also thought it wouldnt matter since builder was higher

quaint mantle
#

can You guys send me full end script and tell me where i must put it?
Pleaaaaaaaaaaaase

placid estuary
#

but i guess i was wrong

thorn isle
#

next time use luckperms verbose

silver robin
rough ibex
#

aka. for people who know programming

eternal oxide
silver robin
rough ibex
#

and your question was already answered

placid estuary
#

so sorry for wasting your times 😭

rough ibex
#

so ticket closed

eternal oxide
#

set its default to false and only give true in teh actual group which needs it

rough ibex
eternal oxide
silver robin
quaint mantle
#

Thanks

kind coral
#

is there a spigot version of paper's ```java
getOfflinePlayerIfCached

eternal oxide
#

no

kind coral
#

is there a similar thing that will prevent my server from exploding?

eternal oxide
#

get the offline player by UUID. if the getName method returns empty then they don;t exist

fickle spindle
#

there is a way for get the items of the book (next page etc)

kind coral
#

thats why i am searching by the name

eternal oxide
#

then no

placid estuary
kind coral
#

it would still compute the OfflinePlayer object

#

which if it doesn't exist it will lag your server for some unspoken reason

eternal oxide
#

getOfflinePlayer(name) will always return an Object

kind coral
eternal oxide
#

it might

#

if its not cached

kind coral
#

yeah i'd have to migrate to paper for this one sadly

eternal oxide
#

what are you trying to do?

kind coral
#

a party plugin

#

its cross servers

eternal oxide
#

why do you need it only if cached?

kind coral
#

im using NATS for messaging so i need to be sure a player is there

thorn isle
#

a player can have played before and not be cached

kind coral
#

also some players may have never played a gamemode so they never joined that server

eternal oxide
#

how would a player get into the party if they are not cached?

thorn isle
#

presumably parties are network wide

kind coral
#

exactly

eternal oxide
#

surely they have to be added by a server they are on

kind coral
#

via Nats, it sends a packet across the shared network and if there is a match in any of the server then its constructed

thorn isle
#

either way i dont think ifCached helps here since you will want the command to also work for players who have never joined a backend

#

this honestly sounds like a command that should execute on the proxy

kind coral
#

would have been much simpler

eternal oxide
#

yeah a proxy command would be perfect for it

thorn isle
#

the only way i see this working is online mode and calling the mojang api if the cache doesn't have the name

#

is the requester also fine with this

kind coral
#

yeah the only thing the server is also cracked so no luck on that

thorn isle
#

tell him that he is a ♿

#

and that the command will be on proxy

kind coral
#

like i could do the trick of getting the UUID by doing "OfflinePlayer:" + nameOfPlayer and get the bytes

kind coral
#

:/

quaint mantle
#

Why cracked though

thorn isle
#

that'll break with certain fastlogin/namechange support systems they probably also have

kind coral
rough ibex
kind coral
#

if you pay the game no need for auth, if you don't you need a password

kind coral
thorn isle
#

this problem comes in two parts pretty much

#

the first is to have some centralized database for name -> uuid; this would be their fastlogin database presumably on the proxy

#

the second is to get the backend to call that database

kind coral
#

the only way i see it is to forward the command trough NATS to find a matching name then actually run the logic on the server the player is on which will take some millis but i think there is a better way

thorn isle
#

database as in a repository for that information

kind coral
#
package it.alessandrocalista.parties.network;

import java.io.Serializable;
import java.util.UUID;

public interface Packet extends Serializable {

    record CreatePacket(UUID owner) implements Packet {
    }

    record MemberJoinPacket(
            UUID partyUUID,
            UUID member
    ) implements Packet {
    }

    record MemberLeavePacket(
            UUID partyUUID,
            UUID member
    ) implements Packet {
    }

    record PromotePacket(
            UUID partyUUID,
            UUID member
    ) implements Packet {
    }

    record DisbandPacket(UUID partyUUID) implements Packet {
    }

    record PartyInvitePacket(
            UUID partyUUID,
            UUID sender,
            UUID target
    ) implements Packet {

    }

    record PartyInviteExpiredPacket(
            UUID partyUUID,
            UUID sender,
            UUID target
    ) implements Packet {

    }
}

thorn isle
#

could be flatfile, could be mysql

kind coral
#

currently this is the packet structure

thorn isle
#

but to resolve names you need a mapping from name to uuid

kind coral
#

every server is synced (waste of memory because if it had been proxy it would have not even needed NATS)

kind coral
thorn isle
#

is the name -> uuid mapping also synchronized across backends?

kind coral
thorn isle
#

there must be

#

otherwise their fastlogin setup wouldn't work

#

the mapping is most likely on the proxy managed by fastlogin

kind coral
#

oh you mean if there exists a database with some data

thorn isle
#

you need to figure out a way to query it

quaint mantle
kind coral
thorn isle
#

either by making a direct request to the db if they use mysql, or through plugin messaging to the proxy that fires your code there that calls the fastlogin api

kind coral
#

YOU ARE A GENIUS

#

WAIT

#

i remember there was a bungee channel to query user data

#

wait

thorn isle
#

unless it's specifically managed by fastlogin it isn't going to help you

#

or are we restricting this to players who are currently online on the network?

cinder abyss
#

Hello, how can I get the vector of the direction the player is looking at ?

chrome beacon
#

getEyeLocation

cinder abyss
#

okay that's not that the problem then

#

humm

#

I'm trying to "launch" an armor stand

#

and he has a gravity using velocity etc.

#

but he suddenly stops orienting in the direction of the player, and keep to Z+

eternal oxide
#

I didn't see an issue

#

oh you mean the facing of the stand

cinder abyss
#

the sword in his hand should always be in the same direction of the player (except when it rotates)

eternal oxide
#

set its direction to the players direction

cinder abyss
cinder abyss
eternal oxide
#

clearly not

cinder abyss
#

but then it just set to another position

cinder abyss
#

and then with velocity it just... idk

echo basalt
#

I assume you're counter-rotating the armorstand's hand towards -yaw

#

which cancels out the rotation of yaw

#

making it always face z?

#

nvm I'm completely off

cinder abyss
#

the hand doesn't make the orientation of the stand ig

chrome beacon
#

Hm? Why are you changing the rotation in the runnable rather than on spawn

cinder abyss
chrome beacon
#

Also do modify the entity the spawn methods consumer

cinder abyss
#

like it's a throw

cinder abyss
#

it doesn't exist in this version

eternal oxide
#

also (just a minor thing) getLocation() already returns a clone so unless you want to use it multiple times you don;t need to clone again

cinder abyss
#

okay thanks

chrome beacon
cinder abyss
#

okay I don't even finish my sentences 😭

#

like it's a axe throw

#

it's spinning

chrome beacon
#

Why do you want it to follow the players direction

#

So if I move my head the axe rotates

cinder abyss
#

no, it keeps the same direction

chrome beacon
#

That's not what your code does

cinder abyss
#

I get the direction one time ?

chrome beacon
#

Wait that was a runLATER

cinder abyss
#

YEAH

#

that's what I thought you thought

chrome beacon
#

🤦‍♂️ My bad

cinder abyss
#

okay the hand is the problem

young knoll
#

So no telekinetic axes?

cinder abyss
#

not yet x)

#

you changed your nickname ?

chrome beacon
#

If you move within 2 ticks :)

#

Well it's more like it will be in the wrong rotation and then correct itself

cinder abyss
#

well I think I fixed it

#

thanks 😄

chrome beacon
#

What did you change?

slim wigeon
#

Got the first row fixed

#

Ignore that, I cannot tell you what I did

chrome beacon
#

Try >= instead of > in the size check

slim wigeon
cinder abyss
#

and now I try to make the item in the hand follow same trend as the armor stand

#

but for now I'll go get some rest, see ya!

buoyant viper
#

Hello, Sharks

#

how do i write Code

smoky oak
quaint mantle
remote swallow
#

OMG KOTLIN ISLAND

#

@blazing ocean

blazing ocean
#

Where do you think the name came from lol

remote swallow
#

i dont know tbh

smoky oak
#

programmers have no imagination

#

everything is copied

mortal vortex
#

Java (the place) is actually beautiful and makes sense that something would be named afrer it.

#

Kotlin Island looks like a place where I'd construct a gulag

kindred valley
#

Maybe this helps....

#

?learnjava

undone axleBOT
#

For Beginners:

Codecademy - Learn Java: Interactive Java programming course from basics to more advanced concepts. Perfect for absolute beginners.
https://www.codecademy.com/learn/learn-java
JetBrains Academy - Java Developer Track: Learn by doing with projects and challenges. It covers Java fundamentals to advanced topics.
https://www.jetbrains.com/academy/
Udemy - Java Programming Masterclass for Software Developers: Updated courses that cover Java 8 to Java 17 features. Suitable for those who prefer structured learning.
https://www.udemy.com/course/java-the-complete-java-developer-course/

For Intermediate to Advanced Learners:

Oracle Java Tutorials: The official guides by Oracle for Java programming—great for understanding the depth of Java.
https://docs.oracle.com/javase/tutorial/
Baeldung - Learn Java and Spring: Focus on Spring Framework and modern Java technologies. Best for intermediate learners aiming to expand their knowledge.
https://www.baeldung.com/

Practice and Hands-on Learning:

Exercism - Java Track: Solve exercises and get feedback from mentors. Great for practicing coding skills.
https://exercism.io/tracks/java
LeetCode: Practice your coding skills and prepare for technical interviews with Java.
https://leetcode.com/

Free Resources and Documentation:

Java Programming and Documentation: A comprehensive collection of Java programming guides, tutorials, and API documentation.
https://docs.oracle.com/en/java/

Community and Support:

Stack Overflow: A vast community of developers. Great for getting help with specific problems or understanding concepts.
https://stackoverflow.com/questions/tagged/java
r/learnjava on Reddit: Join the community of Java learners and get advice, share resources, and discuss projects.
https://www.reddit.com/r/learnjava/

Remember: Learning to program takes practice and patience. Don't hesitate to experiment with code and participate in community discussions. Happy coding! 🎉

buoyant viper
placid estuary
#

how come these recipes don't work? i tried a test recipe with some different materials and it worked fine, but these just don't function

#

the GetHeart method:

public static ItemStack GetHeart(int amt) {
        ItemStack stack = new ItemStack(Material.NETHER_STAR);
        stack.setAmount(amt);
        ItemMeta meta = stack.getItemMeta();
        meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', NovinitysLifesteal.HeartName));
        meta.setLore(new ArrayList<>() {{
            add(ChatColor.GRAY + "A small chunk of life force.");
        }});
        stack.setItemMeta(meta);
        return stack;
    }
#

ive done something very similar to this in past plugins and it's worked completely fine

candid rapids
#

aight so, im real new to plugin dev, anyways, i want to pass an instance of my config file to a class when the server is enabled, and idk how i can do that

undone axleBOT
candid rapids
worldly ice
#

after you can modify the file configuration and save it back to the file

candid rapids
#

like this? effectgen.itemgen(this.getConfig());

worldly ice
#

what's itemgen?

candid rapids
#

its the method

#

effectgen is the class itemgen is the method

fickle spindle
#

How can I take a timestamp when someone make the command test and check if the differenze from the timestamp to another timestamp is less or equal to 24 hours?

worldly ice
#

you used the method in that code snippet but i dont know if it's "right" because i have no idea what you're trying to do

worldly ice
#

not sure what you're asking

candid rapids
# worldly ice right i mean like what does it do

public class effectgen{

public static void itemgen(FileConfiguration config){
    System.out.print("started");
    List<String> plants = config.getStringList("Alchemy.Plants");

    for(int i = 0; i>=plants.size(); i++){

        List<Integer> effects = Listgen.effect(i);
        for(int x = 0;3>x; x++){
            config.set("Alchemy.Plants."+plants.get(i), effects.get(x));
        }
    }
    System.out.print(plants);
}

}

candid rapids
worldly ice
#

when are you calling that

fickle spindle
candid rapids
#

public class Start extends JavaPlugin {
private static Start plugin;

@Override
public void onEnable() {
    plugin = this;
    getLogger().info("onEnable is called!");
    getServer().getPluginManager().registerEvents(new BrewListen(), this);
    getLogger().info("Big brother be watching");
    effectgen.itemgen(this.getConfig());
}
@Override
public void onDisable() {
    getLogger().info("onDisable is called!");
}
public static Start getplugin(){
    return plugin;
}

}

worldly ice
#

also naming conventions 😟

candid rapids
#

i will start naming them in emojis

worldly ice
candid rapids
#

yes

worldly ice
#

what are they

candid rapids
#

[00:50:35 INFO]: [Ablution] Enabling Ablution v0.1
[00:50:35 INFO]: [Ablution] onEnable is called!
[00:50:35 INFO]: [Ablution] Big brother be watching
[00:50:35 ERROR]: Error occurred while enabling Ablution v0.1 (Is it up to date?)
java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Unknown Source) ~[?:?]
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Unknown Source) ~[?:?]
at java.base/jdk.internal.util.Preconditions.checkIndex(Unknown Source) ~[?:?]
at java.base/java.util.Objects.checkIndex(Unknown Source) ~[?:?]
at java.base/java.util.ArrayList.get(Unknown Source) ~[?:?]
at AA-1.0-SNAPSHOT.jar/AbyssalAblution.example.IngredientGen.effectgen.itemgen(effectgen.java:16) ~[AA-1.0-SNAPSHOT.jar:?]
at AA-1.0-SNAPSHOT.jar/AbyssalAblution.example.Start.onEnable(Start.java:19) ~[AA-1.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:280) ~[paper-api-1.21.4-R0.1-SNAPSHOT.jar:?]
at

#

io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:202) ~[paper-1.21.4.jar:1.21.4-187-1d5e5a5]
at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:109) ~[paper-1.21.4.jar:1.21.4-187-1d5e5a5]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:520) ~[paper-api-1.21.4-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.CraftServer.enablePlugin(CraftServer.java:657) ~[paper-1.21.4.jar:1.21.4-187-1d5e5a5]
at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:606) ~[paper-1.21.4.jar:1.21.4-187-1d5e5a5]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:743) ~[paper-1.21.4.jar:1.21.4-187-1d5e5a5]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:488) ~[paper-1.21.4.jar:1.21.4-187-1d5e5a5]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:322) ~[paper-1.21.4.jar:1.21.4-187-1d5e5a5]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[paper-1.21.4.jar:1.21.4-187-1d5e5a5]
at net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:310) ~[paper-1.21.4.jar:1.21.4-187-1d5e5a5]

worldly ice
#

your for loop is wrong

#

for (int i = 0; i < plants.size(); i++) { ... }

#

and it also looks like Alchemy.Plants is an empty list

candid rapids
#

yup, commenting that out fixed that

#

so, now need to do some yaml nonsense

#

Alchemy:
Plants:
Dandelion:
Poppy:
Blue_Orchid:

worldly ice
candid rapids
worldly ice
candid rapids
#

ik,

#

tbh, i thought the issue was passing the file, now ik that none of my system message were getting sent, i realize im where i expected to be, figuring out how to edit this yaml file properly

outer tendon
#

Well my goal is to cut off generation at y=63, among other things, but that's the first part. I want to alater the default generation rather than generate it myself. Is that possible with these methods? I don't quite understand them. Are block populators not intended for additional things like adding stuff like loot to generation?

sullen marlin
outer tendon
#

Hopefully this will work better than using the ChunkLoad event xD

ocean gorge
#

Why can't i find the Material class using Spigot API 1.21.4-R0.1-SNAPSHOT?

ocean gorge
#

sorry, i have to use v2022 because newer versions of IntelliJ don't let me compile plugins

#

the fill button is not clickable

drowsy helm
#

fill button?

ocean gorge
#

And the generated methods onEnable() and onDisable() tell me "no usages"

ocean gorge
smoky anchor
drowsy helm
#

You're just gonna have to find fixes to those issues, updating IJ is the only way of fixing the dependency issue

smoky anchor
ocean gorge
#

Maven

smoky anchor
#

ye, so you'd build your plugin with mvn package or some command, don't remember

#

not with some weird button

ocean gorge
#

15 minutes to update 😭 i wait

smoky anchor
#

I still wanna know what you mean with your "fill button" tho

ocean gorge
#

I'm sorry for my keyboard, i mean "compilation"

pliant topaz
#

Well you just need to properly set it up, probably not setup correctly upon updating

ocean gorge
#

I have to say though that i have never seen such fast support anywhere, impressive

#

Ok, now it works

#

Ty from 🇮🇹

fickle spindle
# ocean gorge I have to say though that i have never seen such fast support anywhere, impressi...

yo man sorry for disturbing you, i saw that you are a JDA user i'm trying to get when someone leave the discord i aready done a slash command that work fine but in my event listener
public class DiscordListener extends ListenerAdapter { @Override public void onSlashCommandInteraction(SlashCommandInteractionEvent event) { } public void GuildLeaveEvent(GuildLeaveEvent event) {} }
the guild leave event doesn't work and the name doesn't become blue how the onSlashCommandInteraction does, sorry another time for disturbing

#

i tried putting @Override to the GuildLeaveEvent too but it get me this error Method does not override method from its superclass

eternal oxide
#

if you Override a method it must exist in teh parent class

lime pulsar
#

is there anyway to prevent plugins from registering commands you want the server default?

quaint mantle
#

You can /minecraft:vanilla_command

lime pulsar
#

before it gets overwritten not after

eternal oxide
#

you could remove their command from teh command map

lime pulsar
#

hrm i thought you couldnt do that?

eternal oxide
#

you can but it requires reflection

#

or

#

You could register yoru own command last which calls the vanilla command

lime pulsar
#

hmm

eternal oxide
#

last to register gets priority

rough drift
#

or

#

use the tab complete event and the command preprocess event

#

to re-route to the vanilla command

#

there is a method like Bukkit.tabComplete or similar

#

or it was on the player I forgor

#

anyways you can use that

#

and then Player#perform to call the command

bright spire
#

It has some issues that are going to be addressed, but I was told it's the smoothest in terms of combat

grand flint
#

what

glossy laurel
#

Why is having your plugin instance stored in a static field considered bad

orchid trout
#

who told you that

#

i mean usually you just use di

rough drift
#

if not properly updated you could accidentally hold the previous instance

smoky anchor
#

-# don't think I ever had an issue with this but
Don't use /reload

thorn isle
#

Reloading plugins is fine as long as the plugin is written with reloads in mind

#

Static fields persist for only as long as the plugin classloader does, which, if you cleanup correctly on unload, won't outlive the next gc cycle

young knoll
#

Generally you just set your static instance to null onDisable

thorn isle
#

You don't need to but you can if you like to

#

If someone is leaking references to your plugin classes you have bigger problems than your static plugin field

valid burrow
#

generally just dont use reload in production

thorn isle
#

full server reloads for sure, but if you know a plugin supports being reloaded, it's fine to reload it

#

in many of my plugins i forgo an internal /myplugin reload command entirely in favor of just supporting reloads with a plugin manager

#

dependency chains make it difficult to support and those plugins usually don't or can't support it

#

but for a standalone plugin? i'd argue it's actually considerably cleaner than internal reload logic

smoky anchor
#

Iirc you can not delete old classes from memory, so doing /reload often will just make the server run out of memory
So dedicated reload command per plugin is still best

thorn isle
#

i'm not sure how /reload works, but plugin managers cause the classes to be re-loaded under a new classloader

jagged thicket
#

yo so should i not make a /reload option for my plugin loader

thorn isle
#

which means the old classloader, and any classes loaded by it, can be garbage collected

young knoll
#

/reload does the same

thorn isle
#

as long as nobody is holding references to any instances of those classes (this is why doing it with dependency chains is hard)

smoky anchor
#

Can classes be garbage collected ?
I don't know much about Java internals

young knoll
#

Assuming yk, nothing keeps it from being cleaned

thorn isle
#

myes

#

which is very difficult to be assured of when working with dependencies

jagged thicket
#

no if im writing smth like bukkit, is there a safe way to implement reload

thorn isle
#

with just bukkit, though, bukkit usually does its own cleanup on unload

#

e.g. listeners and tasks get unregistered and cancelled

#

so unless you're really going out of your way to get your classes referenced after your plugin is disabled, you're probably fine

thorn isle
ivory sleet
slender elbow
#

the classloader needs to be GCd for its classes to be GCd

worldly ingot
#

I also need to be GCd PES2_SadGeRain

slender elbow
#

except for hidden classes, hidden classes may be GCd without having to GC the CL, depending on how the hidden class was created

slender elbow
thorn isle
#

and the classloader can't be gc'd as long as any of its classes can't be gcd, which is as long as any of their instances are still reachable on the heap

#

so having e.g. some worldguard flag in the wg registry is going to keep all of your classes and statics in memory

#

easy to get wrong, but usually not an issue if you're consistent and careful with where you pass your objects

slender elbow
#

generally it isn't something you should care about at all tbh

smoky anchor
#

Today I learned

slender elbow
#

what are you doing

rough ibex
#

over 64KB

smoky anchor
# slender elbow what are you doing

I have a http response that had 181k characters
Wanted to store it somewhere so I can easily test my code and not request this each time :D

#

Specific version please

#

ItemFlags should still work I believe

thorn isle
#

it's itemflags across all the versions but some of them don't work in .4 any longer

#

iirc hide_attributes

smoky anchor
#

Mojank keeps on changing how the tooltip hiding works and I get confused.

thorn isle
#

i think .4 might actually be in an awkward spot where there is no set of flags that hides everything because that's added in .5, and attributes got removed in .4

smoky anchor
#

Don't attributes have it per-attribute in that version ?

thorn isle
#

there's like a new component that hides the lore bits from specific components

smoky anchor
thorn isle
#

hm yeah that seems about right

#

not sure if there's api for that

smoky anchor
#

but it's not per-attribute as I was thinking

thorn isle
#

i've resolved myself to not think about it until .5

smoky anchor
#

I'd hope the API just sets this flag with the ItemFlags

thorn isle
#

Removed the show_in_tooltip field, replaced by tooltip_display component

#

yeah that got removed in .5 again

#

🤡

#
    tooltip_display component
        This component allows the tooltips provided specifically by any given item component to be surpressed.
        This replaces the previous show_in_tooltip fields, hide_additional_tooltip and hide_tooltip components.
        Format: object with fields:
            hide_tooltip - boolean (default: false).
                If true, the item will have no tooltip when hovered.
            hidden_components - list of item component ids (default: []).
                The tooltips provided by any component in this list will be hidden.
                If that component provides no tooltip, it will have no effect.
#

this seems like the better solution to me however

#

hopefully they don't keep changing it back and forth any more after .5

smoky anchor
#

Ah, ofc
I don't think you can hide the default ones
So just copy the default ones (There's a method to get them in Material) and then you can hide them I guess

chrome beacon
#

You're using Paper

#

That's a behaviour difference

#

On Spigot just setting the flag will work

#

Yeah you already found the fix

#

You need to add an attribute

thorn isle
#

ask on the paper discord

chrome beacon
#

🤔 It should

#

Yes

#

Still running Paper?

blazing ocean
#

kek

fickle spindle
#

there is a way to get on all the player the one with the most mined block?

thorn isle
#

among online or all players?

fickle spindle
thorn isle
#

iirc paper lets you access offlineplayer statistics

#

but i don't think there is a "break any block" statistic; there's an individual one for each block type

thorn isle
#

neat it's on spigot

wet breach
fickle spindle
#

ye but how can i check all the players and like every 5 min get the one with the most mined block and do something

thorn isle
#

i don't think you can use that without an associated Material, though

wet breach
#

now all you have to do is query your offlineplayer cache/directory and gather the stats for each player you have

thorn isle
#

like i'm pretty sure the game just doesn't store the aggregate

wet breach
#

once you have all the stats, recommended to put it in a DB

#

and then from then on, you would track the stats when they are online

fickle spindle
#

how can i do a task every 5 min? i never done that

wet breach
#

don't need a task to check once you have all the stats in a DB

#

just need this event

thorn isle
#

i suppose you could loop over all materials but that's going to take a while

grim hound
#

uh

#

is proguard a gradle plugin?

#

cuz uh

compact haven
#

So I'm essentially doing

var inv = player.getInventory().getContents();
.. logout sequence
.. login sequence
player.getInventory().setContents(inv);

and it doesn't restore the inventory. Does this make sense?

thorn isle
#

itemstacks are liable to be mutable

compact haven
#

Ah that's what it is, I just went further in the debugger

#

ugh I hate mutable software, a clone on each ItemStack will suffice, yeah?

thorn isle
#

myeah

#

or arrays.deepclone

compact haven
#

''preciate it, will test

grim hound
#

why the proguard plugin not found?

remote swallow
#

might need to add a different repo

thorn isle
#

ProGuard is a command-line tool that reduces app size by shrinking bytecode

#

Repositories: Central, Kyligence Public

#

should be on maven central

#

do you have maven central declared in your repo list?

thorn isle
# grim hound cuz uh

you have very conveniently omitted the list of places it searched from in your screenshot

thorn isle
#

declare maven in youre repositories list

grim hound
#

didn't quite

#

work

thorn isle
#
repositories {
    mavenCentral()
}
#

maven is special

grim hound
thorn isle
#

gradle has a builtin shorthand for maven central

#

god only knows then

compact haven
#

Seriously confused how the game wants it both ways.

[17:30:02 INFO]: SchoolTests lost connection: Disconnected
[17:30:02 INFO]: [PTCombat] [STDOUT] DIAMOND_SWORD x1
        boolean keepInventory = plugin.config().keepInventory.get();
        ItemStack[] playerInventory = player.getInventory().getContents();
        for (ItemStack item : playerInventory) {
            if (item == null) continue;
            if (item.getAmount() == 0) continue;
            System.out.println(item.getType() + " x" + item.getAmount()); # DIAMOND_SWORD x1
        }

        for (int i = 0; i < playerInventory.length; i++) {
            if (playerInventory[i] == null) continue;
            if (playerInventory[i].getAmount() == 0) continue;
            playerInventory[i] = playerInventory[i].clone();
        }

        Log log = new Log(
                System.currentTimeMillis(),
                player.getLocation(),
                playerInventory,
                !keepInventory,
                combatService.remainingCombatDuration(player),
                npc
        );

        if (!keepInventory)
            player.getInventory().setContents(new ItemStack[0]);

        players.put(playerId, log); # BREAKPOINT
grim hound
#

wait, what's this

#

nvm, didn't change nothing

grim hound
thorn isle
#

considering how its a bytecode obfuscator, almost surely yes

#

but it looks like that plugin might not be the same i linked

grim hound
#

is there supposed to be a change to settings.gradle?

thorn isle
#

try changing it to com.guardsquare.proguard-gradle

grim hound
#

also, why does my intellij hallucinate 3 tasks on each reload

#

the most upper one exists

#

the other 2 don't

young knoll
#

Yeah idk

thorn isle
#

i can't find a com.guardsquare.proguard under the guardsquare group, only proguard-gradle

#

maybe the artifact name was changed since someone last looked at the build script?

compact haven
compact haven
#

Very annoyed. Debugger just can't track that information I guess because it is being cloned properly in memory.

#

player.getInventory().setContents(log.inventory); I believe that Inventory#setContents is the culprit. Not sure why.

young knoll
#

Have you tried delaying the setContents by a tick

compact haven
#

I'm doing that now but by 30 😂

#

yep that worked. that's ridiculous?

#

it's definitely operating sync and the inventory should be loaded by the time PlayerLoginEvent is fired, no?

manic delta
#

What is the best way to save #Blocks in a list and then reset them to the natural state? I want to make a minigame where they can build and I want to reset it

#

I mean the most optimized, practical and lag-free way.

worldly ingot
#

You could take an alternate approach and start the world fresh on startup. Just in your server's startup script, copy/paste world files from a clean directory

#

Unless you want to do this all in the same instance. In which case just a List of some object that holds a type holding the block's x/y/z position and BlockData

#

Or BlockState if you need to maintain the state of block entities like chests or whatnot

manic delta
#

I mean, when the minigame ends, what would be the best way to restart it?

#
public void resetArenaAsync() {
    List<Map.Entry<Location, BlockData>> entries = new ArrayList<>(arenaBackup.entrySet());
    new BukkitRunnable() {
        int index = 0;
        final int batchSize = 20;

        @Override
        public void run() {
            for (int i = 0; i < batchSize && index < entries.size(); i++, index++) {
                Map.Entry<Location, BlockData> entry = entries.get(index);
                entry.getKey().getBlock().setBlockData(entry.getValue(), false);
            }

            if (index >= entries.size()) {
                arenaBackup.clear();
                cancel();
            }
        }
    }.runTaskTimer(plugin, 0, 1);
}

Something like this?

worldly ingot
#

Run through the list of blocks and restore. I'm not sure I understand what your road block is 🤔

private record FormerBlockState(int x, int y, int z, BlockData blockData) {

    private FormerBlockState(Block block) {
        this(block.getX(), block.getY(), block.getZ(), block.getBlockData());
    }

    public void restore(World world) {
        world.setBlockData(x, y, z, blockData);
    }

}

private final List<FormerBlockState> states = new ArrayList<>(256); // Give it an initial size to avoid resizing

@EventHandler
private void onBlockBreak(BlockBreakEvent event) {
    this.states.add(new FormerBlockState(event.getBlock());
}

public void restore(World world) {
    Iterator<FormerBlockState> iterator = states.iterator();
    while (iterator.hasNext()) {
        iterator.next().restore(world);
        iterator.remove();
    }
}
#

Something like that maybe. Though it should be noted that there's more than just block placements that mutate the world

young knoll
worldly ingot
#

You'd have to handle things like explosions, block placements, maybe fluid handling as well

compact haven
#

sorry haha Join

#

that was off the top of my head

#

Login is async no?

young knoll
#

A lot of things just don’t like running in the same tick as events

#

¯_(ツ)_/¯

manic delta
worldly ingot
#

Then what I sent would probably work. How you choose to call the restore() method is up to you if you want to do it in a task or whatever

young knoll
#

We should make BlockFromToEvent fire for every block change

worldly ingot
#

Can pass false to the physics parameter too, which I didn't do

young knoll
#

A true BlockFromToEvent

manic delta
worldly ingot
#

I think you'll be okay. You're not doing anything too crazy. Depending on how many blocks are in your list, you might want to spread out your block placements over time, but you need to be in like the tens of thousands of blocks territory before that even becomes beneficial

manic delta
worldly ingot
#

That's probably fine

#

For comparison's sake (and maybe not an amazing comparison because this is Hypixel hardware lol), we set between 10,000 - 20,000 blocks every 5 seconds or so in the Disasters mode for a flood without a crazy amount of batching

#

In fact the batching was worse performing on the server

manic delta
#

"we set between 10,000 - 20,000 blocks" you work there?

worldly ingot
#

Yes

young knoll
#

That’s impressive for a bunch of intel atom processors running in Simon’s basement

manic delta
#

thats cool

manic delta
worldly ingot
#

Yeah. You should only need batching if you try it and realize "Oh shit I need batching" lmao

#

At which point you can throw it into a task and do like 500 blocks every 5 ticks or so

young knoll
#

Make it dynamic by measuring the time you have left in a tick

#

Oh wait there isn’t really a way to calculate that :(

pliant topaz
#

paper got an event for that iirc but spigot sadly not

drowsy helm
#

I feel like the overhead for that wouldn't be worth it anyway

pliant topaz
#

In my experience it's around 20-25k blocks per remaining time per tick usually (if there are not any other heavy tasks running)

thorn isle
#

not just an event but also a getter for a rolling average of mspt for the past 1,5,10 minutes or something along those lines

pliant topaz
#

(ofc that isnt really a normal thing to do but at that scale it sure makes a difference)

thorn isle
#

i tend to batch my block setting operations per chunk anyway for getChunkAtAsync

pliant topaz
#

interesting

#

i used a work distribution system

thorn isle
#

i mean the main goal is to not trigger sync loads and to keep the logic simple (not having to load and wait for an entire set of chunks to be loaded before proceeding) but it also doubles as work distribution since the work usually is spread over several chunks

pliant topaz
# pliant topaz i used a work distribution system

single workloads in a deque for example to replace a single block, each being really minimal and taking no time alone. Then, when the tick operations finished as many of these queued workloads are done before the next tick begins

pliant topaz
cinder abyss
#

Hi, what's the best way to compare versions to check if the server runs on newer/older than 1.x.x ?

chrome beacon
#

TLDR use Bukkit.getServer().getBukkitVersion() if you want to detect old versions

cinder abyss
chrome beacon
#

Simply split the version string

#

and then check each part as an int

cinder abyss
#

is there a lib that do that pretty well ?

chrome beacon
#

hm? do you need a lib? it's like 20 lines of code

molten hearth
#

this isn't js we don't just have nice things as libraries

fallow ruin
#

Anyone knows how I can change a players skin in my code?

cinder abyss
young knoll
#

I mean technically there are libraries for that

young knoll
#

You can’t change blocks async

manic delta
#

oh

#

so sync?

manic delta
worldly ingot
#

You'd be surprised how well the server operates in the grand scheme of things

manic delta
#

good damn

worldly ingot
#

Once you sit for a minute and realize what all the server has to process 👀 It's crazy it can still do it in like < 5ms/tick

thorn isle
#

well it's only like a few levels of indirection and a few addition/division/multiplication instructions and a write to some long array somewhere

manic delta
worldly ingot
#

Entity AI, block entities, world generation, etc.

thorn isle
#

it gets more expensive with every additional level of complexity mojang adds in the stack but it's still relatively simple

#

it's less about the language and more about the code

worldly ingot
#

To a degree though, lower level languages are objectively faster because it has less to process

#

But yes, you can still write some well optimized Java code :p

thorn isle
#

well... the jit is pretty magical

remote swallow
#

Cough hypixel

thorn isle
#

i did benchmark C style palettedcontainers where the magic multiply division operations were compiled with individual coefficients for each palette size

#

it was pretty much 1:1 to warmed up and fully jit'd java palettedcontainer

worldly ingot
#

What do you do for work, vcs?

thorn isle
#

i'm a farmer

worldly ingot
#

I tell you what, I'd believe that

sullen marlin
#

Yeah java is surprisingly big amongst HFT firms

worldly ingot
#

After all, it runs on like 6 billion devices!

remote swallow
thorn isle
#

mostly wheat

drowsy helm
thorn isle
#

other years rye and such

remote swallow
#

Damn

manic delta
thorn isle
#

last year i had beets

remote swallow
#

What colour you drive

thorn isle
#

i have a few valmets and fords

remote swallow
#

Dayummm

thorn isle
#

only other color I have is a john deere combine

remote swallow
#

Any animals or just crop

drowsy helm
#

Farmer/programmer is an interesting mix lol

slim wigeon
#

As a note, you talking on #help-development . I telling you this as this is should be taken to #general .

thorn isle
#

look at mr mini mod here

thorn isle
#

just crops, animals haven't been profitable since we joined the eu

remote swallow
#

Kek

thorn isle
#

used to have pigs

slim wigeon
worldly ingot
#

I asked only because any time I see you answer a question, you seem knowledgeable and explain yourself well. Rare from an unverified user (that I was going to say joined recently, but you've been here since very early lmao)

slim wigeon
thorn isle
#

i've been lurking for a while

wet breach
remote swallow
slim wigeon
#

But if someone for ever reason is stuck on 1.19.3, ViaVersion will help you

wet breach
#

To an extent

slender elbow
#

people really underestimate how fast java can be

wet breach
slender elbow
#

yeahh lol

thorn isle
#

i think it's probably more like people underestimate how fast computers are these days

remote swallow
#

Gotta get them micro optimizations in

#

Muh cpu cycles

wet breach
slim wigeon
slender elbow
#

like, it ain't python 💀

#

hotspot ❤️

thorn isle
#

oh yes, even just since java 8 which is prehistoric for current plugin developers, performance has improved considerably

drowsy helm
#

Other than JVM overhead, I'm still a firm believer that java is the best all-rounder language out there

wet breach
thorn isle
#

to a remarkable extent, too, e.g. since j9, for loops accessing arrays doing simple arithmetic operations are automagically replaced with simd instructions where applicable

#

well, on some hardware, unless you do something the jit doesn't expect (like unroll it manually); it's still quite fragile

wet breach
#

Yeah i dont miss the early java days or some of the older versions where some stuff was just in code

thorn isle
#

and it's difficult to make well-informed a assumptions about what is actually going to happen at runtime

#

still remarkable for what it is

slim wigeon
#

I wonder if its possible to run the server on NodeJS. I know I can use exec("java.exe") but I talking about the server fully written on NodeJS

drowsy helm
#

spigot serveR?

slim wigeon
#

Any server. Spigot or Paper

drowsy helm
#

well it wouldn't really be spigot or paper if it was written in another lang

#

but its definitely possible, just a massive project

slim wigeon
#

Or these other servers owned by Paper such as waterfall

wet breach
drowsy helm
#

or if you mean api abstractions in another lang, thats been done

thorn isle
#

there's probably an impl for every language there is

wet breach
#

Probably

molten hearth
#

There's flying-squid but its quite dead although there's a more active typescript rewrite

thorn isle
#

writing a minecraft server in x is to languages kind of like "does it run doom" is to hardware

wet breach
#

We have c, c#, c++, php, python, haskell from when someone ran it on a mainframe

drowsy helm
#

rust aswell

#

It's more a question of why, than how

wet breach
#

Yeah i did like the c++ one even though it was short lived

#

Maybe i will do another one at some point.

slim wigeon
#

If it was written in NodeJS, we won't have to compile our plugins

wet breach
#

Compiling isnt really a big deal

slim wigeon
wet breach
#

Scripting languages can be compiled just fyi.

manic delta
thorn isle
#

we won't have to list up on server lists either because the server will crash and burn at 5 players when it's running in any sort of interpreter

wet breach
#

Python is an example of an interpreted language that can be compiled even if not required

chrome beacon
#

Not that hard to make a quick plugin loader that loads .java files if that's what you really want

wet breach
chrome beacon
#

You can call the compiler on the file and then load that in to memory

wet breach
#

Yep

chrome beacon
#

Not that much code either

slim wigeon
thorn isle
#

usefulness would mostly be limited to dev

#

but we have hotswapping and other ide magic for that

thorn isle
#

java doesn't really lend itself well to being a scripting language i don't think

#

was that iterator on an arraylist

#

because if it was each of those remove()'s is going to shift the entire underlying array left by 1

jagged thicket
#

yo vcs2 how big is your farmland

manic delta
jagged thicket
#

also do u play farming simulator

thorn isle
#

no i do enough sitting in a tractor irl to not have to sit in a virtual tractor

#

i also don't play euro truck simulator

jagged thicket
#

i gotta get enough money asap and buy farmlands b4 all lands get occupied

thorn isle
#

don't bother, it's probably the least rewarding profession ever

wet breach
jagged thicket
thorn isle
#

you run the numbers and you might as well invest in stocks for similar returns and less risk and no work

jagged thicket
#

it could be a good investment no?

thorn isle
#

only makes sense if you inherit the equipment and a bunch of land

wet breach
jagged thicket
#

yeah makes sense

thorn isle
#

they say land never loses value but if farming is run-down by regulation or other economic concerns, land becomes next to worthless as well

thorn isle
# manic delta wym

removing from an arraylist shifts every subsequent element left to fill the "hole" left behind by the removal

jagged thicket
#

can it not be used for housing? or is irrigation damage too much

manic delta
thorn isle
#

it can, but housing only pops up near existing population centers

wet breach
manic delta
#
val regen: MutableList<FormerBlockState> = mutableListOf()

@EventHandler
    fun onBlockPlace(event: BlockPlaceEvent) {
        val player = event.player

        if(challenger.equals(player) || opponent.equals(player)) {
            if(status != ArenaStatus.WAITING) return
            if(!flags.contains(ArenaFlags.NO_BUILD)) return
            val block = event.block
            regen.add(FormerBlockState(block.x, block.y, block.z, block.blockData.clone()))
        }
    }

fun restore(world: World) {
        object : BukkitRunnable() {
            var iterator: MutableIterator<FormerBlockState?> = regen.iterator()
            val batchSize: Int = 500

            override fun run() {
                val startTime = System.nanoTime()
                var i = 0
                while (i < batchSize && iterator.hasNext()) {
                    iterator.next()!!.restore(world)
                    iterator.remove()
                    if (System.nanoTime() - startTime > 50000000) {
                        break
                    }
                    i++
                }
                if (!iterator.hasNext()) {
                    cancel()
                }
            }
        }.runTaskTimer(UltimateDuels.get, 0, 5)
    }
slim wigeon
#

Be careful letting people do the work for you. Because they can throw code in there and send a take down request, that is one of the reasons my code is not going to github

manic delta
#

thats all of it

thorn isle
#

and the land prices for such areas are sky high precisely because of the opportunity to wait 20-30 years and be able to sell it for construction

jagged thicket
#

Yeah land overtakes gold sometimes if you wait long enough

thorn isle
#

and if you get it in the right place

slim wigeon
#

And if soneone needs help, you might cannot help them as you did not write the code

thorn isle
#

for farming, though, you'd be looking for land in the middle of nowhere

slim wigeon
thorn isle
#

you'll have turned your O(n) list iteration into O(n^2)

jagged thicket
#

im sure no one here is doing that

wet breach
#

So dont spread misinformation on stuff you are not familiar with

#

I was a bukkit dev staff member around the time all this went down so i am quite aware of the facts

manic delta
thorn isle
#

you could use that well but i'm not sure why you're removing from the iterator in the first place

remote swallow
manic delta
#
fun restore(world: World) {
    object : BukkitRunnable() {
        val batchSize = 500

        override fun run() {
            val startTime = System.nanoTime()
            var i = 0

            while (i < batchSize && regen.isNotEmpty()) {
                regen.pollFirst()?.restore(world)
                if (System.nanoTime() - startTime > 50_000_000) break
                i++
            }

            if (regen.isEmpty()) cancel()
        }
    }.runTaskTimer(UltimateDuels.get, 0, 5)
}
slim wigeon
slim wigeon
wet breach
#

Then dont speak on subjects you are not familiar with

remote swallow
#

You getting dmca is very very very slim

wet breach
#

That is how misinformation gets spread around

#

Since github did not receive a anything to challenge the dmca github had no choice but to move forward with the request

remote swallow
#

Almost everyone here has a github and uses it a lot, and getting a dmca is very low chance

thorn isle
#

i have a different github account for every project i'm involved in

wet breach
#

This is what happened with bukkit on github no one challenged it officially

drowsy helm
slim wigeon
# wet breach That is how misinformation gets spread around

Well, we don't exact to know everything. I also not showing the code because people here. I would sometimes surprised when someone helps me. Like I had this hopper filter system issue and still a issue today. I just managed to stabilize it until I get help with it

wet breach
jagged thicket
#

@slim wigeon what is the password for u website

#

it is asking username and password 💀

thorn isle
#

also what is your credit card number

slim wigeon
#

No, not open

jagged thicket
slim wigeon
#

I locked it because I still working on it, leave it alone

jagged thicket
#

alrrr i will leave it alone

slim wigeon
#

If you want to look at it when its open, I can tell you. Otherwise, I don't need anyone there

placid estuary
#

is there any event for or way to tell when an autocrafter is used to craft an item?

chrome beacon
placid estuary
#

thank you

compact haven
#

hello am going crazy again. I have a gitlab project and I've verified I have an uploaded package because

C:\Users\Dominick>curl -H "Private-Token: REMOVED" https://gitlab.com/api/v4/projects/REMOVED/packages/maven/groupid/artifactid/maven-metadata.xml

return proper metadata, but maven is refusing to find it on install...

my pom.xml, abridged: https://pastes.dev/hIcAtahWOt
my settings.xml, redacted: https://pastes.dev/lgNcxa90Ti

#

Oh, and this warning:
[WARNING] Failed to download REMOVED-2.0.2.jar [https://gitlab.com/api/v4/projects/REMOVED/packages/maven/]

sullen marlin
#

I've never seen http headers used with maven, presume you took it from somewhere?

#

Make sure maven is up to date

worldly ingot
#

GitLab does. Though that configuration looks fine to me

#

I remember there being a setting somewhere in GitLab that like... disables the ability to pull artifacts from a specific repository or something. It's per-project and I think defaults to excluding a project from Maven artifacting. I don't remember what it is

#

Stupidest fucking setting ever, but I remember that being a pain point when I worked with Visionary

slim wigeon
ivory sleet
#

I mean yea repositories

slim wigeon
#

Does it cache these?

eternal oxide
#

maven caches to your local repo

valid burrow
slim wigeon
valid burrow
#

it caches them

#

in your local repo

#

like elgar said

#

unless you run with the -U flag

#

which tells maven to redownload them regardless

slim wigeon
# valid burrow in your local repo

Just checking. I got unlimited data on my hotspot so I don't care either way but when I connect to my mom's internet service, that is where it needs to use the cache files first or my mom would get a call due to high usage. Just saying

#

Data caps are annoying

ivory sleet
#

would be pretty silly if it redownloaded them everytime

blazing ocean
#

who needs caching anyway

valid burrow
#

^

#

if you aren’t exactly writing your own api‘s then you will almost never have to use the -U flag

blazing ocean
#

i mean just version stuff

valid burrow
#

or if the author of the api you are using doesn’t understand the concept of versioning

valid burrow
blazing ocean
#

just use modules and depend on other modules

slim wigeon
valid burrow
valid burrow
#

with -U flag

#

assuming you got about 15mb of depedencies

#

which is decent

slim wigeon
valid burrow
#

and unless you force update them it will keep using them

#

well

#

or you change the version

#

im which case it will try to download the new version obviously

compact haven
#

you downloading the jar has roughly the same impact as maven downloading the jar

blazing ocean
# grim hound

it literally tells you how to set it up in the readme....

blazing ocean
#

you need it in your buildscript repos

grim hound
#

I am blind

grim hound
blazing ocean
#

no

grim hound
#

Ah

#

Okay

placid estuary
#

how come these recipes don't work? i tried a test recipe with some different materials in the same place and it worked fine, but these just don't function
the log statements are also working fine
also no errors

code:
https://paste.md-5.net/colowigose.java

mental drum
#

WHy hasnt this updated? Ive put 3 updates since my original release

#

Like whys it still say version 2024? Ive made 3 resource updates since, 1 was today

slim wigeon
#

I don't really know how spigot update system works but something tells me that this is the original release date. If I wrong, please tell me

eternal oxide
#

did you update the version when you posted the update? show your updates tab

slim wigeon
pseudo hazel
#

I think they mean versions tab

eternal oxide
#

mine is fine. somethign fishy with yours

pseudo hazel
#

but that version 2024 etc is a version you assign

eternal oxide
#

yep

#

when you post an update there is a pulldown/edit box you can update teh version

#

I guess you are just doing the title and not the version

#

If you don;t change the version string it defaults to your current

mental drum
# eternal oxide

Holy shit, congrats on the success my guy. What plugin is this?

eternal oxide
#

small numbers. Used to be millions 😉

smoky anchor
slim wigeon
#

Yes, that

smoky anchor
slim wigeon
#

No, I want to freeze it when its not smelting anything

smoky anchor
#

Yes, if the input slot is empty
That's what I said

slim wigeon
#

I just got this public void onFurnaceSmelt(FurnaceSmeltEvent event) { ItemStack item = event.getResult(); item.setAmount( item.getAmount()*2 ); }

#

Don't mind the doubling, its unrelated

smoky anchor
#

My only idea is to have a ticking task with a list of Locations of furnaces
give the furnaces a PDC with the value of lit time remaining they should hold
And then just keep on setting it back to that ?
Or something like this.

#

I doubt there is a way to freeze it properly.

slim wigeon
#

If there is not a easier way, its ok. I will see how Songoda does it, I was thinking you should know

smoky anchor
#

That is not something I should nor care about knowing

#

But I am curious :D What plugin of theirs are you copying ?

slim wigeon
#

Is that a question directed towards me? If it is, I not trying to copy anything. If anything, I asked for a paid plugin jar I don't remember when, that plugin is JetsHoppers, it has features of EpicHoppers but without BlockBreak. So I would not recommend trying to say I copying stuff

#

As a note, I can use any Songoda plugins but before, there was bugs and I was annoyed so I started working on the plugins

slim wigeon
#

I want to freeze the time remaining when its not smelting anything