#help-development

1 messages · Page 1356 of 1

jaunty epoch
#

but do not only do that

#

I do python

#

but

paper viper
#

skript is horrible

#

do you know that

#

lmao

jaunty epoch
#

yup

eternal night
#

I mean skript is gonna be slower

#

than visual bukkit xD

paper viper
#

debatable

#

the amount of broilerplate and shit visual bukkit creates

#

when it makes the code

#

not sure if its going to be faster either

#

lol

eternal night
#

lol

deft sedge
#

@jaunty epoch maybe look up ur problem on the interwebz or find a server that's deticated to that sort of stuff

jaunty epoch
#

ok

eternal night
#

oh

#

I

jaunty epoch
#

dm me

eternal night
#

cannot do that

jaunty epoch
#

and send me it

eternal night
#

please no ban me bot

jaunty epoch
#

ty

deft sedge
#

I saw that for one second lol

#

the bot's already mad at me for spam

#

but I don't even spam

#

spam

eternal night
#

lol dude just left

#

xD

daring sierra
#

o7

wicked shale
#

Hello, I am receiving an issue where my listener will not be called for some weird reason. Does anyone perhaps know any suggestions? Here is what my code looks like:

public class Main extends JavaPlugin {

  public static Main instance;
  public static HashSet<Player> players = new HashSet<Players>();

  @Override
  public void onLoad() {
    instance = this;
    Bukkit.getServer().getPluginManager().registerEvents(new MyListener(), this);
  } 

  public static Main getInstance() {
    return instance;
  }

}

public class MyListener implements Listener {
   
  public static void onWalkEvent(PlayerMoveEvent event) {
     Main.players.add(Bukkit.getPlayer(event.getPlayer().getUniqueUuid()));
     event.getPlayer().sendMessage(ChatColor.GOLD + "You have walked!");
     event.getPlayer().sendMessage("test");
  }

}
#

I am new to Java

eternal night
#

Your listener methods cannot be static

#

They also should be annotated with @EventHandler

wicked shale
#

Oh

#
public class Main extends JavaPlugin {

  public static Main instance;
  public static HashSet<Player> players = new HashSet<Players>();

  @Override
  public void onLoad() {
    instance = this;
    Bukkit.getServer().getPluginManager().registerEvents(new MyListener(), this);
  } 

  public static Main getInstance() {
    return instance;
  }

}

public class MyListener implements Listener {
   
  @EventHandler
  public void onWalkEvent(PlayerMoveEvent event) {
     Main.players.add(Bukkit.getPlayer(event.getPlayer().getUniqueUuid()));
     event.getPlayer().sendMessage(ChatColor.GOLD + "You have walked!");
     event.getPlayer().sendMessage("test");
  }

}
#

like this?

eternal night
#

Looks better yes

wicked shale
#

alright I will give it a shot

eternal night
#

Tho Bukkit.getPlayer(event.getPlayer(). get UniqueId()) seems just. Like. Why XD

wicked shale
#

Oh

eternal night
#

Like event.getPlayer already returns the player

wicked shale
#

I see

#

so unecessary tight coupling

#

right

#

Yeah it seems to work

#

But wait

#

why do people say not to use static?

#

some other people in other discord told me that

eternal night
#

I mean for the listener method you just straight up can't

#

Spigot won't allow it

wicked shale
#

for set

quaint mantle
#

What's a good redis library to use for a plugin?

eternal oxide
#

you are overriding an existing method in the Listener so your method footprint must match

eternal oxide
#

Static is fine when used correctly.

wicked shale
eternal night
#

This is not an overwrite

quaint mantle
#

Lord have mercy 👴 🤏 👓

#

the static

wicked shale
#

he seems like a good coder

eternal night
#

Kekw

#

Okay then

eternal oxide
#

@eternal night all plugin implementations of listener are overiding the Listeners method.

eternal night
#

No. Open the listener interface

#

Find me those methods

#

That are overwritten

#

Please

quaint mantle
#

stick my dick in her mouth, I call that oral sex. say memes out loud, I call that oral keks

eternal night
#

Switching accounts like a true hero eh XD

paper viper
#

alright im going to come out clean

eternal oxide
#

Oh I see what you are saying, they are annotated not overridden

eternal night
#

Yes

paper viper
#

I wanted to pretend to be a beginner

#

and make shitty code

eternal night
#

So you wasted my time

paper viper
#

and see how ppl would react

#

lmao

eternal night
#

Sweet

#

I really enjoyed it

paper viper
#

Its okay! I know you are a good programmer now

#

lol

eternal night
#

Ah.

#

But yeah. Elgar the listener class is traversed using java reflections to find all methods annotated with Eventhandler

#

So it isn't really overwriting

#

More like, following a schema.

eternal oxide
#

Yep

eternal night
#

Hence why static doesn't work, because static methods are not considered in that traversal

deft sedge
#

is there a way for me to get a function to return two different types of variables

eternal oxide
#

yes

deft sedge
#

How?

eternal oxide
#

create a return type object that holds two

deft sedge
#

ok

cinder thistle
#

What points should be considered in the MySQL vs Mongo argument? I wanna know why we don’t just all use mongo (although sql is older and therefore has more users and people comfortable with it)

deft sedge
#

but what do i set the public thingy to

cinder thistle
#

I guess also all data is maintained via the same commands

deft sedge
#

I want to return an item meta

eternal oxide
#

then set the return as public ItemMeta

deft sedge
#

ok

#

waht about the static

#

some people use public static, whyat does that mean?

eternal oxide
#

static is really for utility methods

deft sedge
#

k

eternal oxide
#

I should say, mostly for

#

a static method or field only ever has one instance

deft sedge
#

it's mad a tme

eternal oxide
#

you need a method name

deft sedge
#

ohh

#

nvm i forgot

#

i remebmer now

#

thx

eternal oxide
#

public ItemMeta methodName() {}

deft sedge
#

k

#

What changes do I have to make to this, i'm trying to check the players inventory for the specifc material that is given

#

I found this code on bukkit forms so it's probably wrong

#

@eternal oxide

#

or anyone else

eternal oxide
#

if you just want to see if a material exists inv.contains(Material)

#

to see if a certain amount exists inv.contains(Material, amount)

deft sedge
#

well I want to get the meta of that certain material, but I think i figured this one out

#

thanks!

#

i am trying to make a function bc this will probably happen a lot

#

my goal for what i'm doing now is to remove certain item from the invenotry

#

so i think if i can get the meta of that item, i can then remove it

eternal oxide
#

ItemStacks have meta not Material

deft sedge
#

oh

#

my goal is to be able to do stuff with things I find in their invenotry. Like for example, If I find a book I wanna add a page to said book

#

how would I do that?

eternal oxide
#

if you just want to remove if found use the contains method to make sure it exists, then use inv.remove(Material)

deft sedge
#

ok

eternal oxide
#

all the methods available for Inventories are in those javadocs

deft sedge
#

ok thanks

sullen dome
#
    @EventHandler
    public void onLogin(AsyncPlayerPreLoginEvent event) {
        if (config.contains("verify." + event.getUniqueId())) {
            return;
        }
        String code = ThreadLocalRandom.current().nextInt(100000, 999999) + "";
        idCode.put(event.getUniqueId(), code);
        codeID.put(code, event.getUniqueId());
        codes.add(code);

ideas why the last line codes.add(code); doesnt't add anything?

eternal night
#

How is the Set/List initialized ?

#

Where are you checking the list later on

sullen dome
#

private List<String> codes = new ArrayList<>();

#

in a JDA-Event

#
 if (!codes.contains(code)) {
            channel.sendMessage("Dieser Code existiert nicht. Bitte versuche es erneut oder kontaktiere einen Admin.").queue(); // code doesn't exist.
            System.out.println(codes);
            return;
        }```

it just prints out ```[]```
eternal night
#

They use the exact same instance of your listener I suppose ?

sullen dome
#

idk

eternal night
#

Creating an instance of this class twice would explain the issue

#

How do you not know lol XD

sullen dome
#

maybe i am? :o

builder.addEventListeners(new ConsoleLogListener(), new VerificationManager());
        Bukkit.getPluginManager().registerEvents(new VerificationManager(), this);```
#

is that the reason why?

eternal night
#

Yeah no you are using two different instances

#

Yes

#

Your listener instance of the class is mutating the list it owns

sullen dome
#

ah nvm

eternal night
#

While your jda instance is just vibing with an empty list

sullen dome
#
 VerificationManager vfManager = new VerificationManager();
        builder.addEventListeners(new ConsoleLogListener(), vfManager);
        Bukkit.getPluginManager().registerEvents(vfManager, this);```

so i guess, this fixes it?
eternal night
#

I mean.

#

Give it a whirl

#

Test it out

sullen dome
#

wow that actually worked. thanks!

#

leaked my uuid 😕

eternal night
#

No problem XD it's a very common mistake when not using static for once

sullen dome
#

i am still a bit stuck at static abuse tho... but outside of that, i guess i am pretty good at stuff now after like 14 months

eternal night
#

Nice 💪💪

sullen dome
#

yoinked discordSRV xd

#

oh god

#

leaking my uuid is different from leaking my ip

young knoll
#

You mean 127.0.0.0

sullen dome
#

was it that?

#

lol

#

isnt that showing the ipv4 normally?

#

or not at localhosts

limber dust
#

127.0.0.1 is just localhost XD

sullen dome
#

yeah ik

#

but usually it shows the real ip... and i just saw an ip and paniced lol

deft sedge
#

How do I make it so that the player can't loose or gain hunger bars unless I set them

deft sedge
#

thx

#

but is there a simple way for me to make it so that they can't loose hunger

#

other than peaceful mode

eternal oxide
#

schedule a repeating task that sets the players saturation every 20 ticks

deft sedge
#

Wil this work?

lunar moat
#

probably

deft sedge
#

k thix

eternal oxide
#

that will only stop them losing health, not hunger

lunar moat
#

are you sure?

#

Called when a human entity's food level changes

eternal oxide
#

um, you are correct. I'm just tired

deft sedge
#

so what did I do wrong is the question

young knoll
#

Registered?

deft sedge
#

I have to register?

#

how do I do that

deft sedge
#

do i do that in main

#

srry i'm new to this

young knoll
#

Usually in your onEnable, yes

ebon birch
#

is it possible to grab a permission in prelogin?

deft sedge
#

k

#

so i do voidregester event?

young knoll
#

no?

deft sedge
#

like that

young knoll
#

no?

#

I sent you the Javadocs

lunar moat
#

getServer().getPluginManager().registerEvents(new StopHungerLoss(), this);

deft sedge
#

k thx

young knoll
#

Spoonfeed

lunar moat
#

btw StopHungerLoss class needs to implement Listener

deft sedge
#

k thx again

lunar moat
#

idk if that helps

ebon birch
#

kinda, i guess i could kick after they login

#

i just wanted to kick during the prelogin login process instead of after

lunar moat
ebon birch
#

i meant during prelogin sorry lol

lunar moat
#

when the player joins the server the PlayerJoinEvent is fired

deft sedge
#

@lunar moat Thanks It works!

ebon birch
#
@EventHandler
    public void onPlayerLogin(PlayerLoginEvent e) {
        Player p = e.getPlayer();
        
        if (!p.hasPermission("luna.join")) {
            p.kickPlayer("Not Allow lmao");
        }
    }

something like this?

lunar moat
#

yeah I think so

young knoll
carmine urchin
#

Usually when entering a portal, the portal searches for an area to create the portal. If it cannot find a safe space it creates the portal with four extra obsidian blocks at the bottom. Not sure if anyone has heard of this but it usually happens when you enter in ocean. When setting a portal location to a different world with e.setTo, (PlayerPortalEvent), and when in my case the portal cannot find a safe spot, it sets the location of the portal at y 246. Anyone know how I could make the y level for the portal the same as vanilla? (Nvrmind I fixed this with location.setY(50)

ebon birch
#

what am i doing wrong?

#
public final class BetaLogin extends JavaPlugin implements Listener {

    @Override
    public void onEnable() {
        getServer().getPluginManager().registerEvents(this, this);
        getServer().getConsoleSender().sendMessage(ChatColor.YELLOW + "BetaLogin Plugin Successfully Enabled");
    }

    @Override
    public void onDisable() {

        getServer().getConsoleSender().sendMessage(ChatColor.YELLOW + "BetaLogin Plugin Successfully Disabled");
    }

    @EventHandler
    public void onPlayerLogin(PlayerLoginEvent e) {
        Player p = e.getPlayer();

        if (!p.hasPermission("luna.join")) {
            p.kickPlayer("Not Allow lmao");
        }
    }

}
limber dust
#

don't just ask what you're doing wrong

#

explain your issue

ebon birch
#

its not kicking me when i join even though i dont have the permission

young knoll
#

Are you op

ebon birch
#

nope

cinder thistle
#

It might be that you’re listening too early in the login process

ebon birch
#

should i try at the playerJoinEvent?

cinder thistle
#

Because at that time, many things might not have loaded yet. This would likely include kicking because it would reply on you being fully connected

#

Yeah give it a shot

#

But it might run when you switch worlds idk

young knoll
#

Don't kick them

#

use event.disallow

ebon birch
#

am i able to then send a kick/error message?

ebon birch
cinder thistle
#

Uhh

#

Try using a bukkitrunnable

left dagger
#

Hey ive got a basic problem i think if anyone can give me any advice

cinder thistle
#

Delay it by a few ticks

ebon birch
#

im going to try the cancellation of event

cinder thistle
#

?ask

young knoll
#

Or you know, the disallow method in the login event

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.

young knoll
#

Like I said

cinder thistle
#

Oh shit didn’t know about that

#

That’s cool

#

Imma use that

tight coyote
#

what

#

lmao

young knoll
#

This is why you check Javadocs

vale zealot
#

hey I literally just started trying to make a plugin for 1.8.9. I don't understand any of the @s or the different text files. does anyone have any tips to get started?

young knoll
#

@s? text files? what

#

Also we don't really support 1.8

tight coyote
#

Annotations and yamls

#

I'm guessing

cinder thistle
#

Update mc

#

Then I’ll help you

vale zealot
#

sorry if I sound crazy, I literally just started and have no idea how anything works.

#

Im talking about the things like @Override, etc

tight coyote
#

so annotations

vale zealot
#

yes

young knoll
#

Override is a normal java annotation, you should learn the basis first

tight coyote
#

Exactly what I was going to say

#

or basically..

vale zealot
#

I guess what I'm trying to ask is where do I start

lunar moat
#

learn core java first

#

the language features, object orientation

tight coyote
#

I love OOP...

young knoll
#

There are hundreds of free tutorials for Java online, you should take a look there

vale zealot
#

Ok thank you guys!

#

I was trying to tackle the entire plugin thing first but I need to learn Java in order to begin. Thanks for the help, will do!

ebon birch
#

it works! thanks!

mystic lion
#

And tell me what I can improve, to improve my java knowledge

lunar moat
#

well, you don't need the addEnchantmentLevels method

#

because you can simply use setEnchantmentLevel(getEnchamentLevel() + how many levels you want to add)

mystic lion
#

Well... what if I'm wanting to have that method for the sake of the code looking shorter/cleaner

lunar moat
#

yeah if you are repeating code it is not looking cleaner

mystic lion
#

I meant in other classes

lunar moat
#

it is basically the same method

mystic lion
#
        setEnchantmentLevels(name, getEnchantmentLevel(name) + level);
        //applyItem();
    }```
#

How about that?

#

Better?

lunar moat
#

yes

mystic lion
#

anything else?

lunar moat
#

the same thing applies to the removeEnchantmentLevels method

mystic lion
#

Already done

#

: )

lunar moat
#

but other than that your code looks fine imo

mystic lion
#

Aight

ebon birch
#

i just realized that the plugin needed to be for bungeecord...

#

not bukkit

mystic lion
#

lmao

ebon birch
#

how do i get permission information from bungee lmao

deft sedge
#

I am trying to scan player inventory for a spicific item which is targetI Then I want to get the info of that item in the inventory. End goal is to check if there's a book and then get the meta and other stuff avbout the book. The code is mad at me for this

#

Any Ideas?

young knoll
#

I is an integer

#

You want an Itemstack

#

I recommend you refresh yourself on java

deft sedge
#

I know that it's an integer. god i'm bad at wording questions, I kind of meant what do I need to change to check all of the slots You don't have to answer, I know you've been helping a lot

#

All the stuff I can find on what I want to do is outdated

young knoll
#

With your current loop you’ll need to get the item from getContents at that index

#

Or you can switch to an enhanced for loop and compare them directly

#

Also the basics of what you want to do aren’t outdated

deft sedge
#

ik but all questions on it are

#

Can I have a link to or an example of an enhaced loop

#

?

#

if u don't want to, just say so ik i've been asking A LOT today

deft sedge
#

thanks

#

I do this but it is mad at me. I'm sure i'm doing something wrong @young knoll

young knoll
#

You access array elements with []

deft sedge
#

so .get contents [i]

#

but i tried that and it didn't work

#

@young knoll

#

i'm definently not picking up on something obvious

quaint mantle
#

ItemStack diamond = new ItemStack(Material.DIAMOND);

deft sedge
#

yea ik

#

i have material stored as a varialbe

limber dust
#

for(ItemStack item : player.getInventory.getContents()){
}

deft sedge
#

ok

young knoll
#

Probably best to avoid the stream

#

They aren’t exactly the fastest

limber dust
#

i know

#

just he wasn't getting anywhere

deft sedge
#

thanks

limber dust
#

not in a bad way

deft sedge
#

is there an easy faster one then stream?

limber dust
#

sorry

#

changed it

deft sedge
#

no not like that lol

#

i'm a noob

limber dust
#

use asList

deft sedge
#

thx for the help

#

ok thx

#

so they both do the same thing

#

but the for loop is simpler right?

limber dust
#

either one will do what you want

deft sedge
#

ok

#

thanks

young knoll
limber dust
#

ye

deft sedge
#

yea i'm gonna do that

limber dust
#

that way each time it loops you get a instance directly from the loop

deft sedge
#

Do I have to put targetI somewhere else? it's not detecting it (TargetI is the item that I want to look for)

limber dust
#
        for(ItemStack item : player.getInventory().getContents()){
            //code here
        }``` you don't need the current part
deft sedge
#

k

limber dust
#

since you already have the ItemStack

#

eg

#
        for(ItemStack item : player.getInventory().getContents()){
            //code here
            item.setType(Material.DIRT);
        }```
deft sedge
#

How do i know if the item i'm looking for is what it found

#

sorry i'm being really slow

#

I only want it to trigger if it finds the item i want it to find

young knoll
#

Compare the type

#

Or use isSimilar

deft sedge
#

ok so in for loop ill do item.isSimmilar(TargetI)

limber dust
#

if you want to stop the loop when it finds the target

#

just do if(isSimilar()){
return;
}

deft sedge
#

yea

#

ok

#

thanks

young knoll
#

Return will return the entire method

#

Use break if you don’t want that

deft sedge
#

ok thanks

limber dust
#

thats right XD

#

my bad

deft sedge
#

I want to get the variable invitemmeta out of this for loop. I tried delcaring it up above, and that didn't work

limber dust
#

you don't need the second ItemMeta

young knoll
#

You are trying to declare it again

#

I strongly suggest you get a good grasp on java basics before working with the API

limber dust
#

^

deft sedge
#

K so like that?

#

and i'll look into that tmr

#

it's late

#

ok nvm

#

i got it

#

thanks ya'll

young knoll
#

That if statement isn’t in use

deft sedge
#

ik

#

i'm putting it into use rn lol

quaint mantle
#

since it implements Iterable u can just do for (ItemStack itemStack : player.getInventory())

quaint mantle
#

What is the best way to serialize a BannerMeta (CraftMetaBanner) for storing in Redis? Bonus points if I can actually deserialize it

#

theres a serialize method that'll convert it to a <String, Object> map

#

to unserialize it, look at the constructor in CraftMetaBanner that takes a Map<String, Object> as the argument

#

Couldn't be bothered, I'm using Apache SerializationUtils.serialize and base64

outer sorrel
#

how could i make it so spigot plugin outputs a message to online players in other servers connected with bungeecord?

maiden briar
#

I want to update that outdated project

weary geyser
#

do you know java?

vagrant pier
#

What mappings does bukkit/spigot use?

heavy mason
abstract spindle
#

Hey Guys,
maybe some of you can Help me with my Problem. My Problem is, when the InventoryClickEvent is called and I am in my custom Inventory he doesn't cancel the event when the Item is not an specif Item.

else if (event.getWhoClicked().getOpenInventory().getTitle().equalsIgnoreCase("Your Documents") && event.getInventory().getSize() == 18) {
            if (event.getClickedInventory() == null) {
                return;
            }
            if (event.getClick().equals(ClickType.NUMBER_KEY)) {
                if (event.getHotbarButton() != -1) {
                    event.setCancelled(!isDocument(event.getCurrentItem()) && !isDocument(event.getCursor()));
                }
            }else {
                event.setCancelled(!isDocument(event.getCurrentItem()) && !isDocument(event.getCursor()));
            }

private boolean isDocument(ItemStack item) {
        try {
            if (item.getType().equals(Material.AIR) || item.getType().equals(Material.WRITABLE_BOOK) || item.getType().equals(Material.WRITTEN_BOOK) || (item.getType().equals(Material.PAPER) && item.hasItemMeta() && !item.getItemMeta().hasCustomModelData())) {
                return true;
            }
        } catch (NullPointerException ignored) {
        }
        return false;
    }
heavy mason
#

event.getClick() == ClickType.NUMBER_KEY - Enums can be compared with ==

#

Try that @abstract spindle

abstract spindle
#

okay I will try

lost matrix
# abstract spindle okay I will try
        } catch (NullPointerException ignored) {
        }

This is the stuff that leads to problems which will lead to days of search.
NEVER ignore a NPE like that. Handle your exceptions properly.
When you have a null pointer then look into your code and see where you messed up.
This is the equivalent of putting ear buds in when the fire alarm goes of...

#

and equals vs == doesnt matter when using enums. Internally its just == anyways.

heavy mason
#

Tbh instead of using a try catch I'd just check if the item is null

abstract spindle
heavy mason
#

Correct me if I'm wrong butI believe it avoids it entirely

lost matrix
#

It is really important that you create variables here. You need to stop stacking methods. You should not just ignore the character limit.
Your code should be thin enough that you can read it on a small 4:3 screen.

lost matrix
#

?paste

queen dragonBOT
heavy mason
#

Ah yes switch-ify if statements

lost matrix
# abstract spindle https://paste.md-5.net/zetuseroba.cs

This is exactly your code just a bit refactored:

  @EventHandler
  public void onClick(final InventoryClickEvent event) {
    Player player = (Player) event.getWhoClicked();
    Inventory openInv = event.getInventory();
    InventoryView openView = event.getView();
    String viewName = openView.getTitle();

    if (event.getClickedInventory() == null) {
      return;
    }

    if (viewName.equalsIgnoreCase("Your Documents") && openInv.getSize() == 18) {
      event.setCancelled(!this.isDocument(event.getCurrentItem()) && !this.isDocument(event.getCursor()));
    }
  }

  private boolean isDocument(ItemStack item) {
    return item != null;
  }
lost matrix
#

Just used exactly that code and it worked without any problems.

#

Instead of serializing the GameMap try just adding a random String...

#

idk. I think 15?

#

Yes 15

#

That should not be the problem

#

It cant be

shy wolf
#

hi guys!,
i need help!:
how can i give my horse saddle or something like that

#

here is my code:

                    ItemStack sadel = new ItemStack(Material.SADDLE); // server sel
                    Entity horse = Bukkit.getWorld("TrestiaMap").spawnEntity(new Location(Bukkit.getWorld("TrestiaMap"), 229, 44, -340), HORSE);
                    horse.setCustomName(ChatColor.GREEN + "sosy 1 test 5566784sd AS DIM");
                    horse.setGlowing(true);
                    horse.setRotation(451, 16);
                    ((Tameable) horse).setOwner(p);
                    ```
fading lake
#

Horse#getInventory#setSaddle

shy wolf
#

uh?

#

i am using 1.16.4

fading lake
#

horse.getInventory().setSaddle(sadel)

shy wolf
#

just saying

fading lake
#

cast horse to Horse not Entity

shy wolf
#

ItemStack sadel = new ItemStack(Material.SADDLE);

#

oops

#

Entity Horse = Bukkit.getWorld("TrestiaMap").spawnEntity(new Location(Bukkit.getWorld("TrestiaMap"), 229, 44, -340), HORSE);

fading lake
#

no

#

Horse horse = (Horse) Bukkit.getWorld.... etc

shy wolf
#

Horse horse = (Horse) Bukkit.getWorld("TrestiaMap").spawnEntity(new Location(Bukkit.getWorld("TrestiaMap"), 229, 44, -340), HORSE);

#

like that?

fading lake
#

yes

shy wolf
#

well more errors

                    ItemStack sadel = new ItemStack(Material.SADDLE); // server sel
                    Horse horse = (Horse) Bukkit.getWorld("TrestiaMap").spawnEntity(new Location(Bukkit.getWorld("TrestiaMap"), 229, 44, -340), HORSE);
                    horse.setCustomName(ChatColor.GREEN + "sosy 1 test 5566784sd AS DIM");
                    horse.setGlowing(true);
                    horse.setRotation(451, 16);
                    ((Tameable) horse).setOwner(p);
                    horse.getInventory().setSaddle(sadel);```
fading lake
#

try

Player p = (Player) sender;
                    ItemStack sadel = new ItemStack(Material.SADDLE); // server sel
                    Entity horse = Bukkit.getWorld("TrestiaMap").spawnEntity(new Location(Bukkit.getWorld("TrestiaMap"), 229, 44, -340), HORSE);
                    horse.setCustomName(ChatColor.GREEN + "sosy 1 test 5566784sd AS DIM");
                    horse.setGlowing(true);
                    horse.setRotation(451, 16);
                    ((Tameable) horse).setOwner(p);
                    ((Horse) horse).getInventory().setSaddle(sadel);
shy wolf
fading lake
#

whats the error

shy wolf
#

Inconvertible types; cannot cast 'org.bukkit.entity.Entity' to 'me.fsih.horse.horse.Horse'

fading lake
#

youre casting it to the wrong thing

#

replace Horse with org.bukkit.entity.Horse

#

((org.bukkit.entity.Horse) horse).getInventory().setSaddle(sadel);

shy wolf
#

ok no error so far let me test it

heavy mason
#

!tryandsee

#

whats the command

#

?tryit

ancient plank
quaint mantle
#

My class doesnt seem to get registered by the main class and I dont know why, this is the error.

hollow sand
#

Hello, I'm trying to make a Hypixel uhc plugin, but I keep getting this error and idrk how to fix it. Any help would be apprecieated

eternal oxide
#

@quaint mantle Caused by: java.lang.ClassCastException: java.util.Collections$UnmodifiableRandomAccessList cannot be cast to org.bukkit.entity.Player

#

PlayerJoin.java:18

quaint mantle
#

Yeaaaaah, tought I would get that one wrong

#

Player playersoundlist = (Player) Bukkit.getServer().getOnlinePlayers();
playersoundlist.playSound(p.getLocation(), Sound.ITEM_CHORUS_FRUIT_TELEPORT, 1f, 1f);

#

So what I did here was trying to make a list of online players to play a sound when a player joins

young knoll
#

You need to iterate over each player

quaint mantle
#

How do I do that?

#

Create an ArrayList?

hollow sand
# hollow sand Hello, I'm trying to make a Hypixel uhc plugin, but I keep getting this error an...

code

public class SwordListener implements Listener {

        private UHC_Items plugin;

        public SwordListener(UHC_Items plugin) {
            this.plugin = plugin;
        }

        public void a(Player player) {
            Bukkit.getScheduler().scheduleSyncDelayedTask(UHC_Items.getPlugin(UHC_Items.class)), new Runnable() {
            @Override
            public void run() {}};
            for (int i = 0; i < player.getInventory().getSize(); ++i) {
                ItemStack a = player.getInventory().getItem(i);
                if (a == null) continue;
                if (!a.hasItemMeta()) continue;
                if (a == a) {
                    ItemMeta b = a.getItemMeta();
                    b.addEnchant(Enchantment.DAMAGE_ALL, 1, false);
                    a.setItemMeta(b);

                }
            }
        }```
eternal oxide
#

getOnlinePlayers() returns an array

ivory sleet
#

You tryna schedule a delayed task?

hollow sand
ivory sleet
#

Idk why everyone keeps using scheduleSyncDelayedTask etc

#

Like the name is implausibly long

#

Use runTaskLater

hollow sand
#

¯_(ツ)_/¯

#

tried

#

doesnt work

ivory sleet
#

It also returns a more useful object

sour rampart
#

public void teleport() {
Bukkit.getScheduler().runTaskLater(Main.getPlugin(), new Runnable() {
List<Player> Players = new ArrayList<>(Bukkit.getOnlinePlayers());
public void run() {
for (int i = 0; i < Players.size(); i++) {
teleportplayer(Players.get(i));
}
teleport();
difficulty --;

        };        
    }, 6000L);
    
}

For some reason, this code is not being called after 5min. Am I doing something wrong?

ivory sleet
#

No

#

Pebkac

hollow sand
#

wait

ivory sleet
#

Anyways if you wanna schedule a delayed task you’d do this

Bukkit.getScheduler().runTaskLater(plugin, () -> {
  //code that runs later
}, delayInTicks);```
hollow sand
#
class SwordListener implements Listener{

private final UHC_Items plugin;

public SwordListener(UHC_Items plugin) {

this.plugin = plugin;
this.plugin.getServer().getPluginManager().registerEvents(this, plugin);
}

@EventHandler
public void onTick() {
Bukkit task = new (task)(this.plugin).runTaskLater(this.plugin 12000);


}```
#

something like this?

ivory sleet
#

Jesus

sour rampart
#

thx

ivory sleet
#

Ofc that won’t work

eternal oxide
#

@quaint mantle java Bukkit.getOnlinePlayers().forEach( player -> player.playSound(player.getLocation(), Sound.ITEM_CHORUS_FRUIT_TELEPORT, 1f, 1f) );

ivory sleet
#

It looks like you’re at the verge of knowing java

#

But anyways

hollow sand
ivory sleet
#

Let me give you a spoon

quaint mantle
#

Is there any way around this cancer?

    public static BannerMeta getMeta(String key, String field) {
        String configSerialized = jedis.hget(key, field);
        YamlConfiguration config = new YamlConfiguration();
        try {
            config.loadFromString(configSerialized);
        } catch (InvalidConfigurationException e) {
            return null;
        }
        return (BannerMeta) config.get("meta");
    }
    
    public static void setMeta(String key, String field, BannerMeta meta) {
        YamlConfiguration config = new YamlConfiguration();
        config.set("meta", meta);
        jedis.hset(key, field, config.saveToString());
    }
ivory sleet
#
void method() {
  BukkitTask task = Bukkit.getScheduler().runTaskLater(this.plugin, () -> {
    //code to execute later
  },12_000L);
}```
#

@hollow sand

hollow sand
#

ah

#

i see

#

and the // is where the code goes, correct>

#

?

ivory sleet
ivory sleet
hollow sand
#

thank you sir

#

o/

sour rampart
#

thx ill try that 🙂

quaint mantle
ivory sleet
#

Lol why do you load and save as/to string?

quaint mantle
#

Redis

#

I mean it works

ivory sleet
#

You put the entire config in your redis cache?

quaint mantle
#

Just the config representing the banner metadata

#

The rest is normal redis stuff

cinder thistle
#

There's got to be a better way to do this, right? I'm thinking DI might be beneficial. If it's the best way to go, then I'll switch from an interface to an abstract class.

quaint mantle
#

I'm using YamlConfiguration.saveAsString() because it looks like the easiest way of serializing a bukkit object to put in redis

ivory sleet
#

Oh well, I’d use Gson for serialization but that looks fine jolly?

lost matrix
ivory sleet
#

Creepercry hmm yeah dependency injection might be a good way to loosely couple your code

cinder thistle
#

Yeah what I was previously doing was having a single static instance that I can retrieve and do stuff that way but DI seems better

quaint mantle
#

Is this code correct?
player.teleport(0, 67, 18, builderspawn);

cinder thistle
#

try it and see

#

and no

ivory sleet
#

You need to wrap that into a location object

cinder thistle
#

world, x, y, z iirc

quaint mantle
#

Yea I tought it wasnt

cinder thistle
#

yeah that

quaint mantle
#

iirc??

eternal oxide
#

is builderspawn already a location?

quaint mantle
#

yes

cinder thistle
#

if I recall correctly

quaint mantle
#

World builderspawn = Bukkit.getWorld("builderspawn");

cinder thistle
#

that's not a location

#

that's a world

#

locations are points in a world

lost matrix
#

Player#teleport(Location)

eternal oxide
#

try Location builderspawn = Bukkit.getWorld("builderspawn").getSpawnLocation();

quaint mantle
#

k

#

Location builderspawn = Bukkit.getWorld("builderspawn").getSpawnLocation();
p.teleport(builderspawn);

#

Should be correct now

#

since there already is getSpawnLocation, I dont need to put coordinates

eternal oxide
#

So long as you have a world called builderspawn

lost matrix
quaint mantle
#

Thx for help.

sour rampart
cinder thistle
#

use code blocks

#

or

#

?paste

queen dragonBOT
eternal oxide
#

please use code blocks or paste site

mystic lion
#

Do you even call the method "teleport()" in any of your classes

sour rampart
ivory sleet
#

Looks like recursion abuse

quaint mantle
cinder thistle
#

okay why tf

#

are you wrapping Bukkit#getOnlinePlayers

#

and why are we not using

for (Player player : Bukkit.getOnlinePlayers()) {}
sour rampart
cinder thistle
#

please camelCase your variable names, not PascalCase as well

young knoll
#

Also why are you repeatedly scheduling delayed tasks instead of using a repeating one

eternal oxide
#

you have a 5 minute delay on that task, and it calls itself

quaint mantle
#

I want to check if a player is in a certain world, am I doing it correctly?

if(player.getWorld().equals("builderspawn")){

    }
young knoll
#

No

#

You need a getName

quaint mantle
#

ty

#

if(player.getWorld().getName().equalsIgnoreCase("builderspawn"))

#

I guess its correct now

#

Is there like an event for building or destroying blocks and stuff?

carmine ivy
#

Is it possible to run mods + plugins with a fabric server

quaint mantle
#

is it the same as BlockPlace event?

quaint mantle
#

ty

carmine ivy
#

No problem

quaint mantle
#

Less goo

limber dust
carmine ivy
#

rip

quaint mantle
limber dust
#

as i said, only forge and plugins, magma has yet to add fabric support

quaint mantle
#

There isnt getworld for BlockPlaceEvent?

limber dust
#

get the player

#

then world

quaint mantle
#

k

#

ty

#

Oh this is cool, I'm learning without watching any tutorials

#

well you should do that

#

Probably

#

or read documentation

#

Altough, as long as I learn and progress, I think I'm fine.

limber dust
#

tutorials are good so you know what things do without needing to ask here

quaint mantle
#

After this plugin I really should get back to those tutorials, it seemed like a good idea to really use the stuff I learned before moving on with another knowledge

limber dust
#

eg, tutorials go over the basics like events, what they do how to register them

#

it saves time asking here

#

not telling you to watch them

#

just saying in general

quaint mantle
#

Yea I already did that a while ago but u need to USE them before learning other stuff

lost matrix
#

Maybe its the main world that you have in your server.properties

quaint mantle
#

Nah I found out they still are in MultiWorld config

#

So the server creates them on startup

#

Anyways, do you guys obfuscate your plugins?

eternal oxide
#

no

limber dust
#

lol

quaint mantle
#

Cant the source code be revealed then?

limber dust
#

wait why do you wanna ob?

eternal oxide
#

The only real point in obfuscation is to protect intellectual property

quaint mantle
#

I dont, but I seem interested in how it works

eternal oxide
#

it can still be decompiled and read

limber dust
#

just makes it slightly more annoying

lost matrix
#

And reading stack traces costs you 10 times as much time

quaint mantle
#

Sheit so it just makes the plugin like 10 times slower

eternal oxide
#

But for a commercial product obfuscation is enough to say you made an attempt to protect your property when it comes to court cases

cinder thistle
quaint mantle
#

So u think obfuscation is useless as long as the plugin isnt commercial

eternal oxide
#

totally

limber dust
#

if anything some people find it sketchy for free plugins to be obfuscated

#

theres just no point for free plugins

quaint mantle
#

Oh yea, so there isnt a backdoor

cinder thistle
#

open source is nice because then there's a lot more trust in it

lost matrix
cinder thistle
#

^

quaint mantle
#

Cool

#

obfuscation is utterly useless as you can deobfuscate it anyway

cinder thistle
#

it just makes it absolute hell if the project is big enough

eternal oxide
#

The only reason MC is obfuscated is for legal reasons. They have to make a basic attempt at protecting their IP/trademark.

limber dust
#

legit look at NMS, it's obfuscated but we still use it

quaint mantle
#

Anyways: update, I got thies error when I try to connect to my server, I have NO IDEA whats going on here.
[13:52:59 WARN]: Failed to handle packet for /xxxx
java.lang.IllegalArgumentException: Listener already listening
at net.minecraft.server.v1_12_R1.Container.addSlotListener(Container.java:56) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.EntityPlayer.syncInventory(EntityPlayer.java:236) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.PlayerList.a(PlayerList.java:219) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.LoginListener.b(LoginListener.java:159) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.LoginListener.e(LoginListener.java:57) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.NetworkManager.a(NetworkManager.java:233) ~[server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.ServerConnection.c(ServerConnection.java:140) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:845) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [server.jar:git-Spigot-79a30d7-acbc348]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_252]
[13:52:59 INFO]: Limejboi lost connection: Internal server error
[13:52:59 INFO]: Limejboi left the game

eternal oxide
#

?paste

queen dragonBOT
cinder thistle
quaint mantle
quaint mantle
cinder thistle
#

show your code

#

otherwise we can't help you

quaint mantle
#

?paste

queen dragonBOT
quaint mantle
limber dust
#

send main class too

quaint mantle
#

public final class main extends JavaPlugin {

@Override
public void onEnable() {
    // Plugin startup logic
    getCommand("menu").setExecutor(new menu());
    getCommand("mapdone").setExecutor(new mapsdone(this));
    getCommand("spawn").setExecutor(new spawn());
    getServer().getPluginManager().registerEvents(new clickevent(this), this);
    getServer().getPluginManager().registerEvents(new PlayerJoin(), this);
    getConfig().options().copyDefaults();
    saveDefaultConfig();
}

}

cinder thistle
#

use paste

quaint mantle
#

you should really learn some java, or java best practices before heading into spigot

cinder thistle
#

^

quaint mantle
#

yeah i agree with otDan

dusk flicker
#

Please do

quaint mantle
cinder thistle
#

use. paste.

#

or code blocks

quaint mantle
cinder thistle
#

also you don't need getConfig().options().copyDefaults();

quaint mantle
#

if you dont know java you cant use apis

cinder thistle
#

saveDefaultConfig(); does everything you need

eternal oxide
#

Some learn best with tutorials, some learn better by trying and failing.

quaint mantle
#

Yea, but I need to finish this lil plugin right here

#

I'm like 80% done now, so I wanna finish it.

#

youre like doing it for server?

quaint mantle
#

Astreans? ig

#

Yea

#

U know it?

#

yea

#

Where are u from bro?

#

so youre like cz

#

Yup

#

czechia too

#

Nazdaaar 😄

#

cssssssssssss

#

chceš pomoct v DM?

#

jj klido

cinder thistle
#

pognt

daring sierra
#

england

sleek pond
#

wtf

#

lowercase class name

#

and the name main

#

i thought i already told you not to do that

obtuse basin
#

Any ideas why this produces an NullPointerException? The error: [15:49:04 INFO]: Enabling MyWorlds v1.0-SNAPSHOT [15:49:04 ERROR]: Error occurred while enabling MyWorlds v1.0-SNAPSHOT (Is it up to date?) java.lang.NullPointerException: null at com.irgendwer.myworlds.MyWorlds.onEnable(MyWorlds.kt:11) ~[?:?] at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:177) ~[JavaPlugin.class:?] at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:318) [JavaPluginLoader.class:?] at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:399) [SimplePluginManager.class:?] at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:477) [CraftServer.class:?] at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:418) [CraftServer.class:?] at net.minecraft.server.MinecraftServer.func_71247_a(MinecraftServer.java:389) [MinecraftServer.class:?] at net.minecraft.server.dedicated.DedicatedServer.func_71197_b(DedicatedServer.java:316) [nz.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:596) [MinecraftServer.class:?] at java.lang.Thread.run(Thread.java:748) [?:1.8.0_282]
The Code: ```
class simplecmd: CommandExecutor {

override fun onCommand(
    sender: CommandSender?,
    command: Command?,
    label: String?,
    args: Array<out String>?
): Boolean {
    if (sender is Player) {
        val player: Player = sender as Player
        val sand: ItemStack = ItemStack(2)
        sand.setAmount(20)

        player.getInventory().addItem(sand)
    }
    return true
}

}Main class:
class MyWorlds: JavaPlugin(), Listener, CommandExecutor {

override fun onEnable() {
    this.getCommand("test").setExecutor(simplecmd())
}

override fun onDisable() {

}

}``` (Written in Kotlin)

young knoll
#

Is command in plugin yml

eternal oxide
#

MyWorlds.kt:11

sleek pond
#

imagine using kotlin

eternal oxide
#

Kotlin looks like someone saw Java once, 10 years ago and wrote down what they could remember.

wet breach
#

@sleek pond using Kotlin is perfectly fine

#

still compiles to byte code that is no different then what java does itself

#

Be nice if people stopped actually caring about the language someone is using especially if it isn't even remotely relevant given the problem occurring -.-

sleek pond
#

its a joke -_-

eternal oxide
#

Nothing wrong with commenting on an observation

young knoll
#

Don’t you still need to shade Kotlin for the plugin to work

wet breach
#

No

#

the Kotlin compiler will turn Kotlin code into appropriate standard JVM Bytecode

#

meaning you can use a Kotlin JVM for it or Java JVM and it wouldn't matter

young knoll
#

Why does Forgelin exist then

wet breach
#

don't know what it is, do you mean running Kotlin JVM Bytecode on Java JVM Bytecode?

sleek pond
#

why does forge gradle exist

obtuse basin
young knoll
#

Ah

opal sluice
#

Hi, does someone knows if there is a maven repository of MMOItems ?

obtuse basin
wet breach
#

MMOItems isn't opensource so why would you expect them to have a repo for it that is publicly accessible @opal sluice ?

opal sluice
#

At least to get the API ^^'

wet breach
#

It doesn't have an API from the looks of it

#

unless that is what mythicLibs is for

opal sluice
#

It does seems to have one ^^

wet breach
#

probably should bug them to release an API lib then

#

instead of forcing the developers to buy the plugin that they are not using other then for development purposes

opal sluice
#

Yeah, I'll write them to ask for it since it's a bit annoying to ask the customer for it's copy of the plugin to actually dev on it ^^'

wet breach
#

Yep probably wise. Never makes sense to have a premium plugin that has an API, but restrict the developers from actually obtaining said API lol

#

so as long as that is the case, not many people will develop additional resources for a premium plugin since you know the barring to entry for it legally.

opal sluice
#

Yeah, I guess that's why the most of the integration of this plugin is in other "Mythic" line up plugin

minor garnet
#

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

[15:07:14 WARN]: org.apache.commons.lang.UnhandledException: Plugin Arma v1.0 generated an exception while executing task 80
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.ConcurrentModificationException
        at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:911)
        at java.util.ArrayList$Itr.next(ArrayList.java:861)
        at vinnydgf.arma.Arma.tick(Arma.java:29)
        at vinnydgf.arma.Arma$1.run(Arma.java:55)
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71)
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
        ... 3 more```
eternal oxide
#

Arma.java:29

minor garnet
eternal oxide
#

concurrent modification. you are adding/removing from an array Async

minor garnet
fading lake
#

clone the array that you're looping through instead

#

thats what I do

#

wait

#

wrong thing

minor garnet
#

where you mean ?

wet breach
#

@fading lake easier way is toss the synchronized tag on it

fading lake
#

wait you can do that?

wet breach
#

Yep

fading lake
#

you mean the synchronized keyword? I'd love to know how that works o_o

minor garnet
#

mm

wet breach
#

yes talking about the keyword

#

using that keyword makes the method synchronized in that it forces anything using to wait in line

fading lake
#

oh thats useful, I've never seen it used before lol

eternal oxide
#

all threads have to syncronize on that object when they access it

wet breach
#

Not something you should toss everywhere, but still handy in some cases like dealing with an Array for example 😛

eternal oxide
#

synchronize forces them to take turns in accessing

fading lake
#

wait does that mean if you call something async then it calls a synchronized method, then it waits for the synchronized method to finish before continuing with the async method?

eternal oxide
#

yes

fading lake
#

🤔

wet breach
#

Alternatively you could also use volatile keyword too @fading lake

fading lake
#

wait what does that one do, apologies not seen these used before

#

@quaint mantle blockbench

wet breach
#

volatile forces cloned objects to merge with the master @fading lake so that everything has the same state for an object 😉

#

so if an object is allowed to be used Asynchronously, you can put that asynch object into a method where anything else accessing said method async will merge their copy of the object with the master, that is where the object originated from.

#

Thus, even if its async the object state is maintained regardless who has a copy using that method

eternal oxide
#

line 29 of Arma

minor garnet
#

arrows.remove(a);

#

hm

#

let me see

wet breach
#

what is happening is you are accessing the array for reading at the same time you are removing

eternal oxide
#

line 55 is running Async tick()

minor garnet
eternal oxide
#

that is calling your remove

minor garnet
#

i never went to use async

wet breach
#

@fading lake quite the opposite

eternal oxide
#

then run it sync not Async

minor garnet
#

add this would solve the error?

fading lake
#

you could replace runTaskTimerAsynchronously with runTaskTimer

minor garnet
#

ok

obtuse basin
#

How do I disable that Spawn get's generated on load of a world?

wet breach
#

The volatile modifier is used to let the JVM know that a thread accessing the variable must always merge its own private copy of the variable with the master copy in the memory. Accessing a volatile variable synchronizes all the cached copied of the variables in the main memory.

#

Has its uses, but just like synchronized not something to just toss everywhere as well 😛

fading lake
#

ah okay

wet breach
#

@fading lake always nice to randomly gain some insight on using something that is rather easy thing. IE using synchronized keyword on an array to stop CME's instead of changing the entire method XD

quaint mantle
fading lake
#

set a different spawn

fading lake
obtuse basin
paper viper
#

I'm not sure that is possible unless you use NMS

fading lake
#

^

paper viper
#

because spawn chunks are usually loaded by default

#

and stay loaded into the memory

fading lake
#

unless you want to fiddle about with it in protocollib, there's not easy way

sage swift
#

find out how multiverse does it?

paper viper
#

You can try that too

fading lake
#

I mean you could immediately unload the chunks in the world on creation but at the end of the day, they're still cached

quaint mantle
#

This is the error I get, I connect my menu opens, join messages are sent without issue, however it disconnects me 2 seconds later and I get this error

[16:29:23 WARN]: Failed to handle packet for /xxx
java.lang.IllegalArgumentException: Listener already listening
at net.minecraft.server.v1_12_R1.Container.addSlotListener(Container.java:56) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.EntityPlayer.syncInventory(EntityPlayer.java:236) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.PlayerList.a(PlayerList.java:219) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.LoginListener.b(LoginListener.java:159) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.LoginListener.e(LoginListener.java:57) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.NetworkManager.a(NetworkManager.java:233) ~[spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.ServerConnection.c(ServerConnection.java:140) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:845) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot.jar:git-Spigot-dcd1643-e60fc34]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_212]
[16:29:25 INFO]: Limejboi lost connection: Internal server error

#

?paste

queen dragonBOT
quaint mantle
ivory sleet
#

Are we talking boxed boolean?

#

Yeah there’s a possibility that is the case

sage swift
fading lake
#

@quaint mantle what happens when /menu is executed? (it's code)

quaint mantle
#

?paste

queen dragonBOT
ivory sleet
#

Not randomly

#

If all strong references are lost then it’s going to be queued for clearing

#

And cleared

sharp bough
#

what does setSaturation do?

#

what is saturation in minecraft?

paper viper
#

like how long food lasts

#

you know steak gives you big saturation

#

takes a while before your hunger starts falling

#

but something like potatoes

#

have small saturation so your hunger falls earlier

sharp bough
#

wait for real?

fading lake
sharp bough
#

6 yeras playing minecraft i have not once heard about saturation lmao

ivory sleet
#

Well I mean let’s say you create new WeakReference(new Boolean(true)); this would instantly be cleared as you never put a strong reference to that boxed boolean object passed. But if you’d do smtng like:

class a extends JavaPlugin {
  Boolean b = new Boolean(true);
  void onEnable() {
    Reference<?> ref = new WeakReference(b);
  }
}``` here we have a strong reference to that object. If and only if all strong references are lost/unset then and only then would the weak reference stop referencing that object
quaint mantle
ivory sleet
#

Idk if I explained it better

sharp bough
#

lol

ivory sleet
#

Yes

#

Assuming that field is the only strong reference to that object

fading lake
fading lake
#

its something to do with when the menu adds a listener to the slot, its just that error isnt making too much sense to me

#

(NMS not spigot)

quaint mantle
#

Me neither

lost matrix
#

Ive read volatile? Who is doing threading? Volatile fixes only very specific issues.

fading lake
#

oh I was just wondering what it is dw

eternal oxide
#

His issue is fixed. he was using Async when he didn;t need to

lost matrix
#

Alright

fading lake
fading lake
#

oh, thank you ❤️

quaint mantle
fading lake
#

huh

#

thats really weird

#

copy/paste your code somewhere, and slowly remove bits of it until it stops crashing, once it stops crashing, you know what bit was causing it ig

minor garnet
#
[09:51:36 WARN]: org.apache.commons.lang.UnhandledException: Plugin Arma v1.0 generated an exception while executing task 279
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:56)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.ConcurrentModificationException
        at java.util.ArrayList$Itr.checkForComodification(ArrayList.java:911)
        at java.util.ArrayList$Itr.next(ArrayList.java:861)
        at vinnydgf.arma.Arma.tick(Arma.java:29)
        at vinnydgf.arma.Arma$1.run(Arma.java:55)
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71)
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:53)
        ... 3 more
#
line 29
    public synchronized void removeArrow(Arrow a) {
        arrows.remove(a);
    }```
line 55 is call async
lost matrix
quaint mantle
eternal oxide
#

@quaint mantle Your issue is probably due to you trying to make the player issue a command before the Join event has finished. Instead of using p.performCommand make a reference to your menu command in your plugin and call it directly.

minor garnet
#
    public void onEnable() {
        getServer().getPluginManager().registerEvents(new GunEvent(), this);
        sendMessage("§aHabilitado com sucesso");
        
        new BukkitRunnable() {
            @Override
            public void run() {
                tick();
            }
        }.runTaskTimer(this, 0, 1);
    }```
lost matrix
#

Probably

eternal oxide
#

he is

fading lake
#

clone the collection if possible

minor garnet
#

asynchronous understanding complex

eternal oxide
#

he's removing in teh tick() method but also adding from other events

minor garnet
#

wait let me see if i understand

#
    public void tick() {
        for (Arrow a : arrows) {
            if (a.isDead() || a == null) {
                arrows.remove(a);
            } else {
                if (a.hasMetadata("sniper")) {
                    particle(EnumParticle.CRIT_MAGIC, a.getLocation()); return;
                } else if (a.hasMetadata("comum")) {
                    particle(EnumParticle.CRIT, a.getLocation());
                }
            }
        }
    }```

i need do this inside of  `public void run() {` ?
lost matrix
fading lake
#

oh thanks

eternal oxide
#

use an iterator not a for loop

paper viper
#

that's going to give cme

#

concurrentmodificationexception

#

i think

eternal oxide
#

his for loop does

paper viper
#

yea

lost matrix
# minor garnet ```vb public void tick() { for (Arrow a : arrows) { if (...

3 ways of doing this:

  1. Use an iterator and its remove() method
  2. Create a second empty collection. Then while iterating over the original you add all elements that should be removed to this extra collection.
    After iterating you simply remove all elements that are in the new collection.
  3. Use the removeIf() method
minor garnet
#

ok

lost matrix
# minor garnet ok

One spoon:

  public void tick() {
    final Iterator<Arrow> iterator = this.arrows.iterator();
    while (iterator.hasNext()) {
      final Arrow arrow = iterator.next();
      if (arrow == null || arrow.isDead()) {
        iterator.remove();
      } else {
        if (arrow.hasMetadata("sniper")) {
          particle(EnumParticle.CRIT_MAGIC, arrow.getLocation());
          return;
        } else if (arrow.hasMetadata("comum")) {
          particle(EnumParticle.CRIT, arrow.getLocation());
        }
      }
    }
  }
minor garnet
#

but when i set a iterator i need use a cast for it for if ?

#

aaah sure

lost matrix
paper viper
#

you don't cast if you specify the generic arguments the first place

lost matrix
#

Because the best collection for removing while iterating is LinkedList.
Thats also the only thing a LinkedList is good at. Otherwise its trash.

minor garnet
paper viper
#

its a class that a ton of data structures falls under

#

like List, Set,

#

etc

minor garnet
#

do you refer to the style of the code?

paper viper
#

hes just talking in general

#

the data structure you are using

#

like are you using a Set, List

minor garnet
#

so, to get an entity I usually use metadata

wet breach
#

@minor garnet Collection is a term to refer to things like arrays or hashmaps. Easier to refer them that way because there is quite a bit of them, and they well collect stuff and sometimes collect other collections etc etc.

minor garnet
deft sedge
paper viper
#

sir this isn't C#

#

methods aren't named like that

lost matrix
# minor garnet i still don't know what collection is

Iterable is the base interface
Collection inherits from Iterable
The base collections (List, Set, Queue) inherit from Collection
Then each base collection has specific implementations
List > LinkedList, ArrayList etc
Set > HashSet, TreeSet etc

minor garnet
#

so when he asked me that question he was referring to that
private ArrayList<Arrow> arrows = new ArrayList<>(); ?

wet breach
#

generally bad practive to return nulls @deft sedge second you are not checking if the item is null rather its metadata. Which will result in an NPE in itself if the item is null to begin.

minor garnet
#

ok so you're talking about daughter class and mother class

deft sedge
#

ok

#

what would I return if it didn't find anything bc I think I can only return ItemMeta

wet breach
#

change the methods type in this case

eternal oxide
#

if yoru return type ItemMeta and you have nothign to return, then return null and check if its null in yoru calling method

deft sedge
#

ok

#

thanks

wet breach
#

But you can return an empty Itemmeta though @deft sedge

lost matrix
deft sedge
#

ill do that @eternal oxide

#

thx

#

also @paper viper I was tired last night ok

lost matrix
#

Alternative would be returning an Optional<ItemMeta>
This is more elegant when you are using functional interfaces and the stream API

wet breach
#

Ah yeah forgot about the Optionals

#

that would be the ideal solution right there

deft sedge
#

k thx guys

wet breach
#

Avoid returning null whenever possible

deft sedge
#

will it store null to the variable if i return null

#

?

wet breach
#

makes it easier when you have other code logic relying on the method and if there is problems down the chain, makes it quite clear or more clear where that problem is at and why.

#

@deft sedge depends how exactly you are doing it. The way you have it in your code, that object only persists so as long as the code in that method is running, but all those objects disappear once you return it like you are.

quaint mantle
deft sedge
#

ok

#

ill look up returning optionals

minor garnet
#

i still get the error

deft sedge
#

@lost matrix is this the documentation on the optional thing

queen dragonBOT
fathom timber
#

?paste

topaz cape
#

hi im hella new to mysql and i don't know anything it really or how it works do anyone recommend me any tutorial or a wiki or something to understand how it's commands work in general?

sleek pond
#

ggl

minor garnet
#

wtf going on

eternal oxide
#

GunEvent.java:74 NPE

wise mesa
#

YOOOO

#

they added slack inline messages t o discord?

#

that's so cool

minor garnet
#

dude i litera do this

#

and when i export this project for plugin thats comments work, i dont know why

eternal oxide
#

what is line 74?

minor garnet
#

i think method ''e.getEntity()'' can be null

#

but

#

why this comments WORKING

eternal oxide
#

nope, notnull

sleek pond
minor garnet
#

using decompiler

minor garnet
#

i found the problem -_-

eternal oxide
#

it was?

deft sedge
#

Would this not stop player damage?

#

because it doesn't work

#

i have it declared and everything

eternal oxide
#

thats Item Damage., When an item takes damage

minor garnet
#

but I still have a problem that I thought had to do with the async but it's actually when it comes to defining the particle for a projectile

deft sedge
#

ok

#

I kinda thought that

#

is there a way for me to limit just playewr damage

#

because the only one i can find is entity damage

minor garnet
#

sometimes i get this particles, but other moments

deft sedge
#

and i dont' want to stop everything from taking damage, just players

eternal oxide
#

entity damage events

#

check if the entity is a Player

deft sedge
#

ok

#

thanks

#

wasn't thinking

lost matrix
minor garnet
#

and get on other location and teleport it again, i dont know

lost matrix
#

Just add a custom model data id to the ItemStacks meta. Then change the appearance of that item using the model id as predicate in your resourcepack.

lost matrix
minor garnet
#

yes

deft sedge
#

How do if an entity damage event was a player?

lost matrix
# minor garnet yes

Minecraft has some really weird limitations for the velocity of entity projectiles.
For high velocity objects like bullets i would always use a ray casting approach.

minor garnet
#

its true,

lost matrix
deft sedge
#

yea

#

thx

minor garnet
#
        if (i.contains("Mauser")) {
            setMetadata(e.getEntity(), "sniper", "sniper"); 
        } else if (i.contains("Otherthing")) {
            setMetadata(e.getEntity(), "comum", "comum");
        } else if (i.contains("Balblalbla")) {```

its better use switch here ?
obtuse basin
lost matrix
minor garnet
#

how to generate a line of particles using the vector?

quaint mantle
minor garnet
#

no -.-

wet breach
#

?jd

wet breach
#

just fyi, the javadocs has a search bar

#

upper right

#

you could try searching vector and seeing everything that uses vector

warm cloak
#

how to create like message manager that would pull message from messages.yml?

lost matrix
lost matrix
minor garnet
#

im using 1.8

#

but i need a code like this,

#
    public void drawLine(Location l, Vector dir) {
        for (double i = 0; i < 200 ; i += 0.5) {
            dir.multiply(i);
            l.add(dir);
            Arma.getInstance().particle(EnumParticle.CRIT_MAGIC, l);
            l.subtract(dir);
            dir.normalize();
        }
    }
    @EventHandler
    public void projectileLaunch(ProjectileLaunchEvent e) {
        Projectile pt = e.getEntity();
        Player p = (Player) pt.getShooter();
        String i = p.getItemInHand().getItemMeta().getDisplayName();    
        Arma.getInstance().particle(EnumParticle.FLAME, p.getEyeLocation());
        invisibleProjectile((Entity) pt);
        drawLine(pt.getLocation(), p.getLocation().getDirection());
        sound(p, i);
        
    }```  funny drawLine is dont working
lost matrix
# minor garnet ```vb public void drawLine(Location l, Vector dir) { for (double i =...
  1. Ancient version.
  2. Wrote this. Didnt test:
  public void particleTrail(final Location from, final Location to, final Particle particle, final double spacing) {
    final Location currentLocation = from.clone();
    final Vector direction = to.toVector().subtract(from.toVector());
    final Vector steVector = direction.normalize().multiply(spacing);
    final int steps = (int) (direction.length() / spacing);
    final World world = currentLocation.getWorld();
    for (int i = 0; i < steps; i++) {
      world.spawnParticle(particle, currentLocation, 1, 0, 0, 0);
      currentLocation.add(steVector);
    }
  }
minor garnet
#

a problem its because i need get a final location

#

and i dont know how i get it

lost matrix
#

Just add the direction to the current location.

minor garnet
#

you mean player.getLocation().getDirection() or projectile.getLocation().getDirection() ? and i need cast it ?

lost matrix
#

Some basic vector maths

minor garnet
#

what

#

but answering my question to get the final location would I have to take the direction of the player or the projectile?

quaint mantle
#

why
Bukkit.getServer().getTPS()

getTPS doesn't exist for me but for others it does

obtuse basin
wet breach
# lost matrix

like your illustration, demonstrates quite a few different things in just one 🙂

sharp bough
#

is there a way to do recipie.setIngredients('T' , Material.CUSTOMITEM)

#

instead of the normal materials

#

can i check the name of the material?

obtuse basin
#

Guys, any Idea why this always will use the default world generator? ```
class simplecmd: CommandExecutor {

override fun onCommand(
    sender: CommandSender?,
    command: Command?,
    label: String?,
    args: Array<out String>?
): Boolean {
    val create: WorldCreator = WorldCreator("test")
    create.generator("FLAT")
    create.createWorld()
    return true
}

}```

paper viper
#

is that Kotlin

#

And also, wdym by default world generator. Like always flat?

obtuse basin
#

this I mean

paper viper
#

That's in java, but in kotlin it would be

#

Bukkit.createWorld(WorldCreator("name").type(WorldType.FLAT));

#

i think

#

And also what brings you to Spigot plugin development 😄

#

I just use this discord as a break from King Mammoth lol

quaint mantle