#help-development

1 messages · Page 2022 of 1

round finch
#

so get online players to array or list something

lime jolt
#

;-;

round finch
#

whatever

young knoll
#

I mean technically you can

hasty prawn
#

He told you to use this, you changed it

lime jolt
#

so how do I go through all online players

hasty prawn
#

No I know, I meant you told them to use it

undone axleBOT
hasty prawn
#

And they changed it to the for(int i...

round finch
#

it is basic java

lime jolt
#

i know how to do a for each loop

#

I want to know what the f Bukkit.getOnlinePlayers(); means

pliant oyster
#

@lime jolt what are u trying to do

round finch
#

?spigot

lime jolt
#

go through each online player and do something to them

#

;-;

round finch
#

spigot documentation

lime jolt
#

THATS WHAT I SAID

hasty prawn
#

@tender shard this blog is nice btw, very useful information NODDERS

lime jolt
#

but i thought u said I could use it some how

young knoll
#

This is the ?learnjava that never ends

#

It just goes on and on my friend

lime jolt
#

so then mfnalex

#

how do I go from that method

#

^^^ true

#

I dont know what that method means

pliant oyster
#

lmao

lime jolt
#

but HOW

pliant oyster
#

it's straight forward

round finch
lime jolt
#

I need an explenation

#

ok

#

so how would I narrate through all of the players

#

using that method

#

I know how to use a loop

undone axleBOT
lime jolt
#

...

pliant oyster
lime jolt
#

;-;

#

I have read it

pliant oyster
lime jolt
#

indeed

#

all 5k pages

#

indeed

vague oracle
#

this is funny to read

lime jolt
#

drum rolll

#

.....

#

most intense typing I have ever seen

#

the answer

#

to all of my problems

simple anvil
#
if (hand == null) {

                p.sendMessage("You need to be holding a item in your main hand");

            }else{
                ItemMeta meta = hand.getItemMeta();
lime jolt
#

...

simple anvil
#

ok

lime jolt
#

........

#

........................

simple anvil
#

Caused by: java.lang.NullPointerException: Cannot invoke "org.bukkit.inventory.meta.ItemMeta.setLore(java.util.List)" because "meta" is null
this is the error

lime jolt
#

;-;

simple anvil
#

why

vague oracle
lime jolt
#

!report mfnalex cyberbulling

simple anvil
lime jolt
#

lol

solemn gulch
#

if i have a folder in my resources directory named configs and a file named config.yml inside of that

how do I do saveResource("configs/config.yml", false) and save it to the plugins directory under config.yml and not configs/config.yml

simple anvil
#

and return stops the code right?

round finch
#

getItemInOffHand
getItemInMainHand

simple anvil
#

return true?

lime jolt
#

anyone know how I can narrate through all of the players in a server

worldly ingot
#

This is not rocket science.

for (Player player : Bukkit.getOnlinePlayers()) {
    player.sendMessage("hi");
}```
#

You need to take the advice of people in this channel and learn some more of the basics

young knoll
#

Work slow down choco

#

What’s the { mean

sharp flare
#

I thought you know how to use loops

lime jolt
#

;-; I know java basics

#

just new to minecrat programming

vague oracle
#

Can you just time him out already?

lime jolt
#

;-;

sharp flare
#

he is pretending too bad

lime jolt
#

no i not

#

;-;

young knoll
#

I know java basics

Doesn’t understand collections

simple anvil
worldly ingot
#

Collections are not Minecraft-related

#

They are Java features

#

These are things you should have a basic understanding of

lime jolt
#

but implementing them with that method for me is not normal

simple anvil
#

yes but hand is null

#

and return should stop the code

lime jolt
#

Bukkit.getOnlinePlayers()

sharp flare
#

You gotta read the docs also

lime jolt
#

is new

round finch
#

java is object oriented programming

lime jolt
#

i know

worldly ingot
#

That's fine, but from there, iterating over it should be something you should know

sharp flare
#

if u can read the java tutorial u said with 5k pages then reading docs for spigot aint that hard

simple anvil
#

oh

#

should i do if meta is null

#

ot hand.gettype

young knoll
#

Check if the item is null or air

round finch
#

wait there is tutorials on every spigot object?

sharp flare
#

I thought ItemMeta gets created when non exist?

simple anvil
#

i thougt hand it a material.air

young knoll
#

It does

#

But not on air

#

Because spigot wack

sharp flare
#

fair

round finch
#

Material.Air feels bad

simple anvil
#

hm

#

if hand.getItemMeta() == null)

young knoll
#

Is air even meant to be in an itemstack

simple anvil
#

should i just do this?

young knoll
#

There’s also hasItemMeta

simple anvil
#

ok

young knoll
#

Correct

#

Which is what you want if you are only reading meta

#

If you are modifying it, that’s different

#

Fair

#

I’m guilty of using getItemMeta when I only want to read

#

Which is bad

simple anvil
#

kinda

#

skimmed it

young knoll
#

Arrows mean go, and go means fast

#

Arrows make code fast

round finch
#

Arrow? wut?

simple anvil
#

so
if(!(sender instanceof Player))?

#

kk

round finch
#

joinks thanks

simple anvil
#

also if i do
/lore
i get a error
i wanna be able to do
/lore agag
and it still send the help page
only if i do /lore set/remove
then i want it to run that code

#

how do i do that

pliant oyster
#

what's the error

round finch
#

oh no i'm using the wrong way
jikes

simple anvil
#

ok give sec

#

sorry

round finch
#

i were unfamiliar

#

first time hearing about it

#

but i guess i havn't done much patterns designs

#

it is messy

simple anvil
#

when i do /lore i get
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0

simple anvil
#

kinda

#

yes

young knoll
#

Only V O I D

simple anvil
#

if i do
/lore
/lore egasrgag
it shows the help page
but if they type remove/set
then it does the code

#

yes but what if
/lore ojkgaga
i want it to still show the hlep page

#

ok

#

thanks

young knoll
#

Switch would work well

simple anvil
#
if (!(args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("set"))){
                p.sendMessage("help page");
                return true;

            }
young knoll
#

Plus that’ll just keep getting uglier as you add more options

simple anvil
#

well i want
/lore
/lore agaega
to both show the help page
how do i do that

sharp flare
#

are u using a list for your lores

simple anvil
#

i think so

sharp flare
#

what

simple anvil
#

iv been coding this for 3 hours

#

will that do waht im trying to do
/lore agag help page
/lore help page

#

i thought u said i should not use a switch

young knoll
#

This channel is great for my self esteem

#

Clearly you must do it all for them

simple anvil
#

im sorry

worldly ingot
#

Last I recall, Arrays#asList() is immutable

young knoll
#

How long until you start charging

worldly ingot
#

Lists.newArrayList(args) would be the appropriate replacement there

young knoll
#

You could also just stick with immutable

#

And use Arrays.copyOfRange

worldly ingot
#

Yep

young knoll
#

I think that’s the name anyway

simple anvil
#

bit to late, im reading it now

#

package com.sun.istack.internal does not exist

#

import com.sun.istack.internal.NotNull;

#

kk

#

what does that do

young knoll
#

That’s a weird import

#

Can’t say I’ve had eclipse tell me to just import things that don’t exist

floral flare
#

Does anyone have any ideas on how to make this returnable?

    @Override
    public void onPluginMessageReceived(String channel, Player player, byte[] message) {
        if (!channel.equals("BungeeCord")) {
            return;
        }
        ByteArrayDataInput in = ByteStreams.newDataInput(message);
        String subChannel = in.readUTF();
        if (subChannel.equals("PlayerCount")) {
            int playerCount = in.readInt();
            //ra
        }
    }```
#

My idea was to put the return on the scoreboard, but you can't do that with a void :/

#

and I confess that I don't remember how to do it

crystal magnet
#

In the BungeeCord API, is a PlayerDisconnectEvent fired for each connected player when the proxy shuts down?

floral flare
crystal magnet
#

i mean when someone runs /end, which makes BungeeCord shut down

floral flare
#

But if you want to get all the players, you have to make a method to get all the players when one player leaves

pliant oyster
#

for some reason, I dont gain hearts from killing ppl and sometimes the person who dies doesnt lose any, what went wrong

        if(lastDamage instanceof EntityDamageByEntityEvent){

            EntityDamageByEntityEvent entityDamage = (EntityDamageByEntityEvent) lastDamage;
            Entity killer = entityDamage.getDamager();

            if(killer instanceof Player){

                Player player = ((Player) killer).getPlayer();

                // Adds a heart to the killer
                double killerHeartAmount = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
                killerHeartAmount = killerHeartAmount + 2.0;
                player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(killerHeartAmount);

                // Removes a heart from the player
                Player player1 = e.getEntity().getPlayer();
                double playerHeartAmount = player1.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
                playerHeartAmount = playerHeartAmount - 2.0;
                player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(playerHeartAmount);

            }

        }```
crystal magnet
#

ok, thanks

floral flare
lethal coral
#

How can I convert a Chatcolor to the nbt value for color for leather armor
Nevermind

worldly ingot
#

Or just update the scoreboard directly if you really want. Get the scoreboard you're updating, set that value

simple anvil
young knoll
#

What

#

If no one is online

sleek turret
#

^^

simple anvil
#

yes

young knoll
#

How can someone say those words

simple anvil
#

no

sleek turret
#

bro my brain hurts trying to understand

simple anvil
#

for get that

#

if 1 person is on the server

#

and they say that

#

how can i make it so i tells me who says the word when i get online

sleek turret
#

if you want to know if someone said something before they left the server, you would need to log chat. i dont think minecraft does that natively.

simple anvil
#

ok

#

danke

young knoll
#

It does

sleek turret
#

bitte

sleek turret
simple anvil
#

how

young knoll
#

All chat is logged and then compressed when the server restarts

simple anvil
#

mhmhmhmhm

#

tasty

#

how do i read them,

sleek turret
young knoll
#

Yes

#

Before a restart it’s plaintext

simple anvil
#

wait nvm

sleek turret
#

oh ok, so @simple anvil, just parse the plain text to find any instances of the message and see who wrote it.

#

i think

#

unless theres a better way

simple anvil
#

im gonna have discord SRV
and ill cansel the event, then brodcast a message

#

that way i can look in the discord chat and search for the keyword

young knoll
#

Probably better to just save the player name to a file manually

#

And like, a time stamp or whatever you want

sleek turret
#

^^

young knoll
#

Discord works too I suppose

simple anvil
#

yes

#

big easy

#

danek

#

in python i can do

name = "cyber"
print($"hi my name is {name}")

is there a way i can do that in java with out
("hi my name is " + name);

young knoll
#

Yes

#

String.format(“hi my name is %s”, name)

simple anvil
#

no but still in the " "

young knoll
#

No

simple anvil
#

oh

young knoll
#

Java doesn’t support string interpolation

#

The best we have is String.format

simple anvil
#

how is that diffrent tehn
String("ok" + "name")

young knoll
#

It’s not

#

But it’s nicer when you have a lot of things to add in

#

So you don’t need a million +‘s

simple anvil
#

%s what does this do

young knoll
#

Placeholder for a string

simple anvil
#

kk

young knoll
#

There’s also %f for floats and so on

#

Has them all listed

simple anvil
#

thanks

quaint mantle
#

Any idea how id make a bomb like so?

#

Note: It takes where the player is facing and throws it in that directions

#

*direction

sharp flare
#

Man I wish i joined this discord server before starting my plugin dev things

#

I spent a lot of time on forums xD

solemn gulch
#

are there any good libraries out there with good documentation for managing configuration files

lethal coral
young knoll
#

You don’t break at the end of the case

lethal coral
#

🤦‍♂️

#

thank you

buoyant viper
ancient plank
#

bomb bomb bomb bomb bomb

#

u probably just set the item's velocity in the direction its thrown then after like 3 seconds generate a sphere around the bomb's location with some particles and sound

#

simple

#

if u don't wanna do the math to generate the sphere urself u can depend on WE iirc @quaint mantle

tidal hollow
#

How can I get the number of totems spent?

I want a message to come out when using a totem

player has used his totem number: 6

quaint mantle
#

any way to make it drop the items?

#

from those blocks however?

sweet pike
#

I've been trying to change the colour of a Particle.SPELL, but anything that I try just spawns white coloured particles. Any help?

location.getWorld().spawnParticle(Particle.SPELL, location.clone().add(0, 1, 0), 0, color.getRed()/255D , color.getGreen()/255D, color.getBlue()/255D , 1);

ancient plank
#

get the blocks destroyed and handle their drops

quaint mantle
#

final question @ancient plank, ingame the item had text above it

#

any way to do that w/out an armor stand?

ancient plank
#

idk man

#

find it out yourself

quaint mantle
#

kk

young knoll
#

Just give the item a name

#

And set it to be visible

quaint mantle
vale cradle
#

is it generally a bad idea to hide NBT Tags from the client?

#

by modifying the items sent to the players using packets

young knoll
#

Meh

#

I mean the main question is, why

vale cradle
#

I'm experimenting :)

#

I already got it working good tho

#

and send an extra value being the hash of the actual nbt to solve the stacking problems that may happen

#

but I was wondering if it would be a good idea to use this in a real environment

young knoll
#

I can’t think of any reason to

ancient plank
#

the only reason I can think of is

vale cradle
#

there can be plenty of reasons to, i.e: keep track of an item without players noticing

ancient plank
#

one guy came in and talked about storing his players' passwords in item nbt

#

kekw

vale cradle
#

were them at least hashed lmao?

ancient plank
#

no

vale cradle
#

kek

young knoll
#

I mean adding pdc is generally unnoticeable

#

Unless they have a mod to show NBT data

#

But who cares if they can see your custom items name or whatever

vale cradle
#

for the most part it doesn't matter, but that's not what I'm asking

ancient plank
#

oh no they can see my CIDs YMg_Dead

young knoll
#

Well if it doesn’t matter then don’t bother

#

At best it does nothing

#

At worst it causes a bunch of weird side effects

vale cradle
#

so, no reason why not?

#

unless there's something I'm missing

young knoll
#

Meh I just don’t trust the client

#

Games wack

ancient plank
#

yeb

#

client wonky

vale cradle
#

hmmm

#

could be interesting if it works with no problem tho

young knoll
#

I think 📄 has options to hide NBT

vale cradle
#

I don't happen to find them, can you tell me where they are?

young knoll
#

No idea

#

I might just be misremembering

vocal cloud
#

Sorta. I've made my own once or twice

#

Yeah I used them to auto register events

#

You can auto register commands as well by having an argument. I might still have it let me check

young knoll
#

You can get the annotations of a class easily enough

#

And go from there

#

And yes I should improve that catch block

quaint mantle
#

how do I prevent a number from going below 1 and above 64?

#

is there like a math.huge

#

or math.boundarys

#

function

#

alr

vocal cloud
#

You want to add methods at runtime bedthonk

young knoll
#

Sounds like Lombok

#

Spoopy

lethal coral
#

https://pastebin.com/EHs6zyJz

    @Override
    public @NotNull Map<String, Object> serialize() {
        Map<String, Object> map = new HashMap<>();
        map.put("pitch", this.pitch);
        // Not putting entity value in as it's generated upon creation.
        //map.put("entity", this.entity);
        map.put("loc", this.location);
        map.put("nbt", this.nbt);
        return map;
    }

    public static NPC deserialize(Map<String, Object> decrypt){
        return new NPC((double) decrypt.get("pitch"), (Location) decrypt.get("loc"), (String) decrypt.get("nbt"));
    }

Why does it throw this error?

quaint mantle
#
Items BasicKey = Items.newItem("basicKey",null, true);

        ItemStack itemA = new ItemStack(Material.TRIPWIRE_HOOK, 1);
        ItemMeta metaA = itemA.getItemMeta();
        metaA.setDisplayName(ChatColor.GREEN + "Basic Key");
        metaA.addEnchant(Enchantment.DURABILITY, 1, true);
        NamespacedKey keyA = NamespaceKeyList.getKey("crateKey");
        metaA.getPersistentDataContainer().set(keyA, PersistentDataType.STRING, "basicCrate");
        ArrayList<String> loreA = new ArrayList<>();
        loreA.add(ChatColor.DARK_GRAY + "A key! can open a basic crate.");
        metaA.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        metaA.setLore(loreA);
        itemA.setItemMeta(metaA);

        BasicKey.setItem(itemA);
#

I feel like im wasting A TON of variables doing this

#

any way I can lower that down?

quaint mantle
#

i constantly type itemA, itemB, etc

#

it gets tiring

#

Yea I thought so

#

Ill try that

vocal cloud
#

Yeah, basically. I'm cleaning it up as it's a mix of two systems due to a server having issues with it.

#

If you want magic look at how Lombok does it

young knoll
#

Fun fact

#

Naming the string in your annotation “value” means you don’t have to specify the name when using it

#

Which was strange to find out

vocal cloud
#

It's the default isn't it? I remember something about that.

young knoll
#

Yeah

simple anvil
#

Are we allowed to post political stuff

#

Sa-mm-nak
Bal-ah-ka-nee-ch-em

smoky oak
#

is --rev 1.18.2 --generate-sources --generate-javadoc --remapped the correct build tools args to generate everything?

faint gale
#

how to make world void how?

smoky oak
faint gale
#

I want to make a skywars server, how do I make the world void?

smoky oak
#

you can either use a prebuilt map or void world, or run a function that sets every block to air in the chunks making up the arena

#

okay wtf is the arg for javadoc

#

nvmind found it

#

where the fuck does it generate to though?

#

like

#

i just compiled but

#

the only javadoc i can find is the 1.18 javadoc from last month

wooden fable
#

Player#setSwimming doesn't work?

#

If I set it to true and you go in water then it works (The player starts swimming right away)

#

But when I try to set it to false it doesn't work. (The player continues to swim)

onyx fjord
#

@wooden fable its getting cancelled on land

#

You must stop it from cancelling

wooden fable
cerulean jasper
#

Is this still how you get itemstack of held item?

invToInteract.getInventory().getItemInMainHand()

(invToInteract is humanentity)

wooden fable
#

I'm trying to set it to false (I'm trying to block sprint-swimming)

cerulean jasper
#

it broke after 1.18.1 or something

onyx fjord
#

Try cancelling the event that triggers when player starts to swim ig

wooden fable
#

I'll try it again, but I've tried that many times (didn't work to)

smoky oak
#

did they change how to register events in 1.18.2?

onyx fjord
wooden fable
#

no?

smoky oak
#

then why the fuck can't i do java @Override public void onEnable(){ getServer().getPluginManager().registerEvent(this, this); }
this anymore

#

it throws an error

wooden fable
#

use registerEvents

#

Not registerEvent

smoky oak
#

wat

wooden fable
#

With a s

onyx fjord
#

Add s

smoky oak
#

why is that a thing

#

what is that a thing for

onyx fjord
#

Always has been I believe

wooden fable
#

registerEvent is a method to, but it takes more arguments.
registerEvents will just register all the events in that listener class

#
    @EventHandler
    public void onSwim(EntityToggleSwimEvent e) {
        e.setCancelled(true);
    }

That didn't work

quaint mantle
#

(Crossplay JavaBedrock) Is there someone in here I can trust with an IP?

#

I need to figure out if someone can join it on Bedrock Ed.

quasi flint
#

Dunno If U can Trust me

wooden fable
#

Is there any packet i can't send (with protocollib) for stopping the sprint-swim animation?

#

Or even just stop the entire sprint swimming

rough drift
#

nothing

#

exactly

grim ice
#

Someone is definitely commiting a crime that will throw him in prison for 10 years 🤓

smoky oak
#

what's the usually used naming scheme for plugins? [major][minor][patch] or [major][minor][build][revision]

ivory sleet
#

Former

smoky oak
#

thx

#

wait

#

people sell plugins

#

how can they do that if all bukkit/spigot code is under GPL3?

ivory sleet
#

I’m not a pro at licenses, but I believe they have to give you source if you ask for it, and most code of plugins is actually written by the authors themselves per say

smoky oak
#

licenses are confusing

#

do you know a website or person that makes this easier?

rough drift
#

like 25€/year for no source and 75€/year for source

#

on spigot

#

i don't remember the plugin tho

#

so how does that work

tall dragon
#

how would they enforce that?

rough drift
#

maybe don't give updates?

tall dragon
#

im pretty sure a license system is not allowed on spigot

rough drift
#

o

ivory sleet
#

But like it takes a lot of effort to enforce someone the license

rough drift
#

yeah but like

#

just don't give out updates?

#

people will just not buy it if they don't want

tall dragon
#

yea, but some servers dont update themselves

#

depend on the kind of plugin

rough drift
#

i know thats why i still get ppl on 1.5.1.2 version of my plugin, which is like 5 months old (note: its free and open source, no reason to not update)

rough drift
#

if so ill try to find it again and report it

ivory sleet
#

I don’t really know, actually

tall dragon
#

what i mean is having a key to make the plugin actually work.

rough drift
#

thats allowed iirc

#

the thing is subscription thing

#

or is it not allowed

#

well wait, just make the key decode the plugin

ivory sleet
#

Like people can license their code afaik

tall dragon
#

ah well having a license system on a spigot plugin does not make much sense

ivory sleet
#

Not sure if same applies to spigot (the software that is)

rough drift
#

and just when ppl buy give them a plugin with the key

#

that decodes stuff

#

lemme just

rough drift
#

optic won't kill me

#

right

#

right??

ivory sleet
#

No clue lol

#

Think he’s pretty soft with pings tho

rough drift
#

well alex pings him 94/7

#

so its fine

ivory sleet
#

🥲

vagrant stratus
rough drift
#

lmao

vagrant stratus
#

actually wait no, I just ignore him

rough drift
#

look at what i replied to in this message

vagrant stratus
tall dragon
#

premium

rough drift
vagrant stratus
#

ah shit

#

right

#

google fucking sucks

#
DRM systems are (provisionally allowed), with the following key caveats:

    All resources must run directly from downloaded file without any manual installation steps or access to a specific server. This means that licensing systems of any form are prohibited. This also means that all applicable code must fail-safe in the event of (web) server error.
    They must not interfere with any aspect of the server outside of the plugin itself.
    We will treat all complaints of DRM abuse with the highest severity, which may result in immediate and permanent suspension of your resource unless sufficient evidence is provided.
    We may request it be removed or altered at any time.
rough drift
#

no its not drm iirc

vagrant stratus
#

literally part of the requirements you should be reading @tall dragon

rough drift
#

its just no updates if you don't buy

rough drift
#

i saw a plugin

#

that had a rental

#

thing

tall dragon
#

well im not making a premium plugin

rough drift
#

and they pointed out its not allowed

tall dragon
#

we were just discussing it

rough drift
#

^

vagrant stratus
#

Either way, when it comes to license systems and premium, you're limited due to the above rule.

smoky oak
#

what is DRM short for?

vagrant stratus
#

Digital Rights Management

smoky oak
#

im reading md's post rn

#

what exactly does 'gambling' mean? Explicit gambling only?

vagrant stratus
#

e.g. a resource based around gambling wouldn't be allowed

smoky oak
#

ah

rough drift
#

so no casino plugin

smoky oak
#

so a mechanic that involves random chance does not count

rough drift
#

sadge

rough drift
smoky oak
#

well it aint that

vagrant stratus
smoky oak
#

ah wel

#

i meant more like that there's a chance somethign just wont work/activate even if done right

dull whale
#

same error

earnest forum
#

if i wanted to make data for different types of blocks for a custom mining system, like each kind of block has different code that runs or different tool thats required, should i use an abstract class and then make a new class for each block which extends the abstract class?

#

or should i just hard code all the different block events into a single class

midnight shore
#

Hi! what lib should i use for inventories in 1.17?

earnest forum
#

?

#

why does it say doesn't exist?

#

is it in a previous version?

drowsy helm
#

what version are you running it in

earnest forum
#

1.18.1

smoky oak
#

is there a event for a beacon activating/deactivating?

tardy delta
#

what commands should i make?

lost matrix
lost matrix
#

The fk is this?

trail bluff
#

what?

lost matrix
#

This is not java nor kotlin. Looks like some sort of scripting language

#

Wait. Its Skript isnt it?

trail bluff
#

Yes, it's a script with the skript-reflect add-on that allows you to use java code

trail bluff
#

:D

lost matrix
#

How about you just write your plugin in java?

trail bluff
lost matrix
#

Then you get auto completion and javadocs and everything else that would explain you how to get those.

ivory sleet
#

Vlad fyi this channel is by no means for Skript assistance, consider joining their discord if you need assistance concerning Skript, thanks!

trail bluff
#

Ok, thanks:)

smoky oak
lost matrix
#

You can do a thousand of those in a tick and dont see it in your timings

smoky oak
#

ok

#

and then further checks from there

#

imma presume that not too many of those blocks are beacons lol

lost matrix
#

Yeah from then on you can get more expensive with every safeguard statement

smoky oak
#

safeguard?

lost matrix
#
        if (some_condition) {
            return;
        }
smoky oak
#

doesnt that result in the same runtime as

if(!condition){
  code;
}
lost matrix
smoky oak
#

also is !(Object == Object) faster, slower, or just as fast as (Object != Object)

#

?

lost matrix
#

Doesnt make a difference. And even if it would we would talk about nanoseconds.

eternal oxide
#

it should be identical once byte code

smoky oak
#

ok

lost matrix
# smoky oak doesnt that result in the same runtime as ```java if(!condition){ code; } ```
  @EventHandler
  public void onMove(PlayerMoveEvent event) {
    if (event.getPlayer().hasPermission("some.permission")) {
      if (event.getFrom().getBlockX() == event.getTo().getBlockX()) {
        if (event.getFrom().getBlockY() == event.getTo().getBlockY()) {
          if (event.getFrom().getBlockZ() == event.getTo().getBlockZ()) {
            event.getPlayer().sendMessage("You are looking around and not moving.");
          }
        }
      }
    }
  }
  @EventHandler
  public void onMove(PlayerMoveEvent event) {
    if (!event.getPlayer().hasPermission("some.permission")) {
      return;
    }
    if (event.getFrom().getBlockX() != event.getTo().getBlockX()) {
      return;
    }
    if (event.getFrom().getBlockY() != event.getTo().getBlockY()) {
      return;
    }
    if (event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
      return;
    }
    event.getPlayer().sendMessage("You are looking around and not moving.");
  }
smoky oak
#

fair point

#

might be worth using

minor garnet
#

@lost matrix java onEnable(); final String[] sword = { "DIAMOND_SWORD", "IRON_SWORD", "GOLD_SWORD", "STONE_SWORD", "WOOD_SWORD", "DIAMOND_PICKAXE", "IRON_PICKAXE", "GOLD_PICKAXE", "STONE_PICKAXE", "WOOD_PICKAXE", "DIAMOND_AXE", "IRON_AXE", "GOLD_AXE", "STONE_AXE", "WOOD_AXE", "DIAMOND_SPADE", "IRON_SPADE", "GOLD_SPADE", "STONE_SPADE", "WOOD_SPADE", "DIAMOND_HOE", "IRON_HOE", "GOLD_HOE", "STONE_HOE", "WOOD_HOE", "BOW", "FISHING_ROD", "BLAZE_ROD", "STICK", "BONE", "GOLD_INGOT", "RECORD_3", "WATCH", "SHEARS", "GREEN_RECORD", "COAL" }; Arrays.asList(sword).stream().forEach(e -> LootManagement.items.add(e));

static List<Material> items = new ArrayList<>();

i was reading in your performance forum on some code, and i'm in doubt on the best way for me to check if a material is inside a list, i'm talking to avoid that every time the object is instantiated and create a new list, i I already created it inside onEnable(), I don't know if for me and using Strings and comparing with a material would be the best way

smoky oak
#

iirc you cant just do list.contains(Object) tho, and O(n) of that should be either 1 or list.length

#

it's O(n)

lost matrix
minor garnet
#

allr

hybrid spoke
#

rather use a set like the resource says

smoky oak
#

you're basically doing what java already has just in complex

lost matrix
smoky oak
#

ouch

#

all Set<T> contains operations are O(1)

minor garnet
smoky oak
#

yea do a set

lost matrix
smoky oak
#

oh true

lost matrix
errant narwhal
#

hi

#

can someone help please

smoky oak
#

a tree set kinda defeats the purpose of a set lol

#

?notworking

undone axleBOT
#

"Does not working" is a useless statement. Please describe what exactly is not working, what you expect it to do, and what actually happens. If you get any console errors, also ?paste the entire stacktrace.

errant narwhal
#

i have an code with save location by arraylist but when reload all arraylist reset

#

then i want to add arraylist to config to keep the file

minor garnet
lost matrix
minor garnet
#

but comparing a material using string

smoky oak
#

why not use new EnumSet.of()

lost matrix
smoky oak
#

@minor garnet

errant narwhal
eternal night
#

Dunno if you want to rely on enum sets for materials for too much longer

smoky oak
#

ha?

#

they just changed implementation from id to enums

minor garnet
eternal night
#

There is an open PR to move those to proper registries

#

Also "just" moved is a vibe

#

Lool

lost matrix
#

Im suspecting that spigot will just deprecate Material for 3 years before dropping it.

smoky oak
#

now that i think about it

eternal night
#

Nah

smoky oak
#

tf are legacy material enums about

eternal night
#

1.12 plugins

#

And no, the material class is just rewritten afaik

#

With as little backwards breaking changed as possible

lost matrix
#

I didnt say anything about implementing that yourself

errant narwhal
lost matrix
smoky oak
#

this a xy problem without even saying whats wanted

hybrid spoke
#

do that, bro.

smoky oak
#

bruh

quaint mantle
#

?xy

undone axleBOT
quaint mantle
#

?learnjava

undone axleBOT
visual tide
lavish hemlock
#

sender as Player

visual tide
#

or do sender is Player

#

if thats true it casts sender automatically

lavish hemlock
#

Oh yeah that's true

#

Smart-casting

visual tide
#

but thats not really applicable in this context

#

its if youre not sure if its actually and want to get null instead of a cce

lavish hemlock
#

I mean theoretically you can do

#

(sender as? Player) ?: error("Not a player :<")

#

But

#

don't

viral crag
#

you only do something if(stack.getAmount() <= 1) less than or equal to 1? what happens if its more than one?

#

ah yeah, i was lining up brackets one level off

kindred valley
#

?learnjava

undone axleBOT
kindred valley
#

i didnt text it for you

viral crag
#

where is the code you have for placing currently?

#

well you need to count your items, and then decide how to split them with the chest being in the center

#

beyond that it is just alignment based on the number of items and the location of the chest

#

so if you have 4 itemstacks, you might choose to have two on left, one in the center and one on the right - for a single chest

#

or you could make your life a bit simpler and just use the chest location as your left margin

#

hmm most of the reasoning would, not sure you can use get and set together like that - ive not tried

#

you also need to interrate through the inventory as you print/place

#

actually, second i do usie it similar to that in a section of code

#
...
OWPPortalDestruction().owpPortalDestruction( lstBlockList.get(0).getBlock(), event );
...
centerBlock.setType(Material.GLOWSTONE);
hasty prawn
#

Use ` not '

viral crag
#

yeah i wlays forget which is which :0

#

anyway, roughly your code will do something like what you want. Specifically I am unsure what happens when you set the airblock to an item

#

you might need to use a custom block or head to represent the item if you don't want it to appear dropped

hasty prawn
#

There's probably a much easier way to do this, nested for loops, or calculating the x/y coordinates yourself using modulo

ancient plank
#

google is useful tbf

hasty prawn
#

EntityDamageEvent maybe?

ancient plank
#

pain

#

time to run around in panic

hasty prawn
#

mfw that post says to use EntityCombustEvent

ancient plank
#

you're*

#

and I'm glad you think that way, feel free to leave a review on yelp and I'll get to you as quick as possible

hasty prawn
#

LMAO

#

No I know

#

I was defending you 😛

#

Yeah that is weird, I would've thought EntityDamageEvent would've been fired atleast.

#

I mean idk how you solved it, or even if you did solve it, but nested for loops/calculating are good options.

ancient plank
#

pain

hasty prawn
#

It won't print the display name if that's what you're asking

kindred valley
#
public class KitEditor implements Listener{
    private ItemStack kitEditor = new ItemStack(Material.BOOK);
    public KitEditor() {
        ItemMeta meta = kitEditor.getItemMeta();
        meta.setDisplayName(ChatColor.GRAY + "Kit Editor");
        ArrayList<String> lore = new ArrayList<>();
        meta.setLore(lore);
        kitEditor.setItemMeta(meta);
    }
    public ItemStack getKitEditor() {
        return kitEditor;
    }
    public void setKitEditor(ItemStack kitEditor) {
        this.kitEditor = kitEditor;
    }
    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
        Player p = e.getPlayer();
        p.getInventory().addItem(kitEditor);
    }
}```iis there any wrong thing on this code
hasty prawn
#

for(int i = 0; i < inventorySize; i++) {
  int x = i % 9;
  int y = i / 9;  

  //use dem bitches
}
#

Honestly I don't know, probably not? Never used getName on an Item Entity before.

hasty prawn
kindred valley
hasty prawn
#

How are you trying to get it

#

Probably using a different instance

ancient plank
#

U gotta check if the entity is an instance of item then cast to get the item type iirc

kindred valley
#

no

hasty prawn
ancient plank
#

Weh weh

#

You're not explaining your issue well

ancient plank
#

Then get pissy at me for responding

hasty prawn
hasty prawn
kindred valley
#
public class KitEditor implements Listener{
    private ItemStack kitEditor = new ItemStack(Material.BOOK);
    public KitEditor() {
        ItemMeta meta = kitEditor.getItemMeta();
        meta.setDisplayName(ChatColor.GRAY + "Kit Editor");
        ArrayList<String> lore = new ArrayList<>();
        meta.setLore(lore);
        kitEditor.setItemMeta(meta);
    }
    public ItemStack getKitEditor() {
        return kitEditor;
    }
    public void setKitEditor(ItemStack kitEditor) {
        this.kitEditor = kitEditor;
    }
    @EventHandler
    public void onJoin(PlayerJoinEvent e) {
        Player p = e.getPlayer();
        p.getInventory().addItem(kitEditor);
    }
}```
ancient plank
#

You asked if get entity then the name would return item type and I responded with the method to get the item type

lavish hemlock
#

I am incredibly conflicted on Spigot versions atm

hasty prawn
ancient plank
lavish hemlock
#

Like, a lot of people still use 1.8, so if I want to get any clients I'd have to dev for it since I probably couldn't persuade them to use ProtocolSupport/ViaVersion.

#

At the same time, I want to develop for the latest version only

hasty prawn
#

But anyways, @kindred valley did you register the listener?

errant narwhal
#

Hi

errant narwhal
#

How to make wait in x second in interact event ?

lavish hemlock
#

Yeah but not everyone updates their Minecraft so it's still kinda necessary if the server wants players

#

It's like
The best solution isn't the best solution since the best solution requires alienating a large portion of your playerbase/clientbase

hasty prawn
#

It's starting from the top left

#

So place your blocks starting from the top left

#

Or figure out how to flip it

iron palm
#

Hey guys.
what is the best way to replace blocks between two locations with less lag and fastest speed as possible.

errant narwhal
#

How to use interact event in scheduler?

hasty prawn
#

?scheduling

undone axleBOT
hasty prawn
#

read that

#

Why are you using -y for non double chests y for double chests

ancient plank
#

double chests are pain

hasty prawn
#

You need to add the chest offsets also

kindred valley
#

which event i need to use for clicking an item

sick herald
#

random question but is it better performance wise to not use the bukkit scheduler for async tasks?

iron palm
kindred valley
#

player is right clicking

iron palm
#

PlayerInteractEvent

hasty prawn
#

Oh I see the problem now

iron palm
hasty prawn
#

I wasn't visualizing it right lol

iron palm
#

Using for was the fastest speed but uh

#

server crashed

#

because of high amount of blocks

#

then i used BukkitRunnable but it was too slowly

hasty prawn
#
//Num rows - current row - 1 (to keep 0-2 instead of 1-3)
int y = (inventorySize / 9) - (i / 9) - 1;

Maybe?

hasty prawn
sick herald
#

and I'm doing lots of them

hasty prawn
#

Then why are you doing it async

sick herald
hasty prawn
#

^ FAWE Prayge

iron palm
ancient plank
#

seems you gotta use EntityDamageByBlockEvent

hasty prawn
#

Seems like it'd be a good idea then huh

sick herald
sick herald
ancient plank
#

aye

iron palm
#

it was the fastest way

ancient plank
#

liquids are blocks

iron palm
#

but it isnt enough sadl

#

y

#

250 blocks for each seconds

hasty prawn
#

It should definitely be able to place 250 blocks/second.

iron palm
#

it is

hasty prawn
#

You might have an underlying issue that you're not seeing

#

Oh

iron palm
#

and it does

#

but

#

it is slow still!!!!

sick herald
#

wdym

iron palm
#

i mean

sick herald
#

it does it all very quickly, I do about a million blocks in less than a sec with it

iron palm
#

i just tried it with 1000 blocks and

#

server crashed

sick herald
#

are u using world edit

ancient plank
#

a lil testing never hurt anyone

sick herald
#

or fawe

#

for the plugin

iron palm
#

none of them lol

sick herald
#

u need the fawe plugin for the api to work lol

#

can u send a ss of your code?

iron palm
#

Im using an api kinda

#

its a single class for regions

iron palm
#

wait a sec

sick herald
#

alright, I got to go for abt 30m as I'm in class but if you still need help I'll be happy to help when I'm back

sick herald
#

I'll send one of my code snippets when I'm back

viral crag
#

mmm try not to use fawe if you can help it, use the normal worldedit api

iron palm
#

this is my old code which when i tested that the server crashed ...

young dome
#

Can we detect if an inventory is not a default inventory in spigot with packets or else ? (an inventory created on the client side)

sick herald
#

that the wrong way to use the api lol

iron palm
viral crag
iron palm
#

but uh if you meaned my own api nah thats fine i think

hollow bluff
iron palm
young dome
viral crag
iron palm
#

using FAWE probably also needs world edit as a required plugin right?

viral crag
#

no

iron palm
#

oh

#

what about FAWE itself?

viral crag
#

if fawe messes up or you mess up, you will be rolling back your server world

young dome
viral crag
#

you will get a server event when someone tries to use bad the inventory as far as i know

hasty prawn
#

Youd have to find their current direction, and apply the x y with that

viral crag
#

many times you will also get an event for moving inventory too fast

young dome
ancient plank
#

me when I first discovered that inventory is client side like 10 months ago YMg_Dead

kindred valley
#

How can I prevent a player from taking an item after clicking on any item in a newly made inventory?

#

🙂

viral crag
# young dome The problem on my side is that when we make a creative give with forge, for bukk...
List<HumanEntity> getViewers()
Gets a list of players viewing the inventory. Note that a player is considered to be viewing their own inventory and internal crafting screen even when said inventory is not open. They will normally be considered to be viewing their inventory even when they have a different inventory screen open, but it's possible for customized inventory screens to exclude the viewer's inventory, so this should never be assumed to be non-empty.
kindred valley
#

okay

young dome
viral crag
#

if the player is online, their personal inventory is always open per the above getViewers description

young dome
#

Except for that, well in theory

viral crag
#

My guess is that you would need a clientmod to actually know - which is also the hotbar "solution"

#

the only exception would be personal inventories that are replaced with a custom inventory like a backpack etc - and in that case you would create an open/closed state

lavish hemlock
young dome
viral crag
young dome
#

Maybe my translations are not quite perfect, excuse me

kindred valley
#

how can i change the example text on the new inventory

maiden thicket
#

wdym example text

#

the title?

sick herald
maiden thicket
#

its set when you create ur inventory

kindred valley
viral crag
#

the setlore text? - hmm you said title

lavish hemlock
maiden thicket
#

then u set it

#

its a parameter

kindred valley
#

how can i prevent the custom item from falling to the ground

maiden thicket
#

inventoryclickevent

kindred valley
#

couldnt find any method on dropevent

kindred valley
maiden thicket
#

setCancelled

kindred valley
#

how can i control if the item is custom item

maiden thicket
kindred valley
#

i know

maiden thicket
#

check the item meta

viral crag
#

...

#

why ask then?

maiden thicket
#

u can do ItemStack#isSimilar

grim ice
maiden thicket
#

wym no

grim ice
#

isSimilar is basically

#

if(item1.equals(item2)) but

#

it does not consider the stack size

kindred valley
#

yes this is different

maiden thicket
#

it checks item meta, durability, etc

grim ice
#

I know

maiden thicket
#

u dont need to consider stack size if ur checking if its a custom item

grim ice
#

dont use it

#

Use PDC

maiden thicket
#

u can just compare the types and the item meta

grim ice
#

or localized names

#

dont

#

or as u like tbf

#

using a pdc or a localized name much better though

kindred valley
#

idk what is pdc

lavish hemlock
#

PersistentDataContainer

kindred valley
#

I tried to read but I did not understand

grim ice
#

if u cant understand it

#

then u prob do not know java

#

its pretty basic

kindred valley
#

🙃

#

i mean i didnt get why im using this

#

dont we have any method on drop event

viral crag
#

public interface PersistentDataContainer - This interface represents a map like object, capable of storing custom tags in it.

lost matrix
kindred valley
lavish hemlock
viral crag
#

1.7 makes for a great security breech

kindred valley
lost matrix
lost matrix
visual tide
#

if youre gonna support 1.8 do what you want but 1.7 is just unreasonable

visual tide
#

context?

viral crag
#

hiding

#

mmm dont you need to override the burning animation ?

delicate lynx
#

the client doesn't know it's still there

kind coral
#

im using 1.12 api but i don't see any better way than using getData() and setData() do you guys know any?

lost matrix
#

Ok i see BlockState but no BlockData...

#

Ah.
BlockState -> MaterialData

lost matrix
golden turret
#

if i kill a player using a bow, will the getKiller return me?

kind coral
#

getKiller() returns player i think

#

but its nullable

golden turret
#

ok

#

is the getKiller ready with the killer in the PlayerDeathEvent?

lost matrix
kind coral
#

i have a luckyblocks plugin but i ran into an issue, i kinda need to have like 3 elements in my map, so like Having

ACustomMap<Key,AnotherKey,Value>

#

is there any implementation ready in java?

#

since i need to check both for the data and the material

ivory sleet
#

Table

#

from guava

lost matrix
kind coral
#

yes i've tried, i think table from guava is the best option

ivory sleet
#

HashBasedTable::create

#

but its slow

kind coral
ivory sleet
#

because like, it has a lot of maps for security and backups

kind coral
ivory sleet
#

Map::computeIfAbsent 😌

lavish hemlock
lost matrix
kind coral
#

yes

#

I have my Map<ObjectWrapper,LuckyBlock>

ivory sleet
kind coral
lost matrix
kind coral
#

i've tried several times, didn't work

#

its about a year that i've been working on this plugin, i'm trying to fix a bug, its a commission for a server

#

well actually i've been maintaining it

#

when something popped up, i don't actually code on it daily like i think you understand

lost matrix
#

getter for a map. That just calls for chaos and fragility in your code...

kind coral
#

where is the static getter?

lost matrix
#
  1. What is MaterialBlock
kind coral
#

my object that wraps my material and data

lost matrix
#

Show it please

kind coral
lost matrix
lavish hemlock
#

Just use @Data

kind coral
#

never used hashcode in my life

lavish hemlock
#

Implementing hashCode is necessary for maps imo

lost matrix
kind coral
#

yeah because else they will always differ right?

golden turret
#

i would like to know when the player.getKiller can be null

kind coral
#

or other stuff

lost matrix
young knoll
#

getKiller will be null if they weren't killed by a player

kind coral
#

so i tought maybe a need a table so i can use <Material, Short, LuckyBlock>

lost matrix
#

Alright so then it should be resolved now

kind coral
#

yes, i'll test now, this thing of hashcode is very cool, might read documentation later, i've seen it across while reading the java book but never used it and forgot about it

smoky oak
#

how tf do i publish stuff on spigot

#

there's no publish button

lost matrix
#

You mean a plugin?

smoky oak
#

ye

lost matrix
smoky oak
#

ah thanks

kind coral
smoky oak
#

what does 'no rating' mean

lost matrix
kind coral
#

yes

lavish hemlock
lost matrix
smoky oak
#

wait a sec i cant select that option

lavish hemlock
#

Wait what

#

Uhh screenshot?

smoky oak
#

that deletes the mouse

#

but here

lavish hemlock
#

Oh

smoky oak
#

im hovering over 'no rating'

lavish hemlock
#

Yeah nvm I don't know what that is

quaint mantle
#
Items treaty = Items.newItem("treaty",null, true);

        item = new ItemStack(Material.PAPER, 1);
        meta = item.getItemMeta();
        meta.setDisplayName(ChatColor.BLUE + "Treaty");
        meta.addEnchant(Enchantment.DURABILITY, 1, true);
        key = NamespaceKeyList.getKey("treaty");
        meta.getPersistentDataContainer().set(key, PersistentDataType.STRING, "true");
        lore = new ArrayList<>();
        lore.add(ChatColor.DARK_GRAY + "Requests to have a treaty with another person.");
        lore.add(ChatColor.DARK_GRAY + "If accepted, you cannot harm eachother.");
        meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
        meta.setLore(lore);
        item.setItemMeta(meta);

        treaty.setItem(item);
#

How would I make this more efficient?

kind coral
#

use List.of(String...) instead of actually using a new instance of the array list

lavish hemlock
lost matrix
# kind coral yes
  public int hashOf(Material material, short data) {
    return material.ordinal() & 0xFFFF | (data & 0xFFFF) << 16;
  }

This should be fast and reliable.

kind coral
quaint mantle
#

It takes up a TON of line space, and I feel as if it isnt efficient at all.

lavish hemlock
#

Eh, more lines != slower

#

It's more down to how complex the operations are

hasty prawn
#

That seems fine anyways

kind coral
lavish hemlock
#

I'm not replying to you lol

hasty prawn
#

Using ItemMeta generally just uses a lot of lines

lavish hemlock
#

Yeah

#

And actually

#

You could probably use Arrays.asList

#

It, unlike List.of, does not create an java.util.ArrayList

#

It actually creates a java.util.Arrays.ArrayList, which is a private implementation of List that directly uses the array.

lost matrix
#

Because this looks not really worth optimizing much

quaint mantle
#

And I hate ugly code a LOT

lavish hemlock
#

Then

#

git gud

#

m8

quaint mantle
#

ive redone thousands of lines of code just cause it doesnt look right to me

hasty prawn
#

You could change the order in which you do things to make it prettier probably

quaint mantle
#

i have OOD when it comes to coding lol

lavish hemlock
smoky oak
#

i remember someone recommending negative checks to me

lavish hemlock
#

I mean either way, OCD is the wrong terminology for perfectionism

viral crag
#

use a code style guide then

smoky oak
#

if(not condition) return multiple times

lavish hemlock
#

But OOD is not a thing

smoky oak
#

different topic

lavish hemlock
#

actually wait one sec

smoky oak
#

How should i use a github link as external download URL, should i link the file or the releases page?

lavish hemlock
#

You're very alien when it comes to coding, I guess.

quaint mantle
hybrid spoke
#

everyone says i have code OCD

lavish hemlock
#

OCD is a very broad mental disorder, and I don't mean to be all SJW about its usage within conversation

#

buuuut I'm a bit of a perfectionist

#

when it comes to how people use words and stuff

quaint mantle
#

ah

#

well then sorry i stated that wrong

hybrid spoke
#

deleting a space is a commit for me

quaint mantle
#

im a perfectionist ig lol

lavish hemlock
#

Indeed

#

And, same

#

I have violated the KISS principle way too much

quaint mantle
#

do you think BiConsumers might help lol

#

in some shape way or form

lavish hemlock
#

KISS, an acronym for keep it simple, stupid, is a design principle noted by the U.S. Navy in 1960. The KISS principle states that most systems work best if they are kept simple rather than made complicated; therefore, simplicity should be a key goal in design, and unnecessary complexity should be avoided. The phrase has been associated with airc...

quaint mantle
#

fair

viral crag
#

then program using SEI rules/style

quaint mantle
#

how do I upload code on a seperate site to show

#

whats the command that sends that link

#

or whatever

lavish hemlock
#

?paste

undone axleBOT
quaint mantle
#

kinda need it

hybrid spoke
#

?paste

undone axleBOT
quaint mantle
#

ty

#

this is WHY i want to change it

#

50 lines for 3 items

#

and it looks ugly

#

a

fallen agate
#

Is there a normal spigot repo for maven? not spigot-api

#

I need net.minecraft.server