#help-development

1 messages · Page 1488 of 1

chilly summit
#

every time lol

dense remnant
#

Umm

I just tried to call

if (p.hasPermission(perm)) {
                    System.out.println("Has permission");
                }

But it somehow acts as a return ?

quaint mantle
#

"acts"?

#

also please share all the relevant code

#

you can't expect me to figure out what's on your screen just by reading world.spawnEntity(loc, EntityType.CREEPER) lmao

dense remnant
#
public void syncRoles() {
        Config conf = Main.getInstance().config;
        conf.reload();
        String[] ranks = objectToStringArray(conf.getRanks());
        ResultSet rs = sendStatement("SELECT * FROM DiscordTable");
        int length = ranks.length;
        System.out.println(ranks.length);
        for (int i = 0; i < length; i++) {
            System.out.println(i);
            JSONObject ob = conf.getObject(ranks[i]);
            System.out.println(ranks[i]);
            String perm = ob.get("Permission").toString();
            try {
                System.out.println(perm + "\n" + rs.getString(1));
                Player p = Bukkit.getServer().getPlayer(rs.getString(1));
                System.out.println("rip");
                if (p.hasPermission(perm)) {
                    System.out.println("Has permission");
                }
            } catch (SQLException throwables) {
                System.out.println("Thrown");
                throwables.printStackTrace();
            }
        }
}```
Full code

When I run it without the if statement it runs through 5 times like it should (ranks.length is 5) but when I add it again it would magically return. Everything I write after the for loop also doesnt execute
quaint mantle
#

ah better

shy wolf
#

?paste

queen dragonBOT
quaint mantle
#

don't add the colons (:)

shy wolf
#

ok

quaint mantle
#

Also, this, seriously lol

#

you don't need to do any "manual reading", Bukkit will handle reading the yaml into a Location object

dense remnant
quaint mantle
dense remnant
#

No it didnt throw any error into the console at least...

#

But what could the error be then in line 17?

quaint mantle
digital plinth
#

gradle stuck at analyzing

shy wolf
#

so are you saying if i will remove the : the code will work?

pine elbow
#

pretty sure thats not gradle stuck but your IDE

dense remnant
#

Okay found the problem

quaint mantle
dense remnant
#

The player is null because I didnt get offlineplayers but onlineplayers. But it is weird that it didnt print any error message.

quaint mantle
pine elbow
#

Is there no spigot/bukkit native way to quickly check if a player has build perms at a location?
I've only been able to find ways that use WorldGuard or try to place a block

quaint mantle
#

"build perms" isn't really a thing in bukkit

pine elbow
#

it is in vanilla though

#

spawn chunks exist

quaint mantle
#

spawn protection yeah, and it's ass tbh lmao

dense remnant
#

What is the correct way to get a offline player? getOfflinePlayer is deprecated

quaint mantle
#

Firing a BlockPlaceEvent won't work though since spawn protection is part of the game's code, not a plugin processed thing

#

So I guess you can check if the player is op and if spawn protection is enabled? ¯_(ツ)_/¯

dense remnant
#

How do I create an uuid from a string again?

quaint mantle
#

Doesn't quite work like that

dense remnant
#

Okay

quaint mantle
#

If you don't have it, just use the username

dense remnant
#

Umm okay

eternal oxide
#

if you have the UUID as a string you can UUID.fromString(string)

dense remnant
#

ty

alpine urchin
#

-ban inappropriate

paper viper
#

that was like days ago

dense remnant
#

Okay, how do I get permissions from offline players?

#

getOfflinePlayer().getPlayer().hasPermission doesnt work of course

tardy delta
#

what does return true; does in the onCommand method?

ivory sleet
tardy delta
#

just escaping without the usage message?

dense remnant
#

You need to return true to tell the server that the command was executed successfully and return false if it wasnt

tardy delta
#

ki

shy wolf
#

i ma still geting null error

quaint mantle
shy wolf
#

some one?

dense remnant
#

Yeah I read that I would need Vault for that

quaint mantle
dense remnant
#

Not big of a problem

quaint mantle
#

indeed

#

or use the API of your perms plugin directly

shy wolf
#

.

quaint mantle
#

current code

#

not the previous one

shy wolf
quaint mantle
#

why don't you just use set(path, location) and getLocation(path)?

#

cfg.set(name+"world", loc.getWorld().getName());
that should probably be name + ".world", you're missing a period there
and you're setting the name somewhere but getting it from a totally different place
you're making this hard for yourself for no reason

tardy delta
#

is that toString() unneccesary?
target.sendMessage(ChatColor.DARK_GREEN + "Healed by " + sender.toString());

quaint mantle
#

if you want to get the name, get the name

tardy delta
#

ow

#

thanks

quaint mantle
quasi flint
#

Can you as the Client somehow detect If the Server send you Ghost Blocks/ Fake Blocks?

quasi flint
#

;7

eternal oxide
#

well, if you damage the block it will revert

quasi flint
#

Would be too god to be true

quaint mantle
quasi flint
eternal oxide
#

then no

shy wolf
quaint mantle
#

no, not LocationManager

#

just the config

shy wolf
#

Location event = config.getLocation("event");

quaint mantle
#

🙏

#

yes!

shy wolf
#

nop

#

error

quaint mantle
#

did you ever set it there in the first place?

shy wolf
quaint mantle
#

let me guess

#

1.8

shy wolf
#

nop

#

1.16

quaint mantle
#

what is "config" exactly?

shy wolf
#

?paste

queen dragonBOT
shy wolf
quaint mantle
#

uh...

#

that's.. not

shy wolf
#

not what?

quaint mantle
#

config shouldn't be the name of a class, it was implied that config was a ConfigurationSection (YamlConfiguration, FileConfiguration, etc)

austere cove
#

why is everything in that class static oml

quaint mantle
#

yeah i can't

shy wolf
#

yes ik i dumb

#

so what to do

#

for basic

quaint mantle
#

with "config" I was implying this

YamlConfiguration config = ...;
Location location = ...;
config.set("some.path", location);

and

YamlConfiguration config = ...;
Location location = config.getLocation("some.path");
shy wolf
#

what i need to fill in the ...

opal sluice
shy wolf
#
public class seteventloc implements CommandExecutor {

    Main plugin;

    public seteventloc(Main plugin) { this.plugin = plugin; }

    private File file = File("plugins/inbar_server/data/Location.yml");
    private FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage("Only players can use that command!");
            return true;
        }
        Player player = (Player) sender;

        if(cmd.getName().equalsIgnoreCase("set-event")) {

            YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
            Location location = player.getLocation();
            config.set("some.path", location);
            player.sendMessage("ok!");

        }
        return true;
    }

}
quaint mantle
#

You already have cfg

#

set the location in there and save the file

shy wolf
#

and what in here?

quaint mantle
#

it was an example

shy wolf
#

sooo

#

can you just make me the code

#

plz

quaint mantle
#

[16:31] Fefo6644: You already have cfg
[16:31] Fefo6644: set the location in there and save the file

shy wolf
#

but the world is null

quaint mantle
#

what?

#

also that does not even compile

#

you should really learn Java before jumping into plugin development

#

like

#

really

#

hold on a minute

#

https://paste.helpch.at/ejikamecol.md
I've heard good things about JetBrains Academy (paid, but with free trial) and Coursera, I strongly suggest you know how to use Java before making actual things with it

lean gull
#

hello

#

for some reason this works

wand = item;```but this doesn't?
```hs
test = item;```
eternal night
#

what

eternal oxide
lean gull
#

the rest is just a bunch of meta stuff

eternal night
#

this is a single line of java code that apperantly reassigns a variable ?

#

like, we have no idea what is going on in your code

eternal oxide
#

Answer me this, when I take an orange from my fridge it doesn't work?

lean gull
#

1 sec im having weird problems

#

ok i'm back, i was missing a { and i had wrong indentation

#

the issue still occurs, what more information do you need btw

rotund pond
eternal night
#

Like, the actual code. Where arre the two variables initialized

lean gull
#
    private static void createFriedCoal() {

        ItemStack item = new ItemStack(Material.COAL, 1);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("§7Fried Coal");
        List<String> lore = new ArrayList<>();
        lore.add("§7You somehow managed to");
        lore.add("§7Fry coal");
        lore.add("");
        lore.add("§a§lCOMMON");
        meta.setLore(lore);
        item.setItemMeta(meta);
        test = item;
    }
}```
eternal night
#

how is test initialized.

lean gull
#

what's initialized

eternal night
#

or defined for that matter

#

like, where do you define the test variable

eternal oxide
#

is test an ItenStack?

lean gull
#

well the last thing sets it

proper notch
#

^^ java requires you define a type, and test is never implicitly defined.

eternal night
#

what

lean gull
#

yeah it sets it to item

eternal night
#

you need to define a variable

#

this isn't python ma friend

proper notch
#

ItemStack test = item

quaint mantle
#

why are you using haskell for your code blocks lmao

lean gull
#

it worked fine in my other item thing

proper notch
#

Show the full code of that

eternal night
#

probably have a field named wand

lean gull
#
public class LudicrousyItems {

    public static ItemStack wand;

    public static void init() {
        // adds wand function to somethin, idk
        createWand();
    }

    private static void createWand() {

        // sets variable "item" to 1 blaze rod
        ItemStack item = new ItemStack(Material.BLAZE_ROD, 1);
        // sets variable "meta" to everything about variable "item"
        ItemMeta meta = item.getItemMeta();
        // sets item name of variable "meta" to "§6Explosive Stick"
        meta.setDisplayName("§6Explosive Stick");
        // sets variable "lore" to a new list
        List<String> lore = new ArrayList<>();
        // adding a line of lore to variable "lore"
        lore.add("§7Right click on a");
        lore.add("§7block to create an");
        lore.add("§7explosion at your location!");
        lore.add("");
        lore.add("§3§lRARE");
        meta.setLore(lore);
        // adding an enchant to variable "meta
        // false = ignores normal minecraft enchantment limit like sharpness 5, though someone said you need to set it to true for no cap
        meta.addEnchant(Enchantment.LUCK, 1, false);
        // sets flag
        meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        // sets variable "item"'s meta to variable "meta"
        item.setItemMeta(meta);
        // adds variable "item" to variable "wand"
        // or how normal people say it: adds the meta i just made to the wand item
        wand = item;


    }

    private static void createFriedCoal() {

        ItemStack item = new ItemStack(Material.COAL, 1);
        ItemMeta meta = item.getItemMeta();
        meta.setDisplayName("§7Fried Coal");
        List<String> lore = new ArrayList<>();
        lore.add("§7You somehow managed to");
        lore.add("§7Fry coal");
        lore.add("");
        lore.add("§a§lCOMMON");
        meta.setLore(lore);
        item.setItemMeta(meta);
        test = item;
    }
}```
eternal night
#

yea

proper notch
#

Gods what formatting is that

eternal night
#

there is your field

rotund pond
lean gull
#

hs

proper notch
#

java exists

lean gull
#

but why does it work on top part

quaint mantle
#

haskell lol

eternal night
#

because you define a field called wand

lean gull
#

a what

#

sorry i started learning java yesterday

proper notch
#

You define a variable wand already with the type ItemStack.

eternal night
#

maybe take a java basics code

proper notch
#

The difference is you never define the type of test, only the value.

rotund pond
#

I think you should learn Java first instead of learning to use spigot API

eternal oxide
#

A Java Field is a variable defined at the class level.

lean gull
#

where did i define wand

#

am confusion

eternal night
#

public static ItemStack wand;

proper notch
#

public static ItemStack wand;

eternal night
#

:>

proper notch
#

at the top of your class you are defining that wand is of type ItemStack

lean gull
#

i searched, 0 results

sweet elm
#

im new is this channel talking about plugins or coding?

quaint mantle
#

it's literally there

proper notch
#

Well we're all literally staring at the code

quaint mantle
#

you should really learn Java before diving straight into plugin making

eternal night
#

^^

quaint mantle
lean gull
#

but i don't want to learn java, i just want the minecraft part

eternal night
#

500 iq play

proper notch
lean gull
#

yeah that's what i said minecraft part

eternal night
#

m8

proper notch
#

That's like saying you want to speak english without knowing how to speak.

eternal oxide
#

Must learn Java, no clicky buttons make plugins

eternal night
#

there is no minecraft part xD

rotund pond
lean gull
#

i mean the minecraft part of java

eternal night
#

wtf xD

lean gull
#

i don't want all of java

eternal night
#

omg

proper notch
eternal night
#

this is great

lean gull
#

ok lemme ask this: what can you do with java

eternal night
#

code programs

eternal oxide
#

Everything

rotund pond
lean gull
#

well i just want the minecraft part of everything

#

i don't want to code games or whatever

rotund pond
eternal night
#

yes, and for that you still need a solid foundation of java

eternal oxide
lean gull
#

java minecraft part of java idk man

eternal night
#

to code good minecraft plugins you'll need a pretty deep understanding of the language

lean gull
#

my english isn't the best

proper notch
#

The only difference between learning to code games and code minecraft plugins is you're learning a different API. You still need to learn Java itself for both.

lean gull
#

anyways i still don't know where i set wand

proper notch
wraith rapids
#

you look like a 1.8 user

proper notch
#

public static ItemStack wand

lean gull
#

oh i see now

lean gull
eternal night
#

Just, learn the java basics first ;/ they are definitely part of your "minecraft java part"

lean gull
#

my b, i put void after static, that's why there were no results

rotund pond
#

You're wasting your breath.
this person has a hard head, personally I will not waste my evening explaining something so obvious.

wraith rapids
#

your mom

rotund pond
#

She's fine, thank you

wraith rapids
#

you're welcome

lean gull
#

anyways i'm out, thanks guys, gals and non-binary

eternal oxide
#

We are all binary in here! Its a part of being a programmer.

vital swift
#

is requesting data from mysql safe?

#

in bungeecord

eternal night
#

as safe as any database interaction

#

you should run it off the main thread

silent turret
#

I cant quite get clickEvent Books to work, can anybody help me? (Rather new to code so you might need to dumb it down)

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.

dusk flicker
#

Send the code

vital swift
silent turret
#

1 sec

dusk flicker
#

(Put it in a paste)

queen dragonBOT
eternal night
#

bungeecord api has a scheduler api similar to spigot

#

yes

vital swift
#

thx, i'll look into it

eternal night
#

tho "async" really just works wherever. Java has a lot of its own threading model

silent turret
#

the 3rd pages.add is where i was trying to impliemnt it

dusk flicker
#

Does the event work at all or no

silent turret
#

well

#

yes kidn of

#

i can get the book, im just unsure how to set up ClickEvents and HoverEVents

#

and i can get The first paoges

eternal night
#

click events and hover events are part of the text inside the book

#

there is no event on the server side for them

#

these events happen on the client side

silent turret
#

well yes i mean, atempting to get to run a command

eternal night
#

there ya go

silent turret
#

attempted that, but Error after error

#

TextComponent hasnt been workin for me

eternal night
#

I mean it is the only way you'll get click/hover events in there using just spigot

silent turret
#

true

lean gull
silent turret
lean gull
#

does not

#

for me atleast

eternal oxide
#

Thats probably because you don't know Java.

lean gull
#

i literally copy pasted the code

eternal oxide
#

And thats why. Without knowing Java you will not notice any mistakes you made.

lean gull
#

how can i do any mistakes if i copied the code

eternal oxide
#

You don't know what the code is doing so you can't tell what you did wrong.

lean gull
#

??????

ivory sleet
#

Because not all code can be put everywhere

lean gull
#

you make no sense

summer scroll
#

My intellij says that the project is out of source root folder, I already fixed that but it gives me error on all class.

#

I can't even use my own classes.

queen dragonBOT
eternal oxide
lean gull
#

too long

#

lemme make a pastebin

#

sike it was a hastebin

#

i'm a riot

quaint mantle
#

silly goose

#

haha

eternal oxide
#

Where in teh example code is this line ShapedRecipe wandRecipe = new ShapedRecipe(NamespacedKey.minecraft("wand"), item);?

lean gull
#

?

eternal night
eternal oxide
#

Its not, so you didn;t copy/paste as you said

lean gull
#

no this is the youtube video tutorial one

#

i copy pasted the spigotmc one, it didn't work so i removed it

#

tho i did try adding NamespacedKey key = new NamespacedKey(this, "diamondcustom"); from the spigotmc one

eternal oxide
#

ok, your line 50 requires a plugin reference, you provided this, which is your LudicrousyItems class.

lean gull
#

ye that's what it said on the spigotmc thing

eternal oxide
#

no its said this if you were in your onEnable, in your main plugin class.

#

You are not in your onEnable or in your main class.

lean gull
#

oh ok

#

the tutorial said to put it where i set my items

#

so i put it there

#

how do i set it to the main thing

eternal oxide
#

well, you redesign your class to remove all the static and make it a singleton

lean gull
#

yeah i understood 0% of that

eternal oxide
#

Change yoru init function to a constructor you can use Dependency Injection to pass a plugin reference.

#

I know 😛

quaint mantle
#

rip floofsy

lean gull
#

i- what?

eternal oxide
#

lol

wraith rapids
#

learn java

lean gull
#

neverrr

quaint mantle
#

tbh

dusk flicker
#

you just hurtin yourself not learning java

lean gull
#

i'mma just put it i the main one

wraith rapids
#

yeah write your entire plugin in a single class

quaint mantle
#

you are wanting to drive a semi truck across the whole country without knowing how to walk

#

literally

wraith rapids
#

no need to give a shit about oop

#

just imagine it's a functional language and make everything static

lean gull
#

a what and make what

eternal oxide
#

rofl

#

That doesn;t happen often

dusk flicker
#

lol ye

lean gull
#

what doesn't happen often

dusk flicker
#

you

lean gull
#

ouch

#

i think

dusk flicker
#

yep

eternal oxide
#

I actually laughed out loud 🙂

sturdy venture
#

functional programming 😌 😌 😌

quaint mantle
#

lmao

ivory sleet
#

Oh no

quaint mantle
#

haha

sturdy venture
#

hello there ladies and gents

#

it's your favourite person

#

here to talk to you about anarcho capitalism haskell!

dusk flicker
#

I have been in here a lot and literally never seen you before

sturdy venture
#

indeed

#

it is a rare occurrence that i step foot in this foul hovel

#

but when i do

#

😌

#

anyway

eternal oxide
#

His name is familiar, but thats probably because it starts with Minecraft

sturdy venture
#

what does everyone here know about monads?

quaint mantle
sturdy venture
sturdy venture
eternal oxide
sturdy venture
#

umm

lean gull
#

ok so what do i do exactly

sturdy venture
#

no that's not what i mean but ok!

lean gull
#

btw i put it in the main and it sent a bunch of errors

sturdy venture
#

let me move to #general so i don't interrupt

dusk flicker
#

you spend more time learning java

#

We aren't gonna spoonfeed

queen dragonBOT
#

Spoonfeed a newbie for a day and they'll come back with more questions. Teach them to find their own answers and you'll both be better off: you won't get stuck answering the easy questions and they'll be much more productive than before.

eternal oxide
#

errors are good! You can learn from them

lean gull
#

i would learn from them if they were in english

dusk flicker
#

what

lean gull
#

and if they made sense too

eternal oxide
#

I bet its almost English

lean gull
#

i literally just set the variable, and then it says it can't find it in the line where i set it????

quaint mantle
#

and it does make sense once you've learned some of it

lean gull
#
NamespacedKey key = new NamespacedKey("Ludicrousy", "diamondcustom");```
https://i.imgur.com/u1O4JSI.png
eternal oxide
lean gull
#

also pog it's 12:00 AM now in my timezone

lean gull
dusk flicker
#

it may just be that NamspacedKeys arent in the api

lean gull
#

ew it's mrenxo

dusk flicker
#

last time I used em they wernt in spigot-api

#

only in the server

eternal oxide
#

this always refers to the class you are currently in.

lean gull
#

good to know

dusk flicker
#

but thats hopefully changed by now

lean gull
#

i changed it tho

spiral pewter
#

I need some help:
I am making a socket plugin for my bungeecord server so I can communicate between servers
and I want it so the socket plugin would be its own plugin that hosts the server and other plugins can hook into the socket plugin to communicate.
how would i do that

eternal oxide
#

Not a simple answer

spiral pewter
#

i just need a answer

eternal oxide
#

ok, yoru plugin can;t host the server

#

your plugins is hosted BY the server

lean gull
#

i put the example in my main thing and now it's still broken

eternal oxide
#

you can expose an API within your plugin that other plugins can access.

lean gull
dusk flicker
#

IMPORTS.

#

this is literally java 1.0

eternal oxide
#

You are getting closer

lean gull
#

?

eternal oxide
#

what IDE are you using? Intelij by the looks

lean gull
#

yee

eternal oxide
#

I've no idea on the key sequence for InteliJ to auto import

lean gull
#

wat dat

dusk flicker
#

Alt + Enter

#

but its weird

#

it will tell u when to do it

dense goblet
#

Is there a way to check if an inventory is open? I want to have a progress bar inventory which doesn't update if nobody has the specific inventory open

eternal oxide
#

getViewers

#

I think

lean gull
#

what's import

dusk flicker
#

oh

#

my

#

fuck

dense goblet
#

ty Elgar

lean gull
#

what do i do with all the errors

dense goblet
#

what are the errors

eternal oxide
#

read teh link I gave you

lean gull
#

oh i just removed one letter and press the thing from the list

dense goblet
lean gull
#

ok so i did NamespacedKey key = new NamespacedKey("Ludicrousy", "wand"); in the items class but it gave me a warnning saying it's deprecated

dense goblet
#

you should use a reference to your plugin instead of a string for the first argument

eternal oxide
#

"Ludicrousy" is wrong

#

I already told you that

lean gull
#

im confused, what do i do

eternal oxide
#

this

lean gull
#

but i need to put it in the items class for the items

dense goblet
#

pressing ctrl+p when your cursor is inside a function will tell you what data type it expects

eternal oxide
#

you need to get it working before you go breaking things

#

NamespacedKey required a Plugin reference, not a String

lean gull
#

and i do that how exactly?

eternal oxide
#

I just told you

lean gull
#

no u told me what this does

#

no wait im dumb

#

and confused

spiral pewter
#

How would i make events in my plugin api

silver robin
#

whats a best way to get 8 blocks in a 3x3 area around one block?
i can make a BlockFace array for NORTH EAST WEST and SOUTH but what is the best way for corner blocks except for 4 calls to blocks.getRelative(1, 0, -1) with 1 and -1 respectively

spiral pewter
#

i can easily do it in javascript

lean gull
spiral pewter
#

but java is way different

dense goblet
silver robin
# spiral pewter idk how that would work tho

i think you have two ways, one is to make users @Override your event method (but in this case it has to be empty) and second is make a interface PluginEventHandler and make some methods there

dense goblet
#

more efficient may be to just make an array list but also harder to adapt for larger areas if you plan on that

silver robin
spiral pewter
silver robin
dense goblet
#

@silver robin renamed dy to dz since that's prob more accurate

for(int dz = -1; dz <= 1; dz++) {
  for(int dx = -1; dx <= 1; dx++) {
    if(dx == dz == 0) continue;
    doYourThing(centreBlock.getRelative(dx, 0, dz));
  }
}
#

replace the 1s with whatever radius you want

silver robin
#

i see how it would be more efficient if i plan on large areas, for example 5x5
but with array list, i would have something like this, right?
(There maybe is a lot of bad syntax, i don't know everything by heart)

List<Set> a = Arrays.asList({1, 1}, {1, -1}, {-1, 1}, {-1, -1})
for (Set coordset : a) {
    Block rb = centerBlock.getRelative(coordset[0], coordset[1]);
}```
quaint mantle
summer scroll
#

If I want to store all entities that spawned from Spawner, is it better to use WeakReference on the Entity or just create a Set and store the UUID instead? or it's just depends on what I'm gonna do with the entity.

ivory sleet
#

You can create a weak hashset

summer scroll
#

weak hashset

#

you mean WeakReference inside HashSet?

ivory sleet
#

Collections.newSetFromMap(new WeakHashMap<>());

dense goblet
summer scroll
dense goblet
#

I recommend the double loop instead

#

both are pretty much instant anyway

#

if you're not doing it hundreds of thousands of times per tick it won't matter

somber hull
#

ok
im very confused
so i have a gui for settings, and i want to read the players input from chat

        settingsPane.addItem(new GuiItem(rlMsgItem, event -> {

        }), 0, 0);

whatever i put in that gets run when the player clicks on the item
how do i get what the player says in chat?

dense goblet
#

you'll need a callback no

#

since you need to wait for the player to type something out

#

first solution that comes to my head is have a singleton chat listener with a hashmap between player and callback function

#

if they send a chat message and are present in the map, cancel the event and fire the callback, and remove them from the map

somber hull
#

hmm

dense goblet
#

your settings pane would just tell the chat listener to add them to the map and you would specify the callback

somber hull
#

but that would break if two people are trying to do it at the same time

dense goblet
#

nope, since its a hashmap

#

Map<Player, Consumer<String>>

somber hull
#

i could close the gui, listen for chat event, repoen gui

dense goblet
#

and in onPlayerSentMessage:

  if(awaitingInputMap.contains(messagePlayer)) {
    awaitingInputMap.get(messagePlayer).accept(message);
    awaitingInputMap.remove(messagePlayer);
    e.setCancelled(true);
  }
somber hull
#

alright

dense goblet
#

if you want something fancy like a timeout, you could start a runnable or make a class which holds the callback and the expiry time, and use that in the hashmap instead

torn shuttle
#

where's the random username dude, I want to make fun of him a bit more

ivory sleet
#

No need to

torn shuttle
#

@wraith rapids hey so I now have two powers which are in the bombardment category, they are specifically for the ender dragon, they are are both for fireballs and they are both configuration instancers, can you guess how long the class name got?

dense goblet
#

does calling openInventory() when a player has a similar inventory already open cause the cursor to jump back?

quaint mantle
vital ridge
#

hey, does someone know the best way to fill a circle? I made a flat particle circle, but dont know rly how to fill it. I know i can just draw alot of little circles inside it but thats gonna take like 20 for loops

#

So yeah if someone knows id be happy

#

Thats my current code:

private void drawCircle(Location loc, float radius) {

        for (double t = 0; t < 50; t += 0.5) {

            float x = radius * (float) Math.sin(t);
            float z = radius * (float) Math.cos(t);

            loc.getWorld().spawnParticle(Particle.REDSTONE,
                    new Location(loc.getWorld(), loc.getX() + x, loc.getY() + 0.5, loc.getZ() + z), 1,
                    new Particle.DustOptions(Color.PURPLE, 1));

eternal oxide
#
new Location(loc.getWorld(), loc.getX() + x, loc.getY() + 0.5, loc.getZ() + z)```
can be written as```java
loc.clone().add(x,0.5,z)```
vital ridge
#

okay

#

will optimize

#

y have any idea how to fill the circle tho?

wraith rapids
#

given a range of r

#

start at x = -r, z = -r

#

iterate over to x = r, z = r

#

over an increment of d

eternal oxide
#

I'd just go with concentric circles, just requires an outer loop for radius

wraith rapids
#

check whether sqrt(x^2 + z^2) is <= r

#

if so, spawn particle

vital ridge
#

So ill create 4 more for loops?

#

basically

eternal oxide
#

no

wraith rapids
#

just this one loop will do

#

in other words, pretend that you are filling a square

#

but only spawn the particle if it's within the circle

vital ridge
#

I rly suck at this math

#

i dont even know

#

how to fill a squre

#

square

wraith rapids
#

start at one corner

#

then move left

#

until you hit the leftmost edge

eternal oxide
#

1 for loop around it all to start at 1 and count up to the radius. The inner loop you do as a multiple of radius for the number of particles you are going to spawn

wraith rapids
#

then move one notch up

#

and go back to the rightmost border

#

then go left

#

rinse and repeat

vital ridge
#

given a range of r
start at x = -r, z = -r
iterate over to x = r, z = r
over an increment of d

#

i thought thats like 4 for loopsd

wraith rapids
#

2

#
for (double x = -r;x <= r;x += d) {
   for (double z = -r;z <= r;z += d) {

   }
}```
dense goblet
#

for the radius check you can use square distance btw, to avoid a sqrt

vital ridge
#

well

#

the first loop

#

is going from

#

one side

#

to another side

#

basically draws a diameter

wraith rapids
#

no

dense goblet
#

no it fills it in

wraith rapids
#

one loop draws a line

vital ridge
#

i dont understand how

#

thats the thing

dense goblet
#

inner loop runs once per outer loop iteration

wraith rapids
#

the second loop makes it draw a line for every x

dense goblet
#

the inner loop iterates over every block in a row along the z axis

#

the outer loops repeats this operation once for every position in a row along the x axis

wraith rapids
#

the code itself draws a dot

#

putting that code in a for x loop makes it draw a line

#

putting that code and loop in a for z loop makes it draw a square

vital ridge
#

so basically in the end

dense goblet
#

your inner loop does:

your outer loop does:
[inner loop]
[inner loop]
[inner loop]
[inner loop]
[inner loop]

wraith rapids
#

putting that code and loop in a for y loop makes it draw a cube

vital ridge
#

im spawning particles

#

at loc.getx + x

#

and log getz + z

#

?

wraith rapids
#

yes

vital ridge
#

yeah that makes more sense

dense goblet
#

together you get:






wraith rapids
#

precompute the value of r^2 so you can compare (x^2 + z^2) <= r^2 instead of sqrt(x^2 + z^2) <= r

#

as square roots are relatively expensive

vital ridge
#

okay as much as i understood

dense goblet
#

to make it a circle you just discard it if dx*dx + dz*dz > r*r

#

yea what nnya said pretty much

vital ridge
#

if i have x + z

#

x and z

dense goblet
#

no, its x * z

#

since the z loop is inside the x loop

#

when you iterate over x, you do a full loop of z

#

so you do:

x=0
  z=0, z=1, z=2, ...
x=1
  z=0, z=1, z=2...
x=2
  z=0, z=1, z=2...
x=...
vital ridge
#

thats so not understandable lol

#

Im almost getting

#

the logic

#

but just not yet

wraith rapids
#

consider the for loop as a multiplication operator

#

we start with 0 dimensions

#

a dot

#

a single particle

#

with a for loop, we can have a lot of particles

#

this makes a line

vital ridge
#

okay

#

thats understandable

wraith rapids
#

we have one dimension

dense goblet
#

if you had it like this:
for(int x=0; x < 10; x++)
doTaskA();

and then doTaskA() is defined as:
for(int z = 0; z < 10; z++)
doTaskB();

wraith rapids
#

let us call this dimension x

dense goblet
#

how many times would task B run?

wraith rapids
#

now, we want a square

#

a square has two dimensions

#

lets call this second dimension y

vital ridge
#

Dimension

wraith rapids
#

what we do now, is we put the for loop in a second for loop

vital ridge
#

What is dimension

#

in english

wraith rapids
#

direction

vital ridge
#

what does that mean

wraith rapids
#

axis of freedom

dense goblet
#

a direction that is orthogonal to all other dimensions

wraith rapids
#

we live in a three dimensional world

#

there is left/right

#

there is up/down

vital ridge
#

yea

wraith rapids
#

and there is in/out

#

3 dimensions

#

x,y,z

#

so, let's take it from the top

#

we have a 0 dimensional object

#

a dot

#

it does not have width

vital ridge
#

y

spring fog
#

How can I more accurately test if a slime entity is on the ground (or if/when it lands)?
Using Entity#isOnGround() to test when it hits the ground while falling returns as true about 2 blocks before it should.

wraith rapids
#

it does not have length

#

it does not have depth

vital ridge
#

mhm

torn shuttle
#

surely there must be a guide out there that this guy can see a visual representation of lol

wraith rapids
#

it is simply a dot

#

now, a line is just a lot of dots side by side

#

a line has one dimension

vital ridge
#

so left or right

wraith rapids
#

yes

#

so we can take a dot

#

and put the dot in a for loop to place it side by side a bunch

#

and we get a line

vital ridge
#

so

wraith rapids
#

now, we want a square

#

just like a line is just a lot of dots side by side

vital ridge
#

whats the dot for loop tho

wraith rapids
#

a square is just a lot of lines side by side

vital ridge
#

to get them in a line

#

x = 0

#

x < what

#

the lenght of the line?

wraith rapids
#

for (int x = 0;x < 10;x++) { //dot }

vital ridge
#

oh o0kay aight

#

yeah

wraith rapids
#

draws a line of 10 dots

dense goblet
#

the inner loop draws a line

wraith rapids
#

now

#

we want a square

#

and just like a line is just a lot of dots side by side

#

a square is just a lot of lines side by side

#

so we put the for loop in a for loop

#

for (int y = 0;y < 10;y++) {for (int x = 0;x < 10;x++) { //dot } }

#

now we have 10 lines

vital ridge
#

but the for loops

wraith rapids
#

each being 10 dots

vital ridge
#

are not

#

interacting

#

with each other

dense goblet
#

^ i.e. the outer loop draws the inner loop (=a line) side by side along a different dimension.

vital ridge
#

right?

wraith rapids
#

they are

spring fog
dense goblet
#

they are since one is inside another

vital ridge
#

it would be printed 20 times inside the for loop?

dense goblet
#

nope

young knoll
#

10 x 10

vital ridge
#

100

#

oh kk

dense goblet
#

it would be 20 if the loops were not nested

#

for(10 times)
hey

for (10 times)
hey

will do 20 times

vital ridge
#

okay

dense goblet
#

for(10 times)
for(10 times)
hey

will do 100 times

vital ridge
#

so nested for loops

dense goblet
#

since the inner loop is 10 heys and the outer loop is 10 of those, 10*10 = 100

vital ridge
#

example x loop and y loop are automatically x *y the output?

#

if they are nested?

dense goblet
#

yes by logical reasoning it will be x * y

eternal oxide
#

@vital ridge does your spawnParticle even work? I just tested it and got nothing

dense goblet
#

for(10 times)
doTaskA();

and task A is:
for(10 times)
doTaskB();

^ you can say that saying doTaskA is the same as saying doTaskB 10 times, right

spring fog
dense goblet
#

so if you do task A 10 times, you will be doing 10 * (task A) = 10 * (10 * task B) = 100 task Bs

dense goblet
#

or pathtrace down from the centre

#

though that wont work on corners

vital ridge
#

i didnt rly understand that tho:

for (x = -r; x <= r; x+=d)
#

i didnt understand the last x+=d

#

like shouldnt it be x++

#

or x+ 0.5

young knoll
#

x+=d is short for x = x + d

dense goblet
#

d defines how dense your particles are

#

if d = 1 it will do 1 particle per block

vital ridge
#

i thought its diameter

dense goblet
#

r is the radius, (2*r) + 1 is the diameter

vital ridge
#

why + 1

#

2*r should be diameter arldy?

spring fog
#

oh wait, i can do a fall damage check on it?

young knoll
#

If it has fallen far enough to take damage, yes

dense goblet
vital ridge
#

1

spring fog
dense goblet
#

nope

vital ridge
#

-1 and 1 difference is 1?

dense goblet
#

1 - -1 = 2

#

but that isnt the amount of times it runs

#

go through the loop in your head

#

it says:
x starts at -1
check if x is less than or equal to 1
if so, do the code
now increment x by 1

vital ridge
#

should be 2 times

quaint mantle
#

<= makes the range inclusive

vital ridge
#

-1 + 1 + 1 = 1

quaint mantle
#

-1 inclusive to 1 inclusive

#

we start at -1

#

-1 <= 1

#

we go to 0

#

0 <= -1

#

we go to 1

#

1 is still <= 1

vital ridge
#

how is 1 smaller or equal to 1 tho?

#

its not smaller

#

its only equal

dense goblet
#

smaller or equal

vital ridge
#

i dont get why we add <=

#

here

quaint mantle
#

OR

#

it is equal

#

it is equal, therefore it is smaller or equal

dense goblet
#

A OR B = A, B, or both

vital ridge
#

why not just =

#

what would happen

#

if i just put

#

=

#

no <-

#

<=

quaint mantle
#

nothing

dense goblet
#

think it through

quaint mantle
#

stop talking and start thinking

dense goblet
#

start at x = -1

#

check the guard (is x = 1?)

#

if it passes, do the code and then do the increment step (x++)

#

if it doesnt pass, finish the loop (without executing the code inside it again)

wraith rapids
#

look up what a for loop does

#

aka learn java

vital ridge
#

I know what it does but math + java fcks everything up for me

wraith rapids
#

you clearly don't

#

you have a vague, intuitive guess as to what it probably does

#

you don't actually know what it does

#

so look it up, make your understanding concrete

dense goblet
#

for(<assignment>;<guard>;<operation>) {
<body>
}
you should know exactly what each part of a for loop does

#

and when it does it

eternal oxide
#

@vital ridge are you trying to achieve something like the dragon breath effect?

vital ridge
#

Basically just a filled circle

wraith rapids
#

what he needs to achieve is understanding for loops

#

dragon breath or whatever else is secondary

eternal oxide
#

it all depends on how he needs it to look. If he is filling grid based its going to show a pattern

dense goblet
#

yea but if you dont want a grid pattern you'd have to get into angles and golden ratio and shit

eternal oxide
#

not really

dense goblet
#

or just random ig but its not gonna be as uniform a covering

wraith rapids
#

yeah elgar

#

tell him how to fill a circle uniformly

eternal oxide
#

    private void drawCircle(Location loc, float radius) {

        for (float r = 0.1f; r < radius; r += 0.1f) {
            for (double t = 0; t < radius * 25; t += 0.5) {

                float x = r * (float) Math.sin(t);
                float z = r * (float) Math.cos(t);

                loc.getWorld().spawnParticle(Particle.REDSTONE,
                        loc.clone().add(x, 0.5, z), 1,
                        new Particle.DustOptions(Color.PURPLE, 1));
            }
        }
    }```
#

using his code

wraith rapids
#

without artifacting because of axis alignments

#

that's not uniform

eternal oxide
#

it increases in density as the radius gets larger

wraith rapids
#

there's going to be a hole in the center

eternal oxide
#

I can;t see one

wraith rapids
#

you need glasses

eternal oxide
#

possibly

wraith rapids
#

but basically, the circumference at the center becomes so small you can't fit your interval in it

#

and you end up with a 1 particle sized hole

eternal oxide
#

due to the particle size there is no hole as they overlap

wraith rapids
#

maybe but that doesn't make it uniform

eternal oxide
#

looks quite uniform to me, but as you say, I may need glasses 🙂

late dove
#

How many server resources can you allocate for the database?
To make it enough for her!

eternal oxide
#

3

#

7

#

1

dense goblet
#

for a sunflower arrangement you'd want to have just one loop which adds a constant to the radius and increase the angle by the golden ratio (or a multiple thereof)

#

its about as uniform as you get

chilly summit
#

I'm probably just an idiot, but this code is giving me a NullPointerException, and I don't understand why.

private boolean UUIDUsed(UUID UUID) {
  Path factionsfolder = Paths.get(plugin.getDataFolder() + "/factions");
  if(Files.exists(factionsfolder)) {
    try {
      Files.createDirectories(factionsfolder);
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  return Arrays.asList(ListFilesInDir(factionsfolder.toFile())).contains(UUID.toString());
}

The error: https://paste.md-5.net/ebugukocaj.bash

#

It makes no sense to me why there's a NullPointerException, nothing here should be null

wraith rapids
#

line 43 being

#

also use System.fileSeparator

#

or File.separator

chilly summit
#

Path factionsfolder = Paths.get(plugin.getDataFolder() + "/factions");

#

is 43

eternal oxide
#

plugin is null

chilly summit
#

no it's not

opal juniper
#

Lmao

wraith rapids
#

there aren't really any other alternatives

eternal oxide
#

ok its not, good luck

opal juniper
#

Where do you initialise “plugin”

chilly summit
#
static Main plugin;
     
    public Factions(Main plugin) {
        RTP.plugin = plugin;
        plugin.getCommand("Factions").setExecutor(this);
    }

Factions is called from Main.java(which is plugin) with

new Factions(this)
lean gull
#

how do i call another java class?
NamespacedKey key = new NamespacedKey(>>><<<, "wand");

wraith rapids
#

what am i looking at

#

why is that static

eternal oxide
#

yep, plugin is null

chilly summit
#

But it's not... I can call to plugin from other places in that class and it works

eternal oxide
#

remove static and assign with this.plugin =

chilly summit
#

Ah oof I had it to RTP.plugin = [...] instead of Factions.plugin = [...]

dense goblet
#

dont do static for stuff that is in any way related to order of execution

wraith rapids
#

yeah don't use Factions.plugin either

#

use this.plugin

#

it's a constructor

#

you have an object

#

use it

chilly summit
#

weird, then why does it work when I call plugin in other parts of that class

wraith rapids
#

you're probably calling them differently, I don't know

chilly summit
#

hmm

eternal oxide
#

you are accessing the passed variable plugin not the Field

wraith rapids
#

if we're talking about "other parts" == the constructor, this ^^

#

basically, don't make random shit static for no reason

#

and make fields final when possible

#

will save you from this happening again

chilly summit
#

I mean, I just have it static because my template plugin I made a while ago (with templates for commands, tab completion, etc.) had it static, I have so clue why I assigned it to static when making my template

wraith rapids
#

revise your template

lean gull
#

i still need help ._.

wraith rapids
#

learn java

#

or rather, learn oop

chilly summit
#

Actually, I know why I did that. Because it doesn't work if i don't do it like that lol

dense goblet
#

thats a bad sign

chilly summit
#

If it's not static I can't use plugin.*

eternal oxide
#

yes you can, you use this.plugin, unless your method is static

chilly summit
#

a lot of my methods are static .-.

wraith rapids
#

make them not static

eternal oxide
#

or redesign that class as static methods should not be designed like you are.

wraith rapids
#

learn what static is and what it's supposed to be used for

dense goblet
#

its your main class right

chilly summit
#

No

#

It's a command's class

eternal oxide
#

a static method can;t rely on a class being intialized

ivory sleet
#

Static sabotages all oop advantages also :[

wraith rapids
#

global state is a maintenance nightmare

eternal oxide
#

if you HAVE to get a plugin reference in yoru static method get it using Bukkit

dense goblet
#

static methods are fine as long as you use them appropriately and keep in mind how your code flows. static code blocks are sussy

wraith rapids
#

i'll sussy your ass

dense goblet
#

my ass is premium material

wraith rapids
#

basically, your design is wrong, your layout is wrong, and you are running into development and maintenance issues like the NPE from earlier because of it

#

you should seek to improve

#

i know you're writing a "but it works and i have to do it that way" over there

#

but spare your effort

chilly summit
#

I just have always been more into other languages like Javascript and only know most basic syntax and how most things in java work, but not some things (even basic ones like static methods,) so I always end up trying to fix errors and just doing what my IDE says would fix it unless I know it won't, which, once again, because I don't always have the knowledge, makes it so I write bad code.

wraith rapids
#

good, that's a good first step

#

i can't really give any concrete advice beyond git gud without seeing code, but acknowledging shortcomings is a good first step

ivory sleet
#

I mean JavaScript isn’t a object oriented fundamentally compared to Java but surely they have some similar syntax

chilly summit
chilly summit
vagrant stratus
#

Generally, static methods should be kept as utility methods

wraith rapids
#

basically, java is an object oriented language, and many of its aspects and advantages revolve around everything being objects

#

static, however, declares dissociation from objects

#

that is, something that is static is not associated with an object

#

putting 2 and 2 together and we end up with static things not being able to use or leverage most of the advantages of the language's core principles

chilly summit
#

I see. I'll not make methods static that don't absolutely need to be static any more in the future

#

Thank you

wraith rapids
#

functions without state can still be static; for example, see the java Math class

#

its methods are nearly all static and stateless

vagrant stratus
#

^ Utility class

wraith rapids
#

they take their input, perform an operation on it, and then return some output

#

they have no internal state

ivory sleet
digital plinth
#

ummm gradle is messed up

covert bluff
digital plinth
digital plinth
covert bluff
#

refresh the maven project if you are using maven

digital plinth
covert bluff
#

once you invalidate cache wait for it to finish indexing libraries

covert bluff
#

also i thin kthere is no need for consolecommandsender unless i missed something

#

commandsender if it isn't an instance of player is automatically coming from console unless im dumb

digital plinth
#

uhhh okay

wraith rapids
#

there are a million different commandsenders

covert bluff
#

sender has method sendMessage()

wraith rapids
#

command blocks, most notably

#

iirc most entities also implement commandsender

covert bluff
#

didn't think of that

#
try {
            String[] values = fileConfiguration.getString("games." + gameName + ".lobbyPoint").split(",");
            double x = Double.parseDouble(values[0].split(":")[1]); // X:0 --> X, 0 -> 0
            double y = Double.parseDouble(values[1].split(":")[1]);
            double z = Double.parseDouble(values[2].split(":")[1]);
            lobbyPoint = new Location(world, x, y, z);
        } catch (Exception e) {
            // Log the exception
            VanillaSkywars.getInstance().getLogger().severe("Failed to load spawnPoint with metadata " + lobbyPoint +  " for gameName: '" + gameName + "'. ExceptionType: " + e);
        }
        VanillaSkywars.getInstance().getLogger().info("lobbyPoint is " + world.getName() + " " + lobbyPoint.getBlockX() + " " + lobbyPoint.getBlockY() + " " + lobbyPoint.getBlockZ());

this is not working and i have no idea why

#

i've added log/debug lines but there's no errors or log

cold tartan
#

is there an event that is called when a firework is used? for some reason PlayerConsumeItemEvent isn't called when I use a firework

digital plinth
#

you should be able to check if the player is aiming at a block and is holding a firework

#

or check if the player is wearing elytra and is in the air

cold tartan
#

ok, thank you!

digital plinth
#

np

#

so what is this

#

gradle compile failure

covert bluff
#

I don't use Gradle so I honestly have no idea

torn shuttle
#

manhunt what a blast from the past

#

do people still remember that?

quick fox
#

I'm creating trying create a plugin that requires custom anvil "recipes" or whatever you'd call them. I have a class that is an instance of Listener and have properly registered it as well. This class is listening for a PrepareAnvilEvent and checks the event.getInventory() for the required items. If the items are present the method will create the output item and call event.setResult() passing in the output item. I also set the repair value too. Everything seems to work in-game, the item shows up in the output slot when the required items are in the input slots but weirdly when I try to take the output item out of the slot nothing happens. Could anyone help me here?

Here is a condensed version of my code:
@EventHandler public void onPrepareAnvil(PrepareAnvilEvent event) { if(event.getInventory.contains(Material.DIRT) && event.getInventory.contain(Material.STONE)) { event.setResult(new ItemStack(Material.DIAMOND)); event.setRepairCost(1); } }

torn shuttle
#

what's "nothing happens"?

quick fox
#

The item stays in the slot and doesn't come onto the cursor

#

its like the item doesn't exist

torn shuttle
#

if you then put the cursor in the inventory as normal does it place it anyhow?

sharp hemlock
#

Anyone know how I can get an armorstand to be close to where a nametag would be, I've tried using negative slimes and such but they never seem to be in close enough level.

quick fox
#

no

torn shuttle
#

wtf are negative slimes lol

sharp bough
#

negative slimes? wut

sharp hemlock
#

Upside down slimes

#

Essentially

#

It lowers the height of the armorstand

torn shuttle
# quick fox no

run code to see if the server is still aware that there is an item in the visual slot at the end of item creation and at the time of clicking it

torn shuttle
sharp hemlock
#

?

sharp bough
#

i have no idea how to use armor stands, but im quite sure theres a better way

#

lmao

torn shuttle
#

yeah

#

just, you know

#

offset the location of the armorstand

#

by a little bit

sharp hemlock
#

I'm trying to use them as passengers, because I don't want to have some choppy animation

torn shuttle
#

this.roleDisplay = (ArmorStand) this.villager.getWorld().spawnEntity(villager.getLocation().add(new Vector(0, 1.72, 0)), EntityType.ARMOR_STAND); here's an example of how I placed it for static entities

#

but it sounds like you should be using the teams api

sharp hemlock
#

I'm trying to use them for custom mobs essentially

torn shuttle
#

not armorstands

sharp hemlock
#

Will that work with mobs?

sharp bough
#

you want to make the player ride a custom mob?

torn shuttle
#

you'll have to check but I don't think so

#

it works on fake players

#

but not on just mobs

#

afaik

#

actually it probably does work

#

pretty sure mcmmo uses it

sharp hemlock
#

Hmm I'll look into that

torn shuttle
#

for the hearts display

#

it will likely make your plugin conflict with mcmmo though

sharp hemlock
#

What I'm trying to do is basically Hypixel's mob system

torn shuttle
#

and any other plugin that uses teams and scoreboards

sharp hemlock
#

Hmm probably not the best way but hey, it'll be useful to see if it works

torn shuttle
#

teams is the best way to do what you want to do

#

it's just that you can only have one and more than one plugin wants to use the best way

quick fox
#

@torn shuttle Ok, I ran some code that printed the items in an inventory during an InventoryClickEvent and when I click on the output slot the item that is visibly located in the slot does not appear to actually be contained withing the contents array of the inventory

quick fox
#

No the other two input items are accounted for, just not the output item

torn shuttle
#

yes, the output is empty

quick fox
#

yes

torn shuttle
#

bet I solved the murder

quick fox
#

but its visually there

torn shuttle
#

it was the maid in the bathroom with sending a packet about an item but server logic not being overriden because you didn't cancel the event and that means the server instantly overwrites your custom output with the default one

quick fox
#

oh, so i just need to cancel the event?

torn shuttle
#

maybe

#

probably?

quick fox
#

ok ill try that out

#

the PrepareAnvilEvent has no setCanceled() method so i dont think it can be canceled

torn shuttle
#

ngl shit like this is why I gave up on using anvils and made my own custom GUI

covert bluff
#

minecraft

quick fox
#

yeah, the only reason i want to use the anvil is because i want to keep the vanilla atheistic and functionality

torn shuttle
#

I can think of a few ways around it but fundamentally you should double check if the actual inventory contents contain the output

#

maybe set it manually

paper viper
#

Is the problem right now that the output is blank?

#

for the anvil

quick fox
#

yeah

#

no

#

the output is visually there, but you can't collect it

paper viper
#

Oh, that's quite.. weird

quick fox
#

yeah, no kidding

paper viper
#

maybe try calling update on the inventory

quick fox
#

I am adding some custom item meta but i dont think that should affect it

paper viper
#

Yeah, all I can say is maybe try updating the anvil inventory

#

wait

#

that method doesnt exist

#

for the anvil inventory 🤔

quick fox
#

Also I checked the contents of the inventory both during the anvil event and afterward during and InventoryOnClick event and both return the two input items but not the output

paper viper
#

how are you setting the output item?

vernal basalt
#

how do i get data from the player nbt directly

quick fox
#

im setting the output item through the event.setResult() method

#

i've also tried setting it directly through the inventory but when i do that it doesn't event apear visually

digital plinth
#

welp does anyone use gradle in here

#

how 2 fix the Unexpected lock protocol found in lock file. Expected 3, found 0. error

paper viper
#

and also for the event, idk why it would display visually but not work physically

quick fox
#

@paper viper Welp, I might just have to use another gui to achieve the goal then. Thanks for your help

paper viper
#

you may have to use the inventoryclickevent and do some weird inventory syncing, but I feel like

digital plinth
paper viper
#

idk i just dont know why

quick fox
#

yeah

digital plinth
#

deleted 6.3

paper viper
#

right?

digital plinth
#

yes

#

cache folder

paper viper
#

what about the .gradle folder

#

in your local project

#

maybe try moving that somewhere at first

#

then restart ide

vernal basalt
#

someone help

somber hull
#

does InventoryOpenedEvent get called when a player is shown an inventory via plugins?
if so, is there a way to stop/check for it

cold tartan
#

on the fireworkexplodeevent is there a way to get the firework item that was used?

stone sinew
somber hull
#

i think i got it

stone sinew
# somber hull could you elaborate?

Inventory.getHolder() | Gets the block or entity belonging to the open inventory
If its null.... more then likely a plugin made the inventory.

somber hull
#

if (inv.getHolder() == null) return;

stone sinew
vernal basalt
#

how do i view player data from the file

#

i want to be able to get info about a player even when offline

stone sinew
digital plinth
#

move it where?

vernal basalt
young knoll
#

You’ll need NMS to read the player data file

blazing ferry
#

I'm making a GUI only crates plugin (theres probably a reason why people dont do this but oh well) and my test only accepts tripwire hooks that are in stacks of one exclusively. anymore than that and it just does the else thingy thing. Heres my code:

                if (player.getInventory().contains(new ItemStack(Material.TRIPWIRE_HOOK))) {
                    player.getInventory().addItem(new ItemStack(Material.CHAINMAIL_BOOTS));
                    player.getInventory().remove(new ItemStack(Material.TRIPWIRE_HOOK, 1));
                    player.sendMessage("Aww... You didn't get the 0.001% chance for getting a good prize. Have some boots! ");
                } else {
                    player.sendMessage("You don't have a key thing in your inventory!");
                }
            }```
#

there is no 0.001% chance. dont worry about that

vernal basalt
stone sinew
vernal basalt
#

yeah that's what i need

#

i can't find a lib that reads it lol

#

so nms?

young knoll
#

Probably a reason for that

stone sinew
young knoll
#

It’s probably best to save the data you need yourself somewhere else