#help-development

1 messages · Page 1985 of 1

tender shard
#

is target a player name? a UUID as string? it doesn't explain at all what it's supposed to be

worldly ingot
#

You have a variable, target

#

What is it?

eternal night
#

in what world would you pass a uuid as a string 👀

narrow stag
#

Bukkit.getPlayerExact(args[0]));

worldly ingot
#

Right, so it's a Player

hardy swan
#

by binary incompatible do you mean only when changing the subclasses sealed under it? or recompiling the class in general

tender shard
worldly ingot
#

Seeing the issue? ;p

narrow stag
quiet ice
worldly ingot
#

addBan(target, args[1], args[2])
This is your method. You are doing addBan(Player, String, String), not addBan(String, String, Date, String)

narrow stag
tender shard
#

bruh for learn, learn java

hardy swan
quiet ice
#

what

tender shard
#

?learnjava

undone axleBOT
worldly ingot
#

You can use args, you just have to verify they're the right type

tender shard
#

choco explained 5 times already that a player is not a string

worldly ingot
#

and those types are,
String: target - the target of the ban
String: reason - reason for the ban, null indicates implementation default
Date: expires - date for the ban's expiration (unban), or null to imply forever
String: source - source of the ban, null indicates implementation default

#

Given that you're using the name ban list, the first arg should just be target.getName() instead of target

tender shard
#

no you should learn java basics

quasi flint
#

heh

tender shard
#

to understand what classes are

quiet ice
#

I think learning java bytecode is helping more there

#

Or just the basics of a stack machine to be more generous

quiet ice
#

Although, learning to read compile errors is also usefull

quiet ice
tender shard
quiet ice
#

those much be instances of those types

narrow stag
#

Guys take it easy, im new at this

#

i swear

tender shard
#

okay then look at this pls:

#

?learnjava

undone axleBOT
narrow stag
#

i don't want that thing

#

i just need a small guide

#

that it

tender shard
#

okay so

  1. you're new
  2. you don't knoiw what you're doing
  3. you don't want to know what you're doing
  4. but you still want help here?
quiet ice
#

Then you will struggle a lot more because converting a string to a date is far more complicated than one might believe

narrow stag
tender shard
#

like the syntax

#

or what a class/type is

#

you'll have a very bad time if you don't look at any of the tutorials I linked

worldly ingot
# hardy swan by binary incompatible do you mean only when changing the subclasses sealed unde...

Picture the following

public class MyClass {

    public static void hello() {
        System.out.println("Hello!");
    }

}```
I have a dependent that calls that method.
```java
MyClass.hello();```
Now I think to myself... well shit, that hello method should really return a boolean to let them know whether my hello was successful! So I change it
```java
public class MyClass {

    public static boolean hello() {
        System.out.println("Hello!");
        return true;
    }

}```
Dependent now breaks because while the parameters and method name are the same and despite the return value not being used, the method signature has changed. My dependent was compiled against and referring to `()V`, but at runtime it no longer exists and provides instead `()Z` because it has a boolean return now
#

That's a binary change in its most basic form

crisp arch
tender shard
#

good example 🙂 ||except that your second code wouldn't compile since you don't return anything||

worldly ingot
#

lol yeah

#

haha i gud

tender shard
#

if I'd be choco, i'd call myself cheese instead

tender shard
#

because cheese ise awesome

tender shard
quiet ice
#

First you need to get the current date, then parse the string duration to a java.time duration, then add the java.time duration to the current date and then you can use the time in that method

tender shard
#

lol

narrow stag
crisp arch
quiet ice
#

Parsing the string duration to a java.time duration is even more complicated because there are 10 different ways to format a duration

narrow stag
# crisp arch do you know how to code in java

Yes but not that good like professional i made some small plugins before but haven't done the ban and args before, But for some reason everyone is making fun of me. Its seems like really bad community here.

crisp arch
#

we aren't here to spoonfeed

tender shard
#

how did you call any methods?

crimson terrace
#

?paste

undone axleBOT
narrow stag
crisp arch
#

ToxicMaster you have to understand we will help you with bugs, but we won't help you learn the language or the API, when there are CLEARLY really good guides and documentation online.

#

you have to understand that

narrow stag
#

I know that

tender shard
narrow stag
#

i just wanted a small answer and how to replace the think with small guide. Im not asking anything else

crisp arch
# narrow stag I know that

we are trying to help you with documentation but if your not gonna read them, it's not the community's fault

tender shard
narrow stag
quiet ice
#

that is easier said than done

tender shard
#

have a nice day

crisp arch
#

@narrow stag choco has answered your question multiple times

tender shard
narrow stag
#

i did it

crisp arch
#

and the fact that your passing the wrong datatype into the function

quiet ice
#

I assume toxicmonster only has a javascript-like language background where types are converted automatically

crisp arch
#

and also the fact that your arguments are incorrect

crimson terrace
narrow stag
#

Bye : /

crisp arch
tender shard
#

You have to use a ShapedRecipe

#

or use different materials

crimson terrace
#

oh ok, thanks

tender shard
#

I also learnt that yesterday D:

crimson terrace
#

thats sad D:

crisp arch
tender shard
#

yeah 😦 as a workaround you could listen to the ItemCraftPrepareEvent

#

but then you can't use the recipe book

quiet ice
tender shard
crisp arch
#

honestly man

tender shard
#

just block him and move on

quiet ice
#

@narrow stag
Picture a method

public void method(String x) {}

The argument x is of type java.lang.String. If you call it with an argument of type int, for example via method(10) it will not compile, as it expect a java.lang.String

#

This is the issue you experience

crisp arch
#

🥣

tender shard
crisp arch
#

whatever

quiet ice
#

it's not really spoonfeeding as it does not solve his main issue directly

tender shard
#

oh I have to add, I don't wanna make fun of people who don't know basic java. but it's also a waste of time to answer to people who do not even WANT to LEARN IT

crisp arch
#

just wanted the answer not the logic behind it

tender shard
#

yeah he just added "String" as parameter lol

quiet ice
#

That also was not a spoonfeed

crisp arch
#

whatever its fine we move on

#

he wasnt the first of his type

tardy delta
#

can someone tell me whats the difference between an inventory click event and a inventory drag event?

tender shard
#

click = click
drag = click, hold down and move curser

tardy delta
#

isnt drag just when you move items around?

#

ah

worldly ingot
#

You can distribute items by holding down your mouse button

quiet ice
#

A spoonfeed would be
"
Use target.getServer().getBanList(BasList.Type.NAME).addBan(target.getName(), args[1], Date.from(Instant.now().add(Duration.parse(args[2]))), sender.getName())
"

tender shard
#

if you listen to InventoryClickEvent, you also want to listen to the dragevent in 99% of cases btw

tardy delta
#

and when you're dragging items, is an inventoryclick event fired too or not?

crisp arch
#

at the beginning im pretty sure

tender shard
#

that's why I said, you wanna listen to both

tardy delta
#

ok

tender shard
crisp arch
#

really?

tender shard
#

I have wasted hours into debugging

#

until I realized drag event != click event

crisp arch
wooden fable
#

Is there a way to get a player from a PrepareAnvilEvent?

tardy delta
#

and something else, in which situations can an inventory not be the top inventory?

crisp arch
#

which makes e.getClickedInventory() null

tender shard
tardy delta
wooden fable
#

Oh yes of course Thx!

tender shard
crisp arch
tender shard
tardy delta
#

oh right atleast im checking that :D

crisp arch
#
@EventHandler
    public void inventoryClick(InventoryClickEvent e) {
        if (e.getClickedInventory() == null) return;
        if (e.getClickedInventory().getType() != InventoryType.ANVIL) return;
// ...
#

i learned this the hard way

#

i kept getting NPE lol

tardy delta
#

but why can you have two inventories in a view?

#

in what kind of situations does that happen?

crisp arch
#

for example a chest inventory

tardy delta
#

oh lol

#

ty

tender shard
tardy delta
#

ye i get it

crimson terrace
worldly ingot
#

Theoretically, for funsies, you chould hold down your mouse button on a single slot for like 10 seconds and it won't update on the server at all until you let go of your mouse button

viral crag
#

the hot bar problem

sage dragon
#

We have this:
https://imgur.com/a/Vt66HIS

Which is pretty hard to look at, if you have a toaster as your pc...

I want to replace all of this by barriers (clientside) as soon as a player executes a specific command.

I've heard about PacketPlayOutMultiBlockChange, but how would that work?

And is this the packet which is being sent when the player enters a world?

spare prism
#

why do my config comments get deleted after the second launch of the plugin (bungee 1.18)?

    @Override
    public void initialize() {
        if (!Main.getInstance().getDataFolder().exists()) Main.getInstance().getDataFolder().mkdir();

        configFile = new File(Main.getInstance().getDataFolder(), "config.yml");
        langFile = new File(Main.getInstance().getDataFolder(), "lang.yml");
        dataFile = new File(Main.getInstance().getDataFolder(), "data.yml");

        if (!configFile.exists()) {
            try {
                InputStream in = Main.getInstance().getResourceAsStream(configFile.getName());
                Files.copy(in, configFile.toPath());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        if(!langFile.exists()) {
            try {
                InputStream in = Main.getInstance().getResourceAsStream(langFile.getName());
                Files.copy(in, langFile.toPath());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        if(!dataFile.exists()) {
            try {
                InputStream in = Main.getInstance().getResourceAsStream(dataFile.getName());
                Files.copy(in, dataFile.toPath());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        loadConfigFiles();
    }

    public void loadConfigFiles() {
        try {
            config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
            langConfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(langFile);
            dataConfig = ConfigurationProvider.getProvider(YamlConfiguration.class).load(dataFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
wooden fable
#

eh, ```java
e.getInventory().getViewers().forEach(HumanEntity::closeInventory);

That doesn't work correctly.
It gives an error and it does not return the items correctly (You will see the item at first but when you open the anvil again one of the items is gone.)
Err: https://pastebin.com/Sh6hTQTE
crisp arch
#

choco do u know how to use this? the documentation on UnsafeValues is pretty scarce

#

it just says String arguments

worldly ingot
#

Stringified NBT. So "Enchantments:[{}]" should suffice

crisp arch
#

Oh so it just adds nbt to it

worldly ingot
#

Yeah

crisp arch
#

alright

wooden fable
wooden fable
#

...

crisp arch
#

this is spoonfeeding but yes

#

it is the right way

wooden fable
midnight shore
#

Hi, how can i get an Inventory from a yaml configuration? I tried saving the inventory and it works (as you can see from the file)

crisp arch
#

1.12.2?

#

i dont know then lol

crisp arch
crisp arch
#

basically convert the inventory to a string without losing any inventory data

midnight shore
#

could you please help me doing that? i have no idea of how to do it

crisp arch
#

for starters

#

dont store your inventory in a YAML file

#

use sql

#

because sql can actually store binary objects

midnight shore
#

Saving

#

and getting

crisp arch
#

yes thats the issue

#

saving userProfile.getInventory() converts it to the name of the class in memory

#

so now

#

its saved as !!org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryPlayer

#

which doesnt save any inventory information

#

it just saved the class name

crisp arch
#

what values?

#

the only values i see is !!org.bukkit.craftbukkit.v1_17_R1.inventory.CraftInventoryPlayer

midnight shore
#

aren't this doing that?

crisp arch
#

ah sorry i didnt see that one sec

crisp arch
#

you need to serialize the inventory in a way where java can recognize the format

#

and convert it back into an inventory

midnight shore
#

uhm

crisp arch
#

before storing something this complicated

#

what do you need to store this inventory for anyways?

midnight shore
#

Thats not the problem but anyways i want to have multiple profiles for players, and each profile has Inventories. Where would i store this inventories? I thought of a yml file

crisp arch
#

if you dont want to use an sql server

#

use sqlite

crisp arch
#

and plus, yaml is for configuration rather then storing things

midnight shore
#

Ty btw

crisp arch
midnight shore
#

i would really like so

#

ty

crisp arch
#

kk one sec

mortal hare
#
sender.sendMessage(ChatColor.RED + String.valueOf(player.getInventory().getItem(2)));

sender.sendMessage(ChatColor.BLUE + String.valueOf(player.getOpenInventory().getItem(38)));
#

ah yes

#

one null one air itemstack

#

what's more interesting is that inventoryView.getItem() uses inventory.getItem() internally

viral crag
#

could just save the hashmap itself

mortal hare
#

but somehows returns null

midnight shore
viral crag
#

indirectly, since I am playing with yaml myself

crisp arch
# midnight shore i would really like so
#

the first one teaches you how to use the jdbc driver, which can interface with the sqlite3 language

#

the second one teaches you how to convert itemstacks to strings (serializing)

#

the third is just sqlite3 documentation if you need help with sending queries and etc

midnight shore
#

ty

crisp arch
#

yw, gl with ur plugin

mortal hare
#

i hate you bukkit api sometimes

crisp arch
#

uh

#

can i see your inventory

#

and hotbar

mortal hare
#

that's current implementation of api

#

i've decompiled it

#

that's how api currently works

mortal hare
#

that's not undefined behaviour i've found it how it works

crisp arch
#

im pretty sure this happens because a blank slot in the OPEN inventory will be air

#

so the visual inventory

#

has air

#

but the inventory in memory

#

will have null

mortal hare
#

CraftInventory.class

    @Override
    public ItemStack getItem(int index) {
        net.minecraft.world.item.ItemStack item = this.getInventory().getItem(index);
        return item.isEmpty() ? null : CraftItemStack.asCraftMirror(item);
    }

CraftInventoryView.class

    @Override
    public ItemStack getItem(int slot) {
        if (slot < 0) {
            return null;
        }
        return CraftItemStack.asCraftMirror(this.container.getSlot(slot).getItem());
    }
crisp arch
#

the slot will be air, just to make it render as nothing

mortal hare
#

that's explicitly made up

#

both return the same except that the getinventory check if itemstack is empty

young shell
#

What would you use as a Alternative to BlockData in 1.8

mortal hare
#

magic values? nbt tags?

eternal night
#

magic values yea

crisp arch
#

im pretty sure getOpenInventory was meant to be called when the player has to see an inventory visually

#

so spigot sends an air item

#

so the client can render it as air

#

and getInventory was meant for the api

mortal hare
#

NMS renders the inventory

#

not the craftbukkit

crisp arch
#

i know but getOpenInventory was meant for the visual inventory

#

so it converts nulls to airs

mortal hare
#

it grabs NMS itemstacks from internal Container object

#

why wouldnt it for inventoryviews

crisp arch
#

thats my logic anyways

#

idfk lol

#

ask like md5 or something

#

yoo does sqlite jdbc bundle with spigotapi now?!?!

eternal night
#

spigot server but yes

crisp arch
#

finally

eternal night
#

what do you mean finally

#

both sqlite and mysql drivers have been bundled forever

crisp arch
#

really?

eternal night
#

Yea

crisp arch
#

ive always had to add it to dependencies in pom

#

or else it wouldnt detect a driver

eternal night
#

they should have existed for quite a while

#

dunno how far back

crisp arch
#

¯_(ツ)_/¯

#

but ive always had to add the driver to pom

#

maybe its different for maven

tender shard
#

I still wonder

#

why are people not supposed to implement InventoryHolder

eternal night
#

because you inject an instance of a class from your plugins classloader into the server

#

if your plugin, for whatever reason, disables the server will not enjoy that

#

not to even talk about reloading

tender shard
#

e.g. ChestSortAPI, ItemsadderAPI, ...

#

WorldGuardAPI

eternal night
#

wat

tender shard
#

well

eternal night
#

you depend on the classloaders of those plugins

#

when you softdepend

tender shard
#

if some plugin calls a method from WorldGuardAPI it also breaks other plugins if WorldGuard now gets disabled

#

and if some plugin does InventoryClickEvent.getHolder() it returns an inventoryholder, and not e.g. my custom object

#

well of course it returns my custom object but

#

it won't break anything

eternal night
#

Well the plugins don't care

#

the server does

#

all of the sudden it holds onto an instance of your class loader

#

if you reload (e.g. close and reopen) you now have dangling instances flying around

tender shard
#

I've never seen custom inventoryholders break anything and I even do /reload very often to test out things

turbid bay
eternal night
#

yes it isn't likely to break

#

it may however

tender shard
#

tl;dr: it creates entities (NMS) and then sends packets to players to let them know this entity exists

turbid bay
tender shard
turbid bay
#

Yes

tender shard
#

hm I don't know

#

they also have examples o nthe spigot page

#

but tbh it looks a bit weird, the author even uses weird package names like NPC.Events.Interact

#

If I was you, I'd use another library for NPCs instead

hasty prawn
#

Citizens

turbid bay
tender shard
warm stirrup
#

Guys in your file "plugin.yml" how many spaces do you use in commands

tender shard
turbid bay
tender shard
#

wdym "using spaces in commands"?

warm stirrup
hasty prawn
tender shard
turbid bay
#

( what does it mean "wdym" pls x)) )

tender shard
#

wdym = "what do you mean"

turbid bay
hasty prawn
#

Hell it already even supports 1.18.2 lol

turbid bay
tender shard
#

yeah citizens works fine on 1.18.2

#

if you use 1.18.1, you have to use the second-last version of citizens

lapis widget
turbid bay
#

it's a little project between friends and I can't afford 10 euros for a plugin that's why I'm looking for an alternative

crisp arch
#
com.mojang.brigadier.exceptions.CommandSyntaxException: Expected '{' at position 0: <--[HERE]```
#

no context

#

i just get this in console

quaint mantle
#

yeah read the spigotmc page

turbid bay
hasty prawn
#

It's for donations

turbid bay
#

is it important to know how to code to use plugins?

hasty prawn
#

Not to use them

#

You should understand YAML though.

river oracle
#

It's important to know how to read yaml

#

Oh oops lop

crisp arch
#

yall know why im getting this error?

[11:41:44] [Server thread/ERROR]: null
com.mojang.brigadier.exceptions.CommandSyntaxException: Expected '{' at position 0: <--[HERE]
#

theres no context

#

no line of code

river oracle
#

What

#

How do you miss a curly brace

#

Are you not using an ide

turbid bay
#

then I confess to you the problem being French is that there is no tutorial

viral crag
#

you have more close braces than open

quaint mantle
#

hey cuties

turbid bay
crisp arch
#

it compiles fine

viral crag
#

welcome to java

river oracle
crisp arch
#

plus it doesnt even look like its my issue com.mojang.brigadier.exceptions.CommandSyntaxException

#

it looks like mojang forgot a brace

#

LMAO

river oracle
#

Idek never used intellij

#

Oof

viral crag
#

a missing open brace may not generate an error unless the main cannot be closed

crisp arch
#

whats weird

#

is the fact that my plugin works fine

#

no bugs

#

it just throws this error

#

i would silence it but i want to know whats going on

river oracle
#

Hmmm lol

crisp arch
#

heck how do i even silence it i dont know whats causing it

sage dragon
#

Hey \o

I want to change a massive amount of blocks clientside, how would I go about this? 😅

viral crag
#

it is likely in a failure statement or a section of code that is not called

crisp arch
#

maybe

#

hm

viral crag
turbid bay
#

i need to install citizens api ?

crisp arch
#

ok ill update yall once i figuire it out ig

sage dragon
viral crag
crisp arch
#

unless your talking about a mod

sage dragon
crisp arch
#

ok so then you need nms

#

send the block packets to some players

sage dragon
# crisp arch nms

I know how to change one block at a time, but that's going to drag a massive lag

crisp arch
#

it shouldnt have massive lag

#

since its only client side

#

and for some players

#

and its nms

#

how many blocks are we talking about here?

sage dragon
sage dragon
viral crag
#

what would be the purpose of having specific players see nonexistant blocks?

hasty prawn
#

You could probably be smart about the order of blocks you send, if you send all the outside ones first then the client isn't trying to render them all, because the ones it's receiving are obstructed anyways?

dry beacon
#

Hey, I'm probably making a really dumb mistake, though the whole event isn't working and intellij says my event was never used for some reason, any help is really appreciated! https://pastebin.com/m86m3xpz

viral crag
#

when the players that can see them go and stand on those blocks the server will likely boot them out

sage dragon
dry beacon
#

;-;

#

thank you!

viral crag
#

virtually replacing the blocks with air does not mean they are rendering any less blocks/chunks

sage dragon
quaint mantle
#

Cope

#

Harder

#

Tell them that

#

🤭🤭

ivory sleet
#

I mean Litch, try the most straightforward approach before immediately just throwing it away lol

viral crag
crisp arch
#

maybe we can figure something less lag intensive

sage dragon
viral crag
#

tell them to turn off shaders

sage dragon
#

Shaders?

crisp arch
#

you can use nms to send client side worldborders

viral crag
sage dragon
sage dragon
viral crag
#

the client settings are their choice, if they do not wish to reduce quality to improve their performance..

#

if they have optifine installed, make them switch to sodium

#

that will cut their render distance request from the server in half

sage dragon
quaint mantle
#

First, what server version?

sage dragon
#

1.17.1

quaint mantle
#

Might be different for each version

#

alright

viral crag
#

fyi it would be easier just to push them a custom texturepack that has no transparent blocks, but that will still not help the issue

sage dragon
quaint mantle
viral crag
sage dragon
#

You can 🤔

viral crag
#

how depends on what you are using for a client

sage dragon
viral crag
#

oof

#

well you cannot modify lunar clientside

quaint mantle
#

Google is your best friend

viral crag
#

state machine - if match do this

smoky oak
#

a switch is a if/else BUT it runs everything from the if it hits until it either a return or a break keyword

viral crag
#

no, a switch is not if-else

smoky oak
#

its called fall through

#

unless you add 'break' in it

#

everything from the 'case' it finds first gets executed

#

including the case: statements below

viral crag
#

use yeild

#

Switch Case L is valid for java 16+

smoky oak
#

you can, but maybe you should look into using Tag.isTagged instead of endsWith()

lean gull
#

can someone explain to me what a command map is

smoky oak
#

fruit?

tender shard
#

why are you using .equals() for barrels?

viral crag
#

find where it is copying the object and destroy the original - likely it is probably fixed in teh official code

smoky oak
#

on a different topic, does the client send a movement packet when the player is walking into a corner, not moving but holding w?

tender shard
#

looks fancy

viral crag
#

you get the drop there and it does not destroy the original unless it is deeper

tender shard
#

ExoticGarden, harvestFruit

#

lol

#

why do I get vacation vibes from that code

viral crag
#

no

tender shard
#

the code you sent even runs for cancelled events

#

you want to return if the event is cancelled, I guess

quaint mantle
#

for the top if statements you could probably use an or || to reduce "if"

viral crag
#

it checks that there is something to harvest and then drops a block if there is. there is nothing about removing the original

quaint mantle
#

ah

tender shard
quaint mantle
#

yes

tender shard
#

ok. thursday?

quaint mantle
#

bett

viral crag
#

that is the event you are looking for

tender shard
#

as said - don't run that code if the event was cancelled already

viral crag
#

e.getClickedBlock().getWorld().dropItemNaturally(e.getClickedBlock().getLocation(), item); there is nothing here that says remove the original...... which leads me to belive the trees do not naturally spawn fruit

#

if they do not, everytime you destroy the original you will have less fruit in teh world

smoky oak
#

how do i cancel a bukkit runable from inside itself

#

(a workaround would rely on yet another static HashMap)

crisp arch
smoky oak
#

huh

#

might work

#

imma try

#

on a different topic anyone knows if i need to set player.isGliding(true) every tick or is it enough to do it once?

#

(for them to keep staying in the gliding state without having an elytra)

crisp arch
#

if they are on the ground

#

they will automatically stop gliding

smoky oak
#

ah no in the air

crisp arch
#

but if they are in the air

smoky oak
#

so i only need to do it once

crisp arch
#

pretty sure

smoky oak
#

k

crisp arch
#

but ive never used isGliding before

crisp arch
smoky oak
#

1 sec

lethal python
#

apply NBT tag to item only while in specific slot

#

hi peepl

smoky oak
#

so i just found out

#

changing a player's attributes is something that persists over relogs

#

(not sure about restarts yet)

viral crag
grim ice
#

that isnt that useful

smoky oak
#

remove the .clone() and that should fix it

grim ice
chrome beacon
#

So it stores entities?

crisp arch
crisp arch
#

and recommended if you want to store small amounts of data

smoky oak
#

i dont use attributes to store data

#

i just found it out because it persisted

crisp arch
#

:)

#

thats why its part of the PDC

#

attribute use PDC to store data

grim ice
#

make an entity into

#

a namespacedkey

#

and a namespacedkey into an entity

chrome beacon
grim ice
#

that shouldnt be used

#

by users

chrome beacon
#

Aight

viral crag
#

i did not look for anvils specifically, but this is old code. I saw the reference that it used to use heads

chrome beacon
#

I just guessed it's use by the name

crisp arch
viral crag
smoky oak
#

well

#

time to lag my server by doing some bullcrap in onMove

viral crag
#

shouldnt affect your server - and if i recall somoene else's code it gets cancelecd after one tick

smoky oak
#

the issue is i have no idea how to do that particular code

golden turret
#

i thought it was the same as

Map<Object, Object> map = new HashMap<>();
Map<Object, Object> otherMap = new HashMap<>();

map.put("a", otherMap);
otherMap.put("b", "c");```
smoky oak
#

im fairly sure player.isGliding() returns false in onMove

golden turret
smoky oak
#

how do i then persist the gliding state without it persisting on the ground?

viral crag
#

they had to keep the state persistent to prevent the server from canceling it automatically.... i think is how it worked

crisp arch
#

make a BukkitRunnable

#

onMove can call like a hundred times a tick

smoky oak
crisp arch
#

BukkitRunnables can be scheduled to run 1 time a tick

crisp arch
lean gull
#

anyone have a good tutorial on lambdas?

smoky oak
#

k tho

#

how do i know when to cancel the state due to players looking up or landing?

sick ermine
#

Does it make sense to use hibernate in my spigot projects

crisp arch
#

iirc

smoky oak
#

its deprecated because it is dependent on the client

#

tho what the heck does a player want to abuse THAT for

crisp arch
#

hm yea i ralized

smoky oak
#

i can just use that lol

crisp arch
#

no dont

#

dont use deprecated methods

#

i think you should just check if the block under the player is a block

smoky oak
#

that isnt air or flowing water

crisp arch
#

^

viral crag
smoky oak
#

?

#

wdym

viral crag
#

i cant find a link to their github offhand

brittle loom
#

Hello, whenever I spawn an armour stand using this code (https://pastebin.com/4xmxbBNQ) the location of the particle I'm spawning is at the right location (tip of the arm location), but when I try moving the armour stand using vectors (https://pastebin.com/y70riPLR) the location gets moved further away from the armour stand and the particle isn't getting displayed at the players hand location. I've spent hours trying to figure out what I'm doing wrong but I can't seem to figure out how to get the hand location while the armour stand is moving, if anyone could help it would be much appreciated.

smoky oak
#

eh the method you gave me will probably work

#

also theres still no jump event in the api and its bloody annoying

crisp arch
#

wait

#

let me see if there is a jump event

viral crag
#

why would there be if there is a flying event?

crisp arch
#

since the PlayerMoveEvent has a #getFrom() and #getTo()

#

you can just find the delta y

lethal python
#

wouldn't that then trigger if player moved up by piston or bounces off bed/slime

#

question mark

crisp arch
#

yes it would

#

but if you look at it in practice, what plugin wouldnt consider being pushed by slime or etc a jump?

lethal python
#

a jump counting plugin lol

#

or a double jump ;o

#

that would be so cool doubl jump plugin

chrome beacon
#

Double jump can be done in vanilla. Anyways you can use the jump statistic to detect jumps

crisp arch
#

define harvest?

smoky oak
#

bleugh

#

i just realized

#

you're shadowinging

lethal python
#

shadowinging

smoky oak
#

declaring the same variable in different scopes

crisp arch
#

what is the scenario right now

#

what happens when you harvest

smoky oak
#

thats actually a server side thing too

crisp arch
#

do you know how to use commands?

#

your opening the inventory on an async thread

#

so it wont work

buoyant viper
#

why not just make bpmenu a command lolwtf

crisp arch
#

just register a command

lethal python
#

pizza guy i have sent a message in the thread for when u have answered everyones questions

crisp arch
#
fruit.getWorld().dropItemNaturally(loc, fruits);
fruit.setType(Material.AIR);
#

?

#

you set the item to air after dropping

#

if you drop the item, you cant change the material like that anymore

#

you should change the material to air before dropping

viral crag
#

while you are fixing it, you might want to switch switch from using Material ....

lethal python
#

mr pizza another message in the thread 😔

viral crag
#

incidentally, it looks like BlockStorage could use the other version: public static void clearBlockInfo(Block b, boolean destroy) {
clearBlockInfo(b.getLocation(), destroy);

grim ice
#

btw

#

Spigot is a framework, right?

viral crag
#

tacos are food?

crisp arch
#

its more of an api because it interfaces with the game

smoky oak
#

not a complete api tho

grim ice
#

how is it an api

#

well it kinda is ig

lethal python
#

u interface with the server

viral crag
#

it gives you access to functionality

grim ice
#

I know but like

#

it controls the flow of the software

#

not you

#

you only control a certain portion

crisp arch
#

it doesnt control any flow

#

it doesnt modify anything on the server

#

no functionality has changed

#

youve only added third party functionality

viral crag
#

it does not do anything by itself

crisp arch
#

exactly

grim ice
#

"it"

crisp arch
#

the plugin

grim ice
#

what is it you're mentioning

#

im talking about spigot

smoky oak
crisp arch
#

if you just ran the plugin with the spigot "framework" without a server running

#

it would do nothing

#

you need a working running server for the plugin to work

#

which makes it an api

grim ice
#

o

crisp arch
#

it takes a lot of courage to admit your wrong so i respect that

grim ice
#

nah i knew i was missing about this topic

#

thats why i asked here

crisp arch
#

lmao

viral crag
#

the blackbox test is usally a good way to determine what you are working with

ivory sleet
#

Some of spigot are framework classes tho

chrome beacon
lost matrix
# grim ice what even is that

You send a signal in and detect the signal that is coming out without knowing what the internals of the blackbox are.

#

Your signal is x and your outcome is y. Sometimes this is enough to derive f where f(x) = y from.

viral crag
#

if the blackbox does nothing by itself, it is nothing. If there is input and output, it is a function or a class. If there are functions to access that produce a result it is possibly an api or library

#

you can determine other aspects as well, its just an overview or evaluation

crisp arch
#

programmers use the weirdest metaphors

smoky oak
#

not just programmers

#

screw politicans

sacred mountain
#

what are the benifits/differences of using java.lang.<type> instead of the "int" "float" "double" "boolean"

#

i know for one that you can null check them

crisp arch
#

the natives are just there to be datatypes

smoky oak
#

well lang cant be used in Set<E>, you need to use Lang, but that's about the extend of my knowledge

crisp arch
#

yes

#

you cant use natives in type parameters

#

List<int wouldnt work butList<Integer> works, because Integer has utility functions that List can use in it's methods

sacred mountain
#

is there a performance difference or can i just use whichever

crisp arch
tall dragon
#

I feel like it would be weird if list uses util functions from integer

#

As anything can go in a list

lost matrix
grim ice
#

would making a class that holds an int in it, and then a list of it, be better than a list of Integer s

crisp arch
#

int stores the binary data

#

but Integer is the wrapper for int

lost matrix
#

Integer has features like auto unboxing which you couldnt implement with your own wrapper class.

grim ice
#

performance

ivory sleet
#

IntList 😌

crisp arch
#

Integer is just the class representation of int

#

since you cant do int#toString(), you do Integer#toString()

eternal night
#

valhalla wen

quiet ice
#

Non-generic collections are always a lot faster than the generic counterparts

ivory sleet
#

I mean there’s a separate Class<T> instance of int as opposed to the Class<T> instance of Integer

quiet ice
#

Especially if you are extra specialised they can be orders of magnitude faster

crisp arch
#

the performance impact is minimal, isnt it?

ivory sleet
#

Integer.class and Integer.TYPE (:

tall dragon
viral crag
crisp arch
#

but dont ask me i didnt write java

#

i just use it and try to figure out its workings

quiet ice
#

So the difference can be HUGE, especially for maps as you avoid all the hashing which can be costly

crisp arch
#

well yea of course, one line of code runs faster than 2 lines of code lol

quiet ice
#

Not really

viral crag
#

how many people crunch mainframe scale data?

grim ice
ivory sleet
#

Yeah all the unnecessary boxing and possibly unboxing could scale quite badly

quaint mantle
quiet ice
#

(~a && ~b) || (a && b) for example is going to be as fast as a == b

grim ice
#

or was that sarcasm

tardy delta
#

maths ew

grim ice
#

for () {} can be faster than streams in hot methods

#

but it is longer

quiet ice
#

It is always going to be faster

grim ice
#

wha

viral crag
#

in small, non-blocking functions on the last few generations of processors, the difference is almost immaterial time-wise

quiet ice
#

for () {} is basically an iterator, Streams are basically an iterator, with a lot more stuff going on in the background

quiet ice
grim ice
#

and eitherway that rule pizzaguy said is really wrong

#

for example interacting with a database

#

it should be done off thread

#

which will take more lines of code

smoky oak
grim ice
#

but would be better than doing it in the main thread

ivory sleet
#

Thing is it all boils down to what instructions the compiler compiles

quiet ice
# smoky oak what the hell does ~ do

invert all bytes. That being said my statement only applies to booleans (and thus this statement does not work in java world - only in booleanic algebra)

viral crag
#

yes/no

grim ice
#

@ivory sleet why hate lombok

eternal night
#

oh no

sleek pond
#

Does the respawn event get called when a player spawns after logging in?

quiet ice
#

However it also comes down to what sort of database. Flatfile DB queries can be on-thread as ideally you'd have no IO due to caching

crisp arch
hasty prawn
#

Lombok smh pepecop

grim ice
#

why is lombok bad

sleek pond
quiet ice
#

poor IDE support

grim ice
#

wat

#

it works cool with intellij

sleek pond
#

Why does this Lombok conversation happen all the time

quiet ice
#

IntelliJ is not the only IDE

eternal night
#

I mean, you also have records now anyway

smoky oak
#

it does not get triggered

eternal night
#

besides @Delegate not much need for lombok

grim ice
quiet ice
#

Technically Delombok is great, lombok's eclipse plugin is incredibly bad

grim ice
#

no

quiet ice
#

There is no reason to use java 8 nowadays

#

Like nada reason

eternal night
#

if you still are on jdk 8 you are about to be surpassed by commercial java apps

#

at which point you know you are legacy

grim ice
#

welp

#

as long as i can use streams

quiet ice
#

You are missing out on a lot

grim ice
#

(that was sarcasm)

quiet ice
#

my favourite J10+ feature is InputStream#readAllBytes

eternal night
#

my fav is var :>

quiet ice
#

oh yeah, that one is nice too

smoky oak
eternal night
#

also just all the additions to streams/optionals after java 8

#

huh ?

#

what do you need explained about var

smoky oak
#

no what does that operator do

eternal night
#

it infers the variable type at compile time ?

smoky oak
#

whats that good for?

eternal night
#

I mean

quiet ice
#

Not typing out huge nested generic statements

grim ice
ivory sleet
grim ice
#

owo

#

apache

quiet ice
#

Isn't that lib for removal now?

grim ice
#

or guava

quiet ice
#

Would you like to type out
Map.Entry<Map.Entry<Integer, Integer>, Map.Entry<Integer, Integer>> for example

grim ice
#

ByteStreams.toByteArray

grim ice
#

from an idiot perspective btw

#

aka me

viral crag
#

Why write code at all if Lombok does it all for you? "Project Lombok is a java library that automatically plugs into your editor and build tools, spicing up your java.
Never write another getter or equals method again, with one annotation your class has a fully featured builder, Automate your logging variables, and much more."

ivory sleet
#

Who cares about aesthetics

quiet ice
#

I mean, we all have used wrappers around it, but they will all have performance impact as there is no way to estimate the full size of a stream

grim ice
#

and if its a file u can use Files class

eternal night
#

smh imagine using file instead of path

grim ice
#

the method accepts Path tho

quiet ice
#

Also, I am sure that a lombok hashcode will be less performant than a hand-written hashcode

grim ice
#

so u will .toPath()

viral crag
ivory sleet
#

Problem with Lombok hashCode is that I have no clue whatsoever how it deals with the hashing

#

Sure it’s possible to find out

quiet ice
#

Probably an Objects#hashcode wrapper

ivory sleet
#

But then what happens when I want to change it

eternal night
#

The "probably" already tells you why lombok might not be the best

#

lol

ivory sleet
golden turret
#

guys

#

how could i detect when my hook lands on the water?

viral crag
#

blockstate change is my guess - since there will be a change when the two interface

golden turret
#

how could i detect when the line of the fishing rod breaks?

viral crag
#

its inside the dropItemNaturally() - and I think I gave you the instruction to fix it abouve

#

LowOnEspresso — Today at 10:52 AM
incidentally, it looks like BlockStorage could use the other version: public static void clearBlockInfo(Block b, boolean destroy) {
clearBlockInfo(b.getLocation(), destroy);

#

change the clearBlockInfo to use the destroy version

grim ice
#

I know js isnt similar to java

#

but just to clarify

#

are they similar

lethal python
#

java is short for javascript

grim ice
#

not the word

lethal python
#

bird is the word

#

i 🤐 now

eternal oxide
#

Java and Javascript are quite different

lethal python
eternal oxide
#

Not the same

smoky oak
eternal oxide
smoky oak
#

the fact alone that you can add strings and numbers

#

just no

lethal python
eternal oxide
#

JavaScript is a lightweight programming language(“scripting language”) and is used to make web pages interactive. It can insert dynamic text into HTML. JavaScript is also known as the browser’s language. JavaScript(JS) is not similar or related to Java. Both the languages have a C-like syntax and are widely used in client-side and server-side Web applications, but there are few similarities only.

lethal python
#

fake

smoky oak
#

how about pointed_dripstone

cursive crow
#

any idea on how to check the first slot of an anvil?

smoky oak
#

get inventory slot <whatever the slot is>

#

someone link the spigot thread

cursive crow
#

right

#

so the anvil's inventory is a normal inventory but with only 3 slots?

smoky oak
#

technically the inventory is the combination of anvil and player inventory

#

since it's a GUI and not a block with storage

#

as such the anvil uses the inventory interface with three extra slots shoved in front of the player inventory

viral crag
cursive crow
#

the amount of nested if statements my plugin has would make a competent programmer cry

smoky oak
#

now im curious

#

show me

#

?paste

undone axleBOT
viral crag
#

"Interface to the various inventories. Behavior relating to Material.AIR is unspecified." What a strange note

eternal oxide
#

convert too many if statements to variables and switches if you can

cursive crow
#

hasn't air not been an item since 1.7

smoky oak
#

about the same time water sources stopped being a thing i believe

viral crag
smoky oak
#

not all materials are allowed to be items

#

by the way

smoky oak
#

how to separate flowing water and water? There's just one non deprecated water material

onyx fjord
#

ik its not a programming question, but since git is associated with programming ill ask it anyway

i have added remote upstream to my git repository, i see all remote branches on my pc (local repo) but its not visible on github page, what do i need to run to show all the branches on github repo

smoky oak
#

thanks

viral crag
#

I have not actually figured out how that translates into flowing water on a level surface - maybe any non-zero is flowing?

smoky oak
#

prob like this

#

((Levelled) b.getBlockData()).getLevel()

viral crag
#

a level of 0 corresponds to a source block, 1-7 regular fluid heights, and 8-15 to "falling" fluids.

smoky oak
#

yea i just need to check != 0

#

also boolean operators work in sequence, right?

viral crag
#

what do you mean in sequence ?

smoky oak
#

le block b

if(b.getType() == Material.AIR
  || b.getType() == Material.WATER
  && ((Levelled) b.getBlockData()).getLevel() != 0)

afaik the second part will not trigger if the first is true and the third wont trigger unless the second's true

#

but im not sure

viral crag
#

in java I do not think that will achieve what you want

smoky oak
#

actually

#

the order of the conditions matter

#

unless they're mutally exclusive then both get checked afaik

#

imma just tryy

#

okay

#

unless doing (Levelled) block.getBlockData() on an air block returns a non null instance of Levelled

#

conditions get checked in the sequence they'rein the code

#

GOD FUCKING DAMMIT

#

i found a bug

#

in spigot

#

well its probably a feature

#

but its messing me up nonetheless

#

uuuurgh

hasty prawn
#

what the bug

viral crag
#

you dont need to check teh level of teh air

smoky oak
#

changing gamemodes RESETS the isAllowedFlight value

#

why

hasty prawn
#

that makes sense

#

You wouldn't want people in Survival to have allowed fight PauseChamp

smoky oak
#

actually i do

#

i flag a group of players with isAllowedFlight, then cancel that event to trigger another

#

that way i can detect someone pressing spacebar in the air

#

uuuurgh

#

but im an admin on my test server

#

so i fucked over myself

#

first world provlems

hasty prawn
#

Listen for PlayerGameModeChangeEvent and then set allowed flight back to true then

smoky oak
#

yea...

#

more work

#

yay

#

also its literally only helpful for admins

#

😄

viral crag
smoky oak
#

yea correct

#

if its air

#

the second part of the if statement does not get run

#

because a or (b and c) gets checked in order if not a then b, if b then c

viral crag
#

i think without the extra brackets limiting the test to water, it will pass on lava ...

smoky oak
#

actually unless i make sure its a water/lava block it probably will just break

#

Levelled is a interface for flowing fluids and cauldron height

#

but there's probably undefined behaviour for parsing blockdata to levelled for anything else

viral crag
#

also unsure if powdered snow is now part of levelled

lost matrix
#

Material#isAir()

smoky oak
#

is that faster than material == Material.AIR ?

vague swallow
#

?paste

undone axleBOT
viral crag
#

isAir() is the new method

smoky oak
#

wasnt the question

young knoll
#

It checks all 3 air types

lost matrix
smoky oak
#

say what now?

#

what other air is there supposed to be

#

like

#

air is everythign that isnt

young knoll
#

cave air and void air

smoky oak
#

. . .

#

WHAT.

#

why is that a thing

#

what for is that a thing??

viral crag
#

new generation

young knoll
#

Cave air is used in worldgen

#

Void air is the default for a block outside the world

vague swallow
#

For some reason I'm getting this error when I'm trying to change a line of a SignChangeEvent:
https://paste.md-5.net/nivovezuhu.sql

This is my code:

@EventHandler
public void onShopCreate(SignChangeEvent e) {
    Player p = e.getPlayer();
    e.setLine(4, "---------------");
}

Does anyone know why?

smoky oak
#

programming languages start counting at 0

#

signs have 4 lines of text

#

do the math lol

young knoll
smoky oak
#

java is one of them

#

i didnt even needed to check the error XD

viral crag
#

zero is a number because it means none!

smoky oak
viral crag
smoky oak
#

zero and null is only equal in javascript

#

sometimes

#

but not always

sour socket
#
                foreach (String line in plugin.getConfig().getStringList("bossbar")) {
                    // TODO: write some code
                }
#

line in doesn't work here

hasty prawn
#

Because thats not java

sour socket
#

mkmk

hasty prawn
#

for(String line : plugin.getConfig().getStringList("bossbar"))

sour socket
#

I have tabnine (AI code assistant)

#

Oh kk

quiet ice
#

AI probably isn't meant to be used in 100% of java dev as of today

#

Perhaps in the future it can be used to develop 100% of the code

viral crag
#

tabnine has lots of broken code in it as well

vague swallow
#

Thanks, I'm always forgetting that it starts at 0

viral crag
#

binary start at 0/1 and so do computers

#

it seems to pull from many places, but it has lots of broken and out dated code. Maybe a bit less in java, not sure

quiet ice
#

Everything takes from public code

#

This is the easiest way to supply AI

visual tide
smoky oak
#

everything i ever did in lua was some kind of variable manipulation

#

but nothing with counting

brave sparrow
viral crag
#

no arrays in assembly

quiet ice
#

arrays start at 0 because of maths

brave sparrow
#

Which is all arrays really are

viral crag
#

stack pointers, yeah

brave sparrow
#

The location of the memory isn’t critical to the concept of the pointer

quiet ice
#

In java arrays behave a bit different

brave sparrow
#

Not really

#

They keep track of their length sure, but that’s the main notable difference

quiet ice
#

They are more of a vetor of pointers

brave sparrow
#

Not really

#

They aren’t resizable

viral crag
#

if I recall, in java the array constructor does not require everything to be the same as it does in other languages

quiet ice
#

Well, vectors do not need to be resizeable

brave sparrow
#

A vector is a data structure backed by an array

quiet ice
#

In java that may be the case, but not in mathematics in general

brave sparrow
#

Java arrays are much closer to a C style array than a vector

quiet ice
#

I used vector quite knowingly because otherwise I had to fall back to list or array, which would basically fall back to array

brave sparrow
#

The only difference is that it has an attached attribute telling you its size

quiet ice
#

So I'd define x with x

viral crag
#

[<number>, <string>, <bool>]

#

constructs like a matrice

brave sparrow
#

Everything non-primitive in Java extends from Object, so you can have an object array

#

That’s not the array behaving differently, that’s the language treating many different things as having a common base

quiet ice
#

well in C arrays are just objects squished together

brave sparrow
#

No

#

In C an array is a block of memory

quiet ice
#

the pointer of the array is the pointer of the first object

brave sparrow
#

The type tells you how big each index is

lost matrix
#

C doesnt have objects. You can just randomly allocate 10 bytes in memory and call it an array

quiet ice
#

Yeah, basically falls back to the same thing

brave sparrow
quiet ice
#

However in java non-primitive arrays are basically (header <point>, <point>, <point>) where in C it'd be (<instance>, <instance>, <instance>)

brave sparrow
#

You can have a pointer array in C too

#

Again, it’s not the array behaving differently

#

Non primitives in Java are always pointers

viral crag
#

"In Java, array is an object of a dynamically generated class. Java array inherits the Object class, and implements the Serializable as well as Cloneable interfaces"

brave sparrow
#

Java doesn’t have non primitive values that aren’t pointers