#help-development

1 messages · Page 1374 of 1

quaint mantle
#

use logic dude

#

if () {}

else {}

paper viper
#
if (block.isBlockPowered()) {
...
}else if(!block.isBlockPowered()){

uh @quaint mantle what is this code?

#

you dont need to do it twice

#

lol

quaint mantle
summer scroll
#

Ah, so It's possible. Is it complicated tho?

paper viper
#

what lol

ivory sleet
#

You need brigadier and commodore

quaint mantle
#

getType().equals(Material.LEVER) ❌
getType() == Material.LEVER ✅

ivory sleet
#

Then it’s all possible (:

paper viper
#

(:

ivory sleet
#

Yes but that’s without commodore

#

Though it’s just a single method call to hook into that

earnest junco
#

Literally the same. What do you think forEach internally calls?

ivory sleet
#

He also forgot the method reference 👀

paper viper
#

Yeah lol

lost matrix
#

This is the reason why people trash talk lambdas.
Horrendous.

ivory sleet
#

It looks fine to me

paper viper
#

^^

lost matrix
#

lol

paper viper
#

I mean with commendore you put that into a file

ivory sleet
#

Not rly

paper viper
#

the structure at least

quaint mantle
ivory sleet
#

That’s optional

quaint mantle
#

🙂

paper viper
#

id rather do that then do like 20 conditionals

#

lmao

ivory sleet
#

The nesting may be somewhat obnoxious

#

But I wouldn’t say horrendous

paper viper
#

Well yeah but that is necessary for tree structure

lost matrix
paper viper
#

then show me what u got

#

command handling was always dirty lmfao

ivory sleet
#

Fortunately he isn’t working for a company

quaint mantle
#

HAHA

lost matrix
paper viper
#

?

#

could you elaborate

lost matrix
#

when my lecture is over

ivory sleet
#

I usually make my design such that any sub commands of a command may only be exposed with in that specific command instance and not any higher. But it also has drawbacks.

#

I think it’s possible to accomplish that with brig also

quaint mantle
#

lambdas are colorized brainfuck

#

a.b(s -> c())

ivory sleet
#

Idk

#

They’re essentially better expressed anonymous functions in my opinion

olive lance
#

getItemMeta can return null when?

quiet ice
#

Lambdas > Anonymous classes

paper viper
#

arent they also slightly faster?

ivory sleet
olive lance
#

is the default name of real items not itemmeta

#

like just wooden axe

ivory sleet
#

Sure java compilers might actually optimize lambdas

paper viper
#

Yeah

olive lance
#

yo

#

so when does hasItemMeta return null?

paper viper
#

wot?

ivory sleet
#

never

#

?

paper viper
#

yeah lol

#

it returns boolean

#

which is primitive

olive lance
#

uh

#

telling me it may return null wtf lol

paper viper
#

thats no way possible lmao

summer scroll
#

he's talking about getItemMeta

paper viper
olive lance
#

oh i know why

#

its cause getItem

quiet ice
#

Or for some reason hasItemMeta returns java.lang.Boolean

olive lance
#

may be air

summer scroll
#

scroll up a little bit xd

summer scroll
quiet ice
#

Probably not

paper viper
#

cause that would be nasty af

#

lol

quiet ice
paper viper
#

^

ivory sleet
#

I mean getItemMeta returns null if the ItemStack has material air but then again it’s actually stated in javadocs iirc

quiet ice
#

Javadocs are really strange

summer scroll
quiet ice
#

It's either you read the javadoc but do not listen to the annotations, or the other way around. There are too many instances where the javadocs say that it can return null, while the method annotation says otherwise

lost matrix
worldly ingot
#

I'd trust the annotations over the doc comments

quiet ice
#

Better save than be sorry, the annotations do not enforce themselves

worldly ingot
#

Annotations are more up-to-date than the docs are

worldly ingot
#

Keep in mind that sometimes implementations change while API docs do not

brittle nova
#

same as here

worldly ingot
#

Block#isBlockPowered() isn't quite what you want to check whether or not a lever is activated

#

You need to poll from its BlockData

#
Switch lever = (Switch) block.getBlockData()
if (lever.isPowered())```
olive lance
#
            if (e.getClickedBlock() == null) return;
            if(e.getItem().hasItemMeta()){``` so were sure hasItemMeta isnnt going to return null here?
worldly ingot
#

hasItemMeta() cannot return null, it returns a primitive boolean. getItemMeta() will only ever return null if the item type is air

#

Generally when creating a new item I'll do this:

ItemStack item = new ItemStack(Material.STONE);
ItemMeta meta = item.getItemMeta();
assert meta != null; // Because this is theoretically impossible, if it returns air... this is a bug in Spigot, we can assert that this is true```
brittle nova
worldly ingot
#

👍

#

Btw, unless you're doing something with those blocks, you don't have to make variables for them

#

Just do a world.getBlockAt(32,102,-64).setType(Material.OAK_PLANKS) instead. Halves your code size

ripe sparrow
#

Hi, I want to implement method to detect best suitable slot for specific ItemStack, what would be the best place to include this method? The best would be ItemStack, but I cannot reference NMS from Bukkit. Second best place I found would be PlayerInventory, but that is not the best solution IMO... The method I am talking about would be something like:

    public EquipmentSlot getItemStackEquipmentSlot(ItemStack stack) {
        return CraftEquipmentSlot.getSlot(EntityInsentient.j(CraftItemStack.asNMSCopy(stack)));
    }
worldly ingot
#

Yeah that's the problem with ItemStack or Material not being an interface

#

imho, Material with a switch statement

quaint mantle
#

But don't worry! Choco is PRing that update to the Spigot development API.

ripe sparrow
lost matrix
worldly ingot
#

Preference at that point PES_SadShrug

#

Dawon,

imho, Material with a switch statement
and then write a CraftBukkit unit test to ensure it's accurate for all Materials according to that method

quaint mantle
#

The new interfaces will be MaterialBlock and MaterialItem, with the block and item material references being constant registries.

paper viper
#

would the Material class be just deleted

#

or deprecated

quaint mantle
#

deprecated

worldly ingot
#

md wants compat between 1.13 - 1.16, so deprecated probably

paper viper
#

k makes sense

worldly ingot
#

I have to revisit that

ripe sparrow
#

Yea, that is exectly what I wanted to avoid, because this switch would have to be kept updated, while NMS have method just for this... :/

worldly ingot
#

There are a lot of methods in Material that could be (and have been in my PR) simplified with a single method

#

Though we're stuck with that technical debt until I can get it merged

quaint mantle
olive lance
#
        wand.getItemMeta().setLore(Arrays.asList("Left Click - Position 1", "Right Click - Position 2"));
        wand.getItemMeta().setDisplayName("Claiming Wand");
        return wand;``` why does this return a regular wooden axe
worldly ingot
#

That was my original goal and is where the PR stands today, imagine

#

getItemMeta() returns a copy, Tom

quaint mantle
olive lance
#

o

ripe sparrow
#

Ok switch case in ItemStack it is then

worldly ingot
#

Yeah, just be sure you're writing a unit test for it

quaint mantle
#
ItemMeta meta = wand.getItemMeta();
// meta.***

wand.setItemMeta(meta);
olive lance
#

mmm i see

ripe sparrow
#

Can I use the NMS method in the test, so the behaviour is the same?

worldly ingot
#

CB sided test, so yes

ripe sparrow
#

ok, thank you!

quaint mantle
#

Where do I have an error?
if(p.getInventory().getItemInMainHand())

brittle igloo
#

Hey! I'm trying to verify if the block that is broken has specific metadata. I got this in my onPlayerBreakBlock():
String displayName = event.getItemInHand().getItemMeta().getDisplayName();

It's a snippet I found on the forum but the player will not get the item in hand as I'm changing it to air and giving them a new one with ItemStack. How can i check if the broken block has the DisplayName?

worldly ingot
#

RE: Limey,
getItemInMainHand() is an ItemStack, not a boolean

#

Mekae, BlockBreakEvent#getItemInHand() probably returns null if breaking without an item but afaik that method doesn't exist on Spigot. If you're using a fork, you should be asking for support there

#

oh actually they don't even have that. lol. I don't know what you're trying to do then

queen nacelle
#

Anyone know here if there is a better way to mitigate arrow drag in water? The only way im able to think of is making a new entity that extends arrow and overrides whatever method does it

brittle igloo
#

Oh haha, the item is a hopper but ItemMeta I gave it (like displayname and lore). Now I have it set when you break the hopper it turns into air before it even reaches your inventory and dropItemNaturally(blockBroken.getLocation() will drop the one i've created with lore and all. This works fine but now all hoppers give the special item.

lost matrix
brittle igloo
#

I will look in to that, thanks!

modern fox
#

I made a thing that spawns a mob and then make a EntityDeathEvent class in the same class and checks if the mob is the same and it works but if I walk away and come back after some time and just unloads the chunk when I come back it doesn't work

modern fox
#

Yes

lost matrix
#

Then you need to register the type in the IRegitry class for your mob which is pretty complicated.

modern fox
#

I'm on 1.8.8 does this still exist?

lost matrix
#

Programmatically?

modern fox
lost matrix
#

To do what exactly?

modern fox
lost matrix
# modern fox Do I need to register every mob?

Every custom mob that should be persistent. And you should also overwrite the nbt serialization methods for saving persistent data in its NBTComponent. (save and load iirc) but dont forget to call super on them.

olive lance
#

when does Block#getLocation return null

quiet ice
#

Never

olive lance
#

it so just did for me

lost matrix
#

You need to load the world before teleporting there.
Use the WorldCreator for that

olive lance
#

pretty sure

quiet ice
#

Strange

woeful birch
#

Worldloadevent might work

lost matrix
# olive lance pretty sure

That would be very improbable. Then something made a custom implementation of the Block interface which would just be stupid unless you want to write unit tests.

lost matrix
modern fox
#

7smile7 if it wasn't NMS how would I do it?

lost matrix
lost matrix
olive lance
#

um ok so heres my error

lost matrix
#

Sure

olive lance
#

the error is from my PlayerInteractEvent handler

#

but it shows up whenever I drop an item

lost matrix
#

The clicked block is null

olive lance
#

not interact

#

i am so confused rn

#

like i press q and it says could not pass playerinteractevent

lost matrix
olive lance
#

for dropitemevent or playerinteractevent

lost matrix
#

playerinteractevent

olive lance
quaint mantle
#

dooes this server help with NMS

lost matrix
quaint mantle
#

ah ty

lost matrix
olive lance
#

why is the method getting called when i drop an item though? is it a bug maybe?

queen nacelle
#

Player interact fires when you drop items

#

If the player does ANYTHING it fires essentially except really chatting

olive lance
#

@lost matrix what about getType returning null?

#

trying to check if its air

queen nacelle
#

if the slot is empty it returns null

olive lance
#

nvm

queen nacelle
#

just null check it

olive lance
#

yes

#

i farted

lost matrix
queen nacelle
#

does getType return Air now in the inventory?

olive lance
#

i think so thats why i was confused

queen nacelle
#

I remember it used to be Air then it was null, then it was some weird thing

#

I just threw like 3 checks in and called it a day havent looked at it since

olive lance
#

like i can fix that null error smile but i still dont want it to say "land is claimed" if youre dropping an item

#

maybe i am just accidentally clicking the mouse when i press q

#

idk

lost matrix
#

Nope that event is fired when you drop an ItemStack. You should just check for some conditions like the Action type

olive lance
#

oh

#

so

#

we just have dropitemevent for convenience

elfin moth
#

hi !

olive lance
#

wait no

elfin moth
#

i can have helps plz i create my first plugin and i need helps i have big problem :x

olive lance
#

there is no drop item action

west lance
#

How do I find the offset that the block is at in terms of Y?

olive lance
#

is that a psysical action?

west lance
#

Cause I'm spawning NPCS and if it's a slab or SNOW they're stuck mid air

acoustic palm
#

hey guys, so I'm looking to make a PR to Spigot that adds the ServerTickStartEvent and ServerTickEndEvent from one of Spigot's downstreams, Paper, and I was just wondering, do I add this directly to the Bukkit repo? or do I make a patch on the Spigot repo?

olive lance
elfin moth
#

1 dev plugins can helps me plz :x?

lost matrix
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.

olive lance
#

@lost matrix dropping an item triggers RIGHT_CLICK_AIR Action

#

how to differentiate between the two?

#

@worldly ingot pls fix

elfin moth
worldly ingot
#

Just a quirk of vanilla, can’t fix it

#

Or, rather, a quirk of the way we check for right clicking air

#

It just listens for when the arm swing happens

west lance
#

Is there a thing called block state location or whatever

#

Or do I need to manually hardcode the offsets of y of each snow layer, slabs, etc?

lost matrix
hollow arch
#

If I just do ItemStack#addUnsafeEnchantment(Enchantment.DURABILITY, 1); - That should render the enchantglint, right?

olive lance
#

weird

#

doesnt the arm swing when doing basically anything though

lost matrix
hollow arch
lost matrix
olive lance
#
        ItemStack wand = new ItemStack(Material.WOODEN_AXE, 1);
        ItemMeta meta = wand.getItemMeta();
        meta.setLore(Arrays.asList("Left Click - Position 1", "Right Click - Position 2"));
        meta.setDisplayName("Claiming Wand");
        wand.setItemMeta(meta);
        return wand;
    }
    public static boolean isWand(ItemStack s){
        if(!s.getType().equals(Material.WOODEN_AXE)) return false;
        if(!s.hasItemMeta()) return false;
        if(s.getItemMeta().equals(getWand().getItemMeta())) return true;
        return false;
    }``` can anybody tell me why the second boolean function isn't returning true
unkempt ore
#

Can I store something gotten statically from the Bukkit class in a static field. I'd assume Spigot makes sure to load the classes when state is safe, right?

#

Or is there some state there

lost matrix
unkempt ore
#

Alright

#

How about the PluginManager

lost matrix
lost matrix
ivory sleet
#

static PluginManager pluginManager = Bukkit.getPluginManager(); pls dont do this ok thanks

lost matrix
#

Yes. For obvious reasons.

#

Check the portal enter event and send the player to the custom nether if he is currently in the custom world

#

Using the WorldCreator class with the Environment set to NETHER

quaint mantle
#

ItemStack mainhand = p.getInventory().getItemInMainHand();
ItemStack lefthand = p.getInventory().getItemInOffHand();
if(mainhand = Material.AIR){

        }
#

why is there an error in if(mainhand = Material.AIR) ?

#

Nevermind

#

but correct me anyway

lost matrix
olive lance
#

How do you delete an Item on the ground

#

just set it to null?

quaint mantle
olive lance
#

which one is better lol

hollow arch
lost matrix
#

Item is an entity so you just call .remove() on it

olive lance
#

thanks

lost matrix
hollow arch
#

Yepp yepp, figured, thank you regardless!

#

Silly mistake

acoustic palm
#

can anyone here tell me where I can get org.spigotmc:minecraft-server and org.bukkit:bukkit from? trying to contribute to CraftBukkit but it's missing those dependencies

#

do I need to download and apply mappings to the official server JAR then add it to Maven Local? if so, what about the Bukkit dependency?

raw swallow
#

<dependency>
<groupId>org.spigotmc....</groupId>
<artifactId>spigot</artifactId>
<version>1.16.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>

outer crane
#

spigot-api iirc

raw swallow
acoustic palm
#

I'm trying to contribute to CraftBukkit remember, not Spigot

acoustic palm
outer crane
#

its spigot-api, right?

acoustic palm
#

you gotta build Spigot with BuildTools first

#

also, yeah spigot is the server

raw swallow
acoustic palm
#

you sure you want the server, not the API?

lost matrix
acoustic palm
#

and this ^

raw swallow
lost matrix
modern fox
#

I made a thing that spawns a mob and then make a EntityDeathEvent class in the same class and checks if the mob is the same and it works but if I walk away and come back after some time and just unloads the chunk when I come back it doesn't work (NON NMS)

lost matrix
modern fox
#

?paste

queen dragonBOT
lost matrix
# modern fox https://paste.md-5.net/kakuhodoru.java (The Class)

You should never register events dynamically. The whole event handler list has to be rebaked each time you register an event. And it can lead to memory leaks really fast.
Register one Listener that delegates the event to every other class that needs it.
Now
This will be false when the entity unloads and then is spawned again because its now a new instance of the Entity class and has nothing to do with your allocated variable anymore.
e.getEntity() == getEntity()
Having hard references to an Entity is a bad idea in most cases and should be avoided. Just use the UUID for comparisons.

modern fox
#

How would I register the class?

#

and you mean would I put a metadata as UUID?

lost matrix
#

You just allocate the UUID of your mob and then check against it. If you need the instance of the mob then you can get it from the static method the Bukkit class provides where you can pass a UUID

#

Dont register a ton of listeners and dont have a variable of type Entity.

olive lance
#

sorry for dumb but how do i use the BYTE persistent data container

#

true/false?

mortal hare
#

do you guys chain methods? im wondering when should you chain methods and when you should not. I've saw some method chaining in builder classes but should you do in normal classes? Anyone have a rule of thumb? Just trying to get the clean coding practises

lost matrix
#

Create one Listener class that delegates the events to a single manager class which holds a Map<UUID, Mob>

young knoll
#

Ah... I may want to remove my dynamic listener registration then

olive lance
#

nvm

modern fox
olive lance
#

i dont really understand the persistentdatacontainers. why is there no boolean

young knoll
#

Just use a byte

#

0 for false 1 for true

lost matrix
olive lance
#

bruh i did that

#

and 0 and 1 was not working

#

maybe i was doing something wrong

young knoll
#

Or has(), set for true, unset for false

mortal hare
#

oh nvm

olive lance
#

sorry excuse the shit screenshot i had to use printscreen

#

this is when i use BYTE and 0 or 1

#

meta.getPersistentDataContainer().set(key, PersistentDataType.BYTE, 1);

lost matrix
#

(byte) 1

olive lance
#

ty

young knoll
#

I guess you could make a boolean type too if you wanted

olive lance
#

now when looking at items for this new persistentcontainer do i need to do a check for the key before i use get ?

#

or will it just return null

young knoll
#

null

quaint mantle
#

How can I simulate right click event in spigot 1.16.4?

young knoll
#

You can call it manually

maiden briar
#

PlayerInteractEvent#getAction

quaint mantle
#

Alright, ill search some more about it and return if i have any more questions

olive lance
#

im deleting

young knoll
#

if (byte == 1) {
//true
} else {
//false
}

olive lance
#

i act like im not in school for this

#

sorry

#

i was thinking it was a bit

summer lily
#

I am a newbie, can anyone help me real quick?

if (e.getItem().getItemMeta().getCustomModelData(1)) {
//code
}

How do I make the code to check the item's custom model data?
Basically if a item has custom model data 1, it will do stuff.
Thank you!

young knoll
#

It returns an integer, you can just compare it

mortal hare
summer lily
#

Can you give an example please?

olive lance
#

does getPersistentDataContainer() return null ever (besides on air)

young knoll
#

You may want to learn java before making plugins

mortal hare
#

#ItemMeta.getCustomModelData()

young knoll
#

if (xxx.getCustomModelData() == 1)

mortal hare
#

Plugins should check that hasCustomModelData() return true before calling this method

summer lily
#

Thank you so much

summer lily
mortal hare
#
ItemMeta meta = e.getItem().getItemMeta();
if (meta.hasCustomModelData() && meta.getCustomModelData() == YOUR_MODEL_ID) {
  //your logic code
}
young knoll
mortal hare
#

do you guys chain methods?

#

its really boggling me

mortal hare
#

@young knoll ikr, can't resist

summer lily
#

Works like a charm

olive lance
#
        ItemStack wand = new ItemStack(Material.WOODEN_AXE, 1);
        ItemMeta meta = wand.getItemMeta();
        assert meta != null;
        meta.setLore(Arrays.asList("Left Click - Position 1", "Right Click - Position 2"));
        meta.setDisplayName("Claiming Wand");
        meta.getPersistentDataContainer().set(key, PersistentDataType.BYTE, (byte) 1);
        wand.setItemMeta(meta);
        return wand;
    }
    public static boolean isWand(ItemStack s){
        if(!s.getType().equals(Material.WOODEN_AXE)) return false;
        if(s.getItemMeta().getPersistentDataContainer().get(key, PersistentDataType.BYTE) == 1) return true;
        return false;
    }``` ok i added all the persistentdatacontainer things. i think its wrong cause my method is still returning false
#

removed unnecessary checks

lost matrix
# mortal hare ok i still don't understand your statement

This example:

  public void handleEvent(final PrepareItemCraftEvent event) {
    final Recipe recipe = event.getRecipe();
    if (!(recipe instanceof ShapedRecipe)) {
      return;
    }
    final NamespacedKey recipeKey = ((ShapedRecipe) recipe).getKey();
    final CustomShapedRecipe customRecipe = this.customShapedRecipeMap.get(recipeKey);
    if (customRecipe == null) {
      return;
    }
    customRecipe.handlePreparation(event);
  }

There are a lot of variables that dont need to be there. But just to make the code a little bit more clear i created
extra variables with expressive names to make sure everyone that reads this code can understand what it does.

young knoll
#

Wait why doesn't the regular recipe have a getKey

mortal hare
#

are we sure that we're talking about the same thing?

young knoll
#

Ah... MerchantRecipe

mortal hare
#

i meant something like

  SomeRandomObject randomObj = new SomeRandomObject();
  // both methods manipulate SomeRandomObject fields and return the instance of the object
  randomObj.method1();
  randomObj.method2();

vs:

SomeRandomObject randomObj = new SomeRandomObject().method1().method2();
#

i think you meant recursion by your example

young knoll
#

I use the second version with builders

mortal hare
#

same

#

but i'm not sure if its doable with normal classes

#

not with utility ones like builder

young knoll
#

Technically the first one will only work if it's a mutable object

#

It's doable if they return themselves

mortal hare
#

yea but is it standard

#

im overthinking this shit

young knoll
#

If the method returns the object it's generally because it's designed to be chained

lost matrix
mortal hare
#

yea i use it in my builder classes too but thought if it was practical to use with data classes

#

but i think not

#

but technically possible

lost matrix
#

Its not used outside of the builder pattern because that would support many bad habits like side effects and its really hard for some clean code patterns to be enforced in that type of structure.

olive lance
#

hey smile could u take a look at the isWand method i did again? i remade it to use persistentdatacontainers

smoky finch
#

Has anyone had any issues with PlayerInteractEvent and berry bushes? Looks like even if the event is cancelled, you can get the berries if you right-click and left-click at the same time.

lost matrix
olive lance
#

ok ill try that thanks

smoky finch
#

Oh, thank you so much. I didn't know about that event. I'll try it right now.

smoky finch
#

Looks like PlayerHarvestBlockEvent solved the issue. ty

quaint mantle
#

how do i register commands in kotlin?

lost matrix
quaint mantle
#

I did some research but I couldn't find anything about this. How can I simulate right click event? Like, make the player click mouse right button. Basically something like:

player.rightClick()
eternal oxide
#

You'd have to manually fire teh click event and use packets to run the animation on the client

lost matrix
quaint mantle
#

Ah alright, thanks

#

I'll check it out

lost matrix
#

Maybe this method

elfin minnow
#

I am confused at why this isnt working

quaint mantle
lost matrix
south onyx
#

I have one question

brittle igloo
#

Hey, Does anybody know where I can find some guide/tutorial/example how to write something in a file? I need to write an exact location of a block and A username/uid in a file.

elfin minnow
#

so whats the crafting table type

south onyx
#

are all data types objects?
like strings, int, etc

elfin minnow
#

oh workbench

graceful turret
#

how to overwrite commands which are already in game?

#

i mean /msg etc.

eternal oxide
#

@graceful turret You asked this yesterday, the answer is still the same.

#

just create the command and register it

graceful turret
#

no i didn't

#

lmao

#

maybe i asked about it month ago

#

bo i 'am not sure

#

not yestterday

quaint mantle
quiet ice
#

The same way you'd do it in java?

#

Of course with kotlin syntax and all.

gritty sand
#

hey so going from craftbukkit.v1_16_R2 to R3

quaint mantle
#

An error pops up when i do that

gritty sand
#

CraftMetaBook no longer contains a list of IChatBaseComponents for its pages

quiet ice
#

What is that error?

gritty sand
#

instead it's just a list of Strings

quaint mantle
#

That

gritty sand
#

does this mean BaseComponent support in books is just gone now?

quaint mantle
#

dont know why its not loading

#

nevermind

gritty sand
#

I have a chunk of code that I've been using for years that renders a bunch of data into a book with hover and click events

#

trying to update it to 1.16.5

olive lance
#

maybe im not setting it right?

quaint mantle
#

hey how can i make a simple headlist and footer tablist with 1.12.2 spigot?

lost matrix
quaint mantle
#

i cant register the command in kotlin

#

and i don't know why

#

I've got this

getCommand("hello").setExecutor(CommandHello())```
olive lance
#

@lost matrix ```public static ItemStack getWand(){
ItemStack wand = new ItemStack(Material.WOODEN_AXE, 1);
ItemMeta meta = wand.getItemMeta();
assert meta != null;

    meta.setLore(Arrays.asList("Left Click - Position 1", "Right Click - Position 2"));
    meta.setDisplayName("Claiming Wand");
    meta.getPersistentDataContainer().set(key, PersistentDataType.BYTE, (byte) 1);
    wand.setItemMeta(meta);
    return wand;
}``` Here is the code for getting the item. Im pretty sure I set the entry right
gritty sand
#

tis a longshot, but does anyone in here happen to know how to add hover and click events to books as of 1.16.5?

olive lance
#

oh yea so uh

#

i kinda dont want to talk about it

#

@brave glenHandler

lost matrix
#

Forgot to register the recipe

#

Or the annotation

olive lance
#

is what i forgot

lost matrix
#

classic

olive lance
#

yup

#

sorry for the trouble lol. at least i know about the persistentdatacontainers now

lost matrix
#

But the api methods are all still there

gritty sand
#

nope, no longer up to date

#

as of the R3 varient of craftbukkit

#

CraftBookMeta no longer has a List<IChatBaseCompoennt>

#

is List<String>

olive lance
gritty sand
#

or maybe my code is even older than this and has been doing it with reflection . . .

#

give me a few I'll see if this method works instead

olive lance
#

from choco's sticky thread

#

in spd

olive lance
#

hey smile, my claim wand methods are static that's not "static abuse" is it?

lost matrix
olive lance
#

But it would be better to make them not static and instantiate a ClaimWand instance to use the methods?

#

sorry for confusing wording if it was the class is just called claimwand those methods are in

lost matrix
unreal finch
#

Hey, I need help using a List<Entity>

Pretty much what I'm trying to do is remove AI and Awareness from all entities when a new chunk is loaded. I know that my current code doesnt work because List<Entity> doesnt work as I wanted it to so I'm trying to find another way to do it or a possible solution. Anything will help, thank you :)

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

lost matrix
gritty sand
#

yeah my code is very old (older than the Component api) so I guess I just need to update it to use the Component api

#

this looks like It's a much nicer way of doing it anyway

quaint mantle
#

@lost matrix how do i make tablist on 1.12.2? spigot

unreal finch
lost matrix
quaint mantle
#

wait theres something like that function? ty

#

i was trying to do the ichatbasecomponent thingy like and it just said cnf

#

ty

lost matrix
#

I think in 1.12 they had the same methods with just BaseComponent[]
So using the ComponentBuilder this should be quite easy.

mortal hare
#

can someone explain this phenomenon: Integer.MAX_VALUE + 1. What does this do? Overflow the Integer, and what then? I saw this somewhere being used

#

does it return random int or what?

ivory sleet
#

wouldnt it return the MIN_VALUE or smtng

#

tho its a shame java doesnt have unsigned int etc

worldly ingot
#

Yes, it would overflow to the minimum value

lost matrix
#

All this is doing is overflow. So int hex it would look like:
0xFFFFFFFF -> 0x0
And in binary it would look like this.
1111 1111 1111 1111 -> 0000 0000 0000 0000

In actuality java does preserve the sign bit. So the memory representation is:
1000 0000 0000 0000

#

Which is just MIN_VALUE i guess...

mortal hare
#

thanks wikipedians

sharp bough
#

lol

mortal hare
#

nvm this gif is too weird

minor fox
#

I'm trying to edit signs and setting lines with Sign#setLine but it doesnt seem to update it

ivory sleet
#

might have to explicitly call update

lost matrix
minor fox
#

ah ok

ivory sleet
#

oh nvm thats for BlockStates

lost matrix
#

I think the BlockState thing is deprecated... im not sure which one is right actually

olive lance
#

why cant a nonstatic method be in a constructor

lost matrix
olive lance
#

trying to call it from another

lost matrix
olive lance
#

im trying to rewrite my entire plugin

lost matrix
olive lance
#

ah ok

#

right

sharp bough
#

7smile7 how are you always online helping random people?

#

honestly every single time i get in here i see you helping someone lmao

#

respect

olive lance
#

the goat

lost matrix
vocal shuttle
#
if (!(sender.hasPermission("sb.help")) || (!(sender.hasPermission("sb.admin")))) {
                sender.sendMessage(ChatColor.RED + "Missing permission:" + " sb.help");
                return true;
            }
            Player player = (Player) sender;

            sendHelpMessage();

            return true;

        }

    private void sendHelpMessage(Player p) {
        TextComponent helpMsgTest = new TextComponent(ChatColor.GOLD + "§l/sb test§r" + ChatColor.WHITE + " - " + ChatColor.AQUA + "Tests plugin & config.");
        helpMsgTest.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/sb test"));
        helpMsgTest.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("/sb test").color(ChatColor.AQUA).create()));

        p.spigot().sendMessage(helpMsgTest);
        return;
    }

'sendHelpMessage(org.bukkit.entity.Player)' in 'com.lethalflame.teleportationball.Commands.SwitcherCommand' cannot be applied to '()'

sage swift
#

gotta send the help message to someone, doncha?

lost matrix
olive lance
#

hey smile. Would a hashmap containing all players/factions be OK for being static? I feel I would use it a lot in other classes. maybe not idk

lost matrix
ivory sleet
#

Why static? I mean it would work with it being not static also?

#

Having it non static would probably help loosely couple your code nvrtheless

olive lance
#

so I made the wrapper class. Now say I have a class to handle some events and a class to handle commands. Does each need a separate instance?

#

or the same one

#

wait it would be the same

#

or the data is different

#

how do i make 1 and use it in all the different classes

lost matrix
#

Everyone needs the same instance. Two different instances would access two different Maps, which would be bad.
So you create one instance of your Manager class in the onEnable() method and then pass this instance to your Listener
and Command classes.

olive lance
#

in the constructor for them?

#

my plugin bout to be top quality thanks smile

ivory sleet
#

next level entrepreneur

olive lance
#

What is a singleton

torn oyster
#

how would i make a plugin that deletes files in other plugins files

#

like

#

im trying to make a command

#

that resets your progress

#

in survival

#

ur money

#

ur mcmmo skills

#

ur claims

#

etc.

eternal oxide
#

use API's not delete files

torn oyster
#

wdym

eternal oxide
#

all those plugins have an API

torn oyster
#

true

eternal oxide
#

you deleting their files will only break things

torn oyster
#

okay ill do that

unkempt ore
#

How would I parse relative locations in my commands?

olive lance
#

player.getLocation

#

nvm

unkempt ore
#

Is there some utility for this

olive lance
#

ur talking about reading the ~ ~1 ~ stuff?

unkempt ore
#

Yep

olive lance
#

idk

sage swift
#

brigadier probably

lost matrix
# unkempt ore Is there some utility for this

You can use a simple String parsing approach. Check if the first character is ~ then use the players coordinate as relative offset
to the followed parsed Integer String (if present). Otherwise use global coordinates for one of the given input.
But you could also check how its done internally.

lost matrix
unkempt ore
#

For some reason I can't see the sources

#

I can just see the interfaces

#

Maybe I imported the API only somehow?

lost matrix
silent vigil
#

How would I add 1 to the z coord if I have the location? Lets say the location is 100 100 100 and i want to make it 100 100 101

#

how would I do that?

unkempt ore
#

I am using Maven

lost matrix
eternal oxide
#

loc.setZ(loc.getZ()+1)

lost matrix
#

or what elgarl said

eternal oxide
#

Both work the same

opal juniper
#

How to set the speed a particle gets removed at?

silent vigil
#

tysm

quaint mantle
#

its when the chunk is unloaded i think?

olive badger
#

Hello, i have multi module project for have multi platform support (bukkit & bungee).
I want to use ACF for create my commands but i don't find how i can shade it into my final jar.

I have that in an sub-module i use for merge all together : https://paste.md-5.net/fuwaminixo.xml
In specific platform i have :

<dependency>
  <groupId>co.aikar</groupId>
  <artifactId>acf-paper</artifactId>
  <version>${libs.acf}</version>
</dependency>

I shade all sub modules (common, bukkit and bungee) in only 1 jar but that jar doesn't contain my dependency.
I need to specify that dependency in my module i use for shading projet ?

Thanks

eternal oxide
#

why not a single project? bungee and spigot cohabit just fine

silent vigil
#

if i throw a snowball does it keep its itemmeta?

#

so I could check it

quiet ice
#

I'm not too sure, the javadocs somewhat do suggest it, so I'd just look if it works

weak kayak
lost matrix
silent vigil
lost matrix
silent vigil
#

ok ty

quaint mantle
#

Is there any way to get player name from a player head block?

#

im trying to get block data ect and i cant find where its at

quiet ice
#

return (((long) x) << 32) | y; merges two integers into a long, right?

lost matrix
#

No

#

I think not

#

Does this even compile?

#

Yes it does. But i think it might mess up the sign bit.

eternal oxide
#

yes breaks teh sign

#

return (((long)x) << 32) | (y & 0xffffffffL);

lost matrix
slim magnet
#

Is it bad to host multiple minigame instances on one spigot server

spare flicker
#

is it possible to mix java button key click actions into the minecraft game
like if i were to be like something like
if (sender instanceof Player) {
//if has item in hand ,
// if player presses B key{
//player event happens
}}

sullen marlin
#

only with a client mod

#

client doesnt tell the server what keys it presses

vocal shuttle
real lodge
#

hi, how can I call a class with the parameter set<EntityType> targets ?
(in java)

sullen marlin
#

make a set and put EntityTypes in it?

spare flicker
#

@sullen marlin what is a good client mod in your opinion

sullen marlin
#

idk

real lodge
sullen marlin
#

I dont get your question

real lodge
#

I have an example java programm with that class:

private TargetNearbyEntityGoal(NPC npc, Set<EntityType> targets, boolean aggressive, double radius) {}```
so I call it by doing ```TargetNearbyEntityGoal(npc,???,true,radius)``` where npc and radius are variables but idk what to put at the ???
sullen marlin
#

A Set containing the EntityTypes to target

#

make a HashSet, add the types, pass it in

spare flicker
#

this may be a dumb question but are forge mods able to mix with spigot mods

sullen marlin
#

no

real lodge
#

oh ok thx

spare flicker
#

one more question thank you for all the help md_5 if im trying to make like a mini map or a special custom gui or something like that would it have to be in forge

lost matrix
spare flicker
#

could i connect this to a server

#

@lost matrix

deft forge
#

is there what plugin that allows illegal enchants to work with essentials? ex. /eenchant protection 5

lost matrix
spare flicker
#

well im learning java and im trying to make a complete server from scratch kinda like a game so ill understand java. As well as im building a resume; but ive been reading the docs for spigot and watching a bit of videos. I am also trying to add lots of interactive like player examining items in hand and custom guis and anything you could really imagin that you would see in a real game like a fps. but i want it all on a server

#

@lost matrix

#

should i be looking at forge

#

im also wondering if this is possible to connect evrything back and forth through a website

lost matrix
# spare flicker should i be looking at forge

Yes. But Spigot is not that beginner friendly and forge is very not beginner friendly.
No idea what you mean by "make a complete server from scratch" but you will run against
a wall for at least 2 years if you jump into such a big project without prior knowledge.
Take it slow and learn the basics step by step.

spare flicker
#

i have prior knowlage

#

ive been working with java script json 2 years and learning basics for java for like a month

#

so im just trying to understand what i should use 🙂

solemn shoal
#

"java script"

#

javascript and java are nothing alike

spare flicker
#

ik

lost matrix
#

spigot > forge if you are new

solemn shoal
#

hm

#

any reason this doesn't work?
public static boolean LogEvents = Util.getConfig().getBoolean("Debug.Log Events");

#

where Util.getConfig() is defined as:

public static FileConfiguration getConfig() {
        return getPlugin().getConfig();
    }```
#

and getPlugin defined as:

public static Plugin getPlugin() {
        return Main.getPlugin();
    }```
#

my config contains this:

lost matrix
#

Do you get any exceptions?

solemn shoal
#

nope

median socket
#

the space. It's non-stanvard YAML

solemn shoal
#

that YAML was generated by spigot

lost matrix
#

Ah i see. the yml is deformed and your ide even tells you that

median socket
#

either do Log_Events or "Log Events"

solemn shoal
#

no?

#

i have rainbow indentation enabled

lost matrix
#

PlayerData or Player_Data or "Player Data"

solemn shoal
#

no i mean, that's working fine

#

when i get the configs

#

i was just showing rainbow indentation there

lost matrix
#

Change it to LogEvents and see if that works

solemn shoal
#

full config.yml btw

#

but that player data block works fine

spare flicker
#

is sponge any good

#

and thank you for all the help @lost matrix

deft forge
#

is there what plugin that allows illegal enchants to work with essentials? ex. /eenchant protection 5

solemn shoal
#

doesnt essentials have a setting for that?

#

yeah, unsafe-enchants

deft forge
#

k thx

solemn shoal
#
# Allow 'unsafe' enchantments in kits and item spawning.
# Warning: Mixing and overleveling some enchantments can cause issues with clients, servers and plugins.
unsafe-enchantments: false```
deft forge
#

what file?

#

@solemn shoal

solemn shoal
#

config.yml

#

tfw i found why my code doesnt work

#

i screwed up my biuld script

#

tfw my build script doesnt work anymore

#

it no longer copies my plugin.yml

#

okay cool, fixed it

deft forge
#

k f

solemn shoal
#

nvm

drowsy helm
#

does PersistentDataContainer#set(key, boolean (as string)) convert the string to a NBTTagByte?

#

it keeps telling me whenever i save a boolean as a string it is a NBTTagByte

#

very strange

sand vector
#

Do eclipse and intelij code look different? so if i used a intelij tutorial would it work on eclipse?

dusky lynx
#

They have different colors but the function pretty much identical

#

I like intelij better because it has a Minecraft plugin that makes the plugin yml for you and imports spigot

sand vector
#

ok thanks for the help

queen nacelle
#

Hey all

#

Anyone know of a way to mitigate arrow drag in water?

#

It is effected by a 0.6f multiplier per tick in water

#

and it doesnt seem to be in AbstractArrow or Arrow

#

is that on the client?

earnest junco
haughty haven
#

heyhey I'm trying to make a custom potion where when the player finishes drinking it, it will make them completely invincible to all damage for 10 seconds. Right now, I'm having trouble finding the name of the event when a player drink a bottle

#
    public static void onPotionDrink(EntityPotionEffectEvent event) {
        Player player = event.getPlayer();

    }
}```
#

this doesn't work at all btw, I'm just trying to find it

sullen marlin
#

it wont work cause its static

#

remove static

earnest junco
haughty haven
sage swift
#

++num increments the variable before using it, right? and would it keep it incremented if i put it in an if statement?

#

ie java if (++num == 1) { something; } else { //num should stay incremented, right? }

drowsy helm
#

yes

#

if num was 0 before the if statement, it will satisfy the if statement

summer scroll
haughty haven
#

oke will check it out

#

@summer scroll I'm not quite sure where to go from here, like this line below checks if the item is the custom item, right?

        Player player = event.getPlayer();
        if (event.getItem().getItemMeta().equals(ItemManager.deus.getItemMeta())) {
           
        }```
#

but how to I check when the item is consumed?

drowsy helm
#

it is consumed in that event

haughty haven
#

oh okay, so it basically already checks that it's been consumed

drowsy helm
#

it does check, it gets called when it gets consumed

haughty haven
#

riiight, okie thanks!

#

and is there a way to add the GENERIC_KNOCKBACK_RESISTANCE attribute (the one on netherite armor) to a temporary potion effect?

#

because I am making a potion which temporarily gives resistance 5 for 10 seconds, and I'm wondering i could put a temporary armour attribute too

drowsy helm
#

you can probably do some packet stuff but you cant add armour attribs to potions iirc

young knoll
#

Yeah you would have to add it to the player and then remove it with a scheduler

haughty haven
#

yeah that makes sense, it seems quite daunting to me as I'm very new to this

#

I can see a lot of problems that I don't know the language/syntax to work around

#

like what if the player has full set of armor on? things like that I still can't wrap my head around because I barely know the language haha

#

guess I'll have to leave that for another day

young knoll
#

What about the armor?

drowsy helm
#

armour maxes out anyway so if you set it over the max value it pads itself i thinkl

#

if not oyu can just use Math.max

haughty haven
# young knoll What about the armor?

like I think I'd have to temporarily replace the player's armor with a piece which gives the player knockback resistance 100 or something, then give the existing one back when the timer is done

#

which I have no clue how to do, but that's not important now

young knoll
haughty haven
#

what, fr?

young knoll
#

yes

#

And other entities

haughty haven
young knoll
#

You will need a scheduler

haughty haven
#

right, i should learn how to do that then

young knoll
sage swift
#

give it a tag in the PersistentDataContainer and check for that

haughty haven
#

oh ok

drowsy helm
#

or nbt

haughty haven
#

I'm guessing using item meta to compare will lag the server if there is a shit load of stuff

drowsy helm
#

pdc can be iffy

#

no not really

#

just not a good way of doing it

sage swift
#

if someone renames an item it will stop working

sage swift
lost matrix
# drowsy helm pdc can be iffy

pdc is just nbt using the spigot api. And its not really practical for raw usage but you can
always build your own wrapper classes to make it pretty.

haughty haven
#

also how do you setColor for a potion using item meta?

lost matrix
haughty haven
#

so this part right here?

olive lance
#

Yo smile. Remember when we were talking about the wrapper class that I will instantiate once to use in other classes

#

If I wanna use it’s methods in a class that gets instantiated many different times how do I do that. Should the one instance of the wrapper class be static?

lost matrix
olive lance
#

Are singletons bad? That’s what I was getting from chocos post

lost matrix
#

But its not always practical. I would stay with the static singleton instance for now 😄

olive lance
#

Ok thanks

final fog
#
public void onEnable() {
        new BukkitRunnable() {

            @Override
            public void run() {
                for(Player player : Bukkit.getOnlinePlayers()) {
                    resetCps(player);
                }
            }
        }.runTaskTimer(this, 100L, 1);``` Do I have to put this in my main class, or can I put it in my listener class.
lost matrix
final fog
#

yeah. I just needed to put something there for now

#

It will be an instance of my Main class

olive lance
#

Far too often I see static being used to access a field from another class, particularly Collection and Map implementations, as well as an instance of the main class. This is a common mistake for new developers and poses some serious issues in terms of code design and flexibility in the future. how do i avoid making a static instance of the main class. to do runnables for example

#

he doesnt really say in the post

paper viper
#

di

final fog
paper viper
#

oh wait for runnables

lost matrix
lost matrix
final fog
#

Make something happen every 5 seconds

olive lance
#

Ok cool. And you said dependency injection didn't really affect performance with many instances of the class right? Cause its just the reference

final fog
#

I don't wanna just shove it all into my main class

olive lance
#

cool

#

arrow code be gone

dusk wedge
#

for people who use protocollib and 1.16.5, does multiblockchange packet work for you? I seem to get an error. if anyone can help me dm me

drowsy helm
#

what error are oyu getting

olive lance
#

what happens when you pass in null to HashMap#remove()

hushed spindle
#

hey guys. just having a question.
what ways exist, to change a players displayname (just the name above their head)? obv. there is a setDisplayName and a setCustomName - are there any other?

untold onyx
#

how do i make player glow for 1.9+ on a 1.8 spigot

#

using viaversion

sullen marlin
#

seems like a question for viaversion

drowsy helm
#

so how can they dupe the items with a runnable?

quaint mantle
#

like

#

I would make something like this:

#

one second

#
@EventHandler
    public void menu(PlayerSwapHandItemsEvent e){
        Player player = e.getPlayer();
        if(!player.isSneaking()) return;
        ItemStack mainhand = e.getOffHandItem();
        ItemStack offhand = e.getMainHandItem();
        player.openInventory(PlayerMenu.build(player));
        Bukkit.getScheduler().runTaskLater(RPGCoreHoof.instance, new Runnable() {
            @Override
            public void run() {
                player.getEquipment().setItemInOffHand(offhand);
                player.setItemInHand(mainhand);
            }
        }, 5L);
    }
#

like this @drowsy helm

#

but I actually don't understand why cancelling the event doesn't do the job, it should

#

but I actually am being dumb

#

I shouldn't pick the items before the schedule

#

I should pick the items from the player's slots during the scheduler

#

it should prevent duping or something like that

#

but that's not ideal :/

drowsy helm
#

dont use player.setItemInHand

#

wait what version is this

quaint mantle
#

it's 1.16.4

#

I didn't use it before

drowsy helm
#

user player.getInventory.setItemInMainHand()

quaint mantle
#

I used .getinventory() and stuff

drowsy helm
#

yeah

quaint mantle
#

I just made this really quick

#

to show you for you to say what you think

drowsy helm
#

hmm i dont see why it wouldnt cancel tho

quaint mantle
#

me neither

solemn shoal
#

gradle question, how can i include resources?

drowsy helm
#

do you need a runnable to swap them back?

quaint mantle
#

default config.yml files are resources

solemn shoal
#

plugin.yml

quaint mantle
#

ooh

#

it's at the resources folder actually

solemn shoal
#

it is in my resources folder

#

and its not in my jar

quaint mantle
#

but you should use a add-on to help you

#

you use IntelliJ?

solemn shoal
#

yes

quaint mantle
#

or I should swap them before the swap happens

#

it's even smarter lol

#

lol that's what I will do

drowsy helm
#

you can try lol

solemn shoal
drowsy helm
#

resources should be in your root

solemn shoal
#

none of these are being included

#

my plugin.yml also exists in the java folder, doesnt work either

quaint mantle
#

it makes a default project

#

with everything set up

#

even the shade plugin from maven

drowsy helm
#

that uses maven doesnt it

quaint mantle
#

yeah it uses maven

#

and everyone should use maven

#

xD

drowsy helm
#

space wants to use gradle

quaint mantle
#

why

drowsy helm
#

so the plugin yml shows up in your root folder but spigot isnt recognising it?

solemn shoal
#

no, its not in my root folder at all

drowsy helm
# quaint mantle why

gradle has some benefits over maven, they asked a question relating to gra dle

solemn shoal
#

jar task:

quaint mantle
#

sorry, sorry

quaint mantle
#

depending on the benefits I will switch

solemn shoal
#

makebukkitjar:

drowsy helm
#

do you have a sourceSEts thing yet

solemn shoal
final fog
#

What’s harder? Coding plugins, or coding Minecraft mods?

solemn shoal
#

coding mods is harder

quaint mantle
#

coding mods definetly

final fog
#

Ah alright

quaint mantle
#

but currently both are easy

#

because of the abstractions and great API's

#

don't feel unmotivated just because mods are harder

solemn shoal
#

update: after a lot of fiddeling:

quaint mantle
#

you can learn both, I'm sure

final fog
#

I heard 1.16 mods are hard to program

solemn shoal
#

time to clean up

quaint mantle
#

depending on what you want to do

#

and how much you're willing to learn

final fog
#

Are they in anyway similar?

drowsy helm
#

somewhat

#

but barely

#

plugins scrape the surface of what is possible, but are accessible to way more people

#

mods can achieve a lot but not many people might play it

final fog
#

I see

#

Thanks for letting me know everyone.

drowsy helm
#

you can achieve a modded experience with plugins but it takes alot of knowledge and resource packs

#

and obviously it would be much less optimised

stoic elk
#

So theres BlockBreakEvent

#

is there like PlayerJumpEvent

solemn shoal
#

i finally have a proper-ish build env

final fog
solemn shoal
#

?jd

stoic elk
#

thanks

#

this is the first java plugin im trying to code lol

solemn shoal
#

wouldnt that fire PlayerMoveEvent?

young knoll
#

There is not

#

But there is a StatisticIncrementEvent

stoic elk
#

slow down i legit barely know java

final fog
#

Learn some java first, it helped me out quite a bit.

solemn shoal
#

i went batch -> java -> C#

#

and now im back to java because plugins

#

imagine if i made a dotnet plugin interface

stoic elk
#

How do you send a message to a player?

#

its like print something right?

young knoll
#

player.sendMessage

#

?jd

stoic elk
#

thanks

haughty haven
#

how do i find connect it to plugin?

#

I'm trying out scheduling for the first time so please bare with me 😅

stoic elk
quaint mantle
#

show full code

young knoll
#

To be exact, the instance of your main class

quaint mantle
haughty haven
haughty haven
young knoll
#

I would say learn java first

#

But nevertheless, pass the instance of your main class through the constructor of your event class

quaint mantle
#
class MyClass {
    public void doSomething() {
        A a = new A(this);
    }
}

class A {
    private final MyClass c;

    public A(MyClass c) {
        this.c = c;
    }
}

@R053#8187

#

@haughty haven

#

thats dependency injection, or DI

haughty haven
#

oh okk, but my main class is in a separate java file

#

like, I don't really get how to link between files

quaint mantle
#

it doesnt matter

haughty haven
#

is it the stuff at the top?
import com.r053.uhcum.items.ItemManager;

#

I see things like this pop up at the top, but it happens automatically

quaint mantle
haughty haven
#

so I don't actually know what happens in the back you know

stoic elk
#

whats up with this?

quaint mantle
#

lmao

stoic elk
#

bruh this is my first plugin

#

dont laugh too hard

quaint mantle
#

not

#

just learn some java

hybrid spoke
stoic elk
#

its not letting me though

#

i do and it wants me to make a class in the in the actual code

solemn shoal
#

lol

stoic elk
#

stop pls

solemn shoal
#

stop what?

quaint mantle
#

watch the java course, itll teach you everything you need to know

hushed spindle
#

hey guys. just having a question.
what ways exist, to change a players displayname (just the name above their head)? obv. there is a setDisplayName and a setCustomName - are there any other?

quaint mantle
#

also spacedash is laughing with you not at you

solemn shoal
#

regardless

quaint mantle
#

you can also use teams

stoic elk
#

oh my gosh

#

im stupid

#

im supposed to use the name of the class 🤦

quaint mantle
#

yikes

stoic elk
#

Bruh ive never used this crap before lmfao

hybrid spoke
#

"crap"

stoic elk
#

yes

solemn shoal
#

"crap"

#

welcome to java

hybrid spoke
#

welcome to programming and logical thinking*

stoic elk
#

fucking automod warning me for talking

solemn shoal
#

nah i mean, at least the c# compiler points out "hey you cant make an instance of a variable"

#

can anyone figure out why my mending code doesnt work?

stoic elk
#

hey i mean for a first plugin, i think when you mine a diamond ore it drops 100 oak buttons is pretty dope

quaint mantle
#

eh

young knoll
#

Datapacks can do that

stoic elk
#

its mostly a test btw

solemn shoal
stoic elk
#

i want to learn so im starting easy

solemn shoal
#

this is my first plugin lol

stoic elk
#

and thats fucking hard

solemn shoal
#

well its an evolution of my first plugin

#

been thru a few renames lol

quaint mantle
#

1.6mb 😂

solemn shoal
#

yeah what about it lol

stoic elk
#

okay so one last question

#

i think ill be good to continue toying with this once i know this

#

why is it red

solemn shoal
#

player does not exist there

quaint mantle
#

because what player

young knoll
#

Because you don’t have a ;

quaint mantle
#

cant just pull a player outta ya ass

stoic elk
#

or can I

quaint mantle
#

🤨

#

thats one madlad

stoic elk
#

so what do I do?

solemn shoal
#

r/suddenlyhomosexual

quaint mantle
#

lmao

dusty herald
#

is this in an event?

solemn shoal
#

wait no

quaint mantle
dusty herald
#

define the player variable ASkatzuKeK

stoic elk
#

i want it to send a message when a block is mined

young knoll
#

event.getPlayer

quaint mantle
#

cant just pull a player outta ya ass

solemn shoal
#

Player player = event.getPlayer();

dusty herald
#

Player player = event.getPlayer();

stoic elk
quaint mantle
#

yikes

#

imma teach you java rq

dusty herald
#

do you not know Java?

stoic elk
#

nope 😛

dusty herald
#

👀

stoic elk
#

im trying to learn but its not going well

young knoll
#

Learn java, you are doing yourself no favours trying to learn it with a third party API

solemn shoal
quaint mantle
#
ReturnType myVariable = (someValue);
myVariable.hasFunctionsToCall();
// This is a comment
dusty herald
#

I am fluent in ass assing

solemn shoal
quaint mantle
dusty herald
#

Why make it one line when it obviously is meant to show them what it is

solemn shoal
#

java syntax

quaint mantle
#

horrible formatting wtf

solemn shoal
#

autoformatted

young knoll
#

Nice staircase

dusty herald
#

that is lambda and a bit advanced for a Java beginner

#

tsk

hybrid spoke
#

📉

quaint mantle
hybrid spoke
#

xD

solemn shoal
#

lambda where?

stoic elk
#

Could this work?

#

private void myMethod () {
Player p = event.getPlayer();
}

solemn shoal
dusty herald
solemn shoal
quaint mantle
dusty herald
#

who doesn't use lambda for runnables

stoic elk
#

OR CAN I

quaint mantle
solemn shoal
#

since when does java support lambdas?

dusty herald
#

since forever

quaint mantle
#

k

#

since 1.8

stoic elk
#

how the fuck do i do this bullshit

patent ice
#

No

solemn shoal
#

ive tried using lambdas in java and it just doesnt

hybrid spoke
#

with java 8 comes lambdas

quaint mantle
#
a.b(C::method);
young knoll
#

Java 8, or 1.8, or class version 52