#help-development

1 messages ¡ Page 1194 of 1

pseudo hazel
#

lol

#

ominous

chrome beacon
#

but ig if it's user input 🤷‍♂️

young knoll
#

The default impl lower cases it, replaces any spaces with _, and then tries to parse it as a namespace key

#

If it doesn’t have a namespace minecraft is assumed

blazing ocean
#

wait are registries modifiable

glossy laurel
#

why would they be modifiable

chrome beacon
blazing ocean
#

exactly

glossy laurel
#

what

blazing ocean
#

so what if I try to register a new block

chrome beacon
#

Won't work

blazing ocean
#

rip

chrome beacon
#

Not all registries are fully modifiable yet

blazing ocean
#

do bukkit registries just pull from NMR registries?

chrome beacon
#

Mojang is working on it

young knoll
#

Yes

glossy laurel
young knoll
#

Also no registries are modifiable while the server is running

#

It all has to be done very very early

blazing ocean
glossy laurel
#

nvm

#

nvm

#

nvm

blazing ocean
young knoll
#

You can do custom blocks server side

#

But you need to lie to the client or it'll freak out

blazing ocean
#

yeah, polymer my beloved

#

i kinda wanna make polymer for spigot but that'd require a fork

young knoll
#

fork of what

blazing ocean
#

of spigot

young knoll
#

why

blazing ocean
#

polymer needs mixins

#

and you can't do all stuff it does with events

#

they modify outgoing packets afaik

young knoll
#

Packet listener

blazing ocean
#

well, packetevents, I guess

glossy laurel
#

What happens when one constructs a PotionEffect with negative or greater than 255 amplifier?

chrome beacon
#

Usually no point in doing so

glossy laurel
#

and when applying such effect it would error too?

chrome beacon
#

Try it and see

glossy laurel
#

:/

#

?tas

undone axleBOT
undone summit
#

Hello, I'm having some problems importing a JAR into my project. this is the error i get when compiling. (I get all the classes from the JAR with autocompletition and i have analyzed the dependency and it reads it). I have added the JAR under the project settings, on the modules dependencies.

chrome beacon
#

Sounds like you added the dependency to Intellij and not Maven

#

And then attempted to compile with maven

#

You should be specifying all your dependencies in your pom.xml

glossy laurel
chrome beacon
#

Yes Artifacts exist

#

You can build without Maven/Gradle

#

It's not recommended though

undone summit
glossy laurel
#

Can a player have Strength 2 for 1 minute and Strength 1 for 2 minutes so that when Strength 2 expires they still have Strength 1 for 1 min?

strange copper
#

I made a small placeholder since I am not at home, but does this look good for only handling an increase in charge?

public abstract class Ultimate extends Attribute {

    public float ultimateCharge = 0;
    public float ultimateMaxCharge;
    public float ultimateChargeAdd;
    protected double delay;

    public boolean enabled = true;

    public Ultimate(float ultimateMaxCharge, float ultimateChargeAdd, double delay) {
        super();
        this.name = "Ultimate Charge";
        this.ultimateMaxCharge = ultimateMaxCharge;
        this.ultimateChargeAdd = ultimateChargeAdd;
        this.delay = delay;
        task = this.runTaskTimer(plugin, 0, (long) delay);
    }

    @Override
    public void run() {
        if (ultimateCharge < ultimateMaxCharge) {
            this.ultimateCharge = Math.min((ultimateCharge + ultimateChargeAdd), ultimateMaxCharge);
        }
    }

}
chrome beacon
#

the ultimate prefix is kind of redundant on those variables

echo basalt
#

I feel like it has no need to be an abstract class that extends attribute

#

all you're doing is passing a couple params so they can be detached

strange copper
#

I'm sorry, when should I use abstract and when not?

echo basalt
#

In short there are 2 main approaches: Composition and Inheritance

#

Composition in most cases is the better one. It allows things to be decoupled and individually testable

#

For example, let's talk about entities so you have a better idea

strange copper
#

Basically this Ultimate class will stand as a base for abilities that fall under this class

echo basalt
#

Mojang's implementation uses inheritance.
You start with a base entity and you extend it to a LivingEntity to implement a couple features like health
Mobs extend LivingEntity and implement Pathfinding etc etc

#

A different approach is to use components. You start with a base entity that just holds a bunch of components and each feature you want to attach is a component

chrome beacon
#

Most game engines use component systems ^^

echo basalt
#

So you can have a "health component" that tracks health, max health and damage, or a position component that tracks position

#

You can then attach logic to these components so that you can have a "pathfinding component" that tracks the path and updates the position

#

Your abilities can also use a modular approach like that

strange copper
#

This is all very confusing to me im sorry haha

echo basalt
#

For abilities, you can split them into "triggers" and "actions", with added restrictions

#

So that when a "trigger" is fired, it goes through its restrictions (player has it unlocked, it's charged / off cooldown etc) and runs the actions (damage mobs, do whatever)

#

Decoupling abilities like this will allow you to, for example, make upgraded versions with shorter cooldowns

#

Or abilities that are a mix of multiple ones (heal and teleport)

#

Here's an example of an Entity Component System

strange copper
#

Yeah that makes sense

echo basalt
#

So yeah I'd like you to try to make a component-based ability system

#

Think of cooldown components, charge components etc

#

You can make Tickable components that tick

strange copper
#

I have those things in my Attribute class

echo basalt
#

And add filters to components so their actions are only fired if the player is holding an item etc

ancient plank
#

I need to rewrite my fishing plugin to use components for its tools tbh

lilac dagger
#

I like the idea of components, not sure how performant it is at a grand scale

chrome beacon
#

They can be quite performant

lilac dagger
#

I guess it's just little components

echo basalt
#

Yeah they're tiny and independent

#

The cool thing about components is that you can kinda tick stuff async

#

also the other cool thing is just attaching logic to an entity without stressing

lilac dagger
#

Ye

blazing ocean
#

hey I have async ticking stuff

lilac dagger
#

Mojang is notorious for their huge entity classes 😦

echo basalt
#
entity.addComponent(EntityComponentTypes.CLICK.create { player, context -> 
  player.sendMessage("you clicked on the entity!!")
})
blazing ocean
#

DisplayEntity.java my beloved

echo basalt
#

this is how we do it at work

lilac dagger
#

Pretty cool

blazing ocean
#

that seems kinda cool but also like a pain to implement

echo basalt
#

You can also attach data and stuff

#

it was quite chill

#

took me maybe 2 hours

grim hound
#

I'm trying to apply a .patch file

strange copper
#

Can I fetch a boolean from a different class or do I have to have a local variable

echo basalt
#
entity.addComponent(EntityComponentTypes.HOLDER.create<String>("hi"))
val text = entity.getComponent(EntityComponentTypes.HOLDER.getType<String>())?.contents ?: ""
#

type shit

grim hound
#

which worked fine previously

grim hound
#

but now intelliJ just doesn't save the changes?

#

wtf

echo basalt
#

?di

undone axleBOT
blazing ocean
grim hound
#

yes

#

I manually did it

blazing ocean
#

they put it in a different change list for some reason

grim hound
#

twice now

#

and it changed a total of: 1 file

#

out of like 25

strange copper
# blazing ocean ...functions?

I am using a function, the problem is that I cannot access the boolean from the other class because it tells me it's not a statement

#

Am I blind

grim hound
#

this

#

did not expect the pic

#

anyhow

grim hound
#

downloaded the .patch

#

intelliJ asked me for each class

#

said yes

#

it didn't apply

#

wtf

#

I changed the general package name but the patch from before applied just fine

blazing ocean
#

try applying it with git

grim hound
blazing ocean
#

try applying it with the git CLI

#

git apply <patch>

grim hound
grim hound
blazing ocean
blazing ocean
grim hound
#

and that's cuz

blazing ocean
#

well

#

yeah

grim hound
#

this is my package

blazing ocean
#

you also need to navigate to your project directory

#

your home dir won't cut it

grim hound
blazing ocean
#

cd <dir> 😭

brittle geyser
blazing ocean
#

why

chrome beacon
#

as long as you're consistent it's fine

grim hound
#

I'll rename them to commandss

brittle geyser
#

no

grim hound
#

whatchu gonna do

brittle geyser
#

?

grim hound
#

I'm renaming them to comandsss

brittle geyser
#

no you dont

blazing ocean
#

I mean, I have commands, utils, resourcepacks, all plural for multiple things

brittle geyser
#

cringe

blazing ocean
#

why?

#

because you don't like it?

worthy yarrow
#

Aren’t you the goon who spam dmed people to use your api?

jade oasis
#

?paste

undone axleBOT
blazing ocean
#

it's literally personal preference

blazing ocean
#

blue kat :c

worthy yarrow
#

I been blue

brittle geyser
worthy yarrow
#

Just haven’t been around lately lol

blazing ocean
#

you haven't been very active

pliant topaz
blazing ocean
worthy yarrow
pliant topaz
#

i mean yea, generally most of the time its singular, but still

#

it can be plural too

blazing ocean
worthy yarrow
#

Well that was only cuz I was spraying chemicals

#

Not an everyday thing unfortunately

grim hound
blazing ocean
#

that was the guy who dmed everyone about his shitty api

#

"brand new advancedAPI"

#

like same bro

#

my api is also so advanced

sterile breach
#

I save in a class several info about players (inventory, enderchest, life, xp, etc...) in sql. Should I first convert the itemstack and other thing in the class to base64 and then convert the class to base64, or can I convert the class directly?

lilac dagger
#

Base64 is not useful in sql

sharp bough
#

i think you can convert quite a few of those things into blob and even combine them all into a single blob

lilac dagger
#

I just save my stuff as json in a TEXT type

blazing ocean
#

i mean you can store it as a string ig

lilac dagger
#

Is blob a data type?

blazing ocean
#

pretty sure pg has one

sharp bough
#

blob is binary for sql

#

like doing outputstream into file

#

but into sql databse

sterile breach
#

why???

lilac dagger
#

I never used this hmm

sterile breach
#

is it more optimized to simply convert with gson?

sharp bough
#

its actually really useful

lilac dagger
#

It sounds cool

sharp bough
#

you already have your instance of itemstack (and a few more things) that are technically blob

blazing ocean
#

I've not really had the need to store blobs in my database yet

#

I've done items with base64 in mongo before

#

but not for this

lilac dagger
#

I just have a json column for options

sharp bough
#

yea that also works, i just like this bc i feel its cleaner

blazing ocean
#

pretty sure pg even has a json type

remote swallow
#

item as blob >>

sharp bough
#

less gooo

sterile breach
#

why isn't it a good idea to store as base64?

sharp bough
blazing ocean
#

it isn't a bad idea

sharp bough
#

blob will take the binary of the instance of the itemstack and save that

glossy laurel
#

isnt base64 more space consuming

blazing ocean
#

not necessarily

sharp bough
#

base64 will convert the itemstack into string and save that

sharp bough
glossy laurel
#

😂

blazing ocean
remote swallow
#

more space more cycles, muh cpu cycles

blazing ocean
#

u128 in kotlin when

lilac dagger
#

I used to use Base64 before, not worth it

sharp bough
#

sounds unique

#

lmfao

blazing ocean
#

I mean a UUID can be stored in a u128 right?

blazing ocean
#

UUIDs are just two longs

lilac dagger
#

Should be ye

sharp bough
blazing ocean
#

most and least significant bits

sharp bough
#

for the meme?

blazing ocean
blazing ocean
sharp bough
#

or im missing smth

blazing ocean
#

and less efficient

sterile breach
#

blob is sql-specific? can blob content also be stored in redis?

remote swallow
#

i store all my uuids as a string with no dashes

blazing ocean
lilac dagger
#

I just keep my UUID as the string representation

remote swallow
#

blob is just a byte array basically

sharp bough
#

💯

blazing ocean
#

no

#

<init> >>>>

sharp bough
#

i just create 1 column for each individual character of the uuid and combine them when i fetch it

lilac dagger
#

The space it saves isn't worth it

sharp bough
#

s/

sterile breach
#

for my system, player data must be stored in sql but also sent to other servers (and to the proxy) via a redis broker message

sharp bough
blazing ocean
#
object ScoringEntries : Table("scoring_entries") {
    val playerId = uuid("player")
    val gameType = varchar("game_type", 255)
    val session = uuid("session")
    val score = integer("score")
    val bonusScore = integer("bonus_score")
    val multiplier = double("multiplier").default(1.0)
}
``` I wonder whether exposed's UUID type is just a string or two longs
#

I would need to check, but am on my phone

#

actually it's a string, I remember putting in my UUID there

sterile breach
lilac dagger
#

Nice ^

remote swallow
#

id probably just use redis to tell the server to freeze the pre login untill the data is saved and it can load it

sharp bough
lilac dagger
#

Forwarding the data is a nice way to prevent loss of data, duplications

sharp bough
#

bc you could simply save -> transfer -> load all in sql

#

if save fails cancel transfer

#

if load fails cancel login

echo basalt
#

Redisson distributed locks :)

blazing ocean
#

I've never worked with redis

sterile breach
#

yes (i've spent dozens of hours “studying” the best way for synchronization and here's what I've come up with (give me a few minutes to write them all down)

blazing ocean
#

I guess I've never had the need for it

remote swallow
#

i love redis

echo basalt
#

just make an RLock of like

#

player-data-<uuid>

#

Get the lock, save data, unlock

sterile breach
#

so

echo basalt
#

get the lock, load data, unlock

sharp bough
#

synchronize(object) but for redis

echo basalt
#

but it's distributed

sharp bough
#

cool

echo basalt
#

there are other distributed locks

#

redisson just has the simplest impl

wintry anvil
#

How would I show an empty line in a scoreboard?
Ive tried this

       Score line1 = objective.getScore("§7");
       line1.setScore(10);
lilac dagger
#

Spaces work too

#

But it has to be a unique line if you use this idea

lilac dagger
#

You can't have 2 scores that have the same name

sterile breach
#

so

The issue with server switches is that we don’t know when the player leave and player join events will be triggered, so we are forced to "lock" the player on the server while loading/saving their data. For this, we’ll use PacketEvents and set them to spectator mode to prevent them from interacting.

To avoid any problems with concurrency and atomicity, we need a central server to lock the data. Public sync plugins often use a database directly (Redis for the best performance and SQL for simplicity). Then, thanks to the atomic tools provided by these databases (procedures for SQL and Lua scripts for Redis), we can interact with the database while ensuring it’s not locked.

The problem with these plugins is that they are designed to be as simple as possible to set up (so they avoid requiring additional plugins on the proxy). As a result, when a player joins a server, the only way to know when they will be "unlocked" is to continuously query the database to check if the player is locked. Even though this doesn’t cause performance issues if implemented properly, it doesn’t seem very "conventional" to me (correct me if I’m wrong).

So, I implemented a system:
We have an SQL database, a Redis messaging system, our proxy, and our servers.

When a player tries to connect, we lock them and send a message to the proxy saying, "As soon as it’s unlocked, send me this player’s data." If it’s unlocked, the proxy sends it back immediately; otherwise, it sends it as soon as possible. (When the player disconnects, the server sends the player data to the proxy.) Only the proxy interacts with SQL, where it stores copies.

lilac dagger
#

So if you have multiple spaces you need to use different colors for each

wintry anvil
#

So like:

        Score line1 = objective.getScore("§b\n");
        line1.setScore(10);

        Score line2 = objective.getScore("§1\n");
        line1.setScore(10);
```?
sterile breach
remote swallow
#

why not just block in the pre login event

sharp bough
#

have you checked you husk sync?

remote swallow
#

it would freeze them on the loading screen

sharp bough
#

he does a great job at that

sharp bough
#

also has redis sql and idk how many other things

sterile breach
sharp bough
#

depends on how he implemented it, but its likely fine

sterile breach
sharp bough
#

i assume you wont have more than 3 4 players transfering at the same time

echo basalt
#

You can't use a proxy as a central service because people can run multi proxy setups

sharp bough
#

even with 10 its still fine

sterile breach
#

yes, in reality, the husksync system does the job very well, but I've long been intrigued by the idea of making a “perfect sync”

remote swallow
sharp bough
#

theres a lot of cases you need to consider

#

it wont take any less than 2 3 weeks to make

sterile breach
sterile breach
wintry anvil
lilac dagger
#

Use imgur pls

wintry anvil
#

okay sec

lilac dagger
#

That link looks sus

warped escarp
#

Hi guys, I'm trying to create a plugin for Minecraft Java through my cell phone, could someone recommend an application for me?

sharp bough
wintry anvil
sharp bough
remote swallow
#

run a vm that you can open vim on

warped escarp
lilac dagger
#

Don't use \n use a space instead

wintry anvil
#

makes sense..

lilac dagger
#

Pretty sure this is a a visible character

wintry anvil
#

fixed, thx

sterile breach
sharp bough
#

if you do want to do it yourself, for the data you have what we said earlier

#

either byte -> blob -> sql

#

byte -> string -> json -> sql as string

#

and the lock thing for redis

#

im honestly not sure how to serialize all that to redis tho

#

ig string could do it, but idk

sterile breach
#

gson is the solution to all our problems

#

cant I just do
byte -> base64 -> sql as string
?

sharp bough
#

that also works

remote swallow
#

why go to byte array to do b64

sterile breach
#

can I convert it directly in b64?

sharp bough
#

byte is the object instance i assume

sterile breach
#

yes its a class who contain inventory content, enderc, life, xp etc...

short pilot
#

ahem

#

when you have custom mobs and want to store instance variables, can you do that directly in your custom mob's class?

#
public class CustomWitherSkeleton extends WitherSkeleton {

    private static final String TEMP_KEY = "temp";

    public CustomWitherSkeleton(Level world) {
        super(EntityType.WITHER_SKELETON, world);
        this.collides = false;
        this.expToDrop = 0;
        this.goalSelector = new GoalSelector(world.getProfilerSupplier());
        this.targetSelector = new GoalSelector(world.getProfilerSupplier());
        this.setInvulnerable(true);
        this.setCanPickUpLoot(false);
        this.setAggressive(false);
        this.setCustomNameVisible(true);
        this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 1.0D, true));
        this.targetSelector.addGoal(1, new NearestAttackableTargetGoal<>(this, Cow.class, true));
    }
#

similar to this static variable declaration

chrome beacon
#

You can do that if you want

#

but you're responsible for ensuring they persist

short pilot
#

oh jeez

#

how does that work in the api

chrome beacon
#

You can just use PDC tags if you want to make things simple

wet breach
short pilot
#

ive never actually had to worry about this before ah

chrome beacon
#

?pdc

chrome beacon
#

?morepdc

undone axleBOT
sterile breach
sharp bough
clear elm
#

How could i do that my plugin adds for example dirt to the inventory of the player aslong it has space if its full it stopps

chrome beacon
torn shuttle
#

look at all them strings

clear elm
#

i have an for loop and would like to break it when no more dirt can be added how could i do this?

clear elm
#

i did , the stuff it sends me is very weird

torn shuttle
#

?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! 🎉

clear elm
#

..

remote swallow
#

i love an for loop

clear elm
#

wdym

remote swallow
clear elm
#

i mean this

remote swallow
#

im making a joke out of using an not a

clear elm
#

my english is bad sorry

clear elm
undone summit
#

What is the correct way of importing classes and methods from another jar in a project?

chrome beacon
#

You're using maven, correct?

undone summit
#

yup

chrome beacon
#

in both projects?

undone summit
#

yessir both

lilac dagger
#

Then you can add the other project as a dependency

#

And set scope to provided or compile

remote swallow
#

after running mvn install on the project you want to use elsewhere

undone summit
#

yes i've tried that with the intellij guide

#

i've tried a lot of stuff but none worked

lilac dagger
#

Oh yeah, you need to mvn install for the other project to see changes

undone summit
#

adding the jar in a lib folder, adding it in the module dependencies

#

none worked

remote swallow
#

in the first project run the install goal, then in the project you want to use it in add the same info of that project as a dep

#

so the artifact group and version

sterile breach
#

You should add it as a dependecy

undone summit
#

i also added that to the pom.xml, i can autocomplete all the methods and classes but when i compile the plugin it doesn't compile

#

saying that the class doesn't exist

remote swallow
#

you need to shade it

#

add the maven shade plugin

chrome beacon
#

That won't solve the compile problem

undone summit
#

what would solve it?

chrome beacon
#

?paste

undone axleBOT
undone summit
#

sure one sec

chrome beacon
#
    <dependency>
      <groupId>xyz.unhandlederror</groupId>
      <artifactId>TWScoreboard</artifactId>
      <version>1.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
#

Change the artifactId to TWCore

#

You don't want your project to depend on itself

#

but on the core

#

also I recommend removing the dependency you added manually in Intellij to prevent confusion about it auto completing but not compiling

undone summit
#

i get this error: ```xyz.unhandlederror:TWCore:jar:1.0 was not found in https://hub.spigotmc.org/nexus/content/repositories/snapshots/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of spigotmc-repo has elapsed or updates are forced

Try to run Maven import with -U flag (force update snapshots)

chrome beacon
#

Need to run mvn install in the TWCore project

undone summit
#

ok i'll try that

pure dagger
#

what to do if i need my config to be editable through file and through minecraft commands, and others say that reloading and saving every time is too unefficient

chrome beacon
#

everytime what?

#

every time you change a value is fine

#

If it's a config those values aren't going to change too often

pure dagger
chrome beacon
#

It's not ideal but it's probably not worth spending too much time on

pure dagger
#

and it was like a map

#

so its more values

#

than just 1

chrome beacon
#

?

pure dagger
#

list of maps

#
  public void addCommand(String command, String time) {
      reload();
      List<Map<?, ?>> mapList = getConfig().getMapList("commands");
      Map<String, String> map = new HashMap<>();
      map.put("command", command);
      map.put("time", time);
      mapList.add(map);
      getConfig().set("commands", mapList);
      save();
  }```
#

it s this code

chrome beacon
#

How are you using that method

pure dagger
#

its when player uses a command

#

if thats what u ask

#

so not really often actually

undone summit
chrome beacon
#

Do note you'll need to run install every time you make a change that you want to be visible to the other project

chrome beacon
#

also why are you reloading?

pure dagger
#

whu

#

why

pure dagger
#

and i dont wanna override

chrome beacon
#

That's fine then

pure dagger
#

why not fan o f

#

map

#

that map usage

chrome beacon
#

You're mixing types

proper cobalt
#

is there a website or smth where i can listen to a few sounds

#

i need to find some suitable onez

pseudo hazel
#

maybe on the wiki, but the names will probably be different

young knoll
#

You can /playsound in game

proud badge
blazing ocean
proper cobalt
#

thanks

#

can anyone save me some time actually

#

a sound for "good" and one for "bad"

#

i cant find any good ones

remote swallow
#

villager happy, anvil smash

pure dagger
#

what

chrome beacon
#

You have one entry for the command and the next entry for time

pure dagger
#

these are strings ???

chrome beacon
#

Yes they are strings

proper cobalt
remote swallow
#

might be villager ambient

chrome beacon
#

but they contain entierly different types of data (or so I assume)

pure dagger
#

what do you mean

chrome beacon
#

Group them together

proper cobalt
pure dagger
#

different types of data, they are strings ??? isnt string type of data

chrome beacon
#

Wait they are grouped 🤦‍♂️

#

That's just a really odd choice of config

#

Think of your users

pure dagger
#
commands:
  - command: "ere"
    time: "12:20"
#

its this right

chrome beacon
#

yeah

#

That's not a common format for the configs

lilac dagger
#

Misses the second dash and first misses a space

pure dagger
chrome beacon
lilac dagger
#

Is this 1 line?

chrome beacon
#

It's a list of maps

lilac dagger
#

Hmm

chrome beacon
#

That type of config isn't very common

proper cobalt
#

yml supports that

chrome beacon
#

yes

pure dagger
#

so how do you group it usuall

proper cobalt
#

im amazed

#

rare yml W

chrome beacon
#

Users why don't know the yml format will struggle with it

chrome beacon
proper cobalt
#

yml is ass 😭

#

i like cdl but its rarely used

chrome beacon
#

It's great wdym

pseudo hazel
#

use the command name as the key maybe?

chrome beacon
#

?

proper cobalt
#

i think the guy who made tacospigot made it too

#

let me find it

pseudo hazel
#

so rarely used that noone knows tf you talking about

pure dagger
#

maybe but its not the same then

#

no repeated commands

pseudo hazel
#

commands:
"my_command":
time: etc

chrome beacon
#
schedule:
  "12:30":
    commands:
    - "/a"
pseudo hazel
#

oh you want repeated commands?

pure dagger
#

i was thinking about it

pseudo hazel
#

right I thought this was just a list of commands xD

pure dagger
#

could 12:30 just be a list?

pseudo hazel
#

sure

chrome beacon
pure dagger
proper cobalt
pseudo hazel
#

or a single item if its only 1 command

pure dagger
#

but i know its only commands so i can skip the "commands:" map

#

i mean another level

pseudo hazel
#

"12:30": cmd

chrome beacon
#

You can allow for both

pure dagger
#

why i did it so dumbly lol

sterile token
#

hello devs, today i would to know, how do you identify the execution enviroment from minecraft plugins? let say you have a library which you want to add in every plugin (Spigot / Paper / Bungeecord) and you want to plugin notify what server software is running via the library. Internally the library should get the package-id from the server and make reflections right?

chrome beacon
#

spigot - plugin.yml
paper - paper-plugin.yml
bunge - bungee.yml

#

Different entry points uwu

#

Alternatively just check for a class that you know won't be present on Spigot for example

lilac dagger
#

Is the paper entry point new?

chrome beacon
#

It's not super new but I wouldn't call it old

sterile token
lilac dagger
#

There's bukkit get version

sterile token
#

oh right

chrome beacon
#

You shouldn't rely on the server package

lilac dagger
#

Ye

#

Paper made sure of that

sterile token
#

allright i follow your recommendations

lilac dagger
#

Bukkit get version is the best way to get your version

#

Probably have to substract the string

#

Not sure

sterile token
#

great, thanks for both of you

lilac dagger
#

😄

sterile token
#

yeah there is not problem about that, im just happy about knowing the best way for it

sterile breach
# sharp bough https://www.mycompiler.io/guides/base64-encoding-decoding-in-java

I asked my friend (gpt) to make me this code and it seems to work, so I just have to use these methods to serialize my user data in sql?


    public static String encodeObject(Object obj) throws IOException {
        ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
        objectOutputStream.writeObject(obj);
        byte[] objectBytes = byteArrayOutputStream.toByteArray();
        return Base64.getEncoder().encodeToString(objectBytes);
    }

    public static Object decodeObject(String base64String) throws IOException, ClassNotFoundException {
        byte[] objectBytes = Base64.getDecoder().decode(base64String);
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(objectBytes);
        ObjectInputStream objectInputStream = new ObjectInputStream(byteArrayInputStream);
        return objectInputStream.readObject();
    }```
lilac dagger
#

There's the bukkit outputstream

#

Not all objects will serialize properly

sterile breach
#

bukkit outpustream is deprecarted Ihv heard

sterile breach
sterile token
#

fast question, spigot server versions starts from 1.7 or 1.7.10?

river oracle
#

because honestly the OOS kinda sucks ass, but also because Bukkit objects go through a separate serialization process (which is also horrible, but that's besides the point)

#

basically if you use OOS your system will probably 100% break every version with an absolute guarentee

#

I mean BOOS struggles with the same issues, but atleast it tries

#

basically BOOS take bucket objects and then runs it through its Config serialization to Map<String, Object> than serializes it to bytes, where as Object Output stream uses some fun java internal magic!

chrome beacon
sterile breach
#

java magic

sterile token
river oracle
#

what are you trying to encode?

sterile token
#

im trying to get the enviroment version Âż?

river oracle
#

talking to the other guy Verano

sterile token
sterile breach
river oracle
#

otherwise your items will break literally every version

sterile breach
river oracle
#

not sure what an occtet is

#

but all of the things you mentioned can be easily serialized to bytes

sterile breach
#

yes I mean bytes

pseudo hazel
#

if users dont need to edit it, just store the bytes

sterile breach
#

why is encoding spigot objects so complex?

river oracle
#

its not complex its just we don't expose good API to do it for a lot of them

#

also javas built in method is kinda blegh

pseudo hazel
#

its not more complex than any other object

sterile breach
#

my class look like
data is a base64 converted itemstack

converting this object with the methods I've provided above may still cause problems (there are only strings and int) ?

public class Syncuser {

    private String server;
    private String data;
    private int level;
}
river oracle
#

idk what any of those mean Shrug but its not hard given you use the right tools

#

its pretty easy to use NBT and serialize ItemStacks I sent the code in my old PR above

#

it works and allows cross version support

twilit coral
#

you mean itemstack or inventory i'm confused

river oracle
#

I mean Inventories are just a list of ItemStacks

#

its anagolous

twilit coral
#

it is, but he said the data is an itemstack

river oracle
#

either way the code I sent works it doesn't matter

sterile breach
#

is it possible to convert an itemstack array with gson? or will it cause the same problems as base64?

twilit coral
#

probably, but idk if it would be larger space

river oracle
#

you have fun with that

sterile breach
twilit coral
#

you mean deserialize wym

river oracle
#

no you have a fundamental misunderstanding of how the magic gson serialization works it would fundamentally fail given any given ItemStack by default

twilit coral
#

how you gonna convert it back to an item

river oracle
#

its Reflection based, bukkit ItemStack wraps, ItemMeta an Int and Material, ItemMeta Wraps DataComponentPatch which wraps some other stuff. Its far to complex for GSON to handle without explicit directions

sterile breach
river oracle
#

not to mention with Gson you also have to handle the fact that ItemStack internally has a derivative called CraftItemStack too which is ever so slighty different

sterile breach
#

i tought gson had no "limits", its good to know

twilit coral
#

it has to have an explicit directive on how to serialize or deserialize things, it can do a lot

blazing ocean
#

i love 20gb mcserver.json

twilit coral
#

it's just for example, to serialize itemstack to string is fine. but deserializing an interface, gson can't do that without an explicit deserializer

#

itemmeta is an interface if you tried it right now, it wouldn't work going back from a string to itemmeta without you implementing your own custom deserializer

river oracle
#

I give up honestly I've told you the correct path a couple times why are avoiding the best method and keep doing this bonk ass shit with the bukkit API which is far inferior in this area

sterile breach
#

I don't intend to use gson or anything like that (I was asking out of curiosity)

twilit coral
#

ya, just best to fllow what miles said easier on the brain

river oracle
blazing ocean
#

okay miles

#

what was your last name again

#

i remember seeing it before

river oracle
blazing ocean
#

same bro

shadow night
deft geode
#

What triggers a VehicleUpdateEvent?

sterile breach
#

VehicleUpdate

blazing ocean
#

anyway check the JD for the event

sterile breach
sterile breach
sullen marlin
#

Seems to be called basically every tick

deft geode
#

Yeah, I tried doing manual testing by broadcasting/logging "Update" if the event was triggered, but nothing

sullen marlin
#

Idk why it exists

#

(for boats and minecarts)

deft geode
#

ahhh ok

#

lemme test

#

welp, you were right lol

#

just spammed chat

young knoll
#

Omg we have a TickEvent

#

*Requires a vehicle

blazing ocean
young knoll
#

Aktually it has a tick start and end event

#

This would be like

#

The middle of the tick

blazing ocean
#

lmao

sacred sinew
#

`package me.wolfispuzzled.duplexDoubler;

import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin;

public final class DuplexDoubler extends JavaPlugin implements Listener {

public DuplexDoubler(DuplexDoubler plugin) {
    this.plugin = plugin;
}

@Override
public void onEnable() {
    // Plugin startup logic
    getServer().getPluginManager().registerEvents(this, this);
}

private final DuplexDoubler plugin;

@Override
public void onDisable() {
    // Plugin shutdown logic
}

@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
    Block block = event.getBlock();
    block.setMetadata("PLACED", new FixedMetadataValue(plugin, "something"));


}

@EventHandler
public void onBlockBreak(BlockBreakEvent event) {

    Block block = event.getBlock();
    if (!block.hasMetadata("PLACED")) {
        event.setDropItems(true);

        // Double and drop items
        event.getBlock().getDrops().forEach(drop -> {
            drop.setAmount(drop.getAmount() * 2);
            event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), drop);
        });
    }
}

}`
this is my 1.21.1 plugin thats supposed to double all block drops that arent placed by a player but its js not doubling anything any1 kow why?

sullen marlin
#

have you debugged what code is running

sacred sinew
#

wdym

hushed spindle
#

Entity#addPassenger() seems to be kinda buggy unless I'm missing something
I'm creating an entity, i tried arrows, item displays, and armor stands because i just want a plain invisible entity for the player to sit on
I add the player as a passenger to this entity
The player doesn't sit, they instead fall through
The entity has the player as a passenger if I check getPassengers(), and the player has the entity as their vehicle if I check getVehicle()

so how come the player isn't sitting lol

#

the player can also move freely during this

sullen marlin
#

hardly surprising given you can't normally ride arrows

hushed spindle
#

right but there shouldn't be a restriction on that

#

gsit uses armor stands, i tried those too

#

ive seen people make plugins where the player rides thrown ender pearls

remote swallow
hushed spindle
#

ticks are 50ms long arent they

young knoll
#

Yes

remote swallow
#

Close enough

glad prawn
bitter rune
#

Why doesn't maps allow you to do more then one key value pair? I understand there's ways around this but it makes the code less clean

blazing ocean
#

you might be looking for multimaps

#

ignore olivo, as always smh

chrome beacon
#

smh 🔫

bitter rune
#

Yeah that'll work thanks

chrome beacon
#

Spigot ships Guava which has Multimaps

bitter rune
slender elbow
#

just sounds more like you want some record for the value rather than a collection value

bitter rune
#

I want to save a boolean and task under the player key

chrome beacon
#

Yeah that's not something you should be using a multimap for

bitter rune
#

Using it to create an off on switch with a task

chrome beacon
#

Wrap that in an object or record

#

or can one player have more than one bool task pair?

bitter rune
#

I'll show what I have once I get back home I've been writing it on pen and paper while we eat dinner lol

young knoll
#

Map<UUID, PlayerData>

#

record PlayerData(BukkitTask task, boolean bool)

eternal night
#

Pair<BukkitTask, Boolean> you mean

torn shuttle
#

I forgot how long my ai automatic wiki translator takes to actually translate

#

it's quite long

#

it's been 20min and it's still working on chinese

blazing ocean
#

how large is your wiki

torn shuttle
#

hm

#

actually I had a condensed file but deleted it a few minutes ago

young knoll
blazing ocean
#

how many words is it

#

in english

torn shuttle
#

about 100k words?

#

maybe more

#

counter says that this old consolidated file is at 84859 words but that's before all of the recent additions

blazing ocean
#

goddamn

torn shuttle
#

it's not that much considering a single plugin it's documenting is nearly at 100k lines of code

blazing ocean
#

one word describing every line

torn shuttle
#

would be accurate if this wasn't documenting several plugins

#

but the real total count might be about that actually

#

the other plugins are nowhere near as large

bitter rune
#

I didn't know you could put multiple variables inside of a value

blazing ocean
#

what

#

...classes?

bitter rune
kind coral
#

Hello, im trying to seek help regarding hibernate, this may be off-topic but its indeed for a minecraft plugin, i have a really big table with a lot of columns and i decided to start applying normalization to make it a bit better, the only problem is that i reached this Hiccup where i get an error where x is null https://paste.gg/p/anonymous/32a23a640f164eb19c6d2073c6bb29cc

but i have no fields called 'x' so i really dont know what is causing it

vagrant stratus
bitter rune
glad prawn
torn shuttle
#

this is still translating

#

I actually think it might take more than 6 hours

#

actually basic math says way longer

#

yeah might be closer to 8 hours

bitter rune
#

I have a question with intellij is there a way to increase the font size within the text editor without increasing the GUI size or the font on the GUI itself

torn shuttle
#

ctrl+scroll

#

or at least that's what I have it bound to

bitter rune
#

ill look in key mappings, thanks

#

default is alt+shift+.

#

this is much better thanks again

#

could also change to a pattern variable (just learned what this is) makes Player player = ... redundant

proper cobalt
#

how can we do custom world gen

#

is there like a guide anywhere

wintry anvil
#
    public EmeraldArmor(YmcExtender plugin) {
        super(plugin);
        this.plugin = plugin;
    }

what am I doing wrong here? super is getting underlined, I could swear I've used that in like 10 plugins before...

proper cobalt
#

depends if ur extending something

#

are you

wintry anvil
#

yeah

#
public class EmeraldArmor extends CustomItemHandler {

    private final YmcExtender plugin;

    public EmeraldArmor(YmcExtender plugin) {
        super(plugin);
        this.plugin = plugin;
    }
young knoll
#

Does the super class have a constructor that requires a plugin

wintry anvil
#

nope

proper cobalt
#

then dont pass in plugin

#

super calls the extensions constructor

#

?learn-java

sacred sinew
#

`@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlock();
block.setMetadata("PLACED", new FixedMetadataValue(plugin, "something"));

}

@EventHandler
public void onBlockBreak(BlockBreakEvent event) {

    Block block = event.getBlock();
    if (!block.hasMetadata("PLACED")) {
        event.setDropItems(true);

        // Double and drop items
        event.getBlock().getDrops().forEach(drop -> {
            drop.setAmount(drop.getAmount() * 2);
            event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), drop);
        });
    }
}`

any1 know why these two listeners arent working? its supposed to double all naturally generated block drops but its only dropping 1

mortal vortex
sacred sinew
#

i did but even if metadata doesnt work then wouldnty it still drop 2?

mortal vortex
#

Yes. That's true

sacred sinew
#

i registered with this getServer().getPluginManager().registerEvents(this, this);

#

everything is in main class

mortal vortex
#
    if (!block.hasMetadata("PLACED")) {

        Collection<ItemStack> originalDrops = block.getDrops(event.getPlayer().getItemInHand());

        event.setDropItems(false);
        
        for (ItemStack drop : originalDrops) {
            ItemStack doubledDrop = drop.clone();
            doubledDrop.setAmount(drop.getAmount() * 2);
            event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), doubledDrop);
        }
    }
#

Does this work?

sacred sinew
#

lemme try

manic delta
#

if i want to load chunks

#

i should use main or async thread

mortal vortex
# manic delta i should use main or async thread

Most chunk-related operations that modify world state MUST be done on the main thread. Otherwise, chunk generation and initial loading can be done async, but final modifications need to be on the main thread

#

From practice, typically i would load chunks async if possible, then switch to main thread for any world modifications

manic delta
#

on getBlocksOfType()

#

or do u have a tip

mortal vortex
# manic delta on getBlocksOfType()
public List<Block> getBlocksOfType(World world, Material targetType, int x1, int y1, int z1, int x2, int y2, int z2) {
    int minX = Math.min(x1, x2);
    int maxX = Math.max(x1, x2);
    int minY = Math.min(y1, y2);
    int maxY = Math.max(y1, y2);
    int minZ = Math.min(z1, z2);
    int maxZ = Math.max(z1, z2);

    List<Block> matchingBlocks = new ArrayList<>();

    // to begin with do it synchronously here 
    CompletableFuture<Void> chunkLoading = new CompletableFuture<>();
    Bukkit.getScheduler().runTask(YourPlugin.getInstance(), () -> {
        for (int x = minX; x <= maxX; x++) {
            for (int y = minY; y <= maxY; y++) {
                for (int z = minZ; z <= maxZ; z++) {
                    Block block = world.getBlockAt(x, y, z);
                    if(!block.getChunk().isLoaded()){
                        block.getChunk().load();
                    }
                }
            }
        }
        chunkLoading.complete(null);
    });

    // wait first
    try {
        chunkLoading.get();
    } catch (InterruptedException | ExecutionException e) {
        e.printStackTrace();
    }

    // the process blocks
    for (int x = minX; x <= maxX; x++) {
        for (int y = minY; y <= maxY; y++) {
            for (int z = minZ; z <= maxZ; z++) {
                Block block = world.getBlockAt(x, y, z);
                if (block.getType() == targetType) {
                    matchingBlocks.add(block);
                }
            }
        }
    }

    return matchingBlocks;
}
#

since you're using CompletableFuture.supplyAsync() to run the block counting operation asynchronously, you should ensure that chunk operations are synchronized,as above.

mortal vortex
#

Dude add debugigng maybe

manic delta
#

i think it blocked the main thread

mortal vortex
#

no no. For getBlocksOfType schedular should be like:

if(!block.getChunk().isLoaded()){
    
    Bukkit.getScheduler().runTask(plugin.getInstance(), () -> {
        block.getChunk().load();
    });
}
#

then in the getBlock do:

if(!chunk.isLoaded()) {
    Bukkit.getScheduler().runTask(plugin.getInstance(), () -> {
        chunk.load();
    });
}
manic delta
#

mmm

#

mind just crashed

sacred sinew
mortal vortex
manic delta
#

or debug

sacred sinew
mortal vortex
#

Dude. print statements

manic delta
#

then you can follow the code

sacred sinew
#

ohh

#

so like System.out.prinln(doubledDrop);

#

for (ItemStack drop : originalDrops) {
ItemStack doubledDrop = drop.clone();
doubledDrop.setAmount(drop.getAmount() * 2);
player.sendMessage(String.valueOf(doubledDrop));
event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), doubledDrop);
}
this is what i put but it doesnt send me the message

mortal vortex
#

are u sure the event is being called

sacred sinew
#

why wouldnt i tbe i registered it

timid berry
#

hi guys

tawny furnace
#

hey

river oracle
#

?ask

undone axleBOT
#

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

tawny furnace
#

@EventHandler
public void onHit(ProjectileHitEvent e) {
if (e.getEntity() instanceof Trident trident) {
if (e.getHitEntity() instanceof Player victim) {
Player shooter = (Player) trident.getShooter();
if (shooter != null) {
ItemStack item = shooter.getInventory().getItemInMainHand();
if (item.getEnchantments().containsKey(this)) {
double speedMultiplier = 6.0;
Vector direction = shooter.getLocation().toVector().subtract(victim.getLocation().toVector());
if (direction.length() != 0.0) {
Vector velocity = direction.normalize().multiply(speedMultiplier);
victim.setVelocity(velocity);
}
}
}
}
}
}

#

I have a strange problem. I am writing a plugin for an enchantment for a trident that will attract a victim to the attacking player when the trident hits the victim. I wrote to the mechanic, but ran into a big problem. The problem is that if the players are in survival mode, the enchantment does not work at all. For some reason, it does not attract at all. If both are creative, then it attracts very strongly. If one has creative, and one is survival, then it attracts as it should. But it should attract as it should if both are survival. I do not know what to do and what it depends on

#

my plugin is the only one on the server

nova notch
# tawny furnace @EventHandler public void onHit(ProjectileHitEvent e) { if (e.getEntity() in...

In computer programming, a common challenge facing systems programmers is that before an operation can be performed, a number of conditions must first be checked to confirm that the operation can be successfully performed. For example, before data can be written to a file, it must be confirmed that 1) the program has the file open for writing; 2...

short drift
#

Is it possible to require several ingredients for a recipe? E.g. 64 gold nuggets to craft a single item?

#
// Register gold coins to gold coin pile recipe.
private void registerGoldCoinPileRecipe() {
    // Create the result item (shulker shell with custom data)
    ItemStack result = new ItemStack(Material.SHULKER_SHELL);
    ItemMeta meta = result.getItemMeta();
    if (meta != null) {
        meta.setCustomModelData(282032);
        meta.setItemName("Kultakolikoita");
        result.setItemMeta(meta);
    }

    // Define the shaped recipe
    NamespacedKey key = new NamespacedKey(plugin, "GOLD_COIN_PILE");
    ShapedRecipe recipe = new ShapedRecipe(key, result);
    recipe.shape("G");

    // Create a custom RecipeChoice for 64 gold nuggets
    ItemStack goldNuggetStack = new ItemStack(Material.GOLD_NUGGET, 64);
    RecipeChoice.ExactChoice goldNuggetChoice = new RecipeChoice.ExactChoice(goldNuggetStack);

    // Set the ingredient for the recipe
    recipe.setIngredient('G', goldNuggetChoice);

    // Register the recipe
    Bukkit.addRecipe(recipe);
}
#

I have tried this, but it allows crafting with only a single gold nugget.

#

The docs do mention that ExactChoice ignores stack size, but what are my options?

sullen marlin
#

you can't do it as a true recipe but there are crafting events you can use

short drift
#
    @EventHandler public void onPrepareItemCraft(PrepareItemCraftEvent event) {
        if (event.getRecipe() != null && event.getRecipe().getResult().getType() == Material.SHULKER_SHELL) {
            ItemStack[] matrix = event.getInventory().getMatrix();
            for (ItemStack item : matrix) {
                if (item != null && item.getType() == Material.GOLD_NUGGET) {
                    if (item.getAmount() < 64) {
                        event.getInventory().setResult(null);
                        break;
                    }
                } else if (item != null && item.getType() == Material.SHULKER_SHELL) {
                    ItemMeta meta = item.getItemMeta();
                    if (meta == null || meta.getCustomModelData() != 282032 || !meta.getDisplayName().equals("Kultakolikoita")) {
                        event.getInventory().setResult(null);
                        break;
                    }
                }
            }
        }
    }

I did try this and it seems to work. Kind of.

#

The only problem is it only subtracts a single material.

#

Do I need to override CraftItemEvent as well?

#

Lot of code for a single recipe, but okay 🤔

mortal vortex
short drift
#

I guess I'm not.

mortal vortex
# short drift I guess I'm not.

No I meant, what other method do you have?

Practically, in conjuncture with your onPrepareItemCraft you should also properly consume the nuggets:

    @EventHandler
    public void onCraftItem(CraftItemEvent event) {
        if (event.getRecipe() != null && event.getRecipe().getResult().getType() == Material.SHULKER_SHELL) {
            ItemStack[] matrix = event.getInventory().getMatrix();
            int remainingNuggets = 64;

            // consume / subtract / idk the word / exactly 64 gold nuggets
            for (int i = 0; i < matrix.length; i++) {
                if (matrix[i] != null && matrix[i].getType() == Material.GOLD_NUGGET) {
                    int currentAmount = matrix[i].getAmount();
                    if (currentAmount <= remainingNuggets) {
                        matrix[i].setAmount(0);
                        remainingNuggets -= currentAmount;
                    } else {
                        matrix[i].setAmount(currentAmount - remainingNuggets);
                        remainingNuggets = 0;
                    }

                    if (remainingNuggets == 0) break;
                }
            }
        }
    }
#

for loops like this get sticky very quickly

short drift
#

Here's what I have so far

#

Trying to hook up to CraftItemEvent failed, though.

tawny furnace
#

@EventHandler
public void onHit(ProjectileHitEvent e) {
if (e.getEntity() instanceof Trident trident) {
if (e.getHitEntity() instanceof Player victim) {
Player shooter = (Player) trident.getShooter();
if (shooter != null) {
ItemStack item = shooter.getInventory().getItemInMainHand();
if (item.getEnchantments().containsKey(this)) {
double speedMultiplier = 6.0;
Vector direction = shooter.getLocation().toVector().subtract(victim.getLocation().toVector());
if (direction.length() != 0.0) {
Vector velocity = direction.normalize().multiply(speedMultiplier);
victim.setVelocity(velocity);
}
}
}
}
}
}

#

I have a strange problem. I am writing a plugin for an enchantment for a trident that will attract a victim to the attacking player when the trident hits the victim. I wrote to the mechanic, but ran into a big problem. The problem is that if the players are in survival mode, the enchantment does not work at all. For some reason, it does not attract at all. If both are creative, then it attracts very strongly. If one has creative, and one is survival, then it attracts as it should. But it should attract as it should if both are survival. I do not know what to do and what it depends on

wide cipher
#

does anyone have the URL to the valentine or test minecraft capes?

#

none of the players have it equipped so i can't use sessionserver

undone axleBOT
sharp bough
#

and invert ifs

tawny furnace
sharp bough
#

on intellij, over the "if" part, alt enter ->

#

looks better

tawny furnace
#

Do you think this will fix it?

mortal vortex
sharp bough
#

no, but its easier to debug and work with like this

wide cipher
#

is there a way to get a single thing from this by a string? like Cape.<StringHere>. Obv this is without doing the long ifs statements.

sharp bough
#

could be if (!item.getEnchantments().containsKey(this)) return; acting funny for creative mode, debug the item, the enchantments and in what scenarios its ture

#

also whats "this" ?

wide cipher
sullen marlin
#

You could make a static register method or add them to a static map in the constructor

wide cipher
sullen marlin
#

Well what you're doing there is a variable

#

Do you know java?

wide cipher
sharp bough
#

is there a way to get a single thing from this by a string? like Cape.<StringHere>. Obv this is without doing the long ifs statements.
reflection might work

#

kinda

barren trail
#

erm

sharp bough
#

something like

    public static Set<Cape> find(String name){
        return Arrays.stream(you class.class.getDeclaredFields())
                .filter(f -> f.getName().equalsIgnoreCase(name))
                .map(f -> {
                    try {
                        return ((Cape) f.get(null));
                    } catch (IllegalAccessException e) {
                        throw new RuntimeException(e);
                    }
                })
                .collect(Collectors.toSet());
    }
#

would be better to return just first match, or fussy find with that given name if you want to return a set

#

up to you

mortal vortex
timid berry
#

a

ebon topaz
#
package me.carillon.foody.food;

import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;

import static org.bukkit.Bukkit.getServer;

public class chicken_sandwich {

    public static ItemStack chicken_sandwich;

    public static void init() {createChickSand();}

    private static void createChickSand() {
        ItemStack item = new ItemStack(Material.BREAD, 1);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("Chicken Sandwich");
        meta.setCustomModelData(1);
        item.setItemMeta(meta);
        chicken_sandwich = item;

        NamespacedKey key = new NamespacedKey(this, "chicken_sandwich");
        ShapedRecipe recipe = new ShapedRecipe(key, item);
        recipe.shape("B", "C", "B");
        recipe.setIngredient('B', Material.CHICKEN);
        recipe.setIngredient('C', Material.COOKED_CHICKEN);
        getServer().addRecipe(recipe);
    }
}

so i have made this custom recipe with item and i want to make a bunch of these in separate classes but how should i initiate all of them in my main class?
plus when i do "this" for the name spaced key it says it cant be reference from a static context but the init function requires it to be static

chrome beacon
#

Yeah so don't use "this"

#

In a static method

drowsy helm
#

you should definitely use an item builder instead of a static method

ebon topaz
chrome beacon
#

yes

#

If you add that feature to it

drowsy helm
#

an item builder is more of a concept

#

you have to make it yourself

chrome beacon
#

^^ Builder pattern

#

^^ This site does a good job of explaining different patterns with examples for different languages including Java

drowsy helm
#

Or use a registry and treat your custom item classes as blueprints

chrome beacon
#

Using both is also an option uwu

ebon topaz
#

ok i think i see

#
package me.carillon.foody;

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

public class ItemBuilder {
    private ItemStack is;


    public ItemBuilder(Material m, int amount){
        is = new ItemStack(m, amount);
    }

    public ItemBuilder setDisplayName(String name){
        ItemMeta meta = is.getItemMeta();
        meta.setDisplayName(name);
        is.setItemMeta(meta);
        return this;
    }

    public ItemBuilder setCustomModelData(int key){
        ItemMeta meta = is.getItemMeta();
        meta.setCustomModelData(key);
        is.setItemMeta(meta);
        return this;
    }

    public ItemBuilder createRecipe(){

        return null;
    }
}

so this is what i got so far,
does this seem right?

drowsy helm
#

yeah looks good

chrome beacon
#

I'd avoid copying the item meta every time

#

You only really need to build that ItemStack when you're done with it

#

also personally I prefer fluent setters in builders

#

but that's up to you

ebon topaz
chrome beacon
#

displayName() instead of setDisplayName()

ebon topaz
#

ah

ebon topaz
# chrome beacon I'd avoid copying the item meta every time
package me.carillon.foody;

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

public class ItemBuilder {
    private ItemStack is;


    public ItemBuilder(Material m, int amount){
        is = new ItemStack(m, amount);
    }

    ItemMeta meta = is.getItemMeta();

    public ItemBuilder setDisplayName(String name){
        meta.setDisplayName(name);
        return this;
    }

    public ItemBuilder setCustomModelData(int key){
        meta.setCustomModelData(key);
        return this;
    }

    public ItemBuilder createRecipe(){

        return null;
    }

    public ItemStack toItemStack(){
        is.setItemMeta(meta);
        return is;
    }
}

so kinda like this?

drowsy helm
#

set the meta in constructor

#

is will be null in that context

ebon topaz
#

so leave the setmeta where they were but only call the getmeta once?

drowsy helm
#

no, you can set meta on build

chrome beacon
#

set item meta only needs to be in the build method

#

rename toItemStack to build

lilac dagger
#

What do you guys think of my item stack builder?

chrome beacon
#

No components support :sadge:

lilac dagger
#

There's no component support needed

chrome beacon
#

components are quite useful uwu

drowsy helm
#

my item builder is a monstrosity, each time i need something new i append another method lol

chrome beacon
#

but yeah Spigot API still needs some work :c

lilac dagger
#

Ye in chat, but I never found use in itemstack

chrome beacon
#

translatable lore etc

drowsy helm
#

I've virtually changed everything to components as defacto

#

they are just better

chrome beacon
#

Gotta localize your server smh

ebon topaz
chrome beacon
#

No

#

You can make a new builder for the recipe if you want

#

or just use the API as is

#

The item builder is just a bit of a detour

lilac dagger
#

How does translation works with components?

chrome beacon
#

You send the key

lilac dagger
#

Ah

chrome beacon
#

The client shows what that key means

#

You'll need to provide keys through a resource pack

lilac dagger
#

But my use is based on custom lore

#

Not mojang lore

#

I also try to not rely on resource packs

#

If I am to impl translation per user I'll do so as a choice in game

#

Where you can choose language

chrome beacon
#

That'll be annoying to handle

#

and you would need to mess with packets

lilac dagger
#

Ah no

#

I just send the translation per player

#

Unless you mean the item stack sharing

chrome beacon
#

yeah that

lilac dagger
#

But I make minigames the item stacks are not shared

chrome beacon
#

Guess that's easier then

lilac dagger
#

My windows installation is almost done 😄

chrome beacon
#

Time for 20 pages of denying tracking

#

and then 3 hours of updating windows

#

another 3 hours of removing bloat

lilac dagger
#

I heard the new updates bring bloat

#

I'll see now if it's true

chrome beacon
#

It does

#

They're rolling out AI to both paint and notepad

lilac dagger
#

I'm in the eu

#

I hope it's not bloated

chrome beacon
#

It's still bloated but it's better at least

#

Helps mass change settings and uninstall stuff you don't want

lilac dagger
#

I'll take my time

#

I got this 😄

#

Yay it boots

#

Now I have to see which driver is the culprit

chrome beacon
#

Wouldn't suprise me if it was an Anticheat

lilac dagger
#

Probably another round of reinstall

#

I don't have anti cheats installed

chrome beacon
#

You don't play any games with them?

lilac dagger
#

It might be the sound driver

#

I do, just not multiplayer

chrome beacon
#

Then they're installed

lilac dagger
#

I got like 3 apps

#

That are bloatware

#

Outlook

#

Office and linkedin

#

I'll uninstall them manually

pure dagger
#

i have a list of locations of chests (which are chests with loot) and every player can open chest (it opens custom inventory not the actual chest), and then they have cooldown, so player has cooldown for every chest he opened, how can i save it to configs?
i just did this:

1st config with list of locations chests (or list of maps with x,y,z)
2nd config with every player having map<Location, Long>

is this ok?

chrome beacon
#

if you're going to use configs you'd need one per player

#

Otherwise you'd end up loading a bunch of data for players that aren't online

pure dagger
#

oh

#

so whats better solution

sharp bough
#

he just gave you one

#

instead of storing the cooldowns on a single file create one per uuid

#

and delete it once all cooldowns are over

pure dagger
#

thats "if i'm going to use configs" sounds like configs are not great option

#

and this feels like not great option

ebon topaz
#
package me.carillon.foody;

import org.bukkit.NamespacedKey;
import org.bukkit.inventory.CraftingRecipe;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;

public class RecipeBuilder {
    private ShapedRecipe sr;

    public RecipeBuilder(String keyy, ItemStack item){
        NamespacedKey key = new NamespacedKey(this, "keyy");
        sr = new ShapedRecipe(key, item);
    }

    public CraftingRecipe build(){
        return sr;
    }
}

me trying to make a recipe builder ;C

chrome beacon
#

"this" won't work

blazing ocean
#

what the hell are those variable names

ebon topaz
chrome beacon
#

A namespaced key takes either a plugin or a string

#

"this" would refer to neither

#

The "this" keyword refers to the current object instance you're in

#

Which would be an instance of RecipeBuilder

pure dagger
#

can you even acces "this" in constructor

#

ok you can

#

why there is no method to get list of locations from config

shadow night
#

Because that's very specific

pure dagger
#

but there is getLocation

chrome beacon
#

Just use getList and cast

pure dagger
#

i mean List<?> but with strings?

shadow night
#

Make a util method to get a location list Ig?

pure dagger
#

yeah i can

#

maybe its better to store it as map

chrome beacon
#

If you set a list of locations it will return a list of locations

#

The Location class is configuration serializable

pure dagger
#

arent locations just strings in config?

chrome beacon
#

It has an identifier that tells Spigot it's a location

pure dagger
#

what identifier

chrome beacon
#

==: org.bukkit.Location or smth like it

pure dagger
#

oh yeah

#

and same with itemstacks right

chrome beacon
#

yeah

pure dagger
#

but the ==: is what

#

its yml function or its just string

chrome beacon
#

That's just a key

#

with the value ==

pure dagger
#

you mean key == and value org.bukkit.Locatin

chrome beacon
#

yes

pure dagger
#

so just cast every element of config.getList("locations") ?

chrome beacon
#

You'd normally load that in to a player data object or smth

pure dagger
#

whats player data objejct

pure dagger
chrome beacon
#

yes

pure dagger
#

thanky

humble sigil
#

hello

#

who knows how to register app for minecraft?

young knoll
#

An app?

chrome beacon
shadow night
#

???

humble sigil
#

electron-nextjs-nestjs project

young knoll
#

What

humble sigil
#

I have an azure account

shadow night
#

?????????????

chrome beacon
#

???

shadow night
#

I think you are off somewhere

chrome beacon
#

Wait you want to login via your launcher

#

I see

humble sigil
#

yes, I am making a launcher

shadow night
#

aha

humble sigil
#

via OAuth

shadow night
#

what if you just didn't

chrome beacon
#

We really don't need another Electron launcher 💀

shadow night
#

Yeah we absolutely do not

chrome beacon
pure dagger
#

how to minecraft

chrome beacon
#

is probably what you're looking for

#

Not 100% sure though

#

MS has 100 different ways of doing login

ebon topaz
#

should i do getServer().addRecipe(recipe); inside the recipe builder?

blazing ocean
#

very creative name i know

young knoll
#

Who’s mrpack

blazing ocean
#

modrinth modpack format

chrome beacon
blazing ocean
#

what

chrome beacon
#

You don't really need to rewrite the launcher in Rust

blazing ocean
#

not the entire thing

#

just a minimal lil launcher

#

takes you straight into the game, no extra bullshit

#

made for easy distribution ig

chrome beacon
#

Prism:

#

It has a CLI uwu

blazing ocean
#

i mean, you still need to set up an instance for that and everything

chrome beacon
#

You'd want that though?

blazing ocean
#

that's meant to be a single click (+ auth ig) and it sets up your instance by itself