#help-development

1 messages · Page 2141 of 1

echo basalt
#

cross-reference it with the NMS packet

#

and wrap it up with ProtocolLib

tepid ore
#

Wait no I'm dum again, I read your message wrong. My bad

quaint mantle
#

for each packet

#

i cant find it on the site

tepid ore
#

Use org.bukkit.block.Block maybe?

lavish folio
quaint mantle
#
    @EventHandler
    public void onInteract(PlayerInteractEvent event){
        Player player = event.getPlayer();

        if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
            Block block = event.getClickedBlock();
            if(block.getType() == Material.DIAMOND){
                player.sendMessage(ChatColor.GRAY + "You mined a " + ChatColor.AQUA + "DIAMOND" + ChatColor.GRAY + " block.");
            }
        }

    }

Why does it nothing when I click on a diamond block?

tepid ore
#

Material.DIAMOND_BLOCK

#

:>

quaint mantle
#

oh

#

my bad

#

:/

tepid ore
#

lol 🙂

quaint mantle
#

yay

#

ty

tepid ore
#

Np :>

quaint mantle
#

Can I also make an event when you click on a diamond block nothing happens until you have a shear in your hand called "name" or so?

tepid ore
#

Ofc?

quaint mantle
#

How can I do that?

lavish folio
#

all imports is good

tepid ore
quaint mantle
#

tyy

#

Im new to java so dont mind

tepid ore
#

Though, you might need to do "Whatever".equals(ChatColor.stripColor(Item.getItemMeta().getDisplayName()))". Idk if chat colors are important in .equals

quaint mantle
#
    public void showGlow(Player player, Entity target) {
        PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
        packet.getIntegers().write(0, target.getEntityId());
        WrappedDataWatcher watcher = new WrappedDataWatcher(player);
        watcher.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x40); //glow
        try {
            ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
    }

@echo basalt

#

i got this much

tepid ore
quaint mantle
#

errors out

tepid ore
#

👍

quaint mantle
#
                Item.getItemMeta().getDisplayName().equals("Orange");

Why does it says cannot resolve "getItemMeta"

safe notch
#

Item is a class

tepid ore
quaint mantle
#

huh

safe notch
#

Name it to “item” and try

quaint mantle
#

I imported Item

safe notch
#

No Item is an entity class

tepid ore
#

You need to do player.getInventory().getItem(slot).getItemMeta() if you haven't

quaint mantle
#

oh

#

:p

tepid ore
#

.getItemMeta() is from the ItemStack class, not Item interface

safe notch
#

ye

tardy delta
#

Item is an itemstack being dropped

tepid ore
#

It is the entity representation of it ye ^

quaint mantle
#
        if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
            Block block = event.getClickedBlock();
            if(block.getType() == Material.DIAMOND_BLOCK){
                player.getInventory().getItemInHand().getItemMeta();
                    Item.getItemMeta().getDisplayName().equals("Orange");
                        player.sendMessage(ChatColor.GRAY + "You mined a " + ChatColor.AQUA + "DIAMOND" + ChatColor.GRAY + " block.");

Still "getItemMeta" cannot resolved

tepid ore
#

player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals("Orange")

quaint mantle
#

ohw

tepid ore
#

This player.getInventory().getItemInHand().getItemMeta(); just gets the item meta, and does nothing with it

quaint mantle
#

Ohh oke

tardy delta
#

item in main hand might be null so null check that

tepid ore
#

^

tepid ore
#

Also, do getItemInMainHand() instead

tardy delta
#

if player.getInventory().getItemInHand() is null

tepid ore
#

Wait

#

No

#

It can't be

#

The type can be air tho

#

Check if getItemMeta() is null

quaint mantle
eternal oxide
#

getItemMeta() can be null, check using hasItemMeta()

tardy delta
#

i had slots where the itemstack was null

quaint mantle
eternal oxide
#

thats only for Inventory contents

tardy delta
#

or are empty slots now returning a new ItemStack(Air)?

#

mmh

eternal oxide
tepid ore
eternal oxide
#

calling getItemMeta() can return null

arctic moth
quaint mantle
arctic moth
#

i cant even stop my server xD

#

its an exception generating new chunk smh

arctic moth
#

but why would it generate

#

while stopping

eternal oxide
#

a null in java means no object. Your code will thrown a NullPointerException

quaint mantle
quaint mantle
#

so does that means it is null?

tepid ore
# quaint mantle so does that means it is null?

Not necessarily, if item is null and you do item.getItemMeta() for example, Java will print an error as you try to get the meta from an item that does not exist. So who's meta should it return if the item is null? Java does not know, and crashes

tardy delta
#

null safe languages 💟

arctic moth
#

i found an error preventing shutdown and none of the stacktrace leads to my plugin

#

is that a bug

#

it has smth to do with aquifier gen

quaint mantle
#
                player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals("Orange");
                
                        player.sendMessage(ChatColor.GRAY + "You mined a " + ChatColor.AQUA + "DIAMOND" + ChatColor.GRAY + " block.");

So I got this now, but every block called Orange get the message. How can I make an else statement here?

tepid ore
tepid ore
#

Write what you want with words :>

arctic moth
#

is this a spigot bug

#

actually i think its in mc itself

quaint mantle
#

Can I like do when a shear called "Orange" can only activate the message?

tepid ore
arctic moth
#

no stack trace to spigot either

arctic moth
#

not my code

tepid ore
#

item.getType() and item.getItemMeta().getDisplayName()

quaint mantle
tepid ore
quaint mantle
#

tyy

tepid ore
#

Np

quaint mantle
#
item.getType() == Material.SHEARS
    player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals("Orange");
#

so I could do this?

#

nvm

#

I cant

tepid ore
#

player.getInventory().getItemInHand().getType() == Material.SHEARS && player.getInventory().getItemInHand().getItemMeta().getDisplayName().equals("Orange");

quaint mantle
#

Tysm 🙂

tepid ore
#

🙂

#

Though, it might be smart to store player.getInventory().getItemInHand() as a variable

#

ItemStack item = player.getInventory().getItemInHand();

quaint mantle
#

how do i do that?

tepid ore
#

So fast

quaint mantle
#

so every time when I use item it means player.getInventory().getItemInHand();?

tepid ore
#

Yes

quaint mantle
#

ah okay

quaint mantle
tepid ore
#

It means and

#

So if the material is shears AND the display name is orange

quaint mantle
#

ah okay

#

thats cool actually

tepid ore
#

&& = and, || = or

quaint mantle
#

okay

tepid ore
#

Java basics :>

#

Sry

quaint mantle
#

so you can see || as an else?

tepid ore
#

Yes

quaint mantle
#

okyyy

#

Thats cool to know

tepid ore
#

Essential

#

To know

quaint mantle
#
    @EventHandler
    public void onInteract(PlayerInteractEvent event){
        Player player = event.getPlayer();
        ItemStack item = player.getInventory().getItemInHand();

        if(event.getAction() == Action.RIGHT_CLICK_BLOCK){
            Block block = event.getClickedBlock();
            if(block.getType() == Material.DIAMOND_BLOCK) {
                item.getType() == Material.SHEARS &&
                    item.getItemMeta().getDisplayName().equals("Orange");
                        player.sendMessage(ChatColor.GRAY + "You mined a " + ChatColor.AQUA + "DIAMOND" + ChatColor.GRAY + " block.");


            }
        }

    }

So this is a good code?

silver reef
#

Hey there, I have been scrolling through alot of documents and forums to find more information about redstone dust.

My setup
I want to itterate a redstone signal from source to end. Where sometimes you power a block and sometimes the redstone powers something else or makes a turn.

My problem
What I am trying to find out is how to read the redstone dust shape. In debug mode (F3) you can somewhat see sides and directions. Altough I have no clue on how to get these values. block$getFace will only return to SELF.

tl;dr: I was wondering if there was a way to check the shape OR facing/direction of redstone dust. 1.8;)

quiet ice
#

?jd-s

undone axleBOT
arctic moth
#

managed to make the main thread kill itself

tardy delta
#

lol

crimson terrace
#

damn, log4j?

arctic moth
#

all i did was force load a few chunks...

crimson terrace
#

I was more talking about the security vulnerabilities

quaint mantle
#

anyone here good with protoclib

#

protocolib

tardy delta
#

how can you see if you still have that security vulnerability?

crimson terrace
#

I just straight dont use log4j since i heard of that vulnerability

quiet ice
#

It is probably the watchdog

silver reef
#

as facing

quiet ice
quiet ice
#

Did you even use my method?

arctic moth
silver reef
#

Didnt see any of what you send

arctic moth
#

wait are u talking to me

quiet ice
#

no

tepid ore
# quaint mantle ```js @EventHandler public void onInteract(PlayerInteractEvent event){ ...

Uhh, not really. You have forgotten a few parenthesis etc. I would have done something like this

@EventHandler
public void onInteract(PlayerInteractEvent event) {
  Player player = event.getPlayer();
  ItemStack item = player.getInventory().getItemInMainHand();

  if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getClickedBlock().getType() != Material.DIAMOND_BLOCK
      || item.getType() != Material.SHEARS || !item.getItemMeta().getDisplayName().equals("Orange"))
    return;
            
   player.sendMessage(ChatColor.GRAY + "You mined a " + ChatColor.AQUA + "DIAMOND" + ChatColor.GRAY + " block.");
}``` What this does is that it test the following: `If you didn't click a block OR the clicked block isn't a diamond block OR the item in your hand isn't shears OR if the shears' display name isn't Orange`, then return. Aka, if something is wrong, return and do nothing. However, if all is good, send the player a message.
silver reef
#

I cannot implement your method

#

RedstoneWire doesnt have alot to offer it seems

tardy delta
#

i can offer you infinite power

waxen plinth
tepid ore
#

1.8

#

It is in their message

waxen plinth
#

💀

tepid ore
#

Yeah...

waxen plinth
#

Well there's your issue dude

silver reef
#

i know where it is, thats why im asking

#

doing

waxen plinth
#

Stop using a version that's 8 years old

tepid ore
#

^

waxen plinth
#

Or stop complaining about not having access to new API

#

Can't have it both ways

tepid ore
#

Why are you even on 1.8?

tardy delta
#

for the pvp props

quaint mantle
tepid ore
#

I mean, there are plugins for that?

#

If you really want it

waxen plinth
#

On 1.8 I believe redstone wire connections are computed, not stored

silver reef
tepid ore
#

Sort of

#

:>

silver reef
#

nah

tardy delta
#

lol

waxen plinth
#

Honestly we should just not allow people to ask for help for 1.8

silver reef
#

it was a response

waxen plinth
#

It is 8 years old and no longer supported

silver reef
#

ah yes, stackoverflow also limits to 1.8+

#

would be nice to see this place change to it

tepid ore
#

Upgrade

waxen plinth
#

Right because it's frustrating trying to help people using extremely outdated versions

quaint mantle
#

how do you send packets in 1.18.2

#

without protoclib

tepid ore
#

Idk, please tell me. I need it

tepid ore
#

Kinda yeah

waxen plinth
#

Yes, very

silver reef
#

you should take a break from your screen, doesnt sound good worying about it 😉

waxen plinth
#

What a condescending reply

#

"I don't want to help people who are using a version that has been unsupported for years"
"Go touch grass"

#

💀

silver reef
#

just here to help

#

f

waxen plinth
#

No you're not lol

crimson terrace
#

you know what? even im gonna touch some grass rn, you both should too. chill out.

silver reef
#

no need to get all stackoverflow on me

arctic moth
#

how would i reset a chunk to the original terrain?

waxen plinth
#

Don't think there's a good way to do that anymore

arctic moth
#

rip

crimson terrace
#

you would probably have to keep a backup of the original terrain for each loaded chunk

arctic moth
#

bruh

waxen plinth
#

If there was a ChunkGenerator for the default vanilla generator it would work

#

But alas there is not

tepid ore
#

Why tho

waxen plinth
#

I dunno, the generator for the default terrain is just null

tepid ore
#

Isn't that, like, very useful

waxen plinth
#

Maybe open a feature request on the jira?

tepid ore
#

no

waxen plinth
#

ok

arctic moth
tepid ore
#

Does any one have a good obfuscator allowed in spigot plugins? Idk what classifies as "not too good obfuscating" as they write about on the website

arctic moth
#

i noticed that in my error thing tho it seemed to generate populators by chunk

#

lol

#

@tender shard was making one earlier

quiet ice
#

Anything beyond that isn't really allowed at this point

#

And even some proguard settings are not allowed for free plugins

tepid ore
#

Mm kay, thank you

crimson terrace
#

I dont need an obfuscator, I just write my code all in one class, thatll do it

tepid ore
arctic moth
#

i think there actually is a website smwhere that flattens scripts automatically

crimson terrace
#

imagine I did that on my 10k line plugin

arctic moth
#

dont remember the url tho

tepid ore
quaint mantle
#

i swear making only ONE entity glow is impossible

tepid ore
#

private does nothing lol

crimson terrace
#

I would not

quaint mantle
#

why does mojang

tepid ore
#

Ahh, I see

quaint mantle
#

have to fuck shit up

#

every update

arctic moth
#

?

crimson terrace
#

not sure what you mean as I am able to do that easily

quaint mantle
#

one entity glow for one specific player?

crimson terrace
#

for one player?

quaint mantle
#

yes

crimson terrace
#

thats different

quaint mantle
#

i dont get this protocolib shit

#

why cant i just make the packet

#

sned it to player

arctic moth
quaint mantle
#

why they gotta make it difficult

crimson terrace
quaint mantle
#

@crimson terrace do u know how to use like vanilla packets

#

in 1.18.2

crimson terrace
#

sadly no. my plugins dont use packets yet

quaint mantle
#

fuk

#

does anyone

arctic moth
crimson terrace
#

just write a script which takes out all \n

arctic moth
#

lol k

#

also indents?

crimson terrace
#

especially those

kindred valley
#

what does only "return" do

#
while(true){
   if(case.equals("1") { 
       return;
   }
}``` Like this
ivory sleet
#

stops code execution within a void function

#

yeah

#

if case equals "1" then itd stop running the code in that function

worldly ingot
#

Well, that wouldn't compile because "case" is a keyword, but if it were any other word, yeah

ivory sleet
#

^

kind hatch
#

Depends on your checks. If it’s just null before any check, then the item is likely just air

#

Can you share your code?

kindred valley
eternal night
#

interact btw is called for both hands for stuff like right click

#

so if your offhand is null, you'd see that here

kind hatch
kindred valley
kind hatch
#

It does, but it also has ends the method.

#

Break will just stop a loop and continue with code execution beneath it.

#

Return is the exit point for a method. So if you return in the middle of a loop. The loop will stop and the method will end.

kindred valley
#

can i use while loop in while loop

kind hatch
#

Yes, but you need to be careful with while loops.

daring lark
#

how could i check if argument in command is number?

kind hatch
#

Sorry, can you ?paste that. I’m on a phone.

#

?paste

undone axleBOT
kindred valley
#

nvm about breaks

kind hatch
#

Just about to say

#

When dealing with while loops, change the value for the check.

kindred valley
#
if(choose == 1) {
   obs.startRecord();
   isEnded = false;
}```
kind hatch
kindred valley
#

🙂

#

umm do i need to keep going or what

kind hatch
#

Oh, you are checking to if your value is false. Then setting it to false in your loop.

#

Hence it will never stop.

#

Set the values to true or invert the check.

cyan compass
#

Can addItem() add more then 1 item at once?

kindred valley
#

yes acutally i passed this phase , it breaks the loop

cyan compass
kind hatch
kindred valley
kind hatch
#

Then add one? Or make a method that has a new loop.

kindred valley
#

I actually get the logic better again

#

thank you

crisp steeple
kind hatch
cyan compass
#

Got it. For loop time

#

Cause it is the same items but for loop feels easier

crisp steeple
#

varargs 🙂

kind hatch
#

If you know the amount that needs to be given, you could set the amount on the itemstack and then just give them the itemstack instead of looping.

quaint mantle
#

to send an entity metadata packet with protocollib what are the necessary fields to update

daring lark
#
                            if(!args[3].equalsIgnoreCase("s") || !args[3].equalsIgnoreCase("b")) {
                                player.sendMessage(ChatColor.GREEN + "Dozwolone typy sklepów to b(kup) oraz s(sprzedaj).");
                                return true;
                            }
                            player.sendMessage(ChatColor.GREEN + "Utworzono sklep.");
                        }``` why when i type b or s plugin is still sending a message about correct shop types. Should not this if statement just get skipped?
crisp steeple
#

it’s not an else statement

sacred mountain
#

how can i get a player's UUID that has never played before?

#

or the player's info like name, uuid

crisp steeple
sacred mountain
#

no as in they have never loggedi n

crisp steeple
#

yes

sacred mountain
#

i thought offlineplayer was for people who have logged in before

#

or is it every mc account

crisp steeple
#

Bukkit.getOfflinePlayer

#

that returns a mc account with the uuid you give

sacred mountain
#

how do i check if a player exists from just a string (name)

#

so if i create a method like isPlayerExist(String name)

crisp steeple
#

Bukkit.getOfflinePlayer(name)

#

deprecated though

#

you mean if they’ve ever logged in before?

worldly ingot
#

It will still always return a player whether or not they exist

crisp steeple
#

yeah it’s wack

worldly ingot
#

If you want to check if some name exists and has an account, you'll have to directly query Mojang API

#

Or, I suppose, Microsoft API

crisp steeple
#

^

#

i think mojang api still works

worldly ingot
#

Probably but not for long

sacred mountain
#
public String getUUIDFromName(String name) {
        Scanner scanner;
        try {
            scanner = new Scanner(new URL("https://api.mojang.com/users/profiles/minecraft/" + name).openStream());
            String rawData = scanner.nextLine();
            scanner.close();
            return UUID.fromString(rawData.split("\"")[3].replaceFirst("([0-9a-fA-F]{8})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]{4})([0-9a-fA-F]+)", "$1-$2-$3-$4-$5")).toString();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "not found";
    }```
#

thats what i have for uuid

#

i didnt make that code

crisp steeple
#

does it work?

sacred mountain
#

cghecjgubg

#

checking*

worldly owl
#

came across this random src on my pc and am trying to fix it, its using (oh god, people are gunna get mad) 1.7 and its trying to do some silent check, and its just not working. ((CraftEntity)entity).getHandle().Silent = silence;, Silent isnt a boolean nor even exists. why did i decide to do this

worldly ingot
#

Any reason you're still using 1.7 though? Are you updating it from 1.7? If so, Bukkit has API to set the silence value of an entity

#

entity.setSilent(true)

worldly owl
#

yeah no i dont feel like updating this dinosaur lmao

#

im just messing around with it cause fun

#

even worse though some of it when i imported into intellij was using java 7

#

i mean im 99% sure its some mineplex code from a leak i got ages ago, so it would explain it.

#

well, given the project literally says mineplex i think it is lmao

kindred valley
#

how can i run main via maven

radiant cedar
#

is this not how i would store properties in yml??

#

but how would I read this data and create an object with each

#

like zorro will be a rank with given multiplier cost and blocks as a list

#

this is how to create the rank but how can i gather these data from the yml

#

to actually put it in as parameters to make the ranks

crisp steeple
#

FileConfiguration#getConfigurationSection(“ranks.” + playerName).get(“value”)

#

also not a good idea to make config based on player names, use uuid instead

radiant cedar
#

this is not player names

#

those are names of the ranks

crisp steeple
#

oh

#

then yeah doesn’t matter

crisp steeple
#

gets a value from the rank

radiant cedar
#

ok but how would i make the blocks work

crisp steeple
#

etc #getInt(“multiplier”)

radiant cedar
#

because i need a list of blocks for each

crisp steeple
radiant cedar
#

no

crisp steeple
#

use getMapList if you want the map

crisp steeple
#

Material.valueOf(blockName) (not sure if it’s case sensitive or not)

radiant cedar
#

i would put "ranks."+ "zorro"

#

?

crisp steeple
#

is there a method for that?

#

i thought there might but i wasn’t sure

crisp steeple
#

ah

#

ok then yeah use that

radiant cedar
#

as parameter

crisp steeple
radiant cedar
#

ye i think so

crisp steeple
#

i would make each rank a configuration section, not a value of a list

radiant cedar
#

how

crisp steeple
#

did you create this yaml manually or did you program it?

radiant cedar
#

manually

crisp steeple
#

yea

radiant cedar
#

ye but below the second rank is wrong i know that part

#

wait ill send only first 2 ranks

#

ranks:

  • name: zorro
    multiplier: 1
    cost: 40000
    blocks:
    - name: stone
    prob: 0.6
    - name: coal_ore
    prob: 0.2
    - name: iron_ore
    prob: 0.2
    - name: gold_ore
    prob: 0.2
  • name: xylia
    multiplier: 1
    cost: 70000
    blocks:
    - name: stone
    prob:
    - name: coal_ore
    prob:
    - name: iron_ore
    prob:
    - name: redstone_ore
    prob:
    - name: lapis_ore
    prob:
    - name: redstone_block
    prob:
    - name: lapis_block
    prob:
#

why tho

#

what does that even mean

crisp steeple
#

it’s not a configuration section

radiant cedar
#

idk what that means 😆

crisp steeple
#

so it can’t have properties like that

radiant cedar
#

huh?

#

but then i cant define what is the name

#

of the rank

#

can i

#

that is what i had initially

#

like this

#

does this work

#

and i have each block: so i can add probability

#

liek oak_log: 0.1

#

can i do that

#

can I explain this clearly so u can help me, never done yml

#

so might need some help

#

if u dont mind

#

ok i got it liek this

#

but why does this not work

eternal night
#

depends on whether you use maven or gradle

#

do you have a pom.xml ?

vocal cloud
#

Think?

eternal night
#

on your right side there should then be a maven tab

#

open it and find the package goal

#

double click that and it should package your jar

radiant cedar
#

can someone help me with reading yml file

tepid ore
radiant cedar
#

idk how to read the yml

#

properly

tepid ore
#

I can't be bothered to real everything you've sent before lol

radiant cedar
#

so this is my class for ranks

tepid ore
#

Yeah?

radiant cedar
#

and I have all the properties of each rank

#

stored in yml

#

like this

tepid ore
#

And what is not working?

radiant cedar
#

i just dont know

#

how to read the yml

#

to store these data

#

in the class

#

or implement rather

fleet falcon
tepid ore
#

To read for example the willow multiplier you would do like config.getInt("willow.multiplier") or whatever the full path is

#

That is all

radiant cedar
#

oh alright

#

but willow is a name for rank

fleet falcon
#

YamlConfiguration.loadConfiguration(new File("path"))

tepid ore
#

^

radiant cedar
#

so is there a way i can generalise a code

#

for all ranks

tepid ore
#

Iterate over all ranks

radiant cedar
#

ye but like

fleet falcon
#

xd

tepid ore
#

And get all values in the loop

radiant cedar
#

how do u get "willow"

fleet falcon
#

yaml is section based language

radiant cedar
fleet falcon
#

get new section then loop it

tepid ore
#

for(String s : new String[] {"willow", "vero"}

radiant cedar
#

so this is bad way

#

of doing

fleet falcon
tepid ore
#

Or just do for(String s : config.getConfigurationSection(SomePath).getKeys(false))

fleet falcon
#

yes

#

better

tepid ore
#

Depends if you have all ranks in the config from start or not

fleet falcon
tepid ore
#

If not, use the first option, otherwise the second

fleet falcon
#

just listen @tepid ore

tepid ore
#

Hmm?

#

To what?

fleet falcon
#

theres no ,

#

i said him

tepid ore
#

Ohh

#

My bad

radiant cedar
#

aight ty guys

tepid ore
#

Thought u told me to listen

#

Np :>

radiant cedar
#

can i ask more question if i get stuck again

tepid ore
#

Ofc

radiant cedar
#

❤️

tepid ore
#

That is why we are here

#

❤️

grim ice
#

i need an idea

#

im SO BORED

tepid ore
#

For?

#

Any plugin?

#

Just random?

grim ice
#

anything i cann code

tepid ore
#

Uhh

#

Configurable mob switch?

grim ice
#

wats that

tepid ore
#

Per-Mob and world?

#

mob limit

#

And disable certain mobs

#

Maybe?

grim ice
#

ehhhh

radiant cedar
tepid ore
#

You need the full path

#

So from the first path

radiant cedar
#

ohh

tepid ore
#

Ranks.willow.multiplier or whatever

radiant cedar
#

ohoh

bronze nest
#

Guys do u know any good tutorial playlists that is good for learning Spigot?

radiant cedar
#

i thought u actually meant the file path

tepid ore
#

Also, do for(String rank : config.getConfigurationSection(YourConfigPathToRanks).getKeys(false))

#

Oh, nono

tepid ore
# bronze nest Guys do u know any good tutorial playlists that is good for learning Spigot?

Howdy all and welcome to my all-new series for Plugin Development! New videos every Monday. Join my discord for help and more :)

Download Eclipse: https://www.eclipse.org/downloads/packages/release/2019-03/r/eclipse-ide-java-developers

Download Java Jre: https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html

Down...

▶ Play video
#

Pretty good imo

#

Do you know Java?

#

Otherwise, start with that

radiant cedar
#

why is first one 0 tho

bronze nest
radiant cedar
tepid ore
#

Then watch the tutorial 🙂

bronze nest
#

Alright thanks bro

tepid ore
#

Np

tepid ore
tepid ore
#

Or is the multiplier 0?

radiant cedar
#

zorro

#

smh

#

lol

tepid ore
#

Does it exist in the config?

#

Ohh

radiant cedar
#

its supposed to be zorro

#

i typo

tepid ore
#

Yeah might be it lol

radiant cedar
#

also idk if this is good idea

#

so i have blocks right

#

and each blocks id

tepid ore
#

What is it?

radiant cedar
#

with probability

#

so the double numbers

#

are probability for each block i want

#

but is this a bad way of writing this

tepid ore
#

I would just do a list, with the blocks and then the odds after a comma

#

But yeah

#

That works

#

I would suggest a list as it is easier to edit and read imo

radiant cedar
#

because this way just like "zorro" "serenity" i would need to search by block name right

tepid ore
#

Yup

#

Though

#

If you have them in a list

radiant cedar
#

how can have them in a list here

tepid ore
#

You can do config.getStringList()

#

add a hyphen before the block name, and remove the :

radiant cedar
#

hyphen and space right

#

where do i keep probaiblity

tepid ore
#
blocks:
- "Stone,10"
- "Dirt,20"
#

Like this

radiant cedar
#

oh alright

fleet falcon
tepid ore
#

I prefer a list, but whatever works

radiant cedar
#

ya i imagine

#

so i will do substrings

#

for this now?

tepid ore
#

Yeah

radiant cedar
#

to seperate name and odds

#

alright

tepid ore
#

Mhm

fleet falcon
#

just write
gold: 0.5
diamond: 0.1

#

and loop them

#

its all

tepid ore
#

^

#

This works too if you want

#

Preference

onyx fjord
#

where do i find itemstack version list?

crisp steeple
#

making yaml manually is not a very good idea

fleet falcon
tepid ore
onyx fjord
#

this v shit

fleet falcon
#

did you hear xmaterials

onyx fjord
#

meh

fleet falcon
#

i think your solution is it

radiant cedar
onyx fjord
#

my plugins supports only latest and prelatest

radiant cedar
#

since my whole yml is liek that

fleet falcon
#

xmaterial is cross platform itemstack parser

tepid ore
#

Though

#

If you want all materials

tepid ore
#

Don't add them by hand

#

Iterate over all materials

#

And add them that way

onyx fjord
#

its made in code, the file

fleet falcon
onyx fjord
#

it serializes the inventory or whatever

fleet falcon
#

is it a database

onyx fjord
#

its a yml file

fleet falcon
#

yes but

#

you are using as

#

database or config

onyx fjord
#

config

fleet falcon
#

okay then xmaterial is better

onyx fjord
#

meh i dont need that

fleet falcon
#

but your choose

onyx fjord
#

i just wanna know the 1.17.1 itemstack version lol

fleet falcon
#

okay i understand you

kindred valley
#

?paste

undone axleBOT
onyx fjord
#

this is what im using

fleet falcon
#

ik

radiant cedar
#

to find each name of block

onyx fjord
#

soo like where the version comes from?

radiant cedar
#

i kept it like this

onyx fjord
#

btw this is the error
java.lang.IllegalArgumentException: Newer version! Server downgrades are not supported!

#

it screams that version is too new

fleet falcon
#

good question but did you complete everything except that

fleet falcon
upper vale
radiant cedar
#

what would blocks: be

#

cus its not Int

#

but does it count as string

#

if like that

#

idk yml bruh

fleet falcon
#

double

radiant cedar
#

huh

#

no i had blockname: block_odds

#

im not hardcoding blockname for each rank

#

so how could iget blocknames as a list

#

if its a key

upper vale
#

Blocks is a configuration section

#

getKeys returns block names

fleet falcon
#

yes as i said above

onyx fjord
#

thx

tepid ore
#

config.getConfigurationSection(path).getKeys(false)

fleet falcon
#

yaml is section based language

onyx fjord
#

btw its 2730 if somebody wanna know

radiant cedar
#

but what is boolean deep

#

for the getKeys method

fleet falcon
#
section1:
    deep-section:
        another-deep-section:
section2:```
tepid ore
#

Whether or not to get the section under

#

Yeah

#

That

radiant cedar
#

so i put true

fleet falcon
#

you should false

#

because you'll need only rank names right

radiant cedar
#

wait what

#

im getting the keys under blocks:

#

so im getting the block names

#

and i can also use these names to get probabilities

fleet falcon
#

no you didn't understand

#

firstly you should loop rank names

#
rank1:
    deep-section:
rank2:
rank3:
#

and get section of the a rank

#

serialize the section

radiant cedar
#

i mean im getting all the values i need with this rn

#

is it bad

fleet falcon
#

can i use anydesk

radiant cedar
#

lolol

fleet falcon
#

okay

#

look

#

do you know what is section

radiant cedar
#

not rly

radiant cedar
#

but im guessing its whatever comes before :

fleet falcon
#

section is it

fleet falcon
fleet falcon
#

but all sections includes under sections of itself

radiant cedar
#

yes

#

but these dont correct?

fleet falcon
#

these are correct

#

but what is parent section of them

radiant cedar
#

yes but these dont have under sections

#

right?

fleet falcon
#

you need it

#

yes

radiant cedar
#

their parent is blocks

fleet falcon
#

good

radiant cedar
#

blocks' parents is ranks

fleet falcon
#

you should loop blocks

#

get blocks section

#

and paste here code

radiant cedar
#

config.getConfigurationSection("ranks." + s + ".blocks")

#

where s is a given name of a rank

tepid ore
#

Yeah

fleet falcon
#

do you want store their proabilities as list

radiant cedar
#

i guess yes

fleet falcon
#

okay then create new method

#

which is returns list

#

the method will need configuration section parameter

radiant cedar
#

static public ArrayList<Double> probabilityList(ConfigurationSection section) {

    ArrayList<Double> probs = new ArrayList<Double>();
    
    return probs;
}
fleet falcon
#

good

crisp steeple
#

syntax error?

#

what

fleet falcon
#

i didnt check it

radiant cedar
#

i dont have any errors

fleet falcon
#

where is it

fleet falcon
#

whats problem

quaint mantle
#

static public

#

no what the fuck

#

die

crisp steeple
worldly ingot
#

They can be in any order, yeah

fleet falcon
#

i teach him config sections i dont i care static and public keywords

#

i talking for her level

radiant cedar
#

<3<3<3

crisp steeple
#

never even knew that

#

lol

worldly ingot
#

If you really want, you can do strictfp final static protected void hello()

radiant cedar
#

huh

worldly ingot
#

No, please don't do that. Just making a point lol

fleet falcon
#

this is a util method

#

so you should make static it

#

but not public

#

make it private

radiant cedar
#

alr

fleet falcon
#

but you need map to make it

radiant cedar
#

does this look right

fleet falcon
#

no

crisp steeple
#

it’s a string

radiant cedar
#

oh maps

#

ok

fleet falcon
#

its really hard

#

to explain

radiant cedar
#

i did this

#

it works

quaint mantle
# radiant cedar
List<Double> probabilities = section.getKeys(false).stream()
                                                   .map(p -> config.getDouble("ranks." + p + ".blocks." + x)
                                                   .collect(Collectors.toList());
radiant cedar
#

what hte hell

#

does that actually work

eternal oxide
#

what is he trying to do with these probabilities?

radiant cedar
#

that comes later

fleet falcon
radiant cedar
#

making prison server

eternal oxide
#

you can get it as a Map simply by get the section, cast to MemorySection and .getMap()

fleet falcon
#

completely same but its one line

radiant cedar
#

yuh yuh i get that i get that

quaint mantle
fleet falcon
#

yeah actually

radiant cedar
#

what does -> even do

fleet falcon
#

i can write all classes in one line using java

radiant cedar
#

in java

fleet falcon
#

no

#

its lambda

quaint mantle
eternal oxide
#

@radiant cedar Is there a reason you want a List of probabilities?

radiant cedar
#

yes

#

for spawn rates of blocks

radiant cedar
#

for each rank of mines

fleet falcon
#

you should use map

#

i said

radiant cedar
#

dont need i will just use 2 arraylists like a noob

eternal oxide
#

it seems odd to want it in a List where you need a key

quaint mantle
#
void take(Consumer<Integer> consumer) {
    consumer.accept(1);
}

//

// myObject.take(i -> System.out.println(i));
myObject.take(System.out::println);
fleet falcon
#

or you can send lambda guide to him

#

today my english is crashed

radiant cedar
#

.getKeys returns an array of strings right

eternal oxide
#

a simple Map would be more useful

fleet falcon
radiant cedar
#

i see string over there so im guessing this means that

#

but

#

looks weird

fleet falcon
#

you can think Set = arraylist

radiant cedar
#

oh ok

fleet falcon
#

but not

#

know it too

ivory sleet
#

a list w/o order and w/o duplicates

radiant cedar
#

ok ty guys

#

can u not just do Material.getMaterial(gold_ore) ??

ivory sleet
#

matchMaterial is preferred

kindred valley
#

I'm checking if the specified item has persistentdatacontainer i want but its not entering

#

p.getInventory().getItemInMainHand().getItemMeta().getPersistentDataContainer().has(new NamespacedKey(Main.plugin, "phone-data"), PersistentDataType.STRING)

#
public PhoneItem() {
        ItemMeta meta = phone.getItemMeta();
        PersistentDataContainer container = meta.getPersistentDataContainer();
        NamespacedKey key = new NamespacedKey(Main.plugin, "phone-data");
        container.set(key, PersistentDataType.STRING, "PHONE");
        phone.setItemMeta(meta);
    }
pastel juniper
#

I want to make a plugin that creates a config file for every player, but I don't really understand how all this work.

pastel juniper
# kindred valley ```java public PhoneItem() { ItemMeta meta = phone.getItemMeta(); ...

public class ItemManager {
public static ItemStack Phone;

public static void init() {
    createPhone();
}
private static void createPhone(){
    ItemStack item = new ItemStack(Material.PAPER, 9);
    ItemMeta meta = item.getItemMeta();

    meta.setDisplayName("Phone");
    PersistentDataContainer pdc = meta.getPersistentDataContainer();
    pdc.set(new NamespacedKey(Main.getPlugin(Main.class), "phone-data"), PersistentDataType.BYTE, (byte) 1);
    item.setItemMeta(meta);
    Phone= item;
}

}

pastel juniper
fleet falcon
#

no

#

purpose of database is storing datas in one part

#

multi yaml file databases is a lot of issues

#

for example you cannot load them in startup

rough drift
#

well not yaml

#

a cheaper format

fleet falcon
#

i recommend sqlite

crisp steeple
#

from my experience using yaml files as a database is very bad and tedious

rough drift
#

I'd suggest however doing this:

Use PDC if you don't need much storage
If you need to act on offline players, store an action that you can run when they join in a file (such as: REMOVE, ADD, SET)

crisp steeple
#

i would recommend sqllite like he said or just an actual database

#

or pdc if it’s small enough

#

but i don’t think that’ll work if you’re making it multi-server

fleet falcon
#

btw i have sqlite api uwu

rough drift
#

fastest and most efficient way for single key-value pair storage

fleet falcon
#

if your server is not hypixel

#

probably you dont need it xd

#

but you can. of course.

rough drift
#

wait

#

wrong

#

Redis + AOF & RDB

rough drift
#

but for a simple key-value pair look up its more than enough

quaint mantle
#

player.getInventory().getItem(i).hasMetadata("test")
Cannot resolve method 'hasMetadata' in 'ItemStack'

rough drift
#

player.getInventory().getItem(i).getPersistentDataContainer().has(key, type);

#

you want that?

quaint mantle
#

i am trying to see if it has metadata

#

with the name "test"

rough drift
#

wdym

#

like a custom tag?

quaint mantle
#

ye

rough drift
#

?pd

#

?pdc

fleet falcon
#

metadata of itemstacks is nbt

quaint mantle
#

that's not even what i'm trying to do

rough drift
fleet falcon
#

or aak persistent data container

quaint mantle
#

what if i cast it to item

#

lol

round agate
solid cargo
#

how can i disable redstone placement. this doesnt work

crisp steeple
#

can you send the full event?

solid cargo
#

the rest of if's work tho

#

except redstone

#

kinda shit code but yeah

#

also registered it on main class in onEnable

river oracle
quaint mantle
#

lmao

#

nice code

river oracle
#

e.g. banned components and check if the material is in the list

solid cargo
quaint mantle
#

what version u on

solid cargo
#

sure i will make a list

#

api is 1.16

#

server is 1.17

river oracle
#
if(bannedComponents.contains(Material material){
  e.setCanelled(true);
}
solid cargo
#

.1

#

yeah

#

thank you

river oracle
solid cargo
#

rest of it works

worldly owl
#

hey to check if the player is online do i just make an if statement and check if Player is null?

worldly owl
#

aight cool tyty

river oracle
solid cargo
#

yes

river oracle
# solid cargo yes

that means redstone isn't being placed you could figure out the correct material if you just do a simple sysout(mat)

#

usually I do that if i'm not quite sure

#

simple debug statement should clear up if you got the right material comparing

worldly owl
#

ah kk ty for the ifno

#

info*

#

im trying to make a mineplex-style core plugin because im bored, its not gunna go well but why not.

solid cargo
#

didnt think of that

#

thanks guys <3

worldly owl
#

ty ;D first proper plugin that im actually going to use lmao

river oracle
#

yep its REDSTONE_WIRE

#

just looked at docs

radiant cedar
#

how can I add a new variable and method for the Player class

#

so everyone can have a rank and money variable

crisp steeple
#

you can’t

#

you would have to make a wrapper class

radiant cedar
#

oh

crisp steeple
#

or switch to kotlin

#

(don’t actually)

worldly owl
#

you can code bukkit plugins with kotlin?

#

damn

#

gg

crisp steeple
#

you can code anything you could in java with kotlin

#

it’s pretty neat

worldly owl
#

really?

crisp steeple
#

not easy really

#

just different

worldly owl
#

i find java easy but kotlin a little confusing

#

granted though my only experience is android apps so.

crisp steeple
#

kotlin has a higher learning curve but a lower starting point

worldly owl
#

not a good reference point lmao

crisp steeple
#

it’s probably easier to learn a small amount of kotlin than a small amount of java

#

but harder to learn a lot of kotlin than it is to learn a lot of java

worldly owl
#

i mean if im honest i find java somewhat easy

#

sometimes its really confusing but like right now it isnt bad

#

i mean i just learned what a constructor is so thats nice

#

btw is ur pfp a crab deotime?

crisp steeple
#

yes

#

carboncrab

worldly owl
#

lets go

#

wait if i use mongodb for storing perms can that handle a hashmap for my permissions

#

infact how tf do i make a hashmap for it he bukkit wiki doesnt really get into that

#

nono

#

it says how to make one

quiet ice
#

Map<Object, Object> x = new HashMap<>();

worldly owl
#

but i dont get how i would add to one through my onjoin event

#

and how i would make one globally avalable because i have an instance thing but thats static

#

whats the difference? ive used neither ;D

quiet ice
#

I am an API dev, I already made that mistake a few times - not so great to refactor afterwards

quaint mantle
#

or just a normal person who follows conventions

#

its not advanced coding

compact haven
#

^

worldly owl
#

yes but what is the difference between a map and a hashmap i dont understand that

compact haven
#

you always use the lowest level contract for field types

worldly owl
#

they sound the same

compact haven
#

Map is an interface

#

HashMap is an implementation

worldly owl
#

ah ok

compact haven
#

It groups things by their hash to minimize the number of equals calls

worldly owl
#

and im assuming after a while that makes a big difference?

#

performance wise anyway

compact haven
#

Uh

quiet ice
#

yeah, that being said hashmaps are not the be-all-end-all of collections

compact haven
#

Not compared to Map, you can’t make a Map

#

Map is just a set of methods a class must have to call itself a Map

worldly owl
#

i have now learned what an interface is, useful.

quiet ice
#

There are multiple implementations like TreeMap, HashMap, LinkedHashMap, ConcurrentHashMap and etc.

quaint mantle
#
interface Animal {
    void speak();
}

class Cat implements Animal {
    @Override
    public void speak() {
        System.out.println("meow");
    }
}

//

Animal animal = new Cat();
animal.speak();
worldly owl
#

i agree

#

good cat

#

cat is good

#

i mean dogs are better and smarter but cat

quiet ice
#

They are nice and all, but sometimes they are too much care.
But then I am also a particularly lazy person

worldly owl
#

my mum loves cats but i like both

#

cats look cute

#

and dogs are better at most other things

#

im watching a yt tutorial for mongodb and java and the guy said the program isnt going to work until i compile it

#

like yeah bro imma go run raw java code rq 1 sec

quiet ice
#

People are doing too much python/lua/javascript/etc these days

worldly owl
#

yes well

#

e

#

the guy told me to make the mongodb client and stuff in the onenable, how tf am i gunna access that outside the onenable

#

can i just make it private static outside the onenable and then make a thing to getMongo()

radiant cedar
#

i got this far

#

where x is the users uuid

#

but if there is no entry for that player

#

how can i make it so the code can make a new key with the

#

uuid

#

so then i can add a key for ranks and money to that

#

@fleet falcon

#

huh

#

like this

#

ye ik the path dosnt exist

#

i have different method to check

#

but how can i add

#

nono but what if that "players."+ x doesnt exist

#

how can i make new

#

what that x

#

ohhh

#

ok thats so good

worldly owl
#

hey how do i add my permissions to the db? it would be kinda dumb to do a hashmap with player,permattachment and im not sure what else to put there

radiant cedar
#

tyy

worldly owl
#

yeah well in general what would i store,

radiant cedar
worldly owl
#

because i got the id stuff alr set i just need a way of storing all the permissionsattachments

undone axleBOT
radiant cedar
#

idk what part of code

#

to paste

worldly owl
#

wait no shouldnt i store a list of strings with all the permission nodes then for each when a player joins add that to the permission attachment?

#

how do i store a list of strings?

#

not a hashmap since that needs 2 things, just a straight list of all of them

tepid ore
#

What are the benefits on making an inner class static? I assume the class is loaded and stored just like a static function, but anything apart from that?

mortal hare
#

Java was hipstery type of programming lang too in the 90s

quaint mantle
#

because they have no reason not to be

quiet ice
#

That is true

mortal hare
#

if you make inner class static you dont need to initialize the outer class in order to construct the inner one

quiet ice
#

Also, did you know that there are CPUs that can execute Java bytecode? So theoretically Java is a low level lang these days.

quaint mantle
#

its so hideous

echo basalt
#

isn't it new Main.MyClass().doSomething()

mortal hare
#

suppose you have a inner class in which you want to use private outer class fields without providing for people to directly access the public fields

quaint mantle
mortal hare
#

then you should use inner non static class

#

i have kinda good example