#help-development

1 messages · Page 2156 of 1

tardy delta
#

anyways does anyone use whats the suppresswarning thing for not using a try with resources on an AutoClosable object?

granite burrow
#

I've got a question, is World#getTime() saved in tick format? I'm assuming it is however whenever I'm doing the math to convert the ticks to time I am getting something different from EssentialsX

mortal hare
#

its saved in minecraft time. 24000 is max

lost matrix
mortal hare
#

it returns value which you input inside vanilla /time set command

quaint mantle
#

I just went with creating different worlds for each team.
Although i'm running into a little issue here.

lost matrix
#

You could use the PlayerItemConsumeEvent

mortal hare
#

it follows 24 hour format but multiplied by 1000

quaint mantle
#

Into the bukkit.yml file, there's a setting that allows you to change the directory of where the world will be generated, but it does not work for some reason.

tardy delta
#

and i found the suppresswarning string, its just 'resource'

granite burrow
lost matrix
#

Then just bridge the events by using a data structure. You just need to find out which one is fired first.

daring lark
#

what is max durability? is it 1?

lost matrix
daring lark
#

lol

#

i thought that it's %

lost matrix
#

Well... its an integer type so that would be quite weird

lost matrix
#

In the context of resource packs (when speaking of predicates for example) then 1.0 is the max value.

tardy delta
#

ow 7smile7, i might indeed want to write implementations for the ConfigSupplier

#

i can just put them in the enum file

lost matrix
#

Where H2ConfigSupplier implements ConfigSupplier

tardy delta
#

ye

#

H2ConfigSupplier::new

#

a supplier for a supplier mm ye

daring lark
#

is there any way to create enchant from string?

lost matrix
tardy delta
#

no no no (String, ConfigSupplier)

#

i meant to store suppliers to the actual configsupplier object

lost matrix
tardy delta
#

too much supplier in that sentence tbh

lethal python
#

if i want to check if there is air at some coordinates is this the fastest way to do it: loc.getBlock().getBlockData().getMaterial() == Material.AIR?

#

is there no method just like isEmpty or something

lost matrix
lethal python
#

sorry i mean if it's air

#

"empty"

lost matrix
#

You simply call

if(block.getType().isAir()) {

}
lethal python
#

:v

chrome beacon
#

getBlock().getType().isAir()

lethal python
#

thank you

daring lark
lost matrix
rough drift
#

no fancy annotation bs for closing

daring lark
lost matrix
daring lark
#

can i convert material to string?

tardy delta
#

Material#name i'd say

lost matrix
#

material.toString()

#

Wait. name() is the clean solution. Doesnt make a diff here but usually you want to use name() for dev purposes and toString for readable representations.

tardy delta
#

what is toString for an enum even returning? as those are just constants

#

when its not overridden

lost matrix
#

the same as name()

tardy delta
#

ah

quaint mantle
#
public static void createWorld(Player p, String name){
        WorldCreator creator = WorldCreator.name(name);
        p.sendMessage("World creation started.");
        new BukkitRunnable() {
            @Override
            public void run() {
                creator.environment(World.Environment.NORMAL);
                creator.type(WorldType.NORMAL);
                creator.createWorld();
            }
        }.runTaskAsynchronously(GioxMC.getPlugin());
        Bukkit.createWorld(creator);
        p.sendMessage("World creation finished.");
    }```
This is the current code that I use to generate worlds, and for some reason, I cannot run it async, is there a particular way to do it or ?
quaint mantle
lost matrix
tardy delta
#

anyways goodnight

quaint mantle
#

And also, does it hit the tps hard ?

lost matrix
quaint mantle
#

Well lets say you have 70 players, about 60 worlds need to be loaded.

#

1 world per player 1 island per player

humble tulip
#

Is it skyblock?

quaint mantle
#

Yeap.

humble tulip
#

I think u should use slimeworlds then

quaint mantle
#

huh?

humble tulip
#

Slimeworldformat

#

Check on spigot

quaint mantle
#

oh same as what hypixel uses

fossil lily
#

Is it possible to disable the "Saved Inventory" feature?

humble tulip
mortal hare
quaint mantle
fossil lily
mortal hare
#

well disabling it completely from the server afaik is not possible, but what you can do is to cancel those actions, just like inventory click events and such

#

but since its creative inventory feature

#

i doubt that it even possible since many things on creative inventories are being handled by client

#

its probs possible

#

but im not sure

#

since items are being added to the player's inventory, server should get info about the player's inventory, thus restoring the previous inventory state should be possible, but im not sure if this exists inside bukkit api or you need to implement this check yourself

lethal python
#

I have a playerinteractevent and i only want it to fire on right clicks how do i do that

mortal hare
#

how tf enderchest is similiar to underclothes 😂

quaint mantle
#

Is there anything that I can do to load a world async and not have as much performance impact ?

daring lark
#
        at com.google.common.base.Preconditions.checkArgument(Preconditions.java:220) ~[guava-31.0.1-jre.jar:?]
        at org.bukkit.NamespacedKey.<init>(NamespacedKey.java:50) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.NamespacedKey.minecraft(NamespacedKey.java:143) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at org.bukkit.enchantments.EnchantmentWrapper.<init>(EnchantmentWrapper.java:12) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]
        at me.placek.blockeconomy.shops.ShopItem.toItemStack(ShopItem.java:38) ~[BlockEconomy.jar:?]
        at me.placek.blockeconomy.commands.ItemCreationTest.onCommand(ItemCreationTest.java:18) ~[BlockEconomy.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]``` why am i getting that error?
#

    public ShopItem(ItemStack item) {
        count = item.getAmount();
        name = item.getItemMeta().getDisplayName();
        material = item.getType().toString();
        enchants = new HashMap<>();
        if(!item.getItemMeta().getEnchants().isEmpty()) {
            for(Map.Entry<Enchantment, Integer> entry : item.getItemMeta().getEnchants().entrySet()) {
                enchants.put(entry.getKey().toString(), entry.getValue());
            }
        }

    }

    int count;
    String name;
    String material;
    Map<String, Integer> enchants;

    public ItemStack toItemStack() {

        ItemStack item = new ItemStack(Material.matchMaterial(material), count);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName(name);
        if(!enchants.isEmpty()) {
            for(Map.Entry<String, Integer> entry : enchants.entrySet())  {
                meta.addEnchant(new EnchantmentWrapper(entry.getKey()), entry.getValue(), false);
            }
        }
        return item;
    }

}``` code
quaint mantle
#

Line 38

daring lark
#

so what i have to fix?

#

like how?

quaint mantle
#

your key is invalid it says it

#

Caused by: java.lang.IllegalArgumentException: Invalid key. Must be [a-z0-9/._-]: Enchantment[minecraft:blast_protection, PROTECTION_EXPLOSIONS]

daring lark
#

so how could i convert string to enchant?

quaint mantle
#

sec

#

Enchantment#getByName

lethal python
#

guys how do i detect if a playerinteractevent was a right click or left click?

daring lark
#

i can use only getbykey

waxen plinth
#

Returns an enum describing what the action was

#

Right/left click on a block/air

void escarp
lethal python
#

thank you redempt

waxen plinth
#

Are you using maven/gradle?

void escarp
#

maven

waxen plinth
#

Do you have placeholder api declared as a dependency via your pom.xml

void escarp
#

i have it as dep in plugin.yml

waxen plinth
#

That's not enough

void escarp
#

what do i need to do?

waxen plinth
#

You need to declare it as a dependency in your pom.xml

#

Declaring it in your plugin.yml will make spigot give an error if your plugin is on the server without the dependency

#

Declaring it in your pom.xml is what actually allows you to link your code against it though

void escarp
#

thanks, I have found the xml i need to add

#
    <repositories>
        <repository>
            <id>placeholderapi</id>
            <url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
        </repository>
    </repositories>
    <dependencies>
        <dependency>
         <groupId>me.clip</groupId>
          <artifactId>placeholderapi</artifactId>
          <version>{VERSION}</version>
         <scope>provided</scope>
        </dependency>
    </dependencies>
daring lark
quaint mantle
#

idk man

void escarp
waxen plinth
#

You left {VERSION} in your pom.xml

#

Replace it with an actual version

grim ice
#

@waxen plinth red is that you!!! First time I've seen u with a new pfp

#

Poggers

void escarp
#

<version>2.11.1</version>

waxen plinth
void escarp
#

which seems to be the latest

grim ice
#

Oh lol

#

I need project ideas rn tbf

#

In the meanwhile im just learning Lua

waxen plinth
#

Why lua?

daring lark
void escarp
#

except for just adding the repository and dependency in pom.xml, is there anything else I need to do?

kind hatch
#

Refresh your project.

void escarp
#

thanks, that worked

daring lark
mortal hare
#

Bukkit is an API. You can spawn particles with #World.spawnParticle() method afaik, but if you want some complex patterns and you don't know shit about trigonometry and calculus, you'll need to research it or use someone else's work.

quaint mantle
# humble tulip Yes

I decided to do it in 1 world, so when players create an island, it makes it 500 blocks away from the last made island.

humble tulip
#

ah ok

quaint mantle
#
  1. Saving on memory.
  2. Reduces tps drops by alot when creating a player island.
humble tulip
#

yeah that's a good solution as well

quaint mantle
#

Although I'll have to look on how to make it so they cannot leave the island, and cannot destroy other people's island.

#

I though of using the PlayerMoveEvent

#

But wouldn't it be too laggy ?

dense falcon
#

What is the "best tutoriel" for you?

#

To learn spigot.

quaint mantle
#

@dense falcon do you know the basics of java ?

#

?learnjava

undone axleBOT
quaint mantle
#

If not, you can use this ^

dense falcon
#

I know yeah.

#

Just Spigot I mean.

humble tulip
#

you learnt java already?

quaint mantle
#

lol

dense falcon
quaint mantle
#

@dense falcon the best way is to read the docs, they explain it better than anyone can

#

yeah he knows java

#

his forge mods are clean

dense falcon
#

Uh what?

errant drift
quaint mantle
#

I'd suggest you to start just by looking around, then start by doing small projects.

dense falcon
humble tulip
quaint mantle
#

There isn't really any good tutorials that I know.

#

just go through the wiki

#

Yeah.

#

they are better than any youtube tutorial

dense falcon
quaint mantle
#

dogshit

dense falcon
#

I know but, the docs is not very... good for me.

quaint mantle
#

wdym ?????

dense falcon
#

I am fond of learning by using a tuto and no a doc.

quaint mantle
#

they include everything

#

You said you know java ?

errant drift
#

if you know java then docs are fine

quaint mantle
#

yeah

#

you may only know how to use the forge api lol

errant drift
#

if you can learn forge then you can do spigot

quaint mantle
#

no offence, but you should take a look at ?learnjava

#

?learnjava

undone axleBOT
quaint mantle
#

First one is the best for starters.

dense falcon
quaint mantle
#

thats the wrong way of learning things

#

docs are made for a reason

dense falcon
#

And know a oop does not means I know read another doc.

vocal cloud
#

You learn one javadoc you learn them all. Learning javadoc is key to learning spigot or you'll be stuck asking basic questions for the rest of your life

dense falcon
#

The spigot doc is good but for example a tuto is better than doc for some reasons: more clearer for a lot of developer, a specific goal.

But I did not learn any programming langage with the doc.

quaint mantle
#

he knows the forge api

dense falcon
#

I've always got used to tutorials but Spigot's doc isn't the worst but sometimes it's nonsense!

vocal cloud
#

You should start making projects. That's the best way to learn. Tutorials are on the forums for various more complex topics and 99% of the time the docs are the answer

dense falcon
#

In truth I manage to find myself there, it's just a question of precise objective...

vocal cloud
#

The docs are mostly ask and ye shall find.

dense falcon
quaint mantle
#

my point exactly

vocal cloud
#

Yeah forge has a higher learning curve and you need to know your way around java and the like. Spigot is easier and has a docs that actually exists

dense falcon
#

For me, forge is good :>.

#

AsyncPlayerPreLoginEvent give the IP of a player?

vocal cloud
dense falcon
#

Ouch ouch ouch.

river oracle
#

Program based name

dense falcon
#

?

vocal cloud
#

ouch?

river oracle
#

Ouch?

dense falcon
#

Nevermind 🤣.

uneven fiber
#

hey

#

how do you use time

#

😻

hybrid spoke
#
This event will fire from the main thread and allows the use of all of the Bukkit API, unlike the AsyncPlayerChatEvent.
Listening to this event forces chat to wait for the main thread which causes delays for chat. AsyncPlayerChatEvent is the encouraged alternative for thread safe implementations.
uneven fiber
#

im trying to cause an effect on an entity for 15 seconds but i dont understand how to get the time

#

is it ticks or ?

hybrid spoke
#

ticks

dense falcon
#

Ticks.

uneven fiber
#

is 1 tick 1 second

hybrid spoke
#

15*20 would it be

#

20 ticks are equivalent to 1 sec

dense falcon
#

20 ticks is 1 sec.

uneven fiber
#

😳

#

thoughts?

#

i dont think this would work

daring lark
#

name = item.getItemMeta().getDisplayName(); how could i get item name? this doesn't work.

quaint mantle
#

please tell me thats not all of your code

uneven fiber
#

me ?

crisp steeple
daring lark
#
        count = item.getAmount();
        name = item.getItemMeta().getDisplayName();
        material = item.getType().toString();
        enchants = new HashMap<>();
        if(!item.getItemMeta().getEnchants().isEmpty()) {
            for(Map.Entry<Enchantment, Integer> entry : item.getItemMeta().getEnchants().entrySet()) {
                enchants.put(entry.getKey().getKey(), entry.getValue());
            }
        }
    }```
uneven fiber
#

rip

quaint mantle
stone obsidian
#

guys i got one of those bugs lol

river oracle
#

What bugs

#

Fire fly bugs

#

Fly bugs

#

Bee bugs

#

There are lots of bugs

daring lark
#

mu json created from this loks like this [{"shopItem":{"count":1,"name":"","material":"STONE_SWORD","enchants":{"minecraft:blast_protection":4}},"shopType":"sell","isAdmin":false,"id":"shopId","price":2,"shopOwnerId":"098cb022-6500-4fa5-acf4-e9a3d223d61b"}] that's why i know it's not working

uneven fiber
#

first time trying this

crisp steeple
stone obsidian
quaint mantle
#

maybe if you showed us the error we could actually help you

stone obsidian
#

i was uploading it lopl

uneven fiber
stone obsidian
#

yaml in a sec

crisp steeple
undone axleBOT
uneven fiber
#

thx

stone obsidian
#

that yaml looks completely fine to me and a bunch of linters i threw it at lol

hybrid spoke
#

io.github.turpcoding.easyreport.ReportCommand.onCommand(ReportCommand.java:62)

daring lark
#

how can i get item name?

stone obsidian
#
mainClass.reloadConfig();``` it's just a reload
#

of the config.yml ofc

lethal python
#

how can i check if two itemstacks are equal in material and name, but ignore the quantity

kind hatch
#

ItemStack#isSimilar()

lethal python
#

thank y ou

#

does that work for the name

#

even for custom name

kind hatch
#

It should

#

It compares the item meta so if it's there, it should work.

lethal python
#

yay it worked

#

now i need to find out how to decrement a stack by 1

kind hatch
#

ItemStack#setAmount()

#

Use that with ItemStack#getAmount()

lethal python
#

event.getItem().setAmount(event.getAmount() - 1)?

kind hatch
#

Close, you would want to use ItemStack#getAmount() instead of Event#getAmount() as the latter does not exist.

lethal python
#

sorry i meant event.getItem().getAmount()

#

thank you

placid shoal
#

Does anybody have any idea on how I would do a basic minecraft account link.

I have a webserver in nodejs all I wanna do is make a player click a link and get his account linked. I know how to code just need the logic behind it. Cause it doesnt make sense in my head.

unkempt peak
#

Hey so I am having a weird issue with spigot buildtools, for some reason when I try to build a version below 1.14 I get this error: java.lang.RuntimeException: Error running command, return status !=0: [C:\Windows\system32\cmd.exe, /D, /C, sh, applyPatches.sh] at org.spigotmc.builder.Builder.runProcess0(Builder.java:973) at org.spigotmc.builder.Builder.runProcess(Builder.java:904) at org.spigotmc.builder.Builder.main(Builder.java:703) at org.spigotmc.builder.Bootstrap.main(Bootstrap.java:27) I know this error is on the buildtools website but I don't have a Linux system and I'm not running it from cmd, also I redownloaded buildtools and I am using java 1.8

kind hatch
unkempt peak
#

I've tried with 16 and 17 too

kind hatch
#

Can you send the full log?

unkempt peak
fringe hemlock
#

Is there anyway to lower the duration of a particle when spawning with PacketPlayOutWorldParticles? From what I read it looks like its hardcoded in the client but I wanted to ask to make sure

#

No the speed of which the particle moves, but the time till it disappears

quaint mantle
#

hello, is there any way to code it so that, if right clicking with an item CONTAINING the word "blank", it does the action?

#

ty

kind hatch
# unkempt peak

So I just downloaded the latest buildtools and ran it with java 8. No issues.
Are you running it in a new directory or an existing one? Because you should always run it in a new directory.

#

Also, do you have Git installed?

fringe hemlock
quaint mantle
#

ty

river oracle
#

make sure to do null checks

unkempt peak
daring lark
#
        at me.placek.blockeconomy.shops.ShopManager.getShopCount(ShopManager.java:28) ~[BlockEconomy.jar:?]
        at me.placek.blockeconomy.commands.ShopCommand.onCommand(ShopCommand.java:54) ~[BlockEconomy.jar:?]
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:45) ~[paper-api-1.18.1-R0.1-SNAPSHOT.jar:?]``` what is wrong with this code?
#
public void restore() throws IOException {
        String path = "plugins" + File.separator + "BlockEconomy" + File.separator + "shops";
        File shopFile = new File(path, "shops.json");
        File shopPath = new File(path);
        if(!shopFile.exists())
            return;
        if(shopFile.length() == 0)
            return;
        FileReader fileReader = new FileReader(shopFile);
        BufferedReader bufferedReader = new BufferedReader(fileReader);
        
        StringBuffer stringBuffer = new StringBuffer();
        String line = null;
        do {
            line = bufferedReader.readLine();
            if(line == null)
                break;
            stringBuffer.append(line);
        } while(line != null);

        shops = new Gson().fromJson(stringBuffer.toString(), shops.getClass());

        Bukkit.getServer().getConsoleSender().sendMessage(BlockEconomy.getPrefix() + ChatColor.GREEN + "Załadowano sklepy.");
        Bukkit.getServer().getConsoleSender().sendMessage(BlockEconomy.getPrefix() + ChatColor.WHITE + "Lista sklepów:" + shops);
    }```
#
        String playerId = player.getUniqueId().toString();
        int shopCount = 0;
        for(Shop shop : shops) {
            if(shop.getShopOwnerId().equals(playerId))
                shopCount++;
        }
        return shopCount;
    }```
sterile token
#

Its possible to set an armorstand the skin of a player?
And then try to put the armor-stand lying in the floor?

earnest forum
#

nah u use entity players

#

like you're trying to duplicate the player on the floor

#

like that murder mystery game on hypixel?

sterile token
earnest forum
#

In this episode of the Spigot MC Plugin series, I start a new plugin called Bodied. This plugin makes it so when a player dies, an NPC is spawned using NMS and is made to lay down and have no nametag. In the next parts of this plugin's development, I will show you how to put items in the body once the player dies, and if no one claims it after a...

▶ Play video
sterile token
#

Thanks

summer scroll
#

Can you execute console commands on clickable text?

echo basalt
#

You can make a proxy command type thing that just forces the console to run it

stone obsidian
#

can someone help me with what appears to be a yaml syntax error

#

it looks fine to me

lethal coral
#

so I'm thinking of making a utility for guis and such but I don't know how I would put that in my other projects. my initial thought is to use something like jitpack then put the scope as system for the dependency. Any thoughts?

uneven fiber
#

Any idea why this isn't working? I want to set the players health to 5 when they are a distance of 10 from an entity

hasty prawn
uneven fiber
#

I was just basing it off of where the player is

hasty prawn
hasty prawn
uneven fiber
#

true

#

I see the issue now thank you

hasty prawn
uneven fiber
#

I wonder what I should change the event to tho

hasty prawn
#

EntityMoveEvent, or if you know which entities you're checking for, use a Runnable.

uneven fiber
hasty prawn
#

Wait EntityMoveEvent doesn't exist nvm

uneven fiber
#

oh lol respect

hasty prawn
#

Runnable it is then, probably better way anyways.

uneven fiber
#

let me try that

lethal coral
hasty prawn
#

Yeah JitPack would work, I use GitHub Packages albeit it's a pain in the ass. Other option if you have a VPS/Dedi is to setup a Nexus repo and host them yourself.

lethal coral
hasty prawn
#

They all have guides for setting them up

lethal coral
#

that's not what I meant

#

like I'm creating a new paper project and it has the onEnable and onDisable which confuses me as the plugin I'm going to be using it in will have that as well

#

will that have conflicts if I have the scope as system

hasty prawn
#

It shouldn't, since your APIs plugin.yml would never be found if it's shaded into another plugin.

#

Therefore they'd never be called by the server anyways. In my API I have an onEnable that does nothing just in case someone loads the API as a standalone.

lethal coral
#

so if I make a gui util how would my inventory click event be registered from there

hasty prawn
#

Make them register your API with their Plugin instance

lethal coral
#

oh

#

smart

uneven fiber
#

Actually I have another question lol

#

So im trying to create a plug in where it destroys every block that is touching the original block that is broken

#

but for some reaosn its only breaking the block to the right of it, not infront, to the left, below, above, or to the right

vocal cloud
#

👀 that's some code

uneven fiber
#

LMFAO bruh i know its ineffecient

#

this is just some basic practice haha

humble tulip
#

Are u trying to break the block or replace it tonair

uneven fiber
#

replace to air sorry

#

i dont care about being able to pick it up lol

humble tulip
#

It's because you put it in an if statement

#

Remove the if statement

uneven fiber
#

OHHHH

#

because im not setting the OG block to air

#

i see

humble tulip
#

The broken block isn't set to air until after all the listeners are executed

#

You can check if the event is cancelled

uneven fiber
#

right

humble tulip
#

Or u can put (ignoreCancelled = true)

#

Next to @EventHandler

#

Also check the getRelative(BlockFace) method

#

For block

uneven fiber
#

thoughts?

humble tulip
#

block.getRelative(BlockFace.UP).setType(Material.AIR);

uneven fiber
humble tulip
#

You don't need to

#

But it's easier to read

uneven fiber
#

oh its more efficient

#

respect yeah

#

im going to change it

humble tulip
#

Also why do you get back the block at location one

cursive briar
#

Im telling Build Tools to run 1.8.4 but it outputs 1.8.8

#

any reason why it would change it.

humble tulip
#

You already have it by doing event.getBlock

cursive briar
#

The logs seem to start with 1.8.4 but then switch to 1.8.8

hasty prawn
#

Why do you need 1.8.4 anyways

uneven fiber
#

dont need that param

cursive briar
#

Working on a few projects and just testing different versions

#

but it shouldnt just switch over

hasty prawn
#

Hm let me try

cursive briar
#

smh the logs are too big

uneven fiber
#

thank you for your help!

cursive briar
#

is the logs

#

its too big to send on anything else lol

humble tulip
#

U can do better tho :)

uneven fiber
#

how

cursive briar
humble tulip
#

Sec

hasty prawn
#

Doesn't seem like it supports 1.8.4 for some reason.

#

1.8.8, 1.8.3, and 1.8 only

#

🤷‍♂️

cursive briar
#

yet 1.8.4 exist

hasty prawn
#

Yeah I have no idea

cursive briar
#

it exist

#

it even found the data it self if u read the logs

hasty prawn
#

They're the same hashes. It's just a delegate.

cursive briar
#

oh yeah

#

weird af

hasty prawn
#

No idea why some 1.8 versions aren't supported, but oh well I guess.

#

Generally testing on 1.8.8 should be good enough. Anyone running 1.8 should be using 1.8.8.

#

It may also be that 1.8.4 didn't have any server changes so it's effectively the same thing as testing on 1.8.3

cursive briar
#

true but it shouldnt even show 1.8.4 then

#

yk what I mean

humble tulip
#

@uneven fiber

cursive briar
#

because if it dosnt support it or just redirects to 1.8.8 then it shouldnt show

hasty prawn
#

I guess, but it might as well try to correct it by automatically updating you then throwing an error I suppose

#

Just some design thing they decided to do.

cursive briar
#
--rev(top)
The version to build.
Requires a version argument.
Defaults to the latest available version.
#

Bruh

hasty prawn
#

What

cursive briar
#

it will "revert" to the latest version of it

#

so 1.8.4 goes to 1.8.8

#

yk what I mean

hasty prawn
#

Nah 1.8.4 goes to 1.8.8 because that's what the json is, it's just 1.8.8.

#

That default is referring to if you don't put a --rev argument.

cursive briar
#

ahh

#

but like if it says 1.8.4 it should be 1.8.4 not 1.8.8

#

if they dont support it then dont show it yk

uneven fiber
#

didn't think of using the for each loop

humble tulip
#

always think of loops whenever youre writing the same code over and over

cursive briar
lone sandal
#

hi does anyone happen to have worked on papi b4?

humble tulip
#

on papi or with papi

lone sandal
#

with

humble tulip
#

i did

lone sandal
#

im trying to parse placeholders

humble tulip
#

mhm

lone sandal
#

using setPlaceholder(player, msg)

uneven fiber
lone sandal
#

so is it fine to pass null for player ?

summer scroll
#

no

uneven fiber
#

not possible

lone sandal
#

i read the docs but it does not state the purpose of player

#

like if i have a global broadcast that is independent of players what do i pass?

humble tulip
#

but i think it is

summer scroll
#

If you have a placeholder that doesn't require player then just throw whatever there as long as it's not null.

#

To broadcast just loop Bukkit#getOnlinePlayers and send the message

lone sandal
humble tulip
#

i think null is safe

#

the method to apply placeholders has the player as nullable

lone sandal
#

aaa

#

cool

#

thanks

summer scroll
#

oh it's nullable?

humble tulip
#

yeah

lone sandal
#

i think ill stick to iter all players since then the other player related placeholders will be available

humble tulip
#

u can also do that

lone sandal
#

wait

#

mine does not show

#

im using 2.11

humble tulip
#

follow the methods called in the return statment

lone sandal
#

oh wait but apply states its nullable

#

okk

humble tulip
#

its safe so its up to u

lone sandal
#

yep. thanks yall

golden kelp
#

How do I get X number of blocks around a player

#

like a invisble sphere around the player which returns all the blocks in it

#

I want to check if they have some light level and remove if they do (unless they are a light source) cuz LightAPI leaves some spots even tho i try to set it false

wet breach
#

bounding box

#

if you have the opposing corners of a bounding box, you can easily create a loop to go through all the coords to get the blocks

lethal coral
#

this is what I get when I try to use jitpack with my utility

#

I don't know what I'm missing

#

I do see that is clearly has an error though

vocal cloud
#

Read the report?

lethal coral
#

I have the error log

vocal cloud
#
⚠️ ERROR: No build artifacts found
Expected artifacts in: $HOME/.m2/repository/me/hapily/plugins/util/paper-plugin-util/1.0```
lethal coral
#

yes

#

I have no clue what that means

vocal cloud
#

Do you have a build in your pom?

lethal coral
#
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <createDependencyReducedPom>false</createDependencyReducedPom>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>

this is what I've got

vocal cloud
#

Wack. No idea. I don't use jitpack anymore due to the issues

lethal coral
#

any other suggestions for people who don't want to spend more than 30 minutes setting it up

vocal cloud
#
/home/jitpack/build/src/main/java/me/hapily/plugins/util/paperpluginutil/menus/Menu.java:[4,18] cannot access org.bukkit.Bukkit
  bad class file: /home/jitpack/.m2/repository/io/papermc/paper/paper-api/1.18.2-R0.1-SNAPSHOT/paper-api-1.18.2-R0.1-SNAPSHOT.jar(org/bukkit/Bukkit.class)
    class file has wrong version 61.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

Well this also looks like an issue

lethal coral
#

yeah

#

both the same though

#

it looks like jitpack is on the wrong version? I'm not sure how to interpret that

vocal cloud
#

Looks like jitpack has 17 since it says that the /home/jitpack class is 61 and that the base is 52 which is 8?

#

?paste your pom rq

undone axleBOT
vocal cloud
#

Ohhh

lethal coral
vocal cloud
#

Did you add a jitpack config so it compiles it for 17 too? Cause it defaults 8 afaik

lethal coral
#

could it be that this was 1.8 :troll:

vocal cloud
vocal cloud
#

Yeah, try changing that

lethal coral
#

this is driving me nuts

vocal cloud
#

I don't use jitpack for a good reason kekw

lethal coral
#

no way

quaint mantle
#

i dont even think jitpack supports 17

lethal coral
#

thank you sir

quaint mantle
#

i remember it took like 4 months for jitpack to support 16

vocal cloud
#

Yeah just host your own™️

vocal cloud
#

Gotta host it yourself so it's done right

celest nacelle
#

Hey, so how would I go about getting an instance of the NMS item class from a bukkit item class without creating a copy?

visual tide
#

there are some static CraftItemStack methods for that i believe

vocal cloud
#

Yeah there is a method to convert. I don't remember

quaint mantle
#

If I have a .yml that I want to load to hashmaps for each player on startup, how would I pull this off or at least read where to make this happen?
Example:

MYUUID1:
  Null: 1
  Foo: 0
  Bar: 0
MYUUID2:
  Null: 3
  Foo: 2
  Bar: 1
eternal oxide
#

if those are in your root path

unkempt peak
#

Is there a way to dispatch a command without logging?

eternal oxide
#

why would you want to issue a command with no logging?

unkempt peak
#

I want to dispatch a command in my plugin without spamming the console, the reason I have to use a command is because I am trying to play a sound to a player and i need it to support modded sounds

#

Right now I'm using Bukkit.dispatchCommand with playsound

unkempt peak
#

I tried that with a sound and I just got a null error, does that support modded sounds?

eternal oxide
#

does exactly as the command playsound does

celest nacelle
eternal oxide
#

If the modded sounds are available in playsound they should be available in that

#

I'm guessing the modded sounds may use a namespacedKey style of naming though

#

Thats how most modded stuff used to work when I was using them

unkempt peak
#

Oh wait i think i figured it out

#

Yeah i think that method will work

#

Thanks

#

Ok so this is weird

#

It works for playSound(string) but not stopSound(string)

#

When i use stopSound I just get a null error

tardy delta
#

What is null?

eternal oxide
#

stopSound is a void. It has no return type

unkempt peak
#

finally I got it working, sorry I was being dumb lol this is why I shouldn't be coding at 3 am

distant fern
#

Hi. I want to create spawning a mob with custom name and hp! How to create a variable of that mob?
Ravager ravager = ..??

#

If i create something like this:

#

Entity spawnedPig = myWorld.spawnEntity(spawnLocation, EntityType.PIG);

#

Then i cant edit his health

eternal oxide
#

Then you can modify all you want in the Consumer before it is added to the world

crisp ivy
#

How can I do that instead of sending the next action bar, it adds seconds to what is right now

#

this is anti logout

midnight shore
#

how can i check if a player has an item in their inventory without counting the player's off hand?

earnest forum
#

regular inventory object doesnt count off hand right?

midnight shore
#

would PlayerInventory.contains() count also the item in the off-hand?

tardy delta
#

i gues ye

midnight shore
#

how could i prevent that?

tardy delta
#

i would do if inv.contains(item) && !offhand.getItem().equals(item)

#

long time since i've worked with inventory stuff so forgive me that bad code

dense falcon
#

How can we make backups in databases like Redis but save part of the map.

#

Kind as soon as the player connects, it brings back part of the desired map.

midnight shore
#

probably you misunderstood... i wanted to check only if in the inventory (without counting the off-hand) there is an item, because in the off-hand there will always be that item (as i programmed like that)

golden kelp
#

tbh at this point ill just loop over the inventory slots that exclude the off hand slot

ebon coral
#

Hio, I am trying to build a 1.8 plugin and I set all of the encoding properties in my gradle build file to use UTF-8 but I still run into issues with UTF-8 characters being all ugly and buggy in chat.

#
    compileJava {
        options.encoding = "UTF-8"
    }
    javadoc {
        options.encoding = "UTF-8"
    }
    processResources {
        filteringCharset = "UTF-8"
    }
}```
#

build.gradle.kts contains this

eternal oxide
#

are your actual files saved in UTF-8?

ebon coral
#

My IntelliJ is using UTF-8 for the files.

eternal oxide
#

Where are you seeing these odd encodings?

ebon coral
eternal oxide
#

and you read that data from a config file?

ebon coral
#

Yes.

eternal oxide
#

then your config file is not UTF-8

ebon coral
#
        filteringCharset = "UTF-8"
    }```
#

Woullldd that not do anythinggg?

summer scroll
#

Startup parameters

eternal oxide
#

if its not saved as UTF-8 before it will not be after compiling

ebon coral
#

OH startup params

#

I should make it have UTF 8 in it?

summer scroll
#

Try to put -Dfile.encoding=UTF-8 before the -jar in your startup parameters.

ebon coral
#

Alright, I appreciate it.

#

That did the trick man, I appreciate it :)

summer scroll
#

No problem 😄

split lake
#

I got made a plugin when 1.17 was newest, are there any things I need to look out for if I wanna run it on 1.18?

distant fern
#

Another question. I want to make a boss that drops a player items. But it drop to who it spawned by item. So its named Bos... of player "playername".
Now Im stuck pls help

if (e.getEntity().getType().equals(EntityType.RAVAGER)) {

                ItemStack Beacon = new ItemStack(Material.PRISMARINE_SHARD, 30);
                ItemMeta meta = Beacon.getItemMeta();
                meta.setDisplayName("§dPLATYNA");
                meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
                Beacon.setItemMeta(meta);
                if (e.getEntity().getCustomName() != null && e.getEntity().getCustomName().startsWith("§l[BOSS]Duzy Swiniol gracza ")) {
                 Im stuck                   
                 }
            }
        }
    }

summer scroll
split lake
#

Just tried and had some issues with location of dropping blocks but I don’t think it’s a version issue

#

Ty

distant fern
tardy delta
#

ah you want to drop the item?

summer scroll
#

I somehow understand what he's trying to achieve.

#

Basically he only want to drop items to the player who spawned the entity.

distant fern
#

no. to add it to eq. But not the Killer eq. The player that the mob name ends with

tardy delta
#

:/

#

i dont understand what he's saying

distant fern
#

ill make a picture in paint for u:D

tardy delta
#

ugh i mean are you trying to only drop an item when someone killed a boss, if the player who killed it also spawned it?

summer scroll
#

Drop items only to the player who spawned boss, no matter who the killer is.

distant fern
#

yes

#

but not to drop but to add it to eq

summer scroll
#

Directly add into player's inventory?

distant fern
#

yeap

summer scroll
#

Store pdc to the entity with the player who spawned the entity name.

tardy delta
#

im out

#

lol

summer scroll
#

And then on EntityDeathEvent, check If the entity who died has the data, If so get the player name from the pdc and then add the item to the inventory.

tardy delta
#

?pdc

tardy delta
#

persistent data container

distant fern
#

ok ill check how to do it

daring lark
#

how to check if item can be stacked? i mean how to check if it is a tool or sth.

dense falcon
#

How works skyblock?

drowsy helm
glossy venture
#

then you allow them to tp to it

#

maybe make a hub

#

rest is up to you

dense falcon
#

I mean to save the island of a player.

drowsy helm
#

depends on your method

#

a lot of people use slime world manager

dense falcon
#

Someone told me he is using Jedis.

drowsy helm
#

which is what i'd recommend

#

redis

dense falcon
drowsy helm
#

for saving islands?

#

redis isnt made for persistent storage

dense falcon
#

Just data like a level, rank?

rough drift
#

Can you get a player owning a PlayerInventory

drowsy helm
#

redis is just meant to be a cache, you want a more long term storage like sql or something

rough drift
#

I am on 1.17.1

humble tulip
#

It's probably the same

rough drift
#

As a lot of people will be mad, going from min 1.16.5 to min 1.17.1, their pc's can't handle 1.17.1 o no

humble tulip
#

getHolder

rough drift
#

(I am making fun of them fyi)

drowsy helm
#

dont see a reason why it wouldnt be in 1.17.1

rough drift
#

nvm

#

it exists

#

Intelli just forgot to find it

drowsy helm
rough drift
#

yeah found it, intelli forgot to show it

#

lmao

humble tulip
#

how do u use jedis for slyblock?

drowsy helm
#

lel

humble tulip
#

To store islands for online players incase theybswitch servers?

#

Or something else

drowsy helm
drowsy helm
humble tulip
#

Ah ok

#

When do u unload invs from jedis?

dense falcon
drowsy helm
humble tulip
#

Swm allows u to have a world per player

drowsy helm
humble tulip
#

Since u can load the entire world in memory

dense falcon
#

And no the world.

drowsy helm
#

yeah thats what swm is made for

humble tulip
drowsy helm
#

its not made to store ENTIRE worlds just like small things

#

pretty much perfect for skyblock

#

Hypixel uses it

humble tulip
#

What even do u use to load data

#

I use asyncplayerprelogin

rough drift
#

my suggestion: store only the chunks that are built in + 1 in the 8 directions, allowing you to still build but use an incredibly low amount of space

drowsy helm
#

honestly even just PlayerJoinEvent is good

#

redis is super fast you barely notice the delay

#

Just use SlimeWorldManager it does all of that for you, fast and stores entities aswell

#

its IS the best system out right now for that usecase

#

Hypixel made a whole forum post about it, they stored like 1m player islands in something like 40gb

#

its insanely efficient

kind hatch
#

It's cause it cuts out the empty space of the chunks. That combined with a smaller storage format.

#

Very clever, but a pain to make from scratch.

#

Really glad they made it public knowledge.

drowsy helm
#

yeah same

#

amazing piece of tech

dense falcon
#

But how do we create the part of the player in your thing there...

drowsy helm
#

each player has their own world

#

you just load it in and tp them onto it

#

then when they leave, save it and remove it form the server

#

and it works on a database so can be loaded onto any other server

humble tulip
dense falcon
#

You didn't understand, they say to load, to import or to update but how do you "create"???

drowsy helm
drowsy helm
dense falcon
#

???

drowsy helm
#

i dont understand your question exactly

humble tulip
drowsy helm
#

its almost the same speed as reading from mem

humble tulip
#

:O

#

Omg that's awesome

dense falcon
#

There is nothing to create a backup to impor after.

#

import.

kind hatch
#

Isn't that up to you to make?

drowsy helm
#

yeah im saying make a template and copy it over

slim kernel
dense falcon
#

"Make a template" ?

humble tulip
#

A slime world template

#

Of the skyblock world

kind hatch
#

Make your island, convert it to a slime world, then use that world as your template. Make copies of it when you need to create a new island.

drowsy helm
#

yeah exactly what i mean

#

sorry im not good at explaining lol

kind hatch
slim kernel
kind hatch
#

Oh, it's because of gson

drowsy helm
#

yeah gson is trying to access it

ivory sleet
#

gson uses reflection and other stuff to scan your class in order to know how to serialize and deserialize it, you probably ought to provide a TypeAdapter or instance creator to gson

eternal oxide
drowsy helm
#

JsonDataFile

#

is that another of your classes?

drowsy helm
#

gson is trying to deserialize the data into that class type

#

all it does is hold a File

kind hatch
#

It might be due to the transient keyword.

drowsy helm
#

possibly yeah

#

is the keyword necessary in your usecase?

kind hatch
#

Oh, well looking up the keyword's usecase. It's there to prevent serialization of an object. So if you set the entire file to be transient, it won't serialize.

slim kernel
#

but everything worked before and I didnt change the keyword

#

I just tried it and even if I remove the keyword it is still the same error

drowsy helm
#

whats the use for JsonDAtaFile anyway

#

you're already directly serializing from the file to PlotData

slim kernel
#

yeah and everything worked fine and I never changed anything there

small current
#

is fawe okay for pasting schematics like skyblock islands ?

slim kernel
#

wait cant I save locations with json?

ivory sleet
#

you can

drowsy helm
#

you should be able to

ivory sleet
#

but you pretty much want to supply a command/strategy object for how its done if you use gson

ivory sleet
#

what would imply that it isnt okay?

#

I mean

#

sure

small current
#

is there anything better ?

ivory sleet
#

define better

humble tulip
#

Ye it's fine and usually skyblock islands are really small so technically u can even gen them yourselves

small current
#

better performance

humble tulip
#

It's good enough

ivory sleet
#

myeah doing it yourself given that you know what you're doing

small current
#

i want to like paste different islands at different locations of ONE world

ivory sleet
#

since fawe relies on top of a ton of other stuff

humble tulip
#

Fawe is better than generating yourself but I'm saying that you can do it yourself

slim kernel
ivory sleet
#

oh yeah

#

actually

#

Location has an instance field called world

#

which is a WeakReference<World>

#

gson doesnt know how to deal with that specifically

humble tulip
#

Create a new object

ivory sleet
#

so you could just provide a TypeAdapter<Location> to gson

humble tulip
#

^oh yeah that

#

Conclure big brain

rough drift
#

if you do getConfigurationSection on a config, and you pass like a.b, do you get config.a.b or it throws an error?

kind hatch
#

You'll get the value at the path a.b inside the config.

trim surge
rough drift
#

not talking about value

#

talking about configuration sections

ivory sleet
trim surge
#

is it the Japanese role play server? LOL

ivory sleet
#

Let’s go #general btw

dawn spire
#

Caused by: java.lang.ClassNotFoundException: org.bukkit.Nameable Anyone got any ideas?

trim surge
#

wrong version / dependency

humble tulip
#

When storing player data, should i use multiple columns or should i serilize to json and just store that

ivory sleet
#

What storage are you using?

#

If it’s a relational database then you don’t wanna store the data as a blob

humble tulip
#

Sql

ivory sleet
#

Yes then multiple columns

humble tulip
#

Ok

ivory sleet
#

In that way you can take advantage of the fact that its sql

humble tulip
#

Ok got it

dawn spire
#

Funny one 😆

humble tulip
dawn spire
#

wdym

humble tulip
#

Other than a classnotfound

tender shard
#

it wasn't meant to be a joke

#

you're using an MC version where this class doesn't exist yet

dawn spire
#

I'm pretty sure it does exist

tender shard
#

so what is your MC version?

dawn spire
#

im not using plain spigot

kind hatch
#

Not according to your stackstrace.

trim surge
tender shard
tender shard
#

@SuppressWarnings("resource")

#

wtf does this do

tardy delta
#

7smile7 told me to create different classes instead of passing lambdas as an argument in the constants

#

otherwise it warns me that im instantiating a hikaridatasource not in a try with resources

#

which doesnt make sense here

trim surge
slim kernel
golden kelp
#

is spigot down

tender shard
golden kelp
#

nvm

golden kelp
tender shard
#

no jk and spigot is online

golden kelp
#

aight

humble tulip
tender shard
#

but the website is indeed kinda slow rn

humble tulip
#

I couldn't load it

slim kernel
#

Anyone know how I get the Location out of the TypeAdapter<Location> to teleport somebody?

tender shard
#

definitely down now lo

golden kelp
#

I am having issues with LightAPI, i try to make it so it looks like the player has a spotlight.
Currently I set a light at the player location and remove the last one. But some arent getting removed
The cases when theres no removal is

  • when player jumps (the old one still stays there)
  • when player moves diagonally (the light still stays t here)
golden kelp
kind hatch
tender shard
tender shard
kind hatch
#

True, but I can fuck with people if it's really down.

golden kelp
tender shard
#

then open a github issue

golden kelp
#

the issue is with how my code stores the locations i think

#

cuz it leaves one or two

#

should i make a list of last 5 locations

tender shard
#

?paste your code

undone axleBOT
crimson terrace
#

I am having problems getting a custom Event I wrote to work.
It extends the CreatureSpawnEvent and adds some data to it, but when I try to listen to it it does not work. I registered the Listener
The constructor of the event is called, I know that much. I put a System.out in there to check it. Is there anything I could be missing?

undone axleBOT
tender shard
#

did you properly override the getHandlers method?

kind hatch
tender shard
#

nope you only have to register the listeners

crimson terrace
tender shard
#

I see

crimson terrace
#

that should be everything that matters, if you need more just let me know

tender shard
#

you do not override the getHandlers method

#

that's your problem

crimson terrace
#

oh ok let me do that really quick

tender shard
#

you have to override both the static getHandlerList and the non-static getHandlers() method

#

just create an empty handlerlist and make both methods return it

tender shard
#

send your RemoverThread class too pls

crimson terrace
tender shard
crimson terrace
#

ok thanks 😄

tender shard
#

np 🙂

tender shard
#

hm that's weird

#

why are you iterating over x and Z from -1 to 10?

#

I'd simply store all lights you have created and then use that list

golden kelp
#

ooooooo

#

ty

twilit roost
#

BungeeCord
Im trying to register commands using for loop
but it's not working..
Main: ```java
Main.getPlugin.getLogger().info("TEST");
Configuration config = Main.getPlugin.config.serversConfig;
for(String s : config.getSection("servers").getStringList("")){
Main.getPlugin.getLogger().info(s);
Main.getPlugin.getProxy().getPluginManager().registerCommand(Main.getPlugin,new JoinServer(s));
}

tender shard
#

you cannot have a list at ""

#

show your config file pls

twilit roost
#

oh
what should i have put there?

earnest forum
#

getStringList("servers.survival")

#

oh

#

no

#

nvm

tender shard
#

for(String s : config.getSection("servers").getKeys(false)

#

this will return "survival" and "hub"

#

now you can get the list for each of those servers

twilit roost
#

oh thx

#

imma try

tender shard
#

by doing List<String> list = config.getStringList("servers." + s);

twilit roost
tender shard
#

oh

#

yeah bungee has a different system

#

one sec

#

?jd-bc

tender shard
#

just use getKeys() instead of getKeys(false)

#

@twilit roost

twilit roost
#

oh k

#

thx
works like a charm 🙂

tender shard
#

great :3

crimson terrace
tender shard
#

hm

#

that's weird, idk

crimson terrace
#

I'll try to register it manually even tho it should be registered already

tender shard
#

your event and your event listener are in the same .jar file, right?

crimson terrace
#

yes

tender shard
#

then i have no idea

crimson terrace
#

ok I'll watch some videos and try fixing it. thanks for helping tho 😄

tender shard
#

can't hurt to send all your code anyway, maybe it's just a tiny stupid error lol

crimson terrace
#

I don't think theres much more to send related to the problem tbh

tender shard
#

ughm wait

#

the code you sent

#

you still listen to the "original" event

#

you have to listen to your custom event class

#

this is what you sent:

#
 @EventHandler
    public void onMonsterSpawn(CreatureSpawnEvent event) {
crimson terrace
tender shard
#

oh yeah that's correct

golden kelp
#

how do i check if any player is at certain location

crimson terrace
#

I have a separate class for the listener

#

and calling the event

tender shard
#

oh you edited your message

golden kelp
#

Yea

#

any player

tender shard
#

loop over all online players and then check if their location is nearby the location oyu wanna check

golden kelp
#

oh that can be kinda performance bad

crimson terrace
tender shard
#

obviously you CANNOT compare locations with == because even moving by 0.000001 block will make it not work anymore

golden kelp
#
@Override
    public void run() {
        for (Location loc : this.vLights.getLightLocations()) {
            int lightLevel = LightAPI.get().getLightLevel(
                loc.getWorld().getName(),
                loc.getBlockX(),
                loc.getBlockY(),
                loc.getBlockZ()
            );
    
            if (lightLevel > 0) {
                LightAPI.get().setLightLevel(
                    loc.getWorld().getName(),
                    loc.getBlockX(),
                    loc.getBlockY(),
                    loc.getBlockZ(),
                    0
                );
            }
        }
    }
tender shard
golden kelp
#

a nested loop

tender shard
#

comparing locations and looping over players is fast, you don't have to worry about performance

golden kelp
#

oo

#

ty

tender shard
#

np

slim kernel
#

Anyone know how to use a TypeAdapter<Location> because I cant save a normal Location in a json?

tender shard
#

Location implements ConfigurationSerializable so you can simply do stuff like myFile.set("location",myLocation);

golden kelp
#
@Override
    public void run() {
        for (Location loc : this.vLights.getLightLocations()) {
            for (Player player: this.vLights.getServer().getOnlinePlayers()) {
                if(player.getLocation().getBlock().equals(loc.getBlock())) {
                    int lightLevel = LightAPI.get().getLightLevel(
                        loc.getWorld().getName(),
                        loc.getBlockX(),
                        loc.getBlockY(),
                        loc.getBlockZ()
                    );
    
                    if (lightLevel > 0) {
                        LightAPI.get().setLightLevel(
                            loc.getWorld().getName(),
                            loc.getBlockX(),
                            loc.getBlockY(),
                            loc.getBlockZ(),
                            0
                        );
                    }
                }
            }
        }
    }
slim kernel
#

because I got a big plot plugin that uses json for everything and now I need a location in there

#

@tender shard

tender shard
slim kernel
#

both

#

just dont know how to use a TypeAdapter

tender shard
#

Yo uhave to implement it yourself

#

a TypeAdapter is a class that has two methods: write(...) and read(...)

golden kelp
tender shard
#

If I was you, I'd simply use the already ConfigurationSerializable features of Location

golden kelp
#

ty

misty current
#

is there an hotkey to resolve all imports in a class?

drowsy helm
#

for which ide

tender shard
#

you mean to "get rid of the imports" and use qualified class names instead?

misty current
#

intellij

#

i meant import everything thats needed

slim kernel
slim kernel
tender shard
slim kernel
tender shard
# slim kernel so like this example here?
        TypeAdapter<Location> adapter = new TypeAdapter<Location>() {
            @Override
            public void write(JsonWriter jsonWriter, Location location) throws IOException {
                // Do something
            }

            @Override
            public Location read(JsonReader jsonReader) throws IOException {
                // Do something
            }
        };
#

you basically have to do all the work yourself, which is to create a new location and manually read/write the existing's locations world, x, y, z, ...

#

there's also Location.serialize() which does all this for you and returns a Map<String,Object> with all the important data

#

but I am not sure how to turn this into Json exactly

#

I don't really like json, I use YAML for everything

#

so sorry I cannot really help you lol

slim kernel
#

and If I just save x y z yaw pitch separately in the json and put it together in the code?

humble tulip
#

Write the x, y, z and world

#

Xyz and doubles

tender shard
humble tulip
#

Oh yes yaw and pitch

#

World as well

slim kernel
#

yes

#

okay thank you mfnalex for explaining me everything

#

oh no

#

I can save a world tho

tender shard
#

you can simply either save the world's name, or the world's UUID

#

and then retrieve it again using Bukkit.getWorld(myWorldsName)

slim kernel
#

truee

tender shard
#

I recommend to use names for worlds instead of UUIDs

#

sometimes people delete the world and let it regenerate using the same name, so I think names are better to identify worlds

slim kernel
#

okay thank you

tender shard
#

np

wet breach
#

what it would kind of look like to re-construct it or save it. Except you will eventually build the location manually after you get all the info needed 🙂

eternal oxide
#

just store teh world name and the Block

slim kernel
#

oh

wet breach
#

the best way to store a location though is to grab the location object as a string

eternal oxide
#

both will serialize fine

wet breach
#

and then use Base64 on it

slim kernel
wet breach
#

then you can just unconvert that base64 string back into a location object 😄

slim kernel
wet breach
#

you can save it but not required

slim kernel
#

okay

eternal oxide
#

you really only need the world name and a Vector for the three coords

slim kernel
eternal oxide
#

its upto you, depends on yoru precision requirement

#

if its for defining areas you only need the 3 values from a Block

slim kernel
#

okok

eternal oxide
#

do your areas have a vertical element?

golden kelp