#help-development

1 messages Ā· Page 1713 of 1

ivory sleet
#

working on data and model management rn

#

I dislike it

quaint mantle
#

So you should be bless and help me šŸ˜‚

ivory sleet
#

annot cmd frameworks are limiting

quaint mantle
#

I mean.. you don’t really need much in a command

#

Except some form of CommandSender

ivory sleet
#

its about reusability

quaint mantle
#

And parameters

quaint mantle
#

Spigot Programming.. Episode 1 ā€œSetting up the Projectā€ - GoodInside

#

I should become a yter

ivory sleet
#

Lmao

quaint mantle
#

Well there’s not really any decent tutorials

#

They all out dated

ivory sleet
#

I wrote one

quaint mantle
#

Ofc you did

muted idol
#

hey there quick question, is there any way to display custom messages when loading into my server? like right when you click to connect to the server the dirt block screen to display custom text

median robin
#

How do I set up the bot?

quaint mantle
#

Which iirc is loaded after that screen

median robin
solar sable
#

you just said "the bot" and didnt specify what it is

median robin
#

For the server idk

#

Nevermind

solar sable
#

specify what you want to ask next time

median robin
#

Okay

lost matrix
#

In the server list of the client?

solar sable
#

i think he said like when the game loads

#

so when it says like "Joining world" like that

solar sable
#

but that impossible lol

solid cargo
#

asking for a little spoonfeed, i cannot figure it out. how can i apply my custom made sharpness 6 book to a sword.

#

the sharpness caps at 5 for me btw

echo basalt
#

addUnsafeEnchantment

solid cargo
#

no, you dont understand

echo basalt
#

PrepareAnvilEvent + addUnsafeEnchantment

solid cargo
#

i have made this custom book

echo basalt
#

So yeah just listen to PrepareAnvilEvent

solid cargo
#

i can set the book a metedata

solar sable
#

i understand what you are trying to get but i dont know how to

solid cargo
#

ah ok

#

ohhh

#

if (firstItem.equals(Material.WHATEVER_SWORD) && secondItem.equals(MY_BOOK)) { do that and that? }

echo basalt
#

Something like

@EventHandler
private void onPrepare(PrepareAnvilEvent event) {
  Inventory inv = event.getInventory();

  ItemStack one = inv.getItem(0);
  ItemStack two = inv.getItem(1);

  if(one == null || two == null)
    return;

  ItemStack result = one.clone();
  result.addUnsafeEnchantments(two.getEnchantments());

  event.setResult(result);
}
solid cargo
#

ah so pretty close

#

thanks

#

but @echo basalt now it doesnt apply books at all lol

#

even vanilla books

echo basalt
#

uh h

#

try doing inv.setItem(3) instead of event.setResult

solid cargo
#

you didnt say what inventory?

echo basalt
#

uh

solid cargo
#

dont you need to define the inventory?

#

or something

echo basalt
#

you can also do something like
Inventory inv = event.getView().getTopInventory();

lost matrix
echo basalt
#

Ah

#

Then just read the meta

solid cargo
#

hmm

echo basalt
#

bit stupid but eh

solid cargo
#

its for a private smp anyways

#

so efficency doesnt really matter

echo basalt
#

nah

#

just make it right

solid cargo
#

idk i really want to ask straight up for a spoonfeed

solar sable
#

whats a spoonfeed

lost matrix
#
  @EventHandler
  public void onPrepare(final PrepareAnvilEvent event) {
    final AnvilInventory inventory = event.getInventory();

    final ItemStack one = inventory.getItem(0);
    final ItemStack two = inventory.getItem(1);

    if (one == null || two == null) {
      return;
    }

    final ItemStack result = one.clone();
    final ItemMeta meta = two.getItemMeta();

    if (!(meta instanceof EnchantmentStorageMeta enchantmentStorageMeta)) {
      return;
    }

    result.addUnsafeEnchantments(enchantmentStorageMeta.getStoredEnchants());
    event.setResult(result);
  }
#

This is

solid cargo
solar sable
solid cargo
#

yeah @lost matrix i apologise :(

solar sable
#

i always do that lol but i didnt know what a spoonfeed was

lost matrix
solid cargo
#

@lost matrix whats ur language level

#

Patterns in 'instanceof' are not supported at language level '5' getting this

solid cargo
#

ok

solar sable
#

also i have a problem on this

solid cargo
#

getting weird errors

solar sable
#
@EventHandler
    private void onMove(final PlayerMoveEvent e) {
        final Player player = e.getPlayer();
        final Material playerMaterial = this.playerMaterials.get(player.getUniqueId());
        if (playerMaterial == null) {
            return;
        }
        final Location from = e.getFrom();
        final Location to = e.getTo();

        if (to == null) {
            return;
        }

        final int fromX = from.getBlockX();
        final int fromY = from.getBlockY();
        final int fromZ = from.getBlockZ();
        final int toX = to.getBlockX();
        final int toY = to.getBlockY();
        final int toZ = to.getBlockZ();

        if (fromX == toX && fromY == toY && fromZ == toZ) {
            return;
        }

        final Block below = to.getBlock().getRelative(BlockFace.DOWN);
        final Material belowMaterial = below.getType();

        if (belowMaterial != playerMaterial) {
            return;
        }

        player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9WalkDetector > &fYou are walking on "));
        this.playerMaterials.remove(player.getUniqueId());
    }
``` it didnt work ingame
solid cargo
#

@lost matrix it gives me this error when building

#

lambda expressions are not supported in -source 1.5

#

and it isnt colored red or anything

solar sable
#

is it a warning or an error

solid cargo
#

none...

#

error when compiling/building

solar sable
#

ah

solid cargo
#

never seen that shit

solar sable
heavy pelican
#

Can anyone help me, I installed spigot on my server and now no one without op can’t build

tacit drift
#

@solar sable you should start using debug messages instead of just requesting help all the time here

#

and you don't need to make every variable final ffs md_5

solar sable
#

well i just copied stuff so .-.

#

my bad

solid cargo
#

@lost matrix getting this error in classes including the anvil event

heavy pelican
solid cargo
#

and spawn protection is like 50

heavy pelican
#

Omgggg

#

Ok

#

I’ll try it

#

Tysm

lost matrix
lost matrix
#

pom.xml

solid cargo
#

i did

#

oh wait

#

to 16?

lost matrix
solid cargo
#

for 1.17

#

anyways.

lost matrix
#
  <properties>
    <java.version>16</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <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.2</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <createDependencyReducedPom>false</createDependencyReducedPom>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
solid cargo
#

oh is it just 16?

#

they changed it?

#

from 1.<versiontype>

#

to just <versionType?>

#

now it straight up rejects to compile ._.

eternal oxide
#

the error will tell you why

solid cargo
#

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project SMPCore: Fatal error compiling

eternal oxide
#

find the actual error in the log

tacit drift
#

šŸ˜…

eternal oxide
#

My bet, you don't have java 16 JDK installed

solid cargo
#

pretty sure i do

#

will check for safety tho

#

whoops

#

my java home is set to 8

#

do i need to restart pc for it to apply?

#

same error btw

paper viper
#

set your java home to 16 then

#

you dont need to restart

solid cargo
paper viper
#

ik for windows you dont have to

#

just open a new cmd prompt

solid cargo
#

what in cmd

chrome beacon
#

Open a new cmd window

solid cargo
chrome beacon
#

Did you reopen it after changing java home

solid cargo
#

the IDE?

#

yes

chrome beacon
#

Could you run java -version

#

In cmd

paper viper
#

yea

solid cargo
chrome beacon
#

You're building with Intellij right?

solid cargo
#

ye

chrome beacon
#

Is jdk 16 selected in project settings

paper viper
#

^

#

and also make sure your gradle or maven setup has java 16 set

solid cargo
#

omfg, how do i do that

paper viper
#

which

solid cargo
#

maven

#

in pom?

paper viper
#
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.8.0</version>
    <configuration>
        <release>16</release>
    </configuration>
</plugin>
solid cargo
#

ah

#

oh its 15

#

still doesnt compile

paper viper
#

wait try again

#

with above

chrome beacon
#

source and target do work with Java 16

#

Just deprecated iirc

solid cargo
#

but there is no release

#

bruuh

#

nothing works

lost matrix
solid cargo
#

hm

#

ok will do

#

IT COMPILED

#

GG

#

the plugin died tho...

#

java.lang.UnsupportedClassVersionError

#

hmm

#

will check internet

eternal oxide
#

that means the version of java you built against is not the same as yoru server version

solid cargo
#

how does that work tho

#

heh?

eternal oxide
#

what spigot is your server running?

solid cargo
#

its an outdated tuinity

#

but it is 1.17

eternal oxide
#

?paste the full version error

undone axleBOT
solid cargo
eternal oxide
#

class file version 60.65535

#

thats java 16

solid cargo
#

huh

eternal oxide
#

or is 52 8? I forget

solar sable
#
@EventHandler
    private void onMove(PlayerMoveEvent e) {
         Player player = e.getPlayer();
         Material playerMaterial = this.playerMaterials.get(player.getUniqueId());
        if (playerMaterial == null) {
            return;
        }
        Location from = e.getFrom();
        Location to = e.getTo();

        if (to == null) {
            return;
        }

        int fromX = from.getBlockX();
        int fromY = from.getBlockY();
        int fromZ = from.getBlockZ();
        int toX = to.getBlockX();
        int toY = to.getBlockY();
        int toZ = to.getBlockZ();

        if (fromX == toX && fromY == toY && fromZ == toZ) {
            return;
        }

        Block below = to.getBlock().getRelative(BlockFace.DOWN);
        Material belowMaterial = below.getType();

        if (belowMaterial == playerMaterial) {
            return;
        }

        player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9WalkDetector > &fYou are walking on "));
        this.playerMaterials.remove(player.getUniqueId());
    }
``` still need help with this
eternal oxide
#

yep 52 is 8, 60 is 16

solid cargo
#

something i found in a website

#

pretty sure yeah

solar sable
solid cargo
eternal oxide
#

Well the error says you are trying to use some preview features

neon nymph
solar sable
#

add logs?

#

how?

neon nymph
#

Yaknow, temporary sysouts

eternal oxide
solar sable
neon nymph
#

System.out.println("it passed this return"); etc

inner tusk
#

any one tell me how to make bazar plugins

solar sable
#

where do i need to put the sysout?

#

before or after the return;

tacit drift
#

Man

neon nymph
#

right on top of those returns

tacit drift
#

learn java

solar sable
#

okay

#

okay i have put the sysout on every return

solid cargo
#

but isnt clean spigot very cocky?

eternal oxide
#

Spigot is what we support

neon nymph
#

Well go on and test it, see where the code ends up

solid cargo
#

@eternal oxide the problem still goes in clean spigot btw

eternal oxide
#

?paste teh error. Spigot error will be different

undone axleBOT
solid cargo
eternal oxide
#

your java must be out of date, if you are running 16

solid cargo
#

my jre?

eternal oxide
#

nothing you have been given/shown in here is a preview feature

#

yes

solid cargo
#

alright

eternal oxide
#

the jre your server is running on

solid cargo
#

ugh im not that deep into servers

#

how can i change it

eternal oxide
#

first test what jre yoru server is using

quaint mantle
#

in a switch in java 8
should i return true and break
or just break
or i shouldn't break

#

i guess no need to break

eternal oxide
#

command prompt, and I think java -version

solid cargo
eternal oxide
quaint mantle
#

ok

solid cargo
#

oh well

#

i have 16.0.2 on intelij

#

jdk i mean

#

i will check if it works on my main smp

eternal oxide
#

yoru java looks fine

#

in your server launch line you could add --enable-preview after the java.

quaint mantle
#

and to modify a string list in fileconfiguration, should i set it again
or if i add, set or anything will it get modified ?

lost matrix
quaint mantle
#

will it get saved ?

solid cargo
quaint mantle
quaint mantle
solid cargo
#

sucks

lost matrix
quaint mantle
#

if i do saveConfig ?

lost matrix
quaint mantle
#

if i get the list, modify it and set it and then save ?

quaint mantle
#

for hashmap, it was not like this

lost matrix
quaint mantle
#

you could modify a list like that

lost matrix
solar sable
#

so guys i found which one that is wrong and apparently its this

 private void onMove(PlayerMoveEvent e) {
         Player player = e.getPlayer();
         Material playerMaterial = this.playerMaterials.get(player.getUniqueId());
        if (playerMaterial == null) {
            System.out.println("test54");
            return;
        }
#

well somewhere in that

quaint mantle
#

but it doesn't get saved in disk i guess

solar sable
lost matrix
quaint mantle
#

i tested

#

it saves armorstand id

#

and when i send destroy packet

#

it will get destroyed

#

all lines

solid cargo
#

@lost matrix i promise its the last ping. when you told me to change to java 16, my whole plugin just got messed up and it died, have any alternatives for the anvil to accept unsafe enchants?

lost matrix
solid cargo
#

alright

solar sable
solid cargo
#

dont ask to ask

#

?ask

undone axleBOT
#

If you have a question, please just ask it. Don't look for staff or topic experts. Don't ask to ask or ask if people are awake or available. Just ask the question to the channel straight out, and wait patiently for a reply. Create a thread in case the help channel you are using is already in use!

lost matrix
solar sable
#

example please?

#

need a spoonfeed for this

lost matrix
#
  private final Map<UUID, Material> playerMaterials = new HashMap<>();

  public void setPlayerMaterial(final Player player, final Material material) {
    this.playerMaterials.put(player.getUniqueId(), material);
  }
#

This method could then be called by an Event like the PlayerJoinEvent or by a command.

solar sable
#

idk where to put this

#

oh ik where

#
 private final Map<UUID, Material> playerMaterials = new HashMap<>();

    public void setPlayerMaterial(final Player player, final Material material) {
        this.playerMaterials.put(player.getUniqueId(), material);
    }

    @EventHandler
    private void onMove(PlayerMoveEvent e) {
         Player player = e.getPlayer();
         Material playerMaterial = this.playerMaterials.get(player.getUniqueId());
        if (playerMaterial == null) {
            System.out.println("test54");
            return;
        }
``` is this correct @lost matrix ?
lost matrix
stone sinew
solar sable
lost matrix
lost matrix
solar sable
#

oo-

#

what now?

lost matrix
#

This method could then be called by an Event like the PlayerJoinEvent or by a command.

solar sable
#

aah

stone sinew
solar sable
lost matrix
# stone sinew Yeap

What do you think would be the cause for a NPE here? Which pointer exactly points to null.

stone sinew
lost matrix
solar sable
#

im just asking what do you mean by

This method could then be called by an Event like the PlayerJoinEvent or by a command

solar sable
lost matrix
#

But when is your method setPlayerMaterial called?

#

If its never called then the map is always empty

stone sinew
solar sable
#
 private final Map<UUID, Material> playerMaterials = new HashMap<>();

    public void setPlayerMaterial(final Player player, final Material material) {
        this.playerMaterials.put(player.getUniqueId(), material);
    }

    @EventHandler
    private void onMove(PlayerMoveEvent e) {
         Player player = e.getPlayer();
         Material playerMaterial = this.playerMaterials.get(player.getUniqueId());
        if (playerMaterial == null) {
            System.out.println("test54");
            return;
        }
``` before the eventhandler
lost matrix
#

There you declare the method. But just declaring a method in a class does literally nothing.

#

I think you should try to get a grasp of the java basics before continuing.

#

Just the very basics

solar sable
#

what i wanna ask now is

#

does it still have an error or am i good to test it

lost matrix
#

This code will run but it will just print out "test54" forever.

solar sable
#

but will it say the message that i want it to?

#
player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9WalkDetector > &fYou are walking on "));
``` this
lost matrix
#

No

solar sable
#

oh

lost matrix
#

What are you trying to do? Do you want to write a game where certain players have to find a specific block?

solar sable
#

no

#

i just want it to detect the block the person is standing/walking on but the last method i used, everytime i move my camera it will repeatedly sends the message so i want it to be only when it is standing on that one block and moving the camera will not make it spam the message

lost matrix
#

Ah. Then you can scrap the Map and just use this:

  @EventHandler
  private void onMove(final PlayerMoveEvent event) {
    final Player player = event.getPlayer();

    final Location from = event.getFrom();
    final Location to = event.getTo();
    
    if(to == null) {
      return;
    }

    final int fromX = from.getBlockX();
    final int fromY = from.getBlockY();
    final int fromZ = from.getBlockZ();
    final int toX = to.getBlockX();
    final int toY = to.getBlockY();
    final int toZ = to.getBlockZ();

    if (fromX == toX && fromY == toY && fromZ == toZ) {
      return;
    }

    final Block below = to.getBlock().getRelative(BlockFace.DOWN);
    final Material belowMaterial = below.getType();

    player.sendMessage("You entered a " + belowMaterial + " Block.");
  }
ivory sleet
#

thats a lot of finals lol

ancient plank
#

yum

solar sable
#
int toX = to.getBlockX();

how to make this not null

solar sable
#

oh

#

thanks

#

yay it works now

#

finally

#

thank you @lost matrix !!

#

double heart for you <<33 ā¤ļø !!

#

oh sorry but this will be the last ping from today

#

but

#

@lost matrix

#

how to make it not detect air?

#

if i jump it detects air so

lost matrix
#

You should be able to find that out yourself.
Just filter materials that are air.

solar sable
#

ah okay

#

i know it involves like !=air or something lol

lost matrix
#

Material has a isAir() method

solid cargo
#

is there a checker that checks if the player has been kicked?

solid cargo
#

yeah found it thanks

#

what is the player kick reason

#

if an operator kicks it

unique meteor
#

is NNY still around here?

chrome beacon
#

He probably got banned again

unique meteor
#

oh damn

chrome beacon
#

He'll be back though

unique meteor
#

what about cipher

chrome beacon
#

Not sure

lilac fossil
#

I am unsure of where to ask this, but I discovered that SpigotMc doesn't support [hr] [/hr] in their plugin descriptions - Is there another way to create a rule/line?

quaint mantle
lilac fossil
#

ah ye true

#

thanks

lost matrix
tardy delta
#

is there a way to avoid this?

#

or a better way to save ItemStack[]

lost matrix
tardy delta
#

can i cast it directly to a ItemStack[] ?

eternal oxide
#

why?

#

and, no

tardy delta
#

i save inventory contents to a file

eternal oxide
#

So?

#

You still don;t need an array when you already have a list

solar sable
#

guys despite the version of the tutorial, can i just use an outdated tutorial like a 1.15 plugin tutorial and use it in a 1.17 plugin?

eternal oxide
#

depends on the tutorial

solar sable
#

cause i dont see many tutorial uses 1.17 yet so

tardy delta
#

setContents() needs an ItemStack[]

eternal oxide
#

then why not use addAll?

#

unless you are preserving nulls you will not be putting items back in the same places

lost matrix
solar sable
#

okay thanks!

tardy delta
#

to store a player's vault

eternal oxide
#

So? you chose to use an array

tardy delta
#

i dunno if there is a better way

solid cargo
#

how can i set nothingness in a minecraft recipe?

tardy delta
#

yes

solid cargo
#

Material.AIR doesnt work btw

#

this wont work

#

but what will?

#

there should be an exp bottle

#

i also tried not defining "G"

eternal oxide
#

{" "," C ","CAC"} No G

solid cargo
#

ahhhh

#

ok

proud basin
#

ChatColor.yellow + player

#

you forgot a addition sign

solid cargo
#

you forgot a +

#

dont care what ide says

#

hm

hasty prawn
#

No, it's saying to add a "" between them

eternal oxide
#

or .toString()

hasty prawn
#

Yeah exactly. You can't add ChatColor and Player. You need a String inbetween so it can assume them both to be Strings and append them.

#

sender.getName() is a String

solid cargo
hasty prawn
#

So either add a String between or do player.getName()

eternal oxide
solid cargo
#
java
 ItemStack item = new ItemStack(Material.EXPERIENCE_BOTTLE);
        NamespacedKey key = new NamespacedKey(this, "exp_bottle");
        EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta();
        meta.setDisplayName(ChatColor.GOLD + "Experience Bottle");
        List<String> lore1 = Arrays.asList(ChatColor.AQUA + "Smash this bottle against your head", ChatColor.AQUA +  "To get experience!");
        meta.setLore(lore1);
        item.setItemMeta(meta);
        ShapedRecipe recipe = new ShapedRecipe(key, item);
        recipe.shape("   ",
                " C ",
                "CFC");

        recipe.setIngredient('F', Material.GLASS_BOTTLE);
        recipe.setIngredient('C', Material.LAPIS_LAZULI);

        return recipe;
#

@eternal oxide pretty sure this is correct

eternal oxide
#

You never registered the recipe

solid cargo
#

i did i think

eternal oxide
#

not in that code

solid cargo
#

Bukkit.addRecipe(this.getRecipeExp()); its in the onEnable thing

eternal oxide
#

Then it looks fine to me

#

did you discover the recipe for the player?

solid cargo
#

no

solar sable
#

guys how to give a player an item?

lost matrix
solar sable
#

ah okay

ivory sleet
#

There’s a method called getInventory() call it on your player variable then call addItem(item) on that

solar sable
#

is there a java doc for this? idk how to use it yet lol

sharp bough
#

just make a command that sends you a message, so you can teleport to the player and give them the item manually

hasty prawn
#

?jd

solar sable
#

thank you

ivory sleet
#

?jd-s (:

undone axleBOT
sharp bough
#

we should show people that

#

the ones that only ask for "premade code"

solid cargo
#

EnchantmentStorageMeta meta = (EnchantmentStorageMeta) item.getItemMeta(); something wrong in this line

#

?paste

undone axleBOT
eternal oxide
#

yeah, why are you using enchantment?

solid cargo
#

whats the alternative then

eternal oxide
#

its an exp bottle

ivory sleet
#

Probably want to check if the instance is of type EnchantmentMetaStorage

eternal oxide
#

its literally ItemMeta

solid cargo
#

ah

#

me dambdaram

weary pagoda
#

is it possible to export structures to other worlds?

lost matrix
weary pagoda
#

kind like bedrock edition, with the structure block you can?

tardy delta
#

is there really no better way to save an inventory to a file?

lost matrix
steep comet
#

Years ago I saw plugin using some.. library? In class he did @Somthing and it generated setter and getter methods.. But it was generated at build time, so the code looked really clean. Do you know what I might be reffering to?

weary pagoda
#

in normal worlds

lost matrix
tardy delta
lost matrix
weary pagoda
#

so when you save the structure to disk the file containing the structure is generated?

quaint mantle
#

addItem does not issue an item to the left hand. how to fix it?

tardy delta
#

ok lemme look at that after my lesson xd

#

lesson is boring

quaint mantle
#

How do i make some code run for 10 seconds?

#

am

sharp bough
#

you could repeat the code you are running, but hold it for 10 seconds wont work

#

you can pause it

#

and resume it later with a scheduler

quaint mantle
#

addItem does not issue an item to the left hand. how to fix it?

sharp bough
quaint mantle
#

I have a code that gives out an item if it can stack

quaint mantle
lost matrix
ashen flicker
#

Add item works great, but you do want to have an inventory check, and then do something with it. Like dropping it on the ground.

#

You could just make your own add item method

quaint mantle
#

sorry

quaint mantle
lost matrix
#

Your for each syntax is faulty

quaint mantle
#

@lost matrix

#

that is, I need to get the size of the inventory through the cycle?

lost matrix
#
    for (final Entry<Enchantment, Integer> entry : player.getInventory().getItemInMainHand().getEnchantments().entrySet()) {
      final Enchantment enchantment = entry.getKey();
      final int lvl = entry.getValue();
    }

But i would def not make such a long statement

lost matrix
quaint mantle
#

okay, thsnks

#

thanks*

#

i'm russian dayn typoi

sharp bough
#

so its been a while since i coded for the last time, i have a Block block, i cant cast this to an itemstack to add it to the player inv, how can i add it?

#

i forgot how to turn it lmao

solar sable
#

hes asking a question for me lol

lost matrix
#

You cant cast a Block to an ItemStack. A Block can have multiple drops. So you need to get all the drops of this
block as ItemStacks.

solar sable
#

so 7smile7 you remember my walk detecting event?

lost matrix
#
    ItemStack breakItem = ...;
    Block block = ...;
    List<ItemStack> drops = block.getDrops(breakItem);
solar sable
#

what i want to do is, instead of sending a message, i want it to give the player the block they are on

#

so if i walk on grass = get grass yk the deal

lost matrix
#
  public ItemStack toDirectItem(final Block block) {
    return new ItemStack(block.getType());
  }
golden turret
#

getdrop?

#

nvm

lost matrix
#

You can not cast an Enum constant to anything else.

echo basalt
#

he probably wants to cast blockdata lmao

lost matrix
#

ItemFrame is not a Block but an Entity

ancient plank
#

😤

lost matrix
#

This doesnt work for any type of Entity. This isnt even valid Java code.

solid cargo
#

how can i remove that annoying unbreaking 1 thing (completely no reference to skyblock, its just an item that i give to my smp players that find exploits)

digital raptor
#

hey i'm trying to build a gradle project but it can't find the spigot.jar?

maiden thicket
#

i dont believe u can remove enchantment lores

lost matrix
maiden thicket
#

oh

#

mvm

#

didnt know that existed

digital raptor
#

I get this error

#
> Could not resolve all files for configuration ':randompackage-spigot:compileClasspath'.
   > Could not find spigot.jar (org.spigotmc:spigot:1.14.4-R0.1-SNAPSHOT).
     Searched in the following locations:
         http://ci.ender.zone/plugin/repository/everything/org/spigotmc/spigot/1.14.4-R0.1-SNAPSHOT/spigot-1.14.4-R0.1-SNAPSHOT.jar
maiden thicket
#

are u trying to use spigot api w nms

#

or spigot api

#

spigots api is the one provided by the maven repository

solid cargo
#

does .strikeLightningEffect give fire

lost matrix
solid cargo
zenith shard
#

hey, I'm using some file systems to delete the world folder and replace it with a different world folder, it copies the files fine, but when I go on the server it still has all the old world, but restarting the server kicks the changes into effect. Is there any way I can make it do it by itself? I use this.plugin.getServer().unloadWorld("world", false); to unload it and Bukkit.createWorld(new WorldCreator("world")); to load it which I'd expect makes it work but it doesnt

regal lake
#

I need some help with the end portal frame, i have to check if the portal frame has a eye or not.
So i tried this: https://paste.md-5.net/qemitusabu.java
But it always says NO, which i don't understand..
It's a end portal frame and i get the block data :/

silk mirage
regal lake
#

Thanks, but i already found the issue..
Quiet silly one... A other event set the block to air.. sooo yea xD

silk mirage
#

_>

tardy delta
#

can a save a list like structure in base64?
like ```yml
test:

  • 1
  • 2
  • 4
#

but i need to access the "test" too

tardy delta
#

well i figured it out

golden turret
#

šŸ¤”

tardy delta
#

only stupid thing is that i cant call static methods from my command class cause player isnt static

vague oracle
#

how is that stupid lol

tardy delta
#

or i place make those methods not static and place them in another class or i make a instance of my command class and call the method :/

#

prob the first

vague oracle
#

why do you need static methods?

#

what are they doing

#

but the first option is better

tardy delta
#

saving and loading lists that my command need

ivory sleet
#

I smell poor design

tardy delta
#

i think you're right

autumn ingot
#

how do you spawn a structure? specifically a stronghold. i want the server to spawn strongholds with every chunk but i can't figure out a simple way to do it

chrome beacon
#

If you want the entire world to be a stronghold you should probably write your own world generator

autumn ingot
#

something like world.spawnStructure

#

is there any method like that

tardy delta
#

this is not really what its supposed to be

ancient plank
#

static brrt

tardy delta
#

also that

proven sedge
#

Hi all, I am trying to create a plugin that uses WorldRegion. I'm setting the plugin up with IntelliJ, but I simply can't seem to avoid including the classes from the WorldRegion jar and shading them so my plugin can't access the other plugin at runtime. Any tips to what might cause this?

quaint mantle
#

any help?

median flint
#

Hey

#

How do I run a set of code if a player left/right clicks a block?

tall dragon
tall dragon
quaint mantle
#

scroll a bit up my previous message

#

sorry my previous previous message

tall dragon
#

Idk i cant go to the message anymore

#

Ah i see. The message still doesnt really explain what coordinates though

ancient plank
median flint
#

What does || mean?

tall dragon
#

Its means Or

#

Bassically

#

U can combine 2 if statement liks so

#

If(check1 || check2)

#

Statement returns true if one of them is true

median flint
#

Thanks man

#

playerinteractevent works perfectly

tall dragon
#

No problem

lusty cipher
#

I'm genuinely surprised I have managed to make my onClick inventory handler crash the server with no exception in the console

median flint
#

congrats

lusty cipher
#

love it

tall dragon
#

Perfection

ancient plank
#

rolled

median flint
#

Hmm

#

How do I make it so that when a special block is clicked a command is run

ancient plank
#

throwback to when my friend crashed the server I used to be a dev on by setting himself as the subject for a /carry command, thus resulting in the attempt of "player#addPassenger(player)" which crashed the server because you can't set an entity as its own passenger. (there's no check on it!)

median flint
#

I dont really want to use coordinates

#

Can I check for NBT tags in getType().

tall dragon
#

Why not use coords 😬

median flint
#

Theres gonna be a lot of the blocks

lusty cipher
#

especially if this is the whole click handler lmao

        ItemStack item = event.getCurrentItem();
        if (item == null) return;
        switch (item.getType()) {
            default:
                closeAndOpen((Player) event.getWhoClicked(), null);
        }
        event.setCancelled(true);
tall dragon
median flint
#

I just dont want to 😩

tall dragon
#

Whats the aplication?

autumn ingot
ancient plank
#

7smile7 likes final

median flint
tall dragon
#

Probably to save on memory

median flint
#

Its just when a block is clicked a player is given an item

tall dragon
autumn ingot
#

like whenever a chunk is created how do you make it just spawn in a stronghold?

golden turret
#

simple question: i have a foreign key and a table that uses that. who sould i delete first? the row that uses the foreign key or the foreign key

tall dragon
ivory sleet
#

I'd say the foreign key first

median flint
tall dragon
#

Alright

#

Well good luck šŸ˜‹

tacit drift
#

feels bad man

median flint
ashen flicker
#

Store location of block somewhere and when they click block at location give item. It’s really not to hard, if you need more features associated to the block, make an object, load blocks on enable, store block object in map. Bing bing bang boom.

median flint
tall dragon
median flint
shadow tide
#

Its always super inefficient to use console commands, so is there a way to display a title to a player, I could just use a message but I like titles

tall dragon
#

but this will not work for all blocks

#

Block and BlockData do not extend PersistentDataHolder

#

only TileState does

#

so if you really wish to to it this way your best bet is to make a custom Metadata System

#

since the solution above will only work on blocks with a TileState. for example a furnace, a chest

median flint
tall dragon
#

šŸ‘

woeful crescent
ashen flicker
#

Think about what your trying to achieve though, like logically. If you want a specific block to do something, you need a way to check this. You can do this based on type or location. That’s really it. Metadata doesn’t save on reboots. An api is really unnecessary for this. I mean this is how crates work, a location, click block at location with crate key in hand. Give random reward.

quaint mantle
#
                Player player = (Player) event.getEntity();
                if(player.isGliding()){
                    BukkitScheduler scheduler = Bukkit.getScheduler();

                    scheduler.runTaskTimer(plugin, () -> {
                        player.setGliding(false);
                    }, 1L * 1L /*<-- the initial delay */, 5L * 1L/*<-- the interval */);

// With BukkitRunnable
                    new BukkitRunnable() {
                        @Override
                        public void run() {
                            player.setGliding(false);
                        }
                    }.runTaskTimer(plugin, 1L * 1L /*<-- the initial delay */, 5L * 1L/*<-- the interval */);
                }
            }```

Hello, how can I make this run 20 times and then stop?
stoic cloud
#

Caching MySQL ResultSet

ashen flicker
#

Just increment an integer and check if integer is 20, then cancel runnable

median flint
#

How would I be able to share a variable across multiple classes?

outer crane
#

Dependency Injection

#

either manually or via guice

old flint
#

can i get answer

outer crane
#

eg:

class ClassWithVariable {
  public ClassWithVariable() {
    int myVar = 69420
  }
}
class ClassWithoutVariable {
  public ClassWithoutVariable(int myVar) {
    System.out.println(myVar)
  }
}
outer crane
#

dont cross post

median flint
#

Thanks mate

#

so could I just use like constructors?

outer crane
#

for example

#

there are libraries like guice:

class ClassWithVariable() {
  public ClassWithVariable() {
    Injector injector = Guice.createInjector(your guice module)
    injector.get(ClassWithoutVariable.class)
  }
}
class ClassWithoutVariable() {
  @Inject
  private int myVar;

  @Inject
  public ClassWithoutVariable(int myVarTwo) {
    /// logic
  }
}
median flint
#

Thanks

#

I dont really understand much though lol

outer crane
#

don't worry

#

server just crasehd lol

outer crane
#

or use some api that doesn't have as much bad practices as bukkit/spigot

#

not a great thing to learn from

stoic cloud
outer crane
#

i lost access to some channels in other servers too

#

maybe server restart?

stoic cloud
#

possibly yeah

median flint
#

Is it actually really hard to do that in java?

outer crane
#

its not

#

just that its clear that you're new and I don't want people new to java to go through learning from bukkit stuff

#

but it is your choice, you do you

echo basalt
#

I'm a bit confused

#

I'm adding client-side lore:

#

And it mostly works fine

#

but not really

median flint
#

But I don't know how else my plugin will work without sending the location to another class

stoic cloud
echo basalt
#

The middle line isn't being added

#

even though literally everything else is

#

The middle line isn't empty or null

#

And it isn't an issue with colorization as I've done tests with colored strings and it works fine

stoic cloud
#

try adding a + "" after it

echo basalt
#

Still doesn't work

outer crane
#

try to use components instead of strings ig?

#

prolly less of a mess

median flint
#

Oskar

#

Can placed blocks have a meta data?

outer crane
#

what kind of metadata

stoic cloud
echo basalt
#

nop

#

doing some other tests, give me a bit

stoic cloud
#

its weird because it's displaying in console as having the rarity there

#

it just doesn't add it to the item

young knoll
#

Have you tried survival mode

echo basalt
#

I'm in survival..

young knoll
#

Hm

stoic cloud
#

can we see your getRarity method?

echo basalt
#

I doubt that getRarity will do much

#

It's legit just a for loop

plain scroll
#

can someone gimmi some basic help- How can i like "get a file" then write in it?

#

so i have a .log file

outer crane
#

Any idea how I'm supposed to get the entity a player might be within attack range of? (take a look at the blue line)

plain scroll
#

and i wanna like "log things" to it

median flint
outer crane
#

i don't think so

#

you can try setting PDC data though

median flint
#

I dont think a skeleton skull has PDC data

outer crane
#

oh

echo basalt
#

it's a tile entity

echo basalt
plain scroll
#

i did

outer crane
#

@median flint iirc Purpur had a patch that keeps stuff like displayname and lore intact after a block has been placed, you might wanna look how that was implemented

#

(purpur is a paper fork)

#

How would I do this?

barren nacelle
#

?learnjava

undone axleBOT
solar sable
#

how to cancel when a player say something in chat?

paper geyser
#

event.setCancelled(true)

#

just cancel it

solar sable
#

ah okay

median flint
#

How do I change the display name of an item/block using metadata?

echo basalt
#

Apparently not colorizing the lore makes it work ??

#

Idfk

#

might be because I have another plugin messing with client-side lore

modest garnet
#

got this error how do i fix?

#

i can share code if necessary

young knoll
#

You are trying to read past the end of a file

modest garnet
torn oyster
#

bump

#

why whenever i do SqlUtil.getConnection().close();
on disable
it has a chance for the plugin not to disable
and i have to kill the server
its so annoying
also the plugin disables before the world saves

#

getConnection() is a Connection

hasty jackal
modest garnet
hasty jackal
#

you're loading the file as a gzip file, so it should already be gzipped

median flint
#

Can a placed block be an ItemStack?

gleaming grove
#

no

median flint
#

oof

gleaming grove
#

placed block is Block

median flint
indigo cave
#

?

gleaming grove
#

create invisible armorstand with nametag in the position of block

indigo cave
#

Use hologram api

median flint
#

It doesnt need to have a hologram

#

Just like when the block is mined it has a different name in your inventory

gleaming grove
#

ahh

mortal hare
outer crane
#

threaded the answer

gleaming grove
#

so you can just change name of Itemstack

median flint
gleaming grove
#

when player get certain item

median flint
#

oh

#

Thanks

modest garnet
young knoll
#

If you want it to be specific blocks you will have to store that data somewhere

median flint
#

@tall dragon You know how you said to use coordinates to check for a block, how would I do that?

hasty jackal
# modest garnet so whats the error im getting?

your code is assuming the file is a gzipped file and I'd be guessing the file that you're loading is not gzip compressed. so either your misusing the gzip stream or the file is not what you expect it to be. which one it is I can't say because I don't know what it's supposed to be.

#

or the file is broken, which could also be true

modest garnet
young knoll
#

You can't readObject on an empty file

next stratus
#

Hey, I have had a brainfart and forgot how to use XMaterial with gradle can anybody advise? šŸ™‚

hasty jackal
#

well empty is no bueno then and you need to handle that before passing it over to the gzip stream

modest garnet
#

the only problem is idk what the hashmap would be to write in the .dat file

hasty jackal
#

well you seem to be writing the data of another plugin, so you'll have to compare with that on what it expects / how it works

shadow tide
#

how do I add a player argument to a command?

modest garnet
tall dragon
hasty jackal
fervent drum
#

is there any bedwars plugin for spigot 1.8.8?

hasty jackal
tacit drift
#

marcely's bedwars

fervent drum
#

ok

#

thanks

median flint
fervent drum
modest garnet
#

and onDisable so it shouldn't matter

shadow tide
#

how do I get all of the online players in a list of strings?

hasty jackal
#

well then just take care of checking if the file is actually there and has content and you're good

hasty jackal
shadow tide
#

yeah, when I learned java I had a lot of trouble with lists

#

soo

#

how?

#

wait

#

would this work? java args[0].equalsIgnoreCase(LifeSteal.getPlugin().getServer().getOnlinePlayers().toString())

young knoll
#

No

hasty jackal
#

that statement makes no sense

shadow tide
#

idk

young knoll
#

If you want to see if a string is a valid online player

#

Use Bukkit.getPlayer and do a null check

tall dragon
median flint
#

could you help me out a bit

#

I really don't know what to do

sharp bough
# median flint could you help me out a bit

"get an instance of the class where the block is then" means do new className() "new" creates a new instance of a class, remember that when you do this you reset the variables in it (unless you specify that you dont want them to reset like static variables etc)

median flint
#

oo

sharp bough
#

creating a new instace of a class when you need to use it multiple times is not a good idea, you can save a variable with the class for example

varName = new className()

varName.data
varName.setData
etc
#

that and

new className.data
new className.setData
etc
#

are the exact same thing

#

but the first one tends to be better in most casses

median flint
#

this is so confusing lol

sharp bough
#

once you understand the structure of java you realize how simple it gets

median flint
sharp bough
#

what?

median flint
#

I already have a class

#

Do I like use a different class name or is it still the same class

sharp bough
#

new className

golden turret
#

qhat is the problem here

sharp bough
#

i dont get the question

median flint
#

same

#

im confusing myself

golden turret
#

say the problem to me

median flint
#

I need to pass a variable from one class to another

eternal oxide
#

?di

undone axleBOT
median flint
golden turret
#

^

median flint
#

oh i'll try that ig

golden turret
#

怊怋

median flint
#

Thanks guys

#

I think I get it now

#

sorry for me being slow af

sharp bough
#

nah you learning

#

it takes time

median flint
#

true

undone aspen
#

Im trying to make a noteblock item with custom block meta already set, im trying this

private ItemStack createItemStack(int note, Instrument instrument){
        ItemStack itemStack = new ItemStack(Material.NOTE_BLOCK);
        BlockStateMeta blockStateMeta = (BlockStateMeta) itemStack.getItemMeta();
        NoteBlock noteBlock = (NoteBlock) blockStateMeta.getBlockState();

        noteBlock.setInstrument(instrument);
        noteBlock.setNote(new Note(note));

        blockStateMeta.setBlockState((BlockState) noteBlock);
        itemStack.setItemMeta(blockStateMeta);

        return itemStack;
    }```

But it says 
`CraftMetaItem cannot be cast to class BlockStateMeta`

What can i do about this?
shut wave
#

hi, i have problems with merchant inventory :(
i created a class extending EntityVillager, and gave it a new MerchantRecipe, but when i righ-click the villager, the inventory disappears

tall dragon
#

that doesn't work

undone aspen
#

how do i get the block meta then?

tall dragon
#

well you would need reference to a placed block in the world

undone aspen
#

but i cant, its an item

#

you can do it with commands

#

/give @s minecraft:note_block{BlockStateTag:{note:9,instrument:bass}}

#

will give you the item, i just want it in a gui with code

shut wave
#

?paste

undone axleBOT
undone aspen
#

and as its possible in vanilla with commands it has to be possible with spigot really

young knoll
#

I don’t think spigot has an API for it

#

But I could be wrong

#

BlockStateMeta is for shulker boxes

tall dragon
#

you might need to edit the nbt

#

but im not quite sure

undone aspen
#

and many other blocks

tall dragon
#

NoteBlock extends Powerable though

#

only Powerable

young knoll
undone aspen
#

then tbh thats kinda shit tbh

median flint
#

lol

undone aspen
#

so how can i do it then? i need to be able to basicaly set the item given by this command /give @s minecraft:note_block{BlockStateTag:{note:9,instrument:bass}} into a gui slot with spigot

shut wave
dull whale
#

how can I create a client entity using protocollib

undone aspen
#

as how can i cast the itemstack to a noteblock

tall dragon
#

@undone aspen just create the blockdata

undone aspen
#

how?

#

and how could i then assign it to the item?

tall dragon
#
ItemStack item = new ItemStack(Material.NOTE_BLOCK);
            ItemMeta itemMeta = item.getItemMeta();
            BlockData data = Material.NOTE_BLOCK.createBlockData();
            NoteBlock noteBlock = (NoteBlock) data;
            noteBlock.setInstrument(/* TODO */);
            noteBlock.setNote(/* TODO */);
            ((BlockDataMeta) itemMeta).setBlockData(noteBlock);
            item.setItemMeta(itemMeta);
#

this should work for you

#

just checked it

undone aspen
#

It does, thank you very much

tall dragon
#

šŸ‘

young knoll
#

So the API does cover it

#

That’s good

tall dragon
#

yep

#

just not very obvious

carmine nacelle
#

Anyone know if theres a way to increase the max level of honey that a beehive can have?

tall dragon
#

not sure thats possible with the api. but i might be wrong

unkempt peak
#

I mean you could create a fake level with a pdc

#

What are you using it for?

sharp bough
eternal oxide
#

Thats almost Java

ornate heart
#

BuildTools keeps installing maven because it says "Maven does not exist. " Any way to fix this? I definitely have maven installed. If I run "mvn" in terminal it works.

paper viper
steady warren
#

I don't know if you're really being serious

paper viper
#

main.getConfig()("Discord")

#

😬

arctic moth
#

how do you make an item that is given to a mob undroppable while still keeping the basic mob drops

#

sorta like the dropChance:0 thing in nbt

#

wait can i just use nbt

young knoll
#

Get the equipment and setXdropChance

#

Exists for the 4 armor slots, and the two hands

arctic moth
#

ok

#

no

#

just the armor and weapons

#

lol

#

wdym

#

u might be able to use the lure thing

#

like hypixel does

#

ye i think thats the lure for the item

#

*lore

#

lol

young knoll
#

You can register custom enchantments to the registry

#

But I believe you still need custom lore to show the text

barren nacelle
#

Does anyone know if I can add nbt when checking for the item in hand Material.FIRE_CHARGE

young knoll
#

Explain?

arctic moth
#

how do you kill in a radius around an something

#

im trying to kill all the items around a dead player

vague oracle
#

player.getNearbyEntities(5, 5, 5, entity -> entity instanceof EntityItem); something like this

arctic moth
#

does the death event happen before they die btw

vague oracle
#

You can cancel drops

arctic moth
#

not doing that

#

wait wdym

young knoll
#

The death event is not cancellable

#

So probably not

arctic moth
#

ik

#

lol

#

im trying to make it kill all of your items when u die

young knoll
#

I think you can just remove all the drops in the death event

vague oracle
#

event.getDrops().clear();

arctic moth
#

thx

torn oyster
torn oyster
#

i can do e.setCancelled() on PlayerDeathEvent

young knoll
#

No you can't

torn oyster
#

huh

young knoll
#

It does not implement cancellable

torn oyster
young knoll
#

Not on spigot anyway

torn oyster
#

paper

#

lol

#
public class EntityDeathEvent extends EntityEvent implements Cancellable {
#
public class PlayerDeathEvent extends EntityDeathEvent {
arctic moth
#

lol i already got it working btw

torn oyster
#

why whenever i do SqlUtil.getConnection().close();
on disable
it has a chance for the plugin not to disable
and i have to kill the server
its so annoying
also the plugin disables before the world saves
getConnection() is a Connection

young knoll
#

Use a connection pool

lost matrix
torn oyster
#

wait

#

i can do that?

#

with hikari normally?

torn oyster
young knoll
#

Close your connections as soon as you are done with them

torn oyster
lost matrix
torn oyster
#

i just make the connection and then use it to make preparedstatements

#

and close it when server closes

young knoll
#

Close the data source in onDisable

#

Close the connection after you do your queries

torn oyster
young knoll
#

You get a new one from the pool when needed

torn oyster
#

so hikaridatasource.getConnection() makes a new one?

young knoll
#

You can even add a flag to make Hikari yell at you if you forget to close them

torn oyster
#

or

barren nacelle
torn oyster
#

setConnection(hikariDataSource.getConnection());?

lost matrix
torn oyster
#

so in every query method, i do
Connection conn = hikariDataSource.createConnectionBuilder().build();

#

right?

lost matrix
#

No

torn oyster
lost matrix
#

You initialise HikariCP once. One single instance. Then later on you get connections using HikariDataSource#getConnection()

torn oyster
#

well i've made the hikaricp once anyway

solar sable
#

guys what is the difference between a Statement lambda and an expression lambda

torn oyster
solar sable
#

because i kinda dont wanna see this warning lol

#

even tho it is a warning i just dont like seeing it lol

young knoll
#

Show the line that causes it

solar sable
#

well its a lot actually but ill just show one

#
if (e.getMessage().toLowerCase(Locale.ROOT).contains("fuck")) {
            e.setCancelled(true);
            Bukkit.getScheduler().runTaskLater(plugin, () -> {
                e.getPlayer().sendMessage(ChatColor.translateAlternateColorCodes('&', "&c&l(!) &bHey, no swearing ") + p.getDisplayName());
            }, 20);
        }
``` context on what i am doing, its just a swear detector lol
lost matrix
solar sable
#

the lambda is the Bukkit.getScheduler().runTaskLater(plugin, () -> {

worldly ingot
#

Yeah, it's suggesting you remove the { } from your lambda

#

because it's just a single line expression

solar sable
#

aah okay

worldly ingot
#

Though tbf, out of a preference of style, I too would use braces here because the line is as long as it is

#

I'd throw it onto a new line in a block like that as well

lost matrix
#

I would shorten the line by a lot and using an expression or create multiple lines withing this statement.
@solar sable

worldly ingot
#

Could make a local var for that entire message tbf

#
String message = ChatColor.translateAlternateColorCodes('&', "&c&l(!) &bHey, no swearing ") + p.getDisplayName()
Bukkit.getScheduler().runTaskLater(plugin, () -> e.getPlayer().sendMessage(message), 20);
#

Really comes down to preference at that point lol

#

Not like an expression is going to be faster than a statement (*in any reasonable way)

young knoll
#

Can't you change that to a method reference

worldly ingot
#

No

lost matrix
#

Wait...

solar sable
#

?javadocs

worldly ingot
#

?jd

solar sable
#

wait whats the command

worldly ingot
#

Close

solar sable
#

oh there it is

#

lol

#

gonna check an event

#

whats the event name for a picking up item by a player?

#

oh nvm i found it

#

EntityPickupItemEvent

lost matrix
# young knoll Can't you change that to a method reference

The scheduler prevents us from just using fields. So this would be the only way i can think of XDD

  @Builder
  private static class FutureMessage {

    private String msg;
    private Player player;

    private void send() {
      this.player.sendMessage(this.msg);
    }

  }

  private final ArrayDeque<FutureMessage> messages = new ArrayDeque<>();

  @EventHandler
  private void onSneak(final PlayerToggleSneakEvent event) {
    this.messages.add(FutureMessage.builder().msg("Hi").player(event.getPlayer()).build());
    Bukkit.getScheduler().runTaskLater(this, this::sendPlayerMessage, 20);
  }

  private void sendPlayerMessage() {
    Optional.ofNullable(this.messages.poll()).ifPresent(FutureMessage::send);
  }
solar sable
#

how to detect when a player pick up something on the ground using EntityPickupItemEvent?

lost matrix
solar sable
#

yes

lost matrix
#
  1. Get the Item entity by calling getItem() on the event.
  2. Then get the ItemStack from this ItemEntity
worldly ingot
torn oyster
#

?paste

undone axleBOT
torn oyster
worldly ingot
#

That's usually caused by the pool being full of open connections. So you're not closing them after you're getting them

torn oyster
#

so do i do

#

Connection.close() after query?

worldly ingot
#

After you've done your necessary operations on the ResultSet, yes

lost matrix
worldly ingot
#

Was just about to suggest that

#

Yeah

#

Beat me to it šŸ˜›

solar sable
#

i did this and idk if its correct

@EventHandler
    public void OnPickup(EntityPickupItemEvent e) {
        Entity player = e.getEntity();
        ItemStack pickup = e.getItem().getItemStack();
        String itemStr = toReadableString(pickup.getType());
        int amount = pickup.getAmount();
        player.sendMessage(ChatColor.translateAlternateColorCodes('&', "&9PickUp Detector > &fYou've picked up &9x%d %s").formatted(amount, itemStr));

    }
young knoll
#

Try it and see

worldly ingot
#

LGTM, but yeah, always best to test it out

solar sable
worldly ingot
#

Also, TIL about String#formatted()

lost matrix
torn oyster
#

i own a dev business