#help-development

1 messages · Page 1611 of 1

young knoll
#

Or the lack of caching the item stack

grim ice
cold tartan
#

is there a way to double block drops with blockbreakevent, because for some reason event.getDrops returns the block drops without fortune

grim ice
#

No, please comment on them

cold tartan
#

i can

#

so first of all

#

methods should use lowerCamelCase

dusk flicker
#

?conventions

undone axleBOT
cold tartan
#

?help

undone axleBOT
#
CafeBabe Help Menu
*Red V3*
**__Admin:__**

selfrole Add or remove a selfrole from yourself.

**__Cleanup:__**

cleanup Base command for deleting messages.

**__Core:__**

embedset Commands for toggling embeds on or off.
info Shows info about CafeBabe.
licenseinfo Get info about Red's licenses.
mydata Commands which interact with the data CafeBabe has about...
set Commands for changing CafeBabe's settings.
uptime Shows CafeBabe's uptime.

**__Downloader:__**

findcog Find which cog a command comes from.

**__Mod:__**

names Show previous names and nicknames of a member.

**__ModLog:__**

casesfor Display cases for the specified member.
listcases List cases for the specified member.
reason Specify a reason for a modlog case.

**__Permissions:__**

permissions Command permission management tools.

tardy delta
#

my maven goals are gone

tribal holly
#

Hi, i'm making a multi-lang plugin but i have a problem with an Enum. When the lang change i wanna "reload" my enum to refresh the value of it how can i do ?

#
 ZEUS_LIGHTNING(GameSettings.LANG.textOf("godItem.ZEUS_LIGHTNING"), "zeus_lightning", 1, Material.PHANTOM_MEMBRANE, ItemType.MISCELLANEOUS),```
#

here : GameSettings.LANG.textOf("godItem.ZEUS_LIGHTNING") is changing when lang change

stone sinew
#

You can't change enum values as they are running. (if I recall correctly.)

paper viper
#

Yeah you can’t change them at all

#

They are meant to be constant

#

Immutable

tribal holly
#

okay so my only solution is to make this :

ZEUS_LIGHTNING("godItem.ZEUS_LIGHTNING", "zeus_lightning", 1, Material.PHANTOM_MEMBRANE, ItemType.MISCELLANEOUS);

public String getName(){
  return GameSettings.LANG.textOf(this.name);
}

paper viper
#

😫

dusk flicker
#

or dont use an enum

paper viper
#

Enum’s aren’t even meant for this purpose

tribal holly
dusk flicker
#

you always have a choice

#

so don't start with that

tribal holly
#

so you advise me to make N customItem class for each custom item i have ?

paper viper
#

Yes, because enums are not the correct choice here

tribal holly
#

why ?

paper viper
#

If they are going to be changeable, then don’t use Enums

dusk flicker
#

That's up to you; Sure thats a possibility but I bet if you think enough another good option may come up

eternal oxide
#

Enums are FIXED CONSTANTS is why

paper viper
#

Exactly

#

It’s the same as public static final

#

Literally

#

The byte code

tribal holly
#

except this litle variable all variable thru the game are not changing and are constant

eternal oxide
#

If you have all your translations already set and you are simply pulling a different translation, then you cna use Enums

tardy delta
#

how can i get every line under the uuid and print all the lines to the player?
this is probably the wrong way

List<String> homes = new ArrayList<>();
homesFile.getConfigurationSection("homes." + p.getUniqueId()).getKeys(true).forEach(home -> {
                if (home.startsWith("homes." + p.getUniqueId())) {
                    homes.add(home);
                }
            });
tribal holly
#

the player is changing the lang at the begining of the game and will not change while game is running

eternal oxide
#

Enums are set at compile time, not after

tribal holly
#

okay i see the problem

fluid cypress
#

is there an easy way in java i can create a random number that is not too random? i mean, for example, between 0 and 100, something that gives me, 23, 47 and 83 is fine, but 23 26 and 85 isnt bc 23 and 26 are too close. i want to teleport players, so, i prefer something less random, and keep them separate if possible

eternal oxide
tardy delta
#

i only want the name and the location

eternal oxide
#

your home variable will be a map containing test and the map of K,V

stone sinew
tardy delta
#

to read it manually from the file

#

doesnt matter for now

stone sinew
eternal oxide
#

cleaner would be to scrap the player name in there and pull that from the OfflinePlayer object and then push the location as an actual Location object

#

you can then use the config method of ConfigSection#getLocation("test")

tardy delta
#

yea i know

eternal oxide
#

you could even leave the player name in there. it will be ignored by getLocation

fluid cypress
eternal oxide
#

show code

#

?paste

undone axleBOT
eternal oxide
#

I hope you also realize that random does mean it could give you the same location 10 times in a row

grim ice
#

?paste

undone axleBOT
cold tartan
#

is there a way to check if a block is placeable? because Material.isBlock() doesn't work for redstone

grim ice
cold tartan
#

ClassName.getRegular();

#

?learnjava

undone axleBOT
cold tartan
#

please @grim ice

grim ice
#

are legit useless

cold tartan
cold tartan
tardy delta
#

w3schools 🥵

summer scroll
#

i mean they're not bad xd

cold tartan
#

its pretty good for learning basic java

quaint mantle
#

what i shoud for making prefixes on 1.17?

#

without scoreboards

#

on packets

tardy delta
#

vault

quaint mantle
#

which packets i need?

quaint mantle
tardy delta
#

like this
p.setDisplayName(Main.getChat().getPlayerPrefix(p) + " " + p.getName());

quaint mantle
#

0wo

quaint mantle
#

is this exists? wtf

grim ice
#

GUESS WHAT

#

its the exact website i read

#

and here u find me :/

opal juniper
#

Go and ask your java questions in a Java discord

fluid cypress
summer scroll
#

we dont answers java question here, we're answers spigot api question

grim ice
#

I mean yeah that's true, but it would be easier for people to understand me if they know spigot too

eternal oxide
grim ice
#

o lol

hardy swan
#

Helo

grim ice
#

but honestly i got a better understanding of java now, at least better than what i had

summer scroll
#

sure, you'll learn from time to time

hardy swan
#

Trust me, there are still a lot to learn. Im still learning too

paper viper
#

Oh boy there is so much

dusk flicker
#

You won't ever stop learning java

quaint mantle
#

which packets i need for prefixes without scoreboards?

dusk flicker
#

Take it from someone that has done it for at least 7 years you never stop learning

paper viper
#

MethodHandles, streams, proper library coding

hardy swan
#

Generics, wildcards

paper viper
#

Even OOP patterns

#

In general

#

Like SOLID

#

The 23 patterns in OOP

#

(Iirc)

dusk flicker
#

It's bad when I use other langs because OOP is literally second nature for me lol

hardy swan
#

Isnt oop like more intuitive?

paper viper
#

honestly I hate and like OOP at the same time

#

I hate it because of the horrible puzzle you have to solve

hardy swan
#

Puzzle?

dusk flicker
#

Yep lol

#

OOP can be a fucking nightmare to understand

paper viper
#

Something like Spring

#

It’s a nightmare

#

That’s why the UML graphs exist

#

But then you still have to plan in advance

#

And half of the time your users wouldn’t understand the structure anyways

#

Lol

dusk flicker
#

gestures at Bukkit

paper viper
#

Mhm

dusk flicker
#

Bukkit is a shit show imo though lol

paper viper
#

So many things are messed up in Bukkit

#

Yeah

dusk flicker
#

?jd

dusk flicker
#

My only idea would be using Tag.REGISTRY_BLOCKS

#

Looking back dont think that will work

cold tartan
#

i guess i could make a list

worldly ingot
#

Yeah I don't think there's anything that determines whether or not a material is placeable

cold tartan
#

/redstone

hasty prawn
#

Why not just use isBlock and also check if it's redstone?

cold tartan
#

well im not sure what other blocks it doesnt work for

stone sinew
hasty prawn
#

Oh, Redstone & Redstone_Wire are different materials

crude sleet
#

https://hastebin.com/qivelerexo.java I try to give a Block the Glow effect, for that i want to Spawn a Shulker with glow effect but in the 1.17 i cant find the new flags. Anyone have ideas or a link with the new flag ids?

grim ice
#

anyone knows how do i get a player last message

crude sleet
#

You can safe the message in a hashmap and can then spend it on you

quartz flicker
#

can somebody help me with fawe api?

#

or world edit api

hasty prawn
#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply.

quaint mantle
#

Yo quick question, when compiling a jar, when's the difference between mvn clean package, and just mvn package?

chrome beacon
quartz flicker
#

im trying to build block party server and i want to make the floor change every round and i made floor presets and i saved them in a class:

lass Platform {
    public Location point1;
    public Location point2;

    public Platform(Location point1,Location point2){
        this.point1 = point1;
        this.point2 = point2;
    }
    public Platform(double x1,double y1,double z1,double x2,double y2,double z2){
        this.point1 = new Location(Bukkit.getWorld("RainbowMan"),x1,y1,z1);
        this.point2  = new Location(Bukkit.getWorld("RainbowMan"),x2,y2,z2);
    }

    public static List<Platform> getPlatforms(){
        List<Platform> platforms = new ArrayList<>();

        platforms.add(new Platform(12,79,-3,-2,79,11));
        platforms.add(new Platform(12,74,-3,-2,74,11));
        platforms.add(new Platform(12,69,-3,-2,69,11));
        platforms.add(new Platform(12,64,-3,-2,64,11));

        platforms.add(new Platform(-4,74,-3,-17,74,11));
        platforms.add(new Platform(-4,69,-3,-17,69,11));
        platforms.add(new Platform(-4,64,-3,-17,64,11));

        platforms.add(new Platform(-4,74,13,-17,74,27));
        platforms.add(new Platform(-4,69,13,-17,69,27));
        platforms.add(new Platform(-4,64,13,-17,64,27));

        platforms.add(new Platform(12,74,13,-2,74,27));
        platforms.add(new Platform(12,69,13,-2,69,27));
        platforms.add(new Platform(12,64,13,-2,64,27));

        platforms.add(new Platform(12,69,29,-2,69,43));
        platforms.add(new Platform(12,64,29,-2,64,43));

        platforms.add(new Platform(-17,64,29,-4,64,43));
        platforms.add(new Platform(-17,69,29,-4,69,43));





        return platforms;
    }
    public static Platform getRandomPlatform(){
        return getPlatforms().get(new Random().nextInt(getPlatforms().size()));
    }
}

and i have this for the floor positions:

private Location getLocation1(){```
#

        return new Location(Bukkit.getWorld("RainbowMan"),26 ,63, -21);
    }
    private Location getLocation2(){
        return  new Location(Bukkit.getWorld("RainbowMan"),12 ,63, -35);
    }

but i dont know how to make it change with the world edit api and i searched it on google but it needed player session and i want it to work from the server and not the player`

hasty prawn
quartz flicker
#

can u send me the code to do it?

#

i searched for couple hours and didnt find it

hasty prawn
#

No, you need to do that on your own. I'm just telling you what you should do. Mess around with IntelliJs autocomplete. There should be CuboidRegion constructors & methods for doing what you need.

chrome beacon
#

It shows you how to create a new session and use it

#

Combine that with the pattern guide and you will have your random floor

quartz flicker
#

is there a console session or something like that?

chrome beacon
#

Bro read what I said

#

And read the link I sent

chrome beacon
#

That too

#

If you're using FAWE make sure to fire things async or you will crash the server

chrome beacon
#

There are many ways to do it. The scheduler is one

quartz flicker
#

like another method for the Scheduler delayedtask

chrome beacon
#

Well you're telling it to wait so it waits

hasty prawn
#

I assume you mean runTaskLater

quartz flicker
#

if i use the world edit maven in pom.xml it will work with fawe?

hasty prawn
#

No, you need to use FAWE's dependency

chrome beacon
quartz flicker
#

i only use the normal world edit in the code

#

not the fawe things

chrome beacon
#

FAWE contains the WorldEditAPI and as such you can just use WorldEdit but you will have to keep in mind FAWE might be slightly outdated

hasty prawn
#

I don't think it contains, it just maintains compatibility

#

Which is pretty nice of them lol

chrome beacon
#

FAWE is built on WorldEdit and acts as a replacement

quartz flicker
#
 Platform platform = Platform.getRandomPlatform();
        CuboidRegion region = new CuboidRegion(
                BlockVector3.at(
                        platform.point1.getBlockX(),platform.point1.getBlockY(),platform.point1.getBlockZ()
                ),
                BlockVector3.at(
                    platform.point2.getBlockX(),platform.point2.getBlockY(),platform.point2.getBlockZ()
                )
        );
        BlockArrayClipboard clipboard = new BlockArrayClipboard(region);

        try (EditSession editSession = WorldEdit.getInstance().newEditSession(region.getWorld())) {
            ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
                    editSession, region, clipboard, region.getMinimumPoint()
            );
            // configure here
            Operations.complete(forwardExtentCopy);
        }```
#

the newEditSession() not exists

chrome beacon
#

Yeah FAWE has that one missing

#

There is a deprecated one you can use

#

Don't have the name of it

quartz flicker
#

WorldEdit.getInstance().getEditSessionFactory()

#

this?

#

its deprecated

#

will it still work?

nimble loom
#

Im planning on making a sign shop plugin, and was wondering if I should record the location of the shop or just check if the sign title has a specific color that gets added when someone with permissions creates the sign shop.

chrome beacon
quartz flicker
#

how much do i need to set the max blocks?

#

its a floor of 15x15

#

what i copy

#

so 225?

chrome beacon
#

You don't need to set max blocks if you don't want to

quartz flicker
#

it needs the max blocks for the constructor

chrome beacon
#

-1 or just max int

quartz flicker
#

oh thx

#
Platform platform = Platform.getRandomPlatform();
        CuboidRegion region = new CuboidRegion(
                BlockVector3.at(
                        platform.point1.getBlockX(),platform.point1.getBlockY(),platform.point1.getBlockZ()
                ),
                BlockVector3.at(
                    platform.point2.getBlockX(),platform.point2.getBlockY(),platform.point2.getBlockZ()
                )
        );
        BlockArrayClipboard clipboard = new BlockArrayClipboard(region);


        try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(region.getWorld(),-1)) {
            ForwardExtentCopy forwardExtentCopy = new ForwardExtentCopy(
                    editSession, region, clipboard, region.getMinimumPoint()
            );
            // configure here
            Operations.complete(forwardExtentCopy);
        }

        try (EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(region.getWorld(),-1)) {
            Operation operation = new ClipboardHolder(clipboard)
                    .createPaste(editSession)
                    .to(getMainFloorPlatform().getPoint1())
                    // configure here
                    .build();
            Operations.complete(operation);
        }
#

thats what i did for now

#

its ok?

chrome beacon
#

I would use max int it's probably better

quartz flicker
#

can u see dm?

vivid zodiac
#

Hi, i'm french sry for this beautiful english

I make my first plugin in 1.16 and i want to break specific block with arrow
but idk what is the event for this
if anyone can help me c:

eternal oxide
#

ProjectileHitEvent

brittle loom
#

Hello, does anyone know a method I can use that prevents players from joining a server?

eternal oxide
#

AsyncPlayerLoginEvent or PlayerLoginEvent

#

?jd

brittle loom
#

Thanks for the help

patent wadi
#

any recommended method for adding advancements?

grim ice
#

how do i register a permission for each argument in a command (plugin.yml)

eternal oxide
#

you register a perm for teh root command. The args you have to manually test

patent wadi
#

implement it yourself by checking for permission when each argument is detected

grim ice
#

oh ok

grim ice
#

if i dont want a perm for the command

#

only for specific args

#

i should not

#

write permissions:

#

right

eternal oxide
#

yes, just leave that field out

tardy delta
#

how can i get the actual values?

if (!homes.isEmpty()) {
                    Utils.message(p, "§f--- §9Homes §f---");
                    homes.forEach(home -> {
                        Utils.message(p, home);
                        Utils.message(p, homesFile.getConfigurationSection("homes." + p.getUniqueId() + "." + home).getKeys(true).toString());
                    });
                }
brittle loom
#

Instead of using getKeys use getValues.

tardy delta
#

lmao you're too smart for this world

brittle loom
#

😂

tardy delta
#

have i really been struggling for this for 4 hours smh

patent wadi
#

Anyone know of a good method for adding advancements?

grim ice
#

Condition 'args.length == 0' is always 'false'

#

why breh

eternal oxide
#

I guess because you are using args

vivid zodiac
eternal oxide
#

remove()

vivid zodiac
#
@EventHandler
    public void onProjectileHit(ProjectileHitEvent e) {
        Entity entity = e.getEntity();

        if(entity instanceof Arrow){
            entity.remove();
        }
    }
#

i have this

opal juniper
#

Yep

#

Personally i would use EntityType

#

But that may work

vivid zodiac
#

Hmm, okay, but i want remove my arrow when it touch specific block

opal juniper
#

e.getHitBlock().getType()

vivid zodiac
#

== Material.Block ?

opal juniper
#

mhm

vivid zodiac
#

e.getHitBlock().getType() == Material.BOOKSHELF this

#

?

ivory sleet
#

Yes

opal juniper
#

^

patent wadi
#

There is an API I would like to try out, in their releases page is a jar file, if add it as a library it all works fine and compiles fine. but its not a plugin so it wont load on the server and not including it the actual plugin can't locate the classes. How would I use this, extract the class path from the jar and drop it into the root of my project? I tried putting the whole jar in there and it didn't like it.

opal juniper
#

Shade it

gritty urchin
#

Hey does anyone here have experience with TokenEnchantAPI?

patent wadi
#

how would i go about that?

opal juniper
#

Do you use maven?

patent wadi
#

nope

opal juniper
#

Intellij?

patent wadi
#

im using netbeans as my IDE

valid crag
#

you couldn't make it more difficult if you wanted

opal juniper
#

oh - sorry idk

#

exactly

valid crag
#

use maven and install the jar locally

#

as for how to use maven with netbeans, idk, ask md5

#

he's the only one I know of who uses that dumpsterfire

eternal oxide
opal juniper
#

or 7smile7 👀

#

from the looks of it

valid crag
#

the bratwurst man

opal juniper
#

mhm

patent wadi
#

yep

valid crag
#

how did your A* go

opal juniper
#

hahahhahaha

#

hahahahhaha

#

lmaooooo

#

ElgarL i tried to use ur algo but it was not really working

#

like

#

in sharp corners

#

it wouldn't path find

eternal oxide
# patent wadi yep

If its available via maven you can add it locally to your project, then add it to your plugin.yml in the libraries section. It will then be downloaded for you on whatever server your jar goes on.

opal juniper
#

so... i followed some shit C tutorial for A*

#

and it turned into an absolute dumpster fire

eternal oxide
patent wadi
#

okay, but the server bitches about it being in the plugins folder because its not a plugin

opal juniper
#

hmmm, maybe i didn't give it enough runs 🤔

valid crag
#

did you use the 8 line search thing I wrote

opal juniper
#

well

opal juniper
#

that became the basis of the loop

#

but

#

it still used the underlying shit cost logic

#

which was made for 2d

valid crag
#

show me what you have

patent wadi
#

so the dependency in the plugin.yml should make the server not try to load the jar as a plugin?

opal juniper
#

?paste

undone axleBOT
eternal oxide
opal juniper
#

only works in the x and y axis

#

it is literally non - functional

patent wadi
#

ok, thank you. ill try that.

vivid zodiac
opal juniper
#

all of what blocks

#

it can only hit one block

valid crag
#

how are the nodes laid out

#

are they spread on a voxel grid

#

like blocks

#

or are they just arbitrarily anywhere

opal juniper
#

yeah blocks = node

valid crag
#

then you don't need cost

#

all nodes are the same length away from all adjacent nodes

vivid zodiac
valid crag
#

the cost of each traversal is 1

quartz flicker
#

how to detect when anvil hit the ground?

opal juniper
#

cost = distance from start afaik

opal juniper
#

yep

robust forge
#

How do I change items durability? I have tried item.setDurability etc

quartz flicker
#

i wanna make the anvil destroy when hit the ground

eternal oxide
#

durability is actually a damage counter

robust forge
#

Oh

eternal oxide
#

measures how much damage the item has taken

valid crag
#

what do the various different costs prefixed by H na d F and G and whatever stand for

robust forge
opal juniper
#

wait ElgarL - ur class extended runnable - did it need to be ran several times for the optimal solution? now i am thinking that maybe i removed your plugin -specific code and made it non-functional

opal juniper
#

let me find the tutorial

valid crag
#

why do lines 31 through 36 exist

#

seems dumb

#

use a priority queue instead

opal juniper
#

bad algo

valid crag
#

delete

eternal oxide
opal juniper
#

G Cost = Distance from start
H cost distance from end

#

F cost = G + H

eternal oxide
#

if you want to increase the accuracy increase nodes or permitted time to run. Both are settings at teh top of the class.

opal juniper
#

idea is that when it moves towards the final goal the F cost is constant @valid crag

valid crag
#

are the nodes created from scratch every time the algo runs or are they pulled from some globally shared network

opal juniper
#

scratch

valid crag
#

right

#

remove lines 31 through 36

#

change the Stack to a PriorityQueue

robust forge
#
meta.damage(30);
item.setItemMeta((ItemMeta) meta);```

I tried this but seems like it doesnt work
valid crag
#

if closedSet.add returns false, continue;

#

that means the node has already been processed

#

no, what

opal juniper
#

let me load up an ide

quartz flicker
#

how to detect when a player hit by falling anvil?

valid crag
#

remove line 38

#

change closedSet.contains to !closedSet.add on line 45

#

remove openSet.contains on line 45

#

delete everything on lines 48 through 56

umbral pagoda
#

hi

valid crag
#

replace them with openSet.push

umbral pagoda
#

how ican know shorts

#

of potions ?

opal juniper
#

hang on

#

ide is now open

valid crag
#

and rename openSet to queue

#

and rename closedSet to processed

umbral pagoda
#

how ican know shorts of potions ?

#

?

valid crag
#

cut the trousers of the potions off at the knees

opal juniper
#

^

robust forge
#
((Damageable) itemMeta).setDamage(20);
item.setItemMeta(itemMeta);```
I tried this too but says "The method setDamage(int) is undefined for the type Damageable"
valid crag
#

wrong damageable

#

there are 2

robust forge
#

Oh ok

valid crag
#

one for entities, one for items

#

you've imported the one for entities

opal juniper
#

queue.pop -> queue.poll?

valid crag
#

whatever is the one that removes and returns the element at the head

vivid zodiac
eternal oxide
#

rayon?

eternal oxide
#

isn;t that a fabric used in dress making?

past maple
#

radius I think

vivid zodiac
opal juniper
#

thats a circle

vivid zodiac
#

sry yes 😂

valid crag
#

How To Remove Blocks in Oblate Spheroid

robust forge
#

org.bukkit.inventory.meta?

valid crag
#

org.bukkit.inventory.meta.Damageable

robust forge
#

Thanks

vivid zodiac
opal juniper
#

that was a joke

#

idk

#

loop

eternal oxide
#

three for loops over x,y,z

quaint mantle
#

Hey there! I am trying to detect left clicks on persistent item frames. Since they are persistent they do not trigger a EntityHitByEntityEvent. What would you suggest?

#

I thought about ray tracing on player interact event

opal juniper
#
java.lang.ClassCastException: class com.jeff.spigotsandbox.astar.Node cannot be cast to class java.lang.Comparable (com.jeff.spigotsandbox.astar.Node is in unnamed module of loader org.bukkit.plugin.java.PluginClassLoader @383bc6f1; java.lang.Comparable is in module java.base of loader 'bootstrap')
#

huh?

vivid zodiac
valid crag
#

either pass a Comparator to the queue's constructor, or make Node comparable

#

priority queues order their elements based on a property

opal juniper
#

oh

eternal oxide
#

you loop over all the blocks in that area and check their distance to the origin

opal juniper
#

right

valid crag
#

so the elements must either be comparable

#

or the queue needs to have a comparator for them

#

in this case we want the comparator to put the elements in order of shortest distance from target to longest distance from target

vivid zodiac
valid crag
#

that is, the closest node to the target is always at the head of the queue

shadow gazelle
#
itemshop:
    mainsize: 27
    stuff:
    categories:
        blocks:
            stuff:
        weapons:
            stuff:

So I have the above config and want to put every category under categories into a public inventory with the user being able to change the name in the config, so being able to change the blocks key to something like ranged, how can I get the first key under categories?

eternal oxide
#

Location#distanceSquared

opal juniper
#

so does node need to implement Comparable?

shadow gazelle
#

I was sent an example yesterday, but I'm pretty sure it wouldn't be able to make the inventories public

valid crag
#

either that or you need to provide a Comparator<Node> to the queue in the constructor

opal juniper
#

ok

valid crag
#

probably makes more sense for making it comparable

opal juniper
#

what does the int represent

#
    @Override
    public int compareTo(Object o) {
        return 0;
    }
valid crag
#

the result of compareTo

#

if o is greater than this, we return a positive value

opal juniper
#

ah ok

valid crag
#

if o is less than this, we return negative

#

if o is equal, we return zero

#

so just return Math.signum(this.distance - other.distance)

opal juniper
#

yeah but like

#

the distance

#

i only have this nodes location

valid crag
#

since you're constructing the nodes as you go, just make the constructor require the target

#

and cache the distance to the target in the constructor

opal juniper
#

target or source?

valid crag
#

target

#

we don't give a shit about the source

shadow gazelle
#

@hasty prawn doesn't seem to work

hasty prawn
#

Send the code for what you're doing

shadow gazelle
#

wtf is happening to Discord

#

?paste

undone axleBOT
shadow gazelle
#

That's what gets run when the server is reloaded (only while someone is on) or someone joins

opal juniper
#
@Override
public int compareTo(Object o) {
    if (o == null || getClass() != o.getClass()) throw new Error();
    Node otherNode = (Node) o;
    return Math.signum(this.target.distance(this.location) - this.target.distance(otherNode.getLocation()));
}

this good?

quaint mantle
#

@eternal oxide you are the one who helped me with entities ray tracing the last time. Do you think this is the best option here?

valid crag
#

implement Comparable<Node>

hasty prawn
valid crag
#

that way compareTo will only accept Nodes

#

and you don't need the casting or other shit

shadow gazelle
eternal oxide
hasty prawn
shadow gazelle
#

The rotation works that way for me

opal juniper
#

ok

shadow gazelle
#

Excuse me what the fuck

quaint mantle
shadow gazelle
#

This game is stupid

#

@hasty prawn it works now lmao

hasty prawn
#

😂

shadow gazelle
#

I did 20

#

and it works

hasty prawn
#

It's super finicky

shadow gazelle
#

Very good game

#

Clearly

high pewter
#

How can I only get advancements that would usually show in chat and get the name that shows in chat? Right now, I'm doing PlayerAdvancementDoneEvent.getAdvancement().getKey().getKey() but this gets an advancement for every single crafting recipe and block you can mine and it shows it as stuff like recipes/building_blocks/spruce_stairs or story/mine_stone instead of Stone Age

hasty prawn
#

Love how mine works for 15 but yours requires 20

quaint mantle
#

I could make them vulnerable and cancel ALL the events but I don’t think this is the best idea

hasty prawn
#

good logic

shadow gazelle
hasty prawn
#

Atleast it works

eternal oxide
shadow gazelle
#

Yeah, thanks for the help

quaint mantle
#

And I don’t understand why I can detect right click so easily and not left click

#

Isn’t it the same packet?

valid crag
#

the protocol is pretty fucked around the clicking and interaction parts

opal juniper
#

hmm it dont work

#

like nothing gets returned

#

i think it is running off to infinity

past pawn
#

you haven't completed the changes yet

opal juniper
#

oh wait it only runs once

#

who is that ?

past pawn
#

show me what you have

opal juniper
#

did u just switch accounts???

past pawn
#

yes

opal juniper
#

mid convo

#

whyyyyy

dusk flicker
#

Lol

past pawn
#

i felt like it

opal juniper
#

its so fucking obvious its u as well cause the names are always stupid as hell lmao

#

?paste

undone axleBOT
valid crag
#

yes, well, the obvious accounts are obvious intentionally

opal juniper
#

wait we never add to the node

#

queue

past pawn
#

i told you to add queue.push in place of the however many lines I told you to delete

shadow gazelle
opal juniper
#

must have missed

#

where

valid crag
#

line 44

hasty prawn
#

Lmao welp

valid crag
#

set the parent of the neighbour node to node

#

and add neighbornode to the queue

#

mext

#

instead of returning a hashset from getNeighbors

#

return an arraylist

#

and change the return type to collection

opal juniper
#

hang on

#

line 44

valid crag
#

sets are inefficient for iteration and are not very space efficient

opal juniper
#

you want a queue.push(neighbourNode)

valid crag
#

yes

opal juniper
#

am i using the wrong queue

valid crag
#

is it a priority queue

opal juniper
#

PriorityQueue<Node> queue = new PriorityQueue<>();

valid crag
#

why are you asking if you're using the wrong queue

opal juniper
#

cause push aint defined

valid crag
#

idr what the actual method is

#

the one that adds an element and blows up if it runs into capacity restrictions

#

maybe add, maybe offer, maybe push

#

there's like 5 of them and I always mix all of them up

opal juniper
#

add

valid crag
#

remember to set the parent

opal juniper
#

lime 86

#

it gets set

#

node1 is a shit var name

valid crag
#

the paren't isn't set 100% properly but it's good enough for now

#

probably

vivid zodiac
opal juniper
#

and u wanted a different Set

valid crag
#

an arraylist

#

you never do contains or remove or add or whatever on the set

#

it might as well be a collection

#

hashsets are very space inefficient

#

and not good at iteration

#

which are the 2 things we care about here

opal juniper
#

return type = collection
neighbours = ArrayList?

valid crag
#

yes

opal juniper
#

ok

valid crag
#

initialize the arraylist to have a size of blockFaces.size()

#

that way it doesn't get resized dumbly or have excess empty elements

opal juniper
#

ok

idle grotto
opal juniper
#

IT WORKS

#

YAYYYY

valid crag
#

now, it doesn't give the optimal path

#

because the way the parent is set isn't right

opal juniper
#

seems pretty good

valid crag
#

but it does give you a path

vivid zodiac
#

anyone know how to use distanceSquared to place blocks arounds it ?

valid crag
#

you remember the A* wiki page

vivid zodiac
#

i looked some exemple but i dont know how it's work

opal juniper
#

yep

valid crag
#

what we have now gives something along the lines of the gif in the 'bounded relazation' section

opal juniper
#

ok...

vivid zodiac
valid crag
#

the optimal route would be this

shadow gazelle
#

Is there any way to detect the server software your plugin is running on?

idle grotto
opal juniper
#

the first seems better

valid crag
#

the path is longer

#

and thus less optimal

eternal oxide
opal juniper
#

ok true

vivid zodiac
valid crag
#

you can slightly improve the path by doing a second pass and picking the nearest node to the source rather than the parent during retrace

vivid zodiac
#
if(e.getHitBlock().getType() == Material.WHITE_CONCRETE)
{
  for(int x = block.getX() - 1; x < block.getX() + 2; x++)
  {
    for(int z = block.getX() - 2; z < block.getX()+2; z++)
    {
      for(int y = block.getX() - 2; y < block.getX() + 2; y++)
      {
        Block blockToDelete = world.getBlockAt(x, y, z);
        blockToDelete.setType(Material.AIR);
      }
    }
  }
}
eternal oxide
#

Its best you tell us what you actually want to do, as you have given two different things so far.

tame coral
#

In inventoryclickevent, is event.isLeftClick() the same as event.getClick() == ClickType.LEFT ?

valid crag
#

but that requires some reworking of the way how the nodes are constructed

eternal oxide
#

so you are just removing blocks all around the hit block

opal juniper
#

hmm this definitely aint the optimal

vivid zodiac
opal juniper
#

will you be around tomorrow? its just i have to go now

valid crag
#

is the target directly behind the stone

opal juniper
#

in the distance

#

but it is directly on the z axist

valid crag
#

whats the second yellow path

opal juniper
#

the one that carries on after the stone is made b4 i added the stone

#

the second with the arrow

#

is the way "around"

valid crag
#

show a bigger screenshot

#

can't see the target

opal juniper
#

500 blocks

valid crag
#

your distance function is probably broken

opal juniper
#

... maybe

hasty prawn
#

no that's definitely optimal 🧠

opal juniper
#

eh - i gtg

#

thanks a tonne

#

it actually works now

shadow gazelle
#

@hasty prawn one other thing with NPCs, have you done turning the NPCs head to the player before?

hasty prawn
#

Yeah

#

Whats your question about it?

shadow gazelle
#

How do you do it lol

#

I know the setting the head pos stuff, but idk how you would track the player's movement

vivid zodiac
hasty prawn
#

And look at them

eternal oxide
#

if you want an actual radius, yes

vivid zodiac
#

entity.getLocation().distanceSquared(location) ?

eternal oxide
#

if you just want a cube of blocks, then you don;t need a distance calculation

#

3 for loops over X,Y,Z + and - radius.
If you just want the whole area you set all blocks.
If you want a sphere you check the distance to each block from the origin before removing it.

vivid zodiac
#

i makes this yes, but i want circle x)

eternal oxide
#

then you check the distance

#

if its outside the distance you don't remove the block

vivid zodiac
#
for(int x = block.getX() - 1; x < block.getX() + 2; x++)
{
      for(int z = block.getZ() - 1; z < block.getZ() + 2; z++)
       {
            for(int y = block.getY() - 1; y < block.getY() + 2; y++)
             {
                Block blockToDelete = world.getBlockAt(x, y, z);
                 if(blockToDelete.getType() == Material.WHITE_CONCRETE)
                 {
                      blockToDelete.setType(Material.AIR);
                  }
              
       }
}
shadow gazelle
eternal oxide
hasty prawn
#

Every second or so, get all the player's with a few blocks of the NPC and check who is the closest

shadow gazelle
#

Hmm yes

#

Falling through the world in my test server

#

very nice

#

Alright then, game

vivid zodiac
eternal oxide
vivid zodiac
#

i want circle

#

mb

eternal oxide
#

then add a distance check

vivid zodiac
#

but with my code i make square

#

how add distance check ? with block location ?

eternal oxide
#
if (block.getLocation().distanceSquared(blockToDelete.getLocation()) < distance) blockToDelete.setType(Material.AIR);```
valid crag
#

spoon

eternal oxide
#

a big wooden one

faint vector
#

how do you guys usualyl go around getting the uuid of a player from their name without sending out requests to minecraft?

valid crag
#

by using paper's getOfflinePlayerIfCached

#

which uses the local usercache

#

beyond that, it isn't really possible

faint vector
#

oh

valid crag
#

granted, getOfflinePlayer also uses the usercache I think

eternal oxide
#

getOfflinePlayers() and loop them to search

valid crag
#

that is gargantually slow and not reliable

vivid zodiac
#

that work perfectly thx

valid crag
#

for one, there can be several offline players with the same name

#

there is no guarantee you'll get the "right" one

eternal oxide
#

Correct, but with Spigot there is no alternative

valid crag
#

use getOfflinePlayer off the main thread I suppose

#

so the network request doesn't kill the server

shadow gazelle
hasty prawn
#

Yeah

shadow gazelle
#

Alright

valid crag
#

it'll try to look it up from the usercache anyway so the request is the worst case scenario

eternal oxide
valid crag
#

iirc it isn't

#

i vaguely remember that being intentional as well

#

as you would be legitimately fucked if it was blocked off

#

you'd have to make the ifCached call sync and then manually ring up mojang api if it doesn't return a result

naive mulch
#

Can somebody link me an open source Spigot mod that uses Brigadier please? Can't really find much.

ivory sleet
#

Doesn’t nms use it?

#

Oh well it’s not a spigot plugin but yeah

worldly ingot
#

Luck's got a library for it. Commodore

naive mulch
# ivory sleet Doesn’t nms use it?

I think so but my friend is currently trying to use CommandSourceStack and can't find it so I think the issue is that he has to specify brigadier as a dependency in his Gradle files but he thinks I'm wrong

worldly ingot
naive mulch
#

Ah so I was right

fluid cypress
#

how can i run each iteration with a second or so of delay?

for (World world : worldRegions.keySet()) {
    // just fill up the list up to the cache size
    for (int i = 0; i < cacheLocationsSize - rtpLocations.size(); i++) {
        // calculate a random location
        Location randomLocation = getRandomLocation(world);
        // add it to the cache
        rtpLocations.get(world).add(randomLocation);
    }
}

i dont fully understand yet the scope when using anonymous functions, or lambdas, or whatever theyre called, the thing u do when doing new BukkitRunnable() {... etc

dusk flicker
#

?scheduling

undone axleBOT
valid crag
#

that's an anonymous local class

#

what it does is creates a local, single-use class without a name that extends BukkitRunnable

vivid zodiac
#

How work location ? I maked this for try, but alltimes i've Z- and X-

if(player.getEyeLocation().getZ() > 0)
{
    player.sendMessage("Z +");
}
if(player.getEyeLocation().getZ() < 0)
{
    player.sendMessage("Z -");
}
if(player.getEyeLocation().getX() > 0)
{
    player.sendMessage("X +");
}
if(player.getEyeLocation().getX() < 0)
{
    player.sendMessage("X -");
}
worldly ingot
#

eye location is just getting the player's location at their eyes

#

You want the direction they're looking

#

player.getLocation().getDirection()

#

Returns you a vector. Compare against those component instead

vivid zodiac
#

ohh

fluid cypress
# dusk flicker ?scheduling

that doesnt say anything about scope, i cant use a local variable inside that, for example. i remember something about atomic integer, but maybe there is something specifically for loops

fluid cypress
eternal oxide
#

depends if they are final or not

ivory sleet
fluid cypress
valid crag
#

the difference is finality

#

you can use final or effectively final variables

#

however variables that are assigned more than once, that is, effectively non-final variables, cannot be used

#

this is because the scope of the anonymous class cannot accurately reflect any changes made to those variables

fluid cypress
#

and can i modify the value of an effectively final variable?

valid crag
#

by definition not

#

it is effectively final if it is not modified

naive mulch
#

With Fabric there's a ServerCommandSource but since mappings for Spigot are different I can't find the equivalent here, the intermediary class name is class_2168 if that helps, where would I use that to find what it's called with Spigot?

fluid cypress
#

by effectively final you mean keep it constant but without using the final keyword, right?

valid crag
#

yes

worldly ingot
#

ConsoleCommandSender iirc, Taco

valid crag
#

if is effectively final, but not labeled as final

naive mulch
#

Thanks

valid crag
#

which as far as the compiler and jvm are concerned, are equivalent

worldly ingot
#

That's the Bukkit interface, sorry. Though there would be a Craft implementation of it that wraps an NMS value

fluid cypress
#

ok, so, like a while loop, but with a MutableInt and a BukkitRunable instead of the while

#

and this.cancel instead of break

valid crag
#

maybe

#

kind of smells like a design issue, but maybe

#

do you have code and context to show

eternal oxide
#

If you are using a Runnable you can pass in a final variable to a local variable and modify it in the runnable

fluid cypress
#

the thing is that it will generate chunks, in a pretty crap pc, and i dont want it to be generating world a lot, idk

#

thats the only reason i want a timer

valid crag
#

consider using paper and chunky

fluid cypress
#

i do

#

tho idk what is chunky

valid crag
#

a chunk pregenerator

fluid cypress
#

ahh

#

yea, i pregenerated all worlds

#

but the resources world is new every day, so

#

im getting some random locations before a player needs it

#

so they dont have to wait for it to generate and stuff

valid crag
#

use, uh

#

what's that one plugin made by one of the paper guys

opal juniper
#

🤔

valid crag
#

it's a rtp plugin that pregenerates the chunks around the rtp locations ahead of time

#

basically what you're trying to achieve right now, I think

opal juniper
#

if not i think 7smile7 has a chunk generator

#

but it just pre-gens chunks

fluid cypress
whole stag
#

Thank you java

grim ice
#

?paste

undone axleBOT
whole stag
#

You couldn't have given a compile time error for this?

opal juniper
#

😄

valid crag
#

well, you can't really convert a for loop into a runnable directly

#

you can make a for loop that runs in a runnable, or you can make a for loop that fires runnables

grim ice
chrome beacon
valid crag
#

but trying to make a for loop pause-resume with a runnable is a bit more involved

opal juniper
#

jail loc = null @grim ice

whole stag
grim ice
#

oh

chrome beacon
#

Aight just know that their jdk can compile with errors and code end up like that

grim ice
#

How is it null???

#

breh

#

its not null though

#

:<

opal juniper
#

meh - sysout it

#

it will tell u if its null then

vivid zodiac
whole stag
#

Seems like that should be compile time, right?

opal juniper
valid crag
#

there are some flags you can set in some cases that allow you to compile shit that shouldn't compile

worldly ingot
#

Player#getFacing() will get you the BlockFace they're facing

#

player.getLocation().getDirection() will get you the exact vector they're looking

valid crag
#

note that it doesn't ever actually return up or down

worldly ingot
#

Correct

grim ice
#

@opal juniper YEAH ITS NOT NULL

#

I JUST CHECKED CONFIG

valid crag
#

config doesn't mean shit

opal juniper
valid crag
#

if it's null it's null

chrome beacon
grim ice
#

no

opal juniper
#

Do that

valid crag
#

then it's probably null

grim ice
opal juniper
#

^

valid crag
#

your config isn't omnipotent

vivid zodiac
grim ice
#

its getting the values from the config

valid crag
#

well it might be getting them wrong

opal juniper
#

But the location it makes is null

grim ice
#

and the values are not null

#

w h a t

valid crag
#

in a nutshell

grim ice
#

the location is an xyz value

valid crag
#

your code probably sucks

#

doublecheck it

grim ice
#

take a look

valid crag
#

no

grim ice
valid crag
#

sysout it and trace the issue

grim ice
#

ok

valid crag
#

or use the helpful npe messages

grim ice
#

wait what

#

why sysout

vivid zodiac
valid crag
#

do you want help or not

worldly ingot
#

You can just compare it directly. No reason to stringify it

#

getFacing() returns a BlockFace. Compare it

vivid zodiac
#

i have error

valid crag
#

and that isn't how you compare strings, anyway

worldly ingot
#

if (player.getFacing() == BlockFace.NORTH) for instance

grim ice
valid crag
#

then do what we tell you to do

#

instead of whining and complaining about it

grim ice
#

how tho

valid crag
#

System.out.println

vivid zodiac
#

thx you

grim ice
#

right below the null line?

valid crag
#

sysout the variable that you suspect being null before invoking any methods on it

grim ice
#

its an object

valid crag
#

no

#

it's a variable

grim ice
#

yes but its a location how can it print a location

chrome beacon
valid crag
#

did you even try it

chrome beacon
#

It should tell you if it's OpenJ9 or not

grim ice
#

so basically

#

?paste

undone axleBOT
whole stag
#

Shows as OpenJDK 64-Bit

chrome beacon
#

Hm idk then pretty sure the compile should fail

whole stag
#

Remote server is the same fwiw

grim ice
#

@valid crag

whole stag
#

And local test environment

grim ice
#

??

fluid cypress
# valid crag but trying to make a for loop pause-resume with a runnable is a bit more involve...

something like this

public static void fillRtpLocations() {
    for (World world : worldRegions.keySet()) {
        for (int i = 0; i < cacheLocationsSize - rtpLocations.size(); i++) {
            Location randomLocation = getRandomLocation(world);
            rtpLocations.get(world).add(randomLocation);
        }
    }
}

to this?

public static void fillRtpLocationsTimer() {
    MutableInt worldIterator = new MutableInt(0);
    MutableInt locationIterator = new MutableInt(0);
    new BukkitRunnable() {
        public void run() {
            if (worldIterator.intValue() < worldRegions.size()) {
                World world = worldRegions.keySet().stream().toList().get(worldIterator.intValue());
                if (locationIterator.intValue() < cacheLocationsSize - rtpLocations.size()) {
                    Location randomLocation = getRandomLocation(world);
                    rtpLocations.get(world).add(randomLocation);
                    locationIterator.add(1);
                } else
                    worldIterator.add(1);
            } else
                this.cancel();
        }
    }.runTaskTimer(instance, 0, 5);
}
#

5 sec of delay for each iteration

valid crag
#

those don't need to be mutable

#

declare them as normal variables inside the bukkitrunnable

#

they only need to be effectively final if they are declared outside of it

fluid cypress
#

mmm right

grim ice
#

bat u there

valid crag
#

other than that, building a list and getting the n'th element of a set with streams is inefficient

#

consider populating a Queue with the contents of the keyset

#

and then popping one element out of it with each iteration

fluid cypress
#

right

opal juniper
#

2hex

vivid zodiac
#

org.bukkit.plugin.AuthorNagException: No legacy enum constant for WHITE_CONCRETE. Did you forget to define a modern (1.13+) api-version in your plugin.yml?
hmmmm ?

grim ice
grim ice
valid crag
#

did you try it

#

did you sysout it

opal juniper
#

SYSOUT THE LOC

valid crag
#

did you do what I told you to do

opal juniper
#

then we help

grim ice
#

like this

#

?

valid crag
#

just do it

opal juniper
#

Yes

valid crag
#

try it instead of asking us for every single fucking step

opal juniper
#

Like that

grim ice
#

ok

wide coyote
grim ice
#

if u dont want to help just dont

opal juniper
#

He does want to help

valid crag
#

you really don't seem like you want help

opal juniper
#

But you are being a pain

grim ice
#

screaming at ppl isnt rly helping

shadow gazelle
#

@hasty prawn one last thing, have you ever done getting the NPC a player is looking ata?

opal juniper
#

We are helping you trouble shoot and you are like but the config isn’t null

valid crag
#

shut up and sysout the location already

vivid zodiac
shadow gazelle
#

Aw, okay

#

I guess I could also get the NPCs from the hash map and get their IDs and make a select command in the form of the ID...

wide coyote
grim ice
#

@opal juniper@valid crag

#

it gave me a npe error

#

again

chrome beacon
#

Well does your config contain the values you're reading

grim ice
#

Yep

chrome beacon
#

Double check that with a sysout

eternal oxide
#

?paste config

undone axleBOT
valid crag
#

the npe isn't important

#

what is important is what the sysout printed

#

why do you think we put the sysout there?

grim ice
#

nothing was printed

#

and what was sent is a npe error

valid crag
#

what line is the sysout on

chrome beacon
#

Sysout won't run if error happens before it

valid crag
#

give me a line number

grim ice
#

is config

valid crag
#

or don't, whatever

grim ice
chrome beacon
grim ice
#

1s

nimble loom
#

Im creating an economy plugin and am currently working on the api for it. Should I make the api methods static and synchronized so i am 100% sure there is no concurrent access?

eternal oxide
#

yep, ints will return null

#

you are reading doubles as ints

grim ice
#

its because theyre doubles

#

omg

#

im dumb

#

is that only reason

valid crag
#

and regrettably, learned nothing from this

#

when you run into a NPE next time, what will you do?

eternal oxide
#

break the whole line up and see what part is null.

#

Welcome back "batman" 😄

grim ice
grim ice
#

i should just replace int with double

#

righr

#

right

valid crag
#

depends on whether you need an int or a double

eternal oxide
#

depends on the precision you want/need

#

or how you save/load

#

.like you know there is a config#getLocation riight?

valid crag
#

right so is there a way to get or compute a soft ref out of a map

#

without it being super gay

eternal oxide
#

soft ref?

valid crag
#

SoftReference

eternal oxide
#

yeah, not sure what you mean

valid crag
#

aka a reference to an object that may be nulled by the garbage collector if the system is low on memory

#

usually used for caches

quaint mantle
#

Hello everyone, I want to save a HashMap on Disable and load it again on Enable. I already know how to save it, but I don't know how to load it again.

    public void onDisable() {
        // Plugin shutdown logic
        File file = new File("plugins/SteinerAddon", "cooldowns.yml");
        FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);

        cfg.set("cooldowns", HeadCMD.cooldown);

        try {
            cfg.save(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }```
grim ice
ivory sleet
#

is every entry/key wrapped with one?

grim ice
#

replacing ints with doubles in that case would fix it

#

right

valid crag
#

every value is

vivid zodiac
#

if i make timer for use item, all server have this timer ?

valid crag
#

Map::computeIfAbsent won't cut it I don't think, as the reference might be nulled by the gc between being grabbed/computed from the map, and actually returned

ivory sleet
#

What map implementation are you using?

eternal oxide
#

surely it would not be gc'd if there is a ref in the map being held

valid crag
#

the ref is to the softref

#

just a regular old hashmap

eternal oxide
#

teh value would if thats null btu the key shoudl still be there

valid crag
#

the whole point of the ordeal is that the actual value isn't referenced anywhere else other than the map, so it can be yeeted by the gc at will

ivory sleet
#

So we're talking about a HashMap<K,SoftReference<V>>

valid crag
#

and the map refers to it with a softref, facilitating said yeeting

#

yes

#

I want to get a V out of it

#

and ensure the V doesn't get yeeted in between the getting/computing and returning part

#

I can't computeIfAbsent a SoftRef<V> and then call get on it to get the V, as then there's a point in time when V isn't referenced strongly

#

so V can be yeeted in between the Map::computeIfAbsent and the SoftRef::get

#

the only way I can think of is to have alike a 1 sized array and put the V in the array inside the computeifabsent call

#

to strongly refer to V for the duration

#

but that's annoying

fluid cypress
#

a way to improve this crap?

public static Location getRandomLocation(World world) {
    Vector min = worldRegions.get(world).getMin();
    Vector max = worldRegions.get(world).getMax();
    Vector offset = max.subtract(min).multiply(new Vector(Math.random(), Math.random(), Math.random()));
    Location randomLocation = min.add(offset).toLocation(world).getChunk().getBlock(0, 0, 0).getLocation();
    Location teleportLocation;
    for (int i = 0;; i++) {
        teleportLocation = randomLocation.clone();
        teleportLocation.setX(randomLocation.getBlockX() + 16 * i);
        for (int x = 0; x < 16; x++) {
            for (int z = 0; z < 16; z++) {
                int airBlocks = 0;
                for (int y = 128; y > 45; y--) {
                    Material blockType = teleportLocation.getBlock().getType();
                    if (blockType == Material.AIR)
                        airBlocks++;
                    else if (blockType == Material.GRASS_BLOCK && airBlocks >= 2)
                        return teleportLocation;
                    else
                        airBlocks = 0;
                }
            }
        }
    }
}

is there an enum or something to know if a block is, like, empty? grass, vines, etc, instead of just checking for air

ivory sleet
#

You could wrap the softref in a class which would cache the value to its instance field during those computations, think its called an adapter or bridger

eternal oxide
#

Will tell you if its an impassable block

valid crag
#

will also return false for a lot stuff that is impassable

eternal oxide
#

grass etc are not solid

valid crag
#

like fences, glass panes, stairs, etc

#

there is a call on Material or Block for isCollidable or something

eternal oxide
#

true

vivid zodiac
#

How can i make good timer ?

valid crag
#

not super reliable either, but it's the best I know of

#

the api doesn't actually let you get to actual collision shapes

#

mmm so I'd use a Map<K, Bridger<V>> where Bridger implements softreference functionality with a sort of on/off switch that'd let me temporarily strongly reference it

#

maybe

ivory sleet
#

yeah precisely

quaint mantle
#

Hey is there a unified library to check if a player can build in a specific place?

#

Without having to make a compat with every single protection plugin

ivory sleet
#

though I suppose that partly eliminates the idea of a soft reference

valid crag
#

one problem I foresee is that for each call on call you always need to ensure an off call

#

otherwise it can accidentally or unexpectedly be left as strongly reachable forever

ivory sleet
#

oh yeah

static ingot
valid crag
#

should be possible to ensure that

#

i think

#

not enforce, but ensure

#

which is good enough i guess

fluid cypress
ivory sleet
#

yeah, well idk I would probably create my own map implementation as a decorator/bridger

quaint mantle
ivory sleet
#

assuming one uses for each which effectively is an iterator loop

static ingot
#

I'm not saying use Vault, I'm saying use the ServicesManager in Spigot like Vault does.

quaint mantle
#

Yes this is basically what I am asking for

static ingot
#

That is how Vault gets any economy/chat/permissions plugin without knowing it and implementing compatibility itself

quaint mantle
#

so do you have any example of services manager for protection?

valid crag
#

i could probably scrape something together with threadlocals or something that'd work as an util

ivory sleet
#

alright gl

quaint mantle
grim ice
#

paste

#

?paste

undone axleBOT
valid crag
#

public static V retrieveV(Map<K, SoftReference<? extends V>, K key)

grim ice
static ingot
grim ice
#

target.teleport(jail_loc);
line 48

#

help pls

quaint mantle
#

I know how they do it, but I don't want to do it?

#

They support a wide range of plugins

static ingot
#

That's not what you want?

quaint mantle
#

I don't want to write a code for every single protection plugin

#

I'm looking for something that already handles it

grim ice
#

          if (args.length == 2 && !args[0].equalsIgnoreCase("create") && plugin.getConfig().isConfigurationSection("jails." + args[1]) && !args[0].equalsIgnoreCase("help") && !args[0].equalsIgnoreCase("reload") && !args[0].equalsIgnoreCase("remove")) {
                    if (sender.hasPermission("jail.teleport")) {
                        Player target = Bukkit.getPlayer(args[1]);
                        Location jail_loc = new Location(p.getWorld(), plugin.getConfig().getDouble("jails." + args[1] + ".x"), plugin.getConfig().getDouble("jails." + args[1] + ".y"), plugin.getConfig().getDouble("jails." + args[1] + ".z"));
                        assert target != null;
                        target.teleport(jail_loc);
                        target.getPersistentDataContainer().set(new NamespacedKey(plugin, "jail"), PersistentDataType.STRING, "jailed");
                        p.sendMessage(ChatColor.DARK_GREEN + "Successfully Sent " + ChatColor.GOLD + target.getDisplayName() + ChatColor.DARK_GREEN + "to jail " + ChatColor.GOLD + args[1]);
                    }
                }```
static ingot
#

That's why Vault uses the ServicesManager - so that they don't have to write code for every single plugin using Vault, lol

quaint mantle
#

Currently I'm calling on PlayerBlockPlaceEvent and I check if it is cancelled

#

if it is I revert my blockplacing

#

same with remove

quaint mantle
#

But then, what's the point of Vault if the ServicesManager allows you to not write a different code per plugin?

neat python
#

I'm a bit stuck. How do I cancel a repeating task from within the task?

eternal oxide
neat python
#

BukkitRunnable is deprecated

#

throws errors when I use it

eternal oxide
#

BukkitTask isn't

dusk flicker
#

?scheduling

undone axleBOT
static ingot
#

You can just implement your region handling in the same plugin though

vivid zodiac
#
Bukkit.getScheduler().runTaskTimer(this, new BukkitRunnable() {
    @Override
    public void run() {
        Bukkit.broadcastMessage("test");
    }
}, 0, 20 * 1);
        at org.bukkit.craftbukkit.v1_16_R3.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:539) ~[spigot.jar:2991-Spigot-018b9a0-f3f3094]```
who can help me? 😦
static ingot
quaint mantle
opal juniper
#

But md is never here

quaint mantle
valid crag
#

thankfully

static ingot
#

ah. no threads here yet. rip

whole stag
#

What's the event that I need to detect when a player throws an ender pearl?

valid crag
#

player throw shit event

static ingot