#help-development

1 messages · Page 598 of 1

spare hazel
#

thats the problem

fluid river
#

is that so hard to write own impl of roman

open lily
quaint mantle
spare hazel
#

it worked before i made my skill classes extend an abstract class Skill

zealous osprey
#

I'm tinkering around with making a website run on the server; For a nicer UI... well... it's not going smoothly XD
The site isn't even loading, just getting the raw HTML displayed to the screen

vivid cave
# quaint mantle why do it if a perfect implementation is already existing

bro, you have a point and that's how programemers should react,
I just don't like it, I think the whole fun of programming is in those kinds of pieces/quick engineering.
I don't think we ultimately program just to make something work.
Plus, the more dependencies / code that ain't yours you use, the more prone to bugs you're about to face, maybe not right now but maybe in some future.

quaint mantle
#

its not a dependency

young knoll
#

We ultimately do program just to make something work

#

Especially in corporate

vivid cave
#

pls read

quaint mantle
#

sorry i skip over words a lot

#

im bad at reading

vivid cave
#

and learn

quaint mantle
#

nah i code to get shit done

#

personally i dont want to spend 4 hours working on a roman numeral implementation when i can just copy and paste an answer from stackoverflow

vivid cave
vivid cave
#

typically the kind of program i enjoy doing

quaint mantle
#

👍🏿

fluid river
quaint mantle
fluid river
#

so instead of brainlessly copypaste he can think

quaint mantle
#

yea you still need to think to make stuff

#

its not just copy and paste

spare hazel
vivid cave
#

the other day i made a "maths expression parser", which can calculate maths expressions based on parameters/exact stuff
this shit must exist already but making it myself made me so proud & happy

fluid river
#

well if you look at the entire project of the guy, you might find a lot of brainless stuff heh

quaint mantle
spare hazel
fluid river
#

ik you are new to it yeah

young knoll
#

The key is to spend 4 hours reinventing the wheel when you are doing a commission and being paid hourly

spare hazel
#

BUT SOMEONE HELP ME WITH MY PROBLEM

#

please

zealous osprey
#
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.Integer.intValue()" because the return value of "java.util.TreeMap.floorKey(Object)" is null
    at com.amirparsa.hypixelskillcore.Utils.RomanNumber.toRoman(RomanNumber.java:31) ~[?:?]```
These lines should give you all the info you need; Look why there could be a `NullPointerException` in line `31` in your `RomanNumber.java` class.
spare hazel
#

the problem is surely from the abstract class i made for all the skills. i just dont know why. it worked before extending all my skill classes to the skill abstract class

zealous osprey
#

at com.amirparsa.hypixelskillcore.Commands.SkillsTextCommand.onCommand(SkillsTextCommand.java:21) ~[?:?]
In that case, check line 21 in your SkillsTextCommand.java class, maybe that'll give you more insight. More I cannot deduce from just an error msg.

spare hazel
#

i provided some code after sending this message

zealous osprey
#

idk what line 21 is

spare hazel
#

sender.sendMessage(ChatColor.YELLOW + "" + ChatColor.BOLD + "Farming " + ChatColor.AQUA + RomanNumber.toRoman(playerAccount.getFarming().getLevel()) + ChatColor.DARK_GRAY + " " + playerAccount.getFarming().getXp() + "/" + (playerAccount.getFarming().getStarterXp() * playerAccount.getFarming().getLevel()));

young knoll
#

Your toRoman method will break if you pass it a 0

spare hazel
young knoll
#

Are you sure about that

zealous osprey
#

It's most likely that you pass to the function toRoman an integer with a value of 0 or so, since you try to find the lowest key, which is 1 the map can't find anything lower than 0, so it returns null?

spare hazel
young knoll
#

Because the error you are getting can only happen with a number < 1

spare hazel
#

public class Farming extends Skill implements ConfigurationSerializable {
private int STARTER_XP = 150;

private int level = 1;
private int xp = 0;
zealous osprey
#

print out playerAccount.getFarming().getLevel() just to be sure

young knoll
#

That’s basically the first step of debugging

spare hazel
zealous osprey
young knoll
#

Meh

zealous osprey
young knoll
#

Most of the time a debugger isn’t worth the effort

zealous osprey
spare hazel
zealous osprey
#

Did you read the article?

spare hazel
#
package com.amirparsa.hypixelskillcore;

import java.util.Map;

public abstract class Skill {
    private int STARTER_XP;

    private int level;
    private int xp;

    private double damageRewards;
    private double healthRewards;
    private double defenseRewards;
    private double moneyRewards;

    public abstract boolean calculateLevelUp();

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public int getXp() {
        return xp;
    }

    public void setXp(int xp) {
        this.xp = xp;
    }

    public double getDamageRewards() {
        return damageRewards;
    }

    public double getHealthRewards() {
        return healthRewards;
    }

    public double getDefenseRewards() {
        return defenseRewards;
    }

    public double getMoneyRewards() {
        return moneyRewards;
    }

    public int getStarterXp() {
        return STARTER_XP;
    }

    public Map<String, Object> serialize(){
        return Map.of(
                "level",level,
                "xp",xp
        );
    }

}

```the whole skill abstract class if that helps
zealous osprey
#

You can use Intelijis Debugger, connect it to a server, like your local test server and get infos about the code you are running

spare hazel
#

oh wait...

quaint mantle
zealous osprey
zealous osprey
spare hazel
quaint mantle
young knoll
#

It counts multiple tabs

#

And also addons

zealous osprey
spare hazel
quaint mantle
quaint mantle
#

the getters can be final

young knoll
#

Shh don’t confuse them with final methods

quaint mantle
#
public final int getLevel() {
        return level;
    }
#

literally still returns level

#

level aint final

zealous osprey
quaint mantle
#

same but with abstract shit, picked up a java course, getting certificate and shit

#

i use a shit ton of abstract now

#

nothing else rlly new tho

#

like only that u can give names to while loops and shit

zealous osprey
#

I started going away from abstracts and doing more stuff with interfaces

quaint mantle
spare hazel
#

wait a minute...

#

is it normal that im defining the variables both in the abstract skill class and the skill class?

quaint mantle
#

no

zealous osprey
#

no?

quaint mantle
#

what

young knoll
#

No

spare hazel
#

how can i fix that

quaint mantle
#

uhhh

#

remove them?

young knoll
#

Only define them in the abstract class?

quaint mantle
#

dont define them

spare hazel
#

bcz when i do level = 69; it gives an error

quaint mantle
#

cus its private

spare hazel
quaint mantle
#

use setLevel(69)

young knoll
#

Use getters and setters to change them

spare hazel
quaint mantle
#

u literally made a function for it

young knoll
#

Or make them protected instead of private

quaint mantle
#

use your functions

spare hazel
#

oh ok

quaint mantle
#

literally there for a reason

fluid river
#

amir needs freejavalessons

#

for sure

eternal night
#

if only someone offered free java lessons 😭

young knoll
#

Who’s java

quaint mantle
#

just use kotlin smh

young knoll
#

I’d rather not

quaint mantle
#

why not

#

easy

young knoll
#

So is java

spare hazel
quaint mantle
#

wow

#

shocker

spare hazel
#

i knew that

quaint mantle
young knoll
#

It compiles to the same JVM code

#

So any speed improvement is solely the compiler

quaint mantle
#

but kotlin kotlin

young knoll
#

Yes, that’s even more reason to not use it

rare rover
quaint mantle
#

i find it confusing sometimes that kotlin does not have the keyword "new"

rare rover
#

It ain't but oki

quaint mantle
quaint mantle
young knoll
#

I don’t see a reason to learn a new syntax just so I can… uhh?

#

Have an extra dependency?

quaint mantle
#

u can just not

#

easy

eternal night
young knoll
#

More dependency mean bigger jar

#

Bigger jar mean people think it fancier

rotund ravine
quaint mantle
#

yea idk

#

i dont use it

#

havent used it in 5 months

#

only thing i would ever use it for is android shit prob

young knoll
#

Like why would I use a join message plugin that’s 20kb when I could use one that’s 2000kb

#

The bigger one must be better

quaint mantle
#

join message plugin?

#

make one yourself

#

easy

#

as

#

that

young knoll
#

What?

#

100x the size means 100x the good

kind hatch
#

More dependencies = more code = more problems.

young knoll
#

That’s why I shade random stock photos into my plugin to boost the size

kind hatch
#

lmao

spare hazel
kind hatch
#

Gotta start doing that if it means better public perception.

young knoll
#

Tbh I think the main thing to boost downloads is having async in the title

#

Or maybe some ✨ dazzle ✨

quaint mantle
#

i should prob transfer my party system to a different plugin than my main one

#

since its in a dungeon crawler plugin?

kind hatch
young knoll
#

✨ Deluxe Async PogSpigot v65.0.1 ✨ (25% SALE!!! 💰)

opal carbon
#

so real

kind hatch
#

commits die

quaint mantle
kind hatch
#

Just end me now. PLEASE

young knoll
#

You gotta bump the version up

young knoll
#

High version means more updates which means better

quaint mantle
#

fixed

rough drift
#

It literally isn't

quaint mantle
#

calm your tits that convo was 30 minutes ago

rough drift
#

I will not

aggressively shaking

quiet ice
#

How to enrage any java dev: mention kotlin

rough drift
#

I used kotlin, and I prefer Java

rare rover
#

okay buddy

mellow pebble
#

hi so im making bungeecord plugin and i came accross ServerConnectedEvent and im curious can that event be used for when player joins server in a network or when joins from for example factions to survival can it be tracked with that event ?

quaint mantle
quaint mantle
echo basalt
#

DataSync

#

none of that deluxe supreme ultra max pro jd

quaint mantle
fluid river
quaint mantle
#

Store

spare hazel
# fluid river true
NukerFall
carefall
This is rocket league!
FREE JAVA LESSONS

JREE FAVA LESSONS
fluid river
quaint mantle
fluid river
fluid river
#

should be TESO respawn system

#

where when you die you turn into a ghost

quaint mantle
#

is it just getting teleported when u die

fluid river
#

and can be reviwed for soul gems

quaint mantle
#

or that

spare hazel
#

i can mass produce plugins but idk how to work with configs

fluid river
#

by yourself or by other players(cheaper)

worldly ingot
quaint mantle
#

i know that,
also gl amir

fluid river
#

so unless you are respawned you are a ghost

quaint mantle
#

but idk what they meant with the respawn system

fluid river
#

it's me lol

#

i mean its my plugin

spare hazel
#

gotta go test my plugin. wish me luck

quaint mantle
quaint mantle
spare hazel
#

why?

quaint mantle
#

cus i already did

fluid river
quaint mantle
#

aint wishing it twice

#

smh

fluid river
#

what exactly does that mean

#

get/set/save/reload/savedefault?

spare hazel
#

oh wait i forgot to build my plugin

mellow pebble
#

anyone familiar with making bungeecord plugins ?

fluid river
#

yeah

#

90% guys here

mellow pebble
#

really simple question just asking someone who has experience

mellow pebble
# spare hazel javadocs: exists

ServerConnectedEvent
Not to be confused with ServerConnectEvent, this event is called once a connection to a server is fully operational, and is about to hand over control of the session to the player.

#

where can i here read if it is only when player connects to the proxy server or if it can be used when player connects to any server

fluid river
#

?jd-bc

spare hazel
#

is there a NetworkConnectedEvent? if there is then this is for server switch

fluid river
#

so you ask this

mellow pebble
#

no no

#

forget it

#

sometimes it is dumb to ask in this chat for help from someone with experience because there will be at least one dumbass that will say read docs like i didnt even try to read the docs

#

if it is written in docs and i have clear answer why would i even come ask here about it 🤦🏻‍♂️

#

yes and in docs it is not written does it trigger only when player is joining proxy server or does it trigger when player joins any server that is in network

#

i know there is switch event but also dumb since you dont have past server where player is from you can only get where is he switching to

fluid river
#

what exactly are you trying to do

terse pumice
#

when teleporting an entity do i need to be checking if the chunk i'm teleporting it to is loaded?

#

unsure if that is done by bukkit automatically

mellow pebble
#

so i want to know can that event be used to get to which server in network is player connecting or it is only when he joins proxy and is being sent to lobby

mellow pebble
#

just player.teleport(location)

terse pumice
#

i'm asking about entities though, i know that when a player is teleported they will automatically load the chunk but am unsure if the same applies for other entities

fluid river
#

not really sure

#

you can quick test it yourself

mellow pebble
#

is there isOp() function for ProxiedPlayer

#

because i cant use it and idk if it is something on my side

terse pumice
#

I can't say I've worked with this myself but you can't op someone on a proxy so I doubt it's a thing

mellow pebble
echo basalt
#

didn't know mojang were the devs of bungeecord

terse pumice
#

they were replying to my unrelated issue aha

mellow pebble
trail coral
#

?pdc

trail coral
mellow pebble
ornate patio
#
Player player = event.getPlayer();
Material holdingType = player.getInventory().getItemInMainHand().getType();

if (player.isSneaking() && (holdingType == Material.POTION || holdingType == Material.SPLASH_POTION || holdingType == Material.LINGERING_POTION)) {
  ...
}
#

any way i can shorten this

#

without listing all 3 potion materials

rotund ravine
#

I mean

#

You can get name and check if it containts Potion

#

an enumset is probably fine too with it listed

ornate patio
rotund ravine
#

true

zealous osprey
#

Do you really need the speed though?

rotund ravine
#

not an enumset tho

ornate patio
ornate patio
trail coral
#

if i save a block in a pdc and then place it, will it still be in the pdc?

chrome beacon
#

Like where is the pdc?

trail coral
#

in a pdc

#

im saving an item

carmine mica
#

blocks don't have PDC

trail coral
#

aw damn

#

im fucked

quaint mantle
#

Manual uwu

chrome beacon
#

If you want to store pdc in a block you can use the chunk pdc

carmine mica
#

block entities have PDC, so if this block has an associated block entity, then you could manually move the PDC info over from the stack to the block entity

chrome beacon
trail coral
#

i want to make a custom effects block or whatever, like giving someone a quartz block that gives them speed2 for example, and i want them to be able to place it aswell

#

and breaking is really easy if i can somehow identify my block after its been placed

chrome beacon
#

Use PDC like we told you too above

trail coral
#

whats a chunk pdc?

quaint mantle
#

Pdc for chunks

trail coral
#

how would i use it

#

?cpdc

#

?chunkpdc

#

:(

chrome beacon
#

Get the chunk

#

Get the pdc

quaint mantle
#

^

chrome beacon
#

And then do your stuff

trail coral
#

pdc of the chunk?

#

oh wait im dumb

#

so just

#

save a chunk, block ?

quaint mantle
trail coral
#

s

#

i understand nothing lmao this is my first time working with pdcs aswell

quaint mantle
#

Deal with bytebuf

chrome beacon
#

All you need to do in this case is save the location of your blocks in the pdc

trail coral
#

wouldnt it be world and coordinates

quaint mantle
#

Block#getChunk ?

chrome beacon
#

Like why have a bunch of locations loaded when the chunks they are in aren't

trail coral
#

i still dont understand how i would save something in a chunk

#

like does a chunk have its own pdc?

chrome beacon
#

Yes

quaint mantle
#

Yez

trail coral
#

oooohhh

#

i get it

#

thank you guys

unborn sable
#

Is there a way for my plugin to place a CreatureSpawner block where the player is?

chrome beacon
#

Get the location of the player is and set the block to spawner?

unborn sable
#

Takes Material and not Block or something like CreatureSpawner

vivid cave
#

is there an event for when a player swaps an item from main to off hand or vice versa ? (out of the inveentory)

chrome beacon
unborn sable
chrome beacon
#

No I mean Material.SPAWNER

unborn sable
#

Then I can't set the type since .setType return void and not the block

quaint mantle
chrome beacon
ornate patio
#

I'm trying to boost a potion's level but for reason meta.hasCustomEffects() is always false

PotionMeta meta = (PotionMeta) holding.getItemMeta();
meta.getPersistentDataContainer().set(new NamespacedKey(plugin, "boostAmount"), PersistentDataType.INTEGER, multiplier);

// Boost effect level of potion
if (meta.hasCustomEffects()) {
    for (PotionEffect effect : meta.getCustomEffects()) {
        int newAmplifier = ((effect.getAmplifier() + 1) * multiplier) - 1;
        meta.addCustomEffect(new PotionEffect(effect.getType(), effect.getDuration(), newAmplifier), true);
    }
}

holding.setItemMeta(meta);
brazen violet
#

packetplayouttitle for 1.20 not working any ideas?

chrome beacon
brazen violet
#

not me asking for a friend

#

so do you have any idea?

chrome beacon
#

No need for NMS

unborn sable
#

Cannot invoke "org.bukkit.inventory.ItemStack.getEnchantments()" because "tool" is null
Why do I get this error when trying to get the item the player used to mine a block with BlockBreakEvent? (I am using event.getPlayer().getItemInUse())

chrome beacon
unborn sable
#

I mean yea since im testing with a pickaxe

ornate patio
lost schooner
#
    @EventHandler
    public void onAnvilPrepare(PrepareAnvilEvent e) {
        Inventory inventory = e.getInventory();
        ItemStack leftItem = inventory.getItem(0);
        ItemStack rightItem = inventory.getItem(1);

        if (leftItem != null && rightItem != null) {
            // Get the enchantments on both items
            Map<Enchantment, Integer> leftEnchantments = getAllEnchantments(leftItem);
            Map<Enchantment, Integer> rightEnchantments = getAllEnchantments(rightItem);
            ItemStack resultItem = stripEnchantments(leftItem.clone());

            // Add the left enchantments
            for (Map.Entry<Enchantment, Integer> entry : leftEnchantments.entrySet()) {
                Enchantment enchantment = entry.getKey();
                int leftLevel = entry.getValue();

                // If the enchantment is on both items, add the higher level or increment the level
                // If the enchantment is only on the left item, add it
                if (rightEnchantments.containsKey(enchantment)) {
                    // If the levels are different, add the higher level
                    // If the levels are the same, increment the level
                    int rightLevel = rightEnchantments.get(enchantment);
                    if (leftLevel != rightLevel) {
                        resultItem.addUnsafeEnchantment(enchantment, Math.max(leftLevel, rightLevel));
                    } else {
                        resultItem.addUnsafeEnchantment(enchantment, leftLevel + 1);
                    }
                } else {
                    // If the enchantment is only on the left item, add it
                    resultItem.addEnchantment(enchantment, leftLevel);
                }
            }

            // Add the right enchantments
            for (Map.Entry<Enchantment, Integer> entry : rightEnchantments.entrySet()) {
                Enchantment enchantment = entry.getKey();
                int level = entry.getValue();

                // If the enchantment is only on the right item, add it
                if (!leftEnchantments.containsKey(enchantment)) {
                    resultItem.addEnchantment(enchantment, level);
                }
            }

            e.setResult(resultItem);
        }
    }
#

When I put a Sharpness V sword and Sharpness V book in, it worked. But when I put a Sharpness VI sword and Sharpness VI book, the result is a sword with Sharpness VII but does nothing when I click it

#

Like I can't pull it out of the anvil

#

Oddly enough, two Sharpness VI swords work

#

The Sharpness VII result sword can be pulled out

#

It seems like enchanted books do not work without their enchantments being meta enchantments

sleek mason
#

Good afternoon! I have a question.
Now I know this might be very frowned upon, and might not exist, but are there any golang bindings available for which to make spigot plugins with? I know I should be using Java for plugins in general, but I cannot code in Java to save my life. I've gotten used to whatever syntax golang uses, that I cannot even read Java code.

craggy estuary
#

Hello I have a question.
When applying patches using applyPatches.sh file it errors out at:

Applying: Spigot Configuration
error: sha1 information is lacking or useless (src/main/java/net/minecraft/server/dedicated/DedicatedServer.java).
error: could not build fake ancestor
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0003 Spigot Configuration
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
  Something did not apply cleanly to Spigot-Server.
  Please review above details and finish the apply then
  save the changes with rebuildPatches.sh

I couldn't figure it out.

sleek mason
#

Are you compiling your own spigot jar?

craggy estuary
sleek mason
#

what's the reason for that?

river oracle
#

Maybe they are forking

#

They don't need a reason really

sleek mason
#

Would make sense yeah

craggy estuary
#

.

river oracle
torn shuttle
#

hey nerds how do you display a barrier particle in anno domini 2023?

sleek mason
#

I'm just curious is all, not meaning to tell them they shouldn't compile their own jars

river oracle
young knoll
young knoll
#

Yeah that one

torn shuttle
#

gotcha

#

thanks nerds

#

except for you @river oracle , you're not even a real nerd

#

you're getting the atomic wedgie

river oracle
#

Send the command you ran

craggy estuary
young knoll
#

You need to provide a path to the work directory for the current version

river oracle
#

^ what I was truna say

sleek mason
#

Would it be feasible to make a plugin that adds a sky block, and an end portal block?

torn shuttle
#

I guess this is not the one

                Particle particle = Particle.BLOCK_MARKER;
                particle.builder().data(Material.BARRIER.createBlockData());
                actualLocation.getWorld().spawnParticle(particle, actualLocation.clone().add(new Vector(0,1,0)), 1);
#

anyone know off the top of their heads how I inject the block data correctly?

unborn sable
#

I send the player a message when they mine a block if the tool is null

torn shuttle
#

nvm got it

rare rover
#

How would I not do this lol

#
    private static final Map<UUID, Map<Material, List<PlayerGenerator>>> playerGenerators = new HashMap<>();```
#

I hate this so much

torn shuttle
#

you're doing that wrong

rare rover
#

I mean it does what I want but in a horrible way

young knoll
#

Make a data class

torn shuttle
#

make a class

young knoll
#

To avoid the nested collections

torn shuttle
#

if you have two maps 99% of the time you should've made it a class

rare rover
#

Yeah true true

#

Because I hate adding and removing to this

#

But I'll change it into a whole class

torn shuttle
#

as well you should

rare rover
#

Thanks

lost schooner
#

How do I make a new ItemMeta?

young knoll
#

Generally you can just do ItemStack#getItemMeta

torn shuttle
rotund ravine
#

Atleats for th esecond part ew

#

nvm

young knoll
#

Which will create one if it doesn’t exist

rotund ravine
#

i read the rest of it just now

lost schooner
rotund ravine
#

Then it's air.

young knoll
#

It will only return null for air

rare rover
rotund ravine
#

It's good, but not for that.

rare rover
#

True

lost schooner
#

How do I convert normal enchants to meta enchants

young knoll
#

?

chrome beacon
#

?

lost schooner
#

So you have ItemStack.addEnchantment etc right

young knoll
#

Mhm

lost schooner
#

But meta enchantments are in EnchantmentStorageMeta.addStoredEnchantment

young knoll
#

It’s the same enchantment

lost schooner
#

Wdym?

#

Normally if I want to dump an entire Map<Enchantment, Integer> into an item I can just use ItemStack.addEnchantments but there is no "multiple enchantment" version of EnchantmentStorageMeta.addStoredEnchantment

chrome beacon
#

For loop

lost schooner
#
        for (Map.Entry<Enchantment, Integer> entry : standardEnchantments.entrySet()) {
            metaEnchantments.addStoredEnchant(entry.getKey(), entry.getValue(), true);
        }
#

I can try this but it says it might result in null exception

#
    public static void convertToMetaEnchants(ItemStack item) {
        if (item == null) {
            return;
        }

        // Convert the "standard enchantments" of the item to "meta enchantments"
        Map<Enchantment, Integer> standardEnchantments = item.getEnchantments();
        EnchantmentStorageMeta metaEnchantments = (EnchantmentStorageMeta) item.getItemMeta();
        for (Map.Entry<Enchantment, Integer> entry : standardEnchantments.entrySet()) {
            metaEnchantments.addStoredEnchant(entry.getKey(), entry.getValue(), true);
        }

        // Strip the "standard enchantments" of the item
        standardEnchantments.keySet().forEach(item::removeEnchantment);
    }
young knoll
#

The enchantment methods in ItemStack just modify the meta

#

If you already have the meta you should use the methods in that instead

lost schooner
#

I don't think that's true because if I add enchantments through ItemStack methods, the enchanted books do not work

#

For instance, a Sharpness V enchanted book will do more damage than it should, rather than working to add enchantments to swords

young knoll
#

ItemStack.addEnchantment just makes a call to ItemMeta.addEnchantment

#

Keep in mind addEnchantment and addStoredEnchantment are different

lost schooner
#

How are they different

young knoll
#

One adds enchantments to the item, the other adds stored enchantments to the item

lost schooner
#

Ok, that it what I'm talking about. There is no ItemStack.addStoredEnchantment

#

You need the meta for that

torn shuttle
#

she's a beaut

lost schooner
#

How do I basically transfer the enchantments to stored enchantments

torn shuttle
#

farming barrier blocks ain't much but it's honest work

young knoll
#

But like I said, if you already have an ItemMeta instance you should use the methods in that

#

Rather than the ones in ItemStack

lost schooner
#

Are stored enchantments only relevant for enchanted books

young knoll
#

Yes

lost schooner
#

So it would be totally fine to have a condition that says "if the result item is an enchanted book, convert all the result enchantments to stored enchantments"

unborn sable
#

java.lang.ClassCastException: class org.bukkit.craftbukkit.v1_20_R1.block.CraftBlock cannot be cast to class org.bukkit.block.CreatureSpawner (org.bukkit.craftbukkit.v1_20_R1.block.CraftBlock and org.bukkit.block.CreatureSpawner are in unnamed module of loader java.net.URLClassLoader @7e774085)

Why can't I get a block as CreatureSpawner even after checking if it is with block.getState() instanceof CreatureSpawner?

young knoll
#

You are trying to cast the block to creature spawner

#

You need to cast the state

unborn sable
young knoll
#

Yes

#

In modern java versions (basically minecraft 1.16+) you can do if (block.getState instanceof CreatureSpawner spawner)

unborn sable
#

If I do EntityType.valueOf("IRON_GOLEM") (the value is an example), does it get the Iron Golem Entity Type?

young knoll
#

It should

unborn sable
#

I am trying to set the spawner type with PDC data but it doesn't set the type.

chrome beacon
#

Show code

unborn sable
#

NamespacedKey key = new NamespacedKey(plugin, "spawnerType");
String spawnerType = pdc.get(key, PersistentDataType.STRING);
CreatureSpawner spawner = (CreatureSpawner) block.getState();

spawner.setSpawnedType(EntityType.valueOf(spawnerType));
young knoll
#

You need to call spawner.update

chrome beacon
#

^

unborn sable
#

Oh...

chrome beacon
#

get state returns a copy

#

Update will apply it

unborn sable
#

It still isn't spawning the mobs

chrome beacon
#

Show the entire code

unborn sable
#
public class BlockPlaceEvent implements Listener {
    private final Silktouch_spawners plugin;
    public BlockPlaceEvent(Silktouch_spawners plugin) {
        this.plugin = plugin;
    }

    public void onBlockPlace(org.bukkit.event.block.BlockPlaceEvent e) {
        Block block = e.getBlockPlaced();
        ItemStack item = e.getItemInHand();
        ItemMeta itemMeta = item.getItemMeta();

        if (block.getType().equals(Material.SPAWNER)) {
            PersistentDataContainer pdc = itemMeta.getPersistentDataContainer();
            NamespacedKey key = new NamespacedKey(plugin, "spawnerType");
            String spawnerType = pdc.get(key, PersistentDataType.STRING);
            CreatureSpawner spawner = (CreatureSpawner) block.getState();

            spawner.setSpawnedType(EntityType.valueOf(spawnerType));
            spawner.update();
        }
    }
}
``` (Left out imports)
young knoll
#

I think you need to wait a tick when using the place event

#

But I could be wrong

#

Because the event fires before the block actually gets placed

quaint mantle
#

Anyone know how OrbitClient increases ur ram usage to crash the client?

unborn sable
#
scheduler.runTaskLater(plugin, () ->{
    spawner.setSpawnedType(EntityType.valueOf(spawnerType));
    spawner.update();
}, 1);
young knoll
#

Move all of it into the delayed part

upbeat fog
#

I need some help with detecting if a player is in a certain radius of an armor stand and give the player regeneration. I tought of a method but its not working.

unborn sable
young knoll
#

At least everything after and including the instanceof check

unborn sable
undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

upbeat fog
#

Basicly whats supposed to happen is when I use an ability, this armorstand and a circle of particles appear and I want it when a player is inside that circle it gives the player healing 3. This is my code:

#
    public void hCSpawnEvent(CreatureSpawnEvent e){
        if(e.getEntity().getType() != EntityType.ARMOR_STAND){
            return;
        }
        if(e.getEntity().getCustomName() == null){
            return;
        }
        if(e.getEntity().getType() == EntityType.ARMOR_STAND && e.getEntity().getCustomName().contains("Healing Circle")){
            healPlayer =  (Player) e.getEntity().getNearbyEntities(.1,.1,.1);
            while(!(e.getEntity().isDead())){
                if(e.getEntity().getNearbyEntities(3,3,3).contains(healPlayer)){
                    healPlayer.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,PotionEffect.INFINITE_DURATION,2));
                }
            }
            if(e.getEntity().isDead()){
                healPlayer.removePotionEffect(PotionEffectType.REGENERATION);
            }
        }
    }```
young knoll
#

Yeah you can’t just use a while loop

#

That’ll lock up the entire server

#

?scheduling

undone axleBOT
upbeat fog
#

Yeah, my first idea was to use a runnable, idk why I switched

#

I still somehow have to find a way to determine the player its supposed to heal

#

I used healPlayer = (Player) e.getEntity().getNearbyEntities(.1,.1,.1); since it spawns at the player's location so I'd just detect the player with that

young knoll
#

Why not just use the player that activates it

#

Or do you want any player inside the circle to be healed

upbeat fog
#

No, only one. At first i tought of getting the player with the rightclick event, when the player activates the ability, but then if someone else used the ability, it would change the player its supposed to heal, wouldn't it?

young knoll
#

No

upbeat fog
#

really?

young knoll
#

Make a class that extends Bukkitrunnable and pass the player you want it to heal in the constructor

#

Then heal said player in the run method

upbeat fog
#

You meant something like this? :

    
    public void HealPlayer(Player p){
        p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,10,2));
    }

    public void run() {
        HealPlayer(events.getInstance().healPlayer);
        runTaskTimer(HB.getInstance(), 5l, 5l);
    }
}```
remote swallow
#

that will keep starting a new task timer running itself

young knoll
#

It also contains no passing of player into constructor

upbeat fog
#

Can you show me what you mean? (Sorry, I do coding occasionally for fun, im no master of Java 💀 )

young knoll
#

private final Player player;

public className(Player player) {
this.player = player
}

remote swallow
#

public class RunnableShit extends BukkitRunnable

    private final Player player;
      
    public RunnableShit(Player player) {
        this.player = player;
    }

    @Override
    public void run() {
        player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,10,2));
    }
}
young knoll
#

No

#

Bad

alpine urchin
#

you can scrape the internet, you won't ever find me putting down protocollib

alpine urchin
#

if anything, i wish more people didn't shade packetevents

remote swallow
#

🥄

alpine urchin
#

i've come to realize i don't like the idea of shading

upbeat fog
#

Bro I just need to get this working, no need to be professional 💀

young knoll
#

I’m going to shade it twice now

alpine urchin
#

people complain about packetevents size but forget protocollib is bigger

remote swallow
#

how big is packet events

young knoll
#

Uhh

#

I think it’s like 2mb without minimizing

wicked remnant
#

thats nothing

remote swallow
#

i would shade it

#

maybe

#

im gonna go find a way to avoid libby

#

oi

#

coll

#

would ur nms thingy break if i shade it into core instead

young knoll
#

What thingy

#

What core

#

What

remote swallow
#

one sec

#

oh WAIT

#

just realised something

#

ignore me

#

"i do anyway"

quaint mantle
alpine urchin
#

so

#

then

#

they have little space for their own shit

#

idk

remote swallow
#

put it on maven central f¯

#

¯_(ツ)_/¯

river oracle
#

Just exclude nms packages

remote swallow
#

yeah well

#

that takes effort

river oracle
fluid river
#

Jawa

river oracle
remote swallow
#

did you steal that off me

remote swallow
#

do you like my commit message

river oracle
#

No

remote swallow
#

why not

ivory sleet
remote swallow
#

no i didnt realise i missed the D on enabled

unborn sable
strange rain
ancient plank
#

and my largest fully custom plugin w/ no external dependency shading is 168KB 5OrnnThinking

warm mesa
#

Hi, Im trying to make an optimizer and right now im trying to make an event that detect when a hopper is getting items inside, but looking in Spigot, I don't see any event, so my question is if somebody can show me how to make an event that detect when a hopper is getting items

young knoll
#

InventoryPickupItemEvent

warm mesa
#

Ammm and with that event can I know when a hopper take an item?

wet breach
#

InventoryMoveItemEvent

young knoll
#

InventoryMoveItemEvent

warm mesa
#

Ammm let me see if I can, hold on

wet breach
#

between those two events you will know if a hopper picks up an item and or moves it to another inventory or hopper

warm mesa
#

@EventHandler
public void onInventoryMoveItem(InventoryMoveItemEvent event) {
if (event.getDestination().getHolder() instanceof Hopper) {
Bukkit.broadcastMessage(ChatColor.YELLOW + "¡Un hopper ha agarrado un item!");
}
}
Let me try with that

wet breach
#

now, as far as making custom events though, that is easy

warm mesa
#

I tried but with the code, when I dropped an item into a hopper, the broadcast do not work.

young knoll
#

That’s the other event

young knoll
warm mesa
#

kk

warm mesa
#

It worked

orchid trout
#

do i have to use fernflower or something to get the source attachment?

drowsy helm
#

use specialsource plugin

orchid trout
#

jav asource attacher

unborn sable
#

Since a NamespacedKey can take a String for both parameters, can I leave the first one blank ("") so it is entered as "name": "value"?

young knoll
#

What

upbeat fog
#

Lmao this shit still aint working

unborn sable
young knoll
#

Maybe

#

But that defeats the entire point of a namespace key

compact haven
#

you can not

unborn sable
young knoll
#

That’s the entire point

unborn sable
young knoll
#

It’s unique to your namespace

#

Otherwise two plugins trying to use the name “type” would break eachother

unborn sable
#

So even if I have one plugin?

compact haven
#

a namespace must not contain anything other than a-z, 0-9, dot, _, or -. it also must be at least 1 character

young knoll
#

Technically a-z

compact haven
#

same with keys, but keys can also have a / for whatever reason

compact haven
worldly ingot
#

because vanilla keys with / exist

#

Biome tags for instance have minecraft:generator/can_generate_ancient_city or something like that

compact haven
#

ah

stoic lichen
#

hello can someone help me about gradle plugin building

young knoll
#

What about it

stoic lichen
#

i just want to build an opensource plugin

#

but i dont know anything about gradle

young knoll
#

If they have it set up right it should be as simple as running gradle build

stoic lichen
#

idk it have a bat file

#

when i run it it shows up 1 sec and go away

young knoll
#

That’s the wrapper

#

Open a command line and run gradlew build

stoic lichen
#

i dont have gradle too

#

how to i get it

young knoll
#

You shouldn’t need it

#

That’s what the wrapper is for

stoic lichen
young knoll
#

Ah powershell how we love you

#

./gradlew build

stoic lichen
#

he loves you back :D

young knoll
#

They must have the wrapper set up wrong

#

You can download gradle here

stoic lichen
#

:(

young knoll
stoic lichen
#

oh

#

btw whats that mean

Project at 'D:\eclipseworkspace\Custom-Nameplates-main' can't be named 'CustomNameplates' because it's located directly under the workspace root. If such a project is renamed, Eclipse would move the container directory. To resolve this problem, move the project out of the workspace root or configure it to have the name 'Custom-Nameplates-main'.

young knoll
#

Seems fairly straightforward to me

stoic lichen
#

idk anything abt gradle

#

i use maven

#

i fix it ig

#

:(

stoic lichen
young knoll
#

Maybe

#

What is is

stoic lichen
#

Its actually a paid plugin

#

but some how it has source code

#

and i find out it

young knoll
#

Generally paid plugins do that for people who are experienced and can solve any issues themselves

stoic lichen
#

i tried to build for a few hours

young knoll
#

Being able to build it yourself is basically proof you can handle your own issues

stoic lichen
#

and i need it

#

there is an economic crisis in our country

#

our money's value decreased by like 25% in 3 days

#

and we cant afford it

#

idk man

#

anyways thanks for helping

young knoll
#

There’s an easy way to go from crop to seed

#

BlockData#getPlacementMaterial

opaque scarab
#

Any way to disable tree generation?

quaint mantle
#

I'm looping through all blocks in a area and its picking up every single block except for player heads and wither skull and creeper head... is there a reason that would cause this?

#
        for (x in minPoint.x.toInt()..maxPoint.x.toInt()) {
            for (y in minPoint.y.toInt()..maxPoint.y.toInt()) {
                zLoop@ for (z in minPoint.z.toInt()..maxPoint.z.toInt()) {
                    val block = world.getBlockAt(x, y, z)

                    if (block.type != Material.AIR) Bukkit.broadcastMessage("${block.type} ------------[${block.location}]")

                    if (block.state is Skull) {
terse pumice
#

Is there an event that is triggered by player.setMetadata()

eternal oxide
#

no

terse pumice
#

gotcha, thank youu

orchid gazelle
buoyant viper
#

hmm

orchid gazelle
#

I approve

terse pumice
#

I'm trying to add support for some Vanish plugins and a handful set the player metadata so was hoping I could use that instead of all the separate APIs

#

lmaoo

upper hazel
#

correct me if I misunderstood. Is it really possible to make 1 plugin fill the plaseholder with its data and this plaseholder can be used by another plugin?

terse pumice
#

if you make a placeholder with PlaceholderAPI other plugins that support it will also be able to use your placeholder

upper hazel
#

this is cool

#

but how plaseholder api connect my plaseholder with another plagin? through packages?

terse pumice
#

if you want support with working on it you'd probably be better suited joining their server

upper hazel
#

thf

robust portal
#

People I've come to you because I'm truly confused.

#

So essentially I'm trying to give the item under hand1 to a player but I cannot for the life of my figure out how to access it

#

This is as far as I got before I gave up.

#

The second thing is accessing it if it always is changing? It's not always going to be diamond helmet

#

Nevermind I simplified the config file lol

hybrid spoke
#

config 1, alexjones 0

robust portal
#

Configs are dumb and I hate them

wintry zenith
robust portal
#

Truth be told I've been coding plugins for about 5 hours now and they just confused the absolute dog piss out of me.

#

Ah fuck me I'm lost again

upper hazel
#

' ' - ?

robust portal
#

huh

upper hazel
#

what this - 'UNBREAKING' - why ' '

robust portal
#

Idk I think i got it

upper hazel
#

a wait this list

#

all normal

#

a wait

#

no

#

wt

robust portal
#

What?

upper hazel
#

ENCHANTMENTS:

#

UNBREAKING: 3

#
  • not exists
buoyant viper
# robust portal

ur appending ".item" outside of the actual config.getString(), u want to do config.getString(args[1] + ".item");

robust portal
#

Oh wow smh

upper hazel
#

'-' not shold be here in UNBREAKING

robust portal
#

Why

upper hazel
#

bc this not list this key

robust portal
#

So like this?

upper hazel
#

no such format exists

#

нуы

#

yes

#

ah end delete ' '

buoyant viper
#

i mean, it could work

#

who knows

upper hazel
#

'-' not shold be here in UNBREAKING

#

' ' - not shold be too

robust portal
#

Do I have to reset the item when adding an enchantment? No right?

buoyant viper
# robust portal

oh yeah, the same will go for getStringList(), ur appending the rest of the path outside of the method for some reason, lol

robust portal
#

What a stupid fucking mistake

buoyant viper
#

so getStringList(args[1] + "hand1.ENCHANTMENTS")

upper hazel
#

whaaa ?

buoyant viper
#

theyre just grabbing values wrong :P

#

or well, correctly, but wrongly

upper hazel
#

what obaut '-' not shold be here in UNBREAKING
' ' - not shold be too

buoyant viper
#

no point in me saying it :P u already told them

upper hazel
#

getStringList(args[1] + "hand1.ENCHANTMENTS") - not tue

#

true

#

for(String key: section.getConfigurationSection(path){

#

wait a moment i write

#

here is an example. Didn't check but something like this

sturdy reef
#

i'd appreciate help on my issue

robust portal
#

Everything works but not item meta isnt setting?

sturdy reef
buoyant viper
#

yes, getItemMeta is a copy, not the original

robust portal
#

Ewww

#

I just realized how fucked off that code is

sturdy reef
#

something like

ItemMeta meta = entity.getEquipment().getItemInMainHand().getItemMeta();
meta.//do whatever you want
entity.getEquipment().getItemInMainHand().setItemMeta(meta);```
sturdy reef
#

with my issue

buoyant viper
#

depends on the issue

sturdy reef
#

.

#

im translating color codes correctly

#

but when i send the message as a TextComponent using .spigot()

#

it get's messed up

buoyant viper
#

what is TextHelper#format and translateHexColorCodes

#

?jd-bcc 1sec

sturdy reef
#
public static String format(String string) {
        return ChatColor.translateAlternateColorCodes('&',string);
    }```
buoyant viper
#

u probably want to use TextComponent.fromLegacyText(String), not just new TextComponent(String)

upper hazel
robust portal
#

Do what?

buoyant viper
#

mans wants a custom item, wouldnt blame em

sturdy reef
#

fromLegacyText() returns a string

buoyant viper
upper hazel
#

i meam you can just use code which i showed above

#

read at your leisure about keys in config.yml

upper hazel
buoyant viper
#

net.md_5.bungee.api.chat.TextComponent#fromLegacyText(java.lang.String) returns a String for u?

robust portal
#

@upper hazel No shit lol

#

Thats why I

#

am here.

sturdy reef
buoyant viper
#

weird, u should be able to use it in it, hell, i do

robust portal
#

Well now everything works but the enchantments smh

upper hazel
robust portal
#

Word alrighty then lol

sturdy reef
#

but on player.spigot()

#

it has to be an array

buoyant viper
#

that one of mine sends from Player.Spigot :p

sturdy reef
#

damn

buoyant viper
#

fromLegacyText very much should be returning BaseComponent[]

sturdy reef
#

intellij is just wilding on my end

buoyant viper
#

maybe try invalidating caches n restart ig

quaint mantle
#

How would one make custom inventory textures ( I just mean opening it and specificying that the client should use it)

robust portal
#

They aint adding boys

upper hazel
#

here a normal code

sturdy reef
#

am i dumb

#

or i just have to do that everytime

@EventHandler
    public void onChat2(AsyncPlayerChatEvent event){
        event.setCancelled(true);
        Player player = event.getPlayer();
        BaseComponent[] format = TextComponent.fromLegacyText(
                TextHelper.format(PlaceholderAPI.setPlaceholders(player, "%luckperms_prefix%") +
                player.getName() + " &8&l➥ " + event.getMessage()));
        for (BaseComponent baseComponent : format) {
            baseComponent.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT,new Text("Hello")));
        }
        player.getServer().spigot().broadcast(format);
    }```
#

looping through every baseComponent

#

before looping

#

after

#

anyways thank god i figured it out

#

winn<3

robust portal
#

@upper hazel Did not work at all

buoyant viper
buoyant viper
robust portal
#

@upper hazel

quaint mantle
#

How would one make custom inventory textures ( I just mean opening it and specificying that the client should use it)

robust portal
#

@upper hazel wya bro help a brotha out

upper hazel
#

delete -

#

end ' '

robust portal
#

I did

upper hazel
#

give me screen config

robust portal
upper hazel
#

delete -

#

in all

#

section

#

whait

robust portal
upper hazel
#

my code not for this config

robust portal
#

Welll could you make it for it because I am stumped brother

upper hazel
#

wait you want setting armor?

robust portal
#

No

#

disregard the armor

#

focus on hand1

upper hazel
#

you need to do the config first

vivid cave
# robust portal

Why don't you treat the null case separatly ?
Like if null, don't add enchants

#

NGL I don't like your code

#

I don't think you should do a for loop to iterate over all main keys

robust portal
#

I wasnt planning it this isnt my original code

vivid cave
#

Hold on lemme do smth for you.

#

Lemme grab my pc and it takes some time to wake up this grandma

vivid cave
#

Inside mob1 ?

#

Or is it the whole file

robust portal
#

Inside mob1

vivid cave
#

Ok

upper hazel
#

here is APPROXIMATELY if only to cover the hand1 section. There's a lot more to add

#

look tutorial on youtube obaut config

#

custom end default config

quaint mantle
upper hazel
#

nah bad idea)
serilization best

glad prawn
vivid cave
#

@robust portal here's what i made

if (hand1!=null){
    String itemMaterial = hand1.getString("item");
    Material mat = Material.getMaterial(itemMaterial);
    if (mat!=null){
        ItemStack item = new ItemStack(mat);
        String itemName = hand1.getString("name");
        item.setDisplayName(itemName);
        ConfigurationSection enchantments = hand1.getConfigurationSection("ENCHANTMENTS");
        if (enchantments!=null){
            for (Map.Entry<String,Object> entry: enchantments.getValues(false).entrySet()){
                Enchantment ench = Enchantment.getByKey(NamespacedKey.fromString(entry.getKey()));
                if (ench!=null) item.addEnchantment(ench, (Integer)entry.getValue());
            }
        }

    }        
}```
#

edited

upper hazel
#

item.addEnchantment(ench, (Integer)entry.getValue()); - i recomend use addSafeEnchantment

eternal oxide
#

there is no addSafeEnchantment

#

there is addUnsafe, but read its javadoc

#

addEnchantment isjust fine so long as you are within the limits of enchantments

upper hazel
#

yea

vivid cave
upper hazel
#

who knows if the way to find the right entity in the worlds is optimized if you constantly record its location in the database

eternal oxide
#

no point in storing an entities location

upper hazel
#

it means it is better to find it through the usual world methods

vivid cave
#

through id

#

save the id in the db

upper hazel
#

i want to get a horse with a specific key, but for this i need to find it in all worlds

vivid cave
#

and upon entities load event, retrieve it if the entity has the same id

#

ah

eternal oxide
#

tag the entitys PDC

vivid cave
#

what is PDC ?

eternal oxide
#

?pdc

vivid cave
#

ah yeah just bukkit way of writing nbt

#

im a gangsta and use NMS with CompoundTag 😎

upper hazel
# eternal oxide ?pdc

yea but how to get through the id without going through the horse entities in the world

vivid cave
eternal oxide
#

what are you doing with the horse?

vivid cave
upper hazel
#

in my plugin, the horse is supposedly the property of the player (as in gta rp with cars) and when entering a command, the player teleports the horse to himself

#

so for teleport i need find horse

#

in ALL worlds

eternal oxide
#

you can;t guarantee the horse will even be loaded.

#

you would be better spawning a new horse when you need it and destroy it when it goes out of range

#

or is unloaded

upper hazel
#

wait i cant get all entity in world if he not load?

vivid cave
#

yeah

eternal oxide
#

no

vivid cave
#

its kinda shit

eternal oxide
#

you only get loaded entities

upper hazel
#

demm

#

and if you load the server with a plugin?

#

in start server

zenith gate
#

When refernecing a namespace key from string do I have to specify pluginName:key or can i just put the name of the key.

vivid cave
#

you have a function which takes both arguments iirc

#

plugin, string

#

if you don't precise the plugin it will default to minecraft namespce iirc

#

but ain't sure

zenith gate
#

so in my case it woud be "pluginname:mykeyname"

vivid cave
#

ah, idk sorry

upper hazel
eternal oxide
#

there is a Chunkunload event

upper hazel
#

i hope this not will hard

#

ah wait

#

if the horse is not loaded, then the location does not change, right?

#

so i can find location end load chank

#

if the location is loaded then the location will be updated

#

or not updated

#

how you think this good idea

#

?

eternal oxide
#

if I were you I'd destroy the horse on chunkUnload. Then when you need the horse, check all worlds for teh horse, if not found, spawn a new one

vivid cave
upper hazel
#

but Is my idea really that bad, I think it's easier no?

eternal oxide
#

no

#

you will lose track of a horse

#

if you allow it to save in an unloaded chunk

upper hazel
#

if i load this chank

#

when find

#

?

vivid cave
#

fromString(key) calls, fromString(key, defaultNamespace=null);

Major steps of fromString(key, defaultNamespace) code that would make it work for your case key="pluginname:mykeyname"

String[] components = string.split(":", 3);
String key = (components.length == 2) ? components[1] : "";
...
if (components.length == 1) {
  //not the case for you
  ...
  return
}
...
String namespace = components[0];
return new NamespacedKey(namespace, key);
#

@zenith gate so NamespacedKey.fromString("pluginname:mykeyname");
works totally

upper hazel
#

the idea is to load the location into the database every second and when the command to get the location is entered, load the chunk and find the horse within a radius of 4 blocks

zenith gate
upper hazel
#

if chank not loaded location not changes

#

yes?

vivid cave
upper hazel
#

@eternal oxide how you think?

vivid cave
#

if your IDE has a decompiler (like IntelliJ or VS Code with java language + gradle/maven support), you should be able to shift/ctrl click function names to see their source

hybrid spoke
#

if you decompile my source i will sue you

eternal oxide
#

off to download all GodCiphers plugins

hybrid spoke
#

dont you dare to also buy the premium ones 😠

eternal oxide
#

I'll use my leet hax0rz skills to not pay

vivid cave
# upper hazel the idea is to load the location into the database every second and when the com...

sorry if it doesn't answer your question, I would do the following:
Whenever some entity load (EntitiesLoadEvent),
Check if they match one of the horse of your db,
If they do: Save the horse entity in your memory (ElgarL will heavily disagree with that but eh),

When someone tries to teleport the horse to them, try to retrieve it from your horse array or whatever structure of your memory you saved it in,
If no find, or if the horse.isValid()==False, then either tell them that their horse couldn't be found, or summon a new horse with same nbt

upper hazel
#

I can just save the serial data about the horse, including skin color and so on?

vivid cave
#

yaaa

upper hazel
#

how can I delete a horse if it is in an unloaded chunk?

#

a wiat

eternal oxide
#

you can;t without loading the chunk

upper hazel
#

i se

#

e

vivid cave
#

the whole issue is that you can't deal with unloaded shit

#

i mean there must be a way somewhere to get the unloaded entities

#

but it's prolly obscure

eternal oxide
#

just delete on chunk unload

upper hazel
#

ok

eternal oxide
#

then you have no issues with old horses in unloaded chunks

upper hazel
#

tin will have to work hard with the database

vivid cave
#

best way to get instant ping of a player?
i realised it's often with a bad update rate, like 5 or 10 seconds or smth ?
I need it to be very dynamic; within a (dt) rather than a (delta t)

eternal oxide
#

the only things you need to store are the details about the horse

#

which don;t change

upper hazel
#

Is this plugin expensive?
horse have another skills

vivid cave
#

ALso is there a way to know about "how much available ram" does the player still have ? (for minecraft)

hazy parrot
#

Player or server?

vivid cave
#

yeah thats what i thought

#

do you guys know how to get a more precise player latency?

#

the shit it returns is within a 5 or 10 seconds refresh rate

#

it aint enough

#

i need a half second (at least) precision

pearl steppe
#

guys i dont know what it is. Custom Structures plugin, and 1 16 5 world edit.

vivid cave
#

hm

vivid cave
#

idk

#

Moving on to my next question, can you guys think of any other way an itemstack can display ?

  • container (any kind of inventory/stuff containing slots)
  • item display (1.19.2 thinggie)
  • item frame
  • Item
chrome beacon
#

Item display is 1.19.4

vivid cave
#

my bad yeah

novel scaffold
#

net.minecraft.util.ReportedException: Ticking entity how can i fix this error?

drowsy helm
#

show the full error

vivid cave
drowsy helm
#

and show your code

novel scaffold
chrome beacon
alpine urchin
#

if you really want it to be as instant as possible youll need to deal with lower level packets

#

but otherwise you can just use player.getPing() which is updated every ~20 seconds

vivid cave
#

or something

#

i forgot which one

alpine urchin
#

ok then do it

vivid cave
#

my plugin does some animation
depending on player connection, it lowers the frame rate, lowers the download rate, lowers the "view angle", etc

alpine urchin
#

what minecraft version are you using

vivid cave
#

1.20

alpine urchin
#

use ping pong packets

vivid cave
#

mkay, but u sure there isn't a native way within ServerPlayer or smth to change granularity ? (which already does the packet job)

#

1 year ago someone told me but i forgot cuz i paused the project since then

alpine urchin
#

idk, ping pong packets is how anticheats do it

#

you can dig into source code

vivid cave
#

hm ok

chrome beacon
silver viper
trail coral
#

how would i scan all blocks above a block?

#

like directly above

flint coyote
chrome beacon
trail coral
#

loop thru what

vivid cave
trail coral
#

also isnt that inneficient?

chrome beacon
trail coral
#

so how would i get the blocks above

flint coyote
chrome beacon
flint coyote
#

atleast not with the amount of details you gave us

trail coral
#

im placing a block, and then another block 10 blocks above OR 10 blocks below and whenever i step on either of them i get teleported to the closest block

#

either up or down

#

it can be anywhere from 1-10 blocks distance

flint coyote
#

I mean you could store the next block via pdc. Although 1-2 blocks below would let you either be in the ground or suffocating

trail coral
#

okay so how would i scan 16 blocks in both directions (up and down.)

#

with 2 for loops?

#

1 checking for a block above and another checking for a block below

flint coyote
#

could do 1 loop and use the loop variable to once add and once subtract it from the location

chrome beacon
#

Will minimize the block lookups required

trail coral
#

i only need to check a 16 block radius

silver viper
eternal oxide
#

you are going to end up with a lot of lost horses in the worlds when your server stops/starts

flint coyote
#

Which persistent data container do you wanna store the horse's data in? Obviously you can't store it on the horse. Will you use the players PDC?

silver viper
#

yeah the players pdc

flint coyote
#

where do you store the horses to remove?

eternal oxide
#

Delete horses in chunk unload so you don;t have junk data stored in unloaded chunks

#

its simpler to clean up when the data is already loaded than try to catch old data when loading

silver viper
flint coyote
#

Then how do you know whether it has to be deleted or was never teleported/recreated?

silver viper
#

i'd probably just delete it as players could just respawn one whenever they want to