#help-development

1 messages · Page 973 of 1

blazing ocean
#

?stacktrace

undone axleBOT
polar forge
#

^

vital void
blazing ocean
#

looks like a connection issue

#
MongoDB Developer Community Forums

Hello @Prasanna_Bale, welcome to the MongoDB community forums. Based on the error message you provided, it appears that you might be encountering a similar issue to the one described in JAVA-2609: mongo throws IllegalStateException: state should be: open. The error could be caused by another process or thread closing the connection with your Mo...

#

?google first 🙏

undone axleBOT
vital void
#

did that

#

even if i create a new connection

#

it dosent make a difference

#

now im getting this

blazing ocean
#

you shouldn't make a new connection on each access

vital void
#

i know

#

but for testing

blazing ocean
#

no

#

you should just not do that

#

show your getMongoDb() method

vocal dew
#

I will put my plugin.yml like this
name: {$PluginName}
main: {$PackageName}.{$MainClass}
version: {$VersionNumber}

vital void
#
mongoDB = MongoClients.create(uri);
blazing ocean
#

yeah

vital void
#

that how i create my connection

blazing ocean
#

that's the issue

blazing ocean
#

you should just have one private static connection that gets initialised at your onEnable and return that

vital void
#

i haev thjat

#

thats where that method is

blazing ocean
#

well you just told me differently

vital void
#

i said for testing i created a new instance

#

and it didnt make a difference

#

so i came here

polar forge
blazing ocean
#
private static MongoClient client;
public static MongoClient getMongoDb() {
    return client;
}

@Override
public void onEnable() {
    client = MongoClients.create(uri);
}
vocal dew
vital void
#

i use lombok

#

so same pre much

blazing ocean
vital void
#

i just use a @getter

polar forge
polar forge
#

Much more easier

vocal dew
polar forge
blazing ocean
#

that's how I do it in all my apps

vital void
#

brb

eternal oxide
blazing ocean
vocal dew
#

I was used jetbraing pycharm its very lagging

eternal oxide
#

IJ with the MC dev plugin kills full powered PC's

blazing ocean
#

skill issue?

#

doesn't for me

eternal oxide
#

he also only has 6gb of ram

polar forge
#

Well I’m using a laptop from 2015 MacBook and it works fine

eternal oxide
#

IJ is memory hungry

blazing ocean
#

i have 8, uses 4-5

polar forge
#

It sounds like a storage skill issue

eternal oxide
#

storage skill issue?

vital void
#

@blazing ocean why static

#

why not from an instance of main class

blazing ocean
#

oh i thought that was just a helper class

vital void
#
        main.getMongoDB().getDatabase("testDb").getCollection("_testcollection").insertOne(document);
#

this an okay way of doing it?

drowsy helm
#

main 😓

vital void
#

and should i have 1 document per player or all players in 1 document

#

@drowsy helm whats wrong with main

vocal dew
#

where I can find the plugin

eternal oxide
#

target folder in your project

vocal dew
#

but I am not sure if my laptop will open tlauncher xd

oak mica
#

How would I make this entity follow a player

chrome beacon
#

Add a follower goal

vocal dew
#

what I need to put in the plugin yml

oak mica
#

could i make the entity save a player that it will follow but not attack

chrome beacon
#

If you want

vocal dew
night parrot
#

how do I convert a server wise plugin to a bungeecord plugin

oak mica
#

so you would use followmobgoal i presume

#

how owuld you get a player as the mob

chrome beacon
#

What plugin is it

oak mica
chrome beacon
#

A player isn't a mob

#

So that's not the right goal

night parrot
chrome beacon
#

Then just rewrite it using the Bungeecord api

night parrot
#

thats the problem, I dont do bungeecord

chrome beacon
#

not much carries over

#

api wise

oak mica
#

that contains follow

chrome beacon
night parrot
chrome beacon
#

How do you think pets work

vocal dew
#

bro I will leave coding plugin because my laptop cant open minecraft and eclipse same time my laptop is very bad so I will next with html css javascript and python

oak mica
chrome beacon
#

There you go use that

oak mica
#

and you cant use a zombie with it because a zombie isnt a tamableentity

chrome beacon
#

You can use the logic from it

oak mica
#

so making a custom goal?

chrome beacon
#

yes

oak mica
#

is there no other way to do it

chrome beacon
#

There probably is

smoky anchor
#

Heyo, how do I get a block with the full data, for example chest with its content or sign with text.
I want to store a block in memory and then later place it somewhere.
Full context: creating undo for my own "world edit" thing.

I was told to store the BlockState, but I don't see a way of placing it.

smoky anchor
#

this will not modify the state of a block if it is no longer the same type as it was when this state was taken. It will return false in this eventuality.
So I first have to place the block data, then do update ?

chrome beacon
#

yes

#

set type and apply state

small valve
#

Is there an event to check when a player attempts to use a spawn egg on a monster spawner?

chrome beacon
#

PlayerInteractEvent

drowsy helm
#

Interact wvent

small valve
#

ahhh is ee

lost matrix
#

is even eee

oak mica
#

How would you get a net.minecraft.world.entity.player.Player target block

#

theres no function in ti

lost matrix
civic sluice
#

org.bukkit.entity.Player provides a method for raytracing and getting a targeted block.

still ridge
#

hello, I read the documentation and I found to change the durability in 1.20 I need to write

ItemMeta meta = event.getItem().getItemMeta()
((Damageable) meta).damage = damage
event.getItem().setItemMeta(meta)

but if I set damage to 0 to remove all damage i keep the durability - 1 on my item, I do somethings wrong ? (i do this piece of code in a PlayerItemDamageEvent event handler)

oak mica
alpine urchin
#

why can't you use bukkit?

#

why NMS?

civic sluice
rapid vigil
lost matrix
still ridge
#
@EventHandler
fun onItemDurabilityDown(event: PlayerItemDamageEvent)
#

(it's in kotlin)

civic sluice
oak mica
#

is there a better way than adding every mob manually

lost matrix
#

PS: You should structure your code a bit more to reduce all those getter calls

ItemStack item = event.getItem();
ItemMeta meta = item.getItemMeta();
Damageable damageable = (Damageable) meta;
damageable.setDamage(0);
item.setItemMeta(meta);

// Now you need to prevent the item from being damaged after you repaired it:
event.setDamage(0);
// or
event.setCancelled(true);
still ridge
lost matrix
civic sluice
lost matrix
small valve
#

I'm not sure though

civic sluice
oak mica
#
        this.target = this.mob.level().getNearestEntity(StreamSupport.stream(this.mob.level().getEntities().getAll().spliterator(), false).filter(entity -> entity instanceof LivingEntity && entity != this.mob && entity != this.p && entity.isAlive() && !entity.isSpectator()).map(entity -> (LivingEntity) entity).toList(), this.targetConditions, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
#

how scuffed is this

tardy delta
#

cringe

shadow night
#

what in the god is that

oak mica
tardy delta
#

reason youre using a spliterator?

oak mica
#

turning it into a stream

tardy delta
#

turning a collection into a stream?

glad prawn
oak mica
tardy delta
#

who even returns an Iterable \💀

oak mica
#

How do i turn org.bukkit.entity.Player into net.minecraft.world.entity.player.Player

oak mica
tardy delta
#

mojang moment

civic sluice
oak mica
#

tyy

#

How would I turn ```java
public class MiniWarde extends Zombie

into a Entity
tardy delta
#

cast it?

oak mica
#

was just askign cuz i usually try not to cast

tardy delta
#

should be an Entity implicitly, atleast if Zombie is

oak mica
tardy delta
#

org.bukkit.entity.Zombie is an Entity

#

ahh youre probably using nms

oak mica
#

i am yes

#

net.minecraft.world.entity.monster.Zombie

tardy delta
#

havent used nms for years but isnt there a getBukkitEntity() or is that craftbukkit

oak mica
#

yeah

#

there is

#

ty

#

Caused by: java.lang.ClassNotFoundException: net.minecraft.world.entity.player.Player

#

oh lord

shadow night
#

remapping moment

oak mica
#

of course it doesnt work

chrome beacon
#

You forgot to remap

oak mica
#

yeah no i fixed that

#

the pathfinding doesnt owrk

#

it should follow me and target mobs

#

instead it just stands there

peak jetty
#

why is that?

oak mica
#

you can use addUnsafeEnchantment or something

#

now it crashes the server :goog:

#

this doesnt wanna work

#

hell nothing wants to work

#

im so confused

#
public class FollowPlayerGoal extends Goal {

    public Player target;
    public Mob mob;
    private int timeToRecalcPath;
    private float oldWaterCost;
    private final PathNavigation navigation;


    public FollowPlayerGoal(Player target, Mob mob) {
        this.target = target;
        this.mob = mob;
        this.navigation = mob.getNavigation();
    }

    public void start() {
        this.timeToRecalcPath = 0;
        this.oldWaterCost = this.mob.getPathfindingMalus(BlockPathTypes.WATER);
        this.mob.setPathfindingMalus(BlockPathTypes.WATER, 0.0F);
    }

    public void stop() {
        this.navigation.stop();
        this.mob.setPathfindingMalus(BlockPathTypes.WATER, this.oldWaterCost);
    }

    public void tick() {
        if (--this.timeToRecalcPath <= 0) {
            this.timeToRecalcPath = this.adjustedTickDelay(10);
            double var0 = this.mob.getX() - this.target.getX();
            double var2 = this.mob.getY() - this.target.getY();
            double var4 = this.mob.getZ() - this.target.getZ();
            double var6 = var0 * var0 + var2 * var2 + var4 * var4;
            if (!(var6 <= (double)2)) {
                this.navigation.moveTo(this.target, 1f);
            } else {
                this.navigation.stop();
            }
        }
    }

    @Override
    public boolean canUse() {
        return true;
    }
}
#

The target is null

#

by the time it gets to tick()

#

i have no clue why

#

I added a null check to tick() now it jsut doesnt move

worldly ingot
#

Then you're passing null to the constructor because it's assigned nowhere else

summer gale
#

How do i add a NBT tag to a entity using spigot NMS 1.15.2

oak mica
#

so it registers before p is set, but i cant set p before either

worldly ingot
#

I thought goals were initialized in a separate method now

oak mica
#

if you go like 10 methods into the super() it registers goals

worldly ingot
#

Are you on the latest version?

oak mica
#

yeah

#

1.20.4

worldly ingot
#

Suppose your only option is to instead pass it lazily. Store it in the entity itself, then in your goal, pull it from the entity

oak mica
#

alright

worldly ingot
#

You can pass the entity itself into your pathfinder's constructor

oak mica
#

yeah i already do that

worldly ingot
#

Then yeah, just be sure you're still doing a null check somewhere

#

Likely in the canUse() method

summer gale
#

How do i add a NBT tag to a entity using spigot NMS 1.15.2

worldly ingot
#

You should have access to the PersistentDataContainer of an entity

#

Entity#getPersistentDataContainer()

summer gale
#

i have access

oak mica
#

alright that works ty

summer gale
#

like i have access to the entity.getBukkitEntity.getPersistentDataContainer

oak mica
#

then you can just use PersistentDataContainer#set

worldly ingot
#

Wait, you're using NMS? PandaThink

summer gale
#

ya

#

But 1.15.2 NMS

worldly ingot
#

Are you extending a vanilla entity class?

#

Or just accessing it?

summer gale
#

extending

#

trying to make a Pet plugin

worldly ingot
#

Then you can override the read/write methods for NBT instead

#

Don't remember what they're called. It's like "save()" and "read()" or something

summer gale
#

yea intellij shows save and read

#

but could those be used to set the texture of the entity?

worldly ingot
#

The texture? Probably not

#

You would need a resource pack for that

summer gale
#

yea using a texture pack

worldly ingot
#

Don't think you can render a specific texture based on NBT though (exception to ones the client actually understands, like cat or villager variants for example)

oak mica
#

neither of them actually make it target a player

#

wait

#

it doesnt actualyl attack

#

it looks at them but doesnt target

icy beacon
oak mica
#
public class MiniWarde extends Zombie {

    public final Player p;

    public MiniWarde(Location loc, Player p) {
        super(EntityType.ZOMBIE, ((CraftWorld) loc.getWorld()).getHandle());

        this.setPos(loc.getX(), loc.getY(), loc.getZ());

        this.setCanPickUpLoot(false);
        this.setAggressive(true);
        this.setCustomNameVisible(true);
        this.p = p;
    }

    @Override
    public void registerGoals() {
        this.goalSelector.addGoal(1, new FollowPlayerGoal(this));
        this.goalSelector.addGoal(1, new MeleeAttackGoal(this, 2.0F, true));
        this.targetSelector.addGoal(0, new TargetMob<>(this, true, false));
        this.goalSelector.addGoal(8, new LookAtPlayerGoal(this, Player.class, 8.0F));
        this.goalSelector.addGoal(8, new RandomLookAroundGoal(this));
    }

    @Override
    public void addBehaviourGoals() {
        this.goalSelector.addGoal(2, new ZombieAttackGoal(this, 1.0, false));
        this.goalSelector.addGoal(6, new MoveThroughVillageGoal(this, 1.0, true, 4, this::canBreakDoors));
        this.goalSelector.addGoal(7, new WaterAvoidingRandomStrollGoal(this, 1.0));
        this.targetSelector.addGoal(1, (new HurtByTargetGoal(this)).setAlertOthers(ZombifiedPiglin.class));
    }

    @Override
    public boolean isSunSensitive() {
        return false;
    }
}```
#

i got the moving thing to work

icy beacon
#

Ah

oak mica
#

but it doesnt target

#
public class TargetMob<T extends LivingEntity> extends TargetGoal {
    protected final int randomInterval;
    @Nullable
    protected LivingEntity target;
    protected TargetingConditions targetConditions;

    public TargetMob(Mob entity, boolean flag, boolean flag1) {
        super(entity, flag, flag1);
        this.randomInterval = reducedTickDelay(10);
        this.setFlags(EnumSet.of(Flag.TARGET));
        this.targetConditions = TargetingConditions.forCombat().range(this.getFollowDistance());
    }


    public boolean canUse() {
        if (this.randomInterval > 0 && this.mob.getRandom().nextInt(this.randomInterval) != 0) {
            return false;
        } else {
            this.findTarget();
            return this.target != null;
        }
    }

    protected void findTarget() {
        this.target = this.mob.level().getNearestEntity(StreamSupport.stream(this.mob.level().getEntities().getAll().spliterator(), false).filter(entity -> entity instanceof LivingEntity && entity != this.mob && entity != ((MiniWarde)this.mob).p && entity.isAlive() && !entity.isSpectator()).map(entity -> (LivingEntity) entity).toList(), this.targetConditions, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
    }

    public void start() {
        findTarget();
        this.mob.setTarget(this.target, this.target instanceof ServerPlayer ? TargetReason.CLOSEST_PLAYER : TargetReason.CLOSEST_ENTITY, true);
        super.start();
    }

}

icy beacon
#

That's outside the scope of my knowledge 🤐

#

Thought you were doing something a bit different haha

#

I remember when I was making a chicken attack a player and my server crashed because of some attribute shit and I had to figure it out

#

Thought you were doing smth similar

oak mica
#

lol nah

#

i dunno why its being so annoying

icy beacon
oak mica
#

fr

#

why isnt there a prebuilt api for htis

kind hatch
#

Make a PR. :p

oak mica
#

i cant make an api ftho

quaint mantle
#

Hi guys I'm trying to set a body to this post request but I get a 400 status code (Bad Request). I don't know what I'm doing wrong.

public class PlayersService {
    public static void createPlayerEntry(UUID uuid) {
        try {
            Map<String, String> body = new HashMap<>();
            body.put("uuid", uuid.toString());
            body.put("first_joined", new Date().toString());

            URL request = new URL(ApiEndpoints.PLAYERS.getUrl());
            HttpURLConnection client = (HttpURLConnection) request.openConnection();
            client.setRequestMethod("POST");
            client.setDoOutput(true);
            client.setRequestProperty("Content-Type", "application/json");
            client.getOutputStream().write(body.toString().getBytes());
            client.getOutputStream().flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
oak mica
#

go check what the api requirement is

#

of the body format

icy beacon
oak mica
#

yeah

#

i would make an api if i could but its gonna be a lot harder than it seems

quaint mantle
#

idk

#

let me sout the info

chrome beacon
quaint mantle
oak mica
#

use com.google.gson

#

probably

chrome beacon
#

gson or jackson are two good json libraries

oak mica
#

but yeah how could you make a custom entity target all mobs

quaint mantle
#

Like this?

oak mica
#

that might work but you shouldnt do that

quaint mantle
#

Idk, I was asking copilot

oak mica
#

JsonObject object = new JsonObject()

#

object#put(key, value)

quaint mantle
#

I had that deam

oak mica
#

then the body is just gson.toString()

quaint mantle
#

with .getBytes() yeah?

oak mica
#

no?

#
JsonObject object = new JsonObject();
object.put("uuid", uuid.toString());
object.put("first_joined", new Date().toString());
String body = object.toString();
quaint mantle
#

but to .write() need a bytes type

oak mica
#

huh

quaint mantle
#

let me try 1 sec

oak mica
#

ok then jsut try that

peak depot
#

Is there something like SignedVelocity for BungeeCord?

zinc moat
#

how do i loop thru all people with a certant permission?

peak depot
#

loop through players check if they have permission x and then do what you need

quaint mantle
#

xdd

zinc moat
tepid turret
#

?paste

undone axleBOT
eternal oxide
tepid turret
#

Reading Null Values Failing?

Basically my GUI is also storing alot of information in the items themselves. And for some reason when Hashing it into a hashmap some null values get turning into the name of one of the sections (null to "upgrade_1") which is confusing.
Getting the section of the item works fine.

itemToDisplay function (Where the logs come from) https://paste.md-5.net/iguravivux.cs

Item Hashing function https://paste.md-5.net/domusizoce.js

[00:44:21 INFO]: {locked_upgrade=null, costs=[minecraft:gold_ingot;12, minecraft:diamond;13, itemsadder:aurorium_pack:aurorium_shard;10, -1;5], item=minecraft:diamond, lore=[Costs 12 Gold Ingot, 13 Diamond, 10 Aurorium Shard, 5 Dollars, Yep], upgrade=Heart2, locked_item=locked_item_example, permission=phytor.advancedboats.upgrade.upgrade_1, slot=4, title=Avoid, error=MemorySection[path='boat_gui.upgrades.upgrade_1.error', root='YamlConfiguration'], bought_item=empty_item, success=MemorySection[path='boat_gui.upgrades.upgrade_1.success', root='YamlConfiguration'], next_upgrade=upgrade_3, modeldata=1, previous_upgrade=null}
[00:44:21 INFO]: Success of item MemorySection[path='boat_gui.upgrades.upgrade_1', root='YamlConfiguration']
[00:44:21 INFO]: {locked_upgrade=[upgrade_1], costs=[minecraft:gold_ingot;12], item=minecraft:gold_ingot, lore=[Costs 12 Gold Ingot, 13 Diamond, 10 Aurorium Shard, 5 Dollars, Yep], upgrade=Heart1, locked_item=null, permission=null, slot=5, title=Cool, error=MemorySection[path='boat_gui.upgrades.upgrade_2.error', root='YamlConfiguration'], bought_item=empty_item, success=MemorySection[path='boat_gui.upgrades.upgrade_2.success', root='YamlConfiguration'], next_upgrade=null, modeldata=1, previous_upgrade=upgrade_1
tepid turret
#

i mean i want help so 🤷‍♂️

quaint mantle
lost matrix
quaint mantle
tepid turret
#

Yea i realised but midway through the plugin the scope changed completely so i just want to get a working version then ill go back through and fix it all

#

(by remaking the entire project)

lost matrix
#

Eg.

HashMap<String, Object> itemHash = itemSecConstructor(section);

Should be something like

SlotItem slotItem = new SlotItem(section);

And SlotItem has fields like item,modeldata etc

zinc moat
chrome beacon
zinc moat
lost matrix
slender elbow
#

broadcastMessage my beloved

lost matrix
#

*Which isnt a problem if your code would be type safe on compile time

tepid turret
#

?

eternal oxide
echo basalt
#

broadcast my beloved

lost matrix
# tepid turret ?

This for example. If you have a typo in here, or simply used the wrong String to access a value, then you are getting random null values for no reason.
But if your Map was a proper class like SlotItem then

LockUpgrade upgrade = slotItem.getLockUpgrade();

Will never have those problems, because you cant have typos as your code would simply not compile then.

tepid turret
#

its 1am and my brain is fried

lost matrix
tepid turret
#

:) thank you

lost matrix
tepid turret
#

lmfao my code is so bad

#

its the exact same but instead of using
getSection(item)

#

it just parses the section

lost matrix
#

Wait... wtf is the purpose of this method?
You give it an ItemStack, and then it randomly grabbs a ConfigurationSection and merges
some values into a HashMap

tepid turret
#
    upgrade_1:
      item: minecraft:diamond
      modeldata: 1
      slot: 4
      title: "Avoid"
      lore:
        - "Costs 12 Gold Ingot, 13 Diamond, 10 Aurorium Shard, 5 Dollars"
        - "Yep"
      costs:
        - minecraft:gold_ingot;12
        - minecraft:diamond;13
        - itemsadder:aurorium_pack:aurorium_shard;10
        - -1;5
      error:
        title: "Not Enough!"
        subtitle: "Not Enough Subtitle"
        chatmessage: "You don't have enough"
        sound:
          - sound{s=entity.allay.item_taken;v=0.5;p=0.5}
          - sound{s=block.enchantment_table.use;v=0.5;p=0.3}
      success:
        title: "Upgrade 2"
        subtitle: "Upgrade 2 subtitle"
        chatmessage: "test"
        sound:
          - sound{s=entity.allay.item_taken;v=0.5;p=0.5}
          - sound{s=block.enchantment_table.use;v=0.5;p=0.3}
          - sound{s=block.beacon.deactivate;v=0.5;p=0.5}
      permission: advancedboats.testperm
      locked_item: locked_item_example
      bought_item: empty_item
      upgrade: Heart2
#

then its used to pass all the information through to my upgrading methods

echo basalt
#

Hm

tepid turret
#

its messy majority of it was done from 1-4 am

echo basalt
#
public class ConfigurableAnnouncement {

  private final Title title;
  private final String chatMessage;
  private final List<Sound> sounds;

  ...

  public void playTo(Player player) {

  }
}
lost matrix
#

The itemConstuctor method is literally doing nothing. ConfigurationSection is a Map<String, Object> under the hood.
All you are doing is getting one map, and simply copying the values into another map.

tepid turret
#

wait omfg i knew that WHY TF DID I DO THAT???

#

i am tired

#

so wait

lost matrix
#

Time for this sleepy boi to hit the hay?

tepid turret
#

nope because tmr i have to do school assessments

#

so i gotta get this done before like 9am tmr

#

(or else i will not do school)

lost matrix
#

So this method here:

  private HashMap<String, Object> itemConstructor(ItemStack item) {
    HashMap<String, Object> itemHash = new HashMap<>();
    if (getSection(item) == null) {
      return null;
    }
    ConfigurationSection conSec = getSection(item);
    itemHash.put("item", conSec.getString("item"));
    itemHash.put("modeldata", conSec.getString("modeldata"));
    itemHash.put("next_upgrade", conSec.getString("next_upgrade"));
    itemHash.put("slot", conSec.getInt("slot"));
    itemHash.put("title", conSec.getString("title"));
    itemHash.put("lore", conSec.getList("lore"));
    itemHash.put("costs", conSec.getList("costs"));
    itemHash.put("permission", conSec.getString("permission"));
    itemHash.put("locked_item", conSec.getString("locked_item"));
    itemHash.put("upgrade", conSec.getString("upgrade"));
    itemHash.put("error", conSec.getConfigurationSection("error"));
    itemHash.put("success", conSec.getConfigurationSection("success"));
    itemHash.put("locked_upgrade", conSec.getList("locked_upgrade"));
    itemHash.put("bought_item", conSec.getString("bought_item"));
    itemHash.put("previous_upgrade", conSec.getString("previous_upgrade"));
    return itemHash;
  }

Could be shortened to just

  private ConfigurationSection itemConstructor(ItemStack item) {
    ConfigurationSection conSec = getSection(item);
    return conSec;
  }

Which would be a method of questionable usefulness

tepid turret
#

yea i realised

#

wow who coulda guessed replacing itemConstructor with my cleaner getSection method would've been better

lost matrix
#

Anyways im gonna go play some games with friends, bb

tepid turret
#

thanks lols

oak mica
#

How do i actually register the custom entity

chrome beacon
#

You don't want to register it to the registry

#

That will cause problems with the client

#

Just spawn it directly

oak mica
#

thats what im doing rn

#

the problem is

chrome beacon
#

You will have to handle the loading and unloading of the entity yourself

oak mica
#

what do i have to do for that

chrome beacon
#

Listen to the entity load and unload events

#

and store your entities somewhere

oak mica
#

also the reason i was talking about that was since this doenst work

#

i was tryna make it target all mbos as long they arent the same type with the same owner

#

but it never gets to that point

oak mica
chrome beacon
#

There are many ways to store data

#

It's up to you how you do it

dapper flower
#

I want to check whatever a block is placed naturally or not, i am interest in only 2 types of block tho, what is the best solution? Using an hashmap or using meta data? I have seen a lot of conflict over this topic by googling it

chrome beacon
#

A database wouldn't be ideal for this usecase

chrome beacon
dapper flower
#

Not really that important

#

So no

oak mica
#

so what else would i be able to use

chrome beacon
#

PDC

#

?pdc

eternal night
#

ohh cafebabe is back

dapper flower
#

Bu ty anyway

oak mica
lost matrix
chrome beacon
chrome beacon
#

yes

oak mica
#

im presuming rn your saying like a hashmap?

chrome beacon
#

no

#

PDC

oak mica
#

a chunks pdc or osmething?

chrome beacon
#

yes

oak mica
#

ah

#

so you would save the entity info in the chunk?

#

and do it on hcunkload / unload?

chrome beacon
#

yes

oak mica
#

how do you filter which entities to save in the pdc and which to not save

lost matrix
#

Even some Blocks have PDCs

worldly ingot
#

Basically if it can store NBT, it probably has a PDC

#

If it doesn't, then we missed it

oak mica
#

how do you actually check if say a zombie is one of your custom zombies

#

is there something in their nbt?

worldly ingot
#

If you put something in its NBT, then yes

oak mica
#

so i presume you should put something in their nbt to filter them?

shadow night
#

Hmm, I wonder if I could "simulate" ticking blocks? Like, have an actual entity with some pdc at the same coordinate as a block and make it act as a block entity or something

lilac dagger
#

Just use packets

oak mica
#
            this.target = this.mob.level().getNearestEntity(this.mob.level().getEntitiesOfClass(this.targetType, this.getTargetSearchArea(this.getFollowDistance()), (entityliving) -> true).stream().filter(entity -> !entity.getBukkitEntity().getPersistentDataContainer().getOrDefault(Overcharged.WARDEN, PersistentDataType.STRING, "").equals(this.mob.getBukkitEntity().getPersistentDataContainer().get(Overcharged.WARDEN, PersistentDataType.STRING))).toList(), this.targetConditions, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
#

i need to stop doing this

dawn flower
#

is there a method that eliminates all extra lines in the lore?

so this wouldnt do anything

line1
empty line
line2```
but this would

Line1
empty line
empty line <-- removes this
line2```

worthy yarrow
#

Well we decided to go with a seasons plugin

quaint mantle
worthy yarrow
#

Nah it’s gonna be cool

quaint mantle
#

But you wont make good money with it

worthy yarrow
#

That’s not my goal

oak mica
#

and i dont understand

#

what do i actually ssave

#

in the pdc

#

that i can use to respawn the same entity

dapper flower
#

Also that is hell because there are no null safety checks

chrome beacon
torn shuttle
quaint mantle
#

How can I do a PATCH request, in Java 8 sais there is no PATCH method?

#

java.net.ProtocolException: Invalid HTTP method: PATCH

#

Move to newer java versions

#

But the plugins are with 1.8.8 and Java 8

icy beacon
#

That is highly unfortunate frankly

quaint mantle
#

I'm trying but still not working I think

quaint mantle
civic sluice
quaint mantle
#

Let's switch the jdk to temurin 11 then

#

xd

worthy yarrow
civic sluice
worldly ingot
#

Or you could, idk, update :p

worthy yarrow
civic sluice
hardy minnow
#

Hey fellas, got a question for you


    @HandleInterface(action = ActionType.GET, handles = InventoryHolder.class)
    public static <T extends InventoryHolder> SInventoryHolder getInventory(T entity) {
        // Stop all viewers from accessing (prevent potential race conditions
        entity.getInventory().getViewers().stream().forEach((HumanEntity::closeInventory));
        
        System.out.println("Inventory:   " + Arrays.toString(entity.getInventory().getContents()));
        return new SInventoryHolder(entity.getInventory().getContents());
    }

I have this code here for serializing the inventory. It fails specifically with a donkey (or other chested horse I'd assume). I can print out the inventory and I get this
[ItemStack{WHEAT x 37}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null] Which is what I'd expect.

I'm just curious as to why the printing of the actual itemstack array works (I assume its using the default configSerializable interface which is what I want) and Gson has an issue with it.

I have other record type classes similar to this that holds info and it doesn't have an issue with those. Only with this InventoryHolder interface does it fail.

#

I also have a similar record for armor contents for mobs and it works fine.

worldly ingot
#

Gson doesn't understand how to serialize an Optional

#

What it's failing on is SEntity, not SInventoryHolder

#

So whatever you're serializing in SEntity holds an Optional field somewhere (which, yikes - Optionals aren't meant to be fields)

hardy minnow
#

I got that, but I have other records that process itemstack objects as well which is where I am concerned why there is a difference between these two

SEntity does not have any optional fields. Its a reflection invoker method for these records. I've narrowed it down to that specific method causing the issue with GSON, but if you really want the invoking code here it is as well

        Gson gson = new Gson();

        JsonObject serializedEntity = new JsonObject();
        serializedEntity.add("EntityType", gson.toJsonTree(new SEntityType(entity.getType())));
        JsonObject attributes = new JsonObject();

        for (Map.Entry<Method, Class<?>> entry : interfaceMethodMap.entrySet()) {
            try {
                if (entry.getKey().getName().startsWith("get")) {

                    Record record = (Record) entry.getKey().invoke(null, this.entity);
                    JsonObject recordJson = gson.toJsonTree(record).getAsJsonObject();
                    attributes.add(entry.getValue().getSimpleName(), recordJson);
                }
            } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
                e.printStackTrace();
            }
        }
        serializedEntity.add("Attributes", attributes);

        return serializedEntity;
    }```
lost matrix
#

This is not how you should serialize objects with Gson.
Ideally you would have one Gson instance for your application which is aware of all serializable classes and how
to serialize them properly.

oak mica
oak mica
torn shuttle
oak mica
#

what do I save in the chunk that will allow me to respawn an entity from it

torn shuttle
#

specifically when it starts running off the monitor for the third time

hardy minnow
oak mica
#

a ultrawide curved monitor

torn shuttle
#

absolutely degenerate behavior

#

I like it

#

you should ping imillusion with your worst examples

worldly ingot
#

I mean bare minimum, put some newlines :(

#

Also, if that's running in any area of code that's particularly hot (which I think it was - this is in a pathfinder?), you're going to lose a lot of performance for really no benefit

echo basalt
worldly ingot
#

One of the reasons Mojang's AI code has as bad performance as it does is because they use streams in some of it :p

#

Another reason is their use of "brains" which I think has made things significantly worse, but that's another issue lol

oak mica
#

huh

worldly ingot
#

Streams have lots of overhead

lilac dagger
#

Thr villager ai looks more complicated than it had to tbh

worthy yarrow
#

So in the design of a seasons plugin, for each season I want to include particles for visual effects. Would the best way to do so be in usage of packets + rendered particles? In that you send particle updates to the player within a certain distance

lilac dagger
#

Yeah

#

Packets would be the best way

worthy yarrow
#

I'm not versed in protocol lib in any way, how difficult is a process like this?

worldly ingot
#

You could broadcast the particles to the world which would use the entity tracker anyways

oak mica
#

annnnyways how do you reload a custom entity when the chunks loaded

worthy yarrow
worldly ingot
#

Why use an internal dependency though? The whole purpose of Bukkit is to abstract things away so you're not depending on specific versions

#

Bukkit's Particle API sends a packet to players

#

World#spawnParticle() will automatically optimize it so it only sends to players capable of seeing it (within 32 blocks)

worthy yarrow
worldly ingot
#

I mean if you want to do it for only one player, then sure, Player#spawnParticle() works fine too

lilac dagger
#

The thing about using packets is that you can make one and send it just to those close enough

worthy yarrow
#

Well it was more for the consideration of ranks but now that I'm talking about it, that doesn't make much sense - to limit visual effects based on a players rank... especially for a seasons plugin haha

worldly ingot
#

And beyond that, if you opt to use Player#spawnParticle() anyways, you can make the server-sided distance check yourself

oak mica
#

what event is called when a entity loads

worthy yarrow
#

I don't think I want to do all that if the spawnParticle method already exists in world

worthy yarrow
# worldly ingot ^

So is that distance just constant at 32? Or can I make that configurable? (Configurable within the same world method rather than having to switch to the player.spawnparticle)

#

Or would this require extra impl

lilac dagger
#

Pretty sure distance is configurable

oak mica
#

Would htis work

#
            this.target = this.mob.level().getNearestEntity(this.mob.level().getEntitiesOfClass(this.targetType, this.getTargetSearchArea(this.getFollowDistance()), (entityliving) -> true).stream().filter(entity -> !entity.getBukkitEntity().getPersistentDataContainer().getOrDefault(Overcharged.WARDEN, PersistentDataType.STRING, "").equals(this.mob.getBukkitEntity().getPersistentDataContainer().get(Overcharged.WARDEN, PersistentDataType.STRING))).toList(), this.targetConditions, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());

alsooo how would i limit the distance

smoky anchor
# oak mica Would htis work

don't kill the entity like this, remove it.
Also don't forget to add your entity-specific data
(If I'm understanding what you're trying to do)

oak mica
smoky anchor
#

If you gave your entity some data, don't forget to copy it over

#

like your own custom data

oak mica
#

wym by data

#

just like nbts tuff?

smoky anchor
#

yes

#

probably

oak mica
#

alr yeh that happens in the constructor

hardy minnow
#

Its something weird to do with accessing items of the inventory with a holder, as it has no issues serializing items in general. When I insert my own array of items rather than pull from the entity
{"EntityType":{"type":"DONKEY"},"Attributes":{"InventoryHolder":{"inventoryContents":[{"type":"DIRT","amount":3},{"type":"DIAMOND_SWORD","amount":5}]},"Damageable":{"health":24.0,"absorptionAmount":0.0},"Ageable":{"age":0,"adult":true},"Attributable":{"attributeMap":{"HORSE_JUMP_STRENGTH":0.5,"GENERIC_MAX_ABSORPTION":0.0,"GENERIC_ARMOR_TOUGHNESS":0.0,"GENERIC_ARMOR":0.0,"GENERIC_MAX_HEALTH":24.0,"GENERIC_KNOCKBACK_RESISTANCE":0.0,"GENERIC_MOVEMENT_SPEED":0.17499999701976776,"GENERIC_ATTACK_KNOCKBACK":0.0,"GENERIC_FOLLOW_RANGE":16.0}},"Nameable":{},"LivingEntity":{"armourContents":[{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1},{"type":"AIR","amount":1}],"mainHand":{"type":"AIR","amount":1},"offHand":{"type":"AIR","amount":1}}}}

earnest lark
#

is there any way to build a jar into a file from gradle

ionic thicket
#
        Location location = null;
        while(true) {
            int x = random.nextInt(-1000,1000);  
            int y = 320;
            int z = random.nextInt(-1000,1000);
            World world = Bukkit.getServer().getWorlds().get(0);
            location = new Location(world, x, y, z);
            if(location.getBlock().getType()==Material.AIR) {
                System.out.println("Location " + x + ", " + y + ", " + z + " is safe");
                break;}
            else {    System.out.println("Location " + x + ", " + y + ", " + z + " is safe not");}
             
        }
        return location;    
    }```
Is there anything wrong?
glad prawn
#

?

earnest lark
#

whats the problem

ionic thicket
#

let me show you

cinder abyss
#

at randomX, 320, randomZ

#

is it normal?

ionic thicket
#

ye just debugging rn

#

oh

#

cant send photos

earnest lark
#

use imgr

remote swallow
#

?img

undone axleBOT
#

Can't send images? That's because you're not verified! Use !verify to complete verification.
Alternatively, you can upload screenshots to any image hosting site and share the link.

Here's some screenshot utilities that you can use to upload images.
Lightshot: https://prnt.sc
Imgur: https://imgur.com/upload
Flameshot: https://flameshot.org

ionic thicket
#

it gets spammed trillion of times

#

let me show you where it is called

hardy minnow
#

entity.getInventory().getContents() does not serialize by default with Gson - says something a java.optional field needing a type adapter

But ``` ItemStack[] itemStacks = new ItemStack[]{new ItemStack(Material.DIRT,3), new ItemStack(Material.DIAMOND_SWORD, 5)};


Is there something I'm missing? It should just be the same itemstack array I'm serializing?
ionic thicket
charred blaze
#

how good is this method to make circle animation?

#

ZFirstHalf is Z coordinate for first half of the circle.

tardy delta
#

dont think Math.pow(2) is a fantastic choice

charred blaze
#

why

earnest lark
ionic thicket
#

yeah but there's a break

earnest lark
earnest lark
#

and ur using a random number generator so it could be a infinate amount of times

charred blaze
earnest lark
#

why dont u use two random numbers and then start at the bottom of the world and use a loop until you find a air block

ionic thicket
#

that's smart

earnest lark
#

or start at the top of the world and go down until you find a block thats not air

#

to find caves

#

to avoid*

ionic thicket
#

im gonna do that way but i dont really understand why it is not working as i did

earnest lark
# ionic thicket that's smart

you can also still put it into a while(true) loop to check if there are not any blocks and it will work almost the same but you wont see nearly as many messages

earnest lark
#

and you keep checking over and over again

tardy delta
# charred blaze why

it calls into Math, it calls into StrictMath, and it calls into FdLibm.Pow just to get the fast path of a pow function, why not multiply it yourself?

earnest lark
#

therefor you will get a lot of output messages

charred blaze
tardy delta
#

also make your variables lowercase, this isnt c#

earnest lark
charred blaze
#

i dont know C# xd

ionic thicket
earnest lark
#

holy shit

#

yea this would be 802347539857 times faster

#

also it prob did that because block 320 cant be anything bc thats build height

ionic thicket
#

found the problem

#

i had to use VOID_AIR

earnest lark
#

yea

remote swallow
#

use Material#isAir

charred blaze
# charred blaze

about this method, somewhy it has tiny cut that never spawns particle in that spot

#

anyone knows why?

ionic thicket
charred blaze
ionic thicket
#

jk

oak mica
#

@torn shuttle i made it better

#
            this.target = this.mob.level().getNearestEntity(this.mob.level().getEntitiesOfClass(this.targetType, this.getTargetSearchArea(this.getFollowDistance()), (entityliving) -> true).stream().filter(entity -> !(entity.getBukkitEntity().getPersistentDataContainer().getOrDefault(Overcharged.WARDEN, PersistentDataType.STRING, "").equals(this.mob.getBukkitEntity().getPersistentDataContainer().get(Overcharged.WARDEN, PersistentDataType.STRING)) || Shard.getSummoningMobs(Overcharged.getPlayerShard(Bukkit.getPlayer(UUID.fromString(this.mob.getBukkitEntity().getPersistentDataContainer().get(Overcharged.WARDEN, PersistentDataType.STRING)))).getItemMeta()).contains(entity.getBukkitEntity()))).toList(), this.targetConditions, this.mob, this.mob.getX(), this.mob.getEyeY(), this.mob.getZ());
oak mica
nova notch
#

wtf is that

cinder abyss
nova notch
#

just because you can do it in one line doesn't mean you should

cinder abyss
#

I think you should use it

oak mica
#

what is a enter

#

i do not understand

worldly ingot
#

Client probably also has a similar hard coded constant

#

Only time it’s higher is if the force flag is set to true, in which case it will render up to 512 blocks

cinder abyss
#

Hello, if I want to get the total available surface using LimitedRegion#getBuffer, do I need to multiply it by 3?

wary harness
#

So started to use Triumph Gui API

#

and I was reading using InventoryHolder

#

is bad practic

#

and now I found out this api is using inventoryholder to

#

so

#

Can I expect bad preformance

quaint mantle
#

Nah

echo basalt
#

I already talked about this a bunch

#

The problem is when the check fails, not when it passes

#

Thing is they call it twice which is twice as bad

quaint mantle
#

You could do compare ids but inventory click doesn't make much lag

echo basalt
#

In short, expect at most 0.2ms per call

tardy delta
echo basalt
#

You'd need 250 players spam clicking on chests in order to have any kind of tps loss

wary harness
#

ok thne this will be good

#

no need to panic around nothing

quaint mantle
#

You aint getting even 50 in a single server

wary harness
#

for safte I will add who click more then 10 times in a min auto ban 🤣

oak mica
#
    @EventHandler
    public static void damage(EntityDamageEvent e) {
        if (e.getEntity() instanceof Player p) {
            ItemStack shard = Overcharged.getPlayerShard(p);
            if(Shard.getSummoningMobs(shard.getItemMeta()).contains(e.getDamageSource().getCausingEntity())) {
                e.setCancelled(true);
                ((CraftMonster)e.getDamageSource().getCausingEntity()).setTarget(null);
            }
        }
    }

how come the warden is still targetting the player even though the player isnt taking damage

#
EntityTargetLivingEntityEvent

isn't getting called when the warden targets the player, anyone know why?

worthy yarrow
#

Some of the winter effects were going to reduce their visibility someway

warm mica
earnest lark
#

is there any way to modify the Spigot server code itself

#

like is there a download for the code somewhere

chrome beacon
#

?contribute

ornate heart
#

So, I've made a custom enchantment via extending the Enchantment class and registering it. I am able to apply the enchantment to an item, but the lore isn't updated with the enchantment + level.

Is this something that I have to handle (the lore)?

vast ledge
#

Yea

#

You have to add the lore manually

ornate heart
#

damn

#

unfortunate

rotund ravine
#

So you should just switch to handling it via the pdc

ornate heart
#

I see

#

Thank you

#

Any common API's that handle enchantments via PDC?

#

Not against developing such a thing myself, but I would want to use one if it's out there.

vast ledge
#

There should be a lib or smth for custom encahnts

ornate heart
#

Doesn't use PDC but thanks.

lime narwhal
#

Hello, i cant understand why is my code not working. I want to create a Shop plugin, i created a gui named "Sell Or Buy"

I want to open that menu when i click on an item. I get the event of which click is (Right or Left). I can't even log that shit it dont works, could you help me ?

Code : https://pastebin.com/vy5xpSuQ

chrome beacon
#

?gui

polar forge
#

Hey guys

#

It still doesn’t work :c

ionic thicket
#

public Location randomLocation() {
Location location = null;
boolean generateNew = true;
World world = Bukkit.getServer().getWorlds().get(0);
while(generateNew) {
boolean k = true;

        int x = random.nextInt(-1000,1000);  
        int z = random.nextInt(-1000,1000);
    
    
    int y = 320;
    while(k==true) {
        location = new Location(world, x, y, z);
        if(location.getBlock().getType().isAir()) {
            y--;
            }
        else if(location.getBlock().isLiquid()) {
            k=false;
            printCoordinates(location);
            System.out.println("Is Water");
        }
        else {location.setY(y+1);
        generateNew=false;
        return location;}
            
        }
    }
    return null;    
}
#

Seems like this code that checks for air and water and return the location if there is no water makes all the server lag/makes some stuff such as events not work

young knoll
#

Because it loads chunks

ionic thicket
#

oof

#

what can i do for it?

#

i used to randomly spawn it somewhere randomly without checking for water and it worked perfectly, coult it be because of the while loop?

#

in my small experience i have never had a good time with loops in spigot plugins

worldly ingot
#

You could probably save yourself a bit of processing by re-using the same chunk for multiple checks. e.g. load one chunk, check maybe 16 positions or so in that chunk for a safe position. At least that way you're only loading one chunk and trying to find a good spot there instead of loading 16 different chunks

ionic thicket
#

mh

haughty granite
#

do you know of a good tutorial and a good boilerplate for starting to develop a plugin that follows good practice?

ionic thicket
flint coyote
#

Why do you want to spawn a mob in unloaded chunks?

ionic thicket
#

it's a mini-boss players need to reach and kill

#

it worked until i put that watercheck

#

but still, happend that on killing that boss some stuff happened and now it doesnt

flint coyote
#

Yeah the water check is the harsh part as you otherwise could spawn the mob once a player loads the chunk

#

If you make sure the relevant chunks have been generated before you could work with chunk snapshots

ionic thicket
#

well, before doing the water check i could spawn it anywhere

flint coyote
#

Even spawning it anywhere would load the chunk which does not make sense before anyone comes close

#

But obviously 1 chunk isn't that bad

worldly ingot
ionic thicket
#

let me check by reducing the spawn to one point

worldly ingot
#

I'm just saying that it would probably load a hell of a lot less chunks if there's a good position in the chunk you're already in, so it's best to give a few different chances in a few different positions within the chunk's coordinates

#

because it's likely that in the 256 columns of blocks in that chunk, you picked a shitty one :p

flint coyote
#

Unless he lands directly in an ocean which isn't that unlikely

flint coyote
#

You use a random chunk, how would it not be able to pick one that is ocean?
Or do you not have oceans?

ionic thicket
#

well because it doesnt land

#

it spawns in a block right above the ground if the ground !isLiquid()

flint coyote
#

Actually it would be a great addition to spigot to be able to check which biome a chunk has without fully generating/loading it.
Since blocks depend on the biome it should be possible to find that out prior to generating all the blocks, spawn the mobs etc.

flint coyote
worldly ingot
ionic thicket
#

but what i mean is:
Chunks should be loaded once it teleport to the boss spawn location

worldly ingot
#

What I'm saying is to not test x 100 z 100, find out "oops, there's a tiny 2x2 pit of lava there", then go to like x -950 z 739 when you could have just checked another spot in that same first chunk and avoid the 2x2 pit of lava

#

Check the same chunk you're at like 8 times or something so that way you're probably going to load literally 1/8th the amount of chunks

flint coyote
#

Yes I got that and I'd agree on that optimization

worldly ingot
#

If your first chunk happens to be an ocean, whatever. The next chunk might not be

#

There's no performance impact there, the alternative would have been to give up after one check and move onto the next chunk anyways

#

So at least you're still checking the same chunk for all the other 100+ biomes that aren't totally water lol

flint coyote
remote swallow
#

iirc theres a get highest block method too

worldly ingot
#

You can pull the biome with World#getBiome()

#

And yes, there is

ionic thicket
worldly ingot
#

Just an extra loop inside of your chunk one

ionic thicket
#

i dont have any chunk loop

flint coyote
worldly ingot
#

There is, it's in RegionAccessor

flint coyote
#

Oh

remote swallow
#

CHOCO

#

WAKEY WAKEY

#

CHOCO STOP TYPE AND LOOK OTHER CHANNELS

worldly ingot
#

tyty

remote swallow
#

there you go

flint coyote
#

Does the RegionAccessor getChunk function load the chunk?

#

getBiome*

#

If not you could check and skip ocean chunks before even loading them and checking any locations

worldly ingot
#
public static Location findRandomLocation(World world) {
    ThreadLocalRandom random = ThreadLocalRandom.current();
    int x = 0, y = 0, z = 0;

    int attempts = 0;
    while (attempts++ < 10) {
        x = random.nextInt(-1000, 1000), z = random.nextInt(-1000, 1000);
        y = world.getHighestBlockYAt(x, z);
        if (world.getBiome(x, y, z) == Biome.OCEAN) {
            continue; // Would want to check for more than just OCEAN, obviously
        }

        Chunk chunk = world.getChunkAt(x >> 4, z >> 4);

        for (int i = 0; i < 16; i++) {
            int minX = chunk.getX() << 4, minZ = chunk.getZ() << 4;
            int maxX = minX + 16, maxZ = minZ + 16;
            x = random.nextInt(minX, maxX), z = random.nextInt(minZ, maxZ);
            y = world.getHighestBlockYAt(x, z);

            Block block = world.getBlockAt(x, y, z); // Could also use World#getType(x, y, z) to avoid a Block allocation
            if (isValidPosition) { // Do your checks here
                return new Location(world, x, y, z);
            }
        }
    }

    return null; // Just a safety in case it couldn't find a position in 10 (* 16) attempts
}```
#

This is probably how I would do it

ionic thicket
#

holy

lost matrix
#

while loop with safety condition? Thats no fun PES_AngeryDiamondSword

worldly ingot
#

And yes, RegionAccessor#getBiome() does not load the chunk

#

It pulls the biome from the noise map

lost matrix
#

Find me a suitable Location or die trying

flint coyote
#

That's perfect

worldly ingot
#

Now absolute worst case you'll load 10 chunks, plus you're checking 16 times within each chunk you find

#

160 checks total

#

(I didn't verify this logic btw - I just wrote this in Discord lol)

flint coyote
ionic thicket
worldly ingot
#

They're just constants

#

HeightMap.OCEAN_FLOOR_WG might be what you want

#

Checks for non-air and non-fluid

flint coyote
#

So I'm able to find a suitable location without loading the chunk when I use that?

worldly ingot
#

Well you could at least check the biome first (as I did in my snippet)

flint coyote
#

Of course

worldly ingot
#

You're going to have to load the chunk one way or another and the World#getChunk() method will do that

#

I have to say though, if you're depending on the Paper API, they do have some async chunk loading. We don't have that in Spigot, but if you're writing a private plugin for a Paper server, take advantage of that

flint coyote
#

Yeah that's what I expected. I thought the height map might be a way around it

worldly ingot
#

Nah, the height map would just help you get the highest block under different conditions

flint coyote
#

I see

flint coyote
young knoll
#

PaperLib allows you to interface with that

worldly ingot
#

Yeah they have an optional softlib

flint coyote
#

Just checked, I might make use of that in the future. Thanks!

ancient plank
worldly ingot
#

They don't? PandaThink

#

It's not super new to where they wouldn't have pulled upstream changes

remote swallow
#

i just thought

ancient plank
#

they don't have it ye

remote swallow
#

choco you might have to break ur cla by looking at paper code for hypixel

worldly ingot
#

Nah I don't work on the server

#

At least not yet lol

ancient plank
#

kek

echo basalt
#

client-sided minigames?

remote swallow
#

dont break cla choco

ancient plank
#

hypoxlr

young knoll
#

None of that paper code is probably even relevant anymore

#

It’s 10 years old

carmine mica
#

EntitySnapshots are in Paper. idk why anyone would use them, its pretty scuffed atm

#

it seems to arbitrarily not save some data about the entity. I can't see a pattern to it

young knoll
#

Unless something went wrong I programmed them to only discard instance specific data

#

Mostly position and uuid

carmine mica
#

what is instance specific? there are tons of positional information stored in entities that are still saved. ALL of the brain stuff

#

iirc, its also not saving some useful data about item frames and paintings

young knoll
#

Ah yeah the brain stuff probably needs more work

#

Pretty sure it also discards some additional positional data on hanging entities, I don’t think it should discard anything else

remote swallow
#

thats funny

ionic thicket
# worldly ingot ```java public static Location findRandomLocation(World world) { ThreadLocal...
    public static Location findRandomLocation(World world) {
        ThreadLocalRandom random = ThreadLocalRandom.current();
        Location location = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
        int x = 0, y = 0, z = 0;

        int attempts = 0;
        while (attempts++ < 10) {
            x = random.nextInt(-1000, 1000);
            z = random.nextInt(-1000, 1000);
            y = world.getHighestBlockYAt(x, z);
            if (world.getBiome(x, y, z) == Biome.OCEAN) {
                continue; // Would want to check for more than just OCEAN, obviously
            }

            Chunk chunk = world.getChunkAt(x >> 4, z >> 4);

            for (int i = 0; i < 16; i++) {
                int minX = chunk.getX() << 4, minZ = chunk.getZ() << 4;
                int maxX = minX + 16, maxZ = minZ + 16;
                x = random.nextInt(minX, maxX); z = random.nextInt(minZ, maxZ);
                y = world.getHighestBlockYAt(x, z);

                Block block = world.getBlockAt(x, y, z); // Could also use World#getType(x, y, z) to avoid a Block allocation
                if(block.getType().isAir()) {
                    y--;
                    }
                else if(block.isLiquid()) {
                    printCoordinates(location);
                    System.out.println("Is Water");
                }
                else {
                    location.setX(x);
                    location.setY(y+1);
                    location.setZ(z);
                    printCoordinates(location);
                    System.out.println("is fine");
                return location;
                }
            }
        }

        return null; // Just a safety in case it couldn't find a position in 10 (* 16) attempts
    }
worldly ingot
#

Shouldn't need your first isAir() check. The getHighestBlockYAt() does that for you

remote swallow
#

^^

ionic thicket
#

how do i find the ground lvl then?

remote swallow
#

its get highest block

#

unless theres building

worldly ingot
#

Also, yeah, you aren't using the Block itself so you can optimize that last bit with a getType() instead

// ...
Material type = world.getType(x, y, z);
if (type == Material.WATER || type == Material.LAVA) {
    continue; // is water
}

return new Location(world, x, y + 1, z);
#

Oh there is an isLiquid() :p

worldly ingot
#

Why? You're avoid a CraftBlock allocation

ionic thicket
echo basalt
#

Not saying that

#

isLiquid is often not enough

#

It fails for waterlogged blocks

worldly ingot
#

Oh, sure

echo basalt
#

Fun thing

#

Kelp is not waterlogged

remote swallow
#

i can stand on waterlogged blocks

echo basalt
#

But it is always on water

worldly ingot
#

Yeah I think waterlogged blocks is less of an issue

young knoll
#

Kelp is just always waterlogged

echo basalt
#

But it doesn't have the waterlogged BlockData

worldly ingot
young knoll
#

Because you can’t un-Waterlog it

echo basalt
#

Still, bit annoying

young knoll
#

It’s basically just water2

echo basalt
#

It fails isLiquid too

young knoll
#

Wack

#

I still want Mojang do come back to waterlogging

#

Java got done dirty in that regard

echo basalt
#

I recently had a commission project that basically teleported you back if you touched on water

#

and kelp was giving issues

#

:)

#

So I just hardcoded it

young knoll
#

The game just needs a fully layer system tbh

remote swallow
#

pr it

young knoll
#

To who

remote swallow
#

minecraft is probably on github

young knoll
#

Yeah lemme just hack the private repo

remote swallow
#

they wont question why rando canada is pring stuff

#

just blind merge

#

my one vein is so chunky

#

its weird

quaint mantle
#

Yo ik this is almost 102% not a thing but can u take pictures of the POV of a player?

remote swallow
#

you could probably raycast it

#

idk if the server knows the fov

lost matrix
echo basalt
#

p sure cmarco did it

quaint mantle
echo basalt
#

Basically you want to do a bunch of raycasts and get a projection going

quaint mantle
#

Well im trying to use it with a discord bot lol

#

If i really wanted to

#

I could just raycast

#

and just use emojis

#

as a very very low resolution version

#

but at that point there isnt a point in it lol

remote swallow
#

ud prob want a cooldown on that bc its heavy

quaint mantle
#

yeah 10 sec

#

Its an anticheat thats very crappy lol

remote swallow
#

also prob not 100% accurate bc players can move before its finished

quaint mantle
#

so its not even needed

#

💀

young knoll
#

It’s a neat thing you can do

#

But it’s not really useful in any way

quaint mantle
#

fr

remote swallow
#

josh why is one of me veins so big

young knoll
#

Must be one of those new giant iron veins from 1.18

#

Kek

remote swallow
#

no im pretty sure its blood

quaint mantle
#

😭

remote swallow
#

Fuckin look at it

#

Ft me leg

earnest lark
#

stop tryna flex bro

quaint mantle
remote swallow
#

i have a sock on

remote swallow
young knoll
#

wtf he said paper

remote swallow
#

calm ur nose

dreamy sleet
#

import org.bukkit.Bukkit;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Objects;

public final class SkillTrees extends JavaPlugin implements Listener {


    private SkillTrees skilltrees;

    @Override
    public void onEnable() {


         skilltrees = this;
        getCommands();
        getListeners();

        // Plugin startup logic

    }

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


    public void getCommands() {
        Objects.requireNonNull(getCommand("skills")).setExecutor(skilltrees);
    }

    public void getListeners() {
Bukkit.getPluginManager().registerEvents(skilltrees, this);
    }
}
[23:03:54 ERROR]: Error occurred while enabling SkillTrees v1.0-SNAPSHOT (Is it up to date?)
java.lang.NullPointerException: null
        at java.util.Objects.requireNonNull(Objects.java:233) ~[?:?]
        at me.jesse.skilltrees.SkillTrees.getCommands(SkillTrees.java:33) ~[SkillTrees-1.0-SNAPSHOT.jar:?]
        at me.jesse.skilltrees.SkillTrees.onEnable(SkillTrees.java:19) ~[SkillTrees-1.0-SNAPSHOT.jar:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:287) ~[purpur-api-1.20.4-R0.1-SNAPSHOT.jar:?]
        at io.papermc.paper.plugin.manager.PaperPluginInstanceManager.enablePlugin(PaperPluginInstanceManager.java:188) ~[purpur-1.20.4.jar:git-Purpur-2169]
        at io.papermc.paper.plugin.manager.PaperPluginManagerImpl.enablePlugin(PaperPluginManagerImpl.java:104) ~[purpur-1.20.4.jar:git-Purpur-2169] ```
#

Could someone tell me why this is registering as null?

tawdry monolith
#

hey guys, is there a way to use an API to get a random minecraft account UUID or username?

sullen marlin
dreamy sleet
slender elbow
#

you're running purpur

#

purpur is not spigot

worldly ingot
#

👏 Tell 'em, Em

dreamy sleet
worldly ingot
#

The problem is just that you didn't register your "skills" command in your plugin.yml

tawdry monolith
dreamy sleet
hollow haven
#

Hellooo~ I'm an amateur as far Java/Spigot goes, so, please. Go easy on me.

I'm using NEZNAMY's TAB plugin for a certain thing. Now, I have two questions:

  1. Is it possible to embed that dependency, or somehow NOT require the user to install the plugin too?
  2. If 1 is not possible, how would I go about abstracting the features that use the dependency, so that they are not REQUIRED.
young knoll
#

Check if the plugin is installed via PluginManager#isPluginLoaded(iirc) and then run code based on that

hollow haven
young knoll
#

You just have to avoid method calls involving the other plugins classes

livid tundra
#

hi, im saving an itemstack to a yml file, what's the v for

#

as in what does it do

delicate lynx
#

I belive data version?

livid tundra
#

so it only changes between updates?

young knoll
#

Yes

livid tundra
#

wait major or minor

eternal night
#

Any version

delicate lynx
#

it just tells the server what version of the item, so it can perform upgrades if needed

dreamy sleet
worthy yarrow
#

https://paste.md-5.net/salukocawu.java

Could I get some notes on this implementation? I'm not very creative so the visual effects / particles will need some work + I still have to write out the custom effects given to players during these seasons

gloomy ocean
#

Would anyone here be able to make me a somewhat simple plugin? (I believe it's simple at least 😭) I'm willing to pay for it to be made in nitro/usd (cashapp, paypal) 🥺

young knoll
#

?services

undone axleBOT
steel dirge
#

anyone work with text displays using packets?

#

the second i set a scale on 1, it makes the text display non-existant

quaint mantle
#

There’s api for it

steel dirge
#

sending them client side

#

using protocollib

#
new WrappedDataValue(12, WrappedDataWatcher.Registry.getVectorSerializer(), new Vector3f(3.0F,3.0F,3.0F))
#

if i dont set a scale, i get the text display

#

thhe second i add it, its gone

steel dirge
#

ik that exists, but why would i spawn say 50 of them if im just creating one catered to the client

#

just seeing if anyone has worked with them before and has set the scale correctly on them

wanton comet
#

Oh you have the player already, just do player.openInventory(player);

river oracle
#

Did you just use chatgpt?

steel dirge
#

xDDD

wanton comet
#

oh shit

#

no didn t use chatgpt

#

forgot the method

river oracle
dreamy sleet
river oracle
#

World edit is seemingly the only way to go here

#

Though I'd be aware of the computational strain saving an entire chunk will have

#

Yeah 66 * (1616) * 324

#

Not sure how much threading can be done with world edit be cautious all I'm tryna say

pliant topaz
#

3m blocks isnt actually that much, prob only take 1-2sec if not less

#

(well, depending on server ressources but still, should be pretty fast)

ionic thicket
#

Can a chunk get unloaded by itself if i use load()?
Should I use setForceLoaded()?

tepid turret
#

Yo so my plugin got basic permissions,
But not all of them are shown in the commands section of the plugin.yml
How do I register them through vault or otherwise so that permissions plugins like luckperms will see it.

eternal oxide
#

add them to your plugin.yml permissions section

upper hazel
#

what's better? Store a link to a location in its usual form or store only the components of an object separately in its own created object

#

as I understand it, option 2 is better, because the location is changeable, just like the Player object

drowsy helm
#

bit of an xy problem that you're asking

floral field
#

how to make those crossversion plugins without NMS or external libraries like those chat management plugins

upper hazel
# drowsy helm what exactly is the usecase

I mean that you can’t transfer or store a location object, right? After all, it is changeable just like the Player object, so the link to the object is stored as a uuid

#

and that's why you need to use worldUUID or worldName

eternal oxide
#

depends

upper hazel
#

Is the situation the same with the location?

eternal oxide
#

yes you can store/transfer a Location object, but it depends on a few things

#

which is why your question is an x/y one

drowsy helm
#

so you just want immutability?

upper hazel
polar forge
#

Hey guys

upper hazel
rotund ravine
#

Sure

drowsy helm
#

just store it as normal, you are over thinking it

eternal oxide
#

You should nto really be using locations if you are refering to Blocks

drowsy helm
#

but again, without any context it's hard to give a concrete answer

upper hazel
#

i save this in map

eternal oxide
#

for restoring a chunk you should def not use Locations

#

a Block has a position, an x,y,z

#

that block is in a Chunk, which is also a x,z

#

that Chunk is in a World, which is the only difficult part

#

as you can;t get a World reference if it's not loaded is all

upper hazel
#

i not should use location?

drowsy helm
#

you're doing that for each block in a chunk?

#

that is a fat heap of mem

upper hazel
#

the thing is that I need to save only part of the chunk, leaving the bedrock

eternal oxide
#

why are you storing ItemStacks?

drowsy helm
#

to store inventories im guessing

upper hazel
#

yes

eternal oxide
#

seems to have nothing to do with a Bl;ock regen

drowsy helm
#

check out minecraft's chunk format, you'll save heaps of memory

#

location is 3 ints, mat is a byte, then inventory content is many many btes

#

times that by however many blocks are in a chunk, and you are using tens of MB per chunk

upper hazel
#

then what is the best way to save chunks ?

eternal oxide
#

many ways, depending on what you want to do with it

upper hazel
#

delete, regenerate.

drowsy helm
#

Just use an Array of materials

eternal oxide
#

a chunk at a time?

polar forge
#

So I have this problem, I can’t see my prefixes of LuckPerms on my test mc server. I translated the “&” codes into chat colours but I still can’t see the prefixes. And if a prefixes is null, null should also be translated.

Here’s the code: https://paste.md-5.net/gikififezo.java

drowsy helm
#

you're most likely missing a chat manager plugin

polar forge
drowsy helm
#

ah nvm

upper hazel
#

all pieces vertically leaving the thigh

eternal oxide
drowsy helm
#

you shouldn't be using displayName for prefixes aswell

eternal oxide
#

We told him that yesterday

polar forge
polar forge
eternal oxide
#

I told you yesterda

drowsy helm
#

AsyncPlayerChatEvent

#

set format

eternal oxide
#

create a method to getFormattedName

polar forge
eternal oxide
#

really?

polar forge
#

It must be the day before

drowsy helm
#

pogger

polar forge
eternal oxide
#

yep it was the 20th

polar forge
#

So I should create a new method sure

upper hazel
#

so uh how i can save chunk?

drowsy helm
#

read that

#

you can just use an array of materials

#

super simple

#

if you want to get more complex, an array of bytes which point to the index of a material on another array

#

then for tyour inventory data, another array

eternal oxide
#

how many chunks are you wanting to save/restore

drowsy helm
#

the index of which is just a 3d vector flattened to a 1d index

upper hazel
eternal oxide
#

There are ways to do what you want but you are being so vague I'm giving up asking 20 questions.

vocal pine
#

Hi there, is there any way to make lore on an ItemMeta translatable? it seems to be purely String based snd I'm not sure how I'd pass in a translation key with arguments to be parsed on client

upper hazel
#

I will answer specifically. I want to use a command to delete a chunk (with filtering of some blocks) and restore them to their original state

#

save only in memory not in files

eternal oxide
#

Then Structures are out

upper hazel
#

what exactly do you want to hear

eternal oxide
#

if you are not saving then chunk Snapshots are your simplest method

upper hazel
#

everything should be the same as it was before restoration (except entity)

eternal oxide
#

you can hold them in memory and read their data to perform yoru block replacement

drowsy helm
#

might be a minecraft limited thing

eternal oxide
#

On chunk load (first time) take a snapshot and hold it in memory

drowsy helm
#

theres definitely trickery you could do to translate it, but nothing natively supported (afaik)

vocal pine
#

ah, probably just isnt worth it for me then, its fairly simple one word lines mostly so cant imagine its going to be too much of an issue to use server default locale

#

appreciate it

smoky anchor
upper hazel
#

As I understand it, ChunkSnapshot stores data about the chunk, but how can I change it for my needs? Can I do something like Chunk.setSnapshot?

eternal oxide
#

no you read BlockData from it as you need

#

x,y,z

#

The Snapshot is literally a copy of the chunk as it is when you take the snapshot

#

a moment in time

upper hazel
#

Are there special methods for deleting chunks? or through overkill?

eternal oxide
#

To restore it to the live chunk, you loop over its data (x,y,z) and set teh BlockData to the live chunk

upper hazel
#

Well, that means deletion and restoration remains the same. Only the storage method changes

eternal oxide
#

its a much smaller memory footprint than the idea you had

#

and simpler

#

getting the data is also a single method call

#

instead of doing it for each and every block

upper hazel
#

ChunkSnapshot saving chunk in bytes?

#

i mean how this can use small mamory

eternal oxide
#

you said you were not saving, you were keeping in memory

eternal oxide
#

I'm guessing English is not your native language as what you said makes no sense

upper hazel
#

i mean after all, the snapshot itself somehow stores data about the chunk

eternal oxide
#

The Snapshot is a copy of the chunk (in memory)

upper hazel
#

but doesn't use much memory

eternal oxide
#

you were storing block data and a location for each

upper hazel
#

oh now i see

polar forge
worthy yarrow
polar forge
#

But I get missing return statement in line 46

#

And I get the error that prefix might not initialise

#

In line 53

worthy yarrow
#

so then add a return statement and initialize the prefix

polar forge
worthy yarrow
#

such as?

polar forge
#

Cannot resolve for getFormattedName

#

And I still have the missing return statement error

eternal oxide
#

you are setting Display Name and not returning it as a String

polar forge
#

I forgor

#

But for the problems I mentioned

#

Any solutions?

eternal oxide
#
String result = "";
String prefix = "";
User user = plugin.getLuckPerms().getUserManager().getUser(player.getUniqueId());
if (user != null)
  prefix = user.getCachedData().getMetaData().getPrefix();
prefix = ChatColor.translateAlternateColorCodes('&', prefix);
...  /add your StringBuilder here to make the result using prefix and name etc.
Return result;```
worthy yarrow
#

Elgarl got the time?

polar forge
#
public String getFormattedName(Player player) {
  User user = plugin.getLuckPerms().getUserManager().getUser(player.getUniqueId());
  if(user == null) return null;

  String prefix = user.getCachedData().getMetaData().getPrefix();

  if(player.hasPermission("hoverinfo.admin")) {
    return prefix + ChatColor.RED + player.getName();
  }

  // etc

  return null; // Default
}