#help-development

1 messages · Page 1359 of 1

lost matrix
#

Just looked at the protocol from 1.8

#

Oh interesting. Could you send the rest of the message?

quaint mantle
#

I can't get any of this to work

#

like PacketPlayOutChat

opal juniper
#

That was the whole message, lemme send some later ones

lost matrix
lost matrix
quaint mantle
#

No

#

I guess that's why huh

lost matrix
opal juniper
#

This is the paper example:

lost matrix
#

Oh damn i didnt think of using a custom implementation of ChunkPacketBlockController...
But lets see if we can get it to work using the current way.

opal juniper
#

Just so that you know, I’m on my phone and boutta go to bed. If you get anywhere with it, probs @ me and I will check tomorrow if I don’t get back to you

lost matrix
opal juniper
#

Sure!

scarlet path
#

?jd

#

!jd

silent vigil
#

how do I make it so that my plugin is compatible with perm plugins? as in if i have luck perms on my server I can give people lets say Plugin.permission?

quaint mantle
#

with an EntityType you can get it's unique id, but how could I get the EntityType with it's id? (that is stored in a data YML file)

silent vigil
#

how would i do that?

lost matrix
quaint mantle
#

search, but basically you can use maven or simply importing the API Jar and insert some code

lost matrix
lost matrix
# silent vigil how would i do that?

And you dont need to use maven or import any of luckperms API
You are basically always compatible with any permission plugin.
Using Player#hasPermission is fine. Registering the permission in your plugin.yml is even better.

quaint mantle
#

stand.getEntityId()

lost matrix
quaint mantle
#

yes

lost matrix
#
UUID entityID = entity.getUniqueId();
// then later
Entity entity = Bukkit.getEntity(entityID);
silent vigil
# lost matrix Is that from an ArmorStand instance?
            Player player = (Player) sender;
            if(player.hasPermission("modplugin.openED")) {


                if(args.length > 0 ){
                    Player target = Bukkit.getPlayerExact(args[0]);

                    Inventory ti = target.getEnderChest();
                    player.openInventory(ti);
                }else{
                    player.sendMessage("Please enter a valid target.");
                }



            }else{
                player.sendMessage("Please get the permission called modplugin.openED");
            }``` this is my code, but when using luckperms and even adding the perm manually It doesnt give the person the perms
lost matrix
quaint mantle
#

fine

lost matrix
quaint mantle
lost matrix
quaint mantle
#

I only want the id's, because I'm doing holograms

#

I'm doing the addline command

silent vigil
eternal night
#

What version are you on

lost matrix
eternal night
#

the method definitely exists in any somewhat acceptable version of spigot

#

lol

lost matrix
#

Thats also what i thought...

quaint mantle
lost matrix
lost matrix
eternal night
#

yikes

silent vigil
lost matrix
# silent vigil where? in lp?

No idea. If it works in op but not when you have the permission then you actually dont have the permission. I just suspect a typo.

eternal night
#

1.8 didn't even have UUIDs yet xD

silent vigil
#

ok copy

eternal night
#

like xD

lost matrix
#

How is this even a version?

quaint mantle
eternal night
#

nop

#

I am stupid

#

That was earlier

#

Right

quaint mantle
#

XD

eternal night
#

It still had entity Id support tho XD

quaint mantle
#

so what can I do to get the armorstand by it's unique id?

eternal night
#

I mean I guess use World#getEntitiesByClass(ArmorStand.class)

#

and then iterate over that list

#

to find the armor stand

#

horribly slow

#

but eh

quaint mantle
#

is for a hologram plugin

lost matrix
#

Ah. Yes. The O(n) for finding an entity by its ID. The taste of outdated versions.

quaint mantle
#

what?

lost matrix
# quaint mantle what?

I would actually not bother writing your own hologram plugin if you are on 1.8
Just use one of the many established ones.

silent vigil
quaint mantle
#

ow damn, 1:40 am, all day and night programming XDD

lost matrix
quaint mantle
lost matrix
eternal night
#

I think it is like /lp tree <player>

silent vigil
#

and from the same plugin another command works

lost matrix
#

modplugin.openEC or modplugin.openED ?

silent vigil
#

EC

lost matrix
#

And your code says what?

silent vigil
#

I changed it from ed about 10 secconds ago

#

(in both_

#

EC

lost matrix
#

Ah ok. Make it all lower case.

silent vigil
#

ok

#

ok ty

#

@lost matrix I changed it still doesnt work

lost matrix
silent vigil
#

ye

lost matrix
#

Then the only explanation is that the user simply does not have the permission.

silent vigil
#

they do

#

i checked twice

#

i gave everyone the command and it still doesnt work

#

idk

lost matrix
#

Create a simple check. Maybe on chat event and check for the permission then return if the player has it or not.

#
  @EventHandler
  public void onChat(AsyncPlayerChatEvent event) {
    Player player = event.getPlayer();
    String perm = event.getMessage();
    String returnMessage = "" + player.hasPermission(perm);
    player.sendMessage(returnMessage);
  }
silent vigil
#

how would I check what permissions the user has?

lost matrix
#

Just write the permission in the chat

silent vigil
#

ok

lost matrix
#

And it will return "true" if the player has the permission and "false" otherwise

silent vigil
#

copy

#

should I make an if statment with the perm?

lost matrix
#

No. Just copy that code into a Listener class and write the permission in chat

silent vigil
#

ok copy

#

copy

#

ty

#

nope nothing

#

but I have the perm group

lost matrix
#

You didnt register the listener

silent vigil
#

im dumb im sorry

#

it says false

#

but the person has perm group

lost matrix
#

So its more of a problem with using LuckPerms correctly 😄 thats good news for you

silent vigil
#

how would I set it properly?

lost matrix
#

LuckPerms is well documented and im out for today ^^

silent vigil
#

ok bye

stone sinew
# silent vigil

I wouldn't ever recommend /reload (Sorry if thats not the /reload message I'm seeing.)

limber dust
#

it looks like it XD

near kite
#

is using a plugin from black spogit can get you arrested??????????????

cloud berry
#

any1 on rn fucc wit jooq? .-. if so how good is it at async stuff

cloud berry
cloud berry
#

dev gangs dont fucc around .-. also dis offtopic

near kite
limber dust
#

wish him well then

#

actually na

#

XD

ivory sleet
cinder thistle
#

smh

ivory sleet
#

You can’t deny they’re

quaint mantle
#

Reloading isn’t bad unless you got a plugin with hella events and things saved in a hash map for whatever reason

dusty herald
#

what

stone sinew
ancient plank
#

plug-in

ivory sleet
#

Hmm I haven’t experienced that yapper

#

Or well maybe cuz I usually create a new instance but ye

stone sinew
#

Reloading isn’t bad unless

#

Reloading is bad period... Just restart to make sure no issues are caused.

drowsy helm
#

Anyone know how vault prioritizes economies when there are two present in a server?

quaint mantle
#

I want to get all the boss bars of the server one by one. So I tried various for-each, but all of them failed. How do I get it?(Bukkit.getBossBars())

#

It's iterator

young knoll
#

Just use the iterator as an iterator?

limber dust
quaint mantle
young knoll
#

while (iterator.hasNext) {
Object whatever = iterator.next
}

quaint mantle
#

ohh thanks

quaint mantle
#

I took all the boss bars of the server with the following code and created the code to output if it contained a player. But as soon as the player comes in, the boss bar is printed out until the server bursts endlessly.

            BossBar bossBar = Bukkit.getBossBars().next();
            Bukkit.broadcastMessage(bossBar + "");
            if (bossBar.getPlayers().contains(player)) {
                bossBar.removePlayer(player);
                Bukkit.broadcastMessage(bossBar + " remove");
            }
        }```
(It prints only `Bukkit.broadcastMessage(bossBar + "");`)
young knoll
#

Store the iterator to a variable first

#

You are getting a new copy each time

quaint mantle
young knoll
#

What?

#

No that’s the item from the iterator, put the iterator itself into a variable once

quaint mantle
#

ah! I understood thanks

#

you meant this right? If i understood correct

        while (bossBarVarb.hasNext()) {
            BossBar bossBar = bossBarVarb.next();
            Bukkit.broadcastMessage(bossBar.getTitle() + "");
            if (bossBar.getPlayers().contains(player)) {
                bossBar.removePlayer(player);
                Bukkit.broadcastMessage(bossBarVarb + " remove");
            }
        }```
young knoll
#

Correct

quaint mantle
#

thanks for help

#

Hey spigot discord, I'm having problem about bossbar. i'm trying to get all bossbars. and it works at only vanilla bossbar (/bossbar add test 1) and it doesn't works on my custom bossbar. (This problem isn't posted on google)

VanillaBossBar creating command:

/bossbar add test 1

custom bossbar creating code:

        bar.addPlayer(player);```
quaint mantle
#

thanks for help, and you meant persistent to vanilla thing?

#

ohhh, I found **not created using createBossBar(String, BarColor, BarStyle, BarFlag...)** thanks,

#

how to get created using createdBossBar?

young knoll
#

Don’t know if you can

#

No reason you can’t use a persistent one I assume

quaint mantle
#

ok, thanks for help

quiet hearth
#

player.addPotionEffect(PotionEffectType.ABSORPTION, 120, 4); Is this not correct? I am using a listener with the PlayerItemConsumeEvent

young knoll
#

No

#

You need a new PotionEffect in there

quiet hearth
#

ok

#

player.addPotionEffect(new PotionEffectType.ABSORPTION, 120, 4);

#

as in that?

young knoll
#

... no

#

Your ide should tell you what the method takes as parameters

quiet hearth
#

It says PotionEffect potioneffect

#

i am using IntelliJ

young knoll
#

Correct

#

So you need a PotionEffect

quiet hearth
#

yep, I figured it out, thanks for the help, Im just getting into spigot development

lethal field
#

Can't register commands in Spigot plugin (I'm Japanese, so I use a translator)
Main ArtifactID.java

package groupid.artifactid;

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

public final class ArtifactID extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        System.out.println(ChatColor.BLUE + "Plugin is enabled.");
        Bukkit.getServer().getPluginManager().registerEvents(this, this);
        getCommand("test").setExecutor(new DebugCommand());
    }

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

Command DebugCommand.java

package groupid.artifactid;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.event.EventHandler;

public class DebugCommand implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 1) {
            String message = args[0];
            if ( message.equalsIgnoreCase("test"))
            {
                sender.sendMessage("test ok");
            }
            else {
                sender.sendMessage("test no");
            }

        }
        return true;
    }

}

plugin.yml

main: groupid.artifactid
name: DebugPlugin
version: 1.0
commands:
  test:
    description: TEST
    aliases: [test1, test2]

I'd like to know what the solution is.

sullen marlin
#

do a clean compile

severe zenith
#

how to set a playerhead by this "ID"?
/give @p minecraft:player_head{display:{Name:"{\"text\":\"Red X\"}"},SkullOwner:{Id:[I;1590668272,1381189552,-1538418164,-1841266247],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYmViNTg4YjIxYTZmOThhZDFmZjRlMDg1YzU1MmRjYjA1MGVmYzljYWI0MjdmNDYwNDhmMThmYzgwMzQ3NWY3In19fQ=="}]}}} 1

summer scroll
#

It should be groupid.artifactid.ArtifactID

lethal field
# summer scroll The main in the plugin.yml is wrong.

Error occurred while enabling ArtifactID v1.0 (Is it up to date?)
java.lang.NullPointerException: Cannot invoke "org.bukkit.command.PluginCommand.setExecutor(org.bukkit.command.CommandExecutor)" because the return value of "groupid.artifactid.ArtifactID.getCommand(String)" is null
at groupid.artifactid.ArtifactID.onEnable(ArtifactID.java:14) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.t(MinecraftServer.java:422) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.l(MinecraftServer.java:383) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.a(MinecraftServer.java:338) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:272) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [spigot-1.12.2.jar:git-Spigot-79a30d7-acbc348]
at java.lang.Thread.run(Thread.java:832) [?:?]

#

beyond repair

humble stirrup
#

send the rest of your code

#

and please use an actual group and artifact id

lethal field
#

I don't understand English very well.

#

What do you want me to send?

humble stirrup
#

groupid.artifactid.ArtifactID class

unreal quartz
#

lol

lethal field
#

I'm not sure.

unreal quartz
#

your main class

lethal field
#

ArtifactID

weary geyser
#

How would you upload a file to a website with java?

humble stirrup
#

that's a very vague question

weary geyser
humble stirrup
#

what is "sending it to a website"

weary geyser
humble stirrup
#

again

#

what website

#

how is it hosted

weary geyser
#

My website

humble stirrup
#

on the same machine?

weary geyser
#

On a vps

humble stirrup
#

somewhere else?

weary geyser
#

vps

humble stirrup
#

use ftp or something then

cloud current
#

Hi everyone I have an issue with a custom villager (nms)

humble stirrup
#

?ask

queen dragonBOT
#

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.

cloud current
#

yes 2 secs

#

//

#

and with fake players they just become invisible

#

but if I go far away and I come back all is normal

#

I can still interact with the npc

drowsy helm
#

how are you spawning them

cloud current
#
public void sendVillager(Player p, CustomVillager villager) {
  Reflection.sendPacket(p, new PacketPlayOutSpawnEntityLiving(villager));

  Reflection.sendPacket(p, new PacketPlayOutEntity.PacketPlayOutEntityLook(villager.getBukkitEntity().getEntityId(), (byte) ((villager.getBukkitEntity().getLocation().getYaw() * 256.0F) / 360.0F), (byte )((villager.getBukkitEntity().getLocation().getPitch() % 360.0) * 256 / 360), false));

  Reflection.sendPacket(p, new PacketPlayOutEntityHeadRotation(villager, (byte) ((villager.getBukkitEntity().getLocation().getYaw() * 256.0F) / 360.0F)));
    }
drowsy helm
#

because you're spawning it with a packet

#

once the player respawns or relogs packet data wont persist

#

same reason why sending a block change through packets isnt permanent

cloud current
drowsy helm
#

spawn it through regular means, not packet

cloud current
#

If they are not permanent why when I go far away and I come back all is good

drowsy helm
#

the data is still cached

#

if you go far enough out, for long enough itll change

quaint mantle
#

anywhere i could find the vanilla minecraft source for enchants

unreal quartz
#

what for

drowsy helm
#

i know theres Minecraft Coder's Pack but thats been abandonned ages ago

#

fat chance of finding minecraft src for latest versions

unreal quartz
#

if you just need formulae for enchants like fortune then I’m pretty sure info like that will be available on the wiki

weary geyser
quaint mantle
#

What I'm trying to do is edit certain values of Enchants, change names, etc. as well as add custom ones. & I really didn't want to have to just make them from scratch.

drowsy helm
weary geyser
#

With java

drowsy helm
eternal oxide
#

run buildtools with --generate-source --generate-docs

drowsy helm
#

or have an ftp server on teh same machine as your site

weary geyser
cloud current
#

@drowsy helm in "Citizens" villagers are spawned with packets

drowsy helm
drowsy helm
drowsy helm
#

do they support and sort of backend?

#

or is it just a basic html css site

weary geyser
#

You can import code from a git repo

#

and all code from the repo will be there

#

folders etc

drowsy helm
#

I'm asking whether they support backend applications like nodeJS or anything

cloud current
drowsy helm
drowsy helm
cloud current
#

no

drowsy helm
#

I mean the code from citizens that you're referring to

cloud current
#

ah

drowsy helm
#

they probably send update packets every so often or under specific circumstances

#

packets just dont work like that and stay persistent

cloud current
drowsy helm
#

spawn packets, entity information packets etc

#

just stuff to retain the data once the player comes backl

#

you'll probably also notice if you spawn the entity before you join, then join it won't have the data

cloud current
#

I add 2 ticks delay

#

I should send packets before adding in world ?

drowsy helm
#

just dont use packetse

#

lemme find what i do

#
   ((CraftWorld)loc.getWorld()).getHandle().addEntity(ent());
cloud current
#

I know how to spawn them without packets

#

but I'm making an api

drowsy helm
#

Then you're gonna have to run packets constantly for whenever you need to send data about the entity to the client

#

i.e when they join, when they render it etc

cloud current
#

wait ((CraftWorld)loc.getWorld()).getHandle().addEntity(ent());

#

I didn't think that when you said spawn them without packets

#

show me

#

player.getWorld().spawnEntity(location, EntityType.VILLAGER) I thought you meant this

drowsy helm
#

nah that doesnt take custom entities

cloud current
#

ah

drowsy helm
#

((CraftWorld)World).getHandle().addEntity(Entity);

#

then just pass the instance of your entity class

cloud current
#

I need custom entity : ' (

drowsy helm
#

Wdym

#

Just have your villager class extend VillagerEntity

#

Thats how custom entities should be handled

weary geyser
#

@drowsy helm Alr i use infinityfree now

#

It has ftp support

drowsy helm
#

i recommend apache net ftp

green prism
#

Guys, i'm creating a keysystem, i need to make a key not place able. I need to check the itemmeta, how can i do this?
I tried with this:

@EventHandler
public void onKeyPlace(BlockPlaceEvent event) {
    Player p = event.getPlayer();
    ItemMeta meta = event.getItemInHand().getItemMeta();
    LangMethods langMethods = new LangMethods(plugin);
    if(event.getBlockPlaced().getBlockData().getMaterial() == Material.TRIPWIRE_HOOK && meta != null && meta.getDisplayName().equals(plugin.getConfig().getString("Key-Mistery-Name"))) {
        event.setCancelled(true);
    }
}
eternal oxide
#

I don't believe ItemMeta is persistent between server starts

quiet ice
#

I would recommend to use PDC if possible as that is more likely to be persistent and appears to be what you want to do

#

Also, ItemStack#getItemMeta is a very expenisve call, you should call it last

green prism
drowsy helm
#

whats the content?

quiet ice
#

I mean the meta.getDisplayName().equals(plugin.getConfig().getString("Key-Mistery-Name")) check

#

Though, it is a matter of perference

green prism
eternal oxide
#

Tripwire is a block. it has BlockData but no meta. Meta is on ItemStacks

green prism
eternal oxide
#

When you place your trip wire it is no longer an ItemStack. You have no meta to compare

#

If you want to track specific blocks you need to implement some database system to know which blocks are your custom ones.

#

or use the chunks PDC

green prism
eternal oxide
#

There is no easy method

green prism
eternal oxide
#

Only special blocks with TileEntities have their own PDC so your only option is either a database or chunk PDC

green prism
eternal oxide
#

You can't

#

its a block and blocks do not have ItemMeta

green prism
eternal oxide
#

a data set that is lost when the server stops

oblique scaffold
#

Is there a way to check if the config has a key without a value? In my config I have keys that don't have any value by default because they are only there if the user wants to overwrite something. I'd like to check if the key is there to make sure users have all the possible config options, but it doesn't seem to work, I think because there's no value the config just ignores it.

green prism
eternal oxide
#

you would have to add the data to every placed block every single time the server starts

#

Which would mean you have a database of what blocks to put the data on

#

Which means you don;t need to put the data on the block at all

green prism
#

Maybe I didn't understand how it works because I thought I could add a metaData to the item and then when it is placed it is not lost and I can compare it.

eternal oxide
#

meta on ItemStacks is permanent, When placed as blocks its lost.

#

blockMeta is temporary

green prism
#

So the only simplest and most effective way is to?

eternal oxide
#

a database or chunk PDC

green prism
eternal oxide
#

no

green prism
eternal oxide
#

You think yes, good luck with that then.

green prism
eternal oxide
#

Good plan

last lintel
#

guys how can i give a player a whole pvp kit with weapons and armor

#

i tried player.getInventory().setItem();

#

and player.getInventory().setArmorContents(armor);

#

but it doesnt work

lost matrix
last lintel
#

then why am i not getting any armor?

lost matrix
last lintel
#

oh yeah

#

public void PVPkit(Player player) {
ItemStack[] armor = {};
armor[0] = new ItemStack(Material.DIAMOND_HELMET, 1);
armor[1] = new ItemStack(Material.DIAMOND_CHESTPLATE, 1);
armor[2] = new ItemStack(Material.DIAMOND_LEGGINGS, 1);
armor[3] = new ItemStack(Material.DIAMOND_BOOTS, 1);

    player.getInventory().setItem(0, new ItemStack(Material.IRON_SWORD, 1));
    player.getInventory().setItem(1, new ItemStack(Material.IRON_AXE, 1));
    player.getInventory().setItem(2, new ItemStack(Material.BOW, 1));
    player.getInventory().setItem(3, new ItemStack(Material.FISHING_ROD, 1));
    player.getInventory().setItem(4, new ItemStack(Material.GOLDEN_APPLE, 5));

    player.getInventory().setArmorContents(armor);
}
#

and then when player teleports to the arena

#

PVPkit(player);

eternal oxide
#

Thats not how to put items in an array

lost matrix
#

This will throw an ArrayIndexOutOfBoundsException

last lintel
#

how do I do it then?

last lintel
#

oh

#

i had to specify the array length then?

#

so it becomes ItemStack[] armor = new ItemStack[4];

fading lake
#

correct

minor garnet
#
    private void invisibleProjectile(Entity e) {
        for (Player all : e.getWorld().getPlayers()) {
            PacketPlayOutEntityDestroy packet = new PacketPlayOutEntityDestroy(new int[] { e.getEntityId() });
            (((CraftPlayer)all).getHandle()).playerConnection.sendPacket(packet);
        } 
    }
    @EventHandler
    public void projectileLaunch(ProjectileLaunchEvent e) {
        Projectile proj = e.getEntity();
        invisibleProjectile((Entity) proj);
    }```
#

invisibleProjectile((Entity) proj); this dont working

last lintel
#

now how do i teleport a player when he dies?

eternal oxide
minor garnet
#

how i do this ?

eternal oxide
#

teh Bukkit scheduler runTask

last lintel
#

how do i teleport my player when he dies?

#

this doesnt work

#

public void onPlayerDeath(PlayerDeathEvent event){
if (event.getEntity().getWorld().getName().equals("pvp")) {
event.getEntity().getInventory().clear();
PVPkit(event.getEntity());
Player player = event.getEntity();
player.teleport(new Location(Bukkit.getWorld("pvp"),-21.367, 85, 91.386, -86, 48));
}
}

young knoll
#

You need to use the damage event and stop them dying

#

Or use the respawn event

last lintel
#

if i choose the respawn event

#

do i teleport them as soon as they respawn if they are in the specified world?

drifting halo
#

@last lintel i think you need to delay a tick

#

Could work fine tho. Not sure

last lintel
#

how do i check which world they died in?

drifting halo
#

What coll said would be easier tbh. You'd have to track the world in the damage event anyway

#

So just check if the damage would kill them and then teleport them to the spawn of the current world they're in

last lintel
#

ok

#

is it PlayerItemDamage?

eternal oxide
#

no

#

Entity damage

last lintel
#

EntityDamageEvent

#

ok

#

how do i check if the damage will kill him?

young knoll
#

Check if their health - event.getFinalDamage <= 0

last lintel
#

problem is I cant access health

#

is it in getEntity()?

young knoll
#

Yes

last lintel
#

i cant find it

oblique scaffold
#

I think the configuration API doesn't work like it should. FileConfiguration.isSet (https://hub.spigotmc.org/javadocs/spigot/org/bukkit/configuration/MemorySection.html#isSet(java.lang.String)) should check if a path is set, and return false if it isn't, even if there's a default value, but for me it always returns true as long as the value is in the default config file. Manually setting the defaults to an empty YamlConfiguration fixes this, but that's not a nice solution, is there anything I'm missing?

cold tusk
#

How can i set the Y of a player?

ivory sleet
#

Probably teleport him

eternal oxide
cold tusk
#
//like this?
Location l = player.getLocation();
player.teleport(new Location(l.getWorld(), l.getX(), l.getY() + 0.4, l.getZ(), l.getYaw(), l.getPitch()));
oblique scaffold
#

If the value for the requested path does not exist but a default value has been specified, this will still return false.
so it should return false, but it doesn't

eternal oxide
#

what default file in the jar?

oblique scaffold
#

config.yml

eternal oxide
#

then its set

oblique scaffold
#

no, because that file specifies the defaults

eternal oxide
#

if it exists in the config at all, its set

oblique scaffold
#

that's the default config file, not the actual config file

eternal oxide
#

no, its just the default config. everything in it is set

oblique scaffold
#

not if I delete it

eternal oxide
#

delete what?

oblique scaffold
#

the value

#

I delete it, so it's not in the actual config anymore, but it does still have a default

eternal oxide
#

If its in the file, it exists.

oblique scaffold
#

according to the docs, that should still return false, but it doesn't

oblique scaffold
#

by that logic the config file would be hardcoded and could never be changed?

eternal oxide
#

if you then test that path for isSet it will reply with false

oblique scaffold
#

I'll try that, one minute

young knoll
oblique scaffold
eternal oxide
#

its the default config FILE, not defaults

oblique scaffold
#

so if a value isn't in the actual config file, it just takes it from the default config file?

eternal oxide
#

defaults are completely separate thing.

#

no

#

its a default FILE, not a default settings

oblique scaffold
#

but then why does it say the value is set, if it's only set in the default file but not the actual file?

eternal oxide
#

its the file that will be copied to your plugin directory when instructed. but every value in it is set

oblique scaffold
eternal oxide
#

because thats the config and default FILE, not default values

oblique scaffold
#

then how can I check if a value is set in the actual config file on disk, ignoring the default one?

eternal oxide
#

once loaded the one in memory is the only one thats checked

oblique scaffold
#

but apparently the default config still affects which values count as set?

eternal oxide
#

no

oblique scaffold
#

I did all that after loading the config

eternal oxide
#

only the one in memory

#

once you load the config it does not check any files

oblique scaffold
#

ok, so I have key X in my default, but I remove it in my file on disk, and then reload the config file, so the one from the disk is in memory now, right?

last lintel
#

how do i remove fire damage from player?

eternal oxide
#

if you already had a config loaded and you load your edited file over it you may confuse it. You should perform a copyDefaults to ensure they match

oblique scaffold
eternal oxide
#

users shoudl not be manually editing yrou file when the server is running

last lintel
#

nvm

#

fireticks

minor garnet
oblique scaffold
#

I don't think there's anything wrong with editing the file while the server is running

#

that's why virtually every plugin has a reload command

#

also you said the default config doesn't set defaults, that seems to be false, I just tried printing the defaults keys and it contains all the stuff from the default config

eternal oxide
#

if you are correctly reloading yoru config you should have no issues

oblique scaffold
eternal oxide
#

Looks fine to me

#

So you are saying that defaults are always being read from the yml in the jar file?

oblique scaffold
#

seems like it

crude charm
#

hi

#

can someone please help me

oblique scaffold
#

but apparently something is still different than adding them dynamically since it worked when I did that

crude charm
#

mvn clean install is giving me this

minor garnet
#
                for (int i = 0; i < 5; i++) {
                    p.sendTitle("§c§lYou died!", "§7Respawning in §f" + i + "§7seconds");
                }``` which runnable do i use perform this task in seconds?
eternal oxide
#

runnables are in ticks 20 ticks = 1 second

silk mirage
#

While using Bukkit.getServer().dispatchCommand() im getting an async error, what method shall i use to prevent this async thing?

eternal oxide
#

runtask or callMethod

silk mirage
#

example?

eternal oxide
#

Bukkit.getScheduler().callMethod(...

ivory sleet
#

isnt it called callSyncMethod btw lol

eternal oxide
#

it could be

silk mirage
#

i mean

#

im trying to run console command-

ivory sleet
#

well do u run that asynchronously?

#

if you do consider dispatching the command on the server thread instead

eternal oxide
#

somethign like (untested) Bukkit.getScheduler().callSyncMethod(plugin, Bukkit.getServer().dispatchCommand(sender,"blah")));

ivory sleet
#

It takes a Callable<V> iirc but yeah

eternal oxide
#

or Bukkit.getScheduler().runTask(plugin, () -> { Bukkit.getServer().dispatchCommand(sender,"blah"); });

ivory sleet
#

depends on your needs

eternal oxide
#

if you want a delay runTaskLater

minor garnet
#

what do you mean delay

ivory sleet
#

later

#

run something after a specified amount of time

minor garnet
#

i intend to make perform this task in seconds

ivory sleet
#

me?

#

😮

minor garnet
#

which one do you recommend

minor garnet
ivory sleet
#

be more specific "in seconds"

eternal oxide
#

convert seconds to ticks

ivory sleet
#

1 second? 2 seconds? or how many seconds

minor garnet
#

5 seconds

ivory sleet
#

runTaskLater(plugin,20L*5L)

#

ok?

minor garnet
#

worse I need to decrease wait, wrong code

#
                for (int i = 5; i != 0; i--) {
                    p.sendTitle("§c§lYou died!", "§7Respawning in §f" + i + "§7seconds");
                }```
ivory sleet
#

thats an odd way to make a decreasing loop but nice, yeah so maybe you could create some sort of recursive delaying task

minor garnet
#

hm

eternal oxide
#

just needs runTaskTimer, and self cancel when finished

ivory sleet
#

yeah either that or recurring delaying task as the delay is suppose to decline for each run if I understand right

eternal oxide
#

you just put the counter in the runnable, outside the run method

#

each time it runs, decrease counter

#

when it reaches zero cancel task

minor garnet
#

i need put a for outside of the run method ?

#
    @SuppressWarnings("deprecation")
    @EventHandler
    public void deathTime(Player p) {
        death.add(p);
        new BukkitRunnable() {
            @Override
            public void run() {
                for (int i = 5; i != 0; i--) 
                { p.sendTitle("§c§lYou died!", "§7Respawning in §f" + i + "§7seconds"); }
                cancel(); death.remove(p);
            }
        }.runTaskLater(Arma.getPlugin(Arma.class),20L);
    }```
eternal oxide
#

no, very wrong

minor garnet
#

whats wrong

eternal oxide
#

It should be something like ```java
final Player player = Bukkit.getPlayer("namehere");
new BukkitRunnable() {

int time = 5;
@Override
 public void run() {
    if (time == 0) this.cancel();
     player.sendTitle("§c§lYou died!", "§7Respawning in §f" + time + "§7seconds", -1, -1, -1);
    time--;
}

}.runTaskTimer(plugin, 0L, 20L);```

minor garnet
#

hm

#

i really need this. ?

eternal oxide
#

readability

ivory sleet
#

its very nice when people put this. and super. if applicable son

ornate heart
#

wow. i always thought i needed to make a class that extended bukkitrunnable in order for it to cancel itself. You learning something new every day...

green prism
#

@eternal oxide, do you remember me? I used a simple if(ItemStackKey.equals(e.getItemInHand) e.setcancelled true..

unreal quartz
ornate heart
ivory sleet
#

single responsibility principle

ornate heart
#

I'm going to have to read up on that

ivory sleet
#

well ofc it depends

#

if you just need a normal bukkit runnable then not perhaps

patent spoke
#

I want to split a string like "8000.00" into two part and use the 8000 without the .00 . How can I split it? (String[] split = output.split("\\."); String splitted = split[0]; did not worked)

eternal oxide
#

String.format

patent spoke
#

and how do I use it?

eternal oxide
#

String.format("%d", 8000.00); would give your 8000

patent spoke
#

ok, thanks

quaint mantle
#

How may I use NMS?

jagged lichen
#

Hello, I have a problem, the problem is that the "Skript" plugin does not read some scripts

lost matrix
# quaint mantle How may I use NMS?

You just need the nms code on your classpath (using maven or just using the spigot jar without maven)
But NMS is nothing you voluntarily use. Its something you try to avoid at all costs and only pick up when you absolutely need to.

quaint mantle
#

I need it as I can't send action bar messages for 1.8.8

lost matrix
civic apex
# quaint mantle How may I use NMS?

Afaik, you shoudnt really use nms, because that will break compatibility with other Minecraft versions, unless you plan on not switching then or having specific code for each version. You would have to update your code every time a new version comes out though

green prism
#

Guys, Door door = (Door) e.getClickedBlock() doesn't work, e.getClickedBlock().getBlockData doesn't work and e.getClickedBlock().getState() doesn't work (With all the server gives me the "Can't cast" error). Help? (1.16.5)

eternal oxide
#

show the actual error

onyx shale
#

its on BlockData

green prism
eternal oxide
#

and "doesn't work" tells us nothing

onyx shale
#

material.door?

#

you meant blockdata.Door

#

you imported wrong one

green prism
#

Where

eternal oxide
#

Door

green prism
#

and i need to make e.getClickBlock().getBlockData or State?

eternal oxide
#

data

green prism
#

Won't work, i think i'm wrong, i'm trying to restart the localhost.

eternal oxide
green prism
#

org.bukkit.block.data.type.Door door = (org.bukkit.block.data.type.Door) e.getClickedBlock().getBlockData();

onyx shale
#

yes

green prism
# onyx shale yes

It doesn't work, it doesn't open the door but I did a very quick debug with System.out.println and it goes all the way to that line, so it passes everything.

eternal oxide
#

What doesn't open the door? Its already a door.

green prism
# eternal oxide What doesn't open the door? Its already a door.
 @EventHandler
    public void onDoorInteract(PlayerInteractEvent e) {
        KeyCheck keyCheck = new KeyCheck(plugin);
        Player p = e.getPlayer();
        if(keyCheck.isKey(p.getInventory().getItemInMainHand())) {
            if(e.getClickedBlock() != null && e.getClickedBlock().getType() == Material.IRON_DOOR) {
                System.out.println("1");
                org.bukkit.block.data.type.Door door = (org.bukkit.block.data.type.Door) e.getClickedBlock().getBlockData();
                door.setOpen(true);
            }
        }
    }```
eternal oxide
#

code block

green prism
#

How

onyx shale
#

pretty sure you need to either save the new data

#

or call update

eternal oxide
#

three ` before and after

onyx shale
#

and as its blockdata i guess set the new one

eternal oxide
#

ty

#

yep, try setting the blockData back on the block

green prism
eternal oxide
#

because you just changed it

#

you need to set it back on the block

green prism
#

e.getClickedBlock().setBlockData(e.getClickedBlock().getBlockData());?

onyx shale
#

you first should store the blockdata,then cast door to it

#

do the change then set with that stored blockdata

green prism
#

oHHHH okAY

eternal oxide
#

e.getClickedBlock().setBlockData(door);

#

you may have to get teh other half of the door and do the same. Not sure on that though

green prism
#

Thanks to everyone and good Easter! (it Work!)

crude charm
#
[ERROR]   The project me.zoibox.core:Core:1.0-SNAPSHOT (E:\core\src\main\pom.xml) has 1 error
[ERROR]     'dependencies.dependency.systemPath' for me.zoibox.core:ActionBarAPI:jar must specify an absolute path but is src/main
/ActionBarAPI-1.5.4.jar @ line 171, column 25
        <dependency>
            <groupId>me.zoibox.core</groupId>
            <artifactId>ActionBarAPI</artifactId>
            <scope>system</scope>
            <version>1.5.4</version>
            <systemPath>src/main/ActionBarAPI-1.5.4.jar</systemPath>
        </dependency>
eternal oxide
#
            <id>jitpack.io</id>
            <url>https://jitpack.io</url>
        </repository>```
#
            <groupId>com.github.connorlinfoot</groupId>
            <artifactId>actionbarapi</artifactId>
            <version>1.5.4</version>
        </dependency>```If thats the correct version
crude charm
#

ty ill give it a try

#
[ERROR]   The project me.zoibox.core:Core:1.0-SNAPSHOT (E:\core\src\main\pom.xml) has 1 error
[ERROR]     'repositories.repository.id' must be unique: jitpack.io -> https://jitpack.io vs https://jitpack.io @ line 74, column
17

@eternal oxide

eternal oxide
#

That says you already have that repo added

crude charm
#

tysm

#
[ERROR] Failed to execute goal on project Core: Could not resolve dependencies for project me.zoibox.core:Core:pom:1.0-SNAPSHOT: C
ould not find artifact com.github.connorlinfoot:actionbarapi:jar:1.5.4 in spigotmc-repo (https://hub.spigotmc.org/nexus/content/gr
oups/public/) -> [Help 1]
****
eternal oxide
#

try ActionBarAPI instead of actionbarapi

crude charm
#

aight

eternal oxide
#

Github has stopped allowing uppercase letters in artifacts but it seems to be selective when it bans them

crude charm
#
[ERROR] Failed to execute goal on project Core: Could not resolve dependencies for project me.zoibox.core:Core:pom:1.0-SNAPSHOT: F
ailure to find com.github.connorlinfoot:ActionBarAPI:jar:1.5.4 in https://hub.spigotmc.org/nexus/content/groups/public/ was cached
 in the local repository, resolution will not be reattempted until the update interval of spigotmc-repo has elapsed or updates are
 forced -> [Help 1]
[ERROR]
eternal oxide
#

show us your pom. Drop it in here and it will be auto formatted

crude charm
eternal oxide
#

you have a space after ActionBarAPI

crude charm
#

oh yeah im dumb at 1am lmfao

#

bruhb

#
[ERROR] Failed to execute goal on project Core: Could not resolve dependencies for project me.zoibox.core:Core:pom:1.0-SNAPSHOT: F
ailure to find com.github.connorlinfoot:ActionBarAPI:jar:1.5.4 in https://hub.spigotmc.org/nexus/content/groups/public/ was cached
 in the local repository, resolution will not be reattempted until the update interval of spigotmc-repo has elapsed or updates are
 forced -> [Help 1]
eternal oxide
#

it should continue past that. its just failign to find it on spigot

minor garnet
crude charm
#

I did before

#

and got an error

eternal oxide
#

you should remove that from yoru project

crude charm
#

why?

eternal oxide
#

no manually added libs

crude charm
#

but then if I mvn clean install

#

then it will not comp[ile action bar api

eternal oxide
#

you should not be compiling it

crude charm
#

huh

eternal oxide
#

its a dependency

crude charm
#

no

#

the whole plugin

eternal oxide
#

You don;t compile it

#

yes, remove yoru local jar and refresh/update your maven

crude charm
#

when I compile the whole plugin it wont compile if I put it under library in intelliJ

eternal oxide
#

run clean package

#

you don;t put it anywhere

crude charm
#

oh

eternal oxide
#

its a maven dependency

crude charm
#

yeah

#

omg

#

im

#

so

#

dumb

#

lmfao

#

[ERROR] Failed to execute goal on project Core: Could not resolve dependencies for project me.zoibox.core:Core:pom:1.0-SNAPSHOT: F
ailure to find com.github.connorlinfoot:ActionBarAPI:jar:1.5.4 in https://hub.spigotmc.org/nexus/content/groups/public/ was cached
in the local repository, resolution will not be reattempted until the update interval of spigotmc-repo has elapsed or updates are
forced -> [Help 1]
[ERROR]

#

deleted it btw

eternal oxide
#

one sec I'll test your depend

crude charm
#

k

eternal oxide
#

give me an init line for ActionBarAPI

crude charm
#

wdym

eternal oxide
#

just a sample line that will use action bar

crude charm
#

ActionBarAPI.sendActionBar(player, "");

tardy yacht
#
//my config query would actually work that way ?
        int Lizenz = yamlConfiguration.getInt("Lizenz");
        if(Lizenz == 1102568){
           Bukkit.getConsoleSender().sendMessage(Main.getPrefix() + "§aDeine Lizenz ist gültig viel spaß mit §5Ultra§7-§dAntiCheat");
        } else {
            Bukkit.getConsoleSender().sendMessage(Main.getPrefix() + "§cDeine Lizenz ist ungültig bitte kaufe dir eine unter:§5 ");
            Bukkit.getPluginManager().disablePlugin(this);
        }
eternal oxide
#

Yeah, I can;t get it to see it either

crude charm
#

idk

#

maven has given me SO many issues

#

I dont understand

minor garnet
crude charm
#

an instance

tardy yacht
#

Unfortunately it does not work

crude charm
#

what do I do @eternal oxide

quiet ice
#

What the hell does Arma#getPlugin(Class) do?

eternal oxide
#

one sec

ivory sleet
#

I think its a type aware static method to get a plugin instance by its class

#

assume Arma extends JavaPlugin

quiet ice
eternal oxide
#

jitpack sees it fine

quiet ice
#

nvm, I replied to the wrong person, meant @tardy yacht

crude charm
#

cant I just get the jar from the plugin dir?

eternal oxide
#

you could install it locally (into yoru maven local)

quiet ice
#

well, you need compile time linking

crude charm
#

fuck this

#

im just not using them

quiet ice
#

Otherwise java will have no idea what the methods are about and guessing would not really owrk

crude charm
#

or if I do im just gonna make my own util

tardy yacht
#

if I run the plugin and the number in the config is correct, it sends the message for wrong

crude charm
#

lmfao

#

@eternal oxide can u help me with one other thing

quiet ice
#

remember, T extends Object == T extends Object tends to misbehave for anything but Boolean and otherwise cached values

crude charm
#

mvn clean install is outputting this

#
[INFO] --- maven-install-plugin:2.4:install (default-install) @ Core ---
[INFO] Installing E:\core\src\main\pom.xml to C:\Users\wsmit\.m2\repository\me\zoibox\core\Core\1.0-SNAPSHOT\Core-1.0-SNAPSHOT.pom

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.998 s
[INFO] Finished at: 2021-04-05T01:10:44+10:00
[INFO] ------------------------------------------------------------------------

eternal oxide
#

No clue, I don;t use install myself

tardy yacht
quiet ice
#

Your code should work though

#

There is nothing wrong and you did a typo that I did not spot or I cannot spot

tardy yacht
#

ok thx

maiden briar
#
        at org.bukkit.plugin.SimplePluginManager.getRegistrationClass(SimplePluginManager.java:703) ~[patched_1.16.5.jar:git-Paper-562]
        at org.bukkit.plugin.SimplePluginManager.getRegistrationClass(SimplePluginManager.java:701) ~[patched_1.16.5.jar:git-Paper-562]
        at org.bukkit.plugin.SimplePluginManager.registerEvents(SimplePluginManager.java:640) ~[patched_1.16.5.jar:git-Paper-562]
        at nl.timnl.eindjeminecraft.EindjeMinecraftPlugin.onEnable(EindjeMinecraftPlugin.java:48) ~[?:?]
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:263) ~[patched_1.16.5.jar:git-Paper-562]
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:380) ~[patched_1.16.5.jar:git-Paper-562]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:483) ~[patched_1.16.5.jar:git-Paper-562]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugin(CraftServer.java:501) ~[patched_1.16.5.jar:git-Paper-562]
        at org.bukkit.craftbukkit.v1_16_R3.CraftServer.enablePlugins(CraftServer.java:415) ~[patched_1.16.5.jar:git-Paper-562]
        at net.minecraft.server.v1_16_R3.MinecraftServer.loadWorld(MinecraftServer.java:580) ~[patched_1.16.5.jar:git-Paper-562]
        at net.minecraft.server.v1_16_R3.DedicatedServer.init(DedicatedServer.java:280) ~[patched_1.16.5.jar:git-Paper-562]
        at net.minecraft.server.v1_16_R3.MinecraftServer.w(MinecraftServer.java:1055) ~[patched_1.16.5.jar:git-Paper-562]
        at net.minecraft.server.v1_16_R3.MinecraftServer.lambda$a$0(MinecraftServer.java:289) ~[patched_1.16.5.jar:git-Paper-562]
        at java.lang.Thread.run(Thread.java:832) [?:?]```
I only registered more events, and then I get this bug
crude charm
tardy yacht
#

use Intellij Idea with the minecraft development plugin then everything should work

quiet ice
#

no

eternal oxide
maiden briar
#

No, I only added Bukkit events

eternal oxide
#

that says you didn;t

crude charm
#

I need help please

maiden briar
#
@EventHandler
    public void onBucketEvent(PlayerBucketEvent e)
    {
        Region region = RegionManager.locationInRegion(e.getBlock().getLocation());

        if(region != null)
        {
            PlayerBuildInRegionEvent event = new PlayerBuildInRegionEvent(region, e.getPlayer());
            Bukkit.getServer().getPluginManager().callEvent(event);

            if(event.isCancelled())
                e.setCancelled(true);
        }
        else
        {
            e.setCancelled(true);
            e.getPlayer().sendMessage(ChatFormat.format("&4Error: &cJe mag hier geen water plaatsen!"));
        }
    }

    @EventHandler
    public void onNetherEvent(PortalCreateEvent e)
    {
        e.setCancelled(true);

        if(e.getEntity() instanceof Player)
        {
            Player player = (Player) e.getEntity();
            player.sendMessage(ChatFormat.format("&4Error: &cJe mag niet naar de nether of de end!"));
        }
    }

    @EventHandler
    public void onDrop(PlayerDropItemEvent e)
    {
        e.setCancelled(true);
    }

    @EventHandler
    public void onReceipe(PlayerRecipeDiscoverEvent e)
    {
        e.setCancelled(true);
    }

    @EventHandler
    public void onRespawn(PlayerRespawnEvent e)
    {
        if(SpawnManager.isSpawnSet())
        {
            Player player = e.getPlayer();
            LocationManager.teleportPlayerToLocation(player, SpawnManager.getSpawn());
            player.sendMessage(ChatFormat.format("&aJe bent naar de spawn geteleporteerd!"));
        }
    }

This is the only code I added

crude charm
#

its not that

#

im trying to compile

#

and its giving me this

maiden briar
#

It is probably "PlayerBucketEvent", because this class doesn't have the method

eternal oxide
#

There is no playerBucketEvent

#

there are seperate fill and empty ones

eternal oxide
#

notice public abstract class PlayerBucketEvent abstract

maiden briar
#

I just created from this the empty and fill

quiet ice
# crude charm \

try to specify <type>jar<type> or similar, I do not know what exactly it is

maiden briar
eternal oxide
#

The child events are. Thats an abstract event so can;t be called

quiet ice
#

<packaging>jar</packaging> within the pom, so at the same level as the dependencies or repositories block

crude charm
#

oh yeah I see that

#

fix it

#

I have 500 iq

ivory sleet
#

true

crude charm
#

it wasn't that btw

minor garnet
ivory sleet
#

what u need help with now again

minor garnet
#

invisibleProjectile() is dont working

eternal oxide
minor garnet
#

proj has to be final ?

quiet ice
#

You see, based on where you redirected I would give you help on collapsing the bukkit runnable into a lambda

minor garnet
#

you mean define it like a final Projectile bla bla ?

eternal oxide
#

yes

#

the runnable can only access it if its final

#

You may have to store it locally in the runnable

minor garnet
#

but when i define it on a cast i need to ?

eternal oxide
#

so when it finally runs its available

minor garnet
#

final Projectile proj = e.getEntity();

#
final Projectile proj = e.getEntity();
new BukkitRunnable() {
    @Override
        public void run() {
            invisibleProjectile((Entity) proj);
        }
    }.runTaskLater(Arma.getPlugin(Arma.class), 50);
}```
eternal oxide
#

store a copy in yru runnable

minor garnet
#

what

#

''yru'' ?

quiet ice
#

Doesn't Javac inject these already if the locals are final?

eternal oxide
#

final projectile = proj;
@override

quiet ice
#

(for anonymous classes)

eternal oxide
#

Yes

minor garnet
#

aaah now i understand

eternal oxide
#

His isn;t final

quiet ice
#

Well, then make it effectively final

eternal oxide
#

yep

hollow bluff
#

I keep getting this error Jar does not contain plugin.yml I'm not quite sure why I keep getting it? This is my pom.xml setup for the build section: xml <build> <finalName>Trouble in Mineville</finalName> <sourceDirectory>src/main/java</sourceDirectory> <resources> <resource> <targetPath>.</targetPath> <filtering>true</filtering> <directory>${basedir}/src/main/resources/</directory> <includes> <include>plugin.yml</include> <include>config.yml</include> </includes> </resource> </resources> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build>

minor garnet
eternal oxide
#

If you had added a try/catch to your runnable you'd have seen it was erring out with an NPE

maiden briar
#
public static DiscordUser getDiscordUserForUUID(UUID uuid)
    {
        AtomicReference<DiscordUser> discordUser = new AtomicReference<>();

        new Thread(() ->
        {
            ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

            if(rs == null)
                return;

            List<DiscordUser> users = new ArrayList<>();

            try
            {
                while(rs.next())
                    users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

            for(DiscordUser dbUser : users)
            {
                if(dbUser.getPlayer().equals(uuid))
                {
                    discordUser.set(dbUser);
                    return;
                }
            }
        }).start();

        return discordUser.get();
    }
#

How to do this async? Because I need to do this async otherwise the server will crash, but I don't know how I can return the correct value

eternal oxide
#

it should

ivory sleet
#

tvhee what u wanna do async?

quiet ice
maiden briar
ivory sleet
#

btw use CompletableFuture instead of creating new threads

minor garnet
#

it is not working

ivory sleet
#

it uses a threadpool instead which is arguably more optimized

maiden briar
#

Example?

ivory sleet
#
Executor executor = new ForkJoinPool();
CompletableFuture<?> future = CompletableFuture.supplyAsync(() -> {
  return DiscordUser.fetch().get();
},executor).thenAccept(obj -> {
  //callback on the same thread the first supplier was called on (not the server thread to say)
});
#

or smtng

maiden briar
#

Thanks

hollow bluff
quiet ice
#

Maven does it automatically if it is in the src/main/resources folder

#

Default policy is include everything in that folder, no need to override it

hollow bluff
#

So just remove incluses and include?

ivory sleet
# maiden briar Thanks

also yeah I'd suggest using your own executor as

     * By default, CompletableFuture uses the ForkJoinPool.commonPool instance.
     * However... ForkJoinPool is a fixed size pool limited by Runtime.availableProcessors.
     * Some (bad) plugins incorrectly use this pool for i/o operations, make calls to Thread.sleep
     * or otherwise block waiting for something else to complete. This prevents the LP cache loading
     * operations from running.
     *
     * By using our own pool, we ensure this will never happen.
``` Yeah its from LP :]
maiden briar
ivory sleet
#

look at the code I sent

maiden briar
#

Yes I looked

ivory sleet
#

it shows an example where I pass it in CompletableFuture#supplyAsync(Supplier,Executor)

maiden briar
#

Incompatible types: expected not void but the lambda body is a block that is not value-compatible

#
Executor executor = new ForkJoinPool();
        CompletableFuture<?> future = CompletableFuture.supplyAsync(() ->
        {
            ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

            if(rs == null)
                return;

            List<DiscordUser> users = new ArrayList<>();

            try
            {
                while(rs.next())
                    users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

            for(DiscordUser dbUser : users)
            {
                if(dbUser.getPlayer().equals(uuid))
                    return dbUser;
            }
            return null;

        },executor).thenAccept(obj ->
        {


            //callback on the same thread the first supplier was called on (not the server thread to say)
        });```
ivory sleet
#

oh no

#

dont use wildcard

maiden briar
#

Where?

ivory sleet
#

you have to specify the type parameter to the type you wanna operate on ofc

#

I presume DiscordUser would be it in this case

maiden briar
#

Yes

ivory sleet
#

CompletableFuture<DiscordUser> ...

maiden briar
#

I changed that, error not solved

ivory sleet
#

yeah

maiden briar
#

How to solve this error? I really have no idea

ivory sleet
#

presumably return null

#

or no

#

cant be

maiden briar
#

If I return everywhere null, Intellij suggest to change it to void

ivory sleet
#

what u got now

maiden briar
#
CompletableFuture
<DiscordUser>
Provided:
CompletableFuture
<Void>```

```java
Executor executor = new ForkJoinPool();
        CompletableFuture<DiscordUser> future = CompletableFuture.supplyAsync(() ->
        {
            ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

            if(rs == null)
                return null;

            List<DiscordUser> users = new ArrayList<>();

            try
            {
                while(rs.next())
                    users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

            for(DiscordUser dbUser : users)
            {
                if(dbUser.getPlayer().equals(uuid))
                    return dbUser;
            }
            return null;

        },executor).thenAccept(obj ->
        {


            //callback on the same thread the first supplier was called on (not the server thread to say)
        });```
ivory sleet
#

yeah

#

since you return null

#

the supplier thinks its a void

#

throw CompletionException

#

or what its called

#

instead of returning null

maiden briar
#
CompletableFuture<DiscordUser> future = CompletableFuture.supplyAsync(() ->
        {
            DiscordUser user = null;

            ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

            if(rs == null)
                return user;

            List<DiscordUser> users = new ArrayList<>();

            try
            {
                while(rs.next())
                    users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

            for(DiscordUser dbUser : users)
            {
                if(dbUser.getPlayer().equals(uuid))
                    return dbUser;
            }
            
            return user;

        },executor).thenAccept(obj ->```
Wants void
#

I now not return null

ivory sleet
#

DiscordUser user = null;

maiden briar
#

Oh, also not allowed?

ivory sleet
#

well thing is if you return null it thinks it is a Void type (its a generics thing)

#

so whenever its null, throw a RuntimeException or smtng

maiden briar
#
Executor executor = new ForkJoinPool();
        CompletableFuture<DiscordUser> future = CompletableFuture.supplyAsync(() ->
        {
            ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

            if(rs == null)
                throw new IllegalStateException("Result set is null");

            List<DiscordUser> users = new ArrayList<>();

            try
            {
                while(rs.next())
                    users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

            for(DiscordUser dbUser : users)
            {
                if(dbUser.getPlayer().equals(uuid))
                    return dbUser;
            }

            throw new IllegalStateException("Result set is null");

        },executor).thenAccept(obj ->
        {


            //callback on the same thread the first supplier was called on (not the server thread to say)
        });```
Not working
ivory sleet
#

hmm

maiden briar
#

I have dinner now, see you later

ivory sleet
#

ok

crude charm
#

can someone please help me

ivory sleet
ivory sleet
crude charm
#

OMG

#

name: Core
version: ${project.version}
main: me.zoibox.core.core.Core
api-version: 1.8
authors: [Zoi]
description: CORE
softdepend:

  • ActionBarAPI
    depend:
  • EventAPI
  • helper
ivory sleet
#

and ur main class is in the jar?

#

and isnt relocated

crude charm
#

let me see

#

no

#

right place

ivory sleet
#

no

#

I mean in the jar

#

when u build

crude charm
ivory sleet
#

go in that jar

#

and check if the main has the same qualified name

hollow bluff
ivory sleet
#

ur jar does not contain plugin.yml

#

simple as that

maiden briar
#

I am back

ivory sleet
#

yeah tvhee

#

read what I said up there

hollow bluff
ivory sleet
#

thats not inside ur jar

#

thats ur project structure

crude charm
#

holy shit

#

luyten is so cluttered

#

I cant find anything

maiden briar
# ivory sleet My bad you should probably not put it into a variable or you'd have to put it as...

I don't understand, can you pls give me the code? This is what I want to reach:

ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

            if(rs == null)
                return null;

            List<DiscordUser> users = new ArrayList<>();

            try
            {
                while(rs.next())
                    users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

            for(DiscordUser dbUser : users)
            {
                if(dbUser.getPlayer().equals(uuid))
                    return dbUser;
            }

            return null;```
crude charm
#

@ivory sleet its still happening

hollow bluff
ivory sleet
#
final Executor executor = new ForkJoinPool();

CompletableFuture<DiscordUser> loadUser() {
  return CompletableFuture.supplyAsync(() -> {
      ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();
      if(rs == null) {
        return null;
      }

      List<DiscordUser> users = new ArrayList<>();
      
      try {
        while(rs.next()) {
          users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));
        }
      } catch(SQLException e) {
        e.printStackTrace();
      }

      for (DiscordUser dbUser : users) {
        if(dbUser.getPlayer().equals(uuid)) {
          return dbUser;
        }
      }

      return null;
  },executor);
}

void loadUser(Consumer<? super DiscordUser> callback) {
  this.loadUser().thenAccept(callback);
}
``` @maiden briar
#

I think

maiden briar
#

Ah thanks

ivory sleet
#

also why allman

#

so horribly space-taking

hollow bluff
#

me?

ivory sleet
#

no tvhee

hollow bluff
#

Can you tell me where I'm supposed to put the plugin.yml file? Cuz honestly, I don't know anymore

ivory sleet
ivory sleet
#

so tbf Idk

#

gradle is superior in my opinion

hollow bluff
#

cuz it's supposed to be where I put it

ivory sleet
#

ye

maiden briar
#
private static final Executor executor = new ForkJoinPool();

    private static CompletableFuture<DiscordUser> loadUser(UUID uuid)
    {
        return CompletableFuture.supplyAsync(() ->
        {
            ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

            if(rs == null)
                return null;

            List<DiscordUser> users = new ArrayList<>();

            try
            {
                while(rs.next())
                    users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));

            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

            for(DiscordUser dbUser : users)
            {
                if(dbUser.getPlayer().equals(uuid))
                {
                    return dbUser;
                }
            }

            return null;
        }, executor);
    }

    public static DiscordUser getDiscordUserForUUID(UUID uuid)
    {
        DiscordUserManager.loadUser(uuid).thenAccept(discordUser ->
        {
            // What to fill in here?
        });
    }```
ivory sleet
#

well thing is if you wanna return the user it would have to be blocking the thread its called on

maiden briar
#

Yes

ivory sleet
#

thought that was what you didnt want

maiden briar
#

I just wanted to get the user async to prevent crashes

ivory sleet
#

thats fine

#

but you'd need to put logic in that callback there

#

or

#

some logic

maiden briar
#

Example?

ivory sleet
#

Idk depends on what u wanna do with the user

#

if u wanna print him do that

#

if u wanna get his id do that?

maiden briar
#

I want to return him

ivory sleet
#

then it would be blocking

#

as I said

maiden briar
#

Checking if not null

#

So I make a boolean from the method and then how to check if the user is not null in the logic?

ivory sleet
#

Actually tvhee

#

you could create a cache

maiden briar
#

I know, but the bot will change them into the database

#

If somebody enters a command

eternal oxide
#

or call a sync method to do whatever logic on the returned player

maiden briar
#

Ok how?

ivory sleet
#

well he's not working with players

opal sluice
#

Hi, does someone has a clue on how to degen a region/chunk with worldedit ? I can't find it in their api

eternal oxide
#

He can still pass an object using the callSyncMethod

maiden briar
#

The idea is simple: I just want to query the database and return the values from it, but then async so the server won't crash

eternal oxide
#

You realize your code can;t stop and wait for the response

maiden briar
#

Yes

eternal oxide
#

you call teh query and then let yoru code go off and do other things

opal sluice
maiden briar
ivory sleet
#

I think you wanna do this tvhee
Fetch from database
Put into cache

If user exists in cache, get it
Else load it and put it in the cache then get it and have a fallback callback

eternal oxide
#

it will only freeze the async thread for a few ms waiting for the sync

maiden briar
#

Yes, but I get a crash then

eternal oxide
#

not like this

ivory sleet
#

loading, querying

maiden briar
#

Ah

opal sluice
#

Or you could try to implement something like the wait()/signal() on linux/C (which require to know how to manipulate threads safely)

ivory sleet
#

and if you wanna run something on the main thread, then simply define that in the callback or the return if its present with BukkitScheduler#callsSyncMethod or just BukkitScheduler#runTask

maiden briar
#
public static DiscordUser getDiscordUserForUUID(UUID uuid)
    {
        Bukkit.getServer().getScheduler().runTask(EindjeMinecraftPlugin.getInstance(), () ->
        {
            ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

            if(rs == null)
                return null;

            List<DiscordUser> users = new ArrayList<>();

            try
            {
                while(rs.next())
                    users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));

            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

            for(DiscordUser dbUser : users)
            {
                if(dbUser.getPlayer().equals(uuid))
                {
                    return dbUser;
                }
            }

            return null;
        });
    }```
Error that I can't return things
ivory sleet
#

that runs on the main thread

#

or server thread rather

maiden briar
#

runTaskAsynchronously then

#

But how can I return the value inside it?

ivory sleet
#

still returns a BukkitTask

#

Elgar told u

eternal oxide
#

then from teh Async task callsync method or a run task

hollow bluff
maiden briar
#

You go to /main/resources and put your plugin.yml inside it

#

If you work with articfacts then refresh it

maiden briar
#

I have public DiscordUser, how to return that user?

ivory sleet
#

Well thing is you cannot always "return" stuff and expect it not to be blocking, especially when we work with multithreading. Instead we use callbacks that defines behaviors of functional interfaces which then are called on separate threads.

maiden briar
#

Ok I understand, how to create this callback?

eternal oxide
#

Bukkit.getScheduler().callSyncMethod( your method here that it can pass your object to

ivory sleet
#

CompletableFuture#runAsync(Supplier)
BukkitScheduler#callSyncMethod(Callable)

#

its basically a function you define which is to be called later at some point

maiden briar
#
public static DiscordUser getDiscordUserForUUID(UUID uuid)
    {
        Future<DiscordUser> future = Bukkit.getServer().getScheduler().callSyncMethod(EindjeMinecraftPlugin.getInstance(), () ->
        {
            ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

            if(rs == null)
                return null;

            List<DiscordUser> users = new ArrayList<>();

            try
            {
                while(rs.next())
                    users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

            for(DiscordUser dbUser : users)
            {
                if(dbUser.getPlayer().equals(uuid))
                    return dbUser;
            }

            return null;
        });

        try
        {
            return future.get();
        }
        catch(InterruptedException | ExecutionException e)
        {
            e.printStackTrace();
        }
        
        return null;
    }```
Something like this?
eternal oxide
#

teh callSync goes inside your Async code to pass back any value you need

hollow bluff
#

ima wait and ask the question later tonight

eternal oxide
#

no, that is firstly sync secondly a blocking future

maiden briar
onyx shale
#

Oh god..

quaint mantle
#

do u guys know any good user-friendly script engines?

onyx shale
#

Explaining CompleteableFuture is one of the hardest thing

hollow bluff
onyx shale
#

Youll have more luck looking over a video

#

Rather than someone explaining it

maiden briar
#

Ok

onyx shale
#

Its one of the advanced java concepts...

maiden briar
eternal oxide
#

the really simple way... make an Async runnable to do yoru loopup...

onyx shale
#

If there is nothing to return yes,async runnable is the way to fo

maiden briar
eternal oxide
#

then at teh very bottom of yoru code, when you have the data you need to return, you use Bukkit.getScheduler().callSyncMethod to call a method in yrou plugin to pass the final data to

ivory sleet
#

hmm I can try explaining it otherwise

#

tvhee

hollow bluff
maiden briar
#

I also was 100% sure of a file, but then I decompiled it and saw it was missing

hollow bluff
#

How do I do that?

maiden briar
#

Search on the web

hollow bluff
#

you can't just tell me here?

maiden briar
#

Ok use luyten to decompile

#

Download that program

#

And open your jar

steep wadi
#

I just ran version 1.8.8 and it does not work.

dusty herald
#

did you use BuildTools?

hollow bluff
maiden briar
#

Ah nice

quaint mantle
#

legacy user detected 🆘

hollow bluff
#

Thanks

steep wadi
maiden briar
#

Conclure is typing.......

dusty herald
#

if you want a working version of 1.8.8 build it yourself

#

DogKek or don't run version 1.8.8

dire marsh
#

I'm sorry did someone say 1.8

#

fuck off

dusty herald
#

that site is not official and is illegal

#

?bt

queen dragonBOT
dire marsh
#

1.8 😂 😂

quaint mantle
#

lmao

maiden briar
#

Which site

dusty herald
#

the site that provides downloads for spigot jars

maiden briar
#

Oh

hollow bluff
#

@maiden briar Can I delete the test folders?

maiden briar
hollow bluff
#

okay

ivory sleet
#
Runnable r1 = () -> {
  System.out.println("hi");
}
Runnable r2 = new Runnable() {
  public void run() {
    System.out.println("hi");
  }
}

You know both of these operate equivalent. They both anonymously implement the method run(), they define that logic happens in run() but they're never called meaning that you don't know that thread nor when it's called.

For instance

class A extends JavaPlugin {
  public void onEnable() {
    r1.run();
  }
}```
here r1.run() is called on the main server thread.

Now let's take a look at CompletableFuture
```java
Supplier<String> s = () -> {
  Thread.sleep(100_000L);
  return "ddd"
};
CompletableFuture<String> fut = CompletableFuture.supplyAsync(s);

So by now you know that the supplier s is just implementing/defining the method Supplier#get. It never calls it. What CompletableFuture.runAsync(s) does is that it takes the supplier you pass and runs it on another thread. Let's call it thread #1.

Lets take a look at blocking vs non blocking

//blocking
void onEnable() {
  String s2 = fut.join();
  System.out.println(s2);
}```
Here we call CompletableFuture#join() which returns the string, but since it returns the value the main server thread has no other choice but to wait 100 seconds (the main server thread) as every operation on a single thread can only be executed consecutively. 

But if we would do this instead:
```java
//non-blocking
void onEnable() {
  fut.thenAccept(obj -> {
    System.out.println(obj);
  });
}

Here we only defines what happens in the Consumer#accept. We never call it on the main server thread. So the Consumer will be called on thread #1 here.

Idk if u got a better understanding now?

maiden briar
#

Wow thanks

eternal oxide
#
    public void getData() {
        new BukkitRunnable() {
            
            @Override
            public void run() {
                //get data...
                
                
                Bukkit.getScheduler().runTask(instance, () -> dataConsumer("test"));
            }
        }.runTaskAsynchronously(this);
    }
    
    public void dataConsumer(String data) {}```
steep wadi
#

In Pterodactyl

quiet ice
#

And?

#

This is spigotmc, not whatever you have issues with

#

Unless this is a spigotmc issue

dire marsh
#

it's because he's trying to run buildtools for the server startup

steep wadi
#

Ok, sorry

dire marsh
#

which is plain wrong

eternal oxide
#

@maiden briar code above

quiet ice
#

oh yeah, buildtools is a builder to build spigot jars

eternal oxide
#

yes

dire marsh
#

imagine using buildtools

#

this post was made by paper gang

quiet ice
#

They use it, just in dev time

dire marsh
#

10 seconds vs 5 minutes of buildtools

quiet ice
#

And plugin devs that use nms (ew) need to run it unless they use codemc (ewww)

dire marsh
#

just get the patched jar from cache folder

quiet ice
#

That's not how maven works

quaint mantle
dire marsh
#

so drop it in your local repo? or just put it in a libraries folder in your plugin?

dire marsh
#

i dont see the problem

maiden briar
#
public static DiscordUser getDiscordUserForUUID(UUID uuid)
    {
        new BukkitRunnable()
        {
            @Override
            public void run()
            {
                DiscordUser user = null;
                
                ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

                if(rs == null)
                    return;

                List<DiscordUser> users = new ArrayList<>();

                try
                {
                    while(rs.next())
                        users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));
                }
                catch(SQLException e)
                {
                    e.printStackTrace();
                }

                for(DiscordUser dbUser : users)
                {
                    if(dbUser.getPlayer().equals(uuid))
                        user = dbUser;
                }
                
                dataConsumer(user);
            }
        };
        
        return null;
    }
    
    private static void dataConsumer(DiscordUser user)
    {
        
    }
dire marsh
#

still takes 4 minutes less

quiet ice
#

Plus, you are now working with paper's API, not with spigot's API

dire marsh
#

Good.

dusty herald
#

Good luck with cross compatibility if you plan on using any paper only features

dire marsh
#

paperlib

quiet ice
#

You are still using the paper jar

#

You will not know what it paper only

dire marsh
#

they're under different packages afaik

#

the classes, at least

quiet ice
#

There are differences outside of that

maiden briar
dire marsh
#

who cares

quiet ice
#

I certainly do care

ivory sleet
#

I care

dusty herald
#

who doesn't care DogKek

quaint mantle
dusty herald
#

👀

quiet ice
#

I may have shipped a lot of releases that only partly worked on spigot, but it's because paper accidentally patched a bug somehow somewhere

maiden briar
# ivory sleet ```java Runnable r1 = () -> { System.out.println("hi"); } Runnable r2 = new Ru...

I tried this, but I can't return the value....

Supplier<DiscordUser> supplier = () ->
        {
            DiscordUser user = null;

            ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

            if(rs == null)
                return null;

            List<DiscordUser> users = new ArrayList<>();

            try
            {
                while(rs.next())
                    users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

            for(DiscordUser dbUser : users)
            {
                if(dbUser.getPlayer().equals(uuid))
                    user = dbUser;
            }

            return user;
        };

        CompletableFuture<DiscordUser> future = CompletableFuture.supplyAsync(supplier);

        future.thenAccept(user ->
        {
            return user; //Doesn't work?
        });```
ivory sleet
#

yes thats the point of using callbacks

#

you wont be able to return values directly due to what I stated in that message

#

another approach if you somehow want to return it would be to cache it then

maiden briar
#
DiscordUser discordUser = null;
        
        Supplier<DiscordUser> supplier = () ->
        {
            DiscordUser user = null;

            ResultSet rs = QueryBuilder.selectFrom("DiscordData").executeWithResult();

            if(rs == null)
                return null;

            List<DiscordUser> users = new ArrayList<>();

            try
            {
                while(rs.next())
                    users.add(MySQLDataConverter.convertDiscordUser(rs.getString(1), rs.getLong(2), rs.getString(3)));
            }
            catch(SQLException e)
            {
                e.printStackTrace();
            }

            for(DiscordUser dbUser : users)
            {
                if(dbUser.getPlayer().equals(uuid))
                    user = dbUser;
            }

            return user;
        };

        CompletableFuture<DiscordUser> future = CompletableFuture.supplyAsync(supplier);

        future.thenAccept(user ->
        {
            discordUser = user;
        });

Already tried this, but then the query won't be executed (always null)

ivory sleet
#

you're trying to lazily set it?

maiden briar
#

What else?

ivory sleet
#

callback?

maiden briar
#

Ok how?

ivory sleet
#
        future.thenAccept(user ->
        {
          //define logic here
        });
maiden briar
#

Oh, I need to return the future, and in my command class I have to fill in the logic?

ivory sleet
#

yeah return the future